From 8d215930d9c2cb28796dc0872cc7e32681d83300 Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Tue, 11 May 2021 15:20:35 -0400 Subject: [PATCH] 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,