From 028e411ffe041368ae7f65b8a5022b4e31ba8163 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 18 Jul 2019 16:46:01 -0600 Subject: [PATCH 1/7] Started DmpsRoutingController --- .../Chassis/DmChassisController.cs | 80 +------- .../Chassis/DmpsRoutingController.cs | 187 ++++++++++++++++++ .../Essentials_DM/Config/DmpsRoutingConfig.cs | 25 +++ .../Essentials_DM/Essentials_DM.csproj | 2 + 4 files changed, 216 insertions(+), 78 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 4e413749..ee99e6b8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -21,8 +21,8 @@ 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//, ICardPortsDevice - { + public class DmChassisController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback + { public DmMDMnxn Chassis { get; private set; } // Feedbacks for EssentialDM @@ -117,82 +117,6 @@ namespace PepperDash.Essentials.DM controller.InputNames = properties.InputNames; controller.OutputNames = properties.OutputNames; return controller; - - - //DmChassisController controller = null; - - //if (type == "dmmd8x8") - //{ - // controller = new DmChassisController(key, name, new DmMd8x8(ipid, Global.ControlSystem)); - - // // 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; - // return controller; - //} - //else if (type == "dmmd16x16") - //{ - // controller = new DmChassisController(key, name, new DmMd16x16(ipid, Global.ControlSystem)); - - // // 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; - // return controller; - //} } catch (System.Exception e) { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs new file mode 100644 index 00000000..f2870300 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -0,0 +1,187 @@ +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.Receivers; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + public class DmpsRoutingController : Device, IRoutingInputsOutputs, IRouting, IHasFeedback + { + public CrestronControlSystem Dmps { get; set; } + public ISystemControl SystemControl { 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; } + + // 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 InputNames { get; set; } + public Dictionary OutputNames { get; set; } + public Dictionary VolumeControls { get; private set; } + + public const int RouteOffTime = 500; + Dictionary RouteOffTimers = new Dictionary(); + + public static DmpsRoutingController GetDmpsRoutingController(string key, string name, + string type, DmpsRoutingPropertiesConfig properties) + { + try + { + ISystemControl systemControl = null; + + type = type.ToLower(); + + systemControl = Global.ControlSystem.SystemControl as ISystemControl; + + if (systemControl == null) + { + return null; + } + + var controller = new DmpsRoutingController(key, name, systemControl); + + controller.InputNames = properties.InputNames; + controller.OutputNames = properties.OutputNames; + + return controller; + + } + catch (System.Exception e) + { + Debug.Console(0, "Error getting DMPS Controller:\r{0}", e); + } + return null; + } + + + /// + /// + /// + /// + /// + /// + public DmpsRoutingController(string key, string name, ISystemControl systemControl) + : base(key, name) + { + Dmps = Global.ControlSystem; + + SystemControl = systemControl; + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); + VolumeControls = new Dictionary(); + TxDictionary = new Dictionary(); + RxDictionary = new Dictionary(); + + VideoOutputFeedbacks = new Dictionary(); + AudioOutputFeedbacks = new Dictionary(); + VideoInputSyncFeedbacks = new Dictionary(); + InputNameFeedbacks = new Dictionary(); + OutputNameFeedbacks = new Dictionary(); + OutputVideoRouteNameFeedbacks = new Dictionary(); + OutputAudioRouteNameFeedbacks = new Dictionary(); + InputEndpointOnlineFeedbacks = new Dictionary(); + OutputEndpointOnlineFeedbacks = new Dictionary(); + + Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); + Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange); + } + + void Dmps_DMInputChange(Switch device, DMInputEventArgs args) + { + //Debug.Console(2, this, "DMSwitch:{0} Input:{1} Event:{2}'", this.Name, args.Number, args.EventId.ToString()); + + switch (args.EventId) + { + case (DMInputEventIds.OnlineFeedbackEventId): + { + Debug.Console(2, this, "DMINput 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; + } + } + } + /// + /// + void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) + { + var output = args.Number; + if (args.EventId == DMOutputEventIds.VolumeEventId && + VolumeControls.ContainsKey(output)) + { + VolumeControls[args.Number].VolumeEventFromChassis(); + } + else if (args.EventId == DMOutputEventIds.OnlineFeedbackEventId) + { + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + } + else if (args.EventId == DMOutputEventIds.VideoOutEventId) + { + if (Dmps.SwitcherOutputs[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(); + } + } + else if (args.EventId == DMOutputEventIds.AudioOutEventId) + { + if (Dmps.SwitcherOutputsoutput].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(); + } + } + else if (args.EventId == DMOutputEventIds.OutputNameEventId) + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + } + + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs new file mode 100644 index 00000000..b57018d8 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.DM; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM.Cards; + +namespace PepperDash.Essentials.DM.Config +{ + /// + /// Represents the "properties" property of a DM device config + /// + public class DmpsRoutingPropertiesConfig + { + [JsonProperty("inputNames")] + public Dictionary InputNames { get; set; } + + [JsonProperty("outputNames")] + public Dictionary OutputNames { get; set; } + } + + +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj index 3e4283e5..99350628 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -97,7 +97,9 @@ + + From dc8d0e25d5ae1a9e8cc465dc48e6a2ec5575e6d7 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 22 Jul 2019 17:04:41 -0600 Subject: [PATCH 2/7] Adds Virtual Dm Tx Controller classes to handle Dmps inputs with mutliple connectors and auto switching. Completes DmpsRoutingController (requires testing) --- .../Routing/RoutingPort.cs | 2 +- .../DmpsInternalVirtualDmTxController.cs | 400 ++++++++++++++++++ .../Chassis/DmpsRoutingController.cs | 339 ++++++++++++++- .../Essentials DM/Essentials_DM/DmPortName.cs | 3 + .../Transmitters/DmTx401CController.cs | 6 +- .../Essentials_DM/Essentials_DM.csproj | 3 +- .../Essentials_DM/VideoStatusHelpers.cs | 20 + 7 files changed, 762 insertions(+), 11 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs index 47e47501..34e9b573 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs @@ -33,7 +33,7 @@ namespace PepperDash.Essentials.Core { Audio = 1, Video = 2, - AudioVideo = 3 + AudioVideo = 4 } public enum eRoutingPortConnectionType diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs new file mode 100644 index 00000000..767a9ebb --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs @@ -0,0 +1,400 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Cards; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.DM +{ + /// + /// + /// + public class DmpsInternalVirtualHdmiVgaInputController : Device, ITxRouting, IHasFeedback + { + public Card.Dmps3HdmiVgaInput InputCard { get; protected set; } + + public eHdcpCapabilityType HdcpSupportCapability { get; protected set; } + public StringFeedback ActiveVideoInputFeedback { get; protected set; } + + public RoutingInputPortWithVideoStatuses HdmiIn { get; protected set; } + public RoutingInputPortWithVideoStatuses VgaIn { get; protected set; } + public RoutingInputPort AudioIn { get; protected set; } + public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } + + public RoutingOutputPort VirtualDmOut { get; protected set; } + + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } + + /// + /// Returns a list containing the Outputs that we want to expose. + /// + public FeedbackCollection Feedbacks { get; private set; } + + public void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public eDmps3InputVideoSource ActualVideoInput + { + get + { + if (InputCard.VideoSourceFeedback != eDmps3InputVideoSource.Auto) + return InputCard.VideoSourceFeedback; + else // auto + { + if (InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) + return eDmps3InputVideoSource.Hdmi; + else if (InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) + return eDmps3InputVideoSource.Vga; + else + return eDmps3InputVideoSource.Bnc; + } + } + } + + public virtual RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn, + VgaIn, + AudioIn, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { VirtualDmOut }; + } + } + + public DmpsInternalVirtualHdmiVgaInputController(string key, string name, DMInput inputCard) + : base(key, name) + { + var hdmiVgaInputCard = inputCard as Card.Dmps3HdmiVgaInput; + + if(hdmiVgaInputCard != null) + { + InputCard = inputCard as Card.Dmps3HdmiVgaInput; + + HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, + eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(hdmiVgaInputCard.HdmiInputPort)); + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this, + VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort)); + AudioIn = new RoutingInputPort(DmPortName.AudioIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, + eDmps3InputAudioSource.Analog, this); + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) + return InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString(); + return ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) + return InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eDmps3InputVideoSource.Vga) + return InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString(); + return ""; + }, + VideoSyncFeedbackFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Vga + && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + } + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); + + VideoSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.VideoSourceFeedback; + }); + AudioSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.AudioSourceFeedback; + }); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => + { + if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + }); + + if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; + + VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); + + // Set Ports for CEC + HdmiIn.Port = InputCard.HdmiInputPort; + } + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + InputCard.HdmiInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + + InputCard.VgaInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + protected void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId == Crestron.SimplSharpPro.DM.DMInputEventIds.SourceSyncEventId) + { + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + protected void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + /// + /// Adds feedback(s) to the list + /// + /// + public void AddToFeedbackList(params Feedback[] newFbs) + { + foreach (var f in newFbs) + { + if (f != null) + { + if (!Feedbacks.Contains(f)) + { + Feedbacks.Add(f); + } + } + } + } + + #region ITxRouting Members + + + public virtual void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(eDmps3InputVideoSource.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } + } + + } + + #endregion + + #region IRouting Members + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + InputCard.VideoSource = (eDmps3InputVideoSource)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + InputCard.AudioSource = (eDmps3InputAudioSource)inputSelector; + } + + #endregion + } + + /// + /// + /// + public class DmpsInternalVirtualHdmiVgaBncInputController : DmpsInternalVirtualHdmiVgaInputController + { + public new Card.Dmps3HdmiVgaBncInput InputCard { get; private set; } + + public RoutingInputPortWithVideoStatuses BncIn { get; private set; } + public RoutingInputPort SpdifIn { get; private set; } + + public override RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn, + VgaIn, + BncIn, + SpdifIn, + AnyVideoInput + }; + } + } + + public DmpsInternalVirtualHdmiVgaBncInputController(string key, string name, Card.Dmps3HdmiVgaBncInput inputCard) + : base(key, name, inputCard) + { + InputCard = inputCard; + + HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, + eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort)); + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this, + VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort)); + BncIn = new RoutingInputPortWithVideoStatuses(DmPortName.BncIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Component, + eDmps3InputVideoSource.Bnc, this, VideoStatusHelper.GetBncInputStatusFuncs(InputCard.BncInputPort)); + SpdifIn = new RoutingInputPort(DmPortName.SpdifIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, + eDmps3InputAudioSource.Spdif, this); + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) + return InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString(); + return ""; + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualVideoInput == eDmps3InputVideoSource.Hdmi) + return InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eDmps3InputVideoSource.Vga) + return InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString(); + if (ActualVideoInput == eDmps3InputVideoSource.Bnc) + return InputCard.BncInputPort.VideoAttributes.GetVideoResolutionString(); + return ""; + }, + VideoSyncFeedbackFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Vga + && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Bnc + && InputCard.BncInputPort.VideoDetectedFeedback.BoolValue) + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + } + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + InputCard.BncInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + InputCard.BncInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + + // Base does remaining inputs + return base.CustomActivate(); + } + + public override void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(eDmps3InputVideoSource.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(BncIn.Selector, null, type); + break; + } + } + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index f2870300..0811ee61 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -5,6 +5,7 @@ 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; @@ -31,6 +32,8 @@ namespace PepperDash.Essentials.DM public Dictionary OutputVideoRouteNameFeedbacks { get; private set; } public Dictionary OutputAudioRouteNameFeedbacks { get; private set; } + public FeedbackCollection Feedbacks { get; private set; } + // Need a couple Lists of generic Backplane ports public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -107,6 +110,274 @@ namespace PepperDash.Essentials.DM Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange); + + // Default to EnableAudioBreakaway + SystemControl.EnableAudioBreakaway.BoolValue = true; + + for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) + { + var tempX = x; + + Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; + + if (outputCard != null) + { + VideoOutputFeedbacks[tempX] = new IntFeedback(() => { + if(outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number;} + else { return 0; }; + }); + AudioOutputFeedbacks[tempX] = new IntFeedback(() => + { + if (outputCard.AudioOutFeedback != null) { return (ushort)outputCard.AudioOutFeedback.Number; } + else { return 0; }; + }); + + OutputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (outputCard.NameFeedback.StringValue != null) + { + return outputCard.NameFeedback.StringValue; + } + else + { + return ""; + } + }); + + OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => + { + if (outputCard.VideoOutFeedback != null) + { + return outputCard.VideoOutFeedback.NameFeedback.StringValue; + } + else + { + return ""; + } + }); + OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => + { + if (outputCard.AudioOutFeedback != null) + { + return outputCard.AudioOutFeedback.NameFeedback.StringValue; + } + else + { + return ""; + + } + }); + + OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return outputCard.EndpointOnlineFeedback; }); + + AddOutputCard(tempX, outputCard); + } + } + + for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) + { + var tempX = x; + + DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; + + if (inputCard != null) + { + InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return inputCard.EndpointOnlineFeedback; }); + + VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => + { + return inputCard.VideoDetectedFeedback.BoolValue; + }); + InputNameFeedbacks[tempX] = new StringFeedback(() => + { + if (inputCard.NameFeedback.StringValue != null) + { + return inputCard.NameFeedback.StringValue; + } + else + { + return ""; + } + }); + } + } + } + + public override bool CustomActivate() + { + + if (InputNames != null) + foreach (var kvp in InputNames) + (Dmps.SwitcherInputs[kvp.Key] as DMInput).Name.StringValue = kvp.Value; + if (OutputNames != null) + foreach (var kvp in OutputNames) + (Dmps.SwitcherOutputs[kvp.Key] as Card.Dmps3OutputBase).Name.StringValue = kvp.Value; + + return base.CustomActivate(); + } + + /// + /// Builds the appropriate ports aand callst the appropreate add port method + /// + /// + /// + public void AddInputCard(uint number, DMInput inputCard) + { + if (inputCard is Card.Dmps3HdmiInputWithoutAnalogAudio) + { + var hdmiInputCard = inputCard as Card.Dmps3HdmiInput; + + var cecPort = hdmiInputCard.HdmiInputPort; + + AddInputPortWithDebug(number, string.Format("hdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); + } + else if (inputCard is Card.Dmps3HdmiInput) + { + var hdmiInputCard = inputCard as Card.Dmps3HdmiInput; + + var cecPort = hdmiInputCard.HdmiInputPort; + + AddInputPortWithDebug(number, string.Format("hdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); + AddInputPortWithDebug(number, string.Format("audioIn{1}", number), eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + } + 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 + + string.Format("-input{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaInputCard); + + DeviceManager.AddDevice(inputCardController); + + AddInputPortWithDebug(number, string.Format("input{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); + } + 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 + + string.Format("-input{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaBncInputCard); + + DeviceManager.AddDevice(inputCardController); + + AddInputPortWithDebug(number, string.Format("input{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); + + } + else if (inputCard is Card.Dmps3DmInput) + { + var hdmiInputCard = inputCard as Card.Dmps3DmInput; + + var cecPort = hdmiInputCard.DmInputPort; + + AddInputPortWithDebug(number, string.Format("dmIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, cecPort); + } + else if (inputCard is Card.Dmps3AirMediaInput) + { + var airMediaInputCard = inputCard as Card.Dmps3AirMediaInput; + + AddInputPortWithDebug(number, string.Format("airMediaIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Streaming); + } + } + + + /// + /// 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 (cecPort != null) + inputPort.Port = cecPort; + + InputPorts.Add(inputPort); + } + + /// + /// Builds the appropriate ports and calls the appropriate add port method + /// + /// + /// + public void AddOutputCard(uint number, Card.Dmps3OutputBase outputCard) + { + if (outputCard is Card.Dmps3HdmiOutput) + { + var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutput; + + var cecPort = hdmiOutputCard.HdmiOutputPort; + + AddHdmiOutputPort(number, cecPort); + } + else if (outputCard is Card.Dmps3DmOutput) + { + var dmOutputCard = outputCard as Card.Dmps3DmOutput; + + var cecPort = dmOutputCard.DmOutputPort; + + AddDmOutputPort(number); + } + } + + /// + /// Adds an HDMI output port + /// + /// + /// + void AddHdmiOutputPort(uint number, ICec cecPort) + { + AddOutputPortWithDebug(number, string.Format("hdmiOut{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, number, cecPort); + } + + /// + /// Adds a DM output port + /// + /// + void AddDmOutputPort(uint number) + { + AddOutputPortWithDebug(number, string.Format("dmOut{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, number); + } + + /// + /// Adds OutputPort + /// + void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) + { + var portKey = string.Format("outputCard{0}--{1}", cardNum, 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(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) + { + var portKey = string.Format("outputCard{0}--{1}", cardNum, 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 Dmps_DMInputChange(Switch device, DMInputEventArgs args) @@ -140,6 +411,9 @@ namespace PepperDash.Essentials.DM void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) { var output = args.Number; + + Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + if (args.EventId == DMOutputEventIds.VolumeEventId && VolumeControls.ContainsKey(output)) { @@ -151,14 +425,13 @@ namespace PepperDash.Essentials.DM } else if (args.EventId == DMOutputEventIds.VideoOutEventId) { - if (Dmps.SwitcherOutputs[output].VideoOutFeedback != null) + if (outputCard != null && outputCard.VideoOutFeedback != null) { - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].VideoOutFeedback.Number, output); + Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, outputCard.VideoOutFeedback.Number, output); } if (VideoOutputFeedbacks.ContainsKey(output)) { VideoOutputFeedbacks[output].FireUpdate(); - } if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) { @@ -167,9 +440,9 @@ namespace PepperDash.Essentials.DM } else if (args.EventId == DMOutputEventIds.AudioOutEventId) { - if (Dmps.SwitcherOutputsoutput].AudioOutFeedback != null) + if (outputCard != null && outputCard.AudioOutFeedback != null) { - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, Chassis.Outputs[output].AudioOutFeedback.Number, output); + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, outputCard.AudioOutFeedback.Number, output); } if (AudioOutputFeedbacks.ContainsKey(output)) { @@ -183,5 +456,61 @@ namespace PepperDash.Essentials.DM } } + + /// + /// + /// + /// + void StartOffTimer(PortNumberType pnt) + { + if (RouteOffTimers.ContainsKey(pnt)) + return; + RouteOffTimers[pnt] = new CTimer(o => + { + ExecuteSwitch(0, pnt.Number, pnt.Type); + }, RouteOffTime); + } + + #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); + } + } + + DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + + // NOTE THAT THESE ARE NOTS - TO CATCH THE AudioVideo TYPE + if (sigType != eRoutingSignalType.Audio) + { + SystemControl.VideoEnter.BoolValue = true; + (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).VideoOut = inCard; + } + + if (sigType != eRoutingSignalType.Video) + { + SystemControl.AudioEnter.BoolValue = true; + (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).AudioOut = inCard; + } + } + + #endregion } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs b/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs index c862f1ed..2c65b3f8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/DmPortName.cs @@ -14,10 +14,12 @@ namespace PepperDash.Essentials.DM public const string AirBoardIn = "AirBoardIn"; public const string AirMediaIn = "AirMediaIn"; public const string AnyVideoIn = "AnyVideoIn"; + public const string AudioIn = "AudioIn"; public const string AudioLoopOut = "AudioLoopOut"; public const string BalancedAudioOut = "BalancedAudioOut"; public const string BalancedAudioOut1 = "BalancedAudioOut1"; public const string BalancedAudioOut2 = "BalancedAudioOut2"; + public const string BncIn = "BncIn"; public const string CompositeIn = "CompositeIn"; public const string DisplayPortIn = "DisplayPortIn"; public const string DmIn = "DmIn"; @@ -32,6 +34,7 @@ namespace PepperDash.Essentials.DM public const string HdmiLoopOut = "HdmiLoopOut"; public const string HdmiOut = "HdmiOut"; public const string Osd = "Osd"; + public const string SpdifIn = "SpdifIn"; public const string VgaIn = "VgaIn"; } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs index eb5c10fc..50b5acb7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx401CController.cs @@ -168,11 +168,9 @@ namespace PepperDash.Essentials.DM && tx.CvbsInput.SyncDetectedFeedback.BoolValue) }; - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, null, this); + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, null, this); AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, diff --git a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj index 99350628..f266c842 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -97,9 +97,10 @@ + - + diff --git a/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs index 096b1e36..50107c37 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/VideoStatusHelpers.cs @@ -48,6 +48,26 @@ namespace PepperDash.Essentials.DM }; } + public static VideoStatusFuncsWrapper GetVgaInputStatusFuncs(VgaDviInputPort port) + { + return new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => port.VideoAttributes.HdcpActiveFeedback.BoolValue, + HdcpStateFeedbackFunc = () => port.VideoAttributes.HdcpStateFeedback.ToString(), + VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), + VideoSyncFeedbackFunc = () => port.SyncDetectedFeedback.BoolValue + }; + } + + public static VideoStatusFuncsWrapper GetBncInputStatusFuncs(Component port) + { + return new VideoStatusFuncsWrapper + { + VideoResolutionFeedbackFunc = () => port.VideoAttributes.GetVideoResolutionString(), + VideoSyncFeedbackFunc = () => port.VideoDetectedFeedback.BoolValue + }; + } + public static VideoStatusFuncsWrapper GetDmInputStatusFuncs(DMInputPort port) { return new VideoStatusFuncsWrapper From a3887510dfabb16ebd05dcb8686617109f9ebe4c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 24 Jul 2019 22:44:39 -0600 Subject: [PATCH 3/7] Additional progress after initial testing. Having issues iterating CrestronControlSystem.SwitcherInputs/Outputs collections. --- PepperDashEssentials/ControlSystem.cs | 16 +++++- .../Chassis/DmpsRoutingController.cs | 54 +++++++++++++------ .../Essentials_DM/Config/DmpsRoutingConfig.cs | 6 +++ 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 1325ea3e..795a4228 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -356,8 +356,22 @@ namespace PepperDash.Essentials public void LoadDevices() { // Build the processor wrapper class + 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")); @@ -373,7 +387,7 @@ 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()); continue; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 0811ee61..35c32fd7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -49,14 +49,12 @@ namespace PepperDash.Essentials.DM Dictionary RouteOffTimers = new Dictionary(); public static DmpsRoutingController GetDmpsRoutingController(string key, string name, - string type, DmpsRoutingPropertiesConfig properties) + DmpsRoutingPropertiesConfig properties) { try { ISystemControl systemControl = null; - - type = type.ToLower(); - + systemControl = Global.ControlSystem.SystemControl as ISystemControl; if (systemControl == null) @@ -90,8 +88,8 @@ namespace PepperDash.Essentials.DM : base(key, name) { Dmps = Global.ControlSystem; - SystemControl = systemControl; + InputPorts = new RoutingPortCollection(); OutputPorts = new RoutingPortCollection(); VolumeControls = new Dictionary(); @@ -112,13 +110,27 @@ namespace PepperDash.Essentials.DM Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange); // Default to EnableAudioBreakaway - SystemControl.EnableAudioBreakaway.BoolValue = true; + //SystemControl.EnableAudioBreakaway. = true; - for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) + Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.NumberOfSwitcherInputs); + Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.NumberOfSwitcherOutputs); + + + + uint tempX = 1; + + foreach (var card in Dmps.SwitcherOutputs) { - var tempX = x; + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); - Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; + var outputCard = card as Card.Dmps3OutputBase; + //} + + //for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) + //{ + //var tempX = x; + + //Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; if (outputCard != null) { @@ -170,15 +182,25 @@ namespace PepperDash.Essentials.DM OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return outputCard.EndpointOnlineFeedback; }); - AddOutputCard(tempX, outputCard); + AddOutputCard(tempX, outputCard); + + tempX++; } } - for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) - { - var tempX = x; + tempX = 1; - DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; + foreach (var card in Dmps.SwitcherInputs) + { + var inputCard = card as DMInput; + + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); + + //for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) + //{ + // var tempX = x; + + // DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; if (inputCard != null) { @@ -200,6 +222,8 @@ namespace PepperDash.Essentials.DM } }); } + + AddInputCard(tempX, inputCard); } } @@ -388,7 +412,7 @@ namespace PepperDash.Essentials.DM { case (DMInputEventIds.OnlineFeedbackEventId): { - Debug.Console(2, this, "DMINput OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); + Debug.Console(2, this, "DM Input OnlineFeedbackEventId for input: {0}. State: {1}", args.Number, device.Inputs[args.Number].EndpointOnlineFeedback); InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); break; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs index b57018d8..57dd4a72 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DmpsRoutingConfig.cs @@ -19,6 +19,12 @@ namespace PepperDash.Essentials.DM.Config [JsonProperty("outputNames")] public Dictionary OutputNames { get; set; } + + public DmpsRoutingPropertiesConfig() + { + InputNames = new Dictionary(); + OutputNames = new Dictionary(); + } } From 5de8b703dd17aa53e1daed5a0da1ff5f5be6b550 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 25 Jul 2019 09:54:06 -0600 Subject: [PATCH 4/7] Adds attemps to hanlde output card types. --- .../Chassis/DmpsRoutingController.cs | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 35c32fd7..3572bf80 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -115,15 +115,13 @@ namespace PepperDash.Essentials.DM Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.NumberOfSwitcherInputs); Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.NumberOfSwitcherOutputs); - - uint tempX = 1; foreach (var card in Dmps.SwitcherOutputs) { - Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType.ToString()); - var outputCard = card as Card.Dmps3OutputBase; + var outputCard = card as DMOutput; //} //for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) @@ -194,7 +192,7 @@ namespace PepperDash.Essentials.DM { var inputCard = card as DMInput; - Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); + Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType.ToString()); //for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) //{ @@ -340,7 +338,7 @@ namespace PepperDash.Essentials.DM /// /// /// - public void AddOutputCard(uint number, Card.Dmps3OutputBase outputCard) + public void AddOutputCard(uint number, DMOutput outputCard) { if (outputCard is Card.Dmps3HdmiOutput) { @@ -349,6 +347,8 @@ namespace PepperDash.Essentials.DM var cecPort = hdmiOutputCard.HdmiOutputPort; AddHdmiOutputPort(number, cecPort); + + return; } else if (outputCard is Card.Dmps3DmOutput) { @@ -357,6 +357,28 @@ namespace PepperDash.Essentials.DM var cecPort = dmOutputCard.DmOutputPort; AddDmOutputPort(number); + return; + + } + else if (outputCard is Card.Dmps3ProgramOutput) + { + // TODO: Deal with audio output + } + else if (outputCard is Card.Dmps3AuxOutput) + { + // TODO: Deal with audio output + } + else if (outputCard is Card.Dmps3CodecOutput) + { + + } + else if (outputCard is Card.Dmps3DialerOutput) + { + + } + else + { + Debug.Console(1, this, "Output Card is of a type not currently handled:", outputCard.CardInputOutputType.ToString()); } } From 1acb3a20c5c3411e276d224a8e007a837097635d Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 26 Jul 2019 16:53:52 -0600 Subject: [PATCH 5/7] Routing tested and working with EfS bridge --- PepperDashEssentials/Bridges/BridgeBase.cs | 8 +- .../Bridges/DmChassisControllerBridge.cs | 27 ++- .../Bridges/DmpsRoutingControllerBridge.cs | 132 ++++++++++++ .../PepperDashEssentials.csproj | 1 + .../Chassis/DmChassisController.cs | 1 - .../DmpsInternalVirtualDmTxController.cs | 173 +++++++++------ .../Chassis/DmpsRoutingController.cs | 199 ++++++++++++------ 7 files changed, 402 insertions(+), 139 deletions(-) create mode 100644 PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index aa3ed15f..93ea87b6 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -102,7 +102,11 @@ namespace PepperDash.Essentials.Bridges (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } - + else if (device is DmpsRoutingController) + { + (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } else if (device is DmTxControllerBase) { (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); @@ -127,7 +131,7 @@ namespace PepperDash.Essentials.Bridges { (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; - } + } else if (device is IBridge) { (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs index e0ff3c52..85558645 100644 --- a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -27,7 +28,7 @@ namespace PepperDash.Essentials.Bridges dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); // Link up outputs - for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs - 1; i++) + for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs; i++) { var ioSlot = i; @@ -39,7 +40,16 @@ namespace PepperDash.Essentials.Bridges Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); var TxKey = dmChassis.TxDictionary[ioSlot]; var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; - TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + if (dmChassis.Chassis is DmMd8x8Cpu3 || dmChassis.Chassis is DmMd8x8Cpu3rps + || dmChassis.Chassis is DmMd16x16Cpu3 || dmChassis.Chassis is DmMd16x16Cpu3rps + || dmChassis.Chassis is DmMd32x32Cpu3 || dmChassis.Chassis is DmMd32x32Cpu3rps) + { + dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + else + { + TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } // TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); // trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); // TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]); @@ -54,7 +64,16 @@ namespace PepperDash.Essentials.Bridges Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); var RxKey = dmChassis.RxDictionary[ioSlot]; var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; - RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + if (dmChassis.Chassis is DmMd8x8Cpu3 || dmChassis.Chassis is DmMd8x8Cpu3rps + || dmChassis.Chassis is DmMd16x16Cpu3 || dmChassis.Chassis is DmMd16x16Cpu3rps + || dmChassis.Chassis is DmMd32x32Cpu3 || dmChassis.Chassis is DmMd32x32Cpu3rps) + { + dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + else + { + RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } } // Feedback dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); @@ -66,8 +85,6 @@ namespace PepperDash.Essentials.Bridges dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); dmChassis.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); - // dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); - // dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); } } diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs new file mode 100644 index 00000000..637e86ae --- /dev/null +++ b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.DM; + +namespace PepperDash.Essentials.Bridges +{ + public static class DmpsRoutingControllerApiExtentions + { + public static void LinkToApi(this DmpsRoutingController dmpsRouter, BasicTriList trilist, uint joinStart, string joinMapKey) + { + var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmpsRoutingControllerJoinMap; + + if (joinMap == null) + joinMap = new DmpsRoutingControllerJoinMap(); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, dmpsRouter, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + // Link up outputs + for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherInputs; i++) + { + var ioSlot = i; + + //if (dmpsRouter.TxDictionary.ContainsKey(ioSlot)) + //{ + // Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); + // var TxKey = dmpsRouter.TxDictionary[ioSlot]; + // var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; + // //TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + // // TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + // // trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); + // // TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]); + // // trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability; + //} + //else + //{ + // // dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]); + //} + + dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + + for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherOutputs; i++) + { + var ioSlot = i; + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); + trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio))); + + //if (dmpsRouter.RxDictionary.ContainsKey(ioSlot)) + //{ + // Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); + // var RxKey = dmpsRouter.RxDictionary[ioSlot]; + // var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; + // //RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + //} + + // Feedback + dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); + dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); + dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + } + } + + + public class DmpsRoutingControllerJoinMap : JoinMapBase + { + public uint OutputVideo { get; set; } + public uint OutputAudio { get; set; } + public uint VideoSyncStatus { get; set; } + public uint InputNames { get; set; } + public uint OutputNames { get; set; } + public uint OutputCurrentVideoInputNames { get; set; } + public uint OutputCurrentAudioInputNames { get; set; } + public uint InputCurrentResolution { get; set; } + public uint InputEndpointOnline { get; set; } + public uint OutputEndpointOnline { get; set; } + //public uint HdcpSupport { get; set; } + //public uint HdcpSupportCapability { get; set; } + + + public DmpsRoutingControllerJoinMap() + {; + OutputVideo = 100; //101-299 + OutputAudio = 300; //301-499 + VideoSyncStatus = 100; //101-299 + InputNames = 100; //101-299 + OutputNames = 300; //301-499 + OutputCurrentVideoInputNames = 2000; //2001-2199 + OutputCurrentAudioInputNames = 2200; //2201-2399 + InputCurrentResolution = 2400; // 2401-2599 + InputEndpointOnline = 500; + OutputEndpointOnline = 700; + //HdcpSupport = 1000; //1001-1199 + //HdcpSupportCapability = 1200; //1201-1399 + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + OutputVideo = OutputVideo + joinOffset; + OutputAudio = OutputAudio + joinOffset; + VideoSyncStatus = VideoSyncStatus + joinOffset; + InputNames = InputNames + joinOffset; + OutputNames = OutputNames + joinOffset; + OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset; + OutputCurrentAudioInputNames = OutputCurrentAudioInputNames + joinOffset; + InputCurrentResolution = InputCurrentResolution + joinOffset; + InputEndpointOnline = InputEndpointOnline + joinOffset; + OutputEndpointOnline = OutputEndpointOnline + joinOffset; + //HdcpSupport = HdcpSupport + joinOffset; + //HdcpSupportCapability = HdcpSupportCapability + joinOffset; + } + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index ae31ff6e..bdc25538 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -121,6 +121,7 @@ + diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index ee99e6b8..4712701c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -142,7 +142,6 @@ namespace PepperDash.Essentials.DM TxDictionary = new Dictionary(); RxDictionary = new Dictionary(); IsOnline.OutputChange += new EventHandler(IsOnline_OutputChange); - //IsOnline.OutputChange += new EventHandler(this.IsOnline_OutputChange); Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); //Chassis.DMSystemChange += new DMSystemEventHandler(Chassis_DMSystemChange); Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs index 767a9ebb..7e58056d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs @@ -86,20 +86,25 @@ namespace PepperDash.Essentials.DM public DmpsInternalVirtualHdmiVgaInputController(string key, string name, DMInput inputCard) : base(key, name) { - var hdmiVgaInputCard = inputCard as Card.Dmps3HdmiVgaInput; + Feedbacks = new FeedbackCollection(); - if(hdmiVgaInputCard != null) + if (inputCard is Card.Dmps3HdmiVgaInput) { InputCard = inputCard as Card.Dmps3HdmiVgaInput; HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, - eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(hdmiVgaInputCard.HdmiInputPort)); + eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort)); VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this, VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort)); AudioIn = new RoutingInputPort(DmPortName.AudioIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, eDmps3InputAudioSource.Analog, this); + if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; + var combinedFuncs = new VideoStatusFuncsWrapper { HdcpActiveFeedbackFunc = () => @@ -125,61 +130,60 @@ namespace PepperDash.Essentials.DM (ActualVideoInput == eDmps3InputVideoSource.Hdmi && InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) || (ActualVideoInput == eDmps3InputVideoSource.Vga - && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) + && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue), + + HasVideoStatusFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Vga + && VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) }; AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, eDmps3InputVideoSource.Auto, this, combinedFuncs); + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); + + VideoSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.VideoSourceFeedback; + }); + AudioSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.AudioSourceFeedback; + }); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => + { + if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + }); + + // Set Ports for CEC + HdmiIn.Port = InputCard.HdmiInputPort; + + VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); + + //AddPostActivationAction(() => + //{ + // Link up all of these damned events to the various RoutingPorts via a helper handler + InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + + InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + //}); } - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); - - VideoSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.VideoSourceFeedback; - }); - AudioSourceNumericFeedback = new IntFeedback(() => - { - return (int)InputCard.AudioSourceFeedback; - }); - - HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => - { - if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) - return 1; - else - return 0; - }); - - if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) - HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; - - VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); - - // Set Ports for CEC - HdmiIn.Port = InputCard.HdmiInputPort; - } - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - InputCard.HdmiInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); - - InputCard.VgaInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); } /// @@ -322,6 +326,11 @@ namespace PepperDash.Essentials.DM SpdifIn = new RoutingInputPort(DmPortName.SpdifIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, eDmps3InputAudioSource.Spdif, this); + if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport) + HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport; + var combinedFuncs = new VideoStatusFuncsWrapper { HdcpActiveFeedbackFunc = () => @@ -351,21 +360,63 @@ namespace PepperDash.Essentials.DM || (ActualVideoInput == eDmps3InputVideoSource.Vga && InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) || (ActualVideoInput == eDmps3InputVideoSource.Bnc - && InputCard.BncInputPort.VideoDetectedFeedback.BoolValue) + && InputCard.BncInputPort.VideoDetectedFeedback.BoolValue), + + HasVideoStatusFunc = () => + (ActualVideoInput == eDmps3InputVideoSource.Hdmi + && HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Vga + && VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) + || (ActualVideoInput == eDmps3InputVideoSource.Bnc + &&BncIn.VideoStatus.HasVideoStatusFeedback.BoolValue) }; AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - } - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - InputCard.BncInputPort.Card.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); - InputCard.BncInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString()); + + VideoSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.VideoSourceFeedback; + }); + AudioSourceNumericFeedback = new IntFeedback(() => + { + return (int)InputCard.AudioSourceFeedback; + }); + + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => + { + if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue) + return 1; + else + return 0; + }); + + // Set Ports for CEC + HdmiIn.Port = InputCard.HdmiInputPort; + + VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback); + + //AddPostActivationAction(() => + //{ + // Link up all of these damned events to the various RoutingPorts via a helper handler + InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + InputCard.HdmiInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + + InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + InputCard.VgaInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + + InputCard.BncInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId); + InputCard.BncInputPort.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId); + //}); - // Base does remaining inputs - return base.CustomActivate(); } public override void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 3572bf80..eaa2d422 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -106,43 +106,73 @@ namespace PepperDash.Essentials.DM InputEndpointOnlineFeedbacks = new Dictionary(); OutputEndpointOnlineFeedbacks = new Dictionary(); - Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); - Dmps.DMOutputChange +=new DMOutputEventHandler(Dmps_DMOutputChange); // Default to EnableAudioBreakaway - //SystemControl.EnableAudioBreakaway. = true; + //if (SystemControl.EnableAudioBreakawayFeedback != null && !SystemControl.EnableAudioBreakawayFeedback.BoolValue) + //{ + // Debug.Console(1, this, "Enabling Audio Breakaway"); + // SystemControl.EnableAudioBreakaway.BoolValue = true; + //} + //if(!SystemControl.VideoEnter.BoolValue) + // SystemControl.VideoEnter.BoolValue = true; + //if(!SystemControl.AudioEnter.BoolValue) + // SystemControl.AudioEnter.BoolValue = true; - Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.NumberOfSwitcherInputs); - Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.NumberOfSwitcherOutputs); + Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.SwitcherInputs.Count); + Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.SwitcherOutputs.Count); - uint tempX = 1; + SetupOutputCards(); + SetupInputCards(); + } + + public override bool CustomActivate() + { + + + // 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; + if (OutputNames != null) + foreach (var kvp in OutputNames) + (Dmps.SwitcherOutputs[kvp.Key] as Card.Dmps3OutputBase).Name.StringValue = kvp.Value; + + // Subscribe to events + Dmps.DMInputChange += new DMInputEventHandler(Dmps_DMInputChange); + Dmps.DMOutputChange += new DMOutputEventHandler(Dmps_DMOutputChange); + + return base.CustomActivate(); + } + + + + /// + /// Iterate the SwitcherOutputs collection to setup feedbacks and add routing ports + /// + void SetupOutputCards() + { foreach (var card in Dmps.SwitcherOutputs) { - Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType.ToString()); var outputCard = card as DMOutput; - //} - //for (uint x = 1; x <= Dmps.NumberOfSwitcherOutputs; x++) - //{ - //var tempX = x; + Debug.Console(1, this, "Adding Output Card Number {0} Type: {1}", outputCard.Number, outputCard.CardInputOutputType.ToString()); - //Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[tempX] as Card.Dmps3OutputBase; - - if (outputCard != null) - { - VideoOutputFeedbacks[tempX] = new IntFeedback(() => { - if(outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number;} + if (outputCard != null) + { + VideoOutputFeedbacks[outputCard.Number] = new IntFeedback(() => + { + if (outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number; } else { return 0; }; }); - AudioOutputFeedbacks[tempX] = new IntFeedback(() => + AudioOutputFeedbacks[outputCard.Number] = new IntFeedback(() => { if (outputCard.AudioOutFeedback != null) { return (ushort)outputCard.AudioOutFeedback.Number; } else { return 0; }; }); - OutputNameFeedbacks[tempX] = new StringFeedback(() => + OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => { if (outputCard.NameFeedback.StringValue != null) { @@ -152,9 +182,9 @@ namespace PepperDash.Essentials.DM { return ""; } - }); + }); - OutputVideoRouteNameFeedbacks[tempX] = new StringFeedback(() => + OutputVideoRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => { if (outputCard.VideoOutFeedback != null) { @@ -165,7 +195,7 @@ namespace PepperDash.Essentials.DM return ""; } }); - OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() => + OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => { if (outputCard.AudioOutFeedback != null) { @@ -178,37 +208,33 @@ namespace PepperDash.Essentials.DM } }); - OutputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return outputCard.EndpointOnlineFeedback; }); + OutputEndpointOnlineFeedbacks[outputCard.Number] = new BoolFeedback(() => { return outputCard.EndpointOnlineFeedback; }); - AddOutputCard(tempX, outputCard); - - tempX++; + AddOutputCard(outputCard.Number, outputCard); } } + } - tempX = 1; - + /// + /// Iterate the SwitcherInputs collection to setup feedbacks and add routing ports + /// + void SetupInputCards() + { foreach (var card in Dmps.SwitcherInputs) { var inputCard = card as DMInput; - Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType.ToString()); - - //for (uint x = 1; x <= Dmps.NumberOfSwitcherInputs; x++) - //{ - // var tempX = x; - - // DMInput inputCard = Dmps.SwitcherInputs[tempX] as DMInput; + Debug.Console(1, this, "Adding Input Card Number {0} Type: {1}", inputCard.Number, inputCard.CardInputOutputType.ToString()); if (inputCard != null) { - InputEndpointOnlineFeedbacks[tempX] = new BoolFeedback(() => { return inputCard.EndpointOnlineFeedback; }); + InputEndpointOnlineFeedbacks[inputCard.Number] = new BoolFeedback(() => { return inputCard.EndpointOnlineFeedback; }); - VideoInputSyncFeedbacks[tempX] = new BoolFeedback(() => + VideoInputSyncFeedbacks[inputCard.Number] = new BoolFeedback(() => { return inputCard.VideoDetectedFeedback.BoolValue; }); - InputNameFeedbacks[tempX] = new StringFeedback(() => + InputNameFeedbacks[inputCard.Number] = new StringFeedback(() => { if (inputCard.NameFeedback.StringValue != null) { @@ -221,23 +247,10 @@ namespace PepperDash.Essentials.DM }); } - AddInputCard(tempX, inputCard); + AddInputCard(inputCard.Number, inputCard); } } - public override bool CustomActivate() - { - - if (InputNames != null) - foreach (var kvp in InputNames) - (Dmps.SwitcherInputs[kvp.Key] as DMInput).Name.StringValue = kvp.Value; - if (OutputNames != null) - foreach (var kvp in OutputNames) - (Dmps.SwitcherOutputs[kvp.Key] as Card.Dmps3OutputBase).Name.StringValue = kvp.Value; - - return base.CustomActivate(); - } - /// /// Builds the appropriate ports aand callst the appropreate add port method /// @@ -251,7 +264,7 @@ namespace PepperDash.Essentials.DM var cecPort = hdmiInputCard.HdmiInputPort; - AddInputPortWithDebug(number, string.Format("hdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); + AddInputPortWithDebug(number, string.Format("HdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); } else if (inputCard is Card.Dmps3HdmiInput) { @@ -259,8 +272,8 @@ namespace PepperDash.Essentials.DM var cecPort = hdmiInputCard.HdmiInputPort; - AddInputPortWithDebug(number, string.Format("hdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); - AddInputPortWithDebug(number, string.Format("audioIn{1}", number), eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); + AddInputPortWithDebug(number, string.Format("HdmiIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, cecPort); + AddInputPortWithDebug(number, string.Format("HudioIn{1}", number), eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio); } else if (inputCard is Card.Dmps3HdmiVgaInput) { @@ -269,11 +282,11 @@ namespace PepperDash.Essentials.DM var hdmiVgaInputCard = inputCard as Card.Dmps3HdmiVgaInput; DmpsInternalVirtualHdmiVgaInputController inputCardController = new DmpsInternalVirtualHdmiVgaInputController(Key + - string.Format("-input{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaInputCard); + string.Format("-HdmiVgaIn{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaInputCard); DeviceManager.AddDevice(inputCardController); - AddInputPortWithDebug(number, string.Format("input{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); + AddInputPortWithDebug(number, string.Format("HdmiVgaIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); } else if (inputCard is Card.Dmps3HdmiVgaBncInput) { @@ -282,11 +295,11 @@ namespace PepperDash.Essentials.DM var hdmiVgaBncInputCard = inputCard as Card.Dmps3HdmiVgaBncInput; DmpsInternalVirtualHdmiVgaBncInputController inputCardController = new DmpsInternalVirtualHdmiVgaBncInputController(Key + - string.Format("-input{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaBncInputCard); + string.Format("-HdmiVgaBncIn{0}", number), string.Format("InternalInputController-{0}", number), hdmiVgaBncInputCard); DeviceManager.AddDevice(inputCardController); - AddInputPortWithDebug(number, string.Format("input{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); + AddInputPortWithDebug(number, string.Format("HdmiVgaBncIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.BackplaneOnly); } else if (inputCard is Card.Dmps3DmInput) @@ -295,13 +308,13 @@ namespace PepperDash.Essentials.DM var cecPort = hdmiInputCard.DmInputPort; - AddInputPortWithDebug(number, string.Format("dmIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, cecPort); + AddInputPortWithDebug(number, string.Format("DmIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, cecPort); } else if (inputCard is Card.Dmps3AirMediaInput) { var airMediaInputCard = inputCard as Card.Dmps3AirMediaInput; - AddInputPortWithDebug(number, string.Format("airMediaIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Streaming); + AddInputPortWithDebug(number, string.Format("AirMediaIn{0}", number), eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Streaming); } } @@ -358,23 +371,57 @@ namespace PepperDash.Essentials.DM AddDmOutputPort(number); return; - } else if (outputCard is Card.Dmps3ProgramOutput) { - // TODO: Deal with audio output + AddAudioOnlyOutputPort(number, "Program"); + return; } else if (outputCard is Card.Dmps3AuxOutput) { - // TODO: Deal with audio output + if(outputCard.CardInputOutputType == eCardInputOutputType.Dmps3Aux1Output) + AddAudioOnlyOutputPort(number, "Aux1"); + else if(outputCard.CardInputOutputType == eCardInputOutputType.Dmps3Aux2Output) + AddAudioOnlyOutputPort(number, "Aux2"); + return; } else if (outputCard is Card.Dmps3CodecOutput) { - + if (number == (uint)CrestronControlSystem.eDmps300cOutputs.Codec1 + || number == (uint)CrestronControlSystem.eDmps3200cOutputs.Codec1 + || number == (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec1 + || number == (uint)CrestronControlSystem.eDmps34K250COutputs.Codec1 + || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Codec1) + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec1.ToString()); + else if (number == (uint)CrestronControlSystem.eDmps300cOutputs.Codec2 + || number == (uint)CrestronControlSystem.eDmps3200cOutputs.Codec2 + || number == (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec2 + || number == (uint)CrestronControlSystem.eDmps34K250COutputs.Codec2 + || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Codec2) + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec2.ToString()); + return; } else if (outputCard is Card.Dmps3DialerOutput) { - + AddAudioOnlyOutputPort(number, "Dialer"); + return; + } + else if (outputCard is Card.Dmps3DigitalMixOutput) + { + if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix1 + || number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix1 + || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix1) + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix1.ToString()); + if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix2 + || number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix2 + || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix2) + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString()); + return; + } + else if (outputCard is Card.Dmps3AecOutput) + { + AddAudioOnlyOutputPort(number, "Aec"); + return; } else { @@ -382,6 +429,15 @@ namespace PepperDash.Essentials.DM } } + /// + /// Adds an Audio only output port + /// + /// + void AddAudioOnlyOutputPort(uint number, string portName) + { + AddOutputPortWithDebug(number, portName, eRoutingSignalType.Audio, eRoutingPortConnectionType.LineAudio, number); + } + /// /// Adds an HDMI output port /// @@ -456,9 +512,11 @@ namespace PepperDash.Essentials.DM /// void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) { + Debug.Console(2, this, "DMOutputChange Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); + var output = args.Number; - Card.Dmps3OutputBase outputCard = Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + DMOutput outputCard = Dmps.SwitcherOutputs[output] as DMOutput; if (args.EventId == DMOutputEventIds.VolumeEventId && VolumeControls.ContainsKey(output)) @@ -543,18 +601,19 @@ namespace PepperDash.Essentials.DM DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + // NOTE THAT THESE ARE NOTS - TO CATCH THE AudioVideo TYPE if (sigType != eRoutingSignalType.Audio) { - SystemControl.VideoEnter.BoolValue = true; + //SystemControl.VideoEnter.BoolValue = true; (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).VideoOut = inCard; } if (sigType != eRoutingSignalType.Video) { - SystemControl.AudioEnter.BoolValue = true; + //SystemControl.AudioEnter.BoolValue = true; (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).AudioOut = inCard; - } + } } #endregion From bdf3e2054f9649f4fe48f2c64bb35b7c64abb881 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 29 Jul 2019 16:32:39 -0600 Subject: [PATCH 6/7] Efforts to debug exceptions thrown on bridge string sigs 101-108 and 301-308 --- PepperDashEssentials/Bridges/BridgeBase.cs | 27 ++-- .../Bridges/DmpsRoutingControllerBridge.cs | 33 ++-- .../Chassis/DmChassisController.cs | 4 +- .../Chassis/DmpsRoutingController.cs | 143 +++++++++++------- 4 files changed, 131 insertions(+), 76 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 93ea87b6..432d87e9 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -221,16 +221,23 @@ namespace PepperDash.Essentials.Bridges /// void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) { - if (Debug.Level >= 1) - Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); + try + { + if (Debug.Level >= 1) + Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } + catch (Exception e) + { + Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); + } } } diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs index 637e86ae..0d6540a0 100644 --- a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs @@ -27,6 +27,8 @@ namespace PepperDash.Essentials.Bridges // Link up outputs for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherInputs; i++) { + Debug.Console(2, dmpsRouter, "Linking Input Card {0}", i); + var ioSlot = i; //if (dmpsRouter.TxDictionary.ContainsKey(ioSlot)) @@ -44,15 +46,22 @@ namespace PepperDash.Essentials.Bridges //{ // // dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]); //} + + if(dmpsRouter.VideoInputSyncFeedbacks[ioSlot] != null) + dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); - dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + //if(dmpsRouter.InputNameFeedbacks[ioSlot] != null) + // dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); - dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); - dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + + if(dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot] != null) + dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); } for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherOutputs; i++) { + Debug.Console(2, dmpsRouter, "Linking Output Card {0}", i); + var ioSlot = i; // Control trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); @@ -67,12 +76,18 @@ namespace PepperDash.Essentials.Bridges //} // Feedback - dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); - dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); - dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); - dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); - dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); - dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); + if(dmpsRouter.VideoOutputFeedbacks[ioSlot] != null) + dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); + if (dmpsRouter.AudioOutputFeedbacks[ioSlot] != null) + dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); + //if (dmpsRouter.OutputNameFeedbacks[ioSlot] != null) + // dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + if (dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot] != null) + dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); + if (dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot] != null) + dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); + if (dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot] != null) + dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 4712701c..7d6d3444 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -172,7 +172,7 @@ namespace PepperDash.Essentials.DM return Chassis.Inputs[tempX].VideoDetectedFeedback.BoolValue; }); InputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Inputs[tempX].NameFeedback.StringValue != null) + if (Chassis.Inputs[tempX].NameFeedback != null) { return Chassis.Inputs[tempX].NameFeedback.StringValue; } @@ -182,7 +182,7 @@ namespace PepperDash.Essentials.DM } }); OutputNameFeedbacks[tempX] = new StringFeedback(() => { - if (Chassis.Outputs[tempX].NameFeedback.StringValue != null) + if (Chassis.Outputs[tempX].NameFeedback != null) { return Chassis.Outputs[tempX].NameFeedback.StringValue; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index eaa2d422..72bb92ac 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -106,18 +106,6 @@ namespace PepperDash.Essentials.DM InputEndpointOnlineFeedbacks = new Dictionary(); OutputEndpointOnlineFeedbacks = new Dictionary(); - - // Default to EnableAudioBreakaway - //if (SystemControl.EnableAudioBreakawayFeedback != null && !SystemControl.EnableAudioBreakawayFeedback.BoolValue) - //{ - // Debug.Console(1, this, "Enabling Audio Breakaway"); - // SystemControl.EnableAudioBreakaway.BoolValue = true; - //} - //if(!SystemControl.VideoEnter.BoolValue) - // SystemControl.VideoEnter.BoolValue = true; - //if(!SystemControl.AudioEnter.BoolValue) - // SystemControl.AudioEnter.BoolValue = true; - Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.SwitcherInputs.Count); Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.SwitcherOutputs.Count); @@ -174,8 +162,9 @@ namespace PepperDash.Essentials.DM OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.NameFeedback.StringValue != null) + if (outputCard.NameFeedback != null) { + Debug.Console(2, this, "Output Card {0} Name: {1}", outputCard.Number, outputCard.NameFeedback.StringValue); return outputCard.NameFeedback.StringValue; } else @@ -186,7 +175,7 @@ namespace PepperDash.Essentials.DM OutputVideoRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.VideoOutFeedback != null) + if (outputCard.VideoOutFeedback != null && outputCard.VideoOutFeedback.NameFeedback != null) { return outputCard.VideoOutFeedback.NameFeedback.StringValue; } @@ -197,7 +186,7 @@ namespace PepperDash.Essentials.DM }); OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.AudioOutFeedback != null) + if (outputCard.AudioOutFeedback != null && outputCard.AudioOutFeedback.NameFeedback != null) { return outputCard.AudioOutFeedback.NameFeedback.StringValue; } @@ -230,18 +219,24 @@ namespace PepperDash.Essentials.DM { InputEndpointOnlineFeedbacks[inputCard.Number] = new BoolFeedback(() => { return inputCard.EndpointOnlineFeedback; }); - VideoInputSyncFeedbacks[inputCard.Number] = new BoolFeedback(() => + if (inputCard.VideoDetectedFeedback != null) { - return inputCard.VideoDetectedFeedback.BoolValue; - }); + VideoInputSyncFeedbacks[inputCard.Number] = new BoolFeedback(() => + { + return inputCard.VideoDetectedFeedback.BoolValue; + }); + } InputNameFeedbacks[inputCard.Number] = new StringFeedback(() => { - if (inputCard.NameFeedback.StringValue != null) + if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue)) { - return inputCard.NameFeedback.StringValue; + Debug.Console(2, this, "Input Card {0} Name: {1}", inputCard.Number, inputCard.NameFeedback.StringValue); + return inputCard.NameFeedback.StringValue; + } else { + Debug.Console(2, this, "Input Card {0} Name is null", inputCard.Number, inputCard.NameFeedback.StringValue); return ""; } }); @@ -482,6 +477,14 @@ namespace PepperDash.Essentials.DM OutputPorts.Add(outputPort); } + /// + /// + /// + void AddVolumeControl(uint number, Audio.Output audio) + { + VolumeControls.Add(number, new DmCardAudioOutputController(audio)); + } + void Dmps_DMInputChange(Switch device, DMInputEventArgs args) { //Debug.Console(2, this, "DMSwitch:{0} Input:{1} Event:{2}'", this.Name, args.Number, args.EventId.ToString()); @@ -523,7 +526,8 @@ namespace PepperDash.Essentials.DM { VolumeControls[args.Number].VolumeEventFromChassis(); } - else if (args.EventId == DMOutputEventIds.OnlineFeedbackEventId) + else if (args.EventId == DMOutputEventIds.OnlineFeedbackEventId + && OutputEndpointOnlineFeedbacks.ContainsKey(output)) { OutputEndpointOnlineFeedbacks[output].FireUpdate(); } @@ -553,11 +557,12 @@ namespace PepperDash.Essentials.DM AudioOutputFeedbacks[output].FireUpdate(); } } - else if (args.EventId == DMOutputEventIds.OutputNameEventId) - { - Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - OutputNameFeedbacks[output].FireUpdate(); - } + //else if (args.EventId == DMOutputEventIds.OutputNameEventId + // && OutputNameFeedbacks.ContainsKey(output)) + //{ + // Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + // OutputNameFeedbacks[output].FireUpdate(); + //} } @@ -579,41 +584,69 @@ namespace PepperDash.Essentials.DM 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); + try + { - 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, "Attempting a DM route from input {0} to output {1} {2}", inputSelector, outputSelector, sigType); + + var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail + var output = Convert.ToUInt32(outputSelector); + + if (input <= Dmps.NumberOfSwitcherInputs && output <= Dmps.NumberOfSwitcherOutputs) { - Debug.Console(2, this, "{0} cancelling route off due to new source", output); - RouteOffTimers[key].Stop(); - RouteOffTimers.Remove(key); + // 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 (key.Number > 0) + { + if (RouteOffTimers.ContainsKey(key)) + { + Debug.Console(2, this, "{0} cancelling route off due to new source", output); + RouteOffTimers[key].Stop(); + RouteOffTimers.Remove(key); + } + } + + DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + + + if (inCard != null) + { + // NOTE THAT THESE ARE NOTS - TO CATCH THE AudioVideo TYPE + if (sigType != eRoutingSignalType.Audio) + { + var outputCard = Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + + //SystemControl.VideoEnter.BoolValue = true; + if (outputCard != null && outputCard.VideoOut != null) + outputCard.VideoOut = inCard; + } + + if (sigType != eRoutingSignalType.Video) + { + var outputCard = Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase; + if (outputCard != null && outputCard.AudioOut != null) + outputCard.AudioOut = inCard; + } + } + 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}", inputSelector, outputSelector); } } - - DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; - - - // NOTE THAT THESE ARE NOTS - TO CATCH THE AudioVideo TYPE - if (sigType != eRoutingSignalType.Audio) + catch (Exception e) { - //SystemControl.VideoEnter.BoolValue = true; - (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).VideoOut = inCard; + Debug.Console(1, this, "Error executing switch: {0}", e); } - - if (sigType != eRoutingSignalType.Video) - { - //SystemControl.AudioEnter.BoolValue = true; - (Dmps.SwitcherOutputs[output] as Card.Dmps3OutputBase).AudioOut = inCard; - } } #endregion From 59b2995a1bba600a154cfa6954194457f00a1da0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 30 Jul 2019 14:19:01 -0600 Subject: [PATCH 7/7] Fixes exceptions in Eisc_SigChange by checking uo for null first. Then fixes issue where if output card is Card.Dmps3CodecOutput the NameFeedback property throws a null ref exception, even if you first check it for null. --- PepperDashEssentials/Bridges/BridgeBase.cs | 17 +++--- .../Bridges/DmpsRoutingControllerBridge.cs | 52 +++++++++++++++---- .../Chassis/DmpsRoutingController.cs | 14 ++--- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 432d87e9..68ca0751 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -226,13 +226,16 @@ namespace PepperDash.Essentials.Bridges if (Debug.Level >= 1) Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); var uo = args.Sig.UserObject; - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); + if (uo != null) + { + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } } catch (Exception e) { diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs index 0d6540a0..1f61b1b6 100644 --- a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -50,8 +51,20 @@ namespace PepperDash.Essentials.Bridges if(dmpsRouter.VideoInputSyncFeedbacks[ioSlot] != null) dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); - //if(dmpsRouter.InputNameFeedbacks[ioSlot] != null) - // dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + if (dmpsRouter.InputNameFeedbacks[ioSlot] != null) + dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); + + trilist.SetStringSigAction(joinMap.InputNames + ioSlot, new Action(s => + { + var inputCard = dmpsRouter.Dmps.SwitcherInputs[ioSlot] as DMInput; + + if (inputCard != null) + { + if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) && inputCard.NameFeedback.StringValue != s) + if(inputCard.Name != null) + inputCard.Name.StringValue = s; + } + })); if(dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot] != null) @@ -67,21 +80,38 @@ namespace PepperDash.Essentials.Bridges trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio))); - //if (dmpsRouter.RxDictionary.ContainsKey(ioSlot)) - //{ - // Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot); - // var RxKey = dmpsRouter.RxDictionary[ioSlot]; - // var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase; - // //RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); - //} + trilist.SetStringSigAction(joinMap.OutputNames + ioSlot, new Action(s => + { + var outputCard = dmpsRouter.Dmps.SwitcherOutputs[ioSlot] as DMOutput; + + //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); + + if (outputCard != null) + { + //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); + + if (!(outputCard is Crestron.SimplSharpPro.DM.Cards.Card.Dmps3CodecOutput) && outputCard.NameFeedback != null) + { + if (!string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) + { + //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); + + if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) + { + outputCard.Name.StringValue = s; + } + } + } + } + })); // Feedback if(dmpsRouter.VideoOutputFeedbacks[ioSlot] != null) dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); if (dmpsRouter.AudioOutputFeedbacks[ioSlot] != null) dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); - //if (dmpsRouter.OutputNameFeedbacks[ioSlot] != null) - // dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); + if (dmpsRouter.OutputNameFeedbacks[ioSlot] != null) + dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); if (dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot] != null) dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); if (dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot] != null) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 72bb92ac..c02d48b9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -162,7 +162,7 @@ namespace PepperDash.Essentials.DM OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => { - if (outputCard.NameFeedback != null) + if (outputCard.NameFeedback != null && !string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) { Debug.Console(2, this, "Output Card {0} Name: {1}", outputCard.Number, outputCard.NameFeedback.StringValue); return outputCard.NameFeedback.StringValue; @@ -557,12 +557,12 @@ namespace PepperDash.Essentials.DM AudioOutputFeedbacks[output].FireUpdate(); } } - //else if (args.EventId == DMOutputEventIds.OutputNameEventId - // && OutputNameFeedbacks.ContainsKey(output)) - //{ - // Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); - // OutputNameFeedbacks[output].FireUpdate(); - //} + else if (args.EventId == DMOutputEventIds.OutputNameEventId + && OutputNameFeedbacks.ContainsKey(output)) + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + } }