mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
Continued working on XML comments
This commit is contained in:
@@ -13,7 +13,7 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Defines the string event handler for line events on the gather
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="text">A string</param>
|
||||
public delegate void LineReceivedHandler(string text);
|
||||
|
||||
/// <summary>
|
||||
@@ -44,17 +44,20 @@ namespace PepperDash.Core
|
||||
StringBuilder ReceiveBuffer = new StringBuilder();
|
||||
|
||||
/// <summary>
|
||||
/// Delimiter, like it says!
|
||||
/// Delimiter character
|
||||
/// </summary>
|
||||
char Delimiter;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delimiter string
|
||||
/// </summary>
|
||||
string StringDelimiter;
|
||||
|
||||
/// <summary>
|
||||
/// Fires up a gather, given a IBasicCommunicaion port and char for de
|
||||
/// Fires up a gather, given a IBasicCommunicaion port and char for delimiter
|
||||
/// </summary>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="delimiter"></param>
|
||||
/// <param name="port"><seealso cref="PepperDash.Core.ICommunicationReceiver"/>ICommunicationReceiver port</param>
|
||||
/// <param name="delimiter">Delimiter character</param>
|
||||
public CommunicationGather(ICommunicationReceiver port, char delimiter)
|
||||
{
|
||||
Port = port;
|
||||
@@ -63,10 +66,10 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Fires up a gather, given a IBasicCommunicaion port and string for delimiter
|
||||
/// </summary>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="delimiter"></param>
|
||||
/// <param name="port"><seealso cref="PepperDash.Core.ICommunicationReceiver"/>ICommunicationReceiver port</param>
|
||||
/// <param name="delimiter">Delimiter string</param>
|
||||
public CommunicationGather(ICommunicationReceiver port, string delimiter)
|
||||
{
|
||||
Port = port;
|
||||
@@ -119,10 +122,10 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Handler for delimited data coming from port
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <param name="sender">An object</param>
|
||||
/// <param name="args">A GenericCommMethodReceiveTextArgs</param>
|
||||
void Port_TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
|
||||
{
|
||||
var handler = LineReceived;
|
||||
|
||||
@@ -18,33 +18,80 @@ using Crestron.SimplSharp.CrestronSockets;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Socket Status Delegate
|
||||
/// </summary>
|
||||
/// <param name="client"><seealso cref="PepperDash.Core.ISocketStatus"/>A ISocketStatus client</param>
|
||||
public delegate void GenericSocketStatusChangeEventDelegate(ISocketStatus client);
|
||||
|
||||
/// <summary>
|
||||
/// Generic socket status change event args class
|
||||
/// </summary>
|
||||
public class GenericSocketStatusChageEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Client property implementing ISocketStatus
|
||||
/// </summary>
|
||||
/// <seealso cref="PepperDash.Core.ISocketStatus"/>
|
||||
/// <inheritdoc/>
|
||||
public ISocketStatus Client { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the GenericSocketStatusChangeEventArgs class
|
||||
/// </remarks>
|
||||
/// <param name="client">A client implementing ISocketStatus</param>
|
||||
public GenericSocketStatusChageEventArgs(ISocketStatus client)
|
||||
{
|
||||
Client = client;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stupid S+ Constructor
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// S+ requires an empty constructor, if not implemented the class will not be avialble in S+
|
||||
/// </remarks>
|
||||
public GenericSocketStatusChageEventArgs() { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generic TCP Server state change event delegate
|
||||
/// </summary>
|
||||
/// <param name="state"><seealso cref="Crestron.SimplSharp.CrestronSockets.ServerState"/>Server state enum</param>
|
||||
public delegate void GenericTcpServerStateChangedEventDelegate(ServerState state);
|
||||
|
||||
/// <summary>
|
||||
/// Generic TCP Server statte change event args class
|
||||
/// </summary>
|
||||
public class GenericTcpServerStateChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// State property
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Implements Crestron sockets server state
|
||||
/// </remarks>
|
||||
/// <seealso cref="Crestron.SimplSharp.CrestronSockets.ServerState"/>
|
||||
public ServerState State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="state">A server implementing ServerState</param>
|
||||
public GenericTcpServerStateChangedEventArgs(ServerState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stupid S+ Constructor
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// S+ requires an empty constructor, if not implemented the class will not be avialble in S+
|
||||
/// </remarks>
|
||||
public GenericTcpServerStateChangedEventArgs() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,50 @@ namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Crestron Control Methods for a comm object
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently Http, Https, Ws, and Wss will not create comm objects, however having them defined in the
|
||||
/// enum resolves the issue where they would cause an exception if passed into the comm factory.
|
||||
///
|
||||
/// When using the eControlMethods in a JSON configuration file use the following example:
|
||||
/// <code>
|
||||
/// "method": "[eControlMethod Enum]"
|
||||
/// </code>
|
||||
///
|
||||
/// Below is a full example of the device JSON configuration
|
||||
/// <code>
|
||||
/// {
|
||||
/// "key": "device-key",
|
||||
/// "name": "Device Name",
|
||||
/// "group": "comm",
|
||||
/// "type": "genericComm",
|
||||
/// "properties": {
|
||||
/// "control": {
|
||||
/// "method": "Com",
|
||||
/// "controlPortDevKey": "processor",
|
||||
/// "controlPortNumber": 1,
|
||||
/// "comParams": {
|
||||
/// "hardwareHandshake": "None",
|
||||
/// "parity": "None",
|
||||
/// "protocol": "RS232",
|
||||
/// "baudRate": 9600,
|
||||
/// "dataBits": 8,
|
||||
/// "softwareHandshake": "None",
|
||||
/// "stopBits": 1
|
||||
/// },
|
||||
/// "tcpSshProperties": {
|
||||
/// "address": "",
|
||||
/// "port": 1515,
|
||||
/// "username": "",
|
||||
/// "password": "",
|
||||
/// "autoReconnect": false,
|
||||
/// "autoReconnectIntervalMs": 30000
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
public enum eControlMethod
|
||||
{
|
||||
None = 0, Com, IpId, IpidTcp, IR, Ssh, Tcpip, Telnet, Cresnet, Cec, Udp, Http, Https, Ws, Wss
|
||||
|
||||
@@ -15,11 +15,25 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public interface ICommunicationReceiver : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler for bytes received
|
||||
/// </summary>
|
||||
event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||
/// <summary>
|
||||
/// Event hanlder for text recieved
|
||||
/// </summary>
|
||||
event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Is connected property.
|
||||
/// </summary>
|
||||
bool IsConnected { get; }
|
||||
/// <summary>
|
||||
/// Connect method
|
||||
/// </summary>
|
||||
void Connect();
|
||||
/// <summary>
|
||||
/// Disconnect method
|
||||
/// </summary>
|
||||
void Disconnect();
|
||||
}
|
||||
|
||||
@@ -66,6 +80,10 @@ namespace PepperDash.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a device that can automatically reconnect when a connection drops. Typically
|
||||
/// used with IP based communications.
|
||||
/// </summary>
|
||||
public interface IAutoReconnect
|
||||
{
|
||||
bool AutoReconnect { get; set; }
|
||||
@@ -73,7 +91,7 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Generic communication method status change type Enum
|
||||
/// </summary>
|
||||
public enum eGenericCommMethodStatusChangeType
|
||||
{
|
||||
@@ -84,15 +102,23 @@ namespace PepperDash.Core
|
||||
/// This delegate defines handler for IBasicCommunication status changes
|
||||
/// </summary>
|
||||
/// <param name="comm">Device firing the status change</param>
|
||||
/// <param name="status"></param>
|
||||
/// <param name="status">A eGenericCommMethodStatusChangeType enum</param>
|
||||
public delegate void GenericCommMethodStatusHandler(IBasicCommunication comm, eGenericCommMethodStatusChangeType status);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Generic communication method receive bytes args class
|
||||
/// </summary>
|
||||
public class GenericCommMethodReceiveBytesArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Bytes array property
|
||||
/// </summary>
|
||||
public byte[] Bytes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="bytes">An array of bytes</param>
|
||||
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
|
||||
{
|
||||
Bytes = bytes;
|
||||
@@ -105,11 +131,22 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Generic communication method receive text args class
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inherits from <seealso cref="System.EventArgs"/>
|
||||
/// </remarks>
|
||||
public class GenericCommMethodReceiveTextArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Text string property
|
||||
/// </summary>
|
||||
public string Text { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="text">A string</param>
|
||||
public GenericCommMethodReceiveTextArgs(string text)
|
||||
{
|
||||
Text = text;
|
||||
@@ -124,15 +161,24 @@ namespace PepperDash.Core
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Communication text helper class
|
||||
/// </summary>
|
||||
public class ComTextHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Method to convert escaped bytes to an array of escaped bytes
|
||||
/// </summary>
|
||||
/// <param name="bytes">An array of bytes</param>
|
||||
/// <returns>Array of escaped characters</returns>
|
||||
public static string GetEscapedText(byte[] bytes)
|
||||
{
|
||||
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to coonvert a string to an array of escaped bytes
|
||||
/// </summary>
|
||||
/// <param name="text">A string</param>
|
||||
/// <returns>Array of escaped characters</returns>
|
||||
public static string GetEscapedText(string text)
|
||||
{
|
||||
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique key interface to require a unique key for the class
|
||||
/// </summary>
|
||||
public interface IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Key
|
||||
/// </summary>
|
||||
string Key { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Named Keyed device interface. Forces the devie to have a Unique Key and a name.
|
||||
/// </summary>
|
||||
public interface IKeyName : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Isn't it obvious :)
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique key interface to require a unique key for the class
|
||||
/// </summary>
|
||||
public interface IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Key
|
||||
/// </summary>
|
||||
string Key { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Named Keyed device interface
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Forces the device to have a Unique Key and a name.
|
||||
/// </remarks>
|
||||
public interface IKeyName : IKeyed
|
||||
{
|
||||
/// <summary>
|
||||
/// Isn't it obvious :)
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,14 @@ namespace PepperDash.Core
|
||||
///// </summary>
|
||||
//public bool HasConfig { get { return Config != null; } }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
List<Action> _PreActivationActions;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
List<Action> _PostActivationActions;
|
||||
|
||||
public static Device DefaultDevice { get { return _DefaultDevice; } }
|
||||
@@ -51,6 +58,11 @@ namespace PepperDash.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="name"></param>
|
||||
public Device(string key, string name) : this(key)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
@@ -1,118 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
public class EthernetHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static EthernetHelper LanHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LanHelper == null) _LanHelper = new EthernetHelper(0);
|
||||
return _LanHelper;
|
||||
}
|
||||
}
|
||||
static EthernetHelper _LanHelper;
|
||||
|
||||
// ADD OTHER HELPERS HERE
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int PortNumber { get; private set; }
|
||||
|
||||
private EthernetHelper(int portNumber)
|
||||
{
|
||||
PortNumber = portNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("linkActive")]
|
||||
public bool LinkActive
|
||||
{
|
||||
get
|
||||
{
|
||||
var status = CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_LINK_STATUS, 0);
|
||||
Debug.Console(0, "LinkActive = {0}", status);
|
||||
return status == "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("dchpActive")]
|
||||
public bool DhcpActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, 0) == "ON";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("hostname")]
|
||||
public string Hostname
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("ipAddress")]
|
||||
public string IPAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("subnetMask")]
|
||||
public string SubnetMask
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("defaultGateway")]
|
||||
public string DefaultGateway
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
public class EthernetHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Lan Helper property
|
||||
/// </summary>
|
||||
public static EthernetHelper LanHelper
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_LanHelper == null) _LanHelper = new EthernetHelper(0);
|
||||
return _LanHelper;
|
||||
}
|
||||
}
|
||||
static EthernetHelper _LanHelper;
|
||||
|
||||
// ADD OTHER HELPERS HERE
|
||||
|
||||
/// <summary>
|
||||
/// Port Number property
|
||||
/// </summary>
|
||||
public int PortNumber { get; private set; }
|
||||
|
||||
private EthernetHelper(int portNumber)
|
||||
{
|
||||
PortNumber = portNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Link Active property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current link status
|
||||
/// </returns>
|
||||
[JsonProperty("linkActive")]
|
||||
public bool LinkActive
|
||||
{
|
||||
get
|
||||
{
|
||||
var status = CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_LINK_STATUS, 0);
|
||||
Debug.Console(0, "LinkActive = {0}", status);
|
||||
return status == "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DHCP Active property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current DHCP state
|
||||
/// </returns>
|
||||
[JsonProperty("dchpActive")]
|
||||
public bool DhcpActive
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, 0) == "ON";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hostname property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current hostname
|
||||
/// </returns>
|
||||
[JsonProperty("hostname")]
|
||||
public string Hostname
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IP Address property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current IP address
|
||||
/// </returns>
|
||||
[JsonProperty("ipAddress")]
|
||||
public string IPAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subnet Mask property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current subnet mask
|
||||
/// </returns>
|
||||
[JsonProperty("subnetMask")]
|
||||
public string SubnetMask
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default Gateway property
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Current router
|
||||
/// </returns>
|
||||
[JsonProperty("defaultGateway")]
|
||||
public string DefaultGateway
|
||||
{
|
||||
get
|
||||
{
|
||||
return CrestronEthernetHelper.GetEthernetParameter(
|
||||
CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,23 +7,72 @@ using Crestron.SimplSharp;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Bool change event args
|
||||
/// Main <c>BoolChangeEventArgs</c> class
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Bool change event args are accessible by all classes and are used to pass boolean values from S# to S+. Constants can be created
|
||||
/// in the classes using the event args. Constants, when used, associate returned values with specific S+ properties.
|
||||
/// <example>
|
||||
/// Implement the following when
|
||||
/// <code>
|
||||
/// public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||
/// </code>
|
||||
/// <code>
|
||||
/// protected void OnBoolChange(bool state, ushort index, ushort type)
|
||||
/// {
|
||||
/// var handler = BoolChange;
|
||||
/// if (handler == null) return;
|
||||
/// var args = new BoolChangeEventArgs(state, type) {Index = index};
|
||||
/// BoolChange(this, args);
|
||||
/// }
|
||||
/// </code>
|
||||
/// When referencing events in S+ you must create a event handler callback method and register the event.
|
||||
/// <code>
|
||||
/// EventHandler BoolChanged(SampleSimplSharpClass sender, BoolChangeEventArgs args)
|
||||
/// {
|
||||
/// If(DebugEnable) Trace("BoolChanged: args[%u].Type[%u] = %u\r", args.Index, args.Type, args.IntValue);
|
||||
///
|
||||
/// Switch(args.Type)
|
||||
/// {
|
||||
/// Case(SampleSimplSharpClass.BoolValueChange):
|
||||
/// {
|
||||
/// // specific bool value changed
|
||||
/// }
|
||||
/// Default:
|
||||
/// {
|
||||
/// // generic bool value changed
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// Register the event
|
||||
/// <code>
|
||||
/// Function Main()
|
||||
/// {
|
||||
/// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
|
||||
/// RegisterEveent(mySplusClass, BoolChange, BoolChanged);
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// </remarks>
|
||||
public class BoolChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Boolean state property
|
||||
/// State property
|
||||
/// </summary>
|
||||
/// <value>Boolean</value>
|
||||
public bool State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean ushort value property
|
||||
/// Integer value property
|
||||
/// </summary>
|
||||
/// <value>Ushort</value>
|
||||
public ushort IntValue { get { return (ushort)(State ? 1 : 0); } }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean change event args type
|
||||
/// Type property
|
||||
/// </summary>
|
||||
/// <value>Ushort</value>
|
||||
public ushort Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -34,16 +83,22 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// S+ requires an empty contructor, otherwise the class will not be avialable in S+.
|
||||
/// </remarks>
|
||||
public BoolChangeEventArgs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <remarks>
|
||||
/// Accepts State as a boolean and Type as a ushort.
|
||||
/// </remarks>
|
||||
/// <param name="state">a boolean value</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
public BoolChangeEventArgs(bool state, ushort type)
|
||||
{
|
||||
State = state;
|
||||
@@ -51,11 +106,14 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <remarks>
|
||||
/// Accepts State as a boolean, type as a ushort and index as ushort.
|
||||
/// </remarks>
|
||||
/// <param name="state">a boolean value</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
/// <param name="index">a ushort number</param>
|
||||
public BoolChangeEventArgs(bool state, ushort type, ushort index)
|
||||
{
|
||||
State = state;
|
||||
@@ -65,8 +123,54 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ushort change event args
|
||||
/// Main <c>UshrtChangeEventArgs</c> class
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Ushort change event args are accessible by all classes and are used to pass ushort values from S# to S+. Constants can be created
|
||||
/// in the classes using the event args. Constants, when used, associate returned values with specific S+ properties.
|
||||
/// <example>
|
||||
/// When using UshrtChangeEventArgs in a class you will need to include a change handler method.
|
||||
/// <code>
|
||||
/// public event EventHandler<UshrtChangeEventArgs> UshortChange;
|
||||
/// </code>
|
||||
/// <code>
|
||||
/// protected void OnUshortChange(ushort value, ushort index, ushort type)
|
||||
/// {
|
||||
/// var handler = UshortChange;
|
||||
/// if (handler == null) return;
|
||||
/// var args = new UshrtChangeEventArgs(value, type) {Index = index};
|
||||
/// UshortChange(this, args);
|
||||
/// }
|
||||
/// </code>
|
||||
/// When referencing events in S+ you must create a event handler callback method and register the event.
|
||||
/// <code>
|
||||
/// EventHandler UshortChanged(SampleSimplSharpClass sender, UshrtChangeEventArgs args)
|
||||
/// {
|
||||
/// If(DebugEnable) Trace("UshortChanged: args[%u].Type[%u] = %u\r", args.Index, args.Type, args.IntValue);
|
||||
///
|
||||
/// Switch(args.Type)
|
||||
/// {
|
||||
/// Case(SampleSimplSharpClass.UshortValueChange):
|
||||
/// {
|
||||
/// // specific ushort value changed
|
||||
/// }
|
||||
/// Default:
|
||||
/// {
|
||||
/// // generic ushort value changed
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// Register the event
|
||||
/// <code>
|
||||
/// Function Main()
|
||||
/// {
|
||||
/// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
|
||||
/// RegisterEveent(mySplusClass, UshortChange, UshortChanged);
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// </remarks>
|
||||
public class UshrtChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
@@ -95,8 +199,8 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// </summary>
|
||||
/// <param name="intValue"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="intValue">a ushort number</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
public UshrtChangeEventArgs(ushort intValue, ushort type)
|
||||
{
|
||||
IntValue = intValue;
|
||||
@@ -106,9 +210,9 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// </summary>
|
||||
/// <param name="intValue"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="intValue">a ushort number</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
/// <param name="index">a ushort number</param>
|
||||
public UshrtChangeEventArgs(ushort intValue, ushort type, ushort index)
|
||||
{
|
||||
IntValue = intValue;
|
||||
@@ -118,8 +222,54 @@ namespace PepperDash.Core
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String change event args
|
||||
/// Main <c>StringChangeEventArgs</c> class
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// String change event args are accessible by all classes and are used to pass ushort values from S# to S+. Constants can be created
|
||||
/// in the classes using the event args. Constants, when used, associate returned values with specific S+ properties.
|
||||
/// <example>
|
||||
/// When using StringChangeEventArgs in a class you will need to include a change handler method.
|
||||
/// <code>
|
||||
/// public event EventHandler<StringChangeEventArgs> StringChange;
|
||||
/// </code>
|
||||
/// <code>
|
||||
/// protected void OnStringChange(string stringValue, ushort index, ushort type)
|
||||
/// {
|
||||
/// var handler = StringChange;
|
||||
/// if (handler == null) return;
|
||||
/// var args = new StringChangeEventArgs(stringValue, type) {Index = index};
|
||||
/// StringChange(this, args);
|
||||
/// }
|
||||
/// </code>
|
||||
/// When referencing events in S+ you must create a event handler callback method and register the event.
|
||||
/// <code>
|
||||
/// EventHandler StringChanged(SampleSimplSharpClass sender, StringChangeEventArgs args)
|
||||
/// {
|
||||
/// If(DebugEnable) Trace("StringChanged: args[%u].Type[%u] = %u\r", args.Index, args.Type, args.StringValue);
|
||||
///
|
||||
/// Switch(args.Type)
|
||||
/// {
|
||||
/// Case(SampleSimplSharpClass.StringValueChange):
|
||||
/// {
|
||||
/// // specific ushort value changed
|
||||
/// }
|
||||
/// Default:
|
||||
/// {
|
||||
/// // generic ushort value changed
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// Register the event
|
||||
/// <code>
|
||||
/// Function Main()
|
||||
/// {
|
||||
/// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
|
||||
/// RegisterEveent(mySplusClass, StringChange, StringChanged);
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
/// </remarks>
|
||||
public class StringChangeEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
@@ -148,8 +298,8 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// </summary>
|
||||
/// <param name="stringValue"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="stringValue">a string</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
public StringChangeEventArgs(string stringValue, ushort type)
|
||||
{
|
||||
StringValue = stringValue;
|
||||
@@ -159,9 +309,9 @@ namespace PepperDash.Core
|
||||
/// <summary>
|
||||
/// Constructor overload
|
||||
/// </summary>
|
||||
/// <param name="stringValue"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="stringValue">a string</param>
|
||||
/// <param name="type">a ushort number</param>
|
||||
/// <param name="index">a ushort number</param>
|
||||
public StringChangeEventArgs(string stringValue, ushort type, ushort index)
|
||||
{
|
||||
StringValue = stringValue;
|
||||
|
||||
@@ -208,12 +208,9 @@ namespace PepperDash.Core.GenericRESTfulCommunications
|
||||
protected void OnBoolChange(bool state, ushort index, ushort type)
|
||||
{
|
||||
var handler = BoolChange;
|
||||
if (handler != null)
|
||||
{
|
||||
var args = new BoolChangeEventArgs(state, type);
|
||||
args.Index = index;
|
||||
BoolChange(this, args);
|
||||
}
|
||||
if (handler == null) return;
|
||||
var args = new BoolChangeEventArgs(state, type) {Index = index};
|
||||
BoolChange(this, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -225,12 +222,9 @@ namespace PepperDash.Core.GenericRESTfulCommunications
|
||||
protected void OnUshrtChange(ushort value, ushort index, ushort type)
|
||||
{
|
||||
var handler = UshrtChange;
|
||||
if (handler != null)
|
||||
{
|
||||
var args = new UshrtChangeEventArgs(value, type);
|
||||
args.Index = index;
|
||||
UshrtChange(this, args);
|
||||
}
|
||||
if (handler == null) return;
|
||||
var args = new UshrtChangeEventArgs(value, type) {Index = index};
|
||||
UshrtChange(this, args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,8 +7,11 @@ using Crestron.SimplSharp;
|
||||
namespace PepperDash.Core.SystemInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Processor info class
|
||||
/// Processor Info
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Stores processor information
|
||||
/// </remarks>
|
||||
public class ProcessorInfo
|
||||
{
|
||||
public string Model { get; set; }
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Core.DebugThings;
|
||||
|
||||
namespace PepperDash.Core.SystemInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// System Info class
|
||||
/// System Info to Simpl
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Contains methods that can be called from S+ to get information about the system.
|
||||
/// </remarks>
|
||||
public class SystemInfoToSimpl
|
||||
{
|
||||
public event EventHandler<BoolChangeEventArgs> BoolChange;
|
||||
@@ -36,7 +41,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
|
||||
try
|
||||
{
|
||||
var processor = new ProcessorInfo();
|
||||
var processor = new ProcessorInfo();
|
||||
processor.Model = InitialParametersClass.ControllerPromptName;
|
||||
processor.SerialNumber = CrestronEnvironment.SystemInfo.SerialNumber;
|
||||
processor.ModuleDirectory = InitialParametersClass.ProgramDirectory.ToString();
|
||||
@@ -281,6 +286,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
catch (Exception e)
|
||||
{
|
||||
var msg = string.Format("RefreshProgramUptimebyIndex({0}) failed:\r{1}", index, e.Message);
|
||||
Debug.Console(0,"");
|
||||
CrestronConsole.PrintLine(msg);
|
||||
//ErrorLog.Error(msg);
|
||||
}
|
||||
@@ -295,25 +301,31 @@ namespace PepperDash.Core.SystemInfo
|
||||
if (string.IsNullOrEmpty(cmd))
|
||||
return;
|
||||
|
||||
string response = "";
|
||||
CrestronConsole.SendControlSystemCommand(cmd, ref response);
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
try
|
||||
{
|
||||
if (response.EndsWith("\x0D\\x0A"))
|
||||
response.Trim('\n');
|
||||
|
||||
OnStringChange(response, 0, SystemInfoConstants.ConsoleResponseChange);
|
||||
string response = "";
|
||||
CrestronConsole.SendControlSystemCommand(cmd, ref response);
|
||||
if (string.IsNullOrEmpty(response)) return;
|
||||
if (response.Contains('\n'))
|
||||
{
|
||||
var lines = response.Split('\n');
|
||||
if (lines == null) return;
|
||||
foreach (var line in lines.Where(line => !string.IsNullOrEmpty(line)))
|
||||
{
|
||||
OnStringChange(line, 0, SystemInfoConstants.ConsoleResponseChange);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnStringChange(response, 0, SystemInfoConstants.ConsoleResponseChange);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Console(0,"Console Command Exception: {0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// private method to parse console messages
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
/// <param name="line"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private string ParseConsoleResponse(string data, string line, string dataStart, string dataEnd)
|
||||
{
|
||||
var response = "";
|
||||
@@ -337,13 +349,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Protected boolean change event handler
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnBoolChange(bool state, ushort index, ushort type)
|
||||
{
|
||||
var handler = BoolChange;
|
||||
@@ -354,13 +360,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
BoolChange(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Protected string change event handler
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnStringChange(string value, ushort index, ushort type)
|
||||
{
|
||||
var handler = StringChange;
|
||||
@@ -371,13 +371,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
StringChange(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Protected processor config change event handler
|
||||
/// </summary>
|
||||
/// <param name="processor"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnProcessorChange(ProcessorInfo processor, ushort index, ushort type)
|
||||
{
|
||||
var handler = ProcessorChange;
|
||||
@@ -388,13 +382,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
ProcessorChange(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ethernet change event handler
|
||||
/// </summary>
|
||||
/// <param name="ethernet"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnEthernetInfoChange(EthernetInfo ethernet, ushort index, ushort type)
|
||||
{
|
||||
var handler = EthernetChange;
|
||||
@@ -405,13 +393,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
EthernetChange(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Control Subnet change event handler
|
||||
/// </summary>
|
||||
/// <param name="ethernet"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnControlSubnetInfoChange(ControlSubnetInfo ethernet, ushort index, ushort type)
|
||||
{
|
||||
var handler = ControlSubnetChange;
|
||||
@@ -422,13 +404,7 @@ namespace PepperDash.Core.SystemInfo
|
||||
ControlSubnetChange(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Program change event handler
|
||||
/// </summary>
|
||||
/// <param name="program"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="type"></param>
|
||||
|
||||
protected void OnProgramChange(ProgramInfo program, ushort index, ushort type)
|
||||
{
|
||||
var handler = ProgramChange;
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace PepperDash.Core.Intersystem.Tokens
|
||||
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
var serialBytes = Encoding.GetEncoding(28591).GetBytes(Value);
|
||||
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
|
||||
|
||||
var xsig = new byte[serialBytes.Length + 3];
|
||||
xsig[0] = (byte)(0xC8 | (Index >> 7));
|
||||
xsig[1] = (byte)((Index - 1) & 0x7F);
|
||||
|
||||
Reference in New Issue
Block a user