mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Merge pull request #1068 from PepperDash/feature/ConsoleImprovements
Update console commands to use ConsoleCommandResponse
This commit is contained in:
@@ -80,7 +80,7 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator);
|
CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
|
|||||||
@@ -388,19 +388,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null;
|
var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null;
|
||||||
if (inputPorts != null)
|
if (inputPorts != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count);
|
CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:", s, inputPorts.Count);
|
||||||
foreach (var routingInputPort in inputPorts)
|
foreach (var routingInputPort in inputPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0}", routingInputPort.Key);
|
CrestronConsole.ConsoleCommandResponse("{0}", routingInputPort.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (outputPorts != null)
|
if (outputPorts == null) return;
|
||||||
{
|
CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:", s, outputPorts.Count);
|
||||||
Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count);
|
|
||||||
foreach (var routingOutputPort in outputPorts)
|
foreach (var routingOutputPort in outputPorts)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0}", routingOutputPort.Key);
|
CrestronConsole.ConsoleCommandResponse("{0}", routingOutputPort.Key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +433,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (device == null)
|
if (device == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to get device with key: {0}", deviceKey);
|
CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +445,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both");
|
CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,18 +456,18 @@ namespace PepperDash.Essentials.Core
|
|||||||
var min = Convert.ToUInt32(timeout);
|
var min = Convert.ToUInt32(timeout);
|
||||||
|
|
||||||
device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min);
|
device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min);
|
||||||
Debug.Console(0, "Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min);
|
CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e);
|
CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting);
|
device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting);
|
||||||
Debug.Console(0, "Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting);
|
CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,21 +172,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints the type names and associated metadata from the FactoryMethods collection.
|
/// Prints the type names and associated metadata from the FactoryMethods collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="command"></param>
|
/// <param name="filter"></param>
|
||||||
public static void GetDeviceFactoryTypes(string filter)
|
public static void GetDeviceFactoryTypes(string filter)
|
||||||
{
|
{
|
||||||
Dictionary<string, DeviceFactoryWrapper> types = new Dictionary<string, DeviceFactoryWrapper>();
|
var types = !string.IsNullOrEmpty(filter)
|
||||||
|
? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value)
|
||||||
|
: FactoryMethods;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(filter))
|
CrestronConsole.ConsoleCommandResponse("Device Types:");
|
||||||
{
|
|
||||||
types = FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
types = FactoryMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(0, "Device Types:");
|
|
||||||
|
|
||||||
foreach (var type in types.OrderBy(t => t.Key))
|
foreach (var type in types.OrderBy(t => t.Key))
|
||||||
{
|
{
|
||||||
@@ -198,7 +191,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
cType = type.Value.CType.FullName;
|
cType = type.Value.CType.FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0,
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
@"Type: '{0}'
|
@"Type: '{0}'
|
||||||
CType: '{1}'
|
CType: '{1}'
|
||||||
Description: {2}", type.Key, cType, description);
|
Description: {2}", type.Key, cType, description);
|
||||||
|
|||||||
@@ -101,22 +101,22 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PrintJoinMapInfo()
|
public void PrintJoinMapInfo()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0}:\n", GetType().Name);
|
CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name);
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
// Get the joins of each type and print them
|
||||||
Debug.Console(0, "Digitals:");
|
CrestronConsole.ConsoleCommandResponse("Digitals:");
|
||||||
var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
||||||
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count);
|
||||||
PrintJoinList(GetSortedJoins(digitals));
|
PrintJoinList(GetSortedJoins(digitals));
|
||||||
|
|
||||||
Debug.Console(0, "Analogs:");
|
CrestronConsole.ConsoleCommandResponse("Analogs:");
|
||||||
var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
||||||
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count);
|
||||||
PrintJoinList(GetSortedJoins(analogs));
|
PrintJoinList(GetSortedJoins(analogs));
|
||||||
|
|
||||||
Debug.Console(0, "Serials:");
|
CrestronConsole.ConsoleCommandResponse("Serials:");
|
||||||
var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
||||||
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count);
|
||||||
PrintJoinList(GetSortedJoins(serials));
|
PrintJoinList(GetSortedJoins(serials));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
foreach (var join in joins)
|
foreach (var join in joins)
|
||||||
{
|
{
|
||||||
Debug.Console(0,
|
CrestronConsole.ConsoleCommandResponse(
|
||||||
@"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
@"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
||||||
join.Value.JoinNumber,
|
join.Value.JoinNumber,
|
||||||
join.Value.Label,
|
join.Value.Label,
|
||||||
@@ -280,7 +280,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
var pluginType = GetType().Name;
|
var pluginType = GetType().Name;
|
||||||
|
|
||||||
Debug.Console(0, "{0}:\n", pluginType);
|
CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
using (var sw = new StreamWriter(fileName))
|
using (var sw = new StreamWriter(fileName))
|
||||||
{
|
{
|
||||||
sw.WriteLine(stringBuilder.ToString());
|
sw.WriteLine(stringBuilder.ToString());
|
||||||
Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName);
|
CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -314,20 +314,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
return sortedJoins;
|
return sortedJoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintJoinList(IEnumerable<KeyValuePair<string, JoinDataComplete>> joins)
|
|
||||||
{
|
|
||||||
foreach (var join in joins)
|
|
||||||
{
|
|
||||||
Debug.Console(0,
|
|
||||||
@"Join Number: {0} | JoinSpan: '{1}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'",
|
|
||||||
join.Value.JoinNumber,
|
|
||||||
join.Value.JoinSpan,
|
|
||||||
join.Key,
|
|
||||||
String.IsNullOrEmpty(join.Value.AttributeName) ? join.Value.Metadata.Label : join.Value.AttributeName,
|
|
||||||
join.Value.Metadata.JoinType.ToString(),
|
|
||||||
join.Value.Metadata.JoinCapabilities.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static StringBuilder AppendJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
static StringBuilder AppendJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -194,10 +194,11 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="command"></param>
|
/// <param name="command"></param>
|
||||||
public static void ReportAssemblyVersions(string command)
|
public static void ReportAssemblyVersions(string command)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Loaded Assemblies:");
|
|
||||||
|
CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:");
|
||||||
foreach (var assembly in LoadedAssemblies)
|
foreach (var assembly in LoadedAssemblies)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0} Version: {1}", assembly.Name, assembly.Version);
|
CrestronConsole.ConsoleCommandResponse("{0} Version: {1}", assembly.Name, assembly.Version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user