Removes essentials-framework as a submodule and brings the files back into the main repo

This commit is contained in:
Neil Dorin
2019-07-09 17:21:53 -06:00
parent 2cd68d40dc
commit 48c6bb78bc
362 changed files with 54624 additions and 5 deletions

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using System.ComponentModel;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public class CrestronGenericBaseCommunicationMonitor : StatusMonitorBase
{
GenericBase Device;
public CrestronGenericBaseCommunicationMonitor(IKeyed parent, GenericBase device, long warningTime, long errorTime)
: base(parent, warningTime, errorTime)
{
Device = device;
}
public override void Start()
{
Device.OnlineStatusChange -= Device_OnlineStatusChange;
Device.OnlineStatusChange += Device_OnlineStatusChange;
GetStatus();
}
public override void Stop()
{
Device.OnlineStatusChange -= Device_OnlineStatusChange;
}
void Device_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
GetStatus();
}
void GetStatus()
{
if (Device.IsOnline)
{
Status = MonitorStatus.IsOk;
StopErrorTimers();
}
else
StartErrorTimers();
}
}
}

View File

@@ -0,0 +1,158 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using System.ComponentModel;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Used for monitoring comms that are IBasicCommunication. Will send a poll string and provide an event when
/// statuses change.
/// </summary>
public class GenericCommunicationMonitor : StatusMonitorBase
{
public IBasicCommunication Client { get; private set; }
long PollTime;
CTimer PollTimer;
string PollString;
Action PollAction;
/// <summary>
///
/// </summary>
/// <param name="client"></param>
/// <param name="pollTime">in MS, >= 5000</param>
/// <param name="warningTime">in MS, >= 5000</param>
/// <param name="errorTime">in MS, >= 5000</param>
/// <param name="pollString">String to send to comm</param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, string pollString) :
base(parent, warningTime, errorTime)
{
if (pollTime > warningTime || pollTime > errorTime)
throw new ArgumentException("pollTime must be less than warning or errorTime");
//if (pollTime < 5000)
// throw new ArgumentException("pollTime cannot be less than 5000 ms");
Client = client;
PollTime = pollTime;
PollString = pollString;
}
/// <summary>
/// Poll is a provided action instead of string
/// </summary>
/// <param name="parent"></param>
/// <param name="client"></param>
/// <param name="pollTime"></param>
/// <param name="warningTime"></param>
/// <param name="errorTime"></param>
/// <param name="pollBytes"></param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, Action pollAction) :
base(parent, warningTime, errorTime)
{
if (pollTime > warningTime || pollTime > errorTime)
throw new ArgumentException("pollTime must be less than warning or errorTime");
//if (pollTime < 5000)
// throw new ArgumentException("pollTime cannot be less than 5000 ms");
Client = client;
PollTime = pollTime;
PollAction = pollAction;
}
/// <summary>
/// Build the monitor from a config object
/// </summary>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client,
CommunicationMonitorConfig props) :
this(parent, client, props.PollInterval, props.TimeToWarning, props.TimeToError, props.PollString)
{
}
public override void Start()
{
Client.BytesReceived += Client_BytesReceived;
Poll();
PollTimer = new CTimer(o => Poll(), null, PollTime, PollTime);
}
public override void Stop()
{
Client.BytesReceived -= this.Client_BytesReceived;
PollTimer.Stop();
PollTimer = null;
StopErrorTimers();
}
/// <summary>
/// Upon any receipt of data, set everything to ok!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Client_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
{
Status = MonitorStatus.IsOk;
ResetErrorTimers();
//
}
void Poll()
{
StartErrorTimers();
if (Client.IsConnected)
{
//Debug.Console(2, this, "Polling");
if(PollAction != null)
PollAction.Invoke();
else
Client.SendText(PollString);
}
else
{
Debug.Console(2, this, "Comm not connected");
}
}
/// <summary>
/// When the client connects, and we're waiting for it, respond and disconect from event
/// </summary>
void OneTimeConnectHandler(object o, EventArgs a)
{
if (Client.IsConnected)
{
//Client.IsConnected -= OneTimeConnectHandler;
Debug.Console(2, this, "Comm connected");
Poll();
}
}
}
public class CommunicationMonitorConfig
{
public int PollInterval { get; set; }
public int TimeToWarning { get; set; }
public int TimeToError { get; set; }
public string PollString { get; set; }
public CommunicationMonitorConfig()
{
PollInterval = 30000;
TimeToWarning = 120000;
TimeToError = 300000;
PollString = "";
}
}
}

