diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48aba0a..5170cca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,7 +17,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added eDaysOfWeek flags enum
- Added support for reading the primitive type double to IcdXmlReader and XmlUtils
- Added ProcessorUtils.GetSystemStartTime() to get DateTime the system started instead of a TimeSpan
- - Added SimplSharpMono environment to IcdEnvironment, for non-pro 4-series environment
### Changed
- Repeater changed to use configured callbacks instead of a dumb event
@@ -25,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Handling a Crestron bug where File.Exists throws an exception on 4-Series instead of returning false
- Changed ProcessorUtils.ModelVersion to be a string, Crestron pulls model version from CrestronEnvironment
- For 4-series console outputs, replacing \n with \r\n to help console readability
+ - Changed RuntimeEnvironment to be 3 variables - Framework for Crestron vs Standard, CrestronSeries for 3 vs 4, and CrestronRuntimeEnvironment for Simpl vs SimplSharpPro vs Server
## [13.0.0] - 2020-09-03
### Added
diff --git a/ICD.Common.Utils/IcdConsole.cs b/ICD.Common.Utils/IcdConsole.cs
index 5a529bf..1edbc2b 100644
--- a/ICD.Common.Utils/IcdConsole.cs
+++ b/ICD.Common.Utils/IcdConsole.cs
@@ -62,8 +62,7 @@ namespace ICD.Common.Utils
message = FixLineEndings(message);
#if SIMPLSHARP
- if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpPro ||
- IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono)
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance)
{
try
{
@@ -89,7 +88,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
- if (IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer)
+ if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server)
CrestronConsole.PrintLine(fixedMessage);
#else
Console.WriteLine(fixedMessage);
@@ -130,7 +129,7 @@ namespace ICD.Common.Utils
try
{
#if SIMPLSHARP
- if (IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer)
+ if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server)
CrestronConsole.Print(fixedMessage);
#else
Console.Write(message);
@@ -166,7 +165,7 @@ namespace ICD.Common.Utils
{
#if SIMPLSHARP
// No console on VC4
- if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer)
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
return false;
return CrestronConsole.SendControlSystemCommand(command, ref result);
@@ -179,8 +178,7 @@ namespace ICD.Common.Utils
{
#if SIMPLSHARP
// Avoid crashing Simpl applications
- if (IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpPro &&
- IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono)
+ if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Appliance)
return false;
if (CrestronConsole.ConsoleRegistered)
@@ -203,8 +201,7 @@ namespace ICD.Common.Utils
///
private static string FixLineEndings(string input)
{
- if (IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono
- && IcdEnvironment.RuntimeEnvironment != IcdEnvironment.eRuntimeEnvironment.SimplSharpMono)
+ if (IcdEnvironment.CrestronSeries != IcdEnvironment.eCrestronSeries.FourSeries)
return input;
return s_NewLineRegex.Replace(input, NEWLINE);
diff --git a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
index 397c800..a30fb96 100644
--- a/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
+++ b/ICD.Common.Utils/IcdEnvironment.SimplSharp.cs
@@ -14,14 +14,10 @@ namespace ICD.Common.Utils
///
private const string INVALID_VALUE = "Invalid Value";
- private static eRuntimeEnvironment s_RuntimeEnvironment;
-
#region Properties
public static string NewLine { get { return CrestronEnvironment.NewLine; } }
- public static eRuntimeEnvironment RuntimeEnvironment { get { return s_RuntimeEnvironment; } }
-
///
/// Gets the network address(es) of the processor.
///
@@ -197,10 +193,16 @@ namespace ICD.Common.Utils
static IcdEnvironment()
{
// Cache the runtime environment
- s_RuntimeEnvironment =
- CrestronEnvironment.DevicePlatform == eDevicePlatform.Server
- ? eRuntimeEnvironment.SimplSharpProServer
- : GetRuntimeEnvironment(CrestronEnvironment.RuntimeEnvironment, Type.GetType("Mono.Runtime") != null);
+ s_Framework = eFramework.Crestron;
+
+ if (CrestronEnvironment.RuntimeEnvironment == eRuntimeEnvironment.SIMPL)
+ s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Simpl;
+ else if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance)
+ s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Appliance;
+ else
+ s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Server;
+
+ s_CrestronSeries = Type.GetType("Mono.Runtime") != null ? eCrestronSeries.FourSeries : eCrestronSeries.ThreeSeries;
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironmentOnProgramStatusEventHandler;
CrestronEnvironment.EthernetEventHandler += CrestronEnvironmentOnEthernetEventHandler;
@@ -258,19 +260,6 @@ namespace ICD.Common.Utils
}
}
- private static eRuntimeEnvironment GetRuntimeEnvironment(Crestron.SimplSharp.eRuntimeEnvironment runtimeEnvironment, bool mono)
- {
- switch (runtimeEnvironment)
- {
- case Crestron.SimplSharp.eRuntimeEnvironment.SIMPL:
- return mono ? eRuntimeEnvironment.SimplSharpMono : eRuntimeEnvironment.SimplSharp;
- case Crestron.SimplSharp.eRuntimeEnvironment.SimplSharpPro:
- return mono ? eRuntimeEnvironment.SimplSharpProMono : eRuntimeEnvironment.SimplSharpPro;
- default:
- throw new ArgumentOutOfRangeException("runtimeEnvironment");
- }
- }
-
#endregion
#region Private Methods
diff --git a/ICD.Common.Utils/IcdEnvironment.Standard.cs b/ICD.Common.Utils/IcdEnvironment.Standard.cs
index fcccc2e..60f1ae7 100644
--- a/ICD.Common.Utils/IcdEnvironment.Standard.cs
+++ b/ICD.Common.Utils/IcdEnvironment.Standard.cs
@@ -14,8 +14,6 @@ namespace ICD.Common.Utils
{
public static string NewLine { get { return Environment.NewLine; } }
- public static eRuntimeEnvironment RuntimeEnvironment { get { return eRuntimeEnvironment.Standard; } }
-
///
/// Gets the network address(es) of the processor.
///
@@ -88,6 +86,13 @@ namespace ICD.Common.Utils
[PublicAPI]
public static IEnumerable Hostnames { get { yield return Dns.GetHostName(); } }
+ static IcdEnvironment()
+ {
+ s_Framework = eFramework.Standard;
+ s_CrestronSeries = eCrestronSeries.Na;
+ s_CrestronRuntimeEnvironment = eCrestronRuntimeEnvironment.Na;
+ }
+
public static DateTime GetLocalTime()
{
return DateTime.Now;
diff --git a/ICD.Common.Utils/IcdEnvironment.cs b/ICD.Common.Utils/IcdEnvironment.cs
index 60682ae..0d78522 100644
--- a/ICD.Common.Utils/IcdEnvironment.cs
+++ b/ICD.Common.Utils/IcdEnvironment.cs
@@ -7,18 +7,35 @@ namespace ICD.Common.Utils
public static partial class IcdEnvironment
{
///
- /// Enumeration to define the various runtime environments a module can run in.
+ /// Enumeration to define the various frameworks a module can run in.
///
- public enum eRuntimeEnvironment
+ public enum eFramework
{
- SimplSharp,
- SimplSharpMono,
- SimplSharpPro,
- SimplSharpProMono,
- SimplSharpProServer,
+ Crestron,
Standard
}
+ ///
+ /// Enumeration to define the Crestron series a module can run it
+ ///
+ public enum eCrestronSeries
+ {
+ Na, //Non-Crestron
+ ThreeSeries,
+ FourSeries
+ }
+
+ ///
+ /// Enumeration to define the various Crestron runtime environments a module can run in
+ ///
+ public enum eCrestronRuntimeEnvironment
+ {
+ Na, //Non-Crestron
+ Simpl, // Running in Simpl, Non-Pro
+ Appliance, // S#Pro running on a Crestron hardware appliance
+ Server // S#Pro running on a server (VC-4)
+ }
+
///
/// Enum for the Program Event Types
///
@@ -69,9 +86,19 @@ namespace ICD.Common.Utils
///
public static event EventHandler OnSystemDateTimeChanged;
+ private static eFramework s_Framework;
+
+ private static eCrestronSeries s_CrestronSeries;
+
+ private static eCrestronRuntimeEnvironment s_CrestronRuntimeEnvironment;
+
private static readonly SafeCriticalSection s_ProgramInitializationSection = new SafeCriticalSection();
private static bool s_ProgramInitializationComplete;
+ public static eFramework Framework {get { return s_Framework; }}
+ public static eCrestronSeries CrestronSeries {get { return s_CrestronSeries; }}
+ public static eCrestronRuntimeEnvironment CrestronRuntimeEnvironment {get { return s_CrestronRuntimeEnvironment; }}
+
///
/// Returns true if the program has been flagged as completely initialized.
///
diff --git a/ICD.Common.Utils/IcdErrorLog.cs b/ICD.Common.Utils/IcdErrorLog.cs
index 93a7862..9059bd6 100644
--- a/ICD.Common.Utils/IcdErrorLog.cs
+++ b/ICD.Common.Utils/IcdErrorLog.cs
@@ -160,28 +160,26 @@ namespace ICD.Common.Utils
if (args.Length > 0)
message = string.Format(message, args);
- switch (IcdEnvironment.RuntimeEnvironment)
+ if (IcdEnvironment.Framework == IcdEnvironment.eFramework.Standard)
{
- case IcdEnvironment.eRuntimeEnvironment.Standard:
- // Prepend the exception type, append the stack trace
- if (exception != null)
- message = string.Format("{0}: {1}{2}{3}",
- exception.GetType().Name,
- message,
- IcdEnvironment.NewLine,
- exception.StackTrace);
+ // Prepend the exception type, append the stack trace
+ if (exception != null)
+ message = string.Format("{0}: {1}{2}{3}",
+ exception.GetType().Name,
+ message,
+ IcdEnvironment.NewLine,
+ exception.StackTrace);
- // Prefix severity and time
- string fixedSeverity = severity.Substring(0, Math.Min(6, severity.Length));
- fixedSeverity = string.Format("{0,-6}", fixedSeverity);
- message = string.Format("{0} - {1} - {2}", fixedSeverity, IcdEnvironment.GetLocalTime(), message);
- break;
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- // Add an extra newline
- message += IcdEnvironment.NewLine;
- break;
+ // Prefix severity and time
+ string fixedSeverity = severity.Substring(0, Math.Min(6, severity.Length));
+ fixedSeverity = string.Format("{0,-6}", fixedSeverity);
+ message = string.Format("{0} - {1} - {2}", fixedSeverity, IcdEnvironment.GetLocalTime(), message);
+
}
+ // Add an extra newline for 4-series to help formatting
+ else if(IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.FourSeries)
+ message += IcdEnvironment.NewLine;
+
// Color formatting
return s_SeverityToColor[severity].FormatAnsi(message);
diff --git a/ICD.Common.Utils/PathUtils.cs b/ICD.Common.Utils/PathUtils.cs
index fad31e3..cae0434 100644
--- a/ICD.Common.Utils/PathUtils.cs
+++ b/ICD.Common.Utils/PathUtils.cs
@@ -26,7 +26,7 @@ namespace ICD.Common.Utils
public static string RootPath {
get
{
- if (IcdEnvironment.RuntimeEnvironment == IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer)
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
return IcdDirectory.GetApplicationRootDirectory();
return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString());
@@ -63,10 +63,9 @@ namespace ICD.Common.Utils
get
{
#if SIMPLSHARP
- switch (IcdEnvironment.RuntimeEnvironment)
+ switch (IcdEnvironment.CrestronSeries)
{
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
+ case IcdEnvironment.eCrestronSeries.FourSeries:
return Join(RootPath, "user");
default:
return Join(RootPath, "User");
@@ -94,21 +93,11 @@ namespace ICD.Common.Utils
{
get
{
- switch (IcdEnvironment.RuntimeEnvironment)
- {
- case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- case IcdEnvironment.eRuntimeEnvironment.Standard:
- return string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer:
- return "ProgramConfig";
-
- default:
- throw new ArgumentOutOfRangeException();
- }
+ // Crestron Server doesn't have meaningful program number
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
+ return "ProgramConfig";
+
+ return string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
}
}
@@ -127,21 +116,11 @@ namespace ICD.Common.Utils
{
get
{
- switch (IcdEnvironment.RuntimeEnvironment)
- {
- case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- case IcdEnvironment.eRuntimeEnvironment.Standard:
- return string.Format("Program{0:D2}Data", ProgramUtils.ProgramNumber);
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer:
- return "ProgramData";
-
- default:
- throw new ArgumentOutOfRangeException();
- }
+ // Crestron Server doesn't have meaningful program number
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
+ return "ProgramData";
+
+ return string.Format("Program{0:D2}Data", ProgramUtils.ProgramNumber);
}
}
@@ -177,23 +156,11 @@ namespace ICD.Common.Utils
{
string directoryName;
- switch (IcdEnvironment.RuntimeEnvironment)
- {
- case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- case IcdEnvironment.eRuntimeEnvironment.Standard:
- directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber);
- break;
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer:
- directoryName = "ProgramLogs";
- break;
-
- default:
- throw new ArgumentOutOfRangeException();
- }
+ // Crestron Server doesn't have meaningful program number
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
+ directoryName = "ProgramLogs";
+ else
+ directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber);
return Join(RootConfigPath, directoryName);
}
@@ -208,29 +175,25 @@ namespace ICD.Common.Utils
{
get
{
- switch (IcdEnvironment.RuntimeEnvironment)
+ if (IcdEnvironment.Framework == IcdEnvironment.eFramework.Crestron)
{
- case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
+ // 3-series
+ if (IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.ThreeSeries)
return Join(RootPath, "HTML");
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
+
+ // 4-series non-server (because Crestron)
+ if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance)
return Join(RootPath, "html");
+
+ // 4-series server (because Crestron)
+ return Join(RootPath, "Html");
+ }
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer:
- return Join(RootPath, "Html");
-
- case IcdEnvironment.eRuntimeEnvironment.Standard:
#if LINUX
return Join(RootPath, "var", "www", "html");
#else
return "C:\\INetPub";
#endif
-
- default:
- throw new ArgumentOutOfRangeException();
- }
}
}
diff --git a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
index e2e37b7..f42b52c 100644
--- a/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
+++ b/ICD.Common.Utils/ProcessorUtils.SimplSharp.cs
@@ -109,16 +109,13 @@ namespace ICD.Common.Utils
try
{
- switch (IcdEnvironment.RuntimeEnvironment)
+ if (IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.FourSeries)
{
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- date = StringUtils.RemoveDuplicateWhitespace(date);
- return DateTime.ParseExact(date, "MMM d yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
-
- default:
- return DateTime.ParseExact(date, "MMM dd yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
+ date = StringUtils.RemoveDuplicateWhitespace(date);
+ return DateTime.ParseExact(date, "MMM d yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
}
+
+ return DateTime.ParseExact(date, "MMM dd yyyy", CultureInfo.InvariantCulture).ToUniversalTime();
}
catch (FormatException)
{
diff --git a/ICD.Common.Utils/ProgramUtils.cs b/ICD.Common.Utils/ProgramUtils.cs
index 0cd69c8..e8a7c5e 100644
--- a/ICD.Common.Utils/ProgramUtils.cs
+++ b/ICD.Common.Utils/ProgramUtils.cs
@@ -21,28 +21,29 @@ namespace ICD.Common.Utils
{
name = (name ?? string.Empty).Trim();
- switch (IcdEnvironment.RuntimeEnvironment)
+ switch (IcdEnvironment.Framework)
{
- case IcdEnvironment.eRuntimeEnvironment.SimplSharp:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpMono:
- int length = Math.Min(13, name.Length);
- name = name.Substring(0, length).PadRight(13);
+ case IcdEnvironment.eFramework.Crestron:
+ switch (IcdEnvironment.CrestronRuntimeEnvironment)
+ {
+ case IcdEnvironment.eCrestronRuntimeEnvironment.Simpl:
+ int length = Math.Min(13, name.Length);
+ name = name.Substring(0, length).PadRight(13);
+ break;
+ case IcdEnvironment.eCrestronRuntimeEnvironment.Appliance:
+ int proLength = Math.Min(26 - 1, name.Length);
+ name = name.Substring(0, proLength).PadRight(26);
+ break;
+ case IcdEnvironment.eCrestronRuntimeEnvironment.Server:
+ // No console
+ return;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
break;
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpPro:
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProMono:
- int proLength = Math.Min(26 - 1, name.Length);
- name = name.Substring(0, proLength).PadRight(26);
- break;
-
- case IcdEnvironment.eRuntimeEnvironment.SimplSharpProServer:
- // No console
- return;
-
- case IcdEnvironment.eRuntimeEnvironment.Standard:
+ case IcdEnvironment.eFramework.Standard:
name += ' ';
break;
-
default:
throw new ArgumentOutOfRangeException();
}