From 0eb6411dd917ad18ae0d1bf2c8879c03c699f37d Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 15 Nov 2019 16:22:18 -0600 Subject: [PATCH 01/14] Added support for 'Large' DM Frames --- PepperDashEssentials/Bridges/BridgeBase.cs | 7 +- .../Bridges/DmBladeChassisControllerBridge.cs | 222 ++ .../Bridges/DmChassisControllerBridge.cs | 6 +- .../DmBladeChassisControllerJoinMap.cs | 109 + .../PepperDashEssentials.csproj | 2 + .../Chassis/DmBladeChassisController.cs | 590 +++++ .../Chassis/DmChassisController.cs | 1893 ++++++++--------- .../Essentials_DM/Config/DeviceFactory.cs | 194 +- .../Endpoints/Receivers/DmRmcHelper.cs | 511 ++--- .../Endpoints/Transmitters/DmTxHelpers.cs | 11 +- .../Essentials_DM/Essentials_DM.csproj | 2 + .../Essentials DM/Essentials_DM/IDmSwitch.cs | 25 + .../Properties/AssemblyInfo.cs | 2 +- 13 files changed, 2266 insertions(+), 1308 deletions(-) create mode 100644 PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs create mode 100644 PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index afb04534..74cc4e87 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -103,11 +103,14 @@ namespace PepperDash.Essentials.Bridges (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } - else if (device is DmChassisController) - { + else if (device is DmChassisController) { (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } + else if (device is DmBladeChassisController) { + (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } else if (device is DmpsRoutingController) { (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); diff --git a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs new file mode 100644 index 00000000..9910d2ed --- /dev/null +++ b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs @@ -0,0 +1,222 @@ +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.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Bridges { + public static class DmBladeChassisControllerApiExtentions { + public static void LinkToApi(this DmBladeChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey) { + DmBladeChassisControllerJoinMap joinMap = new DmBladeChassisControllerJoinMap(); + + var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + var chassis = dmChassis.Chassis as BladeSwitch; + + dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + + + // Link up outputs + for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs; i++) { + var ioSlot = i; + + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); + + if (dmChassis.TxDictionary.ContainsKey(ioSlot)) { + Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + var txKey = dmChassis.TxDictionary[ioSlot]; + var basicTxDevice = DeviceManager.GetDeviceForKey(txKey) as BasicDmTxControllerBase; + + var advancedTxDevice = basicTxDevice as DmTxControllerBase; + + if (dmChassis.Chassis is DmMd128x128 || dmChassis.Chassis is DmMd64x64) { + dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + else { + if (advancedTxDevice != null) { + advancedTxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + Debug.Console(2, "Linking Tx Online Feedback from Advanced Transmitter at input {0}", ioSlot); + } + else if (dmChassis.InputEndpointOnlineFeedbacks[ioSlot] != null) { + Debug.Console(2, "Linking Tx Online Feedback from Input Card {0}", ioSlot); + dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + } + + if (basicTxDevice != null && advancedTxDevice == null) + trilist.BooleanInput[joinMap.TxAdvancedIsPresent + ioSlot].BoolValue = true; + + if (advancedTxDevice != null) { + advancedTxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + } + else if (advancedTxDevice == null || basicTxDevice != null) { + Debug.Console(1, "Setting up actions and feedbacks on input card {0}", ioSlot); + dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) { + Debug.Console(1, "Port value for input card {0} is set", ioSlot); + var port = inputPort.Port; + + if (port != null) { + if (port is HdmiInputWithCEC) { + Debug.Console(1, "Port is HdmiInputWithCec"); + + var hdmiInPortWCec = port as HdmiInputWithCEC; + + if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) { + SetHdcpStateAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + } + + dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (dmChassis.InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)dmChassis.InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + else { + inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--dmIn", ioSlot)]; + + if (inputPort != null) { + var port = inputPort.Port; + + if (port is DMInputPortWithCec) { + Debug.Console(1, "Port is DMInputPortWithCec"); + + var dmInPortWCec = port as DMInputPortWithCec; + + if (dmInPortWCec != null) { + SetHdcpStateAction(dmChassis.PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + } + + dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (dmChassis.InputCardHdcpCapabilityTypes.ContainsKey(ioSlot)) + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)dmChassis.InputCardHdcpCapabilityTypes[ioSlot]; + else + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = 1; + } + } + } + } + } + else { + dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if (inputPort != null) { + var hdmiPort = inputPort.Port as EndpointHdmiInput; + + if (hdmiPort != null) { + SetHdcpStateAction(true, hdmiPort, joinMap.HdcpSupportState + ioSlot, trilist); + dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + } + } + } + if (dmChassis.RxDictionary.ContainsKey(ioSlot)) { + Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + var rxKey = dmChassis.RxDictionary[ioSlot]; + var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + if (dmChassis.Chassis is DmMd128x128 || dmChassis.Chassis is DmMd64x64) { + dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + else if (rxDevice != null) { + rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + } + + // Feedback + dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + + + dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + } + } + + static void SetHdcpStateAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) { + if (hdcpTypeSimple) { + trilist.SetUShortSigAction(join, + new Action(s => { + if (s == 0) { + port.HdcpSupportOff(); + } + else if (s > 0) { + port.HdcpSupportOn(); + } + })); + } + else { + trilist.SetUShortSigAction(join, + new Action(u => { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + })); + } + } + + static void SetHdcpStateAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) { + if (hdcpTypeSimple) { + trilist.SetUShortSigAction(join, + new Action(s => { + if (s == 0) { + port.HdcpSupportOff(); + } + else if (s > 0) { + port.HdcpSupportOn(); + } + })); + } + else { + trilist.SetUShortSigAction(join, + new Action(u => { + port.HdcpCapability = (eHdcpCapabilityType)u; + })); + } + } + + static void SetHdcpStateAction(bool supportsHdcp2, DMInputPortWithCec port, uint join, BasicTriList trilist) { + if (!supportsHdcp2) { + trilist.SetUShortSigAction(join, + new Action(s => { + if (s == 0) { + port.HdcpSupportOff(); + } + else if (s > 0) { + port.HdcpSupportOn(); + } + })); + } + else { + trilist.SetUShortSigAction(join, + new Action(u => { + port.HdcpReceiveCapability = (eHdcpCapabilityType)u; + })); + } + } + + } +} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs index 6bce77c4..c85854b6 100644 --- a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs @@ -32,10 +32,12 @@ namespace PepperDash.Essentials.Bridges Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + var chassis = dmChassis.Chassis as DmMDMnxn; + dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - trilist.SetUShortSigAction(joinMap.SystemId, new Action(o => dmChassis.Chassis.SystemId.UShortValue = o)); - trilist.SetSigTrueAction(joinMap.SystemId, new Action(() => dmChassis.Chassis.ApplySystemId())); + trilist.SetUShortSigAction(joinMap.SystemId, new Action(o => chassis.SystemId.UShortValue = o)); + trilist.SetSigTrueAction(joinMap.SystemId, new Action(() => chassis.ApplySystemId())); dmChassis.SystemIdFeebdack.LinkInputSig(trilist.UShortInput[joinMap.SystemId]); dmChassis.SystemIdBusyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SystemId]); diff --git a/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs new file mode 100644 index 00000000..29ee6471 --- /dev/null +++ b/PepperDashEssentials/Bridges/JoinMaps/DmBladeChassisControllerJoinMap.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Bridges { + public class DmBladeChassisControllerJoinMap : JoinMapBase { + #region Digital/Analogs + #endregion + + #region Digitals + /// + /// High when device is online + /// + public uint IsOnline { get; set; } + /// + /// Range reports video sync feedback for each input + /// + public uint VideoSyncStatus { get; set; } + /// + /// Range reports high if corresponding input's endpoint is online + /// + public uint InputEndpointOnline { get; set; } + /// + /// Range reports high if corresponding output's endpoint is online + /// + public uint OutputEndpointOnline { get; set; } + /// + /// Range reports high if corresponding input's transmitter supports bridging as a separate device for detailed AV switching, HDCP control, etc. + /// + public uint TxAdvancedIsPresent { get; set; } // indicates that there is an attached transmitter that should be bridged to be interacted with + #endregion + + #region Analogs + /// + /// Range sets and reports the current video source for the corresponding output + /// + public uint OutputVideo { get; set; } + /// + /// Range sets and reports the current HDCP state for the corresponding input card + /// + public uint HdcpSupportState { get; set; } + /// + /// Range reports the highest supported HDCP state level for the corresponding input card + /// + public uint HdcpSupportCapability { get; set; } + #endregion + + #region Serials + /// + /// Range sets and reports the name for the corresponding input card + /// + public uint InputNames { get; set; } + /// + /// Range sets and reports the name for the corresponding output card + /// + public uint OutputNames { get; set; } + /// + /// Range reports the name of the current video source for the corresponding output card + /// + public uint OutputCurrentVideoInputNames { get; set; } + /// + /// Range reports the current input resolution for each corresponding input card + /// + public uint InputCurrentResolution { get; set; } + #endregion + + public DmBladeChassisControllerJoinMap() { + //Digital/Analog + + //Digital + IsOnline = 11; + VideoSyncStatus = 100; //101-299 + InputEndpointOnline = 500; //501-699 + OutputEndpointOnline = 700; //701-899 + TxAdvancedIsPresent = 1000; //1001-1199 + + //Analog + OutputVideo = 100; //101-299 + HdcpSupportState = 1000; //1001-1199 + HdcpSupportCapability = 1200; //1201-1399 + + + //Serial + InputNames = 100; //101-299 + OutputNames = 300; //301-499 + OutputCurrentVideoInputNames = 2000; //2001-2199 + InputCurrentResolution = 2400; // 2401-2599 + } + + public override void OffsetJoinNumbers(uint joinStart) { + var joinOffset = joinStart - 1; + + IsOnline = IsOnline + joinOffset; + OutputVideo = OutputVideo + joinOffset; + VideoSyncStatus = VideoSyncStatus + joinOffset; + InputNames = InputNames + joinOffset; + OutputNames = OutputNames + joinOffset; + OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset; + InputCurrentResolution = InputCurrentResolution + joinOffset; + InputEndpointOnline = InputEndpointOnline + joinOffset; + OutputEndpointOnline = OutputEndpointOnline + joinOffset; + HdcpSupportState = HdcpSupportState + joinOffset; + HdcpSupportCapability = HdcpSupportCapability + joinOffset; + } + } +} diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 6ef7e20f..8ec13dc8 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -121,6 +121,8 @@ + + diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs new file mode 100644 index 00000000..6676e3e4 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -0,0 +1,590 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Blades; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM { + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + public class DmBladeChassisController : CrestronGenericBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback { + public DMChassisPropertiesConfig PropertiesConfig { get; set; } + + public Switch Chassis { get; private set; } + + // Feedbacks for EssentialDM + public Dictionary VideoOutputFeedbacks { get; private set; } + public Dictionary AudioOutputFeedbacks { get; private set; } + public Dictionary VideoInputSyncFeedbacks { get; private set; } + public Dictionary InputEndpointOnlineFeedbacks { get; private set; } + public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } + public Dictionary InputNameFeedbacks { get; private set; } + public Dictionary OutputNameFeedbacks { get; private set; } + public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } + public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } + public Dictionary UsbOutputRoutedToFeebacks { get; private set; } + public Dictionary UsbInputRoutedToFeebacks { get; private set; } + + public IntFeedback SystemIdFeebdack { get; private set; } + public BoolFeedback SystemIdBusyFeedback { get; private set; } + + + public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } + + public Dictionary InputCardHdcpCapabilityTypes { get; private set; } + + + // Need a couple Lists of generic Backplane ports + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public Dictionary TxDictionary { get; set; } + public Dictionary RxDictionary { get; set; } + + //public Dictionary InputCards { get; private set; } + //public Dictionary OutputCards { get; private set; } + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + public Dictionary VolumeControls { get; private set; } + + public const int RouteOffTime = 500; + Dictionary RouteOffTimers = new Dictionary(); + + /// + /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now + /// + public static DmBladeChassisController GetDmChassisController(string key, string name, + string type, DMChassisPropertiesConfig properties) { + try { + type = type.ToLower(); + uint ipid = properties.Control.IpIdInt; + + BladeSwitch chassis = null; + if (type == "dmmd64x64") { chassis = new DmMd64x64(ipid, Global.ControlSystem); } + else if (type == "dmmd128x128") { chassis = new DmMd128x128(ipid, Global.ControlSystem); } + + + if (chassis == null) { + return null; + } + + var controller = new DmBladeChassisController(key, name, chassis); + // add the cards and port names + foreach (var kvp in properties.InputSlots) + controller.AddInputBlade(kvp.Value, kvp.Key); + foreach (var kvp in properties.OutputSlots) { + controller.AddOutputBlade(kvp.Value, kvp.Key); + } + + foreach (var kvp in properties.VolumeControls) { + // get the card + // check it for an audio-compatible type + // make a something-something that will make it work + // retire to mountain village + var outNum = kvp.Key; + + var card = controller.Chassis.Outputs[outNum].Card; + Audio.Output audio = null; + if (card is DmHdmi4kOutputBladeCard) + audio = (card as DmHdmi4kOutputBladeCard).Hdmi4kOutput.Audio; + if (audio == null) + continue; + // wire up the audio to something here... + controller.AddVolumeControl(outNum, audio); + } + + controller.InputNames = properties.InputNames; + controller.OutputNames = properties.OutputNames; + controller.PropertiesConfig = properties; + return controller; + } + catch (System.Exception e) { + Debug.Console(0, "Error creating DM chassis:\r{0}", e); + } + return null; + } + + + /// + /// + /// + /// + /// + /// + public DmBladeChassisController(string key, string name, BladeSwitch chassis) + : base(key, name, chassis) { + Chassis = chassis; + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + VolumeControls = new Dictionary(); + TxDictionary = new Dictionary(); + RxDictionary = new Dictionary(); + IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); + Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); + Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); + VideoOutputFeedbacks = new Dictionary(); + UsbOutputRoutedToFeebacks = new Dictionary(); + UsbInputRoutedToFeebacks = new Dictionary(); + VideoInputSyncFeedbacks = new Dictionary(); + InputNameFeedbacks = new Dictionary(); + OutputNameFeedbacks = new Dictionary(); + OutputVideoRouteNameFeedbacks = new Dictionary(); + OutputAudioRouteNameFeedbacks = new Dictionary(); + InputEndpointOnlineFeedbacks = new Dictionary(); + OutputEndpointOnlineFeedbacks = new Dictionary(); + + InputCardHdcpCapabilityFeedbacks = new Dictionary(); + InputCardHdcpCapabilityTypes = new Dictionary(); + + CrestronConsole.PrintLine("GotHere 1"); + for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) { + var tempX = x; + + if (Chassis.Outputs[tempX] != null) { + CrestronConsole.PrintLine("GotHere 2"); + VideoOutputFeedbacks[tempX] = new IntFeedback(() => { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } + else { return 0; }; + }); + + OutputNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Outputs[tempX].NameFeedback != null) { + CrestronConsole.PrintLine("GotHere 3"); + return Chassis.Outputs[tempX].NameFeedback.StringValue; + } + else { + return ""; + } + }); + OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) { + CrestronConsole.PrintLine("GotHere 4"); + return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; + } + else { + return ""; + } + }); + + OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { + CrestronConsole.PrintLine("GotHere 5"); + return Chassis.Outputs[tempX].EndpointOnlineFeedback; + }); + } + + if (Chassis.Inputs[tempX] != null) { + UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => { + CrestronConsole.PrintLine("GotHere 6"); + if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } + else { return 0; }; + }); + VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => { + CrestronConsole.PrintLine("GotHere 7"); + if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) + return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; + else + return false; + }); + InputNameFeedbacks[tempX] = new StringFeedback(() => { + CrestronConsole.PrintLine("GotHere 8"); + if (Chassis.Inputs[tempX].NameFeedback != null) { + return Chassis.Inputs[tempX].NameFeedback.StringValue; + } + else { + return ""; + } + }); + + InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { + CrestronConsole.PrintLine("GotHere 9"); + return Chassis.Inputs[tempX].EndpointOnlineFeedback; + }); + + InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => { + var inputCard = Chassis.Inputs[tempX]; + + if (inputCard.Card is DmHdmi4kInputBladeCard) { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + + if ((inputCard.Card as DmHdmi4kInputBladeCard).Hdmi4kInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + + if (inputCard.Card is DmC4kInputBladeCard) { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + + if ((inputCard.Card as DmC4kInputBladeCard).DmInput.HdcpCapabilityFeedback.Equals(eHdcpCapabilityType.HdcpSupportOff)) + return 0; + else + return 1; + } + + else + return 0; + }); + } + } + } + + /// + /// + /// + /// + /// + public void AddInputBlade(string type, uint number) { + Debug.Console(2, this, "Adding input blade '{0}', slot {1}", type, number); + + type = type.ToLower(); + + if (type == "dmb4kihd") { + var inputBlade = new Dmb4kIHd(number, this.Chassis); + foreach (var item in inputBlade.Inputs) { + var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; + var cecPort = card as ICec; + AddHdmiInBladePorts(item.Number, cecPort); + } + } + + else if (type == "dmb4kihddnt") { + var inputBlade = new Dmb4kIHd(number, this.Chassis); + foreach (var item in inputBlade.Inputs) { + var card = (item.Card as DmHdmi4kInputBladeCard).Hdmi4kInput; + var cecPort = card as ICec; + AddHdmiInBladePorts(item.Number, cecPort); + } + } + + else if (type == "dmb4kic") { + var inputBlade = new Dmb4kIC(number, this.Chassis); + foreach (var item in inputBlade.Inputs) { + AddDmInBladePorts(item.Number); + } + } + + else if (type == "dmbis") { + var inputBlade = new DmbIS(number, this.Chassis); + foreach (var item in inputBlade.Inputs) { + AddDmInMmFiberPorts(item.Number); + } + } + else if (type == "dmbis2") { + var inputBlade = new DmbIS2(number, this.Chassis); + foreach (var item in inputBlade.Inputs) { + AddDmInSmFiberPorts(item.Number); + } + } + } + + + + void AddHdmiInBladePorts(uint number, ICec cecPort) { + AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); + } + + void AddDmInBladePorts(uint number) { + AddInputPortWithDebug(number, "dmCIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); + } + + void AddDmInMmFiberPorts(uint number) { + AddInputPortWithDebug(number, "dmMmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); + } + + void AddDmInSmFiberPorts(uint number) { + AddInputPortWithDebug(number, "dmSmIn", eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); + } + + /// + /// + /// + /// + /// + public void AddOutputBlade(string type, uint number) { + type = type.ToLower(); + + Debug.Console(2, this, "Adding output blade '{0}', slot {1}", type, number); + if (type == "dmb4kohd") { + var outputBlade = new Dmb4KOHD(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddHdmiOutBladePorts(item.Number); + } + } + + else if (type == "dmb4kohddnt") { + var outputBlade = new Dmb4KOHD(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddHdmiOutBladePorts(item.Number); + } + } + + else if (type == "dmb4koc") { + var outputBlade = new Dmb4KOC(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddDmOutBladePorts(item.Number); + } + } + else if (type == "dmb4koc") { + var outputBlade = new Dmb4KOC(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddDmOutBladePorts(item.Number); + } + } + else if (type == "dmbos") { + var outputBlade = new DmbOS(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddDmOutMmFiberBladePorts(item.Number); + } + } + else if (type == "dmbos2") { + var outputBlade = new DmbOS2(number, Chassis); + foreach (var item in outputBlade.Outputs) { + AddDmOutSmFiberBladePorts(item.Number); + } + } + } + + void AddHdmiOutBladePorts(uint number) { + AddOutputPortWithDebug(String.Format("outputBlade{0}", (number / 8 > 0 ? 1 : number / 8)), String.Format("hdmiOut{0}", number) , eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, number); + } + + void AddDmOutBladePorts(uint number) { + AddOutputPortWithDebug(String.Format("outputBlade{0}", (number / 8 > 0 ? 1 : number / 8)), String.Format("dmOut{0}", number), eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, number); + } + + void AddDmOutMmFiberBladePorts(uint number) { + AddOutputPortWithDebug(String.Format("outputBlade{0}", (number / 8 > 0 ? 1 : number / 8)), String.Format("dmOut{0}", number), eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, number); + } + + void AddDmOutSmFiberBladePorts(uint number) { + AddOutputPortWithDebug(String.Format("outputBlade{0}", (number / 8 > 0 ? 1 : number / 8)), String.Format("dmOut{0}", number), eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, number); + } + + + /// + /// Adds InputPort + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); + + InputPorts.Add(inputPort); + } + + /// + /// Adds InputPort and sets Port as ICec object + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort) { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); + + if (inputPort != null) { + if (cecPort != null) + inputPort.Port = cecPort; + + InputPorts.Add(inputPort); + } + else + Debug.Console(2, this, "inputPort is null"); + } + + + /// + /// Adds OutputPort + /// + void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { + var portKey = string.Format("{0}--{1}", cardName, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)); + } + + + /// + /// + /// + void AddVolumeControl(uint number, Audio.Output audio) { + VolumeControls.Add(number, new DmCardAudioOutputController(audio)); + } + + //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) + //{ + + //} + + + void Chassis_DMInputChange(Switch device, DMInputEventArgs args) { + + switch (args.EventId) { + case DMInputEventIds.EndpointOnlineEventId: { + Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.OnlineFeedbackEventId: { + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.VideoDetectedEventId: { + Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); + VideoInputSyncFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.InputNameEventId: { + Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); + InputNameFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.HdcpCapabilityFeedbackEventId: { + Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); + InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); + break; + } + default: { + Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + } + /// + /// + void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) { + + //This should be a switch case JTA 2018-07-02 + var output = args.Number; + + switch (args.EventId) { + case DMOutputEventIds.VolumeEventId: { + if (VolumeControls.ContainsKey(output)) { + VolumeControls[args.Number].VolumeEventFromChassis(); + } + break; + } + case DMOutputEventIds.EndpointOnlineEventId: { + Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.OnlineFeedbackEventId: { + Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.VideoOutEventId: { + if (Chassis.Outputs[output].VideoOutFeedback != null) { + Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].VideoOutFeedback.Number, output); + } + if (VideoOutputFeedbacks.ContainsKey(output)) { + VideoOutputFeedbacks[output].FireUpdate(); + + } + if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) { + OutputVideoRouteNameFeedbacks[output].FireUpdate(); + } + break; + } + case DMOutputEventIds.OutputNameEventId: { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + break; + } + default: { + Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + + } + + + /// + /// + /// + /// + void StartOffTimer(PortNumberType pnt) { + if (RouteOffTimers.ContainsKey(pnt)) + return; + RouteOffTimers[pnt] = new CTimer(o => { + ExecuteSwitch(0, pnt.Number, pnt.Type); + }, RouteOffTime); + } + + + // Send out sigs when coming online + void IsOnline_OutputChange(object sender, EventArgs e) { + if (IsOnline.BoolValue) { + Chassis.EnableUSBBreakaway.BoolValue = true; + + if (InputNames != null) + foreach (var kvp in InputNames) + Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; + if (OutputNames != null) + foreach (var kvp in OutputNames) + Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; + } + } + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) { + Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); + + var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail + var output = Convert.ToUInt32(outputSelector); + // Check to see if there's an off timer waiting on this and if so, cancel + var key = new PortNumberType(output, sigType); + if (input == 0) { + StartOffTimer(key); + } + else { + if (RouteOffTimers.ContainsKey(key)) { + Debug.Console(2, this, "{0} cancelling route off due to new source", output); + RouteOffTimers[key].Stop(); + RouteOffTimers.Remove(key); + } + } + + + + var inCard = input == 0 ? null : Chassis.Inputs[input]; + var outCard = input == 0 ? null : Chassis.Outputs[output]; + + // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES + if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) { + Chassis.VideoEnter.BoolValue = true; + Chassis.Outputs[output].VideoOut = inCard; + } + } + + #endregion + + } + + /* + public struct PortNumberType { + public uint Number { get; private set; } + public eRoutingSignalType Type { get; private set; } + + public PortNumberType(uint number, eRoutingSignalType type) + : this() { + Number = number; + Type = type; + } + }*/ +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 99abf890..c1bddd19 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -1,948 +1,947 @@ - using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Cards; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Cards; - -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// - public class DmChassisController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback - { - public DMChassisPropertiesConfig PropertiesConfig { get; set; } - - public DmMDMnxn Chassis { get; private set; } - - // Feedbacks for EssentialDM - public Dictionary VideoOutputFeedbacks { get; private set; } - public Dictionary AudioOutputFeedbacks { get; private set; } - public Dictionary VideoInputSyncFeedbacks { get; private set; } - public Dictionary InputEndpointOnlineFeedbacks { get; private set; } - public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } - public Dictionary InputNameFeedbacks { get; private set; } - public Dictionary OutputNameFeedbacks { get; private set; } - public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } - public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } - public Dictionary UsbOutputRoutedToFeebacks { get; private set; } - public Dictionary UsbInputRoutedToFeebacks { get; private set; } - - public IntFeedback SystemIdFeebdack { get; private set; } - public BoolFeedback SystemIdBusyFeedback { get; private set; } - - - public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } - - public Dictionary InputCardHdcpCapabilityTypes { get; private set; } - - - // Need a couple Lists of generic Backplane ports - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary TxDictionary { get; set; } - public Dictionary RxDictionary { get; set; } - - //public Dictionary InputCards { get; private set; } - //public Dictionary OutputCards { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - public Dictionary VolumeControls { get; private set; } - - public const int RouteOffTime = 500; - Dictionary RouteOffTimers = new Dictionary(); - - /// - /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now - /// - public static DmChassisController GetDmChassisController(string key, string name, - string type, DMChassisPropertiesConfig properties) - { - try - { - type = type.ToLower(); - uint ipid = properties.Control.IpIdInt; - - DmMDMnxn chassis = null; - if (type == "dmmd8x8") { chassis = new DmMd8x8(ipid, Global.ControlSystem); } - else if (type == "dmmd8x8rps") { chassis = new DmMd8x8rps(ipid, Global.ControlSystem); } - else if (type == "dmmd8x8cpu3") { chassis = new DmMd8x8Cpu3(ipid, Global.ControlSystem); } - else if (type == "dmmd8x8cpu3rps") { chassis = new DmMd8x8Cpu3rps(ipid, Global.ControlSystem); } - - else if (type == "dmmd16x16") { chassis = new DmMd16x16(ipid, Global.ControlSystem); } - else if (type == "dmmd16x16rps") { chassis = new DmMd16x16rps(ipid, Global.ControlSystem); } - else if (type == "dmmd16x16cpu3") { chassis = new DmMd16x16Cpu3(ipid, Global.ControlSystem); } - else if (type == "dmmd16x16cpu3rps") { chassis = new DmMd16x16Cpu3rps(ipid, Global.ControlSystem); } - - else if (type == "dmmd32x32") { chassis = new DmMd32x32(ipid, Global.ControlSystem); } - else if (type == "dmmd32x32rps") { chassis = new DmMd32x32rps(ipid, Global.ControlSystem); } - else if (type == "dmmd32x32cpu3") { chassis = new DmMd32x32Cpu3(ipid, Global.ControlSystem); } - else if (type == "dmmd32x32cpu3rps") { chassis = new DmMd32x32Cpu3rps(ipid, Global.ControlSystem); } - - if (chassis == null) - { - return null; - } - - var controller = new DmChassisController(key, name, chassis); - // add the cards and port names - foreach (var kvp in properties.InputSlots) - controller.AddInputCard(kvp.Value, kvp.Key); - foreach (var kvp in properties.OutputSlots) - { - controller.AddOutputCard(kvp.Value, kvp.Key); - } - - foreach (var kvp in properties.VolumeControls) - { - // get the card - // check it for an audio-compatible type - // make a something-something that will make it work - // retire to mountain village - var outNum = kvp.Key; - var card = controller.Chassis.Outputs[outNum].Card; - Audio.Output audio = null; - if (card is DmcHdo) - audio = (card as DmcHdo).Audio; - else if (card is Dmc4kHdo) - audio = (card as Dmc4kHdo).Audio; - if (audio == null) - continue; - // wire up the audio to something here... - controller.AddVolumeControl(outNum, audio); - } - - controller.InputNames = properties.InputNames; - controller.OutputNames = properties.OutputNames; - controller.PropertiesConfig = properties; - return controller; - } - catch (System.Exception e) - { - Debug.Console(0, "Error creating DM chassis:\r{0}", e); - } - return null; - } - - - /// - /// - /// - /// - /// - /// - public DmChassisController(string key, string name, DmMDMnxn chassis) - : base(key, name, chassis) - { - Chassis = chassis; - InputPorts = new RoutingPortCollection(); - OutputPorts = new RoutingPortCollection(); - VolumeControls = new Dictionary(); - TxDictionary = new Dictionary(); - RxDictionary = new Dictionary(); - IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); - Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); - Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); - VideoOutputFeedbacks = new Dictionary(); - AudioOutputFeedbacks = new Dictionary(); - UsbOutputRoutedToFeebacks = new Dictionary(); - UsbInputRoutedToFeebacks = new Dictionary(); - VideoInputSyncFeedbacks = new Dictionary(); - InputNameFeedbacks = new Dictionary(); - OutputNameFeedbacks = new Dictionary(); - OutputVideoRouteNameFeedbacks = new Dictionary(); - OutputAudioRouteNameFeedbacks = new Dictionary(); - InputEndpointOnlineFeedbacks = new Dictionary(); - OutputEndpointOnlineFeedbacks = new Dictionary(); - - SystemIdFeebdack = new IntFeedback(() => { return Chassis.SystemIdFeedback.UShortValue; }); - SystemIdBusyFeedback = new BoolFeedback(() => { return Chassis.SystemIdBusy.BoolValue; }); - InputCardHdcpCapabilityFeedbacks = new Dictionary(); - InputCardHdcpCapabilityTypes = new Dictionary(); - - - for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) - { - var tempX = x; - - if (Chassis.Outputs[tempX] != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } - else { return 0; }; - }); - AudioOutputFeedbacks[tempX] = new IntFeedback(() => - { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].AudioOutFeedback.Number; } - else { return 0; }; - }); - UsbOutputRoutedToFeebacks[tempX] = new IntFeedback(() => - { - if (Chassis.Outputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Outputs[tempX].USBRoutedToFeedback.Number; } - else { return 0; }; - }); - - OutputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].NameFeedback != null) - { - return Chassis.Outputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].VideoOutFeedback != null) - { - return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; - } - else - { - return ""; - } - }); - OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Outputs[tempX].AudioOutFeedback != null) - { - return Chassis.Outputs[tempX].AudioOutFeedback.NameFeedback.StringValue; - } - else - { - return ""; - - } - }); - - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - return Chassis.Outputs[tempX].EndpointOnlineFeedback; - }); - } - - if (Chassis.Inputs[tempX] != null) - { - UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => - { - if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } - else { return 0; }; - }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => - { - if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) - return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; - else - return false; - }); - InputNameFeedbacks[tempX] = new StringFeedback(() => - { - if (Chassis.Inputs[tempX].NameFeedback != null) - { - return Chassis.Inputs[tempX].NameFeedback.StringValue; - } - else - { - return ""; - } - }); - - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => - { - return Chassis.Inputs[tempX].EndpointOnlineFeedback; - }); - - InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => - { - var inputCard = Chassis.Inputs[tempX]; - - if (inputCard.Card is DmcHd) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHd).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - else if (inputCard.Card is DmcHdDsp) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - if ((inputCard.Card as DmcHdDsp).HdmiInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - else if (inputCard.Card is Dmc4kHdBase) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; - - return (int)(inputCard.Card as Dmc4kHdBase).HdmiInput.HdcpReceiveCapability; - } - else if (inputCard.Card is Dmc4kCBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - return (int)(inputCard.Card as Dmc4kCBase).DmInput.HdcpReceiveCapability; - } - else if ((inputCard.Card as Dmc4kCBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - else if (inputCard.Card is Dmc4kCDspBase) - { - if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) - { - InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; - - return (int)(inputCard.Card as Dmc4kCDspBase).DmInput.HdcpReceiveCapability; - } - else if ((inputCard.Card as Dmc4kCDspBase).DmInput.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - } - else - return 0; - }); - } - } - } - - /// - /// - /// - /// - /// - public void AddInputCard(string type, uint number) - { - Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number); - - type = type.ToLower(); - - if (type == "dmchd") - { - var inputCard = new DmcHd(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmchddsp") - { - var inputCard = new DmcHdDsp(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmc4khd") - { - var inputCard = new Dmc4kHd(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmc4khddsp") - { - var inputCard = new Dmc4kHdDsp(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmc4kzhd") - { - var inputCard = new Dmc4kzHd(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmc4kzhddsp") - { - var inputCard = new Dmc4kzHdDsp(number, this.Chassis); - var cecPort = inputCard.HdmiInput as ICec; - AddHdmiInCardPorts(number, cecPort); - } - else if (type == "dmcc") - { - var inputCard = new DmcC(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmccdsp") - { - var inputCard = new DmcCDsp(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmc4kc") - { - var inputCard = new Dmc4kC(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmc4kcdsp") - { - var inputCard = new Dmc4kCDsp(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmc4kzc") - { - var inputCard = new Dmc4kzC(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmc4kzcdsp") - { - var inputCard = new Dmc4kzCDsp(number, this.Chassis); - var cecPort = inputCard.DmInput as ICec; - AddDmInCardPorts(number, cecPort); - } - else if (type == "dmccat") - { - new DmcCat(number, this.Chassis); - AddDmInCardPorts(number); - } - else if (type == "dmccatdsp") - { - new DmcCatDsp(number, this.Chassis); - AddDmInCardPorts(number); - } - else if (type == "dmcs") - { - new DmcS(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); - AddInCardHdmiAndAudioLoopPorts(number); - } - else if (type == "dmcsdsp") - { - new DmcSDsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); - AddInCardHdmiAndAudioLoopPorts(number); - } - else if (type == "dmcs2") - { - new DmcS2(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); - AddInCardHdmiAndAudioLoopPorts(number); - } - else if (type == "dmcs2dsp") - { - new DmcS2Dsp(number, Chassis); - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); - AddInCardHdmiAndAudioLoopPorts(number); - } - else if (type == "dmcsdi") - { - new DmcSdi(number, Chassis); - AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "sdiOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi, null); - AddInCardHdmiAndAudioLoopPorts(number); - } - else if (type == "dmcdvi") - { - new DmcDvi(number, Chassis); - AddInputPortWithDebug(number, "dviIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcvga") - { - new DmcVga(number, Chassis); - AddInputPortWithDebug(number, "vgaIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Vga); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcvidbnc") - { - new DmcVidBnc(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcvidrcaa") - { - new DmcVidRcaA(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcvidrcad") - { - new DmcVidRcaD(number, Chassis); - AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); - AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcvid4") - { - new DmcVid4(number, Chassis); - AddInputPortWithDebug(number, "compositeIn1", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn2", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn3", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInputPortWithDebug(number, "compositeIn4", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); - AddInCardHdmiLoopPort(number); - } - else if (type == "dmcstr") - { - new DmcStr(number, Chassis); - AddInputPortWithDebug(number, "streamIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming); - AddInCardHdmiAndAudioLoopPorts(number); - } - } - - void AddDmInCardPorts(uint number) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); - AddInCardHdmiAndAudioLoopPorts(number); - } - void AddDmInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddHdmiInCardPorts(uint number, ICec cecPort) - { - AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); - AddInCardHdmiAndAudioLoopPorts(number); - } - - void AddInCardHdmiAndAudioLoopPorts(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null); - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null); - } - - void AddInCardHdmiLoopPort(uint number) - { - AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null); - } - - /// - /// - /// - /// - /// - public void AddOutputCard(string type, uint number) - { - type = type.ToLower(); - - Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number); - if (type == "dmc4khdo") - { - var outputCard = new Dmc4kHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - else if (type == "dmchdo") - { - var outputCard = new DmcHdoSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - var cecPort2 = outputCard.Card2.HdmiOutput; - AddDmcHdoPorts(number, cecPort1, cecPort2); - } - else if (type == "dmc4kcohd") - { - var outputCard = new Dmc4kCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - else if (type == "dmc4kzcohd") - { - var outputCard = new Dmc4kzCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - else if (type == "dmccohd") - { - var outputCard = new DmcCoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - else if (type == "dmccatohd") - { - var outputCard = new DmcCatoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddDmcCoPorts(number, cecPort1); - } - else if (type == "dmcsohd") - { - var outputCard = new DmcSoHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 2); - - } - else if (type == "dmcs2ohd") - { - var outputCard = new DmcS2oHdSingle(number, Chassis); - var cecPort1 = outputCard.Card1.HdmiOutput; - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 2); - } - else if (type == "dmcstro") - { - var outputCard = new DmcStroSingle(number, Chassis); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "streamOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, 2 * (number - 1) + 1); - } - - else - Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type); - } - - void AddDmcHdoPorts(uint number, ICec cecPort1, ICec cecPort2) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 2, cecPort2); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 2); - } - - void AddDmcCoPorts(uint number, ICec cecPort1) - { - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); - AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 2); - } - - - /// - /// Adds InputPort - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); - - InputPorts.Add(inputPort); - } - - /// - /// Adds InputPort and sets Port as ICec object - /// - void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort) - { - var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); - Debug.Console(2, this, "Adding input port '{0}'", portKey); - var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); - - if (inputPort != null) - { - if (cecPort != null) - inputPort.Port = cecPort; - - InputPorts.Add(inputPort); - } - else - Debug.Console(2, this, "inputPort is null"); - } - - /// - /// Adds OutputPort - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) - { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)); - } - - /// - /// Adds OutputPort and sets Port as ICec object - /// - void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) - { - var portKey = string.Format("{0}--{1}", cardName, portName); - Debug.Console(2, this, "Adding output port '{0}'", portKey); - var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); - - if (cecPort != null) - outputPort.Port = cecPort; - - OutputPorts.Add(outputPort); - } - - /// - /// - /// - void AddVolumeControl(uint number, Audio.Output audio) - { - VolumeControls.Add(number, new DmCardAudioOutputController(audio)); - } - - //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) - //{ - - //} - - - void Chassis_DMSystemChange(Switch device, DMSystemEventArgs args) - { - switch (args.EventId) - { - case DMSystemEventIds.SystemIdEventId: - { - Debug.Console(2, this, "SystemIdEvent Value: {0}", Chassis.SystemIdFeedback.UShortValue); - SystemIdFeebdack.FireUpdate(); - break; - } - case DMSystemEventIds.SystemIdBusyEventId: - { - Debug.Console(2, this, "SystemIdBusyEvent State: {0}", Chassis.SystemIdBusy.BoolValue); - SystemIdBusyFeedback.FireUpdate(); - break; - } - } - } - - void Chassis_DMInputChange(Switch device, DMInputEventArgs args) - { - - switch (args.EventId) { - case DMInputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); - InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); - VideoInputSyncFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.InputNameEventId: - { - Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); - InputNameFeedbacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Input {0} UsbRoutedToEventId", args.Number); - UsbInputRoutedToFeebacks[args.Number].FireUpdate(); - break; - } - case DMInputEventIds.HdcpCapabilityFeedbackEventId: - { - Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); - InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - } - /// - /// - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) - { - - //This should be a switch case JTA 2018-07-02 - var output = args.Number; - - switch (args.EventId) - { - case DMOutputEventIds.VolumeEventId: - { - if (VolumeControls.ContainsKey(output)) - { - VolumeControls[args.Number].VolumeEventFromChassis(); - } - break; - } - case DMOutputEventIds.EndpointOnlineEventId: - { - Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.OnlineFeedbackEventId: - { - Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); - OutputEndpointOnlineFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.VideoOutEventId: - { - if (Chassis.Outputs[output].VideoOutFeedback != null) - { - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].VideoOutFeedback.Number, output); - } - if (VideoOutputFeedbacks.ContainsKey(output)) - { - VideoOutputFeedbacks[output].FireUpdate(); - - } - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - { - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - } - break; - } - case DMOutputEventIds.AudioOutEventId: - { - if (Chassis.Outputs[output].AudioOutFeedback != null) - { - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].AudioOutFeedback.Number, output); - } - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - } - break; - } - case DMOutputEventIds.OutputNameEventId: - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - break; - } - case DMOutputEventIds.UsbRoutedToEventId: - { - Debug.Console(2, this, "DM Output {0} UsbRoutedToEventId", args.Number); - UsbOutputRoutedToFeebacks[args.Number].FireUpdate(); - break; - } - default: - { - Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); - break; - } - } - - } - - /// - /// - /// - /// - void StartOffTimer(PortNumberType pnt) - { - if (RouteOffTimers.ContainsKey(pnt)) - return; - RouteOffTimers[pnt] = new CTimer(o => - { - ExecuteSwitch(0, pnt.Number, pnt.Type); - }, RouteOffTime); - } - - - // Send out sigs when coming online - void IsOnline_OutputChange(object sender, EventArgs e) - { - if (IsOnline.BoolValue) - { - Chassis.EnableAudioBreakaway.BoolValue = true; - Chassis.EnableUSBBreakaway.BoolValue = true; - - if (InputNames != null) - foreach (var kvp in InputNames) - Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach(var kvp in OutputNames) - Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; - } - } - - #region IRouting Members - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) - { - Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); - - var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail - var output = Convert.ToUInt32(outputSelector); - // Check to see if there's an off timer waiting on this and if so, cancel - var key = new PortNumberType(output, sigType); - if (input == 0) - { - StartOffTimer(key); - } - else - { - if(RouteOffTimers.ContainsKey(key)) - { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); - } - } - - Card.DMICard inCard = input == 0 ? null : Chassis.Inputs[input]; - Card.DMOCard outCard = input == 0 ? null : Chassis.Outputs[output]; - - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - { - Chassis.VideoEnter.BoolValue = true; - Chassis.Outputs[output].VideoOut = inCard; - } - - if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - Chassis.AudioEnter.BoolValue = true; - Chassis.Outputs[output].AudioOut = inCard; - } - - if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - Chassis.USBEnter.BoolValue = true; - if (Chassis.Outputs[output] != null) - Chassis.Outputs[output].USBRoutedTo = inCard; - } - - if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) - { - Chassis.USBEnter.BoolValue = true; - if(Chassis.Inputs[input] != null) - Chassis.Inputs[input].USBRoutedTo = outCard; - } - } - - #endregion - - } - - public struct PortNumberType - { - public uint Number { get; private set; } - public eRoutingSignalType Type { get; private set; } - - public PortNumberType(uint number, eRoutingSignalType type) : this() - { - Number = number; - Type = type; - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +//using PepperDash.Essentials.DM.Cards; + +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// + public class DmChassisController : CrestronGenericBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback + { + public DMChassisPropertiesConfig PropertiesConfig { get; set; } + + public Switch Chassis { get; private set; } + + // Feedbacks for EssentialDM + public Dictionary VideoOutputFeedbacks { get; private set; } + public Dictionary AudioOutputFeedbacks { get; private set; } + public Dictionary VideoInputSyncFeedbacks { get; private set; } + public Dictionary InputEndpointOnlineFeedbacks { get; private set; } + public Dictionary OutputEndpointOnlineFeedbacks { get; private set; } + public Dictionary InputNameFeedbacks { get; private set; } + public Dictionary OutputNameFeedbacks { get; private set; } + public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } + public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } + public Dictionary UsbOutputRoutedToFeebacks { get; private set; } + public Dictionary UsbInputRoutedToFeebacks { get; private set; } + + public IntFeedback SystemIdFeebdack { get; private set; } + public BoolFeedback SystemIdBusyFeedback { get; private set; } + + + public Dictionary InputCardHdcpCapabilityFeedbacks { get; private set; } + + public Dictionary InputCardHdcpCapabilityTypes { get; private set; } + + + // Need a couple Lists of generic Backplane ports + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public Dictionary TxDictionary { get; set; } + public Dictionary RxDictionary { get; set; } + + //public Dictionary InputCards { get; private set; } + //public Dictionary OutputCards { get; private set; } + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + public Dictionary VolumeControls { get; private set; } + + public const int RouteOffTime = 500; + Dictionary RouteOffTimers = new Dictionary(); + + /// + /// Factory method to create a new chassis controller from config data. Limited to 8x8 right now + /// + public static DmChassisController GetDmChassisController(string key, string name, + string type, DMChassisPropertiesConfig properties) + { + try + { + type = type.ToLower(); + uint ipid = properties.Control.IpIdInt; + + DmMDMnxn chassis = null; + if (type == "dmmd8x8") { chassis = new DmMd8x8(ipid, Global.ControlSystem); } + else if (type == "dmmd8x8rps") { chassis = new DmMd8x8rps(ipid, Global.ControlSystem); } + else if (type == "dmmd8x8cpu3") { chassis = new DmMd8x8Cpu3(ipid, Global.ControlSystem); } + else if (type == "dmmd8x8cpu3rps") { chassis = new DmMd8x8Cpu3rps(ipid, Global.ControlSystem); } + + else if (type == "dmmd16x16") { chassis = new DmMd16x16(ipid, Global.ControlSystem); } + else if (type == "dmmd16x16rps") { chassis = new DmMd16x16rps(ipid, Global.ControlSystem); } + else if (type == "dmmd16x16cpu3") { chassis = new DmMd16x16Cpu3(ipid, Global.ControlSystem); } + else if (type == "dmmd16x16cpu3rps") { chassis = new DmMd16x16Cpu3rps(ipid, Global.ControlSystem); } + + else if (type == "dmmd32x32") { chassis = new DmMd32x32(ipid, Global.ControlSystem); } + else if (type == "dmmd32x32rps") { chassis = new DmMd32x32rps(ipid, Global.ControlSystem); } + else if (type == "dmmd32x32cpu3") { chassis = new DmMd32x32Cpu3(ipid, Global.ControlSystem); } + else if (type == "dmmd32x32cpu3rps") { chassis = new DmMd32x32Cpu3rps(ipid, Global.ControlSystem); } + + if (chassis == null) + { + return null; + } + + var controller = new DmChassisController(key, name, chassis); + // add the cards and port names + foreach (var kvp in properties.InputSlots) + controller.AddInputCard(kvp.Value, kvp.Key); + foreach (var kvp in properties.OutputSlots) + { + controller.AddOutputCard(kvp.Value, kvp.Key); + } + + foreach (var kvp in properties.VolumeControls) + { + // get the card + // check it for an audio-compatible type + // make a something-something that will make it work + // retire to mountain village + var outNum = kvp.Key; + var card = controller.Chassis.Outputs[outNum].Card; + Audio.Output audio = null; + if (card is DmcHdo) + audio = (card as DmcHdo).Audio; + else if (card is Dmc4kHdo) + audio = (card as Dmc4kHdo).Audio; + if (audio == null) + continue; + // wire up the audio to something here... + controller.AddVolumeControl(outNum, audio); + } + + controller.InputNames = properties.InputNames; + controller.OutputNames = properties.OutputNames; + controller.PropertiesConfig = properties; + return controller; + } + catch (System.Exception e) + { + Debug.Console(0, "Error creating DM chassis:\r{0}", e); + } + return null; + } + + + /// + /// + /// + /// + /// + /// + public DmChassisController(string key, string name, DmMDMnxn chassis) + : base(key, name, chassis) + { + Chassis = chassis; + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + VolumeControls = new Dictionary(); + TxDictionary = new Dictionary(); + RxDictionary = new Dictionary(); + IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); + Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); + Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); + Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); + VideoOutputFeedbacks = new Dictionary(); + AudioOutputFeedbacks = new Dictionary(); + UsbOutputRoutedToFeebacks = new Dictionary(); + UsbInputRoutedToFeebacks = new Dictionary(); + VideoInputSyncFeedbacks = new Dictionary(); + InputNameFeedbacks = new Dictionary(); + OutputNameFeedbacks = new Dictionary(); + OutputVideoRouteNameFeedbacks = new Dictionary(); + OutputAudioRouteNameFeedbacks = new Dictionary(); + InputEndpointOnlineFeedbacks = new Dictionary(); + OutputEndpointOnlineFeedbacks = new Dictionary(); + + SystemIdFeebdack = new IntFeedback(() => { return (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue; }); + SystemIdBusyFeedback = new BoolFeedback(() => { return (Chassis as DmMDMnxn).SystemIdBusy.BoolValue; }); + InputCardHdcpCapabilityFeedbacks = new Dictionary(); + InputCardHdcpCapabilityTypes = new Dictionary(); + + + for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) + { + var tempX = x; + + if (Chassis.Outputs[tempX] != null) + { + VideoOutputFeedbacks[tempX] = new IntFeedback(() => + { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } + else { return 0; }; + }); + AudioOutputFeedbacks[tempX] = new IntFeedback(() => + { + if (Chassis.Outputs[tempX].AudioOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].AudioOutFeedback.Number; } + else { return 0; }; + }); + UsbOutputRoutedToFeebacks[tempX] = new IntFeedback(() => + { + if (Chassis.Outputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Outputs[tempX].USBRoutedToFeedback.Number; } + else { return 0; }; + }); + + OutputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Outputs[tempX].NameFeedback != null) + { + return Chassis.Outputs[tempX].NameFeedback.StringValue; + } + else + { + return ""; + } + }); + OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Outputs[tempX].VideoOutFeedback != null) + { + return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; + } + else + { + return ""; + } + }); + OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Outputs[tempX].AudioOutFeedback != null) + { + return Chassis.Outputs[tempX].AudioOutFeedback.NameFeedback.StringValue; + } + else + { + return ""; + + } + }); + + OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => + { + return Chassis.Outputs[tempX].EndpointOnlineFeedback; + }); + } + + if (Chassis.Inputs[tempX] != null) + { + UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => + { + if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } + else { return 0; }; + }); + VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => + { + if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) + return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; + else + return false; + }); + InputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (Chassis.Inputs[tempX].NameFeedback != null) + { + return Chassis.Inputs[tempX].NameFeedback.StringValue; + } + else + { + return ""; + } + }); + + InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => + { + return Chassis.Inputs[tempX].EndpointOnlineFeedback; + }); + + InputCardHdcpCapabilityFeedbacks[tempX] = new IntFeedback(() => + { + var inputCard = Chassis.Inputs[tempX]; + + if (inputCard.Card is DmcHd) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + if ((inputCard.Card as DmcHd).HdmiInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + else if (inputCard.Card is DmcHdDsp) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + if ((inputCard.Card as DmcHdDsp).HdmiInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + else if (inputCard.Card is Dmc4kHdBase) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.Hdcp2_2Support; + + return (int)(inputCard.Card as Dmc4kHdBase).HdmiInput.HdcpReceiveCapability; + } + else if (inputCard.Card is Dmc4kCBase) + { + if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + return (int)(inputCard.Card as Dmc4kCBase).DmInput.HdcpReceiveCapability; + } + else if ((inputCard.Card as Dmc4kCBase).DmInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + else if (inputCard.Card is Dmc4kCDspBase) + { + if (PropertiesConfig.InputSlotSupportsHdcp2[tempX]) + { + InputCardHdcpCapabilityTypes[tempX] = eHdcpCapabilityType.HdcpAutoSupport; + + return (int)(inputCard.Card as Dmc4kCDspBase).DmInput.HdcpReceiveCapability; + } + else if ((inputCard.Card as Dmc4kCDspBase).DmInput.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + } + else + return 0; + }); + } + } + } + + /// + /// + /// + /// + /// + public void AddInputCard(string type, uint number) + { + Debug.Console(2, this, "Adding input card '{0}', slot {1}", type, number); + + type = type.ToLower(); + + if (type == "dmchd") + { + var inputCard = new DmcHd(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmchddsp") + { + var inputCard = new DmcHdDsp(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmc4khd") + { + var inputCard = new Dmc4kHd(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmc4khddsp") + { + var inputCard = new Dmc4kHdDsp(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmc4kzhd") + { + var inputCard = new Dmc4kzHd(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmc4kzhddsp") + { + var inputCard = new Dmc4kzHdDsp(number, this.Chassis); + var cecPort = inputCard.HdmiInput as ICec; + AddHdmiInCardPorts(number, cecPort); + } + else if (type == "dmcc") + { + var inputCard = new DmcC(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmccdsp") + { + var inputCard = new DmcCDsp(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmc4kc") + { + var inputCard = new Dmc4kC(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmc4kcdsp") + { + var inputCard = new Dmc4kCDsp(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmc4kzc") + { + var inputCard = new Dmc4kzC(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmc4kzcdsp") + { + var inputCard = new Dmc4kzCDsp(number, this.Chassis); + var cecPort = inputCard.DmInput as ICec; + AddDmInCardPorts(number, cecPort); + } + else if (type == "dmccat") + { + new DmcCat(number, this.Chassis); + AddDmInCardPorts(number); + } + else if (type == "dmccatdsp") + { + new DmcCatDsp(number, this.Chassis); + AddDmInCardPorts(number); + } + else if (type == "dmcs") + { + new DmcS(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); + AddInCardHdmiAndAudioLoopPorts(number); + } + else if (type == "dmcsdsp") + { + new DmcSDsp(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber); + AddInCardHdmiAndAudioLoopPorts(number); + } + else if (type == "dmcs2") + { + new DmcS2(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); + AddInCardHdmiAndAudioLoopPorts(number); + } + else if (type == "dmcs2dsp") + { + new DmcS2Dsp(number, Chassis); + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber); + AddInCardHdmiAndAudioLoopPorts(number); + } + else if (type == "dmcsdi") + { + new DmcSdi(number, Chassis); + AddInputPortWithDebug(number, "sdiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi); + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "sdiOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Sdi, null); + AddInCardHdmiAndAudioLoopPorts(number); + } + else if (type == "dmcdvi") + { + new DmcDvi(number, Chassis); + AddInputPortWithDebug(number, "dviIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcvga") + { + new DmcVga(number, Chassis); + AddInputPortWithDebug(number, "vgaIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Vga); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcvidbnc") + { + new DmcVidBnc(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcvidrcaa") + { + new DmcVidRcaA(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcvidrcad") + { + new DmcVidRcaD(number, Chassis); + AddInputPortWithDebug(number, "componentIn", eRoutingSignalType.Video, eRoutingPortConnectionType.Component); + AddInputPortWithDebug(number, "audioIn", eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcvid4") + { + new DmcVid4(number, Chassis); + AddInputPortWithDebug(number, "compositeIn1", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn2", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn3", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInputPortWithDebug(number, "compositeIn4", eRoutingSignalType.Video, eRoutingPortConnectionType.Composite); + AddInCardHdmiLoopPort(number); + } + else if (type == "dmcstr") + { + new DmcStr(number, Chassis); + AddInputPortWithDebug(number, "streamIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming); + AddInCardHdmiAndAudioLoopPorts(number); + } + } + + void AddDmInCardPorts(uint number) + { + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat); + AddInCardHdmiAndAudioLoopPorts(number); + } + void AddDmInCardPorts(uint number, ICec cecPort) + { + AddInputPortWithDebug(number, "dmIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, cecPort); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddHdmiInCardPorts(uint number, ICec cecPort) + { + AddInputPortWithDebug(number, "hdmiIn", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, cecPort); + AddInCardHdmiAndAudioLoopPorts(number); + } + + void AddInCardHdmiAndAudioLoopPorts(uint number) + { + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null); + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "audioLoopOut", eRoutingSignalType.Audio, eRoutingPortConnectionType.Hdmi, null); + } + + void AddInCardHdmiLoopPort(uint number) + { + AddOutputPortWithDebug(string.Format("inputCard{0}", number), "hdmiLoopOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null); + } + + /// + /// + /// + /// + /// + public void AddOutputCard(string type, uint number) + { + type = type.ToLower(); + + Debug.Console(2, this, "Adding output card '{0}', slot {1}", type, number); + if (type == "dmc4khdo") + { + var outputCard = new Dmc4kHdoSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + var cecPort2 = outputCard.Card2.HdmiOutput; + AddDmcHdoPorts(number, cecPort1, cecPort2); + } + else if (type == "dmchdo") + { + var outputCard = new DmcHdoSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + var cecPort2 = outputCard.Card2.HdmiOutput; + AddDmcHdoPorts(number, cecPort1, cecPort2); + } + else if (type == "dmc4kcohd") + { + var outputCard = new Dmc4kCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + else if (type == "dmc4kzcohd") + { + var outputCard = new Dmc4kzCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + else if (type == "dmccohd") + { + var outputCard = new DmcCoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + else if (type == "dmccatohd") + { + var outputCard = new DmcCatoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddDmcCoPorts(number, cecPort1); + } + else if (type == "dmcsohd") + { + var outputCard = new DmcSoHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmMmFiber, 2 * (number - 1) + 2); + + } + else if (type == "dmcs2ohd") + { + var outputCard = new DmcS2oHdSingle(number, Chassis); + var cecPort1 = outputCard.Card1.HdmiOutput; + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmSmFiber, 2 * (number - 1) + 2); + } + else if (type == "dmcstro") + { + var outputCard = new DmcStroSingle(number, Chassis); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "streamOut", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, 2 * (number - 1) + 1); + } + + else + Debug.Console(1, this, " WARNING: Output card type '{0}' is not available", type); + } + + void AddDmcHdoPorts(uint number, ICec cecPort1, ICec cecPort2) + { + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut1", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 2, cecPort2); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "audioOut2", eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, 2 * (number - 1) + 2); + } + + void AddDmcCoPorts(uint number, ICec cecPort1) + { + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "hdmiOut1", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2 * (number - 1) + 1, cecPort1); + AddOutputPortWithDebug(string.Format("outputCard{0}", number), "dmOut2", eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, 2 * (number - 1) + 2); + } + + + /// + /// Adds InputPort + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) + { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); + + InputPorts.Add(inputPort); + } + + /// + /// Adds InputPort and sets Port as ICec object + /// + void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort) + { + var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); + Debug.Console(2, this, "Adding input port '{0}'", portKey); + var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); + + if (inputPort != null) + { + if (cecPort != null) + inputPort.Port = cecPort; + + InputPorts.Add(inputPort); + } + else + Debug.Console(2, this, "inputPort is null"); + } + + /// + /// Adds OutputPort + /// + void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) + { + var portKey = string.Format("{0}--{1}", cardName, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)); + } + + /// + /// Adds OutputPort and sets Port as ICec object + /// + void AddOutputPortWithDebug(string cardName, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) + { + var portKey = string.Format("{0}--{1}", cardName, portName); + Debug.Console(2, this, "Adding output port '{0}'", portKey); + var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); + + if (cecPort != null) + outputPort.Port = cecPort; + + OutputPorts.Add(outputPort); + } + + /// + /// + /// + void AddVolumeControl(uint number, Audio.Output audio) + { + VolumeControls.Add(number, new DmCardAudioOutputController(audio)); + } + + //public void SetInputHdcpSupport(uint input, ePdtHdcpSupport hdcpSetting) + //{ + + //} + + + void Chassis_DMSystemChange(Switch device, DMSystemEventArgs args) + { + switch (args.EventId) + { + case DMSystemEventIds.SystemIdEventId: + { + Debug.Console(2, this, "SystemIdEvent Value: {0}", (Chassis as DmMDMnxn).SystemIdFeedback.UShortValue); + SystemIdFeebdack.FireUpdate(); + break; + } + case DMSystemEventIds.SystemIdBusyEventId: + { + Debug.Console(2, this, "SystemIdBusyEvent State: {0}", (Chassis as DmMDMnxn).SystemIdBusy.BoolValue); + SystemIdBusyFeedback.FireUpdate(); + break; + } + } + } + + void Chassis_DMInputChange(Switch device, DMInputEventArgs args) + { + + switch (args.EventId) { + case DMInputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, "DM Input EndpointOnlineEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.VideoDetectedEventId: + { + Debug.Console(2, this, "DM Input {0} VideoDetectedEventId", args.Number); + VideoInputSyncFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.InputNameEventId: + { + Debug.Console(2, this, "DM Input {0} NameFeedbackEventId", args.Number); + InputNameFeedbacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.UsbRoutedToEventId: + { + Debug.Console(2, this, "DM Input {0} UsbRoutedToEventId", args.Number); + UsbInputRoutedToFeebacks[args.Number].FireUpdate(); + break; + } + case DMInputEventIds.HdcpCapabilityFeedbackEventId: + { + Debug.Console(2, this, "DM Input {0} HdcpCapabilityFeedbackEventId", args.Number); + InputCardHdcpCapabilityFeedbacks[args.Number].FireUpdate(); + break; + } + default: + { + Debug.Console(2, this, "DMInputChange fired for Input {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + } + /// + /// + void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) + { + + //This should be a switch case JTA 2018-07-02 + var output = args.Number; + + switch (args.EventId) + { + case DMOutputEventIds.VolumeEventId: + { + if (VolumeControls.ContainsKey(output)) + { + VolumeControls[args.Number].VolumeEventFromChassis(); + } + break; + } + case DMOutputEventIds.EndpointOnlineEventId: + { + Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.OnlineFeedbackEventId: + { + Debug.Console(2, this, "Output {0} DMInputEventIds.OnlineFeedbackEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.VideoOutEventId: + { + if (Chassis.Outputs[output].VideoOutFeedback != null) + { + Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].VideoOutFeedback.Number, output); + } + if (VideoOutputFeedbacks.ContainsKey(output)) + { + VideoOutputFeedbacks[output].FireUpdate(); + + } + if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) + { + OutputVideoRouteNameFeedbacks[output].FireUpdate(); + } + break; + } + case DMOutputEventIds.AudioOutEventId: + { + if (Chassis.Outputs[output].AudioOutFeedback != null) + { + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].AudioOutFeedback.Number, output); + } + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + break; + } + case DMOutputEventIds.OutputNameEventId: + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + break; + } + case DMOutputEventIds.UsbRoutedToEventId: + { + Debug.Console(2, this, "DM Output {0} UsbRoutedToEventId", args.Number); + UsbOutputRoutedToFeebacks[args.Number].FireUpdate(); + break; + } + default: + { + Debug.Console(2, this, "DMOutputChange fired for Output {0} with Unhandled EventId: {1}", args.Number, args.EventId); + break; + } + } + + } + + /// + /// + /// + /// + void StartOffTimer(PortNumberType pnt) + { + if (RouteOffTimers.ContainsKey(pnt)) + return; + RouteOffTimers[pnt] = new CTimer(o => + { + ExecuteSwitch(0, pnt.Number, pnt.Type); + }, RouteOffTime); + } + + + // Send out sigs when coming online + void IsOnline_OutputChange(object sender, EventArgs e) + { + if (IsOnline.BoolValue) + { + (Chassis as DmMDMnxn).EnableAudioBreakaway.BoolValue = true; + (Chassis as DmMDMnxn).EnableUSBBreakaway.BoolValue = true; + + if (InputNames != null) + foreach (var kvp in InputNames) + Chassis.Inputs[kvp.Key].Name.StringValue = kvp.Value; + if (OutputNames != null) + foreach(var kvp in OutputNames) + Chassis.Outputs[kvp.Key].Name.StringValue = kvp.Value; + } + } + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType sigType) + { + Debug.Console(2, this, "Making an awesome DM route from {0} to {1} {2}", inputSelector, outputSelector, sigType); + + var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail + var output = Convert.ToUInt32(outputSelector); + // Check to see if there's an off timer waiting on this and if so, cancel + var key = new PortNumberType(output, sigType); + if (input == 0) + { + StartOffTimer(key); + } + else + { + if(RouteOffTimers.ContainsKey(key)) + { + Debug.Console(2, this, "{0} cancelling route off due to new source", output); + RouteOffTimers[key].Stop(); + RouteOffTimers.Remove(key); + } + } + + var inCard = input == 0 ? null : Chassis.Inputs[input]; + var outCard = input == 0 ? null : Chassis.Outputs[output]; + + // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES + if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + { + Chassis.VideoEnter.BoolValue = true; + Chassis.Outputs[output].VideoOut = inCard; + } + + if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + (Chassis as DmMDMnxn).AudioEnter.BoolValue = true; + Chassis.Outputs[output].AudioOut = inCard; + } + + if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) + { + Chassis.USBEnter.BoolValue = true; + if (Chassis.Outputs[output] != null) + Chassis.Outputs[output].USBRoutedTo = inCard; + } + + if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) + { + Chassis.USBEnter.BoolValue = true; + if(Chassis.Inputs[input] != null) + Chassis.Inputs[input].USBRoutedTo = outCard; + } + } + + #endregion + } + + public struct PortNumberType + { + public uint Number { get; private set; } + public eRoutingSignalType Type { get; private set; } + + public PortNumberType(uint number, eRoutingSignalType type) : this() + { + Number = number; + Type = type; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs index 0eadd2a5..d3fda242 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs @@ -1,97 +1,99 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.AirMedia; -using Crestron.SimplSharpPro.UI; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; -using PepperDash.Essentials.DM.AirMedia; -using PepperDash.Essentials.DM.Endpoints.DGEs; - -namespace PepperDash.Essentials.DM -{ - public class DeviceFactory - { - public static IKeyed GetDevice(DeviceConfig dc) - { - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - - var typeName = dc.Type.ToLower(); - - if (typeName.StartsWith("am")) - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - AmX00 amDevice = null; - if (typeName == "am200") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); - else if(typeName == "am300") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); - - return new AirMediaController(key, name, amDevice, dc, props); - } - else if (typeName.StartsWith("dmmd8x") || typeName.StartsWith("dmmd16x") || typeName.StartsWith("dmmd32x")) - { - var props = JsonConvert.DeserializeObject - (properties.ToString()); - return PepperDash.Essentials.DM.DmChassisController. - GetDmChassisController(key, name, type, props); - } - // Hand off to DmTxHelper class - else if (typeName.StartsWith("dmtx")) - { - var props = JsonConvert.DeserializeObject - (properties.ToString()); - return PepperDash.Essentials.DM.DmTxHelper.GetDmTxController(key, name, type, props); - } - - // Hand off to DmRmcHelper class - else if (typeName.StartsWith("dmrmc")) - { - var props = JsonConvert.DeserializeObject - (properties.ToString()); - return PepperDash.Essentials.DM.DmRmcHelper.GetDmRmcController(key, name, type, props); - } - - else if (typeName.Equals("hdmd4x14ke")) - { - var props = JsonConvert.DeserializeObject - (properties.ToString()); - return PepperDash.Essentials.DM.Chassis.HdMdNxM4kEController.GetController(key, name, type, props); - } - - else if (typeName.Equals("hdmd400ce") || typeName.Equals("hdmd300ce") || typeName.Equals("hdmd200ce") || typeName.Equals("hdmd200c1ge")) - { - var props = JsonConvert.DeserializeObject - (properties.ToString()); - - if (typeName.Equals("hdmd400ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd400CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd300ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd300CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd200ce")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd200CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - else if (typeName.Equals("hdmd200c1ge")) - return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, - new HdMd200C1GE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); - } - - return null; - } - - - } - +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.AirMedia; +using Crestron.SimplSharpPro.UI; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.DM.AirMedia; +using PepperDash.Essentials.DM.Endpoints.DGEs; + +namespace PepperDash.Essentials.DM +{ + public class DeviceFactory + { + public static IKeyed GetDevice(DeviceConfig dc) + { + var key = dc.Key; + var name = dc.Name; + var type = dc.Type; + var properties = dc.Properties; + + var typeName = dc.Type.ToLower(); + + if (typeName.StartsWith("am")) + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + AmX00 amDevice = null; + if (typeName == "am200") + amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); + else if(typeName == "am300") + amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); + + return new AirMediaController(key, name, amDevice, dc, props); + } + else if (typeName.StartsWith("dmmd8x") || typeName.StartsWith("dmmd16x") || typeName.StartsWith("dmmd32x")) + { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + return PepperDash.Essentials.DM.DmChassisController. + GetDmChassisController(key, name, type, props); + } + else if (typeName.StartsWith("dmmd128x") || typeName.StartsWith("dmmd64x")) { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + return PepperDash.Essentials.DM.DmBladeChassisController. + GetDmChassisController(key, name, type, props); + } + // Hand off to DmTxHelper class + else if (typeName.StartsWith("dmtx")) { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + return PepperDash.Essentials.DM.DmTxHelper.GetDmTxController(key, name, type, props); + } + + // Hand off to DmRmcHelper class + else if (typeName.StartsWith("dmrmc")) { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + return PepperDash.Essentials.DM.DmRmcHelper.GetDmRmcController(key, name, type, props); + } + + else if (typeName.Equals("hdmd4x14ke")) { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + return PepperDash.Essentials.DM.Chassis.HdMdNxM4kEController.GetController(key, name, type, props); + } + + else if (typeName.Equals("hdmd400ce") || typeName.Equals("hdmd300ce") || typeName.Equals("hdmd200ce") || typeName.Equals("hdmd200c1ge")) { + var props = JsonConvert.DeserializeObject + (properties.ToString()); + + if (typeName.Equals("hdmd400ce")) + return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, + new HdMd400CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); + else if (typeName.Equals("hdmd300ce")) + return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, + new HdMd300CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); + else if (typeName.Equals("hdmd200ce")) + return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, + new HdMd200CE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); + else if (typeName.Equals("hdmd200c1ge")) + return new PepperDash.Essentials.DM.HdMdxxxCEController(key, name, + new HdMd200C1GE(props.Control.IpIdInt, props.Control.TcpSshProperties.Address, Global.ControlSystem)); + } + + return null; + } + + + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index 8df92ef1..f8ad5cf6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -1,256 +1,257 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -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.Config; - -namespace PepperDash.Essentials.DM -{ - public abstract class DmRmcControllerBase : CrestronGenericBaseDevice - { - public virtual StringFeedback VideoOutputResolutionFeedback { get; protected set; } - public virtual StringFeedback EdidManufacturerFeedback { get; protected set; } - public virtual StringFeedback EdidNameFeedback { get; protected set; } - public virtual StringFeedback EdidPreferredTimingFeedback { get; protected set; } - public virtual StringFeedback EdidSerialNumberFeedback { get; protected set; } - - public DmRmcControllerBase(string key, string name, EndpointReceiverBase device) - : base(key, name, device) - { - // if wired to a chassis, skip registration step in base class - if (device.DMOutput != null) - { - this.PreventRegistration = true; - } - AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); - } - } - - public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice - { - public HDBaseTBase Rmc { get; protected set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmHdBaseTControllerBase(string key, string name, HDBaseTBase rmc) - : base(key, name, rmc) - { - - } - } - - public class DmRmcHelper - { - /// - /// A factory method for various DmTxControllers - /// - /// - /// - /// - /// - public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) - { - // switch on type name... later... - - typeName = typeName.ToLower(); - uint ipid = props.Control.IpIdInt; // Convert.ToUInt16(props.Id, 16); - - - - // right here, we need to grab the tie line that associates this - // RMC with a chassis or processor. If the RMC input's tie line is not - // connected to a chassis, then it's parent is the processor. - // If the RMC is connected to a chassis, then we need to grab the - // output number from the tie line and use that to plug it in. - // Example of chassis-connected: - //{ - // "sourceKey": "dmMd8x8-1", - // "sourcePort": "anyOut2", - // "destinationKey": "dmRmc100C-2", - // "destinationPort": "DmIn" - //} - - // Tx -> RMC link: - //{ - // "sourceKey": "dmTx201C-1", - // "sourcePort": "DmOut", - // "destinationKey": "dmRmc100C-2", - // "destinationPort": "DmIn" - //} - - var tlc = TieLineCollection.Default; - // grab the tie line that has this key as - // THIS DOESN'T WORK BECAUSE THE RMC THAT WE NEED (THIS) HASN'T BEEN MADE - // YET AND THUS WILL NOT HAVE A TIE LINE... - var inputTieLine = tlc.FirstOrDefault(t => - { - var d = t.DestinationPort.ParentDevice; - return d.Key.Equals(key, StringComparison.OrdinalIgnoreCase) - && d is DmChassisController; - }); - - var pKey = props.ParentDeviceKey.ToLower(); - - - - - // Non-DM-chassis endpoints - if (pKey == "processor") - { - // Catch constructor failures, mainly dues to IPID - try - { - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, Global.ControlSystem)); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - } - - - Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); - } - // Endpoints attached to DM Chassis - else - { - var parentDev = DeviceManager.GetDeviceForKey(pKey); - if (!(parentDev is DmChassisController)) - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", - key, pKey); - return null; - } - - var chassis = (parentDev as DmChassisController).Chassis; - var num = props.ParentOutputNumber; - if (num <= 0 || num > chassis.NumberOfOutputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", - key, num); - return null; - } - else - { - var controller = (parentDev as DmChassisController); - controller.RxDictionary.Add(num, key); - } - // Catch constructor failures, mainly dues to IPID - try - { - - // Must use different constructor for CPU3 chassis types. No IPID - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps) - { - if (typeName.StartsWith("hdbasetrx")) - return new HDBaseTRxController(key, name, new HDRx3CB(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c1g")) - return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(chassis.Outputs[num])); - } - else - { - if (typeName.StartsWith("hdbasetrx")) - return new HDBaseTRxController(key, name, new HDRx3CB(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c1g")) - return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100c")) - return new DmRmcX100CController(key, name, new DmRmc100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc100s")) - return new DmRmc100SController(key, name, new DmRmc100S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4k100c")) - return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kz100c")) - return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc150s")) - return new DmRmc150SController(key, name, new DmRmc150S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200c")) - return new DmRmc200CController(key, name, new DmRmc200C(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s")) - return new DmRmc200SController(key, name, new DmRmc200S(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc200s2")) - return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalerc")) - return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers")) - return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmcscalers2")) - return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalerc")) - return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, chassis.Outputs[num])); - if (typeName.StartsWith("dmrmc4kscalercdsp")) - return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, chassis.Outputs[num])); - } - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - } - } - - return null; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +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.Config; + +namespace PepperDash.Essentials.DM +{ + public abstract class DmRmcControllerBase : CrestronGenericBaseDevice + { + public virtual StringFeedback VideoOutputResolutionFeedback { get; protected set; } + public virtual StringFeedback EdidManufacturerFeedback { get; protected set; } + public virtual StringFeedback EdidNameFeedback { get; protected set; } + public virtual StringFeedback EdidPreferredTimingFeedback { get; protected set; } + public virtual StringFeedback EdidSerialNumberFeedback { get; protected set; } + + public DmRmcControllerBase(string key, string name, EndpointReceiverBase device) + : base(key, name, device) + { + // if wired to a chassis, skip registration step in base class + if (device.DMOutput != null) + { + this.PreventRegistration = true; + } + AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); + } + } + + public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice + { + public HDBaseTBase Rmc { get; protected set; } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmHdBaseTControllerBase(string key, string name, HDBaseTBase rmc) + : base(key, name, rmc) + { + + } + } + + public class DmRmcHelper + { + /// + /// A factory method for various DmTxControllers + /// + /// + /// + /// + /// + public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) + { + // switch on type name... later... + + typeName = typeName.ToLower(); + uint ipid = props.Control.IpIdInt; // Convert.ToUInt16(props.Id, 16); + + + + // right here, we need to grab the tie line that associates this + // RMC with a chassis or processor. If the RMC input's tie line is not + // connected to a chassis, then it's parent is the processor. + // If the RMC is connected to a chassis, then we need to grab the + // output number from the tie line and use that to plug it in. + // Example of chassis-connected: + //{ + // "sourceKey": "dmMd8x8-1", + // "sourcePort": "anyOut2", + // "destinationKey": "dmRmc100C-2", + // "destinationPort": "DmIn" + //} + + // Tx -> RMC link: + //{ + // "sourceKey": "dmTx201C-1", + // "sourcePort": "DmOut", + // "destinationKey": "dmRmc100C-2", + // "destinationPort": "DmIn" + //} + + var tlc = TieLineCollection.Default; + // grab the tie line that has this key as + // THIS DOESN'T WORK BECAUSE THE RMC THAT WE NEED (THIS) HASN'T BEEN MADE + // YET AND THUS WILL NOT HAVE A TIE LINE... + var inputTieLine = tlc.FirstOrDefault(t => + { + var d = t.DestinationPort.ParentDevice; + return d.Key.Equals(key, StringComparison.OrdinalIgnoreCase) + && d is DmChassisController; + }); + + var pKey = props.ParentDeviceKey.ToLower(); + + + + + // Non-DM-chassis endpoints + if (pKey == "processor") + { + // Catch constructor failures, mainly dues to IPID + try + { + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, Global.ControlSystem)); + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + } + + + Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); + } + // Endpoints attached to DM Chassis + else + { + var parentDev = DeviceManager.GetDeviceForKey(pKey); + if (!(parentDev is IDmSwitch)) + { + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", + key, pKey); + return null; + } + + var chassis = (parentDev as IDmSwitch).Chassis; + var num = props.ParentOutputNumber; + if (num <= 0 || num > chassis.NumberOfOutputs) + { + Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", + key, num); + return null; + } + else + { + var controller = (parentDev as IDmSwitch); + controller.RxDictionary.Add(num, key); + } + // Catch constructor failures, mainly dues to IPID + try + { + + // Must use different constructor for CPU3 chassis types. No IPID + if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || + chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || + chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || + chassis is DmMd128x128 || chassis is DmMd64x64) + { + if (typeName.StartsWith("hdbasetrx")) + return new HDBaseTRxController(key, name, new HDRx3CB(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c1g")) + return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmcX100CController(key, name, new DmRmc4kz100C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(chassis.Outputs[num])); + } + else + { + if (typeName.StartsWith("hdbasetrx")) + return new HDBaseTRxController(key, name, new HDRx3CB(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c1g")) + return new DmRmc4k100C1GController(key, name, new DmRmc4K100C1G(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100c")) + return new DmRmcX100CController(key, name, new DmRmc100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc100s")) + return new DmRmc100SController(key, name, new DmRmc100S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4k100c")) + return new DmRmcX100CController(key, name, new DmRmc4k100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kz100c")) + return new DmRmcX100CController(key, name, new DmRmc4kz100C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc150s")) + return new DmRmc150SController(key, name, new DmRmc150S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200c")) + return new DmRmc200CController(key, name, new DmRmc200C(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s")) + return new DmRmc200SController(key, name, new DmRmc200S(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc200s2")) + return new DmRmc200S2Controller(key, name, new DmRmc200S2(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalerc")) + return new DmRmcScalerCController(key, name, new DmRmcScalerC(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers")) + return new DmRmcScalerSController(key, name, new DmRmcScalerS(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmcscalers2")) + return new DmRmcScalerS2Controller(key, name, new DmRmcScalerS2(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalerc")) + return new DmRmc4kScalerCController(key, name, new DmRmc4kScalerC(ipid, chassis.Outputs[num])); + if (typeName.StartsWith("dmrmc4kscalercdsp")) + return new DmRmc4kScalerCDspController(key, name, new DmRmc4kScalerCDsp(ipid, chassis.Outputs[num])); + } + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + } + } + + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index ec07662c..94a8d667 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -61,7 +61,7 @@ namespace PepperDash.Essentials.DM else { var parentDev = DeviceManager.GetDeviceForKey(pKey); - if (!(parentDev is DmChassisController)) + if (!(parentDev is IDmSwitch)) { Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", key, pKey); @@ -69,7 +69,7 @@ namespace PepperDash.Essentials.DM } // Get the Crestron chassis and link stuff up - var switchDev = parentDev as DmChassisController; + var switchDev = (parentDev as IDmSwitch); var chassis = switchDev.Chassis; var num = props.ParentInputNumber; @@ -80,8 +80,8 @@ namespace PepperDash.Essentials.DM return null; } else - { - var controller = (parentDev as DmChassisController); + { + var controller = (parentDev as IDmSwitch); controller.TxDictionary.Add(num, key); } @@ -91,7 +91,8 @@ namespace PepperDash.Essentials.DM // Must use different constructor for CPU3 chassis types. No IPID if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps) + chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps|| + chassis is DmMd128x128 || chassis is DmMd64x64) { if (typeName.StartsWith("dmtx200")) return new DmTx200Controller(key, name, new DmTx200C2G(chassis.Inputs[num])); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj index b66e5ab4..74f4d9b7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -95,12 +95,14 @@ + + diff --git a/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs b/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs new file mode 100644 index 00000000..fdbe4956 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +//using PepperDash.Essentials.DM.Cards; + +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM { + public interface IDmSwitch { + Switch Chassis { get; } + + Dictionary TxDictionary { get; } + Dictionary RxDictionary { get; } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs index a7df216a..95a08a40 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ [assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyProduct("Essentials_Devices_Common")] [assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyVersion("1.3.*")] \ No newline at end of file +[assembly: AssemblyVersion("1.4.*")] \ No newline at end of file From 52c387081cafa39bbd66201439554c3a616f58c8 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Mon, 18 Nov 2019 15:12:55 -0600 Subject: [PATCH 02/14] Removed some debug print statements --- .../Chassis/DmBladeChassisController.cs | 8 - .../Endpoints/Transmitters/DmTxHelpers.cs | 358 +++++++++--------- 2 files changed, 179 insertions(+), 187 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 6676e3e4..d00ba884 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -150,12 +150,10 @@ namespace PepperDash.Essentials.DM { InputCardHdcpCapabilityFeedbacks = new Dictionary(); InputCardHdcpCapabilityTypes = new Dictionary(); - CrestronConsole.PrintLine("GotHere 1"); for (uint x = 1; x <= Chassis.NumberOfOutputs; x++) { var tempX = x; if (Chassis.Outputs[tempX] != null) { - CrestronConsole.PrintLine("GotHere 2"); VideoOutputFeedbacks[tempX] = new IntFeedback(() => { if (Chassis.Outputs[tempX].VideoOutFeedback != null) { return (ushort)Chassis.Outputs[tempX].VideoOutFeedback.Number; } else { return 0; }; @@ -163,7 +161,6 @@ namespace PepperDash.Essentials.DM { OutputNameFeedbacks[tempX] = new StringFeedback(() => { if (Chassis.Outputs[tempX].NameFeedback != null) { - CrestronConsole.PrintLine("GotHere 3"); return Chassis.Outputs[tempX].NameFeedback.StringValue; } else { @@ -172,7 +169,6 @@ namespace PepperDash.Essentials.DM { }); OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => { if (Chassis.Outputs[tempX].VideoOutFeedback != null) { - CrestronConsole.PrintLine("GotHere 4"); return Chassis.Outputs[tempX].VideoOutFeedback.NameFeedback.StringValue; } else { @@ -188,19 +184,16 @@ namespace PepperDash.Essentials.DM { if (Chassis.Inputs[tempX] != null) { UsbInputRoutedToFeebacks[tempX] = new IntFeedback(() => { - CrestronConsole.PrintLine("GotHere 6"); if (Chassis.Inputs[tempX].USBRoutedToFeedback != null) { return (ushort)Chassis.Inputs[tempX].USBRoutedToFeedback.Number; } else { return 0; }; }); VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => { - CrestronConsole.PrintLine("GotHere 7"); if (Chassis.Inputs[tempX].VideoDetectedFeedback != null) return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; else return false; }); InputNameFeedbacks[tempX] = new StringFeedback(() => { - CrestronConsole.PrintLine("GotHere 8"); if (Chassis.Inputs[tempX].NameFeedback != null) { return Chassis.Inputs[tempX].NameFeedback.StringValue; } @@ -210,7 +203,6 @@ namespace PepperDash.Essentials.DM { }); InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { - CrestronConsole.PrintLine("GotHere 9"); return Chassis.Inputs[tempX].EndpointOnlineFeedback; }); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 94a8d667..f438b37b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -1,182 +1,182 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - public class DmTxHelper - { - /// - /// A factory method for various DmTxControllers - /// - /// - /// - /// - /// - public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) - { - // switch on type name... later... - - typeName = typeName.ToLower(); - //uint ipid = Convert.ToUInt16(props.Id, 16); - var ipid = props.Control.IpIdInt; - var pKey = props.ParentDeviceKey.ToLower(); - - if (pKey == "processor") - { - // Catch constructor failures, mainly dues to IPID - try - { - if(typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx201")) - return new DmTx201XController(key, name, new DmTx201S(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4k202CController(key, name, new DmTx4kz202C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, Global.ControlSystem)); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(ipid, Global.ControlSystem)); - Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); - } - } - else - { - var parentDev = DeviceManager.GetDeviceForKey(pKey); - if (!(parentDev is IDmSwitch)) - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", - key, pKey); - return null; - } - - // Get the Crestron chassis and link stuff up - var switchDev = (parentDev as IDmSwitch); - var chassis = switchDev.Chassis; - - var num = props.ParentInputNumber; - if (num <= 0 || num > chassis.NumberOfInputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range", - key, num); - return null; - } - else +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + public class DmTxHelper + { + /// + /// A factory method for various DmTxControllers + /// + /// + /// + /// + /// + public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) + { + // switch on type name... later... + + typeName = typeName.ToLower(); + //uint ipid = Convert.ToUInt16(props.Id, 16); + var ipid = props.Control.IpIdInt; + var pKey = props.ParentDeviceKey.ToLower(); + + if (pKey == "processor") + { + // Catch constructor failures, mainly dues to IPID + try + { + if(typeName.StartsWith("dmtx200")) + return new DmTx200Controller(key, name, new DmTx200C2G(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx201")) + return new DmTx201XController(key, name, new DmTx201S(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx4k202")) + return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx4kz202")) + return new DmTx4k202CController(key, name, new DmTx4kz202C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx4k302")) + return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx4kz302")) + return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, Global.ControlSystem)); + if (typeName.StartsWith("dmtx401")) + return new DmTx401CController(key, name, new DmTx401C(ipid, Global.ControlSystem)); + Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key); + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); + } + } + else + { + var parentDev = DeviceManager.GetDeviceForKey(pKey); + if (!(parentDev is IDmSwitch)) + { + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", + key, pKey); + return null; + } + + // Get the Crestron chassis and link stuff up + var switchDev = (parentDev as IDmSwitch); + var chassis = switchDev.Chassis; + + var num = props.ParentInputNumber; + if (num <= 0 || num > chassis.NumberOfInputs) + { + Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range", + key, num); + return null; + } + else { - var controller = (parentDev as IDmSwitch); - controller.TxDictionary.Add(num, key); - } - - // Catch constructor failures, mainly dues to IPID - try - { - // Must use different constructor for CPU3 chassis types. No IPID - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || + var controller = (parentDev as IDmSwitch); + controller.TxDictionary.Add(num, key); + } + + // Catch constructor failures, mainly dues to IPID + try + { + // Must use different constructor for CPU3 chassis types. No IPID + if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || + chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps|| - chassis is DmMd128x128 || chassis is DmMd64x64) - { - if (typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx201")) - return new DmTx201XController(key, name, new DmTx201C(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k100")) - return new DmTx4k100Controller(key, name, new DmTx4K100C1G(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4k202CController(key, name, new DmTx4kz202C(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(chassis.Inputs[num])); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(chassis.Inputs[num])); - } - else - { - if (typeName.StartsWith("dmtx200")) - return new DmTx200Controller(key, name, new DmTx200C2G(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx201")) - return new DmTx201XController(key, name, new DmTx201C(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k100")) - return new DmTx4k100Controller(key, name, new DmTx4K100C1G(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k202")) - return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4kz202")) - return new DmTx4k202CController(key, name, new DmTx4kz202C(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4k302")) - return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx4kz302")) - return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, chassis.Inputs[num])); - if (typeName.StartsWith("dmtx401")) - return new DmTx401CController(key, name, new DmTx401C(ipid, chassis.Inputs[num])); - } - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); - } - } - - return null; - } - } - - public abstract class BasicDmTxControllerBase : CrestronGenericBaseDevice - { - public BasicDmTxControllerBase(string key, string name, GenericBase hardware) - : base(key, name, hardware) - { - - } - } - - /// - /// - /// - public abstract class DmTxControllerBase : BasicDmTxControllerBase - { - public virtual void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } - public virtual eHdcpCapabilityType HdcpSupportCapability { get; protected set; } - public abstract StringFeedback ActiveVideoInputFeedback { get; protected set; } - public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } - - public DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) - : base(key, name, hardware) - { - // if wired to a chassis, skip registration step in base class - if (hardware.DMInput != null) - { - this.PreventRegistration = true; - } - AddToFeedbackList(ActiveVideoInputFeedback); - } - } - //public enum ePdtHdcpSupport - //{ - // HdcpOff = 0, - // Hdcp1 = 1, - // Hdcp2 = 2, - // Hdcp2_2= 3, - // Auto = 99 - //} + chassis is DmMd128x128 || chassis is DmMd64x64) + { + if (typeName.StartsWith("dmtx200")) + return new DmTx200Controller(key, name, new DmTx200C2G(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx201")) + return new DmTx201XController(key, name, new DmTx201C(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k100")) + return new DmTx4k100Controller(key, name, new DmTx4K100C1G(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k202")) + return new DmTx4k202CController(key, name, new DmTx4k202C(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4kz202")) + return new DmTx4k202CController(key, name, new DmTx4kz202C(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k302")) + return new DmTx4k302CController(key, name, new DmTx4k302C(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4kz302")) + return new DmTx4kz302CController(key, name, new DmTx4kz302C(chassis.Inputs[num])); + if (typeName.StartsWith("dmtx401")) + return new DmTx401CController(key, name, new DmTx401C(chassis.Inputs[num])); + } + else + { + if (typeName.StartsWith("dmtx200")) + return new DmTx200Controller(key, name, new DmTx200C2G(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx201")) + return new DmTx201XController(key, name, new DmTx201C(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k100")) + return new DmTx4k100Controller(key, name, new DmTx4K100C1G(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k202")) + return new DmTx4k202CController(key, name, new DmTx4k202C(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4kz202")) + return new DmTx4k202CController(key, name, new DmTx4kz202C(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4k302")) + return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx4kz302")) + return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, chassis.Inputs[num])); + if (typeName.StartsWith("dmtx401")) + return new DmTx401CController(key, name, new DmTx401C(ipid, chassis.Inputs[num])); + } + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); + } + } + + return null; + } + } + + public abstract class BasicDmTxControllerBase : CrestronGenericBaseDevice + { + public BasicDmTxControllerBase(string key, string name, GenericBase hardware) + : base(key, name, hardware) + { + + } + } + + /// + /// + /// + public abstract class DmTxControllerBase : BasicDmTxControllerBase + { + public virtual void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } + public virtual eHdcpCapabilityType HdcpSupportCapability { get; protected set; } + public abstract StringFeedback ActiveVideoInputFeedback { get; protected set; } + public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } + + public DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) + : base(key, name, hardware) + { + // if wired to a chassis, skip registration step in base class + if (hardware.DMInput != null) + { + this.PreventRegistration = true; + } + AddToFeedbackList(ActiveVideoInputFeedback); + } + } + //public enum ePdtHdcpSupport + //{ + // HdcpOff = 0, + // Hdcp1 = 1, + // Hdcp2 = 2, + // Hdcp2_2= 3, + // Auto = 99 + //} } \ No newline at end of file From dd7408dbf14eea51936a9bda2ce922dd2e37baf6 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 18 Nov 2019 14:27:11 -0700 Subject: [PATCH 03/14] Modifies SetupInputCards() to try to fix a NullReferenceException being thrown. Adds a debug statement to check if a given card in the collection can't be cast as DMInput. --- .../Chassis/DmpsRoutingController.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 8d83e7c1..c3a5f431 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -213,10 +213,10 @@ namespace PepperDash.Essentials.DM { var inputCard = card as DMInput; - Debug.Console(1, this, "Adding Input Card Number {0} Type: {1}", inputCard.Number, inputCard.CardInputOutputType.ToString()); - if (inputCard != null) { + Debug.Console(1, this, "Adding Input Card Number {0} Type: {1}", inputCard.Number, inputCard.CardInputOutputType.ToString()); + InputEndpointOnlineFeedbacks[inputCard.Number] = new BoolFeedback(() => { return inputCard.EndpointOnlineFeedback; }); if (inputCard.VideoDetectedFeedback != null) @@ -226,12 +226,13 @@ namespace PepperDash.Essentials.DM return inputCard.VideoDetectedFeedback.BoolValue; }); } + InputNameFeedbacks[inputCard.Number] = new StringFeedback(() => { if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue)) { Debug.Console(2, this, "Input Card {0} Name: {1}", inputCard.Number, inputCard.NameFeedback.StringValue); - return inputCard.NameFeedback.StringValue; + return inputCard.NameFeedback.StringValue; } else @@ -240,9 +241,13 @@ namespace PepperDash.Essentials.DM return ""; } }); - } - AddInputCard(inputCard.Number, inputCard); + AddInputCard(inputCard.Number, inputCard); + } + else + { + Debug.Console(2, this, "***********Input Card of type {0} is cannot be cast as DMInput*************", card.CardInputOutputType); + } } } From 492d8f820313bfdecba4e3e1ae8a7f413fba1149 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 18 Nov 2019 14:41:35 -0700 Subject: [PATCH 04/14] Removed reference to inputCard.NameFeedback.StringValue from debug statement --- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index c3a5f431..fbaadfa2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -237,7 +237,7 @@ namespace PepperDash.Essentials.DM } else { - Debug.Console(2, this, "Input Card {0} Name is null", inputCard.Number, inputCard.NameFeedback.StringValue); + Debug.Console(2, this, "Input Card {0} Name is null", inputCard.Number); return ""; } }); From 905c40dc0a29e817674435dcb20d3826cf2b816f Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 18 Nov 2019 14:53:12 -0700 Subject: [PATCH 05/14] Corrects issue where inputCard was being cast as wrong type --- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index fbaadfa2..3c6b7ea3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -260,7 +260,7 @@ namespace PepperDash.Essentials.DM { if (inputCard is Card.Dmps3HdmiInputWithoutAnalogAudio) { - var hdmiInputCard = inputCard as Card.Dmps3HdmiInput; + var hdmiInputCard = inputCard as Card.Dmps3HdmiInputWithoutAnalogAudio; var cecPort = hdmiInputCard.HdmiInputPort; @@ -277,8 +277,6 @@ namespace PepperDash.Essentials.DM } else if (inputCard is Card.Dmps3HdmiVgaInput) { - // TODO: Build a virtual TX device and assign the ports to it - var hdmiVgaInputCard = inputCard as Card.Dmps3HdmiVgaInput; DmpsInternalVirtualHdmiVgaInputController inputCardController = new DmpsInternalVirtualHdmiVgaInputController(Key + @@ -290,8 +288,6 @@ namespace PepperDash.Essentials.DM } else if (inputCard is Card.Dmps3HdmiVgaBncInput) { - // TODO: Build a virtual TX device and assign the ports to it - var hdmiVgaBncInputCard = inputCard as Card.Dmps3HdmiVgaBncInput; DmpsInternalVirtualHdmiVgaBncInputController inputCardController = new DmpsInternalVirtualHdmiVgaBncInputController(Key + @@ -314,8 +310,6 @@ namespace PepperDash.Essentials.DM { var airMediaInputCard = inputCard as Card.Dmps3AirMediaInput; - - AddInputPortWithDebug(number, string.Format("AirMediaIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming); } } From 6c7bc1a24e55e96ea438219d65e4ea209004b337 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 14:01:57 -0700 Subject: [PATCH 06/14] Adds ability to read input/output names from processor device properties config. Fixes issues with routing to output on DMPS3-4K-150-C --- PepperDashEssentials/ControlSystem.cs | 37 +++++++++++-------- .../Chassis/DmpsRoutingController.cs | 16 ++++---- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index c89f4948..65848f71 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -17,6 +17,8 @@ using PepperDash.Essentials.Fusion; using PepperDash.Essentials.Room.Config; using PepperDash.Essentials.Room.Cotija; +using Newtonsoft.Json; + namespace PepperDash.Essentials { public class ControlSystem : CrestronControlSystem @@ -359,21 +361,7 @@ namespace PepperDash.Essentials DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); - // Check if the processor is a DMPS model - if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) - { - Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); - var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, new DM.Config.DmpsRoutingPropertiesConfig()); - - DeviceManager.AddDevice(dmpsRoutingController); - - - } - else - { - Debug.Console(2, "************Processor is not DMPS type***************"); - } // Add global System Monitor device DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); @@ -390,7 +378,26 @@ namespace PepperDash.Essentials if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower()) Debug.Console(0, "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", - devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); + devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); + + // Check if the processor is a DMPS model + if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) + { + Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); + + var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); + + if(propertiesConfig == null) + propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); + + var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig); + + DeviceManager.AddDevice(dmpsRoutingController); + } + else + { + Debug.Console(2, "************Processor is not DMPS type***************"); + } continue; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 3c6b7ea3..10322ac6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -629,10 +629,10 @@ namespace PepperDash.Essentials.DM } DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; - Card.Dmps3OutputBase outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; - if (inCard != null) - { + //if (inCard != null) + //{ // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) { @@ -659,11 +659,11 @@ namespace PepperDash.Essentials.DM if (inCard != null && inCard.USBRoutedTo != null) inCard.USBRoutedTo = outCard; } - } - else - { - Debug.Console(1, this, "Unable to execute route from input {0} to output {1}. Input card not available", inputSelector, outputSelector); - } + //} + //else + //{ + // Debug.Console(1, this, "Unable to execute route from input {0} to output {1}. Input card not available", inputSelector, outputSelector); + //} } else From f44bde2d8374ad8a9ec360c5f31431cc5f6b5a5d Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 14:50:40 -0700 Subject: [PATCH 07/14] Corrects issue where "new" GlsOdtCCn OccSensor needed to be assigned in GlsOdtOccupancySensorController constructor for adiditional feedbacks to work correctly and not throw null ref exceptions. --- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 10 +++++----- .../Occupancy/GlsOdtOccupancySensorController.cs | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 10322ac6..b7e2565f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -629,7 +629,7 @@ namespace PepperDash.Essentials.DM } DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; - DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; //if (inCard != null) //{ @@ -638,25 +638,25 @@ namespace PepperDash.Essentials.DM { //SystemControl.VideoEnter.BoolValue = true; - if (outCard != null && outCard.VideoOut != null) + if (outCard != null) outCard.VideoOut = inCard; } if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) { - if (outCard != null && outCard.AudioOut != null) + if (outCard != null) outCard.AudioOut = inCard; } if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) { - if (outCard != null && outCard.USBRoutedTo != null) + if (outCard != null) outCard.USBRoutedTo = inCard; } if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) { - if (inCard != null && inCard.USBRoutedTo != null) + if (inCard != null) inCard.USBRoutedTo = outCard; } //} diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs index 5f468e4b..372aa232 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs @@ -30,6 +30,8 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor) : base(key, name, sensor) { + OccSensor = sensor; + AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); From 419d956a8d08752291760253ebf378a3f0481496 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 15:16:21 -0700 Subject: [PATCH 08/14] Switched to using Endpoint.IsOnline instead of EndpointOnlineFeedback for blade chassis as EndpointOnlineFeedback seems to be broken. --- .../Essentials_DM/Chassis/DmBladeChassisController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index d00ba884..7ac6c6b8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -177,8 +177,10 @@ namespace PepperDash.Essentials.DM { }); OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { - CrestronConsole.PrintLine("GotHere 5"); - return Chassis.Outputs[tempX].EndpointOnlineFeedback; + if (Chassis.Outputs[tempX].Endpoint != null) + return Chassis.Outputs[tempX].Endpoint.IsOnline; + else + return Chassis.Outputs[tempX].EndpointOnlineFeedback; }); } From 2173116664e8b2de01ceac3c6223093207ff5f3a Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 15:34:03 -0700 Subject: [PATCH 09/14] Changes to use rxDevice.IsOnline feedback for advanced receivers with blade chassis --- PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs index 9910d2ed..5c58b5db 100644 --- a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs @@ -140,7 +140,7 @@ namespace PepperDash.Essentials.Bridges { var rxKey = dmChassis.RxDictionary[ioSlot]; var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - if (dmChassis.Chassis is DmMd128x128 || dmChassis.Chassis is DmMd64x64) { + if (hdBaseTDevice != null) { dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); } else if (rxDevice != null) { From 9c0440e8f08fefc409d6f3ad99f51e2b27cf1fdf Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 16:01:59 -0700 Subject: [PATCH 10/14] Adds debug statements to compare values between Endpoint.IsOnline and EndpointOnlineFeedback --- .../Essentials_DM/Chassis/DmBladeChassisController.cs | 10 ++++++---- .../Essentials_DM/Chassis/DmChassisController.cs | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 7ac6c6b8..e816f253 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -458,9 +458,8 @@ namespace PepperDash.Essentials.DM { } /// /// - void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) { - - //This should be a switch case JTA 2018-07-02 + void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) + { var output = args.Number; switch (args.EventId) { @@ -471,7 +470,10 @@ namespace PepperDash.Essentials.DM { break; } case DMOutputEventIds.EndpointOnlineEventId: { - Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. EndpointOnlineFeedback State: {1}", args.Number, Chassis.Outputs[output].EndpointOnlineFeedback); + if(Chassis.Outputs[output].Endpoint != null) + Debug.Console(2, this, "Output {0} DMOutputEventIds.EndpointOnlineEventId fired. Endpoint.IsOnline State: {1}", args.Number, Chassis.Outputs[output].Endpoint.IsOnline); + OutputEndpointOnlineFeedbacks[output].FireUpdate(); break; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index c1bddd19..632e555a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -767,8 +767,6 @@ namespace PepperDash.Essentials.DM /// void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) { - - //This should be a switch case JTA 2018-07-02 var output = args.Number; switch (args.EventId) From db08b1fcd9261264de9403eea060101dce069ca5 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 18:02:50 -0700 Subject: [PATCH 11/14] Switches back to using EndpointOnlineFeedback for Rx online detection. Not currently working but believed to be a Crestron issue. --- .../Bridges/DmBladeChassisControllerBridge.cs | 16 ++++++++-------- .../Chassis/DmBladeChassisController.cs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs index 5c58b5db..6daddbb0 100644 --- a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs @@ -137,15 +137,15 @@ namespace PepperDash.Essentials.Bridges { } if (dmChassis.RxDictionary.ContainsKey(ioSlot)) { Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - var rxKey = dmChassis.RxDictionary[ioSlot]; - var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; - var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; - if (hdBaseTDevice != null) { + //var rxKey = dmChassis.RxDictionary[ioSlot]; + //var rxDevice = DeviceManager.GetDeviceForKey(rxKey) as DmRmcControllerBase; + //var hdBaseTDevice = DeviceManager.GetDeviceForKey(rxKey) as DmHdBaseTControllerBase; + //if (hdBaseTDevice != null) { dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - } - else if (rxDevice != null) { - rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - } + //} + //else if (rxDevice != null) { + // rxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + //} } // Feedback diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index e816f253..7d57127a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -177,9 +177,9 @@ namespace PepperDash.Essentials.DM { }); OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { - if (Chassis.Outputs[tempX].Endpoint != null) - return Chassis.Outputs[tempX].Endpoint.IsOnline; - else + //if (Chassis.Outputs[tempX].Endpoint != null) + // return Chassis.Outputs[tempX].Endpoint.IsOnline; + //else return Chassis.Outputs[tempX].EndpointOnlineFeedback; }); } From 11a01c707cfca38d717998204fa453e7f853bc06 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 19:07:19 -0700 Subject: [PATCH 12/14] Fixed issue with Output type on DMPS3-4K-150-C when assigning name. Also adds protection if config incorrectly defiines inputs or outputs that don't exist. --- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index b7e2565f..96b8b0af 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -121,10 +121,18 @@ namespace PepperDash.Essentials.DM // Set input and output names from config if (InputNames != null) foreach (var kvp in InputNames) - (Dmps.SwitcherInputs[kvp.Key] as DMInput).Name.StringValue = kvp.Value; + { + var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); + if(input != null) + input.Name.StringValue = kvp.Value; + } if (OutputNames != null) foreach (var kvp in OutputNames) - (Dmps.SwitcherOutputs[kvp.Key] as Card.Dmps3OutputBase).Name.StringValue = kvp.Value; + { + var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); + if(output != null) + output.Name.StringValue = kvp.Value; + } // Subscribe to events Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); From 89db6809865254adcea3e5f790888386bab1c720 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 19 Nov 2019 20:08:47 -0700 Subject: [PATCH 13/14] Fixed syntax issue in CustomActivate() --- .../Essentials_DM/Chassis/DmpsRoutingController.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 96b8b0af..0c4ff887 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -116,23 +116,25 @@ namespace PepperDash.Essentials.DM public override bool CustomActivate() { - - // Set input and output names from config if (InputNames != null) + { foreach (var kvp in InputNames) { var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); - if(input != null) + if (input != null) input.Name.StringValue = kvp.Value; } + } if (OutputNames != null) + { foreach (var kvp in OutputNames) { var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); - if(output != null) + if (output != null) output.Name.StringValue = kvp.Value; } + } // Subscribe to events Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); From 3b84c0e3dbf7a89f6ae94b56b5926c869b27513c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 26 Nov 2019 14:20:28 -0700 Subject: [PATCH 14/14] Adds PresetBase class and new IHasCameraPresets interface --- .../Messengers/CameraBaseMessenger.cs | 12 ++++++ .../Presets/PresetBase.cs | 39 +++++++++++++++++++ .../Cameras/IHasCameraPresets.cs | 22 +++++++++++ 3 files changed, 73 insertions(+) create mode 100644 PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs create mode 100644 essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs new file mode 100644 index 00000000..fbf1caf2 --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + public class CameraBaseMessenger + { + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs new file mode 100644 index 00000000..76ffbbc3 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Presets +{ + public class PresetBase + { + [JsonProperty("id")] + public int ID { get; set; } + /// + /// Used to store the name of the preset + /// + [JsonProperty("description")] + public string Description { get; set; } + /// + /// Indicates if the preset is defined(stored) in the codec + /// + [JsonProperty("defined")] + public bool Defined { get; set; } + /// + /// Indicates if the preset has the capability to be defined + /// + [JsonProperty("isDefinable")] + public bool IsDefinable { get; set; } + + public PresetBase(int id, string description, bool def, bool isDef) + { + ID = id; + Description = description; + Defined = def; + IsDefinable = isDef; + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs new file mode 100644 index 00000000..a8e8983d --- /dev/null +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Describes a camera with preset functionality + /// + public interface IHasCameraPresets + { + event EventHandler PresetsListHasChanged; + + List Presets { get; } + + void PresetSelect(int preset); + + void PresetStore(int preset, string description); + } +} \ No newline at end of file