From 703695e768eaadd0f6bfdc37b5b125a2596c312c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 3 Apr 2020 09:25:48 -0600 Subject: [PATCH] Adds console method to print join maps at runtime. Adds overload of LinkToApi extension method for IBridge to allow passing the bridge in for JoinMapBaseAdvance applications --- PepperDashEssentials/Bridges/BridgeBase.cs | 70 +++++++++++++++++++ PepperDashEssentials/Bridges/IBridge.cs | 2 + PepperDashEssentials/ControlSystem.cs | 3 +- .../JoinMaps/JoinMapBase.cs | 9 ++- .../Touchpanels/Mpc3Touchpanel.cs | 7 +- 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 0c4e388b..de283e4e 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -20,6 +20,46 @@ using PepperDash.Essentials.DM; namespace PepperDash.Essentials.Bridges { + /// + /// Helper methods for bridges + /// + public static class BridgeHelper + { + public static void PrintJoinMap(string command) + { + string bridgeKey = ""; + string deviceKey = ""; + + var targets = command.Split(' '); + + bridgeKey = targets[0].Trim(); + + var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApi; + + if (bridge == null) + { + Debug.Console(0, "Unable to find bridge with key: '{0}'", bridgeKey); + return; + } + + if (targets.Length > 1) + { + deviceKey = targets[1].Trim(); + + if (!string.IsNullOrEmpty(deviceKey)) + { + bridge.PrintJoinMapForDevice(deviceKey); + return; + } + } + else + { + bridge.PrintJoinMaps(); + } + } + } + + /// /// Base class for all bridge class variants /// @@ -206,6 +246,36 @@ namespace PepperDash.Essentials.Bridges } } + /// + /// Prints all the join maps on this bridge + /// + public void PrintJoinMaps() + { + Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); + + foreach (var joinMap in JoinMaps) + { + joinMap.Value.PrintJoinMapInfo(); + } + } + + /// + /// Prints the join map for a device by key + /// + /// + public void PrintJoinMapForDevice(string deviceKey) + { + var joinMap = JoinMaps[deviceKey]; + + if (joinMap == null) + { + Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + return; + } + + joinMap.PrintJoinMapInfo(); + } + /// /// Used for debugging to trigger an action based on a join number and type /// diff --git a/PepperDashEssentials/Bridges/IBridge.cs b/PepperDashEssentials/Bridges/IBridge.cs index d86a1d1d..f95189a0 100644 --- a/PepperDashEssentials/Bridges/IBridge.cs +++ b/PepperDashEssentials/Bridges/IBridge.cs @@ -10,5 +10,7 @@ namespace PepperDash.Essentials.Bridges public interface IBridge { void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey); + + void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge); } } \ No newline at end of file diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f4046c85..d1ca9b0d 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -51,7 +51,8 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); - // CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Bridges.BridgeHelper.PrintJoinMap, "getjoinmap", "gets map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => { Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 8ea1cf7f..9e9538e1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -48,16 +48,17 @@ namespace PepperDash.Essentials.Core if (joinMapSerialzed != null) { - var joinMap = JsonConvert.DeserializeObject>(joinMapSerialzed); + var joinMapData = JsonConvert.DeserializeObject>(joinMapSerialzed); - if (joinMap != null) - return joinMap; + if (joinMapData != null) + return joinMapData; else return null; } else return null; } + } /// @@ -255,6 +256,8 @@ namespace PepperDash.Essentials.Core Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key); } } + + PrintJoinMapInfo(); } ///// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 6c648a29..c9a5f605 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -28,7 +28,6 @@ namespace PepperDash.Essentials.Core.Touchpanels _Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange); - AddPostActivationAction(() => { // Link up the button feedbacks to the specified BoolFeedbacks @@ -40,7 +39,7 @@ namespace PepperDash.Essentials.Core.Touchpanels { var bKey = button.Key.ToLower(); - var feedback = device.GetFeedbackProperty(feedbackConfig.BoolFeedbackName); + var feedback = device.GetFeedbackProperty(feedbackConfig.FeedbackName); var bFeedback = feedback as BoolFeedback; var iFeedback = feedback as IntFeedback; @@ -72,7 +71,7 @@ namespace PepperDash.Essentials.Core.Touchpanels } else { - Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.BoolFeedbackName, device.Key); + Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.FeedbackName, device.Key); } } else @@ -140,6 +139,6 @@ namespace PepperDash.Essentials.Core.Touchpanels public class KeypadButtonFeedback { public string DeviceKey { get; set; } - public string BoolFeedbackName { get; set; } + public string FeedbackName { get; set; } } } \ No newline at end of file