From 59b2995a1bba600a154cfa6954194457f00a1da0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 30 Jul 2019 14:19:01 -0600 Subject: [PATCH] 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(); + } }