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

This commit is contained in:
Neil Dorin
2020-04-03 09:25:48 -06:00
parent bb3897160b
commit 703695e768
5 changed files with 83 additions and 8 deletions

View File

@@ -20,6 +20,46 @@ using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
/// <summary>
/// Helper methods for bridges
/// </summary>
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();
}
}
}
/// <summary>
/// Base class for all bridge class variants
/// </summary>
@@ -206,6 +246,36 @@ namespace PepperDash.Essentials.Bridges
}
}
/// <summary>
/// Prints all the join maps on this bridge
/// </summary>
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();
}
}
/// <summary>
/// Prints the join map for a device by key
/// </summary>
/// <param name="deviceKey"></param>
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();
}
/// <summary>
/// Used for debugging to trigger an action based on a join number and type
/// </summary>

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -48,16 +48,17 @@ namespace PepperDash.Essentials.Core
if (joinMapSerialzed != null)
{
var joinMap = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
var joinMapData = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
if (joinMap != null)
return joinMap;
if (joinMapData != null)
return joinMapData;
else
return null;
}
else
return null;
}
}
/// <summary>
@@ -255,6 +256,8 @@ namespace PepperDash.Essentials.Core
Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key);
}
}
PrintJoinMapInfo();
}
///// <summary>

View File

@@ -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; }
}
}