From 608a9068b9f92dd7f7aa66f152ecd7ff6c35ec3b Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 22 May 2020 13:56:18 -0500 Subject: [PATCH 1/2] Updated JoinMetadata to add Description property Updated Hrxx0WirelessRemoteController to remove references to JoinMetadata #198 --- .../JoinMaps/JoinMapBase.cs | 21 +++++--- .../Remotes/Hrxx0WirelessRemoteController.cs | 54 +++++++++++-------- .../Routing/RoutingInterfaces.cs | 16 +++--- .../Chassis/DmBladeChassisController.cs | 21 ++++++-- .../Chassis/DmChassisController.cs | 11 +++- .../Chassis/DmpsRoutingController.cs | 22 ++++---- .../Chassis/HdMdNxM4kEBridgeableController.cs | 15 +++++- 7 files changed, 108 insertions(+), 52 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 31616a6d..8d50596e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; -using System.Linq; +using System.Linq; +using System.Runtime.InteropServices; using Crestron.SimplSharp.Reflection; using PepperDash.Core; @@ -363,8 +364,12 @@ namespace PepperDash.Essentials.Core /// /// A label for the join to better describe it's usage /// - [JsonProperty("label")] - public string Label { get; set; } + [Obsolete] + [JsonProperty("label")] + public string Label { get { return Description; } set { Description = value; } } + + [JsonProperty("description")] + public string Description { get; set; } /// /// Signal type(s) /// @@ -454,11 +459,13 @@ namespace PepperDash.Essentials.Core name = attribute.Name; Debug.Console(2, "JoinName Attribute value: {0}", name); return name; - } - } + } + } + + [AttributeUsage(AttributeTargets.All)] - public class JoinNameAttribute : Attribute + public class JoinNameAttribute : CAttribute { private string _Name; @@ -472,5 +479,5 @@ namespace PepperDash.Essentials.Core { get { return _Name; } } - } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs index c5f6d82c..cee8b3eb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Remotes/Hrxx0WirelessRemoteController.cs @@ -149,7 +149,7 @@ namespace PepperDash.Essentials.Core } #endregion - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, PepperDash.Essentials.Core.Bridges.EiscApiAdvanced bridge) + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { var joinMap = new Hrxxx0WirelessRemoteControllerJoinMap(joinStart); @@ -161,33 +161,39 @@ namespace PepperDash.Essentials.Core bridge.AddJoinMap(Key, joinMap); //List ExcludedKeys = new List(); - - - - foreach (Feedback feedback in Feedbacks) + foreach (var feedback in Feedbacks) { - Feedback myFeedback = feedback; + var myFeedback = feedback; - var join = joinMap.Joins.FirstOrDefault(x => x.Value.Metadata.Label.Equals(myFeedback.Key, StringComparison.InvariantCultureIgnoreCase)).Value; + var joinData = + joinMap.Joins.FirstOrDefault( + x => + x.Key.Equals(myFeedback.Key, StringComparison.InvariantCultureIgnoreCase)); - if (join == null) continue; + if (string.IsNullOrEmpty((joinData.Key))) continue; + + var name = joinData.Key; + var join = joinData.Value; if (join.Metadata.JoinType == eJoinType.Digital) { - Debug.Console(0, this, "Linking Bool Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber); - BoolFeedback someFeedback = myFeedback as BoolFeedback; + Debug.Console(0, this, "Linking Bool Feedback '{0}' to join {1}", name, join.JoinNumber); + var someFeedback = myFeedback as BoolFeedback; + if(someFeedback == null) continue; someFeedback.LinkInputSig(trilist.BooleanInput[join.JoinNumber]); } if (join.Metadata.JoinType == eJoinType.Analog) { - Debug.Console(0, this, "Linking Analog Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber); - IntFeedback someFeedback = myFeedback as IntFeedback; + Debug.Console(0, this, "Linking Analog Feedback '{0}' to join {1}", name, join.JoinNumber); + var someFeedback = myFeedback as IntFeedback; + if (someFeedback == null) continue; someFeedback.LinkInputSig(trilist.UShortInput[join.JoinNumber]); } if (join.Metadata.JoinType == eJoinType.Serial) { - Debug.Console(0, this, "Linking Serial Feedback '{0}' to join {1}", join.Metadata.Label, join.JoinNumber); - StringFeedback someFeedback = myFeedback as StringFeedback; + Debug.Console(0, this, "Linking Serial Feedback '{0}' to join {1}", name, join.JoinNumber); + var someFeedback = myFeedback as StringFeedback; + if (someFeedback == null) continue; someFeedback.LinkInputSig(trilist.StringInput[join.JoinNumber]); } } @@ -201,13 +207,19 @@ namespace PepperDash.Essentials.Core for (uint i = 1; i <= _remote.Button.Count; i++) { Debug.Console(2, this, "Attempting to link join index {0}", i); - var join = joinMap.Joins.FirstOrDefault(o => o.Value.Metadata.Label.Equals(_remote.Button[i].Name.ToString(), StringComparison.InvariantCultureIgnoreCase)).Value; - if (join == null) - { - Debug.Console(2, this, "Join '{0}' is null", i); - continue; - } - Debug.Console(2, this, "Setting User Object for '{0}'", join.Metadata.Label); + var index = i; + var joinData = + joinMap.Joins.FirstOrDefault( + o => + o.Key.Equals(_remote.Button[index].Name.ToString(), + StringComparison.InvariantCultureIgnoreCase)); + + if (string.IsNullOrEmpty((joinData.Key))) continue; + + var join = joinData.Value; + var name = joinData.Key; + + Debug.Console(2, this, "Setting User Object for '{0}'", name); if (join.Metadata.JoinType == eJoinType.Digital) { _remote.Button[i].SetButtonAction((b) => trilist.BooleanInput[join.JoinNumber].BoolValue = b); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 3b288290..2c7d5b17 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -80,24 +80,26 @@ namespace PepperDash.Essentials.Core /// public interface IRouting : IRoutingInputsOutputs { - //void ClearRoute(object outputSelector); void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); - } - - public interface ITxRouting : IRouting + } + + public interface IRoutingNumeric : IRouting + { + void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); + } + + public interface ITxRouting : IRoutingNumeric { IntFeedback VideoSourceNumericFeedback { get; } IntFeedback AudioSourceNumericFeedback { get; } - void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); } /// /// Defines a receiver that has internal routing (DM-RMC-4K-Z-SCALER-C) /// - public interface IRmcRouting : IRouting + public interface IRmcRouting : IRoutingNumeric { IntFeedback AudioVideoSourceNumericFeedback { get; } - void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); } /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 5e9c3151..3094c7fd 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -21,7 +21,8 @@ namespace PepperDash.Essentials.DM { /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// /// - public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback { + public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumeric + { public DMChassisPropertiesConfig PropertiesConfig { get; set; } public Switch Chassis { get; private set; } @@ -563,14 +564,23 @@ namespace PepperDash.Essentials.DM { var outCard = input == 0 ? null : Chassis.Outputs[output]; // NOTE THAT BITWISE COMPARISONS - TO CATCH ALL ROUTING TYPES - if ((sigType | eRoutingSignalType.Video) == eRoutingSignalType.Video) { - Chassis.VideoEnter.BoolValue = true; - Chassis.Outputs[output].VideoOut = inCard; - } + if ((sigType | eRoutingSignalType.Video) != eRoutingSignalType.Video) return; + Chassis.VideoEnter.BoolValue = true; + Chassis.Outputs[output].VideoOut = inCard; } #endregion + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + ExecuteSwitch(inputSelector, outputSelector, sigType); + } + + #endregion + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { var joinMap = new DmBladeChassisControllerJoinMap(joinStart); @@ -808,6 +818,7 @@ namespace PepperDash.Essentials.DM { }); } } + } /* diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index b0d4682d..2d9a847f 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -21,7 +21,7 @@ namespace PepperDash.Essentials.DM /// /// [Description("Wrapper class for all DM-MD chassis variants from 8x8 to 32x32")] - public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingInputsOutputs, IRouting, IHasFeedback + public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumeric { public DMChassisPropertiesConfig PropertiesConfig { get; set; } @@ -1094,6 +1094,15 @@ namespace PepperDash.Essentials.DM } #endregion + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + ExecuteSwitch(inputSelector, outputSelector, sigType); + } + + #endregion + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { var joinMap = new DmChassisControllerJoinMap(joinStart); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs index 7d8ba747..32352b49 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmpsRoutingController.cs @@ -18,8 +18,8 @@ using PepperDash.Essentials.DM.Config; using Feedback = PepperDash.Essentials.Core.Feedback; namespace PepperDash.Essentials.DM -{ - public class DmpsRoutingController : EssentialsBridgeableDevice, IRouting, IHasFeedback +{ + public class DmpsRoutingController : EssentialsBridgeableDevice, IRoutingNumeric, IHasFeedback { public CrestronControlSystem Dmps { get; set; } public ISystemControl SystemControl { get; private set; } @@ -661,8 +661,6 @@ namespace PepperDash.Essentials.DM } } } - /// - /// void Dmps_DMOutputChange(Switch device, DMOutputEventArgs args) { Debug.Console(2, this, "DMOutputChange Output: {0} EventId: {1}", args.Number, args.EventId.ToString()); @@ -724,10 +722,7 @@ namespace PepperDash.Essentials.DM { if (RouteOffTimers.ContainsKey(pnt)) return; - RouteOffTimers[pnt] = new CTimer(o => - { - ExecuteSwitch(0, pnt.Number, pnt.Type); - }, RouteOffTime); + RouteOffTimers[pnt] = new CTimer(o => ExecuteSwitch(0, pnt.Number, pnt.Type), RouteOffTime); } #region IRouting Members @@ -809,6 +804,15 @@ namespace PepperDash.Essentials.DM } } - #endregion + #endregion + + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType sigType) + { + ExecuteSwitch(inputSelector, outputSelector, sigType); + } + + #endregion } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs index 87cc72cf..47f4c572 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEBridgeableController.cs @@ -16,7 +16,7 @@ using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.DM.Chassis { [Description("Wrapper class for all HdMdNxM4E switchers")] - public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback + public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingInputsOutputs, IRoutingNumeric, IHasFeedback { private HdMdNxM _Chassis; private HdMd4x14kE _Chassis4x1; @@ -240,6 +240,15 @@ namespace PepperDash.Essentials.DM.Chassis #endregion + #region IRoutingNumeric Members + + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) + { + ExecuteSwitch(inputSelector, outputSelector, signalType); + } + + #endregion + #endregion #region Bridge Linking @@ -389,6 +398,8 @@ namespace PepperDash.Essentials.DM.Chassis } #endregion - + + + } } \ No newline at end of file From 2f1592bc62ab4d8a44d19f0c109d7843ffd42da1 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 22 May 2020 14:56:50 -0500 Subject: [PATCH 2/2] Added XML Comments, Obsolete Message, and backer field #214 --- .../JoinMaps/JoinMapBase.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 8d50596e..676299e5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -346,8 +346,10 @@ namespace PepperDash.Essentials.Core /// /// Metadata describing the join /// - public class JoinMetadata - { + public class JoinMetadata + { + private string _description; + /// /// Join number (based on join offset value) /// @@ -362,14 +364,17 @@ namespace PepperDash.Essentials.Core public uint JoinSpan { get; set; } /// - /// A label for the join to better describe it's usage + /// A label for the join to better describe its usage /// - [Obsolete] + [Obsolete("Use Description instead")] [JsonProperty("label")] - public string Label { get { return Description; } set { Description = value; } } + public string Label { get { return _description; } set { _description = value; } } - [JsonProperty("description")] - public string Description { get; set; } + /// + /// A description for the join to better describe its usage + /// + [JsonProperty("description")] + public string Description { get { return _description; } set { _description = value; } } /// /// Signal type(s) ///