diff --git a/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplate.cs b/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplate.cs deleted file mode 100644 index 0112c01..0000000 --- a/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplate.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using Crestron.SimplSharp; // For Basic SIMPL# Classes -using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -using PepperDash.Essentials; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Core; - -namespace EssentialsPluginTemplateEPI -{ - /// - /// This class contains the necessary properties and static methods required to function as an Essentials Plugin - /// - public class EssentialsPluginFactory - { - /// - /// This string is used to define the minimum version of the - /// Essentials Framework required for this plugin - /// - public static string MinimumEssentialsFrameworkVersion = "1.4.31"; - - /// - /// This method will get called by Essentials when this plugin is loaded. - /// Use it to add factory methods for all new Device types defined in this plugin - /// - public static void LoadPlugin() - { - PepperDash.Essentials.Core.DeviceFactory.AddFactoryForType("EssentialsPluginTemplate", EssentialsPluginFactory.BuildDevice); - - // Add additional factories for each type here - } - - /// - /// Builds an instance of the device type. There should be method like this defined for each device type your plugin needs - /// to be able to build - /// - /// The device configuration - /// The device - public static EssentialsPluginTemplateDevice BuildDevice(DeviceConfig dc) - { - var config = JsonConvert.DeserializeObject(dc.Properties.ToString()); - var newDevice = new EssentialsPluginTemplateDevice(dc.Key, dc.Name, config); - return newDevice; - } - - } -} - diff --git a/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplateFactory.cs b/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplateFactory.cs new file mode 100644 index 0000000..79cfcf9 --- /dev/null +++ b/PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplateFactory.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; // For Basic SIMPL# Classes +using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +using PepperDash.Essentials; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Core; + +namespace EssentialsPluginTemplateEPI +{ + /// + /// This class contains the necessary properties and methods required to function as an Essentials Plugin + /// + public class EssentialsPluginFactory:EssentialsPluginDeviceFactory + { + public EssentialsPluginFactory() + { + // This string is used to define the minimum version of the + // Essentials Framework required for this plugin + MinimumEssentialsFrameworkVersion = "1.6.1"; + + //The strings defined in this list will be used in the configuration file to build the device in this plugin. + TypeNames = new List {"essentialsPluginTemplateDevice"}; + } + + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var config = dc.Properties.ToObject(); + var newDevice = new EssentialsPluginTemplateDevice(dc.Key, dc.Name, config); + return newDevice; + } + + #endregion + } +} + diff --git a/PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateDevice.cs b/PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateDevice.cs index 9cfcd62..dda96b2 100644 --- a/PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateDevice.cs +++ b/PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateDevice.cs @@ -1,22 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Essentials; +using Crestron.SimplSharpPro.DeviceSupport; +using Newtonsoft.Json; +using PDT.EssentialsPluginTemplate.EPI; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Core.Bridges; using PepperDash.Core; -using PepperDash.Essentials.Bridges; namespace EssentialsPluginTemplateEPI { /// /// Example of a plugin device /// - public class EssentialsPluginTemplateDevice : Device, IBridge + public class EssentialsPluginTemplateDevice : EssentialsDevice, IBridgeAdvanced { /// /// Device Constructor. Called by BuildDevice @@ -46,9 +40,28 @@ namespace EssentialsPluginTemplateEPI /// /// /// - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey) + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { - this.LinkToApi(trilist, joinStart, joinMapKey); + // Construct the default join map + var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart); + + // Attempt to get a custom join map if specified in config + var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + + // If we find a custom join map, deserialize it + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + //Checking if the bridge is null allows for backwards compatability with configurations that use EiscApi instead of EiscApiAdvanced + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + // Set all your join actions here + + + // Link all your feedbacks to joins here } } } \ No newline at end of file