commit 3199302daef393bdab0544babd1cde9d1ddb8368 Author: Heath Volmer Date: Wed Jun 15 10:05:41 2016 -0600 Initial. Moving certain classes out of Essentials Base diff --git a/Pepperdash Core/Pepperdash Core.sln b/Pepperdash Core/Pepperdash Core.sln new file mode 100644 index 0000000..cee471a --- /dev/null +++ b/Pepperdash Core/Pepperdash Core.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PepperDash_Core", "Pepperdash Core\PepperDash_Core.csproj", "{87E29B4C-569B-4368-A4ED-984AC1440C96}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {87E29B4C-569B-4368-A4ED-984AC1440C96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87E29B4C-569B-4368-A4ED-984AC1440C96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87E29B4C-569B-4368-A4ED-984AC1440C96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87E29B4C-569B-4368-A4ED-984AC1440C96}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs new file mode 100644 index 0000000..79235f7 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/CommunicationExtras.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace PepperDash.Core +{ + /// + /// Represents a device that uses basic connection + /// + public interface IBasicCommunication : IKeyed + { + event EventHandler BytesReceived; + event EventHandler TextReceived; + bool IsConnected { get; } + bool Connected { get; } + void SendText(string text); + void SendBytes(byte[] bytes); + void Connect(); + } + + + /// + /// + /// + public class GenericCommMethodReceiveBytesArgs : EventArgs + { + public byte[] Bytes { get; private set; } + public GenericCommMethodReceiveBytesArgs(byte[] bytes) + { + Bytes = bytes; + } + } + + /// + /// + /// + public class GenericCommMethodReceiveTextArgs : EventArgs + { + public string Text { get; private set; } + public GenericCommMethodReceiveTextArgs(string text) + { + Text = text; + } + } + + /// + /// + /// + public class ComTextHelper + { + public static string GetEscapedText(byte[] bytes) + { + return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray()); + } + + public static string GetEscapedText(string text) + { + var bytes = Encoding.GetEncoding(28591).GetBytes(text); + return String.Concat(bytes.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray()); + } + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs new file mode 100644 index 0000000..2155a5a --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/CoreInterfaces.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Core +{ + public interface IKeyed + { + string Key { get; } + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/Debug.cs b/Pepperdash Core/Pepperdash Core/Debug.cs new file mode 100644 index 0000000..d53fac2 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/Debug.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronDataStore; + + +namespace PepperDash.Core +{ + public class Debug + { + public static uint Level { get; private set; } + + /// + /// This should called from the ControlSystem Initiailize method. + /// + public static void Initialize() + { + // Add command to console + CrestronConsole.AddNewConsoleCommand(SetDebugFromConsole, "appdebug", + "appdebug:P [0-2]: Sets the application's console debug message level", + ConsoleAccessLevelEnum.AccessOperator); + + uint level = 0; + var err = CrestronDataStoreStatic.GetGlobalUintValue("DebugLevel", out level); + if (err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) + SetDebugLevel(level); + else if (err == CrestronDataStore.CDS_ERROR.CDS_RECORD_NOT_FOUND) + CrestronDataStoreStatic.SetGlobalUintValue("DebugLevel", 0); + else + CrestronConsole.PrintLine("Error restoring console debug level setting: {0}", err); + } + + /// + /// Callback for console command + /// + /// + public static void SetDebugFromConsole(string levelString) + { + try + { + if (string.IsNullOrEmpty(levelString.Trim())) + { + CrestronConsole.PrintLine("AppDebug level = {0}", Level); + return; + } + + SetDebugLevel(Convert.ToUInt32(levelString)); + } + catch + { + CrestronConsole.PrintLine("Usage: appdebug:P [0-2]"); + } + } + + /// + /// Sets the debug level + /// + /// Valid values 0 (no debug), 1 (critical), 2 (all messages) + public static void SetDebugLevel(uint level) + { + if (level <= 2) + { + Level = 2; + CrestronConsole.PrintLine("[Application {0}], Debug level set to {1}", + InitialParametersClass.ApplicationNumber, level); + var err = CrestronDataStoreStatic.SetGlobalUintValue("DebugLevel", level); + if(err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS) + CrestronConsole.PrintLine("Error saving console debug level setting: {0}", err); + } + } + + /// + /// Prints message to console if current debug level is equal to or higher than the level of this message. + /// Uses CrestronConsole.PrintLine. + /// + /// + /// Console format string + /// Object parameters + public static void Console(uint level, string format, params object[] items) + { + if (Level >= level) + CrestronConsole.PrintLine("App {0}:{1}", InitialParametersClass.ApplicationNumber, + string.Format(format, items)); + } + + /// + /// Appends a device Key to the beginning of a message + /// + public static void Console(uint level, IKeyed dev, string format, params object[] items) + { + if (Level >= level) + Console(level, "[{0}] {1}", dev.Key, string.Format(format, items)); + } + + public static void Console(uint level, IKeyed dev, ErrorLogLevel errorLogLevel, + string format, params object[] items) + { + if (Level >= level) + { + var str = string.Format("[{0}] {1}", dev.Key, string.Format(format, items)); + Console(level, str); + LogError(errorLogLevel, str); + } + } + + public static void Console(uint level, ErrorLogLevel errorLogLevel, + string format, params object[] items) + { + if (Level >= level) + { + var str = string.Format(format, items); + Console(level, str); + LogError(errorLogLevel, str); + } + } + + public static void LogError(ErrorLogLevel errorLogLevel, string str) + { + string msg = string.Format("App {0}:{1}", InitialParametersClass.ApplicationNumber, str); + switch (errorLogLevel) + { + case ErrorLogLevel.Error: + ErrorLog.Error(msg); + break; + case ErrorLogLevel.Warning: + ErrorLog.Warn(msg); + break; + case ErrorLogLevel.Notice: + ErrorLog.Notice(msg); + break; + } + } + + public enum ErrorLogLevel + { + Error, Warning, Notice, None + } + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/Device.cs b/Pepperdash Core/Pepperdash Core/Device.cs new file mode 100644 index 0000000..87bd106 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/Device.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PepperDash.Core +{ + //********************************************************************************************************* + /// + /// The core event and status-bearing class that most if not all device and connectors can derive from. + /// + public class Device : IKeyed + { + public string Key { get; protected set; } + public string Name { get; protected set; } + public bool Enabled { get; protected set; } + List _PreActivationActions; + List _PostActivationActions; + + public static Device DefaultDevice { get { return _DefaultDevice; } } + static Device _DefaultDevice = new Device("Default", "Default"); + + /// + /// Base constructor for all Devices. + /// + /// + public Device(string key) + { + Key = key; + if (key.Contains('.')) Debug.Console(0, this, "WARNING: Device name's should not include '.'"); + Name = ""; + } + + public Device(string key, string name) : this(key) + { + Name = name; + } + + public void AddPreActivationAction(Action act) + { + if (_PreActivationActions == null) + _PreActivationActions = new List(); + _PreActivationActions.Add(act); + } + + public void AddPostActivationAction(Action act) + { + if (_PostActivationActions == null) + _PostActivationActions = new List(); + _PostActivationActions.Add(act); + } + + /// + /// Gets this device ready to be used in the system. Runs any added pre-activation items, and + /// all post-activation at end. Classes needing additional logic to + /// run should override CustomActivate() + /// + public bool Activate() + { + if (_PreActivationActions != null) + _PreActivationActions.ForEach(a => a.Invoke()); + var result = CustomActivate(); + if(result && _PostActivationActions != null) + _PostActivationActions.ForEach(a => a.Invoke()); + return result; + } + + /// + /// Called in between Pre and PostActivationActions when Activate() is called. + /// Override to provide addtitional setup when calling activation. Overriding classes + /// do not need to call base.CustomActivate() + /// + /// true if device activated successfully. + public virtual bool CustomActivate() { return true; } + + /// + /// Call to deactivate device - unlink events, etc. Overriding classes do not + /// need to call base.Deactivate() + /// + /// + public virtual bool Deactivate() { return true; } + + /// + /// Helper method to check object for bool value false and fire an Action method + /// + /// Should be of type bool, others will be ignored + /// Action to be run when o is false + public void OnFalse(object o, Action a) + { + if (o is bool && !(bool)o) a(); + } + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/EthernetHelper.cs b/Pepperdash Core/Pepperdash Core/EthernetHelper.cs new file mode 100644 index 0000000..4baf9c6 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/EthernetHelper.cs @@ -0,0 +1,118 @@ +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); + } + } + } +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/Feedbacks HAS SSP LINKS.cs b/Pepperdash Core/Pepperdash Core/Feedbacks HAS SSP LINKS.cs new file mode 100644 index 0000000..4d1d514 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/Feedbacks HAS SSP LINKS.cs @@ -0,0 +1,209 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using Crestron.SimplSharp; + +//namespace PepperDash.Core +//{ +// public abstract class Feedback +// { +// public event EventHandler OutputChange; + +// public virtual bool BoolValue { get { return false; } } +// public virtual int IntValue { get { return 0; } } +// public virtual string StringValue { get { return ""; } } + +// public Cue Cue { get; private set; } + +// public abstract eCueType Type { get; } + +// protected Feedback() +// { +// } + +// protected Feedback(Cue cue) +// { +// Cue = cue; +// } + +// public abstract void FireUpdate(); + +// protected void OnOutputChange() +// { +// if (OutputChange != null) OutputChange(this, EventArgs.Empty); +// } +// } + +// public class BoolFeedbackLocalStorage +// { +// public bool BoolValue +// { +// get { return Output.BoolValue; } +// set +// { + +// } +// } +// public BoolFeedback Output { get; private set; } + +// public BoolFeedbackLocalStorage(BoolFeedback bo) +// { +// Output = bo; +// } +// } + + +// public class BoolFeedback : Feedback +// { +// public override bool BoolValue { get { return ValueFunc.Invoke(); } } + +// public override eCueType Type { get { return eCueType.Bool; } } + +// public Func ValueFunc { get; private set; } +// List LinkedInputSigs = new List(); +// List LinkedComplementInputSigs = new List(); + +// public BoolFeedback(Func valueFunc) +// : this(Cue.DefaultBoolCue, valueFunc) +// { +// } + +// public BoolFeedback(Cue cue, Func valueFunc) +// : base(cue) +// { +// if (cue == null) throw new ArgumentNullException("cue"); +// ValueFunc = valueFunc; +// } + +// public override void FireUpdate() +// { +// LinkedInputSigs.ForEach(s => UpdateSig(s)); +// LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s)); +// OnOutputChange(); +// } + +// public void LinkInputSig(BoolInputSig sig) +// { +// LinkedInputSigs.Add(sig); +// UpdateSig(sig); +// } + +// public void UnlinkInputSig(BoolInputSig sig) +// { +// LinkedInputSigs.Remove(sig); +// } + +// public void LinkComplementInputSig(BoolInputSig sig) +// { +// LinkedComplementInputSigs.Add(sig); +// UpdateComplementSig(sig); +// } + +// public void UnlinkComplementInputSig(BoolInputSig sig) +// { +// LinkedComplementInputSigs.Remove(sig); +// } + +// void UpdateSig(BoolInputSig sig) +// { +// sig.BoolValue = ValueFunc.Invoke(); +// } + +// void UpdateComplementSig(BoolInputSig sig) +// { +// sig.BoolValue = !ValueFunc.Invoke(); +// } +// } + +// //****************************************************************************** +// public class IntFeedback : Feedback +// { +// public override int IntValue { get { return ValueFunc.Invoke(); } } +// public ushort UShortValue { get { return (ushort)ValueFunc.Invoke(); } } +// public override eCueType Type { get { return eCueType.Int; } } + +// Func ValueFunc; +// List LinkedInputSigs = new List(); + +// public IntFeedback(Func valueFunc) +// : this(Cue.DefaultIntCue, valueFunc) +// { +// } + +// public IntFeedback(Cue cue, Func valueFunc) +// : base(cue) +// { +// if (cue == null) throw new ArgumentNullException("cue"); +// ValueFunc = valueFunc; +// } + +// public override void FireUpdate() +// { +// LinkedInputSigs.ForEach(s => UpdateSig(s)); +// OnOutputChange(); +// } + +// public void LinkInputSig(UShortInputSig sig) +// { +// LinkedInputSigs.Add(sig); +// UpdateSig(sig); +// } + +// public void UnlinkInputSig(UShortInputSig sig) +// { +// LinkedInputSigs.Remove(sig); +// } + +// void UpdateSig(UShortInputSig sig) +// { +// sig.UShortValue = this.UShortValue; +// } +// } + + +// //****************************************************************************** +// public class StringFeedback : Feedback +// { +// public override string StringValue { get { return ValueFunc.Invoke(); } } +// public override eCueType Type { get { return eCueType.String; } } + +// public Func ValueFunc { get; private set; } +// List LinkedInputSigs = new List(); + +// public StringFeedback(Func valueFunc) +// : this(Cue.DefaultStringCue, valueFunc) +// { +// } + +// public StringFeedback(Cue cue, Func valueFunc) +// : base(cue) +// { +// if (cue == null) throw new ArgumentNullException("cue"); +// ValueFunc = valueFunc; + +// } + +// public override void FireUpdate() +// { +// LinkedInputSigs.ForEach(s => UpdateSig(s)); +// OnOutputChange(); +// } + +// public void LinkInputSig(StringInputSig sig) +// { +// LinkedInputSigs.Add(sig); +// UpdateSig(sig); +// } + +// public void UnlinkInputSig(StringInputSig sig) +// { +// LinkedInputSigs.Remove(sig); +// } + +// void UpdateSig(StringInputSig sig) +// { +// sig.StringValue = ValueFunc.Invoke(); +// } +// } +//} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/GenericTcpIpClient.cs new file mode 100644 index 0000000..9863360 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/GenericTcpIpClient.cs @@ -0,0 +1,189 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronSockets; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace PepperDash.Core +{ + public class GenericTcpIpClient : Device, IBasicCommunication + { + public event EventHandler BytesReceived; + public event EventHandler TextReceived; + + public bool IsConnected { get { return Client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; } } + public string Status { get { return Client.ClientStatus.ToString(); } } + public string ConnectionFailure { get { return Client.ClientStatus.ToString(); } } + + public bool Connected + { + get { return Client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; } + } + + TCPClient Client; + CTimer RetryTimer; + + public GenericTcpIpClient(string key, string address, int port, int bufferSize) + : base(key) + { + Client = new TCPClient(address, port, bufferSize); + } + + public override bool CustomActivate() + { + Client.SocketStatusChange += new TCPClientSocketStatusChangeEventHandler(Client_SocketStatusChange); + return true; + } + + public override bool Deactivate() + { + Client.SocketStatusChange -= this.Client_SocketStatusChange; + return true; + } + + public void Connect() + { + Client.ConnectToServerAsync(null); + } + + public void Disconnnect() + { + Client.DisconnectFromServer(); + } + + void ConnectToServerCallback(TCPClient c) + { + if (c.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED) + WaitAndTryReconnect(); + } + + void WaitAndTryReconnect() + { + Client.DisconnectFromServer(); + Debug.Console(2, "Attempting reconnect, status={0}", Client.ClientStatus); + RetryTimer = new CTimer(o => { Client.ConnectToServerAsync(ConnectToServerCallback); }, 1000); + } + + void Receive(TCPClient client, int numBytes) + { + if (numBytes > 0) + { + var bytes = client.IncomingDataBuffer.Take(numBytes).ToArray(); + //if (Debug.Level == 2) + // Debug.Console(2, this, "Received: {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + var bytesHandler = BytesReceived; + if (bytesHandler != null) + bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); + var textHandler = TextReceived; + if (textHandler != null) + { + var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length); + textHandler(this, new GenericCommMethodReceiveTextArgs(str)); + } + } + Client.ReceiveDataAsync(Receive); + } + + /// + /// General send method + /// + public void SendText(string text) + { + var bytes = Encoding.GetEncoding(28591).GetBytes(text); + // Check debug level before processing byte array + if (Debug.Level == 2) + Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + Client.SendData(bytes, bytes.Length); + } + + /// + /// This is useful from console and...? + /// + public void SendEscapedText(string text) + { + //if (Client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED) + // Connect(); + var unescapedText = Regex.Replace(text, @"\\x([0-9a-fA-F][0-9a-fA-F])", s => + { + var hex = s.Groups[1].Value; + return ((char)Convert.ToByte(hex, 16)).ToString(); + }); + SendText(unescapedText); + + //var bytes = Encoding.GetEncoding(28591).GetBytes(unescapedText); + //Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, text); + //Client.SendData(bytes, bytes.Length); + } + + public void SendBytes(byte[] bytes) + { + if (Debug.Level == 2) + Debug.Console(2, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes)); + Client.SendData(bytes, bytes.Length); + } + + + void Client_SocketStatusChange(TCPClient client, SocketStatus clientSocketStatus) + { + if (client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED && + client.ClientStatus != SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY) + WaitAndTryReconnect(); + + + Debug.Console(2, this, "Socket status change {0}", clientSocketStatus); + switch (clientSocketStatus) + { + case SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY: + break; + case SocketStatus.SOCKET_STATUS_BROKEN_REMOTELY: + break; + case SocketStatus.SOCKET_STATUS_CONNECTED: + Client.ReceiveDataAsync(Receive); + break; + case SocketStatus.SOCKET_STATUS_CONNECT_FAILED: + break; + case SocketStatus.SOCKET_STATUS_DNS_FAILED: + break; + case SocketStatus.SOCKET_STATUS_DNS_LOOKUP: + break; + case SocketStatus.SOCKET_STATUS_DNS_RESOLVED: + break; + case SocketStatus.SOCKET_STATUS_LINK_LOST: + break; + case SocketStatus.SOCKET_STATUS_NO_CONNECT: + break; + case SocketStatus.SOCKET_STATUS_SOCKET_NOT_EXIST: + break; + case SocketStatus.SOCKET_STATUS_WAITING: + break; + default: + break; + } + } + } + + public class TcpIpConfig + { + [JsonProperty(Required = Required.Always)] + public string Address { get; set; } + + [JsonProperty(Required = Required.Always)] + public int Port { get; set; } + + /// + /// Defaults to 32768 + /// + public int BufferSize { get; set; } + + public TcpIpConfig() + { + BufferSize = 32768; + } + } + +} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/IHasFeedbacks.cs b/Pepperdash Core/Pepperdash Core/IHasFeedbacks.cs new file mode 100644 index 0000000..13b9d56 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/IHasFeedbacks.cs @@ -0,0 +1,53 @@ +//using System.Collections.Generic; +//using System.Linq; + +//namespace PepperDash.Core +//{ +// public interface IHasFeedback : IKeyed +// { +// /// +// /// This method shall return a list of all Output objects on a device, +// /// including all "aggregate" devices. +// /// +// List Feedbacks { get; } + +// } + + +// public static class IHasFeedbackExtensions +// { +// public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates) +// { +// var outputs = source.Feedbacks.OrderBy(x => x.Type); +// if (outputs != null) +// { +// Debug.Console(0, source, "\n\nAvailable outputs:"); +// foreach (var o in outputs) +// { +// string val = ""; +// if (getCurrentStates) +// { +// switch (o.Type) +// { +// case eCueType.Bool: +// val = " = " + o.BoolValue; +// break; +// case eCueType.Int: +// val = " = " + o.IntValue; +// break; +// case eCueType.String: +// val = " = " + o.StringValue; +// break; +// //case eOutputType.Other: +// // break; +// } +// } +// Debug.Console(0, "{0,-8} {1,5} {2}{3}", o.Type, o.Cue.Number, +// (string.IsNullOrEmpty(o.Cue.Name) ? "-none-" : o.Cue.Name), val); +// } +// } +// else +// Debug.Console(0, source, "No available outputs:"); +// } +// } +//} \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj new file mode 100644 index 0000000..087fac6 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj @@ -0,0 +1,96 @@ + + + Release + AnyCPU + 9.0.30729 + 2.0 + {87E29B4C-569B-4368-A4ED-984AC1440C96} + Library + Properties + PepperDash_Core + PepperDash_Core + {0B4745B0-194B-4BB6-8E21-E9057CA92500};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + + + .allowedReferenceRelatedFileExtensions + none + true + bin\ + prompt + 4 + 512 + true + true + + + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\Newtonsoft.Json.Compact.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + + + False + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + + + + + + + + + + + + + + + + + + + + + + PepperDash_Core + PepperDash_Core + + C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\Pepperdash_Core.clz + 1.007.0017 + 6/15/2016 10:01:37 AM + + False + + + + + + + rem S# preparation will execute after these operations + + \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b343790 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/Properties/AssemblyInfo.cs @@ -0,0 +1,8 @@ +using System.Reflection; + +[assembly: AssemblyTitle("Pepperdash_Core")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Pepperdash_Core")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyVersion("1.0.0.*")] + diff --git a/Pepperdash Core/Pepperdash Core/Properties/ControlSystem.cfg b/Pepperdash Core/Pepperdash Core/Properties/ControlSystem.cfg new file mode 100644 index 0000000..e69de29 diff --git a/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.clz b/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.clz new file mode 100644 index 0000000..83f808f Binary files /dev/null and b/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.clz differ diff --git a/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.config b/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.config new file mode 100644 index 0000000..2b2dce7 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/bin/PepperDash_Core.config @@ -0,0 +1,16 @@ + + + PepperDash_Core + PepperDash_Core + PepperDash_Core + 1.007.0017 + SIMPL# Plugin + 5 + 5 + + + + 6/15/2016 10:01:37 AM + 1.0.0.16248 + + \ No newline at end of file diff --git a/Pepperdash Core/Pepperdash Core/bin/SimplSharpData.dat b/Pepperdash Core/Pepperdash Core/bin/SimplSharpData.dat new file mode 100644 index 0000000..816bfe1 Binary files /dev/null and b/Pepperdash Core/Pepperdash Core/bin/SimplSharpData.dat differ diff --git a/Pepperdash Core/Pepperdash Core/bin/manifest.info b/Pepperdash Core/Pepperdash Core/bin/manifest.info new file mode 100644 index 0000000..a0ef742 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/bin/manifest.info @@ -0,0 +1,14 @@ +MainAssembly=PepperDash_Core.dll:92b05d53de3375de2f6efeacaf9dd897 +MainAssemblyMinFirmwareVersion=1.007.0017 +ü +DependencySource=Newtonsoft.Json.Compact.dll:ea996aa2ec65aa1878e7c9d09e37a896 +DependencyPath=PepperDash_Core.clz:Newtonsoft.Json.Compact.dll +DependencyMainAssembly=Newtonsoft.Json.Compact.dll:ea996aa2ec65aa1878e7c9d09e37a896 +ü +DependencySource=SimplSharpCustomAttributesInterface.dll:9c4b4d4c519b655af90016edca2d66b9 +DependencyPath=PepperDash_Core.clz:SimplSharpCustomAttributesInterface.dll +DependencyMainAssembly=SimplSharpCustomAttributesInterface.dll:9c4b4d4c519b655af90016edca2d66b9 +ü +DependencySource=SimplSharpHelperInterface.dll:aed72eb0e19559a3f56708be76445dcd +DependencyPath=PepperDash_Core.clz:SimplSharpHelperInterface.dll +DependencyMainAssembly=SimplSharpHelperInterface.dll:aed72eb0e19559a3f56708be76445dcd diff --git a/Pepperdash Core/Pepperdash Core/bin/manifest.ser b/Pepperdash Core/Pepperdash Core/bin/manifest.ser new file mode 100644 index 0000000..ba16104 Binary files /dev/null and b/Pepperdash Core/Pepperdash Core/bin/manifest.ser differ diff --git a/Pepperdash Core/Pepperdash Core/obj/Debug/Pepperdash_Core.csproj.FileListAbsolute.txt b/Pepperdash Core/Pepperdash Core/obj/Debug/Pepperdash_Core.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..5518a24 --- /dev/null +++ b/Pepperdash Core/Pepperdash Core/obj/Debug/Pepperdash_Core.csproj.FileListAbsolute.txt @@ -0,0 +1,8 @@ +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\obj\Debug\ResolveAssemblyReference.cache +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\SimplSharpCustomAttributesInterface.dll +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\SimplSharpHelperInterface.dll +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\Newtonsoft.Json.Compact.dll +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.pdb +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\obj\Debug\PepperDash_Core.dll +C:\Users\hvolm\Desktop\working\pepperdash-simplsharp-core\Pepperdash Core\Pepperdash Core\obj\Debug\PepperDash_Core.pdb