mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Post-merge 344, compile and warning cleanup
This commit is contained in:
@@ -1,149 +1,149 @@
|
|||||||
using System;
|
using System;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommFactory
|
public class CommFactory
|
||||||
{
|
{
|
||||||
public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig)
|
public static EssentialsControlPropertiesConfig GetControlPropertiesConfig(DeviceConfig deviceConfig)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
|
return JsonConvert.DeserializeObject<EssentialsControlPropertiesConfig>
|
||||||
(deviceConfig.Properties["control"].ToString());
|
(deviceConfig.Properties["control"].ToString());
|
||||||
//Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
|
//Debug.Console(2, "Control TEST: {0}", JsonConvert.SerializeObject(controlConfig));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
||||||
Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
|
Debug.Console(0, "ERROR: [{0}] Control properties deserialize failed:\r{1}", deviceConfig.Key, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a comm method of either com port, TCP, SSH
|
/// Returns a comm method of either com port, TCP, SSH
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="deviceConfig">The Device config object</param>
|
/// <param name="deviceConfig">The Device config object</param>
|
||||||
public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
|
public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
|
||||||
{
|
{
|
||||||
EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);
|
EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);
|
||||||
if (controlConfig == null)
|
if (controlConfig == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IBasicCommunication comm = null;
|
IBasicCommunication comm = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var c = controlConfig.TcpSshProperties;
|
var c = controlConfig.TcpSshProperties;
|
||||||
switch (controlConfig.Method)
|
switch (controlConfig.Method)
|
||||||
{
|
{
|
||||||
case eControlMethod.Com:
|
case eControlMethod.Com:
|
||||||
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort(controlConfig), controlConfig.ComParams);
|
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort(controlConfig), controlConfig.ComParams);
|
||||||
break;
|
break;
|
||||||
case eControlMethod.IR:
|
case eControlMethod.IR:
|
||||||
break;
|
break;
|
||||||
case eControlMethod.Ssh:
|
case eControlMethod.Ssh:
|
||||||
{
|
{
|
||||||
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
|
var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
|
||||||
ssh.AutoReconnect = c.AutoReconnect;
|
ssh.AutoReconnect = c.AutoReconnect;
|
||||||
if(ssh.AutoReconnect)
|
if(ssh.AutoReconnect)
|
||||||
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||||
comm = ssh;
|
comm = ssh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eControlMethod.Tcpip:
|
case eControlMethod.Tcpip:
|
||||||
{
|
{
|
||||||
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
|
var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
|
||||||
tcp.AutoReconnect = c.AutoReconnect;
|
tcp.AutoReconnect = c.AutoReconnect;
|
||||||
if (tcp.AutoReconnect)
|
if (tcp.AutoReconnect)
|
||||||
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
|
||||||
comm = tcp;
|
comm = tcp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eControlMethod.Telnet:
|
case eControlMethod.Telnet:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
|
Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
|
||||||
deviceConfig.Properties.ToString(), e);
|
deviceConfig.Properties.ToString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put it in the device manager if it's the right flavor
|
// put it in the device manager if it's the right flavor
|
||||||
var comDev = comm as Device;
|
var comDev = comm as Device;
|
||||||
if (comDev != null)
|
if (comDev != null)
|
||||||
DeviceManager.AddDevice(comDev);
|
DeviceManager.AddDevice(comDev);
|
||||||
return comm;
|
return comm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
|
public static ComPort GetComPort(EssentialsControlPropertiesConfig config)
|
||||||
{
|
{
|
||||||
var comPar = config.ComParams;
|
var comPar = config.ComParams;
|
||||||
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
var dev = GetIComPortsDeviceFromManagedDevice(config.ControlPortDevKey);
|
||||||
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
if (dev != null && config.ControlPortNumber <= dev.NumberOfComPorts)
|
||||||
return dev.ComPorts[config.ControlPortNumber];
|
return dev.ComPorts[config.ControlPortNumber];
|
||||||
Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
Debug.Console(0, "GetComPort: Device '{0}' does not have com port {1}", config.ControlPortDevKey, config.ControlPortNumber);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
|
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
|
||||||
/// return the ControlSystem object from the Global class.
|
/// return the ControlSystem object from the Global class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
|
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
|
||||||
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
||||||
{
|
{
|
||||||
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
||||||
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
|
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
|
||||||
&& Global.ControlSystem is IComPorts)
|
&& Global.ControlSystem is IComPorts)
|
||||||
return Global.ControlSystem;
|
return Global.ControlSystem;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
||||||
if (dev == null)
|
if (dev == null)
|
||||||
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsControlPropertiesConfig :
|
public class EssentialsControlPropertiesConfig :
|
||||||
PepperDash.Core.ControlPropertiesConfig
|
PepperDash.Core.ControlPropertiesConfig
|
||||||
{
|
{
|
||||||
// ****** All of these things, except for #Pro-specific com stuff, were
|
// ****** All of these things, except for #Pro-specific com stuff, were
|
||||||
// moved into PepperDash.Core to help non-pro PortalSync.
|
// moved into PepperDash.Core to help non-pro PortalSync.
|
||||||
|
|
||||||
//public eControlMethod Method { get; set; }
|
//public eControlMethod Method { get; set; }
|
||||||
|
|
||||||
//public string ControlPortDevKey { get; set; }
|
//public string ControlPortDevKey { get; set; }
|
||||||
|
|
||||||
//[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
//[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||||
//public uint ControlPortNumber { get; set; }
|
//public uint ControlPortNumber { get; set; }
|
||||||
|
|
||||||
//public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
//public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
||||||
|
|
||||||
//public string IrFile { get; set; }
|
//public string IrFile { get; set; }
|
||||||
|
|
||||||
//public ComPortConfig ComParams { get; set; }
|
//public ComPortConfig ComParams { get; set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||||
public ComPort.ComPortSpec ComParams { get; set; }
|
public ComPort.ComPortSpec ComParams { get; set; }
|
||||||
|
|
||||||
public string CresnetId { get; set; }
|
public string CresnetId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -162,37 +162,37 @@ namespace PepperDash.Essentials.Core
|
|||||||
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public string IpId { get; set; }
|
//public string IpId { get; set; }
|
||||||
|
|
||||||
//[JsonIgnore]
|
//[JsonIgnore]
|
||||||
//public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
|
//public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
|
||||||
|
|
||||||
//public char EndOfLineChar { get; set; }
|
//public char EndOfLineChar { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// Defaults to Environment.NewLine;
|
///// Defaults to Environment.NewLine;
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public string EndOfLineString { get; set; }
|
//public string EndOfLineString { get; set; }
|
||||||
|
|
||||||
//public string DeviceReadyResponsePattern { get; set; }
|
//public string DeviceReadyResponsePattern { get; set; }
|
||||||
|
|
||||||
//public EssentialsControlPropertiesConfig()
|
//public EssentialsControlPropertiesConfig()
|
||||||
//{
|
//{
|
||||||
// EndOfLineString = CrestronEnvironment.NewLine;
|
// EndOfLineString = CrestronEnvironment.NewLine;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IrControlSpec
|
public class IrControlSpec
|
||||||
{
|
{
|
||||||
public string PortDeviceKey { get; set; }
|
public string PortDeviceKey { get; set; }
|
||||||
public uint PortNumber { get; set; }
|
public uint PortNumber { get; set; }
|
||||||
public string File { get; set; }
|
public string File { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//public enum eControlMethod
|
//public enum eControlMethod
|
||||||
//{
|
//{
|
||||||
// None = 0, Com, IpId, IR, Ssh, Tcpip, Telnet
|
// None = 0, Com, IpId, IR, Ssh, Tcpip, Telnet
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@@ -299,7 +299,6 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
{
|
{
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
|
||||||
uint id = 0x00;
|
|
||||||
GlsOccupancySensorBase occSensor = null;
|
GlsOccupancySensorBase occSensor = null;
|
||||||
|
|
||||||
occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem);
|
occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem);
|
||||||
@@ -314,7 +313,6 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
{
|
{
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
|
||||||
uint id = 0x00;
|
|
||||||
GlsOccupancySensorBase occSensor = null;
|
GlsOccupancySensorBase occSensor = null;
|
||||||
|
|
||||||
occSensor = new GlsOdtCCn(comm.CresnetIdInt, Global.ControlSystem);
|
occSensor = new GlsOdtCCn(comm.CresnetIdInt, Global.ControlSystem);
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ namespace PepperDash.Essentials
|
|||||||
request.Header.SetHeaderValue("Content-Type", "application/json");
|
request.Header.SetHeaderValue("Content-Type", "application/json");
|
||||||
request.ContentString = postBody;
|
request.ContentString = postBody;
|
||||||
|
|
||||||
Client.DispatchAsync(request, PostConnectionCallback);
|
var err = Client.DispatchAsync(request, PostConnectionCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -316,6 +316,7 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="err"></param>
|
/// <param name="err"></param>
|
||||||
void PostConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err)
|
void PostConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "PostConnectionCallback err: {0}", err);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (resp != null && resp.Code == 200)
|
if (resp != null && resp.Code == 200)
|
||||||
@@ -326,11 +327,7 @@ namespace PepperDash.Essentials
|
|||||||
ServerReconnectTimer = null;
|
ServerReconnectTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning The SSE Client from a previous session might need to be killed...
|
ConnectSseClient(null);
|
||||||
//if (SseClient == null)
|
|
||||||
//{
|
|
||||||
ConnectSseClient(null);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,9 +79,6 @@ namespace PepperDash.Essentials.UIDrivers.VC
|
|||||||
StringBuilder SearchStringBuilder = new StringBuilder();
|
StringBuilder SearchStringBuilder = new StringBuilder();
|
||||||
BoolFeedback SearchStringBackspaceVisibleFeedback;
|
BoolFeedback SearchStringBackspaceVisibleFeedback;
|
||||||
|
|
||||||
#warning WHAT THE HELL happened to this?????
|
|
||||||
BoolFeedback LayoutButtonEnableFeedback;
|
|
||||||
|
|
||||||
ModalDialog IncomingCallModal;
|
ModalDialog IncomingCallModal;
|
||||||
|
|
||||||
eKeypadMode KeypadMode;
|
eKeypadMode KeypadMode;
|
||||||
|
|||||||
Reference in New Issue
Block a user