mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 13:14:49 +00:00
Completed SystemInfo class, created example program for testing. PepperDash Core updates ready for review. Additional changes made to core: Moved EventArgs from JsonToSimpl to root of core for access to the Bool, Ushrt, String change event args classes
This commit is contained in:
@@ -110,14 +110,10 @@
|
|||||||
<Compile Include="JsonToSimpl\JsonToSimplGenericMaster.cs" />
|
<Compile Include="JsonToSimpl\JsonToSimplGenericMaster.cs" />
|
||||||
<Compile Include="JsonToSimpl\JsonToSimplMaster.cs" />
|
<Compile Include="JsonToSimpl\JsonToSimplMaster.cs" />
|
||||||
<Compile Include="Network\DiscoveryThings.cs" />
|
<Compile Include="Network\DiscoveryThings.cs" />
|
||||||
<Compile Include="SystemInfo\ConsoleHelper.cs" />
|
|
||||||
<Compile Include="SystemInfo\ControlSubnetInfo.cs" />
|
|
||||||
<Compile Include="SystemInfo\EthernetInfo.cs" />
|
|
||||||
<Compile Include="SystemInfo\EventArgs and Constants.cs" />
|
<Compile Include="SystemInfo\EventArgs and Constants.cs" />
|
||||||
<Compile Include="SystemInfo\ProcessorInfo.cs" />
|
<Compile Include="SystemInfo\SystemInfoConfig.cs" />
|
||||||
<Compile Include="SystemInfo\ProgramInfo.cs" />
|
|
||||||
<Compile Include="SystemInfo\SystemInfoToSimpl.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="SystemInfo\SystemInfoToSimpl.cs" />
|
||||||
<Compile Include="WebApi\Presets\Preset.cs" />
|
<Compile Include="WebApi\Presets\Preset.cs" />
|
||||||
<Compile Include="WebApi\Presets\User.cs" />
|
<Compile Include="WebApi\Presets\User.cs" />
|
||||||
<Compile Include="WebApi\Presets\WebApiPasscodeClient.cs" />
|
<Compile Include="WebApi\Presets\WebApiPasscodeClient.cs" />
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Console helper class
|
|
||||||
/// </summary>
|
|
||||||
public class ConsoleHelper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Cosntructor
|
|
||||||
/// </summary>
|
|
||||||
public ConsoleHelper()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Parse console respopnse method
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="cmd"></param>
|
|
||||||
/// <param name="line"></param>
|
|
||||||
/// <param name="startString"></param>
|
|
||||||
/// <param name="endString"></param>
|
|
||||||
/// <returns>console response</returns>
|
|
||||||
public string ParseConsoleResponse(string response, string line, string startString, string endString)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(response) || string.IsNullOrEmpty(line) || string.IsNullOrEmpty(startString) || string.IsNullOrEmpty(endString))
|
|
||||||
return "";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var linePos = response.IndexOf(line);
|
|
||||||
var startPos = response.IndexOf(startString, linePos) + startString.Length;
|
|
||||||
var endPos = response.IndexOf(endString, startPos);
|
|
||||||
response = response.Substring(startPos, endPos - startPos).Trim();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("ConsoleHelper.ParseConsoleResponse failed:\r{0}", e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Control subnet class
|
|
||||||
/// </summary>
|
|
||||||
public class ControlSubnetConfig
|
|
||||||
{
|
|
||||||
public ushort Enabled { get; set; }
|
|
||||||
public ushort IsInAutomaticMode { get; set; }
|
|
||||||
public string MacAddress { get; set; }
|
|
||||||
public string IpAddress { get; set; }
|
|
||||||
public string Subnet { get; set; }
|
|
||||||
public string RouterPrefix { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ControlSubnetConfig()
|
|
||||||
{
|
|
||||||
// add logic here if necessary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Control subnet info class
|
|
||||||
/// </summary>
|
|
||||||
public class ControlSubnetInfo
|
|
||||||
{
|
|
||||||
public ControlSubnetConfig properties { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ControlSubnetInfo()
|
|
||||||
{
|
|
||||||
properties.Enabled = (ushort)0;
|
|
||||||
properties.IsInAutomaticMode = (ushort)0;
|
|
||||||
properties.MacAddress = "NA";
|
|
||||||
properties.IpAddress = "NA";
|
|
||||||
properties.Subnet = "NA";
|
|
||||||
properties.RouterPrefix = "NA";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get control subnet info
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool GetInfo()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// get cs adapter id
|
|
||||||
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
|
|
||||||
if (!adapterId.Equals(EthernetAdapterType.EthernetUnknownAdapter))
|
|
||||||
{
|
|
||||||
properties.Enabled = (ushort)EthernetAdapterType.EthernetCSAdapter;
|
|
||||||
properties.IsInAutomaticMode = (ushort)(CrestronEthernetHelper.IsControlSubnetInAutomaticMode ? 1 : 0);
|
|
||||||
properties.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
|
|
||||||
properties.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
|
|
||||||
properties.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
|
|
||||||
properties.RouterPrefix = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CONTROL_SUBNET_ROUTER_PREFIX, adapterId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("ControlSubnetInfo.GetInfo() failed:\r{0}", e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Ethernet class
|
|
||||||
/// </summary>
|
|
||||||
public class EthernetConfig
|
|
||||||
{
|
|
||||||
public ushort DhcpIsOn { get; set; }
|
|
||||||
public string Hostname { get; set; }
|
|
||||||
public string MacAddress { get; set; }
|
|
||||||
public string IpAddress { get; set; }
|
|
||||||
public string Subnet { get; set; }
|
|
||||||
public string Gateway { get; set; }
|
|
||||||
public string Dns1 { get; set; }
|
|
||||||
public string Dns2 { get; set; }
|
|
||||||
public string Dns3 { get; set; }
|
|
||||||
public string Domain { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public EthernetConfig()
|
|
||||||
{
|
|
||||||
// add logic here if necessary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public class EthernetInfo
|
|
||||||
{
|
|
||||||
public EthernetConfig properties { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public EthernetInfo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool GetInfo()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// get lan adapter id
|
|
||||||
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
|
|
||||||
|
|
||||||
// get lan adapter info
|
|
||||||
var dhcpState = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId);
|
|
||||||
if (!string.IsNullOrEmpty(dhcpState))
|
|
||||||
properties.DhcpIsOn = (ushort)(dhcpState.ToLower().Contains("on") ? 1 : 0);
|
|
||||||
|
|
||||||
properties.Hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId);
|
|
||||||
properties.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
|
|
||||||
properties.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
|
|
||||||
properties.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
|
|
||||||
properties.Gateway = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterId);
|
|
||||||
properties.Domain = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId);
|
|
||||||
|
|
||||||
// returns comma seperate list of dns servers with trailing comma
|
|
||||||
// example return: "8.8.8.8 (DHCP),8.8.4.4 (DHCP),"
|
|
||||||
string dns = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId);
|
|
||||||
if (string.IsNullOrEmpty(dns))
|
|
||||||
{
|
|
||||||
properties.Dns1 = "0.0.0.0";
|
|
||||||
properties.Dns2 = "0.0.0.0";
|
|
||||||
properties.Dns3 = "0.0.0.0";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dns.Contains(","))
|
|
||||||
{
|
|
||||||
string[] dnsList = dns.Split(',');
|
|
||||||
properties.Dns1 = !string.IsNullOrEmpty(dnsList[0]) ? dnsList[0] : "0.0.0.0";
|
|
||||||
properties.Dns2 = !string.IsNullOrEmpty(dnsList[1]) ? dnsList[1] : "0.0.0.0";
|
|
||||||
properties.Dns3 = !string.IsNullOrEmpty(dnsList[2]) ? dnsList[2] : "0.0.0.0";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
properties.Dns1 = !string.IsNullOrEmpty(dns) ? dns : "0.0.0.0";
|
|
||||||
properties.Dns2 = "0.0.0.0";
|
|
||||||
properties.Dns3 = "0.0.0.0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("EthernetInfo.GetInfo() failed:\r{0}", e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,10 +23,10 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
public const ushort ProgramUptimeChange = 204;
|
public const ushort ProgramUptimeChange = 204;
|
||||||
|
|
||||||
public const ushort ObjectChange = 301;
|
public const ushort ObjectChange = 301;
|
||||||
public const ushort ProcessorObjectChange = 302;
|
public const ushort ProcessorConfigChange = 302;
|
||||||
public const ushort EthernetObjectChange = 303;
|
public const ushort EthernetConfigChange = 303;
|
||||||
public const ushort ControlSubnetObjectChange = 304;
|
public const ushort ControlSubnetConfigChange = 304;
|
||||||
public const ushort ProgramObjectChange = 305;
|
public const ushort ProgramConfigChange = 305;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -34,7 +34,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessorChangeEventArgs : EventArgs
|
public class ProcessorChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public ProcessorConfig Processor { get; set; }
|
public ProcessorInfo Processor { get; set; }
|
||||||
public ushort Type { get; set; }
|
public ushort Type { get; set; }
|
||||||
public ushort Index { get; set; }
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor overload
|
/// Constructor overload
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessorChangeEventArgs(ProcessorConfig processor, ushort type)
|
public ProcessorChangeEventArgs(ProcessorInfo processor, ushort type)
|
||||||
{
|
{
|
||||||
Processor = processor;
|
Processor = processor;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -58,7 +58,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProcessorChangeEventArgs(ProcessorConfig processor, ushort type, ushort index)
|
public ProcessorChangeEventArgs(ProcessorInfo processor, ushort type, ushort index)
|
||||||
{
|
{
|
||||||
Processor = processor;
|
Processor = processor;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -71,7 +71,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EthernetChangeEventArgs : EventArgs
|
public class EthernetChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public EthernetConfig Adapter { get; set; }
|
public EthernetInfo Adapter { get; set; }
|
||||||
public ushort Type { get; set; }
|
public ushort Type { get; set; }
|
||||||
public ushort Index { get; set; }
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Ethernet"></param>
|
/// <param name="Ethernet"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
public EthernetChangeEventArgs(EthernetConfig ethernet, ushort type)
|
public EthernetChangeEventArgs(EthernetInfo ethernet, ushort type)
|
||||||
{
|
{
|
||||||
Adapter = ethernet;
|
Adapter = ethernet;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -99,7 +99,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Ethernet"></param>
|
/// <param name="Ethernet"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
public EthernetChangeEventArgs(EthernetConfig ethernet, ushort type, ushort index)
|
public EthernetChangeEventArgs(EthernetInfo ethernet, ushort type, ushort index)
|
||||||
{
|
{
|
||||||
Adapter = ethernet;
|
Adapter = ethernet;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -112,7 +112,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlSubnetChangeEventArgs : EventArgs
|
public class ControlSubnetChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public ControlSubnetConfig Adapter { get; set; }
|
public ControlSubnetInfo Adapter { get; set; }
|
||||||
public ushort Type { get; set; }
|
public ushort Type { get; set; }
|
||||||
public ushort Index { get; set; }
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor overload
|
/// Constructor overload
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ControlSubnetChangeEventArgs(ControlSubnetConfig controlSubnet, ushort type)
|
public ControlSubnetChangeEventArgs(ControlSubnetInfo controlSubnet, ushort type)
|
||||||
{
|
{
|
||||||
Adapter = controlSubnet;
|
Adapter = controlSubnet;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -136,7 +136,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor overload
|
/// Constructor overload
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ControlSubnetChangeEventArgs(ControlSubnetConfig controlSubnet, ushort type, ushort index)
|
public ControlSubnetChangeEventArgs(ControlSubnetInfo controlSubnet, ushort type, ushort index)
|
||||||
{
|
{
|
||||||
Adapter = controlSubnet;
|
Adapter = controlSubnet;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -149,7 +149,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProgramChangeEventArgs : EventArgs
|
public class ProgramChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public ProgramConfig Program { get; set; }
|
public ProgramInfo Program { get; set; }
|
||||||
public ushort Type { get; set; }
|
public ushort Type { get; set; }
|
||||||
public ushort Index { get; set; }
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Program"></param>
|
/// <param name="Program"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
public ProgramChangeEventArgs(ProgramConfig program, ushort type)
|
public ProgramChangeEventArgs(ProgramInfo program, ushort type)
|
||||||
{
|
{
|
||||||
Program = program;
|
Program = program;
|
||||||
Type = type;
|
Type = type;
|
||||||
@@ -177,7 +177,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Program"></param>
|
/// <param name="Program"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
public ProgramChangeEventArgs(ProgramConfig program, ushort type, ushort index)
|
public ProgramChangeEventArgs(ProgramInfo program, ushort type, ushort index)
|
||||||
{
|
{
|
||||||
Program = program;
|
Program = program;
|
||||||
Type = type;
|
Type = type;
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Processor properties class
|
|
||||||
/// </summary>
|
|
||||||
public class ProcessorConfig
|
|
||||||
{
|
|
||||||
public string Model { get; set; }
|
|
||||||
public string SerialNumber { get; set; }
|
|
||||||
public string Firmware { get; set; }
|
|
||||||
public string FirmwareDate { get; set; }
|
|
||||||
public string OsVersion { get; set; }
|
|
||||||
public string RuntimeEnvironment { get; set; }
|
|
||||||
public string DevicePlatform { get; set; }
|
|
||||||
public string ModuleDirectory { get; set; }
|
|
||||||
public string LocalTimeZone { get; set; }
|
|
||||||
public string ProgramIdTag { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ProcessorConfig()
|
|
||||||
{
|
|
||||||
Model = "";
|
|
||||||
SerialNumber = "";
|
|
||||||
Firmware = "";
|
|
||||||
FirmwareDate = "";
|
|
||||||
OsVersion = "";
|
|
||||||
RuntimeEnvironment = "";
|
|
||||||
DevicePlatform = "";
|
|
||||||
ModuleDirectory = "";
|
|
||||||
LocalTimeZone = "";
|
|
||||||
ProgramIdTag = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public class ProcessorInfo
|
|
||||||
{
|
|
||||||
public ProcessorConfig properties { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ProcessorInfo()
|
|
||||||
{
|
|
||||||
properties.Model = "";
|
|
||||||
properties.SerialNumber = "";
|
|
||||||
properties.Firmware = "";
|
|
||||||
properties.FirmwareDate = "";
|
|
||||||
properties.OsVersion = "";
|
|
||||||
properties.RuntimeEnvironment = "";
|
|
||||||
properties.DevicePlatform = "";
|
|
||||||
properties.ModuleDirectory = "";
|
|
||||||
properties.LocalTimeZone = "";
|
|
||||||
properties.ProgramIdTag = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get processor info method
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>bool</returns>
|
|
||||||
public bool GetInfo()
|
|
||||||
{
|
|
||||||
var console = new ConsoleHelper();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
properties.Model = InitialParametersClass.ControllerPromptName;
|
|
||||||
properties.SerialNumber = CrestronEnvironment.SystemInfo.SerialNumber;
|
|
||||||
properties.ModuleDirectory = InitialParametersClass.ProgramDirectory.ToString();
|
|
||||||
properties.ProgramIdTag = InitialParametersClass.ProgramIDTag;
|
|
||||||
properties.DevicePlatform = CrestronEnvironment.DevicePlatform.ToString();
|
|
||||||
properties.OsVersion = CrestronEnvironment.OSVersion.Version.ToString();
|
|
||||||
properties.RuntimeEnvironment = CrestronEnvironment.RuntimeEnvironment.ToString();
|
|
||||||
properties.LocalTimeZone = CrestronEnvironment.GetTimeZone().Offset;
|
|
||||||
|
|
||||||
// Does not return firmware version matching a "ver" command
|
|
||||||
// returns the "ver -v" 'CAB' version
|
|
||||||
// example return ver -v:
|
|
||||||
// RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
|
|
||||||
// Build: 14:05:46 Oct 09 2018 (3568.25373)
|
|
||||||
// Cab: 1.503.0070
|
|
||||||
// Applications: 1.0.6855.21351
|
|
||||||
// Updater: 1.4.24
|
|
||||||
// Bootloader: 1.22.00
|
|
||||||
// RMC3-SetupProgram: 1.003.0011
|
|
||||||
// IOPVersion: FPGA [v09] slot:7
|
|
||||||
// PUF: Unknown
|
|
||||||
//Firmware = CrestronEnvironment.OSVersion.Firmware;
|
|
||||||
//Firmware = InitialParametersClass.FirmwareVersion;
|
|
||||||
|
|
||||||
// Use below logic to get actual firmware ver, not the 'CAB' returned by the above
|
|
||||||
// matches console return of a "ver" and on SystemInfo page
|
|
||||||
// example return ver:
|
|
||||||
// RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
|
|
||||||
var response = "";
|
|
||||||
CrestronConsole.SendControlSystemCommand("ver", ref response);
|
|
||||||
properties.Firmware = console.ParseConsoleResponse(response, "Cntrl Eng", "[", "(");
|
|
||||||
properties.FirmwareDate = console.ParseConsoleResponse(response, "Cntrl Eng", "(", ")");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("ProcessorInfo.GetInfo() failed:\r{0}", e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Program class
|
|
||||||
/// </summary>
|
|
||||||
public class ProgramConfig
|
|
||||||
{
|
|
||||||
public string Key { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Header { get; set; }
|
|
||||||
public string System { get; set; }
|
|
||||||
public string CompileTime { get; set; }
|
|
||||||
public string Database { get; set; }
|
|
||||||
public string Environment { get; set; }
|
|
||||||
public string Programmer { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ProgramConfig()
|
|
||||||
{
|
|
||||||
// add logic here if necessary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Program info class
|
|
||||||
/// </summary>
|
|
||||||
public class ProgramInfo
|
|
||||||
{
|
|
||||||
public ProgramConfig properties { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
public ProgramInfo()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get program info by index
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool GetInfoByIndex(int index)
|
|
||||||
{
|
|
||||||
var console = new ConsoleHelper();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string response = "";
|
|
||||||
CrestronConsole.SendControlSystemCommand(string.Format("progcomments:{0}", index), ref response);
|
|
||||||
|
|
||||||
// SIMPL returns
|
|
||||||
properties.Name = console.ParseConsoleResponse(response, "Program File", ":", "\x0D");
|
|
||||||
properties.System = console.ParseConsoleResponse(response, "System Name", ":", "\x0D");
|
|
||||||
properties.Programmer = console.ParseConsoleResponse(response, "Programmer", ":", "\x0D");
|
|
||||||
properties.CompileTime = console.ParseConsoleResponse(response, "Compiled On", ":", "\x0D");
|
|
||||||
properties.Database = console.ParseConsoleResponse(response, "CrestronDB", ":", "\x0D");
|
|
||||||
properties.Environment = console.ParseConsoleResponse(response, "Source Env", ":", "\x0D");
|
|
||||||
|
|
||||||
// S# returns
|
|
||||||
if (properties.System.Length == 0)
|
|
||||||
properties.System = console.ParseConsoleResponse(response, "Application Name", ":", "\x0D");
|
|
||||||
if (properties.Database.Length == 0)
|
|
||||||
properties.Database = console.ParseConsoleResponse(response, "PlugInVersion", ":", "\x0D");
|
|
||||||
if (properties.Environment.Length == 0)
|
|
||||||
properties.Environment = console.ParseConsoleResponse(response, "Program Tool", ":", "\x0D");
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("ProgramInfo.GetInfoByIndex({0}) failed:\r{1}", index, e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
102
Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs
Normal file
102
Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash.Core.SystemInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Processor info class
|
||||||
|
/// </summary>
|
||||||
|
public class ProcessorInfo
|
||||||
|
{
|
||||||
|
public string Model { get; set; }
|
||||||
|
public string SerialNumber { get; set; }
|
||||||
|
public string Firmware { get; set; }
|
||||||
|
public string FirmwareDate { get; set; }
|
||||||
|
public string OsVersion { get; set; }
|
||||||
|
public string RuntimeEnvironment { get; set; }
|
||||||
|
public string DevicePlatform { get; set; }
|
||||||
|
public string ModuleDirectory { get; set; }
|
||||||
|
public string LocalTimeZone { get; set; }
|
||||||
|
public string ProgramIdTag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public ProcessorInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ethernet info class
|
||||||
|
/// </summary>
|
||||||
|
public class EthernetInfo
|
||||||
|
{
|
||||||
|
public ushort DhcpIsOn { get; set; }
|
||||||
|
public string Hostname { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
public string Subnet { get; set; }
|
||||||
|
public string Gateway { get; set; }
|
||||||
|
public string Dns1 { get; set; }
|
||||||
|
public string Dns2 { get; set; }
|
||||||
|
public string Dns3 { get; set; }
|
||||||
|
public string Domain { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public EthernetInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Control subnet info class
|
||||||
|
/// </summary>
|
||||||
|
public class ControlSubnetInfo
|
||||||
|
{
|
||||||
|
public ushort Enabled { get; set; }
|
||||||
|
public ushort IsInAutomaticMode { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
public string Subnet { get; set; }
|
||||||
|
public string RouterPrefix { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public ControlSubnetInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Program info class
|
||||||
|
/// </summary>
|
||||||
|
public class ProgramInfo
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Header { get; set; }
|
||||||
|
public string System { get; set; }
|
||||||
|
public string ProgramIdTag { get; set; }
|
||||||
|
public string CompileTime { get; set; }
|
||||||
|
public string Database { get; set; }
|
||||||
|
public string Environment { get; set; }
|
||||||
|
public string Programmer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
public ProgramInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,18 +3,17 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
|
|
||||||
namespace PepperDash.Core.SystemInfo
|
namespace PepperDash.Core.SystemInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processor Info to Simpl Class
|
/// System Info class
|
||||||
/// Ported from Technics_Core
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SystemInfoToSimpl
|
public class SystemInfoToSimpl
|
||||||
{
|
{
|
||||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||||
public event EventHandler<StringChangeEventArgs> StringChange;
|
public event EventHandler<StringChangeEventArgs> StringChange;
|
||||||
|
|
||||||
public event EventHandler<ProcessorChangeEventArgs> ProcessorChange;
|
public event EventHandler<ProcessorChangeEventArgs> ProcessorChange;
|
||||||
public event EventHandler<EthernetChangeEventArgs> EthernetChange;
|
public event EventHandler<EthernetChangeEventArgs> EthernetChange;
|
||||||
public event EventHandler<ControlSubnetChangeEventArgs> ControlSubnetChange;
|
public event EventHandler<ControlSubnetChangeEventArgs> ControlSubnetChange;
|
||||||
@@ -29,109 +28,266 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get processor info method
|
/// Gets the current processor info
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetProcessorInfo()
|
public void GetProcessorInfo()
|
||||||
{
|
{
|
||||||
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
|
|
||||||
var processor = new ProcessorInfo();
|
try
|
||||||
if (processor.GetInfo() == true)
|
{
|
||||||
OnProcessorChange(processor.properties, 0, SystemInfoConstants.ProcessorObjectChange);
|
var processor = new ProcessorInfo();
|
||||||
|
processor.Model = InitialParametersClass.ControllerPromptName;
|
||||||
|
processor.SerialNumber = CrestronEnvironment.SystemInfo.SerialNumber;
|
||||||
|
processor.ModuleDirectory = InitialParametersClass.ProgramDirectory.ToString();
|
||||||
|
processor.ProgramIdTag = InitialParametersClass.ProgramIDTag;
|
||||||
|
processor.DevicePlatform = CrestronEnvironment.DevicePlatform.ToString();
|
||||||
|
processor.OsVersion = CrestronEnvironment.OSVersion.Version.ToString();
|
||||||
|
processor.RuntimeEnvironment = CrestronEnvironment.RuntimeEnvironment.ToString();
|
||||||
|
processor.LocalTimeZone = CrestronEnvironment.GetTimeZone().Offset;
|
||||||
|
|
||||||
|
// Does not return firmware version matching a "ver" command
|
||||||
|
// returns the "ver -v" 'CAB' version
|
||||||
|
// example return ver -v:
|
||||||
|
// RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
|
||||||
|
// Build: 14:05:46 Oct 09 2018 (3568.25373)
|
||||||
|
// Cab: 1.503.0070
|
||||||
|
// Applications: 1.0.6855.21351
|
||||||
|
// Updater: 1.4.24
|
||||||
|
// Bootloader: 1.22.00
|
||||||
|
// RMC3-SetupProgram: 1.003.0011
|
||||||
|
// IOPVersion: FPGA [v09] slot:7
|
||||||
|
// PUF: Unknown
|
||||||
|
//Firmware = CrestronEnvironment.OSVersion.Firmware;
|
||||||
|
//Firmware = InitialParametersClass.FirmwareVersion;
|
||||||
|
|
||||||
|
// Use below logic to get actual firmware ver, not the 'CAB' returned by the above
|
||||||
|
// matches console return of a "ver" and on SystemInfo page
|
||||||
|
// example return ver:
|
||||||
|
// RMC3 Cntrl Eng [v1.503.3568.25373 (Oct 09 2018), #4001E302] @E-00107f4420f0
|
||||||
|
var response = "";
|
||||||
|
CrestronConsole.SendControlSystemCommand("ver", ref response);
|
||||||
|
processor.Firmware = ParseConsoleResponse(response, "Cntrl Eng", "[", "(");
|
||||||
|
processor.FirmwareDate = ParseConsoleResponse(response, "Cntrl Eng", "(", ")");
|
||||||
|
|
||||||
|
OnProcessorChange(processor, 0, SystemInfoConstants.ProcessorConfigChange);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = string.Format("GetProcessorInfo failed: {0}", e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get processor uptime method
|
/// Gets the current ethernet info
|
||||||
/// </summary>
|
|
||||||
public void RefreshProcessorUptime()
|
|
||||||
{
|
|
||||||
var console = new ConsoleHelper();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string response = "";
|
|
||||||
CrestronConsole.SendControlSystemCommand("uptime", ref response);
|
|
||||||
var uptime = console.ParseConsoleResponse(response, "running for", "running for", "\x0D");
|
|
||||||
OnStringChange(uptime, 0, SystemInfoConstants.ProcessorUptimeChange);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
var msg = string.Format("RefreshProcessorUptime failed:\r{0}", e);
|
|
||||||
CrestronConsole.PrintLine(msg);
|
|
||||||
ErrorLog.Error(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// get ethernet info method
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetEthernetInfo()
|
public void GetEthernetInfo()
|
||||||
{
|
{
|
||||||
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
|
|
||||||
var ethernet = new EthernetInfo();
|
var adapter = new EthernetInfo();
|
||||||
if(ethernet.GetInfo() == true)
|
|
||||||
OnEthernetInfoChange(ethernet.properties, 0, SystemInfoConstants.ObjectChange);
|
try
|
||||||
|
{
|
||||||
|
// get lan adapter id
|
||||||
|
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetLANAdapter);
|
||||||
|
|
||||||
|
// get lan adapter info
|
||||||
|
var dhcpState = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, adapterId);
|
||||||
|
if (!string.IsNullOrEmpty(dhcpState))
|
||||||
|
adapter.DhcpIsOn = (ushort)(dhcpState.ToLower().Contains("on") ? 1 : 0);
|
||||||
|
|
||||||
|
adapter.Hostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, adapterId);
|
||||||
|
adapter.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
|
||||||
|
adapter.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
|
||||||
|
adapter.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
|
||||||
|
adapter.Gateway = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, adapterId);
|
||||||
|
adapter.Domain = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, adapterId);
|
||||||
|
|
||||||
|
// returns comma seperate list of dns servers with trailing comma
|
||||||
|
// example return: "8.8.8.8 (DHCP),8.8.4.4 (DHCP),"
|
||||||
|
string dns = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DNS_SERVER, adapterId);
|
||||||
|
if (dns.Contains(","))
|
||||||
|
{
|
||||||
|
string[] dnsList = dns.Split(',');
|
||||||
|
for (var i = 0; i < dnsList.Length; i++)
|
||||||
|
{
|
||||||
|
if(i == 0)
|
||||||
|
adapter.Dns1 = !string.IsNullOrEmpty(dnsList[0]) ? dnsList[0] : "0.0.0.0";
|
||||||
|
if(i == 1)
|
||||||
|
adapter.Dns2 = !string.IsNullOrEmpty(dnsList[1]) ? dnsList[1] : "0.0.0.0";
|
||||||
|
if(i == 2)
|
||||||
|
adapter.Dns3 = !string.IsNullOrEmpty(dnsList[2]) ? dnsList[2] : "0.0.0.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
adapter.Dns1 = !string.IsNullOrEmpty(dns) ? dns : "0.0.0.0";
|
||||||
|
adapter.Dns2 = "0.0.0.0";
|
||||||
|
adapter.Dns3 = "0.0.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
OnEthernetInfoChange(adapter, 0, SystemInfoConstants.EthernetConfigChange);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = string.Format("GetEthernetInfo failed: {0}", e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get control subnet ethernet info method
|
/// Gets the current control subnet info
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void GetControlSubnetInfo()
|
public void GetControlSubnetInfo()
|
||||||
{
|
{
|
||||||
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
|
|
||||||
var ethernet = new ControlSubnetInfo();
|
var adapter = new ControlSubnetInfo();
|
||||||
if(ethernet.GetInfo() == true)
|
|
||||||
OnControlSubnetInfoChange(ethernet.properties, 0, SystemInfoConstants.ObjectChange);
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// get cs adapter id
|
||||||
|
var adapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
|
||||||
|
if (!adapterId.Equals(EthernetAdapterType.EthernetUnknownAdapter))
|
||||||
|
{
|
||||||
|
adapter.Enabled = 1;
|
||||||
|
adapter.IsInAutomaticMode = (ushort)(CrestronEthernetHelper.IsControlSubnetInAutomaticMode ? 1 : 0);
|
||||||
|
adapter.MacAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, adapterId);
|
||||||
|
adapter.IpAddress = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, adapterId);
|
||||||
|
adapter.Subnet = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, adapterId);
|
||||||
|
adapter.RouterPrefix = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CONTROL_SUBNET_ROUTER_PREFIX, adapterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
adapter.Enabled = 0;
|
||||||
|
adapter.IsInAutomaticMode = 0;
|
||||||
|
adapter.MacAddress = "NA";
|
||||||
|
adapter.IpAddress = "NA";
|
||||||
|
adapter.Subnet = "NA";
|
||||||
|
adapter.RouterPrefix = "NA";
|
||||||
|
|
||||||
|
var msg = string.Format("GetControlSubnetInfo failed: {0}", e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnControlSubnetInfoChange(adapter, 0, SystemInfoConstants.ControlSubnetConfigChange);
|
||||||
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get program info by index method
|
/// Gets the program info by index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
public void GetProgramInfoByIndex(ushort index)
|
public void GetProgramInfoByIndex(ushort index)
|
||||||
{
|
{
|
||||||
|
if (index < 1 || index > 10)
|
||||||
|
return;
|
||||||
|
|
||||||
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(true, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
|
|
||||||
var program = new ProgramInfo();
|
var program = new ProgramInfo();
|
||||||
if (program.GetInfoByIndex(index) == true)
|
|
||||||
OnProgramChange(program.properties, index, SystemInfoConstants.ObjectChange);
|
try
|
||||||
|
{
|
||||||
|
var response = "";
|
||||||
|
CrestronConsole.SendControlSystemCommand(string.Format("progcomments:{0}", index), ref response);
|
||||||
|
|
||||||
|
// no program loaded or running
|
||||||
|
if (response.Contains("Bad or Incomplete Command"))
|
||||||
|
{
|
||||||
|
program.Name = "";
|
||||||
|
program.System = "";
|
||||||
|
program.Programmer = "";
|
||||||
|
program.CompileTime = "";
|
||||||
|
program.Database = "";
|
||||||
|
program.Environment = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// SIMPL returns
|
||||||
|
program.Name = ParseConsoleResponse(response, "Program File", ":", "\x0D");
|
||||||
|
program.System = ParseConsoleResponse(response, "System Name", ":", "\x0D");
|
||||||
|
program.ProgramIdTag = ParseConsoleResponse(response, "Friendly Name", ":", "\x0D");
|
||||||
|
program.Programmer = ParseConsoleResponse(response, "Programmer", ":", "\x0D");
|
||||||
|
program.CompileTime = ParseConsoleResponse(response, "Compiled On", ":", "\x0D");
|
||||||
|
program.Database = ParseConsoleResponse(response, "CrestronDB", ":", "\x0D");
|
||||||
|
program.Environment = ParseConsoleResponse(response, "Source Env", ":", "\x0D");
|
||||||
|
|
||||||
|
// S# returns
|
||||||
|
if (program.System.Length == 0)
|
||||||
|
program.System = ParseConsoleResponse(response, "Application Name", ":", "\x0D");
|
||||||
|
if (program.Database.Length == 0)
|
||||||
|
program.Database = ParseConsoleResponse(response, "PlugInVersion", ":", "\x0D");
|
||||||
|
if (program.Environment.Length == 0)
|
||||||
|
program.Environment = ParseConsoleResponse(response, "Program Tool", ":", "\x0D");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OnProgramChange(program, index, SystemInfoConstants.ProgramConfigChange);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = string.Format("GetProgramInfoByIndex failed: {0}", e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
OnBoolChange(false, 0, SystemInfoConstants.BusyBoolChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refresh program uptime by index
|
/// Gets the processor uptime and passes it to S+
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
public void RefreshProcessorUptime()
|
||||||
public void RefreshProgramUptimeByIndex(int index)
|
|
||||||
{
|
{
|
||||||
var console = new ConsoleHelper();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string response = "";
|
string response = "";
|
||||||
CrestronConsole.SendControlSystemCommand(string.Format("proguptime:{0}", index), ref response);
|
CrestronConsole.SendControlSystemCommand("uptime", ref response);
|
||||||
string uptime = console.ParseConsoleResponse(response, "running for", "running for", "\x0D");
|
var uptime = ParseConsoleResponse(response, "running for", "running for", "\x0D");
|
||||||
OnStringChange(uptime, (ushort)index, SystemInfoConstants.ProgramUptimeChange);
|
OnStringChange(uptime, 0, SystemInfoConstants.ProcessorUptimeChange);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var msg = string.Format("RefreshProgramUptimebyIndex({0}) failed:\r{1}", index, e);
|
var msg = string.Format("RefreshProcessorUptime failed:\r{0}", e.Message);
|
||||||
CrestronConsole.PrintLine(msg);
|
CrestronConsole.PrintLine(msg);
|
||||||
ErrorLog.Error(msg);
|
//ErrorLog.Error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send console command
|
/// Gets the program uptime, by index, and passes it to S+
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
public void RefreshProgramUptimeByIndex(int index)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string response = "";
|
||||||
|
CrestronConsole.SendControlSystemCommand(string.Format("proguptime:{0}", index), ref response);
|
||||||
|
string uptime = ParseConsoleResponse(response, "running for", "running for", "\x0D");
|
||||||
|
OnStringChange(uptime, (ushort)index, SystemInfoConstants.ProgramUptimeChange);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = string.Format("RefreshProgramUptimebyIndex({0}) failed:\r{1}", index, e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends command to console, passes response back using string change event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmd"></param>
|
/// <param name="cmd"></param>
|
||||||
public void SendConsoleCommand(string cmd)
|
public void SendConsoleCommand(string cmd)
|
||||||
@@ -139,18 +295,51 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
if (string.IsNullOrEmpty(cmd))
|
if (string.IsNullOrEmpty(cmd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string consoleResponse = "";
|
string response = "";
|
||||||
CrestronConsole.SendControlSystemCommand(cmd, ref consoleResponse);
|
CrestronConsole.SendControlSystemCommand(cmd, ref response);
|
||||||
if (!string.IsNullOrEmpty(consoleResponse))
|
if (!string.IsNullOrEmpty(response))
|
||||||
{
|
{
|
||||||
if (consoleResponse.Contains("\x0D\x0A"))
|
if (response.EndsWith("\x0D\\x0A"))
|
||||||
consoleResponse.Trim('\n');
|
response.Trim('\n');
|
||||||
OnStringChange(consoleResponse, 0, SystemInfoConstants.ConsoleResponseChange);
|
|
||||||
|
OnStringChange(response, 0, SystemInfoConstants.ConsoleResponseChange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Boolean change event handler
|
/// private method to parse console messages
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="response"></param>
|
||||||
|
/// <param name="line"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="end"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string ParseConsoleResponse(string data, string line, string dataStart, string dataEnd)
|
||||||
|
{
|
||||||
|
var response = "";
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(data) || string.IsNullOrEmpty(line) || string.IsNullOrEmpty(dataStart) || string.IsNullOrEmpty(dataEnd))
|
||||||
|
return response;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var linePos = data.IndexOf(line);
|
||||||
|
var startPos = data.IndexOf(dataStart, linePos) + dataStart.Length;
|
||||||
|
var endPos = data.IndexOf(dataEnd, startPos);
|
||||||
|
response = data.Substring(startPos, endPos - startPos).Trim();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = string.Format("ParseConsoleResponse failed: {0}", e.Message);
|
||||||
|
CrestronConsole.PrintLine(msg);
|
||||||
|
//ErrorLog.Error(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Protected boolean change event handler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="state"></param>
|
/// <param name="state"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
@@ -167,7 +356,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// String change event handler
|
/// Protected string change event handler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
@@ -184,12 +373,12 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processor change event handler
|
/// Protected processor config change event handler
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="processor"></param>
|
/// <param name="processor"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
protected void OnProcessorChange(ProcessorConfig processor, ushort index, ushort type)
|
protected void OnProcessorChange(ProcessorInfo processor, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = ProcessorChange;
|
var handler = ProcessorChange;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
@@ -206,7 +395,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <param name="ethernet"></param>
|
/// <param name="ethernet"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
protected void OnEthernetInfoChange(EthernetConfig ethernet, ushort index, ushort type)
|
protected void OnEthernetInfoChange(EthernetInfo ethernet, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = EthernetChange;
|
var handler = EthernetChange;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
@@ -223,7 +412,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <param name="ethernet"></param>
|
/// <param name="ethernet"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
protected void OnControlSubnetInfoChange(ControlSubnetConfig ethernet, ushort index, ushort type)
|
protected void OnControlSubnetInfoChange(ControlSubnetInfo ethernet, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = ControlSubnetChange;
|
var handler = ControlSubnetChange;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
@@ -240,7 +429,7 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// <param name="program"></param>
|
/// <param name="program"></param>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
protected void OnProgramChange(ProgramConfig program, ushort index, ushort type)
|
protected void OnProgramChange(ProgramInfo program, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = ProgramChange;
|
var handler = ProgramChange;
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user