diff --git a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs index b1ce4b09..6ccc3da7 100644 --- a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs @@ -7,7 +7,6 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; -using Newtonsoft.Json.Linq; namespace PepperDash.Essentials.AppServer.Messengers { @@ -16,7 +15,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// Device being bridged /// - public IRunRouteAction RoutingDevice {get; set;} + public IRunRouteAction RoutingDevice {get; private set;} public IRunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath) : base(key, messagePath) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs deleted file mode 100644 index d9e124fe..00000000 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.EthernetCommunication; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common.Cameras; - -namespace PepperDash.Essentials.AppServer.Messengers -{ - public class SIMPLCameraBaseMessenger : MessengerBase - { - BasicTriList EISC; - - CameraBase Camera; - - uint JoinStart; - - /// - /// 811 - /// - const uint BCameraControlUp = 1; - /// - /// 812 - /// - const uint BCameraControlDown = 2; - /// - /// 813 - /// - const uint BCameraControlLeft = 3; - /// - /// 814 - /// - const uint BCameraControlRight = 4; - /// - /// 815 - /// - const uint BCameraControlZoomIn = 5; - /// - /// 816 - /// - const uint BCameraControlZoomOut = 6; - /// - /// 821 - 826 - /// - const uint BCameraPresetStart = 11; - - /// - /// 831 - /// - const uint BCameraModeAuto = 21; - /// - /// 832 - /// - const uint BCameraModeManual = 22; - /// - /// 833 - /// - const uint BCameraModeOff = 23; - - - public SIMPLCameraBaseMessenger(string key, CameraBase camera, BasicTriList eisc, string messagePath, uint joinStart) - : base(key, messagePath) - { - if (camera == null) - throw new ArgumentNullException("camera"); - - EISC = eisc; - Camera = camera; - JoinStart = joinStart; - - var presetsCamera = Camera as IHasCameraPresets; - - if (presetsCamera != null) - { - presetsCamera.PresetsListHasChanged += new EventHandler(presetsCamera_PresetsListHasChanged); - } - } - - void presetsCamera_PresetsListHasChanged(object sender, EventArgs e) - { - var presetsCamera = Camera as IHasCameraPresets; - - var presetList = new List(); - - if (presetsCamera != null) - presetList = presetsCamera.Presets; - - PostStatusMessage(new - { - presets = presetList - }); - } - - protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) - { - var asc = appServerController; - - - // Add press and holds using helper action - Action addPHAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); - addPHAction("/cameraUp", BCameraControlUp + JoinStart); - addPHAction("/cameraDown", BCameraControlDown + JoinStart); - addPHAction("/cameraLeft", BCameraControlLeft + JoinStart); - addPHAction("/cameraRight", BCameraControlRight + JoinStart); - addPHAction("/cameraZoomIn", BCameraControlZoomIn + JoinStart); - addPHAction("/cameraZoomOut", BCameraControlZoomOut + JoinStart); - - Action addAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - - addAction("/cameraModeAuto", BCameraModeAuto); - addAction("/cameraModeManual", BCameraModeManual); - addAction("/cameraModeOff", BCameraModeOff); - - // camera presets - for (uint i = 0; i < 6; i++) - { - addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i); - } - - asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); - - - } - - /// - /// Helper method to update the full status of the camera - /// - void SendCameraFullMessageObject() - { - var presetsCamera = Camera as IHasCameraPresets; - - var presetList = new List(); - - if (presetsCamera != null) - presetList = presetsCamera.Presets; - - PostStatusMessage(new - { - cameraMode = GetCameraMode(), - hasPresets = Camera is IHasCameraPresets, - presets = presetList - }); - } - - /// - /// - /// - void PostCameraMode() - { - PostStatusMessage(new - { - cameraMode = GetCameraMode() - }); - } - - /// - /// Computes the current camera mode - /// - /// - string GetCameraMode() - { - string m; - if (EISC.GetBool(BCameraModeAuto)) m = eCameraControlMode.Auto.ToString().ToLower(); - else if (EISC.GetBool(BCameraModeManual)) m = eCameraControlMode.Manual.ToString().ToLower(); - else m = eCameraControlMode.Off.ToString().ToLower(); - return m; - } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs new file mode 100644 index 00000000..b3a46acc --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.EthernetCommunication; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common.Cameras; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + public class SIMPLCameraMessenger : MessengerBase + { + BasicTriList EISC; + + uint JoinStart; + + public class BoolJoin + { + /// + /// 1 + /// + public const uint CameraControlUp = 1; + /// + /// 2 + /// + public const uint CameraControlDown = 2; + /// + /// 3 + /// + public const uint CameraControlLeft = 3; + /// + /// 4 + /// + public const uint CameraControlRight = 4; + /// + /// 5 + /// + public const uint CameraControlZoomIn = 5; + /// + /// 6 + /// + public const uint CameraControlZoomOut = 6; + /// + /// 10 + /// + public const uint CameraHasPresets = 10; + /// + /// 11 - 20 + /// + public const uint CameraPresetStart = 10; + + /// + /// 21 + /// + public const uint CameraModeAuto = 21; + /// + /// 22 + /// + public const uint CameraModeManual = 22; + /// + /// 23 + /// + public const uint CameraModeOff = 23; + /// + /// 24 + /// + public const uint CameraSupportsModeAuto = 24; + /// + /// 25 + /// + public const uint CameraSupportsModeOff = 25; + } + + public class UshortJoin + { + /// + /// 10 + /// + public const uint CameraPresetCount = 10; + } + + public class StringJoin + { + /// + /// 11-20 + /// + public const uint CameraPresetNameStart = 10; + } + + public SIMPLCameraMessenger(string key, BasicTriList eisc, string messagePath, uint joinStart) + : base(key, messagePath) + { + EISC = eisc; + JoinStart = joinStart; + + EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject()); + + EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, (b) => PostCameraMode()); + EISC.SetBoolSigAction(BoolJoin.CameraModeManual, (b) => PostCameraMode()); + EISC.SetBoolSigAction(BoolJoin.CameraModeOff, (b) => PostCameraMode()); + } + + + protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) + { + var asc = appServerController; + + + // Add press and holds using helper action + Action addPHAction = (s, u) => + AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); + addPHAction("/cameraUp", BoolJoin.CameraControlUp + JoinStart); + addPHAction("/cameraDown", BoolJoin.CameraControlDown + JoinStart); + addPHAction("/cameraLeft", BoolJoin.CameraControlLeft + JoinStart); + addPHAction("/cameraRight", BoolJoin.CameraControlRight + JoinStart); + addPHAction("/cameraZoomIn", BoolJoin.CameraControlZoomIn + JoinStart); + addPHAction("/cameraZoomOut", BoolJoin.CameraControlZoomOut + JoinStart); + + Action addAction = (s, u) => + AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); + + addAction("/cameraModeAuto", BoolJoin.CameraModeAuto); + addAction("/cameraModeManual", BoolJoin.CameraModeManual); + addAction("/cameraModeOff", BoolJoin.CameraModeOff); + + // camera presets + for (uint i = 1; i <= 6; i++) + { + addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + JoinStart + i); + } + + asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); + + + } + + /// + /// Helper method to update the full status of the camera + /// + void SendCameraFullMessageObject() + { + var presetList = new List(); + + // Build a list of camera presets based on the names and count + if (EISC.GetBool(JoinStart + BoolJoin.CameraHasPresets)) + { + for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++) + { + var presetName = EISC.GetString(JoinStart + StringJoin.CameraPresetNameStart + i); + var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true); + presetList.Add(preset); + } + } + + PostStatusMessage(new + { + cameraMode = GetCameraMode(), + hasPresets = EISC.GetBool(BoolJoin.CameraHasPresets), + presets = presetList + }); + } + + /// + /// + /// + void PostCameraMode() + { + PostStatusMessage(new + { + cameraMode = GetCameraMode() + }); + } + + /// + /// Computes the current camera mode + /// + /// + string GetCameraMode() + { + string m; + if (EISC.GetBool(BoolJoin.CameraModeAuto)) m = eCameraControlMode.Auto.ToString().ToLower(); + else if (EISC.GetBool(BoolJoin.CameraModeManual)) m = eCameraControlMode.Manual.ToString().ToLower(); + else m = eCameraControlMode.Off.ToString().ToLower(); + return m; + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs new file mode 100644 index 00000000..d0f17573 --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.AppServer.Messengers +{ + public class SIMPLRouteMessenger : MessengerBase + { + BasicTriList EISC; + + uint JoinStart; + + public class StringJoin + { + /// + /// 1 + /// + public const uint CurrentSource = 1; + } + + public SIMPLRouteMessenger(string key, BasicTriList eisc, string messagePath, uint joinStart) + : base(key, messagePath) + { + EISC = eisc; + JoinStart = joinStart; + + EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s)); + } + + + protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.AddAction(MessagePath + "/fullStatus", new Action(() => + { + SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource)); + })); + + appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + { + EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem); + })); + + } + + /// + /// Helper method to update full status of the routing device + /// + void SendRoutingFullMessageObject(string sourceKey) + { + if (string.IsNullOrEmpty(sourceKey)) + sourceKey = "none"; + + PostStatusMessage(new + { + selectedSourceKey = sourceKey + }); + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index fb77b945..62d83715 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -116,6 +116,7 @@ + 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 1bc53945..8e2af6cb 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 @@ -80,8 +80,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public class CameraPreset : PresetBase { - public CameraPreset(int id, string description, bool def, bool isDef) - : base(id, description, def, isDef) + public CameraPreset(int id, string description, bool isDefined, bool isDefinable) + : base(id, description, isDefined, isDefinable) { }