From 1a5d4896e168f6ee93e70adeb5eced1d3174cde8 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Tue, 14 Jun 2022 10:43:29 -0400 Subject: [PATCH] Fixes online feedback for DM endpoints that are attached to a 3 series DM chassis or a DMPS-4K unit. --- .../Crestron/CrestronGenericBaseDevice.cs | 18 ++- .../DmpsInternalVirtualDmTxController.cs | 25 ++-- .../Chassis/DmpsRoutingController.cs | 12 ++ .../Chassis/HdMd8xNController.cs | 2 +- .../Endpoints/Receivers/DmRmcHelper.cs | 120 +++++++++++------- .../Endpoints/Transmitters/DmTxHelpers.cs | 41 +++++- 6 files changed, 155 insertions(+), 63 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs index b7534087..f4d13d4e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs @@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Core /// public FeedbackCollection Feedbacks { get; private set; } - public BoolFeedback IsOnline { get; private set; } + public BoolFeedback IsOnline { get; set; } public BoolFeedback IsRegistered { get; private set; } public StringFeedback IpConnectionsText { get; private set; } @@ -73,11 +73,14 @@ namespace PepperDash.Essentials.Core { //Debug.Console(1, this, " Does not require registration. Skipping"); - var response = Hardware.RegisterWithLogging(Key); - if (response != eDeviceRegistrationUnRegistrationResponse.Success) + if (Hardware.Registerable && !Hardware.Registered) { - //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); - return false; + var response = Hardware.RegisterWithLogging(Key); + if (response != eDeviceRegistrationUnRegistrationResponse.Success) + { + //Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response); + return false; + } } IsRegistered.FireUpdate(); @@ -86,7 +89,10 @@ namespace PepperDash.Essentials.Core { AddPostActivationAction(() => { - var response = Hardware.RegisterWithLogging(Key); + if (Hardware.Registerable && !Hardware.Registered) + { + var response = Hardware.RegisterWithLogging(Key); + } IsRegistered.FireUpdate(); }); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs index 75ba7e29..c9c2f261 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsInternalVirtualDmTxController.cs @@ -47,16 +47,23 @@ namespace PepperDash.Essentials.DM { get { - if (InputCard.VideoSourceFeedback != eDmps3InputVideoSource.Auto) - return InputCard.VideoSourceFeedback; - else // auto + try { - if (InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) - return eDmps3InputVideoSource.Hdmi; - else if (InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) - return eDmps3InputVideoSource.Vga; - else - return eDmps3InputVideoSource.Bnc; + 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; + } + } + catch + { + return eDmps3InputVideoSource.Bnc; } } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 5c03e8e9..38a0aed9 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -861,6 +861,7 @@ namespace PepperDash.Essentials.DM void Dmps_DMInputChange(Switch device, DMInputEventArgs args) { + Debug.Console(2, this, "DMInputChange Input: {0} EventId: {1}", args.Number, args.EventId.ToString()); try { switch (args.EventId) @@ -871,6 +872,12 @@ namespace PepperDash.Essentials.DM InputEndpointOnlineFeedbacks[args.Number].FireUpdate(); break; } + case (DMInputEventIds.EndpointOnlineEventId): + { + Debug.Console(2, this, "DM Input EndpointOnlineEventId 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); @@ -916,6 +923,11 @@ namespace PepperDash.Essentials.DM { OutputEndpointOnlineFeedbacks[output].FireUpdate(); } + else if (args.EventId == DMOutputEventIds.EndpointOnlineEventId + && OutputEndpointOnlineFeedbacks.ContainsKey(output)) + { + OutputEndpointOnlineFeedbacks[output].FireUpdate(); + } else if (args.EventId == DMOutputEventIds.VideoOutEventId) { if (outputCard != null && outputCard.VideoOutFeedback != null) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs index 00e3b974..2343f65a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMd8xNController.cs @@ -323,7 +323,7 @@ namespace PepperDash.Essentials.DM.Chassis IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - trilist.StringInput[joinMap.Name.JoinNumber].StringValue = "DM Switcher"; + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index a9282693..ced21918 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -30,14 +30,15 @@ namespace PepperDash.Essentials.DM : base(key, name, device) { _rmc = device; + // if wired to a chassis, skip registration step in base class PreventRegistration = _rmc.DMOutput != null; AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); - + DeviceInfo = new DeviceInfo(); - _rmc.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); }; + IsOnline.OutputChange += (currentDevice, args) => { if (args.BoolValue) UpdateDeviceInfo(); }; } protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) @@ -60,7 +61,7 @@ namespace PepperDash.Essentials.DM Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); trilist.StringInput[joinMap.Name.JoinNumber].StringValue = rmc.Name; if (rmc.VideoOutputResolutionFeedback != null) rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution.JoinNumber]); @@ -330,53 +331,84 @@ namespace PepperDash.Essentials.DM var parentDev = DeviceManager.GetDeviceForKey(pKey); if (parentDev is DmpsRoutingController) { - if ((parentDev as DmpsRoutingController).Dmps4kType) + var dmps = parentDev as DmpsRoutingController; + //Check that the input is within range of this chassis' possible inputs + var num = props.ParentOutputNumber; + Debug.Console(1, "Creating DMPS device '{0}'. Output number '{1}'.", key, num); + if (num <= 0 || num > dmps.Dmps.SwitcherOutputs.Count) { - return GetDmRmcControllerForDmps4k(key, name, typeName, parentDev as DmpsRoutingController, props.ParentOutputNumber); + Debug.Console(0, "Cannot create DMPS device '{0}'. Output number '{1}' is out of range", + key, num); + return null; } - else + // Must use different constructor for DMPS4K types. No IPID + if (Global.ControlSystemIsDmps4kType) { - return GetDmRmcControllerForDmps(key, name, typeName, ipid, parentDev as DmpsRoutingController, props.ParentOutputNumber); + var rmc = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); + Debug.Console(0, "DM endpoint output {0} is for Dmps4k, changing online feedback to chassis", num); + rmc.IsOnline = dmps.OutputEndpointOnlineFeedbacks[num]; + rmc.IsOnline.OutputChange += (currentDevice, args) => + { + foreach (var feedback in rmc.Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + }; + return rmc; } + return GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); } - if (!(parentDev is IDmSwitch)) - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis.", - key, pKey); - return null; - } + else if (parentDev is DmChassisController) + { + var controller = parentDev as DmChassisController; + var chassis = controller.Chassis; + var num = props.ParentOutputNumber; + Debug.Console(1, "Creating DM Chassis device '{0}'. Output number '{1}'.", key, num); - var chassis = (parentDev as IDmSwitch).Chassis; - var num = props.ParentOutputNumber; - - if (num <= 0 || num > chassis.NumberOfOutputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", - key, num); - return null; - } - - var controller = parentDev as IDmSwitch; - controller.RxDictionary.Add(num, key); - // Catch constructor failures, mainly dues to IPID - try - { - // Must use different constructor for CPU3 chassis types. No IPID - if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || - chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || - chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || - chassis is DmMd128x128 || chassis is DmMd64x64) - { - return GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); - } - - return GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); - return null; - } + if (num <= 0 || num > chassis.NumberOfOutputs) + { + Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", + key, num); + return null; + } + controller.RxDictionary.Add(num, key); + // Catch constructor failures, mainly dues to IPID + try + { + // Must use different constructor for CPU3 chassis types. No IPID + if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || + chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || + chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || + chassis is DmMd128x128 || chassis is DmMd64x64) + { + var rmc = GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); + Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); + rmc.IsOnline = controller.OutputEndpointOnlineFeedbacks[num]; + rmc.IsOnline.OutputChange += (currentDevice, args) => + { + foreach (var feedback in rmc.Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + }; + return rmc; + } + return GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + return null; + } + } + else + { + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a DM Chassis or DMPS.", + key, pKey); + return null; + } } private static CrestronGenericBaseDevice GetDmRmcControllerForCpu2Chassis(string key, string name, string typeName, diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 5eb2d7b5..4883849e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -137,7 +137,7 @@ namespace PepperDash.Essentials.DM try { // Must use different constructor for CPU3 or DMPS3-4K types. No IPID - if (isCpu3 || Global.ControlSystemIsDmps4kType) + if (isCpu3 || (parentDev is DmpsRoutingController && Global.ControlSystemIsDmps4kType)) { if (typeName.StartsWith("dmtx200")) return new DmTx200Controller(key, name, new DmTx200C2G(dmInput)); @@ -145,7 +145,7 @@ namespace PepperDash.Essentials.DM return new DmTx201CController(key, name, new DmTx201C(dmInput)); if (typeName.StartsWith("dmtx201s")) return new DmTx201SController(key, name, new DmTx201S(dmInput)); - if (typeName.StartsWith("dmtx4k100")) + if (typeName.StartsWith("dmtx4k100")) return new DmTx4k100Controller(key, name, new DmTx4K100C1G(dmInput)); if (typeName.StartsWith("dmtx4kz100")) return new DmTx4kz100Controller(key, name, new DmTx4kz100C1G(dmInput)); @@ -153,7 +153,7 @@ namespace PepperDash.Essentials.DM return new DmTx4k202CController(key, name, new DmTx4k202C(dmInput)); if (typeName.StartsWith("dmtx4kz202")) return new DmTx4kz202CController(key, name, new DmTx4kz202C(dmInput)); - if (typeName.StartsWith("dmtx4k302")) + if (typeName.StartsWith("dmtx4k302")) return new DmTx4k302CController(key, name, new DmTx4k302C(dmInput)); if (typeName.StartsWith("dmtx4kz302")) return new DmTx4kz302CController(key, name, new DmTx4kz302C(dmInput)); @@ -228,6 +228,41 @@ namespace PepperDash.Essentials.DM } AddToFeedbackList(ActiveVideoInputFeedback); + + var parentDev = DeviceManager.GetDeviceForKey(key); + var num = hardware.DMInput.Number; + + //If Dmps4K, change online feedback to chassis, tx feedback does not work + if (parentDev is DmpsRoutingController && Global.ControlSystemIsDmps4kType) + { + var dmps = parentDev as DmpsRoutingController; + Debug.Console(0, "DM endpoint input {0} is for Dmps4k, changing online feedback to chassis", num); + IsOnline = dmps.InputEndpointOnlineFeedbacks[num]; + } + //If Cpu3 Chassis, change online feedback to chassis, tx feedback does not work + else if (parentDev is DmChassisController) + { + var controller = parentDev as DmChassisController; + var chassis = controller.Chassis; + + if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || + chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || + chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || + chassis is DmMd128x128 || chassis is DmMd64x64) + { + Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); + IsOnline = controller.InputEndpointOnlineFeedbacks[num]; + } + } + + IsOnline.OutputChange += (currentDevice, args) => + { + foreach (var feedback in Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + }; } protected DmTxControllerBase(string key, string name, DmHDBasedTEndPoint hardware) : base(key, name, hardware)