From b2646f50cbd726b320595857e44489d3370d8b3e Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:57:25 -0600 Subject: [PATCH 1/4] feat: add DGE Join map --- .../Endpoints/DGEs/DgeJoinMap.cs | 50 +++++++++++++++++++ .../PepperDash_Essentials_DM.csproj | 1 + 2 files changed, 51 insertions(+) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs new file mode 100644 index 00000000..f53e9383 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.DM.Endpoints.DGEs +{ + public class DgeJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CurrentInputResolution")] + public JoinDataComplete CurrentInputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Current Input Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SyncDetected")] + public JoinDataComplete SyncDetected = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Sync Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpOn")] + public JoinDataComplete HdmiInHdcpOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpOff")] + public JoinDataComplete HdmiInHdcpOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpToggle")] + public JoinDataComplete HdmiInHdcpToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + public DgeJoinMap(uint joinStart) + : this(joinStart, typeof(DgeJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DgeJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index 41b07237..0135334e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -105,6 +105,7 @@ + From bc64ee37cb82750373b805706bec550830cb1303 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:58:46 -0600 Subject: [PATCH 2/4] feat: Add bridging & HDCP support for DGE --- .../Endpoints/DGEs/Dge100Controller.cs | 78 +++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs index ea220a13..1130f654 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs @@ -17,11 +17,12 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core.DeviceInfo; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM.Endpoints.DGEs { [Description("Wrapper class for DGE-100")] - public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider + public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider, IBridgeAdvanced { private const int CtpPort = 41795; private readonly Dge100 _dge; @@ -30,9 +31,12 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs public BasicTriListWithSmartObject Panel { get { return _dge; } } - private DeviceConfig _dc; + private DeviceConfig _dc; + + public VideoStatusOutputs VideoStatusFeedbacks { get; private set; } + + CrestronTouchpanelPropertiesConfig PropertiesConfig; - CrestronTouchpanelPropertiesConfig PropertiesConfig; public Dge100Controller(string key, string name, Dge100 device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) :base(key, name, device) @@ -48,8 +52,20 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs _dc = dc; - PropertiesConfig = props; - } + PropertiesConfig = props; + + var videoStatusFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => _dge.HdmiIn.HdcpSupportOnFeedback.BoolValue, + VideoResolutionFeedbackFunc = () => _dge.HdmiIn.VideoAttributes.GetVideoResolutionString(), + VideoSyncFeedbackFunc = () => _dge.HdmiIn.SyncDetectedFeedback.BoolValue, + }; + + VideoStatusFeedbacks = new VideoStatusOutputs(videoStatusFuncs); + + _dge.HdmiIn.StreamChange += (s,a) => VideoStatusFeedbacks.FireAll(); + _dge.HdmiIn.VideoAttributes.AttributeChange += (o, a) => VideoStatusFeedbacks.FireAll(); + } #region IComPorts Members @@ -187,6 +203,58 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs handler(this, new DeviceInfoEventArgs(DeviceInfo)); } + #endregion + + #region IBridgeAdvanced Members + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DgeJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + //Presses + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOn.JoinNumber, () => _dge.HdmiIn.HdcpSupportOn()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOff.JoinNumber,() => _dge.HdmiIn.HdcpSupportOff()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpToggle.JoinNumber, () => { + if(_dge.HdmiIn.HdcpSupportOnFeedback.BoolValue) + { + _dge.HdmiIn.HdcpSupportOff(); + return; + } + + _dge.HdmiIn.HdcpSupportOn(); + }); + + + // Feedbacks + VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); + VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); + + trilist.OnlineStatusChange += (o, a) => + { + if (!a.DeviceOnLine) return; + + VideoStatusFeedbacks.FireAll(); + }; + } + + + #endregion } From a9fe8bbb10118efb7cd03fc6e402e8eb82b242bb Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:59:13 -0600 Subject: [PATCH 3/4] refactor: move DGE200 factory out of DGE200 class --- .../Endpoints/DGEs/DmDge200CController.cs | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs index 31da45b2..d5df7dc6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs @@ -58,37 +58,37 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs HdmiOut.Port = _dge.HdmiOut; ; } - - public class DmDge200CControllerFactory : EssentialsDeviceFactory - { - public DmDge200CControllerFactory() - { - TypeNames = new List() { "dmdge200c" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Debug.Console(1, "Factory Attempting to create new DgeController Device"); - - DmDge200C dgeDevice = null; - - if (typeName == "dmdge200c") - dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new DmDge200CController(dc.Key , dc.Name, dgeDevice, dc, props); - - return dgeController; - } - } } + + public class DmDge200CControllerFactory : EssentialsDeviceFactory + { + public DmDge200CControllerFactory() + { + TypeNames = new List() { "dmdge200c" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var typeName = dc.Type.ToLower(); + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Debug.Console(1, "Factory Attempting to create new DgeController Device"); + + DmDge200C dgeDevice = null; + + if (typeName == "dmdge200c") + dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); + + if (dgeDevice == null) + { + Debug.Console(1, "Unable to create DGE device"); + return null; + } + + var dgeController = new DmDge200CController(dc.Key, dc.Name, dgeDevice, dc, props); + + return dgeController; + } + } } \ No newline at end of file From ba511067d3781debdee54d5359c58ef863a7955e Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 14:13:15 -0600 Subject: [PATCH 4/4] fix: add missing feedback links --- .../Essentials_DM/Endpoints/DGEs/Dge100Controller.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs index 1130f654..6b0cdf28 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs @@ -245,6 +245,11 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); + VideoStatusFeedbacks.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); + VideoStatusFeedbacks.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber]); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.OnlineStatusChange += (o, a) => { if (!a.DeviceOnLine) return;