fix: Fixed CrestronRuntimeEnvironment uses in utils

This commit is contained in:
Drew Tingen
2022-11-30 12:08:10 -05:00
parent 1c206c5539
commit b09b22266b
4 changed files with 39 additions and 27 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- IcdEnvironment - Added CrestronDevicePlatform, removed from CrestronRuntimeEnvironment, to support SimplWindows on VC-4 - IcdEnvironment - Added CrestronDevicePlatform, removed from CrestronRuntimeEnvironment, to support SimplWindows on VC-4
- Fixed IcdEnvironment CrestronRuntimeEnvironment uses in IcdConsole, PathUtils, and ProgramUtils
## [16.0.5] 2022-07-11 ## [16.0.5] 2022-07-11
### Changed ### Changed

View File

@@ -94,13 +94,17 @@ namespace ICD.Common.Utils
[PublicAPI] [PublicAPI]
public static void ConsoleCommandResponse(string message, params object[] args) public static void ConsoleCommandResponse(string message, params object[] args)
{ {
// No console in Server
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return;
if (args != null && args.Any()) if (args != null && args.Any())
message = string.Format(message, args); message = string.Format(message, args);
message = FixLineEndings(message); message = FixLineEndings(message);
#if !NETSTANDARD #if !NETSTANDARD
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance) if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.SimplSharpPro)
{ {
try try
{ {
@@ -125,7 +129,7 @@ namespace ICD.Common.Utils
try try
{ {
#if !NETSTANDARD #if !NETSTANDARD
if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform != IcdEnvironment.eCrestronDevicePlatform.Server)
CrestronConsole.PrintLine(fixedMessage); CrestronConsole.PrintLine(fixedMessage);
#else #else
Trace.WriteLine(AnsiUtils.StripAnsi(fixedMessage)); Trace.WriteLine(AnsiUtils.StripAnsi(fixedMessage));
@@ -169,7 +173,7 @@ namespace ICD.Common.Utils
try try
{ {
#if !NETSTANDARD #if !NETSTANDARD
if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform != IcdEnvironment.eCrestronDevicePlatform.Server)
CrestronConsole.Print(fixedMessage); CrestronConsole.Print(fixedMessage);
#else #else
Trace.Write(AnsiUtils.StripAnsi(fixedMessage)); Trace.Write(AnsiUtils.StripAnsi(fixedMessage));
@@ -207,8 +211,8 @@ namespace ICD.Common.Utils
public static bool SendControlSystemCommand(string command, ref string result) public static bool SendControlSystemCommand(string command, ref string result)
{ {
#if !NETSTANDARD #if !NETSTANDARD
// No console on VC4 // No console on Crestron Server
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return false; return false;
return CrestronConsole.SendControlSystemCommand(command, ref result); return CrestronConsole.SendControlSystemCommand(command, ref result);
@@ -221,7 +225,11 @@ namespace ICD.Common.Utils
{ {
#if !NETSTANDARD #if !NETSTANDARD
// Avoid crashing Simpl applications // Avoid crashing Simpl applications
if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Appliance) if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.SimplSharpPro)
return false;
// No console in Crestron Server
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return false; return false;
if (CrestronConsole.ConsoleRegistered) if (CrestronConsole.ConsoleRegistered)

View File

@@ -26,7 +26,7 @@ namespace ICD.Common.Utils
public static string RootPath { public static string RootPath {
get get
{ {
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return IcdDirectory.GetApplicationRootDirectory(); return IcdDirectory.GetApplicationRootDirectory();
return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString()); return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString());
@@ -63,13 +63,14 @@ namespace ICD.Common.Utils
get get
{ {
#if !NETSTANDARD #if !NETSTANDARD
switch (IcdEnvironment.CrestronSeries)
{ // Server uses "User" and rest of the e-seres uses "user" :facepalm:
case IcdEnvironment.eCrestronSeries.FourSeries: if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return Join(RootPath, "user"); return Join(RootPath, "User");
default:
return Join(RootPath, "User"); // Rest of processors
} // 3-series traditionally used "User", but isn't case sensitive
return Join(RootPath, "user");
#elif LINUX #elif LINUX
return Join(RootPath, "opt", "ICD.Connect"); return Join(RootPath, "opt", "ICD.Connect");
#else #else
@@ -94,7 +95,7 @@ namespace ICD.Common.Utils
get get
{ {
// Crestron Server doesn't have meaningful program number // Crestron Server doesn't have meaningful program number
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return "ProgramConfig"; return "ProgramConfig";
return string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber); return string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
@@ -117,7 +118,7 @@ namespace ICD.Common.Utils
get get
{ {
// Crestron Server doesn't have meaningful program number // Crestron Server doesn't have meaningful program number
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return "ProgramData"; return "ProgramData";
return string.Format("Program{0:D2}Data", ProgramUtils.ProgramNumber); return string.Format("Program{0:D2}Data", ProgramUtils.ProgramNumber);
@@ -157,7 +158,7 @@ namespace ICD.Common.Utils
string directoryName; string directoryName;
// Crestron Server doesn't have meaningful program number // Crestron Server doesn't have meaningful program number
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server) if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
directoryName = "ProgramLogs"; directoryName = "ProgramLogs";
else else
directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber); directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber);
@@ -181,12 +182,13 @@ namespace ICD.Common.Utils
if (IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.ThreeSeries) if (IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.ThreeSeries)
return Join(RootPath, "HTML"); return Join(RootPath, "HTML");
// 4-series non-server (because Crestron)
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance)
return Join(RootPath, "html");
// 4-series server (because Crestron) // 4-series server (because Crestron)
return Join(RootPath, "Html"); if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return Join(RootPath, "Html");
// 4-series non-server (because Crestron)
return Join(RootPath, "html");
} }
#if LINUX #if LINUX

View File

@@ -24,19 +24,20 @@ namespace ICD.Common.Utils
switch (IcdEnvironment.Framework) switch (IcdEnvironment.Framework)
{ {
case IcdEnvironment.eFramework.Crestron: case IcdEnvironment.eFramework.Crestron:
// No console in servers
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
return;
switch (IcdEnvironment.CrestronRuntimeEnvironment) switch (IcdEnvironment.CrestronRuntimeEnvironment)
{ {
case IcdEnvironment.eCrestronRuntimeEnvironment.Simpl: case IcdEnvironment.eCrestronRuntimeEnvironment.SimplPlus:
int length = Math.Min(13, name.Length); int length = Math.Min(13, name.Length);
name = name.Substring(0, length).PadRight(13); name = name.Substring(0, length).PadRight(13);
break; break;
case IcdEnvironment.eCrestronRuntimeEnvironment.Appliance: case IcdEnvironment.eCrestronRuntimeEnvironment.SimplSharpPro:
int proLength = Math.Min(26 - 1, name.Length); int proLength = Math.Min(26 - 1, name.Length);
name = name.Substring(0, proLength).PadRight(26); name = name.Substring(0, proLength).PadRight(26);
break; break;
case IcdEnvironment.eCrestronRuntimeEnvironment.Server:
// No console
return;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }