diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 89e463ec..003b1f66 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -45,7 +45,6 @@ jobs: - name: Update AssemblyInfo.cs shell: powershell run: | - Write-Output ${{ env.VERSION }} ./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }} - name: restore Nuget Packages run: nuget install .\packages.config -OutputDirectory .\packages -ExcludeVersion diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 72720299..f1a6a278 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,12 +31,11 @@ jobs: shell: powershell env: TAG_NAME: ${{ github.event.release.tag_name }} - run: echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + run: echo "VERSION=$($Env:TAG_NAME)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append # Use the version number to set the version of the assemblies - name: Update AssemblyInfo.cs shell: powershell run: | - Write-Output ${{ env.VERSION }} ./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }} - name: restore Nuget Packages run: nuget install .\packages.config -OutputDirectory .\packages -ExcludeVersion diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 4a439d19..34d1cd60 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -18,14 +18,14 @@ using PepperDash.Essentials.DM.Config; using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.DM -{ +{ public class DmpsRoutingController : EssentialsBridgeableDevice, IRoutingNumericWithFeedback, IHasFeedback { public CrestronControlSystem Dmps { get; set; } - public ISystemControl SystemControl { get; private set; } - - //IroutingNumericEvent - public event EventHandler NumericSwitchChange; + public ISystemControl SystemControl { get; private set; } + + //IroutingNumericEvent + public event EventHandler NumericSwitchChange; // Feedbacks for EssentialDM public Dictionary VideoOutputFeedbacks { get; private set; } @@ -57,16 +57,16 @@ namespace PepperDash.Essentials.DM /// /// Text that represents when an output has no source routed to it /// - public string NoRouteText = ""; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); + public string NoRouteText = ""; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); } @@ -133,8 +133,8 @@ namespace PepperDash.Essentials.DM OutputEndpointOnlineFeedbacks = new Dictionary(); Debug.Console(1, this, "{0} Switcher Inputs Present.", Dmps.SwitcherInputs.Count); - Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.SwitcherOutputs.Count); - + Debug.Console(1, this, "{0} Switcher Outputs Present.", Dmps.SwitcherOutputs.Count); + Debug.Console(1, this, "{0} Inputs in ControlSystem", Dmps.NumberOfSwitcherInputs); Debug.Console(1, this, "{0} Outputs in ControlSystem", Dmps.NumberOfSwitcherOutputs); @@ -155,57 +155,57 @@ namespace PepperDash.Essentials.DM Dmps.DMOutputChange += Dmps_DMOutputChange; return base.CustomActivate(); - } - - private void SetOutputNames() - { - if (OutputNames == null) - { - return; - } - - foreach (var kvp in OutputNames) - { - var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); - if (output != null && output.Name.Type != eSigType.NA) - { - output.Name.StringValue = kvp.Value; - } - } - } - - private void SetInputNames() - { - if (InputNames == null) - { - return; - } - foreach (var kvp in InputNames) - { - var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); - if (input != null && input.Name.Type != eSigType.NA) - { - input.Name.StringValue = kvp.Value; - } - } - } - + } + + private void SetOutputNames() + { + if (OutputNames == null) + { + return; + } + + foreach (var kvp in OutputNames) + { + var output = (Dmps.SwitcherOutputs[kvp.Key] as DMOutput); + if (output != null && output.Name.Type != eSigType.NA) + { + output.Name.StringValue = kvp.Value; + } + } + } + + private void SetInputNames() + { + if (InputNames == null) + { + return; + } + foreach (var kvp in InputNames) + { + var input = (Dmps.SwitcherInputs[kvp.Key] as DMInput); + if (input != null && input.Name.Type != eSigType.NA) + { + input.Name.StringValue = kvp.Value; + } + } + } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { + { var joinMap = new DmpsRoutingControllerJoinMap(joinStart); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - else - { - Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); @@ -214,194 +214,203 @@ namespace PepperDash.Essentials.DM LinkInputsToApi(trilist, joinMap); LinkOutputsToApi(trilist, joinMap); - } - - private void LinkOutputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) - { - for (uint i = 1; i <= Dmps.SwitcherOutputs.Count; i++) - { - Debug.Console(2, this, "Linking Output Card {0}", i); - - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - // Control - trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, - o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)); - trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, - o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)); - - trilist.SetStringSigAction(joinMap.OutputNames.JoinNumber + ioSlotJoin, s => - { - var outputCard = Dmps.SwitcherOutputs[ioSlot] as DMOutput; - - //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); - - if (outputCard == null) - { - return; - } - //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); - - if (outputCard is Card.Dmps3CodecOutput || outputCard.NameFeedback == null) - { - return; - } - if (string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) - { - return; - } - //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); - - if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) - { - outputCard.Name.StringValue = s; - } - }); - - // Feedback - if (VideoOutputFeedbacks[ioSlot] != null) - { - VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); - } - if (AudioOutputFeedbacks[ioSlot] != null) - { - AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); - } - if (OutputNameFeedbacks[ioSlot] != null) - { - OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); - } - if (OutputVideoRouteNameFeedbacks[ioSlot] != null) - { - OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); - } - if (OutputAudioRouteNameFeedbacks[ioSlot] != null) - { - OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( - trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); - } - if (OutputEndpointOnlineFeedbacks[ioSlot] != null) - { - OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - } - - private void LinkInputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) - { - for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++) - { - Debug.Console(2, this, "Linking Input Card {0}", i); - - var ioSlot = i; - var ioSlotJoin = ioSlot - 1; - - if (VideoInputSyncFeedbacks[ioSlot] != null) - { - VideoInputSyncFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); - } - - if (InputNameFeedbacks[ioSlot] != null) - { - InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); - } - - trilist.SetStringSigAction(joinMap.InputNames.JoinNumber + ioSlotJoin, s => - { - var inputCard = Dmps.SwitcherInputs[ioSlot] as DMInput; - - if (inputCard == null) - { - return; - } - - if (inputCard.NameFeedback == null || string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) || - inputCard.NameFeedback.StringValue == s) - { - return; - } - - if (inputCard.Name != null) - { - inputCard.Name.StringValue = s; - } - }); - - - if (InputEndpointOnlineFeedbacks[ioSlot] != null) - { - InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( - trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); - } - } - } - - + } + + private void LinkOutputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) + { + for (uint i = 1; i <= Dmps.SwitcherOutputs.Count; i++) + { + Debug.Console(2, this, "Linking Output Card {0}", i); + + var ioSlot = i; + var ioSlotJoin = ioSlot - 1; + + // Control + trilist.SetUShortSigAction(joinMap.OutputVideo.JoinNumber + ioSlotJoin, + o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)); + trilist.SetUShortSigAction(joinMap.OutputAudio.JoinNumber + ioSlotJoin, + o => ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)); + + trilist.SetStringSigAction(joinMap.OutputNames.JoinNumber + ioSlotJoin, s => + { + var outputCard = Dmps.SwitcherOutputs[ioSlot] as DMOutput; + + //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); + + if (outputCard == null) + { + return; + } + //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); + + if (outputCard is Card.Dmps3CodecOutput || outputCard.NameFeedback == null) + { + return; + } + if (string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) + { + return; + } + //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); + + if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) + { + outputCard.Name.StringValue = s; + } + }); + + // Feedback + if (VideoOutputFeedbacks[ioSlot] != null) + { + VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo.JoinNumber + ioSlotJoin]); + } + if (AudioOutputFeedbacks[ioSlot] != null) + { + AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio.JoinNumber + ioSlotJoin]); + } + if (OutputNameFeedbacks[ioSlot] != null) + { + OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames.JoinNumber + ioSlotJoin]); + } + if (OutputVideoRouteNameFeedbacks[ioSlot] != null) + { + OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig( + trilist.StringInput[joinMap.OutputCurrentVideoInputNames.JoinNumber + ioSlotJoin]); + } + if (OutputAudioRouteNameFeedbacks[ioSlot] != null) + { + OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig( + trilist.StringInput[joinMap.OutputCurrentAudioInputNames.JoinNumber + ioSlotJoin]); + } + if (OutputEndpointOnlineFeedbacks[ioSlot] != null) + { + OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.OutputEndpointOnline.JoinNumber + ioSlotJoin]); + } + } + } + + private void LinkInputsToApi(BasicTriList trilist, DmpsRoutingControllerJoinMap joinMap) + { + for (uint i = 1; i <= Dmps.SwitcherInputs.Count; i++) + { + Debug.Console(2, this, "Linking Input Card {0}", i); + + var ioSlot = i; + var ioSlotJoin = ioSlot - 1; + + if (VideoInputSyncFeedbacks[ioSlot] != null) + { + VideoInputSyncFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber + ioSlotJoin]); + } + + if (InputNameFeedbacks[ioSlot] != null) + { + InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames.JoinNumber + ioSlotJoin]); + } + + trilist.SetStringSigAction(joinMap.InputNames.JoinNumber + ioSlotJoin, s => + { + var inputCard = Dmps.SwitcherInputs[ioSlot] as DMInput; + + if (inputCard == null) + { + return; + } + + if (inputCard.NameFeedback == null || string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) || + inputCard.NameFeedback.StringValue == s) + { + return; + } + + if (inputCard.Name != null) + { + inputCard.Name.StringValue = s; + } + }); + + + if (InputEndpointOnlineFeedbacks[ioSlot] != null) + { + InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig( + trilist.BooleanInput[joinMap.InputEndpointOnline.JoinNumber + ioSlotJoin]); + } + } + } + + /// /// Iterate the SwitcherOutputs collection to setup feedbacks and add routing ports /// void SetupOutputCards() { - foreach (var card in Dmps.SwitcherOutputs) - { + foreach (var card in Dmps.SwitcherOutputs) + { Debug.Console(1, this, "Output Card Type: {0}", card.CardInputOutputType); - var outputCard = card as DMOutput; - - if (outputCard == null) - { - Debug.Console(1, this, "Output card {0} is not a DMOutput", card.CardInputOutputType); - continue; - } - + var outputCard = card as DMOutput; + + if (outputCard == null) + { + Debug.Console(1, this, "Output card {0} is not a DMOutput", card.CardInputOutputType); + continue; + } + Debug.Console(1, this, "Adding Output Card Number {0} Type: {1}", outputCard.Number, outputCard.CardInputOutputType.ToString()); VideoOutputFeedbacks[outputCard.Number] = new IntFeedback(() => { - if (outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number; } - return 0; + if (outputCard.VideoOutFeedback != null) { return (ushort)outputCard.VideoOutFeedback.Number; } + return 0; ; }); AudioOutputFeedbacks[outputCard.Number] = new IntFeedback(() => { - if (outputCard.AudioOutFeedback != null) { return (ushort)outputCard.AudioOutFeedback.Number; } - return 0; - ; + try + { + if (outputCard.AudioOutFeedback != null) + { + return (ushort) outputCard.AudioOutFeedback.Number; + } + return 0; + } + catch (NotSupportedException) + { + return (ushort) outputCard.AudioOutSourceFeedback; + } }); - OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { + OutputNameFeedbacks[outputCard.Number] = new StringFeedback(() => + { 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; - } - return ""; + } + return ""; }); - OutputVideoRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { + OutputVideoRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => + { if (outputCard.VideoOutFeedback != null && outputCard.VideoOutFeedback.NameFeedback != null) { return outputCard.VideoOutFeedback.NameFeedback.StringValue; - } - return NoRouteText; + } + return NoRouteText; }); - OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => - { + OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() => + { if (outputCard.AudioOutFeedback != null && outputCard.AudioOutFeedback.NameFeedback != null) { return outputCard.AudioOutFeedback.NameFeedback.StringValue; - } - return NoRouteText; + } + return NoRouteText; }); OutputEndpointOnlineFeedbacks[outputCard.Number] = new BoolFeedback(() => outputCard.EndpointOnlineFeedback); - AddOutputCard(outputCard.Number, outputCard); + AddOutputCard(outputCard.Number, outputCard); } } @@ -513,26 +522,26 @@ namespace PepperDash.Essentials.DM AddInputPortWithDebug(number, string.Format("AirMediaIn{0}", number), eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming); } - } - - - /// - /// Adds InputPort - /// - private 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) - { - FeedbackMatchObject = Dmps.SwitcherInputs[cardNum] - }; - ; - - InputPorts.Add(inputPort); - } - + } + + + /// + /// Adds InputPort + /// + private 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) + { + FeedbackMatchObject = Dmps.SwitcherInputs[cardNum] + }; + ; + + InputPorts.Add(inputPort); + } + /// /// Adds InputPort and sets Port as ICec object /// @@ -540,9 +549,9 @@ namespace PepperDash.Essentials.DM { 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) - { - FeedbackMatchObject = Dmps.SwitcherInputs[cardNum] + var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this) + { + FeedbackMatchObject = Dmps.SwitcherInputs[cardNum] }; ; @@ -550,7 +559,7 @@ namespace PepperDash.Essentials.DM inputPort.Port = cecPort; InputPorts.Add(inputPort); - } + } /// @@ -566,23 +575,23 @@ namespace PepperDash.Essentials.DM var cecPort = hdmiOutputCard.HdmiOutputPort; - AddHdmiOutputPort(number, cecPort); + AddHdmiOutputPort(number, cecPort); } - else if (outputCard is Card.Dmps3HdmiOutputBackend) - { - var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutputBackend; - - var cecPort = hdmiOutputCard.HdmiOutputPort; - - AddHdmiOutputPort(number, cecPort); + else if (outputCard is Card.Dmps3HdmiOutputBackend) + { + var hdmiOutputCard = outputCard as Card.Dmps3HdmiOutputBackend; + + var cecPort = hdmiOutputCard.HdmiOutputPort; + + AddHdmiOutputPort(number, cecPort); } else if (outputCard is Card.Dmps3DmOutput) - { - AddDmOutputPort(number); + { + AddDmOutputPort(number); } - else if (outputCard is Card.Dmps3DmOutputBackend) - { - AddDmOutputPort(number); + else if (outputCard is Card.Dmps3DmOutputBackend) + { + AddDmOutputPort(number); } else if (outputCard is Card.Dmps3ProgramOutput) { @@ -590,51 +599,51 @@ namespace PepperDash.Essentials.DM var programOutput = new DmpsAudioOutputController(string.Format("processor-programAudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase); - DeviceManager.AddDevice(programOutput); + DeviceManager.AddDevice(programOutput); } - else if (outputCard is Card.Dmps3AuxOutput) - { - switch (outputCard.CardInputOutputType) - { - case eCardInputOutputType.Dmps3Aux1Output: + else if (outputCard is Card.Dmps3AuxOutput) + { + switch (outputCard.CardInputOutputType) + { + case eCardInputOutputType.Dmps3Aux1Output: { AddAudioOnlyOutputPort(number, "Aux1"); var aux1Output = new DmpsAudioOutputController(string.Format("processor-aux1AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase); DeviceManager.AddDevice(aux1Output); - } - break; - case eCardInputOutputType.Dmps3Aux2Output: + } + break; + case eCardInputOutputType.Dmps3Aux2Output: { AddAudioOnlyOutputPort(number, "Aux2"); var aux2Output = new DmpsAudioOutputController(string.Format("processor-aux2AudioOutput"), "Program Audio Output", outputCard as Card.Dmps3OutputBase); DeviceManager.AddDevice(aux2Output); - } - break; - } - } - else if (outputCard is Card.Dmps3CodecOutput) - { - switch (number) - { - case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec1: - case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec1: - case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec1: - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec1.ToString()); - break; - case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec2: - case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec2: - case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec2: - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec2.ToString()); - break; - } - } + } + break; + } + } + else if (outputCard is Card.Dmps3CodecOutput) + { + switch (number) + { + case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec1: + case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec1: + case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec1: + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec1.ToString()); + break; + case (uint)CrestronControlSystem.eDmps34K350COutputs.Codec2: + case (uint)CrestronControlSystem.eDmps34K250COutputs.Codec2: + case (uint)CrestronControlSystem.eDmps3300cAecOutputs.Codec2: + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps300cOutputs.Codec2.ToString()); + break; + } + } else if (outputCard is Card.Dmps3DialerOutput) { - AddAudioOnlyOutputPort(number, "Dialer"); + AddAudioOnlyOutputPort(number, "Dialer"); } else if (outputCard is Card.Dmps3DigitalMixOutput) { @@ -645,11 +654,11 @@ namespace PepperDash.Essentials.DM if (number == (uint)CrestronControlSystem.eDmps34K250COutputs.Mix2 || number == (uint)CrestronControlSystem.eDmps34K300COutputs.Mix2 || number == (uint)CrestronControlSystem.eDmps34K350COutputs.Mix2) - AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString()); + AddAudioOnlyOutputPort(number, CrestronControlSystem.eDmps34K250COutputs.Mix2.ToString()); } else if (outputCard is Card.Dmps3AecOutput) { - AddAudioOnlyOutputPort(number, "Aec"); + AddAudioOnlyOutputPort(number, "Aec"); } else { @@ -692,9 +701,9 @@ namespace PepperDash.Essentials.DM { 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) - { - FeedbackMatchObject = Dmps.SwitcherOutputs[cardNum] + OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this) + { + FeedbackMatchObject = Dmps.SwitcherOutputs[cardNum] }); } @@ -705,9 +714,9 @@ namespace PepperDash.Essentials.DM { 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) - { - FeedbackMatchObject = Dmps.SwitcherOutputs[cardNum] + var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this) + { + FeedbackMatchObject = Dmps.SwitcherOutputs[cardNum] }; if (cecPort != null) @@ -768,74 +777,55 @@ namespace PepperDash.Essentials.DM { OutputEndpointOnlineFeedbacks[output].FireUpdate(); } - else if (args.EventId == DMOutputEventIds.VideoOutEventId) - { - if (outputCard == null) return; - - var outputFeedbackIndex = outputCard.VideoOutFeedback == null ? 0 : outputCard.VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchVideo:{0} Routed Input:{1} Output:{2}'", this.Name, - outputFeedbackIndex, output); - - if (VideoOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = - InputPorts.FirstOrDefault(p => (DMInput) p.FeedbackMatchObject == outputCard.VideoOutFeedback); - var localOutputPort = OutputPorts.FirstOrDefault(p => (DMOutput) p.FeedbackMatchObject == outputCard); - - VideoOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, VideoOutputFeedbacks[output].UShortValue, - localOutputPort, localInputPort, eRoutingSignalType.Video)); - } - if (OutputVideoRouteNameFeedbacks.ContainsKey(output)) - { - OutputVideoRouteNameFeedbacks[output].FireUpdate(); - } - } - else if (args.EventId == DMOutputEventIds.AudioOutEventId) - { - /* - if (outputCard == null || outputCard.AudioOutFeedback == null) return; - - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, - outputCard.AudioOutFeedback.Number, output); - - if (AudioOutputFeedbacks.ContainsKey(output)) - { - AudioOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, AudioOutputFeedbacks[output].UShortValue, eRoutingSignalType.Audio)); - } - */ - - if (outputCard == null) return; - - var outputFeedbackIndex = outputCard.AudioOutFeedback == null ? 0 : outputCard.VideoOutFeedback.Number; - - Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, - outputFeedbackIndex, output); - - if (AudioOutputFeedbacks.ContainsKey(output)) - { - var localInputPort = - InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == outputCard.AudioOutFeedback); - var localOutputPort = OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == outputCard); - - AudioOutputFeedbacks[output].FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(output, AudioOutputFeedbacks[output].UShortValue, - localOutputPort, localInputPort, eRoutingSignalType.Audio)); - } - if (OutputAudioRouteNameFeedbacks.ContainsKey(output)) - { - OutputAudioRouteNameFeedbacks[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.VideoOutEventId) + { + if (outputCard != null && outputCard.VideoOutFeedback != null) + { + 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)) + { + OutputVideoRouteNameFeedbacks[output].FireUpdate(); + } + } + else if (args.EventId == DMOutputEventIds.AudioOutEventId) + { + try + { + if (outputCard != null && outputCard.AudioOutFeedback != null) + { + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", this.Name, + outputCard.AudioOutFeedback.Number, output); + } + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + } + catch (NotSupportedException) + { + if (outputCard != null) + { + Debug.Console(2, this, "DMSwitchAudio:{0} Routed Input:{1} Output:{2}'", Name, + outputCard.AudioOutSourceFeedback, output); + } + if (AudioOutputFeedbacks.ContainsKey(output)) + { + AudioOutputFeedbacks[output].FireUpdate(); + } + } + } + else if (args.EventId == DMOutputEventIds.OutputNameEventId + && OutputNameFeedbacks.ContainsKey(output)) + { + Debug.Console(2, this, "DM Output {0} NameFeedbackEventId", output); + OutputNameFeedbacks[output].FireUpdate(); + } + } /// @@ -861,7 +851,14 @@ namespace PepperDash.Essentials.DM var input = Convert.ToUInt32(inputSelector); // Cast can sometimes fail var output = Convert.ToUInt32(outputSelector); - if (input <= Dmps.NumberOfSwitcherInputs && output <= Dmps.NumberOfSwitcherOutputs) + var sigTypeIsUsbOrVideo = ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) || + ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) || + ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput); + + if ((input <= Dmps.NumberOfSwitcherInputs && output <= Dmps.NumberOfSwitcherOutputs && + sigTypeIsUsbOrVideo) || + (input <= Dmps.NumberOfSwitcherInputs + 5 && output <= Dmps.NumberOfSwitcherOutputs && + (sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio)) { // Check to see if there's an off timer waiting on this and if so, cancel var key = new PortNumberType(output, sigType); @@ -879,37 +876,55 @@ namespace PepperDash.Essentials.DM } } - DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; - DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; + + DMOutput dmOutputCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; //if (inCard != null) //{ - // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - { + // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES + if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) + { + DMInput dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + //SystemControl.VideoEnter.BoolValue = true; + if (dmOutputCard != null) + dmOutputCard.VideoOut = dmInputCard; + } - //SystemControl.VideoEnter.BoolValue = true; - if (outCard != null) - outCard.VideoOut = inCard; + if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + DMInput dmInputCard = null; + if (input <= Dmps.NumberOfSwitcherInputs) + { + dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; } - if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - if (outCard != null) - outCard.AudioOut = inCard; - } + if (dmOutputCard != null) + try + { + dmOutputCard.AudioOut = dmInputCard; + } + catch (NotSupportedException) + { + Debug.Console(1, this, "Routing input {0} audio to output {1}", + (eDmps34KAudioOutSource) input, (CrestronControlSystem.eDmps34K350COutputs) output); - if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - if (outCard != null) - outCard.USBRoutedTo = inCard; - } + dmOutputCard.AudioOutSource = (eDmps34KAudioOutSource) input; + } + } - if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) - { - if (inCard != null) - inCard.USBRoutedTo = outCard; - } + if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) + { + DMInput dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + if (dmOutputCard != null) + dmOutputCard.USBRoutedTo = dmInputCard; + } + + if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) + { + DMInput dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + if (dmInputCard != null) + dmInputCard.USBRoutedTo = dmOutputCard; + } //} //else //{ @@ -919,7 +934,8 @@ namespace PepperDash.Essentials.DM } else { - Debug.Console(1, this, "Unable to execute route from input {0} to output {1}", inputSelector, outputSelector); + Debug.Console(1, this, "Unable to execute route from input {0} to output {1}", inputSelector, + outputSelector); } } catch (Exception e) @@ -928,15 +944,15 @@ namespace PepperDash.Essentials.DM } } - #endregion - - #region IRoutingNumeric Members - - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) - { - ExecuteSwitch(inputSelector, outputSelector, sigType); - } - - #endregion + #endregion + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + ExecuteSwitch(inputSelector, outputSelector, sigType); + } + + #endregion } } \ No newline at end of file diff --git a/packages.config b/packages.config index 296413b6..c138dd1b 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + \ No newline at end of file