diff --git a/EssentialsBuilds b/EssentialsBuilds index 2f47697..e9f64d5 160000 --- a/EssentialsBuilds +++ b/EssentialsBuilds @@ -1 +1 @@ -Subproject commit 2f47697d3e6f2bba5311fbe5af20860e718d6cf4 +Subproject commit e9f64d5d7be181e88e593581a595b0c54e421baf diff --git a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.csproj b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.csproj index 2bd0780..9037cae 100644 --- a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.csproj +++ b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.csproj @@ -100,7 +100,6 @@ - diff --git a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.suo b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.suo index e671876..a0b689c 100644 Binary files a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.suo and b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.EPI.suo differ diff --git a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.projectinfo b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.projectinfo index 7bcafcb..24a2e0c 100644 Binary files a/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.projectinfo and b/PDT.PanasonicDisplay.EPI/PDT.PanasonicDisplay.projectinfo differ diff --git a/PDT.PanasonicDisplay.EPI/PanasonicDisplay.cs b/PDT.PanasonicDisplay.EPI/PanasonicDisplay.cs index f859f9a..0c3ce53 100644 --- a/PDT.PanasonicDisplay.EPI/PanasonicDisplay.cs +++ b/PDT.PanasonicDisplay.EPI/PanasonicDisplay.cs @@ -19,7 +19,7 @@ using PepperDash.Essentials.Core.Config; using System.Collections; -using PepperDash.Essentials.Bridges; +using PepperDash.Essentials.Core.Bridges; @@ -28,7 +28,8 @@ namespace PDT.PanasonicDisplay.EPI /// /// /// - public class PanasonicDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IBridge + [Description("Panasonic TH series Display")] + public class PanasonicDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor, IBridgeAdvanced { /// /// The communication device @@ -546,11 +547,120 @@ public void VolumeUp(bool pressRelease) /// /// /// - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey) + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { - this.LinkToApiExt(trilist, joinStart, joinMapKey); + DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(joinStart, typeof(DisplayControllerJoinMap)); + + var JoinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(JoinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(JoinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", Name); + + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name; + + + var commMonitor = this as ICommunicationMonitor; + if (commMonitor != null) + { + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + } + + InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]); + + // Two way feedbacks + var twoWayDisplay = this as PepperDash.Essentials.Core.TwoWayDisplayBase; + if (twoWayDisplay != null) + { + trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true); + + twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler(CurrentInputFeedback_OutputChange); + + + + } + + // Power Off + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => + { + PowerOff(); + }); + + PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); + + // PowerOn + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => + { + PowerOn(); + }); + + + PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + + int count = 1; + var displayBase = this as PepperDash.Essentials.Core.DisplayBase; + foreach (var input in InputPorts) + { + //displayDevice.InputKeys.Add(input.Key.ToString()); + //var tempKey = InputKeys.ElementAt(count - 1); + trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + count), () => { ExecuteSwitch(InputPorts[input.Key.ToString()].Selector); }); + Debug.Console(2, this, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset.JoinNumber + count, InputPorts[input.Key.ToString()].Key.ToString()); + trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + count)].StringValue = input.Key.ToString(); + count++; + } + + Debug.Console(2, this, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); + trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) => + { + if (a == 0) + { + PowerOff(); + } + else if (a > 0 && a < InputPorts.Count) + { + ExecuteSwitch(InputPorts.ElementAt(a - 1).Selector); + } + else if (a == 102) + { + PowerToggle(); + + } + Debug.Console(2, this, "InputChange {0}", a); + + + }); + + + var volumeDisplay = this as IBasicVolumeControls; + if (volumeDisplay != null) + { + trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, (b) => volumeDisplay.VolumeUp(b)); + trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, (b) => volumeDisplay.VolumeDown(b)); + trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, () => volumeDisplay.MuteToggle()); + + var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; + if (volumeDisplayWithFeedback != null) + { + volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]); + volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]); + } + } } + void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + + Debug.Console(0, this, "CurrentInputFeedback_OutputChange {0}", e.StringValue); + + } + #endregion } } \ No newline at end of file diff --git a/PDT.PanasonicDisplay.EPI/PanasonicDisplayBridge.cs b/PDT.PanasonicDisplay.EPI/PanasonicDisplayBridge.cs deleted file mode 100644 index 2fcdee4..0000000 --- a/PDT.PanasonicDisplay.EPI/PanasonicDisplayBridge.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Bridges; -using Newtonsoft.Json; - -namespace PDT.PanasonicDisplay.EPI -{ - public static class PanasonicDisplayBridge - { - - - public static void LinkToApiExt(this PanasonicDisplay displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) - { - - DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(); - - var JoinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); - - if (!string.IsNullOrEmpty(JoinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(JoinMapSerialized); - - joinMap.OffsetJoinNumbers(joinStart); - - Debug.Console(1, "Linking to Trilist '{0}'",trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Display: {0}", displayDevice.Name); - - trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name; - - - var commMonitor = displayDevice as ICommunicationMonitor; - if (commMonitor != null) - { - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - } - - displayDevice.InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]); - - // Two way feedbacks - var twoWayDisplay = displayDevice as PepperDash.Essentials.Core.TwoWayDisplayBase; - if (twoWayDisplay != null) - { - trilist.SetBool(joinMap.IsTwoWayDisplay, true); - - twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler(CurrentInputFeedback_OutputChange); - - - - } - - // Power Off - trilist.SetSigTrueAction(joinMap.PowerOff, () => - { - displayDevice.PowerOff(); - }); - - displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler(PowerIsOnFeedback_OutputChange); - displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); - - // PowerOn - trilist.SetSigTrueAction(joinMap.PowerOn, () => - { - displayDevice.PowerOn(); - }); - - - displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); - - int count = 1; - var displayBase = displayDevice as PepperDash.Essentials.Core.DisplayBase; - foreach (var input in displayDevice.InputPorts) - { - //displayDevice.InputKeys.Add(input.Key.ToString()); - //var tempKey = InputKeys.ElementAt(count - 1); - trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[input.Key.ToString()].Selector); }); - Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[input.Key.ToString()].Key.ToString()); - trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString(); - count++; - } - - Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect); - trilist.SetUShortSigAction(joinMap.InputSelect, (a) => - - { - if (a == 0) - { - displayDevice.PowerOff(); - } - else if (a > 0 && a < displayDevice.InputPorts.Count ) - { - displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector); - } - else if (a == 102) - { - displayDevice.PowerToggle(); - - } - Debug.Console(2, displayDevice, "InputChange {0}", a); - - - }); - - - var volumeDisplay = displayDevice as IBasicVolumeControls; - if (volumeDisplay != null) - { - trilist.SetBoolSigAction(joinMap.VolumeUp, (b) => volumeDisplay.VolumeUp(b)); - trilist.SetBoolSigAction(joinMap.VolumeDown, (b) => volumeDisplay.VolumeDown(b)); - trilist.SetSigTrueAction(joinMap.VolumeMute, () => volumeDisplay.MuteToggle()); - - var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback; - if(volumeDisplayWithFeedback != null) - { - volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevelFB]); - volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]); - } - } - } - - static void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - - Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", e.StringValue); - - } - - static void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) - { - - // Debug.Console(0, "PowerIsOnFeedback_OutputChange {0}", e.BoolValue); - if (!e.BoolValue) - { - - - } - else - { - - } - } - - - - - } - public class DisplayControllerJoinMap : JoinMapBase - { - // Digital - public uint PowerOff { get; set; } - public uint PowerOn { get; set; } - public uint IsTwoWayDisplay { get; set; } - public uint VolumeUp { get; set; } - public uint VolumeDown { get; set; } - public uint VolumeMute { get; set; } - public uint InputSelectOffset { get; set; } - public uint ButtonVisibilityOffset { get; set; } - public uint IsOnline { get; set; } - - // Analog - public uint InputSelect { get; set; } - public uint VolumeLevelFB { get; set; } - - // Serial - public uint Name { get; set; } - public uint InputNamesOffset { get; set; } - - - public DisplayControllerJoinMap() - { - // Digital - IsOnline = 50; - PowerOff = 1; - PowerOn = 2; - IsTwoWayDisplay = 3; - VolumeUp = 5; - VolumeDown = 6; - VolumeMute = 7; - - ButtonVisibilityOffset = 40; - InputSelectOffset = 10; - - // Analog - InputSelect = 11; - VolumeLevelFB = 5; - - // Serial - Name = 1; - InputNamesOffset = 10; - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - IsOnline = IsOnline + joinOffset; - PowerOff = PowerOff + joinOffset; - PowerOn = PowerOn + joinOffset; - IsTwoWayDisplay = IsTwoWayDisplay + joinOffset; - ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset; - Name = Name + joinOffset; - InputNamesOffset = InputNamesOffset + joinOffset; - InputSelectOffset = InputSelectOffset + joinOffset; - - InputSelect = InputSelect + joinOffset; - - VolumeUp = VolumeUp + joinOffset; - VolumeDown = VolumeDown + joinOffset; - VolumeMute = VolumeMute + joinOffset; - VolumeLevelFB = VolumeLevelFB + joinOffset; - } - } -} diff --git a/PDT.PanasonicDisplay.EPI/PluginFactory.cs b/PDT.PanasonicDisplay.EPI/PluginFactory.cs index bb7ebd3..9edb91f 100644 --- a/PDT.PanasonicDisplay.EPI/PluginFactory.cs +++ b/PDT.PanasonicDisplay.EPI/PluginFactory.cs @@ -10,31 +10,29 @@ using Newtonsoft.Json; - - namespace PDT.PanasonicDisplay.EPI { - public class PluginFactory + /// + /// This class is responsible for defining the minimum requirements of the plugin and define the necessary requirement for Essentails to load this plugin. + /// + public class PanasonicDisplayFactory : EssentialsPluginDeviceFactory { /// /// Load the types to the factory /// - public static void LoadPlugin() + public PanasonicDisplayFactory() { - PepperDash.Essentials.Core.DeviceFactory.AddFactoryForType("panasonicdisplay", PluginFactory.BuildDevice); - } + MinimumEssentialsFrameworkVersion = "1.5.0"; - /// - /// Must use this version of Essentials as minimum - /// - public static string MinimumEssentialsFrameworkVersion = "1.4.32"; + TypeNames = new List() {"panasonicDisplay", "panasonicThDisplay"}; + } /// /// Builds an instance of the device and returns it /// /// Device Configuration /// Instance of Device - public static PanasonicDisplay BuildDevice(DeviceConfig dc) + public override EssentialsDevice BuildDevice(DeviceConfig dc) { var comm = CommFactory.CreateCommForDevice(dc); diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.DM.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.DM.dll index 8a9174a..ee5fc38 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.DM.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.DM.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.EthernetCommunications.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.EthernetCommunications.dll index 107864e..dbdd889 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.EthernetCommunications.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.EthernetCommunications.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Fusion.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Fusion.dll index f81b415..b9f88ff 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Fusion.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Fusion.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Gateways.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Gateways.dll index 106aad2..92ca34d 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Gateways.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Gateways.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.GeneralIO.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.GeneralIO.dll index d8587c9..04aa0b4 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.GeneralIO.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.GeneralIO.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Lighting.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Lighting.dll index 98252ba..f4e8c4f 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Lighting.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Lighting.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Shades.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Shades.dll index ae4aec6..7cd61a4 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Shades.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.Shades.dll differ diff --git a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.UI.dll b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.UI.dll index 21a5bdb..0178897 100644 Binary files a/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.UI.dll and b/PDT.PanasonicDisplay.EPI/bin/Debug/Crestron.SimplSharpPro.UI.dll differ