diff --git a/Pepperdash Core/Pepperdash Core/Comm/CommunicationGather.cs b/Pepperdash Core/Pepperdash Core/Comm/CommunicationGather.cs
index 3d03f2e..bf12d3c 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/CommunicationGather.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/CommunicationGather.cs
@@ -13,7 +13,7 @@ namespace PepperDash.Core
///
/// Defines the string event handler for line events on the gather
///
- ///
+ /// A string
public delegate void LineReceivedHandler(string text);
///
@@ -44,17 +44,20 @@ namespace PepperDash.Core
StringBuilder ReceiveBuffer = new StringBuilder();
///
- /// Delimiter, like it says!
+ /// Delimiter character
///
char Delimiter;
-
+
+ ///
+ /// Delimiter string
+ ///
string StringDelimiter;
///
- /// Fires up a gather, given a IBasicCommunicaion port and char for de
+ /// Fires up a gather, given a IBasicCommunicaion port and char for delimiter
///
- ///
- ///
+ /// ICommunicationReceiver port
+ /// Delimiter character
public CommunicationGather(ICommunicationReceiver port, char delimiter)
{
Port = port;
@@ -63,10 +66,10 @@ namespace PepperDash.Core
}
///
- ///
+ /// Fires up a gather, given a IBasicCommunicaion port and string for delimiter
///
- ///
- ///
+ /// ICommunicationReceiver port
+ /// Delimiter string
public CommunicationGather(ICommunicationReceiver port, string delimiter)
{
Port = port;
@@ -119,10 +122,10 @@ namespace PepperDash.Core
}
///
- ///
+ /// Handler for delimited data coming from port
///
- ///
- ///
+ /// An object
+ /// A GenericCommMethodReceiveTextArgs
void Port_TextReceivedStringDelimiter(object sender, GenericCommMethodReceiveTextArgs args)
{
var handler = LineReceived;
diff --git a/Pepperdash Core/Pepperdash Core/Comm/EventArgs.cs b/Pepperdash Core/Pepperdash Core/Comm/EventArgs.cs
index ecf6db8..eb01d46 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/EventArgs.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/EventArgs.cs
@@ -18,33 +18,80 @@ using Crestron.SimplSharp.CrestronSockets;
namespace PepperDash.Core
{
+ ///
+ /// Socket Status Delegate
+ ///
+ /// A ISocketStatus client
public delegate void GenericSocketStatusChangeEventDelegate(ISocketStatus client);
+
+ ///
+ /// Generic socket status change event args class
+ ///
public class GenericSocketStatusChageEventArgs : EventArgs
{
+ ///
+ /// Client property implementing ISocketStatus
+ ///
+ ///
+ ///
public ISocketStatus Client { get; private set; }
+ ///
+ /// Constructor
+ ///
+ ///
+ /// Initializes a new instance of the GenericSocketStatusChangeEventArgs class
+ ///
+ /// A client implementing ISocketStatus
public GenericSocketStatusChageEventArgs(ISocketStatus client)
{
Client = client;
}
+
///
- /// Stupid S+ Constructor
+ /// Constructor
///
+ ///
+ /// S+ requires an empty constructor, if not implemented the class will not be avialble in S+
+ ///
public GenericSocketStatusChageEventArgs() { }
}
+ ///
+ /// Generic TCP Server state change event delegate
+ ///
+ /// Server state enum
public delegate void GenericTcpServerStateChangedEventDelegate(ServerState state);
+
+ ///
+ /// Generic TCP Server statte change event args class
+ ///
public class GenericTcpServerStateChangedEventArgs : EventArgs
{
+ ///
+ /// State property
+ ///
+ ///
+ /// Implements Crestron sockets server state
+ ///
+ ///
public ServerState State { get; private set; }
+ ///
+ /// Constructor
+ ///
+ /// A server implementing ServerState
public GenericTcpServerStateChangedEventArgs(ServerState state)
{
State = state;
}
+
///
- /// Stupid S+ Constructor
+ /// Constructor
///
+ ///
+ /// S+ requires an empty constructor, if not implemented the class will not be avialble in S+
+ ///
public GenericTcpServerStateChangedEventArgs() { }
}
diff --git a/Pepperdash Core/Pepperdash Core/Comm/eControlMethods.cs b/Pepperdash Core/Pepperdash Core/Comm/eControlMethods.cs
index 4e5d2eb..4e90700 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/eControlMethods.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/eControlMethods.cs
@@ -8,7 +8,50 @@ namespace PepperDash.Core
{
///
/// Crestron Control Methods for a comm object
- ///
+ ///
+ ///
+ /// 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:
+ ///
+ /// "method": "[eControlMethod Enum]"
+ ///
+ ///
+ /// Below is a full example of the device JSON configuration
+ ///
+ /// {
+ /// "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
+ /// }
+ /// }
+ /// }
+ /// }
+ ///
+ ///
public enum eControlMethod
{
None = 0, Com, IpId, IpidTcp, IR, Ssh, Tcpip, Telnet, Cresnet, Cec, Udp, Http, Https, Ws, Wss
diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
index c5892a4..199422c 100644
--- a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
+++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs
@@ -15,11 +15,25 @@ namespace PepperDash.Core
///
public interface ICommunicationReceiver : IKeyed
{
+ ///
+ /// Event handler for bytes received
+ ///
event EventHandler BytesReceived;
+ ///
+ /// Event hanlder for text recieved
+ ///
event EventHandler TextReceived;
-
+ ///
+ /// Is connected property.
+ ///
bool IsConnected { get; }
+ ///
+ /// Connect method
+ ///
void Connect();
+ ///
+ /// Disconnect method
+ ///
void Disconnect();
}
@@ -66,6 +80,10 @@ namespace PepperDash.Core
}
+ ///
+ /// Represents a device that can automatically reconnect when a connection drops. Typically
+ /// used with IP based communications.
+ ///
public interface IAutoReconnect
{
bool AutoReconnect { get; set; }
@@ -73,7 +91,7 @@ namespace PepperDash.Core
}
///
- ///
+ /// Generic communication method status change type Enum
///
public enum eGenericCommMethodStatusChangeType
{
@@ -84,15 +102,23 @@ namespace PepperDash.Core
/// This delegate defines handler for IBasicCommunication status changes
///
/// Device firing the status change
- ///
+ /// A eGenericCommMethodStatusChangeType enum
public delegate void GenericCommMethodStatusHandler(IBasicCommunication comm, eGenericCommMethodStatusChangeType status);
///
- ///
+ /// Generic communication method receive bytes args class
///
public class GenericCommMethodReceiveBytesArgs : EventArgs
{
+ ///
+ /// Bytes array property
+ ///
public byte[] Bytes { get; private set; }
+
+ ///
+ /// Constructor
+ ///
+ /// An array of bytes
public GenericCommMethodReceiveBytesArgs(byte[] bytes)
{
Bytes = bytes;
@@ -105,11 +131,22 @@ namespace PepperDash.Core
}
///
- ///
+ /// Generic communication method receive text args class
///
+ ///
+ /// Inherits from
+ ///
public class GenericCommMethodReceiveTextArgs : EventArgs
{
+ ///
+ /// Text string property
+ ///
public string Text { get; private set; }
+
+ ///
+ /// Constructor
+ ///
+ /// A string
public GenericCommMethodReceiveTextArgs(string text)
{
Text = text;
@@ -124,15 +161,24 @@ namespace PepperDash.Core
///
- ///
+ /// Communication text helper class
///
public class ComTextHelper
{
+ ///
+ /// Method to convert escaped bytes to an array of escaped bytes
+ ///
+ /// An array of bytes
+ /// Array of escaped characters
public static string GetEscapedText(byte[] bytes)
{
return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray());
}
-
+ ///
+ /// Method to coonvert a string to an array of escaped bytes
+ ///
+ /// A string
+ /// Array of escaped characters
public static string GetEscapedText(string text)
{
var bytes = Encoding.GetEncoding(28591).GetBytes(text);
diff --git a/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
index 3a5df42..0a21f3b 100644
--- a/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
+++ b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs
@@ -1,30 +1,33 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Crestron.SimplSharp;
-
-namespace PepperDash.Core
-{
- ///
- /// Unique key interface to require a unique key for the class
- ///
- public interface IKeyed
- {
- ///
- /// Unique Key
- ///
- string Key { get; }
- }
-
- ///
- /// Named Keyed device interface. Forces the devie to have a Unique Key and a name.
- ///
- public interface IKeyName : IKeyed
- {
- ///
- /// Isn't it obvious :)
- ///
- string Name { get; }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+namespace PepperDash.Core
+{
+ ///
+ /// Unique key interface to require a unique key for the class
+ ///
+ public interface IKeyed
+ {
+ ///
+ /// Unique Key
+ ///
+ string Key { get; }
+ }
+
+ ///
+ /// Named Keyed device interface
+ ///
+ ///
+ /// Forces the device to have a Unique Key and a name.
+ ///
+ public interface IKeyName : IKeyed
+ {
+ ///
+ /// Isn't it obvious :)
+ ///
+ string Name { get; }
+ }
}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/Device.cs b/Pepperdash Core/Pepperdash Core/Device.cs
index 62dc6b1..affb7aa 100644
--- a/Pepperdash Core/Pepperdash Core/Device.cs
+++ b/Pepperdash Core/Pepperdash Core/Device.cs
@@ -33,7 +33,14 @@ namespace PepperDash.Core
/////
//public bool HasConfig { get { return Config != null; } }
+ ///
+ ///
+ ///
List _PreActivationActions;
+
+ ///
+ ///
+ ///
List _PostActivationActions;
public static Device DefaultDevice { get { return _DefaultDevice; } }
@@ -51,6 +58,11 @@ namespace PepperDash.Core
}
+ ///
+ /// Constructor overload
+ ///
+ ///
+ ///
public Device(string key, string name) : this(key)
{
Name = name;
diff --git a/Pepperdash Core/Pepperdash Core/EthernetHelper.cs b/Pepperdash Core/Pepperdash Core/EthernetHelper.cs
index be0d5fa..c7c1757 100644
--- a/Pepperdash Core/Pepperdash Core/EthernetHelper.cs
+++ b/Pepperdash Core/Pepperdash Core/EthernetHelper.cs
@@ -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
- {
- ///
- ///
- ///
- public static EthernetHelper LanHelper
- {
- get
- {
- if (_LanHelper == null) _LanHelper = new EthernetHelper(0);
- return _LanHelper;
- }
- }
- static EthernetHelper _LanHelper;
-
- // ADD OTHER HELPERS HERE
-
- ///
- ///
- ///
- public int PortNumber { get; private set; }
-
- private EthernetHelper(int portNumber)
- {
- PortNumber = portNumber;
- }
-
- ///
- ///
- ///
- [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 == "";
- }
- }
-
- ///
- ///
- ///
- [JsonProperty("dchpActive")]
- public bool DhcpActive
- {
- get
- {
- return CrestronEthernetHelper.GetEthernetParameter(
- CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, 0) == "ON";
- }
- }
-
- ///
- ///
- ///
- [JsonProperty("hostname")]
- public string Hostname
- {
- get
- {
- return CrestronEthernetHelper.GetEthernetParameter(
- CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
- }
- }
-
- ///
- ///
- ///
- [JsonProperty("ipAddress")]
- public string IPAddress
- {
- get
- {
- return CrestronEthernetHelper.GetEthernetParameter(
- CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
- }
- }
-
- ///
- ///
- ///
- [JsonProperty("subnetMask")]
- public string SubnetMask
- {
- get
- {
- return CrestronEthernetHelper.GetEthernetParameter(
- CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0);
- }
- }
-
- ///
- ///
- ///
- [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
+ {
+ ///
+ /// Lan Helper property
+ ///
+ public static EthernetHelper LanHelper
+ {
+ get
+ {
+ if (_LanHelper == null) _LanHelper = new EthernetHelper(0);
+ return _LanHelper;
+ }
+ }
+ static EthernetHelper _LanHelper;
+
+ // ADD OTHER HELPERS HERE
+
+ ///
+ /// Port Number property
+ ///
+ public int PortNumber { get; private set; }
+
+ private EthernetHelper(int portNumber)
+ {
+ PortNumber = portNumber;
+ }
+
+ ///
+ /// Link Active property
+ ///
+ ///
+ /// Current link status
+ ///
+ [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 == "";
+ }
+ }
+
+ ///
+ /// DHCP Active property
+ ///
+ ///
+ /// Current DHCP state
+ ///
+ [JsonProperty("dchpActive")]
+ public bool DhcpActive
+ {
+ get
+ {
+ return CrestronEthernetHelper.GetEthernetParameter(
+ CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_DHCP_STATE, 0) == "ON";
+ }
+ }
+
+ ///
+ /// Hostname property
+ ///
+ ///
+ /// Current hostname
+ ///
+ [JsonProperty("hostname")]
+ public string Hostname
+ {
+ get
+ {
+ return CrestronEthernetHelper.GetEthernetParameter(
+ CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0);
+ }
+ }
+
+ ///
+ /// IP Address property
+ ///
+ ///
+ /// Current IP address
+ ///
+ [JsonProperty("ipAddress")]
+ public string IPAddress
+ {
+ get
+ {
+ return CrestronEthernetHelper.GetEthernetParameter(
+ CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0);
+ }
+ }
+
+ ///
+ /// Subnet Mask property
+ ///
+ ///
+ /// Current subnet mask
+ ///
+ [JsonProperty("subnetMask")]
+ public string SubnetMask
+ {
+ get
+ {
+ return CrestronEthernetHelper.GetEthernetParameter(
+ CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0);
+ }
+ }
+
+ ///
+ /// Default Gateway property
+ ///
+ ///
+ /// Current router
+ ///
+ [JsonProperty("defaultGateway")]
+ public string DefaultGateway
+ {
+ get
+ {
+ return CrestronEthernetHelper.GetEthernetParameter(
+ CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/EventArgs.cs b/Pepperdash Core/Pepperdash Core/EventArgs.cs
index 6def673..c56299f 100644
--- a/Pepperdash Core/Pepperdash Core/EventArgs.cs
+++ b/Pepperdash Core/Pepperdash Core/EventArgs.cs
@@ -7,23 +7,72 @@ using Crestron.SimplSharp;
namespace PepperDash.Core
{
///
- /// Bool change event args
+ /// Main BoolChangeEventArgs class
///
+ ///
+ /// 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.
+ ///
+ /// Implement the following when
+ ///
+ /// public event EventHandler BoolChange;
+ ///
+ ///
+ /// 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);
+ /// }
+ ///
+ /// When referencing events in S+ you must create a event handler callback method and register the event.
+ ///
+ /// 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
+ /// }
+ /// }
+ /// }
+ ///
+ /// Register the event
+ ///
+ /// Function Main()
+ /// {
+ /// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
+ /// RegisterEveent(mySplusClass, BoolChange, BoolChanged);
+ /// }
+ ///
+ ///
+ ///
public class BoolChangeEventArgs : EventArgs
{
///
- /// Boolean state property
+ /// State property
///
+ /// Boolean
public bool State { get; set; }
///
- /// Boolean ushort value property
+ /// Integer value property
///
+ /// Ushort
public ushort IntValue { get { return (ushort)(State ? 1 : 0); } }
///
- /// Boolean change event args type
+ /// Type property
///
+ /// Ushort
public ushort Type { get; set; }
///
@@ -34,16 +83,22 @@ namespace PepperDash.Core
///
/// Constructor
///
+ ///
+ /// S+ requires an empty contructor, otherwise the class will not be avialable in S+.
+ ///
public BoolChangeEventArgs()
{
}
///
- /// Constructor overload
+ /// Constructor
///
- ///
- ///
+ ///
+ /// Accepts State as a boolean and Type as a ushort.
+ ///
+ /// a boolean value
+ /// a ushort number
public BoolChangeEventArgs(bool state, ushort type)
{
State = state;
@@ -51,11 +106,14 @@ namespace PepperDash.Core
}
///
- /// Constructor overload
+ /// Constructor
///
- ///
- ///
- ///
+ ///
+ /// Accepts State as a boolean, type as a ushort and index as ushort.
+ ///
+ /// a boolean value
+ /// a ushort number
+ /// a ushort number
public BoolChangeEventArgs(bool state, ushort type, ushort index)
{
State = state;
@@ -65,8 +123,54 @@ namespace PepperDash.Core
}
///
- /// Ushort change event args
+ /// Main UshrtChangeEventArgs class
///
+ ///
+ /// 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.
+ ///
+ /// When using UshrtChangeEventArgs in a class you will need to include a change handler method.
+ ///
+ /// public event EventHandler UshortChange;
+ ///
+ ///
+ /// 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);
+ /// }
+ ///
+ /// When referencing events in S+ you must create a event handler callback method and register the event.
+ ///
+ /// 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
+ /// }
+ /// }
+ /// }
+ ///
+ /// Register the event
+ ///
+ /// Function Main()
+ /// {
+ /// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
+ /// RegisterEveent(mySplusClass, UshortChange, UshortChanged);
+ /// }
+ ///
+ ///
+ ///
public class UshrtChangeEventArgs : EventArgs
{
///
@@ -95,8 +199,8 @@ namespace PepperDash.Core
///
/// Constructor overload
///
- ///
- ///
+ /// a ushort number
+ /// a ushort number
public UshrtChangeEventArgs(ushort intValue, ushort type)
{
IntValue = intValue;
@@ -106,9 +210,9 @@ namespace PepperDash.Core
///
/// Constructor overload
///
- ///
- ///
- ///
+ /// a ushort number
+ /// a ushort number
+ /// a ushort number
public UshrtChangeEventArgs(ushort intValue, ushort type, ushort index)
{
IntValue = intValue;
@@ -118,8 +222,54 @@ namespace PepperDash.Core
}
///
- /// String change event args
+ /// Main StringChangeEventArgs class
///
+ ///
+ /// 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.
+ ///
+ /// When using StringChangeEventArgs in a class you will need to include a change handler method.
+ ///
+ /// public event EventHandler StringChange;
+ ///
+ ///
+ /// 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);
+ /// }
+ ///
+ /// When referencing events in S+ you must create a event handler callback method and register the event.
+ ///
+ /// 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
+ /// }
+ /// }
+ /// }
+ ///
+ /// Register the event
+ ///
+ /// Function Main()
+ /// {
+ /// //RegisterEveent([S+ class name], [S# event], [S+ event handler]);
+ /// RegisterEveent(mySplusClass, StringChange, StringChanged);
+ /// }
+ ///
+ ///
+ ///
public class StringChangeEventArgs : EventArgs
{
///
@@ -148,8 +298,8 @@ namespace PepperDash.Core
///
/// Constructor overload
///
- ///
- ///
+ /// a string
+ /// a ushort number
public StringChangeEventArgs(string stringValue, ushort type)
{
StringValue = stringValue;
@@ -159,9 +309,9 @@ namespace PepperDash.Core
///
/// Constructor overload
///
- ///
- ///
- ///
+ /// a string
+ /// a ushort number
+ /// a ushort number
public StringChangeEventArgs(string stringValue, ushort type, ushort index)
{
StringValue = stringValue;
diff --git a/Pepperdash Core/Pepperdash Core/GenericRESTfulCommunications/GenericRESTfulClient.cs b/Pepperdash Core/Pepperdash Core/GenericRESTfulCommunications/GenericRESTfulClient.cs
index 7d8df61..1a2124a 100644
--- a/Pepperdash Core/Pepperdash Core/GenericRESTfulCommunications/GenericRESTfulClient.cs
+++ b/Pepperdash Core/Pepperdash Core/GenericRESTfulCommunications/GenericRESTfulClient.cs
@@ -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);
}
///
@@ -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);
}
///
diff --git a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs
index cbf5f4b..368ddec 100644
--- a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs
+++ b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoConfig.cs
@@ -7,8 +7,11 @@ using Crestron.SimplSharp;
namespace PepperDash.Core.SystemInfo
{
///
- /// Processor info class
+ /// Processor Info
///
+ ///
+ /// Stores processor information
+ ///
public class ProcessorInfo
{
public string Model { get; set; }
diff --git a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
index 1d58a80..4d822c3 100644
--- a/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
+++ b/Pepperdash Core/Pepperdash Core/SystemInfo/SystemInfoToSimpl.cs
@@ -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
{
///
- /// System Info class
+ /// System Info to Simpl
///
+ ///
+ /// Contains methods that can be called from S+ to get information about the system.
+ ///
public class SystemInfoToSimpl
{
public event EventHandler 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);
+ }
}
-
- ///
- /// private method to parse console messages
- ///
- ///
- ///
- ///
- ///
- ///
+
private string ParseConsoleResponse(string data, string line, string dataStart, string dataEnd)
{
var response = "";
@@ -337,13 +349,7 @@ namespace PepperDash.Core.SystemInfo
return response;
}
-
- ///
- /// Protected boolean change event handler
- ///
- ///
- ///
- ///
+
protected void OnBoolChange(bool state, ushort index, ushort type)
{
var handler = BoolChange;
@@ -354,13 +360,7 @@ namespace PepperDash.Core.SystemInfo
BoolChange(this, args);
}
}
-
- ///
- /// Protected string change event handler
- ///
- ///
- ///
- ///
+
protected void OnStringChange(string value, ushort index, ushort type)
{
var handler = StringChange;
@@ -371,13 +371,7 @@ namespace PepperDash.Core.SystemInfo
StringChange(this, args);
}
}
-
- ///
- /// Protected processor config change event handler
- ///
- ///
- ///
- ///
+
protected void OnProcessorChange(ProcessorInfo processor, ushort index, ushort type)
{
var handler = ProcessorChange;
@@ -388,13 +382,7 @@ namespace PepperDash.Core.SystemInfo
ProcessorChange(this, args);
}
}
-
- ///
- /// Ethernet change event handler
- ///
- ///
- ///
- ///
+
protected void OnEthernetInfoChange(EthernetInfo ethernet, ushort index, ushort type)
{
var handler = EthernetChange;
@@ -405,13 +393,7 @@ namespace PepperDash.Core.SystemInfo
EthernetChange(this, args);
}
}
-
- ///
- /// Control Subnet change event handler
- ///
- ///
- ///
- ///
+
protected void OnControlSubnetInfoChange(ControlSubnetInfo ethernet, ushort index, ushort type)
{
var handler = ControlSubnetChange;
@@ -422,13 +404,7 @@ namespace PepperDash.Core.SystemInfo
ControlSubnetChange(this, args);
}
}
-
- ///
- /// Program change event handler
- ///
- ///
- ///
- ///
+
protected void OnProgramChange(ProgramInfo program, ushort index, ushort type)
{
var handler = ProgramChange;
diff --git a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs
index 845b297..cc61b1f 100644
--- a/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs
+++ b/Pepperdash Core/Pepperdash Core/XSigUtility/Tokens/XSigSerialToken.cs
@@ -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);