mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
Merge pull request #369 from PepperDash/bugfix/SystemMonitor-IndexOutOfRange
Fix system monitor index out of range exception
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();
|
GoWithLoad();
|
||||||
|
|||||||
@@ -339,6 +339,35 @@ namespace PepperDash.Essentials.Core
|
|||||||
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
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.Diagnostics;
|
using Crestron.SimplSharpPro.Diagnostics;
|
||||||
@@ -106,13 +107,16 @@ namespace PepperDash.Essentials.Core.Monitoring
|
|||||||
{
|
{
|
||||||
var splitString = response.Trim().Split('\r', '\n');
|
var splitString = response.Trim().Split('\r', '\n');
|
||||||
|
|
||||||
var lastStartRaw = splitString[2];
|
var lastStartRaw = splitString.FirstOrDefault(o => o.Contains("started"));
|
||||||
var lastStartIndex = lastStartRaw.IndexOf(':');
|
var uptimeRaw = splitString.FirstOrDefault(o => o.Contains("running"));
|
||||||
|
|
||||||
_lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim();
|
if (!String.IsNullOrEmpty(lastStartRaw))
|
||||||
|
{
|
||||||
var uptimeRaw = splitString[0];
|
var lastStartIndex = lastStartRaw.IndexOf(':');
|
||||||
|
_lastStart = lastStartRaw.Substring(lastStartIndex + 1).Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(uptimeRaw)) return;
|
||||||
var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal);
|
var forIndex = uptimeRaw.IndexOf("for", StringComparison.Ordinal);
|
||||||
|
|
||||||
//4 => "for " to get what's on the right
|
//4 => "for " to get what's on the right
|
||||||
|
|||||||
Reference in New Issue
Block a user