From 33c3aa99791dd3ce4cefe67e35e50b630da16d85 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 15 Jun 2022 11:16:45 -0500 Subject: [PATCH] feat: added roomName reporting to EvaluateFile, updated constants used by JSON wrapper modules, refactored programCompatibility checks --- .../Pepperdash Core/JsonToSimpl/Constants.cs | 24 +++++++---- .../JsonToSimpl/JsonToSimplFileMaster.cs | 41 ++++++++++++------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Pepperdash Core/Pepperdash Core/JsonToSimpl/Constants.cs b/Pepperdash Core/Pepperdash Core/JsonToSimpl/Constants.cs index e69efb0..0bf9872 100644 --- a/Pepperdash Core/Pepperdash Core/JsonToSimpl/Constants.cs +++ b/Pepperdash Core/Pepperdash Core/JsonToSimpl/Constants.cs @@ -21,19 +21,24 @@ namespace PepperDash.Core.JsonToSimpl public const ushort JsonIsValidBoolChange = 2; /// - /// + /// Reports the if the device is 3-series compatible /// - public const ushort UshortValueChange = 101; + public const ushort ProgramCompatibility3SeriesChange = 3; /// - /// Reports the Crestron Series enum value + /// Reports the if the device is 4-series compatible /// - public const ushort CrestronSeriesValueChange = 102; + public const ushort ProgramCompatibility4SeriesChange = 4; /// /// Reports the device platform enum value /// - public const ushort DevicePlatformValueChange = 103; + public const ushort DevicePlatformValueChange = 5; + + /// + /// + /// + public const ushort UshortValueChange = 101; /// /// @@ -58,14 +63,19 @@ namespace PepperDash.Core.JsonToSimpl public const ushort FilePathResolvedChange = 205; /// - /// Reports the root directory + /// Reports the root directory change /// public const ushort RootDirectoryChange = 206; /// - /// Reports the room ID + /// Reports the room ID change /// public const ushort RoomIdChange = 207; + + /// + /// Reports the room name change + /// + public const ushort RoomNameChange = 208; } /// diff --git a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFileMaster.cs b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFileMaster.cs index 9906462..c5f50d5 100644 --- a/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFileMaster.cs +++ b/Pepperdash Core/Pepperdash Core/JsonToSimpl/JsonToSimplFileMaster.cs @@ -66,15 +66,33 @@ namespace PepperDash.Core.JsonToSimpl var dirSeparator = Path.DirectorySeparatorChar; var dirSeparatorAlt = Path.AltDirectorySeparatorChar; - var is4Series = CrestronEnvironment.ProgramCompatibility == eCrestronSeries.Series4; - var isServer = CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; + var series = CrestronEnvironment.ProgramCompatibility; - OnUshrtChange((ushort)CrestronEnvironment.ProgramCompatibility, 0, - JsonToSimplConstants.CrestronSeriesValueChange); - - OnUshrtChange((ushort) CrestronEnvironment.DevicePlatform, 0, + var is3Series = (eCrestronSeries.Series3 == (series & eCrestronSeries.Series3)); + OnBoolChange(is3Series, 0, + JsonToSimplConstants.ProgramCompatibility3SeriesChange); + + var is4Series = (eCrestronSeries.Series4 == (series & eCrestronSeries.Series4)); + OnBoolChange(is4Series, 0, + JsonToSimplConstants.ProgramCompatibility4SeriesChange); + + var isServer = CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; + OnBoolChange(isServer, 0, JsonToSimplConstants.DevicePlatformValueChange); - + + // get the roomID + var roomId = Crestron.SimplSharp.InitialParametersClass.RoomId; + if (!string.IsNullOrEmpty(roomId)) + { + OnStringChange(roomId, 0, JsonToSimplConstants.RoomIdChange); + } + + // get the roomName + var roomName = Crestron.SimplSharp.InitialParametersClass.RoomName; + if (!string.IsNullOrEmpty(roomName)) + { + OnStringChange(roomName, 0, JsonToSimplConstants.RoomNameChange); + } var rootDirectory = Directory.GetApplicationRootDirectory(); OnStringChange(rootDirectory, 0, JsonToSimplConstants.RootDirectoryChange); @@ -114,14 +132,7 @@ namespace PepperDash.Core.JsonToSimpl if (Directory.Exists(fileDirectory)) { // get the directory info - var directoryInfo = new DirectoryInfo(fileDirectory); - - // get the roomID - if (!string.IsNullOrEmpty(rootDirectory)) - { - var roomId = directoryInfo.Name; - OnStringChange(roomId, 0, JsonToSimplConstants.RoomIdChange); - } + var directoryInfo = new DirectoryInfo(fileDirectory); // get the file to be read var actualFile = directoryInfo.GetFiles(fileName).FirstOrDefault();