From 8d215930d9c2cb28796dc0872cc7e32681d83300 Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Tue, 11 May 2021 15:20:35 -0400 Subject: [PATCH 1/5] Adds WriteControlProperty to ReconfigurableDevice CameraBase now uses ReconfigurableDevice --- .../Devices/ReconfigurableDevice.cs | 8 +++++++ .../Cameras/CameraBase.cs | 22 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs index 7b4f1c99..60c8db0c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs @@ -7,6 +7,8 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace PepperDash.Essentials.Core.Devices { @@ -52,6 +54,12 @@ namespace PepperDash.Essentials.Core.Devices Name = config.Name; } + protected virtual void WriteControlProperty(JToken controlObject) + { + Config.Properties["control"] = JToken.FromObject(controlObject); + CustomSetConfig(Config); + } + /// /// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc) /// diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs index 8b42cd82..edfd34cb 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs @@ -8,6 +8,8 @@ using Crestron.SimplSharp.Reflection; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Devices; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Devices.Common.Codec; @@ -25,7 +27,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras Focus = 8 } - public abstract class CameraBase : EssentialsDevice, IRoutingOutputs + public abstract class CameraBase : ReconfigurableDevice, IRoutingOutputs { public eCameraControlMode ControlMode { get; protected set; } @@ -70,12 +72,20 @@ namespace PepperDash.Essentials.Devices.Common.Cameras // A bitmasked value to indicate the movement capabilites of this camera protected eCameraCapabilities Capabilities { get; set; } - protected CameraBase(string key, string name) : - base(key, name) - { - OutputPorts = new RoutingPortCollection(); + protected CameraBase(DeviceConfig config) : base(config) + { + OutputPorts = new RoutingPortCollection(); - ControlMode = eCameraControlMode.Manual; + ControlMode = eCameraControlMode.Manual; + + } + + protected CameraBase(string key, string name) : + base (new DeviceConfig{Name = name, Key = key}) + { + OutputPorts = new RoutingPortCollection(); + + ControlMode = eCameraControlMode.Manual; } protected void LinkCameraToApi(CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, From da179c01f5098d1a5469bb84743f363f4cf1d2c0 Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Tue, 11 May 2021 17:52:26 -0400 Subject: [PATCH 2/5] Fixes UpdateDeviceConfig() --- .../Config/Essentials/ConfigWriter.cs | 320 +++++++++--------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs index cb361d28..b97eeafa 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs @@ -1,162 +1,162 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Config -{ - /// - /// Responsible for updating config at runtime, and writing the updates out to a local file - /// - public class ConfigWriter - { - public const string LocalConfigFolder = "LocalConfig"; - - public const long WriteTimeout = 30000; - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Config +{ + /// + /// Responsible for updating config at runtime, and writing the updates out to a local file + /// + public class ConfigWriter + { + public const string LocalConfigFolder = "LocalConfig"; + + public const long WriteTimeout = 30000; + public static CTimer WriteTimer; - static CCriticalSection fileLock = new CCriticalSection(); - - /// - /// Updates the config properties of a device - /// - /// - /// - /// - public static bool UpdateDeviceProperties(string deviceKey, JToken properties) - { - bool success = false; - - // Get the current device config - var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey)); - - if (deviceConfig != null) - { - // Replace the current properties JToken with the new one passed into this method - deviceConfig.Properties = properties; - - Debug.Console(1, "Updated properties of device: '{0}'", deviceKey); - - success = true; - } - - ResetTimer(); - - return success; - } - - public static bool UpdateDeviceConfig(DeviceConfig config) - { - bool success = false; - - var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(config.Key)); - - if (deviceConfig != null) - { - deviceConfig = config; - - Debug.Console(1, "Updated config of device: '{0}'", config.Key); - - success = true; - } - - ResetTimer(); - - return success; - } - - public static bool UpdateRoomConfig(DeviceConfig config) - { - bool success = false; - - var deviceConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(d => d.Key.Equals(config.Key)); - - if (deviceConfig != null) - { - deviceConfig = config; - - Debug.Console(1, "Updated config of device: '{0}'", config.Key); - - success = true; - } - - ResetTimer(); - - return success; - } - - /// - /// Resets (or starts) the write timer - /// - static void ResetTimer() - { - if (WriteTimer == null) - WriteTimer = new CTimer(WriteConfigFile, WriteTimeout); - - WriteTimer.Reset(WriteTimeout); - - Debug.Console(1, "Config File write timer has been reset."); - } - - /// - /// Writes the current config to a file in the LocalConfig subfolder - /// - /// - private static void WriteConfigFile(object o) - { - var filePath = Global.FilePathPrefix + LocalConfigFolder + Global.DirectorySeparator + "configurationFile.json"; - - var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject); - - WriteFile(filePath, configData); - } - - /// - /// Writes - /// - /// - /// - public static void WriteFile(string filePath, string configData) - { - if (WriteTimer != null) - WriteTimer.Stop(); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file"); - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath); - - try - { - if (fileLock.TryEnter()) - { - using (StreamWriter sw = new StreamWriter(filePath)) - { - sw.Write(configData); - sw.Flush(); - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock"); - } - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e); - } - finally - { - if (fileLock != null && !fileLock.Disposed) - fileLock.Leave(); - - } - } - - - } + static CCriticalSection fileLock = new CCriticalSection(); + + /// + /// Updates the config properties of a device + /// + /// + /// + /// + public static bool UpdateDeviceProperties(string deviceKey, JToken properties) + { + bool success = false; + + // Get the current device config + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(deviceKey)); + + if (deviceConfig != null) + { + // Replace the current properties JToken with the new one passed into this method + deviceConfig.Properties = properties; + + Debug.Console(1, "Updated properties of device: '{0}'", deviceKey); + + success = true; + } + + ResetTimer(); + + return success; + } + + public static bool UpdateDeviceConfig(DeviceConfig config) + { + bool success = false; + + var deviceConfig = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key)); + + if (deviceConfig >= 0) + { + ConfigReader.ConfigObject.Devices[deviceConfig] = config; + + Debug.Console(1, "Updated config of device: '{0}'", config.Key); + + success = true; + } + + ResetTimer(); + + return success; + } + + public static bool UpdateRoomConfig(DeviceConfig config) + { + bool success = false; + + var deviceConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(d => d.Key.Equals(config.Key)); + + if (deviceConfig != null) + { + deviceConfig = config; + + Debug.Console(1, "Updated config of device: '{0}'", config.Key); + + success = true; + } + + ResetTimer(); + + return success; + } + + /// + /// Resets (or starts) the write timer + /// + static void ResetTimer() + { + if (WriteTimer == null) + WriteTimer = new CTimer(WriteConfigFile, WriteTimeout); + + WriteTimer.Reset(WriteTimeout); + + Debug.Console(1, "Config File write timer has been reset."); + } + + /// + /// Writes the current config to a file in the LocalConfig subfolder + /// + /// + private static void WriteConfigFile(object o) + { + var filePath = Global.FilePathPrefix + LocalConfigFolder + Global.DirectorySeparator + "configurationFile.json"; + + var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject); + + WriteFile(filePath, configData); + } + + /// + /// Writes + /// + /// + /// + public static void WriteFile(string filePath, string configData) + { + if (WriteTimer != null) + WriteTimer.Stop(); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file"); + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath); + + try + { + if (fileLock.TryEnter()) + { + using (StreamWriter sw = new StreamWriter(filePath)) + { + sw.Write(configData); + sw.Flush(); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock"); + } + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e); + } + finally + { + if (fileLock != null && !fileLock.Disposed) + fileLock.Leave(); + + } + } + + + } } \ No newline at end of file From 5fc4ff602782325faf681460dc0ae56d180d2624 Mon Sep 17 00:00:00 2001 From: Jason Alborough Date: Tue, 11 May 2021 20:28:15 -0400 Subject: [PATCH 3/5] #700 FIxes issue where ConfigWrite.UpdateDeviceConfig and UpdateRoomConfig do not write config to file --- .../Config/Essentials/ConfigWriter.cs | 14 +++++++------- .../Devices/ReconfigurableDevice.cs | 6 +----- .../Cameras/CameraBase.cs | 6 ++---- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs index b97eeafa..c6224859 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Essentials/ConfigWriter.cs @@ -54,11 +54,11 @@ namespace PepperDash.Essentials.Core.Config { bool success = false; - var deviceConfig = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key)); + var deviceConfigIndex = ConfigReader.ConfigObject.Devices.FindIndex(d => d.Key.Equals(config.Key)); - if (deviceConfig >= 0) + if (deviceConfigIndex >= 0) { - ConfigReader.ConfigObject.Devices[deviceConfig] = config; + ConfigReader.ConfigObject.Devices[deviceConfigIndex] = config; Debug.Console(1, "Updated config of device: '{0}'", config.Key); @@ -74,13 +74,13 @@ namespace PepperDash.Essentials.Core.Config { bool success = false; - var deviceConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(d => d.Key.Equals(config.Key)); + var roomConfigIndex = ConfigReader.ConfigObject.Rooms.FindIndex(d => d.Key.Equals(config.Key)); - if (deviceConfig != null) + if (roomConfigIndex >= 0) { - deviceConfig = config; + ConfigReader.ConfigObject.Rooms[roomConfigIndex] = config; - Debug.Console(1, "Updated config of device: '{0}'", config.Key); + Debug.Console(1, "Updated room of device: '{0}'", config.Key); success = true; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs index 60c8db0c..81988199 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs @@ -54,11 +54,7 @@ namespace PepperDash.Essentials.Core.Devices Name = config.Name; } - protected virtual void WriteControlProperty(JToken controlObject) - { - Config.Properties["control"] = JToken.FromObject(controlObject); - CustomSetConfig(Config); - } + /// /// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs index edfd34cb..def22069 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraBase.cs @@ -81,11 +81,9 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } protected CameraBase(string key, string name) : - base (new DeviceConfig{Name = name, Key = key}) + this (new DeviceConfig{Name = name, Key = key}) { - OutputPorts = new RoutingPortCollection(); - - ControlMode = eCameraControlMode.Manual; + } protected void LinkCameraToApi(CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, From eac7c91327a00f968b1efbce2390d714a8c2eaad Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 13 May 2021 18:07:03 -0600 Subject: [PATCH 4/5] Create rfi_request.md --- .github/ISSUE_TEMPLATE/rfi_request.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/rfi_request.md diff --git a/.github/ISSUE_TEMPLATE/rfi_request.md b/.github/ISSUE_TEMPLATE/rfi_request.md new file mode 100644 index 00000000..e69ac70f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rfi_request.md @@ -0,0 +1,26 @@ +--- +name: Request for Information +about: Request specific information about capabilities of the framework +title: "[RFI]-" +labels: RFI +assignees: '' + +--- + +**What is your request?** +Please provide as much detail as possible. + + +**What is the intended use case** +- [ ] Essentials Standalone Application +- [ ] Essentials + SIMPL Windows Hybrid + +**User Interface Requirements** +- [ ] Not Applicable (logic only) +- [ ] Smart Graphics Touchpanel +- [ ] Cisco Touch10 +- [ ] Mobile Control + + +**Additional context** +Add any other context or screenshots about the request here. From 2d36b808008976ab2e037e97fc9d45e3e3c06fb1 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 14 May 2021 15:46:12 -0600 Subject: [PATCH 5/5] Adds CH5 option --- .github/ISSUE_TEMPLATE/rfi_request.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/rfi_request.md b/.github/ISSUE_TEMPLATE/rfi_request.md index e69ac70f..8ad25ac6 100644 --- a/.github/ISSUE_TEMPLATE/rfi_request.md +++ b/.github/ISSUE_TEMPLATE/rfi_request.md @@ -17,9 +17,10 @@ Please provide as much detail as possible. **User Interface Requirements** - [ ] Not Applicable (logic only) -- [ ] Smart Graphics Touchpanel +- [ ] Crestron Smart Graphics Touchpanel - [ ] Cisco Touch10 - [ ] Mobile Control +- [ ] Crestron CH5 Touchpanel interface **Additional context**