From bdf3e2054f9649f4fe48f2c64bb35b7c64abb881 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 29 Jul 2019 16:32:39 -0600 Subject: [PATCH] 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