From 34f3e543f2160eac8ee41cff9e6204bc30be771d Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Fri, 11 Jan 2019 20:22:23 -0500 Subject: [PATCH] Adds Display Controller base with some basic functioanlity. --- PepperDashEssentials/Bridges/BridgeBase.cs | 5 + PepperDashEssentials/Bridges/BridgeFactory.cs | 246 ++++++++---------- .../Bridges/DisplayControllerBridge.cs | 23 +- essentials-framework | 2 +- 4 files changed, 127 insertions(+), 149 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 8205bafa..82a4cb6a 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -87,6 +87,11 @@ namespace PepperDash.Essentials.Bridges (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } + else if (device is PepperDash.Essentials.Core.TwoWayDisplayBase) + { + (device as TwoWayDisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } else if (device is DmChassisController) { (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); diff --git a/PepperDashEssentials/Bridges/BridgeFactory.cs b/PepperDashEssentials/Bridges/BridgeFactory.cs index 8079aa80..8b9ba75c 100644 --- a/PepperDashEssentials/Bridges/BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/BridgeFactory.cs @@ -14,168 +14,128 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.EthernetCommunication; namespace PepperDash.Essentials + { - public class BridgeFactory - { - public static IKeyed GetDevice(DeviceConfig dc) - { - // ? why is this static JTA 2018-06-13? +public class BridgeFactory +{ + public static IKeyed GetDevice(DeviceConfig dc) + { + // ? why is this static JTA 2018-06-13? - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - var propAnon = new { }; + var key = dc.Key; + var name = dc.Name; + var type = dc.Type; + var properties = dc.Properties; + var propAnon = new { }; - var typeName = dc.Type.ToLower(); - var groupName = dc.Group.ToLower(); + var typeName = dc.Type.ToLower(); + var groupName = dc.Group.ToLower(); - //Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); + //Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); - if (typeName == "eiscapi") - { - return new EiscApi(dc); + if (typeName == "eiscapi") + { + return new EiscApi(dc); + } + + return null; + } +} + + +public class CommBridge : Device +{ + public CommBridgeProperties Properties { get; private set; } + + public List CommDevices { get; private set; } + + public CommBridge(string key, string name, JToken properties) + : base(key, name) + { + Properties = JsonConvert.DeserializeObject(properties.ToString()); + } + + public override bool CustomActivate() + { + // Create EiscApis + if (Properties.Eiscs != null) + { + foreach (var eisc in Properties.Eiscs) + { + var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname); } - - return null; } - } - public class DmBridge : Device - { - public EiscBridgeProperties Properties { get; private set; } + foreach (var deviceKey in Properties.CommDevices) + { + var device = DeviceManager.GetDeviceForKey(deviceKey); - public PepperDash.Essentials.DM.DmChassisController DmSwitch { get; private set; } - - public DmBridge(string key, string name, JToken properties) : base(key, name) - { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - } - - public override bool CustomActivate() - { - // Create EiscApis - if (Properties.Eiscs != null) - { - foreach (var eisc in Properties.Eiscs) - { - var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname); - - ApiEisc.Eisc.SetUShortSigAction(101, u => DmSwitch.ExecuteSwitch(u,1, eRoutingSignalType.Video)); - ApiEisc.Eisc.SetUShortSigAction(102, u => DmSwitch.ExecuteSwitch(u,2, eRoutingSignalType.Video)); - } + if (device != null) + { + Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key); + CommDevices.Add(device as IBasicCommunication); } - - foreach (var device in DeviceManager.AllDevices) - { - if (device.Key == this.Properties.ParentDeviceKey) - { - Debug.Console(0, "deviceKey {0} Matches", device.Key); - DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController; - } - else - { - Debug.Console(0, "deviceKey {0} doesn't match", device.Key); - } + else + { + Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey); } - - Debug.Console(0, "Bridge {0} Activated", this.Name); - return true; } + + // Iterate through all the CommDevices and link up their Actions and Feedbacks + + Debug.Console(0, "Bridge {0} Activated", this.Name); + + return true; } - - public class CommBridge : Device - { - public CommBridgeProperties Properties { get; private set; } - - public List CommDevices { get; private set; } - - public CommBridge(string key, string name, JToken properties) - : base(key, name) - { - Properties = JsonConvert.DeserializeObject(properties.ToString()); - } - - public override bool CustomActivate() - { - // Create EiscApis - if (Properties.Eiscs != null) - { - foreach (var eisc in Properties.Eiscs) - { - var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname); - } - } - - foreach (var deviceKey in Properties.CommDevices) - { - var device = DeviceManager.GetDeviceForKey(deviceKey); - - if (device != null) - { - Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key); - CommDevices.Add(device as IBasicCommunication); - } - else - { - Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey); - } - } - - // Iterate through all the CommDevices and link up their Actions and Feedbacks - - Debug.Console(0, "Bridge {0} Activated", this.Name); - - return true; - } - } +} - public class EiscBridgeProperties - { - public string ParentDeviceKey { get; set; } - public eApiType ApiType { get; set; } - public List Eiscs { get; set; } - public string ApiOverrideFilePath { get; set; } +public class EiscBridgeProperties +{ + public string ParentDeviceKey { get; set; } + public eApiType ApiType { get; set; } + public List Eiscs { get; set; } + public string ApiOverrideFilePath { get; set; } - public class EiscProperties - { - public string IpId { get; set; } - public string Hostname { get; set; } - } + public class EiscProperties + { + public string IpId { get; set; } + public string Hostname { get; set; } } +} - public class CommBridgeProperties : EiscBridgeProperties - { - public List CommDevices { get; set; } - } +public class CommBridgeProperties : EiscBridgeProperties +{ + public List CommDevices { get; set; } +} - public enum eApiType { Eisc = 0 } +public enum eApiType { Eisc = 0 } - public class BridgeApiEisc - { - public uint Ipid { get; private set; } - public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } +public class BridgeApiEisc +{ + public uint Ipid { get; private set; } + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } - public BridgeApiEisc(string ipid, string hostname) - { - Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); - Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem); - Eisc.Register(); - Eisc.SigChange += Eisc_SigChange; - Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); - } - void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) - { - if (Debug.Level >= 1) - Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); - } + public BridgeApiEisc(string ipid, string hostname) + { + Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); + Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem); + Eisc.Register(); + Eisc.SigChange += Eisc_SigChange; + Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid); } -} \ No newline at end of file + void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) + { + if (Debug.Level >= 1) + Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } +} +} + \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs b/PepperDashEssentials/Bridges/DisplayControllerBridge.cs index 9dd018fb..d154c624 100644 --- a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DisplayControllerBridge.cs @@ -10,7 +10,7 @@ using PepperDash.Essentials.Devices.Common; namespace PepperDash.Essentials.Bridges { - public static class SamsungDisplayControllerApiExtensions + public static class DisplayControllerApiExtensions { public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey) { @@ -20,10 +20,10 @@ namespace PepperDash.Essentials.Bridges { joinMap = new DisplayControllerJoinMap(); } - + joinMap.OffsetJoinNumbers(joinStart); Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to lighting Type {0}", displayDevice.GetType().Name.ToString()); + Debug.Console(0, "Linking to Bridge Type {0}", displayDevice.GetType().Name.ToString()); var commMonitor = displayDevice as ICommunicationMonitor; commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); @@ -36,7 +36,19 @@ namespace PepperDash.Essentials.Bridges // Poewer On trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn()); displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); - + + + 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); + } + }); // GenericLighitng Actions & FeedBack // int sceneIndex = 1; @@ -83,6 +95,7 @@ namespace PepperDash.Essentials.Bridges { public uint IsOnline { get; set; } public uint PowerOff { get; set; } + public uint InputSelect { get; set; } public uint PowerOn { get; set; } public uint SelectScene { get; set; } public uint LightingSceneOffset { get; set; } @@ -95,7 +108,7 @@ namespace PepperDash.Essentials.Bridges IsOnline = 1; PowerOff = 1; PowerOn = 2; - SelectScene = 1; + InputSelect = 1; IntegrationIdSet = 1; LightingSceneOffset = 10; ButtonVisibilityOffset = 40; diff --git a/essentials-framework b/essentials-framework index 78182ecd..2cfdc4f2 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit 78182ecd8650f59e9f02494233c23ea44a5dc490 +Subproject commit 2cfdc4f2668f803b376415ebd938326c1047f206