mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
docs(core): Adds missing XML comments for public members
This commit is contained in:
@@ -22,6 +22,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private CTimer DebugExpiryPeriod;
|
private CTimer DebugExpiryPeriod;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current debug setting
|
||||||
|
/// </summary>
|
||||||
public eStreamDebuggingSetting DebugSetting { get; private set; }
|
public eStreamDebuggingSetting DebugSetting { get; private set; }
|
||||||
|
|
||||||
private uint _DebugTimeoutInMs;
|
private uint _DebugTimeoutInMs;
|
||||||
@@ -38,11 +41,20 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that receive stream debugging is enabled
|
||||||
|
/// </summary>
|
||||||
public bool RxStreamDebuggingIsEnabled{ get; private set; }
|
public bool RxStreamDebuggingIsEnabled{ get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that transmit stream debugging is enabled
|
||||||
|
/// </summary>
|
||||||
public bool TxStreamDebuggingIsEnabled { get; private set; }
|
public bool TxStreamDebuggingIsEnabled { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentDeviceKey"></param>
|
||||||
public CommunicationStreamDebugging(string parentDeviceKey)
|
public CommunicationStreamDebugging(string parentDeviceKey)
|
||||||
{
|
{
|
||||||
ParentDeviceKey = parentDeviceKey;
|
ParentDeviceKey = parentDeviceKey;
|
||||||
|
|||||||
@@ -8,34 +8,56 @@ using Newtonsoft.Json;
|
|||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Config properties that indicate how to communicate with a device for control
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlPropertiesConfig
|
public class ControlPropertiesConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The method of control
|
||||||
|
/// </summary>
|
||||||
public eControlMethod Method { get; set; }
|
public eControlMethod Method { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The key of the device that contains the control port
|
||||||
|
/// </summary>
|
||||||
public string ControlPortDevKey { get; set; }
|
public string ControlPortDevKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of the control port on the device specified by ControlPortDevKey
|
||||||
|
/// </summary>
|
||||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||||
public uint ControlPortNumber { get; set; }
|
public uint ControlPortNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the control port on the device specified by ControlPortDevKey
|
||||||
|
/// </summary>
|
||||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||||
public string ControlPortName { get; set; }
|
public string ControlPortName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Properties for ethernet based communications
|
||||||
|
/// </summary>
|
||||||
public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The filename and path for the IR file
|
||||||
|
/// </summary>
|
||||||
public string IrFile { get; set; }
|
public string IrFile { get; set; }
|
||||||
|
|
||||||
//public ComPortConfig ComParams { get; set; }
|
/// <summary>
|
||||||
|
/// The IpId of a Crestron device
|
||||||
//[JsonConverter(typeof(ComSpecJsonConverter))]
|
/// </summary>
|
||||||
//public ComPort.ComPortSpec ComParams { get; set; }
|
|
||||||
|
|
||||||
public string IpId { get; set; }
|
public string IpId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Readonly uint representation of the IpId
|
||||||
|
/// </summary>
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
|
public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Char indicating end of line
|
||||||
|
/// </summary>
|
||||||
public char EndOfLineChar { get; set; }
|
public char EndOfLineChar { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -43,8 +65,14 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string EndOfLineString { get; set; }
|
public string EndOfLineString { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates
|
||||||
|
/// </summary>
|
||||||
public string DeviceReadyResponsePattern { get; set; }
|
public string DeviceReadyResponsePattern { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public ControlPropertiesConfig()
|
public ControlPropertiesConfig()
|
||||||
{
|
{
|
||||||
EndOfLineString = CrestronEnvironment.NewLine;
|
EndOfLineString = CrestronEnvironment.NewLine;
|
||||||
|
|||||||
@@ -18,49 +18,108 @@ using Crestron.SimplSharp.CrestronSockets;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for notifying of socket status changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
public delegate void GenericSocketStatusChangeEventDelegate(ISocketStatus client);
|
public delegate void GenericSocketStatusChangeEventDelegate(ISocketStatus client);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs class for socket status changes
|
||||||
|
/// </summary>
|
||||||
public class GenericSocketStatusChageEventArgs : EventArgs
|
public class GenericSocketStatusChageEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ISocketStatus Client { get; private set; }
|
public ISocketStatus Client { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
public GenericSocketStatusChageEventArgs(ISocketStatus client)
|
public GenericSocketStatusChageEventArgs(ISocketStatus client)
|
||||||
{
|
{
|
||||||
Client = client;
|
Client = client;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericSocketStatusChageEventArgs() { }
|
public GenericSocketStatusChageEventArgs() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for notifying of TCP Server state changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
public delegate void GenericTcpServerStateChangedEventDelegate(ServerState state);
|
public delegate void GenericTcpServerStateChangedEventDelegate(ServerState state);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs class for TCP Server state changes
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpServerStateChangedEventArgs : EventArgs
|
public class GenericTcpServerStateChangedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ServerState State { get; private set; }
|
public ServerState State { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
public GenericTcpServerStateChangedEventArgs(ServerState state)
|
public GenericTcpServerStateChangedEventArgs(ServerState state)
|
||||||
{
|
{
|
||||||
State = state;
|
State = state;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericTcpServerStateChangedEventArgs() { }
|
public GenericTcpServerStateChangedEventArgs() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate for TCP Server socket status changes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
public delegate void GenericTcpServerSocketStatusChangeEventDelegate(object socket, uint clientIndex, SocketStatus clientStatus);
|
public delegate void GenericTcpServerSocketStatusChangeEventDelegate(object socket, uint clientIndex, SocketStatus clientStatus);
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server socket status changes
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpServerSocketStatusChangeEventArgs : EventArgs
|
public class GenericTcpServerSocketStatusChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public object Socket { get; private set; }
|
public object Socket { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public uint ReceivedFromClientIndex { get; private set; }
|
public uint ReceivedFromClientIndex { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public SocketStatus ClientStatus { get; set; }
|
public SocketStatus ClientStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
public GenericTcpServerSocketStatusChangeEventArgs(object socket, SocketStatus clientStatus)
|
public GenericTcpServerSocketStatusChangeEventArgs(object socket, SocketStatus clientStatus)
|
||||||
{
|
{
|
||||||
Socket = socket;
|
Socket = socket;
|
||||||
ClientStatus = clientStatus;
|
ClientStatus = clientStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
/// <param name="clientStatus"></param>
|
||||||
public GenericTcpServerSocketStatusChangeEventArgs(object socket, uint clientIndex, SocketStatus clientStatus)
|
public GenericTcpServerSocketStatusChangeEventArgs(object socket, uint clientIndex, SocketStatus clientStatus)
|
||||||
{
|
{
|
||||||
Socket = socket;
|
Socket = socket;
|
||||||
@@ -68,14 +127,24 @@ namespace PepperDash.Core
|
|||||||
ClientStatus = clientStatus;
|
ClientStatus = clientStatus;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericTcpServerSocketStatusChangeEventArgs() { }
|
public GenericTcpServerSocketStatusChangeEventArgs() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server com method receive text
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpServerCommMethodReceiveTextArgs : EventArgs
|
public class GenericTcpServerCommMethodReceiveTextArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public uint ReceivedFromClientIndex { get; private set; }
|
public uint ReceivedFromClientIndex { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort ReceivedFromClientIndexShort
|
public ushort ReceivedFromClientIndexShort
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -84,49 +153,92 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Text { get; private set; }
|
public string Text { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
public GenericTcpServerCommMethodReceiveTextArgs(string text)
|
public GenericTcpServerCommMethodReceiveTextArgs(string text)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
public GenericTcpServerCommMethodReceiveTextArgs(string text, uint clientIndex)
|
public GenericTcpServerCommMethodReceiveTextArgs(string text, uint clientIndex)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
ReceivedFromClientIndex = clientIndex;
|
ReceivedFromClientIndex = clientIndex;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericTcpServerCommMethodReceiveTextArgs() { }
|
public GenericTcpServerCommMethodReceiveTextArgs() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for TCP server client ready for communication
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpServerClientReadyForcommunicationsEventArgs : EventArgs
|
public class GenericTcpServerClientReadyForcommunicationsEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool IsReady;
|
public bool IsReady;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isReady"></param>
|
||||||
public GenericTcpServerClientReadyForcommunicationsEventArgs(bool isReady)
|
public GenericTcpServerClientReadyForcommunicationsEventArgs(bool isReady)
|
||||||
{
|
{
|
||||||
IsReady = isReady;
|
IsReady = isReady;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericTcpServerClientReadyForcommunicationsEventArgs() { }
|
public GenericTcpServerClientReadyForcommunicationsEventArgs() { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventArgs for UDP connected
|
||||||
|
/// </summary>
|
||||||
public class GenericUdpConnectedEventArgs : EventArgs
|
public class GenericUdpConnectedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort UConnected;
|
public ushort UConnected;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool Connected;
|
public bool Connected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public GenericUdpConnectedEventArgs() { }
|
public GenericUdpConnectedEventArgs() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uconnected"></param>
|
||||||
public GenericUdpConnectedEventArgs(ushort uconnected)
|
public GenericUdpConnectedEventArgs(ushort uconnected)
|
||||||
{
|
{
|
||||||
UConnected = uconnected;
|
UConnected = uconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="connected"></param>
|
||||||
public GenericUdpConnectedEventArgs(bool connected)
|
public GenericUdpConnectedEventArgs(bool connected)
|
||||||
{
|
{
|
||||||
Connected = connected;
|
Connected = connected;
|
||||||
|
|||||||
@@ -8,50 +8,86 @@ using Crestron.SimplSharp.Net.Http;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Client for communicating with an HTTP Server Side Event pattern
|
||||||
|
/// </summary>
|
||||||
public class GenericHttpSseClient : ICommunicationReceiver
|
public class GenericHttpSseClient : ICommunicationReceiver
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies when bytes have been received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies when text has been received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates connection status
|
||||||
|
/// </summary>
|
||||||
public bool IsConnected
|
public bool IsConnected
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unique identifier for the instance
|
||||||
|
/// </summary>
|
||||||
public string Key
|
public string Key
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name for the instance
|
||||||
|
/// </summary>
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// URL of the server
|
||||||
|
/// </summary>
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
HttpClient Client;
|
HttpClient Client;
|
||||||
HttpClientRequest Request;
|
HttpClientRequest Request;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
public GenericHttpSseClient(string key, string name)
|
public GenericHttpSseClient(string key, string name)
|
||||||
{
|
{
|
||||||
Key = key;
|
Key = key;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Connects to the server. Requires Url to be set first.
|
||||||
|
/// </summary>
|
||||||
public void Connect()
|
public void Connect()
|
||||||
{
|
{
|
||||||
InitiateConnection(Url);
|
InitiateConnection(Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnects from the server
|
||||||
|
/// </summary>
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
CloseConnection(null);
|
CloseConnection(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initiates connection to the server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
public void InitiateConnection(string url)
|
public void InitiateConnection(string url)
|
||||||
{
|
{
|
||||||
CrestronInvoke.BeginInvoke(o =>
|
CrestronInvoke.BeginInvoke(o =>
|
||||||
@@ -84,6 +120,10 @@ namespace PepperDash.Core
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the connection to the server
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s"></param>
|
||||||
public void CloseConnection(string s)
|
public void CloseConnection(string s)
|
||||||
{
|
{
|
||||||
if (Client != null)
|
if (Client != null)
|
||||||
@@ -165,10 +205,6 @@ namespace PepperDash.Core
|
|||||||
Debug.Console(1, this, "DataConnection OnBytesReceived Fired");
|
Debug.Console(1, this, "DataConnection OnBytesReceived Fired");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="asyncResult"></param>
|
|
||||||
private void ReadCallBack(Crestron.SimplSharp.CrestronIO.IAsyncResult asyncResult)
|
private void ReadCallBack(Crestron.SimplSharp.CrestronIO.IAsyncResult asyncResult)
|
||||||
{
|
{
|
||||||
//we are getting back everything here, so cast the state from the call
|
//we are getting back everything here, so cast the state from the call
|
||||||
@@ -222,14 +258,38 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RequestState
|
public class RequestState
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const int BUFFER_SIZE = 10000;
|
public const int BUFFER_SIZE = 10000;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public byte[] BufferRead;
|
public byte[] BufferRead;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public HttpClient HttpClient;
|
public HttpClient HttpClient;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public HttpClientRequest Request;
|
public HttpClientRequest Request;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public HttpClientResponse Response;
|
public HttpClientResponse Response;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public Stream StreamResponse;
|
public Stream StreamResponse;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool Done;
|
public bool Done;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public RequestState()
|
public RequestState()
|
||||||
{
|
{
|
||||||
BufferRead = new byte[BUFFER_SIZE];
|
BufferRead = new byte[BUFFER_SIZE];
|
||||||
@@ -246,6 +306,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class StreamAsyncTest
|
public class StreamAsyncTest
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public CEvent wait_for_response = new CEvent(true, false);
|
public CEvent wait_for_response = new CEvent(true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,9 @@ using Crestron.SimplSharp.CrestronSockets;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic secure TCP/IP client for server
|
||||||
|
/// </summary>
|
||||||
public class GenericSecureTcpIpClient_ForServer : Device, IAutoReconnect
|
public class GenericSecureTcpIpClient_ForServer : Device, IAutoReconnect
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,8 +34,14 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
//public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
//public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of text received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceived;
|
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of auto reconnect sequence triggered
|
||||||
|
/// </summary>
|
||||||
public event EventHandler AutoReconnectTriggered;
|
public event EventHandler AutoReconnectTriggered;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -41,7 +50,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceivedQueueInvoke;
|
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceivedQueueInvoke;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of socket status change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericTcpServerSocketStatusChangeEventArgs> ConnectionChange;
|
public event EventHandler<GenericTcpServerSocketStatusChangeEventArgs> ConnectionChange;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic secure TCP/IP server
|
||||||
|
/// </summary>
|
||||||
public class GenericSecureTcpIpServer : Device
|
public class GenericSecureTcpIpServer : Device
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
@@ -55,6 +58,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
|
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public delegate void ServerHasChokedCallbackDelegate();
|
public delegate void ServerHasChokedCallbackDelegate();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace PepperDash.Core
|
|||||||
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
||||||
{
|
{
|
||||||
private const string SPlusKey = "Uninitialized SshClient";
|
private const string SPlusKey = "Uninitialized SshClient";
|
||||||
|
/// <summary>
|
||||||
|
/// Object to enable stream debugging
|
||||||
|
/// </summary>
|
||||||
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,10 +34,10 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
///
|
/////
|
||||||
/// </summary>
|
///// </summary>
|
||||||
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Address of server
|
/// Address of server
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace PepperDash.Core
|
|||||||
public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
||||||
{
|
{
|
||||||
private const string SplusKey = "Uninitialized TcpIpClient";
|
private const string SplusKey = "Uninitialized TcpIpClient";
|
||||||
|
/// <summary>
|
||||||
|
/// Object to enable stream debugging
|
||||||
|
/// </summary>
|
||||||
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -172,7 +175,7 @@ namespace PepperDash.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key">unique string to differentiate between instances</param>
|
||||||
/// <param name="address"></param>
|
/// <param name="address"></param>
|
||||||
/// <param name="port"></param>
|
/// <param name="port"></param>
|
||||||
/// <param name="bufferSize"></param>
|
/// <param name="bufferSize"></param>
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ using Crestron.SimplSharp.CrestronSockets;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic TCP/IP client for server
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpIpClient_ForServer : Device, IAutoReconnect
|
public class GenericTcpIpClient_ForServer : Device, IAutoReconnect
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,8 +34,14 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
//public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
//public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of text received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceived;
|
public event EventHandler<GenericTcpServerCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of socket status change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<GenericTcpServerSocketStatusChangeEventArgs> ConnectionChange;
|
public event EventHandler<GenericTcpServerSocketStatusChangeEventArgs> ConnectionChange;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic TCP/IP server device
|
||||||
|
/// </summary>
|
||||||
public class GenericTcpIpServer : Device
|
public class GenericTcpIpServer : Device
|
||||||
{
|
{
|
||||||
#region Events
|
#region Events
|
||||||
@@ -49,6 +52,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
|
public ServerHasChokedCallbackDelegate ServerHasChoked { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public delegate void ServerHasChokedCallbackDelegate();
|
public delegate void ServerHasChokedCallbackDelegate();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -330,6 +336,10 @@ namespace PepperDash.Core
|
|||||||
Key = key;
|
Key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialze with server configuration object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serverConfigObject"></param>
|
||||||
public void Initialize(TcpServerConfigObject serverConfigObject)
|
public void Initialize(TcpServerConfigObject serverConfigObject)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -416,7 +426,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stop Listeneing
|
/// Stop Listening
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void StopListening()
|
public void StopListening()
|
||||||
{
|
{
|
||||||
@@ -592,6 +602,11 @@ namespace PepperDash.Core
|
|||||||
return received;
|
return received;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the IP address based on the client index
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clientIndex"></param>
|
||||||
|
/// <returns>IP address of the client</returns>
|
||||||
public string GetClientIPAddress(uint clientIndex)
|
public string GetClientIPAddress(uint clientIndex)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "GetClientIPAddress Index: {0}", clientIndex);
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "GetClientIPAddress Index: {0}", clientIndex);
|
||||||
|
|||||||
@@ -15,9 +15,15 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic UDP Server device
|
||||||
|
/// </summary>
|
||||||
public class GenericUdpServer : Device, ISocketStatusWithStreamDebugging
|
public class GenericUdpServer : Device, ISocketStatusWithStreamDebugging
|
||||||
{
|
{
|
||||||
private const string SplusKey = "Uninitialized Udp Server";
|
private const string SplusKey = "Uninitialized Udp Server";
|
||||||
|
/// <summary>
|
||||||
|
/// Object to enable stream debugging
|
||||||
|
/// </summary>
|
||||||
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -6,15 +6,36 @@ using Crestron.SimplSharp;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Allows for two simultaneous TCP clients to connect to a redundant pair of QSC Core DSPs and manages
|
||||||
|
/// </summary>
|
||||||
public class QscCoreDoubleTcpIpClient : IKeyed
|
public class QscCoreDoubleTcpIpClient : IKeyed
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Key to uniquely identify the instance of the class
|
||||||
|
/// </summary>
|
||||||
public string Key { get; private set; }
|
public string Key { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fires when a bool value changes to notify the S+ module
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Fires when a ushort value changes to notify the S+ module
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<UshrtChangeEventArgs> UshortChange;
|
public event EventHandler<UshrtChangeEventArgs> UshortChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Fires when a string value changes to notify the S+ module
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<StringChangeEventArgs> StringChange;
|
public event EventHandler<StringChangeEventArgs> StringChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client for the master DSP unit
|
||||||
|
/// </summary>
|
||||||
public GenericTcpIpClient MasterClient { get; private set; }
|
public GenericTcpIpClient MasterClient { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The client for the slave DSP unit
|
||||||
|
/// </summary>
|
||||||
public GenericTcpIpClient SlaveClient { get; private set; }
|
public GenericTcpIpClient SlaveClient { get; private set; }
|
||||||
|
|
||||||
string Username;
|
string Username;
|
||||||
@@ -45,7 +66,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Connects to both DSP units
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="masterAddress"></param>
|
/// <param name="masterAddress"></param>
|
||||||
@@ -55,6 +76,7 @@ namespace PepperDash.Core
|
|||||||
/// <param name="username"></param>
|
/// <param name="username"></param>
|
||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
/// <param name="pollingIntervalSeconds"></param>
|
/// <param name="pollingIntervalSeconds"></param>
|
||||||
|
/// <param name="lineEnding"></param>
|
||||||
public void Connect(string key, string masterAddress, int masterPort,
|
public void Connect(string key, string masterAddress, int masterPort,
|
||||||
string slaveAddress, int slavePort, string username, string password,
|
string slaveAddress, int slavePort, string username, string password,
|
||||||
int pollingIntervalSeconds, string lineEnding)
|
int pollingIntervalSeconds, string lineEnding)
|
||||||
@@ -299,14 +321,31 @@ namespace PepperDash.Core
|
|||||||
handler(this, new StringChangeEventArgs(value, type));
|
handler(this, new StringChangeEventArgs(value, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort MasterIsActiveId = 3;
|
public const ushort MasterIsActiveId = 3;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort SlaveIsActiveId = 4;
|
public const ushort SlaveIsActiveId = 4;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort MainModuleInitiailzeId = 5;
|
public const ushort MainModuleInitiailzeId = 5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort MasterClientStatusId = 101;
|
public const ushort MasterClientStatusId = 101;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort SlaveClientStatusId = 102;
|
public const ushort SlaveClientStatusId = 102;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort LineReceivedId = 201;
|
public const ushort LineReceivedId = 201;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,69 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum eControlMethod
|
public enum eControlMethod
|
||||||
{
|
{
|
||||||
None = 0, Com, IpId, IpidTcp, IR, Ssh, Tcpip, Telnet, Cresnet, Cec, Udp, Http, Https, Ws, Wss, SecureTcpIp
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// RS232/422/485
|
||||||
|
/// </summary>
|
||||||
|
Com,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IpId (most Crestron ethernet devices)
|
||||||
|
/// </summary>
|
||||||
|
IpId,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IpIdTcp (HD-MD series, etc.)
|
||||||
|
/// </summary>
|
||||||
|
IpidTcp,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestron IR control
|
||||||
|
/// </summary>
|
||||||
|
IR,
|
||||||
|
/// <summary>
|
||||||
|
/// SSH client
|
||||||
|
/// </summary>
|
||||||
|
Ssh,
|
||||||
|
/// <summary>
|
||||||
|
/// TCP/IP client
|
||||||
|
/// </summary>
|
||||||
|
Tcpip,
|
||||||
|
/// <summary>
|
||||||
|
/// Telnet
|
||||||
|
/// </summary>
|
||||||
|
Telnet,
|
||||||
|
/// <summary>
|
||||||
|
/// Crestnet device
|
||||||
|
/// </summary>
|
||||||
|
Cresnet,
|
||||||
|
/// <summary>
|
||||||
|
/// CEC Control, via a DM HDMI port
|
||||||
|
/// </summary>
|
||||||
|
Cec,
|
||||||
|
/// <summary>
|
||||||
|
/// UDP Server
|
||||||
|
/// </summary>
|
||||||
|
Udp,
|
||||||
|
/// <summary>
|
||||||
|
/// HTTP client
|
||||||
|
/// </summary>
|
||||||
|
Http,
|
||||||
|
/// <summary>
|
||||||
|
/// HTTPS client
|
||||||
|
/// </summary>
|
||||||
|
Https,
|
||||||
|
/// <summary>
|
||||||
|
/// Websocket client
|
||||||
|
/// </summary>
|
||||||
|
Ws,
|
||||||
|
/// <summary>
|
||||||
|
/// Secure Websocket client
|
||||||
|
/// </summary>
|
||||||
|
Wss,
|
||||||
|
/// <summary>
|
||||||
|
/// Secure TCP/IP
|
||||||
|
/// </summary>
|
||||||
|
SecureTcpIp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,11 +15,26 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICommunicationReceiver : IKeyed
|
public interface ICommunicationReceiver : IKeyed
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of bytes received
|
||||||
|
/// </summary>
|
||||||
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of text received
|
||||||
|
/// </summary>
|
||||||
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates connection status
|
||||||
|
/// </summary>
|
||||||
bool IsConnected { get; }
|
bool IsConnected { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// Connect to the device
|
||||||
|
/// </summary>
|
||||||
void Connect();
|
void Connect();
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnect from the device
|
||||||
|
/// </summary>
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +43,16 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IBasicCommunication : ICommunicationReceiver
|
public interface IBasicCommunication : ICommunicationReceiver
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Send text to the device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
void SendText(string text);
|
void SendText(string text);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send bytes to the device
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
void SendBytes(byte[] bytes);
|
void SendBytes(byte[] bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +69,9 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IStreamDebugging
|
public interface IStreamDebugging
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Object to enable stream debugging
|
||||||
|
/// </summary>
|
||||||
CommunicationStreamDebugging StreamDebugging { get; }
|
CommunicationStreamDebugging StreamDebugging { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,21 +81,37 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISocketStatus : IBasicCommunication
|
public interface ISocketStatus : IBasicCommunication
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of socket status changes
|
||||||
|
/// </summary>
|
||||||
event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current socket status of the client
|
||||||
|
/// </summary>
|
||||||
SocketStatus ClientStatus { get; }
|
SocketStatus ClientStatus { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a device that implements ISocketStatus and IStreamDebugging
|
/// Describes a device that implements ISocketStatus and IStreamDebugging
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISocketStatusWithStreamDebugging : ISocketStatus, IStreamDebugging
|
public interface ISocketStatusWithStreamDebugging : ISocketStatus, IStreamDebugging
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that can automatically attempt to reconnect
|
||||||
|
/// </summary>
|
||||||
public interface IAutoReconnect
|
public interface IAutoReconnect
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enable automatic recconnect
|
||||||
|
/// </summary>
|
||||||
bool AutoReconnect { get; set; }
|
bool AutoReconnect { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Interval in ms to attempt automatic recconnections
|
||||||
|
/// </summary>
|
||||||
int AutoReconnectIntervalMs { get; set; }
|
int AutoReconnectIntervalMs { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +120,14 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum eGenericCommMethodStatusChangeType
|
public enum eGenericCommMethodStatusChangeType
|
||||||
{
|
{
|
||||||
Connected, Disconnected
|
/// <summary>
|
||||||
|
/// Connected
|
||||||
|
/// </summary>
|
||||||
|
Connected,
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnected
|
||||||
|
/// </summary>
|
||||||
|
Disconnected
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -92,14 +142,22 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public byte[] Bytes { get; private set; }
|
public byte[] Bytes { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
|
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
|
||||||
{
|
{
|
||||||
Bytes = bytes;
|
Bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericCommMethodReceiveBytesArgs() { }
|
public GenericCommMethodReceiveBytesArgs() { }
|
||||||
}
|
}
|
||||||
@@ -109,13 +167,28 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenericCommMethodReceiveTextArgs : EventArgs
|
public class GenericCommMethodReceiveTextArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Text { get; private set; }
|
public string Text { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Delimiter { get; private set; }
|
public string Delimiter { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
public GenericCommMethodReceiveTextArgs(string text)
|
public GenericCommMethodReceiveTextArgs(string text)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="delimiter"></param>
|
||||||
public GenericCommMethodReceiveTextArgs(string text, string delimiter)
|
public GenericCommMethodReceiveTextArgs(string text, string delimiter)
|
||||||
:this(text)
|
:this(text)
|
||||||
{
|
{
|
||||||
@@ -123,7 +196,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stupid S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericCommMethodReceiveTextArgs() { }
|
public GenericCommMethodReceiveTextArgs() { }
|
||||||
}
|
}
|
||||||
@@ -135,17 +208,32 @@ namespace PepperDash.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ComTextHelper
|
public class ComTextHelper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets escaped text for a byte array
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bytes"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetEscapedText(byte[] bytes)
|
public static string GetEscapedText(byte[] bytes)
|
||||||
{
|
{
|
||||||
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets escaped text for a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetEscapedText(string text)
|
public static string GetEscapedText(string text)
|
||||||
{
|
{
|
||||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||||
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets debug text for a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetDebugText(string text)
|
public static string GetDebugText(string text)
|
||||||
{
|
{
|
||||||
return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value));
|
return Regex.Replace(text, @"[^\u0020-\u007E]", a => GetEscapedText(a.Value));
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ using PepperDash.Core;
|
|||||||
|
|
||||||
namespace PepperDash.Core.Config
|
namespace PepperDash.Core.Config
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a Portal formatted config file
|
||||||
|
/// </summary>
|
||||||
public class PortalConfigReader
|
public class PortalConfigReader
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace PepperDash.Core
|
|||||||
List<Action> _PreActivationActions;
|
List<Action> _PreActivationActions;
|
||||||
List<Action> _PostActivationActions;
|
List<Action> _PostActivationActions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
||||||
static Device _DefaultDevice = new Device("Default", "Default");
|
static Device _DefaultDevice = new Device("Default", "Default");
|
||||||
|
|
||||||
@@ -51,6 +54,11 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor with key and name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
public Device(string key, string name) : this(key)
|
public Device(string key, string name) : this(key)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@@ -63,6 +71,10 @@ namespace PepperDash.Core
|
|||||||
// Config = config;
|
// Config = config;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a pre activation action
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="act"></param>
|
||||||
public void AddPreActivationAction(Action act)
|
public void AddPreActivationAction(Action act)
|
||||||
{
|
{
|
||||||
if (_PreActivationActions == null)
|
if (_PreActivationActions == null)
|
||||||
@@ -70,6 +82,10 @@ namespace PepperDash.Core
|
|||||||
_PreActivationActions.Add(act);
|
_PreActivationActions.Add(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a post activation action
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="act"></param>
|
||||||
public void AddPostActivationAction(Action act)
|
public void AddPostActivationAction(Action act)
|
||||||
{
|
{
|
||||||
if (_PostActivationActions == null)
|
if (_PostActivationActions == null)
|
||||||
@@ -77,6 +93,9 @@ namespace PepperDash.Core
|
|||||||
_PostActivationActions.Add(act);
|
_PostActivationActions.Add(act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the preactivation actions
|
||||||
|
/// </summary>
|
||||||
public void PreActivate()
|
public void PreActivate()
|
||||||
{
|
{
|
||||||
if (_PreActivationActions != null)
|
if (_PreActivationActions != null)
|
||||||
@@ -98,6 +117,9 @@ namespace PepperDash.Core
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the postactivation actions
|
||||||
|
/// </summary>
|
||||||
public void PostActivate()
|
public void PostActivate()
|
||||||
{
|
{
|
||||||
if (_PostActivationActions != null)
|
if (_PostActivationActions != null)
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to help with accessing values from the CrestronEthernetHelper class
|
||||||
|
/// </summary>
|
||||||
public class EthernetHelper
|
public class EthernetHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace PepperDash.Core.GenericRESTfulCommunications
|
|||||||
/// <param name="requestType"></param>
|
/// <param name="requestType"></param>
|
||||||
/// <param name="username"></param>
|
/// <param name="username"></param>
|
||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
|
/// <param name="contentType"></param>
|
||||||
public void SubmitRequest(string url, ushort port, ushort requestType, string contentType, string username, string password)
|
public void SubmitRequest(string url, ushort port, ushort requestType, string contentType, string username, string password)
|
||||||
{
|
{
|
||||||
if (url.StartsWith("https:", StringComparison.OrdinalIgnoreCase))
|
if (url.StartsWith("https:", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|||||||
@@ -52,19 +52,55 @@ namespace PepperDash.Core.JsonStandardObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ComParamsConfig
|
public class ComParamsConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int baudRate { get; set; }
|
public int baudRate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int dataBits { get; set; }
|
public int dataBits { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int stopBits { get; set; }
|
public int stopBits { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string parity { get; set; }
|
public string parity { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string protocol { get; set; }
|
public string protocol { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string hardwareHandshake { get; set; }
|
public string hardwareHandshake { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string softwareHandshake { get; set; }
|
public string softwareHandshake { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int pacing { get; set; }
|
public int pacing { get; set; }
|
||||||
|
|
||||||
// convert properties for simpl
|
// convert properties for simpl
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplBaudRate { get { return Convert.ToUInt16(baudRate); } }
|
public ushort simplBaudRate { get { return Convert.ToUInt16(baudRate); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplDataBits { get { return Convert.ToUInt16(dataBits); } }
|
public ushort simplDataBits { get { return Convert.ToUInt16(dataBits); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplStopBits { get { return Convert.ToUInt16(stopBits); } }
|
public ushort simplStopBits { get { return Convert.ToUInt16(stopBits); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplPacing { get { return Convert.ToUInt16(pacing); } }
|
public ushort simplPacing { get { return Convert.ToUInt16(pacing); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -81,16 +117,44 @@ namespace PepperDash.Core.JsonStandardObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TcpSshPropertiesConfig
|
public class TcpSshPropertiesConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string address { get; set; }
|
public string address { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int port { get; set; }
|
public int port { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string username { get; set; }
|
public string username { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string password { get; set; }
|
public string password { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool autoReconnect { get; set; }
|
public bool autoReconnect { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int autoReconnectIntervalMs { get; set; }
|
public int autoReconnectIntervalMs { get; set; }
|
||||||
|
///
|
||||||
|
|
||||||
// convert properties for simpl
|
// convert properties for simpl
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplPort { get { return Convert.ToUInt16(port); } }
|
public ushort simplPort { get { return Convert.ToUInt16(port); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplAutoReconnect { get { return (ushort)(autoReconnect ? 1 : 0); } }
|
public ushort simplAutoReconnect { get { return (ushort)(autoReconnect ? 1 : 0); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplAutoReconnectIntervalMs { get { return Convert.ToUInt16(autoReconnectIntervalMs); } }
|
public ushort simplAutoReconnectIntervalMs { get { return Convert.ToUInt16(autoReconnectIntervalMs); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -107,13 +171,31 @@ namespace PepperDash.Core.JsonStandardObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlConfig
|
public class ControlConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string method { get; set; }
|
public string method { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string controlPortDevKey { get; set; }
|
public string controlPortDevKey { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int controlPortNumber { get; set; }
|
public int controlPortNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ComParamsConfig comParams { get; set; }
|
public ComParamsConfig comParams { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public TcpSshPropertiesConfig tcpSshProperties { get; set; }
|
public TcpSshPropertiesConfig tcpSshProperties { get; set; }
|
||||||
|
|
||||||
// convert properties for simpl
|
// convert properties for simpl
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplControlPortNumber { get { return Convert.ToUInt16(controlPortNumber); } }
|
public ushort simplControlPortNumber { get { return Convert.ToUInt16(controlPortNumber); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -131,12 +213,27 @@ namespace PepperDash.Core.JsonStandardObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PropertiesConfig
|
public class PropertiesConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int deviceId { get; set; }
|
public int deviceId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool enabled { get; set; }
|
public bool enabled { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ControlConfig control { get; set; }
|
public ControlConfig control { get; set; }
|
||||||
|
|
||||||
// convert properties for simpl
|
// convert properties for simpl
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplDeviceId { get { return Convert.ToUInt16(deviceId); } }
|
public ushort simplDeviceId { get { return Convert.ToUInt16(deviceId); } }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort simplEnabled { get { return (ushort)(enabled ? 1 : 0); } }
|
public ushort simplEnabled { get { return (ushort)(enabled ? 1 : 0); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,17 +11,40 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class JsonToSimplConstants
|
public class JsonToSimplConstants
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort BoolValueChange = 1;
|
public const ushort BoolValueChange = 1;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort JsonIsValidBoolChange = 2;
|
public const ushort JsonIsValidBoolChange = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort UshortValueChange = 101;
|
public const ushort UshortValueChange = 101;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort StringValueChange = 201;
|
public const ushort StringValueChange = 201;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort FullPathToArrayChange = 202;
|
public const ushort FullPathToArrayChange = 202;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort ActualFilePathChange = 203;
|
public const ushort ActualFilePathChange = 203;
|
||||||
|
|
||||||
// TODO: pdc-20: Added below constants for passing file path and filename back to S+
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort FilenameResolvedChange = 204;
|
public const ushort FilenameResolvedChange = 204;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort FilePathResolvedChange = 205;
|
public const ushort FilePathResolvedChange = 205;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,13 +58,33 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SPlusValueWrapper
|
public class SPlusValueWrapper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public SPlusType ValueType { get; private set; }
|
public SPlusType ValueType { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort Index { get; private set; }
|
public ushort Index { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort BoolUShortValue { get; set; }
|
public ushort BoolUShortValue { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string StringValue { get; set; }
|
public string StringValue { get; set; }
|
||||||
|
|
||||||
public SPlusValueWrapper() { }
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public SPlusValueWrapper() {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
public SPlusValueWrapper(SPlusType type, ushort index)
|
public SPlusValueWrapper(SPlusType type, ushort index)
|
||||||
{
|
{
|
||||||
ValueType = type;
|
ValueType = type;
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ using Crestron.SimplSharp;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The global class to manage all the instances of JsonToSimplMaster
|
||||||
|
/// </summary>
|
||||||
public class J2SGlobal
|
public class J2SGlobal
|
||||||
{
|
{
|
||||||
static List<JsonToSimplMaster> Masters = new List<JsonToSimplMaster>();
|
static List<JsonToSimplMaster> Masters = new List<JsonToSimplMaster>();
|
||||||
|
|||||||
@@ -8,15 +8,24 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to interact with an array of values with the S+ modules
|
||||||
|
/// </summary>
|
||||||
public class JsonToSimplArrayLookupChild : JsonToSimplChildObjectBase
|
public class JsonToSimplArrayLookupChild : JsonToSimplChildObjectBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string SearchPropertyName { get; set; }
|
public string SearchPropertyName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string SearchPropertyValue { get; set; }
|
public string SearchPropertyValue { get; set; }
|
||||||
|
|
||||||
int ArrayIndex;
|
int ArrayIndex;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For <2.4.1 array lookups
|
/// For gt2.4.1 array lookups
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file"></param>
|
/// <param name="file"></param>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
|
|||||||
@@ -8,13 +8,27 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for JSON objects
|
||||||
|
/// </summary>
|
||||||
public abstract class JsonToSimplChildObjectBase : IKeyed
|
public abstract class JsonToSimplChildObjectBase : IKeyed
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of bool change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of ushort change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<UshrtChangeEventArgs> UShortChange;
|
public event EventHandler<UshrtChangeEventArgs> UShortChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of string change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<StringChangeEventArgs> StringChange;
|
public event EventHandler<StringChangeEventArgs> StringChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delegate to get all values
|
||||||
|
/// </summary>
|
||||||
public SPlusValuesDelegate GetAllValuesDelegate { get; set; }
|
public SPlusValuesDelegate GetAllValuesDelegate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,6 +36,9 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public SPlusValuesDelegate SetAllPathsDelegate { get; set; }
|
public SPlusValuesDelegate SetAllPathsDelegate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unique identifier for instance
|
||||||
|
/// </summary>
|
||||||
public string Key { get; protected set; }
|
public string Key { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -35,8 +52,14 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PathSuffix { get; protected set; }
|
public string PathSuffix { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if the instance is linked to an object
|
||||||
|
/// </summary>
|
||||||
public bool LinkedToObject { get; protected set; }
|
public bool LinkedToObject { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reference to Master instance
|
||||||
|
/// </summary>
|
||||||
protected JsonToSimplMaster Master;
|
protected JsonToSimplMaster Master;
|
||||||
|
|
||||||
// The sent-in JPaths for the various types
|
// The sent-in JPaths for the various types
|
||||||
@@ -47,7 +70,7 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call this before doing anything else
|
/// Call this before doing anything else
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file"></param>
|
/// <param name="masterUniqueId"></param>
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
/// <param name="pathPrefix"></param>
|
/// <param name="pathPrefix"></param>
|
||||||
/// <param name="pathSuffix"></param>
|
/// <param name="pathSuffix"></param>
|
||||||
@@ -64,6 +87,10 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
Debug.Console(1, "JSON Child [{0}] cannot link to master {1}", key, masterUniqueId);
|
Debug.Console(1, "JSON Child [{0}] cannot link to master {1}", key, masterUniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the path prefix for the object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathPrefix"></param>
|
||||||
public void SetPathPrefix(string pathPrefix)
|
public void SetPathPrefix(string pathPrefix)
|
||||||
{
|
{
|
||||||
PathPrefix = pathPrefix;
|
PathPrefix = pathPrefix;
|
||||||
@@ -240,29 +267,54 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
GetAllValuesDelegate();
|
GetAllValuesDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="theValue"></param>
|
||||||
public void USetBoolValue(ushort key, ushort theValue)
|
public void USetBoolValue(ushort key, ushort theValue)
|
||||||
{
|
{
|
||||||
SetBoolValue(key, theValue == 1);
|
SetBoolValue(key, theValue == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="theValue"></param>
|
||||||
public void SetBoolValue(ushort key, bool theValue)
|
public void SetBoolValue(ushort key, bool theValue)
|
||||||
{
|
{
|
||||||
if (BoolPaths.ContainsKey(key))
|
if (BoolPaths.ContainsKey(key))
|
||||||
SetValueOnMaster(BoolPaths[key], new JValue(theValue));
|
SetValueOnMaster(BoolPaths[key], new JValue(theValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="theValue"></param>
|
||||||
public void SetUShortValue(ushort key, ushort theValue)
|
public void SetUShortValue(ushort key, ushort theValue)
|
||||||
{
|
{
|
||||||
if (UshortPaths.ContainsKey(key))
|
if (UshortPaths.ContainsKey(key))
|
||||||
SetValueOnMaster(UshortPaths[key], new JValue(theValue));
|
SetValueOnMaster(UshortPaths[key], new JValue(theValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="theValue"></param>
|
||||||
public void SetStringValue(ushort key, string theValue)
|
public void SetStringValue(ushort key, string theValue)
|
||||||
{
|
{
|
||||||
if (StringPaths.ContainsKey(key))
|
if (StringPaths.ContainsKey(key))
|
||||||
SetValueOnMaster(StringPaths[key], new JValue(theValue));
|
SetValueOnMaster(StringPaths[key], new JValue(theValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keyPath"></param>
|
||||||
|
/// <param name="valueToSave"></param>
|
||||||
public void SetValueOnMaster(string keyPath, JValue valueToSave)
|
public void SetValueOnMaster(string keyPath, JValue valueToSave)
|
||||||
{
|
{
|
||||||
var path = GetFullPath(keyPath);
|
var path = GetFullPath(keyPath);
|
||||||
@@ -292,6 +344,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
|
|
||||||
// Helpers for events
|
// Helpers for events
|
||||||
//******************************************************************************************
|
//******************************************************************************************
|
||||||
|
/// <summary>
|
||||||
|
/// Event helper
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnBoolChange(bool state, ushort index, ushort type)
|
protected void OnBoolChange(bool state, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = BoolChange;
|
var handler = BoolChange;
|
||||||
@@ -304,6 +362,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************************
|
//******************************************************************************************
|
||||||
|
/// <summary>
|
||||||
|
/// Event helper
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnUShortChange(ushort state, ushort index, ushort type)
|
protected void OnUShortChange(ushort state, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = UShortChange;
|
var handler = UShortChange;
|
||||||
@@ -315,6 +379,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event helper
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnStringChange(string value, ushort index, ushort type)
|
protected void OnStringChange(string value, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
var handler = StringChange;
|
var handler = StringChange;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a JSON file that can be read and written to
|
||||||
|
/// </summary>
|
||||||
public class JsonToSimplFileMaster : JsonToSimplMaster
|
public class JsonToSimplFileMaster : JsonToSimplMaster
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -17,10 +20,18 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Filepath { get; private set; }
|
public string Filepath { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Filepath to the actual file that will be read (Portal or local)
|
||||||
|
/// </summary>
|
||||||
public string ActualFilePath { get; private set; }
|
public string ActualFilePath { get; private set; }
|
||||||
|
|
||||||
// TODO: pdc-20: added to return filename back to SIMPL
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Filename { get; private set; }
|
public string Filename { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string FilePathName { get; private set; }
|
public string FilePathName { get; private set; }
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public class JsonToSimplFixedPathObject : JsonToSimplChildObjectBase
|
public class JsonToSimplFixedPathObject : JsonToSimplChildObjectBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public JsonToSimplFixedPathObject()
|
public JsonToSimplFixedPathObject()
|
||||||
{
|
{
|
||||||
this.LinkedToObject = true;
|
this.LinkedToObject = true;
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
//using System.IO;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharp.Net.Http;
|
|
||||||
using Crestron.SimplSharp.Net.Https;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Generic Master
|
||||||
|
/// </summary>
|
||||||
public class JsonToSimplGenericMaster : JsonToSimplMaster
|
public class JsonToSimplGenericMaster : JsonToSimplMaster
|
||||||
{
|
{
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
@@ -24,6 +20,9 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
// To prevent multiple same-file access
|
// To prevent multiple same-file access
|
||||||
static object WriteLock = new object();
|
static object WriteLock = new object();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Callback action for saving
|
||||||
|
/// </summary>
|
||||||
public Action<string> SaveCallback { get; set; }
|
public Action<string> SaveCallback { get; set; }
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
@@ -116,38 +115,4 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
Debug.Console(0, this, "WARNING: No save callback defined.");
|
Debug.Console(0, this, "WARNING: No save callback defined.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// JContainer jpart = JsonObject;
|
|
||||||
// // walk down the path and find where it goes
|
|
||||||
//#warning Does not handle arrays.
|
|
||||||
// foreach (var part in path.Split('.'))
|
|
||||||
// {
|
|
||||||
|
|
||||||
// var openPos = part.IndexOf('[');
|
|
||||||
// if (openPos > -1)
|
|
||||||
// {
|
|
||||||
// openPos++; // move to number
|
|
||||||
// var closePos = part.IndexOf(']');
|
|
||||||
// var arrayName = part.Substring(0, openPos - 1); // get the name
|
|
||||||
// var index = Convert.ToInt32(part.Substring(openPos, closePos - openPos));
|
|
||||||
|
|
||||||
// // Check if the array itself exists and add the item if so
|
|
||||||
// if (jpart[arrayName] != null)
|
|
||||||
// {
|
|
||||||
// var arrayObj = jpart[arrayName] as JArray;
|
|
||||||
// var item = arrayObj[index];
|
|
||||||
// if (item == null)
|
|
||||||
// arrayObj.Add(new JObject());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Debug.Console(0, "IGNORING MISSING ARRAY VALUE FOR NOW");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // Build the
|
|
||||||
// if (jpart[part] == null)
|
|
||||||
// jpart.Add(new JProperty(part, new JObject()));
|
|
||||||
// jpart = jpart[part] as JContainer;
|
|
||||||
// }
|
|
||||||
// jpart.Replace(UnsavedValues[path]);
|
|
||||||
@@ -10,15 +10,27 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Abstract base class for JsonToSimpl interactions
|
||||||
|
/// </summary>
|
||||||
public abstract class JsonToSimplMaster : IKeyed
|
public abstract class JsonToSimplMaster : IKeyed
|
||||||
{
|
{
|
||||||
/*****************************************************************************************/
|
/// <summary>
|
||||||
/** Events **/
|
/// Notifies of bool change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of ushort change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<UshrtChangeEventArgs> UshrtChange;
|
public event EventHandler<UshrtChangeEventArgs> UshrtChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of string change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<StringChangeEventArgs> StringChange;
|
public event EventHandler<StringChangeEventArgs> StringChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of associated child modules
|
||||||
|
/// </summary>
|
||||||
protected List<JsonToSimplChildObjectBase> Children = new List<JsonToSimplChildObjectBase>();
|
protected List<JsonToSimplChildObjectBase> Children = new List<JsonToSimplChildObjectBase>();
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
@@ -28,6 +40,9 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Key { get { return UniqueID; } }
|
public string Key { get { return UniqueID; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A unique ID
|
||||||
|
/// </summary>
|
||||||
public string UniqueID { get; protected set; }
|
public string UniqueID { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -70,6 +85,9 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public JObject JsonObject { get; protected set; }
|
public JObject JsonObject { get; protected set; }
|
||||||
|
|
||||||
/*****************************************************************************************/
|
/*****************************************************************************************/
|
||||||
@@ -126,12 +144,22 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
//Debug.Console(0, "Master[{0}] Unsaved size={1}", UniqueID, UnsavedValues.Count);
|
//Debug.Console(0, "Master[{0}] Unsaved size={1}", UniqueID, UnsavedValues.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the file
|
||||||
|
/// </summary>
|
||||||
public abstract void Save();
|
public abstract void Save();
|
||||||
|
|
||||||
|
|
||||||
//******************************************************************************************
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public static class JsonFixes
|
public static class JsonFixes
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deserializes a string into a JObject
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="json"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static JObject ParseObject(string json)
|
public static JObject ParseObject(string json)
|
||||||
{
|
{
|
||||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||||
@@ -144,6 +172,11 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deserializes a string into a JArray
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="json"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static JArray ParseArray(string json)
|
public static JArray ParseArray(string json)
|
||||||
{
|
{
|
||||||
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
using (var reader = new JsonTextReader(new Crestron.SimplSharp.CrestronIO.StringReader(json)))
|
||||||
@@ -157,8 +190,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helpers for events
|
/// <summary>
|
||||||
//******************************************************************************************
|
/// Helper event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnBoolChange(bool state, ushort index, ushort type)
|
protected void OnBoolChange(bool state, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
if (BoolChange != null)
|
if (BoolChange != null)
|
||||||
@@ -169,7 +206,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************************
|
/// <summary>
|
||||||
|
/// Helper event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnUshrtChange(ushort state, ushort index, ushort type)
|
protected void OnUshrtChange(ushort state, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
if (UshrtChange != null)
|
if (UshrtChange != null)
|
||||||
@@ -180,6 +222,12 @@ namespace PepperDash.Core.JsonToSimpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
protected void OnStringChange(string value, ushort index, ushort type)
|
protected void OnStringChange(string value, ushort index, ushort type)
|
||||||
{
|
{
|
||||||
if (StringChange != null)
|
if (StringChange != null)
|
||||||
|
|||||||
@@ -1,221 +1,195 @@
|
|||||||
using System;
|
using System;
|
||||||
//using System.IO;
|
//using System.IO;
|
||||||
using System.Collections.Generic;
|
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;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
using PepperDash.Core.Config;
|
using PepperDash.Core.Config;
|
||||||
|
|
||||||
namespace PepperDash.Core.JsonToSimpl
|
namespace PepperDash.Core.JsonToSimpl
|
||||||
{
|
{
|
||||||
public class JsonToSimplPortalFileMaster : JsonToSimplMaster
|
/// <summary>
|
||||||
{
|
/// Portal File Master
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// Sets the filepath as well as registers this with the Global.Masters list
|
public class JsonToSimplPortalFileMaster : JsonToSimplMaster
|
||||||
/// </summary>
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the filepath as well as registers this with the Global.Masters list
|
||||||
|
/// </summary>
|
||||||
public string PortalFilepath { get; private set; }
|
public string PortalFilepath { get; private set; }
|
||||||
|
|
||||||
public string ActualFilePath { get; private set; }
|
/// <summary>
|
||||||
|
/// File path of the actual file being read (Portal or local)
|
||||||
/*****************************************************************************************/
|
/// </summary>
|
||||||
/** Privates **/
|
public string ActualFilePath { get; private set; }
|
||||||
|
|
||||||
// To prevent multiple same-file access
|
/*****************************************************************************************/
|
||||||
object StringBuilderLock = new object();
|
/** Privates **/
|
||||||
static object FileLock = new object();
|
|
||||||
|
// To prevent multiple same-file access
|
||||||
/*****************************************************************************************/
|
object StringBuilderLock = new object();
|
||||||
|
static object FileLock = new object();
|
||||||
/// <summary>
|
|
||||||
/// SIMPL+ default constructor.
|
/*****************************************************************************************/
|
||||||
/// </summary>
|
|
||||||
public JsonToSimplPortalFileMaster()
|
/// <summary>
|
||||||
{
|
/// SIMPL+ default constructor.
|
||||||
}
|
/// </summary>
|
||||||
|
public JsonToSimplPortalFileMaster()
|
||||||
/// <summary>
|
{
|
||||||
/// Read, evaluate and udpate status
|
}
|
||||||
/// </summary>
|
|
||||||
public void EvaluateFile(string portalFilepath)
|
/// <summary>
|
||||||
{
|
/// Read, evaluate and udpate status
|
||||||
PortalFilepath = portalFilepath;
|
/// </summary>
|
||||||
|
public void EvaluateFile(string portalFilepath)
|
||||||
OnBoolChange(false, 0, JsonToSimplConstants.JsonIsValidBoolChange);
|
{
|
||||||
if (string.IsNullOrEmpty(PortalFilepath))
|
PortalFilepath = portalFilepath;
|
||||||
{
|
|
||||||
CrestronConsole.PrintLine("Cannot evaluate file. JSON file path not set");
|
OnBoolChange(false, 0, JsonToSimplConstants.JsonIsValidBoolChange);
|
||||||
return;
|
if (string.IsNullOrEmpty(PortalFilepath))
|
||||||
}
|
{
|
||||||
|
CrestronConsole.PrintLine("Cannot evaluate file. JSON file path not set");
|
||||||
// Resolve possible wildcarded filename
|
return;
|
||||||
|
}
|
||||||
// If the portal file is xyz.json, then
|
|
||||||
// the file we want to check for first will be called xyz.local.json
|
// Resolve possible wildcarded filename
|
||||||
var localFilepath = Path.ChangeExtension(PortalFilepath, "local.json");
|
|
||||||
Debug.Console(0, this, "Checking for local file {0}", localFilepath);
|
// If the portal file is xyz.json, then
|
||||||
var actualLocalFile = GetActualFileInfoFromPath(localFilepath);
|
// the file we want to check for first will be called xyz.local.json
|
||||||
|
var localFilepath = Path.ChangeExtension(PortalFilepath, "local.json");
|
||||||
if (actualLocalFile != null)
|
Debug.Console(0, this, "Checking for local file {0}", localFilepath);
|
||||||
{
|
var actualLocalFile = GetActualFileInfoFromPath(localFilepath);
|
||||||
|
|
||||||
|
if (actualLocalFile != null)
|
||||||
|
{
|
||||||
ActualFilePath = actualLocalFile.FullName;
|
ActualFilePath = actualLocalFile.FullName;
|
||||||
OnStringChange(ActualFilePath, 0, JsonToSimplConstants.ActualFilePathChange);
|
OnStringChange(ActualFilePath, 0, JsonToSimplConstants.ActualFilePathChange);
|
||||||
}
|
}
|
||||||
// If the local file does not exist, then read the portal file xyz.json
|
// If the local file does not exist, then read the portal file xyz.json
|
||||||
// and create the local.
|
// and create the local.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Local JSON file not found {0}\rLoading portal JSON file", localFilepath);
|
Debug.Console(1, this, "Local JSON file not found {0}\rLoading portal JSON file", localFilepath);
|
||||||
var actualPortalFile = GetActualFileInfoFromPath(portalFilepath);
|
var actualPortalFile = GetActualFileInfoFromPath(portalFilepath);
|
||||||
if (actualPortalFile != null)
|
if (actualPortalFile != null)
|
||||||
{
|
{
|
||||||
var newLocalPath = Path.ChangeExtension(actualPortalFile.FullName, "local.json");
|
var newLocalPath = Path.ChangeExtension(actualPortalFile.FullName, "local.json");
|
||||||
// got the portal file, hand off to the merge / save method
|
// got the portal file, hand off to the merge / save method
|
||||||
PortalConfigReader.ReadAndMergeFileIfNecessary(actualPortalFile.FullName, newLocalPath);
|
PortalConfigReader.ReadAndMergeFileIfNecessary(actualPortalFile.FullName, newLocalPath);
|
||||||
ActualFilePath = newLocalPath;
|
ActualFilePath = newLocalPath;
|
||||||
OnStringChange(ActualFilePath, 0, JsonToSimplConstants.ActualFilePathChange);
|
OnStringChange(ActualFilePath, 0, JsonToSimplConstants.ActualFilePathChange);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var msg = string.Format("Portal JSON file not found: {0}", PortalFilepath);
|
var msg = string.Format("Portal JSON file not found: {0}", PortalFilepath);
|
||||||
Debug.Console(1, this, msg);
|
Debug.Console(1, this, msg);
|
||||||
ErrorLog.Error(msg);
|
ErrorLog.Error(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point we should have a local file. Do it.
|
// At this point we should have a local file. Do it.
|
||||||
Debug.Console(1, "Reading local JSON file {0}", ActualFilePath);
|
Debug.Console(1, "Reading local JSON file {0}", ActualFilePath);
|
||||||
|
|
||||||
string json = File.ReadToEnd(ActualFilePath, System.Text.Encoding.ASCII);
|
string json = File.ReadToEnd(ActualFilePath, System.Text.Encoding.ASCII);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JsonObject = JObject.Parse(json);
|
JsonObject = JObject.Parse(json);
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
child.ProcessAll();
|
child.ProcessAll();
|
||||||
OnBoolChange(true, 0, JsonToSimplConstants.JsonIsValidBoolChange);
|
OnBoolChange(true, 0, JsonToSimplConstants.JsonIsValidBoolChange);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var msg = string.Format("JSON parsing failed:\r{0}", e);
|
var msg = string.Format("JSON parsing failed:\r{0}", e);
|
||||||
CrestronConsole.PrintLine(msg);
|
CrestronConsole.PrintLine(msg);
|
||||||
ErrorLog.Error(msg);
|
ErrorLog.Error(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the FileInfo object for a given path, with possible wildcards
|
/// Returns the FileInfo object for a given path, with possible wildcards
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
FileInfo GetActualFileInfoFromPath(string path)
|
FileInfo GetActualFileInfoFromPath(string path)
|
||||||
{
|
{
|
||||||
var dir = Path.GetDirectoryName(path);
|
var dir = Path.GetDirectoryName(path);
|
||||||
var localFilename = Path.GetFileName(path);
|
var localFilename = Path.GetFileName(path);
|
||||||
var directory = new DirectoryInfo(dir);
|
var directory = new DirectoryInfo(dir);
|
||||||
// search the directory for the file w/ wildcards
|
// search the directory for the file w/ wildcards
|
||||||
return directory.GetFiles(localFilename).FirstOrDefault();
|
return directory.GetFiles(localFilename).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="level"></param>
|
/// <param name="level"></param>
|
||||||
public void setDebugLevel(int level)
|
public void setDebugLevel(int level)
|
||||||
{
|
{
|
||||||
Debug.SetDebugLevel(level);
|
Debug.SetDebugLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void Save()
|
public override void Save()
|
||||||
{
|
{
|
||||||
// this code is duplicated in the other masters!!!!!!!!!!!!!
|
// this code is duplicated in the other masters!!!!!!!!!!!!!
|
||||||
UnsavedValues = new Dictionary<string, JValue>();
|
UnsavedValues = new Dictionary<string, JValue>();
|
||||||
// Make each child update their values into master object
|
// Make each child update their values into master object
|
||||||
foreach (var child in Children)
|
foreach (var child in Children)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Master [{0}] checking child [{1}] for updates to save", UniqueID, child.Key);
|
Debug.Console(1, "Master [{0}] checking child [{1}] for updates to save", UniqueID, child.Key);
|
||||||
child.UpdateInputsForMaster();
|
child.UpdateInputsForMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnsavedValues == null || UnsavedValues.Count == 0)
|
if (UnsavedValues == null || UnsavedValues.Count == 0)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Master [{0}] No updated values to save. Skipping", UniqueID);
|
Debug.Console(1, "Master [{0}] No updated values to save. Skipping", UniqueID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lock (FileLock)
|
lock (FileLock)
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Saving");
|
Debug.Console(1, "Saving");
|
||||||
foreach (var path in UnsavedValues.Keys)
|
foreach (var path in UnsavedValues.Keys)
|
||||||
{
|
{
|
||||||
var tokenToReplace = JsonObject.SelectToken(path);
|
var tokenToReplace = JsonObject.SelectToken(path);
|
||||||
if (tokenToReplace != null)
|
if (tokenToReplace != null)
|
||||||
{// It's found
|
{// It's found
|
||||||
tokenToReplace.Replace(UnsavedValues[path]);
|
tokenToReplace.Replace(UnsavedValues[path]);
|
||||||
Debug.Console(1, "JSON Master[{0}] Updating '{1}'", UniqueID, path);
|
Debug.Console(1, "JSON Master[{0}] Updating '{1}'", UniqueID, path);
|
||||||
}
|
}
|
||||||
else // No token. Let's make one
|
else // No token. Let's make one
|
||||||
{
|
{
|
||||||
//http://stackoverflow.com/questions/17455052/how-to-set-the-value-of-a-json-path-using-json-net
|
//http://stackoverflow.com/questions/17455052/how-to-set-the-value-of-a-json-path-using-json-net
|
||||||
Debug.Console(1, "JSON Master[{0}] Cannot write value onto missing property: '{1}'", UniqueID, path);
|
Debug.Console(1, "JSON Master[{0}] Cannot write value onto missing property: '{1}'", UniqueID, path);
|
||||||
|
|
||||||
// JContainer jpart = JsonObject;
|
}
|
||||||
// // walk down the path and find where it goes
|
}
|
||||||
//#warning Does not handle arrays.
|
using (StreamWriter sw = new StreamWriter(ActualFilePath))
|
||||||
// foreach (var part in path.Split('.'))
|
{
|
||||||
// {
|
try
|
||||||
|
{
|
||||||
// var openPos = part.IndexOf('[');
|
sw.Write(JsonObject.ToString());
|
||||||
// if (openPos > -1)
|
sw.Flush();
|
||||||
// {
|
}
|
||||||
// openPos++; // move to number
|
catch (Exception e)
|
||||||
// var closePos = part.IndexOf(']');
|
{
|
||||||
// var arrayName = part.Substring(0, openPos - 1); // get the name
|
string err = string.Format("Error writing JSON file:\r{0}", e);
|
||||||
// var index = Convert.ToInt32(part.Substring(openPos, closePos - openPos));
|
Debug.Console(0, err);
|
||||||
|
ErrorLog.Warn(err);
|
||||||
// // Check if the array itself exists and add the item if so
|
return;
|
||||||
// if (jpart[arrayName] != null)
|
}
|
||||||
// {
|
}
|
||||||
// var arrayObj = jpart[arrayName] as JArray;
|
}
|
||||||
// var item = arrayObj[index];
|
}
|
||||||
// if (item == null)
|
}
|
||||||
// arrayObj.Add(new JObject());
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// Debug.Console(0, "IGNORING MISSING ARRAY VALUE FOR NOW");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// // Build the
|
|
||||||
// if (jpart[part] == null)
|
|
||||||
// jpart.Add(new JProperty(part, new JObject()));
|
|
||||||
// jpart = jpart[part] as JContainer;
|
|
||||||
// }
|
|
||||||
// jpart.Replace(UnsavedValues[path]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
using (StreamWriter sw = new StreamWriter(ActualFilePath))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
sw.Write(JsonObject.ToString());
|
|
||||||
sw.Flush();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
string err = string.Format("Error writing JSON file:\r{0}", e);
|
|
||||||
Debug.Console(0, err);
|
|
||||||
ErrorLog.Warn(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ using PepperDash.Core.DebugThings;
|
|||||||
|
|
||||||
namespace PepperDash.Core
|
namespace PepperDash.Core
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a debugging context
|
||||||
|
/// </summary>
|
||||||
public class DebugContext
|
public class DebugContext
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -149,6 +152,14 @@ namespace PepperDash.Core
|
|||||||
Console(level, "[{0}] {1}", dev.Key, string.Format(format, items));
|
Console(level, "[{0}] {1}", dev.Key, string.Format(format, items));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level"></param>
|
||||||
|
/// <param name="dev"></param>
|
||||||
|
/// <param name="errorLogLevel"></param>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <param name="items"></param>
|
||||||
public void Console(uint level, IKeyed dev, Debug.ErrorLogLevel errorLogLevel,
|
public void Console(uint level, IKeyed dev, Debug.ErrorLogLevel errorLogLevel,
|
||||||
string format, params object[] items)
|
string format, params object[] items)
|
||||||
{
|
{
|
||||||
@@ -160,6 +171,13 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level"></param>
|
||||||
|
/// <param name="errorLogLevel"></param>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <param name="items"></param>
|
||||||
public void Console(uint level, Debug.ErrorLogLevel errorLogLevel,
|
public void Console(uint level, Debug.ErrorLogLevel errorLogLevel,
|
||||||
string format, params object[] items)
|
string format, params object[] items)
|
||||||
{
|
{
|
||||||
@@ -171,6 +189,11 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="errorLogLevel"></param>
|
||||||
|
/// <param name="str"></param>
|
||||||
public void LogError(Debug.ErrorLogLevel errorLogLevel, string str)
|
public void LogError(Debug.ErrorLogLevel errorLogLevel, string str)
|
||||||
{
|
{
|
||||||
string msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);
|
string msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str);
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ namespace PepperDash.Core.DebugThings
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="contextKey"></param>
|
/// <param name="contextKey"></param>
|
||||||
/// <param name="level"></param>
|
/// <param name="level"></param>
|
||||||
/// <returns>True if level is between 0 & 2 and the conte </returns>
|
|
||||||
public void SetLevel(string contextKey, int level)
|
public void SetLevel(string contextKey, int level)
|
||||||
{
|
{
|
||||||
if (level < 0 || level > 2)
|
if (level < 0 || level > 2)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ using Crestron.SimplSharp;
|
|||||||
|
|
||||||
namespace PepperDash.Core.PasswordManagement
|
namespace PepperDash.Core.PasswordManagement
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class to allow user interaction with the PasswordManager
|
||||||
|
/// </summary>
|
||||||
public class PasswordClient
|
public class PasswordClient
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ using PepperDash.Core.JsonStandardObjects;
|
|||||||
|
|
||||||
namespace PepperDash.Core.PasswordManagement
|
namespace PepperDash.Core.PasswordManagement
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Allows passwords to be stored and managed
|
||||||
|
/// </summary>
|
||||||
public class PasswordManager
|
public class PasswordManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,22 +11,61 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SystemInfoConstants
|
public class SystemInfoConstants
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort BoolValueChange = 1;
|
public const ushort BoolValueChange = 1;
|
||||||
public const ushort CompleteBoolChange = 2;
|
/// <summary>
|
||||||
public const ushort BusyBoolChange = 3;
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort CompleteBoolChange = 2;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort BusyBoolChange = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort UshortValueChange = 101;
|
public const ushort UshortValueChange = 101;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort StringValueChange = 201;
|
public const ushort StringValueChange = 201;
|
||||||
public const ushort ConsoleResponseChange = 202;
|
/// <summary>
|
||||||
public const ushort ProcessorUptimeChange = 203;
|
///
|
||||||
public const ushort ProgramUptimeChange = 204;
|
/// </summary>
|
||||||
|
public const ushort ConsoleResponseChange = 202;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort ProcessorUptimeChange = 203;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort ProgramUptimeChange = 204;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public const ushort ObjectChange = 301;
|
public const ushort ObjectChange = 301;
|
||||||
public const ushort ProcessorConfigChange = 302;
|
/// <summary>
|
||||||
public const ushort EthernetConfigChange = 303;
|
///
|
||||||
public const ushort ControlSubnetConfigChange = 304;
|
/// </summary>
|
||||||
public const ushort ProgramConfigChange = 305;
|
public const ushort ProcessorConfigChange = 302;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort EthernetConfigChange = 303;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort ControlSubnetConfigChange = 304;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public const ushort ProgramConfigChange = 305;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -34,9 +73,18 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessorChangeEventArgs : EventArgs
|
public class ProcessorChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ProcessorInfo Processor { get; set; }
|
public ProcessorInfo Processor { get; set; }
|
||||||
public ushort Type { get; set; }
|
/// <summary>
|
||||||
public ushort Index { get; set; }
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
@@ -71,9 +119,18 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EthernetChangeEventArgs : EventArgs
|
public class EthernetChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public EthernetInfo Adapter { get; set; }
|
public EthernetInfo Adapter { get; set; }
|
||||||
public ushort Type { get; set; }
|
/// <summary>
|
||||||
public ushort Index { get; set; }
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
@@ -112,9 +169,18 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlSubnetChangeEventArgs : EventArgs
|
public class ControlSubnetChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ControlSubnetInfo Adapter { get; set; }
|
public ControlSubnetInfo Adapter { get; set; }
|
||||||
public ushort Type { get; set; }
|
/// <summary>
|
||||||
public ushort Index { get; set; }
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
@@ -149,9 +215,18 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProgramChangeEventArgs : EventArgs
|
public class ProgramChangeEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ProgramInfo Program { get; set; }
|
public ProgramInfo Program { get; set; }
|
||||||
public ushort Type { get; set; }
|
/// <summary>
|
||||||
public ushort Index { get; set; }
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public ushort Index { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
|||||||
@@ -11,15 +11,45 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProcessorInfo
|
public class ProcessorInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Model { get; set; }
|
public string Model { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string SerialNumber { get; set; }
|
public string SerialNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Firmware { get; set; }
|
public string Firmware { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string FirmwareDate { get; set; }
|
public string FirmwareDate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string OsVersion { get; set; }
|
public string OsVersion { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string RuntimeEnvironment { get; set; }
|
public string RuntimeEnvironment { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string DevicePlatform { get; set; }
|
public string DevicePlatform { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string ModuleDirectory { get; set; }
|
public string ModuleDirectory { get; set; }
|
||||||
public string LocalTimeZone { get; set; }
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string LocalTimeZone { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string ProgramIdTag { get; set; }
|
public string ProgramIdTag { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,15 +66,45 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EthernetInfo
|
public class EthernetInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort DhcpIsOn { get; set; }
|
public ushort DhcpIsOn { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Hostname { get; set; }
|
public string Hostname { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string MacAddress { get; set; }
|
public string MacAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string IpAddress { get; set; }
|
public string IpAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Subnet { get; set; }
|
public string Subnet { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Gateway { get; set; }
|
public string Gateway { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Dns1 { get; set; }
|
public string Dns1 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Dns2 { get; set; }
|
public string Dns2 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Dns3 { get; set; }
|
public string Dns3 { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Domain { get; set; }
|
public string Domain { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -61,11 +121,29 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControlSubnetInfo
|
public class ControlSubnetInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort Enabled { get; set; }
|
public ushort Enabled { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort IsInAutomaticMode { get; set; }
|
public ushort IsInAutomaticMode { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string MacAddress { get; set; }
|
public string MacAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string IpAddress { get; set; }
|
public string IpAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Subnet { get; set; }
|
public string Subnet { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string RouterPrefix { get; set; }
|
public string RouterPrefix { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,13 +160,37 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProgramInfo
|
public class ProgramInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Header { get; set; }
|
public string Header { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string System { get; set; }
|
public string System { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string ProgramIdTag { get; set; }
|
public string ProgramIdTag { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string CompileTime { get; set; }
|
public string CompileTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Database { get; set; }
|
public string Database { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Environment { get; set; }
|
public string Environment { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Programmer { get; set; }
|
public string Programmer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,12 +11,30 @@ namespace PepperDash.Core.SystemInfo
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SystemInfoToSimpl
|
public class SystemInfoToSimpl
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of bool change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of string change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<StringChangeEventArgs> StringChange;
|
public event EventHandler<StringChangeEventArgs> StringChange;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of processor change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<ProcessorChangeEventArgs> ProcessorChange;
|
public event EventHandler<ProcessorChangeEventArgs> ProcessorChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of ethernet change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<EthernetChangeEventArgs> EthernetChange;
|
public event EventHandler<EthernetChangeEventArgs> EthernetChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of control subnet change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<ControlSubnetChangeEventArgs> ControlSubnetChange;
|
public event EventHandler<ControlSubnetChangeEventArgs> ControlSubnetChange;
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies of program change
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<ProgramChangeEventArgs> ProgramChange;
|
public event EventHandler<ProgramChangeEventArgs> ProgramChange;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,20 +9,44 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace PepperDash.Core.WebApi.Presets
|
namespace PepperDash.Core.WebApi.Presets
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a preset
|
||||||
|
/// </summary>
|
||||||
public class Preset
|
public class Preset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ID of preset
|
||||||
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User ID
|
||||||
|
/// </summary>
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Room Type ID
|
||||||
|
/// </summary>
|
||||||
public int RoomTypeId { get; set; }
|
public int RoomTypeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Preset Name
|
||||||
|
/// </summary>
|
||||||
public string PresetName { get; set; }
|
public string PresetName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Preset Number
|
||||||
|
/// </summary>
|
||||||
public int PresetNumber { get; set; }
|
public int PresetNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Preset Data
|
||||||
|
/// </summary>
|
||||||
public string Data { get; set; }
|
public string Data { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public Preset()
|
public Preset()
|
||||||
{
|
{
|
||||||
PresetName = "";
|
PresetName = "";
|
||||||
@@ -53,6 +77,11 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PresetReceivedEventArgs() { }
|
public PresetReceivedEventArgs() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="preset"></param>
|
||||||
|
/// <param name="success"></param>
|
||||||
public PresetReceivedEventArgs(Preset preset, bool success)
|
public PresetReceivedEventArgs(Preset preset, bool success)
|
||||||
{
|
{
|
||||||
LookupSuccess = success;
|
LookupSuccess = success;
|
||||||
|
|||||||
@@ -11,12 +11,24 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string ExternalId { get; set; }
|
public string ExternalId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +48,9 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort ULookupSuccess { get { return (ushort)(LookupSuccess ? 1 : 0); } }
|
public ushort ULookupSuccess { get { return (ushort)(LookupSuccess ? 1 : 0); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public User User { get; private set; }
|
public User User { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -43,6 +58,11 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UserReceivedEventArgs() { }
|
public UserReceivedEventArgs() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="success"></param>
|
||||||
public UserReceivedEventArgs(User user, bool success)
|
public UserReceivedEventArgs(User user, bool success)
|
||||||
{
|
{
|
||||||
LookupSuccess = success;
|
LookupSuccess = success;
|
||||||
@@ -55,10 +75,19 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserAndRoomMessage
|
public class UserAndRoomMessage
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int RoomTypeId { get; set; }
|
public int RoomTypeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public int PresetNumber { get; set; }
|
public int PresetNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,24 @@ using PepperDash.Core.JsonToSimpl;
|
|||||||
|
|
||||||
namespace PepperDash.Core.WebApi.Presets
|
namespace PepperDash.Core.WebApi.Presets
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Passcode client for the WebApi
|
||||||
|
/// </summary>
|
||||||
public class WebApiPasscodeClient : IKeyed
|
public class WebApiPasscodeClient : IKeyed
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies when user received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<UserReceivedEventArgs> UserReceived;
|
public event EventHandler<UserReceivedEventArgs> UserReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies when Preset received
|
||||||
|
/// </summary>
|
||||||
public event EventHandler<PresetReceivedEventArgs> PresetReceived;
|
public event EventHandler<PresetReceivedEventArgs> PresetReceived;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unique identifier for this instance
|
||||||
|
/// </summary>
|
||||||
public string Key { get; private set; }
|
public string Key { get; private set; }
|
||||||
|
|
||||||
//string JsonMasterKey;
|
//string JsonMasterKey;
|
||||||
@@ -46,6 +58,13 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the instance
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="jsonMasterKey"></param>
|
||||||
|
/// <param name="urlBase"></param>
|
||||||
|
/// <param name="defaultPresetJsonFilePath"></param>
|
||||||
public void Initialize(string key, string jsonMasterKey, string urlBase, string defaultPresetJsonFilePath)
|
public void Initialize(string key, string jsonMasterKey, string urlBase, string defaultPresetJsonFilePath)
|
||||||
{
|
{
|
||||||
Key = key;
|
Key = key;
|
||||||
@@ -58,6 +77,10 @@ namespace PepperDash.Core.WebApi.Presets
|
|||||||
J2SMaster.Initialize(jsonMasterKey);
|
J2SMaster.Initialize(jsonMasterKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the user for a passcode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="passcode"></param>
|
||||||
public void GetUserForPasscode(string passcode)
|
public void GetUserForPasscode(string passcode)
|
||||||
{
|
{
|
||||||
// Bullshit duplicate code here... These two cases should be the same
|
// Bullshit duplicate code here... These two cases should be the same
|
||||||
|
|||||||
@@ -8,7 +8,18 @@ namespace PepperDash.Core.Intersystem.Serialization
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IXSigSerialization
|
public interface IXSigSerialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Serialize the sig data
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
IEnumerable<XSigToken> Serialize();
|
IEnumerable<XSigToken> Serialize();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deserialize the sig data
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="tokens"></param>
|
||||||
|
/// <returns></returns>
|
||||||
T Deserialize<T>(IEnumerable<XSigToken> tokens) where T : class, IXSigSerialization;
|
T Deserialize<T>(IEnumerable<XSigToken> tokens) where T : class, IXSigSerialization;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,27 @@ using System;
|
|||||||
|
|
||||||
namespace PepperDash.Core.Intersystem.Serialization
|
namespace PepperDash.Core.Intersystem.Serialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to handle this specific exception type
|
||||||
|
/// </summary>
|
||||||
public class XSigSerializationException : Exception
|
public class XSigSerializationException : Exception
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// default constructor
|
||||||
|
/// </summary>
|
||||||
public XSigSerializationException() { }
|
public XSigSerializationException() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// constructor with message
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
public XSigSerializationException(string message) : base(message) { }
|
public XSigSerializationException(string message) : base(message) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// constructor with message and innner exception
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="inner"></param>
|
||||||
public XSigSerializationException(string message, Exception inner) : base(message, inner) { }
|
public XSigSerializationException(string message, Exception inner) : base(message, inner) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,18 @@ using System;
|
|||||||
|
|
||||||
namespace PepperDash.Core.Intersystem.Tokens
|
namespace PepperDash.Core.Intersystem.Tokens
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an XSigAnalogToken
|
||||||
|
/// </summary>
|
||||||
public sealed class XSigAnalogToken : XSigToken, IFormattable
|
public sealed class XSigAnalogToken : XSigToken, IFormattable
|
||||||
{
|
{
|
||||||
private readonly ushort _value;
|
private readonly ushort _value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
public XSigAnalogToken(int index, ushort value)
|
public XSigAnalogToken(int index, ushort value)
|
||||||
: base(index)
|
: base(index)
|
||||||
{
|
{
|
||||||
@@ -16,16 +24,26 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public ushort Value
|
public ushort Value
|
||||||
{
|
{
|
||||||
get { return _value; }
|
get { return _value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public override XSigTokenType TokenType
|
public override XSigTokenType TokenType
|
||||||
{
|
{
|
||||||
get { return XSigTokenType.Analog; }
|
get { return XSigTokenType.Analog; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override byte[] GetBytes()
|
public override byte[] GetBytes()
|
||||||
{
|
{
|
||||||
return new[] {
|
return new[] {
|
||||||
@@ -36,17 +54,32 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public override XSigToken GetTokenWithOffset(int offset)
|
public override XSigToken GetTokenWithOffset(int offset)
|
||||||
{
|
{
|
||||||
if (offset == 0) return this;
|
if (offset == 0) return this;
|
||||||
return new XSigAnalogToken(Index + offset, Value);
|
return new XSigAnalogToken(Index + offset, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Index + " = 0x" + Value.ToString("X4");
|
return Index + " = 0x" + Value.ToString("X4");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format"></param>
|
||||||
|
/// <param name="formatProvider"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public string ToString(string format, IFormatProvider formatProvider)
|
public string ToString(string format, IFormatProvider formatProvider)
|
||||||
{
|
{
|
||||||
return Value.ToString(format, formatProvider);
|
return Value.ToString(format, formatProvider);
|
||||||
|
|||||||
@@ -2,10 +2,18 @@ using System;
|
|||||||
|
|
||||||
namespace PepperDash.Core.Intersystem.Tokens
|
namespace PepperDash.Core.Intersystem.Tokens
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an XSigDigitalToken
|
||||||
|
/// </summary>
|
||||||
public sealed class XSigDigitalToken : XSigToken
|
public sealed class XSigDigitalToken : XSigToken
|
||||||
{
|
{
|
||||||
private readonly bool _value;
|
private readonly bool _value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
public XSigDigitalToken(int index, bool value)
|
public XSigDigitalToken(int index, bool value)
|
||||||
: base(index)
|
: base(index)
|
||||||
{
|
{
|
||||||
@@ -16,16 +24,26 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public bool Value
|
public bool Value
|
||||||
{
|
{
|
||||||
get { return _value; }
|
get { return _value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public override XSigTokenType TokenType
|
public override XSigTokenType TokenType
|
||||||
{
|
{
|
||||||
get { return XSigTokenType.Digital; }
|
get { return XSigTokenType.Digital; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override byte[] GetBytes()
|
public override byte[] GetBytes()
|
||||||
{
|
{
|
||||||
return new[] {
|
return new[] {
|
||||||
@@ -34,17 +52,31 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public override XSigToken GetTokenWithOffset(int offset)
|
public override XSigToken GetTokenWithOffset(int offset)
|
||||||
{
|
{
|
||||||
if (offset == 0) return this;
|
if (offset == 0) return this;
|
||||||
return new XSigDigitalToken(Index + offset, Value);
|
return new XSigDigitalToken(Index + offset, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Index + " = " + (Value ? "High" : "Low");
|
return Index + " = " + (Value ? "High" : "Low");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="formatProvider"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public string ToString(IFormatProvider formatProvider)
|
public string ToString(IFormatProvider formatProvider)
|
||||||
{
|
{
|
||||||
return Value.ToString(formatProvider);
|
return Value.ToString(formatProvider);
|
||||||
|
|||||||
@@ -3,10 +3,18 @@ using System.Text;
|
|||||||
|
|
||||||
namespace PepperDash.Core.Intersystem.Tokens
|
namespace PepperDash.Core.Intersystem.Tokens
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an XSigSerialToken
|
||||||
|
/// </summary>
|
||||||
public sealed class XSigSerialToken : XSigToken
|
public sealed class XSigSerialToken : XSigToken
|
||||||
{
|
{
|
||||||
private readonly string _value;
|
private readonly string _value;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
public XSigSerialToken(int index, string value)
|
public XSigSerialToken(int index, string value)
|
||||||
: base(index)
|
: base(index)
|
||||||
{
|
{
|
||||||
@@ -17,16 +25,26 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public string Value
|
public string Value
|
||||||
{
|
{
|
||||||
get { return _value; }
|
get { return _value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
public override XSigTokenType TokenType
|
public override XSigTokenType TokenType
|
||||||
{
|
{
|
||||||
get { return XSigTokenType.Serial; }
|
get { return XSigTokenType.Serial; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override byte[] GetBytes()
|
public override byte[] GetBytes()
|
||||||
{
|
{
|
||||||
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
|
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
|
||||||
@@ -40,12 +58,21 @@ namespace PepperDash.Core.Intersystem.Tokens
|
|||||||
return xsig;
|
return xsig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public override XSigToken GetTokenWithOffset(int offset)
|
public override XSigToken GetTokenWithOffset(int offset)
|
||||||
{
|
{
|
||||||
if (offset == 0) return this;
|
if (offset == 0) return this;
|
||||||
return new XSigSerialToken(Index + offset, Value);
|
return new XSigSerialToken(Index + offset, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Index + " = \"" + Value + "\"";
|
return Index + " = \"" + Value + "\"";
|
||||||
|
|||||||
Reference in New Issue
Block a user