From ed335cc9aeea8a81e939b31d111ac1fa7ea8df44 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Fri, 12 Aug 2022 09:26:09 -0400 Subject: [PATCH] Fixes for offline feedback for DM endpoints that don't provide offline feedback in the hardware definition. Adds offline and name feedback to joinMap for these devices. --- .../Crestron/CrestronGenericBaseDevice.cs | 2 +- .../Receivers/DmHdBaseTEndpointController.cs | 30 ++++++++++- .../Receivers/DmRmc4k100C1GController.cs | 34 ++++++++++-- .../Endpoints/Receivers/DmRmcHelper.cs | 30 +++++------ .../Transmitters/DmTx4k100Controller.cs | 34 ++++++++---- .../Endpoints/Transmitters/DmTxHelpers.cs | 54 ++++++++++--------- .../Transmitters/HDBaseTTxController.cs | 24 ++++++++- 7 files changed, 149 insertions(+), 59 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron/CrestronGenericBaseDevice.cs index f4d13d4e..32407ba3 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; set; } + public BoolFeedback IsOnline { get; private set; } public BoolFeedback IsRegistered { get; private set; } public StringFeedback IpConnectionsText { get; private set; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs index 3af4f0fe..ec3553a1 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs @@ -1,8 +1,10 @@ -using Crestron.SimplSharp.Ssh; +using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - +using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core; +using PepperDash.Core; +using Newtonsoft.Json; namespace PepperDash.Essentials.DM { @@ -28,6 +30,30 @@ namespace PepperDash.Essentials.DM OutputPorts = new RoutingPortCollection {HDBaseTSink}; } + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmRmcControllerJoinMap(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."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; + } + #region IComPorts Members public CrestronCollection ComPorts { get { return Rmc.ComPorts; } } public int NumberOfComPorts { get { return Rmc.NumberOfComPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs index 92af7ce1..529f740a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs @@ -1,9 +1,11 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; - +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core; +using PepperDash.Core; +using Newtonsoft.Json; namespace PepperDash.Essentials.DM { @@ -31,6 +33,30 @@ namespace PepperDash.Essentials.DM InputPorts = new RoutingPortCollection {DmIn}; OutputPorts = new RoutingPortCollection {HdmiOut}; + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DmRmcControllerJoinMap(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."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; } #region IIROutputPorts Members 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 ced21918..5d644a2a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -188,7 +188,7 @@ namespace PepperDash.Essentials.DM #endregion } - public abstract class DmHdBaseTControllerBase : CrestronGenericBaseDevice + public abstract class DmHdBaseTControllerBase : CrestronGenericBridgeableBaseDevice { protected HDBaseTBase Rmc; @@ -342,12 +342,12 @@ namespace PepperDash.Essentials.DM return null; } // Must use different constructor for DMPS4K types. No IPID - if (Global.ControlSystemIsDmps4kType) + if (Global.ControlSystemIsDmps4kType || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") { 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) => + rmc.IsOnline.SetValueFunc(() => dmps.OutputEndpointOnlineFeedbacks[num].BoolValue); + dmps.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => { foreach (var feedback in rmc.Feedbacks) { @@ -380,19 +380,20 @@ namespace PepperDash.Essentials.DM 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) + chassis is DmMd128x128 || chassis is DmMd64x64 + || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") { 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) + rmc.IsOnline.SetValueFunc(() => controller.OutputEndpointOnlineFeedbacks[num].BoolValue); + controller.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => { - if (feedback != null) - feedback.FireUpdate(); - } - }; + foreach (var feedback in rmc.Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + }; return rmc; } return GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); @@ -521,8 +522,7 @@ namespace PepperDash.Essentials.DM var props = JsonConvert.DeserializeObject (dc.Properties.ToString()); - return DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); - + return DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs index d2a9f7bc..5bbf5fd5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; +using Newtonsoft.Json; namespace PepperDash.Essentials.DM { @@ -20,14 +21,6 @@ namespace PepperDash.Essentials.DM public RoutingInputPort HdmiIn { get; private set; } public RoutingOutputPort DmOut { get; private set; } - //public IntFeedback VideoSourceNumericFeedback { get; protected set; } - //public IntFeedback AudioSourceNumericFeedback { get; protected set; } - //public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - //public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - /// /// Helps get the "real" inputs, including when in Auto /// @@ -70,11 +63,34 @@ namespace PepperDash.Essentials.DM HdmiIn.Port = Tx; PreventRegistration = true; + + var parentDev = DeviceManager.GetDeviceForKey(key); + var num = tx.DMInputOutput.Number; + if (parentDev is DmpsRoutingController) + { + var dmps = parentDev as DmpsRoutingController; + IsOnline.SetValueFunc(() => dmps.InputEndpointOnlineFeedbacks[num].BoolValue); + dmps.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } + else if (parentDev is DmChassisController) + { + var controller = parentDev as DmChassisController; + IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); + controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { - Debug.Console(1, this, "No properties to link. Skipping device {0}", Name); + var joinMap = new HDBaseTTxControllerJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + this.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; } #region IIROutputPorts Members 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 4883849e..d04f462c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -221,37 +221,39 @@ namespace PepperDash.Essentials.DM protected DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) : base(key, name, hardware) { - // if wired to a chassis or DMPS, skip registration step in base class - if (hardware.DMInput != null || (Global.ControlSystemIsDmpsType && hardware.DMInput != null)) - { - this.PreventRegistration = true; - } - 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) + // if wired to a chassis or DMPS, skip registration step in base class + if (hardware.DMInput != null) { - 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; + this.PreventRegistration = true; - 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 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) { - Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); - IsOnline = controller.InputEndpointOnlineFeedbacks[num]; + var dmps = parentDev as DmpsRoutingController; + Debug.Console(0, "DM endpoint input {0} is for Dmps4k, changing online feedback to chassis", num); + IsOnline.SetValueFunc(() => dmps.InputEndpointOnlineFeedbacks[num].BoolValue); + dmps.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } + //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.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); + controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs index 800da2a9..d7a78237 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; +using Crestron.SimplSharpPro.DM; using Newtonsoft.Json; using PepperDash.Core; @@ -18,7 +19,7 @@ namespace PepperDash.Essentials.DM /// Controller class for suitable for HDBaseT transmitters /// [Description("Wrapper Class for HDBaseT devices based on HDTx3CB class")] - public class HDBaseTTxController: BasicDmTxControllerBase, IRoutingInputsOutputs, IComPorts + public class HDBaseTTxController : BasicDmTxControllerBase, IRoutingInputsOutputs, IComPorts { public RoutingInputPort HdmiIn { get; private set; } public RoutingOutputPort DmOut { get; private set; } @@ -34,6 +35,21 @@ namespace PepperDash.Essentials.DM InputPorts = new RoutingPortCollection { HdmiIn }; OutputPorts = new RoutingPortCollection { DmOut }; + + var parentDev = DeviceManager.GetDeviceForKey(key); + var num = tx.DMInputOutput.Number; + if (parentDev is DmpsRoutingController) + { + var dmps = parentDev as DmpsRoutingController; + IsOnline.SetValueFunc(() => dmps.InputEndpointOnlineFeedbacks[num].BoolValue); + dmps.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } + else if (parentDev is DmChassisController) + { + var controller = parentDev as DmChassisController; + IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); + controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); + } } #region IRoutingInputs Members @@ -79,7 +95,7 @@ namespace PepperDash.Essentials.DM Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); this.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - + trilist.StringInput[joinMap.Name.JoinNumber].StringValue = this.Name; } #endregion @@ -100,6 +116,10 @@ namespace PepperDash.Essentials.DM JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete(new JoinData { JoinNumber = 6, JoinSpan = 1 }, + new JoinMetadata { Description = "DM Tx Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); /// /// Plugin device BridgeJoinMap constructor