From 0b9ed462b49012f692bdc939ed87d8788ad8f451 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 4 Sep 2019 14:28:50 -0600 Subject: [PATCH] Tested working onsite with Trevor Payne --- PepperDashEssentials/Bridges/BridgeBase.cs | 5 + .../Bridges/HdMdxxxCEControllerBridge.cs | 172 ++++++++++++++++++ .../PepperDashEssentials.csproj | 1 + .../Essentials_DM/Config/DeviceFactory.cs | 2 +- .../DmLite/HdMdxxxCEController.cs | 47 +++-- .../Essentials_DM/Essentials_DM.csproj | 2 +- 6 files changed, 216 insertions(+), 13 deletions(-) create mode 100644 PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index cb452029..d14af594 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -141,6 +141,11 @@ namespace PepperDash.Essentials.Bridges { (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; + } + else if (device is HdMdxxxCEController) + { + (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; } //else if (device is LightingBase) //{ diff --git a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs new file mode 100644 index 00000000..1c21789c --- /dev/null +++ b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM; + +namespace PepperDash.Essentials.Bridges +{ + public static class HdMdxxxCEControllerApiExtensions + { + public static void LinkToApi(this HdMdxxxCEController hdMdPair, BasicTriList trilist, uint joinStart, string joinMapKey) + { + var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as HdMdxxxCEControllerJoinMap; + + if (joinMap == null) + joinMap = new HdMdxxxCEControllerJoinMap(); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, hdMdPair, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + hdMdPair.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + hdMdPair.RemoteEndDetectedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RemoteEndDetected]); + + trilist.SetSigTrueAction(joinMap.AutoRouteOn, new Action(() => hdMdPair.AutoRouteOn())); + hdMdPair.AutoRouteOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoRouteOn]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff, new Action(() => hdMdPair.AutoRouteOff())); + hdMdPair.AutoRouteOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoRouteOff]); + + trilist.SetSigTrueAction(joinMap.PriorityRoutingOn, new Action(() => hdMdPair.PriorityRouteOn())); + hdMdPair.PriorityRoutingOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOn]); + trilist.SetSigTrueAction(joinMap.PriorityRoutingOff, new Action(() => hdMdPair.PriorityRouteOff())); + hdMdPair.PriorityRoutingOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PriorityRoutingOff]); + + trilist.SetSigTrueAction(joinMap.InputOnScreenDisplayEnabled, new Action(() => hdMdPair.OnScreenDisplayEnable())); + hdMdPair.InputOnScreenDisplayEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayEnabled]); + trilist.SetSigTrueAction(joinMap.AutoRouteOff, new Action(() => hdMdPair.OnScreenDisplayDisable())); + hdMdPair.InputOnScreenDisplayEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.InputOnScreenDisplayDisabled]); + + trilist.SetUShortSigAction(joinMap.VideoSource, new Action((i) => hdMdPair.ExecuteSwitch(i, null, eRoutingSignalType.Video | eRoutingSignalType.Audio))); + hdMdPair.VideoSourceFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoSource]); + + trilist.UShortInput[joinMap.SourceCount].UShortValue = (ushort)hdMdPair.InputPorts.Count; + + foreach (var input in hdMdPair.InputPorts) + { + var number = Convert.ToUInt16(input.Selector); + hdMdPair.SyncDetectedFeedbacks[number].LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected + number]); + trilist.StringInput[joinMap.SourceNames + number].StringValue = input.Key; + } + + } + + public class HdMdxxxCEControllerJoinMap : JoinMapBase + { + #region Digitals + /// + /// High when the pair is online + /// + public uint IsOnline { get; set; } + + /// + /// High when the remote end device is online + /// + public uint RemoteEndDetected { get; set; } + + /// + /// Sets Auto Route On and provides feedback + /// + public uint AutoRouteOn { get; set; } + + /// + /// Sets Auto Route Off and provides feedback + /// + public uint AutoRouteOff { get; set; } + + /// + /// Sets Priority Routing On and provides feedback + /// + public uint PriorityRoutingOn { get; set; } + + /// + /// Sets Priority Routing Off and provides feedback + /// + public uint PriorityRoutingOff { get; set; } + + /// + /// Enables OSD and provides feedback + /// + public uint InputOnScreenDisplayEnabled { get; set; } + + /// + /// Disables OSD and provides feedback + /// + public uint InputOnScreenDisplayDisabled { get; set; } + + /// + /// Provides Video Sync Detected feedback for each input + /// + public uint SyncDetected { get; set; } + #endregion + + #region Analogs + /// + /// Sets the video source for the receiver's HDMI out and provides feedback + /// + public uint VideoSource { get; set; } + + /// + /// Indicates the number of sources supported by the Tx/Rx pair + /// + public uint SourceCount { get; set; } + #endregion + + #region Serials + /// + /// Indicates the name of each input port + /// + public uint SourceNames { get; set; } + #endregion + + public HdMdxxxCEControllerJoinMap() + { + //Digital + IsOnline = 1; + RemoteEndDetected = 2; + AutoRouteOn = 3; + AutoRouteOff = 4; + PriorityRoutingOn = 5; + PriorityRoutingOff = 6; + InputOnScreenDisplayEnabled = 7; + InputOnScreenDisplayDisabled = 8; + SyncDetected = 10; // 11-15 + + //Analog + VideoSource = 1; + SourceCount = 2; + + //Serials + SourceNames = 10; // 11-15 + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + RemoteEndDetected = RemoteEndDetected + joinOffset; + AutoRouteOn = AutoRouteOn + joinOffset; + AutoRouteOff = AutoRouteOff + joinOffset; + PriorityRoutingOn = PriorityRoutingOn + joinOffset; + PriorityRoutingOff = PriorityRoutingOff + joinOffset; + InputOnScreenDisplayEnabled = InputOnScreenDisplayEnabled + joinOffset; + InputOnScreenDisplayDisabled = InputOnScreenDisplayDisabled + joinOffset; + SyncDetected = SyncDetected + joinOffset; + + VideoSource = VideoSource + joinOffset; + SourceCount = SourceCount + joinOffset; + + SourceNames = SourceNames + joinOffset; + } + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 3327128a..65eda177 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -129,6 +129,7 @@ + diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs index 4bdaf432..0eadd2a5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs @@ -69,7 +69,7 @@ namespace PepperDash.Essentials.DM return PepperDash.Essentials.DM.Chassis.HdMdNxM4kEController.GetController(key, name, type, props); } - else if (typeName.Equals("hdmd400ce") || typeName.Equals("hdmd300ce") || typeName.Equals("hdmd200ce")) + else if (typeName.Equals("hdmd400ce") || typeName.Equals("hdmd300ce") || typeName.Equals("hdmd200ce") || typeName.Equals("hdmd200c1ge")) { var props = JsonConvert.DeserializeObject (properties.ToString()); diff --git a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs b/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs index 26a181ce..7a4c4900 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/DmLite/HdMdxxxCEController.cs @@ -16,13 +16,13 @@ namespace PepperDash.Essentials.DM /// /// Represent both a transmitter and receiver pair of the HD-MD-400-C-E / HD-MD-300-C-E / HD-MD-200-C-E kits /// - public class HdMdxxxCEController : CrestronGenericBaseDevice, IRouting //, IComPorts + public class HdMdxxxCEController : CrestronGenericBaseDevice, IRouting//, IComPorts { /// - /// DmLite Ports - /// - public RoutingOutputPort ToRx { get; private set; } - public RoutingInputPort FromTx { get; private set; } + ///// DmLite Ports + ///// + //public RoutingOutputPort ToRx { get; private set; } + //public RoutingInputPort FromTx { get; private set; } public RoutingOutputPort HdmiOut { get; private set; } @@ -30,16 +30,34 @@ namespace PepperDash.Essentials.DM public RoutingPortCollection InputPorts { get; private set; } + /// + /// The value of the current video source for the HDMI output on the receiver + /// public IntFeedback VideoSourceFeedback { get; private set; } + /// + /// Indicates if Auto Route is on on the transmitter + /// public BoolFeedback AutoRouteOnFeedback { get; private set; } + /// + /// Indicates if Priority Routing is on on the transmitter + /// public BoolFeedback PriorityRoutingOnFeedback { get; private set; } + /// + /// INdicates if the On Screen Display is enabled + /// public BoolFeedback InputOnScreenDisplayEnabledFeedback { get; private set; } + /// + /// Indicates if video sync is detected on each of the inputs + /// public Dictionary SyncDetectedFeedbacks { get; private set; } + /// + /// Indicates if the remote end device is detected + /// public BoolFeedback RemoteEndDetectedFeedback { get; private set; } public RoutingPortCollection OutputPorts @@ -63,6 +81,8 @@ namespace PepperDash.Essentials.DM InputPorts = new RoutingPortCollection(); + SyncDetectedFeedbacks = new Dictionary(); + // Add the HDMI input port on the receiver InputPorts.Add(new RoutingInputPort(DmPortName.Hdmi, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 1, this)); @@ -110,16 +130,17 @@ namespace PepperDash.Essentials.DM InputPorts[DmPortName.HdmiIn].Port = TxRxPair.HdmiInputs[1]; } + //ToRx = new RoutingOutputPort(DmPortName.ToTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, + // eRoutingPortConnectionType.DmCat, null, this); - ToRx = new RoutingOutputPort(DmPortName.ToTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - FromTx = new RoutingInputPort(DmPortName.FromTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); + //FromTx = new RoutingInputPort(DmPortName.FromTx, eRoutingSignalType.Audio | eRoutingSignalType.Video, + // eRoutingPortConnectionType.DmCat, null, this); HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null, this); + OutputPorts[DmPortName.HdmiOut].Port = TxRxPair.HdmiOutputs[1]; + TxRxPair.DMInputChange += new DMInputEventHandler(TxRxPair_DMInputChange); TxRxPair.DMOutputChange += new DMOutputEventHandler(TxRxPair_DMOutputChange); TxRxPair.DMSystemChange += new DMSystemEventHandler(TxRxPair_DMSystemChange); @@ -183,7 +204,11 @@ namespace PepperDash.Essentials.DM public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { - TxRxPair.HdmiOutputs[1].VideoOut = TxRxPair.Inputs[(uint)inputSelector]; + var number = Convert.ToUInt32(inputSelector); // Cast can sometimes fail + + var input = number == 0 ? null : TxRxPair.Inputs[number]; + + TxRxPair.HdmiOutputs[1].VideoOut = input; } // This device has a different class for com ports which will make it hard to implement IComPorts.... diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj index 263a6c63..68aa1e17 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -113,7 +113,7 @@ - +