using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; namespace EssentialsPluginTemplate { /// /// Plugin device template for logic devices that don't communicate outside the program /// /// /// Rename the class to match the device plugin being developed. /// /// /// "EssentialsPluginTemplateLogicDevice" renamed to "SamsungMdcDevice" /// public class EssentialsPluginTemplateLogicDevice : EssentialsBridgeableDevice { /// /// It is often desirable to store the config /// private EssentialsPluginConfigObjectTemplate _config; /// /// Plugin device constructor /// /// /// /// public EssentialsPluginTemplateLogicDevice(string key, string name, EssentialsPluginConfigObjectTemplate config) : base(key, name) { Debug.Console(0, this, "Constructing new {0} instance", name); // TODO [ ] Update the constructor as needed for the plugin device being developed _config = config; } #region Overrides of EssentialsBridgeableDevice /// /// Links the plugin device to the EISC bridge /// /// /// /// /// public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { var joinMap = new EssentialsPluginBridgeJoinMapTemplate(joinStart); // This adds the join map to the collection on the bridge if (bridge != null) { bridge.AddJoinMap(Key, joinMap); } var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); if (customJoins != null) { joinMap.SetCustomJoinData(customJoins); } Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); // TODO [ ] Implement bridge links as needed // links to bridge trilist.SetString(joinMap.DeviceName.JoinNumber, Name); trilist.OnlineStatusChange += (o, a) => { if (!a.DeviceOnLine) return; trilist.SetString(joinMap.DeviceName.JoinNumber, Name); }; } #endregion } }