View File

@@ -0,0 +1,57 @@
using System;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public interface IStatusMonitor
{
IKeyed Parent { get; }
event EventHandler<MonitorStatusChangeEventArgs> StatusChange;
MonitorStatus Status { get; }
string Message { get; }
BoolFeedback IsOnlineFeedback { get; set; }
void Start();
void Stop();
}
/// <summary>
/// Represents a class that has a basic communication monitoring
/// </summary>
public interface ICommunicationMonitor
{
StatusMonitorBase CommunicationMonitor { get; }
}
/// <summary>
/// StatusUnknown = 0, IsOk = 1, InWarning = 2, InError = 3
/// </summary>
public enum MonitorStatus
{
StatusUnknown = 0,
IsOk = 1,
InWarning = 2,
InError = 3
}
public class MonitorStatusChangeEventArgs : EventArgs
{
public MonitorStatus Status { get; private set; }
public string Message { get; private set; }
public MonitorStatusChangeEventArgs(MonitorStatus status)
{
Status = status;
Message = status == MonitorStatus.IsOk ? "" : status.ToString();
}
public MonitorStatusChangeEventArgs(MonitorStatus status, string message)
{
Status = status;
Message = message;
}
}
}

View File

@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using System.ComponentModel;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
public abstract class StatusMonitorBase : IStatusMonitor, IKeyName
{
public event EventHandler<MonitorStatusChangeEventArgs> StatusChange;
/// <summary>
/// Format returned: "parentdevkey-comMonitor"
/// </summary>
public string Key { get { return Parent.Key + "-comMonitor"; } }
public string Name { get { return "Comm. monitor"; } }
public IKeyed Parent { get; private set; }
public BoolFeedback IsOnlineFeedback { get; set; }
public bool IsOnline;
public MonitorStatus Status
{
get { return _Status; }
protected set
{
if (value != _Status)
{
_Status = value;
OnStatusChange(value);
}
}
}
MonitorStatus _Status;
public string Message
{
get { return _Message; }
set
{
if (value == _Message) return;
_Message = value;
OnStatusChange(Status, value);
}
}
string _Message;
long WarningTime;
long ErrorTime;
CTimer WarningTimer;
CTimer ErrorTimer;
public StatusMonitorBase(IKeyed parent, long warningTime, long errorTime)
{
Parent = parent;
if (warningTime > errorTime)
throw new ArgumentException("warningTime must be less than errorTime");
if (warningTime < 5000 || errorTime < 5000)
throw new ArgumentException("time values cannot be less that 5000 ms");
IsOnlineFeedback = new BoolFeedback(() => { return IsOnline; });
Status = MonitorStatus.StatusUnknown;
WarningTime = warningTime;
ErrorTime = errorTime;
}
public abstract void Start();
public abstract void Stop();
protected void OnStatusChange(MonitorStatus status)
{
if (_Status == MonitorStatus.IsOk)
IsOnline = true;
else
IsOnline = false;
IsOnlineFeedback.FireUpdate();
var handler = StatusChange;
if (handler != null)
handler(this, new MonitorStatusChangeEventArgs(status));
}
protected void OnStatusChange(MonitorStatus status, string message)
{
if (_Status == MonitorStatus.IsOk)
IsOnline = true;
else
IsOnline = false;
IsOnlineFeedback.FireUpdate();
var handler = StatusChange;
if (handler != null)
handler(this, new MonitorStatusChangeEventArgs(status, message));
}
protected void StartErrorTimers()
{
if (WarningTimer == null) WarningTimer = new CTimer(o => { Status = MonitorStatus.InWarning; }, WarningTime);
if (ErrorTimer == null) ErrorTimer = new CTimer(o => { Status = MonitorStatus.InError; }, ErrorTime);
}
protected void StopErrorTimers()
{
if (WarningTimer != null) WarningTimer.Stop();
if (ErrorTimer != null) ErrorTimer.Stop();
WarningTimer = null;
ErrorTimer = null;
}
protected void ResetErrorTimers()
{
if(WarningTimer != null)
WarningTimer.Reset(WarningTime, WarningTime);
if(ErrorTimer != null)
ErrorTimer.Reset(ErrorTime, ErrorTime);
}
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using System.ComponentModel;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
{
/// <summary>
///
/// </summary>
public class StatusMonitorCollection : IStatusMonitor
{
public IKeyed Parent { get; private set; }
List<IStatusMonitor> Monitors = new List<IStatusMonitor>();
#region IStatusMonitor Members
public event EventHandler<MonitorStatusChangeEventArgs> StatusChange;
public MonitorStatus Status { get; protected set; }
public string Message { get; private set; }
public BoolFeedback IsOnlineFeedback { get; set; }
public StatusMonitorCollection(IKeyed parent)
{
Parent = parent;
}
public void Start()
{
foreach (var mon in Monitors)
mon.StatusChange += mon_StatusChange;
ProcessStatuses();
}
void ProcessStatuses()
{
var InError = Monitors.Where(m => m.Status == MonitorStatus.InError);
var InWarning = Monitors.Where(m => m.Status == MonitorStatus.InWarning);
var IsOk = Monitors.Where(m => m.Status == MonitorStatus.IsOk);
MonitorStatus initialStatus;
string prefix = "0:";
if (InError.Count() > 0)
{
initialStatus = MonitorStatus.InError;
prefix = "3:";
}
else if (InWarning.Count() > 0)
{
initialStatus = MonitorStatus.InWarning;
prefix = "2:";
}
else if (InWarning.Count() > 0)
initialStatus = MonitorStatus.IsOk;
else
initialStatus = MonitorStatus.StatusUnknown;
// Build the error message string
if (InError.Count() > 0 || InWarning.Count() > 0)
{
StringBuilder sb = new StringBuilder(prefix);
if (InError.Count() > 0)
{
// Do string splits and joins
sb.Append(string.Format("{0} Errors:", InError.Count()));
foreach (var mon in InError)
sb.Append(string.Format("{0}, ", mon.Parent.Key));
}
if (InWarning.Count() > 0)
{
sb.Append(string.Format("{0} Warnings:", InWarning.Count()));
foreach (var mon in InWarning)
sb.Append(string.Format("{0}, ", mon.Parent.Key));
}
Message = sb.ToString();
}
// Want to fire even if status doesn't change because the message may.
Status = initialStatus;
OnStatusChange(initialStatus, Message);
}
void mon_StatusChange(object sender, MonitorStatusChangeEventArgs e)
{
ProcessStatuses();
}
public void Stop()
{
throw new NotImplementedException();
}
#endregion
public void AddMonitor(IStatusMonitor monitor)
{
if (!Monitors.Contains(monitor))
Monitors.Add(monitor);
}
protected void OnStatusChange(MonitorStatus status, string message)
{
var handler = StatusChange;
if (handler != null)
handler(this, new MonitorStatusChangeEventArgs(status, message));
}
}
}

View File

@@ -0,0 +1,404 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.Diagnostics;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace PepperDash.Essentials.Core.Monitoring
{
/// <summary>
/// Wrapper for the static SystemMonitor class to extend functionality and provide external access
/// to SystemMonitor via APIs
/// </summary>
public class SystemMonitorController : Device
{
public event EventHandler<EventArgs> SystemMonitorPropertiesChanged;
public Dictionary<uint, ProgramStatusFeedbacks> ProgramStatusFeedbackCollection;
public IntFeedback TimeZoneFeedback { get; set; }
public StringFeedback TimeZoneTextFeedback { get; set; }
public StringFeedback IOControllerVersionFeedback { get; set; }
public StringFeedback SnmpVersionFeedback { get; set; }
public StringFeedback BACnetAppVersionFeedback { get; set; }
public StringFeedback ControllerVersionFeedback { get; set; }
public SystemMonitorController(string key)
: base(key)
{
Debug.Console(2, this, "Adding SystemMonitorController.");
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
//CrestronConsole.AddNewConsoleCommand(RefreshSystemMonitorData, "RefreshSystemMonitor", "Refreshes System Monitor Feedbacks", ConsoleAccessLevelEnum.AccessOperator);
TimeZoneFeedback = new IntFeedback(new Func<int>( () => SystemMonitor.TimeZoneInformation.TimeZoneNumber));
TimeZoneTextFeedback = new StringFeedback(new Func<string>( () => SystemMonitor.TimeZoneInformation.TimeZoneName));
IOControllerVersionFeedback = new StringFeedback(new Func<string>( () => SystemMonitor.VersionInformation.IOPVersion));
SnmpVersionFeedback = new StringFeedback(new Func<string>( () => SystemMonitor.VersionInformation.SNMPVersion));
BACnetAppVersionFeedback = new StringFeedback(new Func<string>( () => SystemMonitor.VersionInformation.BACNetVersion));
ControllerVersionFeedback = new StringFeedback(new Func<string>( () => SystemMonitor.VersionInformation.ControlSystemVersion));
//var status = string.Format("System Monitor Status: \r TimeZone: {0}\rTimeZoneText: {1}\rIOControllerVersion: {2}\rSnmpAppVersionFeedback: {3}\rBACnetAppVersionFeedback: {4}\rControllerVersionFeedback: {5}",
// SystemMonitor.TimeZoneInformation.TimeZoneNumber, SystemMonitor.TimeZoneInformation.TimeZoneName, SystemMonitor.VersionInformation.IOPVersion, SystemMonitor.VersionInformation.SNMPVersion,
// SystemMonitor.VersionInformation.BACNetVersion, SystemMonitor.VersionInformation.ControlSystemVersion);
//Debug.Console(1, this, status);
ProgramStatusFeedbackCollection = new Dictionary<uint, ProgramStatusFeedbacks>();
foreach (var prog in SystemMonitor.ProgramCollection)
{
var program = new ProgramStatusFeedbacks(prog);
ProgramStatusFeedbackCollection.Add(prog.Number, program);
}
SystemMonitor.ProgramChange += new ProgramStateChangeEventHandler(SystemMonitor_ProgramChange);
SystemMonitor.TimeZoneInformation.TimeZoneChange += new TimeZoneChangeEventHandler(TimeZoneInformation_TimeZoneChange);
}
/// <summary>
/// Gets data in separate thread
/// </summary>
/// <param name="command"></param>
void RefreshSystemMonitorData(string command)
{
// this takes a while, launch a new thread
CrestronInvoke.BeginInvoke((o) =>
{
TimeZoneFeedback.FireUpdate();
TimeZoneTextFeedback.FireUpdate();
IOControllerVersionFeedback.FireUpdate();
SnmpVersionFeedback.FireUpdate();
BACnetAppVersionFeedback.FireUpdate();
ControllerVersionFeedback.FireUpdate();
OnSystemMonitorPropertiesChanged();
}
);
}
void OnSystemMonitorPropertiesChanged()
{
var handler = SystemMonitorPropertiesChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
}
public override bool CustomActivate()
{
RefreshSystemMonitorData(null);
return base.CustomActivate();
}
//// Sets the time zone
//public void SetTimeZone(int timeZone)
//{
// SystemMonitor.TimeZoneInformation.TimeZoneNumber = timeZone;
//}
/// <summary>
/// Responds to program change events and triggers the appropriate feedbacks to update
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
void SystemMonitor_ProgramChange(Program sender, ProgramEventArgs args)
{
Debug.Console(2, this, "Program Change Detected for slot: {0}", sender.Number);
Debug.Console(2, this, "Event Type: {0}", args.EventType);
var program = ProgramStatusFeedbackCollection[sender.Number];
if (args.EventType == eProgramChangeEventType.OperatingState)
{
program.ProgramStartedFeedback.FireUpdate();
program.ProgramStoppedFeedback.FireUpdate();
program.ProgramInfo.OperatingState = args.OperatingState;
//program.GetProgramInfo();
if (args.OperatingState == eProgramOperatingState.Start)
program.GetProgramInfo();
else
{
program.AggregatedProgramInfoFeedback.FireUpdate();
program.OnProgramInfoChanged();
}
}
else if (args.EventType == eProgramChangeEventType.RegistrationState)
{
program.ProgramRegisteredFeedback.FireUpdate();
program.ProgramUnregisteredFeedback.FireUpdate();
program.ProgramInfo.RegistrationState = args.RegistrationState;
program.GetProgramInfo();
}
}
/// <summary>
/// Responds to time zone changes and updates the appropriate feedbacks
/// </summary>
/// <param name="args"></param>
void TimeZoneInformation_TimeZoneChange(TimeZoneEventArgs args)
{
Debug.Console(2, this, "Time Zone Change Detected.");
TimeZoneFeedback.FireUpdate();
TimeZoneTextFeedback.FireUpdate();
OnSystemMonitorPropertiesChanged();
}
public class ProgramStatusFeedbacks
{
public event EventHandler<ProgramInfoEventArgs> ProgramInfoChanged;
public Program Program;
public ProgramInfo ProgramInfo { get; set; }
public BoolFeedback ProgramStartedFeedback;
public BoolFeedback ProgramStoppedFeedback;
public BoolFeedback ProgramRegisteredFeedback;
public BoolFeedback ProgramUnregisteredFeedback;
public StringFeedback ProgramNameFeedback;
public StringFeedback ProgramCompileTimeFeedback;
public StringFeedback CrestronDataBaseVersionFeedback;
// SIMPL windows version
public StringFeedback EnvironmentVersionFeedback;
public StringFeedback AggregatedProgramInfoFeedback;
public ProgramStatusFeedbacks(Program program)
{
ProgramInfo = new ProgramInfo(program.Number);
Program = program;
ProgramInfo.OperatingState = Program.OperatingState;
ProgramInfo.RegistrationState = Program.RegistrationState;
ProgramStartedFeedback = new BoolFeedback(new Func<bool>( () => Program.OperatingState == eProgramOperatingState.Start));
ProgramStoppedFeedback = new BoolFeedback(new Func<bool>( () => Program.OperatingState == eProgramOperatingState.Stop));
ProgramRegisteredFeedback = new BoolFeedback(new Func<bool>( () => Program.RegistrationState == eProgramRegistrationState.Register));
ProgramUnregisteredFeedback = new BoolFeedback(new Func<bool>( () => Program.RegistrationState == eProgramRegistrationState.Unregister));
ProgramNameFeedback = new StringFeedback(new Func<string>(() => ProgramInfo.ProgramFile));
ProgramCompileTimeFeedback = new StringFeedback(new Func<string>(() => ProgramInfo.CompileTime));
CrestronDataBaseVersionFeedback = new StringFeedback(new Func<string>(() => ProgramInfo.CrestronDB));
EnvironmentVersionFeedback = new StringFeedback(new Func<string>(() => ProgramInfo.Environment));
AggregatedProgramInfoFeedback = new StringFeedback(new Func<string>(() => JsonConvert.SerializeObject(ProgramInfo)));
GetProgramInfo();
}
/// <summary>
/// Retrieves information about a running program
/// </summary>
public void GetProgramInfo()
{
CrestronInvoke.BeginInvoke((o) =>
{
Debug.Console(2, "Attempting to get program info for slot: {0}", Program.Number);
string response = null;
var success = CrestronConsole.SendControlSystemCommand(string.Format("progcomments:{0}", Program.Number), ref response);
if (success)
{
//Debug.Console(2, "Progcomments Response: \r{0}", response);
if (!response.ToLower().Contains("bad or incomplete"))
{
// Shared properteis
ProgramInfo.ProgramFile = ParseConsoleData(response, "Program File", ": ", "\n");
ProgramInfo.CompilerRevision = ParseConsoleData(response, "Compiler Rev", ": ", "\n");
ProgramInfo.CompileTime = ParseConsoleData(response, "Compiled On", ": ", "\n");
ProgramInfo.Include4Dat = ParseConsoleData(response, "Include4.dat", ": ", "\n");
if (ProgramInfo.ProgramFile.Contains(".dll"))
{
// SSP Program
ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ": ", "\n");
ProgramInfo.ApplicationName = ParseConsoleData(response, "Application Name", ": ", "\n");
ProgramInfo.ProgramTool = ParseConsoleData(response, "Program Tool", ": ", "\n");
ProgramInfo.MinFirmwareVersion = ParseConsoleData(response, "Min Firmware Version", ": ", "\n");
ProgramInfo.PlugInVersion = ParseConsoleData(response, "PlugInVersion", ": ", "\n");
}
else if (ProgramInfo.ProgramFile.Contains(".smw"))
{
// SIMPL Windows Program
ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ":", "\n");
ProgramInfo.SystemName = ParseConsoleData(response, "System Name", ": ", "\n");
ProgramInfo.CrestronDB = ParseConsoleData(response, "CrestronDB", ": ", "\n");
ProgramInfo.Environment = ParseConsoleData(response, "Source Env", ": ", "\n");
ProgramInfo.Programmer = ParseConsoleData(response, "Programmer", ": ", "\n");
}
//Debug.Console(2, "ProgramInfo: \r{0}", JsonConvert.SerializeObject(ProgramInfo));
}
else
{
Debug.Console(2, "Bad or incomplete console command response. Initializing ProgramInfo for slot: {0}", Program.Number);
// Assume no valid program info. Constructing a new object will wipe all properties
ProgramInfo = new ProgramInfo(Program.Number);
ProgramInfo.OperatingState = Program.OperatingState;
ProgramInfo.RegistrationState = Program.RegistrationState;
}
}
else
{
Debug.Console(2, "Progcomments Attempt Unsuccessful for slot: {0}", Program.Number);
}
ProgramNameFeedback.FireUpdate();
ProgramCompileTimeFeedback.FireUpdate();
CrestronDataBaseVersionFeedback.FireUpdate();
EnvironmentVersionFeedback.FireUpdate();
AggregatedProgramInfoFeedback.FireUpdate();
OnProgramInfoChanged();
});
}
public void OnProgramInfoChanged()
{
//Debug.Console(1, "Firing ProgramInfoChanged for slot: {0}", Program.Number);
var handler = ProgramInfoChanged;
if (handler != null)
{
handler(this, new ProgramInfoEventArgs(ProgramInfo));
}
}
private string ParseConsoleData(string data, string line, string startString, string endString)
{
string outputData = "";
if (data.Length > 0)
{
try
{
//Debug.Console(2, "ParseConsoleData Data: {0}, Line {1}, startStirng {2}, endString {3}", data, line, startString, endString);
var linePosition = data.IndexOf(line);
var startPosition = data.IndexOf(startString, linePosition) + startString.Length;
var endPosition = data.IndexOf(endString, startPosition);
outputData = data.Substring(startPosition, endPosition - startPosition).Trim();
//Debug.Console(2, "ParseConsoleData Return: {0}", outputData);
}
catch (Exception e)
{
Debug.Console(1, "Error Parsing Console Data:\r{0}", e);
}
}
return outputData;
}
}
}
/// <summary>
/// Class for serializing program slot information
/// </summary>
public class ProgramInfo
{
// Shared properties
[JsonProperty("programNumber")]
public uint ProgramNumber { get; private set; }
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("operatingState")]
public eProgramOperatingState OperatingState { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("registrationState")]
public eProgramRegistrationState RegistrationState { get; set; }
[JsonProperty("programFile")]
public string ProgramFile { get; set; }
[JsonProperty("friendlyName")]
public string FriendlyName { get; set; }
[JsonProperty("compilerRevision")]
public string CompilerRevision { get; set; }
[JsonProperty("compileTime")]
public string CompileTime { get; set; }
[JsonProperty("include4Dat")]
public string Include4Dat { get; set; }
// SIMPL Windows properties
[JsonProperty("systemName")]
public string SystemName { get; set; }
[JsonProperty("crestronDb")]
public string CrestronDB { get; set; }
[JsonProperty("environment")]
public string Environment { get; set; }
[JsonProperty("programmer")]
public string Programmer { get; set; }
// SSP Properties
[JsonProperty("applicationName")]
public string ApplicationName { get; set; }
[JsonProperty("programTool")]
public string ProgramTool { get; set; }
[JsonProperty("minFirmwareVersion")]
public string MinFirmwareVersion { get; set; }
[JsonProperty("plugInVersion")]
public string PlugInVersion { get; set; }
public ProgramInfo(uint number)
{
ProgramNumber = number;
ProgramFile = "";
FriendlyName = "";
CompilerRevision = "";
CompileTime = "";
Include4Dat = "";
SystemName = "";
CrestronDB = "";
Environment = "";
Programmer = "";
ApplicationName = "";
ProgramTool = "";
MinFirmwareVersion = "";
PlugInVersion = "";
}
}
public class ProgramInfoEventArgs : EventArgs
{
public ProgramInfo ProgramInfo;
public ProgramInfoEventArgs(ProgramInfo progInfo)
{
ProgramInfo = progInfo;
}
}
}