From b457886ee32306f45f47b6c63c8b7a7bb187109b Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 2 Nov 2020 12:38:23 -0700 Subject: [PATCH 1/3] Update to route correctly for DMPS3-4K --- .../Chassis/DmpsRoutingController.cs | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index adf73bde..9970be5c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -813,36 +813,42 @@ namespace PepperDash.Essentials.DM } } - DMInput inCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; - DMOutput outCard = output == 0 ? null : Dmps.SwitcherOutputs[output] as DMOutput; - + DMInput dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + 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) + if ((sigType & eRoutingSignalType.Video) == eRoutingSignalType.Video) { - //SystemControl.VideoEnter.BoolValue = true; - if (outCard != null) - outCard.VideoOut = inCard; + if (dmOutputCard != null) + dmOutputCard.VideoOut = dmInputCard; } - if ((sigType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) { - if (outCard != null) - outCard.AudioOut = inCard; + if (dmOutputCard != null) + try + { + dmOutputCard.AudioOut = dmInputCard; + } + catch (NotSupportedException) + { + dmOutputCard.AudioOutSource = (eDmps34KAudioOutSource) input; + } } - if ((sigType | eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) + if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) { - if (outCard != null) - outCard.USBRoutedTo = inCard; + if (dmOutputCard != null) + dmOutputCard.USBRoutedTo = dmInputCard; } - if ((sigType | eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) + if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) { - if (inCard != null) - inCard.USBRoutedTo = outCard; + if (dmInputCard != null) + dmInputCard.USBRoutedTo = dmOutputCard; } //} //else From 3cd8a1f310ad635c94aba3c2c06deac82ffec3f8 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 3 Nov 2020 08:30:13 -0700 Subject: [PATCH 2/3] update output change event & feedbacks --- .../Chassis/DmpsRoutingController.cs | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 9970be5c..06d9d7b6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -351,10 +351,19 @@ namespace PepperDash.Essentials.DM ; }); 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(() => @@ -753,15 +762,31 @@ namespace PepperDash.Essentials.DM } } else if (args.EventId == DMOutputEventIds.AudioOutEventId) - { - 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(); - } + { + 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)) From 88f1230620999dd555967435b4d99eee72ade9a1 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 4 Nov 2020 14:43:17 -0600 Subject: [PATCH 3/3] got it all working --- .../Chassis/DmpsRoutingController.cs | 152 ++++++++++-------- 1 file changed, 86 insertions(+), 66 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 06d9d7b6..051ef88e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -818,74 +818,94 @@ namespace PepperDash.Essentials.DM 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) - { - // 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 dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + var output = Convert.ToUInt32(outputSelector); + + 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); + 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); + } + } + + 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) - { - //SystemControl.VideoEnter.BoolValue = true; - if (dmOutputCard != null) - dmOutputCard.VideoOut = dmInputCard; - } - - if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - { - if (dmOutputCard != null) - try - { - dmOutputCard.AudioOut = dmInputCard; - } - catch (NotSupportedException) - { - dmOutputCard.AudioOutSource = (eDmps34KAudioOutSource) input; - } - } - - if ((sigType & eRoutingSignalType.UsbOutput) == eRoutingSignalType.UsbOutput) - { - if (dmOutputCard != null) - dmOutputCard.USBRoutedTo = dmInputCard; - } - - if ((sigType & eRoutingSignalType.UsbInput) == eRoutingSignalType.UsbInput) - { - if (dmInputCard != null) - dmInputCard.USBRoutedTo = dmOutputCard; - } - //} - //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); - } + //if (inCard != null) + //{ + // 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; + } + + if ((sigType & eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + { + DMInput dmInputCard = null; + if (input <= Dmps.NumberOfSwitcherInputs) + { + dmInputCard = input == 0 ? null : Dmps.SwitcherInputs[input] as DMInput; + } + + 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); + + dmOutputCard.AudioOutSource = (eDmps34KAudioOutSource) input; + } + } + + 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 + //{ + // 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); + } } catch (Exception e) {