From 3b84c0e3dbf7a89f6ae94b56b5926c869b27513c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 26 Nov 2019 14:20:28 -0700 Subject: [PATCH 01/33] Adds PresetBase class and new IHasCameraPresets interface --- .../Messengers/CameraBaseMessenger.cs | 12 ++++++ .../Presets/PresetBase.cs | 39 +++++++++++++++++++ .../Cameras/IHasCameraPresets.cs | 22 +++++++++++ 3 files changed, 73 insertions(+) create mode 100644 PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs create mode 100644 essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs new file mode 100644 index 00000000..fbf1caf2 --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + public class CameraBaseMessenger + { + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs new file mode 100644 index 00000000..76ffbbc3 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Presets/PresetBase.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Presets +{ + public class PresetBase + { + [JsonProperty("id")] + public int ID { get; set; } + /// + /// Used to store the name of the preset + /// + [JsonProperty("description")] + public string Description { get; set; } + /// + /// Indicates if the preset is defined(stored) in the codec + /// + [JsonProperty("defined")] + public bool Defined { get; set; } + /// + /// Indicates if the preset has the capability to be defined + /// + [JsonProperty("isDefinable")] + public bool IsDefinable { get; set; } + + public PresetBase(int id, string description, bool def, bool isDef) + { + ID = id; + Description = description; + Defined = def; + IsDefinable = isDef; + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs new file mode 100644 index 00000000..a8e8983d --- /dev/null +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/IHasCameraPresets.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Describes a camera with preset functionality + /// + public interface IHasCameraPresets + { + event EventHandler PresetsListHasChanged; + + List Presets { get; } + + void PresetSelect(int preset); + + void PresetStore(int preset, string description); + } +} \ No newline at end of file From 3e9b67a1ad340f56d851cd72e42a536ce478a5e9 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 26 Nov 2019 14:27:17 -0700 Subject: [PATCH 02/33] Bringes in stashed changes to camera functions --- .../PepperDashEssentials.csproj | 1 + .../EssentialsHuddleRoomPropertiesConfig.cs | 23 ++++++++++ .../Devices/SourceListItem.cs | 32 +++++++++++++ .../PepperDash_Essentials_Core.csproj | 1 + .../Cameras/CameraBase.cs | 45 ++++++++++++++++--- .../Cameras/CameraControl.cs | 6 +-- .../Cameras/CameraVisca.cs | 26 +++++++++-- .../Essentials Devices Common.csproj | 1 + .../VideoCodec/CiscoCodec/RoomPresets.cs | 29 +++--------- .../VideoCodec/ZoomRoom/ResponseObjects.cs | 4 +- 10 files changed, 130 insertions(+), 38 deletions(-) diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index a238a4e8..f752ab0a 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -108,6 +108,7 @@ + diff --git a/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs b/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs index 2044484d..528436d6 100644 --- a/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs +++ b/PepperDashEssentials/Room/Config/EssentialsHuddleRoomPropertiesConfig.cs @@ -4,6 +4,10 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; + namespace PepperDash.Essentials.Room.Config { /// @@ -11,9 +15,28 @@ namespace PepperDash.Essentials.Room.Config /// public class EssentialsHuddleRoomPropertiesConfig : EssentialsRoomPropertiesConfig { + /// + /// The key of the default display device + /// + [JsonProperty("defaultDisplayKey")] public string DefaultDisplayKey { get; set; } + + /// + /// The key of the default audio device + /// + [JsonProperty("defaultAudioKey")] public string DefaultAudioKey { get; set; } + + /// + /// The key of the source list for the room + /// + [JsonProperty("sourceListKey")] public string SourceListKey { get; set; } + + /// + /// The key of the default source item from the source list + /// + [JsonProperty("defaultSourceItem")] public string DefaultSourceItem { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs index efa2b2ad..601d75a7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/SourceListItem.cs @@ -67,36 +67,68 @@ namespace PepperDash.Essentials.Core [JsonProperty("name")] public string Name { get; set; } + /// + /// Specifies and icon for the source list item + /// [JsonProperty("icon")] public string Icon { get; set; } + /// + /// Alternate icon + /// [JsonProperty("altIcon")] public string AltIcon { get; set; } + /// + /// Indicates if the item should be included in the source list + /// [JsonProperty("includeInSourceList")] public bool IncludeInSourceList { get; set; } + /// + /// Used to specify the order of the items in the source list when displayed + /// [JsonProperty("order")] public int Order { get; set; } + /// + /// The key of the device for volume control + /// [JsonProperty("volumeControlKey")] public string VolumeControlKey { get; set; } + /// + /// The type of source list item + /// [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public eSourceListItemType Type { get; set; } + /// + /// The list of routes to execute for this source list item + /// [JsonProperty("routeList")] public List RouteList { get; set; } + /// + /// Indicates if this source should be disabled for sharing to the far end call participants via codec content + /// [JsonProperty("disableCodecSharing")] public bool DisableCodecSharing { get; set; } + /// + /// Indicates if this source should be disabled for routing to a shared output + /// [JsonProperty("disableRoutedSharing")] public bool DisableRoutedSharing { get; set; } [JsonProperty("destinations")] public List Destinations { get; set; } + /// + /// A means to reference a source list for this source item, in the event that this source has an input that can have sources routed to it + /// + [JsonProperty("sourceListKey")] + public string SourceListKey { get; set; } public SourceListItem() { diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 7c3cd563..ea0a189b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -147,6 +147,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 8a7dcf03..079338e1 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 @@ -2,13 +2,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common.Codec; using System.Text.RegularExpressions; +using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Presets; +using PepperDash.Essentials.Devices.Common.Codec; + +using Newtonsoft.Json; namespace PepperDash.Essentials.Devices.Common.Cameras { @@ -21,8 +24,16 @@ namespace PepperDash.Essentials.Devices.Common.Cameras Focus = 8 } - public abstract class CameraBase : Device + public abstract class CameraBase : Device, IRoutingOutputs { + public eCameraControlMode ControlMode { get; protected set; } + + #region IRoutingOutputs Members + + public RoutingPortCollection OutputPorts { get; protected set; } + + #endregion + public bool CanPan { get @@ -59,14 +70,36 @@ namespace PepperDash.Essentials.Devices.Common.Cameras protected eCameraCapabilities Capabilities { get; set; } public CameraBase(string key, string name) : - base(key, name) { } + base(key, name) + { + OutputPorts = new RoutingPortCollection(); + + ControlMode = eCameraControlMode.Manual; + } } + public class CameraPreset : PresetBase + { + public CameraPreset(int id, string description, bool def, bool isDef) + : base(id, description, def, isDef) + { + + } + } + public class CameraPropertiesConfig { public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } public ControlPropertiesConfig Control { get; set; } + [JsonProperty("supportsAutoMode")] + public bool SupportsAutoMode { get; set; } + + [JsonProperty("supportsOffMode")] + public bool SupportsOffMode { get; set; } + + [JsonProperty("presets")] + public List Presets { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs index b17bd325..43788336 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs @@ -9,9 +9,9 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Devices.Common.Cameras { public enum eCameraControlMode - { - Off = 0, - Manual, + { + Manual = 0, + Off, Auto } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs index 182b560c..bcf6a4f9 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs @@ -11,7 +11,7 @@ using Crestron.SimplSharp.Reflection; namespace PepperDash.Essentials.Devices.Common.Cameras { - public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor + public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -25,11 +25,14 @@ namespace PepperDash.Essentials.Devices.Common.Cameras public bool PowerIsOn { get; private set; } byte[] IncomingBuffer = new byte[] { }; - public BoolFeedback PowerIsOnFeedback { get; private set; } + public BoolFeedback PowerIsOnFeedback { get; private set; } public CameraVisca(string key, string name, IBasicCommunication comm, CameraPropertiesConfig props) : base(key, name) { + Presets = props.Presets; + + OutputPorts.Add(new RoutingOutputPort("videoOut", eRoutingSignalType.Video, eRoutingPortConnectionType.None, null, this, true)); // Default to all capabilties Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus; @@ -206,5 +209,22 @@ namespace PepperDash.Essentials.Devices.Common.Cameras SendBytes(new byte[] { 0x81, 0x01, 0x04, 0x3F, 0x01, (byte)presetNumber, 0xFF }); } - } + #region IHasCameraPresets Members + + public event EventHandler PresetsListHasChanged; + + public List Presets { get; private set; } + + public void PresetSelect(int preset) + { + RecallPreset(preset); + } + + public void PresetStore(int preset, string description) + { + SavePreset(preset); + } + + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index bed83feb..38250dfc 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -102,6 +102,7 @@ + diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs index 2846674a..1b456774 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/RoomPresets.cs @@ -7,6 +7,7 @@ using Crestron.SimplSharp; using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Devices.Common.VideoCodec.Cisco; namespace PepperDash.Essentials.Devices.Common.VideoCodec @@ -67,34 +68,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } /// - /// Represents a room preset on a video coded. Typically stores camera position(s) and video routing. Can be recalled by Far End if enabled. + /// Represents a room preset on a video codec. Typically stores camera position(s) and video routing. Can be recalled by Far End if enabled. /// - public class CodecRoomPreset + public class CodecRoomPreset : PresetBase { - [JsonProperty("id")] - public int ID { get; set; } - /// - /// Used to store the name of the preset - /// - [JsonProperty("description")] - public string Description { get; set; } - /// - /// Indicates if the preset is defined(stored) in the codec - /// - [JsonProperty("defined")] - public bool Defined { get; set; } - /// - /// Indicates if the preset has the capability to be defined - /// - [JsonProperty("isDefinable")] - public bool IsDefinable { get; set; } - public CodecRoomPreset(int id, string description, bool def, bool isDef) + : base(id, description, def, isDef) { - ID = id; - Description = description; - Defined = def; - IsDefinable = isDef; + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs index 3a78c5e0..c603ca08 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs @@ -979,8 +979,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom meeting.StartTime = b.StartTime; if (b.EndTime != null) meeting.EndTime = b.EndTime; - if (b.IsPrivate != null) - meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; + + meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. From 0ed613de73a310c6cfcf76257e92b918c83c3b49 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Sun, 1 Dec 2019 20:50:55 -0700 Subject: [PATCH 03/33] Progress on CameraBaseMessenger --- .../Messengers/CameraBaseMessenger.cs | 92 ++++++++++++++++++- .../Messengers/Ddvc01VtcMessenger.cs | 7 +- .../Cameras/CameraBase.cs | 1 + .../Cameras/CameraControl.cs | 6 ++ 4 files changed, 102 insertions(+), 4 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs index fbf1caf2..338bc86b 100644 --- a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -4,9 +4,99 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common.Cameras; + namespace PepperDash.Essentials.AppServer.Messengers { - public class CameraBaseMessenger + public class CameraBaseMessenger : MessengerBase { + /// + /// Device being bridged + /// + public CameraBase Camera { get; set; } + + /// + /// Constructor + /// + /// + /// + /// + public CameraBaseMessenger(string key, CameraBase camera, string messagePath) + : base(key, messagePath) + { + if (camera == null) + throw new ArgumentNullException("camera"); + + Camera = camera; + + var presetsCamera = Camera as IHasCameraPresets; + + if (presetsCamera != null) + { + presetsCamera.PresetsListHasChanged += new EventHandler(presetsCamera_PresetsListHasChanged); + } + + } + + void presetsCamera_PresetsListHasChanged(object sender, EventArgs e) + { + SendCameraFullMessageObject(); + } + + protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); + + var ptzCamera = Camera as IHasCameraPtzControl; + + if (ptzCamera != null) + { + // Need to evaluate how to pass through these P&H actions. Need a method that takes a bool maybe? + AppServerController.AddAction(MessagePath + "/cameraUp", new PressAndHoldAction(ptzCamera.TiltUp)); + + } + + } + + /// + /// Helper method to update the full status of the camera + /// + void SendCameraFullMessageObject() + { + var presetsCamera = Camera as IHasCameraPresets; + + var presets = new List(); + + if (presetsCamera != null) + presets = presetsCamera.Presets; + + var info = new + { + cameraMode = GetCameraMode(), + hasPresets = Camera as IHasCameraPresets, + presets = presets + }; + } + + /// + /// Computes the current camera mode + /// + /// + string GetCameraMode() + { + string m; + if (Camera is IHasCameraAutoMode && (Camera as IHasCameraAutoMode).CameraAutoModeIsOnFeedback.BoolValue) + m = eCameraControlMode.Auto.ToString().ToLower(); + else if (Camera is IPower && !(Camera as IPower).PowerIsOnFeedback.BoolValue) + m = eCameraControlMode.Off.ToString().ToLower(); + else + m = eCameraControlMode.Manual.ToString().ToLower(); + return m; + } } } \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs index e3de11d0..b7dfa22c 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs @@ -9,6 +9,7 @@ using Crestron.SimplSharpPro.EthernetCommunication; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.AppServer.Messengers { @@ -557,9 +558,9 @@ namespace PepperDash.Essentials.AppServer.Messengers string GetCameraMode() { string m; - if (EISC.GetBool(BCameraModeAuto)) m = "auto"; - else if (EISC.GetBool(BCameraModeManual)) m = "manual"; - else m = "off"; + 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; } 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 079338e1..1bc53945 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 @@ -87,6 +87,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } } + public class CameraPropertiesConfig { public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs index 43788336..36142bdd 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraControl.cs @@ -88,6 +88,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras /// public interface IHasCameraPanControl { + // void PanLeft(bool pressRelease); + // void PanRight(bool pressRelease); void PanLeft(); void PanRight(); void PanStop(); @@ -98,6 +100,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras /// public interface IHasCameraTiltControl { + // void TiltDown(bool pressRelease); + // void TildUp(bool pressRelease); void TiltDown(); void TiltUp(); void TiltStop(); @@ -108,6 +112,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras /// public interface IHasCameraZoomControl { + // void ZoomIn(bool pressRelease); + // void ZoomOut(bool pressRelease); void ZoomIn(); void ZoomOut(); void ZoomStop(); From 042c94e6cf1479b06361961cc6ed546f8e1a705d Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 3 Dec 2019 21:54:11 -0700 Subject: [PATCH 04/33] Wrapped up CameraBaseMessenger --- .../Messengers/CameraBaseMessenger.cs | 66 ++++++++++++++++++- ...eControlEssentialsHuddleSpaceRoomBridge.cs | 25 +++++++ 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs index 338bc86b..e1a3468a 100644 --- a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -56,11 +56,73 @@ namespace PepperDash.Essentials.AppServer.Messengers if (ptzCamera != null) { + // Need to evaluate how to pass through these P&H actions. Need a method that takes a bool maybe? - AppServerController.AddAction(MessagePath + "/cameraUp", new PressAndHoldAction(ptzCamera.TiltUp)); - + AppServerController.AddAction(MessagePath + "/cameraUp", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.TiltUp(); + else + ptzCamera.TiltStop(); + })); + AppServerController.AddAction(MessagePath + "/cameraDown", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.TiltDown(); + else + ptzCamera.TiltStop(); + })); + AppServerController.AddAction(MessagePath + "/cameraLeft", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.PanLeft(); + else + ptzCamera.PanStop(); + })); + AppServerController.AddAction(MessagePath + "/cameraRight", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.PanRight(); + else + ptzCamera.PanStop(); + })); + AppServerController.AddAction(MessagePath + "/cameraZoomIn", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.ZoomIn(); + else + ptzCamera.ZoomStop(); + })); + AppServerController.AddAction(MessagePath + "/cameraZoomOut", new PressAndHoldAction((b) => + { + if (b) + ptzCamera.ZoomOut(); + else + ptzCamera.ZoomStop(); + })); } + if (Camera is IHasCameraAutoMode) + { + appServerController.AddAction(MessagePath + "/cameraModeAuto", new Action((Camera as IHasCameraAutoMode).CameraAutoModeOn)); + appServerController.AddAction(MessagePath + "/cameraModeManual", new Action((Camera as IHasCameraAutoMode).CameraAutoModeOff)); + } + + if (Camera is IPower) + { + appServerController.AddAction(MessagePath + "/cameraModeOff", new Action((Camera as IPower).PowerOff)); + } + + var presetsCamera = Camera as IHasCameraPresets; + + if (presetsCamera != null) + { + for(int i = 1; i <= 6; i++) + { + var preset = i; + appServerController.AddAction(MessagePath + "/cameraPreset" + i, new Action((p) => presetsCamera.PresetSelect(preset))); + } + } } /// diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs index fd36389a..5c82d488 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs @@ -25,6 +25,8 @@ namespace PepperDash.Essentials public AudioCodecBaseMessenger ACMessenger { get; private set; } + public Dictionary DeviceMessengers { get; private set; } + /// /// @@ -115,6 +117,8 @@ namespace PepperDash.Essentials ACMessenger.RegisterWithAppServer(Parent); } + SetupDeviceMessengers(); + var defCallRm = Room as IRunDefaultCallRoute; if (defCallRm != null) { @@ -134,6 +138,27 @@ namespace PepperDash.Essentials Room.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled; } + /// + /// Set up the messengers for each device type + /// + void SetupDeviceMessengers() + { + DeviceMessengers = new Dictionary(); + + foreach (var device in DeviceManager.AllDevices) + { + Debug.Console(2, this, "Attempting to set up device messenger for device: {0}", device.Key); + + if (device is Essentials.Devices.Common.Cameras.CameraBase) + { + var camDevice = device as Essentials.Devices.Common.Cameras.CameraBase; + var devKey = device.Key; + Debug.Console(2, this, "Adding CameraBaseMessenger for device: {0}", devKey); + DeviceMessengers.Add(devKey, new CameraBaseMessenger(devKey + "-" + Parent.Key, camDevice, "/device/" + devKey)); + } + } + } + /// /// /// From e74d8c2497aae06033ea43e0c1fe9770d3c34103 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 4 Dec 2019 22:36:25 -0700 Subject: [PATCH 05/33] Updates to IRunRouteAction to require specification of sourceListKey --- ...eControlEssentialsHuddleSpaceRoomBridge.cs | 41 ++++- .../EssentialsHuddleVtc1FusionController.cs | 4 +- .../Room/Types/EssentialsDualDisplayRoom.cs | 20 +-- .../Room/Types/EssentialsHuddleSpaceRoom.cs | 20 +-- .../Room/Types/EssentialsHuddleVtc1Room.cs | 20 +-- ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 4 +- ...lsHuddleSpaceFusionSystemControllerBase.cs | 6 +- .../Room/Interfaces.cs | 5 +- .../Essentials Devices Common.csproj | 1 + .../Factory/DeviceFactory.cs | 33 ++-- .../SoftCodec/BlueJeansPc.cs | 164 ++++++++++++++++++ 11 files changed, 264 insertions(+), 54 deletions(-) create mode 100644 essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs index 5c82d488..711f60a1 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs @@ -69,7 +69,45 @@ namespace PepperDash.Essentials var routeRoom = Room as IRunRouteAction; if(routeRoom != null) Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action(c => - routeRoom.RunRouteAction(c.SourceListItem))); + { + if(string.IsNullOrEmpty(c.SourceListKey)) + routeRoom.RunRouteAction(c.SourceListItem, Room.SourceListKey); + else + { + routeRoom.RunRouteAction(c.SourceListItem, c.SourceListKey); + } + })); + + //****************Temp until testing complete. Then move to own messenger*********************** + + var routeDevice = DeviceManager.GetDeviceForKey("inRoomPc-1") as IRunRouteAction; + if (routeDevice != null) + { + Parent.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + { + routeDevice.RunRouteAction(c.SourceListItem, c.SourceListKey); + })); + + var sinkDevice = routeDevice as IRoutingSinkNoSwitching; + if(sinkDevice != null) + { + sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) => + { + var contentObject = new + { + selectedSourceKey = sinkDevice.CurrentSourceInfoKey + }; + + Parent.SendMessageToServer(JObject.FromObject(new + { + type = "/device/inRoomPc-1/status", + content = contentObject + })); + + }); + } + } + var defaultRoom = Room as IRunDefaultPresentRoute; if(defaultRoom != null) @@ -455,6 +493,7 @@ namespace PepperDash.Essentials public class SourceSelectMessageContent { public string SourceListItem { get; set; } + public string SourceListKey { get; set; } } /// diff --git a/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs b/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs index 8ec55881..c6c85d1a 100644 --- a/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs +++ b/PepperDashEssentials/Fusion/EssentialsHuddleVtc1FusionController.cs @@ -186,7 +186,7 @@ namespace PepperDash.Essentials.Fusion FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource); - FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff")); + FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey)); // NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig); @@ -342,7 +342,7 @@ namespace PepperDash.Essentials.Fusion // Current Source var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig); - defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"); }); ; + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey); }); ; } } } diff --git a/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs b/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs index 44c88724..27539ebd 100644 --- a/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsDualDisplayRoom.cs @@ -348,7 +348,7 @@ namespace PepperDash.Essentials CrestronEnvironment.Sleep(1000); - RunRouteAction("roomOff"); + RunRouteAction("roomOff", SourceListKey); } /// @@ -357,7 +357,7 @@ namespace PepperDash.Essentials public override bool RunDefaultPresentRoute() { if (DefaultSourceItem != null) - RunRouteAction(DefaultSourceItem); + RunRouteAction(DefaultSourceItem, SourceListKey); return DefaultSourceItem != null; } @@ -368,7 +368,7 @@ namespace PepperDash.Essentials /// public bool RunDefaultCallRoute() { - RunRouteAction(DefaultCodecRouteString); + RunRouteAction(DefaultCodecRouteString, SourceListKey); return true; } @@ -376,9 +376,9 @@ namespace PepperDash.Essentials /// /// /// - public void RunRouteAction(string routeKey) + public void RunRouteAction(string routeKey, string sourceListKey) { - RunRouteAction(routeKey, null); + RunRouteAction(routeKey, sourceListKey, null); } /// @@ -386,7 +386,7 @@ namespace PepperDash.Essentials /// route or commands /// /// - public void RunRouteAction(string routeKey, Action successCallback) + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) { // Run this on a separate thread new CTimer(o => @@ -398,10 +398,10 @@ namespace PepperDash.Essentials { Debug.Console(1, this, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey); if (dict == null) { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey); return; } @@ -619,7 +619,7 @@ namespace PepperDash.Essentials { if (!EnablePowerOnToLastSource || LastSourceKey == null) return; - RunRouteAction(LastSourceKey); + RunRouteAction(LastSourceKey, SourceListKey); } /// @@ -630,7 +630,7 @@ namespace PepperDash.Essentials var allRooms = DeviceManager.AllDevices.Where(d => d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); foreach (var room in allRooms) - (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); + (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey); } #region IPrivacy Members diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index e4b503c3..9fd4b863 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -223,7 +223,7 @@ namespace PepperDash.Essentials CrestronEnvironment.Sleep(1000); - RunRouteAction("roomOff"); + RunRouteAction("roomOff", SourceListKey); } /// @@ -237,7 +237,7 @@ namespace PepperDash.Essentials return false; } - RunRouteAction(DefaultSourceItem); + RunRouteAction(DefaultSourceItem, SourceListKey); return true; } @@ -260,9 +260,9 @@ namespace PepperDash.Essentials /// /// /// - public void RunRouteAction(string routeKey) + public void RunRouteAction(string routeKey, string sourceListKey) { - RunRouteAction(routeKey, null); + RunRouteAction(routeKey, sourceListKey, null); } /// @@ -270,16 +270,16 @@ namespace PepperDash.Essentials /// route or commands /// /// - public void RunRouteAction(string routeKey, Action successCallback) + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) { // Run this on a separate thread new CTimer(o => { Debug.Console(1, this, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey); if(dict == null) { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey); return; } @@ -287,7 +287,7 @@ namespace PepperDash.Essentials if (!dict.ContainsKey(routeKey)) { Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", - routeKey, SourceListKey); + routeKey, sourceListKey); return; } @@ -426,7 +426,7 @@ namespace PepperDash.Essentials { if (!EnablePowerOnToLastSource || LastSourceKey == null) return; - RunRouteAction(LastSourceKey); + RunRouteAction(LastSourceKey, SourceListKey); } /// @@ -494,7 +494,7 @@ namespace PepperDash.Essentials var allRooms = DeviceManager.AllDevices.Where(d => d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); foreach (var room in allRooms) - (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); + (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey); } } } \ No newline at end of file diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index c8e867a4..e1bdb6cf 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -348,7 +348,7 @@ namespace PepperDash.Essentials CrestronEnvironment.Sleep(1000); - RunRouteAction("roomOff"); + RunRouteAction("roomOff", SourceListKey); } /// @@ -357,7 +357,7 @@ namespace PepperDash.Essentials public override bool RunDefaultPresentRoute() { if (DefaultSourceItem != null) - RunRouteAction(DefaultSourceItem); + RunRouteAction(DefaultSourceItem, SourceListKey); return DefaultSourceItem != null; } @@ -368,7 +368,7 @@ namespace PepperDash.Essentials /// public bool RunDefaultCallRoute() { - RunRouteAction(DefaultCodecRouteString); + RunRouteAction(DefaultCodecRouteString, SourceListKey); return true; } @@ -376,9 +376,9 @@ namespace PepperDash.Essentials /// /// /// - public void RunRouteAction(string routeKey) + public void RunRouteAction(string routeKey, string sourceListKey) { - RunRouteAction(routeKey, null); + RunRouteAction(routeKey, sourceListKey, null); } /// @@ -386,7 +386,7 @@ namespace PepperDash.Essentials /// route or commands /// /// - public void RunRouteAction(string routeKey, Action successCallback) + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) { // Run this on a separate thread new CTimer(o => @@ -398,10 +398,10 @@ namespace PepperDash.Essentials { Debug.Console(1, this, "Run route action '{0}'", routeKey); - var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey); + var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey); if (dict == null) { - Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey); + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey); return; } @@ -608,7 +608,7 @@ namespace PepperDash.Essentials { if (!EnablePowerOnToLastSource || LastSourceKey == null) return; - RunRouteAction(LastSourceKey); + RunRouteAction(LastSourceKey, SourceListKey); } /// @@ -619,7 +619,7 @@ namespace PepperDash.Essentials var allRooms = DeviceManager.AllDevices.Where(d => d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions); foreach (var room in allRooms) - (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff"); + (room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey); } #region IPrivacy Members diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 57e68010..fbc3f5b6 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -941,7 +941,7 @@ namespace PepperDash.Essentials if (_CurrentRoom != null) _CurrentRoom.CurrentSourceChange += new SourceInfoChangeHandler(CurrentRoom_CurrentSingleSourceChange); - TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd")); + TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd", _CurrentRoom.SourceListKey)); (Parent as EssentialsPanelMainInterfaceDriver).HeaderDriver.SetupHeaderButtons(this, CurrentRoom); } @@ -987,7 +987,7 @@ namespace PepperDash.Essentials if (CurrentRoom.CurrentSourceInfo != null && CurrentRoom.CurrentSourceInfo.DisableCodecSharing) { Debug.Console(1, CurrentRoom, "Transitioning to in-call, cancelling non-sharable source"); - CurrentRoom.RunRouteAction("codecOsd"); + CurrentRoom.RunRouteAction("codecOsd", CurrentRoom.SourceListKey); } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index ef5634aa..e8422f95 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -332,7 +332,7 @@ namespace PepperDash.Essentials.Core.Fusion FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsRoomBase).PowerOnToDefaultOrLastSource); - FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction("roomOff")); + FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction("roomOff", Room.SourceListKey)); // NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig); FusionRoom.ErrorMessage.InputSig.StringValue = "3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;"; @@ -1086,7 +1086,7 @@ namespace PepperDash.Essentials.Core.Fusion SourceToFeedbackSigs.Add(pSrc, sigD.InputSig); // And respond to selection in Fusion - sigD.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction(routeKey)); + sigD.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction(routeKey, Room.SourceListKey)); } catch (Exception) { @@ -1288,7 +1288,7 @@ namespace PepperDash.Essentials.Core.Fusion // Current Source var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig); - defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as IRunRouteAction).RunRouteAction("roomOff"); }); ; + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) (Room as IRunRouteAction).RunRouteAction("roomOff", Room.SourceListKey); }); ; } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs index 36f390c3..1743bdaa 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs @@ -35,9 +35,10 @@ namespace PepperDash.Essentials.Core /// public interface IRunRouteAction { - void RunRouteAction(string routeKey); + void RunRouteAction(string routeKey, string sourceListKey); + + void RunRouteAction(string routeKey, string sourceListKey, Action successCallback); - void RunRouteAction(string routeKey, Action successCallback); } /// diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 38250dfc..a0ed40c9 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -120,6 +120,7 @@ + diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs index 671dec12..5fe89500 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs @@ -144,22 +144,27 @@ namespace PepperDash.Essentials.Devices.Common return new Core.Devices.Laptop(key, name); } - else if (typeName == "mockvc") - { - return new VideoCodec.MockVC(dc); - } + else if (typeName == "bluejeanspc") + { + return new SoftCodec.BlueJeansPc(key, name); + } - else if (typeName == "mockac") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - return new AudioCodec.MockAC(key, name, props); - } + else if (typeName == "mockvc") + { + return new VideoCodec.MockVC(dc); + } - else if (typeName.StartsWith("ciscospark")) - { - var comm = CommFactory.CreateCommForDevice(dc); - return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); - } + else if (typeName == "mockac") + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + return new AudioCodec.MockAC(key, name, props); + } + + else if (typeName.StartsWith("ciscospark")) + { + var comm = CommFactory.CreateCommForDevice(dc); + return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); + } else if (typeName == "zoomroom") { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs new file mode 100644 index 00000000..462ae5cb --- /dev/null +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Core.Devices; +using PepperDash.Essentials.Core.Config; + + +namespace PepperDash.Essentials.Devices.Common.SoftCodec +{ + public class BlueJeansPc : InRoomPc, IRoutingInputs, IRunRouteAction, IRoutingSinkNoSwitching + { + + public RoutingInputPort AnyVideoIn { get; private set; } + + #region IRoutingInputs Members + + public RoutingPortCollection InputPorts { get; private set; } + + #endregion + + public BlueJeansPc(string key, string name) + : base(key, name) + { + InputPorts = new RoutingPortCollection(); + InputPorts.Add(AnyVideoIn = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this)); + } + + #region IRunRouteAction Members + + public void RunRouteAction(string routeKey, string sourceListKey) + { + RunRouteAction(routeKey, sourceListKey, null); + } + + public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback) + { + CrestronInvoke.BeginInvoke(o => + { + Debug.Console(1, this, "Run route action '{0}' on SourceList: {1}", routeKey, sourceListKey); + + var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey); + if (dict == null) + { + Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey); + return; + } + + // Try to get the list item by it's string key + if (!dict.ContainsKey(routeKey)) + { + Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'", + routeKey, sourceListKey); + return; + } + + var item = dict[routeKey]; + + foreach (var route in item.RouteList) + { + DoRoute(route); + } + + // store the name and UI info for routes + if (item.SourceKey == "none") + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = null; + } + else if (item.SourceKey != null) + { + CurrentSourceInfoKey = routeKey; + CurrentSourceInfo = item; + } + + // report back when done + if (successCallback != null) + successCallback(); + }); + } + + #endregion + + /// + /// + /// + /// + /// + bool DoRoute(SourceRouteListItem route) + { + IRoutingSinkNoSwitching dest = null; + + dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching; + + if (dest == null) + { + Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey); + return false; + } + + if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase)) + { + dest.ReleaseRoute(); + if (dest is IPower) + (dest as IPower).PowerOff(); + } + else + { + var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs; + if (source == null) + { + Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey); + return false; + } + dest.ReleaseAndMakeRoute(source, route.Type); + } + return true; + } + + + + #region IHasCurrentSourceInfoChange Members + + public string CurrentSourceInfoKey { get; set; } + + /// + /// The SourceListItem last run - containing names and icons + /// + public SourceListItem CurrentSourceInfo + { + get { return _CurrentSourceInfo; } + set + { + if (value == _CurrentSourceInfo) return; + + var handler = CurrentSourceChange; + // remove from in-use tracker, if so equipped + if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control"); + + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.WillChange); + + _CurrentSourceInfo = value; + + // add to in-use tracking + if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking) + (_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control"); + if (handler != null) + handler(_CurrentSourceInfo, ChangeType.DidChange); + } + } + SourceListItem _CurrentSourceInfo; + + public event SourceInfoChangeHandler CurrentSourceChange; + + #endregion + } +} \ No newline at end of file From df192895a160469c65de8fa309de49c688cf26a9 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 5 Dec 2019 15:43:53 -0700 Subject: [PATCH 06/33] Moved messaging for new types to specifc type messengers and tested. --- .../Messengers/CameraBaseMessenger.cs | 12 +-- .../Messengers/IRunRouteActionMessenger.cs | 82 +++++++++++++++++++ ...eControlEssentialsHuddleSpaceRoomBridge.cs | 45 +++------- .../PepperDashEssentials.csproj | 1 + 4 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs index e1a3468a..f11130b0 100644 --- a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -132,17 +132,17 @@ namespace PepperDash.Essentials.AppServer.Messengers { var presetsCamera = Camera as IHasCameraPresets; - var presets = new List(); + var presetList = new List(); if (presetsCamera != null) - presets = presetsCamera.Presets; + presetList = presetsCamera.Presets; - var info = new + PostStatusMessage(new { cameraMode = GetCameraMode(), - hasPresets = Camera as IHasCameraPresets, - presets = presets - }; + hasPresets = Camera is IHasCameraPresets, + presets = presetList + }); } /// diff --git a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs new file mode 100644 index 00000000..b1ce4b09 --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +using Newtonsoft.Json.Linq; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + public class IRunRouteActionMessenger : MessengerBase + { + /// + /// Device being bridged + /// + public IRunRouteAction RoutingDevice {get; set;} + + public IRunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath) + : base(key, messagePath) + { + if (routingDevice == null) + throw new ArgumentNullException("routingDevice"); + + RoutingDevice = routingDevice; + + var routingSink = RoutingDevice as IRoutingSinkNoSwitching; + + if (routingSink != null) + { + routingSink.CurrentSourceChange += new SourceInfoChangeHandler(routingSink_CurrentSourceChange); + } + } + + void routingSink_CurrentSourceChange(SourceListItem info, ChangeType type) + { + SendRoutingFullMessageObject(); + } + + protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendRoutingFullMessageObject)); + + appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + { + RoutingDevice.RunRouteAction(c.SourceListItem, c.SourceListKey); + })); + + var sinkDevice = RoutingDevice as IRoutingSinkNoSwitching; + if(sinkDevice != null) + { + sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) => + { + SendRoutingFullMessageObject(); + }); + } + } + + /// + /// Helper method to update full status of the routing device + /// + void SendRoutingFullMessageObject() + { + var sinkDevice = RoutingDevice as IRoutingSinkNoSwitching; + + if(sinkDevice != null) + { + var sourceKey = sinkDevice.CurrentSourceInfoKey; + + if (string.IsNullOrEmpty(sourceKey)) + sourceKey = "none"; + + PostStatusMessage(new + { + selectedSourceKey = sourceKey + }); + } + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs index 711f60a1..8a67ba14 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlEssentialsHuddleSpaceRoomBridge.cs @@ -78,36 +78,6 @@ namespace PepperDash.Essentials } })); - //****************Temp until testing complete. Then move to own messenger*********************** - - var routeDevice = DeviceManager.GetDeviceForKey("inRoomPc-1") as IRunRouteAction; - if (routeDevice != null) - { - Parent.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => - { - routeDevice.RunRouteAction(c.SourceListItem, c.SourceListKey); - })); - - var sinkDevice = routeDevice as IRoutingSinkNoSwitching; - if(sinkDevice != null) - { - sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) => - { - var contentObject = new - { - selectedSourceKey = sinkDevice.CurrentSourceInfoKey - }; - - Parent.SendMessageToServer(JObject.FromObject(new - { - type = "/device/inRoomPc-1/status", - content = contentObject - })); - - }); - } - } - var defaultRoom = Room as IRunDefaultPresentRoute; if(defaultRoom != null) @@ -190,9 +160,18 @@ namespace PepperDash.Essentials if (device is Essentials.Devices.Common.Cameras.CameraBase) { var camDevice = device as Essentials.Devices.Common.Cameras.CameraBase; - var devKey = device.Key; - Debug.Console(2, this, "Adding CameraBaseMessenger for device: {0}", devKey); - DeviceMessengers.Add(devKey, new CameraBaseMessenger(devKey + "-" + Parent.Key, camDevice, "/device/" + devKey)); + Debug.Console(2, this, "Adding CameraBaseMessenger for device: {0}", device.Key); + var cameraMessenger = new CameraBaseMessenger(device.Key + "-" + Parent.Key, camDevice, "/device/" + device.Key); + DeviceMessengers.Add(device.Key, cameraMessenger); + cameraMessenger.RegisterWithAppServer(Parent); + } + if (device is Essentials.Devices.Common.SoftCodec.BlueJeansPc) + { + var softCodecDevice = device as Essentials.Devices.Common.SoftCodec.BlueJeansPc; + Debug.Console(2, this, "Adding IRunRouteActionMessnger for device: {0}", device.Key); + var routeMessenger = new IRunRouteActionMessenger(device.Key + "-" + Parent.Key, softCodecDevice, "/device/" + device.Key); + DeviceMessengers.Add(device.Key, routeMessenger); + routeMessenger.RegisterWithAppServer(Parent); } } } diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 0a535d76..91f07c7d 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -113,6 +113,7 @@ + From 85f28498c435349fb21dace01ab42bd47c15096e Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 6 Dec 2019 16:27:25 -0700 Subject: [PATCH 07/33] Adds SIMPLCameraBaseMessenger --- .../Messengers/CameraBaseMessenger.cs | 12 +- .../Messengers/SIMPLCameraBaseMessenger.cs | 176 ++++++++++++++++++ .../PepperDashEssentials.csproj | 1 + .../Room/EssentialsRoomBase.cs | 2 + 4 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs diff --git a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs index f11130b0..043341a9 100644 --- a/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/CameraBaseMessenger.cs @@ -45,7 +45,17 @@ namespace PepperDash.Essentials.AppServer.Messengers void presetsCamera_PresetsListHasChanged(object sender, EventArgs e) { - SendCameraFullMessageObject(); + 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) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs new file mode 100644 index 00000000..d9e124fe --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs @@ -0,0 +1,176 @@ +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/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 91f07c7d..fb77b945 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -115,6 +115,7 @@ + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs index e8193837..c5162ffc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs @@ -172,6 +172,8 @@ namespace PepperDash.Essentials.Core RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownPromptSeconds; else if (mode == eVacancyMode.InInitialVacancy) RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds; + else if (mode == eVacancyMode.InShutdownWarning) + RoomVacancyShutdownTimer.SecondsToCount = 60; VacancyMode = mode; RoomVacancyShutdownTimer.Start(); From ebc50f0caa012141d3183ca173ce7e427145557e Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 9 Dec 2019 16:38:25 -0700 Subject: [PATCH 08/33] Updates SIMPLCameraMessenger and adds SIMPLRouteMessenger --- .../Messengers/IRunRouteActionMessenger.cs | 3 +- .../Messengers/SIMPLCameraBaseMessenger.cs | 176 ---------------- .../Messengers/SIMPLCameraMessenger.cs | 191 ++++++++++++++++++ .../Messengers/SIMPLRouteMessenger.cs | 66 ++++++ .../PepperDashEssentials.csproj | 1 + .../Cameras/CameraBase.cs | 4 +- 6 files changed, 261 insertions(+), 180 deletions(-) delete mode 100644 PepperDashEssentials/AppServer/Messengers/SIMPLCameraBaseMessenger.cs create mode 100644 PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs create mode 100644 PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs 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) { } From 5819ac78ece675a9ce51f93d2441a2e0ac136886 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Dec 2019 14:25:29 -0700 Subject: [PATCH 09/33] Adds properties config for SIMPL Messenger classes and adds SetupDeviceMessengers() to MobileControlDdvc01RoomBridge to add individual device messengers --- .../Messengers/SIMPLCameraMessenger.cs | 6 +- .../Messengers/SIMPLRouteMessenger.cs | 2 +- .../SimplMessengerPropertiesConfig.cs | 17 ++++++ .../MobileControlDdvc01RoomBridge.cs | 60 ++++++++++++++++++- PepperDashEssentials/Bridges/BridgeBase.cs | 4 +- .../PepperDashEssentials.csproj | 5 +- .../Config/BasicConfig.cs | 20 +++++++ 7 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index b3a46acc..d9868c69 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -95,7 +95,7 @@ namespace PepperDash.Essentials.AppServer.Messengers : base(key, messagePath) { EISC = eisc; - JoinStart = joinStart; + JoinStart = joinStart - 1; EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject()); @@ -130,7 +130,7 @@ namespace PepperDash.Essentials.AppServer.Messengers // camera presets for (uint i = 1; i <= 6; i++) { - addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + JoinStart + i); + addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart); } asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); @@ -150,7 +150,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++) { - var presetName = EISC.GetString(JoinStart + StringJoin.CameraPresetNameStart + i); + var presetName = EISC.GetString(StringJoin.CameraPresetNameStart + i + JoinStart); var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true); presetList.Add(preset); } diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs index d0f17573..21eabaff 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs @@ -29,7 +29,7 @@ namespace PepperDash.Essentials.AppServer.Messengers : base(key, messagePath) { EISC = eisc; - JoinStart = joinStart; + JoinStart = joinStart - 1; EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s)); } diff --git a/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs b/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs new file mode 100644 index 00000000..9ee7407e --- /dev/null +++ b/PepperDashEssentials/AppServer/Messengers/SimplMessengerPropertiesConfig.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Bridges; + +namespace PepperDash.Essentials.AppServer.Messengers +{ + /// + /// Properties to configure a SIMPL Messenger + /// + public class SimplMessengerPropertiesConfig : EiscApiPropertiesConfig.ApiDevicePropertiesConfig + { + } +} \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs index eefd8fbc..9d8ec22b 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs @@ -110,7 +110,6 @@ namespace PepperDash.Essentials.Room.MobileControl /// 621 /// public const uint SourceIsEnabledJoinStart = 621; - } public class UshortJoin @@ -755,6 +754,8 @@ namespace PepperDash.Essentials.Room.MobileControl co.Devices.Add(conf); } + SetupDeviceMessengers(); + Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented)); var handler = ConfigurationIsReady; @@ -766,6 +767,63 @@ namespace PepperDash.Essentials.Room.MobileControl ConfigIsLoaded = true; } + /// + /// Iterates device config and adds messengers as neede for each device type + /// + void SetupDeviceMessengers() + { + try + { + foreach (var device in ConfigReader.ConfigObject.Devices) + { + if (device.Group.Equals("appServerMessenger")) + { + var props = JsonConvert.DeserializeObject(device.Properties.ToString()); + + var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key); + + MessengerBase messenger = null; + + var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey); + + if (dev == null) + { + Debug.Console(1, this, "Unable to find device config for key: '{0}'", props.DeviceKey); + return; + } + + var type = device.Type.ToLower(); + + if (type.Equals("simplcameramessenger")) + { + Debug.Console(2, this, "Adding SIMPLCameraMessenger for: '{0}'", props.DeviceKey); + messenger = new SIMPLCameraMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart); + + } + else if (type.Equals("simplroutemessenger")) + { + Debug.Console(2, this, "Adding SIMPLRouteMessenger for: '{0}'", props.DeviceKey); + messenger = new SIMPLRouteMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart); + } + + if (messenger != null) + { + DeviceManager.AddDevice(messenger); + messenger.RegisterWithAppServer(Parent); + } + else + { + Debug.Console(2, this, "Unable to add messenger for device: '{0}' of type: '{1}'", props.DeviceKey, type); + } + } + } + } + catch (Exception e) + { + Debug.Console(2, this, "Error Setting up Device Managers: {0}", e); + } + } + /// /// /// diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 74cc4e87..784be59f 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -269,10 +269,10 @@ namespace PepperDash.Essentials.Bridges public EssentialsControlPropertiesConfig Control { get; set; } [JsonProperty("devices")] - public List Devices { get; set; } + public List Devices { get; set; } - public class ApiDevice + public class ApiDevicePropertiesConfig { [JsonProperty("deviceKey")] public string DeviceKey { get; set; } diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 62d83715..6cb64c5b 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -115,8 +115,9 @@ - - + + + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs index 3673a384..904bfc74 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/BasicConfig.cs @@ -39,5 +39,25 @@ namespace PepperDash.Essentials.Core.Config return SourceLists[key]; } + + /// + /// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null + /// + /// Key of desired device + /// + public DeviceConfig GetDeviceForKey(string key) + { + if (string.IsNullOrEmpty(key)) + return null; + + var deviceConfig = Devices.FirstOrDefault(d => d.Key.Equals(key)); + + if (deviceConfig != null) + return deviceConfig; + else + { + return null; + } + } } } \ No newline at end of file From c54351f8eec4fd4d53233be43c8257d6335ac765 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Dec 2019 14:28:20 -0700 Subject: [PATCH 10/33] Adds CustomUnregisterWithAppServer method to allow unregistration at runtime --- .../Messengers/SIMPLCameraMessenger.cs | 24 ++++++++++++++++--- .../Messengers/SIMPLRouteMessenger.cs | 11 +++++++-- .../MobileControlDdvc01RoomBridge.cs | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index d9868c69..bbf16cea 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -109,10 +109,11 @@ namespace PepperDash.Essentials.AppServer.Messengers { var asc = appServerController; + asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); // Add press and holds using helper action Action addPHAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); + asc.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); @@ -121,7 +122,7 @@ namespace PepperDash.Essentials.AppServer.Messengers addPHAction("/cameraZoomOut", BoolJoin.CameraControlZoomOut + JoinStart); Action addAction = (s, u) => - AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); + asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); addAction("/cameraModeAuto", BoolJoin.CameraModeAuto); addAction("/cameraModeManual", BoolJoin.CameraModeManual); @@ -132,10 +133,27 @@ namespace PepperDash.Essentials.AppServer.Messengers { addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart); } + } - asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject)); + public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.RemoveAction(MessagePath + "/fullStatus"); + appServerController.RemoveAction(MessagePath + "/cameraUp"); + appServerController.RemoveAction(MessagePath + "/cameraDown"); + appServerController.RemoveAction(MessagePath + "/cameraLeft"); + appServerController.RemoveAction(MessagePath + "/cameraRight"); + appServerController.RemoveAction(MessagePath + "/cameraZoomIn"); + appServerController.RemoveAction(MessagePath + "/cameraZoomOut"); + appServerController.RemoveAction(MessagePath + "/cameraModeAuto"); + appServerController.RemoveAction(MessagePath + "/cameraModeManual"); + appServerController.RemoveAction(MessagePath + "/cameraModeOff"); + EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, null); + + EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, null); + EISC.SetBoolSigAction(BoolJoin.CameraModeManual, null); + EISC.SetBoolSigAction(BoolJoin.CameraModeOff, null); } /// diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs index 21eabaff..7b8c26d4 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLRouteMessenger.cs @@ -34,7 +34,6 @@ namespace PepperDash.Essentials.AppServer.Messengers EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s)); } - protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) { appServerController.AddAction(MessagePath + "/fullStatus", new Action(() => @@ -42,13 +41,21 @@ namespace PepperDash.Essentials.AppServer.Messengers SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource)); })); - appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + appServerController.AddAction(MessagePath +"/source", new Action(c => { EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem); })); } + public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController) + { + appServerController.RemoveAction(MessagePath + "/fullStatus"); + appServerController.RemoveAction(MessagePath + "/source"); + + EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, null); + } + /// /// Helper method to update full status of the routing device /// diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs index 9d8ec22b..863f1681 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs @@ -776,13 +776,12 @@ namespace PepperDash.Essentials.Room.MobileControl { foreach (var device in ConfigReader.ConfigObject.Devices) { - if (device.Group.Equals("appServerMessenger")) + if (device.Group.Equals("simplmessenger")) { var props = JsonConvert.DeserializeObject(device.Properties.ToString()); var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key); - MessengerBase messenger = null; var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey); @@ -793,6 +792,7 @@ namespace PepperDash.Essentials.Room.MobileControl } var type = device.Type.ToLower(); + MessengerBase messenger = null; if (type.Equals("simplcameramessenger")) { From 16d57952676027354e1dc3c6d5e70c5a26bf405a Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 16 Dec 2019 13:14:37 -0700 Subject: [PATCH 11/33] Updates to JoinMapBase to support better definition of joins. --- .../Messengers/IRunRouteActionMessenger.cs | 2 +- ...01AtcMessenger.cs => SIMPLAtcMessenger.cs} | 4 +- ...01VtcMessenger.cs => SIMPLVtcMessenger.cs} | 4 +- .../MobileControlDdvc01RoomBridge.cs | 71 +++++++++++++++---- .../JoinMaps/CameraControllerJoinMap.cs | 24 ++++++- PepperDashEssentials/Factory/DeviceFactory.cs | 2 +- .../PepperDashEssentials.csproj | 4 +- .../JoinMaps/JoinMapBase.cs | 25 +++++++ 8 files changed, 112 insertions(+), 24 deletions(-) rename PepperDashEssentials/AppServer/Messengers/{Ddvc01AtcMessenger.cs => SIMPLAtcMessenger.cs} (97%) rename PepperDashEssentials/AppServer/Messengers/{Ddvc01VtcMessenger.cs => SIMPLVtcMessenger.cs} (99%) diff --git a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs index 6ccc3da7..c39d1dfb 100644 --- a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendRoutingFullMessageObject)); - appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + appServerController.AddAction(MessagePath + "/source", new Action(c => { RoutingDevice.RunRouteAction(c.SourceListItem, c.SourceListKey); })); diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs similarity index 97% rename from PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs rename to PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index eee94350..019b7742 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.Devices.Common.Codec; namespace PepperDash.Essentials.AppServer.Messengers { - public class Ddvc01AtcMessenger : MessengerBase + public class SIMPLAtcMessenger : MessengerBase { BasicTriList EISC; @@ -97,7 +97,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// /// - public Ddvc01AtcMessenger(string key, BasicTriList eisc, string messagePath) + public SIMPLAtcMessenger(string key, BasicTriList eisc, string messagePath) : base(key, messagePath) { EISC = eisc; diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs similarity index 99% rename from PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs rename to PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index b7dfa22c..d0163288 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -13,7 +13,7 @@ using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.AppServer.Messengers { - public class Ddvc01VtcMessenger : MessengerBase + public class SIMPLVtcMessenger : MessengerBase { BasicTriList EISC; @@ -240,7 +240,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// /// - public Ddvc01VtcMessenger(string key, BasicTriList eisc, string messagePath) + public SIMPLVtcMessenger(string key, BasicTriList eisc, string messagePath) : base(key, messagePath) { EISC = eisc; diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs index 863f1681..b85431fb 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs @@ -18,10 +18,16 @@ using PepperDash.Essentials.Room.Config; namespace PepperDash.Essentials.Room.MobileControl { - public class MobileControlDdvc01RoomBridge : MobileControlBridgeBase, IDelayedConfiguration + public class MobileControlSIMPLRoomBridge : MobileControlBridgeBase, IDelayedConfiguration { public class BoolJoin { + + /// + /// 1 + /// + public const uint ConfigIsInEssentials = 100; + /// /// 301 /// @@ -237,8 +243,8 @@ namespace PepperDash.Essentials.Room.MobileControl MobileControlDdvc01DeviceBridge SourceBridge; - Ddvc01AtcMessenger AtcMessenger; - Ddvc01VtcMessenger VtcMessenger; + SIMPLAtcMessenger AtcMessenger; + SIMPLVtcMessenger VtcMessenger; /// @@ -247,7 +253,7 @@ namespace PepperDash.Essentials.Room.MobileControl /// /// /// - public MobileControlDdvc01RoomBridge(string key, string name, uint ipId) + public MobileControlSIMPLRoomBridge(string key, string name, uint ipId) : base(key, name) { try @@ -278,24 +284,33 @@ namespace PepperDash.Essentials.Room.MobileControl SetupFeedbacks(); var atcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key); - AtcMessenger = new Ddvc01AtcMessenger(atcKey, EISC, "/device/audioCodec"); + AtcMessenger = new SIMPLAtcMessenger(atcKey, EISC, "/device/audioCodec"); AtcMessenger.RegisterWithAppServer(Parent); var vtcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key); - VtcMessenger = new Ddvc01VtcMessenger(vtcKey, EISC, "/device/videoCodec"); + VtcMessenger = new SIMPLVtcMessenger(vtcKey, EISC, "/device/videoCodec"); VtcMessenger.RegisterWithAppServer(Parent); EISC.SigChange += EISC_SigChange; EISC.OnlineStatusChange += (o, a) => { - Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}", a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue); + Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}. Use Essentials Config={2}", + a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue, EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue); + if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) LoadConfigValues(); + + if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + UseEssentialsConfig(); }; // load config if it's already there if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue) LoadConfigValues(); + if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + { + UseEssentialsConfig(); + } CrestronConsole.AddNewConsoleCommand(s => { @@ -322,6 +337,22 @@ namespace PepperDash.Essentials.Room.MobileControl return base.CustomActivate(); } + void UseEssentialsConfig() + { + ConfigIsLoaded = false; + + SetupDeviceMessengers(); + + Debug.Console(0, this, "******* ESSENTIALS CONFIG: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented)); + + var handler = ConfigurationIsReady; + if (handler != null) + { + handler(this, new EventArgs()); + } + + ConfigIsLoaded = true; + } /// /// Setup the actions to take place on various incoming API calls @@ -373,6 +404,9 @@ namespace PepperDash.Essentials.Room.MobileControl EISC.PulseBool(BoolJoin.ShutdownCancel))); } + + + /// /// /// @@ -782,13 +816,18 @@ namespace PepperDash.Essentials.Room.MobileControl var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key); + if (DeviceManager.GetDeviceForKey(messengerKey) != null) + { + Debug.Console(2, this, "Messenger with key: {0} already exists. Skipping...", messengerKey); + continue; + } var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey); if (dev == null) { Debug.Console(1, this, "Unable to find device config for key: '{0}'", props.DeviceKey); - return; + continue; } var type = device.Type.ToLower(); @@ -798,7 +837,6 @@ namespace PepperDash.Essentials.Room.MobileControl { Debug.Console(2, this, "Adding SIMPLCameraMessenger for: '{0}'", props.DeviceKey); messenger = new SIMPLCameraMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart); - } else if (type.Equals("simplroutemessenger")) { @@ -931,12 +969,15 @@ namespace PepperDash.Essentials.Room.MobileControl if (Debug.Level >= 1) Debug.Console(1, this, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); + if (uo != null) + { + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } } /// diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index cf087e5f..ce8b2f5e 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -25,6 +25,19 @@ namespace PepperDash.Essentials.Bridges public CameraControllerJoinMap() { + Joins = new Dictionary(); + + Joins.Add("isOnline", new JoinMetadata() + { JoinNumber = 9, Label = "IsOnline", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("powerOn", new JoinMetadata() + { JoinNumber = 7, Label = "PowerOn", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("powerOff", new JoinMetadata() + { JoinNumber = 8, Label = "PowerOff", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("up", new JoinMetadata() + { JoinNumber = 1, Label = "TiltUp", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + + + // Digital IsOnline = 9; PowerOff = 8; @@ -37,14 +50,23 @@ namespace PepperDash.Essentials.Bridges ZoomOut = 6; PresetRecallOffset = 10; PresetSaveOffset = 30; - NumberOfPresets = 5; + // Analog + NumberOfPresets = 5; } public override void OffsetJoinNumbers(uint joinStart) { var joinOffset = joinStart - 1; + + foreach (var join in Joins) + { + join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; + } + + + IsOnline = IsOnline + joinOffset; PowerOff = PowerOff + joinOffset; PowerOn = PowerOn + joinOffset; diff --git a/PepperDashEssentials/Factory/DeviceFactory.cs b/PepperDashEssentials/Factory/DeviceFactory.cs index 24c4bfe1..1e0e8ffb 100644 --- a/PepperDashEssentials/Factory/DeviceFactory.cs +++ b/PepperDashEssentials/Factory/DeviceFactory.cs @@ -69,7 +69,7 @@ namespace PepperDash.Essentials { var comm = CommFactory.GetControlPropertiesConfig(dc); - var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlDdvc01RoomBridge(key, name, comm.IpIdInt); + var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlSIMPLRoomBridge(key, name, comm.IpIdInt); bridge.AddPreActivationAction(() => { var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as MobileControlSystemController; diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 6cb64c5b..3b1679c0 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -110,9 +110,9 @@ - + - + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 23669066..cdba6c4d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -40,8 +40,33 @@ namespace PepperDash.Essentials.Core /// public abstract void OffsetJoinNumbers(uint joinStart); + public Dictionary Joins { get; set; } + } + + public enum eJoinCapabilities + { + Read = 1, + Write = 2 + } + + public enum eJoinType + { + Digital = 1, + Analog = 2, + Serial = 4 + } + + public class JoinMetadata + { + public string Label { get; set; } + public eJoinType JoinType { get; set; } + public uint JoinNumber { get; set; } + public uint JoinSpan { get; set; } + public eJoinCapabilities JoinCapabilities { get; set; } } + + } \ No newline at end of file From 0d854270b6c060efa11dfd9211ef7e0c5c64e6be Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 17 Dec 2019 10:58:17 -0700 Subject: [PATCH 12/33] Adds new JoinMap for CameraControllerJoinMap --- .../JoinMaps/CameraControllerJoinMap.cs | 52 ++++++++++++++++--- .../JoinMaps/JoinMapBase.cs | 29 +++++++++++ 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index ce8b2f5e..b78ef472 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -23,20 +23,56 @@ namespace PepperDash.Essentials.Bridges public uint PresetSaveOffset { get; set; } public uint NumberOfPresets { get; set; } + public enum eCameraControllerJoinMapKey + { + IsOnline, + PowerOn, + PowerOff, + TiltUp, + TiltDown, + PanLeft, + PanRight, + ZoomIn, + ZoomOut, + PresetRecallStart, + PresetSaveStart, + PresetLabelStart, + NumberOfPresets + } + public CameraControllerJoinMap() { Joins = new Dictionary(); - Joins.Add("isOnline", new JoinMetadata() - { JoinNumber = 9, Label = "IsOnline", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add("powerOn", new JoinMetadata() - { JoinNumber = 7, Label = "PowerOn", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add("powerOff", new JoinMetadata() - { JoinNumber = 8, Label = "PowerOff", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add("up", new JoinMetadata() - { JoinNumber = 1, Label = "TiltUp", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.IsOnline.ToString(), new JoinMetadata() + { JoinNumber = 9, Label = "Is Online", JoinCapabilities = eJoinCapabilities.Read, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PowerOn.ToString(), new JoinMetadata() + { JoinNumber = 7, Label = "Power On", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PowerOff.ToString(), new JoinMetadata() + { JoinNumber = 8, Label = "Power Off", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.TiltUp.ToString(), new JoinMetadata() + { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.TiltDown.ToString(), new JoinMetadata() + { JoinNumber = 2, Label = "TiltDown", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PanLeft.ToString(), new JoinMetadata() + { JoinNumber = 3, Label = "Pan Left", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PanRight.ToString(), new JoinMetadata() + { JoinNumber = 4, Label = "Pan Right", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.ZoomIn.ToString(), new JoinMetadata() + { JoinNumber = 5, Label = "Zoom In", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.ZoomOut.ToString(), new JoinMetadata() + { JoinNumber = 6, Label = "Zoom Out", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PresetRecallStart.ToString(), new JoinMetadata() + { JoinNumber = 11, Label = "Preset Recall Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Digital }); + Joins.Add(eCameraControllerJoinMapKey.PresetLabelStart.ToString(), new JoinMetadata() + { JoinNumber = 11, Label = "Preset Label Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Serial }); + Joins.Add(eCameraControllerJoinMapKey.PresetSaveStart.ToString(), new JoinMetadata() + { JoinNumber = 31, Label = "Preset Save Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Digital }); + + Joins.Add(eCameraControllerJoinMapKey.NumberOfPresets.ToString(), new JoinMetadata() + { JoinNumber = 5, Label = "Number of Presets", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Analog }); // Digital IsOnline = 9; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index cdba6c4d..a739511a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -6,6 +6,8 @@ using Crestron.SimplSharp; using PepperDash.Essentials.Core.Config; +using Newtonsoft.Json; + namespace PepperDash.Essentials.Core { public static class JoinMapHelper @@ -43,6 +45,10 @@ namespace PepperDash.Essentials.Core public Dictionary Joins { get; set; } } + /// + /// Read = Provides feedback to SIMPL + /// Write = Responds to sig values from SIMPL + /// public enum eJoinCapabilities { Read = 1, @@ -56,12 +62,35 @@ namespace PepperDash.Essentials.Core Serial = 4 } + /// + /// Data describing the join + /// public class JoinMetadata { + /// + /// A label for the join to better describe it's usage + /// + [JsonProperty("label")] public string Label { get; set; } + /// + /// Signal type(s) + /// + [JsonProperty("joinType")] public eJoinType JoinType { get; set; } + /// + /// Join number (based on join offset value) + /// + [JsonProperty("joinNumber")] public uint JoinNumber { get; set; } + /// + /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range + /// + [JsonProperty("joinSpan")] public uint JoinSpan { get; set; } + /// + /// Indicates whether the join is read and/or write + /// + [JsonProperty("joinCapabilities")] public eJoinCapabilities JoinCapabilities { get; set; } } From 96cd5cfe81fd9c8947f1977ca4ee48f9be8c3ca2 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 17 Dec 2019 21:36:47 -0700 Subject: [PATCH 13/33] New JoinMap scheme working on CameraControllerJoinMap. Added MobileControlSIMPLRoomJoinMap and began implementing on MobileControlSIMPLRoomBridge --- ...dge.cs => MobileControlSIMPLRoomBridge.cs} | 23 ++-- .../MobileControlSIMPLRoomJoinMap.cs | 124 +++++++++++++++++ PepperDashEssentials/Bridges/BridgeBase.cs | 2 + .../Bridges/CameraControllerBridge.cs | 73 +++++++--- .../JoinMaps/CameraControllerJoinMap.cs | 130 ++++++------------ .../PepperDashEssentials.csproj | 3 +- .../JoinMaps/JoinMapBase.cs | 89 +++++++++++- .../Cameras/CameraVisca.cs | 11 +- .../BiampTesira/BiampTesiraForteDspLevel.cs | 13 ++ .../Essentials Devices Common/DSP/DspBase.cs | 23 ---- .../Power Controllers/Digitallogger.cs | 4 +- essentials-framework/pepperdashcore-builds | 2 +- 12 files changed, 345 insertions(+), 152 deletions(-) rename PepperDashEssentials/AppServer/RoomBridges/{MobileControlDdvc01RoomBridge.cs => MobileControlSIMPLRoomBridge.cs} (98%) create mode 100644 PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs similarity index 98% rename from PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs rename to PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs index b85431fb..d93da71c 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Core; +using PepperDash.Essentials.AppServer; using PepperDash.Essentials.AppServer.Messengers; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; @@ -186,15 +187,7 @@ namespace PepperDash.Essentials.Room.MobileControl /// /// 402 /// - public const uint ServerUrl = 402; - /// - /// 512 - /// - public const uint RoomSpeedDialNamesJoinStart = 512; - /// - /// 516 - /// - public const uint RoomSpeedDialNumberssJoinStart = 516; + public const uint ServerUrl = 402; /// /// 601 /// @@ -228,6 +221,8 @@ namespace PepperDash.Essentials.Room.MobileControl public ThreeSeriesTcpIpEthernetIntersystemCommunications EISC { get; private set; } + public MobileControlSIMPLRoomJoinMap JoinMap { get; private set; } + /// /// /// @@ -263,8 +258,18 @@ namespace PepperDash.Essentials.Room.MobileControl if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg); + JoinMap = new MobileControlSIMPLRoomJoinMap(); + + // TODO: Possibly set up alternate constructor or take in joinMapKey and joinStart properties in constructor + + + JoinMap.OffsetJoinNumbers(1); + SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC); DeviceManager.AddDevice(SourceBridge); + + + } catch (Exception) { diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs new file mode 100644 index 00000000..bcea7845 --- /dev/null +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.AppServer +{ + public class MobileControlSIMPLRoomJoinMap : JoinMapBase + { + public const string ConfigIsLocal = "ConfigIsLocal"; + public const string RoomIsOn = "RoomIsOn"; + public const string PrivacyMute = "PrivacyMute"; + public const string PromptForCode = "PromptForCode"; + public const string ClientJoined = "ClientJoined"; + public const string ActivityShare = "ActivityShare"; + public const string ActivityPhoneCall = "ActivityPhoneCall"; + public const string ActivtyVideoCall = "ActivityVideoCall"; + public const string MasterVolume = "MasterVolumeMute"; + public const string VolumeJoinStart = "VolumeMutesJoinStart"; + public const string ShutdownCancel = "ShutdownCancel"; + public const string ShutdownEnd = "ShutdownEnd"; + public const string ShutdownStart = "ShutdownStart"; + public const string SourceHasChanged = "SourceHasChanged"; + public const string SpeedDialVisibleStartJoin = "SpeedDialVisibleStartJoin"; + public const string ConfigIsReady = "ConfigIsReady"; + public const string HideVideoConfRecents = "HideVideoConfRecents"; + public const string ShowCameraWhenNotInCall = "ShowCameraWhenNotInCall"; + public const string UseSourceEnabled = "UseSourceEnabled"; + public const string SourceShareDisableJoinStart = "SourceShareDisableJoinStart"; + public const string SourceIsEnabledJoinStart = "SourceIsEnabledJoinStart"; + + //public const string MasterVolumeLevel = "MasterVolumeLevel"; + public const string VolumeSlidersJoinStart = "VolumeSlidersJoinStart"; + public const string ShutdownPromptDuration = "ShutdownPromptDuration"; + public const string NumberOfAuxFaders = "NumberOfAuxFaders"; + + public const string VolumeSliderNamesJoinStart = "VolumeSliderNamesJoinStart"; + public const string SelectedSourceKey = "SelectedSourceKey"; + public const string SpeedDialNameStartJoin = "SpeedDialNameStartJoin"; + public const string SpeedDialNumberStartJoin = "SpeedDialNumberStartJoin"; + public const string ConfigRoomName = "ConfigRoomName"; + public const string ConfigHelpMessage = "ConfigHelpMessage"; + public const string ConfigHelpNumber = "ConfigHelpNumber"; + public const string ConfigRoomPhoneNumber = "ConfigRoomPhoneNumber"; + public const string ConfigRoomURI = "ConfigRoomURI"; + public const string UserCodeToSystem = "UserCodeToSystem"; + public const string ServerUrl = "ServerUrl"; + public const string RoomSpeedDialNamesJoinStart = "RoomSpeedDialNamesJoinStart"; + public const string RoomSpeedDialNumberssJoinStart = "RoomSpeedDialNumberssJoinStart"; + public const string SourceNameJoinStart = "SourceNameJoinStart"; + public const string SourceIconJoinStart = "SourceIconJoinStart"; + public const string SourceKeyJoinStart = "SourceKeyJoinStart"; + public const string SourceTypeJoinStart = "SourceTypeJoinStart"; + public const string CameraNearNameStart = "CameraNearNameStart"; + public const string CameraFarName = "CameraFarName"; + + public MobileControlSIMPLRoomJoinMap() + { + Joins.Add(ConfigIsLocal, new JoinMetadata() { JoinNumber = 100, Label = "Config is local to Essentials", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(RoomIsOn, new JoinMetadata() { JoinNumber = 301, Label = "Room Is On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PrivacyMute, new JoinMetadata() { JoinNumber = 12, Label = "Privacy Mute Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PromptForCode, new JoinMetadata() { JoinNumber = 41, Label = "Prompt User for Code", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ClientJoined, new JoinMetadata() { JoinNumber = 42, Label = "Client Joined", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ActivityShare, new JoinMetadata() { JoinNumber = 51, Label = "Activity Share", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ActivityPhoneCall, new JoinMetadata() { JoinNumber = 52, Label = "Activity Phone Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ActivtyVideoCall, new JoinMetadata() { JoinNumber = 53, Label = "Activity Video Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(MasterVolume, new JoinMetadata() { JoinNumber = 1, Label = "Master Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.DigitalAnalogSerial }); + Joins.Add(VolumeJoinStart, new JoinMetadata() { JoinNumber = 2, Label = "Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 9, JoinType = eJoinType.DigitalAnalogSerial }); + Joins.Add(ShutdownCancel, new JoinMetadata() { JoinNumber = 61, Label = "Shutdown Cancel", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ShutdownEnd, new JoinMetadata() { JoinNumber = 62, Label = "Shutdown End", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ShutdownStart, new JoinMetadata() { JoinNumber = 63, Label = "ShutdownStart", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SourceHasChanged, new JoinMetadata() { JoinNumber = 71, Label = "Source Changed", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + // Possibly move these to Audio Codec Messenger + Joins.Add(SpeedDialVisibleStartJoin, new JoinMetadata() { JoinNumber = 261, Label = "Speed Dial Visible", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 10, JoinType = eJoinType.Digital }); + Joins.Add(ConfigIsReady, new JoinMetadata() { JoinNumber = 501, Label = "Config info from SIMPL is ready", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(HideVideoConfRecents, new JoinMetadata() { JoinNumber = 502, Label = "Hide Video Conference Recents", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ShowCameraWhenNotInCall, new JoinMetadata() { JoinNumber = 503, Label = "Show camera when not in call", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(UseSourceEnabled, new JoinMetadata() { JoinNumber = 504, Label = "Use Source Enabled Joins", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SourceShareDisableJoinStart, new JoinMetadata() { JoinNumber = 601, Label = "Source is not sharable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); + Joins.Add(SourceIsEnabledJoinStart, new JoinMetadata() { JoinNumber = 621, Label = "Source is enabled", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); + + + Joins.Add(ShutdownPromptDuration, new JoinMetadata() { JoinNumber = 61, Label = "Shutdown Prompt Timer Duration", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); + Joins.Add(NumberOfAuxFaders, new JoinMetadata() { JoinNumber = 101, Label = "Number of Auxilliary Faders", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); + + + Joins.Add(SelectedSourceKey, new JoinMetadata() { JoinNumber = 71, Label = "Key of selected source", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + + // Possibly move these to Audio Codec Messenger + Joins.Add(SpeedDialNameStartJoin, new JoinMetadata() { JoinNumber = 241, Label = "Speed Dial names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); + Joins.Add(SpeedDialNumberStartJoin, new JoinMetadata() { JoinNumber = 251, Label = "Speed Dial numbers", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); + Joins.Add(UserCodeToSystem, new JoinMetadata() { JoinNumber = 401, Label = "User Ccde", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ServerUrl, new JoinMetadata() { JoinNumber = 402, Label = "Server URL", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ConfigRoomName, new JoinMetadata() { JoinNumber = 501, Label = "Room Nnme", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ConfigHelpMessage, new JoinMetadata() { JoinNumber = 502, Label = "Room help message", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ConfigHelpNumber, new JoinMetadata() { JoinNumber = 503, Label = "Room help number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ConfigRoomPhoneNumber, new JoinMetadata() { JoinNumber = 504, Label = "Room phone number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(ConfigRoomURI, new JoinMetadata() { JoinNumber = 505, Label = "Room URI", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(SourceNameJoinStart, new JoinMetadata() { JoinNumber = 601, Label = "Source Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); + Joins.Add(SourceIconJoinStart, new JoinMetadata() { JoinNumber = 621, Label = "Source Icons", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); + Joins.Add(SourceKeyJoinStart, new JoinMetadata() { JoinNumber = 641, Label = "Source Keys", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); + Joins.Add(SourceTypeJoinStart, new JoinMetadata() { JoinNumber = 661, Label = "Source Types", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); + + Joins.Add(CameraNearNameStart, new JoinMetadata() { JoinNumber = 761, Label = "Near End Camera Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); + Joins.Add(CameraNearNameStart, new JoinMetadata() { JoinNumber = 770, Label = "Far End Camera Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + foreach (var join in Joins) + { + join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; + } + + PrintJoinMapInfo(); + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 784be59f..5a542fa0 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -55,6 +55,8 @@ namespace PepperDash.Essentials.Bridges { public EiscApiPropertiesConfig PropertiesConfig { get; private set; } + public Dictionary JoinMaps { get; set; } + public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } public EiscApi(DeviceConfig dc) : diff --git a/PepperDashEssentials/Bridges/CameraControllerBridge.cs b/PepperDashEssentials/Bridges/CameraControllerBridge.cs index badf9ea0..21a9d3eb 100644 --- a/PepperDashEssentials/Bridges/CameraControllerBridge.cs +++ b/PepperDashEssentials/Bridges/CameraControllerBridge.cs @@ -15,7 +15,6 @@ namespace PepperDash.Essentials.Bridges { public static class CameraControllerApiExtensions { - public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey) { CameraControllerJoinMap joinMap = new CameraControllerJoinMap(); @@ -31,13 +30,13 @@ namespace PepperDash.Essentials.Bridges Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); var commMonitor = cameraDevice as ICommunicationMonitor; - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.IsOnline)]); var ptzCamera = cameraDevice as IHasCameraPtzControl; if (ptzCamera != null) { - trilist.SetBoolSigAction(joinMap.Left, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PanLeft), (b) => { if (b) { @@ -48,7 +47,7 @@ namespace PepperDash.Essentials.Bridges ptzCamera.PanStop(); } }); - trilist.SetBoolSigAction(joinMap.Right, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PanRight), (b) => { if (b) { @@ -60,7 +59,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.Up, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.TiltUp), (b) => { if (b) { @@ -71,7 +70,7 @@ namespace PepperDash.Essentials.Bridges ptzCamera.TiltStop(); } }); - trilist.SetBoolSigAction(joinMap.Down, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.TiltDown), (b) => { if (b) { @@ -83,7 +82,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.ZoomIn, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.ZoomIn), (b) => { if (b) { @@ -95,7 +94,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.ZoomOut, (b) => + trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.ZoomOut), (b) => { if (b) { @@ -108,27 +107,57 @@ namespace PepperDash.Essentials.Bridges }); } - if (cameraDevice.GetType().Name.ToString().ToLower() == "cameravisca") + if (cameraDevice is IPower) { - var viscaCamera = cameraDevice as PepperDash.Essentials.Devices.Common.Cameras.CameraVisca; - trilist.SetSigTrueAction(joinMap.PowerOn, () => viscaCamera.PowerOn()); - trilist.SetSigTrueAction(joinMap.PowerOff, () => viscaCamera.PowerOff()); + var powerCamera = cameraDevice as IPower; + trilist.SetSigTrueAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOn), () => powerCamera.PowerOn()); + trilist.SetSigTrueAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOff), () => powerCamera.PowerOff()); + + powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOn)]); + powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOff)]); + } - viscaCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]); - viscaCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]); + if (cameraDevice is ICommunicationMonitor) + { + var monitoredCamera = cameraDevice as ICommunicationMonitor; + monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.IsOnline)]); + } - viscaCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); - for (int i = 0; i < joinMap.NumberOfPresets; i++) + if (cameraDevice is IHasCameraPresets) + { + // Set the preset lables when they change + var presetsCamera = cameraDevice as IHasCameraPresets; + presetsCamera.PresetsListHasChanged += new EventHandler((o, a) => + { + for (int i = 1; i <= joinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); i++) + { + int tempNum = i - 1; + + string label = "" ; + + var preset = presetsCamera.Presets.FirstOrDefault(p => p.ID.Equals(i)); + + if (preset != null) + label = preset.Description; + + trilist.SetString((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart) + tempNum), label); + } + }); + + for (int i = 0; i < joinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); i++) { int tempNum = i; - trilist.SetSigTrueAction((ushort)(joinMap.PresetRecallOffset + tempNum), () => + + trilist.SetSigTrueAction((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart) + tempNum), () => { - viscaCamera.RecallPreset(tempNum); + presetsCamera.PresetSelect(tempNum); + }); + trilist.SetSigTrueAction((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetSaveStart) + tempNum), () => + { + var label = trilist.GetString(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart + tempNum)); + + presetsCamera.PresetStore(tempNum, label); }); - trilist.SetSigTrueAction((ushort)(joinMap.PresetSaveOffset + tempNum), () => - { - viscaCamera.SavePreset(tempNum); - }); } } } diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index b78ef472..aa86b96d 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -8,112 +8,70 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Bridges { + /// + /// Join map for CameraBase devices + /// public class CameraControllerJoinMap : JoinMapBase { - public uint IsOnline { get; set; } - public uint PowerOff { get; set; } - public uint PowerOn { get; set; } - public uint Up { get; set; } - public uint Down { get; set; } - public uint Left { get; set; } - public uint Right { get; set; } - public uint ZoomIn { get; set; } - public uint ZoomOut { get; set; } - public uint PresetRecallOffset { get; set; } - public uint PresetSaveOffset { get; set; } - public uint NumberOfPresets { get; set; } - - public enum eCameraControllerJoinMapKey - { - IsOnline, - PowerOn, - PowerOff, - TiltUp, - TiltDown, - PanLeft, - PanRight, - ZoomIn, - ZoomOut, - PresetRecallStart, - PresetSaveStart, - PresetLabelStart, - NumberOfPresets - } + public const string IsOnline = "IsOnline"; + public const string PowerOff = "PowerOff"; + public const string PowerOn = "PowerOn"; + public const string TiltUp = "TiltUp"; + public const string TiltDown = "TiltDown"; + public const string PanLeft = "PanLeft"; + public const string PanRight = "PanRight"; + public const string ZoomIn = "ZoomIn"; + public const string ZoomOut = "ZoomOut"; + public const string PresetRecallStart = "PresetRecallStart"; + public const string PresetSaveStart = "PresetSaveStart"; + public const string PresetLabelStart = "PresetReacllStgart"; + public const string NumberOfPresets = "NumberOfPresets"; public CameraControllerJoinMap() { - Joins = new Dictionary(); + Joins.Add(TiltUp, new JoinMetadata() + { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(TiltDown, new JoinMetadata() + { JoinNumber = 2, Label = "TiltDown", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PanLeft, new JoinMetadata() + { JoinNumber = 3, Label = "Pan Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PanRight, new JoinMetadata() + { JoinNumber = 4, Label = "Pan Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ZoomIn, new JoinMetadata() + { JoinNumber = 5, Label = "Zoom In", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ZoomOut, new JoinMetadata() + { JoinNumber = 6, Label = "Zoom Out", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.IsOnline.ToString(), new JoinMetadata() - { JoinNumber = 9, Label = "Is Online", JoinCapabilities = eJoinCapabilities.Read, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PowerOn.ToString(), new JoinMetadata() - { JoinNumber = 7, Label = "Power On", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PowerOff.ToString(), new JoinMetadata() - { JoinNumber = 8, Label = "Power Off", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.TiltUp.ToString(), new JoinMetadata() - { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.TiltDown.ToString(), new JoinMetadata() - { JoinNumber = 2, Label = "TiltDown", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PanLeft.ToString(), new JoinMetadata() - { JoinNumber = 3, Label = "Pan Left", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PanRight.ToString(), new JoinMetadata() - { JoinNumber = 4, Label = "Pan Right", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.ZoomIn.ToString(), new JoinMetadata() - { JoinNumber = 5, Label = "Zoom In", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.ZoomOut.ToString(), new JoinMetadata() - { JoinNumber = 6, Label = "Zoom Out", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PowerOn, new JoinMetadata() + { JoinNumber = 7, Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(PowerOff, new JoinMetadata() + { JoinNumber = 8, Label = "Power Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IsOnline, new JoinMetadata() + { JoinNumber = 9, Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PresetRecallStart.ToString(), new JoinMetadata() - { JoinNumber = 11, Label = "Preset Recall Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.PresetLabelStart.ToString(), new JoinMetadata() - { JoinNumber = 11, Label = "Preset Label Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Serial }); + Joins.Add(PresetRecallStart, new JoinMetadata() + { JoinNumber = 11, Label = "Preset Recall Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); + Joins.Add(PresetLabelStart, new JoinMetadata() + { JoinNumber = 11, Label = "Preset Label Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - Joins.Add(eCameraControllerJoinMapKey.PresetSaveStart.ToString(), new JoinMetadata() - { JoinNumber = 31, Label = "Preset Save Start", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 20, JoinType = eJoinType.Digital }); + Joins.Add(PresetSaveStart, new JoinMetadata() + { JoinNumber = 31, Label = "Preset Save Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); - Joins.Add(eCameraControllerJoinMapKey.NumberOfPresets.ToString(), new JoinMetadata() - { JoinNumber = 5, Label = "Number of Presets", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Analog }); + Joins.Add(NumberOfPresets, new JoinMetadata() + { JoinNumber = 11, Label = "Number of Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - // Digital - IsOnline = 9; - PowerOff = 8; - PowerOn = 7; - Up = 1; - Down = 2; - Left = 3; - Right = 4; - ZoomIn = 5; - ZoomOut = 6; - PresetRecallOffset = 10; - PresetSaveOffset = 30; - - // Analog - NumberOfPresets = 5; } public override void OffsetJoinNumbers(uint joinStart) { var joinOffset = joinStart - 1; - - + foreach (var join in Joins) { join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; } - - - IsOnline = IsOnline + joinOffset; - PowerOff = PowerOff + joinOffset; - PowerOn = PowerOn + joinOffset; - Up = Up + joinOffset; - Down = Down + joinOffset; - Left = Left + joinOffset; - Right = Right + joinOffset; - ZoomIn = ZoomIn + joinOffset; - ZoomOut = ZoomOut + joinOffset; - PresetRecallOffset = PresetRecallOffset + joinOffset; - PresetSaveOffset = PresetSaveOffset + joinOffset; + PrintJoinMapInfo(); } } } \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 3b1679c0..063c3796 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -120,6 +120,7 @@ + @@ -195,7 +196,7 @@ - + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index a739511a..6a8dc7ce 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; +using PepperDash.Core; using PepperDash.Essentials.Core.Config; using Newtonsoft.Json; @@ -42,24 +43,101 @@ namespace PepperDash.Essentials.Core /// public abstract void OffsetJoinNumbers(uint joinStart); - public Dictionary Joins { get; set; } + /// + /// The collection of joins and associated metadata + /// + public Dictionary Joins = new Dictionary(); + + /// + /// Prints the join information to console + /// + public void PrintJoinMapInfo() + { + Debug.Console(0, "{0}:\n", this.GetType().Name); + + // Get the joins of each type and print them + Debug.Console(0, "Digitals:"); + var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(digitals)); + + Debug.Console(0, "Analogs:"); + var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(analogs)); + + Debug.Console(0, "Serials:"); + var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(serials)); + + } + + /// + /// Returns a sorted list by JoinNumber + /// + /// + /// + List> GetSortedJoins(Dictionary joins) + { + var sortedJoins = joins.ToList(); + + sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); + + return sortedJoins; + } + + void PrintJoinList(List> joins) + { + foreach (var join in joins) + { + Debug.Console(0, + @"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'", + join.Value.JoinNumber, + join.Value.Label, + join.Value.JoinSpan, + join.Value.JoinType.ToString(), + join.Value.JoinCapabilities.ToString()); + } + } + + /// + /// Returns the join number for the join with the specified key + /// + /// + /// + public uint GetJoinForKey(string key) + { + if (Joins.ContainsKey(key)) + return Joins[key].JoinNumber; + + else return 0; + } + + } /// /// Read = Provides feedback to SIMPL /// Write = Responds to sig values from SIMPL /// + [Flags] public enum eJoinCapabilities { - Read = 1, - Write = 2 + None = 0, + ToSIMPL = 1, + FromSIMPL = 2, + ToFromSIMPL = ToSIMPL | FromSIMPL } + [Flags] public enum eJoinType { + None = 0, Digital = 1, Analog = 2, - Serial = 4 + Serial = 4, + DigitalAnalog = Digital | Analog, + DigitalSerial = Digital | Serial, + AnalogSerial = Analog | Serial, + DigitalAnalogSerial = Digital | Analog | Serial } /// @@ -95,7 +173,4 @@ namespace PepperDash.Essentials.Core } - - - } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs index bcf6a4f9..3d50079b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs @@ -11,7 +11,7 @@ using Crestron.SimplSharp.Reflection; namespace PepperDash.Essentials.Devices.Common.Cameras { - public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets + public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets, IPower { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -135,6 +135,15 @@ namespace PepperDash.Essentials.Devices.Common.Cameras { SendBytes(new Byte[] {0x81, 0x01, 0x04, 0x00, 0x03, 0xFF}); } + + public void PowerToggle() + { + if (PowerIsOnFeedback.BoolValue) + PowerOff(); + else + PowerOn(); + } + public void PanLeft() { SendPanTiltCommand(new byte[] {0x01, 0x03}); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs index d0f83115..15d424a2 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs @@ -10,6 +10,19 @@ using System.Text.RegularExpressions; namespace PepperDash.Essentials.Devices.Common.DSP { + public interface IBiampTesiraDspLevelControl : IBasicVolumeWithFeedback + { + /// + /// In BiAmp: Instance Tag, QSC: Named Control, Polycom: + /// + string ControlPointTag { get; } + int Index1 { get; } + int Index2 { get; } + bool HasMute { get; } + bool HasLevel { get; } + bool AutomaticUnmuteOnVolumeUp { get; } + } + public class TesiraForteLevelControl : TesiraForteControlPoint, IBiampTesiraDspLevelControl, IKeyed { bool _IsMuted; diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs index 36c655d2..cdb832ab 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs @@ -49,27 +49,4 @@ namespace PepperDash.Essentials.Devices.Common.DSP { } - - - // Main program - // VTC - // ATC - // Mics, unusual - - public interface IBiampTesiraDspLevelControl : IBasicVolumeWithFeedback - { - /// - /// In BiAmp: Instance Tag, QSC: Named Control, Polycom: - /// - string ControlPointTag { get; } -#warning I dont think index1 and index2 should be a part of the interface. JTA 2018-07-17 - int Index1 { get; } - int Index2 { get; } - bool HasMute { get; } - bool HasLevel { get; } - bool AutomaticUnmuteOnVolumeUp { get; } - } - - - } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs index e48a5b7b..5003f795 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs @@ -103,7 +103,7 @@ namespace PepperDash.Essentials.Devices.Common }); CircuitIsCritical[circuit] = new BoolFeedback(() => { - if (CircuitStatus[circuit].critical != null) + if (CircuitStatus[circuit] != null) { return CircuitStatus[circuit].critical; } @@ -114,7 +114,7 @@ namespace PepperDash.Essentials.Devices.Common }); CircuitState[circuit] = new BoolFeedback(() => { - if (CircuitStatus[circuit].state != null) + if (CircuitStatus[circuit] != null) { return CircuitStatus[circuit].state; } diff --git a/essentials-framework/pepperdashcore-builds b/essentials-framework/pepperdashcore-builds index 45949f09..2d9c383d 160000 --- a/essentials-framework/pepperdashcore-builds +++ b/essentials-framework/pepperdashcore-builds @@ -1 +1 @@ -Subproject commit 45949f09bdcf6548be7fdf5c860ea4e3a5cf152d +Subproject commit 2d9c383db02ef3ef69dee8d42201c746fdfe79ea From 08d6090bc52b48994c89e3ce766c02ca7e416810 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 18 Dec 2019 16:37:37 -0700 Subject: [PATCH 14/33] Finished converting MobileControlSIMPLRoomBridge to use new MobileControlSIMPLRoomJoinMap --- .../Messengers/SIMPLCameraMessenger.cs | 209 ++++++----- .../MobileControlSIMPLRoomBridge.cs | 345 ++++-------------- .../MobileControlSIMPLRoomJoinMap.cs | 12 +- .../JoinMaps/CameraControllerJoinMap.cs | 25 +- .../JoinMaps/JoinMapBase.cs | 12 + 5 files changed, 234 insertions(+), 369 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index bbf16cea..468331d6 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.EthernetCommunication; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Bridges; using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.AppServer.Messengers @@ -16,92 +17,96 @@ namespace PepperDash.Essentials.AppServer.Messengers { BasicTriList EISC; - uint JoinStart; + CameraControllerJoinMap JoinMap; - 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; + //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; - } + // /// + // /// 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 UshortJoin + //{ + // /// + // /// 10 + // /// + // public const uint CameraPresetCount = 10; + //} - public class StringJoin - { - /// - /// 11-20 - /// - public const uint CameraPresetNameStart = 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 - 1; + //JoinStart = joinStart - 1; + JoinMap = new CameraControllerJoinMap(); - EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject()); + JoinMap.OffsetJoinNumbers(joinStart); - EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, (b) => PostCameraMode()); - EISC.SetBoolSigAction(BoolJoin.CameraModeManual, (b) => PostCameraMode()); - EISC.SetBoolSigAction(BoolJoin.CameraModeOff, (b) => PostCameraMode()); + + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets), (u) => SendCameraFullMessageObject()); + + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto), (b) => PostCameraMode()); + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual), (b) => PostCameraMode()); + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff), (b) => PostCameraMode()); } @@ -114,24 +119,29 @@ namespace PepperDash.Essentials.AppServer.Messengers // Add press and holds using helper action Action addPHAction = (s, u) => asc.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); + addPHAction("/cameraUp", JoinMap.GetJoinForKey(CameraControllerJoinMap.TiltUp)); + addPHAction("/cameraDown", JoinMap.GetJoinForKey(CameraControllerJoinMap.TiltDown)); + addPHAction("/cameraLeft", JoinMap.GetJoinForKey(CameraControllerJoinMap.PanLeft)); + addPHAction("/cameraRight", JoinMap.GetJoinForKey(CameraControllerJoinMap.PanRight)); + addPHAction("/cameraZoomIn", JoinMap.GetJoinForKey(CameraControllerJoinMap.ZoomIn)); + addPHAction("/cameraZoomOut", JoinMap.GetJoinForKey(CameraControllerJoinMap.ZoomOut)); Action addAction = (s, u) => asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/cameraModeAuto", BoolJoin.CameraModeAuto); - addAction("/cameraModeManual", BoolJoin.CameraModeManual); - addAction("/cameraModeOff", BoolJoin.CameraModeOff); + addAction("/cameraModeAuto", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto)); + addAction("/cameraModeManual", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual)); + addAction("/cameraModeOff", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff)); + var presetStart = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart); + var presetEnd = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart) + JoinMap.GetJoinSpanForKey(CameraControllerJoinMap.PresetRecallStart); + + int presetId = 1; // camera presets - for (uint i = 1; i <= 6; i++) + for (uint i = presetStart; i <= presetEnd; i++) { - addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart); + addAction("/cameraPreset" + (presetId), i); + presetId++; } } @@ -149,11 +159,11 @@ namespace PepperDash.Essentials.AppServer.Messengers appServerController.RemoveAction(MessagePath + "/cameraModeManual"); appServerController.RemoveAction(MessagePath + "/cameraModeOff"); - EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, null); + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets), null); - EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, null); - EISC.SetBoolSigAction(BoolJoin.CameraModeManual, null); - EISC.SetBoolSigAction(BoolJoin.CameraModeOff, null); + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto), null); + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual), null); + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff), null); } /// @@ -164,20 +174,25 @@ namespace PepperDash.Essentials.AppServer.Messengers var presetList = new List(); // Build a list of camera presets based on the names and count - if (EISC.GetBool(JoinStart + BoolJoin.CameraHasPresets)) + if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.SupportsPresets))) { - for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++) + var presetStart = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart); + var presetEnd = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart) + JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); + + var presetId = 1; + for (uint i = presetStart; i < presetEnd; i++) { - var presetName = EISC.GetString(StringJoin.CameraPresetNameStart + i + JoinStart); - var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true); + var presetName = EISC.GetString(i); + var preset = new CameraPreset(presetId, presetName, string.IsNullOrEmpty(presetName), true); presetList.Add(preset); + presetId++; } } PostStatusMessage(new { cameraMode = GetCameraMode(), - hasPresets = EISC.GetBool(BoolJoin.CameraHasPresets), + hasPresets = EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.SupportsPresets)), presets = presetList }); } @@ -200,8 +215,8 @@ namespace PepperDash.Essentials.AppServer.Messengers 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(); + if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto))) m = eCameraControlMode.Auto.ToString().ToLower(); + else if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual))) m = eCameraControlMode.Manual.ToString().ToLower(); else m = eCameraControlMode.Off.ToString().ToLower(); return m; } diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs index d93da71c..45f0e709 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs @@ -21,199 +21,6 @@ namespace PepperDash.Essentials.Room.MobileControl { public class MobileControlSIMPLRoomBridge : MobileControlBridgeBase, IDelayedConfiguration { - public class BoolJoin - { - - /// - /// 1 - /// - public const uint ConfigIsInEssentials = 100; - - /// - /// 301 - /// - public const uint RoomIsOn = 301; - - /// - /// 12 - /// - public const uint PrivacyMute = 12; - - /// - /// 41 - /// - public const uint PromptForCode = 41; - /// - /// 42 - /// - public const uint ClientJoined = 42; - /// - /// 51 - /// - public const uint ActivityShare = 51; - /// - /// 52 - /// - public const uint ActivityPhoneCall = 52; - /// - /// 53 - /// - public const uint ActivityVideoCall = 53; - - /// - /// 1 - /// - public const uint MasterVolumeIsMuted = 1; - /// - /// 1 - /// - public const uint MasterVolumeMuteToggle = 1; - /// - /// 1 - /// - public const uint VolumeMutesJoinStart = 1; - /// - /// 61 - /// - public const uint ShutdownCancel = 61; - /// - /// 62 - /// - public const uint ShutdownEnd = 62; - /// - /// 63 - /// - public const uint ShutdownStart = 63; - /// - /// 72 - /// - public const uint SourceHasChanged = 71; - - /// - /// 261 - The start of the range of speed dial visibles - /// - public const uint SpeedDialVisibleStartJoin = 261; - /// - /// 501 - /// - public const uint ConfigIsReady = 501; - /// - /// 502 - /// - public const uint HideVideoConfRecents = 502; - /// - /// 503 - /// - public const uint ShowCameraWhenNotInCall = 503; - /// - /// 504 - /// - public const uint UseSourceEnabled = 504; - /// - /// 601 - /// - public const uint SourceShareDisableJoinStart = 601; - /// - /// 621 - /// - public const uint SourceIsEnabledJoinStart = 621; - } - - public class UshortJoin - { - /// - /// 1 - /// - public const uint MasterVolumeLevel = 1; - /// - /// 1 - /// - public const uint VolumeSlidersJoinStart = 1; - /// - /// 61 - /// - public const uint ShutdownPromptDuration = 61; - /// - /// 101 - /// - public const uint NumberOfAuxFaders = 101; - } - - public class StringJoin - { - /// - /// 1 - /// - public const uint VolumeSliderNamesJoinStart = 1; - /// - /// 71 - /// - public const uint SelectedSourceKey = 71; - - /// - /// 241 - /// - public const uint SpeedDialNameStartJoin = 241; - - /// - /// 251 - /// - public const uint SpeedDialNumberStartJoin = 251; - - /// - /// 501 - /// - public const uint ConfigRoomName = 501; - /// - /// 502 - /// - public const uint ConfigHelpMessage = 502; - /// - /// 503 - /// - public const uint ConfigHelpNumber = 503; - /// - /// 504 - /// - public const uint ConfigRoomPhoneNumber = 504; - /// - /// 505 - /// - public const uint ConfigRoomURI = 505; - /// - /// 401 - /// - public const uint UserCodeToSystem = 401; - /// - /// 402 - /// - public const uint ServerUrl = 402; - /// - /// 601 - /// - public const uint SourceNameJoinStart = 601; - /// - /// 621 - /// - public const uint SourceIconJoinStart = 621; - /// - /// 641 - /// - public const uint SourceKeyJoinStart = 641; - /// - /// 661 - /// - public const uint SourceTypeJoinStart = 661; - /// - /// 761 - /// - public const uint CameraNearNameStart = 761; - /// - /// 770 - presence of this name on the input will cause the camera to be added - /// - public const uint CameraFarName = 770; - } - /// /// Fires when config is ready to go /// @@ -231,7 +38,7 @@ namespace PepperDash.Essentials.Room.MobileControl public override string RoomName { get { - var name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue; + var name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomName)].StringValue; return string.IsNullOrEmpty(name) ? "Not Loaded" : name; } } @@ -260,9 +67,7 @@ namespace PepperDash.Essentials.Room.MobileControl JoinMap = new MobileControlSIMPLRoomJoinMap(); - // TODO: Possibly set up alternate constructor or take in joinMapKey and joinStart properties in constructor - - + // TODO: Possibly set up alternate constructor or take in joinMapKey and joinStart properties in constructor JoinMap.OffsetJoinNumbers(1); SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC); @@ -300,19 +105,19 @@ namespace PepperDash.Essentials.Room.MobileControl EISC.OnlineStatusChange += (o, a) => { Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}. Use Essentials Config={2}", - a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue, EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue); + a.DeviceOnLine, EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue, EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue); - if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) + if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue) LoadConfigValues(); - if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue) UseEssentialsConfig(); }; // load config if it's already there - if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue) + if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue) // || EISC.BooleanInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady].BoolValue) LoadConfigValues(); - if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue) { UseEssentialsConfig(); } @@ -364,35 +169,38 @@ namespace PepperDash.Essentials.Room.MobileControl /// void SetupFunctions() { - Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(BoolJoin.PromptForCode))); - Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(BoolJoin.ClientJoined))); + Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PromptForCode)))); + Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ClientJoined)))); Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus)); Parent.AddAction(@"/room/room1/source", new Action(c => { - EISC.SetString(StringJoin.SelectedSourceKey, c.SourceListItem); - EISC.PulseBool(BoolJoin.SourceHasChanged); + EISC.SetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey), c.SourceListItem); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceHasChanged)); })); Parent.AddAction(@"/room/room1/defaultsource", new Action(() => - EISC.PulseBool(BoolJoin.ActivityShare))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare)))); Parent.AddAction(@"/room/room1/activityPhone", new Action(() => - EISC.PulseBool(BoolJoin.ActivityPhoneCall))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall)))); Parent.AddAction(@"/room/room1/activityVideo", new Action(() => - EISC.PulseBool(BoolJoin.ActivityVideoCall))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall)))); Parent.AddAction(@"/room/room1/volumes/master/level", new Action(u => - EISC.SetUshort(UshortJoin.MasterVolumeLevel, u))); + EISC.SetUshort(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), u))); Parent.AddAction(@"/room/room1/volumes/master/muteToggle", new Action(() => - EISC.PulseBool(BoolJoin.MasterVolumeIsMuted))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)))); Parent.AddAction(@"/room/room1/volumes/master/privacyMuteToggle", new Action(() => - EISC.PulseBool(BoolJoin.PrivacyMute))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute)))); // /xyzxyz/volumes/master/muteToggle ---> BoolInput[1] - for (uint i = 2; i <= 7; i++) + var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + + for (uint i = volumeStart; i <= volumeEnd; i++) { var index = i; Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/level", index), new Action(u => @@ -402,11 +210,11 @@ namespace PepperDash.Essentials.Room.MobileControl } Parent.AddAction(@"/room/room1/shutdownStart", new Action(() => - EISC.PulseBool(BoolJoin.ShutdownStart))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownStart)))); Parent.AddAction(@"/room/room1/shutdownEnd", new Action(() => - EISC.PulseBool(BoolJoin.ShutdownEnd))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownEnd)))); Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => - EISC.PulseBool(BoolJoin.ShutdownCancel))); + EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownCancel)))); } @@ -436,21 +244,21 @@ namespace PepperDash.Essentials.Room.MobileControl void SetupFeedbacks() { // Power - EISC.SetBoolSigAction(BoolJoin.RoomIsOn, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.RoomIsOn), b => PostStatusMessage(new { isOn = b })); // Source change things - EISC.SetSigTrueAction(BoolJoin.SourceHasChanged, () => + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceHasChanged), () => PostStatusMessage(new { - selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue + selectedSourceKey = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey)].StringValue })); // Volume things - EISC.SetUShortSigAction(UshortJoin.MasterVolumeLevel, u => + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), u => PostStatusMessage(new { volumes = new @@ -465,7 +273,7 @@ namespace PepperDash.Essentials.Room.MobileControl // map MasterVolumeIsMuted join -> status/volumes/master/muted // - EISC.SetBoolSigAction(BoolJoin.MasterVolumeIsMuted, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), b => PostStatusMessage(new { volumes = new @@ -476,7 +284,7 @@ namespace PepperDash.Essentials.Room.MobileControl } } })); - EISC.SetBoolSigAction(BoolJoin.PrivacyMute, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute), b => PostStatusMessage(new { volumes = new @@ -488,7 +296,10 @@ namespace PepperDash.Essentials.Room.MobileControl } })); - for (uint i = 2; i <= 7; i++) + var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + + for (uint i = volumeStart; i <= volumeEnd; i++) { var index = i; // local scope for lambdas EISC.SetUShortSigAction(index, u => // start at join 2 @@ -519,7 +330,7 @@ namespace PepperDash.Essentials.Room.MobileControl }); } - EISC.SetUShortSigAction(UshortJoin.NumberOfAuxFaders, u => + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders), u => PostStatusMessage(new { volumes = new { numberOfAuxFaders = u, @@ -527,30 +338,30 @@ namespace PepperDash.Essentials.Room.MobileControl })); // shutdown things - EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() => + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownCancel), new Action(() => PostMessage("/room/shutdown/", new { state = "wasCancelled" }))); - EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() => + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownEnd), new Action(() => PostMessage("/room/shutdown/", new { state = "hasFinished" }))); - EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() => + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownStart), new Action(() => PostMessage("/room/shutdown/", new { state = "hasStarted", - duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue + duration = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownPromptDuration)].UShortValue }))); // Config things - EISC.SetSigTrueAction(BoolJoin.ConfigIsReady, LoadConfigValues); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady), LoadConfigValues); // Activity modes - EISC.SetSigTrueAction(BoolJoin.ActivityShare, () => UpdateActivity(1)); - EISC.SetSigTrueAction(BoolJoin.ActivityPhoneCall, () => UpdateActivity(2)); - EISC.SetSigTrueAction(BoolJoin.ActivityVideoCall, () => UpdateActivity(3)); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare), () => UpdateActivity(1)); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall), () => UpdateActivity(2)); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall), () => UpdateActivity(3)); } @@ -594,7 +405,7 @@ namespace PepperDash.Essentials.Room.MobileControl Debug.Console(0, this, "Replacing Room[0] in config"); co.Rooms[0] = rm; } - rm.Name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue; + rm.Name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomName)].StringValue; rm.Key = "room1"; rm.Type = "ddvc01"; @@ -605,13 +416,13 @@ namespace PepperDash.Essentials.Room.MobileControl rmProps = JsonConvert.DeserializeObject(rm.Properties.ToString()); rmProps.Help = new EssentialsHelpPropertiesConfig(); - rmProps.Help.CallButtonText = EISC.StringOutput[StringJoin.ConfigHelpNumber].StringValue; - rmProps.Help.Message = EISC.StringOutput[StringJoin.ConfigHelpMessage].StringValue; + rmProps.Help.CallButtonText = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigHelpNumber)].StringValue; + rmProps.Help.Message = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigHelpMessage)].StringValue; rmProps.Environment = new EssentialsEnvironmentPropertiesConfig(); // enabled defaults to false - rmProps.RoomPhoneNumber = EISC.StringOutput[StringJoin.ConfigRoomPhoneNumber].StringValue; - rmProps.RoomURI = EISC.StringOutput[StringJoin.ConfigRoomURI].StringValue; + rmProps.RoomPhoneNumber = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomPhoneNumber)].StringValue; + rmProps.RoomURI = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomURI)].StringValue; rmProps.SpeedDials = new List(); // This MAY need a check @@ -619,7 +430,7 @@ namespace PepperDash.Essentials.Room.MobileControl rmProps.VideoCodecKey = "videoCodec"; // volume control names - var volCount = EISC.UShortOutput[UshortJoin.NumberOfAuxFaders].UShortValue; + var volCount = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; //// use Volumes object or? //rmProps.VolumeSliderNames = new List(); @@ -664,18 +475,18 @@ namespace PepperDash.Essentials.Room.MobileControl // add sources... for (uint i = 0; i <= 19; i++) { - var name = EISC.StringOutput[StringJoin.SourceNameJoinStart + i].StringValue; - if (EISC.BooleanOutput[BoolJoin.UseSourceEnabled].BoolValue - && !EISC.BooleanOutput[BoolJoin.SourceIsEnabledJoinStart + i].BoolValue) + var name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceNameJoinStart) + i].StringValue; + if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UseSourceEnabled)].BoolValue + && !EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceIsEnabledJoinStart) + i].BoolValue) { continue; } - else if(!EISC.BooleanOutput[BoolJoin.UseSourceEnabled].BoolValue && string.IsNullOrEmpty(name)) + else if(!EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UseSourceEnabled)].BoolValue && string.IsNullOrEmpty(name)) break; - var icon = EISC.StringOutput[StringJoin.SourceIconJoinStart + i].StringValue; - var key = EISC.StringOutput[StringJoin.SourceKeyJoinStart + i].StringValue; - var type = EISC.StringOutput[StringJoin.SourceTypeJoinStart + i].StringValue; - var disableShare = EISC.BooleanOutput[BoolJoin.SourceShareDisableJoinStart + i].BoolValue; + var icon = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceIconJoinStart) + i].StringValue; + var key = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceKeyJoinStart) + i].StringValue; + var type = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceTypeJoinStart) + i].StringValue; + var disableShare = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceShareDisableJoinStart) + i].BoolValue; Debug.Console(0, this, "Adding source {0} '{1}'", key, name); var newSLI = new SourceListItem{ @@ -717,14 +528,14 @@ namespace PepperDash.Essentials.Room.MobileControl var acFavs = new List(); for (uint i = 0; i < 4; i++) { - if (!EISC.GetBool(BoolJoin.SpeedDialVisibleStartJoin + i)) + if (!EISC.GetBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialVisibleStartJoin) + i)) { break; } acFavs.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem() { - Name = EISC.GetString(StringJoin.SpeedDialNameStartJoin + i), - Number = EISC.GetString(StringJoin.SpeedDialNumberStartJoin + i), + Name = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialNameStartJoin) + i), + Number = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialNumberStartJoin) + i), Type = PepperDash.Essentials.Devices.Common.Codec.eCodecCallType.Audio }); } @@ -756,7 +567,7 @@ namespace PepperDash.Essentials.Room.MobileControl var camsProps = new List(); for (uint i = 0; i < 9; i++) { - var name = EISC.GetString(i + StringJoin.CameraNearNameStart); + var name = EISC.GetString(i + JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.CameraNearNameStart)); if (!string.IsNullOrEmpty(name)) { camsProps.Add(new @@ -766,7 +577,7 @@ namespace PepperDash.Essentials.Room.MobileControl }); } } - var farName = EISC.GetString(StringJoin.CameraFarName); + var farName = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.CameraFarName)); if (!string.IsNullOrEmpty(farName)) { camsProps.Add(new @@ -874,7 +685,7 @@ namespace PepperDash.Essentials.Room.MobileControl { if (ConfigIsLoaded) { - var count = EISC.UShortOutput[UshortJoin.NumberOfAuxFaders].UShortValue; + var count = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; Debug.Console(1, this, "The Fader Count is : {0}", count); @@ -882,7 +693,11 @@ namespace PepperDash.Essentials.Room.MobileControl // Create auxFaders var auxFaderDict = new Dictionary(); - for (uint i = 2; i <= count; i++) + + var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + + for (uint i = volumeStart; i <= count; i++) { auxFaderDict.Add("level-" + i, new Volume("level-" + i, @@ -896,22 +711,22 @@ namespace PepperDash.Essentials.Room.MobileControl var volumes = new Volumes(); volumes.Master = new Volume("master", - EISC.UShortOutput[UshortJoin.MasterVolumeLevel].UShortValue, - EISC.BooleanOutput[BoolJoin.MasterVolumeIsMuted].BoolValue, - EISC.StringOutput[1].StringValue, + EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].UShortValue, + EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].BoolValue, + EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].StringValue, true, "something.png"); volumes.Master.HasPrivacyMute = true; - volumes.Master.PrivacyMuted = EISC.BooleanOutput[BoolJoin.PrivacyMute].BoolValue; + volumes.Master.PrivacyMuted = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute)].BoolValue; volumes.AuxFaders = auxFaderDict; - volumes.NumberOfAuxFaders = EISC.UShortInput[UshortJoin.NumberOfAuxFaders].UShortValue; + volumes.NumberOfAuxFaders = EISC.UShortInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; PostStatusMessage(new { activityMode = GetActivityMode(), - isOn = EISC.BooleanOutput[BoolJoin.RoomIsOn].BoolValue, - selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue, + isOn = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.RoomIsOn)].BoolValue, + selectedSourceKey = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey)].StringValue, volumes = volumes }); } @@ -930,9 +745,9 @@ namespace PepperDash.Essentials.Room.MobileControl /// int GetActivityMode() { - if (EISC.BooleanOutput[BoolJoin.ActivityPhoneCall].BoolValue) return 2; - else if (EISC.BooleanOutput[BoolJoin.ActivityShare].BoolValue) return 1; - else if (EISC.BooleanOutput[BoolJoin.ActivityVideoCall].BoolValue) return 3; + if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall)].BoolValue) return 2; + else if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare)].BoolValue) return 1; + else if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall)].BoolValue) return 3; return 0; } @@ -1009,8 +824,8 @@ namespace PepperDash.Essentials.Room.MobileControl protected override void UserCodeChange() { Debug.Console(1, this, "Server user code changed: {0}", UserCode); - EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode; - EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ClientAppUrl; + EISC.StringInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UserCodeToSystem)].StringValue = UserCode; + EISC.StringInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ServerUrl)].StringValue = Parent.Config.ClientAppUrl; } } } \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs index bcea7845..2544c94f 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.AppServer public const string ClientJoined = "ClientJoined"; public const string ActivityShare = "ActivityShare"; public const string ActivityPhoneCall = "ActivityPhoneCall"; - public const string ActivtyVideoCall = "ActivityVideoCall"; + public const string ActivityVideoCall = "ActivityVideoCall"; public const string MasterVolume = "MasterVolumeMute"; public const string VolumeJoinStart = "VolumeMutesJoinStart"; public const string ShutdownCancel = "ShutdownCancel"; @@ -67,15 +67,16 @@ namespace PepperDash.Essentials.AppServer Joins.Add(ClientJoined, new JoinMetadata() { JoinNumber = 42, Label = "Client Joined", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(ActivityShare, new JoinMetadata() { JoinNumber = 51, Label = "Activity Share", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(ActivityPhoneCall, new JoinMetadata() { JoinNumber = 52, Label = "Activity Phone Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ActivtyVideoCall, new JoinMetadata() { JoinNumber = 53, Label = "Activity Video Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(ActivityVideoCall, new JoinMetadata() { JoinNumber = 53, Label = "Activity Video Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(MasterVolume, new JoinMetadata() { JoinNumber = 1, Label = "Master Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.DigitalAnalogSerial }); - Joins.Add(VolumeJoinStart, new JoinMetadata() { JoinNumber = 2, Label = "Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 9, JoinType = eJoinType.DigitalAnalogSerial }); + Joins.Add(VolumeJoinStart, new JoinMetadata() { JoinNumber = 2, Label = "Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 8, JoinType = eJoinType.DigitalAnalogSerial }); Joins.Add(ShutdownCancel, new JoinMetadata() { JoinNumber = 61, Label = "Shutdown Cancel", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(ShutdownEnd, new JoinMetadata() { JoinNumber = 62, Label = "Shutdown End", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(ShutdownStart, new JoinMetadata() { JoinNumber = 63, Label = "ShutdownStart", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(SourceHasChanged, new JoinMetadata() { JoinNumber = 71, Label = "Source Changed", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); // Possibly move these to Audio Codec Messenger Joins.Add(SpeedDialVisibleStartJoin, new JoinMetadata() { JoinNumber = 261, Label = "Speed Dial Visible", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 10, JoinType = eJoinType.Digital }); + // Joins.Add(ConfigIsReady, new JoinMetadata() { JoinNumber = 501, Label = "Config info from SIMPL is ready", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(HideVideoConfRecents, new JoinMetadata() { JoinNumber = 502, Label = "Hide Video Conference Recents", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(ShowCameraWhenNotInCall, new JoinMetadata() { JoinNumber = 503, Label = "Show camera when not in call", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); @@ -93,6 +94,7 @@ namespace PepperDash.Essentials.AppServer // Possibly move these to Audio Codec Messenger Joins.Add(SpeedDialNameStartJoin, new JoinMetadata() { JoinNumber = 241, Label = "Speed Dial names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); Joins.Add(SpeedDialNumberStartJoin, new JoinMetadata() { JoinNumber = 251, Label = "Speed Dial numbers", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); + // Joins.Add(UserCodeToSystem, new JoinMetadata() { JoinNumber = 401, Label = "User Ccde", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(ServerUrl, new JoinMetadata() { JoinNumber = 402, Label = "Server URL", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(ConfigRoomName, new JoinMetadata() { JoinNumber = 501, Label = "Room Nnme", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); @@ -105,8 +107,10 @@ namespace PepperDash.Essentials.AppServer Joins.Add(SourceKeyJoinStart, new JoinMetadata() { JoinNumber = 641, Label = "Source Keys", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); Joins.Add(SourceTypeJoinStart, new JoinMetadata() { JoinNumber = 661, Label = "Source Types", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); + // Possibly move these to Audio Codec Messenger Joins.Add(CameraNearNameStart, new JoinMetadata() { JoinNumber = 761, Label = "Near End Camera Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); - Joins.Add(CameraNearNameStart, new JoinMetadata() { JoinNumber = 770, Label = "Far End Camera Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CameraFarName, new JoinMetadata() { JoinNumber = 770, Label = "Far End Camera Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + // } public override void OffsetJoinNumbers(uint joinStart) diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index aa86b96d..ce4594bc 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -26,13 +26,19 @@ namespace PepperDash.Essentials.Bridges public const string PresetSaveStart = "PresetSaveStart"; public const string PresetLabelStart = "PresetReacllStgart"; public const string NumberOfPresets = "NumberOfPresets"; + public const string CameraModeAuto = "CameraModeAuto"; + public const string CameraModeManual = "CameraModeManual"; + public const string CameraModeOff = "CameraModeOff"; + public const string SupportsCameraModeAuto = "SupportsCameraModeAuto"; + public const string SupportsCameraModeOff = "SupportsCameraModeOff"; + public const string SupportsPresets = "SupportsPresets"; public CameraControllerJoinMap() { - Joins.Add(TiltUp, new JoinMetadata() - { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(TiltDown, new JoinMetadata() - { JoinNumber = 2, Label = "TiltDown", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(TiltDown, new JoinMetadata() + { JoinNumber = 2, Label = "Tilt Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(PanLeft, new JoinMetadata() { JoinNumber = 3, Label = "Pan Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(PanRight, new JoinMetadata() @@ -60,6 +66,19 @@ namespace PepperDash.Essentials.Bridges Joins.Add(NumberOfPresets, new JoinMetadata() { JoinNumber = 11, Label = "Number of Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); + Joins.Add(CameraModeAuto, new JoinMetadata() + { JoinNumber = 51, Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraModeManual, new JoinMetadata() + { JoinNumber = 52, Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraModeOff, new JoinMetadata() + { JoinNumber = 53, Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + Joins.Add(SupportsCameraModeAuto, new JoinMetadata() + { JoinNumber = 55, Label = "Supports Camera Mode Auto", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SupportsCameraModeOff, new JoinMetadata() + { JoinNumber = 56, Label = "Supports Camera Mode Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SupportsPresets, new JoinMetadata() + { JoinNumber = 57, Label = "Supports Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); } public override void OffsetJoinNumbers(uint joinStart) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 6a8dc7ce..620e3b14 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -111,6 +111,18 @@ namespace PepperDash.Essentials.Core else return 0; } + /// + /// Returns the join span for the join with the specified key + /// + /// + /// + public uint GetJoinSpanForKey(string key) + { + if (Joins.ContainsKey(key)) + return Joins[key].JoinSpan; + + else return 0; + } } From 51ece9dafffe52df660678904a9ecf0c1c48cca8 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 19 Dec 2019 17:11:12 -0700 Subject: [PATCH 15/33] Adds SIMPLAtcJoinMap and SIMPLVtcJoinMap and implements them on respective messengers --- .../AppServer/Messengers/SIMPLAtcMessenger.cs | 183 +++--- .../AppServer/Messengers/SIMPLVtcMessenger.cs | 577 +++++++++--------- .../SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 75 +++ .../SIMPLJoinMaps/SIMPLVtcJoinMap.cs | 116 ++++ .../PepperDashEssentials.csproj | 2 + .../JoinMaps/JoinMapBase.cs | 36 ++ 6 files changed, 623 insertions(+), 366 deletions(-) create mode 100644 PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs create mode 100644 PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index 019b7742..96cf2706 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -16,75 +16,77 @@ namespace PepperDash.Essentials.AppServer.Messengers { BasicTriList EISC; - /// - /// 221 - /// - const uint BDialHangupOnHook = 221; + public SIMPLAtcJoinMap JoinMap {get; private set;} - /// - /// 251 - /// - const uint BIncomingAnswer = 251; - /// - /// 252 - /// - const uint BIncomingReject = 252; - /// - /// 241 - /// - const uint BSpeedDial1 = 241; - /// - /// 242 - /// - const uint BSpeedDial2 = 242; - /// - /// 243 - /// - const uint BSpeedDial3 = 243; - /// - /// 244 - /// - const uint BSpeedDial4 = 244; + ///// + ///// 221 + ///// + //const uint BDialHangupOnHook = 221; - /// - /// 201 - /// - const uint SCurrentDialString = 201; - /// - /// 211 - /// - const uint SCurrentCallNumber = 211; - /// - /// 212 - /// - const uint SCurrentCallName = 212; - /// - /// 221 - /// - const uint SHookState = 221; - /// - /// 222 - /// - const uint SCallDirection = 222; + ///// + ///// 251 + ///// + //const uint BIncomingAnswer = 251; + ///// + ///// 252 + ///// + //const uint BIncomingReject = 252; + ///// + ///// 241 + ///// + //const uint BSpeedDial1 = 241; + ///// + ///// 242 + ///// + //const uint BSpeedDial2 = 242; + ///// + ///// 243 + ///// + //const uint BSpeedDial3 = 243; + ///// + ///// 244 + ///// + //const uint BSpeedDial4 = 244; - /// - /// 201-212 0-9*# - /// - Dictionary DTMFMap = new Dictionary - { - { "1", 201 }, - { "2", 202 }, - { "3", 203 }, - { "4", 204 }, - { "5", 205 }, - { "6", 206 }, - { "7", 207 }, - { "8", 208 }, - { "9", 209 }, - { "0", 210 }, - { "*", 211 }, - { "#", 212 }, - }; + ///// + ///// 201 + ///// + //const uint SCurrentDialString = 201; + ///// + ///// 211 + ///// + //const uint SCurrentCallNumber = 211; + ///// + ///// 212 + ///// + //const uint SCurrentCallName = 212; + ///// + ///// 221 + ///// + //const uint SHookState = 221; + ///// + ///// 222 + ///// + //const uint SCallDirection = 222; + + ///// + ///// 201-212 0-9*# + ///// + //Dictionary DTMFMap = new Dictionary + //{ + // { "1", 201 }, + // { "2", 202 }, + // { "3", 203 }, + // { "4", 204 }, + // { "5", 205 }, + // { "6", 206 }, + // { "7", 207 }, + // { "8", 208 }, + // { "9", 209 }, + // { "0", 210 }, + // { "*", 211 }, + // { "#", 212 }, + //}; /// /// @@ -100,7 +102,12 @@ namespace PepperDash.Essentials.AppServer.Messengers public SIMPLAtcMessenger(string key, BasicTriList eisc, string messagePath) : base(key, messagePath) { - EISC = eisc; + EISC = eisc; + + JoinMap = new SIMPLAtcJoinMap(); + + // TODO: Take in JoinStart value from config + JoinMap.OffsetJoinNumbers(201); CurrentCallItem = new CodecActiveCallItem(); CurrentCallItem.Type = eCodecCallType.Audio; @@ -117,9 +124,9 @@ namespace PepperDash.Essentials.AppServer.Messengers this.PostStatusMessage(new { calls = GetCurrentCallList(), - currentCallString = EISC.GetString(SCurrentCallNumber), - currentDialString = EISC.GetString(SCurrentDialString), - isInCall = EISC.GetString(SHookState) == "Connected" + currentCallString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName)), + currentDialString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString)), + isInCall = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState)) == "Connected" }); } @@ -131,26 +138,26 @@ namespace PepperDash.Essentials.AppServer.Messengers { //EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s })); - EISC.SetStringSigAction(SHookState, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState), s => { CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true); //GetCurrentCallList(); SendFullStatus(); }); - EISC.SetStringSigAction(SCurrentCallNumber, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallNumber), s => { CurrentCallItem.Number = s; SendCallsList(); }); - EISC.SetStringSigAction(SCurrentCallName, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName), s => { CurrentCallItem.Name = s; SendCallsList(); }); - EISC.SetStringSigAction(SCallDirection, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CallDirection), s => { CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true); SendCallsList(); @@ -163,25 +170,31 @@ namespace PepperDash.Essentials.AppServer.Messengers // Add straight pulse calls Action addAction = (s, u) => AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/endCallById", BDialHangupOnHook); - addAction("/endAllCalls", BDialHangupOnHook); - addAction("/acceptById", BIncomingAnswer); - addAction("/rejectById", BIncomingReject); - addAction("/speedDial1", BSpeedDial1); - addAction("/speedDial2", BSpeedDial2); - addAction("/speedDial3", BSpeedDial3); - addAction("/speedDial4", BSpeedDial4); + addAction("/endCallById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall)); + addAction("/endAllCalls", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall)); + addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingAnswer)); + addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingReject)); + + var speeddialStart = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart); + var speeddialEnd = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLAtcJoinMap.SpeedDialStart); + + var speedDialIndex = 1; + for (uint i = speeddialStart; i < speeddialEnd; i++) + { + addAction(string.Format("/speedDial{0}", speedDialIndex), i); + } // Get status AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus)); // Dial on string - AppServerController.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(SCurrentDialString, s))); + AppServerController.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString), s))); // Pulse DTMF AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => { - if (DTMFMap.ContainsKey(s)) + var join = JoinMap.GetJoinForKey(s); + if (join > 0) { - EISC.PulseBool(DTMFMap[s], 100); + EISC.PulseBool(join, 100); } })); } diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index d0163288..eaa550d9 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -17,223 +17,225 @@ namespace PepperDash.Essentials.AppServer.Messengers { BasicTriList EISC; - /********* Bools *********/ - /// - /// 724 - /// - const uint BDialHangup = 724; - /// - /// 750 - /// - const uint BCallIncoming = 750; - /// - /// 751 - /// - const uint BIncomingAnswer = 751; - /// - /// 752 - /// - const uint BIncomingReject = 752; - /// - /// 741 - /// - const uint BSpeedDial1 = 741; - /// - /// 742 - /// - const uint BSpeedDial2 = 742; - /// - /// 743 - /// - const uint BSpeedDial3 = 743; - /// - /// 744 - /// - const uint BSpeedDial4 = 744; - /// - /// 800 - /// - const uint BDirectorySearchBusy = 800; - /// - /// 801 - /// - const uint BDirectoryLineSelected = 801; - /// - /// 801 when selected entry is a contact - /// - const uint BDirectoryEntryIsContact = 801; - /// - /// 802 To show/hide back button - /// - const uint BDirectoryIsRoot = 802; - /// - /// 803 Pulse from system to inform us when directory is ready - /// - const uint DDirectoryHasChanged = 803; - /// - /// 804 - /// - const uint BDirectoryRoot = 804; - /// - /// 805 - /// - const uint BDirectoryFolderBack = 805; - /// - /// 806 - /// - const uint BDirectoryDialSelectedLine = 806; - /// - /// 811 - /// - const uint BCameraControlUp = 811; - /// - /// 812 - /// - const uint BCameraControlDown = 812; - /// - /// 813 - /// - const uint BCameraControlLeft = 813; - /// - /// 814 - /// - const uint BCameraControlRight = 814; - /// - /// 815 - /// - const uint BCameraControlZoomIn = 815; - /// - /// 816 - /// - const uint BCameraControlZoomOut = 816; - /// - /// 821 - 826 - /// - const uint BCameraPresetStart = 821; + public SIMPLVtcJoinMap JoinMap { get; private set; } - /// - /// 831 - /// - const uint BCameraModeAuto = 831; - /// - /// 832 - /// - const uint BCameraModeManual = 832; - /// - /// 833 - /// - const uint BCameraModeOff = 833; + ///********* Bools *********/ + ///// + ///// 724 + ///// + //const uint BDialHangup = 724; + ///// + ///// 750 + ///// + //const uint BCallIncoming = 750; + ///// + ///// 751 + ///// + //const uint BIncomingAnswer = 751; + ///// + ///// 752 + ///// + //const uint BIncomingReject = 752; + ///// + ///// 741 + ///// + //const uint BSpeedDial1 = 741; + ///// + ///// 742 + ///// + //const uint BSpeedDial2 = 742; + ///// + ///// 743 + ///// + //const uint BSpeedDial3 = 743; + ///// + ///// 744 + ///// + //const uint BSpeedDial4 = 744; + ///// + ///// 800 + ///// + //const uint BDirectorySearchBusy = 800; + ///// + ///// 801 + ///// + //const uint BDirectoryLineSelected = 801; + ///// + ///// 801 when selected entry is a contact + ///// + //const uint BDirectoryEntryIsContact = 801; + ///// + ///// 802 To show/hide back button + ///// + //const uint BDirectoryIsRoot = 802; + ///// + ///// 803 Pulse from system to inform us when directory is ready + ///// + //const uint BDirectoryHasChanged = 803; + ///// + ///// 804 + ///// + //const uint BDirectoryRoot = 804; + ///// + ///// 805 + ///// + //const uint BDirectoryFolderBack = 805; + ///// + ///// 806 + ///// + //const uint BDirectoryDialSelectedLine = 806; + ///// + ///// 811 + ///// + //const uint BCameraControlUp = 811; + ///// + ///// 812 + ///// + //const uint BCameraControlDown = 812; + ///// + ///// 813 + ///// + //const uint BCameraControlLeft = 813; + ///// + ///// 814 + ///// + //const uint BCameraControlRight = 814; + ///// + ///// 815 + ///// + //const uint BCameraControlZoomIn = 815; + ///// + ///// 816 + ///// + //const uint BCameraControlZoomOut = 816; + ///// + ///// 821 - 826 + ///// + //const uint BCameraPresetStart = 821; - /// - /// 841 - /// - const uint BCameraSelfView = 841; + ///// + ///// 831 + ///// + //const uint BCameraModeAuto = 831; + ///// + ///// 832 + ///// + //const uint BCameraModeManual = 832; + ///// + ///// 833 + ///// + //const uint BCameraModeOff = 833; - /// - /// 842 - /// - const uint BCameraLayout = 842; - /// - /// 843 - /// - const uint BCameraSupportsAutoMode = 843; - /// - /// 844 - /// - const uint BCameraSupportsOffMode = 844; + ///// + ///// 841 + ///// + //const uint BCameraSelfView = 841; + + ///// + ///// 842 + ///// + //const uint BCameraLayout = 842; + ///// + ///// 843 + ///// + //const uint BCameraSupportsAutoMode = 843; + ///// + ///// 844 + ///// + //const uint BCameraSupportsOffMode = 844; - /********* Ushorts *********/ - /// - /// 760 - /// - const uint UCameraNumberSelect = 760; - /// - /// 801 - /// - const uint UDirectorySelectRow = 801; - /// - /// 801 - /// - const uint UDirectoryRowCount = 801; + ///********* Ushorts *********/ + ///// + ///// 760 + ///// + //const uint UCameraNumberSelect = 760; + ///// + ///// 801 + ///// + //const uint UDirectorySelectRow = 801; + ///// + ///// 801 + ///// + //const uint UDirectoryRowCount = 801; - /********* Strings *********/ - /// - /// 701 - /// - const uint SCurrentDialString = 701; - /// - /// 702 - /// - const uint SCurrentCallName = 702; - /// - /// 703 - /// - const uint SCurrentCallNumber = 703; - /// - /// 731 - /// - const uint SHookState = 731; - /// - /// 722 - /// - const uint SCallDirection = 722; - /// - /// 751 - /// - const uint SIncomingCallName = 751; - /// - /// 752 - /// - const uint SIncomingCallNumber = 752; + ///********* Strings *********/ + ///// + ///// 701 + ///// + //const uint SCurrentDialString = 701; + ///// + ///// 702 + ///// + //const uint SCurrentCallName = 702; + ///// + ///// 703 + ///// + //const uint SCurrentCallNumber = 703; + ///// + ///// 731 + ///// + //const uint SHookState = 731; + ///// + ///// 722 + ///// + //const uint SCallDirection = 722; + ///// + ///// 751 + ///// + //const uint SIncomingCallName = 751; + ///// + ///// 752 + ///// + //const uint SIncomingCallNumber = 752; - /// - /// 800 - /// - const uint SDirectorySearchString = 800; - /// - /// 801-1055 - /// - const uint SDirectoryEntriesStart = 801; - /// - /// 1056 - /// - const uint SDirectoryEntrySelectedName = 1056; - /// - /// 1057 - /// - const uint SDirectoryEntrySelectedNumber = 1057; - /// - /// 1058 - /// - const uint SDirectorySelectedFolderName = 1058; + ///// + ///// 800 + ///// + //const uint SDirectorySearchString = 800; + ///// + ///// 801-1055 + ///// + //const uint SDirectoryEntriesStart = 801; + ///// + ///// 1056 + ///// + //const uint SDirectoryEntrySelectedName = 1056; + ///// + ///// 1057 + ///// + //const uint SDirectoryEntrySelectedNumber = 1057; + ///// + ///// 1058 + ///// + //const uint SDirectorySelectedFolderName = 1058; - /// - /// 701-712 0-9*# - /// - Dictionary DTMFMap = new Dictionary - { - { "1", 701 }, - { "2", 702 }, - { "3", 703 }, - { "4", 704 }, - { "5", 705 }, - { "6", 706 }, - { "7", 707 }, - { "8", 708 }, - { "9", 709 }, - { "0", 710 }, - { "*", 711 }, - { "#", 712 }, - }; + ///// + ///// 701-712 0-9*# + ///// + //Dictionary DTMFMap = new Dictionary + //{ + // { "1", 701 }, + // { "2", 702 }, + // { "3", 703 }, + // { "4", 704 }, + // { "5", 705 }, + // { "6", 706 }, + // { "7", 707 }, + // { "8", 708 }, + // { "9", 709 }, + // { "0", 710 }, + // { "*", 711 }, + // { "#", 712 }, + //}; CodecActiveCallItem CurrentCallItem; CodecActiveCallItem IncomingCallItem; - ushort PreviousDirectoryLength = 0; + ushort PreviousDirectoryLength = 701; /// /// @@ -245,6 +247,12 @@ namespace PepperDash.Essentials.AppServer.Messengers { EISC = eisc; + JoinMap = new SIMPLVtcJoinMap(); + + // TODO: Take in JoinStart value from config + JoinMap.OffsetJoinNumbers(200); + + CurrentCallItem = new CodecActiveCallItem(); CurrentCallItem.Type = eCodecCallType.Video; CurrentCallItem.Id = "-video-"; @@ -257,31 +265,31 @@ namespace PepperDash.Essentials.AppServer.Messengers protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) { var asc = appServerController; - EISC.SetStringSigAction(SHookState, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.HookState), s => { CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true); PostFullStatus(); // SendCallsList(); }); - EISC.SetStringSigAction(SCurrentCallNumber, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallNumber), s => { CurrentCallItem.Number = s; PostCallsList(); }); - EISC.SetStringSigAction(SCurrentCallName, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallName), s => { CurrentCallItem.Name = s; PostCallsList(); }); - EISC.SetStringSigAction(SCallDirection, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CallDirection), s => { CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true); PostCallsList(); }); - EISC.SetBoolSigAction(BCallIncoming, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCall), b => { if (b) { @@ -289,8 +297,8 @@ namespace PepperDash.Essentials.AppServer.Messengers { Direction = eCodecCallDirection.Incoming, Id = "-video-incoming", - Name = EISC.GetString(SIncomingCallName), - Number = EISC.GetString(SIncomingCallNumber), + Name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCallName)), + Number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCallNumber)), Status = eCodecCallStatus.Ringing, Type = eCodecCallType.Video }; @@ -303,14 +311,14 @@ namespace PepperDash.Essentials.AppServer.Messengers PostCallsList(); }); - EISC.SetBoolSigAction(BCameraSupportsAutoMode, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsAutoMode), b => { PostStatusMessage(new { cameraSupportsAutoMode = b }); }); - EISC.SetBoolSigAction(BCameraSupportsOffMode, b => + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsOffMode), b => { PostStatusMessage(new { @@ -319,91 +327,97 @@ namespace PepperDash.Essentials.AppServer.Messengers }); // Directory insanity - EISC.SetUShortSigAction(UDirectoryRowCount, u => + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount), u => { // The length of the list comes in before the list does. // Splice the sig change operation onto the last string sig that will be changing // when the directory entries make it through. if (PreviousDirectoryLength > 0) { - EISC.ClearStringSigAction(SDirectoryEntriesStart + PreviousDirectoryLength - 1); + EISC.ClearStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + PreviousDirectoryLength - 1); } - EISC.SetStringSigAction(SDirectoryEntriesStart + u - 1, s => PostDirectory()); + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + u - 1, s => PostDirectory()); PreviousDirectoryLength = u; }); - EISC.SetStringSigAction(SDirectoryEntrySelectedName, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName), s => { PostStatusMessage(new { directoryContactSelected = new { - name = EISC.GetString(SDirectoryEntrySelectedName), + name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName)), } }); }); - EISC.SetStringSigAction(SDirectoryEntrySelectedNumber, s => + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber), s => { PostStatusMessage(new { directoryContactSelected = new { - number = EISC.GetString(SDirectoryEntrySelectedNumber), + number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber)), } }); }); - EISC.SetStringSigAction(SDirectorySelectedFolderName, s => PostStatusMessage(new + EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName), s => PostStatusMessage(new { - directorySelectedFolderName = EISC.GetString(SDirectorySelectedFolderName) + directorySelectedFolderName = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName)) })); - EISC.SetSigTrueAction(BCameraModeAuto, () => PostCameraMode()); - EISC.SetSigTrueAction(BCameraModeManual, () => PostCameraMode()); - EISC.SetSigTrueAction(BCameraModeOff, () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto), () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual), () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeOff), () => PostCameraMode()); - EISC.SetBoolSigAction(BCameraSelfView, b => PostStatusMessage(new + EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView), b => PostStatusMessage(new { cameraSelfView = b })); - EISC.SetUShortSigAction(UCameraNumberSelect, (u) => PostSelectedCamera()); + EISC.SetUShortSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), (u) => PostSelectedCamera()); // 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); - addPHAction("/cameraDown", BCameraControlDown); - addPHAction("/cameraLeft", BCameraControlLeft); - addPHAction("/cameraRight", BCameraControlRight); - addPHAction("/cameraZoomIn", BCameraControlZoomIn); - addPHAction("/cameraZoomOut", BCameraControlZoomOut); + addPHAction("/cameraUp", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraTiltUp)); + addPHAction("/cameraDown", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraTiltDown)); + addPHAction("/cameraLeft", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPanLeft)); + addPHAction("/cameraRight", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPanRight)); + addPHAction("/cameraZoomIn", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraZoomIn)); + addPHAction("/cameraZoomOut", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraZoomOut)); // Add straight pulse calls using helper action Action addAction = (s, u) => AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/endCallById", BDialHangup); - addAction("/endAllCalls", BDialHangup); - addAction("/acceptById", BIncomingAnswer); - addAction("/rejectById", BIncomingReject); - addAction("/speedDial1", BSpeedDial1); - addAction("/speedDial2", BSpeedDial2); - addAction("/speedDial3", BSpeedDial3); - addAction("/speedDial4", BSpeedDial4); - addAction("/cameraModeAuto", BCameraModeAuto); - addAction("/cameraModeManual", BCameraModeManual); - addAction("/cameraModeOff", BCameraModeOff); - addAction("/cameraSelfView", BCameraSelfView); - addAction("/cameraLayout", BCameraLayout); + addAction("/endCallById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.EndCall)); + addAction("/endAllCalls", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.EndCall)); + addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingAnswer)); + addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingReject)); + + var speeddialStart = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart); + var speeddialEnd = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLAtcJoinMap.SpeedDialStart); + + var speedDialIndex = 1; + for (uint i = speeddialStart; i < speeddialEnd; i++) + { + addAction(string.Format("/speedDial{0}", speedDialIndex), i); + } + + addAction("/cameraModeAuto", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto)); + addAction("/cameraModeManual", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual)); + addAction("/cameraModeOff", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeOff)); + addAction("/cameraSelfView", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView)); + addAction("/cameraLayout", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraLayout)); asc.AddAction("/cameraSelect", new Action(SelectCamera)); // camera presets for(uint i = 0; i < 6; i++) { - addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i); + addAction("/cameraPreset" + (i + 1), JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPresetStart) + i); } asc.AddAction(MessagePath + "/isReady", new Action(PostIsReady)); @@ -411,27 +425,28 @@ namespace PepperDash.Essentials.AppServer.Messengers asc.AddAction(MessagePath + "/fullStatus", new Action(PostFullStatus)); // Dial on string asc.AddAction(MessagePath + "/dial", new Action(s => - EISC.SetString(SCurrentDialString, s))); - // Pulse DTMF - asc.AddAction(MessagePath + "/dtmf", new Action(s => - { - if (DTMFMap.ContainsKey(s)) - { - EISC.PulseBool(DTMFMap[s], 100); - } - })); + EISC.SetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentDialString), s))); + // Pulse DTMF + AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => + { + var join = JoinMap.GetJoinForKey(s); + if (join > 0) + { + EISC.PulseBool(join, 100); + } + })); // Directory madness - asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(BDirectoryRoot))); - asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(BDirectoryFolderBack))); + asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRoot)))); + asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryFolderBack)))); asc.AddAction(MessagePath + "/directoryById", new Action(s => { // the id should contain the line number to forward to simpl try { var u = ushort.Parse(s); - EISC.SetUshort(UDirectorySelectRow, u); - EISC.PulseBool(BDirectoryLineSelected); + EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectRow), u); + EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryLineSelected)); } catch (Exception) { @@ -445,8 +460,8 @@ namespace PepperDash.Essentials.AppServer.Messengers try { var u = ushort.Parse(s); - EISC.SetUshort(UDirectorySelectRow, u); - EISC.PulseBool(BDirectoryLineSelected); + EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectRow), u); + EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryLineSelected)); } catch { @@ -454,17 +469,17 @@ namespace PepperDash.Essentials.AppServer.Messengers } })); asc.AddAction(MessagePath + "/directoryDialContact", new Action(() => { - EISC.PulseBool(BDirectoryDialSelectedLine); + EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryDialSelectedLine)); })); asc.AddAction(MessagePath + "/getDirectory", new Action(() => { - if (EISC.GetUshort(UDirectoryRowCount) > 0) + if (EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount)) > 0) { PostDirectory(); } else { - EISC.PulseBool(BDirectoryRoot); + EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRoot)); } })); } @@ -478,18 +493,18 @@ namespace PepperDash.Essentials.AppServer.Messengers { calls = GetCurrentCallList(), cameraMode = GetCameraMode(), - cameraSelfView = EISC.GetBool(BCameraSelfView), - cameraSupportsAutoMode = EISC.GetBool(BCameraSupportsAutoMode), - cameraSupportsOffMode = EISC.GetBool(BCameraSupportsOffMode), - currentCallString = EISC.GetString(SCurrentCallNumber), - currentDialString = EISC.GetString(SCurrentDialString), + cameraSelfView = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView)), + cameraSupportsAutoMode = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsAutoMode)), + cameraSupportsOffMode = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsOffMode)), + currentCallString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallNumber)), + currentDialString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentDialString)), directoryContactSelected = new { - name = EISC.GetString(SDirectoryEntrySelectedName), - number = EISC.GetString(SDirectoryEntrySelectedNumber) + name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName)), + number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber)) }, - directorySelectedFolderName = EISC.GetString(SDirectorySelectedFolderName), - isInCall = EISC.GetString(SHookState) == "Connected", + directorySelectedFolderName = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName)), + isInCall = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.HookState)) == "Connected", hasDirectory = true, hasDirectorySearch = false, hasRecents = !EISC.BooleanOutput[502].BoolValue, @@ -504,11 +519,11 @@ namespace PepperDash.Essentials.AppServer.Messengers /// void PostDirectory() { - var u = EISC.GetUshort(UDirectoryRowCount); + var u = EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount)); var items = new List(); for (uint i = 0; i < u; i++) { - var name = EISC.GetString(SDirectoryEntriesStart + i); + var name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + i); var id = (i + 1).ToString(); // is folder or contact? if (name.StartsWith("[+]")) @@ -533,7 +548,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { currentDirectory = new { - isRootDirectory = EISC.GetBool(BDirectoryIsRoot), + isRootDirectory = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryIsRoot)), directoryResults = items } }; @@ -558,8 +573,8 @@ namespace PepperDash.Essentials.AppServer.Messengers string GetCameraMode() { string m; - if (EISC.GetBool(BCameraModeAuto)) m = eCameraControlMode.Auto.ToString().ToLower(); - else if (EISC.GetBool(BCameraModeManual)) m = eCameraControlMode.Manual.ToString().ToLower(); + if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto))) m = eCameraControlMode.Auto.ToString().ToLower(); + else if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual))) m = eCameraControlMode.Manual.ToString().ToLower(); else m = eCameraControlMode.Off.ToString().ToLower(); return m; } @@ -577,7 +592,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// string GetSelectedCamera() { - var num = EISC.GetUshort(UCameraNumberSelect); + var num = EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect)); string m; if (num == 100) { @@ -621,11 +636,11 @@ namespace PepperDash.Essentials.AppServer.Messengers var cam = s.Substring(6); if (cam.ToLower() == "far") { - EISC.SetUshort(UCameraNumberSelect, 100); + EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), 100); } else { - EISC.SetUshort(UCameraNumberSelect, UInt16.Parse(cam)); + EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), UInt16.Parse(cam)); } } @@ -640,7 +655,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { list.Add(CurrentCallItem); } - if (EISC.GetBool(BCallIncoming)) { + if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CallIncoming))) { } return list; diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs new file mode 100644 index 00000000..d1b19e0f --- /dev/null +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.AppServer +{ + public class SIMPLAtcJoinMap : JoinMapBase + { + public const string EndCall = "EndCall"; + public const string IncomingAnswer = "IncomingAnswer"; + public const string IncomingReject = "IncomingReject"; + public const string SpeedDialStart = "SpeedDialStart"; + public const string CurrentDialString = "CurrentDialString"; + public const string CurrentCallNumber = "CurrentCallNumber"; + public const string CurrentCallName = "CurrentCallName"; + public const string HookState = "HookState"; + public const string CallDirection = "CallDirection"; + public const string Dtmf0 = "0"; + public const string Dtmf1 = "1"; + public const string Dtmf2 = "2"; + public const string Dtmf3 = "3"; + public const string Dtmf4 = "4"; + public const string Dtmf5 = "5"; + public const string Dtmf6 = "6"; + public const string Dtmf7 = "7"; + public const string Dtmf8 = "8"; + public const string Dtmf9 = "9"; + public const string DtmfStar = "*"; + public const string DtmfPound = "#"; + + + public SIMPLAtcJoinMap() + { + Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 21, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IncomingAnswer, new JoinMetadata() { JoinNumber = 51, Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IncomingReject, new JoinMetadata() { JoinNumber = 52, Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SpeedDialStart, new JoinMetadata() { JoinNumber = 41, Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 4, JoinType = eJoinType.Digital }); + Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(HookState, new JoinMetadata() { JoinNumber = 21, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 21, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf4, new JoinMetadata() { JoinNumber = 4, Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf5, new JoinMetadata() { JoinNumber = 5, Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf6, new JoinMetadata() { JoinNumber = 6, Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf7, new JoinMetadata() { JoinNumber = 7, Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf8, new JoinMetadata() { JoinNumber = 8, Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf9, new JoinMetadata() { JoinNumber = 9, Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf0, new JoinMetadata() { JoinNumber = 10, Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DtmfStar, new JoinMetadata() { JoinNumber = 11, Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DtmfPound, new JoinMetadata() { JoinNumber = 12, Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + foreach (var join in Joins) + { + join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; + } + + PrintJoinMapInfo(); + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs new file mode 100644 index 00000000..788bd33b --- /dev/null +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.AppServer +{ + public class SIMPLVtcJoinMap : JoinMapBase + { + public const string EndCall = "EndCall"; + public const string IncomingCall = "IncomingCall"; + public const string IncomingAnswer = "IncomingAnswer"; + public const string IncomingReject = "IncomingReject"; + public const string SpeedDialStart = "SpeedDialStart"; + public const string DirectorySearchBusy = "DirectorySearchBusy"; + public const string DirectoryLineSelected = "DirectoryLineSelected"; + public const string DirectoryEntryIsContact = "DirectoryEntryIsContact"; + public const string DirectoryIsRoot = "DirectoryIsRoot"; + public const string DDirectoryHasChanged = "DDirectoryHasChanged"; + public const string DirectoryRoot = "DirectoryRoot"; + public const string DirectoryFolderBack = "DirectoryFoldeBrack"; + public const string DirectoryDialSelectedLine = "DirectoryDialSelectedLine"; + + public const string CameraTiltUp = "CameraTiltUp"; + public const string CameraTiltDown = "CameraTiltDown"; + public const string CameraPanLeft = "CameraPanLeft"; + public const string CameraPanRight = "CameraPanRight"; + public const string CameraZoomIn = "CameraZoomIn"; + public const string CameraZoomOut = "CameraZoomOut"; + public const string CameraPresetStart = "CameraPresetStart"; + public const string CameraModeAuto = "CameraModeAuto"; + public const string CameraModeManual = "CameraModeManual"; + public const string CameraModeOff = "CameraModeOff"; + + public const string CameraSelfView = "CameraSelfView"; + public const string CameraLayout = "CameraLayout"; + + public const string CameraSupportsAutoMode = "CameraSupportsAutoMode"; + public const string CameraSupportsOffMode = "CameraSupportsOffMode"; + + public const string CameraNumberSelect = "CameraNumberSelect"; + public const string DirectorySelectRow = "DirectorySelectRow"; + public const string DirectoryRowCount = "DirectoryRowCount"; + + public const string CurrentDialString = "CurrentDialString"; + public const string CurrentCallNumber = "CurrentCallNumber"; + public const string CurrentCallName = "CurrentCallName"; + public const string HookState = "HookState"; + public const string CallDirection = "CallDirection"; + public const string IncomingCallName = "IncomingCallName"; + public const string IncomingCallNumber = "IncomingCallNumber"; + public const string DirectorySearchString = "DirectorySearchString"; + public const string DirectoryEntriesStart = "EndCaDirectoryEntriesStartll"; + public const string DirectoryEntrySelectedName = "DirectoryEntrySelectedName"; + public const string DirectoryEntrySelectedNumber = "DirectoryEntrySelectedNumber"; + public const string DirectorySelectedFolderName = "DirectorySelectedFolderName"; + + public const string Dtmf0 = "0"; + public const string Dtmf1 = "1"; + public const string Dtmf2 = "2"; + public const string Dtmf3 = "3"; + public const string Dtmf4 = "4"; + public const string Dtmf5 = "5"; + public const string Dtmf6 = "6"; + public const string Dtmf7 = "7"; + public const string Dtmf8 = "8"; + public const string Dtmf9 = "9"; + public const string DtmfStar = "*"; + public const string DtmfPound = "#"; + + + public SIMPLVtcJoinMap() + { + // TODO: Set Join metedata + + Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 21, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IncomingAnswer, new JoinMetadata() { JoinNumber = 51, Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IncomingReject, new JoinMetadata() { JoinNumber = 52, Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(SpeedDialStart, new JoinMetadata() { JoinNumber = 41, Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 4, JoinType = eJoinType.Digital }); + Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(HookState, new JoinMetadata() { JoinNumber = 21, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 21, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf4, new JoinMetadata() { JoinNumber = 4, Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf5, new JoinMetadata() { JoinNumber = 5, Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf6, new JoinMetadata() { JoinNumber = 6, Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf7, new JoinMetadata() { JoinNumber = 7, Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf8, new JoinMetadata() { JoinNumber = 8, Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf9, new JoinMetadata() { JoinNumber = 9, Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(Dtmf0, new JoinMetadata() { JoinNumber = 10, Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DtmfStar, new JoinMetadata() { JoinNumber = 11, Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DtmfPound, new JoinMetadata() { JoinNumber = 12, Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + foreach (var join in Joins) + { + join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; + } + + PrintJoinMapInfo(); + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 063c3796..79972021 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -120,6 +120,8 @@ + + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 620e3b14..3dcb26a2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -185,4 +185,40 @@ namespace PepperDash.Essentials.Core } + public enum eBiologicalSex + { + Unknown = 0, + Female = 1, + Male = 2, + Intersex = Male | Female + } + + public class Human + { + + eBiologicalSex BiologicalSex; + + public bool IsMale + { + get { return (BiologicalSex & eBiologicalSex.Male) == eBiologicalSex.Male; } + } + + public bool IsFemale + { + get { return (BiologicalSex & eBiologicalSex.Female) == eBiologicalSex.Female; } + } + + public bool IsIntersex + { + get { return (BiologicalSex & eBiologicalSex.Intersex) == eBiologicalSex.Intersex; } + } + + public bool IsDeservingOfBasicHumanRights + { + get + { + return this is Human; + } + } + } } \ No newline at end of file From df92bdac8e36ed19f1805c939197e77d5e6609fb Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 20 Dec 2019 10:33:03 -0700 Subject: [PATCH 16/33] Updates to SIMPLVtcJoinMap --- .../AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs index 788bd33b..d7f45673 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs @@ -77,10 +77,19 @@ namespace PepperDash.Essentials.AppServer { // TODO: Set Join metedata - Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 21, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 24, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(IncomingCall, new JoinMetadata() { JoinNumber = 50, Label = "Incoming Call FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(IncomingAnswer, new JoinMetadata() { JoinNumber = 51, Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(IncomingReject, new JoinMetadata() { JoinNumber = 52, Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(SpeedDialStart, new JoinMetadata() { JoinNumber = 41, Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 4, JoinType = eJoinType.Digital }); + + Joins.Add(DirectorySearchBusy, new JoinMetadata() { JoinNumber = 100, Label = "Directory Search Busy FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryLineSelected, new JoinMetadata() { JoinNumber = 101, Label = "Directory Line Selected FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryEntryIsContact, new JoinMetadata() { JoinNumber = 101, Label = "Directory Selected Entry Is Contact FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryIsRoot, new JoinMetadata() { JoinNumber = 102, Label = "Directory is on Root FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DDirectoryHasChanged, new JoinMetadata() { JoinNumber = 103, Label = "Directory has changed FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); From e218f13d450fc9bcca19cd263cc6c18b75583c42 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 2 Jan 2020 15:59:04 -0700 Subject: [PATCH 17/33] Finished SIMPLVtcJoinMap --- .../SIMPLJoinMaps/SIMPLVtcJoinMap.cs | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs index d7f45673..c2b17b30 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs @@ -88,13 +88,46 @@ namespace PepperDash.Essentials.AppServer Joins.Add(DirectoryEntryIsContact, new JoinMetadata() { JoinNumber = 101, Label = "Directory Selected Entry Is Contact FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(DirectoryIsRoot, new JoinMetadata() { JoinNumber = 102, Label = "Directory is on Root FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(DDirectoryHasChanged, new JoinMetadata() { JoinNumber = 103, Label = "Directory has changed FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryRoot, new JoinMetadata() { JoinNumber = 104, Label = "Go to Directory Root", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryFolderBack, new JoinMetadata() { JoinNumber = 105, Label = "Go back one directory level", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(DirectoryDialSelectedLine, new JoinMetadata() { JoinNumber = 106, Label = "Dial selected directory line", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraTiltUp, new JoinMetadata() { JoinNumber = 111, Label = "Camera Tilt Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraTiltDown, new JoinMetadata() { JoinNumber = 112, Label = "Camera Tilt Down", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraPanLeft, new JoinMetadata() { JoinNumber = 113, Label = "Camera Pan Left", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraPanRight, new JoinMetadata() { JoinNumber = 114, Label = "Camera Pan Right", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraZoomIn, new JoinMetadata() { JoinNumber = 115, Label = "Camera Zoom In", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraZoomOut, new JoinMetadata() { JoinNumber = 116, Label = "Camera Zoom Out", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraPresetStart, new JoinMetadata() { JoinNumber = 121, Label = "Camera Presets", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 5, JoinType = eJoinType.Digital }); + Joins.Add(CameraModeAuto, new JoinMetadata() { JoinNumber = 131, Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraModeManual, new JoinMetadata() { JoinNumber = 132, Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraModeOff, new JoinMetadata() { JoinNumber = 133, Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + Joins.Add(CameraSelfView, new JoinMetadata() { JoinNumber = 141, Label = "Camera Self View Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraLayout, new JoinMetadata() { JoinNumber = 142, Label = "Camera Layout Toggle", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + Joins.Add(CameraSupportsAutoMode, new JoinMetadata() { JoinNumber = 143, Label = "Camera Supports Auto Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add(CameraSupportsOffMode, new JoinMetadata() { JoinNumber = 144, Label = "Camera Supports Off Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); + + + Joins.Add(CameraNumberSelect, new JoinMetadata() { JoinNumber = 60, Label = "Camera Number Select/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); + Joins.Add(DirectorySelectRow, new JoinMetadata() { JoinNumber = 101, Label = "Directory Select Row/FB", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); + Joins.Add(DirectoryRowCount, new JoinMetadata() { JoinNumber = 101, Label = "Directory Row Count FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(HookState, new JoinMetadata() { JoinNumber = 21, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 21, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 3, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 2, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(HookState, new JoinMetadata() { JoinNumber = 31, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 22, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(IncomingCallName, new JoinMetadata() { JoinNumber = 51, Label = "Incoming Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(IncomingCallNumber, new JoinMetadata() { JoinNumber = 52, Label = "Incoming Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + + Joins.Add(DirectorySearchString, new JoinMetadata() { JoinNumber = 52, Label = "Directory Search String", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntriesStart, new JoinMetadata() { JoinNumber = 52, Label = "Directory Entries", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 255, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntrySelectedName, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Entry Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntrySelectedNumber, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Entry Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectorySelectedFolderName, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Folder Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); @@ -107,7 +140,6 @@ namespace PepperDash.Essentials.AppServer Joins.Add(Dtmf0, new JoinMetadata() { JoinNumber = 10, Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(DtmfStar, new JoinMetadata() { JoinNumber = 11, Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(DtmfPound, new JoinMetadata() { JoinNumber = 12, Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - } public override void OffsetJoinNumbers(uint joinStart) From 1a44d28adb881b75e475940d8db08d4bf7749a7b Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 2 Jan 2020 16:03:09 -0700 Subject: [PATCH 18/33] Fixes incorrect variable name --- PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index eaa550d9..751c1007 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -655,7 +655,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { list.Add(CurrentCallItem); } - if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CallIncoming))) { + if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCall))) { } return list; From dd1b15edee76e4b281851dcb126858dd9fc8d4c2 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 6 Jan 2020 15:41:59 -0700 Subject: [PATCH 19/33] Fixed issues found with join numbers and speed dial iteration --- .../AppServer/Messengers/SIMPLAtcMessenger.cs | 1 + .../AppServer/Messengers/SIMPLVtcMessenger.cs | 3 ++- .../AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 2 +- .../AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs | 10 +++++----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index 96cf2706..b29fe890 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -182,6 +182,7 @@ namespace PepperDash.Essentials.AppServer.Messengers for (uint i = speeddialStart; i < speeddialEnd; i++) { addAction(string.Format("/speedDial{0}", speedDialIndex), i); + speedDialIndex++; } // Get status diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index 751c1007..b81b2276 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -250,7 +250,7 @@ namespace PepperDash.Essentials.AppServer.Messengers JoinMap = new SIMPLVtcJoinMap(); // TODO: Take in JoinStart value from config - JoinMap.OffsetJoinNumbers(200); + JoinMap.OffsetJoinNumbers(701); CurrentCallItem = new CodecActiveCallItem(); @@ -404,6 +404,7 @@ namespace PepperDash.Essentials.AppServer.Messengers for (uint i = speeddialStart; i < speeddialEnd; i++) { addAction(string.Format("/speedDial{0}", speedDialIndex), i); + speedDialIndex++; } addAction("/cameraModeAuto", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto)); diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs index d1b19e0f..b5e8c568 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -44,7 +44,7 @@ namespace PepperDash.Essentials.AppServer Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(HookState, new JoinMetadata() { JoinNumber = 21, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 21, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 22, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs index c2b17b30..b5776065 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs @@ -122,11 +122,11 @@ namespace PepperDash.Essentials.AppServer Joins.Add(IncomingCallName, new JoinMetadata() { JoinNumber = 51, Label = "Incoming Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(IncomingCallNumber, new JoinMetadata() { JoinNumber = 52, Label = "Incoming Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectorySearchString, new JoinMetadata() { JoinNumber = 52, Label = "Directory Search String", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntriesStart, new JoinMetadata() { JoinNumber = 52, Label = "Directory Entries", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 255, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntrySelectedName, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Entry Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntrySelectedNumber, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Entry Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectorySelectedFolderName, new JoinMetadata() { JoinNumber = 52, Label = "Selected Directory Folder Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectorySearchString, new JoinMetadata() { JoinNumber = 100, Label = "Directory Search String", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntriesStart, new JoinMetadata() { JoinNumber = 101, Label = "Directory Entries", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 255, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntrySelectedName, new JoinMetadata() { JoinNumber = 356, Label = "Selected Directory Entry Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectoryEntrySelectedNumber, new JoinMetadata() { JoinNumber = 357, Label = "Selected Directory Entry Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); + Joins.Add(DirectorySelectedFolderName, new JoinMetadata() { JoinNumber = 358, Label = "Selected Directory Folder Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); From 7f87b083cb60dd656ca57226115f8c0e52711d2d Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 16 Jan 2020 20:12:44 -0700 Subject: [PATCH 20/33] Adds improved camera messaging to VideoCodecBaseMessenger --- .../Messengers/VideoCodecBaseMessenger.cs | 225 +++++++++++++++++- 1 file changed, 224 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs b/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs index 29c80085..0ee943c9 100644 --- a/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/VideoCodecBaseMessenger.cs @@ -7,6 +7,8 @@ using Crestron.SimplSharp; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using PepperDash.Core; + using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.Cameras; using PepperDash.Essentials.Devices.Common.VideoCodec; @@ -202,6 +204,59 @@ namespace PepperDash.Essentials.AppServer.Messengers { appServerController.AddAction(MessagePath + "/getCallHistory", new Action(GetCallHistory)); } + var cameraCodec = Codec as IHasCodecCameras; + if (cameraCodec != null) + { + Debug.Console(2, this, "Adding IHasCodecCameras Actions"); + + cameraCodec.CameraSelected += new EventHandler(cameraCodec_CameraSelected); + + appServerController.AddAction(MessagePath + "/cameraSelect", new Action(s => cameraCodec.SelectCamera(s))); + + MapCameraActions(); + + var presetsCodec = Codec as IHasCodecRoomPresets; + if (presetsCodec != null) + { + Debug.Console(2, this, "Adding IHasCodecRoomPresets Actions"); + + presetsCodec.CodecRoomPresetsListHasChanged += new EventHandler(presetsCodec_CameraPresetsListHasChanged); + + appServerController.AddAction(MessagePath + "/cameraPreset", new Action(u => presetsCodec.CodecRoomPresetSelect(u))); + appServerController.AddAction(MessagePath + "/cameraPresetStore", new Action(p => presetsCodec.CodecRoomPresetStore(p.ID, p.Description))); + } + + var speakerTrackCodec = Codec as IHasCameraAutoMode; + if (speakerTrackCodec != null) + { + Debug.Console(2, this, "Adding IHasCameraAutoMode Actions"); + + speakerTrackCodec.CameraAutoModeIsOnFeedback.OutputChange += new EventHandler(CameraAutoModeIsOnFeedback_OutputChange); + + appServerController.AddAction(MessagePath + "/cameraAuto", new Action(speakerTrackCodec.CameraAutoModeOn)); + appServerController.AddAction(MessagePath + "/cameraManual", new Action(speakerTrackCodec.CameraAutoModeOff)); + } + } + + var selfViewCodec = Codec as IHasCodecSelfView; + + if (selfViewCodec != null) + { + Debug.Console(2, this, "Adding IHasCodecSelfView Actions"); + + appServerController.AddAction(MessagePath + "/cameraSelfView", new Action(selfViewCodec.SelfViewModeToggle)); + } + + var layoutsCodec = Codec as IHasCodecLayouts; + + if (layoutsCodec != null) + { + Debug.Console(2, this, "Adding IHasCodecLayouts Actions"); + + appServerController.AddAction(MessagePath + "/cameraRemoteView", new Action(layoutsCodec.LocalLayoutToggle)); + } + + Debug.Console(2, this, "Adding Privacy & Standby Actions"); appServerController.AddAction(MessagePath + "/privacyModeOn", new Action(Codec.PrivacyModeOn)); appServerController.AddAction(MessagePath + "/privacyModeOff", new Action(Codec.PrivacyModeOff)); @@ -212,6 +267,89 @@ namespace PepperDash.Essentials.AppServer.Messengers appServerController.AddAction(MessagePath + "/standbyOff", new Action(Codec.StandbyDeactivate)); } + void presetsCodec_CameraPresetsListHasChanged(object sender, EventArgs e) + { + PostCameraPresets(); + } + + void CameraAutoModeIsOnFeedback_OutputChange(object sender, PepperDash.Essentials.Core.FeedbackEventArgs e) + { + PostCameraMode(); + } + + + void cameraCodec_CameraSelected(object sender, CameraSelectedEventArgs e) + { + MapCameraActions(); + PostSelectedCamera(); + } + + /// + /// Maps the camera control actions to the current selected camera on the codec + /// + void MapCameraActions() + { + var cameraCodec = Codec as IHasCameras; + + if (cameraCodec != null && cameraCodec.SelectedCamera != null) + { + + AppServerController.RemoveAction(MessagePath + "/cameraUp"); + AppServerController.RemoveAction(MessagePath + "/cameraDown"); + AppServerController.RemoveAction(MessagePath + "/cameraLeft"); + AppServerController.RemoveAction(MessagePath + "/cameraRight"); + AppServerController.RemoveAction(MessagePath + "/cameraZoomIn"); + AppServerController.RemoveAction(MessagePath + "/cameraZoomOut"); + AppServerController.RemoveAction(MessagePath + "/cameraHome"); + + var camera = cameraCodec.SelectedCamera as IHasCameraPtzControl; + if (camera != null) + { + AppServerController.AddAction(MessagePath + "/cameraUp", new PressAndHoldAction(new Action(b => { if (b)camera.TiltUp(); else camera.TiltStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraDown", new PressAndHoldAction(new Action(b => { if (b)camera.TiltDown(); else camera.TiltStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraLeft", new PressAndHoldAction(new Action(b => { if (b)camera.PanLeft(); else camera.PanStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraRight", new PressAndHoldAction(new Action(b => { if (b)camera.PanRight(); else camera.PanStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraZoomIn", new PressAndHoldAction(new Action(b => { if (b)camera.ZoomIn(); else camera.ZoomStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraZoomOut", new PressAndHoldAction(new Action(b => { if (b)camera.ZoomOut(); else camera.ZoomStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraHome", new Action(camera.PositionHome)); + + var focusCamera = cameraCodec as IHasCameraFocusControl; + + AppServerController.RemoveAction(MessagePath + "/cameraAutoFocus"); + AppServerController.RemoveAction(MessagePath + "/cameraFocusNear"); + AppServerController.RemoveAction(MessagePath + "/cameraFocusFar"); + + if (focusCamera != null) + { + AppServerController.AddAction(MessagePath + "/cameraAutoFocus", new Action(focusCamera.TriggerAutoFocus)); + AppServerController.AddAction(MessagePath + "/cameraFocusNear", new PressAndHoldAction(new Action(b => { if (b)focusCamera.FocusNear(); else focusCamera.FocusStop(); }))); + AppServerController.AddAction(MessagePath + "/cameraFocusFar", new PressAndHoldAction(new Action(b => { if (b)focusCamera.FocusFar(); else focusCamera.FocusStop(); }))); + } + } + } + } + + string GetCameraMode() + { + string m = ""; + + var speakerTrackCodec = Codec as IHasCameraAutoMode; + if (speakerTrackCodec != null) + { + if (speakerTrackCodec.CameraAutoModeIsOnFeedback.BoolValue) m = eCameraControlMode.Auto.ToString(); + else m = eCameraControlMode.Manual.ToString(); + } + + var cameraOffCodec = Codec as IHasCameraOff; + if (cameraOffCodec != null) + { + if (cameraOffCodec.CameraIsOffFeedback.BoolValue) + m = eCameraControlMode.Off.ToString(); + } + + return m; + } + void GetCallHistory() { var codec = (Codec as IHasCallHistory); @@ -344,6 +482,22 @@ namespace PepperDash.Essentials.AppServer.Messengers return; } + object cameraInfo = null; + + var camerasCodec = Codec as IHasCodecCameras; + if (camerasCodec != null) + { + cameraInfo = new + { + cameraManualSupported = true, // For now, we assume manual mode is supported and selectively hide controls based on camera selection + cameraAutoSupported = Codec is IHasCameraAutoMode, + cameraOffSupported = Codec is IHasCameraOff, + cameraMode = GetCameraMode(), + cameraList = camerasCodec.Cameras, + selectedCamera = GetSelectedCamera(camerasCodec) + }; + } + var info = Codec.CodecInfo; PostStatusMessage(new { @@ -366,8 +520,77 @@ namespace PepperDash.Essentials.AppServer.Messengers hasDirectory = Codec is IHasDirectory, hasDirectorySearch = true, hasRecents = Codec is IHasCallHistory, - hasCameras = Codec is IHasCodecCameras + hasCameras = Codec is IHasCameras, + cameras = cameraInfo, + presets = GetCurrentPresets() }); } + + /// + /// + /// + void PostCameraMode() + { + PostStatusMessage(new + { + cameras = new + { + cameraMode = GetCameraMode() + } + }); + } + + void PostSelectedCamera() + { + var camerasCodec = Codec as IHasCodecCameras; + + PostStatusMessage(new + { + cameras = new + { + selectedCamera = GetSelectedCamera(camerasCodec) + }, + presets = GetCurrentPresets() + }); + } + + void PostCameraPresets() + { + + PostStatusMessage(new + { + presets = GetCurrentPresets() + }); + } + + object GetSelectedCamera(IHasCodecCameras camerasCodec) + { + return new + { + key = camerasCodec.SelectedCameraFeedback.StringValue, + isFarEnd = camerasCodec.ControllingFarEndCameraFeedback.BoolValue, + capabilites = new + { + canPan = camerasCodec.SelectedCamera.CanPan, + canTilt = camerasCodec.SelectedCamera.CanTilt, + canZoom = camerasCodec.SelectedCamera.CanZoom, + canFocus = camerasCodec.SelectedCamera.CanFocus + } + }; + } + + List GetCurrentPresets() + { + var presetsCodec = Codec as IHasCodecRoomPresets; + + List currentPresets = null; + + if (presetsCodec != null && Codec is IHasFarEndCameraControl && (Codec as IHasFarEndCameraControl).ControllingFarEndCameraFeedback.BoolValue) + currentPresets = presetsCodec.FarEndRoomPresets; + else + currentPresets = presetsCodec.NearEndPresets; + + return currentPresets; + } } } \ No newline at end of file From 113b08a2271017dbffa836f962ff608e4cd85c74 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Mar 2020 14:21:12 -0600 Subject: [PATCH 21/33] Adds ValidValues string array to JoinMetadata class for storing things like enum values or predetermined strings --- .../JoinMaps/JoinMapBase.cs | 46 +++---------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 3dcb26a2..374151ff 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -161,7 +161,7 @@ namespace PepperDash.Essentials.Core /// A label for the join to better describe it's usage /// [JsonProperty("label")] - public string Label { get; set; } + public string Label { get; protected set; } /// /// Signal type(s) /// @@ -181,44 +181,12 @@ namespace PepperDash.Essentials.Core /// Indicates whether the join is read and/or write /// [JsonProperty("joinCapabilities")] - public eJoinCapabilities JoinCapabilities { get; set; } + public eJoinCapabilities JoinCapabilities { get; protected set; } + /// + /// Indicates a set of valid values (particularly if this translates to an enum + /// + [JsonProperty("validValues")] + public string[] ValidValues { get; protected set; } } - - public enum eBiologicalSex - { - Unknown = 0, - Female = 1, - Male = 2, - Intersex = Male | Female - } - - public class Human - { - - eBiologicalSex BiologicalSex; - - public bool IsMale - { - get { return (BiologicalSex & eBiologicalSex.Male) == eBiologicalSex.Male; } - } - - public bool IsFemale - { - get { return (BiologicalSex & eBiologicalSex.Female) == eBiologicalSex.Female; } - } - - public bool IsIntersex - { - get { return (BiologicalSex & eBiologicalSex.Intersex) == eBiologicalSex.Intersex; } - } - - public bool IsDeservingOfBasicHumanRights - { - get - { - return this is Human; - } - } - } } \ No newline at end of file From b71313248d249feb6703f91d137f4dab1b554f16 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 10 Mar 2020 15:01:28 -0600 Subject: [PATCH 22/33] Addresses issues causing build to fail. --- .../Room/Types/EssentialsHuddleSpaceRoom.cs | 26 +++++++++++++++++-- .../Room/Types/EssentialsHuddleVtc1Room.cs | 26 +++++++++++++++++-- .../EssentialsHuddlePanelAvFunctionsDriver.cs | 2 +- ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 2 +- .../JoinMaps/JoinMapBase.cs | 6 ++--- .../Essentials Devices Common/DSP/DspBase.cs | 15 ----------- 6 files changed, 53 insertions(+), 24 deletions(-) diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index 9bec05b8..b14e563d 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -264,8 +264,30 @@ namespace PepperDash.Essentials /// public void RunRouteAction(string routeKey) { - RunRouteAction(routeKey, null); - } + RunRouteAction(routeKey, new Action(() => { })); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string souceListKey) + { + throw new NotImplementedException(); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string souceListKey, Action successCallback) + { + throw new NotImplementedException(); + } /// /// Gets a source from config list SourceListKey and dynamically build and executes the diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index b2db56ae..c5021526 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -394,8 +394,30 @@ namespace PepperDash.Essentials /// public void RunRouteAction(string routeKey) { - RunRouteAction(routeKey, null); - } + RunRouteAction(routeKey, new Action(() => { })); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string souceListKey) + { + throw new NotImplementedException(); + } + + /// + /// + /// + /// + /// + /// + public void RunRouteAction(string routeKey, string souceListKey, Action successCallback) + { + throw new NotImplementedException(); + } /// /// Gets a source from config list SourceListKey and dynamically build and executes the diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs index 144fafb4..232a99da 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs @@ -564,7 +564,7 @@ namespace PepperDash.Essentials void UiSelectSource(string key) { // Run the route and when it calls back, show the source - CurrentRoom.RunRouteAction(key, null); + CurrentRoom.RunRouteAction(key, new Action(() => { })); } /// diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index fbc3f5b6..9248e50a 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -726,7 +726,7 @@ namespace PepperDash.Essentials void UiSelectSource(string key) { // Run the route and when it calls back, show the source - CurrentRoom.RunRouteAction(key, null); + CurrentRoom.RunRouteAction(key, new Action(() => { })); } /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 3415abd2..dcdd7c8a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -163,7 +163,7 @@ namespace PepperDash.Essentials.Core /// A label for the join to better describe it's usage /// [JsonProperty("label")] - public string Label { get; protected set; } + public string Label { get; set; } /// /// Signal type(s) /// @@ -183,12 +183,12 @@ namespace PepperDash.Essentials.Core /// Indicates whether the join is read and/or write /// [JsonProperty("joinCapabilities")] - public eJoinCapabilities JoinCapabilities { get; protected set; } + public eJoinCapabilities JoinCapabilities { get; set; } /// /// Indicates a set of valid values (particularly if this translates to an enum /// [JsonProperty("validValues")] - public string[] ValidValues { get; protected set; } + public string[] ValidValues { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs index 318268f1..0f572642 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs @@ -56,19 +56,4 @@ namespace PepperDash.Essentials.Devices.Common.DSP // ATC // Mics, unusual - public interface IBiampTesiraDspLevelControl : IBasicVolumeWithFeedback - { - /// - /// In BiAmp: Instance Tag, QSC: Named Control, Polycom: - /// - string ControlPointTag { get; } - int Index1 { get; } - int Index2 { get; } - bool HasMute { get; } - bool HasLevel { get; } - bool AutomaticUnmuteOnVolumeUp { get; } - } - - - } \ No newline at end of file From a2ca41d965836185e8f18d2b1b88822c17364d9c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 26 Mar 2020 11:59:32 -0600 Subject: [PATCH 23/33] Adds back in the plugin interfaces. Modifies PluginLoader to try new inteface method for custom plugins first, then fail back to legacy method --- .../PluginLoading/PluginLoading.cs | 124 +++++--- .../PepperDash_Essentials_Core.csproj | 2 + .../Plugins/IPluginDeviceConfig.cs | 4 + .../IRoutingInputsExtensions.cs | 300 ------------------ .../Routing-CHECK REMOVE/RoutingInterfaces.cs | 57 ---- .../Routing-CHECK REMOVE/RoutingPort.cs | 144 --------- .../RoutingPortCollection.cs | 26 -- .../Routing-CHECK REMOVE/TieLine.cs | 142 --------- 8 files changed, 89 insertions(+), 710 deletions(-) delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/IRoutingInputsExtensions.cs delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingInterfaces.cs delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPort.cs delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPortCollection.cs delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/TieLine.cs diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs index 032bea2e..dcffacdd 100644 --- a/PepperDashEssentials/PluginLoading/PluginLoading.cs +++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Plugins; namespace PepperDash.Essentials { @@ -338,49 +339,21 @@ namespace PepperDash.Essentials { try { - var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); - var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); - if (loadPlugin != null) + var plugin = type as IPluginDeviceConfig; + if (plugin != null) { - Debug.Console(2, "LoadPlugin method found in {0}", type.Name); - - var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); - - var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); - if (minimumVersion != null) - { - Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); - - var minimumVersionString = minimumVersion.GetValue(null) as string; - - if (!string.IsNullOrEmpty(minimumVersionString)) - { - var passed = Global.IsRunningMinimumVersionOrHigher(minimumVersionString); - - if (!passed) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); - continue; - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); - } - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); - } - - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding plugin: {0}", loadedAssembly.Name); - loadPlugin.Invoke(null, null); + LoadCustomPlugin(plugin, loadedAssembly); } - } + else + { + var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); + var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); + if (loadPlugin != null) + { + LoadCustomLegacyPlugin(type, loadPlugin, loadedAssembly); + } + } + } catch (Exception e) { Debug.Console(2, "Load Plugin not found. {0} is not a plugin assembly. Exception: {1}", loadedAssembly.Name, e); @@ -400,6 +373,75 @@ namespace PepperDash.Essentials Debug.Console(0, "Done Loading Custom Plugin Types."); } + /// + /// Loads a + /// + /// + static void LoadCustomPlugin(IPluginDeviceConfig plugin, LoadedAssembly loadedAssembly) + { + var passed = Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion); + + if (!passed) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", plugin.MinimumEssentialsFrameworkVersion); + return; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", plugin.MinimumEssentialsFrameworkVersion); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name); + plugin.LoadPlugin(); + } + + /// + /// Loads a a custom plugin via the legacy method + /// + /// + /// + static void LoadCustomLegacyPlugin(CType type, MethodInfo loadPlugin, LoadedAssembly loadedAssembly) + { + Debug.Console(2, "LoadPlugin method found in {0}", type.Name); + + var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); + + var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); + if (minimumVersion != null) + { + Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); + + var minimumVersionString = minimumVersion.GetValue(null) as string; + + if (!string.IsNullOrEmpty(minimumVersionString)) + { + var passed = Global.IsRunningMinimumVersionOrHigher(minimumVersionString); + + if (!passed) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); + return; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading legacy plugin: {0}", loadedAssembly.Name); + loadPlugin.Invoke(null, null); + + } + /// /// Loads plugins /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 61d1ffce..70be9e8c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -156,6 +156,8 @@ + + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs index 7ac894c6..6808bf90 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs @@ -3,9 +3,13 @@ using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.Plugins { + /// + /// Defines a class that is capable of loading custom plugin device types + /// public interface IPluginDeviceConfig { string MinimumEssentialsFrameworkVersion { get; } + void LoadPlugin(); IKeyed BuildDevice(DeviceConfig dc); } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/IRoutingInputsExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/IRoutingInputsExtensions.cs deleted file mode 100644 index ad4a3458..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/IRoutingInputsExtensions.cs +++ /dev/null @@ -1,300 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public static class IRoutingInputsExtensions - { - /// - /// Gets any existing route for a destination, clears it, and then - /// - public static void ReleaseAndMakeRoute(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) - { - var sw = new Stopwatch(); - sw.Start(); - - destination.ReleaseRoute(); - - if (source == null) return; - var newRoute = destination.GetRouteToSource(source, signalType); - if (newRoute == null) return; - RouteDescriptorCollection.DefaultCollection.AddRouteDescriptor(newRoute); - Debug.Console(2, destination, "Executing new route"); - newRoute.ExecuteRoutes(); - sw.Stop(); - Debug.Console(2, destination, "Route took {0} ms", sw.ElapsedMilliseconds); - } - - /// - /// Will release the existing route on the destination - /// - /// - /// - public static void ReleaseRoute(this IRoutingInputs destination) - { - var current = RouteDescriptorCollection.DefaultCollection.RemoveRouteDescriptor(destination); - if (current != null) - { - Debug.Console(2, destination, "Releasing current route: {0}", current.Source.Key); - current.ReleaseRoutes(); - } - } - - - /// - /// - /// - /// - /// - /// - /// - public static RouteDescriptor GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, eRoutingSignalType signalType) - { - var routeTable = new RouteDescriptor (source, destination, signalType); - - Debug.Console(0, destination, "Attempting to build source route from {0}***", source.Key); - if (!destination.GetRouteToSource(source, null, null, signalType, 0, routeTable)) - routeTable = null; - - Debug.Console(0, destination, "Route{0} discovered ***", routeTable == null ? " NOT" : ""); - return routeTable; - } - - /// - /// The recursive part of this. Will stop on each device, search its inputs for the - /// desired source and if not found, invoke this function for the each input port - /// hoping to find the source. - /// - /// - /// - /// - /// - /// - /// - /// - /// true if source is hit - static bool GetRouteToSource(this IRoutingInputs destination, IRoutingOutputs source, - RoutingOutputPort onSuccessOutputPort, List alreadyCheckedDevices, - eRoutingSignalType signalType, int cycle, RouteDescriptor routeTable) - { - cycle++; - Debug.Console(0, destination, "SelectInput-cycle {1}. Finding {2} route back to {0}", source.Key, cycle, signalType); - var destDevInputTies = TieLineCollection.Default.Where(t => - t.DestinationPort.ParentDevice == destination && (t.Type == signalType || t.Type == eRoutingSignalType.AudioVideo)); - - // find a direct tie - var directTie = destDevInputTies.FirstOrDefault( - t => !(t.SourcePort.ParentDevice is IRoutingInputsOutputs) - && t.DestinationPort.ParentDevice == destination - && t.SourcePort.ParentDevice == source); - RoutingInputPort inputPort = null; - if (directTie != null) // Found a tie directly to the source - { - Debug.Console(0, destination, "Found direct tie to {0}**", source.Key); - inputPort = directTie.DestinationPort; - } - else // no direct-connect. Walk back devices. - { - Debug.Console(0, destination, "is not directly connected to {0}. Walking down tie lines", source.Key); - - // No direct tie? Run back out on the inputs' attached devices... - // Only the ones that are routing devices - var attachedMidpoints = destDevInputTies.Where(t => t.SourcePort.ParentDevice is IRoutingInputsOutputs); - foreach (var inputTieToTry in attachedMidpoints) - { - Debug.Console(0, destination, "Trying to find route on {0}", inputTieToTry.SourcePort.ParentDevice.Key); - var upstreamDeviceOutputPort = inputTieToTry.SourcePort; - var upstreamRoutingDevice = upstreamDeviceOutputPort.ParentDevice as IRoutingInputsOutputs; - // Check if this previous device has already been walked - if (!(alreadyCheckedDevices != null && alreadyCheckedDevices.Contains(upstreamRoutingDevice))) - { - // haven't seen this device yet. Do it. Pass the output port to the next - // level to enable switching on success - var upstreamRoutingSuccess = upstreamRoutingDevice.GetRouteToSource(source, upstreamDeviceOutputPort, - alreadyCheckedDevices, signalType, cycle, routeTable); - if (upstreamRoutingSuccess) - { - Debug.Console(0, destination, "Upstream device route found"); - inputPort = inputTieToTry.DestinationPort; - break; // Stop looping the inputs in this cycle - } - } - } - } - - // we have a route on corresponding inputPort. *** Do the route *** - if (inputPort != null) - { - Debug.Console(0, destination, "adding route:"); - if (onSuccessOutputPort == null) - { - // it's a sink device - routeTable.Routes.Add(new RouteSwitchDescriptor(inputPort)); - } - else if (destination is IRouting) - { - routeTable.Routes.Add(new RouteSwitchDescriptor (onSuccessOutputPort, inputPort)); - } - else // device is merely IRoutingInputOutputs - Debug.Console(0, destination, " No routing. Passthrough device"); - Debug.Console(0, destination, "Exiting cycle {0}", cycle); - return true; - } - - if(alreadyCheckedDevices == null) - alreadyCheckedDevices = new List(); - alreadyCheckedDevices.Add(destination as IRoutingInputsOutputs); - - Debug.Console(0, destination, "No route found to {0}", source.Key); - return false; - } - } - - - - - - // MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE - - - /// - /// A collection of routes - typically the global DefaultCollection is used - /// - public class RouteDescriptorCollection - { - public static RouteDescriptorCollection DefaultCollection - { - get - { - if (_DefaultCollection == null) - _DefaultCollection = new RouteDescriptorCollection(); - return _DefaultCollection; - } - } - static RouteDescriptorCollection _DefaultCollection; - - List RouteDescriptors = new List(); - - public void AddRouteDescriptor(RouteDescriptor descriptor) - { - if (RouteDescriptors.Any(t => t.Destination == descriptor.Destination)) - { - Debug.Console(1, descriptor.Destination, - "Route to [{0}] already exists in global routes table", descriptor.Source.Key); - return; - } - RouteDescriptors.Add(descriptor); - } - - public RouteDescriptor GetRouteDescriptorForDestination(IRoutingInputs destination) - { - return RouteDescriptors.FirstOrDefault(rd => rd.Destination == destination); - } - - /// - /// Returns the RouteDescriptor for a given destination and removes it from collection. - /// Returns null if no route with the provided destination exists. - /// - public RouteDescriptor RemoveRouteDescriptor(IRoutingInputs destination) - { - var descr = GetRouteDescriptorForDestination(destination); - if (descr != null) - RouteDescriptors.Remove(descr); - return descr; - } - } - - /// - /// Represents an collection of individual route steps between Source and Destination - /// - public class RouteDescriptor - { - public IRoutingInputs Destination { get; private set; } - public IRoutingOutputs Source { get; private set; } - public eRoutingSignalType SignalType { get; private set; } - public List Routes { get; private set; } - - - public RouteDescriptor(IRoutingOutputs source, IRoutingInputs destination, eRoutingSignalType signalType) - { - Destination = destination; - Source = source; - SignalType = signalType; - Routes = new List(); - } - - public void ExecuteRoutes() - { - foreach (var route in Routes) - { - Debug.Console(2, route.ToString()); - if (route.SwitchingDevice is IRoutingSinkWithSwitching) - (route.SwitchingDevice as IRoutingSinkWithSwitching).ExecuteSwitch(route.InputPort.Selector); - else if (route.SwitchingDevice is IRouting) - { - (route.SwitchingDevice as IRouting).ExecuteSwitch(route.InputPort.Selector, route.OutputPort.Selector, SignalType); - route.OutputPort.InUseTracker.AddUser(Destination, "destination"); - } - } - } - - public void ReleaseRoutes() - { - foreach (var route in Routes) - { - if (route.SwitchingDevice is IRouting) - { - // Pull the route from the port. Whatever is watching the output's in use tracker is - // responsible for responding appropriately. - route.OutputPort.InUseTracker.RemoveUser(Destination, "destination"); - } - } - } - - public override string ToString() - { - var routesText = Routes.Select(r => r.ToString()).ToArray(); - return string.Format("Route table from {0} to {1}:\r{2}", Source.Key, Destination.Key, string.Join("\r", routesText)); - } - } - - /// - /// Represents an individual link for a route - /// - public class RouteSwitchDescriptor - { - public IRoutingInputs SwitchingDevice { get { return InputPort.ParentDevice; } } - public RoutingOutputPort OutputPort { get; set; } - public RoutingInputPort InputPort { get; set; } - - public RouteSwitchDescriptor(RoutingInputPort inputPort) - { - InputPort = inputPort; - } - - public RouteSwitchDescriptor(RoutingOutputPort outputPort, RoutingInputPort inputPort) - { - InputPort = inputPort; - OutputPort = outputPort; - } - - public override string ToString() - { - if(OutputPort == null) // IRoutingSink - return string.Format("{0} switches to input '{1}'", SwitchingDevice.Key, InputPort.Selector); - - return string.Format("{0} switches output '{1}' to input '{2}'", SwitchingDevice.Key, OutputPort.Selector, InputPort.Selector); - } - } -} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingInterfaces.cs deleted file mode 100644 index 352a35dc..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingInterfaces.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - //******************************************************************************************* - // Interfaces - - public interface IRoutingInputs : IKeyed - { - RoutingPortCollection InputPorts { get; } - } - - public interface IRoutingOutputs : IKeyed - { - RoutingPortCollection OutputPorts { get; } - } - - /// - /// For fixed-source endpoint devices - /// - public interface IRoutingSinkNoSwitching : IRoutingInputs - { - - } - - public interface IRoutingSinkWithSwitching : IRoutingSinkNoSwitching - { - //void ClearRoute(); - void ExecuteSwitch(object inputSelector); - } - - /// - /// For devices like RMCs, baluns, other devices with no switching. - /// - public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs - { - } - - public interface IRouting : IRoutingInputsOutputs - { - //void ClearRoute(object outputSelector); - void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); - } - - public interface IRoutingSource : IRoutingOutputs - { - } -} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPort.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPort.cs deleted file mode 100644 index e2a026ab..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPort.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Collections.Generic; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - /// - /// Base class for RoutingInput and Output ports - /// - public abstract class RoutingPort : IKeyed - { - public string Key { get; private set; } - public eRoutingSignalType Type { get; private set; } - public eRoutingPortConnectionType ConnectionType { get; private set; } - public readonly object Selector; - public bool IsInternal { get; private set; } - - public RoutingPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, bool isInternal) - { - Key = key; - Type = type; - ConnectionType = connType; - Selector = selector; - IsInternal = IsInternal; - } - } - - public enum eRoutingSignalType - { - Audio, - Video, - AudioVideo - } - - public enum eRoutingPortConnectionType - { - None, BackplaneOnly, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, Composite, Component, DmCat, DmMmFiber, DmSmFiber - } - - /// - /// Basic RoutingInput with no statuses. - /// - public class RoutingInputPort : RoutingPort - { - /// - /// The IRoutingInputs object this lives on - /// - public IRoutingInputs ParentDevice { get; private set; } - - /// - /// Constructor for a basic RoutingInputPort - /// - /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. - /// May be string, number, whatever - /// The IRoutingInputs object this lives on - public RoutingInputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, - object selector, IRoutingInputs parent) - : this (key, type, connType, selector, parent, false) - { - } - - /// - /// Constructor for a virtual routing input port that lives inside a device. For example - /// the ports that link a DM card to a DM matrix bus - /// - /// true for internal ports - public RoutingInputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, - object selector, IRoutingInputs parent, bool isInternal) - : base(key, type, connType, selector, isInternal) - { - if (parent == null) - throw new ArgumentNullException("parent"); - ParentDevice = parent; - } - - } - - /// - /// A RoutingInputPort for devices like DM-TX and DM input cards. - /// Will provide video statistics on connected signals - /// - public class RoutingInputPortWithVideoStatuses : RoutingInputPort - { - /// - /// Video statuses attached to this port - /// - public VideoStatusOutputs VideoStatus { get; private set; } - - /// - /// Constructor - /// - /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. - /// May be string, number, whatever - /// The IRoutingInputs object this lives on - /// A VideoStatusFuncsWrapper used to assign the callback funcs that will get - /// the values for the various stats - public RoutingInputPortWithVideoStatuses(string key, - eRoutingSignalType type, eRoutingPortConnectionType connType, object selector, - IRoutingInputs parent, VideoStatusFuncsWrapper funcs) : - base(key, type, connType, selector, parent) - { - VideoStatus = new VideoStatusOutputs(funcs); - } - } - - public class RoutingOutputPort : RoutingPort - { - /// - /// The IRoutingOutputs object this port lives on - /// - public IRoutingOutputs ParentDevice { get; private set; } - - public InUseTracking InUseTracker { get; private set; } - - - /// - /// - /// An object used to refer to this port in the IRouting device's ExecuteSwitch method. - /// May be string, number, whatever - /// The IRoutingOutputs object this port lives on - public RoutingOutputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, - object selector, IRoutingOutputs parent) - : this(key, type, connType, selector, parent, false) - { - } - - public RoutingOutputPort(string key, eRoutingSignalType type, eRoutingPortConnectionType connType, - object selector, IRoutingOutputs parent, bool isInternal) - : base(key, type, connType, selector, isInternal) - { - if (parent == null) - throw new ArgumentNullException("parent"); - ParentDevice = parent; - InUseTracker = new InUseTracking(); - } - - public override string ToString() - { - return ParentDevice.Key + ":" + Key; - } - } -} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPortCollection.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPortCollection.cs deleted file mode 100644 index ba972ab7..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/RoutingPortCollection.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - /// - /// Basically a List , with an indexer to find ports by key name - /// - public class RoutingPortCollection : List where T: RoutingPort - { - /// - /// Case-insensitive port lookup linked to ports' keys - /// - public T this[string key] - { - get - { - return this.FirstOrDefault(i => i.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); - } - } - } -} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/TieLine.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/TieLine.cs deleted file mode 100644 index 6a89d2de..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing-CHECK REMOVE/TieLine.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - public class TieLine - { - public RoutingOutputPort SourcePort { get; private set; } - public RoutingInputPort DestinationPort { get; private set; } - public int InUseCount { get { return DestinationUsingThis.Count; } } - - /// - /// Gets the type of this tie line. Will either be the type of the desination port - /// or the type of OverrideType when it is set. - /// - public eRoutingSignalType Type - { - get - { - if (OverrideType.HasValue) return OverrideType.Value; - return DestinationPort.Type; - } - } - - /// - /// Use this to override the Type property for the destination port. For example, - /// when the tie line is type AudioVideo, and the signal flow should be limited to - /// Audio-only or Video only, changing this type will alter the signal paths - /// available to the routing algorithm without affecting the actual Type - /// of the destination port. - /// - public eRoutingSignalType? OverrideType { get; set; } - - List DestinationUsingThis = new List(); - - /// - /// For tie lines that represent internal links, like from cards to the matrix in a DM. - /// This property is true if SourcePort and DestinationPort IsInternal - /// property are both true - /// - public bool IsInternal { get { return SourcePort.IsInternal && DestinationPort.IsInternal; } } - public bool TypeMismatch { get { return SourcePort.Type != DestinationPort.Type; } } - public bool ConnectionTypeMismatch { get { return SourcePort.ConnectionType != DestinationPort.ConnectionType; } } - public string TypeMismatchNote { get; set; } - - /// - /// - /// - /// - /// - public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort) - { - if (sourcePort == null || destinationPort == null) - throw new ArgumentNullException("source or destination port"); - SourcePort = sourcePort; - DestinationPort = destinationPort; - } - - /// - /// Creates a tie line with an overriding Type. See help for OverrideType property for info - /// - /// The signal type to limit the link to. Overrides DestinationPort.Type - public TieLine(RoutingOutputPort sourcePort, RoutingInputPort destinationPort, eRoutingSignalType overrideType) : - this(sourcePort, destinationPort) - { - OverrideType = overrideType; - } - - public static TieLine TieLineFromStrings(string sourceKey, string sourcePortKey, string destinationKey, string destinationPortKey) - { - var sourceDev = DeviceManager.GetDeviceForKey(sourceKey) as IRoutingOutputs; - if (sourceDev == null) - { - Debug.Console(1, "WARNING: Cannot create tie line, routable source '{0}' not found", sourceKey); - return null; - } - var destDev = DeviceManager.GetDeviceForKey(destinationKey) as IRoutingInputs; - if (destDev == null) - { - Debug.Console(1, "WARNING: Cannot create tie line, routable destination '{0}' not found", destinationKey); - return null; - } - var sourcePort = sourceDev.OutputPorts[sourcePortKey]; - if (sourcePort == null) - { - Debug.Console(1, "WARNING: Cannot create tie line. Source '{0}' does not contain port '{1}'", sourceKey, sourcePortKey); - return null; - } - var destPort = destDev.InputPorts[destinationPortKey]; - if (destPort == null) - { - Debug.Console(1, "WARNING: Cannot create tie line. Destination '{0}' does not contain port '{1}'", destinationKey, destinationPortKey); - return null; - } - - return new TieLine(sourcePort, destPort); - } - - /// - /// Will link up video status from supporting inputs to connected outputs - /// - public void Activate() - { - // Now does nothing - } - - public void Deactivate() - { - // Now does nothing - } - - public override string ToString() - { - return string.Format("Tie line: [{0}]{1} --> [{2}]{3}", SourcePort.ParentDevice.Key, SourcePort.Key, - DestinationPort.ParentDevice.Key, DestinationPort.Key); - } - } - - - //******************************************************************************** - - public class TieLineCollection : List - { - public static TieLineCollection Default - { - get - { - if (_Default == null) - _Default = new TieLineCollection(); - return _Default; - } - } - static TieLineCollection _Default; - } -} \ No newline at end of file From 50d5850097cc1f2bd4ad7fde1d6012c2a407d7c8 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 26 Mar 2020 14:10:50 -0600 Subject: [PATCH 24/33] Changes to instantiate the plugin loader class from the custom plugin --- PepperDashEssentials/PluginLoading/PluginLoading.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs index dcffacdd..d12775c7 100644 --- a/PepperDashEssentials/PluginLoading/PluginLoading.cs +++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs @@ -339,9 +339,9 @@ namespace PepperDash.Essentials { try { - var plugin = type as IPluginDeviceConfig; - if (plugin != null) + if (typeof(IPluginDeviceConfig).IsAssignableFrom(type)) { + var plugin = (IPluginDeviceConfig)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); LoadCustomPlugin(plugin, loadedAssembly); } else From a403a8b81f6d0c8f2e2bdc5695b6f34119f66ea4 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 26 Mar 2020 16:10:54 -0600 Subject: [PATCH 25/33] Attempt at modifying device factory mechanism --- .../PluginLoading/PluginLoading.cs | 13 +++-- .../Config/Comm and IR/GenericComm.cs | 32 ++++++++++-- .../Devices/EssentialsDevice.cs | 50 +++++++++++++++++++ .../Devices/ReconfigurableDevice.cs | 2 +- .../Factory/DeviceFactory.cs | 13 +++++ .../PepperDash_Essentials_Core.csproj | 1 + .../Plugins/IPluginDeviceConfig.cs | 21 ++++++-- 7 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs index d12775c7..8c444622 100644 --- a/PepperDashEssentials/PluginLoading/PluginLoading.cs +++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs @@ -70,6 +70,11 @@ namespace PepperDash.Essentials { version = Global.AssemblyVersion; assembly = Assembly.GetExecutingAssembly(); + break; + } + case ("PepperDashEssentialsBase.dll"): + { + break; } case ("PepperDash_Core.dll"): @@ -339,9 +344,9 @@ namespace PepperDash.Essentials { try { - if (typeof(IPluginDeviceConfig).IsAssignableFrom(type)) + if (typeof(IPluginDeviceFactory).IsAssignableFrom(type)) { - var plugin = (IPluginDeviceConfig)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); + var plugin = (IPluginDeviceFactory)Crestron.SimplSharp.Reflection.Activator.CreateInstance(type); LoadCustomPlugin(plugin, loadedAssembly); } else @@ -377,7 +382,7 @@ namespace PepperDash.Essentials /// Loads a /// /// - static void LoadCustomPlugin(IPluginDeviceConfig plugin, LoadedAssembly loadedAssembly) + static void LoadCustomPlugin(IPluginDeviceFactory plugin, LoadedAssembly loadedAssembly) { var passed = Global.IsRunningMinimumVersionOrHigher(plugin.MinimumEssentialsFrameworkVersion); @@ -392,7 +397,7 @@ namespace PepperDash.Essentials } Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading plugin: {0}", loadedAssembly.Name); - plugin.LoadPlugin(); + plugin.LoadTypeFactories(); } /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs index 1998f62e..86faab64 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs @@ -13,12 +13,14 @@ using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { + + /// /// Serves as a generic wrapper class for all styles of IBasicCommuncation ports /// - public class - GenericComm : ReconfigurableDevice + public class GenericComm : ReconfigurableDevice { + EssentialsControlPropertiesConfig PropertiesConfig; public IBasicCommunication CommPort { get; private set; } @@ -29,6 +31,14 @@ namespace PepperDash.Essentials.Core PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); CommPort = CommFactory.CreateCommForDevice(config); + + + } + + public static IKeyed BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); } public void SetPortConfig(string portConfig) @@ -51,6 +61,22 @@ namespace PepperDash.Essentials.Core ConfigWriter.UpdateDeviceConfig(config); } - + + public class Factory : EssentialsDevice.Factory + { + #region IDeviceFactory Members + + List TypeNames = new List() { "genericComm" }; + + #endregion + + public override IKeyed BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + return new GenericComm(dc); + } + } } + + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs new file mode 100644 index 00000000..00263f0f --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines the basic needs for an EssentialsDevice to enable it to be build by an IDeviceFactory class + /// + public abstract class EssentialsDevice : Device + { + public EssentialsDevice(string key) + : base(key) + { + + } + + public abstract class Factory : IDeviceFactory + { + #region IDeviceFactory Members + + public List TypeNames { get; protected set; } + + public virtual void LoadTypeFactories() + { + foreach (var typeName in TypeNames) + { + DeviceFactory.AddFactoryForType(typeName, BuildDevice); + } + } + + #endregion + + public abstract IKeyed BuildDevice(DeviceConfig dc); + + public Factory() + { + TypeNames = new List(); + } + + } + + + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs index 3acfcac0..b19b40b5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/ReconfigurableDevice.cs @@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.Devices /// /// /// - public abstract class ReconfigurableDevice : Device + public abstract class ReconfigurableDevice : EssentialsDevice { public event EventHandler ConfigChanged; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index c07bc010..47947691 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -87,4 +87,17 @@ namespace PepperDash.Essentials.Core return null; } } + + + /// + /// Responsible for loading all of the device types + /// + public class CoreDeviceFactory + { + public CoreDeviceFactory() + { + var genComm = new GenericComm.Factory() as IDeviceFactory; + genComm.LoadTypeFactories(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 70be9e8c..d728bbd0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -132,6 +132,7 @@ + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs index 6808bf90..b8fa03a3 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs @@ -1,15 +1,28 @@ using PepperDash.Core; using PepperDash.Essentials.Core.Config; -namespace PepperDash.Essentials.Core.Plugins +namespace PepperDash.Essentials.Core { /// /// Defines a class that is capable of loading custom plugin device types /// - public interface IPluginDeviceConfig + public interface IPluginDeviceFactory : IDeviceFactory { + /// + /// Required to define the minimum version for Essentials in the format xx.yy.zz + /// string MinimumEssentialsFrameworkVersion { get; } - void LoadPlugin(); - IKeyed BuildDevice(DeviceConfig dc); + + } + + /// + /// Defines a class that is capable of loading device types + /// + public interface IDeviceFactory + { + /// + /// Will be called when the plugin is loaded by Essentials. Must add any new types to the DeviceFactory using DeviceFactory.AddFactoryForType() for each new type + /// + void LoadTypeFactories(); } } \ No newline at end of file From 739bd0c31224982b17285faf9a55f4a03abac5a3 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Thu, 26 Mar 2020 21:16:28 -0600 Subject: [PATCH 26/33] Adds JoinMapAdvanced class and updates SIMPLAtcJoinMap and SIMPLAtcMessenger accordingly --- .../AppServer/Messengers/SIMPLAtcMessenger.cs | 28 +-- .../AppServer/Messengers/SIMPLVtcMessenger.cs | 4 +- .../SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 100 +++++---- .../JoinMaps/JoinMapBase.cs | 195 ++++++++++++++++-- 4 files changed, 254 insertions(+), 73 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index b29fe890..3df9c912 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -124,9 +124,9 @@ namespace PepperDash.Essentials.AppServer.Messengers this.PostStatusMessage(new { calls = GetCurrentCallList(), - currentCallString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName)), - currentDialString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString)), - isInCall = EISC.GetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState)) == "Connected" + currentCallString = EISC.GetString(JoinMap.CurrentCallName.JoinNumber), + currentDialString = EISC.GetString(JoinMap.CurrentDialString.JoinNumber), + isInCall = EISC.GetString(JoinMap.HookState.JoinNumber) == "Connected" }); } @@ -138,26 +138,26 @@ namespace PepperDash.Essentials.AppServer.Messengers { //EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s })); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.HookState), s => + EISC.SetStringSigAction(JoinMap.HookState.JoinNumber, s => { CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true); //GetCurrentCallList(); SendFullStatus(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallNumber), s => + EISC.SetStringSigAction(JoinMap.CurrentCallNumber.JoinNumber, s => { CurrentCallItem.Number = s; SendCallsList(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentCallName), s => + EISC.SetStringSigAction(JoinMap.CurrentCallName.JoinNumber, s => { CurrentCallItem.Name = s; SendCallsList(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CallDirection), s => + EISC.SetStringSigAction(JoinMap.CallDirection.JoinNumber, s => { CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true); SendCallsList(); @@ -170,13 +170,13 @@ namespace PepperDash.Essentials.AppServer.Messengers // Add straight pulse calls Action addAction = (s, u) => AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/endCallById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall)); - addAction("/endAllCalls", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.EndCall)); - addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingAnswer)); - addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLAtcJoinMap.IncomingReject)); + addAction("/endCallById", JoinMap.EndCall.JoinNumber); + addAction("/endAllCalls", JoinMap.EndCall.JoinNumber); + addAction("/acceptById", JoinMap.IncomingAnswer.JoinNumber); + addAction("/rejectById", JoinMap.IncomingReject.JoinNumber); - var speeddialStart = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart); - var speeddialEnd = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLAtcJoinMap.SpeedDialStart); + var speeddialStart = JoinMap.SpeedDialStart.JoinNumber; + var speeddialEnd = JoinMap.SpeedDialStart.JoinNumber + JoinMap.SpeedDialStart.JoinSpan; var speedDialIndex = 1; for (uint i = speeddialStart; i < speeddialEnd; i++) @@ -188,7 +188,7 @@ namespace PepperDash.Essentials.AppServer.Messengers // Get status AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus)); // Dial on string - AppServerController.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(JoinMap.GetJoinForKey(SIMPLAtcJoinMap.CurrentDialString), s))); + AppServerController.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(JoinMap.CurrentDialString.JoinNumber, s))); // Pulse DTMF AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => { diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index b81b2276..c89d1495 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -397,8 +397,8 @@ namespace PepperDash.Essentials.AppServer.Messengers addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingAnswer)); addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingReject)); - var speeddialStart = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart); - var speeddialEnd = JoinMap.GetJoinForKey(SIMPLAtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLAtcJoinMap.SpeedDialStart); + var speeddialStart = JoinMap.GetJoinForKey(SIMPLVtcJoinMap.SpeedDialStart); + var speeddialEnd = JoinMap.GetJoinForKey(SIMPLVtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLVtcJoinMap.SpeedDialStart); var speedDialIndex = 1; for (uint i = speeddialStart; i < speeddialEnd; i++) diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs index b5e8c568..e13c3b06 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -3,61 +3,71 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; using PepperDash.Essentials.Core; namespace PepperDash.Essentials.AppServer { - public class SIMPLAtcJoinMap : JoinMapBase + public class SIMPLAtcJoinMap : JoinMapBaseAdvanced { - public const string EndCall = "EndCall"; - public const string IncomingAnswer = "IncomingAnswer"; - public const string IncomingReject = "IncomingReject"; - public const string SpeedDialStart = "SpeedDialStart"; - public const string CurrentDialString = "CurrentDialString"; - public const string CurrentCallNumber = "CurrentCallNumber"; - public const string CurrentCallName = "CurrentCallName"; - public const string HookState = "HookState"; - public const string CallDirection = "CallDirection"; - public const string Dtmf0 = "0"; - public const string Dtmf1 = "1"; - public const string Dtmf2 = "2"; - public const string Dtmf3 = "3"; - public const string Dtmf4 = "4"; - public const string Dtmf5 = "5"; - public const string Dtmf6 = "6"; - public const string Dtmf7 = "7"; - public const string Dtmf8 = "8"; - public const string Dtmf9 = "9"; - public const string DtmfStar = "*"; - public const string DtmfPound = "#"; - + [JoinName("EndCall")] + public JoinDataComplete EndCall = new JoinDataComplete( new JoinData() { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata() { Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("IncomingAnswer")] + public JoinDataComplete IncomingAnswer = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("IncomingReject")] + public JoinDataComplete IncomingReject = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("SpeedDialStart")] + public JoinDataComplete SpeedDialStart = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 4 }, new JoinMetadata() { Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CurrentDialString")] + public JoinDataComplete CurrentDialString = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentCallNumber")] + public JoinDataComplete CurrentCallNumber = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentCallName")] + public JoinDataComplete CurrentCallName = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentHookStateCallName")] + public JoinDataComplete HookState = new JoinDataComplete(new JoinData() { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CallDirection")] + public JoinDataComplete CallDirection = new JoinDataComplete(new JoinData() { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("0")] + public JoinDataComplete Dtmf0 = new JoinDataComplete(new JoinData() { JoinNumber = 10, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("1")] + public JoinDataComplete Dtmf1 = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("2")] + public JoinDataComplete Dtmf2 = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("3")] + public JoinDataComplete Dtmf3 = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("4")] + public JoinDataComplete Dtmf4 = new JoinDataComplete(new JoinData() { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("5")] + public JoinDataComplete Dtmf5 = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("6")] + public JoinDataComplete Dtmf6 = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("7")] + public JoinDataComplete Dtmf7 = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("8")] + public JoinDataComplete Dtmf8 = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("9")] + public JoinDataComplete Dtmf9 = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("*")] + public JoinDataComplete DtmfStar = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("#")] + public JoinDataComplete DtmfPound = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); public SIMPLAtcJoinMap() { - Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 21, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IncomingAnswer, new JoinMetadata() { JoinNumber = 51, Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IncomingReject, new JoinMetadata() { JoinNumber = 52, Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SpeedDialStart, new JoinMetadata() { JoinNumber = 41, Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 4, JoinType = eJoinType.Digital }); - Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 11, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 12, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(HookState, new JoinMetadata() { JoinNumber = 21, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 22, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf4, new JoinMetadata() { JoinNumber = 4, Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf5, new JoinMetadata() { JoinNumber = 5, Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf6, new JoinMetadata() { JoinNumber = 6, Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf7, new JoinMetadata() { JoinNumber = 7, Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf8, new JoinMetadata() { JoinNumber = 8, Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf9, new JoinMetadata() { JoinNumber = 9, Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf0, new JoinMetadata() { JoinNumber = 10, Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DtmfStar, new JoinMetadata() { JoinNumber = 11, Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DtmfPound, new JoinMetadata() { JoinNumber = 12, Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - + // Add all the JoinDataComplete properties to the Joins Dictionary + GetType() + .GetCType() + .GetProperties() + .Where(x => x.PropertyType == typeof(uint)) + .ToList() + .ForEach(prop => + { + var join = (JoinDataComplete)prop.GetValue(this, null); + Joins.Add(join.GetNameAttribute(), join); + }); } public override void OffsetJoinNumbers(uint joinStart) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index dcdd7c8a..26664434 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; using PepperDash.Core; using PepperDash.Essentials.Core.Config; @@ -37,6 +38,7 @@ namespace PepperDash.Essentials.Core /// /// Base class for join maps /// + [Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")] public abstract class JoinMapBase { /// @@ -65,7 +67,7 @@ namespace PepperDash.Essentials.Core Debug.Console(0, "Analogs:"); var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); PrintJoinList(GetSortedJoins(analogs)); - + Debug.Console(0, "Serials:"); var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); PrintJoinList(GetSortedJoins(serials)); @@ -128,6 +130,102 @@ namespace PepperDash.Essentials.Core } + /// + /// Base class for join maps + /// + public abstract class JoinMapBaseAdvanced + { + /// + /// Modifies all the join numbers by adding the offset. This should never be called twice + /// + /// + public abstract void OffsetJoinNumbers(uint joinStart); + + /// + /// The collection of joins and associated metadata + /// + public Dictionary Joins = new Dictionary(); + + /// + /// Prints the join information to console + /// + public void PrintJoinMapInfo() + { + Debug.Console(0, "{0}:\n", this.GetType().Name); + + // Get the joins of each type and print them + Debug.Console(0, "Digitals:"); + var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(digitals)); + + Debug.Console(0, "Analogs:"); + var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(analogs)); + + Debug.Console(0, "Serials:"); + var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + PrintJoinList(GetSortedJoins(serials)); + + } + + /// + /// Returns a sorted list by JoinNumber + /// + /// + /// + List> GetSortedJoins(Dictionary joins) + { + var sortedJoins = joins.ToList(); + + sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber)); + + return sortedJoins; + } + + void PrintJoinList(List> joins) + { + foreach (var join in joins) + { + Debug.Console(0, + @"Join Number: {0} | JoinSpan: '{1}' | Label: '{2}' | Type: '{3}' | Capabilities: '{4}'", + join.Value.JoinNumber, + join.Value.JoinSpan, + join.Value.Metadata.Label, + join.Value.Metadata.JoinType.ToString(), + join.Value.Metadata.JoinCapabilities.ToString()); + } + } + + /// + /// Returns the join number for the join with the specified key + /// + /// + /// + public uint GetJoinForKey(string key) + { + if (Joins.ContainsKey(key)) + return Joins[key].JoinNumber; + else + return 0; + } + + + + /// + /// Returns the join span for the join with the specified key + /// + /// + /// + public uint GetJoinSpanForKey(string key) + { + if (Joins.ContainsKey(key)) + return Joins[key].JoinSpan; + + else return 0; + } + + } + /// /// Read = Provides feedback to SIMPL /// Write = Responds to sig values from SIMPL @@ -155,10 +253,23 @@ namespace PepperDash.Essentials.Core } /// - /// Data describing the join + /// Metadata describing the join /// public class JoinMetadata { + /// + /// Join number (based on join offset value) + /// + [JsonProperty("joinNumber")] + [Obsolete] + public uint JoinNumber { get; set; } + /// + /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range + /// + [Obsolete] + [JsonProperty("joinSpan")] + public uint JoinSpan { get; set; } + /// /// A label for the join to better describe it's usage /// @@ -170,16 +281,6 @@ namespace PepperDash.Essentials.Core [JsonProperty("joinType")] public eJoinType JoinType { get; set; } /// - /// Join number (based on join offset value) - /// - [JsonProperty("joinNumber")] - public uint JoinNumber { get; set; } - /// - /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range - /// - [JsonProperty("joinSpan")] - public uint JoinSpan { get; set; } - /// /// Indicates whether the join is read and/or write /// [JsonProperty("joinCapabilities")] @@ -191,4 +292,74 @@ namespace PepperDash.Essentials.Core public string[] ValidValues { get; set; } } + + /// + /// Data describing the join. Can be + /// + public class JoinData + { + /// + /// Join number (based on join offset value) + /// + [JsonProperty("joinNumber")] + public uint JoinNumber { get; set; } + /// + /// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range + /// + [JsonProperty("joinSpan")] + public uint JoinSpan { get; set; } + } + + /// + /// A class to aggregate the JoinData and JoinMetadata for a join + /// + public class JoinDataComplete + { + JoinData _Data { get; set; } + public JoinMetadata Metadata { get; set; } + + public JoinDataComplete(JoinData data, JoinMetadata metadata) + { + _Data = data; + Metadata = metadata; + } + + public uint JoinNumber + { + get { return _Data.JoinNumber; } + set { _Data.JoinNumber = value; } + } + + public uint JoinSpan + { + get { return _Data.JoinSpan; } + } + + public string GetNameAttribute() + { + string name = string.Empty; + JoinNameAttribute attribute = (JoinNameAttribute)Attribute.GetCustomAttribute(typeof(JoinDataComplete), typeof(JoinNameAttribute)); + if (attribute != null) + { + name = attribute.Name; + } + return name; + } + } + + [AttributeUsage(AttributeTargets.Field)] + public class JoinNameAttribute : Attribute + { + private string _name; + public string Name + { + get { return this.Name; } + set { this._name = value; } + } + + public JoinNameAttribute(string name) + { + this._name = name; + } + } } \ No newline at end of file From 1873cca375c9f28d6f00382943dbe33fcf61b58c Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 27 Mar 2020 08:34:28 -0600 Subject: [PATCH 27/33] updated new EssentialsDevice base class --- .../Devices/EssentialsDevice.cs | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs index 00263f0f..88c62f48 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/EssentialsDevice.cs @@ -14,37 +14,34 @@ namespace PepperDash.Essentials.Core /// public abstract class EssentialsDevice : Device { - public EssentialsDevice(string key) + protected EssentialsDevice(string key) : base(key) { } + } - public abstract class Factory : IDeviceFactory + public abstract class Factory : IDeviceFactory + { + #region IDeviceFactory Members + + public List TypeNames { get; protected set; } + + public virtual void LoadTypeFactories() { - #region IDeviceFactory Members - - public List TypeNames { get; protected set; } - - public virtual void LoadTypeFactories() + foreach (var typeName in TypeNames) { - foreach (var typeName in TypeNames) - { - DeviceFactory.AddFactoryForType(typeName, BuildDevice); - } + DeviceFactory.AddFactoryForType(typeName, BuildDevice); } - - #endregion - - public abstract IKeyed BuildDevice(DeviceConfig dc); - - public Factory() - { - TypeNames = new List(); - } - } - + #endregion + + public abstract IKeyed BuildDevice(DeviceConfig dc); + + protected Factory() + { + TypeNames = new List(); + } } } \ No newline at end of file From c45bf4405626b12cdf31258616245c848431134c Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 27 Mar 2020 09:22:44 -0600 Subject: [PATCH 28/33] modifies GetJoinForKey and GetJoinSpanForKey to be one-liners * converts private JoinData property to readonly JoinData field and updates usages * fixes some accidental recursiveness in JoinNameAttribute - converts Name property to auto-property --- .../JoinMaps/JoinMapBase.cs | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 26664434..8b1afdfa 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -203,14 +203,10 @@ namespace PepperDash.Essentials.Core /// public uint GetJoinForKey(string key) { - if (Joins.ContainsKey(key)) - return Joins[key].JoinNumber; - else - return 0; + return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; } - /// /// Returns the join span for the join with the specified key /// @@ -218,12 +214,8 @@ namespace PepperDash.Essentials.Core /// public uint GetJoinSpanForKey(string key) { - if (Joins.ContainsKey(key)) - return Joins[key].JoinSpan; - - else return 0; + return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; } - } /// @@ -315,24 +307,24 @@ namespace PepperDash.Essentials.Core /// public class JoinDataComplete { - JoinData _Data { get; set; } + private readonly JoinData _data; public JoinMetadata Metadata { get; set; } public JoinDataComplete(JoinData data, JoinMetadata metadata) { - _Data = data; + _data = data; Metadata = metadata; } public uint JoinNumber { - get { return _Data.JoinNumber; } - set { _Data.JoinNumber = value; } + get { return _data.JoinNumber; } + set { _data.JoinNumber = value; } } public uint JoinSpan { - get { return _Data.JoinSpan; } + get { return _data.JoinSpan; } } public string GetNameAttribute() @@ -350,16 +342,11 @@ namespace PepperDash.Essentials.Core [AttributeUsage(AttributeTargets.Field)] public class JoinNameAttribute : Attribute { - private string _name; - public string Name - { - get { return this.Name; } - set { this._name = value; } - } + public string Name { get; set; } public JoinNameAttribute(string name) { - this._name = name; + Name = name; } } } \ No newline at end of file From 46578cb3e295fb23c3fb7ee8e06a40626751a0f6 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 27 Mar 2020 09:23:40 -0600 Subject: [PATCH 29/33] Updates constructor dictionary building & removes unneccesary usings --- .../AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs index e13c3b06..7db70a35 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; +using System.Linq; using Crestron.SimplSharp.Reflection; using PepperDash.Essentials.Core; @@ -58,16 +54,12 @@ namespace PepperDash.Essentials.AppServer public SIMPLAtcJoinMap() { // Add all the JoinDataComplete properties to the Joins Dictionary - GetType() + Joins = GetType() .GetCType() .GetProperties() - .Where(x => x.PropertyType == typeof(uint)) - .ToList() - .ForEach(prop => - { - var join = (JoinDataComplete)prop.GetValue(this, null); - Joins.Add(join.GetNameAttribute(), join); - }); + .Where(prop => prop.IsDefined(typeof (JoinNameAttribute), false)) + .Select(prop => (JoinDataComplete) prop.GetValue(this, null)) + .ToDictionary(join => join.GetNameAttribute(), join => join); } public override void OffsetJoinNumbers(uint joinStart) From 1ae93b3ffdb54fa18055cfe788989321b1fd0eda Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 31 Mar 2020 10:53:24 -0600 Subject: [PATCH 30/33] Updates CameraControllerBridge and SIMPLCameraMessenger.cs to use new CameraControllerJoinMap --- .../AppServer/Messengers/SIMPLAtcMessenger.cs | 18 +-- .../Messengers/SIMPLCameraMessenger.cs | 127 ++++-------------- .../SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 27 +--- .../Bridges/AirMediaControllerBridge.cs | 2 +- PepperDashEssentials/Bridges/AppleTvBridge.cs | 2 +- PepperDashEssentials/Bridges/BridgeBase.cs | 22 ++- .../Bridges/C2nRthsControllerBridge.cs | 2 +- .../Bridges/CameraControllerBridge.cs | 51 +++---- .../Bridges/DigitalLoggerBridge.cs | 2 +- .../Bridges/DisplayControllerBridge.cs | 2 +- .../Bridges/DmBladeChassisControllerBridge.cs | 2 +- .../Bridges/DmChassisControllerBridge.cs | 2 +- .../Bridges/DmRmcControllerBridge.cs | 2 +- .../Bridges/DmTxControllerBridge.cs | 2 +- .../DmpsAudioOutputControllerBridge.cs | 2 +- .../Bridges/DmpsRoutingControllerBridge.cs | 2 +- .../Bridges/GenericLightingBridge.cs | 2 +- .../Bridges/GenericRelayDeviceBridge.cs | 2 +- .../GlsOccupancySensorBaseControllerBridge.cs | 2 +- .../Bridges/HdMdxxxCEControllerBridge.cs | 2 +- .../Bridges/IBasicCommunicationBridge.cs | 2 +- .../Bridges/IDigitalInputBridge.cs | 2 +- .../Bridges/IRSetTopBoxBaseBridge.cs | 2 +- .../JoinMaps/CameraControllerJoinMap.cs | 124 +++++++---------- .../Bridges/StatusSignControllerBridge.cs | 2 +- .../Bridges/SystemMonitorBridge.cs | 2 +- .../PluginLoading/PluginLoading.cs | 2 +- .../JoinMaps/JoinMapBase.cs | 124 ++++++++++++++--- 28 files changed, 258 insertions(+), 277 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index 3df9c912..6fd7ffae 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -104,10 +104,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { EISC = eisc; - JoinMap = new SIMPLAtcJoinMap(); - - // TODO: Take in JoinStart value from config - JoinMap.OffsetJoinNumbers(201); + JoinMap = new SIMPLAtcJoinMap(201); CurrentCallItem = new CodecActiveCallItem(); CurrentCallItem.Type = eCodecCallType.Audio; @@ -192,11 +189,14 @@ namespace PepperDash.Essentials.AppServer.Messengers // Pulse DTMF AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => { - var join = JoinMap.GetJoinForKey(s); - if (join > 0) - { - EISC.PulseBool(join, 100); - } + var join = JoinMap.Joins[s]; + if (join != null) + { + if (join.JoinNumber > 0) + { + EISC.PulseBool(join.JoinNumber, 100); + } + } })); } diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs index 468331d6..9cf6456f 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLCameraMessenger.cs @@ -19,94 +19,19 @@ namespace PepperDash.Essentials.AppServer.Messengers CameraControllerJoinMap JoinMap; - //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 - 1; - JoinMap = new CameraControllerJoinMap(); - JoinMap.OffsetJoinNumbers(joinStart); + JoinMap = new CameraControllerJoinMap(joinStart); + EISC.SetUShortSigAction(JoinMap.NumberOfPresets.JoinNumber, (u) => SendCameraFullMessageObject()); - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets), (u) => SendCameraFullMessageObject()); - - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto), (b) => PostCameraMode()); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual), (b) => PostCameraMode()); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff), (b) => PostCameraMode()); + EISC.SetBoolSigAction(JoinMap.CameraModeAuto.JoinNumber, (b) => PostCameraMode()); + EISC.SetBoolSigAction(JoinMap.CameraModeManual.JoinNumber, (b) => PostCameraMode()); + EISC.SetBoolSigAction(JoinMap.CameraModeOff.JoinNumber, (b) => PostCameraMode()); } @@ -119,22 +44,22 @@ namespace PepperDash.Essentials.AppServer.Messengers // Add press and holds using helper action Action addPHAction = (s, u) => asc.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); - addPHAction("/cameraUp", JoinMap.GetJoinForKey(CameraControllerJoinMap.TiltUp)); - addPHAction("/cameraDown", JoinMap.GetJoinForKey(CameraControllerJoinMap.TiltDown)); - addPHAction("/cameraLeft", JoinMap.GetJoinForKey(CameraControllerJoinMap.PanLeft)); - addPHAction("/cameraRight", JoinMap.GetJoinForKey(CameraControllerJoinMap.PanRight)); - addPHAction("/cameraZoomIn", JoinMap.GetJoinForKey(CameraControllerJoinMap.ZoomIn)); - addPHAction("/cameraZoomOut", JoinMap.GetJoinForKey(CameraControllerJoinMap.ZoomOut)); + addPHAction("/cameraUp", JoinMap.TiltUp.JoinNumber); + addPHAction("/cameraDown", JoinMap.TiltDown.JoinNumber); + addPHAction("/cameraLeft", JoinMap.PanLeft.JoinNumber); + addPHAction("/cameraRight", JoinMap.PanRight.JoinNumber); + addPHAction("/cameraZoomIn", JoinMap.ZoomIn.JoinNumber); + addPHAction("/cameraZoomOut", JoinMap.ZoomOut.JoinNumber); Action addAction = (s, u) => asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/cameraModeAuto", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto)); - addAction("/cameraModeManual", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual)); - addAction("/cameraModeOff", JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff)); + addAction("/cameraModeAuto", JoinMap.CameraModeAuto.JoinNumber); + addAction("/cameraModeManual", JoinMap.CameraModeManual.JoinNumber); + addAction("/cameraModeOff", JoinMap.CameraModeOff.JoinNumber); - var presetStart = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart); - var presetEnd = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart) + JoinMap.GetJoinSpanForKey(CameraControllerJoinMap.PresetRecallStart); + var presetStart = JoinMap.PresetRecallStart.JoinNumber; + var presetEnd = JoinMap.PresetRecallStart.JoinNumber + JoinMap.PresetRecallStart.JoinSpan; int presetId = 1; // camera presets @@ -159,11 +84,11 @@ namespace PepperDash.Essentials.AppServer.Messengers appServerController.RemoveAction(MessagePath + "/cameraModeManual"); appServerController.RemoveAction(MessagePath + "/cameraModeOff"); - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets), null); + EISC.SetUShortSigAction(JoinMap.NumberOfPresets.JoinNumber, null); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto), null); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual), null); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeOff), null); + EISC.SetBoolSigAction(JoinMap.CameraModeAuto.JoinNumber, null); + EISC.SetBoolSigAction(JoinMap.CameraModeManual.JoinNumber, null); + EISC.SetBoolSigAction(JoinMap.CameraModeOff.JoinNumber, null); } /// @@ -174,10 +99,10 @@ namespace PepperDash.Essentials.AppServer.Messengers var presetList = new List(); // Build a list of camera presets based on the names and count - if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.SupportsPresets))) + if (EISC.GetBool(JoinMap.SupportsPresets.JoinNumber)) { - var presetStart = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart); - var presetEnd = JoinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart) + JoinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); + var presetStart = JoinMap.PresetLabelStart.JoinNumber; + var presetEnd = JoinMap.PresetLabelStart.JoinNumber + JoinMap.NumberOfPresets.JoinNumber; var presetId = 1; for (uint i = presetStart; i < presetEnd; i++) @@ -192,7 +117,7 @@ namespace PepperDash.Essentials.AppServer.Messengers PostStatusMessage(new { cameraMode = GetCameraMode(), - hasPresets = EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.SupportsPresets)), + hasPresets = EISC.GetBool(JoinMap.SupportsPresets.JoinNumber), presets = presetList }); } @@ -215,8 +140,8 @@ namespace PepperDash.Essentials.AppServer.Messengers string GetCameraMode() { string m; - if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeAuto))) m = eCameraControlMode.Auto.ToString().ToLower(); - else if (EISC.GetBool(JoinMap.GetJoinForKey(CameraControllerJoinMap.CameraModeManual))) m = eCameraControlMode.Manual.ToString().ToLower(); + if (EISC.GetBool(JoinMap.CameraModeAuto.JoinNumber)) m = eCameraControlMode.Auto.ToString().ToLower(); + else if (EISC.GetBool(JoinMap.CameraModeManual.JoinNumber)) m = eCameraControlMode.Manual.ToString().ToLower(); else m = eCameraControlMode.Off.ToString().ToLower(); return m; } diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs index 7db70a35..4ae724e2 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -9,7 +9,7 @@ namespace PepperDash.Essentials.AppServer public class SIMPLAtcJoinMap : JoinMapBaseAdvanced { [JoinName("EndCall")] - public JoinDataComplete EndCall = new JoinDataComplete( new JoinData() { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata() { Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + public JoinDataComplete EndCall = new JoinDataComplete(new JoinData() { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata() { Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); [JoinName("IncomingAnswer")] public JoinDataComplete IncomingAnswer = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); [JoinName("IncomingReject")] @@ -51,27 +51,14 @@ namespace PepperDash.Essentials.AppServer [JoinName("#")] public JoinDataComplete DtmfPound = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public SIMPLAtcJoinMap() + /// + /// Constructor that passes the joinStart to the base class + /// + /// + public SIMPLAtcJoinMap(uint joinStart) + : base(joinStart) { - // Add all the JoinDataComplete properties to the Joins Dictionary - Joins = GetType() - .GetCType() - .GetProperties() - .Where(prop => prop.IsDefined(typeof (JoinNameAttribute), false)) - .Select(prop => (JoinDataComplete) prop.GetValue(this, null)) - .ToDictionary(join => join.GetNameAttribute(), join => join); - } - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - foreach (var join in Joins) - { - join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; - } - - PrintJoinMapInfo(); } } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs b/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs index 1f1b64dc..6d819c7b 100644 --- a/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs +++ b/PepperDashEssentials/Bridges/AirMediaControllerBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { AirMediaControllerJoinMap joinMap = new AirMediaControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/AppleTvBridge.cs b/PepperDashEssentials/Bridges/AppleTvBridge.cs index 6169a712..99501baa 100644 --- a/PepperDashEssentials/Bridges/AppleTvBridge.cs +++ b/PepperDashEssentials/Bridges/AppleTvBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { AppleTvJoinMap joinMap = new AppleTvJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if(!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index 03be4d7c..0c4e388b 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -45,7 +45,6 @@ namespace PepperDash.Essentials.Bridges { } - } /// @@ -55,7 +54,7 @@ namespace PepperDash.Essentials.Bridges { public EiscApiPropertiesConfig PropertiesConfig { get; private set; } - public Dictionary JoinMaps { get; set; } + protected Dictionary JoinMaps { get; private set; } public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } @@ -97,7 +96,7 @@ namespace PepperDash.Essentials.Bridges } else if (device is CameraBase) { - (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); continue; } else if (device is PepperDash.Essentials.Core.DisplayBase) @@ -190,6 +189,23 @@ namespace PepperDash.Essentials.Bridges }); } + /// + /// Adds a join map + /// + /// + /// + public void AddJoinMap(string deviceKey, JoinMapBaseAdvanced joinMap) + { + if (!JoinMaps.ContainsKey(deviceKey)) + { + JoinMaps.Add(deviceKey, joinMap); + } + else + { + Debug.Console(2, this, "Unable to add join map with key '{0}'. Key already exists in JoinMaps dictionary", deviceKey); + } + } + /// /// Used for debugging to trigger an action based on a join number and type /// diff --git a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs b/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs index 58f4600d..13b78bae 100644 --- a/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs +++ b/PepperDashEssentials/Bridges/C2nRthsControllerBridge.cs @@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Bridges { var joinMap = new C2nRthsControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/CameraControllerBridge.cs b/PepperDashEssentials/Bridges/CameraControllerBridge.cs index 21a9d3eb..8e25300a 100644 --- a/PepperDashEssentials/Bridges/CameraControllerBridge.cs +++ b/PepperDashEssentials/Bridges/CameraControllerBridge.cs @@ -15,28 +15,31 @@ namespace PepperDash.Essentials.Bridges { public static class CameraControllerApiExtensions { - public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey) + public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge) { - CameraControllerJoinMap joinMap = new CameraControllerJoinMap(); + CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + // Adds the join map to the bridge + bridge.AddJoinMap(cameraDevice.Key, joinMap); - if (!string.IsNullOrEmpty(joinMapSerialized)) - joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - joinMap.OffsetJoinNumbers(joinStart); + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString()); var commMonitor = cameraDevice as ICommunicationMonitor; - commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.IsOnline)]); + commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); var ptzCamera = cameraDevice as IHasCameraPtzControl; if (ptzCamera != null) { - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PanLeft), (b) => + trilist.SetBoolSigAction(joinMap.PanLeft.JoinNumber, (b) => { if (b) { @@ -47,7 +50,7 @@ namespace PepperDash.Essentials.Bridges ptzCamera.PanStop(); } }); - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PanRight), (b) => + trilist.SetBoolSigAction(joinMap.PanRight.JoinNumber, (b) => { if (b) { @@ -59,7 +62,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.TiltUp), (b) => + trilist.SetBoolSigAction(joinMap.TiltUp.JoinNumber, (b) => { if (b) { @@ -70,7 +73,7 @@ namespace PepperDash.Essentials.Bridges ptzCamera.TiltStop(); } }); - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.TiltDown), (b) => + trilist.SetBoolSigAction(joinMap.TiltDown.JoinNumber, (b) => { if (b) { @@ -82,7 +85,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.ZoomIn), (b) => + trilist.SetBoolSigAction(joinMap.ZoomIn.JoinNumber, (b) => { if (b) { @@ -94,7 +97,7 @@ namespace PepperDash.Essentials.Bridges } }); - trilist.SetBoolSigAction(joinMap.GetJoinForKey(CameraControllerJoinMap.ZoomOut), (b) => + trilist.SetBoolSigAction(joinMap.ZoomOut.JoinNumber, (b) => { if (b) { @@ -110,17 +113,17 @@ namespace PepperDash.Essentials.Bridges if (cameraDevice is IPower) { var powerCamera = cameraDevice as IPower; - trilist.SetSigTrueAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOn), () => powerCamera.PowerOn()); - trilist.SetSigTrueAction(joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOff), () => powerCamera.PowerOff()); + trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn()); + trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff()); - powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOn)]); - powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.PowerOff)]); + powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]); + powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]); } if (cameraDevice is ICommunicationMonitor) { var monitoredCamera = cameraDevice as ICommunicationMonitor; - monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GetJoinForKey(CameraControllerJoinMap.IsOnline)]); + monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); } if (cameraDevice is IHasCameraPresets) @@ -129,7 +132,7 @@ namespace PepperDash.Essentials.Bridges var presetsCamera = cameraDevice as IHasCameraPresets; presetsCamera.PresetsListHasChanged += new EventHandler((o, a) => { - for (int i = 1; i <= joinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); i++) + for (int i = 1; i <= joinMap.NumberOfPresets.JoinNumber; i++) { int tempNum = i - 1; @@ -140,21 +143,21 @@ namespace PepperDash.Essentials.Bridges if (preset != null) label = preset.Description; - trilist.SetString((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart) + tempNum), label); + trilist.SetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum), label); } }); - for (int i = 0; i < joinMap.GetJoinForKey(CameraControllerJoinMap.NumberOfPresets); i++) + for (int i = 0; i < joinMap.NumberOfPresets.JoinNumber; i++) { int tempNum = i; - trilist.SetSigTrueAction((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetRecallStart) + tempNum), () => + trilist.SetSigTrueAction((ushort)(joinMap.PresetRecallStart.JoinNumber + tempNum), () => { presetsCamera.PresetSelect(tempNum); }); - trilist.SetSigTrueAction((ushort)(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetSaveStart) + tempNum), () => + trilist.SetSigTrueAction((ushort)(joinMap.PresetSaveStart.JoinNumber + tempNum), () => { - var label = trilist.GetString(joinMap.GetJoinForKey(CameraControllerJoinMap.PresetLabelStart + tempNum)); + var label = trilist.GetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum)); presetsCamera.PresetStore(tempNum, label); }); diff --git a/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs b/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs index 2c857da2..7d3fab3d 100644 --- a/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs +++ b/PepperDashEssentials/Bridges/DigitalLoggerBridge.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Bridges { DigitalLoggerJoinMap joinMap = new DigitalLoggerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs b/PepperDashEssentials/Bridges/DisplayControllerBridge.cs index 25791796..c94b3691 100644 --- a/PepperDashEssentials/Bridges/DisplayControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DisplayControllerBridge.cs @@ -23,7 +23,7 @@ namespace PepperDash.Essentials.Bridges DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if(!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs index 6daddbb0..221745e8 100644 --- a/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmBladeChassisControllerBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { public static void LinkToApi(this DmBladeChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey) { DmBladeChassisControllerJoinMap joinMap = new DmBladeChassisControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs index e193cc2c..9c8c8551 100644 --- a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs @@ -23,7 +23,7 @@ namespace PepperDash.Essentials.Bridges { DmChassisControllerJoinMap joinMap = new DmChassisControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs b/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs index ca7bdeca..1e99b734 100644 --- a/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmRmcControllerBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { DmRmcControllerJoinMap joinMap = new DmRmcControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs index 91f8c6d7..9b28611e 100644 --- a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Bridges { DmTxControllerJoinMap joinMap = new DmTxControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs index 406550a4..f721b44f 100644 --- a/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsAudioOutputControllerBridge.cs @@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Bridges { DmpsAudioOutputControllerJoinMap joinMap = new DmpsAudioOutputControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs index cc95e07b..eb359dd9 100644 --- a/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmpsRoutingControllerBridge.cs @@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Bridges { DmpsRoutingControllerJoinMap joinMap = new DmpsRoutingControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/GenericLightingBridge.cs b/PepperDashEssentials/Bridges/GenericLightingBridge.cs index 543e124e..d76bbebb 100644 --- a/PepperDashEssentials/Bridges/GenericLightingBridge.cs +++ b/PepperDashEssentials/Bridges/GenericLightingBridge.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Bridges { GenericLightingJoinMap joinMap = new GenericLightingJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs b/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs index 95566712..684a5550 100644 --- a/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs +++ b/PepperDashEssentials/Bridges/GenericRelayDeviceBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { GenericRelayControllerJoinMap joinMap = new GenericRelayControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs index d905beef..a49061b7 100644 --- a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs +++ b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs @@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Bridges { GlsOccupancySensorBaseJoinMap joinMap = new GlsOccupancySensorBaseJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs index 0ec23c55..52bacfec 100644 --- a/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs +++ b/PepperDashEssentials/Bridges/HdMdxxxCEControllerBridge.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials.Bridges { HdMdxxxCEControllerJoinMap joinMap = new HdMdxxxCEControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs index 86fbf78b..6ae9334c 100644 --- a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs +++ b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Bridges { IBasicCommunicationJoinMap joinMap = new IBasicCommunicationJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/IDigitalInputBridge.cs b/PepperDashEssentials/Bridges/IDigitalInputBridge.cs index 4d42cbdc..54c48e1a 100644 --- a/PepperDashEssentials/Bridges/IDigitalInputBridge.cs +++ b/PepperDashEssentials/Bridges/IDigitalInputBridge.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Bridges { IDigitalInputJoinMap joinMap = new IDigitalInputJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs index 68d765bc..0f7b5786 100644 --- a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs +++ b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs @@ -17,7 +17,7 @@ namespace PepperDash.Essentials.Bridges public static void LinkToApi(this PepperDash.Essentials.Devices.Common.IRSetTopBoxBase stbDevice, BasicTriList trilist, uint joinStart, string joinMapKey) { SetTopBoxControllerJoinMap joinMap = new SetTopBoxControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index ce4594bc..17bd1a71 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -11,86 +11,56 @@ namespace PepperDash.Essentials.Bridges /// /// Join map for CameraBase devices /// - public class CameraControllerJoinMap : JoinMapBase + public class CameraControllerJoinMap : JoinMapBaseAdvanced { - public const string IsOnline = "IsOnline"; - public const string PowerOff = "PowerOff"; - public const string PowerOn = "PowerOn"; - public const string TiltUp = "TiltUp"; - public const string TiltDown = "TiltDown"; - public const string PanLeft = "PanLeft"; - public const string PanRight = "PanRight"; - public const string ZoomIn = "ZoomIn"; - public const string ZoomOut = "ZoomOut"; - public const string PresetRecallStart = "PresetRecallStart"; - public const string PresetSaveStart = "PresetSaveStart"; - public const string PresetLabelStart = "PresetReacllStgart"; - public const string NumberOfPresets = "NumberOfPresets"; - public const string CameraModeAuto = "CameraModeAuto"; - public const string CameraModeManual = "CameraModeManual"; - public const string CameraModeOff = "CameraModeOff"; - public const string SupportsCameraModeAuto = "SupportsCameraModeAuto"; - public const string SupportsCameraModeOff = "SupportsCameraModeOff"; - public const string SupportsPresets = "SupportsPresets"; + [JoinName("TiltUp")] + public JoinDataComplete TiltUp = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() { Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("TiltDown")] + public JoinDataComplete TiltDown = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata() { Label = "Tilt Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PanLeft")] + public JoinDataComplete PanLeft = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata() { Label = "Pan Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PanRight")] + public JoinDataComplete PanRight = new JoinDataComplete(new JoinData() { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata() { Label = "Pan Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ZoomIn")] + public JoinDataComplete ZoomIn = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata() { Label = "Zoom In", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ZoomOut")] + public JoinDataComplete ZoomOut = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata() { Label = "Zoom Out", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public CameraControllerJoinMap() + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 }, new JoinMetadata() { Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PowerOn")] + public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata() { Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PowerOff")] + public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + + [JoinName("NumberOfPresets")] + public JoinDataComplete NumberOfPresets = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "Tells Essentials the number of defined presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("PresetRecallStart")] + public JoinDataComplete PresetRecallStart = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 20 }, new JoinMetadata() { Label = "Preset Recall Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PresetLabelStart")] + public JoinDataComplete PresetLabelStart = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 20 }, new JoinMetadata() { Label = "Preset Label Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("PresetSaveStart")] + public JoinDataComplete PresetSaveStart = new JoinDataComplete(new JoinData() { JoinNumber = 31, JoinSpan = 20 }, new JoinMetadata() { Label = "Preset Save Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CameraModeAuto")] + public JoinDataComplete CameraModeAuto = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraModeManual")] + public JoinDataComplete CameraModeManual = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraModeOff")] + public JoinDataComplete CameraModeOff = new JoinDataComplete(new JoinData() { JoinNumber = 53, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SupportsCameraModeAuto")] + public JoinDataComplete SupportsCameraModeAuto = new JoinDataComplete(new JoinData() { JoinNumber = 55, JoinSpan = 1 }, new JoinMetadata() { Label = "Supports Camera Mode Auto", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("SupportsCameraModeOff")] + public JoinDataComplete SupportsCameraModeOff = new JoinDataComplete(new JoinData() { JoinNumber = 56, JoinSpan = 1 }, new JoinMetadata() { Label = "Supports Camera Mode Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("SupportsPresets")] + public JoinDataComplete SupportsPresets = new JoinDataComplete(new JoinData() { JoinNumber = 57, JoinSpan = 1 }, new JoinMetadata() { Label = "Supports Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + + public CameraControllerJoinMap(uint joinStart) + :base(joinStart) { - Joins.Add(TiltDown, new JoinMetadata() - { JoinNumber = 1, Label = "Tilt Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(TiltDown, new JoinMetadata() - { JoinNumber = 2, Label = "Tilt Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(PanLeft, new JoinMetadata() - { JoinNumber = 3, Label = "Pan Left", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(PanRight, new JoinMetadata() - { JoinNumber = 4, Label = "Pan Right", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ZoomIn, new JoinMetadata() - { JoinNumber = 5, Label = "Zoom In", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ZoomOut, new JoinMetadata() - { JoinNumber = 6, Label = "Zoom Out", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(PowerOn, new JoinMetadata() - { JoinNumber = 7, Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(PowerOff, new JoinMetadata() - { JoinNumber = 8, Label = "Power Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IsOnline, new JoinMetadata() - { JoinNumber = 9, Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(PresetRecallStart, new JoinMetadata() - { JoinNumber = 11, Label = "Preset Recall Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); - Joins.Add(PresetLabelStart, new JoinMetadata() - { JoinNumber = 11, Label = "Preset Label Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - - Joins.Add(PresetSaveStart, new JoinMetadata() - { JoinNumber = 31, Label = "Preset Save Start", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); - - Joins.Add(NumberOfPresets, new JoinMetadata() - { JoinNumber = 11, Label = "Number of Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - - Joins.Add(CameraModeAuto, new JoinMetadata() - { JoinNumber = 51, Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraModeManual, new JoinMetadata() - { JoinNumber = 52, Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraModeOff, new JoinMetadata() - { JoinNumber = 53, Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(SupportsCameraModeAuto, new JoinMetadata() - { JoinNumber = 55, Label = "Supports Camera Mode Auto", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SupportsCameraModeOff, new JoinMetadata() - { JoinNumber = 56, Label = "Supports Camera Mode Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SupportsPresets, new JoinMetadata() - { JoinNumber = 57, Label = "Supports Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - } - - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - foreach (var join in Joins) - { - join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; - } - - PrintJoinMapInfo(); } } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs b/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs index df38ba26..860f070d 100644 --- a/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs +++ b/PepperDashEssentials/Bridges/StatusSignControllerBridge.cs @@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Bridges { var joinMap = new StatusSignControllerJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/Bridges/SystemMonitorBridge.cs b/PepperDashEssentials/Bridges/SystemMonitorBridge.cs index 6e41a43f..d048b493 100644 --- a/PepperDashEssentials/Bridges/SystemMonitorBridge.cs +++ b/PepperDashEssentials/Bridges/SystemMonitorBridge.cs @@ -14,7 +14,7 @@ namespace PepperDash.Essentials.Bridges { var joinMap = new SystemMonitorJoinMap(); - var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); if(!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs index e1b0f555..11a4ee32 100644 --- a/PepperDashEssentials/PluginLoading/PluginLoading.cs +++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs @@ -415,7 +415,7 @@ namespace PepperDash.Essentials // Deal with any .cplz files UnzipAndMoveCplzArchives(); - if(Directory.Exists(_loadedPluginsDirectoryPath) { + if(Directory.Exists(_loadedPluginsDirectoryPath)) { // Load the assemblies from the loadedPlugins folder into the AppDomain LoadPluginAssemblies(); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 8b1afdfa..8ea1cf7f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core /// /// /// - public static string GetJoinMapForDevice(string joinMapKey) + public static string GetSerializedJoinMapForDevice(string joinMapKey) { if (string.IsNullOrEmpty(joinMapKey)) return null; @@ -33,6 +33,31 @@ namespace PepperDash.Essentials.Core else return null; } + + /// + /// Attempts to find a custom join map by key and returns it deserialized if found + /// + /// + /// + public static Dictionary TryGetJoinMapAdvancedForDevice(string joinMapKey) + { + if (string.IsNullOrEmpty(joinMapKey)) + return null; + + var joinMapSerialzed = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; + + if (joinMapSerialzed != null) + { + var joinMap = JsonConvert.DeserializeObject>(joinMapSerialzed); + + if (joinMap != null) + return joinMap; + else + return null; + } + else + return null; + } } /// @@ -135,17 +160,32 @@ namespace PepperDash.Essentials.Core /// public abstract class JoinMapBaseAdvanced { - /// - /// Modifies all the join numbers by adding the offset. This should never be called twice - /// - /// - public abstract void OffsetJoinNumbers(uint joinStart); + protected uint _joinOffset; /// /// The collection of joins and associated metadata /// public Dictionary Joins = new Dictionary(); + protected JoinMapBaseAdvanced(uint joinStart) + { + _joinOffset = joinStart - 1; + + // Add all the JoinDataComplete properties to the Joins Dictionary and pass in the offset + Joins = GetType() + .GetCType() + .GetProperties() + .Where(prop => prop.IsDefined(typeof(JoinNameAttribute), false)) + .Select(prop => (JoinDataComplete)prop.GetValue(this, null)) + .ToDictionary(join => join.GetNameAttribute(), join => + { + join.SetJoinOffset(_joinOffset); + return join; + }); + + PrintJoinMapInfo(); + } + /// /// Prints the join information to console /// @@ -197,25 +237,46 @@ namespace PepperDash.Essentials.Core } /// - /// Returns the join number for the join with the specified key + /// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom /// - /// - /// - public uint GetJoinForKey(string key) + /// + public void SetCustomJoinData(Dictionary joinData) { - return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; + foreach (var customJoinData in joinData) + { + var join = Joins[customJoinData.Key]; + + if (join != null) + { + join.SetCustomJoinData(customJoinData.Value); + } + else + { + Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key); + } + } } + ///// + ///// Returns the join number for the join with the specified key + ///// + ///// + ///// + //public uint GetJoinForKey(string key) + //{ + // return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0; + //} - /// - /// Returns the join span for the join with the specified key - /// - /// - /// - public uint GetJoinSpanForKey(string key) - { - return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; - } + + ///// + ///// Returns the join span for the join with the specified key + ///// + ///// + ///// + //public uint GetJoinSpanForKey(string key) + //{ + // return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; + //} } /// @@ -307,7 +368,9 @@ namespace PepperDash.Essentials.Core /// public class JoinDataComplete { - private readonly JoinData _data; + private uint _joinOffset; + + private JoinData _data; public JoinMetadata Metadata { get; set; } public JoinDataComplete(JoinData data, JoinMetadata metadata) @@ -316,9 +379,21 @@ namespace PepperDash.Essentials.Core Metadata = metadata; } + /// + /// Sets the join offset value + /// + /// + public void SetJoinOffset(uint joinOffset) + { + _joinOffset = joinOffset; + } + + /// + /// The join number (including the offset) + /// public uint JoinNumber { - get { return _data.JoinNumber; } + get { return _data.JoinNumber+ _joinOffset; } set { _data.JoinNumber = value; } } @@ -327,6 +402,11 @@ namespace PepperDash.Essentials.Core get { return _data.JoinSpan; } } + public void SetCustomJoinData(JoinData customJoinData) + { + _data = customJoinData; + } + public string GetNameAttribute() { string name = string.Empty; From e52259e750f1d8afeb6e22e1b9de089cf3e2eafd Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 31 Mar 2020 20:52:05 -0600 Subject: [PATCH 31/33] Updated SIMPLVtcJoinMap to new join scheme --- .../MobileControlSIMPLRoomJoinMap.cs | 18 +- .../SIMPLJoinMaps/SIMPLAtcJoinMap.cs | 7 +- .../SIMPLJoinMaps/SIMPLVtcJoinMap.cs | 250 ++++++++---------- .../JoinMaps/CameraControllerJoinMap.cs | 2 - .../PluginLoading/PluginLoading.cs | 1 - 5 files changed, 127 insertions(+), 151 deletions(-) diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs index 2544c94f..f256213f 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs @@ -9,7 +9,7 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.AppServer { - public class MobileControlSIMPLRoomJoinMap : JoinMapBase + public class MobileControlSIMPLRoomJoinMap : JoinMapBaseAdvanced { public const string ConfigIsLocal = "ConfigIsLocal"; public const string RoomIsOn = "RoomIsOn"; @@ -33,7 +33,6 @@ namespace PepperDash.Essentials.AppServer public const string SourceShareDisableJoinStart = "SourceShareDisableJoinStart"; public const string SourceIsEnabledJoinStart = "SourceIsEnabledJoinStart"; - //public const string MasterVolumeLevel = "MasterVolumeLevel"; public const string VolumeSlidersJoinStart = "VolumeSlidersJoinStart"; public const string ShutdownPromptDuration = "ShutdownPromptDuration"; public const string NumberOfAuxFaders = "NumberOfAuxFaders"; @@ -58,7 +57,8 @@ namespace PepperDash.Essentials.AppServer public const string CameraNearNameStart = "CameraNearNameStart"; public const string CameraFarName = "CameraFarName"; - public MobileControlSIMPLRoomJoinMap() + public MobileControlSIMPLRoomJoinMap(uint joinStart) + :base(joinStart) { Joins.Add(ConfigIsLocal, new JoinMetadata() { JoinNumber = 100, Label = "Config is local to Essentials", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(RoomIsOn, new JoinMetadata() { JoinNumber = 301, Label = "Room Is On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); @@ -76,6 +76,7 @@ namespace PepperDash.Essentials.AppServer Joins.Add(SourceHasChanged, new JoinMetadata() { JoinNumber = 71, Label = "Source Changed", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); // Possibly move these to Audio Codec Messenger Joins.Add(SpeedDialVisibleStartJoin, new JoinMetadata() { JoinNumber = 261, Label = "Speed Dial Visible", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 10, JoinType = eJoinType.Digital }); + // Joins.Add(ConfigIsReady, new JoinMetadata() { JoinNumber = 501, Label = "Config info from SIMPL is ready", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); Joins.Add(HideVideoConfRecents, new JoinMetadata() { JoinNumber = 502, Label = "Hide Video Conference Recents", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); @@ -113,16 +114,5 @@ namespace PepperDash.Essentials.AppServer // } - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - foreach (var join in Joins) - { - join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; - } - - PrintJoinMapInfo(); - } } } \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs index 4ae724e2..20abb31e 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLAtcJoinMap.cs @@ -22,10 +22,15 @@ namespace PepperDash.Essentials.AppServer public JoinDataComplete CurrentCallNumber = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); [JoinName("CurrentCallName")] public JoinDataComplete CurrentCallName = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); - [JoinName("CurrentHookStateCallName")] + [JoinName("HookState")] public JoinDataComplete HookState = new JoinDataComplete(new JoinData() { JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); [JoinName("CallDirection")] public JoinDataComplete CallDirection = new JoinDataComplete(new JoinData() { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("IncomingCallName")] + public JoinDataComplete IncomingCallName = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Incoming Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("IncomingCallNumber")] + public JoinDataComplete IncomingCallNumber = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Incoming Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("0")] public JoinDataComplete Dtmf0 = new JoinDataComplete(new JoinData() { JoinNumber = 10, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); [JoinName("1")] diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs index b5776065..1ce3c5aa 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/SIMPLVtcJoinMap.cs @@ -9,149 +9,133 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.AppServer { - public class SIMPLVtcJoinMap : JoinMapBase + public class SIMPLVtcJoinMap : JoinMapBaseAdvanced { - public const string EndCall = "EndCall"; - public const string IncomingCall = "IncomingCall"; - public const string IncomingAnswer = "IncomingAnswer"; - public const string IncomingReject = "IncomingReject"; - public const string SpeedDialStart = "SpeedDialStart"; - public const string DirectorySearchBusy = "DirectorySearchBusy"; - public const string DirectoryLineSelected = "DirectoryLineSelected"; - public const string DirectoryEntryIsContact = "DirectoryEntryIsContact"; - public const string DirectoryIsRoot = "DirectoryIsRoot"; - public const string DDirectoryHasChanged = "DDirectoryHasChanged"; - public const string DirectoryRoot = "DirectoryRoot"; - public const string DirectoryFolderBack = "DirectoryFoldeBrack"; - public const string DirectoryDialSelectedLine = "DirectoryDialSelectedLine"; + [JoinName("EndCall")] + public JoinDataComplete EndCall = new JoinDataComplete(new JoinData() { JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata() { Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("IncomingCall")] + public JoinDataComplete IncomingCall = new JoinDataComplete(new JoinData() { JoinNumber = 50, JoinSpan = 1 }, new JoinMetadata() { Label = "Incoming Call", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("IncomingAnswer")] + public JoinDataComplete IncomingAnswer = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("IncomingReject")] + public JoinDataComplete IncomingReject = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("SpeedDialStart")] + public JoinDataComplete SpeedDialStart = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 4 }, new JoinMetadata() { Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public const string CameraTiltUp = "CameraTiltUp"; - public const string CameraTiltDown = "CameraTiltDown"; - public const string CameraPanLeft = "CameraPanLeft"; - public const string CameraPanRight = "CameraPanRight"; - public const string CameraZoomIn = "CameraZoomIn"; - public const string CameraZoomOut = "CameraZoomOut"; - public const string CameraPresetStart = "CameraPresetStart"; - public const string CameraModeAuto = "CameraModeAuto"; - public const string CameraModeManual = "CameraModeManual"; - public const string CameraModeOff = "CameraModeOff"; + [JoinName("DirectorySearchBusy")] + public JoinDataComplete DirectorySearchBusy = new JoinDataComplete(new JoinData() { JoinNumber = 100, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Search Busy FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryLineSelected")] + public JoinDataComplete DirectoryLineSelected = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Line Selected FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryEntryIsContact")] + public JoinDataComplete DirectoryEntryIsContact = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Selected Entry Is Contact FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryIsRoot")] + public JoinDataComplete DirectoryIsRoot = new JoinDataComplete(new JoinData() { JoinNumber = 102, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory is on Root FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DDirectoryHasChanged")] + public JoinDataComplete DDirectoryHasChanged = new JoinDataComplete(new JoinData() { JoinNumber = 103, JoinSpan = 1 }, new JoinMetadata() {Label = "Directory has changed FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryRoot")] + public JoinDataComplete DirectoryRoot = new JoinDataComplete(new JoinData() { JoinNumber = 104, JoinSpan = 1 }, new JoinMetadata() { Label = "Go to Directory Root", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryFolderBack")] + public JoinDataComplete DirectoryFolderBack = new JoinDataComplete(new JoinData() { JoinNumber = 105, JoinSpan = 1 }, new JoinMetadata() { Label = "Go back one directory level", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryDialSelectedLine")] + public JoinDataComplete DirectoryDialSelectedLine = new JoinDataComplete(new JoinData() { JoinNumber = 106, JoinSpan = 1 }, new JoinMetadata() { Label = "Dial selected directory line", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public const string CameraSelfView = "CameraSelfView"; - public const string CameraLayout = "CameraLayout"; + [JoinName("CameraTiltUp")] + public JoinDataComplete CameraTiltUp = new JoinDataComplete(new JoinData() { JoinNumber = 111, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Tilt Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraTiltDown")] + public JoinDataComplete CameraTiltDown = new JoinDataComplete(new JoinData() { JoinNumber = 112, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Tilt Down", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraPanLeft")] + public JoinDataComplete CameraPanLeft = new JoinDataComplete(new JoinData() { JoinNumber = 113, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Pan Left", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraPanRight")] + public JoinDataComplete CameraPanRight = new JoinDataComplete(new JoinData() { JoinNumber = 114, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Pan Right", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraZoomIn")] + public JoinDataComplete CameraZoomIn = new JoinDataComplete(new JoinData() { JoinNumber = 115, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Zoom In", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraZoomOut")] + public JoinDataComplete CameraZoomOut = new JoinDataComplete(new JoinData() { JoinNumber = 116, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Zoom Out", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CameraPresetStart")] + public JoinDataComplete CameraPresetStart = new JoinDataComplete(new JoinData() { JoinNumber = 121, JoinSpan = 5 }, new JoinMetadata() { Label = "Camera Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public const string CameraSupportsAutoMode = "CameraSupportsAutoMode"; - public const string CameraSupportsOffMode = "CameraSupportsOffMode"; + [JoinName("CameraModeAuto")] + public JoinDataComplete CameraModeAuto = new JoinDataComplete(new JoinData() { JoinNumber = 131, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraModeManual")] + public JoinDataComplete CameraModeManual = new JoinDataComplete(new JoinData() { JoinNumber = 132, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraModeOff")] + public JoinDataComplete CameraModeOff = new JoinDataComplete(new JoinData() { JoinNumber = 133, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - public const string CameraNumberSelect = "CameraNumberSelect"; - public const string DirectorySelectRow = "DirectorySelectRow"; - public const string DirectoryRowCount = "DirectoryRowCount"; + [JoinName("CameraSelfView")] + public JoinDataComplete CameraSelfView = new JoinDataComplete(new JoinData() { JoinNumber = 141, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Self View Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraLayout")] + public JoinDataComplete CameraLayout = new JoinDataComplete(new JoinData() { JoinNumber = 142, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Layout Toggle", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); - public const string CurrentDialString = "CurrentDialString"; - public const string CurrentCallNumber = "CurrentCallNumber"; - public const string CurrentCallName = "CurrentCallName"; - public const string HookState = "HookState"; - public const string CallDirection = "CallDirection"; - public const string IncomingCallName = "IncomingCallName"; - public const string IncomingCallNumber = "IncomingCallNumber"; - public const string DirectorySearchString = "DirectorySearchString"; - public const string DirectoryEntriesStart = "EndCaDirectoryEntriesStartll"; - public const string DirectoryEntrySelectedName = "DirectoryEntrySelectedName"; - public const string DirectoryEntrySelectedNumber = "DirectoryEntrySelectedNumber"; - public const string DirectorySelectedFolderName = "DirectorySelectedFolderName"; + [JoinName("CameraSupportsAutoMode")] + public JoinDataComplete CameraSupportsAutoMode = new JoinDataComplete(new JoinData() { JoinNumber = 143, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Supports Auto Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CameraSupportsOffMode")] + public JoinDataComplete CameraSupportsOffMode = new JoinDataComplete(new JoinData() { JoinNumber = 144, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Supports Off Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public const string Dtmf0 = "0"; - public const string Dtmf1 = "1"; - public const string Dtmf2 = "2"; - public const string Dtmf3 = "3"; - public const string Dtmf4 = "4"; - public const string Dtmf5 = "5"; - public const string Dtmf6 = "6"; - public const string Dtmf7 = "7"; - public const string Dtmf8 = "8"; - public const string Dtmf9 = "9"; - public const string DtmfStar = "*"; - public const string DtmfPound = "#"; - + [JoinName("CameraNumberSelect")] + public JoinDataComplete CameraNumberSelect = new JoinDataComplete(new JoinData() { JoinNumber = 60, JoinSpan = 1 }, new JoinMetadata() { Label = "Camera Number Select/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectorySelectRow")] + public JoinDataComplete DirectorySelectRow = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Select Row", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("DirectoryRowCount")] + public JoinDataComplete DirectoryRowCount = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Row Count FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public SIMPLVtcJoinMap() + [JoinName("CurrentDialString")] + public JoinDataComplete CurrentDialString = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentCallName")] + public JoinDataComplete CurrentCallName = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CurrentCallNumber")] + public JoinDataComplete CurrentCallNumber = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("HookState")] + public JoinDataComplete HookState = new JoinDataComplete(new JoinData() { JoinNumber = 31, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CallDirection")] + public JoinDataComplete CallDirection = new JoinDataComplete(new JoinData() { JoinNumber = 22, JoinSpan = 1 }, new JoinMetadata() { Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("IncomingCallName")] + public JoinDataComplete IncomingCallName = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() { Label = "Incoming Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("IncomingCallNumber")] + public JoinDataComplete IncomingCallNumber = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Incoming Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("DirectorySearchString")] + public JoinDataComplete DirectorySearchString = new JoinDataComplete(new JoinData() { JoinNumber = 100, JoinSpan = 1 }, new JoinMetadata() { Label = "Directory Search String", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("DirectoryEntriesStart")] + public JoinDataComplete DirectoryEntriesStart = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 255 }, new JoinMetadata() { Label = "Directory Entries", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("DirectoryEntrySelectedName")] + public JoinDataComplete DirectoryEntrySelectedName = new JoinDataComplete(new JoinData() { JoinNumber = 356, JoinSpan = 1 }, new JoinMetadata() { Label = "Selected Directory Entry Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("DirectoryEntrySelectedNumber")] + public JoinDataComplete DirectoryEntrySelectedNumber = new JoinDataComplete(new JoinData() { JoinNumber = 357, JoinSpan = 1 }, new JoinMetadata() { Label = "Selected Directory Entry Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("DirectorySelectedFolderName")] + public JoinDataComplete DirectorySelectedFolderName = new JoinDataComplete(new JoinData() { JoinNumber = 358, JoinSpan = 1 }, new JoinMetadata() { Label = "Selected Directory Folder Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("1")] + public JoinDataComplete Dtmf1 = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("2")] + public JoinDataComplete Dtmf2 = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("3")] + public JoinDataComplete Dtmf3 = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("4")] + public JoinDataComplete Dtmf4 = new JoinDataComplete(new JoinData() { JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("5")] + public JoinDataComplete Dtmf5 = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("6")] + public JoinDataComplete Dtmf6 = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("7")] + public JoinDataComplete Dtmf7 = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("8")] + public JoinDataComplete Dtmf8 = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("9")] + public JoinDataComplete Dtmf9 = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("0")] + public JoinDataComplete Dtmf0 = new JoinDataComplete(new JoinData() { JoinNumber = 10, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("*")] + public JoinDataComplete DtmfStar = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("#")] + public JoinDataComplete DtmfPound = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + public SIMPLVtcJoinMap(uint joinStart) + :base(joinStart) { - // TODO: Set Join metedata - - Joins.Add(EndCall, new JoinMetadata() { JoinNumber = 24, Label = "Hang Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IncomingCall, new JoinMetadata() { JoinNumber = 50, Label = "Incoming Call FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IncomingAnswer, new JoinMetadata() { JoinNumber = 51, Label = "Answer Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(IncomingReject, new JoinMetadata() { JoinNumber = 52, Label = "Reject Incoming Call", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SpeedDialStart, new JoinMetadata() { JoinNumber = 41, Label = "Speed Dial", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 4, JoinType = eJoinType.Digital }); - - Joins.Add(DirectorySearchBusy, new JoinMetadata() { JoinNumber = 100, Label = "Directory Search Busy FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryLineSelected, new JoinMetadata() { JoinNumber = 101, Label = "Directory Line Selected FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryEntryIsContact, new JoinMetadata() { JoinNumber = 101, Label = "Directory Selected Entry Is Contact FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryIsRoot, new JoinMetadata() { JoinNumber = 102, Label = "Directory is on Root FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DDirectoryHasChanged, new JoinMetadata() { JoinNumber = 103, Label = "Directory has changed FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryRoot, new JoinMetadata() { JoinNumber = 104, Label = "Go to Directory Root", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryFolderBack, new JoinMetadata() { JoinNumber = 105, Label = "Go back one directory level", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DirectoryDialSelectedLine, new JoinMetadata() { JoinNumber = 106, Label = "Dial selected directory line", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(CameraTiltUp, new JoinMetadata() { JoinNumber = 111, Label = "Camera Tilt Up", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraTiltDown, new JoinMetadata() { JoinNumber = 112, Label = "Camera Tilt Down", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraPanLeft, new JoinMetadata() { JoinNumber = 113, Label = "Camera Pan Left", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraPanRight, new JoinMetadata() { JoinNumber = 114, Label = "Camera Pan Right", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraZoomIn, new JoinMetadata() { JoinNumber = 115, Label = "Camera Zoom In", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraZoomOut, new JoinMetadata() { JoinNumber = 116, Label = "Camera Zoom Out", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraPresetStart, new JoinMetadata() { JoinNumber = 121, Label = "Camera Presets", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 5, JoinType = eJoinType.Digital }); - Joins.Add(CameraModeAuto, new JoinMetadata() { JoinNumber = 131, Label = "Camera Mode Auto", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraModeManual, new JoinMetadata() { JoinNumber = 132, Label = "Camera Mode Manual", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraModeOff, new JoinMetadata() { JoinNumber = 133, Label = "Camera Mode Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(CameraSelfView, new JoinMetadata() { JoinNumber = 141, Label = "Camera Self View Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraLayout, new JoinMetadata() { JoinNumber = 142, Label = "Camera Layout Toggle", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - Joins.Add(CameraSupportsAutoMode, new JoinMetadata() { JoinNumber = 143, Label = "Camera Supports Auto Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(CameraSupportsOffMode, new JoinMetadata() { JoinNumber = 144, Label = "Camera Supports Off Mode FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - - - Joins.Add(CameraNumberSelect, new JoinMetadata() { JoinNumber = 60, Label = "Camera Number Select/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - Joins.Add(DirectorySelectRow, new JoinMetadata() { JoinNumber = 101, Label = "Directory Select Row/FB", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - Joins.Add(DirectoryRowCount, new JoinMetadata() { JoinNumber = 101, Label = "Directory Row Count FB", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - - Joins.Add(CurrentDialString, new JoinMetadata() { JoinNumber = 1, Label = "Current Dial String", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallNumber, new JoinMetadata() { JoinNumber = 3, Label = "Current Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CurrentCallName, new JoinMetadata() { JoinNumber = 2, Label = "Current Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(HookState, new JoinMetadata() { JoinNumber = 31, Label = "Current Hook State", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(CallDirection, new JoinMetadata() { JoinNumber = 22, Label = "Current Call Direction", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(IncomingCallName, new JoinMetadata() { JoinNumber = 51, Label = "Incoming Call Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(IncomingCallNumber, new JoinMetadata() { JoinNumber = 52, Label = "Incoming Call Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - - Joins.Add(DirectorySearchString, new JoinMetadata() { JoinNumber = 100, Label = "Directory Search String", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntriesStart, new JoinMetadata() { JoinNumber = 101, Label = "Directory Entries", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 255, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntrySelectedName, new JoinMetadata() { JoinNumber = 356, Label = "Selected Directory Entry Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectoryEntrySelectedNumber, new JoinMetadata() { JoinNumber = 357, Label = "Selected Directory Entry Number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(DirectorySelectedFolderName, new JoinMetadata() { JoinNumber = 358, Label = "Selected Directory Folder Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - - Joins.Add(Dtmf1, new JoinMetadata() { JoinNumber = 1, Label = "DTMF 1", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf2, new JoinMetadata() { JoinNumber = 2, Label = "DTMF 2", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf3, new JoinMetadata() { JoinNumber = 3, Label = "DTMF 3", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf4, new JoinMetadata() { JoinNumber = 4, Label = "DTMF 4", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf5, new JoinMetadata() { JoinNumber = 5, Label = "DTMF 5", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf6, new JoinMetadata() { JoinNumber = 6, Label = "DTMF 6", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf7, new JoinMetadata() { JoinNumber = 7, Label = "DTMF 7", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf8, new JoinMetadata() { JoinNumber = 8, Label = "DTMF 8", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf9, new JoinMetadata() { JoinNumber = 9, Label = "DTMF 9", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(Dtmf0, new JoinMetadata() { JoinNumber = 10, Label = "DTMF 0", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DtmfStar, new JoinMetadata() { JoinNumber = 11, Label = "DTMF *", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(DtmfPound, new JoinMetadata() { JoinNumber = 12, Label = "DTMF #", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); } - public override void OffsetJoinNumbers(uint joinStart) - { - var joinOffset = joinStart - 1; - - foreach (var join in Joins) - { - join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; - } - - PrintJoinMapInfo(); - } } } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index 17bd1a71..44666a4e 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -33,7 +33,6 @@ namespace PepperDash.Essentials.Bridges [JoinName("PowerOff")] public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("NumberOfPresets")] public JoinDataComplete NumberOfPresets = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata() { Label = "Tells Essentials the number of defined presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); [JoinName("PresetRecallStart")] @@ -57,7 +56,6 @@ namespace PepperDash.Essentials.Bridges [JoinName("SupportsPresets")] public JoinDataComplete SupportsPresets = new JoinDataComplete(new JoinData() { JoinNumber = 57, JoinSpan = 1 }, new JoinMetadata() { Label = "Supports Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - public CameraControllerJoinMap(uint joinStart) :base(joinStart) { diff --git a/PepperDashEssentials/PluginLoading/PluginLoading.cs b/PepperDashEssentials/PluginLoading/PluginLoading.cs index 11a4ee32..456c1dd1 100644 --- a/PepperDashEssentials/PluginLoading/PluginLoading.cs +++ b/PepperDashEssentials/PluginLoading/PluginLoading.cs @@ -39,7 +39,6 @@ namespace PepperDash.Essentials // The temp directory where .cplz archives will be unzipped to static string _tempDirectory = _pluginDirectory + Global.DirectorySeparator + "temp"; - static PluginLoader() { LoadedAssemblies = new List(); From ed627875a0c03c843420a1c68d5885b14d26fa21 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 11:16:27 -0600 Subject: [PATCH 32/33] Updates remaining SIMPL Bridges for MC to JoinMapBaseAdvanced. Updates affected bridges --- .../AppServer/Messengers/SIMPLAtcMessenger.cs | 2 +- .../AppServer/Messengers/SIMPLVtcMessenger.cs | 154 +++++++------- .../MobileControlSIMPLRoomBridge.cs | 149 +++++++------- .../MobileControlSIMPLRoomJoinMap.cs | 189 +++++++++--------- .../PepperDashEssentials.csproj | 1 - .../PepperDash_Essentials_Core.csproj | 1 + 6 files changed, 245 insertions(+), 251 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index 6fd7ffae..5bf042b9 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -189,7 +189,7 @@ namespace PepperDash.Essentials.AppServer.Messengers // Pulse DTMF AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => { - var join = JoinMap.Joins[s]; + var join = JoinMap.Joins[s]; if (join != null) { if (join.JoinNumber > 0) diff --git a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index c89d1495..c67e335e 100644 --- a/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -247,11 +247,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { EISC = eisc; - JoinMap = new SIMPLVtcJoinMap(); - - // TODO: Take in JoinStart value from config - JoinMap.OffsetJoinNumbers(701); - + JoinMap = new SIMPLVtcJoinMap(701); CurrentCallItem = new CodecActiveCallItem(); CurrentCallItem.Type = eCodecCallType.Video; @@ -265,31 +261,31 @@ namespace PepperDash.Essentials.AppServer.Messengers protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController) { var asc = appServerController; - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.HookState), s => + EISC.SetStringSigAction(JoinMap.HookState.JoinNumber, s => { CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true); PostFullStatus(); // SendCallsList(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallNumber), s => + EISC.SetStringSigAction(JoinMap.CurrentCallNumber.JoinNumber, s => { CurrentCallItem.Number = s; PostCallsList(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallName), s => + EISC.SetStringSigAction(JoinMap.CurrentCallName.JoinNumber, s => { CurrentCallItem.Name = s; PostCallsList(); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CallDirection), s => + EISC.SetStringSigAction(JoinMap.CallDirection.JoinNumber, s => { CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true); PostCallsList(); }); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCall), b => + EISC.SetBoolSigAction(JoinMap.IncomingCall.JoinNumber, b => { if (b) { @@ -297,8 +293,8 @@ namespace PepperDash.Essentials.AppServer.Messengers { Direction = eCodecCallDirection.Incoming, Id = "-video-incoming", - Name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCallName)), - Number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCallNumber)), + Name = EISC.GetString(JoinMap.IncomingCallName.JoinNumber), + Number = EISC.GetString(JoinMap.IncomingCallNumber.JoinNumber), Status = eCodecCallStatus.Ringing, Type = eCodecCallType.Video }; @@ -311,14 +307,14 @@ namespace PepperDash.Essentials.AppServer.Messengers PostCallsList(); }); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsAutoMode), b => + EISC.SetBoolSigAction(JoinMap.CameraSupportsAutoMode.JoinNumber, b => { PostStatusMessage(new { cameraSupportsAutoMode = b }); }); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsOffMode), b => + EISC.SetBoolSigAction(JoinMap.CameraSupportsOffMode.JoinNumber, b => { PostStatusMessage(new { @@ -327,78 +323,78 @@ namespace PepperDash.Essentials.AppServer.Messengers }); // Directory insanity - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount), u => + EISC.SetUShortSigAction(JoinMap.DirectoryRowCount.JoinNumber, u => { // The length of the list comes in before the list does. // Splice the sig change operation onto the last string sig that will be changing // when the directory entries make it through. if (PreviousDirectoryLength > 0) { - EISC.ClearStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + PreviousDirectoryLength - 1); + EISC.ClearStringSigAction(JoinMap.DirectoryEntriesStart.JoinNumber + PreviousDirectoryLength - 1); } - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + u - 1, s => PostDirectory()); + EISC.SetStringSigAction(JoinMap.DirectoryEntriesStart.JoinNumber + u - 1, s => PostDirectory()); PreviousDirectoryLength = u; }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName), s => + EISC.SetStringSigAction(JoinMap.DirectoryEntrySelectedName.JoinNumber, s => { PostStatusMessage(new { directoryContactSelected = new { - name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName)), + name = EISC.GetString(JoinMap.DirectoryEntrySelectedName.JoinNumber), } }); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber), s => + EISC.SetStringSigAction(JoinMap.DirectoryEntrySelectedNumber.JoinNumber, s => { PostStatusMessage(new { directoryContactSelected = new { - number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber)), + number = EISC.GetString(JoinMap.DirectoryEntrySelectedNumber.JoinNumber), } }); }); - EISC.SetStringSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName), s => PostStatusMessage(new + EISC.SetStringSigAction(JoinMap.DirectorySelectedFolderName.JoinNumber, s => PostStatusMessage(new { - directorySelectedFolderName = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName)) + directorySelectedFolderName = EISC.GetString(JoinMap.DirectorySelectedFolderName.JoinNumber) })); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto), () => PostCameraMode()); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual), () => PostCameraMode()); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeOff), () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.CameraModeAuto.JoinNumber, () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.CameraModeManual.JoinNumber, () => PostCameraMode()); + EISC.SetSigTrueAction(JoinMap.CameraModeOff.JoinNumber, () => PostCameraMode()); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView), b => PostStatusMessage(new + EISC.SetBoolSigAction(JoinMap.CameraSelfView.JoinNumber, b => PostStatusMessage(new { cameraSelfView = b })); - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), (u) => PostSelectedCamera()); + EISC.SetUShortSigAction(JoinMap.CameraNumberSelect.JoinNumber, (u) => PostSelectedCamera()); // Add press and holds using helper action Action addPHAction = (s, u) => AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); - addPHAction("/cameraUp", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraTiltUp)); - addPHAction("/cameraDown", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraTiltDown)); - addPHAction("/cameraLeft", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPanLeft)); - addPHAction("/cameraRight", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPanRight)); - addPHAction("/cameraZoomIn", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraZoomIn)); - addPHAction("/cameraZoomOut", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraZoomOut)); + addPHAction("/cameraUp", JoinMap.CameraTiltUp.JoinNumber); + addPHAction("/cameraDown", JoinMap.CameraTiltDown.JoinNumber); + addPHAction("/cameraLeft", JoinMap.CameraPanLeft.JoinNumber); + addPHAction("/cameraRight", JoinMap.CameraPanRight.JoinNumber); + addPHAction("/cameraZoomIn", JoinMap.CameraZoomIn.JoinNumber); + addPHAction("/cameraZoomOut", JoinMap.CameraZoomOut.JoinNumber); // Add straight pulse calls using helper action Action addAction = (s, u) => AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/endCallById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.EndCall)); - addAction("/endAllCalls", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.EndCall)); - addAction("/acceptById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingAnswer)); - addAction("/rejectById", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingReject)); + addAction("/endCallById", JoinMap.EndCall.JoinNumber); + addAction("/endAllCalls", JoinMap.EndCall.JoinNumber); + addAction("/acceptById", JoinMap.IncomingAnswer.JoinNumber); + addAction("/rejectById", JoinMap.IncomingReject.JoinNumber); - var speeddialStart = JoinMap.GetJoinForKey(SIMPLVtcJoinMap.SpeedDialStart); - var speeddialEnd = JoinMap.GetJoinForKey(SIMPLVtcJoinMap.SpeedDialStart) + JoinMap.GetJoinSpanForKey(SIMPLVtcJoinMap.SpeedDialStart); + var speeddialStart = JoinMap.SpeedDialStart.JoinNumber; + var speeddialEnd = JoinMap.SpeedDialStart.JoinNumber + JoinMap.SpeedDialStart.JoinSpan; var speedDialIndex = 1; for (uint i = speeddialStart; i < speeddialEnd; i++) @@ -407,18 +403,18 @@ namespace PepperDash.Essentials.AppServer.Messengers speedDialIndex++; } - addAction("/cameraModeAuto", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto)); - addAction("/cameraModeManual", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual)); - addAction("/cameraModeOff", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeOff)); - addAction("/cameraSelfView", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView)); - addAction("/cameraLayout", JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraLayout)); + addAction("/cameraModeAuto", JoinMap.CameraModeAuto.JoinNumber); + addAction("/cameraModeManual", JoinMap.CameraModeManual.JoinNumber); + addAction("/cameraModeOff", JoinMap.CameraModeOff.JoinNumber); + addAction("/cameraSelfView", JoinMap.CameraSelfView.JoinNumber); + addAction("/cameraLayout", JoinMap.CameraLayout.JoinNumber); asc.AddAction("/cameraSelect", new Action(SelectCamera)); // camera presets for(uint i = 0; i < 6; i++) { - addAction("/cameraPreset" + (i + 1), JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraPresetStart) + i); + addAction("/cameraPreset" + (i + 1), JoinMap.CameraPresetStart.JoinNumber + i); } asc.AddAction(MessagePath + "/isReady", new Action(PostIsReady)); @@ -426,28 +422,31 @@ namespace PepperDash.Essentials.AppServer.Messengers asc.AddAction(MessagePath + "/fullStatus", new Action(PostFullStatus)); // Dial on string asc.AddAction(MessagePath + "/dial", new Action(s => - EISC.SetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentDialString), s))); + EISC.SetString(JoinMap.CurrentDialString.JoinNumber, s))); // Pulse DTMF AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => { - var join = JoinMap.GetJoinForKey(s); - if (join > 0) + var join = JoinMap.Joins[s]; + if (join != null) { - EISC.PulseBool(join, 100); + if (join.JoinNumber > 0) + { + EISC.PulseBool(join.JoinNumber, 100); + } } })); // Directory madness - asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRoot)))); - asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryFolderBack)))); + asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(JoinMap.DirectoryRoot.JoinNumber))); + asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(JoinMap.DirectoryFolderBack.JoinNumber))); asc.AddAction(MessagePath + "/directoryById", new Action(s => { // the id should contain the line number to forward to simpl try { var u = ushort.Parse(s); - EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectRow), u); - EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryLineSelected)); + EISC.SetUshort(JoinMap.DirectorySelectRow.JoinNumber, u); + EISC.PulseBool(JoinMap.DirectoryLineSelected.JoinNumber); } catch (Exception) { @@ -461,8 +460,8 @@ namespace PepperDash.Essentials.AppServer.Messengers try { var u = ushort.Parse(s); - EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectRow), u); - EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryLineSelected)); + EISC.SetUshort(JoinMap.DirectorySelectRow.JoinNumber, u); + EISC.PulseBool(JoinMap.DirectoryLineSelected.JoinNumber); } catch { @@ -470,17 +469,17 @@ namespace PepperDash.Essentials.AppServer.Messengers } })); asc.AddAction(MessagePath + "/directoryDialContact", new Action(() => { - EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryDialSelectedLine)); + EISC.PulseBool(JoinMap.DirectoryDialSelectedLine.JoinNumber); })); asc.AddAction(MessagePath + "/getDirectory", new Action(() => { - if (EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount)) > 0) + if (EISC.GetUshort(JoinMap.DirectoryRowCount.JoinNumber) > 0) { PostDirectory(); } else { - EISC.PulseBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRoot)); + EISC.PulseBool(JoinMap.DirectoryRoot.JoinNumber); } })); } @@ -494,18 +493,18 @@ namespace PepperDash.Essentials.AppServer.Messengers { calls = GetCurrentCallList(), cameraMode = GetCameraMode(), - cameraSelfView = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSelfView)), - cameraSupportsAutoMode = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsAutoMode)), - cameraSupportsOffMode = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraSupportsOffMode)), - currentCallString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentCallNumber)), - currentDialString = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CurrentDialString)), + cameraSelfView = EISC.GetBool(JoinMap.CameraSelfView.JoinNumber), + cameraSupportsAutoMode = EISC.GetBool(JoinMap.CameraSupportsAutoMode.JoinNumber), + cameraSupportsOffMode = EISC.GetBool(JoinMap.CameraSupportsOffMode.JoinNumber), + currentCallString = EISC.GetString(JoinMap.CurrentCallNumber.JoinNumber), + currentDialString = EISC.GetString(JoinMap.CurrentDialString.JoinNumber), directoryContactSelected = new { - name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedName)), - number = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntrySelectedNumber)) + name = EISC.GetString(JoinMap.DirectoryEntrySelectedName.JoinNumber), + number = EISC.GetString(JoinMap.DirectoryEntrySelectedNumber.JoinNumber) }, - directorySelectedFolderName = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectorySelectedFolderName)), - isInCall = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.HookState)) == "Connected", + directorySelectedFolderName = EISC.GetString(JoinMap.DirectorySelectedFolderName.JoinNumber), + isInCall = EISC.GetString(JoinMap.HookState.JoinNumber) == "Connected", hasDirectory = true, hasDirectorySearch = false, hasRecents = !EISC.BooleanOutput[502].BoolValue, @@ -520,11 +519,11 @@ namespace PepperDash.Essentials.AppServer.Messengers /// void PostDirectory() { - var u = EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryRowCount)); + var u = EISC.GetUshort(JoinMap.DirectoryRowCount.JoinNumber); var items = new List(); for (uint i = 0; i < u; i++) { - var name = EISC.GetString(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryEntriesStart) + i); + var name = EISC.GetString(JoinMap.DirectoryEntriesStart.JoinNumber + i); var id = (i + 1).ToString(); // is folder or contact? if (name.StartsWith("[+]")) @@ -549,7 +548,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { currentDirectory = new { - isRootDirectory = EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.DirectoryIsRoot)), + isRootDirectory = EISC.GetBool(JoinMap.DirectoryIsRoot.JoinNumber), directoryResults = items } }; @@ -574,8 +573,8 @@ namespace PepperDash.Essentials.AppServer.Messengers string GetCameraMode() { string m; - if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeAuto))) m = eCameraControlMode.Auto.ToString().ToLower(); - else if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraModeManual))) m = eCameraControlMode.Manual.ToString().ToLower(); + if (EISC.GetBool(JoinMap.CameraModeAuto.JoinNumber)) m = eCameraControlMode.Auto.ToString().ToLower(); + else if (EISC.GetBool(JoinMap.CameraModeManual.JoinNumber)) m = eCameraControlMode.Manual.ToString().ToLower(); else m = eCameraControlMode.Off.ToString().ToLower(); return m; } @@ -593,7 +592,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// string GetSelectedCamera() { - var num = EISC.GetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect)); + var num = EISC.GetUshort(JoinMap.CameraNumberSelect.JoinNumber); string m; if (num == 100) { @@ -637,11 +636,11 @@ namespace PepperDash.Essentials.AppServer.Messengers var cam = s.Substring(6); if (cam.ToLower() == "far") { - EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), 100); + EISC.SetUshort(JoinMap.CameraNumberSelect.JoinNumber, 100); } else { - EISC.SetUshort(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.CameraNumberSelect), UInt16.Parse(cam)); + EISC.SetUshort(JoinMap.CameraNumberSelect.JoinNumber, UInt16.Parse(cam)); } } @@ -656,7 +655,8 @@ namespace PepperDash.Essentials.AppServer.Messengers { list.Add(CurrentCallItem); } - if (EISC.GetBool(JoinMap.GetJoinForKey(SIMPLVtcJoinMap.IncomingCall))) { + if (EISC.GetBool(JoinMap.IncomingCall.JoinNumber)) + { } return list; diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs index 45f0e709..a8589b92 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs @@ -38,7 +38,7 @@ namespace PepperDash.Essentials.Room.MobileControl public override string RoomName { get { - var name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomName)].StringValue; + var name = EISC.StringOutput[JoinMap.ConfigRoomName.JoinNumber].StringValue; return string.IsNullOrEmpty(name) ? "Not Loaded" : name; } } @@ -65,10 +65,7 @@ namespace PepperDash.Essentials.Room.MobileControl if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg); - JoinMap = new MobileControlSIMPLRoomJoinMap(); - - // TODO: Possibly set up alternate constructor or take in joinMapKey and joinStart properties in constructor - JoinMap.OffsetJoinNumbers(1); + JoinMap = new MobileControlSIMPLRoomJoinMap(1); SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC); DeviceManager.AddDevice(SourceBridge); @@ -105,19 +102,19 @@ namespace PepperDash.Essentials.Room.MobileControl EISC.OnlineStatusChange += (o, a) => { Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}. Use Essentials Config={2}", - a.DeviceOnLine, EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue, EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue); + a.DeviceOnLine, EISC.BooleanOutput[JoinMap.ConfigIsReady.JoinNumber].BoolValue, EISC.BooleanOutput[JoinMap.ConfigIsLocal.JoinNumber].BoolValue); - if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue) + if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.ConfigIsReady.JoinNumber].BoolValue) LoadConfigValues(); - if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue) + if (a.DeviceOnLine && EISC.BooleanOutput[JoinMap.ConfigIsLocal.JoinNumber].BoolValue) UseEssentialsConfig(); }; // load config if it's already there - if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady)].BoolValue) // || EISC.BooleanInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady].BoolValue) + if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.ConfigIsReady.JoinNumber].BoolValue) // || EISC.BooleanInput[JoinMap.ConfigIsReady].BoolValue) LoadConfigValues(); - if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsLocal)].BoolValue) + if (EISC.IsOnline && EISC.BooleanOutput[JoinMap.ConfigIsLocal.JoinNumber].BoolValue) { UseEssentialsConfig(); } @@ -169,36 +166,36 @@ namespace PepperDash.Essentials.Room.MobileControl /// void SetupFunctions() { - Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PromptForCode)))); - Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ClientJoined)))); + Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(JoinMap.PromptForCode.JoinNumber))); + Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(JoinMap.ClientJoined.JoinNumber))); Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus)); Parent.AddAction(@"/room/room1/source", new Action(c => { - EISC.SetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey), c.SourceListItem); - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceHasChanged)); + EISC.SetString(JoinMap.CurrentSourceKey.JoinNumber, c.SourceListItem); + EISC.PulseBool(JoinMap.SourceHasChanged.JoinNumber); })); Parent.AddAction(@"/room/room1/defaultsource", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare)))); + EISC.PulseBool(JoinMap.ActivityShare.JoinNumber))); Parent.AddAction(@"/room/room1/activityPhone", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall)))); + EISC.PulseBool(JoinMap.ActivityPhoneCall.JoinNumber))); Parent.AddAction(@"/room/room1/activityVideo", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall)))); + EISC.PulseBool(JoinMap.ActivityVideoCall.JoinNumber))); Parent.AddAction(@"/room/room1/volumes/master/level", new Action(u => - EISC.SetUshort(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), u))); + EISC.SetUshort(JoinMap.MasterVolume.JoinNumber, u))); Parent.AddAction(@"/room/room1/volumes/master/muteToggle", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)))); + EISC.PulseBool(JoinMap.MasterVolume.JoinNumber))); Parent.AddAction(@"/room/room1/volumes/master/privacyMuteToggle", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute)))); + EISC.PulseBool(JoinMap.PrivacyMute.JoinNumber))); // /xyzxyz/volumes/master/muteToggle ---> BoolInput[1] - var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); - var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeStart = JoinMap.VolumeJoinStart.JoinNumber; + var volumeEnd = JoinMap.VolumeJoinStart.JoinNumber + JoinMap.VolumeJoinStart.JoinSpan; for (uint i = volumeStart; i <= volumeEnd; i++) { @@ -210,11 +207,11 @@ namespace PepperDash.Essentials.Room.MobileControl } Parent.AddAction(@"/room/room1/shutdownStart", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownStart)))); + EISC.PulseBool(JoinMap.ShutdownStart.JoinNumber))); Parent.AddAction(@"/room/room1/shutdownEnd", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownEnd)))); + EISC.PulseBool(JoinMap.ShutdownEnd.JoinNumber))); Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => - EISC.PulseBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownCancel)))); + EISC.PulseBool(JoinMap.ShutdownCancel.JoinNumber))); } @@ -244,21 +241,21 @@ namespace PepperDash.Essentials.Room.MobileControl void SetupFeedbacks() { // Power - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.RoomIsOn), b => + EISC.SetBoolSigAction(JoinMap.RoomIsOn.JoinNumber, b => PostStatusMessage(new { isOn = b })); // Source change things - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceHasChanged), () => + EISC.SetSigTrueAction(JoinMap.SourceHasChanged.JoinNumber, () => PostStatusMessage(new { - selectedSourceKey = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey)].StringValue + selectedSourceKey = EISC.StringOutput[JoinMap.CurrentSourceKey.JoinNumber].StringValue })); // Volume things - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), u => + EISC.SetUShortSigAction(JoinMap.MasterVolume.JoinNumber, u => PostStatusMessage(new { volumes = new @@ -273,7 +270,7 @@ namespace PepperDash.Essentials.Room.MobileControl // map MasterVolumeIsMuted join -> status/volumes/master/muted // - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume), b => + EISC.SetBoolSigAction(JoinMap.MasterVolume.JoinNumber, b => PostStatusMessage(new { volumes = new @@ -284,7 +281,7 @@ namespace PepperDash.Essentials.Room.MobileControl } } })); - EISC.SetBoolSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute), b => + EISC.SetBoolSigAction(JoinMap.PrivacyMute.JoinNumber, b => PostStatusMessage(new { volumes = new @@ -296,8 +293,8 @@ namespace PepperDash.Essentials.Room.MobileControl } })); - var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); - var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeStart = JoinMap.VolumeJoinStart.JoinNumber; + var volumeEnd = JoinMap.VolumeJoinStart.JoinNumber + JoinMap.VolumeJoinStart.JoinSpan; for (uint i = volumeStart; i <= volumeEnd; i++) { @@ -330,7 +327,7 @@ namespace PepperDash.Essentials.Room.MobileControl }); } - EISC.SetUShortSigAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders), u => + EISC.SetUShortSigAction(JoinMap.NumberOfAuxFaders.JoinNumber, u => PostStatusMessage(new { volumes = new { numberOfAuxFaders = u, @@ -338,30 +335,30 @@ namespace PepperDash.Essentials.Room.MobileControl })); // shutdown things - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownCancel), new Action(() => + EISC.SetSigTrueAction(JoinMap.ShutdownCancel.JoinNumber, new Action(() => PostMessage("/room/shutdown/", new { state = "wasCancelled" }))); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownEnd), new Action(() => + EISC.SetSigTrueAction(JoinMap.ShutdownEnd.JoinNumber, new Action(() => PostMessage("/room/shutdown/", new { state = "hasFinished" }))); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownStart), new Action(() => + EISC.SetSigTrueAction(JoinMap.ShutdownStart.JoinNumber, new Action(() => PostMessage("/room/shutdown/", new { state = "hasStarted", - duration = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ShutdownPromptDuration)].UShortValue + duration = EISC.UShortOutput[JoinMap.ShutdownPromptDuration.JoinNumber].UShortValue }))); // Config things - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigIsReady), LoadConfigValues); + EISC.SetSigTrueAction(JoinMap.ConfigIsReady.JoinNumber, LoadConfigValues); // Activity modes - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare), () => UpdateActivity(1)); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall), () => UpdateActivity(2)); - EISC.SetSigTrueAction(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall), () => UpdateActivity(3)); + EISC.SetSigTrueAction(JoinMap.ActivityShare.JoinNumber, () => UpdateActivity(1)); + EISC.SetSigTrueAction(JoinMap.ActivityPhoneCall.JoinNumber, () => UpdateActivity(2)); + EISC.SetSigTrueAction(JoinMap.ActivityVideoCall.JoinNumber, () => UpdateActivity(3)); } @@ -405,7 +402,7 @@ namespace PepperDash.Essentials.Room.MobileControl Debug.Console(0, this, "Replacing Room[0] in config"); co.Rooms[0] = rm; } - rm.Name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomName)].StringValue; + rm.Name = EISC.StringOutput[JoinMap.ConfigRoomName.JoinNumber].StringValue; rm.Key = "room1"; rm.Type = "ddvc01"; @@ -416,13 +413,13 @@ namespace PepperDash.Essentials.Room.MobileControl rmProps = JsonConvert.DeserializeObject(rm.Properties.ToString()); rmProps.Help = new EssentialsHelpPropertiesConfig(); - rmProps.Help.CallButtonText = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigHelpNumber)].StringValue; - rmProps.Help.Message = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigHelpMessage)].StringValue; + rmProps.Help.CallButtonText = EISC.StringOutput[JoinMap.ConfigHelpNumber.JoinNumber].StringValue; + rmProps.Help.Message = EISC.StringOutput[JoinMap.ConfigHelpMessage.JoinNumber].StringValue; rmProps.Environment = new EssentialsEnvironmentPropertiesConfig(); // enabled defaults to false - rmProps.RoomPhoneNumber = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomPhoneNumber)].StringValue; - rmProps.RoomURI = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ConfigRoomURI)].StringValue; + rmProps.RoomPhoneNumber = EISC.StringOutput[JoinMap.ConfigRoomPhoneNumber.JoinNumber].StringValue; + rmProps.RoomURI = EISC.StringOutput[JoinMap.ConfigRoomURI.JoinNumber].StringValue; rmProps.SpeedDials = new List(); // This MAY need a check @@ -430,7 +427,7 @@ namespace PepperDash.Essentials.Room.MobileControl rmProps.VideoCodecKey = "videoCodec"; // volume control names - var volCount = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; + var volCount = EISC.UShortOutput[JoinMap.NumberOfAuxFaders.JoinNumber].UShortValue; //// use Volumes object or? //rmProps.VolumeSliderNames = new List(); @@ -475,18 +472,18 @@ namespace PepperDash.Essentials.Room.MobileControl // add sources... for (uint i = 0; i <= 19; i++) { - var name = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceNameJoinStart) + i].StringValue; - if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UseSourceEnabled)].BoolValue - && !EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceIsEnabledJoinStart) + i].BoolValue) + var name = EISC.StringOutput[JoinMap.SourceNameJoinStart.JoinNumber + i].StringValue; + if (EISC.BooleanOutput[JoinMap.UseSourceEnabled.JoinNumber].BoolValue + && !EISC.BooleanOutput[JoinMap.SourceIsEnabledJoinStart.JoinNumber + i].BoolValue) { continue; } - else if(!EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UseSourceEnabled)].BoolValue && string.IsNullOrEmpty(name)) + else if(!EISC.BooleanOutput[JoinMap.UseSourceEnabled.JoinNumber].BoolValue && string.IsNullOrEmpty(name)) break; - var icon = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceIconJoinStart) + i].StringValue; - var key = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceKeyJoinStart) + i].StringValue; - var type = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceTypeJoinStart) + i].StringValue; - var disableShare = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SourceShareDisableJoinStart) + i].BoolValue; + var icon = EISC.StringOutput[JoinMap.SourceIconJoinStart.JoinNumber + i].StringValue; + var key = EISC.StringOutput[JoinMap.SourceKeyJoinStart.JoinNumber + i].StringValue; + var type = EISC.StringOutput[JoinMap.SourceTypeJoinStart.JoinNumber + i].StringValue; + var disableShare = EISC.BooleanOutput[JoinMap.SourceShareDisableJoinStart.JoinNumber + i].BoolValue; Debug.Console(0, this, "Adding source {0} '{1}'", key, name); var newSLI = new SourceListItem{ @@ -528,14 +525,14 @@ namespace PepperDash.Essentials.Room.MobileControl var acFavs = new List(); for (uint i = 0; i < 4; i++) { - if (!EISC.GetBool(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialVisibleStartJoin) + i)) + if (!EISC.GetBool(JoinMap.SpeedDialVisibleStartJoin.JoinNumber + i)) { break; } acFavs.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem() { - Name = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialNameStartJoin) + i), - Number = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SpeedDialNumberStartJoin) + i), + Name = EISC.GetString(JoinMap.SpeedDialNameStartJoin.JoinNumber + i), + Number = EISC.GetString(JoinMap.SpeedDialNumberStartJoin.JoinNumber + i), Type = PepperDash.Essentials.Devices.Common.Codec.eCodecCallType.Audio }); } @@ -567,7 +564,7 @@ namespace PepperDash.Essentials.Room.MobileControl var camsProps = new List(); for (uint i = 0; i < 9; i++) { - var name = EISC.GetString(i + JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.CameraNearNameStart)); + var name = EISC.GetString(i + JoinMap.CameraNearNameStart.JoinNumber); if (!string.IsNullOrEmpty(name)) { camsProps.Add(new @@ -577,7 +574,7 @@ namespace PepperDash.Essentials.Room.MobileControl }); } } - var farName = EISC.GetString(JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.CameraFarName)); + var farName = EISC.GetString(JoinMap.CameraFarName.JoinNumber); if (!string.IsNullOrEmpty(farName)) { camsProps.Add(new @@ -685,7 +682,7 @@ namespace PepperDash.Essentials.Room.MobileControl { if (ConfigIsLoaded) { - var count = EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; + var count = EISC.UShortOutput[JoinMap.NumberOfAuxFaders.JoinNumber].UShortValue; Debug.Console(1, this, "The Fader Count is : {0}", count); @@ -694,8 +691,8 @@ namespace PepperDash.Essentials.Room.MobileControl // Create auxFaders var auxFaderDict = new Dictionary(); - var volumeStart = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); - var volumeEnd = JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart) + JoinMap.GetJoinSpanForKey(MobileControlSIMPLRoomJoinMap.VolumeJoinStart); + var volumeStart = JoinMap.VolumeJoinStart.JoinNumber; + var volumeEnd = JoinMap.VolumeJoinStart.JoinNumber + JoinMap.VolumeJoinStart.JoinSpan; for (uint i = volumeStart; i <= count; i++) { @@ -711,22 +708,22 @@ namespace PepperDash.Essentials.Room.MobileControl var volumes = new Volumes(); volumes.Master = new Volume("master", - EISC.UShortOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].UShortValue, - EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].BoolValue, - EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.MasterVolume)].StringValue, + EISC.UShortOutput[JoinMap.MasterVolume.JoinNumber].UShortValue, + EISC.BooleanOutput[JoinMap.MasterVolume.JoinNumber].BoolValue, + EISC.StringOutput[JoinMap.MasterVolume.JoinNumber].StringValue, true, "something.png"); volumes.Master.HasPrivacyMute = true; - volumes.Master.PrivacyMuted = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.PrivacyMute)].BoolValue; + volumes.Master.PrivacyMuted = EISC.BooleanOutput[JoinMap.PrivacyMute.JoinNumber].BoolValue; volumes.AuxFaders = auxFaderDict; - volumes.NumberOfAuxFaders = EISC.UShortInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.NumberOfAuxFaders)].UShortValue; + volumes.NumberOfAuxFaders = EISC.UShortInput[JoinMap.NumberOfAuxFaders.JoinNumber].UShortValue; PostStatusMessage(new { activityMode = GetActivityMode(), - isOn = EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.RoomIsOn)].BoolValue, - selectedSourceKey = EISC.StringOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.SelectedSourceKey)].StringValue, + isOn = EISC.BooleanOutput[JoinMap.RoomIsOn.JoinNumber].BoolValue, + selectedSourceKey = EISC.StringOutput[JoinMap.CurrentSourceKey.JoinNumber].StringValue, volumes = volumes }); } @@ -745,9 +742,9 @@ namespace PepperDash.Essentials.Room.MobileControl /// int GetActivityMode() { - if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityPhoneCall)].BoolValue) return 2; - else if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityShare)].BoolValue) return 1; - else if (EISC.BooleanOutput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ActivityVideoCall)].BoolValue) return 3; + if (EISC.BooleanOutput[JoinMap.ActivityPhoneCall.JoinNumber].BoolValue) return 2; + else if (EISC.BooleanOutput[JoinMap.ActivityShare.JoinNumber].BoolValue) return 1; + else if (EISC.BooleanOutput[JoinMap.ActivityVideoCall.JoinNumber].BoolValue) return 3; return 0; } @@ -824,8 +821,8 @@ namespace PepperDash.Essentials.Room.MobileControl protected override void UserCodeChange() { Debug.Console(1, this, "Server user code changed: {0}", UserCode); - EISC.StringInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.UserCodeToSystem)].StringValue = UserCode; - EISC.StringInput[JoinMap.GetJoinForKey(MobileControlSIMPLRoomJoinMap.ServerUrl)].StringValue = Parent.Config.ClientAppUrl; + EISC.StringInput[JoinMap.UserCodeToSystem.JoinNumber].StringValue = UserCode; + EISC.StringInput[JoinMap.ServerUrl.JoinNumber].StringValue = Parent.Config.ClientAppUrl; } } } \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs index f256213f..286fe28e 100644 --- a/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs +++ b/PepperDashEssentials/AppServer/SIMPLJoinMaps/MobileControlSIMPLRoomJoinMap.cs @@ -11,108 +11,105 @@ namespace PepperDash.Essentials.AppServer { public class MobileControlSIMPLRoomJoinMap : JoinMapBaseAdvanced { - public const string ConfigIsLocal = "ConfigIsLocal"; - public const string RoomIsOn = "RoomIsOn"; - public const string PrivacyMute = "PrivacyMute"; - public const string PromptForCode = "PromptForCode"; - public const string ClientJoined = "ClientJoined"; - public const string ActivityShare = "ActivityShare"; - public const string ActivityPhoneCall = "ActivityPhoneCall"; - public const string ActivityVideoCall = "ActivityVideoCall"; - public const string MasterVolume = "MasterVolumeMute"; - public const string VolumeJoinStart = "VolumeMutesJoinStart"; - public const string ShutdownCancel = "ShutdownCancel"; - public const string ShutdownEnd = "ShutdownEnd"; - public const string ShutdownStart = "ShutdownStart"; - public const string SourceHasChanged = "SourceHasChanged"; - public const string SpeedDialVisibleStartJoin = "SpeedDialVisibleStartJoin"; - public const string ConfigIsReady = "ConfigIsReady"; - public const string HideVideoConfRecents = "HideVideoConfRecents"; - public const string ShowCameraWhenNotInCall = "ShowCameraWhenNotInCall"; - public const string UseSourceEnabled = "UseSourceEnabled"; - public const string SourceShareDisableJoinStart = "SourceShareDisableJoinStart"; - public const string SourceIsEnabledJoinStart = "SourceIsEnabledJoinStart"; + [JoinName("MasterVolume")] + public JoinDataComplete MasterVolume = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata() {Label = "Master Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalAnalogSerial }); + [JoinName("VolumeJoinStart")] + public JoinDataComplete VolumeJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 8 }, new JoinMetadata() {Label = "Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalAnalogSerial }); - public const string VolumeSlidersJoinStart = "VolumeSlidersJoinStart"; - public const string ShutdownPromptDuration = "ShutdownPromptDuration"; - public const string NumberOfAuxFaders = "NumberOfAuxFaders"; + [JoinName("PrivacyMute")] + public JoinDataComplete PrivacyMute = new JoinDataComplete(new JoinData() { JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata() { Label = "Privacy Mute Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); - public const string VolumeSliderNamesJoinStart = "VolumeSliderNamesJoinStart"; - public const string SelectedSourceKey = "SelectedSourceKey"; - public const string SpeedDialNameStartJoin = "SpeedDialNameStartJoin"; - public const string SpeedDialNumberStartJoin = "SpeedDialNumberStartJoin"; - public const string ConfigRoomName = "ConfigRoomName"; - public const string ConfigHelpMessage = "ConfigHelpMessage"; - public const string ConfigHelpNumber = "ConfigHelpNumber"; - public const string ConfigRoomPhoneNumber = "ConfigRoomPhoneNumber"; - public const string ConfigRoomURI = "ConfigRoomURI"; - public const string UserCodeToSystem = "UserCodeToSystem"; - public const string ServerUrl = "ServerUrl"; - public const string RoomSpeedDialNamesJoinStart = "RoomSpeedDialNamesJoinStart"; - public const string RoomSpeedDialNumberssJoinStart = "RoomSpeedDialNumberssJoinStart"; - public const string SourceNameJoinStart = "SourceNameJoinStart"; - public const string SourceIconJoinStart = "SourceIconJoinStart"; - public const string SourceKeyJoinStart = "SourceKeyJoinStart"; - public const string SourceTypeJoinStart = "SourceTypeJoinStart"; - public const string CameraNearNameStart = "CameraNearNameStart"; - public const string CameraFarName = "CameraFarName"; + [JoinName("PromptForCode")] + public JoinDataComplete PromptForCode = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 1 }, new JoinMetadata() {Label = "Prompt User for Code", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ClientJoined")] + public JoinDataComplete ClientJoined = new JoinDataComplete(new JoinData() { JoinNumber = 42, JoinSpan = 1 }, new JoinMetadata() { Label = "Client Joined", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ActivityShare")] + public JoinDataComplete ActivityShare = new JoinDataComplete(new JoinData() { JoinNumber = 51, JoinSpan = 1 }, new JoinMetadata() {Label = "Activity Share", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ActivityPhoneCall")] + public JoinDataComplete ActivityPhoneCall = new JoinDataComplete(new JoinData() { JoinNumber = 52, JoinSpan = 1 }, new JoinMetadata() { Label = "Activity Phone Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ActivityVideoCall")] + public JoinDataComplete ActivityVideoCall = new JoinDataComplete(new JoinData() { JoinNumber = 53, JoinSpan = 1 }, new JoinMetadata() { Label = "Activity Video Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ShutdownPromptDuration")] + public JoinDataComplete ShutdownPromptDuration = new JoinDataComplete(new JoinData() { JoinNumber = 61, JoinSpan = 1 }, new JoinMetadata() { Label ="Shutdown Cancel", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("ShutdownCancel")] + public JoinDataComplete ShutdownCancel = new JoinDataComplete(new JoinData() { JoinNumber = 61, JoinSpan = 1 }, new JoinMetadata() { Label ="Shutdown Cancel", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ShutdownEnd")] + public JoinDataComplete ShutdownEnd = new JoinDataComplete(new JoinData() { JoinNumber = 62, JoinSpan = 1 }, new JoinMetadata() { Label = "Shutdown End", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ShutdownStart")] + public JoinDataComplete ShutdownStart = new JoinDataComplete(new JoinData() { JoinNumber = 63, JoinSpan = 1 }, new JoinMetadata() { Label = "Shutdown Start", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceHasChanged")] + public JoinDataComplete SourceHasChanged = new JoinDataComplete(new JoinData() { JoinNumber = 71, JoinSpan = 1 }, new JoinMetadata() { Label = "Source Changed", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CurrentSourceKey")] + public JoinDataComplete CurrentSourceKey = new JoinDataComplete(new JoinData() { JoinNumber = 71, JoinSpan = 1 }, new JoinMetadata() { Label = "Key of selected source", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Serial }); + + + [JoinName("ConfigIsLocal")] + public JoinDataComplete ConfigIsLocal = new JoinDataComplete(new JoinData() { JoinNumber = 100, JoinSpan = 1 }, new JoinMetadata() { Label = "Config is local to Essentials", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("NumberOfAuxFaders")] + public JoinDataComplete NumberOfAuxFaders = new JoinDataComplete(new JoinData() { JoinNumber = 101, JoinSpan = 1 }, new JoinMetadata() { Label = "Number of Auxilliary Faders", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("SpeedDialNameStartJoin")] + public JoinDataComplete SpeedDialNameStartJoin = new JoinDataComplete(new JoinData() { JoinNumber = 241, JoinSpan = 10 }, new JoinMetadata() { Label = "Speed Dial names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SpeedDialNumberStartJoin")] + public JoinDataComplete SpeedDialNumberStartJoin = new JoinDataComplete(new JoinData() { JoinNumber = 251, JoinSpan = 10 }, new JoinMetadata() { Label = "Speed Dial numbers", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SpeedDialVisibleStartJoin")] + public JoinDataComplete SpeedDialVisibleStartJoin = new JoinDataComplete(new JoinData() { JoinNumber = 261, JoinSpan = 10 }, new JoinMetadata() { Label = "Speed Dial Visible", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("RoomIsOn")] + public JoinDataComplete RoomIsOn = new JoinDataComplete(new JoinData() { JoinNumber = 301, JoinSpan = 1 }, new JoinMetadata() { Label = "Room Is On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("UserCodeToSystem")] + public JoinDataComplete UserCodeToSystem = new JoinDataComplete(new JoinData() { JoinNumber = 401, JoinSpan = 1 }, new JoinMetadata() { Label = "User Ccde", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ServerUrl")] + public JoinDataComplete ServerUrl = new JoinDataComplete(new JoinData() { JoinNumber = 402, JoinSpan = 1 }, new JoinMetadata() { Label ="Server URL", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ConfigRoomName")] + public JoinDataComplete ConfigRoomName = new JoinDataComplete(new JoinData() { JoinNumber = 501, JoinSpan = 1 }, new JoinMetadata() {Label = "Room Nnme", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ConfigHelpMessage")] + public JoinDataComplete ConfigHelpMessage = new JoinDataComplete(new JoinData() { JoinNumber = 502, JoinSpan = 1 }, new JoinMetadata() { Label = "Room help message", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ConfigHelpNumber")] + public JoinDataComplete ConfigHelpNumber = new JoinDataComplete(new JoinData() { JoinNumber = 503, JoinSpan = 1 }, new JoinMetadata() { Label = "Room help number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ConfigRoomPhoneNumber")] + public JoinDataComplete ConfigRoomPhoneNumber = new JoinDataComplete(new JoinData() { JoinNumber = 504, JoinSpan = 1 }, new JoinMetadata() { Label = "Room phone number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ConfigRoomURI")] + public JoinDataComplete ConfigRoomURI = new JoinDataComplete(new JoinData() { JoinNumber = 505, JoinSpan = 1 }, new JoinMetadata() { Label = "Room URI", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("ConfigIsReady")] + public JoinDataComplete ConfigIsReady = new JoinDataComplete(new JoinData() { JoinNumber = 501, JoinSpan = 1 }, new JoinMetadata() { Label = "Config info from SIMPL is ready", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("HideVideoConfRecents")] + public JoinDataComplete HideVideoConfRecents = new JoinDataComplete(new JoinData() { JoinNumber = 502, JoinSpan = 1 }, new JoinMetadata() { Label = "Hide Video Conference Recents", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("ShowCameraWhenNotInCall")] + public JoinDataComplete ShowCameraWhenNotInCall = new JoinDataComplete(new JoinData() { JoinNumber = 503, JoinSpan = 1 }, new JoinMetadata() { Label = "Show camera when not in call", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("UseSourceEnabled")] + public JoinDataComplete UseSourceEnabled = new JoinDataComplete(new JoinData() { JoinNumber = 504, JoinSpan = 1 }, new JoinMetadata() { Label = "Use Source Enabled Joins", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + + [JoinName("SourceShareDisableJoinStart")] + public JoinDataComplete SourceShareDisableJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 601, JoinSpan = 20 }, new JoinMetadata() { Label = "Source is not sharable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("SourceIsEnabledJoinStart")] + public JoinDataComplete SourceIsEnabledJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 621, JoinSpan = 20 }, new JoinMetadata() { Label = "Source is enabled", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("SourceNameJoinStart")] + public JoinDataComplete SourceNameJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 601, JoinSpan = 20 }, new JoinMetadata() { Label = "Source Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SourceIconJoinStart")] + public JoinDataComplete SourceIconJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 621, JoinSpan = 20 }, new JoinMetadata() { Label = "Source Icons", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SourceKeyJoinStart")] + public JoinDataComplete SourceKeyJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 641, JoinSpan = 20 }, new JoinMetadata() { Label = "Source Keys", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("SourceTypeJoinStart")] + public JoinDataComplete SourceTypeJoinStart = new JoinDataComplete(new JoinData() { JoinNumber = 661, JoinSpan = 20 }, new JoinMetadata() { Label = "Source Types", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("CameraNearNameStart")] + public JoinDataComplete CameraNearNameStart = new JoinDataComplete(new JoinData() { JoinNumber = 761, JoinSpan = 10 }, new JoinMetadata() { Label = "Near End Camera Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); + [JoinName("CameraFarName")] + public JoinDataComplete CameraFarName = new JoinDataComplete(new JoinData() { JoinNumber = 770, JoinSpan = 1 }, new JoinMetadata() { Label = "Far End Camera Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Serial }); public MobileControlSIMPLRoomJoinMap(uint joinStart) :base(joinStart) { - Joins.Add(ConfigIsLocal, new JoinMetadata() { JoinNumber = 100, Label = "Config is local to Essentials", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(RoomIsOn, new JoinMetadata() { JoinNumber = 301, Label = "Room Is On", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(PrivacyMute, new JoinMetadata() { JoinNumber = 12, Label = "Privacy Mute Toggle/FB", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(PromptForCode, new JoinMetadata() { JoinNumber = 41, Label = "Prompt User for Code", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ClientJoined, new JoinMetadata() { JoinNumber = 42, Label = "Client Joined", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ActivityShare, new JoinMetadata() { JoinNumber = 51, Label = "Activity Share", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ActivityPhoneCall, new JoinMetadata() { JoinNumber = 52, Label = "Activity Phone Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ActivityVideoCall, new JoinMetadata() { JoinNumber = 53, Label = "Activity Video Call", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(MasterVolume, new JoinMetadata() { JoinNumber = 1, Label = "Master Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.DigitalAnalogSerial }); - Joins.Add(VolumeJoinStart, new JoinMetadata() { JoinNumber = 2, Label = "Volume Mute Toggle/FB/Level/Label", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 8, JoinType = eJoinType.DigitalAnalogSerial }); - Joins.Add(ShutdownCancel, new JoinMetadata() { JoinNumber = 61, Label = "Shutdown Cancel", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ShutdownEnd, new JoinMetadata() { JoinNumber = 62, Label = "Shutdown End", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ShutdownStart, new JoinMetadata() { JoinNumber = 63, Label = "ShutdownStart", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SourceHasChanged, new JoinMetadata() { JoinNumber = 71, Label = "Source Changed", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - // Possibly move these to Audio Codec Messenger - Joins.Add(SpeedDialVisibleStartJoin, new JoinMetadata() { JoinNumber = 261, Label = "Speed Dial Visible", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 10, JoinType = eJoinType.Digital }); - - // - Joins.Add(ConfigIsReady, new JoinMetadata() { JoinNumber = 501, Label = "Config info from SIMPL is ready", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(HideVideoConfRecents, new JoinMetadata() { JoinNumber = 502, Label = "Hide Video Conference Recents", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(ShowCameraWhenNotInCall, new JoinMetadata() { JoinNumber = 503, Label = "Show camera when not in call", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(UseSourceEnabled, new JoinMetadata() { JoinNumber = 504, Label = "Use Source Enabled Joins", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Digital }); - Joins.Add(SourceShareDisableJoinStart, new JoinMetadata() { JoinNumber = 601, Label = "Source is not sharable", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); - Joins.Add(SourceIsEnabledJoinStart, new JoinMetadata() { JoinNumber = 621, Label = "Source is enabled", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Digital }); - - - Joins.Add(ShutdownPromptDuration, new JoinMetadata() { JoinNumber = 61, Label = "Shutdown Prompt Timer Duration", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - Joins.Add(NumberOfAuxFaders, new JoinMetadata() { JoinNumber = 101, Label = "Number of Auxilliary Faders", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Analog }); - - - Joins.Add(SelectedSourceKey, new JoinMetadata() { JoinNumber = 71, Label = "Key of selected source", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - - // Possibly move these to Audio Codec Messenger - Joins.Add(SpeedDialNameStartJoin, new JoinMetadata() { JoinNumber = 241, Label = "Speed Dial names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); - Joins.Add(SpeedDialNumberStartJoin, new JoinMetadata() { JoinNumber = 251, Label = "Speed Dial numbers", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); - // - Joins.Add(UserCodeToSystem, new JoinMetadata() { JoinNumber = 401, Label = "User Ccde", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ServerUrl, new JoinMetadata() { JoinNumber = 402, Label = "Server URL", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ConfigRoomName, new JoinMetadata() { JoinNumber = 501, Label = "Room Nnme", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ConfigHelpMessage, new JoinMetadata() { JoinNumber = 502, Label = "Room help message", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ConfigHelpNumber, new JoinMetadata() { JoinNumber = 503, Label = "Room help number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ConfigRoomPhoneNumber, new JoinMetadata() { JoinNumber = 504, Label = "Room phone number", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(ConfigRoomURI, new JoinMetadata() { JoinNumber = 505, Label = "Room URI", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - Joins.Add(SourceNameJoinStart, new JoinMetadata() { JoinNumber = 601, Label = "Source Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - Joins.Add(SourceIconJoinStart, new JoinMetadata() { JoinNumber = 621, Label = "Source Icons", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - Joins.Add(SourceKeyJoinStart, new JoinMetadata() { JoinNumber = 641, Label = "Source Keys", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - Joins.Add(SourceTypeJoinStart, new JoinMetadata() { JoinNumber = 661, Label = "Source Types", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 20, JoinType = eJoinType.Serial }); - - // Possibly move these to Audio Codec Messenger - Joins.Add(CameraNearNameStart, new JoinMetadata() { JoinNumber = 761, Label = "Near End Camera Names", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 10, JoinType = eJoinType.Serial }); - Joins.Add(CameraFarName, new JoinMetadata() { JoinNumber = 770, Label = "Far End Camera Name", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinSpan = 1, JoinType = eJoinType.Serial }); - // + } - } } \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index b2bd2802..3c4fd6b5 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -174,7 +174,6 @@ - diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 9dbf7000..3989722e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -156,6 +156,7 @@ + From 4bf1da36e2799df9395d606d71766236f2d8aa30 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 1 Apr 2020 11:32:24 -0600 Subject: [PATCH 33/33] Moves PluginLoader to Essentials.Core. Moves IDeviceFactory and IPluginDeviceFactory interfaces to their own files in a better locatino --- .../Config/Comm and IR/GenericComm.cs | 2 +- .../Factory/IDeviceFactory.cs | 19 + .../PepperDash_Essentials_Core.csproj | 4 +- ...eviceConfig.cs => IPluginDeviceFactory.cs} | 13 +- .../Plugins/PluginLoader.cs | 445 ++++++++++++++++++ 5 files changed, 470 insertions(+), 13 deletions(-) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs rename essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/{IPluginDeviceConfig.cs => IPluginDeviceFactory.cs} (50%) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs index 86faab64..0b0e4d82 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/GenericComm.cs @@ -62,7 +62,7 @@ namespace PepperDash.Essentials.Core ConfigWriter.UpdateDeviceConfig(config); } - public class Factory : EssentialsDevice.Factory + public class Factory : Essentials.Core.Factory { #region IDeviceFactory Members diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs new file mode 100644 index 00000000..0781d647 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/IDeviceFactory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines a class that is capable of loading device types + /// + public interface IDeviceFactory + { + /// + /// Will be called when the plugin is loaded by Essentials. Must add any new types to the DeviceFactory using DeviceFactory.AddFactoryForType() for each new type + /// + void LoadTypeFactories(); + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 8125a667..c3ea8202 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -138,6 +138,7 @@ + @@ -157,8 +158,9 @@ + - + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs similarity index 50% rename from essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs index b8fa03a3..ff979599 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/IPluginDeviceFactory.cs @@ -1,5 +1,5 @@ using PepperDash.Core; -using PepperDash.Essentials.Core.Config; + namespace PepperDash.Essentials.Core { @@ -15,14 +15,5 @@ namespace PepperDash.Essentials.Core } - /// - /// Defines a class that is capable of loading device types - /// - public interface IDeviceFactory - { - /// - /// Will be called when the plugin is loaded by Essentials. Must add any new types to the DeviceFactory using DeviceFactory.AddFactoryForType() for each new type - /// - void LoadTypeFactories(); - } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs new file mode 100644 index 00000000..3870159d --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -0,0 +1,445 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Reflection; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials +{ + /// + /// Deals with loading plugins at runtime + /// + public static class PluginLoader + { + /// + /// The complete list of loaded assemblies. Includes Essentials Framework assemblies and plugins + /// + public static List LoadedAssemblies { get; private set; } + + /// + /// The list of assemblies loaded from the plugins folder + /// + static List LoadedPluginFolderAssemblies; + + /// + /// The directory to look in for .cplz plugin packages + /// + static string _pluginDirectory = Global.FilePathPrefix + "plugins"; + + /// + /// The directory where plugins will be moved to and loaded from + /// + static string _loadedPluginsDirectoryPath = _pluginDirectory + Global.DirectorySeparator + "loadedAssemblies"; + + // The temp directory where .cplz archives will be unzipped to + static string _tempDirectory = _pluginDirectory + Global.DirectorySeparator + "temp"; + + + static PluginLoader() + { + LoadedAssemblies = new List(); + LoadedPluginFolderAssemblies = new List(); + } + + /// + /// Retrieves all the loaded assemblies from the program directory + /// + public static void AddProgramAssemblies() + { + Debug.Console(2, "Getting Assemblies loaded with Essentials"); + // Get the loaded assembly filenames + var appDi = new DirectoryInfo(Global.ApplicationDirectoryPathPrefix); + var assemblyFiles = appDi.GetFiles("*.dll"); + + Debug.Console(2, "Found {0} Assemblies", assemblyFiles.Length); + + foreach (var fi in assemblyFiles) + { + string version = string.Empty; + Assembly assembly = null; + + switch (fi.Name) + { + case ("PepperDashEssentials.dll"): + { + version = Global.AssemblyVersion; + assembly = Assembly.GetExecutingAssembly(); + break; + } + case ("PepperDash_Core.dll"): + { + version = PepperDash.Core.Debug.PepperDashCoreVersion; + break; + } + } + + LoadedAssemblies.Add(new LoadedAssembly(fi.Name, version, assembly)); + } + + if (Debug.Level > 1) + { + Debug.Console(2, "Loaded Assemblies:"); + + foreach (var assembly in LoadedAssemblies) + { + Debug.Console(2, "Assembly: {0}", assembly.Name); + } + } + } + + /// + /// Loads an assembly via Reflection and adds it to the list of loaded assemblies + /// + /// + static LoadedAssembly LoadAssembly(string filePath) + { + Debug.Console(2, "Attempting to load {0}", filePath); + var assembly = Assembly.LoadFrom(filePath); + if (assembly != null) + { + var assyVersion = GetAssemblyVersion(assembly); + + var loadedAssembly = new LoadedAssembly(assembly.GetName().Name, assyVersion, assembly); + LoadedAssemblies.Add(loadedAssembly); + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loaded assembly '{0}', version {1}", loadedAssembly.Name, loadedAssembly.Version); + return loadedAssembly; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Unable to load assembly: '{0}'", filePath); + } + + return null; + + } + + /// + /// Attempts to get the assembly informational version and if not possible gets the version + /// + /// + /// + static string GetAssemblyVersion(Assembly assembly) + { + var ver = assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); + if (ver != null && ver.Length > 0) + { + // Get the AssemblyInformationalVersion + AssemblyInformationalVersionAttribute verAttribute = ver[0] as AssemblyInformationalVersionAttribute; + return verAttribute.InformationalVersion; + } + else + { + // Get the AssemblyVersion + var version = assembly.GetName().Version; + var verStr = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision); + return verStr; + } + } + + /// + /// Checks if the filename matches an already loaded assembly file's name + /// + /// + /// True if file already matches loaded assembly file. + public static bool CheckIfAssemblyLoaded(string name) + { + Debug.Console(2, "Checking if assembly: {0} is loaded...", name); + var loadedAssembly = LoadedAssemblies.FirstOrDefault(s => s.Name.Equals(name)); + + if (loadedAssembly != null) + { + Debug.Console(2, "Assembly already loaded."); + return true; + } + else + { + Debug.Console(2, "Assembly not loaded."); + return false; + } + } + + /// + /// Used by console command to report the currently loaded assemblies and versions + /// + /// + public static void ReportAssemblyVersions(string command) + { + Debug.Console(0, "Loaded Assemblies:"); + foreach (var assembly in LoadedAssemblies) + { + Debug.Console(0, "{0} Version: {1}", assembly.Name, assembly.Version); + } + } + + /// + /// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder + /// + static void MoveDllAssemblies() + { + Debug.Console(0, "Looking for .dll assemblies from plugins folder..."); + + var pluginDi = new DirectoryInfo(_pluginDirectory); + var pluginFiles = pluginDi.GetFiles("*.dll"); + + if (pluginFiles.Length > 0) + { + if (!Directory.Exists(_loadedPluginsDirectoryPath)) + { + Directory.CreateDirectory(_loadedPluginsDirectoryPath); + } + } + + foreach (var pluginFile in pluginFiles) + { + try + { + Debug.Console(0, "Found .dll: {0}", pluginFile.Name); + + if (!CheckIfAssemblyLoaded(pluginFile.Name)) + { + string filePath = string.Empty; + + filePath = _loadedPluginsDirectoryPath + Global.DirectorySeparator + pluginFile.Name; + + // Check if there is a previous file in the loadedPlugins directory and delete + if (File.Exists(filePath)) + { + Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); + File.Delete(filePath); + } + + // Move the file + File.Move(pluginFile.FullName, filePath); + Debug.Console(2, "Moved {0} to {1}", pluginFile.FullName, filePath); + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", pluginFile.FullName); + } + } + catch (Exception e) + { + Debug.Console(2, "Error with plugin file {0} . Exception: {1}", pluginFile.FullName, e); + continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here + } + } + + Debug.Console(0, "Done with .dll assemblies"); + } + + /// + /// Unzips each .cplz archive into the temp directory and moves any unloaded files into loadedPlugins + /// + static void UnzipAndMoveCplzArchives() + { + Debug.Console(0, "Looking for .cplz archives from plugins folder..."); + var di = new DirectoryInfo(_pluginDirectory); + var zFiles = di.GetFiles("*.cplz"); + + if (zFiles.Length > 0) + { + if (!Directory.Exists(_loadedPluginsDirectoryPath)) + { + Directory.CreateDirectory(_loadedPluginsDirectoryPath); + } + } + + foreach (var zfi in zFiles) + { + Directory.CreateDirectory(_tempDirectory); + var tempDi = new DirectoryInfo(_tempDirectory); + + Debug.Console(0, "Found cplz: {0}. Unzipping into temp plugins directory", zfi.Name); + var result = CrestronZIP.Unzip(zfi.FullName, tempDi.FullName); + Debug.Console(0, "UnZip Result: {0}", result.ToString()); + + var tempFiles = tempDi.GetFiles("*.dll"); + foreach (var tempFile in tempFiles) + { + try + { + if (!CheckIfAssemblyLoaded(tempFile.Name)) + { + string filePath = string.Empty; + + filePath = _loadedPluginsDirectoryPath + Global.DirectorySeparator + tempFile.Name; + + // Check if there is a previous file in the loadedPlugins directory and delete + if (File.Exists(filePath)) + { + Debug.Console(0, "Found existing file in loadedPlugins: {0} Deleting and moving new file to replace it", filePath); + File.Delete(filePath); + } + + // Move the file + File.Move(tempFile.FullName, filePath); + Debug.Console(2, "Moved {0} to {1}", tempFile.FullName, filePath); + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Skipping assembly: {0}. There is already an assembly with that name loaded.", tempFile.FullName); + } + } + catch (Exception e) + { + Debug.Console(2, "Assembly {0} is not a custom assembly. Exception: {1}", tempFile.FullName, e); + continue; //catching any load issues and continuing. There will be exceptions loading Crestron .dlls from the cplz Probably should do something different here + } + } + + // Delete the .cplz and the temp directory + Directory.Delete(_tempDirectory, true); + zfi.Delete(); + } + + Debug.Console(0, "Done with .cplz archives"); + } + + /// + /// Attempts to load the assemblies from the loadedPlugins folder + /// + static void LoadPluginAssemblies() + { + Debug.Console(0, "Loading assemblies from loadedPlugins folder..."); + var pluginDi = new DirectoryInfo(_loadedPluginsDirectoryPath); + var pluginFiles = pluginDi.GetFiles("*.dll"); + + Debug.Console(2, "Found {0} plugin assemblies to load", pluginFiles.Length); + + foreach (var pluginFile in pluginFiles) + { + var loadedAssembly = LoadAssembly(pluginFile.FullName); + + LoadedPluginFolderAssemblies.Add(loadedAssembly); + } + + Debug.Console(0, "All Plugins Loaded."); + } + + /// + /// Iterate the loaded assemblies and try to call the LoadPlugin method + /// + static void LoadCustomPluginTypes() + { + Debug.Console(0, "Loading Custom Plugin Types..."); + foreach (var loadedAssembly in LoadedPluginFolderAssemblies) + { + // iteratate this assembly's classes, looking for "LoadPlugin()" methods + try + { + var assy = loadedAssembly.Assembly; + var types = assy.GetTypes(); + foreach (var type in types) + { + try + { + var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); + var loadPlugin = methods.FirstOrDefault(m => m.Name.Equals("LoadPlugin")); + if (loadPlugin != null) + { + Debug.Console(2, "LoadPlugin method found in {0}", type.Name); + + var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static); + + var minimumVersion = fields.FirstOrDefault(p => p.Name.Equals("MinimumEssentialsFrameworkVersion")); + if (minimumVersion != null) + { + Debug.Console(2, "MinimumEssentialsFrameworkVersion found"); + + var minimumVersionString = minimumVersion.GetValue(null) as string; + + if (!string.IsNullOrEmpty(minimumVersionString)) + { + var passed = Global.IsRunningMinimumVersionOrHigher(minimumVersionString); + + if (!passed) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Plugin indicates minimum Essentials version {0}. Dependency check failed. Skipping Plugin", minimumVersionString); + continue; + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Passed plugin passed dependency check (required version {0})", minimumVersionString); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion found but not set. Loading plugin, but your mileage may vary."); + } + } + else + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "MinimumEssentialsFrameworkVersion not found. Loading plugin, but your mileage may vary."); + } + + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Adding plugin: {0}", loadedAssembly.Name); + loadPlugin.Invoke(null, null); + } + } + catch (Exception e) + { + Debug.Console(2, "Load Plugin not found. {0} is not a plugin assembly. Exception: {1}", loadedAssembly.Name, e); + continue; + } + + } + } + catch (Exception e) + { + Debug.Console(2, "Error Loading Assembly: {0} Exception: (1) ", loadedAssembly.Name, e); + continue; + } + } + // plugin dll will be loaded. Any classes in plugin should have a static constructor + // that registers that class with the Core.DeviceFactory + Debug.Console(0, "Done Loading Custom Plugin Types."); + } + + /// + /// Loads plugins + /// + public static void LoadPlugins() + { + if (Directory.Exists(_pluginDirectory)) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Plugins directory found, checking for plugins"); + + // Deal with any .dll files + MoveDllAssemblies(); + + // Deal with any .cplz files + UnzipAndMoveCplzArchives(); + + if(Directory.Exists(_loadedPluginsDirectoryPath)) { + // Load the assemblies from the loadedPlugins folder into the AppDomain + LoadPluginAssemblies(); + + // Load the types from any custom plugin assemblies + LoadCustomPluginTypes(); + } + } + } + } + + /// + /// Represents an assembly loaded at runtime and it's associated metadata + /// + public class LoadedAssembly + { + public string Name { get; private set; } + public string Version { get; private set; } + public Assembly Assembly { get; private set; } + + public LoadedAssembly(string name, string version, Assembly assembly) + { + Name = name; + Version = version; + Assembly = assembly; + } + } +} \ No newline at end of file