mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Merge branch 'development' into feature/vc4-eisc
This commit is contained in:
@@ -1,120 +1,120 @@
|
|||||||
using System;
|
using System;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
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, and puts this into the DeviceManager
|
/// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager
|
||||||
/// </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.ComParams, controlConfig);
|
comm = new ComPortController(deviceConfig.Key + "-com", GetComPort, controlConfig.ComParams, controlConfig);
|
||||||
break;
|
break;
|
||||||
case eControlMethod.Cec:
|
case eControlMethod.Cec:
|
||||||
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort, controlConfig);
|
||||||
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.Udp:
|
case eControlMethod.Udp:
|
||||||
{
|
{
|
||||||
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
|
var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
|
||||||
comm = udp;
|
comm = udp;
|
||||||
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>
|
||||||
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device
|
/// Gets an ICec port from a RoutingInput or RoutingOutput on a device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ICec GetCecPort(ControlPropertiesConfig config)
|
public static ICec GetCecPort(ControlPropertiesConfig config)
|
||||||
{
|
{
|
||||||
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey);
|
||||||
|
|
||||||
if (dev != null)
|
if (dev != null)
|
||||||
@@ -147,64 +147,64 @@ namespace PepperDash.Essentials.Core
|
|||||||
Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey);
|
Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
|
|
||||||
/// return the ControlSystem object from the Global class.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
|
|
||||||
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
|
||||||
{
|
|
||||||
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
|
||||||
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
|
|
||||||
&& Global.ControlSystem is IComPorts)
|
|
||||||
return Global.ControlSystem;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
|
||||||
if (dev == null)
|
|
||||||
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public class EssentialsControlPropertiesConfig :
|
|
||||||
PepperDash.Core.ControlPropertiesConfig
|
|
||||||
{
|
|
||||||
|
|
||||||
[JsonConverter(typeof(ComSpecJsonConverter))]
|
|
||||||
public ComPort.ComPortSpec ComParams { get; set; }
|
|
||||||
|
|
||||||
public string CresnetId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to provide uint conversion of string CresnetId
|
|
||||||
/// </summary>
|
|
||||||
public uint CresnetIdInt
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Convert.ToUInt32(CresnetId, 16);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string InfinetId { get; set; }
|
/// <summary>
|
||||||
|
/// Helper to grab the IComPorts device for this PortDeviceKey. Key "controlSystem" will
|
||||||
|
/// return the ControlSystem object from the Global class.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>IComPorts device or null if the device is not found or does not implement IComPorts</returns>
|
||||||
|
public static IComPorts GetIComPortsDeviceFromManagedDevice(string ComPortDevKey)
|
||||||
|
{
|
||||||
|
if ((ComPortDevKey.Equals("controlSystem", System.StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| ComPortDevKey.Equals("processor", System.StringComparison.OrdinalIgnoreCase))
|
||||||
|
&& Global.ControlSystem is IComPorts)
|
||||||
|
return Global.ControlSystem;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dev = DeviceManager.GetDeviceForKey(ComPortDevKey) as IComPorts;
|
||||||
|
if (dev == null)
|
||||||
|
Debug.Console(0, "ComPortConfig: Cannot find com port device '{0}'", ComPortDevKey);
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class EssentialsControlPropertiesConfig :
|
||||||
|
PepperDash.Core.ControlPropertiesConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonConverter(typeof(ComSpecJsonConverter))]
|
||||||
|
public ComPort.ComPortSpec ComParams { get; set; }
|
||||||
|
|
||||||
|
public string CresnetId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to provide uint conversion of string CresnetId
|
||||||
|
/// </summary>
|
||||||
|
public uint CresnetIdInt
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Convert.ToUInt32(CresnetId, 16);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string InfinetId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attepmts to provide uiont conversion of string InifinetId
|
/// Attepmts to provide uiont conversion of string InifinetId
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -221,13 +221,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId));
|
throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>,
|
||||||
/// The OS Version of the processor (Firmware Version)
|
/// The OS Version of the processor (Firmware Version)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("osVersion")]
|
[JsonProperty("osVersion")]
|
||||||
@@ -92,5 +92,18 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
// return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware;
|
// return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The information gathered by the processor at runtime about it's NICs and their IP addresses.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("ipInfo")]
|
||||||
|
public Dictionary<short, EthernetAdapterInfo> IpInfo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Global.EthernetAdapterInfoCollection;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public class EthernetAdapterInfo
|
||||||
|
{
|
||||||
|
public EthernetAdapterType Type { get; set; }
|
||||||
|
public bool DhcpIsOn { get; set; }
|
||||||
|
public string Hostname { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
public string Subnet { get; set; }
|
||||||
|
public string Gateway { get; set; }
|
||||||
|
public string Dns1 { get; set; }
|
||||||
|
public string Dns2 { get; set; }
|
||||||
|
public string Dns3 { get; set; }
|
||||||
|
public string Domain { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,177 +1,178 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharp.CrestronDataStore;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharp.CrestronDataStore;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.License;
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.License;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Schema;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Newtonsoft.Json.Schema;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
|
||||||
{
|
namespace PepperDash.Essentials.Core
|
||||||
public static class Global
|
{
|
||||||
{
|
public static class Global
|
||||||
|
{
|
||||||
public static CrestronControlSystem ControlSystem { get; set; }
|
public static CrestronControlSystem ControlSystem { get; set; }
|
||||||
|
|
||||||
public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } }
|
public static eDevicePlatform Platform { get { return CrestronEnvironment.DevicePlatform; } }
|
||||||
|
|
||||||
public static LicenseManager LicenseManager { get; set; }
|
public static LicenseManager LicenseManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path prefix to the folder containing configuration files
|
/// The file path prefix to the folder containing configuration files
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string FilePathPrefix { get; private set; }
|
public static string FilePathPrefix { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path prefix to the applciation directory
|
/// The file path prefix to the applciation directory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string ApplicationDirectoryPathPrefix
|
public static string ApplicationDirectoryPathPrefix
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory();
|
return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the directory separator character based on the running OS
|
/// Returns the directory separator character based on the running OS
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static char DirectorySeparator
|
public static char DirectorySeparator
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return System.IO.Path.DirectorySeparatorChar;
|
return System.IO.Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wildcarded config file name for global reference
|
/// Wildcarded config file name for global reference
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ConfigFileName = "*configurationFile*.json";
|
public const string ConfigFileName = "*configurationFile*.json";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the file path prefix
|
/// Sets the file path prefix
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="prefix"></param>
|
/// <param name="prefix"></param>
|
||||||
public static void SetFilePathPrefix(string prefix)
|
public static void SetFilePathPrefix(string prefix)
|
||||||
{
|
{
|
||||||
FilePathPrefix = prefix;
|
FilePathPrefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string _AssemblyVersion;
|
static string _AssemblyVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Assembly Version of Essentials
|
/// Gets the Assembly Version of Essentials
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The Assembly Version at Runtime</returns>
|
/// <returns>The Assembly Version at Runtime</returns>
|
||||||
public static string AssemblyVersion
|
public static string AssemblyVersion
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _AssemblyVersion;
|
return _AssemblyVersion;
|
||||||
}
|
}
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
_AssemblyVersion = value;
|
_AssemblyVersion = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the Assembly version to the version of the Essentials Library
|
/// Sets the Assembly version to the version of the Essentials Library
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assemblyVersion"></param>
|
/// <param name="assemblyVersion"></param>
|
||||||
public static void SetAssemblyVersion(string assemblyVersion)
|
public static void SetAssemblyVersion(string assemblyVersion)
|
||||||
{
|
{
|
||||||
AssemblyVersion = assemblyVersion;
|
AssemblyVersion = assemblyVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true.
|
/// Checks to see if the running version meets or exceed the minimum specified version. For beta versions (0.xx.yy), will always return true.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="minimumVersion">Minimum specified version in format of xx.yy.zz</param>
|
/// <param name="minimumVersion">Minimum specified version in format of xx.yy.zz</param>
|
||||||
/// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns>
|
/// <returns>Returns true if the running version meets or exceeds the minimum specified version</returns>
|
||||||
public static bool IsRunningMinimumVersionOrHigher(string minimumVersion)
|
public static bool IsRunningMinimumVersionOrHigher(string minimumVersion)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
|
Debug.Console(2, "Comparing running version '{0}' to minimum version '{1}'", AssemblyVersion, minimumVersion);
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(minimumVersion))
|
if (String.IsNullOrEmpty(minimumVersion))
|
||||||
{
|
{
|
||||||
Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
|
Debug.Console(0,"Plugin does not specify a minimum version. Loading plugin may not work as expected. Proceeding with loading plugin");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*");
|
var runtimeVersion = Regex.Match(AssemblyVersion, @"^(\d*).(\d*).(\d*).*");
|
||||||
|
|
||||||
var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value);
|
var runtimeVersionMajor = Int16.Parse(runtimeVersion.Groups[1].Value);
|
||||||
var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value);
|
var runtimeVersionMinor = Int16.Parse(runtimeVersion.Groups[2].Value);
|
||||||
var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value);
|
var runtimeVersionBuild = Int16.Parse(runtimeVersion.Groups[3].Value);
|
||||||
|
|
||||||
var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild);
|
var runtimeVer = new Version(runtimeVersionMajor, runtimeVersionMinor, runtimeVersionBuild);
|
||||||
|
|
||||||
Version minimumVer;
|
Version minimumVer;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
minimumVer = new Version(minimumVersion);
|
minimumVer = new Version(minimumVersion);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
|
Debug.Console(2, "unable to parse minimum version {0}. Bypassing plugin load.", minimumVersion);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for beta build version
|
// Check for beta build version
|
||||||
if (runtimeVer.Major != 0)
|
if (runtimeVer.Major != 0)
|
||||||
{
|
{
|
||||||
return runtimeVer.CompareTo(minimumVer) >= 0;
|
return runtimeVer.CompareTo(minimumVer) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
|
Debug.Console(2, "Running Local Build. Bypassing Dependency Check.");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$");
|
var minVersion = Regex.Match(minimumVersion, @"^(\d*).(\d*).(\d*)$");
|
||||||
|
|
||||||
if(!minVersion.Success)
|
if(!minVersion.Success)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value);
|
var minVersionMajor = Int16.Parse(minVersion.Groups[1].Value);
|
||||||
var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value);
|
var minVersionMinor = Int16.Parse(minVersion.Groups[2].Value);
|
||||||
var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value);
|
var minVersionBuild = Int16.Parse(minVersion.Groups[3].Value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (minVersionMajor > runtimeVersionMajor)
|
if (minVersionMajor > runtimeVersionMajor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (minVersionMinor > runtimeVersionMinor)
|
if (minVersionMinor > runtimeVersionMinor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (minVersionBuild > runtimeVersionBuild)
|
if (minVersionBuild > runtimeVersionBuild)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static Global()
|
static Global()
|
||||||
{
|
{
|
||||||
// Fire up CrestronDataStoreStatic
|
// Fire up CrestronDataStoreStatic
|
||||||
var err = CrestronDataStoreStatic.InitCrestronDataStore();
|
var err = CrestronDataStoreStatic.InitCrestronDataStore();
|
||||||
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
if (err != CrestronDataStore.CDS_ERROR.CDS_SUCCESS)
|
||||||
{
|
{
|
||||||
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
|
CrestronConsole.PrintLine("Error starting CrestronDataStoreStatic: {0}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,6 +224,7 @@
|
|||||||
<Compile Include="Fusion\FusionRviDataClasses.cs" />
|
<Compile Include="Fusion\FusionRviDataClasses.cs" />
|
||||||
<Compile Include="Gateways\CenRfgwController.cs" />
|
<Compile Include="Gateways\CenRfgwController.cs" />
|
||||||
<Compile Include="Gateways\EssentialsRfGatewayConfig.cs" />
|
<Compile Include="Gateways\EssentialsRfGatewayConfig.cs" />
|
||||||
|
<Compile Include="Global\EthernetAdapterInfo.cs" />
|
||||||
<Compile Include="Queues\ComsMessage.cs" />
|
<Compile Include="Queues\ComsMessage.cs" />
|
||||||
<Compile Include="Queues\ProcessStringMessage.cs" />
|
<Compile Include="Queues\ProcessStringMessage.cs" />
|
||||||
<Compile Include="Queues\GenericQueue.cs" />
|
<Compile Include="Queues\GenericQueue.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user