mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
Added try/catch to ParseUptime with a way to view what was being parsed
This commit is contained in:
@@ -91,6 +91,9 @@ namespace PepperDash.Essentials
|
|||||||
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
|
|
||||||
|
CrestronConsole.AddNewConsoleCommand(DeviceManager.GetRoutingPorts,
|
||||||
|
"getroutingports", "Reports all routing ports, if any. Requires a device key", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
if (!Debug.DoNotLoadOnNextBoot)
|
if (!Debug.DoNotLoadOnNextBoot)
|
||||||
{
|
{
|
||||||
GoWithLoad(null);
|
GoWithLoad(null);
|
||||||
|
|||||||
@@ -337,7 +337,36 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
com.SimulateReceive(match.Groups[2].Value);
|
com.SimulateReceive(match.Groups[2].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prints a list of routing inputs and outputs by device key.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">Device key from which to report data</param>
|
||||||
|
public static void GetRoutingPorts(string s)
|
||||||
|
{
|
||||||
|
var device = GetDeviceForKey(s);
|
||||||
|
|
||||||
|
if (device == null) return;
|
||||||
|
var inputPorts = (device as IRoutingInputsOutputs).InputPorts;
|
||||||
|
var outputPorts = (device as IRoutingInputsOutputs).OutputPorts;
|
||||||
|
if (inputPorts != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count);
|
||||||
|
foreach (var routingInputPort in inputPorts)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "{0}", routingInputPort.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (outputPorts != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count);
|
||||||
|
foreach (var routingOutputPort in outputPorts)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "{0}", routingOutputPort.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to set the debug level of a device
|
/// Attempts to set the debug level of a device
|
||||||
|
|||||||
@@ -103,20 +103,27 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ParseUptime(string response)
|
private void ParseUptime(string response)
|
||||||
{
|
{
|
||||||
var splitString = response.Trim().Split('\r', '\n');
|
try
|
||||||
|
{
|
||||||
var lastStartRaw = splitString[2];
|
var splitString = response.Trim().Split('\r', '\n');
|
||||||
var lastStartIndex = lastStartRaw.IndexOf(':');
|
|
||||||
|
var lastStartRaw = splitString[2];
|
||||||
_lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim();
|
var lastStartIndex = lastStartRaw.IndexOf(':');
|
||||||
|
|
||||||
var uptimeRaw = splitString[0];
|
_lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim();
|
||||||
|
|
||||||
var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal);
|
var uptimeRaw = splitString[0];
|
||||||
|
|
||||||
//4 => "for " to get what's on the right
|
var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal);
|
||||||
_uptime = uptimeRaw.Substring(forIndex + 4);
|
|
||||||
|
//4 => "for " to get what's on the right
|
||||||
|
_uptime = uptimeRaw.Substring(forIndex + 4);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ErrorLog.Exception(String.Format("Exception unable to parse string '{1}'", response), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs)
|
private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs)
|
||||||
|
|||||||
Reference in New Issue
Block a user