mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
fix: Fixed CrestronRuntimeEnvironment uses in utils
This commit is contained in:
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
- 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
|
||||
### Changed
|
||||
|
||||
@@ -94,13 +94,17 @@ namespace ICD.Common.Utils
|
||||
[PublicAPI]
|
||||
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())
|
||||
message = string.Format(message, args);
|
||||
|
||||
message = FixLineEndings(message);
|
||||
|
||||
#if !NETSTANDARD
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Appliance)
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.SimplSharpPro)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -125,7 +129,7 @@ namespace ICD.Common.Utils
|
||||
try
|
||||
{
|
||||
#if !NETSTANDARD
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform != IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
CrestronConsole.PrintLine(fixedMessage);
|
||||
#else
|
||||
Trace.WriteLine(AnsiUtils.StripAnsi(fixedMessage));
|
||||
@@ -169,7 +173,7 @@ namespace ICD.Common.Utils
|
||||
try
|
||||
{
|
||||
#if !NETSTANDARD
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment != IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform != IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
CrestronConsole.Print(fixedMessage);
|
||||
#else
|
||||
Trace.Write(AnsiUtils.StripAnsi(fixedMessage));
|
||||
@@ -207,8 +211,8 @@ namespace ICD.Common.Utils
|
||||
public static bool SendControlSystemCommand(string command, ref string result)
|
||||
{
|
||||
#if !NETSTANDARD
|
||||
// No console on VC4
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
// No console on Crestron Server
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return false;
|
||||
|
||||
return CrestronConsole.SendControlSystemCommand(command, ref result);
|
||||
@@ -221,7 +225,11 @@ namespace ICD.Common.Utils
|
||||
{
|
||||
#if !NETSTANDARD
|
||||
// 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;
|
||||
|
||||
if (CrestronConsole.ConsoleRegistered)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ICD.Common.Utils
|
||||
public static string RootPath {
|
||||
get
|
||||
{
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return IcdDirectory.GetApplicationRootDirectory();
|
||||
|
||||
return IcdDirectory.GetDirectoryRoot(IcdPath.DirectorySeparatorChar.ToString());
|
||||
@@ -63,13 +63,14 @@ namespace ICD.Common.Utils
|
||||
get
|
||||
{
|
||||
#if !NETSTANDARD
|
||||
switch (IcdEnvironment.CrestronSeries)
|
||||
{
|
||||
case IcdEnvironment.eCrestronSeries.FourSeries:
|
||||
return Join(RootPath, "user");
|
||||
default:
|
||||
return Join(RootPath, "User");
|
||||
}
|
||||
|
||||
// Server uses "User" and rest of the e-seres uses "user" :facepalm:
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return Join(RootPath, "User");
|
||||
|
||||
// Rest of processors
|
||||
// 3-series traditionally used "User", but isn't case sensitive
|
||||
return Join(RootPath, "user");
|
||||
#elif LINUX
|
||||
return Join(RootPath, "opt", "ICD.Connect");
|
||||
#else
|
||||
@@ -94,7 +95,7 @@ namespace ICD.Common.Utils
|
||||
get
|
||||
{
|
||||
// Crestron Server doesn't have meaningful program number
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return "ProgramConfig";
|
||||
|
||||
return string.Format("Program{0:D2}Config", ProgramUtils.ProgramNumber);
|
||||
@@ -117,7 +118,7 @@ namespace ICD.Common.Utils
|
||||
get
|
||||
{
|
||||
// Crestron Server doesn't have meaningful program number
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return "ProgramData";
|
||||
|
||||
return string.Format("Program{0:D2}Data", ProgramUtils.ProgramNumber);
|
||||
@@ -157,7 +158,7 @@ namespace ICD.Common.Utils
|
||||
string directoryName;
|
||||
|
||||
// Crestron Server doesn't have meaningful program number
|
||||
if (IcdEnvironment.CrestronRuntimeEnvironment == IcdEnvironment.eCrestronRuntimeEnvironment.Server)
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
directoryName = "ProgramLogs";
|
||||
else
|
||||
directoryName = string.Format("Program{0:D2}Logs", ProgramUtils.ProgramNumber);
|
||||
@@ -181,12 +182,13 @@ namespace ICD.Common.Utils
|
||||
if (IcdEnvironment.CrestronSeries == IcdEnvironment.eCrestronSeries.ThreeSeries)
|
||||
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)
|
||||
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
|
||||
|
||||
@@ -24,19 +24,20 @@ namespace ICD.Common.Utils
|
||||
switch (IcdEnvironment.Framework)
|
||||
{
|
||||
case IcdEnvironment.eFramework.Crestron:
|
||||
// No console in servers
|
||||
if (IcdEnvironment.CrestronDevicePlatform == IcdEnvironment.eCrestronDevicePlatform.Server)
|
||||
return;
|
||||
|
||||
switch (IcdEnvironment.CrestronRuntimeEnvironment)
|
||||
{
|
||||
case IcdEnvironment.eCrestronRuntimeEnvironment.Simpl:
|
||||
case IcdEnvironment.eCrestronRuntimeEnvironment.SimplPlus:
|
||||
int length = Math.Min(13, name.Length);
|
||||
name = name.Substring(0, length).PadRight(13);
|
||||
break;
|
||||
case IcdEnvironment.eCrestronRuntimeEnvironment.Appliance:
|
||||
case IcdEnvironment.eCrestronRuntimeEnvironment.SimplSharpPro:
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user