diff --git a/src/PepperDash.Essentials.Core/Bridges/BridgeApi.cs b/src/PepperDash.Essentials.Core/Bridges/BridgeApi.cs new file mode 100644 index 00000000..a9ef37b1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/BridgeApi.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Core.Bridges +{ + /// + /// Base class for bridge API variants + /// + public abstract class BridgeApi : EssentialsDevice + { + protected BridgeApi(string key) : + base(key) + { + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs index 19c0f501..0007d556 100644 --- a/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs +++ b/src/PepperDash.Essentials.Core/Bridges/BridgeBase.cs @@ -1,83 +1,10 @@ extern alias Full; - -using System; -using System.Collections.Generic; using Crestron.SimplSharp; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.EthernetCommunication; - -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; //using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.Core.Bridges { - /// - /// Helper methods for bridges - /// - public static class BridgeHelper - { - public static void PrintJoinMap(string command) - { - var targets = command.Split(' '); - - var bridgeKey = targets[0].Trim(); - - var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced; - - if (bridge == null) - { - Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); - return; - } - - if (targets.Length > 1) - { - var deviceKey = targets[1].Trim(); - - if (string.IsNullOrEmpty(deviceKey)) return; - bridge.PrintJoinMapForDevice(deviceKey); - } - else - { - bridge.PrintJoinMaps(); - } - } - public static void JoinmapMarkdown(string command) - { - var targets = command.Split(' '); - - var bridgeKey = targets[0].Trim(); - - var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced; - - if (bridge == null) - { - Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); - return; - } - - if (targets.Length > 1) - { - var deviceKey = targets[1].Trim(); - - if (string.IsNullOrEmpty(deviceKey)) return; - bridge.MarkdownJoinMapForDevice(deviceKey, bridgeKey); - } - else - { - bridge.MarkdownForBridge(bridgeKey); - - } - } - } - - /// /// Base class for all bridge class variants /// @@ -91,414 +18,4 @@ namespace PepperDash.Essentials.Core.Bridges } } - - /// - /// Base class for bridge API variants - /// - public abstract class BridgeApi : EssentialsDevice - { - protected BridgeApi(string key) : - base(key) - { - - } - } - - /// - /// Bridge API using EISC - /// - public class EiscApiAdvanced : BridgeApi, ICommunicationMonitor - { - public EiscApiPropertiesConfig PropertiesConfig { get; private set; } - - public Dictionary JoinMaps { get; private set; } - - public BasicTriList Eisc { get; private set; } - - public EiscApiAdvanced(DeviceConfig dc, BasicTriList eisc) : - base(dc.Key) - { - JoinMaps = new Dictionary(); - - PropertiesConfig = dc.Properties.ToObject(); - //PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Eisc = eisc; - - Eisc.SigChange += Eisc_SigChange; - - CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, Eisc, 120000, 300000); - - AddPostActivationAction(LinkDevices); - AddPostActivationAction(LinkRooms); - AddPostActivationAction(RegisterEisc); - } - - public override bool CustomActivate() - { - CommunicationMonitor.Start(); - return base.CustomActivate(); - } - - public override bool Deactivate() - { - CommunicationMonitor.Stop(); - return base.Deactivate(); - } - - private void LinkDevices() - { - Debug.Console(1, this, "Linking Devices..."); - - if (PropertiesConfig.Devices == null) - { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No devices linked to this bridge"); - return; - } - - foreach (var d in PropertiesConfig.Devices) - { - var device = DeviceManager.GetDeviceForKey(d.DeviceKey); - - if (device == null) - { - continue; - } - - Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - - if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, - "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", - device.Key); - continue; - } - - var bridge = device as IBridgeAdvanced; - if (bridge != null) - { - bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); - } - } - } - - private void RegisterEisc() - { - if (Eisc.Registered) - { - return; - } - - var registerResult = Eisc.Register(); - - if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult); - return; - } - - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful"); - } - - public void LinkRooms() - { - Debug.Console(1, this, "Linking Rooms..."); - - if (PropertiesConfig.Rooms == null) - { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No rooms linked to this bridge."); - return; - } - - foreach (var room in PropertiesConfig.Rooms) - { - var rm = DeviceManager.GetDeviceForKey(room.RoomKey) as IBridgeAdvanced; - - if (rm == null) - { - Debug.Console(1, this, Debug.ErrorLogLevel.Notice, - "Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey); - continue; - } - - rm.LinkToApi(Eisc, room.JoinStart, room.JoinMapKey, this); - } - } - - /// - /// 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); - } - } - - /// - /// Prints all the join maps on this bridge - /// - public virtual void PrintJoinMaps() - { - Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); - - foreach (var joinMap in JoinMaps) - { - Debug.Console(0, "Join map for device '{0}':", joinMap.Key); - joinMap.Value.PrintJoinMapInfo(); - } - } - /// - /// Generates markdown for all join maps on this bridge - /// - public virtual void MarkdownForBridge(string bridgeKey) - { - Debug.Console(0, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X")); - - foreach (var joinMap in JoinMaps) - { - Debug.Console(0, "Generating markdown for device '{0}':", joinMap.Key); - joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey); - } - } - - /// - /// Prints the join map for a device by key - /// - /// - public void PrintJoinMapForDevice(string deviceKey) - { - var joinMap = JoinMaps[deviceKey]; - - if (joinMap == null) - { - Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); - return; - } - - Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); - joinMap.PrintJoinMapInfo(); - } - /// - /// Prints the join map for a device by key - /// - /// - public void MarkdownJoinMapForDevice(string deviceKey, string bridgeKey) - { - var joinMap = JoinMaps[deviceKey]; - - if (joinMap == null) - { - Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); - return; - } - - Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); - joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey); - } - - /// - /// Used for debugging to trigger an action based on a join number and type - /// - /// - /// - /// - public void ExecuteJoinAction(uint join, string type, object state) - { - try - { - switch (type.ToLower()) - { - case "digital": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToBoolean(state)); - } - else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); - break; - } - case "analog": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToUInt16(state)); - } - else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); break; - } - case "serial": - { - var uo = Eisc.BooleanOutput[join].UserObject as Action; - if (uo != null) - { - Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); - uo(Convert.ToString(state)); - } - else - Debug.Console(2, this, "User Action is null. Nothing to Execute"); - break; - } - default: - { - Debug.Console(2, "Unknown join type. Use digital/serial/analog"); - break; - } - } - } - catch (Exception e) - { - Debug.Console(1, this, "Error: {0}", e); - } - - } - - /// - /// Handles incoming sig changes - /// - /// - /// - protected void Eisc_SigChange(object currentDevice, SigEventArgs args) - { - try - { - if (Debug.Level >= 1) - Debug.Console(1, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); - var uo = args.Sig.UserObject; - - if (uo == null) return; - - Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); - 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); - } - catch (Exception e) - { - Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); - } - } - - #region Implementation of ICommunicationMonitor - - public StatusMonitorBase CommunicationMonitor { get; private set; } - - #endregion - } - - public class EiscApiPropertiesConfig - { - [JsonProperty("control")] - public EssentialsControlPropertiesConfig Control { get; set; } - - [JsonProperty("devices")] - public List Devices { get; set; } - - [JsonProperty("rooms")] - public List Rooms { get; set; } - - - public class ApiDevicePropertiesConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("joinStart")] - public uint JoinStart { get; set; } - - [JsonProperty("joinMapKey")] - public string JoinMapKey { get; set; } - } - - public class ApiRoomPropertiesConfig - { - [JsonProperty("roomKey")] - public string RoomKey { get; set; } - - [JsonProperty("joinStart")] - public uint JoinStart { get; set; } - - [JsonProperty("joinMapKey")] - public string JoinMapKey { get; set; } - } - - } - - public class EiscApiAdvancedFactory : EssentialsDeviceFactory - { - public EiscApiAdvancedFactory() - { - TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device"); - - var controlProperties = CommFactory.GetControlPropertiesConfig(dc); - - BasicTriList eisc; - - switch (dc.Type.ToLower()) - { - case "eiscapiadv": - case "eiscapiadvanced": - { - eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, - controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "eiscapiadvancedserver": - { - eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); - break; - } - case "eiscapiadvancedclient": - { - eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "vceiscapiadv": - case "vceiscapiadvanced": - { - if (string.IsNullOrEmpty(controlProperties.RoomId)) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); - eisc = null; - break; - } - eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, - Global.ControlSystem); - break; - } - default: - eisc = null; - break; - } - - if (eisc == null) - { - return null; - } - - return new EiscApiAdvanced(dc, eisc); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/BridgeHelper.cs b/src/PepperDash.Essentials.Core/Bridges/BridgeHelper.cs new file mode 100644 index 00000000..a9955378 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/BridgeHelper.cs @@ -0,0 +1,64 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Bridges +{ + /// + /// Helper methods for bridges + /// + public static class BridgeHelper + { + public static void PrintJoinMap(string command) + { + var targets = command.Split(' '); + + var bridgeKey = targets[0].Trim(); + + var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced; + + if (bridge == null) + { + Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); + return; + } + + if (targets.Length > 1) + { + var deviceKey = targets[1].Trim(); + + if (string.IsNullOrEmpty(deviceKey)) return; + bridge.PrintJoinMapForDevice(deviceKey); + } + else + { + bridge.PrintJoinMaps(); + } + } + public static void JoinmapMarkdown(string command) + { + var targets = command.Split(' '); + + var bridgeKey = targets[0].Trim(); + + var bridge = DeviceManager.GetDeviceForKey(bridgeKey) as EiscApiAdvanced; + + if (bridge == null) + { + Debug.Console(0, "Unable to find advanced bridge with key: '{0}'", bridgeKey); + return; + } + + if (targets.Length > 1) + { + var deviceKey = targets[1].Trim(); + + if (string.IsNullOrEmpty(deviceKey)) return; + bridge.MarkdownJoinMapForDevice(deviceKey, bridgeKey); + } + else + { + bridge.MarkdownForBridge(bridgeKey); + + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvanced.cs b/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvanced.cs new file mode 100644 index 00000000..24bc536a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvanced.cs @@ -0,0 +1,308 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharp.Reflection; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Bridges +{ + /// + /// Bridge API using EISC + /// + public class EiscApiAdvanced : BridgeApi, ICommunicationMonitor + { + public EiscApiPropertiesConfig PropertiesConfig { get; private set; } + + public Dictionary JoinMaps { get; private set; } + + public BasicTriList Eisc { get; private set; } + + public EiscApiAdvanced(DeviceConfig dc, BasicTriList eisc) : + base(dc.Key) + { + JoinMaps = new Dictionary(); + + PropertiesConfig = dc.Properties.ToObject(); + //PropertiesConfig = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Eisc = eisc; + + Eisc.SigChange += Eisc_SigChange; + + CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, Eisc, 120000, 300000); + + AddPostActivationAction(LinkDevices); + AddPostActivationAction(LinkRooms); + AddPostActivationAction(RegisterEisc); + } + + public override bool CustomActivate() + { + CommunicationMonitor.Start(); + return base.CustomActivate(); + } + + public override bool Deactivate() + { + CommunicationMonitor.Stop(); + return base.Deactivate(); + } + + private void LinkDevices() + { + Debug.Console(1, this, "Linking Devices..."); + + if (PropertiesConfig.Devices == null) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No devices linked to this bridge"); + return; + } + + foreach (var d in PropertiesConfig.Devices) + { + var device = DeviceManager.GetDeviceForKey(d.DeviceKey); + + if (device == null) + { + continue; + } + + Debug.Console(1, this, "Linking Device: '{0}'", device.Key); + + if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, + "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", + device.Key); + continue; + } + + var bridge = device as IBridgeAdvanced; + if (bridge != null) + { + bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); + } + } + } + + private void RegisterEisc() + { + if (Eisc.Registered) + { + return; + } + + var registerResult = Eisc.Register(); + + if (registerResult != eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Registration result: {0}", registerResult); + return; + } + + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "EISC registration successful"); + } + + public void LinkRooms() + { + Debug.Console(1, this, "Linking Rooms..."); + + if (PropertiesConfig.Rooms == null) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "No rooms linked to this bridge."); + return; + } + + foreach (var room in PropertiesConfig.Rooms) + { + var rm = DeviceManager.GetDeviceForKey(room.RoomKey) as IBridgeAdvanced; + + if (rm == null) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Notice, + "Room {0} does not implement IBridgeAdvanced. Skipping...", room.RoomKey); + continue; + } + + rm.LinkToApi(Eisc, room.JoinStart, room.JoinMapKey, this); + } + } + + /// + /// 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); + } + } + + /// + /// Prints all the join maps on this bridge + /// + public virtual void PrintJoinMaps() + { + Debug.Console(0, this, "Join Maps for EISC IPID: {0}", Eisc.ID.ToString("X")); + + foreach (var joinMap in JoinMaps) + { + Debug.Console(0, "Join map for device '{0}':", joinMap.Key); + joinMap.Value.PrintJoinMapInfo(); + } + } + /// + /// Generates markdown for all join maps on this bridge + /// + public virtual void MarkdownForBridge(string bridgeKey) + { + Debug.Console(0, this, "Writing Joinmaps to files for EISC IPID: {0}", Eisc.ID.ToString("X")); + + foreach (var joinMap in JoinMaps) + { + Debug.Console(0, "Generating markdown for device '{0}':", joinMap.Key); + joinMap.Value.MarkdownJoinMapInfo(joinMap.Key, bridgeKey); + } + } + + /// + /// Prints the join map for a device by key + /// + /// + public void PrintJoinMapForDevice(string deviceKey) + { + var joinMap = JoinMaps[deviceKey]; + + if (joinMap == null) + { + Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + return; + } + + Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); + joinMap.PrintJoinMapInfo(); + } + /// + /// Prints the join map for a device by key + /// + /// + public void MarkdownJoinMapForDevice(string deviceKey, string bridgeKey) + { + var joinMap = JoinMaps[deviceKey]; + + if (joinMap == null) + { + Debug.Console(0, this, "Unable to find joinMap for device with key: '{0}'", deviceKey); + return; + } + + Debug.Console(0, "Join map for device '{0}' on EISC '{1}':", deviceKey, Key); + joinMap.MarkdownJoinMapInfo(deviceKey, bridgeKey); + } + + /// + /// Used for debugging to trigger an action based on a join number and type + /// + /// + /// + /// + public void ExecuteJoinAction(uint join, string type, object state) + { + try + { + switch (type.ToLower()) + { + case "digital": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToBoolean(state)); + } + else + Debug.Console(2, this, "User Action is null. Nothing to Execute"); + break; + } + case "analog": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToUInt16(state)); + } + else + Debug.Console(2, this, "User Action is null. Nothing to Execute"); break; + } + case "serial": + { + var uo = Eisc.BooleanOutput[join].UserObject as Action; + if (uo != null) + { + Debug.Console(2, this, "Executing Action: {0}", uo.ToString()); + uo(Convert.ToString(state)); + } + else + Debug.Console(2, this, "User Action is null. Nothing to Execute"); + break; + } + default: + { + Debug.Console(2, "Unknown join type. Use digital/serial/analog"); + break; + } + } + } + catch (Exception e) + { + Debug.Console(1, this, "Error: {0}", e); + } + + } + + /// + /// Handles incoming sig changes + /// + /// + /// + protected void Eisc_SigChange(object currentDevice, SigEventArgs args) + { + try + { + if (Debug.Level >= 1) + Debug.Console(1, this, "EiscApiAdvanced change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); + var uo = args.Sig.UserObject; + + if (uo == null) return; + + Debug.Console(1, this, "Executing Action: {0}", uo.ToString()); + 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); + } + catch (Exception e) + { + Debug.Console(2, this, "Error in Eisc_SigChange handler: {0}", e); + } + } + + #region Implementation of ICommunicationMonitor + + public StatusMonitorBase CommunicationMonitor { get; private set; } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvancedFactory.cs b/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvancedFactory.cs new file mode 100644 index 00000000..8f613dc3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/EiscApiAdvancedFactory.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.EthernetCommunication; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class EiscApiAdvancedFactory : EssentialsDeviceFactory + { + public EiscApiAdvancedFactory() + { + TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new EiscApiAdvanced Device"); + + var controlProperties = CommFactory.GetControlPropertiesConfig(dc); + + BasicTriList eisc; + + switch (dc.Type.ToLower()) + { + case "eiscapiadv": + case "eiscapiadvanced": + { + eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, + controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "eiscapiadvancedserver": + { + eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); + break; + } + case "eiscapiadvancedclient": + { + eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "vceiscapiadv": + case "vceiscapiadvanced": + { + if (string.IsNullOrEmpty(controlProperties.RoomId)) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); + eisc = null; + break; + } + eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, + Global.ControlSystem); + break; + } + default: + eisc = null; + break; + } + + if (eisc == null) + { + return null; + } + + return new EiscApiAdvanced(dc, eisc); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/EiscApiPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Bridges/EiscApiPropertiesConfig.cs new file mode 100644 index 00000000..e4b665c4 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Bridges/EiscApiPropertiesConfig.cs @@ -0,0 +1,44 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Bridges +{ + public class EiscApiPropertiesConfig + { + [JsonProperty("control")] + public EssentialsControlPropertiesConfig Control { get; set; } + + [JsonProperty("devices")] + public List Devices { get; set; } + + [JsonProperty("rooms")] + public List Rooms { get; set; } + + + public class ApiDevicePropertiesConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("joinStart")] + public uint JoinStart { get; set; } + + [JsonProperty("joinMapKey")] + public string JoinMapKey { get; set; } + } + + public class ApiRoomPropertiesConfig + { + [JsonProperty("roomKey")] + public string RoomKey { get; set; } + + [JsonProperty("joinStart")] + public uint JoinStart { get; set; } + + [JsonProperty("joinMapKey")] + public string JoinMapKey { get; set; } + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Bridges/IBridge.cs b/src/PepperDash.Essentials.Core/Bridges/IBridgeAdvanced.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Bridges/IBridge.cs rename to src/PepperDash.Essentials.Core/Bridges/IBridgeAdvanced.cs diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs index 2f6050b6..1616d899 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecJsonConverter.cs @@ -53,52 +53,4 @@ namespace PepperDash.Essentials.Core throw new NotImplementedException(); } } - - /// - /// The gist of this converter: The comspec JSON comes in with normal values that need to be converted - /// into enum names. This converter takes the value and applies the appropriate enum's name prefix to the value - /// and then returns the enum value using Enum.Parse. NOTE: Does not write - /// - public class ComSpecPropsJsonConverter : JsonConverter - { - public override bool CanConvert(Type objectType) - { - return objectType == typeof(ComPort.eComBaudRates) - || objectType == typeof(ComPort.eComDataBits) - || objectType == typeof(ComPort.eComParityType) - || objectType == typeof(ComPort.eComHardwareHandshakeType) - || objectType == typeof(ComPort.eComSoftwareHandshakeType) - || objectType == typeof(ComPort.eComProtocolType) - || objectType == typeof(ComPort.eComStopBits); - } - - public override bool CanRead { get { return true; } } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - //Debug.Console(2, "ReadJson type: " + objectType.Name); - if (objectType == typeof(ComPort.eComBaudRates)) - return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false); - else if (objectType == typeof(ComPort.eComDataBits)) - return Enum.Parse(typeof(ComPort.eComDataBits), "ComspecDataBits" + reader.Value, true); - else if (objectType == typeof(ComPort.eComHardwareHandshakeType)) - return Enum.Parse(typeof(ComPort.eComHardwareHandshakeType), "ComspecHardwareHandshake" + reader.Value, true); - else if (objectType == typeof(ComPort.eComParityType)) - return Enum.Parse(typeof(ComPort.eComParityType), "ComspecParity" + reader.Value, true); - else if (objectType == typeof(ComPort.eComProtocolType)) - return Enum.Parse(typeof(ComPort.eComProtocolType), "ComspecProtocol" + reader.Value, true); - else if (objectType == typeof(ComPort.eComSoftwareHandshakeType)) - return Enum.Parse(typeof(ComPort.eComSoftwareHandshakeType), "ComspecSoftwareHandshake" + reader.Value, true); - else if (objectType == typeof(ComPort.eComStopBits)) - return Enum.Parse(typeof(ComPort.eComStopBits), "ComspecStopBits" + reader.Value, true); - return null; - } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException(); - } - } - - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ComSpecPropsJsonConverter.cs b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecPropsJsonConverter.cs new file mode 100644 index 00000000..fa0857e7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/ComSpecPropsJsonConverter.cs @@ -0,0 +1,53 @@ +extern alias Full; +using System; +using Crestron.SimplSharpPro; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + /// + /// The gist of this converter: The comspec JSON comes in with normal values that need to be converted + /// into enum names. This converter takes the value and applies the appropriate enum's name prefix to the value + /// and then returns the enum value using Enum.Parse. NOTE: Does not write + /// + public class ComSpecPropsJsonConverter : JsonConverter + { + public override bool CanConvert(Type objectType) + { + return objectType == typeof(ComPort.eComBaudRates) + || objectType == typeof(ComPort.eComDataBits) + || objectType == typeof(ComPort.eComParityType) + || objectType == typeof(ComPort.eComHardwareHandshakeType) + || objectType == typeof(ComPort.eComSoftwareHandshakeType) + || objectType == typeof(ComPort.eComProtocolType) + || objectType == typeof(ComPort.eComStopBits); + } + + public override bool CanRead { get { return true; } } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + //Debug.Console(2, "ReadJson type: " + objectType.Name); + if (objectType == typeof(ComPort.eComBaudRates)) + return Enum.Parse(typeof(ComPort.eComBaudRates), "ComspecBaudRate" + reader.Value, false); + else if (objectType == typeof(ComPort.eComDataBits)) + return Enum.Parse(typeof(ComPort.eComDataBits), "ComspecDataBits" + reader.Value, true); + else if (objectType == typeof(ComPort.eComHardwareHandshakeType)) + return Enum.Parse(typeof(ComPort.eComHardwareHandshakeType), "ComspecHardwareHandshake" + reader.Value, true); + else if (objectType == typeof(ComPort.eComParityType)) + return Enum.Parse(typeof(ComPort.eComParityType), "ComspecParity" + reader.Value, true); + else if (objectType == typeof(ComPort.eComProtocolType)) + return Enum.Parse(typeof(ComPort.eComProtocolType), "ComspecProtocol" + reader.Value, true); + else if (objectType == typeof(ComPort.eComSoftwareHandshakeType)) + return Enum.Parse(typeof(ComPort.eComSoftwareHandshakeType), "ComspecSoftwareHandshake" + reader.Value, true); + else if (objectType == typeof(ComPort.eComStopBits)) + return Enum.Parse(typeof(ComPort.eComStopBits), "ComspecStopBits" + reader.Value, true); + return null; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs index 892caa92..c045b994 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/CommFactory.cs @@ -174,64 +174,4 @@ namespace PepperDash.Essentials.Core } } } - - /// - /// - /// - public class EssentialsControlPropertiesConfig : - PepperDash.Core.ControlPropertiesConfig - { - - [JsonConverter(typeof(ComSpecJsonConverter))] - public ComPort.ComPortSpec ComParams { get; set; } - - public string RoomId { get; set; } - - public string CresnetId { get; set; } - - /// - /// Attempts to provide uint conversion of string CresnetId - /// - public uint CresnetIdInt - { - get - { - try - { - return Convert.ToUInt32(CresnetId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId)); - } - } - } - - public string InfinetId { get; set; } - - /// - /// Attepmts to provide uiont conversion of string InifinetId - /// - public uint InfinetIdInt - { - get - { - try - { - return Convert.ToUInt32(InfinetId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId)); - } - } - } - } - - public class IrControlSpec - { - public string PortDeviceKey { get; set; } - public uint PortNumber { get; set; } - public string File { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs index db06d2aa..5e5e5d3c 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevice.cs @@ -1,11 +1,9 @@ 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 @@ -54,33 +52,4 @@ namespace PepperDash.Essentials.Core Communication.SendText(s + LineEnding); } } - - public class ConsoleCommMockDevicePropertiesConfig - { - public string LineEnding { get; set; } - public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } - - public ConsoleCommMockDevicePropertiesConfig() - { - LineEnding = "\x0a"; - } - } - - public class ConsoleCommMockDeviceFactory : EssentialsDeviceFactory - { - public ConsoleCommMockDeviceFactory() - { - TypeNames = new List() { "commmock" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Comm Mock Device"); - var comm = CommFactory.CreateCommForDevice(dc); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new ConsoleCommMockDevice(dc.Key, dc.Name, props, comm); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDeviceFactory.cs b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDeviceFactory.cs new file mode 100644 index 00000000..ee3b4c72 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDeviceFactory.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class ConsoleCommMockDeviceFactory : EssentialsDeviceFactory + { + public ConsoleCommMockDeviceFactory() + { + TypeNames = new List() { "commmock" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Comm Mock Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new ConsoleCommMockDevice(dc.Key, dc.Name, props, comm); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevicePropertiesConfig.cs b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevicePropertiesConfig.cs new file mode 100644 index 00000000..c95c8872 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/ConsoleCommMockDevicePropertiesConfig.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + public class ConsoleCommMockDevicePropertiesConfig + { + public string LineEnding { get; set; } + public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } + + public ConsoleCommMockDevicePropertiesConfig() + { + LineEnding = "\x0a"; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/EssentialsControlPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Comm and IR/EssentialsControlPropertiesConfig.cs new file mode 100644 index 00000000..ffd7ea7e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/EssentialsControlPropertiesConfig.cs @@ -0,0 +1,60 @@ +extern alias Full; +using System; +using Crestron.SimplSharpPro; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public class EssentialsControlPropertiesConfig : + PepperDash.Core.ControlPropertiesConfig + { + + [JsonConverter(typeof(ComSpecJsonConverter))] + public ComPort.ComPortSpec ComParams { get; set; } + + public string RoomId { get; set; } + + public string CresnetId { get; set; } + + /// + /// Attempts to provide uint conversion of string CresnetId + /// + public uint CresnetIdInt + { + get + { + try + { + return Convert.ToUInt32(CresnetId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", CresnetId)); + } + } + } + + public string InfinetId { get; set; } + + /// + /// Attepmts to provide uiont conversion of string InifinetId + /// + public uint InfinetIdInt + { + get + { + try + { + return Convert.ToUInt32(InfinetId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to conver Infinet ID: {0} to hex. Error:\n{1}", InfinetId)); + } + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs index 8ce6a8c5..4316e562 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/GenericComm.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using Crestron.SimplSharp.CrestronSockets; using Crestron.SimplSharpPro.DeviceSupport; using Full.Newtonsoft.Json; @@ -127,18 +126,4 @@ namespace PepperDash.Essentials.Core }); } } - - public class GenericCommFactory : EssentialsDeviceFactory - { - public GenericCommFactory() - { - TypeNames = new List() { "genericComm" }; - } - - public override EssentialsDevice 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/src/PepperDash.Essentials.Core/Comm and IR/GenericCommFactory.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericCommFactory.cs new file mode 100644 index 00000000..b7fdd484 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/GenericCommFactory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class GenericCommFactory : EssentialsDeviceFactory + { + public GenericCommFactory() + { + TypeNames = new List() { "genericComm" }; + } + + public override EssentialsDevice 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/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs index 31342a94..ca8cf829 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClient.cs @@ -100,16 +100,4 @@ namespace PepperDash.Essentials.Core #endregion } - public class GenericHttpClientEventArgs : EventArgs - { - public string ResponseText { get; private set; } - public string RequestPath { get; private set; } - public HTTP_CALLBACK_ERROR Error { get; set; } - public GenericHttpClientEventArgs(string response, string request, HTTP_CALLBACK_ERROR error) - { - ResponseText = response; - RequestPath = request; - Error = error; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClientEventArgs.cs b/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClientEventArgs.cs new file mode 100644 index 00000000..0341ef2a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/GenericHttpClientEventArgs.cs @@ -0,0 +1,18 @@ +using System; +using Crestron.SimplSharp.Net.Http; + +namespace PepperDash.Essentials.Core +{ + public class GenericHttpClientEventArgs : EventArgs + { + public string ResponseText { get; private set; } + public string RequestPath { get; private set; } + public HTTP_CALLBACK_ERROR Error { get; set; } + public GenericHttpClientEventArgs(string response, string request, HTTP_CALLBACK_ERROR error) + { + ResponseText = response; + RequestPath = request; + Error = error; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/CommunicationExtras.cs b/src/PepperDash.Essentials.Core/Comm and IR/IComPortsDevice.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Comm and IR/CommunicationExtras.cs rename to src/PepperDash.Essentials.Core/Comm and IR/IComPortsDevice.cs diff --git a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs index b682af71..7066478a 100644 --- a/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs +++ b/src/PepperDash.Essentials.Core/Comm and IR/IRPortHelper.cs @@ -220,18 +220,4 @@ namespace PepperDash.Essentials.Core } }*/ } - - /// - /// Wrapper to help in IR port creation - /// - public class IrOutPortConfig - { - public IROutputPort Port { get; set; } - public string FileName { get; set; } - - public IrOutPortConfig() - { - FileName = ""; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/IrControlSpec.cs b/src/PepperDash.Essentials.Core/Comm and IR/IrControlSpec.cs new file mode 100644 index 00000000..b2537d1d --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/IrControlSpec.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + public class IrControlSpec + { + public string PortDeviceKey { get; set; } + public uint PortNumber { get; set; } + public string File { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Comm and IR/IrOutPortConfig.cs b/src/PepperDash.Essentials.Core/Comm and IR/IrOutPortConfig.cs new file mode 100644 index 00000000..0a48987b --- /dev/null +++ b/src/PepperDash.Essentials.Core/Comm and IR/IrOutPortConfig.cs @@ -0,0 +1,18 @@ +using Crestron.SimplSharpPro; + +namespace PepperDash.Essentials.Core +{ + /// + /// Wrapper to help in IR port creation + /// + public class IrOutPortConfig + { + public IROutputPort Port { get; set; } + public string FileName { get; set; } + + public IrOutPortConfig() + { + FileName = ""; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/DeviceConfig.cs b/src/PepperDash.Essentials.Core/Config/DeviceConfig.cs index ba21ae38..01f1d01f 100644 --- a/src/PepperDash.Essentials.Core/Config/DeviceConfig.cs +++ b/src/PepperDash.Essentials.Core/Config/DeviceConfig.cs @@ -1,6 +1,4 @@ extern alias Full; - -using System; using System.Collections.Generic; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; @@ -49,34 +47,4 @@ namespace PepperDash.Essentials.Core.Config public DeviceConfig() {} } - - /// - /// - /// - public class DevicePropertiesConverter : JsonConverter - { - - public override bool CanConvert(Type objectType) - { - return objectType == typeof(JToken); - } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - return JToken.ReadFrom(reader); - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException("SOD OFF HOSER"); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/DevicePropertiesConverter.cs b/src/PepperDash.Essentials.Core/Config/DevicePropertiesConverter.cs new file mode 100644 index 00000000..88b45cea --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/DevicePropertiesConverter.cs @@ -0,0 +1,37 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; +using Full::Newtonsoft.Json.Linq; + +namespace PepperDash.Essentials.Core.Config +{ + /// + /// + /// + public class DevicePropertiesConverter : JsonConverter + { + + public override bool CanConvert(Type objectType) + { + return objectType == typeof(JToken); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + return JToken.ReadFrom(reader); + } + + public override bool CanWrite + { + get + { + return false; + } + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException("SOD OFF HOSER"); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigStatusEventArgs.cs b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigStatusEventArgs.cs new file mode 100644 index 00000000..7335bd6c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigStatusEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core.Config +{ + public class ConfigStatusEventArgs : EventArgs + { + public eUpdateStatus UpdateStatus { get; private set; } + + public ConfigStatusEventArgs(eUpdateStatus status) + { + UpdateStatus = status; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs index 71783373..72962ff7 100644 --- a/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs +++ b/src/PepperDash.Essentials.Core/Config/Essentials/ConfigUpdater.cs @@ -200,26 +200,4 @@ namespace PepperDash.Essentials.Core.Config } } - - public enum eUpdateStatus - { - UpdateStarted, - ConfigFileReceived, - ArchivingConfigs, - DeletingLocalConfig, - WritingConfigFile, - RestartingProgram, - UpdateSucceeded, - UpdateFailed - } - - public class ConfigStatusEventArgs : EventArgs - { - public eUpdateStatus UpdateStatus { get; private set; } - - public ConfigStatusEventArgs(eUpdateStatus status) - { - UpdateStatus = status; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/EssentialsConfig.cs b/src/PepperDash.Essentials.Core/Config/Essentials/EssentialsConfig.cs index 16b1886b..a07aa0c8 100644 --- a/src/PepperDash.Essentials.Core/Config/Essentials/EssentialsConfig.cs +++ b/src/PepperDash.Essentials.Core/Config/Essentials/EssentialsConfig.cs @@ -61,14 +61,4 @@ namespace PepperDash.Essentials.Core.Config Rooms = new List(); } } - - /// - /// - /// - public class SystemTemplateConfigs - { - public EssentialsConfig System { get; set; } - - public EssentialsConfig Template { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/SystemTemplateConfigs.cs b/src/PepperDash.Essentials.Core/Config/Essentials/SystemTemplateConfigs.cs new file mode 100644 index 00000000..58e604fb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/Essentials/SystemTemplateConfigs.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core.Config +{ + /// + /// + /// + public class SystemTemplateConfigs + { + public EssentialsConfig System { get; set; } + + public EssentialsConfig Template { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/Essentials/eUpdateStatus.cs b/src/PepperDash.Essentials.Core/Config/Essentials/eUpdateStatus.cs new file mode 100644 index 00000000..bf855283 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/Essentials/eUpdateStatus.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Core.Config +{ + public enum eUpdateStatus + { + UpdateStarted, + ConfigFileReceived, + ArchivingConfigs, + DeletingLocalConfig, + WritingConfigFile, + RestartingProgram, + UpdateSucceeded, + UpdateFailed + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/InfoConfig.cs b/src/PepperDash.Essentials.Core/Config/InfoConfig.cs index 820abde5..ca8a6574 100644 --- a/src/PepperDash.Essentials.Core/Config/InfoConfig.cs +++ b/src/PepperDash.Essentials.Core/Config/InfoConfig.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; @@ -51,61 +50,4 @@ namespace PepperDash.Essentials.Core.Config RuntimeInfo = new RuntimeInfo(); } } - - - /// - /// Represents runtime information about the program/processor - /// - public class RuntimeInfo - { - /// - /// The name of the running application - /// - [JsonProperty("appName")] - public string AppName {get; set;} - //{ - // get - // { - // return Assembly.GetExecutingAssembly().GetName().Name; - // } - //} - - /// - /// The Assembly version of the running application - /// - [JsonProperty("assemblyVersion")] - public string AssemblyVersion {get; set;} - //{ - // get - // { - // var version = Assembly.GetExecutingAssembly().GetName().Version; - // return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); - // } - //} - - /// , - /// The OS Version of the processor (Firmware Version) - /// - [JsonProperty("osVersion")] - public string OsVersion {get; set;} - //{ - // get - // { - // return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware; - // } - //} - - /// - /// The information gathered by the processor at runtime about it's NICs and their IP addresses. - /// - [JsonProperty("ipInfo")] - public Dictionary IpInfo - { - get - { - return Global.EthernetAdapterInfoCollection; - } - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Config/RuntimeInfo.cs b/src/PepperDash.Essentials.Core/Config/RuntimeInfo.cs new file mode 100644 index 00000000..4fa91660 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/RuntimeInfo.cs @@ -0,0 +1,61 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Config +{ + /// + /// Represents runtime information about the program/processor + /// + public class RuntimeInfo + { + /// + /// The name of the running application + /// + [JsonProperty("appName")] + public string AppName {get; set;} + //{ + // get + // { + // return Assembly.GetExecutingAssembly().GetName().Name; + // } + //} + + /// + /// The Assembly version of the running application + /// + [JsonProperty("assemblyVersion")] + public string AssemblyVersion {get; set;} + //{ + // get + // { + // var version = Assembly.GetExecutingAssembly().GetName().Version; + // return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); + // } + //} + + /// , + /// The OS Version of the processor (Firmware Version) + /// + [JsonProperty("osVersion")] + public string OsVersion {get; set;} + //{ + // get + // { + // return Crestron.SimplSharp.CrestronEnvironment.OSVersion.Firmware; + // } + //} + + /// + /// The information gathered by the processor at runtime about it's NICs and their IP addresses. + /// + [JsonProperty("ipInfo")] + public Dictionary IpInfo + { + get + { + return Global.EthernetAdapterInfoCollection; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2NIoControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2NIoControllerFactory.cs new file mode 100644 index 00000000..ad283514 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2NIoControllerFactory.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class C2NIoControllerFactory : EssentialsDeviceFactory + { + public C2NIoControllerFactory() + { + TypeNames = new List() { "c2nio" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new C2N-IO Device"); + + return new C2NIoController(dc.Key, GetC2NIoDevice, dc); + } + + static C2nIo GetC2NIoDevice(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nIo", parentKey); + return new C2nIo(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nIo", parentKey); + return new C2nIo(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2nIoController.cs b/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2nIoController.cs index f1f1891d..5cff3bd2 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2nIoController.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/C2nIo/C2nIoController.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; @@ -65,42 +63,4 @@ namespace PepperDash.Essentials.Core.CrestronIO #endregion } - - public class C2NIoControllerFactory : EssentialsDeviceFactory - { - public C2NIoControllerFactory() - { - TypeNames = new List() { "c2nio" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new C2N-IO Device"); - - return new C2NIoController(dc.Key, GetC2NIoDevice, dc); - } - - static C2nIo GetC2NIoDevice(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nIo", parentKey); - return new C2nIo(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nIo", parentKey); - return new C2nIo(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Configuration.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Configuration.cs new file mode 100644 index 00000000..1e1e75dd --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Configuration.cs @@ -0,0 +1,11 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class CenCi31Configuration + { + [JsonProperty("card")] + public string Card { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Controller.cs index 7e29e0e0..3dd7b899 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31Controller.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; using Crestron.SimplSharpPro.ThreeSeriesCards; -using Full.Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.CrestronIO.Cards { @@ -85,34 +83,4 @@ namespace PepperDash.Essentials.Core.CrestronIO.Cards DeviceManager.AddDevice(device); } } - - public class CenCi31Configuration - { - [JsonProperty("card")] - public string Card { get; set; } - } - - public class CenCi31ControllerFactory : EssentialsDeviceFactory - { - public CenCi31ControllerFactory() - { - TypeNames = new List {"cenci31"}; - } - #region Overrides of EssentialsDeviceFactory - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory attempting to build new CEN-CI-1"); - - var controlProperties = CommFactory.GetControlPropertiesConfig(dc); - var ipId = controlProperties.IpIdInt; - - var cardCage = new CenCi31(ipId, Global.ControlSystem); - var config = dc.Properties.ToObject(); - - return new CenCi31Controller(dc.Key, dc.Name, config, cardCage); - } - - #endregion - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31ControllerFactory.cs new file mode 100644 index 00000000..84d6258d --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi31ControllerFactory.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.ThreeSeriesCards; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class CenCi31ControllerFactory : EssentialsDeviceFactory + { + public CenCi31ControllerFactory() + { + TypeNames = new List {"cenci31"}; + } + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory attempting to build new CEN-CI-1"); + + var controlProperties = CommFactory.GetControlPropertiesConfig(dc); + var ipId = controlProperties.IpIdInt; + + var cardCage = new CenCi31(ipId, Global.ControlSystem); + var config = dc.Properties.ToObject(); + + return new CenCi31Controller(dc.Key, dc.Name, config, cardCage); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Configuration.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Configuration.cs new file mode 100644 index 00000000..92d76f6f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Configuration.cs @@ -0,0 +1,12 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class CenCi33Configuration + { + [JsonProperty("cards")] + public Dictionary Cards { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Controller.cs index d1eb0166..a067bfa5 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33Controller.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; using Crestron.SimplSharpPro.ThreeSeriesCards; -using Full.Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.CrestronIO.Cards { @@ -100,34 +98,4 @@ namespace PepperDash.Essentials.Core.CrestronIO.Cards } } } - - public class CenCi33Configuration - { - [JsonProperty("cards")] - public Dictionary Cards { get; set; } - } - - public class CenCi33ControllerFactory : EssentialsDeviceFactory - { - public CenCi33ControllerFactory() - { - TypeNames = new List {"cenci33"}; - } - #region Overrides of EssentialsDeviceFactory - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory attempting to build new CEN-CI-3"); - - var controlProperties = CommFactory.GetControlPropertiesConfig(dc); - var ipId = controlProperties.IpIdInt; - - var cardCage = new CenCi33(ipId, Global.ControlSystem); - var config = dc.Properties.ToObject(); - - return new CenCi33Controller(dc.Key, dc.Name, config, cardCage); - } - - #endregion - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33ControllerFactory.cs new file mode 100644 index 00000000..65841df7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/CenCi33ControllerFactory.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.ThreeSeriesCards; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class CenCi33ControllerFactory : EssentialsDeviceFactory + { + public CenCi33ControllerFactory() + { + TypeNames = new List {"cenci33"}; + } + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory attempting to build new CEN-CI-3"); + + var controlProperties = CommFactory.GetControlPropertiesConfig(dc); + var ipId = controlProperties.IpIdInt; + + var cardCage = new CenCi33(ipId, Global.ControlSystem); + var config = dc.Properties.ToObject(); + + return new CenCi33Controller(dc.Key, dc.Name, config, cardCage); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageConfiguration.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageConfiguration.cs new file mode 100644 index 00000000..31414509 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageConfiguration.cs @@ -0,0 +1,12 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class InternalCardCageConfiguration + { + [JsonProperty("cards")] + public Dictionary Cards { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageController.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageController.cs index 97286945..bbf03ea1 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageController.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageController.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; using Crestron.SimplSharpPro.ThreeSeriesCards; -using Full.Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.CrestronIO.Cards { @@ -108,36 +106,4 @@ namespace PepperDash.Essentials.Core.CrestronIO.Cards } } } - - public class InternalCardCageConfiguration - { - [JsonProperty("cards")] - public Dictionary Cards { get; set; } - } - - public class InternalCardCageControllerFactory : EssentialsDeviceFactory - { - public InternalCardCageControllerFactory() - { - TypeNames = new List {"internalcardcage"}; - } - #region Overrides of EssentialsDeviceFactory - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory attempting to build new Internal Card Cage Controller"); - - if (!Global.ControlSystem.SupportsThreeSeriesPlugInCards) - { - Debug.Console(0, Debug.ErrorLogLevel.Warning, "Current control system does NOT support 3-Series cards. Everything is NOT awesome."); - return null; - } - - var config = dc.Properties.ToObject(); - - return new InternalCardCageController(dc.Key, dc.Name, config); - } - - #endregion - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageControllerFactory.cs new file mode 100644 index 00000000..2387320a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Cards/InternalCardCageControllerFactory.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO.Cards +{ + public class InternalCardCageControllerFactory : EssentialsDeviceFactory + { + public InternalCardCageControllerFactory() + { + TypeNames = new List {"internalcardcage"}; + } + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory attempting to build new Internal Card Cage Controller"); + + if (!Global.ControlSystem.SupportsThreeSeriesPlugInCards) + { + Debug.Console(0, Debug.ErrorLogLevel.Warning, "Current control system does NOT support 3-Series cards. Everything is NOT awesome."); + return null; + } + + var config = dc.Properties.ToObject(); + + return new InternalCardCageController(dc.Key, dc.Name, config); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/DinCenCn/DinCenCnController.cs b/src/PepperDash.Essentials.Core/Crestron IO/DinCenCn/DinCenCn2Controller.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Crestron IO/DinCenCn/DinCenCnController.cs rename to src/PepperDash.Essentials.Core/Crestron IO/DinCenCn/DinCenCn2Controller.cs diff --git a/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8Controller.cs index 794fe609..45abc53d 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8Controller.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; @@ -39,42 +37,4 @@ namespace PepperDash.Essentials.Core.CrestronIO } - - public class DinIo8ControllerFactory : EssentialsDeviceFactory - { - public DinIo8ControllerFactory() - { - TypeNames = new List() { "DinIo8" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new DinIo8 Device"); - - return new DinIo8Controller(dc.Key, GetDinIo8Device, dc); - } - - static DinIo8 GetDinIo8Device(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new DinIo8", parentKey); - return new DinIo8(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new DinIo8", parentKey); - return new DinIo8(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8ControllerFactory.cs new file mode 100644 index 00000000..859313bb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/DinIo8/DinIo8ControllerFactory.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class DinIo8ControllerFactory : EssentialsDeviceFactory + { + public DinIo8ControllerFactory() + { + TypeNames = new List() { "DinIo8" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new DinIo8 Device"); + + return new DinIo8Controller(dc.Key, GetDinIo8Device, dc); + } + + static DinIo8 GetDinIo8Device(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new DinIo8", parentKey); + return new DinIo8(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new DinIo8", parentKey); + return new DinIo8(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104Controller.cs index 50647126..fc32bf48 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104Controller.cs @@ -1,14 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Essentials.Core.Config; - - -using PepperDash.Core; namespace PepperDash.Essentials.Core { @@ -40,30 +35,4 @@ namespace PepperDash.Essentials.Core #endregion } - - public class CenIoDigIn104ControllerFactory : EssentialsDeviceFactory - { - public CenIoDigIn104ControllerFactory() - { - TypeNames = new List() { "ceniodigin104" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new CEN-DIGIN-104 Device"); - - var control = CommFactory.GetControlPropertiesConfig(dc); - if (control == null) - { - Debug.Console(1, "Factory failed to create a new CEN-DIGIN-104 Device, control properties not found"); - return null; - } - var ipid = control.IpIdInt; - if (ipid != 0) return new CenIoDigIn104Controller(dc.Key, dc.Name, new CenIoDi104(ipid, Global.ControlSystem)); - - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104ControllerFactory.cs new file mode 100644 index 00000000..397285e8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/CenIoDigIn104ControllerFactory.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class CenIoDigIn104ControllerFactory : EssentialsDeviceFactory + { + public CenIoDigIn104ControllerFactory() + { + TypeNames = new List() { "ceniodigin104" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CEN-DIGIN-104 Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-DIGIN-104 Device, control properties not found"); + return null; + } + var ipid = control.IpIdInt; + if (ipid != 0) return new CenIoDigIn104Controller(dc.Key, dc.Name, new CenIoDi104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAbalogInputDeviceFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAbalogInputDeviceFactory.cs new file mode 100644 index 00000000..8f694117 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAbalogInputDeviceFactory.cs @@ -0,0 +1,29 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class GenericVersiportAbalogInputDeviceFactory : EssentialsDeviceFactory + { + public GenericVersiportAbalogInputDeviceFactory() + { + TypeNames = new List() { "versiportanaloginput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + if (props == null) return null; + + var portDevice = new GenericVersiportAnalogInputDevice(dc.Key, dc.Name, GenericVersiportAnalogInputDevice.GetVersiportDigitalInput, props); + + return portDevice; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs index 5da79bbf..2c9a5bbb 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportAnalogInputDevice.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -9,7 +8,6 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; @@ -185,26 +183,4 @@ namespace PepperDash.Essentials.Core.CrestronIO } } - - - public class GenericVersiportAbalogInputDeviceFactory : EssentialsDeviceFactory - { - public GenericVersiportAbalogInputDeviceFactory() - { - TypeNames = new List() { "versiportanaloginput" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - if (props == null) return null; - - var portDevice = new GenericVersiportAnalogInputDevice(dc.Key, dc.Name, GenericVersiportAnalogInputDevice.GetVersiportDigitalInput, props); - - return portDevice; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportInputDevice.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDevice.cs similarity index 84% rename from src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportInputDevice.cs rename to src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDevice.cs index fd215545..c8df179e 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportInputDevice.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDevice.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -9,7 +8,6 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; @@ -145,26 +143,4 @@ namespace PepperDash.Essentials.Core.CrestronIO } } - - - public class GenericVersiportDigitalInputDeviceFactory : EssentialsDeviceFactory - { - public GenericVersiportDigitalInputDeviceFactory() - { - TypeNames = new List() { "versiportinput" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - if (props == null) return null; - - var portDevice = new GenericVersiportDigitalInputDevice(dc.Key, dc.Name, GenericVersiportDigitalInputDevice.GetVersiportDigitalInput, props); - - return portDevice; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDeviceFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDeviceFactory.cs new file mode 100644 index 00000000..17bf8343 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Inputs/GenericVersiportDigitalInputDeviceFactory.cs @@ -0,0 +1,29 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class GenericVersiportDigitalInputDeviceFactory : EssentialsDeviceFactory + { + public GenericVersiportDigitalInputDeviceFactory() + { + TypeNames = new List() { "versiportinput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + if (props == null) return null; + + var portDevice = new GenericVersiportDigitalInputDevice(dc.Key, dc.Name, GenericVersiportDigitalInputDevice.GetVersiportDigitalInput, props); + + return portDevice; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104Controller.cs index d994a11c..96eaf6cb 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104Controller.cs @@ -1,14 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Essentials.Core.Config; - - -using PepperDash.Core; namespace PepperDash.Essentials.Core { @@ -52,42 +47,4 @@ namespace PepperDash.Essentials.Core #endregion } - - /// - /// CEN-IO-IR-104 controller fatory - /// - public class CenIoIr104ControllerFactory : EssentialsDeviceFactory - { - /// - /// Constructor - /// - public CenIoIr104ControllerFactory() - { - TypeNames = new List() { "cenioir104" }; - } - - /// - /// Build device CEN-IO-IR-104 - /// - /// - /// - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new CEN-IO-IR-104 Device"); - - var control = CommFactory.GetControlPropertiesConfig(dc); - if (control == null) - { - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device, control properties not found"); - return null; - } - - var ipid = control.IpIdInt; - if(ipid != 0) return new CenIoIr104Controller(dc.Key, dc.Name, new CenIoIr104(ipid, Global.ControlSystem)); - - Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104ControllerFactory.cs new file mode 100644 index 00000000..be25e153 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Ir/CenIoIr104ControllerFactory.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// CEN-IO-IR-104 controller fatory + /// + public class CenIoIr104ControllerFactory : EssentialsDeviceFactory + { + /// + /// Constructor + /// + public CenIoIr104ControllerFactory() + { + TypeNames = new List() { "cenioir104" }; + } + + /// + /// Build device CEN-IO-IR-104 + /// + /// + /// + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CEN-IO-IR-104 Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device, control properties not found"); + return null; + } + + var ipid = control.IpIdInt; + if(ipid != 0) return new CenIoIr104Controller(dc.Key, dc.Name, new CenIoIr104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportOutputDevice.cs b/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDevice.cs similarity index 86% rename from src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportOutputDevice.cs rename to src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDevice.cs index 2b3d0fab..9bfd68c2 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportOutputDevice.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDevice.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -9,7 +8,6 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; @@ -166,26 +164,4 @@ namespace PepperDash.Essentials.Core.CrestronIO } } - - - public class GenericVersiportDigitalOutputDeviceFactory : EssentialsDeviceFactory - { - public GenericVersiportDigitalOutputDeviceFactory() - { - TypeNames = new List() { "versiportoutput" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - if (props == null) return null; - - var portDevice = new GenericVersiportDigitalOutputDevice(dc.Key, dc.Name, GenericVersiportDigitalOutputDevice.GetVersiportDigitalOutput, props); - - return portDevice; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDeviceFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDeviceFactory.cs new file mode 100644 index 00000000..578b875c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Outputs/GenericVersiportDigitalOutputDeviceFactory.cs @@ -0,0 +1,29 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public class GenericVersiportDigitalOutputDeviceFactory : EssentialsDeviceFactory + { + public GenericVersiportDigitalOutputDeviceFactory() + { + TypeNames = new List() { "versiportoutput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Versiport Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + if (props == null) return null; + + var portDevice = new GenericVersiportDigitalOutputDevice(dc.Key, dc.Name, GenericVersiportDigitalOutputDevice.GetVersiportDigitalOutput, props); + + return portDevice; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104Controller.cs b/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104Controller.cs index ba13ede8..56fa343a 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104Controller.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104Controller.cs @@ -1,8 +1,5 @@ -using System.Collections.Generic; -using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { @@ -42,36 +39,4 @@ namespace PepperDash.Essentials.Core get { return _ry104.NumberOfRelayPorts; } } } - - /// - /// CEN-IO-RY Controller factory - /// - public class CenIoRy104ControllerFactory : EssentialsDeviceFactory - { - /// - /// Constructor - /// - public CenIoRy104ControllerFactory() - { - TypeNames = new List() { "ceniory104" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create a new CEN-IO-RY-104 Device"); - - var controlPropertiesConfig = CommFactory.GetControlPropertiesConfig(dc); - if (controlPropertiesConfig == null) - { - Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device, control properties not found"); - return null; - } - - var ipid = controlPropertiesConfig.IpIdInt; - if (ipid != 0) return new CenIoRy104Controller(dc.Key, dc.Name, new CenIoRy104(ipid, Global.ControlSystem)); - - Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device using IP-ID-{0}", ipid); - return null; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104ControllerFactory.cs b/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104ControllerFactory.cs new file mode 100644 index 00000000..d12a6356 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Relay/CenIoRy104ControllerFactory.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// CEN-IO-RY Controller factory + /// + public class CenIoRy104ControllerFactory : EssentialsDeviceFactory + { + /// + /// Constructor + /// + public CenIoRy104ControllerFactory() + { + TypeNames = new List() { "ceniory104" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create a new CEN-IO-RY-104 Device"); + + var controlPropertiesConfig = CommFactory.GetControlPropertiesConfig(dc); + if (controlPropertiesConfig == null) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device, control properties not found"); + return null; + } + + var ipid = controlPropertiesConfig.IpIdInt; + if (ipid != 0) return new CenIoRy104Controller(dc.Key, dc.Name, new CenIoRy104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device using IP-ID-{0}", ipid); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutput.cs b/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutput.cs index 19f8e0df..8f3e53ac 100644 --- a/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutput.cs +++ b/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutput.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -18,9 +17,4 @@ namespace PepperDash.Essentials.Core.CrestronIO void On(); void Off(); } - - public interface ISwitchedOutputCollection - { - Dictionary SwitchedOutputs { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutputCollection.cs b/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutputCollection.cs new file mode 100644 index 00000000..74a84ef4 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron IO/Relay/ISwitchedOutputCollection.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + public interface ISwitchedOutputCollection + { + Dictionary SwitchedOutputs { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs index d9650e63..b1d5e46b 100644 --- a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs +++ b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDevice.cs @@ -1,10 +1,8 @@ using System; using System.Linq; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Core.JsonStandardObjects; -using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Core { @@ -170,46 +168,6 @@ namespace PepperDash.Essentials.Core #endregion } - public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced - { - protected CrestronGenericBridgeableBaseDevice(string key, string name, GenericBase hardware) : base(key, name, hardware) - { - } - protected CrestronGenericBridgeableBaseDevice(string key, string name) - : base(key, name) - { - } - - - public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); - } - - - //*********************************************************************************** - public class CrestronGenericBaseDeviceEventIds - { - public const uint IsOnline = 1; - public const uint IpConnectionsText =2; - } - - /// - /// Adds logging to Register() failure - /// - public static class GenericBaseExtensions - { - public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key) - { - var result = device.Register(); - var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? - Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; - Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); - //if (result != eDeviceRegistrationUnRegistrationResponse.Success) - //{ - // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); - //} - return result; - } - - } + //*********************************************************************************** } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDeviceEventIds.cs b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDeviceEventIds.cs new file mode 100644 index 00000000..aa86f2ef --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBaseDeviceEventIds.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core +{ + public class CrestronGenericBaseDeviceEventIds + { + public const uint IsOnline = 1; + public const uint IpConnectionsText =2; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBridgeableBaseDevice.cs b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBridgeableBaseDevice.cs new file mode 100644 index 00000000..3448e5d5 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron/CrestronGenericBridgeableBaseDevice.cs @@ -0,0 +1,21 @@ +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Core +{ + public abstract class CrestronGenericBridgeableBaseDevice : CrestronGenericBaseDevice, IBridgeAdvanced + { + protected CrestronGenericBridgeableBaseDevice(string key, string name, GenericBase hardware) : base(key, name, hardware) + { + } + + protected CrestronGenericBridgeableBaseDevice(string key, string name) + : base(key, name) + { + } + + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Crestron/GenericBaseExtensions.cs b/src/PepperDash.Essentials.Core/Crestron/GenericBaseExtensions.cs new file mode 100644 index 00000000..1d2ef108 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Crestron/GenericBaseExtensions.cs @@ -0,0 +1,25 @@ +using Crestron.SimplSharpPro; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Adds logging to Register() failure + /// + public static class GenericBaseExtensions + { + public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key) + { + var result = device.Register(); + var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? + Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; + Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); + //if (result != eDeviceRegistrationUnRegistrationResponse.Success) + //{ + // Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); + //} + return result; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Device Info/DeviceInfoChangeHandler.cs b/src/PepperDash.Essentials.Core/Device Info/DeviceInfoChangeHandler.cs new file mode 100644 index 00000000..c6775224 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Device Info/DeviceInfoChangeHandler.cs @@ -0,0 +1,6 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.DeviceInfo +{ + public delegate void DeviceInfoChangeHandler(IKeyed device, DeviceInfoEventArgs args); +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Device Info/IDeviceInfoProvider.cs b/src/PepperDash.Essentials.Core/Device Info/IDeviceInfoProvider.cs index ea9c16e6..3ad2ec8b 100644 --- a/src/PepperDash.Essentials.Core/Device Info/IDeviceInfoProvider.cs +++ b/src/PepperDash.Essentials.Core/Device Info/IDeviceInfoProvider.cs @@ -11,6 +11,4 @@ namespace PepperDash.Essentials.Core.DeviceInfo void UpdateDeviceInfo(); } - - public delegate void DeviceInfoChangeHandler(IKeyed device, DeviceInfoEventArgs args); } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannel.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannel.cs index 5a38c703..3a9edf92 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannel.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannel.cs @@ -1,6 +1,4 @@ using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; @@ -18,30 +16,4 @@ namespace PepperDash.Essentials.Core void Info(bool pressRelease); void Exit(bool pressRelease); } - - /// - /// - /// - public static class IChannelExtensions - { - public static void LinkButtons(this IChannel dev, BasicTriList triList) - { - triList.SetBoolSigAction(123, dev.ChannelUp); - triList.SetBoolSigAction(124, dev.ChannelDown); - triList.SetBoolSigAction(125, dev.LastChannel); - triList.SetBoolSigAction(137, dev.Guide); - triList.SetBoolSigAction(129, dev.Info); - triList.SetBoolSigAction(134, dev.Exit); - } - - public static void UnlinkButtons(this IChannel dev, BasicTriList triList) - { - triList.ClearBoolSigAction(123); - triList.ClearBoolSigAction(124); - triList.ClearBoolSigAction(125); - triList.ClearBoolSigAction(137); - triList.ClearBoolSigAction(129); - triList.ClearBoolSigAction(134); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannelExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannelExtensions.cs new file mode 100644 index 00000000..5e28dcb7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IChannelExtensions.cs @@ -0,0 +1,30 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IChannelExtensions + { + public static void LinkButtons(this IChannel dev, BasicTriList triList) + { + triList.SetBoolSigAction(123, dev.ChannelUp); + triList.SetBoolSigAction(124, dev.ChannelDown); + triList.SetBoolSigAction(125, dev.LastChannel); + triList.SetBoolSigAction(137, dev.Guide); + triList.SetBoolSigAction(129, dev.Info); + triList.SetBoolSigAction(134, dev.Exit); + } + + public static void UnlinkButtons(this IChannel dev, BasicTriList triList) + { + triList.ClearBoolSigAction(123); + triList.ClearBoolSigAction(124); + triList.ClearBoolSigAction(125); + triList.ClearBoolSigAction(137); + triList.ClearBoolSigAction(129); + triList.ClearBoolSigAction(134); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColor.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColor.cs new file mode 100644 index 00000000..633b3b81 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColor.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public interface IColor + { + void Red(bool pressRelease); + void Green(bool pressRelease); + void Yellow(bool pressRelease); + void Blue(bool pressRelease); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorFunctions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorExtensions.cs similarity index 77% rename from src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorFunctions.cs rename to src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorExtensions.cs index 232362e9..76fdfd40 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorFunctions.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IColorExtensions.cs @@ -6,18 +6,7 @@ using PepperDash.Essentials.Core.SmartObjects; namespace PepperDash.Essentials.Core { - /// - /// - /// - public interface IColor - { - void Red(bool pressRelease); - void Green(bool pressRelease); - void Yellow(bool pressRelease); - void Blue(bool pressRelease); - } - - /// + /// /// /// public static class IColorExtensions diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPad.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPad.cs index a69cfe3b..65f1ef3c 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPad.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPad.cs @@ -1,5 +1,4 @@ using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; @@ -19,32 +18,4 @@ namespace PepperDash.Essentials.Core void Menu(bool pressRelease); void Exit(bool pressRelease); } - - /// - /// - /// - public static class IDPadExtensions - { - public static void LinkButtons(this IDPad dev, BasicTriList triList) - { - triList.SetBoolSigAction(138, dev.Up); - triList.SetBoolSigAction(139, dev.Down); - triList.SetBoolSigAction(140, dev.Left); - triList.SetBoolSigAction(141, dev.Right); - triList.SetBoolSigAction(142, dev.Select); - triList.SetBoolSigAction(130, dev.Menu); - triList.SetBoolSigAction(134, dev.Exit); - } - - public static void UnlinkButtons(this IDPad dev, BasicTriList triList) - { - triList.ClearBoolSigAction(138); - triList.ClearBoolSigAction(139); - triList.ClearBoolSigAction(140); - triList.ClearBoolSigAction(141); - triList.ClearBoolSigAction(142); - triList.ClearBoolSigAction(130); - triList.ClearBoolSigAction(134); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPadExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPadExtensions.cs new file mode 100644 index 00000000..ddf6eb50 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDPadExtensions.cs @@ -0,0 +1,32 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IDPadExtensions + { + public static void LinkButtons(this IDPad dev, BasicTriList triList) + { + triList.SetBoolSigAction(138, dev.Up); + triList.SetBoolSigAction(139, dev.Down); + triList.SetBoolSigAction(140, dev.Left); + triList.SetBoolSigAction(141, dev.Right); + triList.SetBoolSigAction(142, dev.Select); + triList.SetBoolSigAction(130, dev.Menu); + triList.SetBoolSigAction(134, dev.Exit); + } + + public static void UnlinkButtons(this IDPad dev, BasicTriList triList) + { + triList.ClearBoolSigAction(138); + triList.ClearBoolSigAction(139); + triList.ClearBoolSigAction(140); + triList.ClearBoolSigAction(141); + triList.ClearBoolSigAction(142); + triList.ClearBoolSigAction(130); + triList.ClearBoolSigAction(134); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvr.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvr.cs index 9e55702c..351fffaf 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvr.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvr.cs @@ -4,8 +4,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; @@ -19,22 +17,4 @@ namespace PepperDash.Essentials.Core void DvrList(bool pressRelease); void Record(bool pressRelease); } - - /// - /// - /// - public static class IDvrExtensions - { - public static void LinkButtons(this IDvr dev, BasicTriList triList) - { - triList.SetBoolSigAction(136, dev.DvrList); - triList.SetBoolSigAction(152, dev.Record); - } - - public static void UnlinkButtons(this IDvr dev, BasicTriList triList) - { - triList.ClearBoolSigAction(136); - triList.ClearBoolSigAction(152); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvrExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvrExtensions.cs new file mode 100644 index 00000000..e7d9915f --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IDvrExtensions.cs @@ -0,0 +1,22 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IDvrExtensions + { + public static void LinkButtons(this IDvr dev, BasicTriList triList) + { + triList.SetBoolSigAction(136, dev.DvrList); + triList.SetBoolSigAction(152, dev.Record); + } + + public static void UnlinkButtons(this IDvr dev, BasicTriList triList) + { + triList.ClearBoolSigAction(136); + triList.ClearBoolSigAction(152); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControl.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControl.cs new file mode 100644 index 00000000..6686701b --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControl.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines the ability to power a device on and off + /// + public interface IHasPowerControl + { + void PowerOn(); + void PowerOff(); + void PowerToggle(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlExtensions.cs new file mode 100644 index 00000000..17c462dc --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlExtensions.cs @@ -0,0 +1,36 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IHasPowerControlExtensions + { + public static void LinkButtons(this IHasPowerControl dev, BasicTriList triList) + { + triList.SetSigFalseAction(101, dev.PowerOn); + triList.SetSigFalseAction(102, dev.PowerOff); + triList.SetSigFalseAction(103, dev.PowerToggle); + + var fbdev = dev as IHasPowerControlWithFeedback; + if (fbdev != null) + { + fbdev.PowerIsOnFeedback.LinkInputSig(triList.BooleanInput[101]); + } + } + + public static void UnlinkButtons(this IHasPowerControl dev, BasicTriList triList) + { + triList.ClearBoolSigAction(101); + triList.ClearBoolSigAction(102); + triList.ClearBoolSigAction(103); + + var fbdev = dev as IHasPowerControlWithFeedback; + if (fbdev != null) + { + fbdev.PowerIsOnFeedback.UnlinkInputSig(triList.BooleanInput[101]); + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlWithFeedback.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlWithFeedback.cs new file mode 100644 index 00000000..f0aa9029 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasPowerControlWithFeedback.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Adds feedback for current power state + /// + public interface IHasPowerControlWithFeedback : IHasPowerControl + { + BoolFeedback PowerIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl.cs index bb800b44..8ffb57ec 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl.cs @@ -1,5 +1,4 @@ -using System; -using PepperDash.Core; +using PepperDash.Core; namespace PepperDash.Essentials.Core.DeviceTypeInterfaces { @@ -12,34 +11,4 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces void LinkSystemMonitorToAppServer(); } - - /// - /// Describes a MobileSystemController that accepts IEssentialsRoom - /// - public interface IMobileControl3 : IMobileControl - { - void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent); - } - - /// - /// Describes a MobileControl Room Bridge - /// - public interface IMobileControlRoomBridge : IKeyed - { - event EventHandler UserCodeChanged; - - event EventHandler UserPromptedForCode; - - event EventHandler ClientJoined; - - string UserCode { get; } - - string QrCodeUrl { get; } - - string QrCodeChecksum { get; } - - string McServerUrl { get; } - - string RoomName { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl3.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl3.cs new file mode 100644 index 00000000..85e4bd94 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControl3.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.DeviceTypeInterfaces +{ + /// + /// Describes a MobileSystemController that accepts IEssentialsRoom + /// + public interface IMobileControl3 : IMobileControl + { + void CreateMobileControlRoomBridge(IEssentialsRoom room, IMobileControl parent); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControlRoomBridge.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControlRoomBridge.cs new file mode 100644 index 00000000..9cde5f4f --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IMobileControlRoomBridge.cs @@ -0,0 +1,27 @@ +using System; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.DeviceTypeInterfaces +{ + /// + /// Describes a MobileControl Room Bridge + /// + public interface IMobileControlRoomBridge : IKeyed + { + event EventHandler UserCodeChanged; + + event EventHandler UserPromptedForCode; + + event EventHandler ClientJoined; + + string UserCode { get; } + + string QrCodeUrl { get; } + + string QrCodeChecksum { get; } + + string McServerUrl { get; } + + string RoomName { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumeric.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericExtensions.cs similarity index 63% rename from src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumeric.cs rename to src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericExtensions.cs index 62ea8b3f..0137cb99 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumeric.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericExtensions.cs @@ -1,45 +1,10 @@ using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; namespace PepperDash.Essentials.Core { - /// - /// - /// - public interface INumericKeypad:IKeyed - { - void Digit0(bool pressRelease); - void Digit1(bool pressRelease); - void Digit2(bool pressRelease); - void Digit3(bool pressRelease); - void Digit4(bool pressRelease); - void Digit5(bool pressRelease); - void Digit6(bool pressRelease); - void Digit7(bool pressRelease); - void Digit8(bool pressRelease); - void Digit9(bool pressRelease); - - /// - /// Used to hide/show the button and/or text on the left-hand keypad button - /// - bool HasKeypadAccessoryButton1 { get; } - string KeypadAccessoryButton1Label { get; } - void KeypadAccessoryButton1(bool pressRelease); - - bool HasKeypadAccessoryButton2 { get; } - string KeypadAccessoryButton2Label { get; } - void KeypadAccessoryButton2(bool pressRelease); - } - - public interface ISetTopBoxNumericKeypad : INumericKeypad - { - void Dash(bool pressRelease); - void KeypadEnter(bool pressRelease); - } - - /// + /// /// /// public static class INumericExtensions diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericKeypad.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericKeypad.cs new file mode 100644 index 00000000..a24ddf3d --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/INumericKeypad.cs @@ -0,0 +1,32 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public interface INumericKeypad:IKeyed + { + void Digit0(bool pressRelease); + void Digit1(bool pressRelease); + void Digit2(bool pressRelease); + void Digit3(bool pressRelease); + void Digit4(bool pressRelease); + void Digit5(bool pressRelease); + void Digit6(bool pressRelease); + void Digit7(bool pressRelease); + void Digit8(bool pressRelease); + void Digit9(bool pressRelease); + + /// + /// Used to hide/show the button and/or text on the left-hand keypad button + /// + bool HasKeypadAccessoryButton1 { get; } + string KeypadAccessoryButton1Label { get; } + void KeypadAccessoryButton1(bool pressRelease); + + bool HasKeypadAccessoryButton2 { get; } + string KeypadAccessoryButton2Label { get; } + void KeypadAccessoryButton2(bool pressRelease); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPasswordPrompt.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPasswordPrompt.cs index 6ecdd775..4f8043a0 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPasswordPrompt.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPasswordPrompt.cs @@ -22,35 +22,4 @@ namespace PepperDash.Essentials.Core /// void SubmitPassword(string password); } - - public class PasswordPromptEventArgs : EventArgs - { - /// - /// Indicates if the last submitted password was incorrect - /// - public bool LastAttemptWasIncorrect { get; private set; } - - /// - /// Indicates that the login attempt has failed - /// - public bool LoginAttemptFailed { get; private set; } - - /// - /// Indicates that the process was cancelled and the prompt should be dismissed - /// - public bool LoginAttemptCancelled { get; private set; } - - /// - /// A message to be displayed to the user - /// - public string Message { get; private set; } - - public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) - { - LastAttemptWasIncorrect = lastAttemptIncorrect; - LoginAttemptFailed = loginFailed; - LoginAttemptCancelled = loginCancelled; - Message = message; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPower.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPower.cs index 0fcf32e9..e922eb0c 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPower.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IPower.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.Fusion; using PepperDash.Essentials.Core; @@ -24,54 +23,4 @@ namespace PepperDash.Essentials.Core void PowerToggle(); BoolFeedback PowerIsOnFeedback { get; } } - - /// - /// Adds feedback for current power state - /// - public interface IHasPowerControlWithFeedback : IHasPowerControl - { - BoolFeedback PowerIsOnFeedback { get; } - } - - /// - /// Defines the ability to power a device on and off - /// - public interface IHasPowerControl - { - void PowerOn(); - void PowerOff(); - void PowerToggle(); - } - - /// - /// - /// - public static class IHasPowerControlExtensions - { - public static void LinkButtons(this IHasPowerControl dev, BasicTriList triList) - { - triList.SetSigFalseAction(101, dev.PowerOn); - triList.SetSigFalseAction(102, dev.PowerOff); - triList.SetSigFalseAction(103, dev.PowerToggle); - - var fbdev = dev as IHasPowerControlWithFeedback; - if (fbdev != null) - { - fbdev.PowerIsOnFeedback.LinkInputSig(triList.BooleanInput[101]); - } - } - - public static void UnlinkButtons(this IHasPowerControl dev, BasicTriList triList) - { - triList.ClearBoolSigAction(101); - triList.ClearBoolSigAction(102); - triList.ClearBoolSigAction(103); - - var fbdev = dev as IHasPowerControlWithFeedback; - if (fbdev != null) - { - fbdev.PowerIsOnFeedback.UnlinkInputSig(triList.BooleanInput[101]); - } - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControls.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControls.cs index a9a92126..872b3a3b 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControls.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControls.cs @@ -1,6 +1,4 @@ -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; namespace PepperDash.Essentials.Core @@ -37,19 +35,4 @@ namespace PepperDash.Essentials.Core void DvrList(bool pressRelease); void Replay(bool pressRelease); } - - public static class ISetTopBoxControlsExtensions - { - public static void LinkButtons(this ISetTopBoxControls dev, BasicTriList triList) - { - triList.SetBoolSigAction(136, dev.DvrList); - triList.SetBoolSigAction(152, dev.Replay); - } - - public static void UnlinkButtons(this ISetTopBoxControls dev, BasicTriList triList) - { - triList.ClearBoolSigAction(136); - triList.ClearBoolSigAction(152); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControlsExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControlsExtensions.cs new file mode 100644 index 00000000..19e56872 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxControlsExtensions.cs @@ -0,0 +1,19 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + public static class ISetTopBoxControlsExtensions + { + public static void LinkButtons(this ISetTopBoxControls dev, BasicTriList triList) + { + triList.SetBoolSigAction(136, dev.DvrList); + triList.SetBoolSigAction(152, dev.Replay); + } + + public static void UnlinkButtons(this ISetTopBoxControls dev, BasicTriList triList) + { + triList.ClearBoolSigAction(136); + triList.ClearBoolSigAction(152); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxNumericKeypad.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxNumericKeypad.cs new file mode 100644 index 00000000..e0ea31f6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISetTopBoxNumericKeypad.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core +{ + public interface ISetTopBoxNumericKeypad : INumericKeypad + { + void Dash(bool pressRelease); + void KeypadEnter(bool pressRelease); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransport.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransport.cs index 1189c10b..896e5bbb 100644 --- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransport.cs +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransport.cs @@ -1,6 +1,4 @@ -using Crestron.SimplSharpPro.DeviceSupport; - -namespace PepperDash.Essentials.Core +namespace PepperDash.Essentials.Core { /// /// @@ -16,38 +14,4 @@ namespace PepperDash.Essentials.Core void Stop(bool pressRelease); void Record(bool pressRelease); } - - /// - /// - /// - public static class ITransportExtensions - { - /// - /// Attaches to trilist joins: Play:145, Pause:146, Stop:147, ChapPlus:148, ChapMinus:149, Rewind:150, Ffwd:151, Record:154 - /// - /// - public static void LinkButtons(this ITransport dev, BasicTriList triList) - { - triList.SetBoolSigAction(145, dev.Play); - triList.SetBoolSigAction(146, dev.Pause); - triList.SetBoolSigAction(147, dev.Stop); - triList.SetBoolSigAction(148, dev.ChapPlus); - triList.SetBoolSigAction(149, dev.ChapMinus); - triList.SetBoolSigAction(150, dev.Rewind); - triList.SetBoolSigAction(151, dev.FFwd); - triList.SetBoolSigAction(154, dev.Record); - } - - public static void UnlinkButtons(this ITransport dev, BasicTriList triList) - { - triList.ClearBoolSigAction(145); - triList.ClearBoolSigAction(146); - triList.ClearBoolSigAction(147); - triList.ClearBoolSigAction(148); - triList.ClearBoolSigAction(149); - triList.ClearBoolSigAction(150); - triList.ClearBoolSigAction(151); - triList.ClearBoolSigAction(154); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransportExtensions.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransportExtensions.cs new file mode 100644 index 00000000..e15733cd --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ITransportExtensions.cs @@ -0,0 +1,38 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class ITransportExtensions + { + /// + /// Attaches to trilist joins: Play:145, Pause:146, Stop:147, ChapPlus:148, ChapMinus:149, Rewind:150, Ffwd:151, Record:154 + /// + /// + public static void LinkButtons(this ITransport dev, BasicTriList triList) + { + triList.SetBoolSigAction(145, dev.Play); + triList.SetBoolSigAction(146, dev.Pause); + triList.SetBoolSigAction(147, dev.Stop); + triList.SetBoolSigAction(148, dev.ChapPlus); + triList.SetBoolSigAction(149, dev.ChapMinus); + triList.SetBoolSigAction(150, dev.Rewind); + triList.SetBoolSigAction(151, dev.FFwd); + triList.SetBoolSigAction(154, dev.Record); + } + + public static void UnlinkButtons(this ITransport dev, BasicTriList triList) + { + triList.ClearBoolSigAction(145); + triList.ClearBoolSigAction(146); + triList.ClearBoolSigAction(147); + triList.ClearBoolSigAction(148); + triList.ClearBoolSigAction(149); + triList.ClearBoolSigAction(150); + triList.ClearBoolSigAction(151); + triList.ClearBoolSigAction(154); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/PasswordPromptEventArgs.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/PasswordPromptEventArgs.cs new file mode 100644 index 00000000..0364b090 --- /dev/null +++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/PasswordPromptEventArgs.cs @@ -0,0 +1,35 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + public class PasswordPromptEventArgs : EventArgs + { + /// + /// Indicates if the last submitted password was incorrect + /// + public bool LastAttemptWasIncorrect { get; private set; } + + /// + /// Indicates that the login attempt has failed + /// + public bool LoginAttemptFailed { get; private set; } + + /// + /// Indicates that the process was cancelled and the prompt should be dismissed + /// + public bool LoginAttemptCancelled { get; private set; } + + /// + /// A message to be displayed to the user + /// + public string Message { get; private set; } + + public PasswordPromptEventArgs(bool lastAttemptIncorrect, bool loginFailed, bool loginCancelled, string message) + { + LastAttemptWasIncorrect = lastAttemptIncorrect; + LoginAttemptFailed = loginFailed; + LoginAttemptCancelled = loginCancelled; + Message = message; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ApiAttribute.cs b/src/PepperDash.Essentials.Core/Devices/ApiAttribute.cs new file mode 100644 index 00000000..eefa13e8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/ApiAttribute.cs @@ -0,0 +1,11 @@ +using System; +using Crestron.SimplSharp.Reflection; + +namespace PepperDash.Essentials.Core +{ + [AttributeUsage(AttributeTargets.All)] + public class ApiAttribute : CAttribute + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/AudioInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/AudioChangeEventArgs.cs similarity index 85% rename from src/PepperDash.Essentials.Core/Devices/AudioInterfaces.cs rename to src/PepperDash.Essentials.Core/Devices/AudioChangeEventArgs.cs index 90aa4909..7efaa71c 100644 --- a/src/PepperDash.Essentials.Core/Devices/AudioInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/AudioChangeEventArgs.cs @@ -8,13 +8,7 @@ using Crestron.SimplSharpPro.DeviceSupport; namespace PepperDash.Essentials.Core { - - public enum AudioChangeType - { - Mute, Volume - } - - public class AudioChangeEventArgs + public class AudioChangeEventArgs { public AudioChangeType ChangeType { get; private set; } public IBasicVolumeControls AudioDevice { get; private set; } diff --git a/src/PepperDash.Essentials.Core/Devices/AudioChangeType.cs b/src/PepperDash.Essentials.Core/Devices/AudioChangeType.cs new file mode 100644 index 00000000..28b54d63 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/AudioChangeType.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Core +{ + public enum AudioChangeType + { + Mute, Volume + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ChangeType.cs b/src/PepperDash.Essentials.Core/Devices/ChangeType.cs new file mode 100644 index 00000000..6f1b7eb9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/ChangeType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public enum ChangeType + { + WillChange, DidChange + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/CodecInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/CodecInterfaces.cs deleted file mode 100644 index afb1da17..00000000 --- a/src/PepperDash.Essentials.Core/Devices/CodecInterfaces.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - /// - /// Adds control of codec receive volume - /// - public interface IReceiveVolume - { - // Break this out into 3 interfaces - void SetReceiveVolume(ushort level); - void ReceiveMuteOn(); - void ReceiveMuteOff(); - void ReceiveMuteToggle(); - IntFeedback ReceiveLevelFeedback { get; } - BoolFeedback ReceiveMuteIsOnFeedback { get; } - } - - /// - /// Adds control of codec transmit volume - /// - public interface ITransmitVolume - { - void SetTransmitVolume(ushort level); - void TransmitMuteOn(); - void TransmitMuteOff(); - void TransmitMuteToggle(); - IntFeedback TransmitLevelFeedback { get; } - BoolFeedback TransmitMuteIsOnFeedback { get; } - } - - /// - /// Adds control of codec privacy function (microphone mute) - /// - public interface IPrivacy - { - void PrivacyModeOn(); - void PrivacyModeOff(); - void PrivacyModeToggle(); - BoolFeedback PrivacyModeIsOnFeedback { get; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ConfigSnippetAttribute.cs b/src/PepperDash.Essentials.Core/Devices/ConfigSnippetAttribute.cs new file mode 100644 index 00000000..dde6ffd1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/ConfigSnippetAttribute.cs @@ -0,0 +1,21 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] + public class ConfigSnippetAttribute : Attribute + { + private string _ConfigSnippet; + + public ConfigSnippetAttribute(string configSnippet) + { + //Debug.Console(2, "Setting Config Snippet {0}", configSnippet); + _ConfigSnippet = configSnippet; + } + + public string ConfigSnippet + { + get { return _ConfigSnippet; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/DescriptionAttribute.cs b/src/PepperDash.Essentials.Core/Devices/DescriptionAttribute.cs new file mode 100644 index 00000000..14b85388 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/DescriptionAttribute.cs @@ -0,0 +1,21 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] + public class DescriptionAttribute : Attribute + { + private string _Description; + + public DescriptionAttribute(string description) + { + //Debug.Console(2, "Setting Description: {0}", description); + _Description = description; + } + + public string Description + { + get { return _Description; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceActionWrapper.cs b/src/PepperDash.Essentials.Core/Devices/DeviceActionWrapper.cs new file mode 100644 index 00000000..b6f46ab9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/DeviceActionWrapper.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + public class DeviceActionWrapper + { + public string DeviceKey { get; set; } + public string MethodName { get; set; } + public object[] Params { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs b/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs index dafda2a9..74b91dbd 100644 --- a/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs +++ b/src/PepperDash.Essentials.Core/Devices/DeviceJsonApi.cs @@ -295,77 +295,5 @@ namespace PepperDash.Essentials.Core } - } - - public class DeviceActionWrapper - { - public string DeviceKey { get; set; } - public string MethodName { get; set; } - public object[] Params { get; set; } - } - - public class PropertyNameType - { - object Parent; - - [JsonIgnore] - public PropertyInfo PropInfo { get; private set; } - public string Name { get { return PropInfo.Name; } } - public string Type { get { return PropInfo.PropertyType.Name; } } - public string Value { get - { - if (PropInfo.CanRead) - { - try - { - return PropInfo.GetValue(Parent, null).ToString(); - } - catch (Exception) - { - return null; - } - } - else - return null; - } } - - public bool CanRead { get { return PropInfo.CanRead; } } - public bool CanWrite { get { return PropInfo.CanWrite; } } - - - public PropertyNameType(PropertyInfo info, object parent) - { - PropInfo = info; - Parent = parent; - } - } - - public class MethodNameParams - { - [JsonIgnore] - public MethodInfo MethodInfo { get; private set; } - - public string Name { get { return MethodInfo.Name; } } - public IEnumerable Params { get { - return MethodInfo.GetParameters().Select(p => - new NameType { Name = p.Name, Type = p.ParameterType.Name }); - } } - - public MethodNameParams(MethodInfo info) - { - MethodInfo = info; - } - } - - public class NameType - { - public string Name { get; set; } - public string Type { get; set; } - } - - [AttributeUsage(AttributeTargets.All)] - public class ApiAttribute : CAttribute - { - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceUsageEventArgs.cs b/src/PepperDash.Essentials.Core/Devices/DeviceUsageEventArgs.cs new file mode 100644 index 00000000..2b0b5cd4 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/DeviceUsageEventArgs.cs @@ -0,0 +1,10 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + public class DeviceUsageEventArgs : EventArgs + { + public DateTime UsageEndTime { get; set; } + public int MinutesUsed { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs index bc8af721..b79d0d45 100644 --- a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs @@ -1,12 +1,10 @@ using System; -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; namespace PepperDash.Essentials.Core { @@ -49,97 +47,4 @@ namespace PepperDash.Essentials.Core }); } } - - [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] - public class DescriptionAttribute : Attribute - { - private string _Description; - - public DescriptionAttribute(string description) - { - //Debug.Console(2, "Setting Description: {0}", description); - _Description = description; - } - - public string Description - { - get { return _Description; } - } - } - - [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] - public class ConfigSnippetAttribute : Attribute - { - private string _ConfigSnippet; - - public ConfigSnippetAttribute(string configSnippet) - { - //Debug.Console(2, "Setting Config Snippet {0}", configSnippet); - _ConfigSnippet = configSnippet; - } - - public string ConfigSnippet - { - get { return _ConfigSnippet; } - } - } - - /// - /// Devices the basic needs for a Device Factory - /// - public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice - { - #region IDeviceFactory Members - - /// - /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device - /// - public List TypeNames { get; protected set; } - - /// - /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list - /// - public void LoadTypeFactories() - { - foreach (var typeName in TypeNames) - { - //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); - var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; - string description = descriptionAttribute[0].Description; - var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; - DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); - } - } - - /// - /// The method that will build the device - /// - /// The device config - /// An instance of the device - public abstract EssentialsDevice BuildDevice(DeviceConfig dc); - - #endregion - } - - /// - /// Devices the basic needs for a Device Factory - /// - public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice - { - /// - /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") - /// - public string MinimumEssentialsFrameworkVersion { get; protected set; } - } - - public abstract class EssentialsPluginDevelopmentDeviceFactory : EssentialsDeviceFactory, IPluginDevelopmentDeviceFactory where T : EssentialsDevice - { - /// - /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") - /// - public string MinimumEssentialsFrameworkVersion { get; protected set; } - - public List DevelopmentEssentialsFrameworkVersions { get; protected set; } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsDeviceFactory.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsDeviceFactory.cs new file mode 100644 index 00000000..89e5169f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsDeviceFactory.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsDeviceFactory : IDeviceFactory where T:EssentialsDevice + { + #region IDeviceFactory Members + + /// + /// A list of strings that can be used in the type property of a DeviceConfig object to build an instance of this device + /// + public List TypeNames { get; protected set; } + + /// + /// Loads an item to the DeviceFactory.FactoryMethods dictionary for each entry in the TypeNames list + /// + public void LoadTypeFactories() + { + foreach (var typeName in TypeNames) + { + //Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); + var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; + string description = descriptionAttribute[0].Description; + var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[]; + DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); + } + } + + /// + /// The method that will build the device + /// + /// The device config + /// An instance of the device + public abstract EssentialsDevice BuildDevice(DeviceConfig dc); + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDevelopmentDeviceFactory.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDevelopmentDeviceFactory.cs new file mode 100644 index 00000000..bb5281c6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDevelopmentDeviceFactory.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public abstract class EssentialsPluginDevelopmentDeviceFactory : EssentialsDeviceFactory, IPluginDevelopmentDeviceFactory where T : EssentialsDevice + { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// + public string MinimumEssentialsFrameworkVersion { get; protected set; } + + public List DevelopmentEssentialsFrameworkVersions { get; protected set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDeviceFactory.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDeviceFactory.cs new file mode 100644 index 00000000..d74bda2f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/EssentialsPluginDeviceFactory.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Devices the basic needs for a Device Factory + /// + public abstract class EssentialsPluginDeviceFactory : EssentialsDeviceFactory, IPluginDeviceFactory where T : EssentialsDevice + { + /// + /// Specifies the minimum version of Essentials required for a plugin to run. Must use the format Major.Minor.Build (ex. "1.4.33") + /// + public string MinimumEssentialsFrameworkVersion { get; protected set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs b/src/PepperDash.Essentials.Core/Devices/GenericCommunicationMonitoredDevice.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Devices/GenericMonitoredTcpDevice.cs rename to src/PepperDash.Essentials.Core/Devices/GenericCommunicationMonitoredDevice.cs diff --git a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs index 3c35b686..889dead6 100644 --- a/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs +++ b/src/PepperDash.Essentials.Core/Devices/GenericIRController.cs @@ -1,13 +1,11 @@ extern alias Full; using System; -using System.Collections.Generic; using Crestron.SimplSharpPro.DeviceSupport; using Full.Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.Devices { @@ -110,31 +108,4 @@ namespace PepperDash.Essentials.Core.Devices _port.PressRelease(command, pressRelease); } } - - public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced - { - public GenericIrControllerJoinMap(uint joinStart) : base(joinStart) - { - } - } - - public class GenericIrControllerFactory : EssentialsDeviceFactory - { - public GenericIrControllerFactory() - { - TypeNames = new List {"genericIrController"}; - } - #region Overrides of EssentialsDeviceFactory - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic IR Controller Device"); - - var irPort = IRPortHelper.GetIrOutputPortController(dc); - - return new GenericIrController(dc.Key, dc.Name, irPort); - } - - #endregion - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/GenericIrControllerFactory.cs b/src/PepperDash.Essentials.Core/Devices/GenericIrControllerFactory.cs new file mode 100644 index 00000000..68ba7860 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/GenericIrControllerFactory.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Devices +{ + public class GenericIrControllerFactory : EssentialsDeviceFactory + { + public GenericIrControllerFactory() + { + TypeNames = new List {"genericIrController"}; + } + #region Overrides of EssentialsDeviceFactory + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic IR Controller Device"); + + var irPort = IRPortHelper.GetIrOutputPortController(dc); + + return new GenericIrController(dc.Key, dc.Name, irPort); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/GenericIrControllerJoinMap.cs b/src/PepperDash.Essentials.Core/Devices/GenericIrControllerJoinMap.cs new file mode 100644 index 00000000..3d86d32c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/GenericIrControllerJoinMap.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core.Devices +{ + public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced + { + public GenericIrControllerJoinMap(uint joinStart) : base(joinStart) + { + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IAttachVideoStatus.cs b/src/PepperDash.Essentials.Core/Devices/IAttachVideoStatus.cs new file mode 100644 index 00000000..32e8e32a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IAttachVideoStatus.cs @@ -0,0 +1,12 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Describes a device that can have a video sync providing device attached to it + /// + public interface IAttachVideoStatus : IKeyed + { + // Extension methods will depend on this + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IAudioZone.cs b/src/PepperDash.Essentials.Core/Devices/IAudioZone.cs new file mode 100644 index 00000000..5f0f785c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IAudioZone.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines minimum functionality for an audio zone + /// + public interface IAudioZone : IBasicVolumeWithFeedback + { + void SelectInput(ushort input); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IAudioZones.cs b/src/PepperDash.Essentials.Core/Devices/IAudioZones.cs new file mode 100644 index 00000000..d157b716 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IAudioZones.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + /// + /// Identifies a device that contains audio zones + /// + public interface IAudioZones : IRouting + { + Dictionary Zone { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IProjectorInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/IBasicVideoMute.cs similarity index 56% rename from src/PepperDash.Essentials.Core/Devices/IProjectorInterfaces.cs rename to src/PepperDash.Essentials.Core/Devices/IBasicVideoMute.cs index c0cb33ed..bcb45a65 100644 --- a/src/PepperDash.Essentials.Core/Devices/IProjectorInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/IBasicVideoMute.cs @@ -10,13 +10,4 @@ namespace PepperDash.Essentials.Core { void VideoMuteToggle(); } - - public interface IBasicVideoMuteWithFeedback : IBasicVideoMute - { - BoolFeedback VideoMuteIsOn { get; } - - void VideoMuteOn(); - void VideoMuteOff(); - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IBasicVideoMuteWithFeedback.cs b/src/PepperDash.Essentials.Core/Devices/IBasicVideoMuteWithFeedback.cs new file mode 100644 index 00000000..67dc21a7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IBasicVideoMuteWithFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core +{ + public interface IBasicVideoMuteWithFeedback : IBasicVideoMute + { + BoolFeedback VideoMuteIsOn { get; } + + void VideoMuteOn(); + void VideoMuteOff(); + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IBasicVolumeControls.cs b/src/PepperDash.Essentials.Core/Devices/IBasicVolumeControls.cs new file mode 100644 index 00000000..58dc3b9f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IBasicVolumeControls.cs @@ -0,0 +1,16 @@ +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines minimal volume and mute control methods + /// + public interface IBasicVolumeControls + { + void VolumeUp(bool pressRelease); + void VolumeDown(bool pressRelease); + void MuteToggle(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IBasicVolumeWithFeedback.cs b/src/PepperDash.Essentials.Core/Devices/IBasicVolumeWithFeedback.cs new file mode 100644 index 00000000..dc31378f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IBasicVolumeWithFeedback.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Adds feedback and direct volume level set to IBasicVolumeControls + /// + public interface IBasicVolumeWithFeedback : IBasicVolumeControls + { + BoolFeedback MuteFeedback { get; } + void MuteOn(); + void MuteOff(); + void SetVolume(ushort level); + IntFeedback VolumeLevelFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IDisplayUsage.cs b/src/PepperDash.Essentials.Core/Devices/IDisplayUsage.cs new file mode 100644 index 00000000..6384e789 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IDisplayUsage.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For display classes that can provide usage data + /// + public interface IDisplayUsage + { + IntFeedback LampHours { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs b/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs index 645339bb..10258bde 100644 --- a/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs +++ b/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs @@ -1,15 +1,5 @@ -using System.Collections.Generic; - -namespace PepperDash.Essentials.Core +namespace PepperDash.Essentials.Core { - public interface IHasDspPresets - { - List Presets { get; } - - void RecallPreset(IDspPreset preset); - - } - public interface IDspPreset { string Name { get; } diff --git a/src/PepperDash.Essentials.Core/Devices/IFullAudioSettings.cs b/src/PepperDash.Essentials.Core/Devices/IFullAudioSettings.cs new file mode 100644 index 00000000..0fc6111a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IFullAudioSettings.cs @@ -0,0 +1,41 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public interface IFullAudioSettings : IBasicVolumeWithFeedback + { + void SetBalance(ushort level); + void BalanceLeft(bool pressRelease); + void BalanceRight(bool pressRelease); + + void SetBass(ushort level); + void BassUp(bool pressRelease); + void BassDown(bool pressRelease); + + void SetTreble(ushort level); + void TrebleUp(bool pressRelease); + void TrebleDown(bool pressRelease); + + bool hasMaxVolume { get; } + void SetMaxVolume(ushort level); + void MaxVolumeUp(bool pressRelease); + void MaxVolumeDown(bool pressRelease); + + bool hasDefaultVolume { get; } + void SetDefaultVolume(ushort level); + void DefaultVolumeUp(bool pressRelease); + void DefaultVolumeDown(bool pressRelease); + + void LoudnessToggle(); + void MonoToggle(); + + BoolFeedback LoudnessFeedback { get; } + BoolFeedback MonoFeedback { get; } + IntFeedback BalanceFeedback { get; } + IntFeedback BassFeedback { get; } + IntFeedback TrebleFeedback { get; } + IntFeedback MaxVolumeFeedback { get; } + IntFeedback DefaultVolumeFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasControlledPowerOutlets.cs b/src/PepperDash.Essentials.Core/Devices/IHasControlledPowerOutlets.cs new file mode 100644 index 00000000..eb965cf1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasControlledPowerOutlets.cs @@ -0,0 +1,17 @@ +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash_Essentials_Core.Devices +{ + /// + /// Interface for any device that contains a collection of IHasPowerReboot Devices + /// + public interface IHasControlledPowerOutlets : IKeyName + { + /// + /// Collection of IPduOutlets + /// + ReadOnlyDictionary PduOutlets { get; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasCurrentVolumeControls.cs b/src/PepperDash.Essentials.Core/Devices/IHasCurrentVolumeControls.cs new file mode 100644 index 00000000..dbe266fd --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasCurrentVolumeControls.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// A class that implements this contains a reference to a current IBasicVolumeControls device. + /// The class may have multiple IBasicVolumeControls. + /// + public interface IHasCurrentVolumeControls + { + IBasicVolumeControls CurrentVolumeControls { get; } + event EventHandler CurrentVolumeDeviceChange; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasDspPresets.cs b/src/PepperDash.Essentials.Core/Devices/IHasDspPresets.cs new file mode 100644 index 00000000..e1e697f5 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasDspPresets.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public interface IHasDspPresets + { + List Presets { get; } + + void RecallPreset(IDspPreset preset); + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasFeedback.cs b/src/PepperDash.Essentials.Core/Devices/IHasFeedback.cs new file mode 100644 index 00000000..e755c7f4 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasFeedback.cs @@ -0,0 +1,14 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public interface IHasFeedback : IKeyed + { + /// + /// This method shall return a list of all Output objects on a device, + /// including all "aggregate" devices. + /// + FeedbackCollection Feedbacks { get; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs b/src/PepperDash.Essentials.Core/Devices/IHasFeedbackExtensions.cs similarity index 84% rename from src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs rename to src/PepperDash.Essentials.Core/Devices/IHasFeedbackExtensions.cs index cc5e1054..54209bab 100644 --- a/src/PepperDash.Essentials.Core/Devices/IHasFeedbacks.cs +++ b/src/PepperDash.Essentials.Core/Devices/IHasFeedbackExtensions.cs @@ -7,18 +7,7 @@ using PepperDash.Core; namespace PepperDash.Essentials.Core { - public interface IHasFeedback : IKeyed - { - /// - /// This method shall return a list of all Output objects on a device, - /// including all "aggregate" devices. - /// - FeedbackCollection Feedbacks { get; } - - } - - - public static class IHasFeedbackExtensions + public static class IHasFeedbackExtensions { public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates) { diff --git a/src/PepperDash.Essentials.Core/Devices/IHasMuteControl.cs b/src/PepperDash.Essentials.Core/Devices/IHasMuteControl.cs new file mode 100644 index 00000000..1e29be69 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasMuteControl.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines basic mute control methods + /// + public interface IHasMuteControl + { + void MuteToggle(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasMuteControlWithFeedback.cs b/src/PepperDash.Essentials.Core/Devices/IHasMuteControlWithFeedback.cs new file mode 100644 index 00000000..b8c9a456 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasMuteControlWithFeedback.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines mute control methods and properties with feedback + /// + public interface IHasMuteControlWithFeedback : IHasMuteControl + { + BoolFeedback MuteFeedback { get; } + void MuteOn(); + void MuteOff(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/IHasPowerCycle.cs similarity index 62% rename from src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs rename to src/PepperDash.Essentials.Core/Devices/IHasPowerCycle.cs index 0f3b3fbf..f5bec208 100644 --- a/src/PepperDash.Essentials.Core/Devices/PduInterfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/IHasPowerCycle.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -20,16 +19,4 @@ namespace PepperDash_Essentials_Core.Devices /// void PowerCycle(); } - - /// - /// Interface for any device that contains a collection of IHasPowerReboot Devices - /// - public interface IHasControlledPowerOutlets : IKeyName - { - /// - /// Collection of IPduOutlets - /// - ReadOnlyDictionary PduOutlets { get; } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasVolumeControl.cs b/src/PepperDash.Essentials.Core/Devices/IHasVolumeControl.cs new file mode 100644 index 00000000..7199ded8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasVolumeControl.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines basic volume control methods + /// + public interface IHasVolumeControl + { + void VolumeUp(bool pressRelease); + void VolumeDown(bool pressRelease); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasVolumeControlWithFeedback.cs b/src/PepperDash.Essentials.Core/Devices/IHasVolumeControlWithFeedback.cs new file mode 100644 index 00000000..1356785d --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasVolumeControlWithFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines volume control methods and properties with feedback + /// + public interface IHasVolumeControlWithFeedback : IHasVolumeControl + { + void SetVolume(ushort level); + IntFeedback VolumeLevelFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IHasVolumeDevice.cs b/src/PepperDash.Essentials.Core/Devices/IHasVolumeDevice.cs new file mode 100644 index 00000000..366a3c0e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IHasVolumeDevice.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// A class that implements this, contains a reference to an IBasicVolumeControls device. + /// For example, speakers attached to an audio zone. The speakers can provide reference + /// to their linked volume control. + /// + public interface IHasVolumeDevice + { + IBasicVolumeControls VolumeDevice { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IMakeModel.cs b/src/PepperDash.Essentials.Core/Devices/IMakeModel.cs new file mode 100644 index 00000000..bc39a1b7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IMakeModel.cs @@ -0,0 +1,10 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public interface IMakeModel : IKeyed + { + string DeviceMake { get; } + string DeviceModel { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/FIND HOMES Interfaces.cs b/src/PepperDash.Essentials.Core/Devices/IOnline.cs similarity index 59% rename from src/PepperDash.Essentials.Core/Devices/FIND HOMES Interfaces.cs rename to src/PepperDash.Essentials.Core/Devices/IOnline.cs index 318f5179..06ae4cff 100644 --- a/src/PepperDash.Essentials.Core/Devices/FIND HOMES Interfaces.cs +++ b/src/PepperDash.Essentials.Core/Devices/IOnline.cs @@ -6,8 +6,6 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; - namespace PepperDash.Essentials.Core { @@ -31,26 +29,4 @@ namespace PepperDash.Essentials.Core //{ // IComPorts ComPortsDevice { get; } //} - - /// - /// Describes a device that can have a video sync providing device attached to it - /// - public interface IAttachVideoStatus : IKeyed - { - // Extension methods will depend on this - } - - /// - /// For display classes that can provide usage data - /// - public interface IDisplayUsage - { - IntFeedback LampHours { get; } - } - - public interface IMakeModel : IKeyed - { - string DeviceMake { get; } - string DeviceModel { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IPrivacy.cs b/src/PepperDash.Essentials.Core/Devices/IPrivacy.cs new file mode 100644 index 00000000..81ad3a10 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IPrivacy.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Adds control of codec privacy function (microphone mute) + /// + public interface IPrivacy + { + void PrivacyModeOn(); + void PrivacyModeOff(); + void PrivacyModeToggle(); + BoolFeedback PrivacyModeIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IReceiveVolume.cs b/src/PepperDash.Essentials.Core/Devices/IReceiveVolume.cs new file mode 100644 index 00000000..bcbf063a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IReceiveVolume.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + /// + /// Adds control of codec receive volume + /// + public interface IReceiveVolume + { + // Break this out into 3 interfaces + void SetReceiveVolume(ushort level); + void ReceiveMuteOn(); + void ReceiveMuteOff(); + void ReceiveMuteToggle(); + IntFeedback ReceiveLevelFeedback { get; } + BoolFeedback ReceiveMuteIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ITransmitVolume.cs b/src/PepperDash.Essentials.Core/Devices/ITransmitVolume.cs new file mode 100644 index 00000000..1a890279 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/ITransmitVolume.cs @@ -0,0 +1,15 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Adds control of codec transmit volume + /// + public interface ITransmitVolume + { + void SetTransmitVolume(ushort level); + void TransmitMuteOn(); + void TransmitMuteOff(); + void TransmitMuteToggle(); + IntFeedback TransmitLevelFeedback { get; } + BoolFeedback TransmitMuteIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs b/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs index 05b59366..d83fd20e 100644 --- a/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs +++ b/src/PepperDash.Essentials.Core/Devices/IUsageTracking.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; -using PepperDash.Core; namespace PepperDash.Essentials.Core { @@ -19,86 +17,4 @@ namespace PepperDash.Essentials.Core // device.UsageTracker = new UsageTracking(); // } //} - - public class UsageTracking - { - public event EventHandler DeviceUsageEnded; - - public InUseTracking InUseTracker { get; protected set; } - - public bool UsageIsTracked { get; set; } - - public bool UsageTrackingStarted { get; protected set; } - public DateTime UsageStartTime { get; protected set; } - public DateTime UsageEndTime { get; protected set; } - - public Device Parent { get; private set; } - - public UsageTracking(Device parent) - { - Parent = parent; - - InUseTracker = new InUseTracking(); - - InUseTracker.InUseFeedback.OutputChange += InUseFeedback_OutputChange; //new EventHandler(); - } - - void InUseFeedback_OutputChange(object sender, EventArgs e) - { - if(InUseTracker.InUseFeedback.BoolValue) - { - StartDeviceUsage(); - } - else - { - EndDeviceUsage(); - } - } - - - /// - /// Stores the usage start time - /// - public void StartDeviceUsage() - { - UsageTrackingStarted = true; - UsageStartTime = DateTime.Now; - } - - /// - /// Calculates the difference between the usage start and end times, gets the total minutes used and fires an event to pass that info to a consumer - /// - public void EndDeviceUsage() - { - try - { - UsageTrackingStarted = false; - - UsageEndTime = DateTime.Now; - - if (UsageStartTime != null) - { - var timeUsed = UsageEndTime - UsageStartTime; - - var handler = DeviceUsageEnded; - - if (handler != null) - { - Debug.Console(1, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); - handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); - } - } - } - catch (Exception e) - { - Debug.Console(1, "Error ending device usage: {0}", e); - } - } - } - - public class DeviceUsageEventArgs : EventArgs - { - public DateTime UsageEndTime { get; set; } - public int MinutesUsed { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs b/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs deleted file mode 100644 index c8a5df39..00000000 --- a/src/PepperDash.Essentials.Core/Devices/IVolumeAndAudioInterfaces.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Core -{ - /// - /// Defines minimal volume and mute control methods - /// - public interface IBasicVolumeControls - { - void VolumeUp(bool pressRelease); - void VolumeDown(bool pressRelease); - void MuteToggle(); - } - - /// - /// Defines basic volume control methods - /// - public interface IHasVolumeControl - { - void VolumeUp(bool pressRelease); - void VolumeDown(bool pressRelease); - } - - /// - /// Defines volume control methods and properties with feedback - /// - public interface IHasVolumeControlWithFeedback : IHasVolumeControl - { - void SetVolume(ushort level); - IntFeedback VolumeLevelFeedback { get; } - } - - /// - /// Defines basic mute control methods - /// - public interface IHasMuteControl - { - void MuteToggle(); - } - - /// - /// Defines mute control methods and properties with feedback - /// - public interface IHasMuteControlWithFeedback : IHasMuteControl - { - BoolFeedback MuteFeedback { get; } - void MuteOn(); - void MuteOff(); - } - - /// - /// Adds feedback and direct volume level set to IBasicVolumeControls - /// - public interface IBasicVolumeWithFeedback : IBasicVolumeControls - { - BoolFeedback MuteFeedback { get; } - void MuteOn(); - void MuteOff(); - void SetVolume(ushort level); - IntFeedback VolumeLevelFeedback { get; } - } - - /// - /// A class that implements this contains a reference to a current IBasicVolumeControls device. - /// The class may have multiple IBasicVolumeControls. - /// - public interface IHasCurrentVolumeControls - { - IBasicVolumeControls CurrentVolumeControls { get; } - event EventHandler CurrentVolumeDeviceChange; - } - - - /// - /// - /// - public interface IFullAudioSettings : IBasicVolumeWithFeedback - { - void SetBalance(ushort level); - void BalanceLeft(bool pressRelease); - void BalanceRight(bool pressRelease); - - void SetBass(ushort level); - void BassUp(bool pressRelease); - void BassDown(bool pressRelease); - - void SetTreble(ushort level); - void TrebleUp(bool pressRelease); - void TrebleDown(bool pressRelease); - - bool hasMaxVolume { get; } - void SetMaxVolume(ushort level); - void MaxVolumeUp(bool pressRelease); - void MaxVolumeDown(bool pressRelease); - - bool hasDefaultVolume { get; } - void SetDefaultVolume(ushort level); - void DefaultVolumeUp(bool pressRelease); - void DefaultVolumeDown(bool pressRelease); - - void LoudnessToggle(); - void MonoToggle(); - - BoolFeedback LoudnessFeedback { get; } - BoolFeedback MonoFeedback { get; } - IntFeedback BalanceFeedback { get; } - IntFeedback BassFeedback { get; } - IntFeedback TrebleFeedback { get; } - IntFeedback MaxVolumeFeedback { get; } - IntFeedback DefaultVolumeFeedback { get; } - } - - /// - /// A class that implements this, contains a reference to an IBasicVolumeControls device. - /// For example, speakers attached to an audio zone. The speakers can provide reference - /// to their linked volume control. - /// - public interface IHasVolumeDevice - { - IBasicVolumeControls VolumeDevice { get; } - } - - /// - /// Identifies a device that contains audio zones - /// - public interface IAudioZones : IRouting - { - Dictionary Zone { get; } - } - - /// - /// Defines minimum functionality for an audio zone - /// - public interface IAudioZone : IBasicVolumeWithFeedback - { - void SelectInput(ushort input); - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/MethodNameParams.cs b/src/PepperDash.Essentials.Core/Devices/MethodNameParams.cs new file mode 100644 index 00000000..3ba823de --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/MethodNameParams.cs @@ -0,0 +1,25 @@ +extern alias Full; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp.Reflection; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + public class MethodNameParams + { + [JsonIgnore] + public MethodInfo MethodInfo { get; private set; } + + public string Name { get { return MethodInfo.Name; } } + public IEnumerable Params { get { + return MethodInfo.GetParameters().Select(p => + new NameType { Name = p.Name, Type = p.ParameterType.Name }); + } } + + public MethodNameParams(MethodInfo info) + { + MethodInfo = info; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/NameType.cs b/src/PepperDash.Essentials.Core/Devices/NameType.cs new file mode 100644 index 00000000..14beb894 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/NameType.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core +{ + public class NameType + { + public string Name { get; set; } + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs index 03e884f0..50e4a667 100644 --- a/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs +++ b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPc.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using Crestron.SimplSharpPro; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; -using PepperDash.Core; namespace PepperDash.Essentials.Core.Devices { @@ -64,19 +61,4 @@ namespace PepperDash.Essentials.Core.Devices #endregion } - - public class InRoomPcFactory : EssentialsDeviceFactory - { - public InRoomPcFactory() - { - TypeNames = new List() { "inroompc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new InRoomPc Device"); - return new InRoomPc(dc.Key, dc.Name); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PC/InRoomPcFactory.cs b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPcFactory.cs new file mode 100644 index 00000000..f9c47a81 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/PC/InRoomPcFactory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Devices +{ + public class InRoomPcFactory : EssentialsDeviceFactory + { + public InRoomPcFactory() + { + TypeNames = new List() { "inroompc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new InRoomPc Device"); + return new InRoomPc(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs b/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs index a2864d77..2434704f 100644 --- a/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs +++ b/src/PepperDash.Essentials.Core/Devices/PC/Laptop.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using Crestron.SimplSharpPro; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; -using PepperDash.Core; namespace PepperDash.Essentials.Core.Devices { @@ -64,18 +61,4 @@ namespace PepperDash.Essentials.Core.Devices #endregion } - - public class LaptopFactory : EssentialsDeviceFactory - { - public LaptopFactory() - { - TypeNames = new List() { "laptop" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Laptop Device"); - return new Core.Devices.Laptop(dc.Key, dc.Name); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PC/LaptopFactory.cs b/src/PepperDash.Essentials.Core/Devices/PC/LaptopFactory.cs new file mode 100644 index 00000000..cca7fab6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/PC/LaptopFactory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Devices +{ + public class LaptopFactory : EssentialsDeviceFactory + { + public LaptopFactory() + { + TypeNames = new List() { "laptop" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Laptop Device"); + return new Core.Devices.Laptop(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/PresentationDeviceType.cs b/src/PepperDash.Essentials.Core/Devices/PresentationSourceType.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Devices/PresentationDeviceType.cs rename to src/PepperDash.Essentials.Core/Devices/PresentationSourceType.cs diff --git a/src/PepperDash.Essentials.Core/Devices/PropertyNameType.cs b/src/PepperDash.Essentials.Core/Devices/PropertyNameType.cs new file mode 100644 index 00000000..18aa9e32 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/PropertyNameType.cs @@ -0,0 +1,43 @@ +extern alias Full; +using System; +using Crestron.SimplSharp.Reflection; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + public class PropertyNameType + { + object Parent; + + [JsonIgnore] + public PropertyInfo PropInfo { get; private set; } + public string Name { get { return PropInfo.Name; } } + public string Type { get { return PropInfo.PropertyType.Name; } } + public string Value { get + { + if (PropInfo.CanRead) + { + try + { + return PropInfo.GetValue(Parent, null).ToString(); + } + catch (Exception) + { + return null; + } + } + else + return null; + } } + + public bool CanRead { get { return PropInfo.CanRead; } } + public bool CanWrite { get { return PropInfo.CanWrite; } } + + + public PropertyNameType(PropertyInfo info, object parent) + { + PropInfo = info; + Parent = parent; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ReconfigurableBridgableDevice.cs b/src/PepperDash.Essentials.Core/Devices/ReconfigurableBridgableDevice.cs new file mode 100644 index 00000000..12ae0ede --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/ReconfigurableBridgableDevice.cs @@ -0,0 +1,15 @@ +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Devices +{ + public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced + { + protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config) + { + } + + public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/ReconfigurableDevice.cs b/src/PepperDash.Essentials.Core/Devices/ReconfigurableDevice.cs index 50bf90bd..b81858d3 100644 --- a/src/PepperDash.Essentials.Core/Devices/ReconfigurableDevice.cs +++ b/src/PepperDash.Essentials.Core/Devices/ReconfigurableDevice.cs @@ -5,9 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using Full.Newtonsoft.Json; using Full.Newtonsoft.Json.Linq; @@ -67,13 +65,4 @@ namespace PepperDash.Essentials.Core.Devices ConfigWriter.UpdateDeviceConfig(config); } } - - public abstract class ReconfigurableBridgableDevice : ReconfigurableDevice, IBridgeAdvanced - { - protected ReconfigurableBridgableDevice(DeviceConfig config) : base(config) - { - } - - public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge); - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/SmartObjectBaseTypes.cs b/src/PepperDash.Essentials.Core/Devices/SmartObjectJoinOffsets.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Devices/SmartObjectBaseTypes.cs rename to src/PepperDash.Essentials.Core/Devices/SmartObjectJoinOffsets.cs diff --git a/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs b/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs index 87c66e75..4373f74c 100644 --- a/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs +++ b/src/PepperDash.Essentials.Core/Devices/SourceListItem.cs @@ -13,15 +13,7 @@ using PepperDash.Core; namespace PepperDash.Essentials.Core { - /// - /// - /// - public enum eSourceListItemType - { - Route, Off, Other, SomethingAwesomerThanThese - } - - /// + /// /// Represents an item in a source list - can be deserialized into. /// public class SourceListItem @@ -151,28 +143,4 @@ namespace PepperDash.Essentials.Core } - - public class SourceRouteListItem - { - [JsonProperty("sourceKey")] - public string SourceKey { get; set; } - - [JsonProperty("destinationKey")] - public string DestinationKey { get; set; } - - [JsonProperty("type")] - public eRoutingSignalType Type { get; set; } - } - - /// - /// Defines the valid destination types for SourceListItems in a room - /// - public enum eSourceListItemDestinationTypes - { - defaultDisplay, - leftDisplay, - rightDisplay, - programAudio, - codecContent - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/SourceRouteListItem.cs b/src/PepperDash.Essentials.Core/Devices/SourceRouteListItem.cs new file mode 100644 index 00000000..40233b97 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/SourceRouteListItem.cs @@ -0,0 +1,17 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + public class SourceRouteListItem + { + [JsonProperty("sourceKey")] + public string SourceKey { get; set; } + + [JsonProperty("destinationKey")] + public string DestinationKey { get; set; } + + [JsonProperty("type")] + public eRoutingSignalType Type { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/UsageTracking.cs b/src/PepperDash.Essentials.Core/Devices/UsageTracking.cs new file mode 100644 index 00000000..e0699186 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/UsageTracking.cs @@ -0,0 +1,81 @@ +using System; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public class UsageTracking + { + public event EventHandler DeviceUsageEnded; + + public InUseTracking InUseTracker { get; protected set; } + + public bool UsageIsTracked { get; set; } + + public bool UsageTrackingStarted { get; protected set; } + public DateTime UsageStartTime { get; protected set; } + public DateTime UsageEndTime { get; protected set; } + + public Device Parent { get; private set; } + + public UsageTracking(Device parent) + { + Parent = parent; + + InUseTracker = new InUseTracking(); + + InUseTracker.InUseFeedback.OutputChange += InUseFeedback_OutputChange; //new EventHandler(); + } + + void InUseFeedback_OutputChange(object sender, EventArgs e) + { + if(InUseTracker.InUseFeedback.BoolValue) + { + StartDeviceUsage(); + } + else + { + EndDeviceUsage(); + } + } + + + /// + /// Stores the usage start time + /// + public void StartDeviceUsage() + { + UsageTrackingStarted = true; + UsageStartTime = DateTime.Now; + } + + /// + /// Calculates the difference between the usage start and end times, gets the total minutes used and fires an event to pass that info to a consumer + /// + public void EndDeviceUsage() + { + try + { + UsageTrackingStarted = false; + + UsageEndTime = DateTime.Now; + + if (UsageStartTime != null) + { + var timeUsed = UsageEndTime - UsageStartTime; + + var handler = DeviceUsageEnded; + + if (handler != null) + { + Debug.Console(1, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); + handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); + } + } + } + catch (Exception e) + { + Debug.Console(1, "Error ending device usage: {0}", e); + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/VolumeDeviceChangeEventArgs.cs b/src/PepperDash.Essentials.Core/Devices/VolumeDeviceChangeEventArgs.cs index 2171cb73..f4889956 100644 --- a/src/PepperDash.Essentials.Core/Devices/VolumeDeviceChangeEventArgs.cs +++ b/src/PepperDash.Essentials.Core/Devices/VolumeDeviceChangeEventArgs.cs @@ -25,12 +25,4 @@ namespace PepperDash.Essentials.Core Type = type; } } - - /// - /// - /// - public enum ChangeType - { - WillChange, DidChange - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/eSourceListItemDestinationTypes.cs b/src/PepperDash.Essentials.Core/Devices/eSourceListItemDestinationTypes.cs new file mode 100644 index 00000000..c3c4ee28 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/eSourceListItemDestinationTypes.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines the valid destination types for SourceListItems in a room + /// + public enum eSourceListItemDestinationTypes + { + defaultDisplay, + leftDisplay, + rightDisplay, + programAudio, + codecContent + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/eSourceListItemType.cs b/src/PepperDash.Essentials.Core/Devices/eSourceListItemType.cs new file mode 100644 index 00000000..a4f10c65 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/eSourceListItemType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public enum eSourceListItemType + { + Route, Off, Other, SomethingAwesomerThanThese + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs b/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs index 7a8eb8b1..570d1f0b 100644 --- a/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs +++ b/src/PepperDash.Essentials.Core/Display/BasicIrDisplay.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -8,7 +7,6 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; @@ -216,27 +214,4 @@ namespace PepperDash.Essentials.Core LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); } } - - public class BasicIrDisplayFactory : EssentialsDeviceFactory - { - public BasicIrDisplayFactory() - { - TypeNames = new List() { "basicirdisplay" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); - var ir = IRPortHelper.GetIrPort(dc.Properties); - if (ir != null) - { - var display = new BasicIrDisplay(dc.Key, dc.Name, ir.Port, ir.FileName); - display.IrPulseTime = 200; // Set default pulse time for IR commands. - return display; - } - - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/BasicIrDisplayFactory.cs b/src/PepperDash.Essentials.Core/Display/BasicIrDisplayFactory.cs new file mode 100644 index 00000000..8035798e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Display/BasicIrDisplayFactory.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class BasicIrDisplayFactory : EssentialsDeviceFactory + { + public BasicIrDisplayFactory() + { + TypeNames = new List() { "basicirdisplay" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new BasicIrDisplay Device"); + var ir = IRPortHelper.GetIrPort(dc.Properties); + if (ir != null) + { + var display = new BasicIrDisplay(dc.Key, dc.Name, ir.Port, ir.FileName); + display.IrPulseTime = 200; // Set default pulse time for IR commands. + return display; + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/DisplayBase.cs b/src/PepperDash.Essentials.Core/Display/DisplayBase.cs index a8de2796..d133bada 100644 --- a/src/PepperDash.Essentials.Core/Display/DisplayBase.cs +++ b/src/PepperDash.Essentials.Core/Display/DisplayBase.cs @@ -259,70 +259,4 @@ namespace PepperDash.Essentials.Core } } - - /// - /// - /// - public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback - { - public StringFeedback CurrentInputFeedback { get; private set; } - - abstract protected Func CurrentInputFeedbackFunc { get; } - - public override BoolFeedback PowerIsOnFeedback { get; protected set; } - - abstract protected Func PowerIsOnFeedbackFunc { get; } - - - public static MockDisplay DefaultDisplay - { - get - { - if (_DefaultDisplay == null) - _DefaultDisplay = new MockDisplay("default", "Default Display"); - return _DefaultDisplay; - } - } - static MockDisplay _DefaultDisplay; - - public TwoWayDisplayBase(string key, string name) - : base(key, name) - { - CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); - - WarmupTime = 7000; - CooldownTime = 15000; - - PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); - - Feedbacks.Add(CurrentInputFeedback); - Feedbacks.Add(PowerIsOnFeedback); - - PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; - - } - - void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) - { - if (UsageTracker != null) - { - if (PowerIsOnFeedback.BoolValue) - UsageTracker.StartDeviceUsage(); - else - UsageTracker.EndDeviceUsage(); - } - } - - public event EventHandler NumericSwitchChange; - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType - protected void OnSwitchChange(RoutingNumericEventArgs e) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/MockDisplay.cs b/src/PepperDash.Essentials.Core/Display/MockDisplay.cs index d7f36f13..d56ec571 100644 --- a/src/PepperDash.Essentials.Core/Display/MockDisplay.cs +++ b/src/PepperDash.Essentials.Core/Display/MockDisplay.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -12,7 +11,6 @@ using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { @@ -219,19 +217,4 @@ namespace PepperDash.Essentials.Core LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge); } } - - public class MockDisplayFactory : EssentialsDeviceFactory - { - public MockDisplayFactory() - { - TypeNames = new List() { "mockdisplay" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Mock Display Device"); - return new MockDisplay(dc.Key, dc.Name); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/MockDisplayFactory.cs b/src/PepperDash.Essentials.Core/Display/MockDisplayFactory.cs new file mode 100644 index 00000000..4fca7661 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Display/MockDisplayFactory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class MockDisplayFactory : EssentialsDeviceFactory + { + public MockDisplayFactory() + { + TypeNames = new List() { "mockdisplay" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Mock Display Device"); + return new MockDisplay(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Display/TwoWayDisplayBase.cs b/src/PepperDash.Essentials.Core/Display/TwoWayDisplayBase.cs new file mode 100644 index 00000000..b8f3bbe1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Display/TwoWayDisplayBase.cs @@ -0,0 +1,70 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback + { + public StringFeedback CurrentInputFeedback { get; private set; } + + abstract protected Func CurrentInputFeedbackFunc { get; } + + public override BoolFeedback PowerIsOnFeedback { get; protected set; } + + abstract protected Func PowerIsOnFeedbackFunc { get; } + + + public static MockDisplay DefaultDisplay + { + get + { + if (_DefaultDisplay == null) + _DefaultDisplay = new MockDisplay("default", "Default Display"); + return _DefaultDisplay; + } + } + static MockDisplay _DefaultDisplay; + + public TwoWayDisplayBase(string key, string name) + : base(key, name) + { + CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc); + + WarmupTime = 7000; + CooldownTime = 15000; + + PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc); + + Feedbacks.Add(CurrentInputFeedback); + Feedbacks.Add(PowerIsOnFeedback); + + PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + + } + + void PowerIsOnFeedback_OutputChange(object sender, EventArgs e) + { + if (UsageTracker != null) + { + if (PowerIsOnFeedback.BoolValue) + UsageTracker.StartDeviceUsage(); + else + UsageTracker.EndDeviceUsage(); + } + } + + public event EventHandler NumericSwitchChange; + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType + protected void OnSwitchChange(RoutingNumericEventArgs e) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, e); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Ethernet/EthernetStatistics.cs b/src/PepperDash.Essentials.Core/Ethernet/EthernetSettings.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Ethernet/EthernetStatistics.cs rename to src/PepperDash.Essentials.Core/Ethernet/EthernetSettings.cs diff --git a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs index d53aef19..7d0aae73 100644 --- a/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Factory/DeviceFactory.cs @@ -18,19 +18,6 @@ using PepperDash.Essentials.Core.Touchpanels; namespace PepperDash.Essentials.Core { - public class DeviceFactoryWrapper - { - public CType CType { get; set; } - public string Description { get; set; } - public Func FactoryMethod { get; set; } - - public DeviceFactoryWrapper() - { - CType = null; - Description = "Not Available"; - } - } - public class DeviceFactory { public DeviceFactory() diff --git a/src/PepperDash.Essentials.Core/Factory/DeviceFactoryWrapper.cs b/src/PepperDash.Essentials.Core/Factory/DeviceFactoryWrapper.cs new file mode 100644 index 00000000..81d8cf9f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Factory/DeviceFactoryWrapper.cs @@ -0,0 +1,20 @@ +using System; +using Crestron.SimplSharp.Reflection; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class DeviceFactoryWrapper + { + public CType CType { get; set; } + public string Description { get; set; } + public Func FactoryMethod { get; set; } + + public DeviceFactoryWrapper() + { + CType = null; + Description = "Not Available"; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Factory/IHasReady.cs b/src/PepperDash.Essentials.Core/Factory/IHasReady.cs new file mode 100644 index 00000000..1431262d --- /dev/null +++ b/src/PepperDash.Essentials.Core/Factory/IHasReady.cs @@ -0,0 +1,10 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + public interface IHasReady + { + event EventHandler IsReadyEvent; + bool IsReady { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Factory/IsReadyEventArgs.cs b/src/PepperDash.Essentials.Core/Factory/IsReadyEventArgs.cs new file mode 100644 index 00000000..66729726 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Factory/IsReadyEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + public class IsReadyEventArgs : EventArgs + { + public bool IsReady { get; set; } + + public IsReadyEventArgs(bool data) + { + IsReady = data; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Factory/ReadyEventArgs.cs b/src/PepperDash.Essentials.Core/Factory/ReadyEventArgs.cs index be8369d2..6066563b 100644 --- a/src/PepperDash.Essentials.Core/Factory/ReadyEventArgs.cs +++ b/src/PepperDash.Essentials.Core/Factory/ReadyEventArgs.cs @@ -7,21 +7,6 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core { - public class IsReadyEventArgs : EventArgs - { - public bool IsReady { get; set; } - - public IsReadyEventArgs(bool data) - { - IsReady = data; - } - } - - public interface IHasReady - { - event EventHandler IsReadyEvent; - bool IsReady { get; } - } } namespace PepperDash_Essentials_Core diff --git a/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackAnd.cs b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackAnd.cs new file mode 100644 index 00000000..a7f5b668 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackAnd.cs @@ -0,0 +1,19 @@ +using System.Linq; + +namespace PepperDash.Essentials.Core +{ + public class BoolFeedbackAnd : BoolFeedbackLogic + { + protected override void Evaluate() + { + var prevValue = ComputedValue; + var newValue = OutputsIn.All(o => o.BoolValue); + if (newValue == prevValue) + { + return; + } + ComputedValue = newValue; + Output.FireUpdate(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLinq.cs b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLinq.cs new file mode 100644 index 00000000..305050c3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLinq.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public class BoolFeedbackLinq : BoolFeedbackLogic + { + readonly Func, bool> _predicate; + + public BoolFeedbackLinq(Func, bool> predicate) + : base() + { + _predicate = predicate; + } + + protected override void Evaluate() + { + var prevValue = ComputedValue; + var newValue = _predicate(OutputsIn); + if (newValue == prevValue) + { + return; + } + ComputedValue = newValue; + Output.FireUpdate(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Feedbacks/BoolOutputLogicals.cs b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLogic.cs similarity index 61% rename from src/PepperDash.Essentials.Core/Feedbacks/BoolOutputLogicals.cs rename to src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLogic.cs index a8dae7b8..1080ad7c 100644 --- a/src/PepperDash.Essentials.Core/Feedbacks/BoolOutputLogicals.cs +++ b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackLogic.cs @@ -81,57 +81,4 @@ namespace PepperDash.Essentials.Core protected abstract void Evaluate(); } - - public class BoolFeedbackAnd : BoolFeedbackLogic - { - protected override void Evaluate() - { - var prevValue = ComputedValue; - var newValue = OutputsIn.All(o => o.BoolValue); - if (newValue == prevValue) - { - return; - } - ComputedValue = newValue; - Output.FireUpdate(); - } - } - - public class BoolFeedbackOr : BoolFeedbackLogic - { - protected override void Evaluate() - { - var prevValue = ComputedValue; - var newValue = OutputsIn.Any(o => o.BoolValue); - if (newValue == prevValue) - { - return; - } - ComputedValue = newValue; - Output.FireUpdate(); - } - } - - public class BoolFeedbackLinq : BoolFeedbackLogic - { - readonly Func, bool> _predicate; - - public BoolFeedbackLinq(Func, bool> predicate) - : base() - { - _predicate = predicate; - } - - protected override void Evaluate() - { - var prevValue = ComputedValue; - var newValue = _predicate(OutputsIn); - if (newValue == prevValue) - { - return; - } - ComputedValue = newValue; - Output.FireUpdate(); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackOr.cs b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackOr.cs new file mode 100644 index 00000000..71fdddc6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackOr.cs @@ -0,0 +1,19 @@ +using System.Linq; + +namespace PepperDash.Essentials.Core +{ + public class BoolFeedbackOr : BoolFeedbackLogic + { + protected override void Evaluate() + { + var prevValue = ComputedValue; + var newValue = OutputsIn.Any(o => o.BoolValue); + if (newValue == prevValue) + { + return; + } + ComputedValue = newValue; + Output.FireUpdate(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackOneShot.cs b/src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackPulse.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackOneShot.cs rename to src/PepperDash.Essentials.Core/Feedbacks/BoolFeedbackPulse.cs diff --git a/src/PepperDash.Essentials.Core/Feedbacks/FeedbackBase.cs b/src/PepperDash.Essentials.Core/Feedbacks/Feedback.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Feedbacks/FeedbackBase.cs rename to src/PepperDash.Essentials.Core/Feedbacks/Feedback.cs diff --git a/src/PepperDash.Essentials.Core/Feedbacks/FeedbackEventArgs.cs b/src/PepperDash.Essentials.Core/Feedbacks/FeedbackEventArgs.cs index 9a7f5c29..eae75c51 100644 --- a/src/PepperDash.Essentials.Core/Feedbacks/FeedbackEventArgs.cs +++ b/src/PepperDash.Essentials.Core/Feedbacks/FeedbackEventArgs.cs @@ -38,11 +38,4 @@ namespace PepperDash.Essentials.Core Type = eFeedbackEventType.TypeString; } } - - public enum eFeedbackEventType - { - TypeBool, - TypeInt, - TypeString - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Feedbacks/eFeedbackEventType.cs b/src/PepperDash.Essentials.Core/Feedbacks/eFeedbackEventType.cs new file mode 100644 index 00000000..ca9efeee --- /dev/null +++ b/src/PepperDash.Essentials.Core/Feedbacks/eFeedbackEventType.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + public enum eFeedbackEventType + { + TypeBool, + TypeInt, + TypeString + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/File/FileEventArgs.cs b/src/PepperDash.Essentials.Core/File/FileEventArgs.cs new file mode 100644 index 00000000..85be05ec --- /dev/null +++ b/src/PepperDash.Essentials.Core/File/FileEventArgs.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + public class FileEventArgs + { + public FileEventArgs(string data) { Data = data; } + public string Data { get; private set; } // readonly + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/File/FileIO.cs b/src/PepperDash.Essentials.Core/File/FileIO.cs index 51d64230..f17bad52 100644 --- a/src/PepperDash.Essentials.Core/File/FileIO.cs +++ b/src/PepperDash.Essentials.Core/File/FileIO.cs @@ -269,10 +269,4 @@ namespace PepperDash.Essentials.Core } } - public class FileEventArgs - { - public FileEventArgs(string data) { Data = data; } - public string Data { get; private set; } // readonly - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/ActionResponse.cs b/src/PepperDash.Essentials.Core/Fusion/ActionResponse.cs new file mode 100644 index 00000000..d9be4aaa --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/ActionResponse.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class ActionResponse + { + //[XmlElement(ElementName = "RequestID")] + public string RequestID { get; set; } + //[XmlElement(ElementName = "ActionID")] + public string ActionID { get; set; } + //[XmlElement(ElementName = "Parameters")] + public List Parameters { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Attendees.cs b/src/PepperDash.Essentials.Core/Fusion/Attendees.cs new file mode 100644 index 00000000..34ee6857 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Attendees.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class Attendees + { + //[XmlElement(ElementName = "Required")] + public Required Required { get; set; } + //[XmlElement(ElementName = "Optional")] + public Optional Optional { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index f3827d0a..f8113f9b 100644 --- a/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/src/PepperDash.Essentials.Core/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -1632,188 +1632,5 @@ namespace PepperDash.Essentials.Core.Fusion } - public static class FusionRoomExtensions - { - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static BooleanSigData CreateOffsetBoolSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.Bool, number, name, mask); - return fr.UserDefinedBooleanSigDetails[number]; - } - - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static UShortSigData CreateOffsetUshortSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.UShort, number, name, mask); - return fr.UserDefinedUShortSigDetails[number]; - } - - /// - /// Creates and returns a fusion attribute. The join number will match the established Simpl - /// standard of 50+, and will generate a 50+ join in the RVI. It calls - /// FusionRoom.AddSig with join number - 49 - /// - /// The new attribute - public static StringSigData CreateOffsetStringSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) - { - if (number < 50) - { - throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); - } - number -= 49; - fr.AddSig(eSigType.String, number, name, mask); - return fr.UserDefinedStringSigDetails[number]; - } - - /// - /// Creates and returns a static asset - /// - /// the new asset - public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, - string instanceId) - { - try - { - Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); - - fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; - } - catch (InvalidOperationException ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); - return null; - } - catch (Exception e) - { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); - return null; - } - } - - public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, - string type, string instanceId) - { - try - { - Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, - instanceId); - - fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); - return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; - } - catch (InvalidOperationException ex) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); - return null; - } - catch (Exception e) - { - Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); - return null; - } - } - } - //************************************************************************************************ - /// - /// Extensions to enhance Fusion room, asset and signal creation. - /// - public static class FusionStaticAssetExtensions - { - /// - /// Tries to set a Fusion asset with the make and model of a device. - /// If the provided Device is IMakeModel, will set the corresponding parameters on the fusion static asset. - /// Otherwise, does nothing. - /// - public static void TrySetMakeModel(this FusionStaticAsset asset, Device device) - { - var mm = device as IMakeModel; - if (mm != null) - { - asset.ParamMake.Value = mm.DeviceMake; - asset.ParamModel.Value = mm.DeviceModel; - } - } - - /// - /// Tries to attach the AssetError input on a Fusion asset to a Device's - /// CommunicationMonitor.StatusChange event. Does nothing if the device is not - /// IStatusMonitor - /// - /// - /// - public static void TryLinkAssetErrorToCommunication(this FusionStaticAsset asset, Device device) - { - if (device is ICommunicationMonitor) - { - var monitor = (device as ICommunicationMonitor).CommunicationMonitor; - monitor.StatusChange += (o, a) => - { - // Link connected and error inputs on asset - asset.Connected.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; - asset.AssetError.InputSig.StringValue = a.Status.ToString(); - }; - // set current value - asset.Connected.InputSig.BoolValue = monitor.Status == MonitorStatus.IsOk; - asset.AssetError.InputSig.StringValue = monitor.Status.ToString(); - } - } - } - - public class RoomInformation - { - public RoomInformation() - { - FusionCustomProperties = new List(); - } - - public string ID { get; set; } - public string Name { get; set; } - public string Location { get; set; } - public string Description { get; set; } - public string TimeZone { get; set; } - public string WebcamURL { get; set; } - public string BacklogMsg { get; set; } - public string SubErrorMsg { get; set; } - public string EmailInfo { get; set; } - public List FusionCustomProperties { get; set; } - } - - public class FusionCustomProperty - { - public FusionCustomProperty() - { - } - - public FusionCustomProperty(string id) - { - ID = id; - } - - public string ID { get; set; } - public string CustomFieldName { get; set; } - public string CustomFieldType { get; set; } - public string CustomFieldValue { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Event.cs b/src/PepperDash.Essentials.Core/Fusion/Event.cs new file mode 100644 index 00000000..7b7e5472 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Event.cs @@ -0,0 +1,139 @@ +using System; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class Event + { + //[XmlElement(ElementName = "MeetingID")] + public string MeetingID { get; set; } + //[XmlElement(ElementName = "RVMeetingID")] + public string RVMeetingID { get; set; } + //[XmlElement(ElementName = "Recurring")] + public string Recurring { get; set; } + //[XmlElement(ElementName = "InstanceID")] + public string InstanceID { get; set; } + //[XmlElement(ElementName = "dtStart")] + public DateTime dtStart { get; set; } + //[XmlElement(ElementName = "dtEnd")] + public DateTime dtEnd { get; set; } + //[XmlElement(ElementName = "Organizer")] + public string Organizer { get; set; } + //[XmlElement(ElementName = "Attendees")] + public Attendees Attendees { get; set; } + //[XmlElement(ElementName = "Resources")] + public Resources Resources { get; set; } + //[XmlElement(ElementName = "IsEvent")] + public string IsEvent { get; set; } + //[XmlElement(ElementName = "IsRoomViewMeeting")] + public string IsRoomViewMeeting { get; set; } + //[XmlElement(ElementName = "IsPrivate")] + public string IsPrivate { get; set; } + //[XmlElement(ElementName = "IsExchangePrivate")] + public string IsExchangePrivate { get; set; } + //[XmlElement(ElementName = "MeetingTypes")] + public MeetingTypes MeetingTypes { get; set; } + //[XmlElement(ElementName = "ParticipantCode")] + public string ParticipantCode { get; set; } + //[XmlElement(ElementName = "PhoneNo")] + public string PhoneNo { get; set; } + //[XmlElement(ElementName = "WelcomeMsg")] + public string WelcomeMsg { get; set; } + //[XmlElement(ElementName = "Subject")] + public string Subject { get; set; } + //[XmlElement(ElementName = "LiveMeeting")] + public LiveMeeting LiveMeeting { get; set; } + //[XmlElement(ElementName = "ShareDocPath")] + public string ShareDocPath { get; set; } + //[XmlElement(ElementName = "HaveAttendees")] + public string HaveAttendees { get; set; } + //[XmlElement(ElementName = "HaveResources")] + public string HaveResources { get; set; } + + /// + /// Gets the duration of the meeting + /// + public string DurationInMinutes + { + get + { + string duration; + + var timeSpan = dtEnd.Subtract(dtStart); + int hours = timeSpan.Hours; + double minutes = timeSpan.Minutes; + double roundedMinutes = Math.Round(minutes); + if (hours > 0) + { + duration = string.Format("{0} hours {1} minutes", hours, roundedMinutes); + } + else + { + duration = string.Format("{0} minutes", roundedMinutes); + } + + return duration; + } + } + + /// + /// Gets the remaining time in the meeting. Returns null if the meeting is not currently in progress. + /// + public string RemainingTime + { + get + { + var now = DateTime.Now; + + string remainingTime; + + if (GetInProgress()) + { + var timeSpan = dtEnd.Subtract(now); + int hours = timeSpan.Hours; + double minutes = timeSpan.Minutes; + double roundedMinutes = Math.Round(minutes); + if (hours > 0) + { + remainingTime = string.Format("{0} hours {1} minutes", hours, roundedMinutes); + } + else + { + remainingTime = string.Format("{0} minutes", roundedMinutes); + } + + return remainingTime; + } + else + return null; + } + + } + + /// + /// Indicates that the meeting is in progress + /// + public bool isInProgress + { + get + { + return GetInProgress(); + } + } + + /// + /// Determines if the meeting is in progress + /// + /// Returns true if in progress + bool GetInProgress() + { + var now = DateTime.Now; + + if (now > dtStart && now < dtEnd) + { + return true; + } + else + return false; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionAsset.cs b/src/PepperDash.Essentials.Core/Fusion/FusionAsset.cs new file mode 100644 index 00000000..40bf1749 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionAsset.cs @@ -0,0 +1,32 @@ +using System; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class FusionAsset + { + public uint SlotNumber { get; set; } + public string Name { get; set; } + public string Type { get; set; } + public string InstanceId { get;set; } + + public FusionAsset() + { + + } + + public FusionAsset(uint slotNum, string assetName, string type, string instanceId) + { + SlotNumber = slotNum; + Name = assetName; + Type = type; + if (string.IsNullOrEmpty(instanceId)) + { + InstanceId = Guid.NewGuid().ToString(); + } + else + { + InstanceId = instanceId; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionCustomProperty.cs b/src/PepperDash.Essentials.Core/Fusion/FusionCustomProperty.cs new file mode 100644 index 00000000..5b6635f2 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionCustomProperty.cs @@ -0,0 +1,19 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class FusionCustomProperty + { + public FusionCustomProperty() + { + } + + public FusionCustomProperty(string id) + { + ID = id; + } + + public string ID { get; set; } + public string CustomFieldName { get; set; } + public string CustomFieldType { get; set; } + public string CustomFieldValue { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionOccupancySensorAsset.cs b/src/PepperDash.Essentials.Core/Fusion/FusionOccupancySensorAsset.cs new file mode 100644 index 00000000..93bd94ab --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionOccupancySensorAsset.cs @@ -0,0 +1,26 @@ +using System; +using Crestron.SimplSharpPro.Fusion; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class FusionOccupancySensorAsset + { + // SlotNumber fixed at 4 + + public uint SlotNumber { get { return 4; } } + public string Name { get { return "Occupancy Sensor"; } } + public eAssetType Type { get; set; } + public string InstanceId { get; set; } + + public FusionOccupancySensorAsset() + { + } + + public FusionOccupancySensorAsset(eAssetType type) + { + Type = type; + + InstanceId = Guid.NewGuid().ToString(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionRoomExtensions.cs b/src/PepperDash.Essentials.Core/Fusion/FusionRoomExtensions.cs new file mode 100644 index 00000000..db33ebdc --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionRoomExtensions.cs @@ -0,0 +1,110 @@ +using System; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.Fusion; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Fusion +{ + public static class FusionRoomExtensions + { + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static BooleanSigData CreateOffsetBoolSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.Bool, number, name, mask); + return fr.UserDefinedBooleanSigDetails[number]; + } + + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static UShortSigData CreateOffsetUshortSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.UShort, number, name, mask); + return fr.UserDefinedUShortSigDetails[number]; + } + + /// + /// Creates and returns a fusion attribute. The join number will match the established Simpl + /// standard of 50+, and will generate a 50+ join in the RVI. It calls + /// FusionRoom.AddSig with join number - 49 + /// + /// The new attribute + public static StringSigData CreateOffsetStringSig(this FusionRoom fr, uint number, string name, eSigIoMask mask) + { + if (number < 50) + { + throw new ArgumentOutOfRangeException("number", "Cannot be less than 50"); + } + number -= 49; + fr.AddSig(eSigType.String, number, name, mask); + return fr.UserDefinedStringSigDetails[number]; + } + + /// + /// Creates and returns a static asset + /// + /// the new asset + public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, + string instanceId) + { + try + { + Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); + + fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + return null; + } + } + + public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, + string type, string instanceId) + { + try + { + Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, + instanceId); + + fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; + } + catch (InvalidOperationException ex) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex); + return null; + } + catch (Exception e) + { + Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e); + return null; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionRoomGuids.cs b/src/PepperDash.Essentials.Core/Fusion/FusionRoomGuids.cs new file mode 100644 index 00000000..b8570763 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionRoomGuids.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.Fusion; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Fusion +{ + // Helper Classes for GUIDs + + /// + /// Stores GUIDs to be written to a file in NVRAM + /// + public class FusionRoomGuids + { + public string RoomName { get; set; } + public uint IpId { get; set; } + public string RoomGuid { get; set; } + public FusionOccupancySensorAsset OccupancyAsset { get; set; } + public Dictionary StaticAssets { get; set; } + + public FusionRoomGuids() + { + StaticAssets = new Dictionary(); + OccupancyAsset = new FusionOccupancySensorAsset(); + } + + public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets) + { + RoomName = roomName; + IpId = ipId; + RoomGuid = roomGuid; + + StaticAssets = staticAssets; + OccupancyAsset = new FusionOccupancySensorAsset(); + } + + public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets, FusionOccupancySensorAsset occAsset) + { + RoomName = roomName; + IpId = ipId; + RoomGuid = roomGuid; + + StaticAssets = staticAssets; + OccupancyAsset = occAsset; + } + + /// + /// Generates a new room GUID prefixed by the program slot number and NIC MAC address + /// + /// + /// + public string GenerateNewRoomGuid(uint progSlot, string mac) + { + Guid roomGuid = Guid.NewGuid(); + + return string.Format("{0}-{1}-{2}", progSlot, mac, roomGuid.ToString()); + } + + + /// + /// Adds an asset to the StaticAssets collection and returns the new asset + /// + /// + /// + /// + /// + /// + /// + public FusionAsset AddStaticAsset(FusionRoom room, int uid, string assetName, string type, string instanceId) + { + var slotNum = GetNextAvailableAssetNumber(room); + + Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); + + var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId); + + StaticAssets.Add(uid, tempAsset); + + return tempAsset; + } + + /// + /// Returns the next available slot number in the Fusion UserConfigurableAssetDetails collection + /// + /// + /// + public static uint GetNextAvailableAssetNumber(FusionRoom room) + { + uint slotNum = 0; + + foreach (var item in room.UserConfigurableAssetDetails) + { + if(item.Number > slotNum) + slotNum = item.Number; + } + + if (slotNum < 5) + { + slotNum = 5; + } + else + slotNum = slotNum + 1; + + Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum); + + return slotNum; + } + + } + + //*************************************************************************************************** + + //**************************************************************************************************** + // Helper Classes for XML API + + + //[XmlRoot(ElementName = "RequestAction")] + + //[XmlRoot(ElementName = "ActionResponse")] + + //[XmlRoot(ElementName = "Parameter")] + + ////[XmlRoot(ElementName = "Parameters")] + //public class Parameters + //{ + // //[XmlElement(ElementName = "Parameter")] + // public List Parameter { get; set; } + //} + + //[XmlRoot(ElementName = "Event")] + + //[XmlRoot(ElementName = "Resources")] + + //[XmlRoot(ElementName = "Rooms")] + + //[XmlRoot(ElementName = "Room")] + + //[XmlRoot(ElementName = "Attendees")] + + //[XmlRoot(ElementName = "Required")] + + //[XmlRoot(ElementName = "Optional")] + + //[XmlRoot(ElementName = "MeetingType")] + + //[XmlRoot(ElementName = "MeetingTypes")] + + //[XmlRoot(ElementName = "LiveMeeting")] + + //[XmlRoot(ElementName = "LiveMeetingURL")] +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs b/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs deleted file mode 100644 index 99fc0abb..00000000 --- a/src/PepperDash.Essentials.Core/Fusion/FusionRviDataClasses.cs +++ /dev/null @@ -1,499 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.Fusion; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Fusion -{ - // Helper Classes for GUIDs - - /// - /// Stores GUIDs to be written to a file in NVRAM - /// - public class FusionRoomGuids - { - public string RoomName { get; set; } - public uint IpId { get; set; } - public string RoomGuid { get; set; } - public FusionOccupancySensorAsset OccupancyAsset { get; set; } - public Dictionary StaticAssets { get; set; } - - public FusionRoomGuids() - { - StaticAssets = new Dictionary(); - OccupancyAsset = new FusionOccupancySensorAsset(); - } - - public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets) - { - RoomName = roomName; - IpId = ipId; - RoomGuid = roomGuid; - - StaticAssets = staticAssets; - OccupancyAsset = new FusionOccupancySensorAsset(); - } - - public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets, FusionOccupancySensorAsset occAsset) - { - RoomName = roomName; - IpId = ipId; - RoomGuid = roomGuid; - - StaticAssets = staticAssets; - OccupancyAsset = occAsset; - } - - /// - /// Generates a new room GUID prefixed by the program slot number and NIC MAC address - /// - /// - /// - public string GenerateNewRoomGuid(uint progSlot, string mac) - { - Guid roomGuid = Guid.NewGuid(); - - return string.Format("{0}-{1}-{2}", progSlot, mac, roomGuid.ToString()); - } - - - /// - /// Adds an asset to the StaticAssets collection and returns the new asset - /// - /// - /// - /// - /// - /// - /// - public FusionAsset AddStaticAsset(FusionRoom room, int uid, string assetName, string type, string instanceId) - { - var slotNum = GetNextAvailableAssetNumber(room); - - Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); - - var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId); - - StaticAssets.Add(uid, tempAsset); - - return tempAsset; - } - - /// - /// Returns the next available slot number in the Fusion UserConfigurableAssetDetails collection - /// - /// - /// - public static uint GetNextAvailableAssetNumber(FusionRoom room) - { - uint slotNum = 0; - - foreach (var item in room.UserConfigurableAssetDetails) - { - if(item.Number > slotNum) - slotNum = item.Number; - } - - if (slotNum < 5) - { - slotNum = 5; - } - else - slotNum = slotNum + 1; - - Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum); - - return slotNum; - } - - } - - public class FusionOccupancySensorAsset - { - // SlotNumber fixed at 4 - - public uint SlotNumber { get { return 4; } } - public string Name { get { return "Occupancy Sensor"; } } - public eAssetType Type { get; set; } - public string InstanceId { get; set; } - - public FusionOccupancySensorAsset() - { - } - - public FusionOccupancySensorAsset(eAssetType type) - { - Type = type; - - InstanceId = Guid.NewGuid().ToString(); - } - } - - public class FusionAsset - { - public uint SlotNumber { get; set; } - public string Name { get; set; } - public string Type { get; set; } - public string InstanceId { get;set; } - - public FusionAsset() - { - - } - - public FusionAsset(uint slotNum, string assetName, string type, string instanceId) - { - SlotNumber = slotNum; - Name = assetName; - Type = type; - if (string.IsNullOrEmpty(instanceId)) - { - InstanceId = Guid.NewGuid().ToString(); - } - else - { - InstanceId = instanceId; - } - } - } - - //*************************************************************************************************** - - public class RoomSchedule - { - public List Meetings { get; set; } - - public RoomSchedule() - { - Meetings = new List(); - } - } - - //**************************************************************************************************** - // Helper Classes for XML API - - /// - /// Data needed to request the local time from the Fusion server - /// - public class LocalTimeRequest - { - public string RequestID { get; set; } - } - - /// - /// All the data needed for a full schedule request in a room - /// - /// //[XmlRoot(ElementName = "RequestSchedule")] - public class RequestSchedule - { - //[XmlElement(ElementName = "RequestID")] - public string RequestID { get; set; } - //[XmlElement(ElementName = "RoomID")] - public string RoomID { get; set; } - //[XmlElement(ElementName = "Start")] - public DateTime Start { get; set; } - //[XmlElement(ElementName = "HourSpan")] - public double HourSpan { get; set; } - - public RequestSchedule(string requestID, string roomID) - { - RequestID = requestID; - RoomID = roomID; - Start = DateTime.Now; - HourSpan = 24; - } - } - - - //[XmlRoot(ElementName = "RequestAction")] - public class RequestAction - { - //[XmlElement(ElementName = "RequestID")] - public string RequestID { get; set; } - //[XmlElement(ElementName = "RoomID")] - public string RoomID { get; set; } - //[XmlElement(ElementName = "ActionID")] - public string ActionID { get; set; } - //[XmlElement(ElementName = "Parameters")] - public List Parameters { get; set; } - - public RequestAction(string roomID, string actionID, List parameters) - { - RoomID = roomID; - ActionID = actionID; - Parameters = parameters; - } - } - - //[XmlRoot(ElementName = "ActionResponse")] - public class ActionResponse - { - //[XmlElement(ElementName = "RequestID")] - public string RequestID { get; set; } - //[XmlElement(ElementName = "ActionID")] - public string ActionID { get; set; } - //[XmlElement(ElementName = "Parameters")] - public List Parameters { get; set; } - } - - //[XmlRoot(ElementName = "Parameter")] - public class Parameter - { - //[XmlAttribute(AttributeName = "ID")] - public string ID { get; set; } - //[XmlAttribute(AttributeName = "Value")] - public string Value { get; set; } - } - - ////[XmlRoot(ElementName = "Parameters")] - //public class Parameters - //{ - // //[XmlElement(ElementName = "Parameter")] - // public List Parameter { get; set; } - //} - - /// - /// Data structure for a ScheduleResponse from Fusion - /// - /// //[XmlRoot(ElementName = "ScheduleResponse")] - public class ScheduleResponse - { - //[XmlElement(ElementName = "RequestID")] - public string RequestID { get; set; } - //[XmlElement(ElementName = "RoomID")] - public string RoomID { get; set; } - //[XmlElement(ElementName = "RoomName")] - public string RoomName { get; set; } - //[XmlElement("Event")] - public List Events { get; set; } - - public ScheduleResponse() - { - Events = new List(); - } - } - - //[XmlRoot(ElementName = "Event")] - public class Event - { - //[XmlElement(ElementName = "MeetingID")] - public string MeetingID { get; set; } - //[XmlElement(ElementName = "RVMeetingID")] - public string RVMeetingID { get; set; } - //[XmlElement(ElementName = "Recurring")] - public string Recurring { get; set; } - //[XmlElement(ElementName = "InstanceID")] - public string InstanceID { get; set; } - //[XmlElement(ElementName = "dtStart")] - public DateTime dtStart { get; set; } - //[XmlElement(ElementName = "dtEnd")] - public DateTime dtEnd { get; set; } - //[XmlElement(ElementName = "Organizer")] - public string Organizer { get; set; } - //[XmlElement(ElementName = "Attendees")] - public Attendees Attendees { get; set; } - //[XmlElement(ElementName = "Resources")] - public Resources Resources { get; set; } - //[XmlElement(ElementName = "IsEvent")] - public string IsEvent { get; set; } - //[XmlElement(ElementName = "IsRoomViewMeeting")] - public string IsRoomViewMeeting { get; set; } - //[XmlElement(ElementName = "IsPrivate")] - public string IsPrivate { get; set; } - //[XmlElement(ElementName = "IsExchangePrivate")] - public string IsExchangePrivate { get; set; } - //[XmlElement(ElementName = "MeetingTypes")] - public MeetingTypes MeetingTypes { get; set; } - //[XmlElement(ElementName = "ParticipantCode")] - public string ParticipantCode { get; set; } - //[XmlElement(ElementName = "PhoneNo")] - public string PhoneNo { get; set; } - //[XmlElement(ElementName = "WelcomeMsg")] - public string WelcomeMsg { get; set; } - //[XmlElement(ElementName = "Subject")] - public string Subject { get; set; } - //[XmlElement(ElementName = "LiveMeeting")] - public LiveMeeting LiveMeeting { get; set; } - //[XmlElement(ElementName = "ShareDocPath")] - public string ShareDocPath { get; set; } - //[XmlElement(ElementName = "HaveAttendees")] - public string HaveAttendees { get; set; } - //[XmlElement(ElementName = "HaveResources")] - public string HaveResources { get; set; } - - /// - /// Gets the duration of the meeting - /// - public string DurationInMinutes - { - get - { - string duration; - - var timeSpan = dtEnd.Subtract(dtStart); - int hours = timeSpan.Hours; - double minutes = timeSpan.Minutes; - double roundedMinutes = Math.Round(minutes); - if (hours > 0) - { - duration = string.Format("{0} hours {1} minutes", hours, roundedMinutes); - } - else - { - duration = string.Format("{0} minutes", roundedMinutes); - } - - return duration; - } - } - - /// - /// Gets the remaining time in the meeting. Returns null if the meeting is not currently in progress. - /// - public string RemainingTime - { - get - { - var now = DateTime.Now; - - string remainingTime; - - if (GetInProgress()) - { - var timeSpan = dtEnd.Subtract(now); - int hours = timeSpan.Hours; - double minutes = timeSpan.Minutes; - double roundedMinutes = Math.Round(minutes); - if (hours > 0) - { - remainingTime = string.Format("{0} hours {1} minutes", hours, roundedMinutes); - } - else - { - remainingTime = string.Format("{0} minutes", roundedMinutes); - } - - return remainingTime; - } - else - return null; - } - - } - - /// - /// Indicates that the meeting is in progress - /// - public bool isInProgress - { - get - { - return GetInProgress(); - } - } - - /// - /// Determines if the meeting is in progress - /// - /// Returns true if in progress - bool GetInProgress() - { - var now = DateTime.Now; - - if (now > dtStart && now < dtEnd) - { - return true; - } - else - return false; - } - } - - //[XmlRoot(ElementName = "Resources")] - public class Resources - { - //[XmlElement(ElementName = "Rooms")] - public Rooms Rooms { get; set; } - } - - //[XmlRoot(ElementName = "Rooms")] - public class Rooms - { - //[XmlElement(ElementName = "Room")] - public List Room { get; set; } - } - - //[XmlRoot(ElementName = "Room")] - public class Room - { - //[XmlElement(ElementName = "Name")] - public string Name { get; set; } - //[XmlElement(ElementName = "ID")] - public string ID { get; set; } - //[XmlElement(ElementName = "MPType")] - public string MPType { get; set; } - } - - //[XmlRoot(ElementName = "Attendees")] - public class Attendees - { - //[XmlElement(ElementName = "Required")] - public Required Required { get; set; } - //[XmlElement(ElementName = "Optional")] - public Optional Optional { get; set; } - } - - //[XmlRoot(ElementName = "Required")] - public class Required - { - //[XmlElement(ElementName = "Attendee")] - public List Attendee { get; set; } - } - - //[XmlRoot(ElementName = "Optional")] - public class Optional - { - //[XmlElement(ElementName = "Attendee")] - public List Attendee { get; set; } - } - - //[XmlRoot(ElementName = "MeetingType")] - public class MeetingType - { - //[XmlAttribute(AttributeName = "ID")] - public string ID { get; set; } - //[XmlAttribute(AttributeName = "Value")] - public string Value { get; set; } - } - - //[XmlRoot(ElementName = "MeetingTypes")] - public class MeetingTypes - { - //[XmlElement(ElementName = "MeetingType")] - public List MeetingType { get; set; } - } - - //[XmlRoot(ElementName = "LiveMeeting")] - public class LiveMeeting - { - //[XmlElement(ElementName = "URL")] - public string URL { get; set; } - //[XmlElement(ElementName = "ID")] - public string ID { get; set; } - //[XmlElement(ElementName = "Key")] - public string Key { get; set; } - //[XmlElement(ElementName = "Subject")] - public string Subject { get; set; } - } - - //[XmlRoot(ElementName = "LiveMeetingURL")] - public class LiveMeetingURL - { - //[XmlElement(ElementName = "LiveMeeting")] - public LiveMeeting LiveMeeting { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionStaticAssetExtensions.cs b/src/PepperDash.Essentials.Core/Fusion/FusionStaticAssetExtensions.cs new file mode 100644 index 00000000..ed8f5730 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/FusionStaticAssetExtensions.cs @@ -0,0 +1,50 @@ +using Crestron.SimplSharpPro.Fusion; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Fusion +{ + /// + /// Extensions to enhance Fusion room, asset and signal creation. + /// + public static class FusionStaticAssetExtensions + { + /// + /// Tries to set a Fusion asset with the make and model of a device. + /// If the provided Device is IMakeModel, will set the corresponding parameters on the fusion static asset. + /// Otherwise, does nothing. + /// + public static void TrySetMakeModel(this FusionStaticAsset asset, Device device) + { + var mm = device as IMakeModel; + if (mm != null) + { + asset.ParamMake.Value = mm.DeviceMake; + asset.ParamModel.Value = mm.DeviceModel; + } + } + + /// + /// Tries to attach the AssetError input on a Fusion asset to a Device's + /// CommunicationMonitor.StatusChange event. Does nothing if the device is not + /// IStatusMonitor + /// + /// + /// + public static void TryLinkAssetErrorToCommunication(this FusionStaticAsset asset, Device device) + { + if (device is ICommunicationMonitor) + { + var monitor = (device as ICommunicationMonitor).CommunicationMonitor; + monitor.StatusChange += (o, a) => + { + // Link connected and error inputs on asset + asset.Connected.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; + asset.AssetError.InputSig.StringValue = a.Status.ToString(); + }; + // set current value + asset.Connected.InputSig.BoolValue = monitor.Status == MonitorStatus.IsOk; + asset.AssetError.InputSig.StringValue = monitor.Status.ToString(); + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/LiveMeeting.cs b/src/PepperDash.Essentials.Core/Fusion/LiveMeeting.cs new file mode 100644 index 00000000..766bf559 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/LiveMeeting.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class LiveMeeting + { + //[XmlElement(ElementName = "URL")] + public string URL { get; set; } + //[XmlElement(ElementName = "ID")] + public string ID { get; set; } + //[XmlElement(ElementName = "Key")] + public string Key { get; set; } + //[XmlElement(ElementName = "Subject")] + public string Subject { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/LiveMeetingURL.cs b/src/PepperDash.Essentials.Core/Fusion/LiveMeetingURL.cs new file mode 100644 index 00000000..16387558 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/LiveMeetingURL.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class LiveMeetingURL + { + //[XmlElement(ElementName = "LiveMeeting")] + public LiveMeeting LiveMeeting { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/LocalTimeRequest.cs b/src/PepperDash.Essentials.Core/Fusion/LocalTimeRequest.cs new file mode 100644 index 00000000..7c2fe75c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/LocalTimeRequest.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + /// + /// Data needed to request the local time from the Fusion server + /// + public class LocalTimeRequest + { + public string RequestID { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/MeetingChangeEventArgs.cs b/src/PepperDash.Essentials.Core/Fusion/MeetingChangeEventArgs.cs new file mode 100644 index 00000000..4522f268 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/MeetingChangeEventArgs.cs @@ -0,0 +1,9 @@ +using System; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class MeetingChangeEventArgs : EventArgs + { + public Event Meeting { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/MeetingType.cs b/src/PepperDash.Essentials.Core/Fusion/MeetingType.cs new file mode 100644 index 00000000..0d491391 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/MeetingType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class MeetingType + { + //[XmlAttribute(AttributeName = "ID")] + public string ID { get; set; } + //[XmlAttribute(AttributeName = "Value")] + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/MeetingTypes.cs b/src/PepperDash.Essentials.Core/Fusion/MeetingTypes.cs new file mode 100644 index 00000000..a56b6595 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/MeetingTypes.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class MeetingTypes + { + //[XmlElement(ElementName = "MeetingType")] + public List MeetingType { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Optional.cs b/src/PepperDash.Essentials.Core/Fusion/Optional.cs new file mode 100644 index 00000000..541e5834 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Optional.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class Optional + { + //[XmlElement(ElementName = "Attendee")] + public List Attendee { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Parameter.cs b/src/PepperDash.Essentials.Core/Fusion/Parameter.cs new file mode 100644 index 00000000..495f8afc --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Parameter.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class Parameter + { + //[XmlAttribute(AttributeName = "ID")] + public string ID { get; set; } + //[XmlAttribute(AttributeName = "Value")] + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs b/src/PepperDash.Essentials.Core/Fusion/ProcessorProgReg.cs similarity index 91% rename from src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs rename to src/PepperDash.Essentials.Core/Fusion/ProcessorProgReg.cs index 62109d97..68a1e259 100644 --- a/src/PepperDash.Essentials.Core/Fusion/FusionProcessorQueries.cs +++ b/src/PepperDash.Essentials.Core/Fusion/ProcessorProgReg.cs @@ -50,13 +50,4 @@ namespace PepperDash.Essentials.Core.Fusion return programs; } } - - /// - /// Used in ProcessorProgReg - /// - public class ProcessorProgramItem - { - public bool Exists { get; set; } - public string Name { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/ProcessorProgramItem.cs b/src/PepperDash.Essentials.Core/Fusion/ProcessorProgramItem.cs new file mode 100644 index 00000000..046bd729 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/ProcessorProgramItem.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + /// + /// Used in ProcessorProgReg + /// + public class ProcessorProgramItem + { + public bool Exists { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/RequestAction.cs b/src/PepperDash.Essentials.Core/Fusion/RequestAction.cs new file mode 100644 index 00000000..f908a946 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/RequestAction.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class RequestAction + { + //[XmlElement(ElementName = "RequestID")] + public string RequestID { get; set; } + //[XmlElement(ElementName = "RoomID")] + public string RoomID { get; set; } + //[XmlElement(ElementName = "ActionID")] + public string ActionID { get; set; } + //[XmlElement(ElementName = "Parameters")] + public List Parameters { get; set; } + + public RequestAction(string roomID, string actionID, List parameters) + { + RoomID = roomID; + ActionID = actionID; + Parameters = parameters; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/RequestSchedule.cs b/src/PepperDash.Essentials.Core/Fusion/RequestSchedule.cs new file mode 100644 index 00000000..e47b598e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/RequestSchedule.cs @@ -0,0 +1,28 @@ +using System; + +namespace PepperDash.Essentials.Core.Fusion +{ + /// + /// All the data needed for a full schedule request in a room + /// + /// //[XmlRoot(ElementName = "RequestSchedule")] + public class RequestSchedule + { + //[XmlElement(ElementName = "RequestID")] + public string RequestID { get; set; } + //[XmlElement(ElementName = "RoomID")] + public string RoomID { get; set; } + //[XmlElement(ElementName = "Start")] + public DateTime Start { get; set; } + //[XmlElement(ElementName = "HourSpan")] + public double HourSpan { get; set; } + + public RequestSchedule(string requestID, string roomID) + { + RequestID = requestID; + RoomID = roomID; + Start = DateTime.Now; + HourSpan = 24; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Required.cs b/src/PepperDash.Essentials.Core/Fusion/Required.cs new file mode 100644 index 00000000..621052ad --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Required.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class Required + { + //[XmlElement(ElementName = "Attendee")] + public List Attendee { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Resources.cs b/src/PepperDash.Essentials.Core/Fusion/Resources.cs new file mode 100644 index 00000000..3ccc5a06 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Resources.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class Resources + { + //[XmlElement(ElementName = "Rooms")] + public Rooms Rooms { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Room.cs b/src/PepperDash.Essentials.Core/Fusion/Room.cs new file mode 100644 index 00000000..2b6f23df --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Room.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core.Fusion +{ + public class Room + { + //[XmlElement(ElementName = "Name")] + public string Name { get; set; } + //[XmlElement(ElementName = "ID")] + public string ID { get; set; } + //[XmlElement(ElementName = "MPType")] + public string MPType { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/RoomInformation.cs b/src/PepperDash.Essentials.Core/Fusion/RoomInformation.cs new file mode 100644 index 00000000..cc22e064 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/RoomInformation.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class RoomInformation + { + public RoomInformation() + { + FusionCustomProperties = new List(); + } + + public string ID { get; set; } + public string Name { get; set; } + public string Location { get; set; } + public string Description { get; set; } + public string TimeZone { get; set; } + public string WebcamURL { get; set; } + public string BacklogMsg { get; set; } + public string SubErrorMsg { get; set; } + public string EmailInfo { get; set; } + public List FusionCustomProperties { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/RoomSchedule.cs b/src/PepperDash.Essentials.Core/Fusion/RoomSchedule.cs new file mode 100644 index 00000000..a9305c3b --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/RoomSchedule.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class RoomSchedule + { + public List Meetings { get; set; } + + public RoomSchedule() + { + Meetings = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/Rooms.cs b/src/PepperDash.Essentials.Core/Fusion/Rooms.cs new file mode 100644 index 00000000..d96ce416 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/Rooms.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + public class Rooms + { + //[XmlElement(ElementName = "Room")] + public List Room { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/FusionEventHandlers.cs b/src/PepperDash.Essentials.Core/Fusion/ScheduleChangeEventArgs.cs similarity index 72% rename from src/PepperDash.Essentials.Core/Fusion/FusionEventHandlers.cs rename to src/PepperDash.Essentials.Core/Fusion/ScheduleChangeEventArgs.cs index 26647a96..56ee345a 100644 --- a/src/PepperDash.Essentials.Core/Fusion/FusionEventHandlers.cs +++ b/src/PepperDash.Essentials.Core/Fusion/ScheduleChangeEventArgs.cs @@ -10,9 +10,4 @@ namespace PepperDash.Essentials.Core.Fusion { public RoomSchedule Schedule { get; set; } } - - public class MeetingChangeEventArgs : EventArgs - { - public Event Meeting { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Fusion/ScheduleResponse.cs b/src/PepperDash.Essentials.Core/Fusion/ScheduleResponse.cs new file mode 100644 index 00000000..022a20e3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Fusion/ScheduleResponse.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Fusion +{ + /// + /// Data structure for a ScheduleResponse from Fusion + /// + /// //[XmlRoot(ElementName = "ScheduleResponse")] + public class ScheduleResponse + { + //[XmlElement(ElementName = "RequestID")] + public string RequestID { get; set; } + //[XmlElement(ElementName = "RoomID")] + public string RoomID { get; set; } + //[XmlElement(ElementName = "RoomName")] + public string RoomName { get; set; } + //[XmlElement("Event")] + public List Events { get; set; } + + public ScheduleResponse() + { + Events = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Global/JobTimer.cs b/src/PepperDash.Essentials.Core/Global/JobTimer.cs index 83159c12..635e70d1 100644 --- a/src/PepperDash.Essentials.Core/Global/JobTimer.cs +++ b/src/PepperDash.Essentials.Core/Global/JobTimer.cs @@ -50,31 +50,4 @@ namespace PepperDash.Essentials.Core } } - - /// - /// - /// - public class JobTimerItem - { - public string Key { get; private set; } - public Action JobAction { get; private set; } - public eJobTimerCycleTypes CycleType { get; private set; } - /// - /// - /// - public DateTime RunNextAt { get; set; } - - public JobTimerItem(string key, eJobTimerCycleTypes cycle, Action act) - { - - } - } - - public enum eJobTimerCycleTypes - { - RunEveryDay, - RunEveryHour, - RunEveryHalfHour, - RunEveryMinute - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Global/JobTimerItem.cs b/src/PepperDash.Essentials.Core/Global/JobTimerItem.cs new file mode 100644 index 00000000..737de0d7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Global/JobTimerItem.cs @@ -0,0 +1,23 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public class JobTimerItem + { + public string Key { get; private set; } + public Action JobAction { get; private set; } + public eJobTimerCycleTypes CycleType { get; private set; } + /// + /// + /// + public DateTime RunNextAt { get; set; } + + public JobTimerItem(string key, eJobTimerCycleTypes cycle, Action act) + { + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Global/Scheduler.cs b/src/PepperDash.Essentials.Core/Global/Scheduler.cs index 960a56ef..a30079da 100644 --- a/src/PepperDash.Essentials.Core/Global/Scheduler.cs +++ b/src/PepperDash.Essentials.Core/Global/Scheduler.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; @@ -7,7 +6,6 @@ using Crestron.SimplSharp.Scheduler; using PepperDash.Core; using PepperDash.Essentials.Core.Fusion; -using PepperDash.Essentials.Room.Config; using Activator = System.Activator; namespace PepperDash.Essentials.Core @@ -122,157 +120,4 @@ Recurrence Days: {5} return EventGroups.TryGetValue(key, out returnValue) ? returnValue : null; } } - - public static class SchedulerUtilities - { - /// - /// Checks the day of week in eventTime to see if it matches the weekdays defined in the recurrence enum. - /// - /// - /// - /// - public static bool CheckIfDayOfWeekMatchesRecurrenceDays(DateTime eventTime, ScheduledEventCommon.eWeekDays recurrence) - { - bool isMatch = false; - - var dayOfWeek = eventTime.DayOfWeek; - - Debug.Console(1, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek); - - switch (dayOfWeek) - { - case DayOfWeek.Sunday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Sunday) == ScheduledEventCommon.eWeekDays.Sunday) - isMatch = true; - break; - } - case DayOfWeek.Monday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Monday) == ScheduledEventCommon.eWeekDays.Monday) - isMatch = true; - break; - } - case DayOfWeek.Tuesday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Tuesday) == ScheduledEventCommon.eWeekDays.Tuesday) - isMatch = true; - break; - } - case DayOfWeek.Wednesday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Wednesday) == ScheduledEventCommon.eWeekDays.Wednesday) - isMatch = true; - break; - } - case DayOfWeek.Thursday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Thursday) == ScheduledEventCommon.eWeekDays.Thursday) - isMatch = true; - break; - } - case DayOfWeek.Friday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Friday) == ScheduledEventCommon.eWeekDays.Friday) - isMatch = true; - break; - } - case DayOfWeek.Saturday: - { - if ((recurrence & ScheduledEventCommon.eWeekDays.Saturday) == ScheduledEventCommon.eWeekDays.Saturday) - isMatch = true; - break; - } - } - - Debug.Console(1, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch); - - return isMatch; - } - - public static bool CheckEventTimeForMatch(ScheduledEvent evnt, DateTime time) - { - return evnt.DateAndTime.Hour == time.Hour && evnt.DateAndTime.Minute == time.Minute; - } - - public static bool CheckEventRecurrenceForMatch(ScheduledEvent evnt, ScheduledEventCommon.eWeekDays days) - { - return evnt.Recurrence.RecurrenceDays == days; - } - - public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler) - { - if (group == null) - { - Debug.Console(0, "Unable to create event. Group is null"); - return; - } - var scheduledEvent = new ScheduledEvent(config.Key, group) - { - Acknowledgeable = config.Acknowledgeable, - Persistent = config.Persistent - }; - - scheduledEvent.UserCallBack += handler; - - scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday); - - var eventTime = DateTime.Parse(config.Time); - - if (DateTime.Now > eventTime) - { - eventTime = eventTime.AddDays(1); - } - - Debug.Console(2, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek, - config.Days); - - var dayOfWeekConverted = ConvertDayOfWeek(eventTime); - - Debug.Console(1, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted); - - while (!dayOfWeekConverted.IsFlagSet(config.Days)) - { - eventTime = eventTime.AddDays(1); - - dayOfWeekConverted = ConvertDayOfWeek(eventTime); - } - - scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime); - - scheduledEvent.Recurrence.Weekly(config.Days); - - if (config.Enable) - { - scheduledEvent.Enable(); - } - else - { - scheduledEvent.Disable(); - } - } - - private static ScheduledEventCommon.eWeekDays ConvertDayOfWeek(DateTime eventTime) - { - return (ScheduledEventCommon.eWeekDays) Enum.Parse(typeof(ScheduledEventCommon.eWeekDays), eventTime.DayOfWeek.ToString(), true); - } - - private static bool IsFlagSet(this T value, T flag) where T : struct - { - CheckIsEnum(true); - - var lValue = Convert.ToInt64(value); - var lFlag = Convert.ToInt64(flag); - - return (lValue & lFlag) != 0; - } - - private static void CheckIsEnum(bool withFlags) - { - if (!typeof(T).IsEnum) - throw new ArgumentException(string.Format("Type '{0}' is not an enum", typeof(T).FullName)); - if (withFlags && !Attribute.IsDefined(typeof(T), typeof(FlagsAttribute))) - throw new ArgumentException(string.Format("Type '{0}' doesn't have the 'Flags' attribute", typeof(T).FullName)); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Global/SchedulerUtilities.cs b/src/PepperDash.Essentials.Core/Global/SchedulerUtilities.cs new file mode 100644 index 00000000..6598a8a2 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Global/SchedulerUtilities.cs @@ -0,0 +1,160 @@ +using System; +using Crestron.SimplSharp.Scheduler; +using PepperDash.Core; +using PepperDash.Essentials.Room.Config; + +namespace PepperDash.Essentials.Core +{ + public static class SchedulerUtilities + { + /// + /// Checks the day of week in eventTime to see if it matches the weekdays defined in the recurrence enum. + /// + /// + /// + /// + public static bool CheckIfDayOfWeekMatchesRecurrenceDays(DateTime eventTime, ScheduledEventCommon.eWeekDays recurrence) + { + bool isMatch = false; + + var dayOfWeek = eventTime.DayOfWeek; + + Debug.Console(1, "[Scheduler]: eventTime day of week is: {0}", dayOfWeek); + + switch (dayOfWeek) + { + case DayOfWeek.Sunday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Sunday) == ScheduledEventCommon.eWeekDays.Sunday) + isMatch = true; + break; + } + case DayOfWeek.Monday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Monday) == ScheduledEventCommon.eWeekDays.Monday) + isMatch = true; + break; + } + case DayOfWeek.Tuesday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Tuesday) == ScheduledEventCommon.eWeekDays.Tuesday) + isMatch = true; + break; + } + case DayOfWeek.Wednesday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Wednesday) == ScheduledEventCommon.eWeekDays.Wednesday) + isMatch = true; + break; + } + case DayOfWeek.Thursday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Thursday) == ScheduledEventCommon.eWeekDays.Thursday) + isMatch = true; + break; + } + case DayOfWeek.Friday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Friday) == ScheduledEventCommon.eWeekDays.Friday) + isMatch = true; + break; + } + case DayOfWeek.Saturday: + { + if ((recurrence & ScheduledEventCommon.eWeekDays.Saturday) == ScheduledEventCommon.eWeekDays.Saturday) + isMatch = true; + break; + } + } + + Debug.Console(1, "[Scheduler]: eventTime day of week matches recurrence days: {0}", isMatch); + + return isMatch; + } + + public static bool CheckEventTimeForMatch(ScheduledEvent evnt, DateTime time) + { + return evnt.DateAndTime.Hour == time.Hour && evnt.DateAndTime.Minute == time.Minute; + } + + public static bool CheckEventRecurrenceForMatch(ScheduledEvent evnt, ScheduledEventCommon.eWeekDays days) + { + return evnt.Recurrence.RecurrenceDays == days; + } + + public static void CreateEventFromConfig(ScheduledEventConfig config, ScheduledEventGroup group, ScheduledEvent.UserEventCallBack handler) + { + if (group == null) + { + Debug.Console(0, "Unable to create event. Group is null"); + return; + } + var scheduledEvent = new ScheduledEvent(config.Key, group) + { + Acknowledgeable = config.Acknowledgeable, + Persistent = config.Persistent + }; + + scheduledEvent.UserCallBack += handler; + + scheduledEvent.DateAndTime.SetFirstDayOfWeek(ScheduledEventCommon.eFirstDayOfWeek.Sunday); + + var eventTime = DateTime.Parse(config.Time); + + if (DateTime.Now > eventTime) + { + eventTime = eventTime.AddDays(1); + } + + Debug.Console(2, "[Scheduler] Current Date day of week: {0} recurrence days: {1}", eventTime.DayOfWeek, + config.Days); + + var dayOfWeekConverted = ConvertDayOfWeek(eventTime); + + Debug.Console(1, "[Scheduler] eventTime Day: {0}", dayOfWeekConverted); + + while (!dayOfWeekConverted.IsFlagSet(config.Days)) + { + eventTime = eventTime.AddDays(1); + + dayOfWeekConverted = ConvertDayOfWeek(eventTime); + } + + scheduledEvent.DateAndTime.SetAbsoluteEventTime(eventTime); + + scheduledEvent.Recurrence.Weekly(config.Days); + + if (config.Enable) + { + scheduledEvent.Enable(); + } + else + { + scheduledEvent.Disable(); + } + } + + private static ScheduledEventCommon.eWeekDays ConvertDayOfWeek(DateTime eventTime) + { + return (ScheduledEventCommon.eWeekDays) Enum.Parse(typeof(ScheduledEventCommon.eWeekDays), eventTime.DayOfWeek.ToString(), true); + } + + private static bool IsFlagSet(this T value, T flag) where T : struct + { + CheckIsEnum(true); + + var lValue = Convert.ToInt64(value); + var lFlag = Convert.ToInt64(flag); + + return (lValue & lFlag) != 0; + } + + private static void CheckIsEnum(bool withFlags) + { + if (!typeof(T).IsEnum) + throw new ArgumentException(string.Format("Type '{0}' is not an enum", typeof(T).FullName)); + if (withFlags && !Attribute.IsDefined(typeof(T), typeof(FlagsAttribute))) + throw new ArgumentException(string.Format("Type '{0}' doesn't have the 'Flags' attribute", typeof(T).FullName)); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Global/eJobTimerCycleTypes.cs b/src/PepperDash.Essentials.Core/Global/eJobTimerCycleTypes.cs new file mode 100644 index 00000000..857e6a5e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Global/eJobTimerCycleTypes.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + public enum eJobTimerCycleTypes + { + RunEveryDay, + RunEveryHour, + RunEveryHalfHour, + RunEveryMinute + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/InUseTracking/InUseTracking.cs b/src/PepperDash.Essentials.Core/InUseTracking/InUseTracking.cs index 4bf1a551..94e444c2 100644 --- a/src/PepperDash.Essentials.Core/InUseTracking/InUseTracking.cs +++ b/src/PepperDash.Essentials.Core/InUseTracking/InUseTracking.cs @@ -70,23 +70,7 @@ namespace PepperDash.Essentials.Core } } - /// - /// Wrapper for label/object pair representing in-use status. Allows the same object to - /// register for in-use with different roles. - /// - public class InUseTrackingObject - { - public string Label { get; private set; } - public object User { get; private set; } - - public InUseTrackingObject(object user, string label) - { - User = user; - Label = label; - } - } - - //public class InUseEventArgs + //public class InUseEventArgs //{ // public int EventType { get; private set; } // public InUseTracking Tracker { get; private set; } diff --git a/src/PepperDash.Essentials.Core/InUseTracking/InUseTrackingObject.cs b/src/PepperDash.Essentials.Core/InUseTracking/InUseTrackingObject.cs new file mode 100644 index 00000000..cc3dac45 --- /dev/null +++ b/src/PepperDash.Essentials.Core/InUseTracking/InUseTrackingObject.cs @@ -0,0 +1,18 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Wrapper for label/object pair representing in-use status. Allows the same object to + /// register for in-use with different roles. + /// + public class InUseTrackingObject + { + public string Label { get; private set; } + public object User { get; private set; } + + public InUseTrackingObject(object user, string label) + { + User = user; + Label = label; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinData.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinData.cs new file mode 100644 index 00000000..31e0c22c --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinData.cs @@ -0,0 +1,27 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + /// + /// Data describing the join. Can be overridden from configuratino + /// + 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; } + /// + /// Fusion Attribute Name (optional) + /// + [JsonProperty("attributeName")] + public string AttributeName { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinDataComplete.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinDataComplete.cs new file mode 100644 index 00000000..88ef339d --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinDataComplete.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using Crestron.SimplSharp.Reflection; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// A class to aggregate the JoinData and JoinMetadata for a join + /// + public class JoinDataComplete + { + private uint _joinOffset; + + private JoinData _data; + public JoinMetadata Metadata { get; set; } + /// + /// To store some future information as you please + /// + public object UserObject { get; private set; } + + public JoinDataComplete(JoinData data, JoinMetadata metadata) + { + _data = data; + Metadata = metadata; + } + + public string GetMarkdownFormattedData(string stringFormatter, int descriptionLen) + { + + //Fixed Width Headers + var joinNumberLen = String.Format("Join Number").Length; + var joinSpanLen = String.Format("Join Span").Length; + var typeLen = String.Format("AnalogDigitalSerial").Length; + var capabilitiesLen = String.Format("ToFromFusion").Length; + + //Track which one failed, if it did + const string placeholder = "unknown"; + var dataArray = new Dictionary + { + {"joinNumber", placeholder.PadRight(joinNumberLen, ' ')}, + {"joinSpan", placeholder.PadRight(joinSpanLen, ' ')}, + {"description", placeholder.PadRight(descriptionLen, ' ')}, + {"joinType", placeholder.PadRight(typeLen, ' ')}, + {"capabilities", placeholder.PadRight(capabilitiesLen, ' ')} + }; + + + try + { + dataArray["joinNumber"] = String.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' '); + dataArray["joinSpan"] = String.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' '); + dataArray["description"] = String.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' '); + dataArray["joinType"] = String.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' '); + dataArray["capabilities"] = String.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' '); + + return String.Format(stringFormatter, + dataArray["joinNumber"], + dataArray["joinSpan"], + dataArray["description"], + dataArray["joinType"], + dataArray["capabilities"]); + + } + catch (Exception e) + { + //Don't Throw - we don't want to kill the system if this falls over - it's not mission critical. Print the error, use placeholder data + var errorKey = string.Empty; + foreach (var item in dataArray) + { + if (item.Value.TrimEnd() == placeholder) continue; + errorKey = item.Key; + break; + } + Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); + return String.Format(stringFormatter, + dataArray["joinNumber"], + dataArray["joinSpan"], + dataArray["description"], + dataArray["joinType"], + dataArray["capabilities"]); + } + } + + + /// + /// 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+ _joinOffset; } + set { _data.JoinNumber = value; } + } + + public uint JoinSpan + { + get { return _data.JoinSpan; } + } + + public string AttributeName + { + get { return _data.AttributeName; } + } + + public void SetCustomJoinData(JoinData customJoinData) + { + _data = customJoinData; + } + + public string GetNameAttribute(MemberInfo memberInfo) + { + var name = string.Empty; + var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); + + if (attribute == null) return name; + + name = attribute.Name; + Debug.Console(2, "JoinName Attribute value: {0}", name); + return name; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs index e16640ce..b62582c7 100644 --- a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBase.cs @@ -3,86 +3,14 @@ using System; using System.Collections.Generic; using System.Data; -using System.Globalization; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp; using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -using Full.Newtonsoft.Json; namespace PepperDash.Essentials.Core { - public static class JoinMapHelper - { - /// - /// Attempts to get the serialized join map from config - /// - /// - /// - public static string GetSerializedJoinMapForDevice(string joinMapKey) - { - if (string.IsNullOrEmpty(joinMapKey)) - return null; - - var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; - - return joinMap.ToString(); - } - - /// - /// Attempts to get the serialized join map from config - /// - /// - /// - public static string GetJoinMapForDevice(string joinMapKey) - { - return GetSerializedJoinMapForDevice(joinMapKey); - } - - /// - /// Attempts to find a custom join map by key and returns it deserialized if found - /// - /// - /// - public static Dictionary TryGetJoinMapAdvancedForDevice(string joinMapKey) - { - try - { - if (string.IsNullOrEmpty(joinMapKey)) - return null; - - if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) - { - Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey); - return null; - } - - Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey); - - var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; - - if (joinMapJToken == null) - return null; - - var joinMapData = joinMapJToken.ToObject>(); - - return joinMapData; - } - catch (Exception e) - { - Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); - return null; - } - } - - } - /// /// Base class for join maps /// @@ -173,491 +101,4 @@ namespace PepperDash.Essentials.Core return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0; } } - - /// - /// Base class for join maps - /// - public abstract class JoinMapBaseAdvanced - { - protected uint JoinOffset; - - /// - /// The collection of joins and associated metadata - /// - public Dictionary Joins { get; private set; } - - protected JoinMapBaseAdvanced(uint joinStart) - { - Joins = new Dictionary(); - - JoinOffset = joinStart - 1; - } - - protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart) - { - AddJoins(type); - } - - protected void AddJoins(Type type) - { - var fields = - type.GetCType() - .GetFields(BindingFlags.Public | BindingFlags.Instance) - .Where(f => f.IsDefined(typeof (JoinNameAttribute), true)); - - foreach (var field in fields) - { - var childClass = Convert.ChangeType(this, type, null); - - var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields. - - if (value == null) - { - Debug.Console(0, "Unable to cast base class to {0}", type.Name); - continue; - } - - value.SetJoinOffset(JoinOffset); - - var joinName = value.GetNameAttribute(field); - - if (String.IsNullOrEmpty(joinName)) continue; - - Joins.Add(joinName, value); - } - - - if (Debug.Level > 0) - { - PrintJoinMapInfo(); - } - } - - /// - /// Prints the join information to console - /// - public void PrintJoinMapInfo() - { - Debug.Console(0, "{0}:\n", 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); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - 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); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - 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); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - PrintJoinList(GetSortedJoins(serials)); - - } - /// - /// Prints the join information to console - /// - public void MarkdownJoinMapInfo(string deviceKey, string bridgeKey) - { - var pluginType = GetType().Name; - - Debug.Console(0, "{0}:\n", pluginType); - - var sb = new StringBuilder(); - - sb.AppendLine(String.Format("# {0}", GetType().Name)); - sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey)); - sb.AppendLine(); - sb.AppendLine("## Digitals"); - // Get the joins of each type and print them - var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - var digitalSb = AppendJoinList(GetSortedJoins(digitals)); - digitalSb.AppendLine("## Analogs"); - digitalSb.AppendLine(); - - Debug.Console(0, "Analogs:"); - var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - var analogSb = AppendJoinList(GetSortedJoins(analogs)); - analogSb.AppendLine("## Serials"); - analogSb.AppendLine(); - - Debug.Console(0, "Serials:"); - var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - var serialSb = AppendJoinList(GetSortedJoins(serials)); - - sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); - sb.Append(digitalSb).Append(analogSb).Append(serialSb); - - WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey); - - } - - private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey) - { - var fileName = String.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey); - - using (var sw = new StreamWriter(fileName)) - { - sw.WriteLine(stringBuilder.ToString()); - Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName); - } - - } - - /// - /// 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}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'", - join.Value.JoinNumber, - join.Value.JoinSpan, - join.Key, - String.IsNullOrEmpty(join.Value.AttributeName) ? join.Value.Metadata.Label : join.Value.AttributeName, - join.Value.Metadata.JoinType.ToString(), - join.Value.Metadata.JoinCapabilities.ToString()); - } - } - - static StringBuilder AppendJoinList(List> joins) - { - var sb = new StringBuilder(); - const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |"; - const int joinNumberLen = 11; - const int joinSpanLen = 9; - const int typeLen = 19; - const int capabilitiesLen = 12; - var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max(); - - //build header - sb.AppendLine(String.Format(stringFormatter, - String.Format("Join Number").PadRight(joinNumberLen, ' '), - String.Format("Join Span").PadRight(joinSpanLen, ' '), - String.Format("Description").PadRight(descriptionLen, ' '), - String.Format("Type").PadRight(typeLen, ' '), - String.Format("Capabilities").PadRight(capabilitiesLen, ' '))); - //build table seperator - sb.AppendLine(String.Format(stringFormatter, - new String('-', joinNumberLen), - new String('-', joinSpanLen), - new String('-', descriptionLen), - new String('-', typeLen), - new String('-', capabilitiesLen))); - - foreach (var join in joins) - { - sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen)); - } - sb.AppendLine(); - return sb; - } - - /// - /// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom - /// - /// - public void SetCustomJoinData(Dictionary joinData) - { - foreach (var customJoinData in joinData) - { - var join = Joins[customJoinData.Key]; - - if (join != null) - { - join.SetCustomJoinData(customJoinData.Value); - } - else - { - Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); - } - } - - PrintJoinMapInfo(); - } - - ///// - ///// 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; - //} - } - - /// - /// Read = Provides feedback to SIMPL - /// Write = Responds to sig values from SIMPL - /// - [Flags] - public enum eJoinCapabilities - { - None = 0, - ToSIMPL = 1, - FromSIMPL = 2, - ToFromSIMPL = ToSIMPL | FromSIMPL, - ToFusion = 4, - FromFusion = 8, - ToFromFusion = ToFusion | FromFusion, - } - - [Flags] - public enum eJoinType - { - None = 0, - Digital = 1, - Analog = 2, - Serial = 4, - DigitalAnalog = Digital | Analog, - DigitalSerial = Digital | Serial, - AnalogSerial = Analog | Serial, - DigitalAnalogSerial = Digital | Analog | Serial, - } - - /// - /// Metadata describing the join - /// - public class JoinMetadata - { - private string _description; - - /// - /// 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 its usage - /// - [Obsolete("Use Description instead")] - [JsonProperty("label")] - public string Label { get { return _description; } set { _description = value; } } - - /// - /// A description for the join to better describe its usage - /// - [JsonProperty("description")] - public string Description { get { return _description; } set { _description = value; } } - /// - /// Signal type(s) - /// - [JsonProperty("joinType")] - public eJoinType JoinType { get; set; } - /// - /// Indicates whether the join is read and/or write - /// - [JsonProperty("joinCapabilities")] - public eJoinCapabilities JoinCapabilities { get; set; } - /// - /// Indicates a set of valid values (particularly if this translates to an enum - /// - [JsonProperty("validValues")] - public string[] ValidValues { get; set; } - - } - - /// - /// Data describing the join. Can be overridden from configuratino - /// - 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; } - /// - /// Fusion Attribute Name (optional) - /// - [JsonProperty("attributeName")] - public string AttributeName { get; set; } - } - - /// - /// A class to aggregate the JoinData and JoinMetadata for a join - /// - public class JoinDataComplete - { - private uint _joinOffset; - - private JoinData _data; - public JoinMetadata Metadata { get; set; } - /// - /// To store some future information as you please - /// - public object UserObject { get; private set; } - - public JoinDataComplete(JoinData data, JoinMetadata metadata) - { - _data = data; - Metadata = metadata; - } - - public string GetMarkdownFormattedData(string stringFormatter, int descriptionLen) - { - - //Fixed Width Headers - var joinNumberLen = String.Format("Join Number").Length; - var joinSpanLen = String.Format("Join Span").Length; - var typeLen = String.Format("AnalogDigitalSerial").Length; - var capabilitiesLen = String.Format("ToFromFusion").Length; - - //Track which one failed, if it did - const string placeholder = "unknown"; - var dataArray = new Dictionary - { - {"joinNumber", placeholder.PadRight(joinNumberLen, ' ')}, - {"joinSpan", placeholder.PadRight(joinSpanLen, ' ')}, - {"description", placeholder.PadRight(descriptionLen, ' ')}, - {"joinType", placeholder.PadRight(typeLen, ' ')}, - {"capabilities", placeholder.PadRight(capabilitiesLen, ' ')} - }; - - - try - { - dataArray["joinNumber"] = String.Format("{0}", JoinNumber.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinNumberLen, ' '); - dataArray["joinSpan"] = String.Format("{0}", JoinSpan.ToString(CultureInfo.InvariantCulture).ReplaceIfNullOrEmpty(placeholder)).PadRight(joinSpanLen, ' '); - dataArray["description"] = String.Format("{0}", Metadata.Description.ReplaceIfNullOrEmpty(placeholder)).PadRight(descriptionLen, ' '); - dataArray["joinType"] = String.Format("{0}", Metadata.JoinType.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(typeLen, ' '); - dataArray["capabilities"] = String.Format("{0}", Metadata.JoinCapabilities.ToString().ReplaceIfNullOrEmpty(placeholder)).PadRight(capabilitiesLen, ' '); - - return String.Format(stringFormatter, - dataArray["joinNumber"], - dataArray["joinSpan"], - dataArray["description"], - dataArray["joinType"], - dataArray["capabilities"]); - - } - catch (Exception e) - { - //Don't Throw - we don't want to kill the system if this falls over - it's not mission critical. Print the error, use placeholder data - var errorKey = string.Empty; - foreach (var item in dataArray) - { - if (item.Value.TrimEnd() == placeholder) continue; - errorKey = item.Key; - break; - } - Debug.Console(0, "Unable to decode join metadata {1}- {0}", e.Message, !String.IsNullOrEmpty(errorKey) ? (' ' + errorKey) : String.Empty); - return String.Format(stringFormatter, - dataArray["joinNumber"], - dataArray["joinSpan"], - dataArray["description"], - dataArray["joinType"], - dataArray["capabilities"]); - } - } - - - /// - /// 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+ _joinOffset; } - set { _data.JoinNumber = value; } - } - - public uint JoinSpan - { - get { return _data.JoinSpan; } - } - - public string AttributeName - { - get { return _data.AttributeName; } - } - - public void SetCustomJoinData(JoinData customJoinData) - { - _data = customJoinData; - } - - public string GetNameAttribute(MemberInfo memberInfo) - { - var name = string.Empty; - var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute)); - - if (attribute == null) return name; - - name = attribute.Name; - Debug.Console(2, "JoinName Attribute value: {0}", name); - return name; - } - } - - - - [AttributeUsage(AttributeTargets.All)] - public class JoinNameAttribute : CAttribute - { - private string _Name; - - public JoinNameAttribute(string name) - { - Debug.Console(2, "Setting Attribute Name: {0}", name); - _Name = name; - } - - public string Name - { - get { return _Name; } - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBaseAdvanced.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBaseAdvanced.cs new file mode 100644 index 00000000..f6786413 --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapBaseAdvanced.cs @@ -0,0 +1,253 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharp.Reflection; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Base class for join maps + /// + public abstract class JoinMapBaseAdvanced + { + protected uint JoinOffset; + + /// + /// The collection of joins and associated metadata + /// + public Dictionary Joins { get; private set; } + + protected JoinMapBaseAdvanced(uint joinStart) + { + Joins = new Dictionary(); + + JoinOffset = joinStart - 1; + } + + protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart) + { + AddJoins(type); + } + + protected void AddJoins(Type type) + { + var fields = + type.GetCType() + .GetFields(BindingFlags.Public | BindingFlags.Instance) + .Where(f => f.IsDefined(typeof (JoinNameAttribute), true)); + + foreach (var field in fields) + { + var childClass = Convert.ChangeType(this, type, null); + + var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields. + + if (value == null) + { + Debug.Console(0, "Unable to cast base class to {0}", type.Name); + continue; + } + + value.SetJoinOffset(JoinOffset); + + var joinName = value.GetNameAttribute(field); + + if (String.IsNullOrEmpty(joinName)) continue; + + Joins.Add(joinName, value); + } + + + if (Debug.Level > 0) + { + PrintJoinMapInfo(); + } + } + + /// + /// Prints the join information to console + /// + public void PrintJoinMapInfo() + { + Debug.Console(0, "{0}:\n", 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); + Debug.Console(2, "Found {0} Digital Joins", digitals.Count); + 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); + Debug.Console(2, "Found {0} Analog Joins", analogs.Count); + 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); + Debug.Console(2, "Found {0} Serial Joins", serials.Count); + PrintJoinList(GetSortedJoins(serials)); + + } + /// + /// Prints the join information to console + /// + public void MarkdownJoinMapInfo(string deviceKey, string bridgeKey) + { + var pluginType = GetType().Name; + + Debug.Console(0, "{0}:\n", pluginType); + + var sb = new StringBuilder(); + + sb.AppendLine(String.Format("# {0}", GetType().Name)); + sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey)); + sb.AppendLine(); + sb.AppendLine("## Digitals"); + // Get the joins of each type and print them + var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Digital Joins", digitals.Count); + var digitalSb = AppendJoinList(GetSortedJoins(digitals)); + digitalSb.AppendLine("## Analogs"); + digitalSb.AppendLine(); + + Debug.Console(0, "Analogs:"); + var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Analog Joins", analogs.Count); + var analogSb = AppendJoinList(GetSortedJoins(analogs)); + analogSb.AppendLine("## Serials"); + analogSb.AppendLine(); + + Debug.Console(0, "Serials:"); + var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); + Debug.Console(2, "Found {0} Serial Joins", serials.Count); + var serialSb = AppendJoinList(GetSortedJoins(serials)); + + sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); + sb.Append(digitalSb).Append(analogSb).Append(serialSb); + + WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey); + + } + + private static void WriteJoinmapMarkdown(StringBuilder stringBuilder, string pluginType, string bridgeKey, string deviceKey) + { + var fileName = String.Format("{0}{1}{2}__{3}__{4}.md", Global.FilePathPrefix, "joinMaps/", pluginType, bridgeKey, deviceKey); + + using (var sw = new StreamWriter(fileName)) + { + sw.WriteLine(stringBuilder.ToString()); + Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName); + } + + } + + /// + /// 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}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'", + join.Value.JoinNumber, + join.Value.JoinSpan, + join.Key, + String.IsNullOrEmpty(join.Value.AttributeName) ? join.Value.Metadata.Label : join.Value.AttributeName, + join.Value.Metadata.JoinType.ToString(), + join.Value.Metadata.JoinCapabilities.ToString()); + } + } + + static StringBuilder AppendJoinList(List> joins) + { + var sb = new StringBuilder(); + const string stringFormatter = "| {0} | {1} | {2} | {3} | {4} |"; + const int joinNumberLen = 11; + const int joinSpanLen = 9; + const int typeLen = 19; + const int capabilitiesLen = 12; + var descriptionLen = (from @join in joins select @join.Value into j select j.Metadata.Description.Length).Concat(new[] {11}).Max(); + + //build header + sb.AppendLine(String.Format(stringFormatter, + String.Format("Join Number").PadRight(joinNumberLen, ' '), + String.Format("Join Span").PadRight(joinSpanLen, ' '), + String.Format("Description").PadRight(descriptionLen, ' '), + String.Format("Type").PadRight(typeLen, ' '), + String.Format("Capabilities").PadRight(capabilitiesLen, ' '))); + //build table seperator + sb.AppendLine(String.Format(stringFormatter, + new String('-', joinNumberLen), + new String('-', joinSpanLen), + new String('-', descriptionLen), + new String('-', typeLen), + new String('-', capabilitiesLen))); + + foreach (var join in joins) + { + sb.AppendLine(join.Value.GetMarkdownFormattedData(stringFormatter, descriptionLen)); + } + sb.AppendLine(); + return sb; + } + + /// + /// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom + /// + /// + public void SetCustomJoinData(Dictionary joinData) + { + foreach (var customJoinData in joinData) + { + var join = Joins[customJoinData.Key]; + + if (join != null) + { + join.SetCustomJoinData(customJoinData.Value); + } + else + { + Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); + } + } + + PrintJoinMapInfo(); + } + + ///// + ///// 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; + //} + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMapHelper.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapHelper.cs new file mode 100644 index 00000000..c1610f7b --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMapHelper.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public static class JoinMapHelper + { + /// + /// Attempts to get the serialized join map from config + /// + /// + /// + public static string GetSerializedJoinMapForDevice(string joinMapKey) + { + if (string.IsNullOrEmpty(joinMapKey)) + return null; + + var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; + + return joinMap.ToString(); + } + + /// + /// Attempts to get the serialized join map from config + /// + /// + /// + public static string GetJoinMapForDevice(string joinMapKey) + { + return GetSerializedJoinMapForDevice(joinMapKey); + } + + /// + /// Attempts to find a custom join map by key and returns it deserialized if found + /// + /// + /// + public static Dictionary TryGetJoinMapAdvancedForDevice(string joinMapKey) + { + try + { + if (string.IsNullOrEmpty(joinMapKey)) + return null; + + if (!ConfigReader.ConfigObject.JoinMaps.ContainsKey(joinMapKey)) + { + Debug.Console(2, "No Join Map found in config with key: '{0}'", joinMapKey); + return null; + } + + Debug.Console(2, "Attempting to load custom join map with key: {0}", joinMapKey); + + var joinMapJToken = ConfigReader.ConfigObject.JoinMaps[joinMapKey]; + + if (joinMapJToken == null) + return null; + + var joinMapData = joinMapJToken.ToObject>(); + + return joinMapData; + } + catch (Exception e) + { + Debug.Console(2, "Error getting join map for key: '{0}'. Error: {1}", joinMapKey, e); + return null; + } + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinMetadata.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinMetadata.cs new file mode 100644 index 00000000..e4ae111a --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinMetadata.cs @@ -0,0 +1,56 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + /// + /// Metadata describing the join + /// + public class JoinMetadata + { + private string _description; + + /// + /// 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 its usage + /// + [Obsolete("Use Description instead")] + [JsonProperty("label")] + public string Label { get { return _description; } set { _description = value; } } + + /// + /// A description for the join to better describe its usage + /// + [JsonProperty("description")] + public string Description { get { return _description; } set { _description = value; } } + /// + /// Signal type(s) + /// + [JsonProperty("joinType")] + public eJoinType JoinType { get; set; } + /// + /// Indicates whether the join is read and/or write + /// + [JsonProperty("joinCapabilities")] + public eJoinCapabilities JoinCapabilities { get; set; } + /// + /// Indicates a set of valid values (particularly if this translates to an enum + /// + [JsonProperty("validValues")] + public string[] ValidValues { get; set; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/JoinNameAttribute.cs b/src/PepperDash.Essentials.Core/JoinMaps/JoinNameAttribute.cs new file mode 100644 index 00000000..b60a673f --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/JoinNameAttribute.cs @@ -0,0 +1,23 @@ +using System; +using Crestron.SimplSharp.Reflection; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + [AttributeUsage(AttributeTargets.All)] + public class JoinNameAttribute : CAttribute + { + private string _Name; + + public JoinNameAttribute(string name) + { + Debug.Console(2, "Setting Attribute Name: {0}", name); + _Name = name; + } + + public string Name + { + get { return _Name; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/eJoinCapabilities.cs b/src/PepperDash.Essentials.Core/JoinMaps/eJoinCapabilities.cs new file mode 100644 index 00000000..885f59ab --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/eJoinCapabilities.cs @@ -0,0 +1,20 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// Read = Provides feedback to SIMPL + /// Write = Responds to sig values from SIMPL + /// + [Flags] + public enum eJoinCapabilities + { + None = 0, + ToSIMPL = 1, + FromSIMPL = 2, + ToFromSIMPL = ToSIMPL | FromSIMPL, + ToFusion = 4, + FromFusion = 8, + ToFromFusion = ToFusion | FromFusion, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/JoinMaps/eJoinType.cs b/src/PepperDash.Essentials.Core/JoinMaps/eJoinType.cs new file mode 100644 index 00000000..07c91e30 --- /dev/null +++ b/src/PepperDash.Essentials.Core/JoinMaps/eJoinType.cs @@ -0,0 +1,17 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + [Flags] + public enum eJoinType + { + None = 0, + Digital = 1, + Analog = 2, + Serial = 4, + DigitalAnalog = Digital | Analog, + DigitalSerial = Digital | Serial, + AnalogSerial = Analog | Serial, + DigitalAnalogSerial = Digital | Analog | Serial, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs b/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs deleted file mode 100644 index 4afb85bf..00000000 --- a/src/PepperDash.Essentials.Core/License/EssentialsLicenseManager.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronDataStore; - -using PepperDash.Essentials.Core; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.License -{ - public abstract class LicenseManager - { - public BoolFeedback LicenseIsValid { get; protected set; } - public StringFeedback LicenseMessage { get; protected set; } - public StringFeedback LicenseLog { get; protected set; } - - protected LicenseManager() - { - CrestronConsole.AddNewConsoleCommand( - s => CrestronConsole.ConsoleCommandResponse(GetStatusString()), - "licensestatus", "shows license and related data", - ConsoleAccessLevelEnum.AccessOperator); - } - - protected abstract string GetStatusString(); - } - - public class MockEssentialsLicenseManager : LicenseManager - { - /// - /// Returns the singleton mock license manager for this app - /// - public static MockEssentialsLicenseManager Manager - { - get - { - if (_Manager == null) - _Manager = new MockEssentialsLicenseManager(); - return _Manager; - } - } - static MockEssentialsLicenseManager _Manager; - - bool IsValid; - - MockEssentialsLicenseManager() : base() - { - LicenseIsValid = new BoolFeedback("LicenseIsValid", - () => { return IsValid; }); - CrestronConsole.AddNewConsoleCommand( - s => SetFromConsole(s.Equals("true", StringComparison.OrdinalIgnoreCase)), - "mocklicense", "true or false for testing", ConsoleAccessLevelEnum.AccessOperator); - - bool valid; - var err = CrestronDataStoreStatic.GetGlobalBoolValue("MockLicense", out valid); - if (err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) - SetIsValid(valid); - else if (err == CrestronDataStore.CDS_ERROR.CDS_RECORD_NOT_FOUND) - CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", false); - else - CrestronConsole.PrintLine("Error restoring Mock License setting: {0}", err); - } - - void SetIsValid(bool isValid) - { - IsValid = isValid; - CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid); - Debug.Console(0, "Mock License is{0} valid", IsValid ? "" : " not"); - LicenseIsValid.FireUpdate(); - } - - void SetFromConsole(bool isValid) - { - SetIsValid(isValid); - } - - protected override string GetStatusString() - { - return string.Format("License Status: {0}", IsValid ? "Valid" : "Not Valid"); - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/License/LicenseManager.cs b/src/PepperDash.Essentials.Core/License/LicenseManager.cs new file mode 100644 index 00000000..8cfa8730 --- /dev/null +++ b/src/PepperDash.Essentials.Core/License/LicenseManager.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + + +namespace PepperDash.Essentials.License +{ + public abstract class LicenseManager + { + public BoolFeedback LicenseIsValid { get; protected set; } + public StringFeedback LicenseMessage { get; protected set; } + public StringFeedback LicenseLog { get; protected set; } + + protected LicenseManager() + { + CrestronConsole.AddNewConsoleCommand( + s => CrestronConsole.ConsoleCommandResponse(GetStatusString()), + "licensestatus", "shows license and related data", + ConsoleAccessLevelEnum.AccessOperator); + } + + protected abstract string GetStatusString(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/License/MockEssentialsLicenseManager.cs b/src/PepperDash.Essentials.Core/License/MockEssentialsLicenseManager.cs new file mode 100644 index 00000000..1cadde1c --- /dev/null +++ b/src/PepperDash.Essentials.Core/License/MockEssentialsLicenseManager.cs @@ -0,0 +1,63 @@ +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronDataStore; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.License +{ + public class MockEssentialsLicenseManager : LicenseManager + { + /// + /// Returns the singleton mock license manager for this app + /// + public static MockEssentialsLicenseManager Manager + { + get + { + if (_Manager == null) + _Manager = new MockEssentialsLicenseManager(); + return _Manager; + } + } + static MockEssentialsLicenseManager _Manager; + + bool IsValid; + + MockEssentialsLicenseManager() : base() + { + LicenseIsValid = new BoolFeedback("LicenseIsValid", + () => { return IsValid; }); + CrestronConsole.AddNewConsoleCommand( + s => SetFromConsole(s.Equals("true", StringComparison.OrdinalIgnoreCase)), + "mocklicense", "true or false for testing", ConsoleAccessLevelEnum.AccessOperator); + + bool valid; + var err = CrestronDataStoreStatic.GetGlobalBoolValue("MockLicense", out valid); + if (err == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) + SetIsValid(valid); + else if (err == CrestronDataStore.CDS_ERROR.CDS_RECORD_NOT_FOUND) + CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", false); + else + CrestronConsole.PrintLine("Error restoring Mock License setting: {0}", err); + } + + void SetIsValid(bool isValid) + { + IsValid = isValid; + CrestronDataStoreStatic.SetGlobalBoolValue("MockLicense", isValid); + Debug.Console(0, "Mock License is{0} valid", IsValid ? "" : " not"); + LicenseIsValid.FireUpdate(); + } + + void SetFromConsole(bool isValid) + { + SetIsValid(isValid); + } + + protected override string GetStatusString() + { + return string.Format("License Status: {0}", IsValid ? "Valid" : "Not Valid"); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/ILightingLoad.cs b/src/PepperDash.Essentials.Core/Lighting/ILightingLoad.cs new file mode 100644 index 00000000..24890793 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Lighting/ILightingLoad.cs @@ -0,0 +1,15 @@ +namespace PepperDash.Essentials.Core.Lighting +{ + /// + /// Requiremnts for controlling a lighting load + /// + public interface ILightingLoad + { + void SetLoadLevel(int level); + void Raise(); + void Lower(); + + IntFeedback LoadLevelFeedback { get; } + BoolFeedback LoadIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/ILightingMasterRaiseLower.cs b/src/PepperDash.Essentials.Core/Lighting/ILightingMasterRaiseLower.cs new file mode 100644 index 00000000..da4308c3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Lighting/ILightingMasterRaiseLower.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core.Lighting +{ + /// + /// Requirements for a device that implements master raise/lower + /// + public interface ILightingMasterRaiseLower + { + void MasterRaise(); + void MasterLower(); + void MasterRaiseLowerStop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/ILightingScenes.cs b/src/PepperDash.Essentials.Core/Lighting/ILightingScenes.cs new file mode 100644 index 00000000..09f3d8b7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Lighting/ILightingScenes.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Lighting +{ + /// + /// Requirements for a device that implements lighting scene control + /// + public interface ILightingScenes + { + event EventHandler LightingSceneChange; + + List LightingScenes { get; } + + void SelectScene(LightingScene scene); + + LightingScene CurrentLightingScene { get; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/Lighting Interfaces.cs b/src/PepperDash.Essentials.Core/Lighting/Lighting Interfaces.cs deleted file mode 100644 index 6c0eaad3..00000000 --- a/src/PepperDash.Essentials.Core/Lighting/Lighting Interfaces.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Lighting -{ - /// - /// Requirements for a device that implements lighting scene control - /// - public interface ILightingScenes - { - event EventHandler LightingSceneChange; - - List LightingScenes { get; } - - void SelectScene(LightingScene scene); - - LightingScene CurrentLightingScene { get; } - - } - - /// - /// Requirements for a device that implements master raise/lower - /// - public interface ILightingMasterRaiseLower - { - void MasterRaise(); - void MasterLower(); - void MasterRaiseLowerStop(); - } - - /// - /// Requiremnts for controlling a lighting load - /// - public interface ILightingLoad - { - void SetLoadLevel(int level); - void Raise(); - void Lower(); - - IntFeedback LoadLevelFeedback { get; } - BoolFeedback LoadIsOnFeedback { get; } - } - - public class LightingSceneChangeEventArgs : EventArgs - { - public LightingScene CurrentLightingScene { get; private set; } - - public LightingSceneChangeEventArgs(LightingScene scene) - { - CurrentLightingScene = scene; - } - } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs b/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs index 5bb677a2..addb0cd9 100644 --- a/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs +++ b/src/PepperDash.Essentials.Core/Lighting/LightingBase.cs @@ -136,34 +136,4 @@ namespace PepperDash.Essentials.Core.Lighting return joinMap; } } - - public class LightingScene - { - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] - public string Name { get; set; } - [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] - public string ID { get; set; } - bool _IsActive; - [JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)] - public bool IsActive - { - get - { - return _IsActive; - } - set - { - _IsActive = value; - IsActiveFeedback.FireUpdate(); - } - } - - [JsonIgnore] - public BoolFeedback IsActiveFeedback { get; set; } - - public LightingScene() - { - IsActiveFeedback = new BoolFeedback(new Func(() => IsActive)); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/LightingScene.cs b/src/PepperDash.Essentials.Core/Lighting/LightingScene.cs new file mode 100644 index 00000000..b4d521aa --- /dev/null +++ b/src/PepperDash.Essentials.Core/Lighting/LightingScene.cs @@ -0,0 +1,36 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Lighting +{ + public class LightingScene + { + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name { get; set; } + [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] + public string ID { get; set; } + bool _IsActive; + [JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)] + public bool IsActive + { + get + { + return _IsActive; + } + set + { + _IsActive = value; + IsActiveFeedback.FireUpdate(); + } + } + + [JsonIgnore] + public BoolFeedback IsActiveFeedback { get; set; } + + public LightingScene() + { + IsActiveFeedback = new BoolFeedback(new Func(() => IsActive)); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Lighting/LightingSceneChangeEventArgs.cs b/src/PepperDash.Essentials.Core/Lighting/LightingSceneChangeEventArgs.cs new file mode 100644 index 00000000..aaed1350 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Lighting/LightingSceneChangeEventArgs.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Lighting +{ + public class LightingSceneChangeEventArgs : EventArgs + { + public LightingScene CurrentLightingScene { get; private set; } + + public LightingSceneChangeEventArgs(LightingScene scene) + { + CurrentLightingScene = scene; + } + } + +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Microphone Privacy/KeyedDevice.cs b/src/PepperDash.Essentials.Core/Microphone Privacy/KeyedDevice.cs new file mode 100644 index 00000000..e340694c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Microphone Privacy/KeyedDevice.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Core.Privacy +{ + public class KeyedDevice + { + public string DeviceKey { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs index 55b458a7..0900bfd8 100644 --- a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs +++ b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyController.cs @@ -6,7 +6,6 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.CrestronIO; @@ -234,21 +233,4 @@ namespace PepperDash.Essentials.Core.Privacy } } } - - public class MicrophonePrivacyControllerFactory : EssentialsDeviceFactory - { - public MicrophonePrivacyControllerFactory() - { - TypeNames = new List() { "microphoneprivacycontroller" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new MIcrophonePrivacyController Device"); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); - - return new Core.Privacy.MicrophonePrivacyController(dc.Key, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerConfig.cs b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerConfig.cs index 1c172090..3d35b1c4 100644 --- a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerConfig.cs +++ b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerConfig.cs @@ -14,9 +14,4 @@ namespace PepperDash.Essentials.Core.Privacy public KeyedDevice GreenLedRelay { get; set; } public KeyedDevice RedLedRelay { get; set; } } - - public class KeyedDevice - { - public string DeviceKey { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerFactory.cs b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerFactory.cs new file mode 100644 index 00000000..e3a036c6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Microphone Privacy/MicrophonePrivacyControllerFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Privacy +{ + public class MicrophonePrivacyControllerFactory : EssentialsDeviceFactory + { + public MicrophonePrivacyControllerFactory() + { + TypeNames = new List() { "microphoneprivacycontroller" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new MIcrophonePrivacyController Device"); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + + return new Core.Privacy.MicrophonePrivacyController(dc.Key, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/CommunicationMonitorConfig.cs b/src/PepperDash.Essentials.Core/Monitoring/CommunicationMonitorConfig.cs new file mode 100644 index 00000000..d44c7de8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/CommunicationMonitorConfig.cs @@ -0,0 +1,18 @@ +namespace PepperDash.Essentials.Core +{ + public class CommunicationMonitorConfig + { + public int PollInterval { get; set; } + public int TimeToWarning { get; set; } + public int TimeToError { get; set; } + public string PollString { get; set; } + + public CommunicationMonitorConfig() + { + PollInterval = 30000; + TimeToWarning = 120000; + TimeToError = 300000; + PollString = ""; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs index edb4c31b..14d31d9c 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/GenericCommunicationMonitor.cs @@ -244,21 +244,4 @@ namespace PepperDash.Essentials.Core } } } - - - public class CommunicationMonitorConfig - { - public int PollInterval { get; set; } - public int TimeToWarning { get; set; } - public int TimeToError { get; set; } - public string PollString { get; set; } - - public CommunicationMonitorConfig() - { - PollInterval = 30000; - TimeToWarning = 120000; - TimeToError = 300000; - PollString = ""; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/ICommunicationMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/ICommunicationMonitor.cs new file mode 100644 index 00000000..dced2e7f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/ICommunicationMonitor.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Represents a class that has a basic communication monitoring + /// + public interface ICommunicationMonitor + { + StatusMonitorBase CommunicationMonitor { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/IStatusMonitor.cs b/src/PepperDash.Essentials.Core/Monitoring/IStatusMonitor.cs new file mode 100644 index 00000000..4ffbed39 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/IStatusMonitor.cs @@ -0,0 +1,16 @@ +using System; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public interface IStatusMonitor + { + IKeyed Parent { get; } + event EventHandler StatusChange; + MonitorStatus Status { get; } + string Message { get; } + BoolFeedback IsOnlineFeedback { get; set; } + void Start(); + void Stop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/Interfaces.cs b/src/PepperDash.Essentials.Core/Monitoring/Interfaces.cs deleted file mode 100644 index 6e4a847e..00000000 --- a/src/PepperDash.Essentials.Core/Monitoring/Interfaces.cs +++ /dev/null @@ -1,57 +0,0 @@ - -using System; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - public interface IStatusMonitor - { - IKeyed Parent { get; } - event EventHandler StatusChange; - MonitorStatus Status { get; } - string Message { get; } - BoolFeedback IsOnlineFeedback { get; set; } - void Start(); - void Stop(); - } - - - /// - /// Represents a class that has a basic communication monitoring - /// - public interface ICommunicationMonitor - { - StatusMonitorBase CommunicationMonitor { get; } - } - - /// - /// StatusUnknown = 0, IsOk = 1, InWarning = 2, InError = 3 - /// - public enum MonitorStatus - { - StatusUnknown = 0, - IsOk = 1, - InWarning = 2, - InError = 3 - } - - public class MonitorStatusChangeEventArgs : EventArgs - { - public MonitorStatus Status { get; private set; } - public string Message { get; private set; } - - public MonitorStatusChangeEventArgs(MonitorStatus status) - { - Status = status; - Message = status == MonitorStatus.IsOk ? "" : status.ToString(); - } - - public MonitorStatusChangeEventArgs(MonitorStatus status, string message) - { - Status = status; - Message = message; - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/MonitorStatus.cs b/src/PepperDash.Essentials.Core/Monitoring/MonitorStatus.cs new file mode 100644 index 00000000..2b67a509 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/MonitorStatus.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// StatusUnknown = 0, IsOk = 1, InWarning = 2, InError = 3 + /// + public enum MonitorStatus + { + StatusUnknown = 0, + IsOk = 1, + InWarning = 2, + InError = 3 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/MonitorStatusChangeEventArgs.cs b/src/PepperDash.Essentials.Core/Monitoring/MonitorStatusChangeEventArgs.cs new file mode 100644 index 00000000..71b6da3c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/MonitorStatusChangeEventArgs.cs @@ -0,0 +1,24 @@ + +using System; + + +namespace PepperDash.Essentials.Core +{ + public class MonitorStatusChangeEventArgs : EventArgs + { + public MonitorStatus Status { get; private set; } + public string Message { get; private set; } + + public MonitorStatusChangeEventArgs(MonitorStatus status) + { + Status = status; + Message = status == MonitorStatus.IsOk ? "" : status.ToString(); + } + + public MonitorStatusChangeEventArgs(MonitorStatus status, string message) + { + Status = status; + Message = message; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/ProgramInfo.cs b/src/PepperDash.Essentials.Core/Monitoring/ProgramInfo.cs new file mode 100644 index 00000000..08a0e74a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/ProgramInfo.cs @@ -0,0 +1,89 @@ +extern alias Full; +using Crestron.SimplSharpPro.Diagnostics; +using Full::Newtonsoft.Json; +using Full::Newtonsoft.Json.Converters; + +namespace PepperDash.Essentials.Core.Monitoring +{ + /// + /// Class for serializing program slot information + /// + public class ProgramInfo + { + // Shared properties + + [JsonProperty("programNumber")] + public uint ProgramNumber { get; private set; } + + [JsonConverter(typeof (StringEnumConverter))] + [JsonProperty("operatingState")] + public eProgramOperatingState OperatingState { get; set; } + + [JsonConverter(typeof (StringEnumConverter))] + [JsonProperty("registrationState")] + public eProgramRegistrationState RegistrationState { get; set; } + + [JsonProperty("programFile")] + public string ProgramFile { get; set; } + + [JsonProperty("friendlyName")] + public string FriendlyName { get; set; } + + [JsonProperty("compilerRevision")] + public string CompilerRevision { get; set; } + + [JsonProperty("compileTime")] + public string CompileTime { get; set; } + + [JsonProperty("include4Dat")] + public string Include4Dat { get; set; } + + // SIMPL Windows properties + [JsonProperty("systemName")] + public string SystemName { get; set; } + + [JsonProperty("crestronDb")] + public string CrestronDb { get; set; } + + [JsonProperty("environment")] + public string Environment { get; set; } + + [JsonProperty("programmer")] + public string Programmer { get; set; } + + + // SSP Properties + [JsonProperty("applicationName")] + public string ApplicationName { get; set; } + + [JsonProperty("programTool")] + public string ProgramTool { get; set; } + + [JsonProperty("minFirmwareVersion")] + public string MinFirmwareVersion { get; set; } + + [JsonProperty("plugInVersion")] + public string PlugInVersion { get; set; } + + public ProgramInfo(uint number) + { + ProgramNumber = number; + + ProgramFile = ""; + FriendlyName = ""; + CompilerRevision = ""; + CompileTime = ""; + Include4Dat = ""; + + SystemName = ""; + CrestronDb = ""; + Environment = ""; + Programmer = ""; + + ApplicationName = ""; + ProgramTool = ""; + MinFirmwareVersion = ""; + PlugInVersion = ""; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/ProgramInfoEventArgs.cs b/src/PepperDash.Essentials.Core/Monitoring/ProgramInfoEventArgs.cs new file mode 100644 index 00000000..00cac85e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Monitoring/ProgramInfoEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core.Monitoring +{ + public class ProgramInfoEventArgs : EventArgs + { + public ProgramInfo ProgramInfo; + + public ProgramInfoEventArgs(ProgramInfo progInfo) + { + ProgramInfo = progInfo; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs index b9d25127..3cc71e85 100644 --- a/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs +++ b/src/PepperDash.Essentials.Core/Monitoring/SystemMonitorController.cs @@ -8,7 +8,6 @@ using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.Diagnostics; using PepperDash.Core; using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Core.Monitoring @@ -664,96 +663,4 @@ namespace PepperDash.Essentials.Core.Monitoring } } } - - /// - /// Class for serializing program slot information - /// - public class ProgramInfo - { - // Shared properties - - [JsonProperty("programNumber")] - public uint ProgramNumber { get; private set; } - - [JsonConverter(typeof (StringEnumConverter))] - [JsonProperty("operatingState")] - public eProgramOperatingState OperatingState { get; set; } - - [JsonConverter(typeof (StringEnumConverter))] - [JsonProperty("registrationState")] - public eProgramRegistrationState RegistrationState { get; set; } - - [JsonProperty("programFile")] - public string ProgramFile { get; set; } - - [JsonProperty("friendlyName")] - public string FriendlyName { get; set; } - - [JsonProperty("compilerRevision")] - public string CompilerRevision { get; set; } - - [JsonProperty("compileTime")] - public string CompileTime { get; set; } - - [JsonProperty("include4Dat")] - public string Include4Dat { get; set; } - - // SIMPL Windows properties - [JsonProperty("systemName")] - public string SystemName { get; set; } - - [JsonProperty("crestronDb")] - public string CrestronDb { get; set; } - - [JsonProperty("environment")] - public string Environment { get; set; } - - [JsonProperty("programmer")] - public string Programmer { get; set; } - - - // SSP Properties - [JsonProperty("applicationName")] - public string ApplicationName { get; set; } - - [JsonProperty("programTool")] - public string ProgramTool { get; set; } - - [JsonProperty("minFirmwareVersion")] - public string MinFirmwareVersion { get; set; } - - [JsonProperty("plugInVersion")] - public string PlugInVersion { get; set; } - - public ProgramInfo(uint number) - { - ProgramNumber = number; - - ProgramFile = ""; - FriendlyName = ""; - CompilerRevision = ""; - CompileTime = ""; - Include4Dat = ""; - - SystemName = ""; - CrestronDb = ""; - Environment = ""; - Programmer = ""; - - ApplicationName = ""; - ProgramTool = ""; - MinFirmwareVersion = ""; - PlugInVersion = ""; - } - } - - public class ProgramInfoEventArgs : EventArgs - { - public ProgramInfo ProgramInfo; - - public ProgramInfoEventArgs(ProgramInfo progInfo) - { - ProgramInfo = progInfo; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/GlsOccupancySensorBaseControllerFactory.cs b/src/PepperDash.Essentials.Core/Occupancy/GlsOccupancySensorBaseControllerFactory.cs new file mode 100644 index 00000000..190e298a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Occupancy/GlsOccupancySensorBaseControllerFactory.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory + { + public GlsOccupancySensorBaseControllerFactory() + { + TypeNames = new List { "glsoirccn" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOirOccupancySensorController Device"); + + return new GlsOirOccupancySensorController(dc.Key, GetGlsOirCCn, dc); + } + + private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); + return new GlsOirCCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); + return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorController.cs b/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorController.cs index dd6b3605..1c582915 100644 --- a/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorController.cs +++ b/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorController.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; @@ -239,46 +238,4 @@ namespace PepperDash.Essentials.Core } } - - public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory - { - public GlsOdtOccupancySensorControllerFactory() - { - TypeNames = new List { "glsodtccn" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); - } - - private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = String.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - } - - - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorControllerFactory.cs b/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorControllerFactory.cs new file mode 100644 index 00000000..04567ad7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Occupancy/GlsOdtOccupancySensorControllerFactory.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory + { + public GlsOdtOccupancySensorControllerFactory() + { + TypeNames = new List { "glsodtccn" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); + } + + private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = String.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/GlsOirOccupancySensorController.cs b/src/PepperDash.Essentials.Core/Occupancy/GlsOirOccupancySensorController.cs index 573d94ac..52be60dc 100644 --- a/src/PepperDash.Essentials.Core/Occupancy/GlsOirOccupancySensorController.cs +++ b/src/PepperDash.Essentials.Core/Occupancy/GlsOirOccupancySensorController.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; -using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; @@ -37,44 +35,4 @@ namespace PepperDash.Essentials.Core #endregion } - - public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory - { - public GlsOccupancySensorBaseControllerFactory() - { - TypeNames = new List { "glsoirccn" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOirOccupancySensorController Device"); - - return new GlsOirOccupancySensorController(dc.Key, GetGlsOirCCn, dc); - } - - private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); - return new GlsOirCCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); - return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/IOccupancyStatusProviderAggregator.cs b/src/PepperDash.Essentials.Core/Occupancy/IOccupancyStatusProviderAggregator.cs index dfa4fef1..f42563f0 100644 --- a/src/PepperDash.Essentials.Core/Occupancy/IOccupancyStatusProviderAggregator.cs +++ b/src/PepperDash.Essentials.Core/Occupancy/IOccupancyStatusProviderAggregator.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.GeneralIO; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { @@ -88,22 +86,4 @@ namespace PepperDash.Essentials.Core _aggregatedOccupancyStatus.ClearOutputs(); } } - - public class OccupancyAggregatorFactory : EssentialsDeviceFactory - { - public OccupancyAggregatorFactory() - { - TypeNames = new List { "occupancyAggregator", "occAggregate" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - var config = dc.Properties.ToObject(); - - return new IOccupancyStatusProviderAggregator(dc.Key, dc.Name, config); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Occupancy/OccupancyAggregatorFactory.cs b/src/PepperDash.Essentials.Core/Occupancy/OccupancyAggregatorFactory.cs new file mode 100644 index 00000000..905d6a72 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Occupancy/OccupancyAggregatorFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class OccupancyAggregatorFactory : EssentialsDeviceFactory + { + public OccupancyAggregatorFactory() + { + TypeNames = new List { "occupancyAggregator", "occAggregate" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + var config = dc.Properties.ToObject(); + + return new IOccupancyStatusProviderAggregator(dc.Key, dc.Name, config); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionController.cs b/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionController.cs new file mode 100644 index 00000000..b856deed --- /dev/null +++ b/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionController.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + /// + /// Describes the functionality of a device that can provide partition state either manually via user input or optionally via a sensor state + /// + public interface IPartitionController : IPartitionStateProvider + { + List AdjacentRoomKeys { get; } + + void SetPartitionStatePresent(); + + void SetPartitionStateNotPresent(); + + void ToggglePartitionState(); + + void SetManualMode(); + + void SetAutoMode(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionStateProvider.cs b/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionStateProvider.cs index adb420b7..c5c0fde0 100644 --- a/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionStateProvider.cs +++ b/src/PepperDash.Essentials.Core/PartitionSensor/IPartitionStateProvider.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -15,22 +14,4 @@ namespace PepperDash.Essentials.Core { BoolFeedback PartitionPresentFeedback { get; } } - - /// - /// Describes the functionality of a device that can provide partition state either manually via user input or optionally via a sensor state - /// - public interface IPartitionController : IPartitionStateProvider - { - List AdjacentRoomKeys { get; } - - void SetPartitionStatePresent(); - - void SetPartitionStateNotPresent(); - - void ToggglePartitionState(); - - void SetManualMode(); - - void SetAutoMode(); - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Plugins/IPluginDevelopmentDeviceFactory.cs b/src/PepperDash.Essentials.Core/Plugins/IPluginDevelopmentDeviceFactory.cs new file mode 100644 index 00000000..699a8388 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Plugins/IPluginDevelopmentDeviceFactory.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public interface IPluginDevelopmentDeviceFactory : IPluginDeviceFactory + { + List DevelopmentEssentialsFrameworkVersions { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Plugins/IPluginDeviceFactory.cs b/src/PepperDash.Essentials.Core/Plugins/IPluginDeviceFactory.cs index ec823007..592f3951 100644 --- a/src/PepperDash.Essentials.Core/Plugins/IPluginDeviceFactory.cs +++ b/src/PepperDash.Essentials.Core/Plugins/IPluginDeviceFactory.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using PepperDash.Core; @@ -15,11 +14,6 @@ namespace PepperDash.Essentials.Core string MinimumEssentialsFrameworkVersion { get; } } - - public interface IPluginDevelopmentDeviceFactory : IPluginDeviceFactory - { - List DevelopmentEssentialsFrameworkVersions { get; } - } } diff --git a/src/PepperDash.Essentials.Core/Plugins/LoadedAssembly.cs b/src/PepperDash.Essentials.Core/Plugins/LoadedAssembly.cs new file mode 100644 index 00000000..894f29ca --- /dev/null +++ b/src/PepperDash.Essentials.Core/Plugins/LoadedAssembly.cs @@ -0,0 +1,26 @@ +using Crestron.SimplSharp.Reflection; + +namespace PepperDash.Essentials +{ + /// + /// 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; + } + + public void SetAssembly(Assembly assembly) + { + Assembly = assembly; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs index 9da843b8..5a263630 100644 --- a/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs +++ b/src/PepperDash.Essentials.Core/Plugins/PluginLoader.cs @@ -521,26 +521,4 @@ namespace PepperDash.Essentials } } - - /// - /// 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; - } - - public void SetAssembly(Assembly assembly) - { - Assembly = assembly; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Presets/DevicePresets.cs b/src/PepperDash.Essentials.Core/Presets/DevicePresetsModel.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Presets/DevicePresets.cs rename to src/PepperDash.Essentials.Core/Presets/DevicePresetsModel.cs diff --git a/src/PepperDash.Essentials.Core/Presets/PresetChannel.cs b/src/PepperDash.Essentials.Core/Presets/PresetChannel.cs index 203722f3..37e0bd92 100644 --- a/src/PepperDash.Essentials.Core/Presets/PresetChannel.cs +++ b/src/PepperDash.Essentials.Core/Presets/PresetChannel.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -21,13 +20,4 @@ namespace PepperDash.Essentials.Core.Presets [JsonProperty(Required = Required.Always, PropertyName = "channel")] public string Channel { get; set; } } - - public class PresetsList - { - [JsonProperty(Required=Required.Always,PropertyName = "name")] - public string Name { get; set; } - - [JsonProperty(Required = Required.Always, PropertyName = "channels")] - public List Channels { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Presets/PresetsList.cs b/src/PepperDash.Essentials.Core/Presets/PresetsList.cs new file mode 100644 index 00000000..d8ed39a6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Presets/PresetsList.cs @@ -0,0 +1,15 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Presets +{ + public class PresetsList + { + [JsonProperty(Required=Required.Always,PropertyName = "name")] + public string Name { get; set; } + + [JsonProperty(Required = Required.Always, PropertyName = "channels")] + public List Channels { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs index e46e93cb..d3164411 100644 --- a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs +++ b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; @@ -492,55 +491,4 @@ namespace PepperDash.Essentials.Core } } } - - public class RoomOnToDefaultSourceWhenOccupiedConfig - { - [JsonProperty("roomKey")] - public string RoomKey { get; set; } - - [JsonProperty("enableRoomOnWhenOccupied")] - public bool EnableRoomOnWhenOccupied { get; set; } - - [JsonProperty("occupancyStartTime")] - public string OccupancyStartTime { get; set; } - - [JsonProperty("occupancyEndTime")] - public string OccupancyEndTime { get; set; } - - [JsonProperty("enableSunday")] - public bool EnableSunday { get; set; } - - [JsonProperty("enableMonday")] - public bool EnableMonday { get; set; } - - [JsonProperty("enableTuesday")] - public bool EnableTuesday { get; set; } - - [JsonProperty("enableWednesday")] - public bool EnableWednesday { get; set; } - - [JsonProperty("enableThursday")] - public bool EnableThursday { get; set; } - - [JsonProperty("enableFriday")] - public bool EnableFriday { get; set; } - - [JsonProperty("enableSaturday")] - public bool EnableSaturday { get; set; } - } - - public class RoomOnToDefaultSourceWhenOccupiedFactory : EssentialsDeviceFactory - { - public RoomOnToDefaultSourceWhenOccupiedFactory() - { - TypeNames = new List() { "roomonwhenoccupancydetectedfeature" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device"); - return new RoomOnToDefaultSourceWhenOccupied(dc); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedConfig.cs b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedConfig.cs new file mode 100644 index 00000000..4fb38f09 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedConfig.cs @@ -0,0 +1,41 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + public class RoomOnToDefaultSourceWhenOccupiedConfig + { + [JsonProperty("roomKey")] + public string RoomKey { get; set; } + + [JsonProperty("enableRoomOnWhenOccupied")] + public bool EnableRoomOnWhenOccupied { get; set; } + + [JsonProperty("occupancyStartTime")] + public string OccupancyStartTime { get; set; } + + [JsonProperty("occupancyEndTime")] + public string OccupancyEndTime { get; set; } + + [JsonProperty("enableSunday")] + public bool EnableSunday { get; set; } + + [JsonProperty("enableMonday")] + public bool EnableMonday { get; set; } + + [JsonProperty("enableTuesday")] + public bool EnableTuesday { get; set; } + + [JsonProperty("enableWednesday")] + public bool EnableWednesday { get; set; } + + [JsonProperty("enableThursday")] + public bool EnableThursday { get; set; } + + [JsonProperty("enableFriday")] + public bool EnableFriday { get; set; } + + [JsonProperty("enableSaturday")] + public bool EnableSaturday { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedFactory.cs b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedFactory.cs new file mode 100644 index 00000000..952c09d3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Behaviours/RoomOnToDefaultSourceWhenOccupiedFactory.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class RoomOnToDefaultSourceWhenOccupiedFactory : EssentialsDeviceFactory + { + public RoomOnToDefaultSourceWhenOccupiedFactory() + { + TypeNames = new List() { "roomonwhenoccupancydetectedfeature" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new RoomOnToDefaultSourceWhenOccupied Device"); + return new RoomOnToDefaultSourceWhenOccupied(dc); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs index 820d363f..2328774d 100644 --- a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs +++ b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombiner.cs @@ -277,21 +277,4 @@ namespace PepperDash.Essentials.Core #endregion } - - public class EssentialsRoomCombinerFactory : EssentialsDeviceFactory - { - public EssentialsRoomCombinerFactory() - { - TypeNames = new List { "essentialsroomcombiner" }; - } - - public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new EssentialsRoomCombiner Device"); - - var props = dc.Properties.ToObject(); - - return new EssentialsRoomCombiner(dc.Key, props); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerFactory.cs b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerFactory.cs new file mode 100644 index 00000000..b39234cf --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public class EssentialsRoomCombinerFactory : EssentialsDeviceFactory + { + public EssentialsRoomCombinerFactory() + { + TypeNames = new List { "essentialsroomcombiner" }; + } + + public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new EssentialsRoomCombiner Device"); + + var props = dc.Properties.ToObject(); + + return new EssentialsRoomCombiner(dc.Key, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs index d926a4a8..fa2ca2e8 100644 --- a/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs +++ b/src/PepperDash.Essentials.Core/Room/Combining/EssentialsRoomCombinerPropertiesConfig.cs @@ -5,9 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - -using PepperDash.Core; - using Full.Newtonsoft.Json; namespace PepperDash.Essentials.Core @@ -50,67 +47,4 @@ namespace PepperDash.Essentials.Core [JsonProperty("scenarioChangeDebounceTimeSeconds")] public int ScenarioChangeDebounceTimeSeconds { get; set; } } - - /// - /// Config properties for a partition that separates rooms - /// - public class PartitionConfig : IKeyName - { - [JsonProperty("key")] - public string Key { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Key of the device that implements IPartitionStateProvider to provide the state of the partition - /// - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - /// - /// Keys of the rooms that this partion would be located between - /// - [JsonProperty("adjacentRoomKeys")] - public List AdjacentRoomKeys { get; set; } - } - - /// - /// Config propeties for a room combination scenario - /// - public class RoomCombinationScenarioConfig : IKeyName - { - [JsonProperty("key")] - public string Key { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("partitionStates")] - public List PartitionStates { get; set; } - - /// - /// Determines which UI devices get mapped to which room in this scenario. The Key should be the key of the UI device and the Value should be the key of the room to map to - /// - [JsonProperty("uiMap")] - public Dictionary UiMap { get; set; } - - [JsonProperty("activationActions")] - public List ActivationActions { get; set; } - - [JsonProperty("deactivationActions")] - public List DeactivationActions { get; set; } - } - - /// - /// Config properties to represent the state of a partition sensor in a RoomCombinationScenario - /// - public class PartitionState - { - [JsonProperty("partitionKey")] - public string PartitionKey { get; set; } - - [JsonProperty("partitionSensedState")] - public bool PartitionPresent { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/IEssentialsRoomCombiner.cs b/src/PepperDash.Essentials.Core/Room/Combining/IEssentialsRoomCombiner.cs index e6bdd983..c9939fa1 100644 --- a/src/PepperDash.Essentials.Core/Room/Combining/IEssentialsRoomCombiner.cs +++ b/src/PepperDash.Essentials.Core/Room/Combining/IEssentialsRoomCombiner.cs @@ -65,33 +65,4 @@ namespace PepperDash.Essentials.Core /// void SetRoomCombinationScenario(string scenarioKey); } - - public interface IRoomCombinationScenario : IKeyName - { - /// - /// When true, indicates that this room combination scenario is active - /// - BoolFeedback IsActiveFeedback { get; } - - /// - /// Activates this room combination scenario - /// - void Activate(); - - /// - /// Deactivates this room combination scenario - /// - void Deactivate(); - - /// - /// The state of the partitions that would activate this scenario - /// - List PartitionStates { get; } - - /// - /// The mapping of UIs by key to rooms by key - /// - Dictionary UiMap { get; set; } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/IRoomCombinationScenario.cs b/src/PepperDash.Essentials.Core/Room/Combining/IRoomCombinationScenario.cs new file mode 100644 index 00000000..80f9b1d8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Combining/IRoomCombinationScenario.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public interface IRoomCombinationScenario : IKeyName + { + /// + /// When true, indicates that this room combination scenario is active + /// + BoolFeedback IsActiveFeedback { get; } + + /// + /// Activates this room combination scenario + /// + void Activate(); + + /// + /// Deactivates this room combination scenario + /// + void Deactivate(); + + /// + /// The state of the partitions that would activate this scenario + /// + List PartitionStates { get; } + + /// + /// The mapping of UIs by key to rooms by key + /// + Dictionary UiMap { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/PartitionConfig.cs b/src/PepperDash.Essentials.Core/Room/Combining/PartitionConfig.cs new file mode 100644 index 00000000..b1af1383 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Combining/PartitionConfig.cs @@ -0,0 +1,31 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Config properties for a partition that separates rooms + /// + public class PartitionConfig : IKeyName + { + [JsonProperty("key")] + public string Key { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Key of the device that implements IPartitionStateProvider to provide the state of the partition + /// + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + /// + /// Keys of the rooms that this partion would be located between + /// + [JsonProperty("adjacentRoomKeys")] + public List AdjacentRoomKeys { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/PartitionState.cs b/src/PepperDash.Essentials.Core/Room/Combining/PartitionState.cs new file mode 100644 index 00000000..f75361c4 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Combining/PartitionState.cs @@ -0,0 +1,17 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core +{ + /// + /// Config properties to represent the state of a partition sensor in a RoomCombinationScenario + /// + public class PartitionState + { + [JsonProperty("partitionKey")] + public string PartitionKey { get; set; } + + [JsonProperty("partitionSensedState")] + public bool PartitionPresent { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenarioConfig.cs b/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenarioConfig.cs new file mode 100644 index 00000000..b8a1bcd5 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Combining/RoomCombinationScenarioConfig.cs @@ -0,0 +1,34 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Config propeties for a room combination scenario + /// + public class RoomCombinationScenarioConfig : IKeyName + { + [JsonProperty("key")] + public string Key { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("partitionStates")] + public List PartitionStates { get; set; } + + /// + /// Determines which UI devices get mapped to which room in this scenario. The Key should be the key of the UI device and the Value should be the key of the room to map to + /// + [JsonProperty("uiMap")] + public Dictionary UiMap { get; set; } + + [JsonProperty("activationActions")] + public List ActivationActions { get; set; } + + [JsonProperty("deactivationActions")] + public List DeactivationActions { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomScheduledEventsConfig.cs b/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomScheduledEventsConfig.cs index a4239ec2..2f073ac3 100644 --- a/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomScheduledEventsConfig.cs +++ b/src/PepperDash.Essentials.Core/Room/Config/EssentialsRoomScheduledEventsConfig.cs @@ -1,10 +1,8 @@ extern alias Full; using System.Collections.Generic; -using Crestron.SimplSharp.Scheduler; using Full.Newtonsoft.Json; using Full.Newtonsoft.Json.Converters; -using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Room.Config { @@ -13,31 +11,4 @@ namespace PepperDash.Essentials.Room.Config [JsonProperty("scheduledEvents")] public List ScheduledEvents; } - - public class ScheduledEventConfig - { - [JsonProperty("key")] - public string Key; - - [JsonProperty("name")] - public string Name; - - [JsonProperty("days")] - public ScheduledEventCommon.eWeekDays Days; - - [JsonProperty("time")] - public string Time; - - [JsonProperty("actions")] - public List Actions; - - [JsonProperty("persistent")] - public bool Persistent; - - [JsonProperty("acknowledgeable")] - public bool Acknowledgeable; - - [JsonProperty("enable")] - public bool Enable; - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Config/ScheduledEventConfig.cs b/src/PepperDash.Essentials.Core/Room/Config/ScheduledEventConfig.cs new file mode 100644 index 00000000..d8bfc38f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/Config/ScheduledEventConfig.cs @@ -0,0 +1,35 @@ +extern alias Full; +using System.Collections.Generic; +using Crestron.SimplSharp.Scheduler; +using Full::Newtonsoft.Json; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Room.Config +{ + public class ScheduledEventConfig + { + [JsonProperty("key")] + public string Key; + + [JsonProperty("name")] + public string Name; + + [JsonProperty("days")] + public ScheduledEventCommon.eWeekDays Days; + + [JsonProperty("time")] + public string Time; + + [JsonProperty("actions")] + public List Actions; + + [JsonProperty("persistent")] + public bool Persistent; + + [JsonProperty("acknowledgeable")] + public bool Acknowledgeable; + + [JsonProperty("enable")] + public bool Enable; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs index 72bf9060..0dd427eb 100644 --- a/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs +++ b/src/PepperDash.Essentials.Core/Room/EssentialsRoomBase.cs @@ -374,42 +374,4 @@ namespace PepperDash.Essentials.Core return true; } } - - /// - /// To describe the various ways a room may be shutting down - /// - public enum eShutdownType - { - None = 0, - External, - Manual, - Vacancy - } - - public enum eVacancyMode - { - None = 0, - InInitialVacancy, - InShutdownWarning - } - - /// - /// - /// - public enum eWarmingCoolingMode - { - None, - Warming, - Cooling - } - - public abstract class EssentialsRoomEmergencyBase : IKeyed - { - public string Key { get; private set; } - - public EssentialsRoomEmergencyBase(string key) - { - Key = key; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/EssentialsRoomEmergencyBase.cs b/src/PepperDash.Essentials.Core/Room/EssentialsRoomEmergencyBase.cs new file mode 100644 index 00000000..0c545e5c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/EssentialsRoomEmergencyBase.cs @@ -0,0 +1,14 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public abstract class EssentialsRoomEmergencyBase : IKeyed + { + public string Key { get; private set; } + + public EssentialsRoomEmergencyBase(string key) + { + Key = key; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IEnvironmentalControls.cs b/src/PepperDash.Essentials.Core/Room/IEnvironmentalControls.cs new file mode 100644 index 00000000..8a95c6af --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IEnvironmentalControls.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + /// + /// Describes environmental controls available on a room such as lighting, shades, temperature, etc. + /// + public interface IEnvironmentalControls + { + List EnvironmentalControlDevices { get; } + + bool HasEnvironmentalControlDevices { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IHasDefaultDisplay.cs b/src/PepperDash.Essentials.Core/Room/IHasDefaultDisplay.cs new file mode 100644 index 00000000..a7230b7c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IHasDefaultDisplay.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms with a single display + /// + public interface IHasDefaultDisplay + { + IRoutingSinkWithSwitching DefaultDisplay { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IHasInCallFeedback.cs b/src/PepperDash.Essentials.Core/Room/IHasInCallFeedback.cs new file mode 100644 index 00000000..dfffdcbf --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IHasInCallFeedback.cs @@ -0,0 +1,17 @@ +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + + +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms with in call feedback + /// + public interface IHasInCallFeedback + { + BoolFeedback InCallFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IHasMultipleDisplays.cs b/src/PepperDash.Essentials.Core/Room/IHasMultipleDisplays.cs new file mode 100644 index 00000000..b9c881f9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IHasMultipleDisplays.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms with multiple displays + /// + public interface IHasMultipleDisplays + { + Dictionary Displays { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IRunDefaultCallRoute.cs b/src/PepperDash.Essentials.Core/Room/IRunDefaultCallRoute.cs new file mode 100644 index 00000000..763d7050 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IRunDefaultCallRoute.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms that have default presentation and calling routes + /// + public interface IRunDefaultCallRoute : IRunDefaultPresentRoute + { + bool RunDefaultCallRoute(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IRunDefaultPresentRoute.cs b/src/PepperDash.Essentials.Core/Room/IRunDefaultPresentRoute.cs new file mode 100644 index 00000000..2030f210 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IRunDefaultPresentRoute.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms that default presentation only routing + /// + public interface IRunDefaultPresentRoute + { + bool RunDefaultPresentRoute(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IRunDirectRouteAction.cs b/src/PepperDash.Essentials.Core/Room/IRunDirectRouteAction.cs new file mode 100644 index 00000000..8e2e1ad3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IRunDirectRouteAction.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Simplified routing direct from source to destination + /// + public interface IRunDirectRouteAction + { + void RunDirectRoute(string sourceKey, string destinationKey); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/IRunRouteAction.cs b/src/PepperDash.Essentials.Core/Room/IRunRouteAction.cs new file mode 100644 index 00000000..d885410b --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/IRunRouteAction.cs @@ -0,0 +1,15 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms with routing + /// + public interface IRunRouteAction + { + void RunRouteAction(string routeKey, string sourceListKey); + + void RunRouteAction(string routeKey, string sourceListKey, Action successCallback); + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/Interfaces.cs b/src/PepperDash.Essentials.Core/Room/Interfaces.cs deleted file mode 100644 index b5121e9c..00000000 --- a/src/PepperDash.Essentials.Core/Room/Interfaces.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - - -namespace PepperDash.Essentials.Core -{ - /// - /// For rooms with in call feedback - /// - public interface IHasInCallFeedback - { - BoolFeedback InCallFeedback { get; } - } - - /// - /// For rooms with a single display - /// - public interface IHasDefaultDisplay - { - IRoutingSinkWithSwitching DefaultDisplay { get; } - } - - /// - /// For rooms with multiple displays - /// - public interface IHasMultipleDisplays - { - Dictionary Displays { get; } - } - - /// - /// For rooms with routing - /// - public interface IRunRouteAction - { - void RunRouteAction(string routeKey, string sourceListKey); - - void RunRouteAction(string routeKey, string sourceListKey, Action successCallback); - - } - - /// - /// Simplified routing direct from source to destination - /// - public interface IRunDirectRouteAction - { - void RunDirectRoute(string sourceKey, string destinationKey); - } - - /// - /// For rooms that default presentation only routing - /// - public interface IRunDefaultPresentRoute - { - bool RunDefaultPresentRoute(); - } - - /// - /// For rooms that have default presentation and calling routes - /// - public interface IRunDefaultCallRoute : IRunDefaultPresentRoute - { - bool RunDefaultCallRoute(); - } - - /// - /// Describes environmental controls available on a room such as lighting, shades, temperature, etc. - /// - public interface IEnvironmentalControls - { - List EnvironmentalControlDevices { get; } - - bool HasEnvironmentalControlDevices { get; } - } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/eShutdownType.cs b/src/PepperDash.Essentials.Core/Room/eShutdownType.cs new file mode 100644 index 00000000..7c4a094c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/eShutdownType.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// To describe the various ways a room may be shutting down + /// + public enum eShutdownType + { + None = 0, + External, + Manual, + Vacancy + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/eVacancyMode.cs b/src/PepperDash.Essentials.Core/Room/eVacancyMode.cs new file mode 100644 index 00000000..a58c7dd8 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/eVacancyMode.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + public enum eVacancyMode + { + None = 0, + InInitialVacancy, + InShutdownWarning + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Room/eWarmingCoolingMode.cs b/src/PepperDash.Essentials.Core/Room/eWarmingCoolingMode.cs new file mode 100644 index 00000000..9b6d2e57 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Room/eWarmingCoolingMode.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public enum eWarmingCoolingMode + { + None, + Warming, + Cooling + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IHasCurrentSourceInfoChange.cs b/src/PepperDash.Essentials.Core/Routing/IHasCurrentSourceInfoChange.cs new file mode 100644 index 00000000..9928da4a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IHasCurrentSourceInfoChange.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For rooms with a single presentation source, change event + /// + public interface IHasCurrentSourceInfoChange + { + string CurrentSourceInfoKey { get; set; } + SourceListItem CurrentSourceInfo { get; set; } + event SourceInfoChangeHandler CurrentSourceChange; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRmcRouting.cs b/src/PepperDash.Essentials.Core/Routing/IRmcRouting.cs new file mode 100644 index 00000000..52290bd2 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRmcRouting.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines a receiver that has internal routing (DM-RMC-4K-Z-SCALER-C) + /// + public interface IRmcRouting : IRoutingNumeric + { + IntFeedback AudioVideoSourceNumericFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRmcRoutingWithFeedback.cs b/src/PepperDash.Essentials.Core/Routing/IRmcRoutingWithFeedback.cs new file mode 100644 index 00000000..a8e6d5f0 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRmcRoutingWithFeedback.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an IRmcRouting with a feedback event + /// + public interface IRmcRoutingWithFeedback : IRmcRouting + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRouting.cs b/src/PepperDash.Essentials.Core/Routing/IRouting.cs new file mode 100644 index 00000000..f6a233b1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRouting.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines a midpoint device as have internal routing. Any devices in the middle of the + /// signal chain, that do switching, must implement this for routing to work otherwise + /// the routing algorithm will treat the IRoutingInputsOutputs device as a passthrough + /// device. + /// + public interface IRouting : IRoutingInputsOutputs + { + void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingFeedback.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingFeedback.cs new file mode 100644 index 00000000..df5498d9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingFeedback.cs @@ -0,0 +1,14 @@ +using System; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an event structure for reporting output route data + /// + public interface IRoutingFeedback : IKeyName + { + event EventHandler NumericSwitchChange; + //void OnSwitchChange(RoutingNumericEventArgs e); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingInputs.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingInputs.cs new file mode 100644 index 00000000..b2c29c62 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingInputs.cs @@ -0,0 +1,12 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines a class that has a collection of RoutingInputPorts + /// + public interface IRoutingInputs : IKeyed + { + RoutingPortCollection InputPorts { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs index 65a30ff4..725c16df 100644 --- a/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsExtensions.cs @@ -11,28 +11,7 @@ using PepperDash.Core; namespace PepperDash.Essentials.Core { - public class RouteRequest - { - public IRoutingSink Destination {get; set;} - public IRoutingOutputs Source {get; set;} - public eRoutingSignalType SignalType {get; set;} - - public void HandleCooldown(object sender, FeedbackEventArgs args) - { - var coolingDevice = sender as IWarmingCooling; - - if(args.BoolValue == false) - { - Destination.ReleaseAndMakeRoute(Source, SignalType); - - if(sender == null) return; - - coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown; - } - } - } - - /// + /// /// Extensions added to any IRoutingInputs classes to provide discovery-based routing /// on those destinations. /// @@ -264,162 +243,4 @@ namespace PepperDash.Essentials.Core // MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE MOVE - - - /// - /// A collection of RouteDescriptors - typically the static 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(); - - /// - /// Adds a RouteDescriptor to the list. If an existing RouteDescriptor for the - /// destination exists already, it will not be added - in order to preserve - /// proper route releasing. - /// - /// - 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); - } - - /// - /// Gets the RouteDescriptor for a destination - /// - /// null if no RouteDescriptor for a destination exists - 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(); - } - - /// - /// Executes all routes described in this collection. Typically called via - /// extension method IRoutingInputs.ReleaseAndMakeRoute() - /// - public void ExecuteRoutes() - { - foreach (var route in Routes) - { - Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); - if (route.SwitchingDevice is IRoutingSink) - { - var device = route.SwitchingDevice as IRoutingSinkWithSwitching; - if (device == null) - continue; - - device.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-" + SignalType); - Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); - } - } - } - - /// - /// Releases all routes in this collection. Typically called via - /// extension method IRoutingInputs.ReleaseAndMakeRoute() - /// - 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-" + SignalType); - Debug.Console(2, "Port {0} releasing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); - } - } - } - - 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(SwitchingDevice is IRouting) - return string.Format("{0} switches output '{1}' to input '{2}'", SwitchingDevice.Key, OutputPort.Selector, InputPort.Selector); - else - return string.Format("{0} switches to input '{1}'", SwitchingDevice.Key, InputPort.Selector); - - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingInputsOutputs.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsOutputs.cs new file mode 100644 index 00000000..1cbef608 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingInputsOutputs.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For devices like RMCs, baluns, other devices with no switching. + /// + public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingNumeric.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingNumeric.cs new file mode 100644 index 00000000..d41909f1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingNumeric.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Core +{ + public interface IRoutingNumeric : IRouting + { + void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingNumericWithFeedback.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingNumericWithFeedback.cs new file mode 100644 index 00000000..e278a193 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingNumericWithFeedback.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an IRoutingNumeric with a feedback event + /// + public interface IRoutingNumericWithFeedback : IRoutingNumeric, IRoutingFeedback + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingOutputs.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingOutputs.cs new file mode 100644 index 00000000..c27b5e19 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingOutputs.cs @@ -0,0 +1,13 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Defines a class that has a collection of RoutingOutputPorts + /// + + public interface IRoutingOutputs : IKeyed + { + RoutingPortCollection OutputPorts { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingSink.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingSink.cs new file mode 100644 index 00000000..b4220d4e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingSink.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// For fixed-source endpoint devices + /// + public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingSinkNoSwitching.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingSinkNoSwitching.cs new file mode 100644 index 00000000..7233abaf --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingSinkNoSwitching.cs @@ -0,0 +1,13 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// For fixed-source endpoint devices + /// + [Obsolete("Please switch to IRoutingSink")] + public interface IRoutingSinkNoSwitching : IRoutingSink + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingSinkWithSwitching.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingSinkWithSwitching.cs new file mode 100644 index 00000000..d809ca16 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingSinkWithSwitching.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Endpoint device like a display, that selects inputs + /// + public interface IRoutingSinkWithSwitching : IRoutingSink + { + //void ClearRoute(); + void ExecuteSwitch(object inputSelector); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingSource.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingSource.cs new file mode 100644 index 00000000..d50bcbb0 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingSource.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an IRoutingOutputs devices as being a source - the start of the chain + /// + public interface IRoutingSource : IRoutingOutputs + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingWithClear.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingWithClear.cs new file mode 100644 index 00000000..077d4ecd --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingWithClear.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core +{ + public interface IRoutingWithClear : IRouting + { + /// + /// Clears a route to an output, however a device needs to do that + /// + /// Output to clear + /// signal type to clear + void ClearRoute(object outputSelector, eRoutingSignalType signalType); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/IRoutingWithFeedback.cs b/src/PepperDash.Essentials.Core/Routing/IRoutingWithFeedback.cs new file mode 100644 index 00000000..0b58ff02 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/IRoutingWithFeedback.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an IRouting with a feedback event + /// + public interface IRoutingWithFeedback : IRouting, IRoutingFeedback + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/ITxRouting.cs b/src/PepperDash.Essentials.Core/Routing/ITxRouting.cs new file mode 100644 index 00000000..0950e6a6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/ITxRouting.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core +{ + public interface ITxRouting : IRoutingNumeric + { + IntFeedback VideoSourceNumericFeedback { get; } + IntFeedback AudioSourceNumericFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/ITxRoutingWithFeedback.cs b/src/PepperDash.Essentials.Core/Routing/ITxRoutingWithFeedback.cs new file mode 100644 index 00000000..484fa134 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/ITxRoutingWithFeedback.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// Defines an IRmcRouting with a feedback event + /// + public interface ITxRoutingWithFeedback : ITxRouting + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs b/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs new file mode 100644 index 00000000..7339d31e --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RouteDescriptor.cs @@ -0,0 +1,76 @@ +using System.Collections.Generic; +using System.Linq; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// 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(); + } + + /// + /// Executes all routes described in this collection. Typically called via + /// extension method IRoutingInputs.ReleaseAndMakeRoute() + /// + public void ExecuteRoutes() + { + foreach (var route in Routes) + { + Debug.Console(2, "ExecuteRoutes: {0}", route.ToString()); + if (route.SwitchingDevice is IRoutingSink) + { + var device = route.SwitchingDevice as IRoutingSinkWithSwitching; + if (device == null) + continue; + + device.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-" + SignalType); + Debug.Console(2, "Output port {0} routing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); + } + } + } + + /// + /// Releases all routes in this collection. Typically called via + /// extension method IRoutingInputs.ReleaseAndMakeRoute() + /// + 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-" + SignalType); + Debug.Console(2, "Port {0} releasing. Count={1}", route.OutputPort.Key, route.OutputPort.InUseTracker.InUseCountFeedback.UShortValue); + } + } + } + + 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)); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RouteDescriptorCollection.cs b/src/PepperDash.Essentials.Core/Routing/RouteDescriptorCollection.cs new file mode 100644 index 00000000..e5f9ecfb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RouteDescriptorCollection.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using System.Linq; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// A collection of RouteDescriptors - typically the static 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(); + + /// + /// Adds a RouteDescriptor to the list. If an existing RouteDescriptor for the + /// destination exists already, it will not be added - in order to preserve + /// proper route releasing. + /// + /// + 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); + } + + /// + /// Gets the RouteDescriptor for a destination + /// + /// null if no RouteDescriptor for a destination exists + 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; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs b/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs new file mode 100644 index 00000000..983985ab --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RouteRequest.cs @@ -0,0 +1,23 @@ +namespace PepperDash.Essentials.Core +{ + public class RouteRequest + { + public IRoutingSink Destination {get; set;} + public IRoutingOutputs Source {get; set;} + public eRoutingSignalType SignalType {get; set;} + + public void HandleCooldown(object sender, FeedbackEventArgs args) + { + var coolingDevice = sender as IWarmingCooling; + + if(args.BoolValue == false) + { + Destination.ReleaseAndMakeRoute(Source, SignalType); + + if(sender == null) return; + + coolingDevice.IsCoolingDownFeedback.OutputChange -= HandleCooldown; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs b/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs new file mode 100644 index 00000000..90d487a5 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RouteSwitchDescriptor.cs @@ -0,0 +1,32 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// 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(SwitchingDevice is IRouting) + return string.Format("{0} switches output '{1}' to input '{2}'", SwitchingDevice.Key, OutputPort.Selector, InputPort.Selector); + else + return string.Format("{0} switches to input '{1}'", SwitchingDevice.Key, InputPort.Selector); + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingInputPort.cs b/src/PepperDash.Essentials.Core/Routing/RoutingInputPort.cs new file mode 100644 index 00000000..3c4d5411 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RoutingInputPort.cs @@ -0,0 +1,70 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// 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; + } + + + + + ///// + ///// Static method to get a named port from a named device + ///// + ///// Returns null if device or port doesn't exist + //public static RoutingInputPort GetDevicePort(string deviceKey, string portKey) + //{ + // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingInputs; + // if (sourceDev == null) + // return null; + // return sourceDev.InputPorts[portKey]; + //} + + ///// + ///// Static method to get a named port from a card in a named ICardPortsDevice device + ///// Uses ICardPortsDevice.GetChildInputPort + ///// + ///// 'input-N' + ///// null if device, card or port doesn't exist + //public static RoutingInputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) + //{ + // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; + // if (sourceDev == null) + // return null; + // return sourceDev.GetChildInputPort(cardKey, portKey); + //} + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingInputPortWithVideoStatuses.cs b/src/PepperDash.Essentials.Core/Routing/RoutingInputPortWithVideoStatuses.cs new file mode 100644 index 00000000..9d9d32b5 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RoutingInputPortWithVideoStatuses.cs @@ -0,0 +1,30 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// 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); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs b/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs deleted file mode 100644 index 952a48b1..00000000 --- a/src/PepperDash.Essentials.Core/Routing/RoutingInterfaces.cs +++ /dev/null @@ -1,207 +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 -{ - - /// - /// The handler type for a Room's SourceInfoChange - /// - public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type); - - - //******************************************************************************************* - // Interfaces - - /// - /// For rooms with a single presentation source, change event - /// - public interface IHasCurrentSourceInfoChange - { - string CurrentSourceInfoKey { get; set; } - SourceListItem CurrentSourceInfo { get; set; } - event SourceInfoChangeHandler CurrentSourceChange; - } - - /// - /// Defines a class that has a collection of RoutingInputPorts - /// - public interface IRoutingInputs : IKeyed - { - RoutingPortCollection InputPorts { get; } - } - - /// - /// Defines a class that has a collection of RoutingOutputPorts - /// - - public interface IRoutingOutputs : IKeyed - { - RoutingPortCollection OutputPorts { get; } - } - - /// - /// For fixed-source endpoint devices - /// - public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange - { - - } - - /// - /// For fixed-source endpoint devices - /// - [Obsolete("Please switch to IRoutingSink")] - public interface IRoutingSinkNoSwitching : IRoutingSink - { - - } - - /// - /// Endpoint device like a display, that selects inputs - /// - public interface IRoutingSinkWithSwitching : IRoutingSink - { - //void ClearRoute(); - void ExecuteSwitch(object inputSelector); - } - - /// - /// For devices like RMCs, baluns, other devices with no switching. - /// - public interface IRoutingInputsOutputs : IRoutingInputs, IRoutingOutputs - { - } - - /// - /// Defines a midpoint device as have internal routing. Any devices in the middle of the - /// signal chain, that do switching, must implement this for routing to work otherwise - /// the routing algorithm will treat the IRoutingInputsOutputs device as a passthrough - /// device. - /// - public interface IRouting : IRoutingInputsOutputs - { - void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType); - } - - public interface IRoutingWithClear : IRouting - { - /// - /// Clears a route to an output, however a device needs to do that - /// - /// Output to clear - /// signal type to clear - void ClearRoute(object outputSelector, eRoutingSignalType signalType); - } - - public interface IRoutingNumeric : IRouting - { - void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type); - } - - public interface ITxRouting : IRoutingNumeric - { - IntFeedback VideoSourceNumericFeedback { get; } - IntFeedback AudioSourceNumericFeedback { get; } - } - - /// - /// Defines a receiver that has internal routing (DM-RMC-4K-Z-SCALER-C) - /// - public interface IRmcRouting : IRoutingNumeric - { - IntFeedback AudioVideoSourceNumericFeedback { get; } - } - - - /// - /// Defines an IRmcRouting with a feedback event - /// - public interface ITxRoutingWithFeedback : ITxRouting - { - } - - /// - /// Defines an IRmcRouting with a feedback event - /// - public interface IRmcRoutingWithFeedback : IRmcRouting - { - } - - /// - /// Defines an IRoutingOutputs devices as being a source - the start of the chain - /// - public interface IRoutingSource : IRoutingOutputs - { - } - - /// - /// Defines an event structure for reporting output route data - /// - public interface IRoutingFeedback : IKeyName - { - event EventHandler NumericSwitchChange; - //void OnSwitchChange(RoutingNumericEventArgs e); - } - - /// - /// Defines an IRoutingNumeric with a feedback event - /// - public interface IRoutingNumericWithFeedback : IRoutingNumeric, IRoutingFeedback - { - } - - /// - /// Defines an IRouting with a feedback event - /// - public interface IRoutingWithFeedback : IRouting, IRoutingFeedback - { - - } - - public class RoutingNumericEventArgs : EventArgs - { - - public uint? Output { get; set; } - public uint? Input { get; set; } - - public eRoutingSignalType SigType { get; set; } - public RoutingInputPort InputPort { get; set; } - public RoutingOutputPort OutputPort { get; set; } - - public RoutingNumericEventArgs(uint output, uint input, eRoutingSignalType sigType) : this(output, input, null, null, sigType) - { - } - - public RoutingNumericEventArgs(RoutingOutputPort outputPort, RoutingInputPort inputPort, - eRoutingSignalType sigType) - : this(null, null, outputPort, inputPort, sigType) - { - } - - public RoutingNumericEventArgs() - : this(null, null, null, null, 0) - { - - } - - public RoutingNumericEventArgs(uint? output, uint? input, RoutingOutputPort outputPort, - RoutingInputPort inputPort, eRoutingSignalType sigType) - { - OutputPort = outputPort; - InputPort = inputPort; - - Output = output; - Input = input; - SigType = sigType; - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingNumericEventArgs.cs b/src/PepperDash.Essentials.Core/Routing/RoutingNumericEventArgs.cs new file mode 100644 index 00000000..09544c0f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RoutingNumericEventArgs.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DM; + + +namespace PepperDash.Essentials.Core +{ + //******************************************************************************************* + // Interfaces + + + public class RoutingNumericEventArgs : EventArgs + { + + public uint? Output { get; set; } + public uint? Input { get; set; } + + public eRoutingSignalType SigType { get; set; } + public RoutingInputPort InputPort { get; set; } + public RoutingOutputPort OutputPort { get; set; } + + public RoutingNumericEventArgs(uint output, uint input, eRoutingSignalType sigType) : this(output, input, null, null, sigType) + { + } + + public RoutingNumericEventArgs(RoutingOutputPort outputPort, RoutingInputPort inputPort, + eRoutingSignalType sigType) + : this(null, null, outputPort, inputPort, sigType) + { + } + + public RoutingNumericEventArgs() + : this(null, null, null, null, 0) + { + + } + + public RoutingNumericEventArgs(uint? output, uint? input, RoutingOutputPort outputPort, + RoutingInputPort inputPort, eRoutingSignalType sigType) + { + OutputPort = outputPort; + InputPort = inputPort; + + Output = output; + Input = input; + SigType = sigType; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingOutputPort.cs b/src/PepperDash.Essentials.Core/Routing/RoutingOutputPort.cs new file mode 100644 index 00000000..ef251cd6 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/RoutingOutputPort.cs @@ -0,0 +1,70 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + 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; + } + + ///// + ///// Static method to get a named port from a named device + ///// + ///// Returns null if device or port doesn't exist + //public static RoutingOutputPort GetDevicePort(string deviceKey, string portKey) + //{ + // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingOutputs; + // if (sourceDev == null) + // return null; + // var port = sourceDev.OutputPorts[portKey]; + // if (port == null) + // Debug.Console(0, "WARNING: Device '{0}' does does not contain output port '{1}'", deviceKey, portKey); + // return port; + //} + + ///// + ///// Static method to get a named port from a card in a named ICardPortsDevice device + ///// Uses ICardPortsDevice.GetChildOutputPort on that device + ///// + ///// 'input-N' or 'output-N' + ///// null if device, card or port doesn't exist + //public static RoutingOutputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) + //{ + // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; + // if (sourceDev == null) + // return null; + // var port = sourceDev.GetChildOutputPort(cardKey, portKey); + //} + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs index 79dd4eda..5fb06aff 100644 --- a/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs +++ b/src/PepperDash.Essentials.Core/Routing/RoutingPort.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using PepperDash.Core; @@ -28,180 +27,4 @@ namespace PepperDash.Essentials.Core IsInternal = isInternal; } } - - [Flags] - public enum eRoutingSignalType - { - Audio = 1, - Video = 2, - AudioVideo = Audio | Video, - UsbOutput = 8, - UsbInput = 16 - } - - public enum eRoutingPortConnectionType - { - None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, - Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming - } - - /// - /// 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; - } - - - - - ///// - ///// Static method to get a named port from a named device - ///// - ///// Returns null if device or port doesn't exist - //public static RoutingInputPort GetDevicePort(string deviceKey, string portKey) - //{ - // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingInputs; - // if (sourceDev == null) - // return null; - // return sourceDev.InputPorts[portKey]; - //} - - ///// - ///// Static method to get a named port from a card in a named ICardPortsDevice device - ///// Uses ICardPortsDevice.GetChildInputPort - ///// - ///// 'input-N' - ///// null if device, card or port doesn't exist - //public static RoutingInputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) - //{ - // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; - // if (sourceDev == null) - // return null; - // return sourceDev.GetChildInputPort(cardKey, portKey); - //} - } - - /// - /// 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; - } - - ///// - ///// Static method to get a named port from a named device - ///// - ///// Returns null if device or port doesn't exist - //public static RoutingOutputPort GetDevicePort(string deviceKey, string portKey) - //{ - // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as IRoutingOutputs; - // if (sourceDev == null) - // return null; - // var port = sourceDev.OutputPorts[portKey]; - // if (port == null) - // Debug.Console(0, "WARNING: Device '{0}' does does not contain output port '{1}'", deviceKey, portKey); - // return port; - //} - - ///// - ///// Static method to get a named port from a card in a named ICardPortsDevice device - ///// Uses ICardPortsDevice.GetChildOutputPort on that device - ///// - ///// 'input-N' or 'output-N' - ///// null if device, card or port doesn't exist - //public static RoutingOutputPort GetDeviceCardPort(string deviceKey, string cardKey, string portKey) - //{ - // var sourceDev = DeviceManager.GetDeviceForKey(deviceKey) as ICardPortsDevice; - // if (sourceDev == null) - // return null; - // var port = sourceDev.GetChildOutputPort(cardKey, portKey); - //} - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/SourceInfoChangeHandler.cs b/src/PepperDash.Essentials.Core/Routing/SourceInfoChangeHandler.cs new file mode 100644 index 00000000..5dc5ad20 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/SourceInfoChangeHandler.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// The handler type for a Room's SourceInfoChange + /// + public delegate void SourceInfoChangeHandler(/*EssentialsRoomBase room,*/ SourceListItem info, ChangeType type); +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/TieLine.cs b/src/PepperDash.Essentials.Core/Routing/TieLine.cs index 25bf4ea3..a60d031a 100644 --- a/src/PepperDash.Essentials.Core/Routing/TieLine.cs +++ b/src/PepperDash.Essentials.Core/Routing/TieLine.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -94,18 +93,4 @@ namespace PepperDash.Essentials.Core } //******************************************************************************** - - 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 diff --git a/src/PepperDash.Essentials.Core/Routing/TieLineCollection.cs b/src/PepperDash.Essentials.Core/Routing/TieLineCollection.cs new file mode 100644 index 00000000..351bbd2a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/TieLineCollection.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + 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 diff --git a/src/PepperDash.Essentials.Core/Routing/eRoutingPortConnectionType.cs b/src/PepperDash.Essentials.Core/Routing/eRoutingPortConnectionType.cs new file mode 100644 index 00000000..37bae175 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/eRoutingPortConnectionType.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core +{ + public enum eRoutingPortConnectionType + { + None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, + Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Routing/eRoutingSignalType.cs b/src/PepperDash.Essentials.Core/Routing/eRoutingSignalType.cs new file mode 100644 index 00000000..03d9285a --- /dev/null +++ b/src/PepperDash.Essentials.Core/Routing/eRoutingSignalType.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + [Flags] + public enum eRoutingSignalType + { + Audio = 1, + Video = 2, + AudioVideo = Audio | Video, + UsbOutput = 8, + UsbInput = 16 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Secrets/ISecret.cs b/src/PepperDash.Essentials.Core/Secrets/ISecret.cs new file mode 100644 index 00000000..cac97b5f --- /dev/null +++ b/src/PepperDash.Essentials.Core/Secrets/ISecret.cs @@ -0,0 +1,23 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// interface for delivering secrets in Essentials. + /// + public interface ISecret + { + /// + /// Instance of ISecretProvider that the secret belongs to + /// + ISecretProvider Provider { get; } + + /// + /// Key of the secret in the provider + /// + string Key { get; } + + /// + /// Value of the secret + /// + object Value { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Secrets/Interfaces.cs b/src/PepperDash.Essentials.Core/Secrets/ISecretProvider.cs similarity index 68% rename from src/PepperDash.Essentials.Core/Secrets/Interfaces.cs rename to src/PepperDash.Essentials.Core/Secrets/ISecretProvider.cs index d2fd750a..9597c667 100644 --- a/src/PepperDash.Essentials.Core/Secrets/Interfaces.cs +++ b/src/PepperDash.Essentials.Core/Secrets/ISecretProvider.cs @@ -34,25 +34,4 @@ namespace PepperDash.Essentials.Core /// string Description { get; } } - - /// - /// interface for delivering secrets in Essentials. - /// - public interface ISecret - { - /// - /// Instance of ISecretProvider that the secret belongs to - /// - ISecretProvider Provider { get; } - - /// - /// Key of the secret in the provider - /// - string Key { get; } - - /// - /// Value of the secret - /// - object Value { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/ICrestronBasicShade.cs b/src/PepperDash.Essentials.Core/Shades/ICrestronBasicShade.cs new file mode 100644 index 00000000..0e594318 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/ICrestronBasicShade.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials.Core.Shades +{ + public interface ICrestronBasicShade : IShadesOpenClosedFeedback, IShadesStop, + IShadesStopOrMove, IShadesFeedback, IShadesRaiseLowerFeedback + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/ISceneFeedback.cs b/src/PepperDash.Essentials.Core/Shades/ISceneFeedback.cs new file mode 100644 index 00000000..ff8453c9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/ISceneFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// + /// + public interface ISceneFeedback + { + void Run(); + BoolFeedback AllAreAtSceneFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShades.cs b/src/PepperDash.Essentials.Core/Shades/IShades.cs new file mode 100644 index 00000000..9eb57684 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShades.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for an object that contains shades + /// + public interface IShades + { + List Shades { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesFeedback.cs b/src/PepperDash.Essentials.Core/Shades/IShadesFeedback.cs new file mode 100644 index 00000000..f0fe7a53 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesFeedback.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Basic feedback for shades position + /// + public interface IShadesFeedback: IShadesPosition, IShadesStopFeedback + { + IntFeedback PositionFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesOpenClose.cs b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClose.cs new file mode 100644 index 00000000..2f0c9d23 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClose.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for a device that implements basic Open/Close shade control + /// + [Obsolete("Please use IShadesOpenCloseStop instead")] + public interface IShadesOpenClose + { + void Open(); + void Close(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosePreset.cs b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosePreset.cs new file mode 100644 index 00000000..dc0020a9 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosePreset.cs @@ -0,0 +1,13 @@ +using System; + +namespace PepperDash.Essentials.Core.Shades +{ + public interface IShadesOpenClosePreset : IShadesOpenCloseStop + { + void RecallPreset(uint presetNumber); + void SavePreset(uint presetNumber); + string StopOrPresetButtonLabel { get; } + + event EventHandler PresetSaved; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesOpenCloseStop.cs b/src/PepperDash.Essentials.Core/Shades/IShadesOpenCloseStop.cs new file mode 100644 index 00000000..bcde0162 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesOpenCloseStop.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for a device that implements basic Open/Close/Stop shade control (Uses 3 relays) + /// + public interface IShadesOpenCloseStop + { + void Open(); + void Close(); + void Stop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosedFeedback.cs b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosedFeedback.cs new file mode 100644 index 00000000..4edfea68 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesOpenClosedFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for a shade/scene that is open or closed + /// + public interface IShadesOpenClosedFeedback: IShadesOpenCloseStop + { + BoolFeedback ShadeIsOpenFeedback { get; } + BoolFeedback ShadeIsClosedFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesPosition.cs b/src/PepperDash.Essentials.Core/Shades/IShadesPosition.cs new file mode 100644 index 00000000..460ff747 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesPosition.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for position + /// + public interface IShadesPosition + { + void SetPosition(ushort value); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLower.cs b/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLower.cs new file mode 100644 index 00000000..fe1b4378 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLower.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for a shade that implements press/hold raise/lower functions + /// + [Obsolete("Please use IShadesOpenCloseStop instead")] + public interface IShadesRaiseLower + { + void Raise(bool state); + void Lower(bool state); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLowerFeedback.cs b/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLowerFeedback.cs new file mode 100644 index 00000000..59988771 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesRaiseLowerFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Requirements for a shade device that provides raising/lowering feedback + /// + public interface IShadesRaiseLowerFeedback + { + BoolFeedback ShadeIsLoweringFeedback { get; } + BoolFeedback ShadeIsRaisingFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesStop.cs b/src/PepperDash.Essentials.Core/Shades/IShadesStop.cs new file mode 100644 index 00000000..6955a3a2 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesStop.cs @@ -0,0 +1,13 @@ +using System; + +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// + /// + [Obsolete("Please use IShadesOpenCloseStop instead")] + public interface IShadesStop + { + void Stop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesStopFeedback.cs b/src/PepperDash.Essentials.Core/Shades/IShadesStopFeedback.cs new file mode 100644 index 00000000..61d9e0fb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesStopFeedback.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Basic feedback for shades/scene stopped + /// + public interface IShadesStopFeedback : IShadesOpenCloseStop + { + BoolFeedback IsStoppedFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/IShadesStopOrMove.cs b/src/PepperDash.Essentials.Core/Shades/IShadesStopOrMove.cs new file mode 100644 index 00000000..cc3d1868 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/IShadesStopOrMove.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Core.Shades +{ + /// + /// Used to implement raise/stop/lower/stop from single button + /// + public interface IShadesStopOrMove + { + void OpenOrStop(); + void CloseOrStop(); + void OpenCloseOrStop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/Shade Interfaces.cs b/src/PepperDash.Essentials.Core/Shades/Shade Interfaces.cs deleted file mode 100644 index 2fded479..00000000 --- a/src/PepperDash.Essentials.Core/Shades/Shade Interfaces.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core.Shades -{ - /// - /// Requirements for an object that contains shades - /// - public interface IShades - { - List Shades { get; } - } - - /// - /// Requirements for a device that implements basic Open/Close shade control - /// - [Obsolete("Please use IShadesOpenCloseStop instead")] - public interface IShadesOpenClose - { - void Open(); - void Close(); - } - - /// - /// Requirements for a device that implements basic Open/Close/Stop shade control (Uses 3 relays) - /// - public interface IShadesOpenCloseStop - { - void Open(); - void Close(); - void Stop(); - } - - public interface IShadesOpenClosePreset : IShadesOpenCloseStop - { - void RecallPreset(uint presetNumber); - void SavePreset(uint presetNumber); - string StopOrPresetButtonLabel { get; } - - event EventHandler PresetSaved; - } - - /// - /// Requirements for a shade that implements press/hold raise/lower functions - /// - [Obsolete("Please use IShadesOpenCloseStop instead")] - public interface IShadesRaiseLower - { - void Raise(bool state); - void Lower(bool state); - } - - /// - /// Requirements for a shade device that provides raising/lowering feedback - /// - public interface IShadesRaiseLowerFeedback - { - BoolFeedback ShadeIsLoweringFeedback { get; } - BoolFeedback ShadeIsRaisingFeedback { get; } - } - - /// - /// Requirements for a shade/scene that is open or closed - /// - public interface IShadesOpenClosedFeedback: IShadesOpenCloseStop - { - BoolFeedback ShadeIsOpenFeedback { get; } - BoolFeedback ShadeIsClosedFeedback { get; } - } - - /// - /// - /// - [Obsolete("Please use IShadesOpenCloseStop instead")] - public interface IShadesStop - { - void Stop(); - } - - /// - /// Used to implement raise/stop/lower/stop from single button - /// - public interface IShadesStopOrMove - { - void OpenOrStop(); - void CloseOrStop(); - void OpenCloseOrStop(); - } - - /// - /// Basic feedback for shades/scene stopped - /// - public interface IShadesStopFeedback : IShadesOpenCloseStop - { - BoolFeedback IsStoppedFeedback { get; } - } - - /// - /// Requirements for position - /// - public interface IShadesPosition - { - void SetPosition(ushort value); - } - - /// - /// Basic feedback for shades position - /// - public interface IShadesFeedback: IShadesPosition, IShadesStopFeedback - { - IntFeedback PositionFeedback { get; } - } - - /// - /// - /// - public interface ISceneFeedback - { - void Run(); - BoolFeedback AllAreAtSceneFeedback { get; } - } - - public interface ICrestronBasicShade : IShadesOpenClosedFeedback, IShadesStop, - IShadesStopOrMove, IShadesFeedback, IShadesRaiseLowerFeedback - { - - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/ShadeController.cs b/src/PepperDash.Essentials.Core/Shades/ShadeController.cs index fc50f631..d263a63c 100644 --- a/src/PepperDash.Essentials.Core/Shades/ShadeController.cs +++ b/src/PepperDash.Essentials.Core/Shades/ShadeController.cs @@ -4,9 +4,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - namespace PepperDash.Essentials.Core.Shades { /// @@ -45,32 +42,4 @@ namespace PepperDash.Essentials.Core.Shades Shades.Add(shade); } } - - public class ShadeControllerConfigProperties - { - public List Shades { get; set; } - - - public class ShadeConfig - { - public string Key { get; set; } - } - } - - public class ShadeControllerFactory : EssentialsDeviceFactory - { - public ShadeControllerFactory() - { - TypeNames = new List() { "shadecontroller" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new ShadeController Device"); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); - - return new Core.Shades.ShadeController(dc.Key, dc.Name, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/ShadeControllerConfigProperties.cs b/src/PepperDash.Essentials.Core/Shades/ShadeControllerConfigProperties.cs new file mode 100644 index 00000000..49a6ef39 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/ShadeControllerConfigProperties.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Shades +{ + public class ShadeControllerConfigProperties + { + public List Shades { get; set; } + + + public class ShadeConfig + { + public string Key { get; set; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Shades/ShadeControllerFactory.cs b/src/PepperDash.Essentials.Core/Shades/ShadeControllerFactory.cs new file mode 100644 index 00000000..659a7389 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Shades/ShadeControllerFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Shades +{ + public class ShadeControllerFactory : EssentialsDeviceFactory + { + public ShadeControllerFactory() + { + TypeNames = new List() { "shadecontroller" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new ShadeController Device"); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + + return new Core.Shades.ShadeController(dc.Key, dc.Name, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs index 0064fd7a..a0609985 100644 --- a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs +++ b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimer.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -10,8 +9,6 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Core.Timers { @@ -127,53 +124,4 @@ namespace PepperDash.Essentials.Core.Timers //} } } - - /// - /// Configuration Properties for RetriggerableTimer - /// - public class RetriggerableTimerPropertiesConfig - { - [JsonProperty("startTimerOnActivation")] - public bool StartTimerOnActivation { get; set; } - - [JsonProperty("timerIntervalMs")] - public long TimerIntervalMs { get; set; } - - [JsonProperty("events")] - public Dictionary Events { get; set; } - - public RetriggerableTimerPropertiesConfig() - { - Events = new Dictionary(); - } - } - - /// - /// The set of values describing events on the timer - /// - public enum eRetriggerableTimerEvents - { - Elapsed, - Stopped, - } - - /// - /// Factory class - /// - public class RetriggerableTimerFactory : EssentialsDeviceFactory - { - public RetriggerableTimerFactory() - { - TypeNames = new List() { "retriggerabletimer" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new RetriggerableTimer Device"); - - return new RetriggerableTimer(dc.Key, dc); - } - } - - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerFactory.cs b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerFactory.cs new file mode 100644 index 00000000..60fb7868 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Timers +{ + /// + /// Factory class + /// + public class RetriggerableTimerFactory : EssentialsDeviceFactory + { + public RetriggerableTimerFactory() + { + TypeNames = new List() { "retriggerabletimer" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new RetriggerableTimer Device"); + + return new RetriggerableTimer(dc.Key, dc); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerPropertiesConfig.cs new file mode 100644 index 00000000..07613537 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Timers/RetriggerableTimerPropertiesConfig.cs @@ -0,0 +1,26 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Timers +{ + /// + /// Configuration Properties for RetriggerableTimer + /// + public class RetriggerableTimerPropertiesConfig + { + [JsonProperty("startTimerOnActivation")] + public bool StartTimerOnActivation { get; set; } + + [JsonProperty("timerIntervalMs")] + public long TimerIntervalMs { get; set; } + + [JsonProperty("events")] + public Dictionary Events { get; set; } + + public RetriggerableTimerPropertiesConfig() + { + Events = new Dictionary(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs b/src/PepperDash.Essentials.Core/Timers/SecondsCountdownTimer.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Timers/CountdownTimer.cs rename to src/PepperDash.Essentials.Core/Timers/SecondsCountdownTimer.cs diff --git a/src/PepperDash.Essentials.Core/Timers/eRetriggerableTimerEvents.cs b/src/PepperDash.Essentials.Core/Timers/eRetriggerableTimerEvents.cs new file mode 100644 index 00000000..5c341c44 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Timers/eRetriggerableTimerEvents.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Timers +{ + /// + /// The set of values describing events on the timer + /// + public enum eRetriggerableTimerEvents + { + Elapsed, + Stopped, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/CrestronTouchpanelPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Touchpanels/CrestronTouchpanelPropertiesConfig.cs index 73b66bce..15299239 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/CrestronTouchpanelPropertiesConfig.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/CrestronTouchpanelPropertiesConfig.cs @@ -43,12 +43,4 @@ /// public const string Verbose = "verbose"; } - - /// - /// - /// - public class UiSetupPropertiesConfig - { - public bool IsVisible { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Interfaces.cs b/src/PepperDash.Essentials.Core/Touchpanels/IHasBasicTriListWithSmartObject.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Touchpanels/Interfaces.cs rename to src/PepperDash.Essentials.Core/Touchpanels/IHasBasicTriListWithSmartObject.cs diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/HabaneroKeyboardController.cs b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/HabaneroKeyboardController.cs index 5e068c12..2eecd32b 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/HabaneroKeyboardController.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/HabaneroKeyboardController.cs @@ -409,28 +409,4 @@ namespace PepperDash.Essentials.Core.Touchpanels.Keyboards public const uint ClearVisibleJoin = 2911; } - - /// - /// - /// - public class KeyboardControllerPressEventArgs : EventArgs - { - public string Text { get; private set; } - public KeyboardSpecialKey SpecialKey { get; private set; } - - public KeyboardControllerPressEventArgs(string text) - { - Text = text; - } - - public KeyboardControllerPressEventArgs(KeyboardSpecialKey key) - { - SpecialKey = key; - } - } - - public enum KeyboardSpecialKey - { - None = 0, Backspace, Clear, GoButton, SecondaryButton - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardControllerPressEventArgs.cs b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardControllerPressEventArgs.cs new file mode 100644 index 00000000..c0d5a5c3 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardControllerPressEventArgs.cs @@ -0,0 +1,23 @@ +using System; + +namespace PepperDash.Essentials.Core.Touchpanels.Keyboards +{ + /// + /// + /// + public class KeyboardControllerPressEventArgs : EventArgs + { + public string Text { get; private set; } + public KeyboardSpecialKey SpecialKey { get; private set; } + + public KeyboardControllerPressEventArgs(string text) + { + Text = text; + } + + public KeyboardControllerPressEventArgs(KeyboardSpecialKey key) + { + SpecialKey = key; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardSpecialKey.cs b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardSpecialKey.cs new file mode 100644 index 00000000..f1833220 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Touchpanels/Keyboards/KeyboardSpecialKey.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Core.Touchpanels.Keyboards +{ + public enum KeyboardSpecialKey + { + None = 0, Backspace, Clear, GoButton, SecondaryButton + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/KeypadButton.cs b/src/PepperDash.Essentials.Core/Touchpanels/KeypadButton.cs new file mode 100644 index 00000000..9bd5417c --- /dev/null +++ b/src/PepperDash.Essentials.Core/Touchpanels/KeypadButton.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core.Touchpanels +{ + /// + /// Represents the configuration of a keybad buggon + /// + public class KeypadButton + { + public Dictionary EventTypes { get; set; } + public KeypadButtonFeedback Feedback { get; set; } + + public KeypadButton() + { + EventTypes = new Dictionary(); + Feedback = new KeypadButtonFeedback(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/KeypadButtonFeedback.cs b/src/PepperDash.Essentials.Core/Touchpanels/KeypadButtonFeedback.cs new file mode 100644 index 00000000..e3271430 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Touchpanels/KeypadButtonFeedback.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Core.Touchpanels +{ + /// + /// + /// + public class KeypadButtonFeedback + { + public string DeviceKey { get; set; } + public string FeedbackName { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3TouchpanelController.cs similarity index 88% rename from src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs rename to src/PepperDash.Essentials.Core/Touchpanels/Mpc3TouchpanelController.cs index c9a5f605..3ee642b2 100644 --- a/src/PepperDash.Essentials.Core/Touchpanels/Mpc3Touchpanel.cs +++ b/src/PepperDash.Essentials.Core/Touchpanels/Mpc3TouchpanelController.cs @@ -117,28 +117,4 @@ namespace PepperDash.Essentials.Core.Touchpanels } - - /// - /// Represents the configuration of a keybad buggon - /// - public class KeypadButton - { - public Dictionary EventTypes { get; set; } - public KeypadButtonFeedback Feedback { get; set; } - - public KeypadButton() - { - EventTypes = new Dictionary(); - Feedback = new KeypadButtonFeedback(); - } - } - - /// - /// - /// - public class KeypadButtonFeedback - { - public string DeviceKey { get; set; } - public string FeedbackName { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Touchpanels/TriListExtensions.cs b/src/PepperDash.Essentials.Core/Touchpanels/SigAndTriListExtensions.cs similarity index 100% rename from src/PepperDash.Essentials.Core/Touchpanels/TriListExtensions.cs rename to src/PepperDash.Essentials.Core/Touchpanels/SigAndTriListExtensions.cs diff --git a/src/PepperDash.Essentials.Core/Touchpanels/UiSetupPropertiesConfig.cs b/src/PepperDash.Essentials.Core/Touchpanels/UiSetupPropertiesConfig.cs new file mode 100644 index 00000000..07eb2416 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Touchpanels/UiSetupPropertiesConfig.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public class UiSetupPropertiesConfig + { + public bool IsVisible { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/DefaultPageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/DefaultPageManager.cs new file mode 100644 index 00000000..3c127d2d --- /dev/null +++ b/src/PepperDash.Essentials.Core/UI PageManagers/DefaultPageManager.cs @@ -0,0 +1,35 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core.PageManagers +{ + /// + /// A simple class that hides and shows the default subpage for a given source type + /// + public class DefaultPageManager : PageManager + { + BasicTriList TriList; + uint BackingPageJoin; + + public DefaultPageManager(IUiDisplayInfo device, BasicTriList trilist) + { + TriList = trilist; + BackingPageJoin = GetOffsetJoin(device.DisplayUiType) + 1; + } + + public DefaultPageManager(uint join, BasicTriList trilist) + { + TriList = trilist; + BackingPageJoin = join; + } + + public override void Show() + { + TriList.BooleanInput[BackingPageJoin].BoolValue = true; + } + + public override void Hide() + { + TriList.BooleanInput[BackingPageJoin].BoolValue = false; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/BlurayPageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/DiscPlayerMediumPageManager.cs similarity index 100% rename from src/PepperDash.Essentials.Core/UI PageManagers/BlurayPageManager.cs rename to src/PepperDash.Essentials.Core/UI PageManagers/DiscPlayerMediumPageManager.cs diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/MediumLeftSwitchablePageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/MediumLeftSwitchablePageManager.cs new file mode 100644 index 00000000..1f22b64e --- /dev/null +++ b/src/PepperDash.Essentials.Core/UI PageManagers/MediumLeftSwitchablePageManager.cs @@ -0,0 +1,40 @@ +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core.PageManagers +{ + /// + /// A page manager for a page with backing panel and a switchable side panel + /// + public abstract class MediumLeftSwitchablePageManager : PageManager + { + protected BasicTriListWithSmartObject TriList; + protected uint LeftSubpageJoin; + protected uint BackingPageJoin; + protected uint[] AllLeftSubpages; + protected uint DisplayUiType; + + protected MediumLeftSwitchablePageManager(uint displayUiType) + { + DisplayUiType = displayUiType; + } + + protected void InterlockLeftSubpage(uint join) + { + join = join + GetOffsetJoin(); + ClearLeftInterlock(); + TriList.BooleanInput[join].BoolValue = true; + LeftSubpageJoin = join; + } + + protected void ClearLeftInterlock() + { + foreach (var p in AllLeftSubpages) + TriList.BooleanInput[GetOffsetJoin() + p].BoolValue = false; + } + + protected uint GetOffsetJoin() + { + return GetOffsetJoin(DisplayUiType); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/PageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/PageManager.cs index 1f261f87..51530862 100644 --- a/src/PepperDash.Essentials.Core/UI PageManagers/PageManager.cs +++ b/src/PepperDash.Essentials.Core/UI PageManagers/PageManager.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core.PageManagers @@ -26,71 +25,4 @@ namespace PepperDash.Essentials.Core.PageManagers return 10000 + (deviceType * 100); } } - - /// - /// A simple class that hides and shows the default subpage for a given source type - /// - public class DefaultPageManager : PageManager - { - BasicTriList TriList; - uint BackingPageJoin; - - public DefaultPageManager(IUiDisplayInfo device, BasicTriList trilist) - { - TriList = trilist; - BackingPageJoin = GetOffsetJoin(device.DisplayUiType) + 1; - } - - public DefaultPageManager(uint join, BasicTriList trilist) - { - TriList = trilist; - BackingPageJoin = join; - } - - public override void Show() - { - TriList.BooleanInput[BackingPageJoin].BoolValue = true; - } - - public override void Hide() - { - TriList.BooleanInput[BackingPageJoin].BoolValue = false; - } - } - - /// - /// A page manager for a page with backing panel and a switchable side panel - /// - public abstract class MediumLeftSwitchablePageManager : PageManager - { - protected BasicTriListWithSmartObject TriList; - protected uint LeftSubpageJoin; - protected uint BackingPageJoin; - protected uint[] AllLeftSubpages; - protected uint DisplayUiType; - - protected MediumLeftSwitchablePageManager(uint displayUiType) - { - DisplayUiType = displayUiType; - } - - protected void InterlockLeftSubpage(uint join) - { - join = join + GetOffsetJoin(); - ClearLeftInterlock(); - TriList.BooleanInput[join].BoolValue = true; - LeftSubpageJoin = join; - } - - protected void ClearLeftInterlock() - { - foreach (var p in AllLeftSubpages) - TriList.BooleanInput[GetOffsetJoin() + p].BoolValue = false; - } - - protected uint GetOffsetJoin() - { - return GetOffsetJoin(DisplayUiType); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxTwoPanelPageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxMediumPageManager.cs similarity index 100% rename from src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxTwoPanelPageManager.cs rename to src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxMediumPageManager.cs diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs index e0f44046..abb0c82b 100644 --- a/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs +++ b/src/PepperDash.Essentials.Core/UI PageManagers/SetTopBoxThreePanelPageManager.cs @@ -1,114 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Presets; namespace PepperDash.Essentials.Core.PageManagers { - public class ThreePanelPlusOnePageManager : PageManager - { - protected BasicTriListWithSmartObject TriList; - - public uint Position5TabsId { get; set; } - - /// - /// Show the tabs on the third panel - /// - protected bool ShowPosition5Tabs; - - /// - /// Joins that are always visible when this manager is visible - /// - protected uint[] FixedVisibilityJoins; - - /// - /// - /// - protected uint CurrentVisiblePosition5Item; - - /// - /// - /// - /// - public ThreePanelPlusOnePageManager(BasicTriListWithSmartObject trilist) - { - TriList = trilist; - CurrentVisiblePosition5Item = 1; - } - - /// - /// The joins for the switchable panel in position 5 - /// - Dictionary Position5SubpageJoins = new Dictionary - { - { 1, 10053 }, - { 2, 10054 } - }; - - /// - /// - /// - public override void Show() - { - // Project the joins into corresponding sigs. - var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[u]).ToList(); - foreach (var sig in fixedSigs) - sig.BoolValue = true; - - if (ShowPosition5Tabs) - { - // Show selected tab - TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true; - // hook up tab object - var tabSo = TriList.SmartObjects[Position5TabsId]; - tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = new Action(b => { if (!b) ShowTab(1); }); - tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = new Action(b => { if (!b) ShowTab(2); }); - tabSo.SigChange -= tabSo_SigChange; - tabSo.SigChange += tabSo_SigChange; - } - } - - void tabSo_SigChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.SmartObjectEventArgs args) - { - var uo = args.Sig.UserObject; - if(uo is Action) - (uo as Action)(args.Sig.BoolValue); - } - - public override void Hide() - { - var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[u]).ToList(); - foreach (var sig in fixedSigs) - sig.BoolValue = false; - if (ShowPosition5Tabs) - { - TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false; - - //var tabSo = TriList.SmartObjects[Position5TabsId]; - //tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = null; - //tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = null; - } - } - - void ShowTab(uint number) - { - // Ignore re-presses - if (CurrentVisiblePosition5Item == number) return; - // Swap subpage - var bi = TriList.BooleanInput; - if (CurrentVisiblePosition5Item > 0) - bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false; - CurrentVisiblePosition5Item = number; - bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true; - } - } - - - - public class SetTopBoxThreePanelPageManager : ThreePanelPlusOnePageManager + public class SetTopBoxThreePanelPageManager : ThreePanelPlusOnePageManager { ISetTopBoxControls SetTopBox; DevicePresetsView PresetsView; diff --git a/src/PepperDash.Essentials.Core/UI PageManagers/ThreePanelPlusOnePageManager.cs b/src/PepperDash.Essentials.Core/UI PageManagers/ThreePanelPlusOnePageManager.cs new file mode 100644 index 00000000..94bdef15 --- /dev/null +++ b/src/PepperDash.Essentials.Core/UI PageManagers/ThreePanelPlusOnePageManager.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash.Essentials.Core.PageManagers +{ + public class ThreePanelPlusOnePageManager : PageManager + { + protected BasicTriListWithSmartObject TriList; + + public uint Position5TabsId { get; set; } + + /// + /// Show the tabs on the third panel + /// + protected bool ShowPosition5Tabs; + + /// + /// Joins that are always visible when this manager is visible + /// + protected uint[] FixedVisibilityJoins; + + /// + /// + /// + protected uint CurrentVisiblePosition5Item; + + /// + /// + /// + /// + public ThreePanelPlusOnePageManager(BasicTriListWithSmartObject trilist) + { + TriList = trilist; + CurrentVisiblePosition5Item = 1; + } + + /// + /// The joins for the switchable panel in position 5 + /// + Dictionary Position5SubpageJoins = new Dictionary + { + { 1, 10053 }, + { 2, 10054 } + }; + + /// + /// + /// + public override void Show() + { + // Project the joins into corresponding sigs. + var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[(uint)u]).ToList(); + foreach (var sig in fixedSigs) + sig.BoolValue = true; + + if (ShowPosition5Tabs) + { + // Show selected tab + TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true; + // hook up tab object + var tabSo = TriList.SmartObjects[Position5TabsId]; + tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = new Action(b => { if (!b) ShowTab(1); }); + tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = new Action(b => { if (!b) ShowTab(2); }); + tabSo.SigChange -= tabSo_SigChange; + tabSo.SigChange += tabSo_SigChange; + } + } + + void tabSo_SigChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.SmartObjectEventArgs args) + { + var uo = args.Sig.UserObject; + if(uo is Action) + (uo as Action)(args.Sig.BoolValue); + } + + public override void Hide() + { + var fixedSigs = FixedVisibilityJoins.Select(u => TriList.BooleanInput[u]).ToList(); + foreach (var sig in fixedSigs) + sig.BoolValue = false; + if (ShowPosition5Tabs) + { + TriList.BooleanInput[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false; + + //var tabSo = TriList.SmartObjects[Position5TabsId]; + //tabSo.BooleanOutput["Tab Button 1 Press"].UserObject = null; + //tabSo.BooleanOutput["Tab Button 2 Press"].UserObject = null; + } + } + + void ShowTab(uint number) + { + // Ignore re-presses + if (CurrentVisiblePosition5Item == number) return; + // Swap subpage + var bi = TriList.BooleanInput; + if (CurrentVisiblePosition5Item > 0) + bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = false; + CurrentVisiblePosition5Item = number; + bi[Position5SubpageJoins[CurrentVisiblePosition5Item]].BoolValue = true; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs b/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs index 8b657fd5..ee50f5cd 100644 --- a/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs +++ b/src/PepperDash.Essentials.Core/Utilities/ActionSequence.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -11,8 +10,6 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Core.Utilities { /// @@ -119,43 +116,4 @@ namespace PepperDash.Essentials.Core.Utilities } } } - - /// - /// Configuration Properties for ActionSequence - /// - public class ActionSequencePropertiesConfig - { - [JsonProperty("actionSequence")] - public List ActionSequence { get; set; } - - public ActionSequencePropertiesConfig() - { - ActionSequence = new List(); - } - } - - public class SequencedDeviceActionWrapper : DeviceActionWrapper - { - [JsonProperty("delayMs")] - public int DelayMs { get; set; } - } - - /// - /// Factory class - /// - public class ActionSequenceFactory : EssentialsDeviceFactory - { - public ActionSequenceFactory() - { - TypeNames = new List() { "actionsequence" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new ActionSequence Device"); - - return new ActionSequence(dc.Key, dc); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Utilities/ActionSequenceFactory.cs b/src/PepperDash.Essentials.Core/Utilities/ActionSequenceFactory.cs new file mode 100644 index 00000000..fa82ca26 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Utilities/ActionSequenceFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.Utilities +{ + /// + /// Factory class + /// + public class ActionSequenceFactory : EssentialsDeviceFactory + { + public ActionSequenceFactory() + { + TypeNames = new List() { "actionsequence" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new ActionSequence Device"); + + return new ActionSequence(dc.Key, dc); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Utilities/ActionSequencePropertiesConfig.cs b/src/PepperDash.Essentials.Core/Utilities/ActionSequencePropertiesConfig.cs new file mode 100644 index 00000000..d75e75d1 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Utilities/ActionSequencePropertiesConfig.cs @@ -0,0 +1,20 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Utilities +{ + /// + /// Configuration Properties for ActionSequence + /// + public class ActionSequencePropertiesConfig + { + [JsonProperty("actionSequence")] + public List ActionSequence { get; set; } + + public ActionSequencePropertiesConfig() + { + ActionSequence = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Utilities/SequencedDeviceActionWrapper.cs b/src/PepperDash.Essentials.Core/Utilities/SequencedDeviceActionWrapper.cs new file mode 100644 index 00000000..67f411eb --- /dev/null +++ b/src/PepperDash.Essentials.Core/Utilities/SequencedDeviceActionWrapper.cs @@ -0,0 +1,11 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Core.Utilities +{ + public class SequencedDeviceActionWrapper : DeviceActionWrapper + { + [JsonProperty("delayMs")] + public int DelayMs { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusFuncsWrapper.cs b/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusFuncsWrapper.cs new file mode 100644 index 00000000..18ab69f7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusFuncsWrapper.cs @@ -0,0 +1,26 @@ +using System; + +namespace PepperDash.Essentials.Core +{ + /// + /// Use this class to pass in values to RoutingInputPorts. Unused properties will have default + /// funcs assigned to them. + /// + public class VideoStatusFuncsWrapper + { + public Func HasVideoStatusFunc { get; set; } + public Func HdcpActiveFeedbackFunc { get; set; } + public Func HdcpStateFeedbackFunc { get; set; } + public Func VideoResolutionFeedbackFunc { get; set; } + public Func VideoSyncFeedbackFunc { get; set; } + + public VideoStatusFuncsWrapper() + { + HasVideoStatusFunc = () => true; + HdcpActiveFeedbackFunc = () => false; + HdcpStateFeedbackFunc = () => ""; + VideoResolutionFeedbackFunc = () => "n/a"; + VideoSyncFeedbackFunc = () => false; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusOutputs.cs b/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusOutputs.cs index 62d0040a..b139200b 100644 --- a/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusOutputs.cs +++ b/src/PepperDash.Essentials.Core/VideoStatus/VideoStatusOutputs.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -8,29 +7,7 @@ using Crestron.SimplSharpPro.DM; namespace PepperDash.Essentials.Core { - /// - /// Use this class to pass in values to RoutingInputPorts. Unused properties will have default - /// funcs assigned to them. - /// - public class VideoStatusFuncsWrapper - { - public Func HasVideoStatusFunc { get; set; } - public Func HdcpActiveFeedbackFunc { get; set; } - public Func HdcpStateFeedbackFunc { get; set; } - public Func VideoResolutionFeedbackFunc { get; set; } - public Func VideoSyncFeedbackFunc { get; set; } - - public VideoStatusFuncsWrapper() - { - HasVideoStatusFunc = () => true; - HdcpActiveFeedbackFunc = () => false; - HdcpStateFeedbackFunc = () => ""; - VideoResolutionFeedbackFunc = () => "n/a"; - VideoSyncFeedbackFunc = () => false; - } - } - - /// + /// /// Wraps up the common video statuses exposed on a video input port /// public class VideoStatusOutputs diff --git a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs index 70596904..630aa807 100644 --- a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs +++ b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOut.cs @@ -1,13 +1,8 @@ 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.Config; - using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.Devices.Common @@ -61,59 +56,4 @@ namespace PepperDash.Essentials.Devices.Common #endregion } - - - /// - /// Allows a zone-device's audio control to be attached to the endpoint, for easy routing and - /// control switching. Will also set the zone name on attached devices, like SWAMP or other - /// hardware with names built in. - /// - public class GenericAudioOutWithVolume : GenericAudioOut, IHasVolumeDevice - { - public string VolumeDeviceKey { get; private set; } - public uint VolumeZone { get; private set; } - - public IBasicVolumeControls VolumeDevice - { - get - { - var dev = DeviceManager.GetDeviceForKey(VolumeDeviceKey); - if (dev is IAudioZones) - return (dev as IAudioZones).Zone[VolumeZone]; - else return dev as IBasicVolumeControls; - } - } - - /// - /// Constructor - adds the name to the attached audio device, if appropriate. - /// - /// - /// - /// - /// - public GenericAudioOutWithVolume(string key, string name, string audioDevice, uint zone) - : base(key, name) - { - VolumeDeviceKey = audioDevice; - VolumeZone = zone; - } - - } - - public class GenericAudioOutWithVolumeFactory : EssentialsDeviceFactory - { - public GenericAudioOutWithVolumeFactory() - { - TypeNames = new List() { "genericaudiooutwithvolume" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device"); - var zone = dc.Properties.Value("zone"); - return new GenericAudioOutWithVolume(dc.Key, dc.Name, - dc.Properties.Value("volumeDeviceKey"), zone); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolume.cs b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolume.cs new file mode 100644 index 00000000..9c973afc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolume.cs @@ -0,0 +1,41 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common +{ + /// + /// Allows a zone-device's audio control to be attached to the endpoint, for easy routing and + /// control switching. Will also set the zone name on attached devices, like SWAMP or other + /// hardware with names built in. + /// + public class GenericAudioOutWithVolume : GenericAudioOut, IHasVolumeDevice + { + public string VolumeDeviceKey { get; private set; } + public uint VolumeZone { get; private set; } + + public IBasicVolumeControls VolumeDevice + { + get + { + var dev = DeviceManager.GetDeviceForKey(VolumeDeviceKey); + if (dev is IAudioZones) + return (dev as IAudioZones).Zone[VolumeZone]; + else return dev as IBasicVolumeControls; + } + } + + /// + /// Constructor - adds the name to the attached audio device, if appropriate. + /// + /// + /// + /// + /// + public GenericAudioOutWithVolume(string key, string name, string audioDevice, uint zone) + : base(key, name) + { + VolumeDeviceKey = audioDevice; + VolumeZone = zone; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolumeFactory.cs b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolumeFactory.cs new file mode 100644 index 00000000..9b44ec03 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Audio/GenericAudioOutWithVolumeFactory.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class GenericAudioOutWithVolumeFactory : EssentialsDeviceFactory + { + public GenericAudioOutWithVolumeFactory() + { + TypeNames = new List() { "genericaudiooutwithvolume" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device"); + var zone = dc.Properties.Value("zone"); + return new GenericAudioOutWithVolume(dc.Key, dc.Name, + dc.Properties.Value("volumeDeviceKey"), zone); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/AudioCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/AudioCodecInfo.cs new file mode 100644 index 00000000..f5731674 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/AudioCodecInfo.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.AudioCodec +{ + /// + /// Stores general information about a codec + /// + public abstract class AudioCodecInfo + { + public abstract string PhoneNumber { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/IAudioCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/IAudioCodecInfo.cs index e853c898..11fc8ee3 100644 --- a/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/IAudioCodecInfo.cs +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/Interfaces/IAudioCodecInfo.cs @@ -13,12 +13,4 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec { AudioCodecInfo CodecInfo { get; } } - - /// - /// Stores general information about a codec - /// - public abstract class AudioCodecInfo - { - public abstract string PhoneNumber { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs index 84880654..7cc98830 100644 --- a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAC.cs @@ -1,12 +1,9 @@ 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.Config; using PepperDash.Essentials.Devices.Common.Codec; namespace PepperDash.Essentials.Devices.Common.AudioCodec @@ -95,37 +92,4 @@ namespace PepperDash.Essentials.Devices.Common.AudioCodec } } - - public class MockAudioCodecInfo : AudioCodecInfo - { - string _phoneNumber; - - public override string PhoneNumber - { - get - { - return _phoneNumber; - } - set - { - _phoneNumber = value; - } - } - } - - public class MockACFactory : EssentialsDeviceFactory - { - public MockACFactory() - { - TypeNames = new List() { "mockac" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new MockAc Device"); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); - return new AudioCodec.MockAC(dc.Key, dc.Name, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockACFactory.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockACFactory.cs new file mode 100644 index 00000000..8febcb19 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockACFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.AudioCodec +{ + public class MockACFactory : EssentialsDeviceFactory + { + public MockACFactory() + { + TypeNames = new List() { "mockac" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new MockAc Device"); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + return new AudioCodec.MockAC(dc.Key, dc.Name, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAudioCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAudioCodecInfo.cs new file mode 100644 index 00000000..7f2b08ba --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/AudioCodec/MockAC/MockAudioCodecInfo.cs @@ -0,0 +1,19 @@ +namespace PepperDash.Essentials.Devices.Common.AudioCodec +{ + public class MockAudioCodecInfo : AudioCodecInfo + { + string _phoneNumber; + + public override string PhoneNumber + { + get + { + return _phoneNumber; + } + set + { + _phoneNumber = value; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs index 294e9066..99e471a6 100644 --- a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; @@ -13,22 +12,12 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Devices.Common.Codec; using Full.Newtonsoft.Json; namespace PepperDash.Essentials.Devices.Common.Cameras { - public enum eCameraCapabilities - { - None = 0, - Pan = 1, - Tilt = 2, - Zoom = 4, - Focus = 8 - } - public abstract class CameraBase : ReconfigurableDevice, IRoutingOutputs { [JsonProperty("controlMode", NullValueHandling = NullValueHandling.Ignore)] @@ -267,31 +256,4 @@ namespace PepperDash.Essentials.Devices.Common.Cameras } } } - - - public class CameraPreset : PresetBase - { - public CameraPreset(int id, string description, bool isDefined, bool isDefinable) - : base(id, description, isDefined, isDefinable) - { - - } - } - - - 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/src/PepperDash.Essentials.Devices.Common/Cameras/CameraControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraControl.cs deleted file mode 100644 index cbf53476..00000000 --- a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraControl.cs +++ /dev/null @@ -1,166 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Devices.Common.Cameras -{ - public enum eCameraControlMode - { - Manual = 0, - Off, - Auto - } - - - public interface IHasCameras - { - event EventHandler CameraSelected; - - List Cameras { get; } - - CameraBase SelectedCamera { get; } - - StringFeedback SelectedCameraFeedback { get; } - - void SelectCamera(string key); - } - - /// - /// Aggregates far end cameras with near end cameras - /// - public interface IHasCodecCameras : IHasCameras, IHasFarEndCameraControl - { - - } - - /// - /// To be implmented on codecs that can disable their camera(s) to blank the near end video - /// - public interface IHasCameraOff - { - BoolFeedback CameraIsOffFeedback { get; } - void CameraOff(); - } - - /// - /// Describes the ability to mute and unmute camera video - /// - public interface IHasCameraMute - { - BoolFeedback CameraIsMutedFeedback { get; } - void CameraMuteOn(); - void CameraMuteOff(); - void CameraMuteToggle(); - } - - public interface IHasCameraMuteWithUnmuteReqeust : IHasCameraMute - { - event EventHandler VideoUnmuteRequested; - } - - public class CameraSelectedEventArgs : EventArgs - { - public CameraBase SelectedCamera { get; private set; } - - public CameraSelectedEventArgs(CameraBase camera) - { - SelectedCamera = camera; - } - } - - public interface IHasFarEndCameraControl - { - CameraBase FarEndCamera { get; } - - BoolFeedback ControllingFarEndCameraFeedback { get; } - - } - - /// - /// Used to decorate a camera as a far end - /// - public interface IAmFarEndCamera - { - - } - - public interface IHasCameraControls - { - } - - /// - /// Aggregates the pan, tilt and zoom interfaces - /// - public interface IHasCameraPtzControl : IHasCameraPanControl, IHasCameraTiltControl, IHasCameraZoomControl - { - /// - /// Resets the camera position - /// - void PositionHome(); - } - - /// - /// Interface for camera pan control - /// - public interface IHasCameraPanControl : IHasCameraControls - { - void PanLeft(); - void PanRight(); - void PanStop(); - } - - /// - /// Interface for camera tilt control - /// - public interface IHasCameraTiltControl : IHasCameraControls - { - void TiltDown(); - void TiltUp(); - void TiltStop(); - } - - /// - /// Interface for camera zoom control - /// - public interface IHasCameraZoomControl : IHasCameraControls - { - void ZoomIn(); - void ZoomOut(); - void ZoomStop(); - } - - /// - /// Interface for camera focus control - /// - public interface IHasCameraFocusControl : IHasCameraControls - { - void FocusNear(); - void FocusFar(); - void FocusStop(); - - void TriggerAutoFocus(); - } - - public interface IHasAutoFocusMode - { - void SetFocusModeAuto(); - void SetFocusModeManual(); - void ToggleFocusMode(); - } - - public interface IHasCameraAutoMode : IHasCameraControls - { - void CameraAutoModeOn(); - void CameraAutoModeOff(); - void CameraAutoModeToggle(); - BoolFeedback CameraAutoModeIsOnFeedback { get; } - } - - - - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPreset.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPreset.cs new file mode 100644 index 00000000..99e210aa --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPreset.cs @@ -0,0 +1,13 @@ +using PepperDash.Essentials.Core.Presets; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public class CameraPreset : PresetBase + { + public CameraPreset(int id, string description, bool isDefined, bool isDefinable) + : base(id, description, isDefined, isDefinable) + { + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPropertiesConfig.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPropertiesConfig.cs new file mode 100644 index 00000000..246801b5 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraPropertiesConfig.cs @@ -0,0 +1,24 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + 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/src/PepperDash.Essentials.Devices.Common/Cameras/CameraSelectedEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraSelectedEventArgs.cs new file mode 100644 index 00000000..fe3c7618 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraSelectedEventArgs.cs @@ -0,0 +1,17 @@ +using System; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public class CameraSelectedEventArgs : EventArgs + { + public CameraBase SelectedCamera { get; private set; } + + public CameraSelectedEventArgs(CameraBase camera) + { + SelectedCamera = camera; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs index 5f609c46..7191bceb 100644 --- a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraVisca.cs @@ -9,13 +9,10 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Devices.Common.Codec; using System.Text.RegularExpressions; using Crestron.SimplSharp.Reflection; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Devices.Common.Cameras { public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets, IHasPowerControlWithFeedback, IBridgeAdvanced, IHasCameraFocusControl, IHasAutoFocusMode @@ -635,63 +632,4 @@ namespace PepperDash.Essentials.Devices.Common.Cameras #endregion } - - public class CameraViscaFactory : EssentialsDeviceFactory - { - public CameraViscaFactory() - { - TypeNames = new List() { "cameravisca" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new CameraVisca Device"); - var comm = CommFactory.CreateCommForDevice(dc); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new Cameras.CameraVisca(dc.Key, dc.Name, comm, props); - } - } - - - public class CameraViscaPropertiesConfig : CameraPropertiesConfig - { - /// - /// Control ID of the camera (1-7) - /// - [JsonProperty("id")] - public uint Id { get; set; } - - /// - /// Slow Pan speed (0-18) - /// - [JsonProperty("panSpeedSlow")] - public uint PanSpeedSlow { get; set; } - - /// - /// Fast Pan speed (0-18) - /// - [JsonProperty("panSpeedFast")] - public uint PanSpeedFast { get; set; } - - /// - /// Slow tilt speed (0-18) - /// - [JsonProperty("tiltSpeedSlow")] - public uint TiltSpeedSlow { get; set; } - - /// - /// Fast tilt speed (0-18) - /// - [JsonProperty("tiltSpeedFast")] - public uint TiltSpeedFast { get; set; } - - /// - /// Time a button must be held before fast speed is engaged (Milliseconds) - /// - [JsonProperty("fastSpeedHoldTimeMs")] - public uint FastSpeedHoldTimeMs { get; set; } - - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaFactory.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaFactory.cs new file mode 100644 index 00000000..eac79aa2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public class CameraViscaFactory : EssentialsDeviceFactory + { + public CameraViscaFactory() + { + TypeNames = new List() { "cameravisca" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CameraVisca Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new Cameras.CameraVisca(dc.Key, dc.Name, comm, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaPropertiesConfig.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaPropertiesConfig.cs new file mode 100644 index 00000000..07dbd9d7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/CameraViscaPropertiesConfig.cs @@ -0,0 +1,45 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public class CameraViscaPropertiesConfig : CameraPropertiesConfig + { + /// + /// Control ID of the camera (1-7) + /// + [JsonProperty("id")] + public uint Id { get; set; } + + /// + /// Slow Pan speed (0-18) + /// + [JsonProperty("panSpeedSlow")] + public uint PanSpeedSlow { get; set; } + + /// + /// Fast Pan speed (0-18) + /// + [JsonProperty("panSpeedFast")] + public uint PanSpeedFast { get; set; } + + /// + /// Slow tilt speed (0-18) + /// + [JsonProperty("tiltSpeedSlow")] + public uint TiltSpeedSlow { get; set; } + + /// + /// Fast tilt speed (0-18) + /// + [JsonProperty("tiltSpeedFast")] + public uint TiltSpeedFast { get; set; } + + /// + /// Time a button must be held before fast speed is engaged (Milliseconds) + /// + [JsonProperty("fastSpeedHoldTimeMs")] + public uint FastSpeedHoldTimeMs { get; set; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IAmFarEndCamera.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IAmFarEndCamera.cs new file mode 100644 index 00000000..6efc5093 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IAmFarEndCamera.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Used to decorate a camera as a far end + /// + public interface IAmFarEndCamera + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasAutoFocusMode.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasAutoFocusMode.cs new file mode 100644 index 00000000..5924bf33 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasAutoFocusMode.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasAutoFocusMode + { + void SetFocusModeAuto(); + void SetFocusModeManual(); + void ToggleFocusMode(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraAutoMode.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraAutoMode.cs new file mode 100644 index 00000000..df17f51a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraAutoMode.cs @@ -0,0 +1,12 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasCameraAutoMode : IHasCameraControls + { + void CameraAutoModeOn(); + void CameraAutoModeOff(); + void CameraAutoModeToggle(); + BoolFeedback CameraAutoModeIsOnFeedback { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraControls.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraControls.cs new file mode 100644 index 00000000..0e068589 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraControls.cs @@ -0,0 +1,6 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasCameraControls + { + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraFocusControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraFocusControl.cs new file mode 100644 index 00000000..889200dc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraFocusControl.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Interface for camera focus control + /// + public interface IHasCameraFocusControl : IHasCameraControls + { + void FocusNear(); + void FocusFar(); + void FocusStop(); + + void TriggerAutoFocus(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMute.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMute.cs new file mode 100644 index 00000000..4bb7a4d0 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMute.cs @@ -0,0 +1,15 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Describes the ability to mute and unmute camera video + /// + public interface IHasCameraMute + { + BoolFeedback CameraIsMutedFeedback { get; } + void CameraMuteOn(); + void CameraMuteOff(); + void CameraMuteToggle(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMuteWithUnmuteReqeust.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMuteWithUnmuteReqeust.cs new file mode 100644 index 00000000..6a2763b2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraMuteWithUnmuteReqeust.cs @@ -0,0 +1,9 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasCameraMuteWithUnmuteReqeust : IHasCameraMute + { + event EventHandler VideoUnmuteRequested; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraOff.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraOff.cs new file mode 100644 index 00000000..16d7b3a9 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraOff.cs @@ -0,0 +1,13 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// To be implmented on codecs that can disable their camera(s) to blank the near end video + /// + public interface IHasCameraOff + { + BoolFeedback CameraIsOffFeedback { get; } + void CameraOff(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPanControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPanControl.cs new file mode 100644 index 00000000..69057c6e --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPanControl.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Interface for camera pan control + /// + public interface IHasCameraPanControl : IHasCameraControls + { + void PanLeft(); + void PanRight(); + void PanStop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPtzControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPtzControl.cs new file mode 100644 index 00000000..1023b84a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraPtzControl.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Aggregates the pan, tilt and zoom interfaces + /// + public interface IHasCameraPtzControl : IHasCameraPanControl, IHasCameraTiltControl, IHasCameraZoomControl + { + /// + /// Resets the camera position + /// + void PositionHome(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraTiltControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraTiltControl.cs new file mode 100644 index 00000000..9b0b183f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraTiltControl.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Interface for camera tilt control + /// + public interface IHasCameraTiltControl : IHasCameraControls + { + void TiltDown(); + void TiltUp(); + void TiltStop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraZoomControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraZoomControl.cs new file mode 100644 index 00000000..5a9d0f9a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameraZoomControl.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Interface for camera zoom control + /// + public interface IHasCameraZoomControl : IHasCameraControls + { + void ZoomIn(); + void ZoomOut(); + void ZoomStop(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameras.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameras.cs new file mode 100644 index 00000000..2b53a822 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCameras.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasCameras + { + event EventHandler CameraSelected; + + List Cameras { get; } + + CameraBase SelectedCamera { get; } + + StringFeedback SelectedCameraFeedback { get; } + + void SelectCamera(string key); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCodecCameras.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCodecCameras.cs new file mode 100644 index 00000000..22473364 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasCodecCameras.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + /// + /// Aggregates far end cameras with near end cameras + /// + public interface IHasCodecCameras : IHasCameras, IHasFarEndCameraControl + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/IHasFarEndCameraControl.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasFarEndCameraControl.cs new file mode 100644 index 00000000..097e6363 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/IHasFarEndCameraControl.cs @@ -0,0 +1,12 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public interface IHasFarEndCameraControl + { + CameraBase FarEndCamera { get; } + + BoolFeedback ControllingFarEndCameraFeedback { get; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraCapabilities.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraCapabilities.cs new file mode 100644 index 00000000..687e47fc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraCapabilities.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public enum eCameraCapabilities + { + None = 0, + Pan = 1, + Tilt = 2, + Zoom = 4, + Focus = 8 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraControlMode.cs b/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraControlMode.cs new file mode 100644 index 00000000..1356793c --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Cameras/eCameraControlMode.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public enum eCameraControlMode + { + Manual = 0, + Off, + Auto + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/Call.cs b/src/PepperDash.Essentials.Devices.Common/Codec/Call.cs new file mode 100644 index 00000000..0003f805 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/Call.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class Call + { + public string Number { get; set; } + public string Protocol { get; set; } + public string CallRate { get; set; } + public string CallType { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecActiveCallItem.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecActiveCallItem.cs index f9624991..c77b86c2 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/CodecActiveCallItem.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecActiveCallItem.cs @@ -59,17 +59,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec } } } - - /// - /// - /// - public class CodecCallStatusItemChangeEventArgs : EventArgs - { - public CodecActiveCallItem CallItem { get; private set; } - - public CodecCallStatusItemChangeEventArgs(CodecActiveCallItem item) - { - CallItem = item; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallDirection.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallDirection.cs new file mode 100644 index 00000000..c23b58f7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallDirection.cs @@ -0,0 +1,29 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class CodecCallDirection + { + /// + /// Takes the Cisco call type and converts to the matching enum + /// + /// + /// + public static eCodecCallDirection ConvertToDirectionEnum(string s) + { + switch (s.ToLower()) + { + case "incoming": + { + return eCodecCallDirection.Incoming; + } + case "outgoing": + { + return eCodecCallDirection.Outgoing; + } + default: + return eCodecCallDirection.Unknown; + } + + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallFavorites.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallFavorites.cs new file mode 100644 index 00000000..15a7818b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallFavorites.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents favorites entries for a codec device + /// + public class CodecCallFavorites + { + public List Favorites { get; set; } + + public CodecCallFavorites() + { + Favorites = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallHistory.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallHistory.cs new file mode 100644 index 00000000..c09c473f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallHistory.cs @@ -0,0 +1,120 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using Full::Newtonsoft.Json.Converters; +using PepperDash.Essentials.Devices.Common.VideoCodec; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents the recent call history for a codec device + /// + public class CodecCallHistory + { + public event EventHandler RecentCallsListHasChanged; + + public List RecentCalls { get; private set; } + + /// + /// Item that gets added to the list when there are no recent calls in history + /// + CallHistoryEntry ListEmptyEntry; + + public CodecCallHistory() + { + ListEmptyEntry = new CallHistoryEntry() { Name = "No Recent Calls" }; + + RecentCalls = new List(); + + RecentCalls.Add(ListEmptyEntry); + } + + void OnRecentCallsListChange() + { + var handler = RecentCallsListHasChanged; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + + public void RemoveEntry(CallHistoryEntry entry) + { + RecentCalls.Remove(entry); + OnRecentCallsListChange(); + } + + /// + /// Generic call history entry, not device specific + /// + public class CallHistoryEntry : CodecActiveCallItem + { + [JsonConverter(typeof(IsoDateTimeConverter))] + [JsonProperty("startTime")] + public DateTime StartTime { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + [JsonProperty("occurrenceType")] + public eCodecOccurrenceType OccurrenceType { get; set; } + [JsonProperty("occurrenceHistoryId")] + public string OccurrenceHistoryId { get; set; } + } + + /// + /// Converts a list of call history entries returned by a Cisco codec to the generic list type + /// + /// + /// + public void ConvertCiscoCallHistoryToGeneric(List entries) + { + var genericEntries = new List(); + + foreach (CiscoCallHistory.Entry entry in entries) + { + + genericEntries.Add(new CallHistoryEntry() + { + Name = entry.DisplayName.Value, + Number = entry.CallbackNumber.Value, + StartTime = entry.LastOccurrenceStartTime.Value, + OccurrenceHistoryId = entry.LastOccurrenceHistoryId.Value, + OccurrenceType = ConvertToOccurenceTypeEnum(entry.OccurrenceType.Value) + }); + } + + // Check if list is empty and if so, add an item to display No Recent Calls + if(genericEntries.Count == 0) + genericEntries.Add(ListEmptyEntry); + + RecentCalls = genericEntries; + OnRecentCallsListChange(); + } + + /// + /// Takes the Cisco occurence type and converts it to the matching enum + /// + /// + /// Takes the Cisco privacy type and converts to the matching enum + /// + /// + /// + public static eMeetingPrivacy ConvertToDirectionEnum(string s) + { + switch (s.ToLower()) + { + case "public": + { + return eMeetingPrivacy.Public; + } + case "private": + { + return eMeetingPrivacy.Private; + } + default: + return eMeetingPrivacy.Unknown; + } + + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatus.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatus.cs new file mode 100644 index 00000000..8d4b5456 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatus.cs @@ -0,0 +1,66 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class CodecCallStatus + { + + /// + /// Takes the Cisco call type and converts to the matching enum + /// + /// + /// + public static eCodecCallStatus ConvertToStatusEnum(string s) + { + switch (s) + { + case "Connected": + { + return eCodecCallStatus.Connected; + } + case "Connecting": + { + return eCodecCallStatus.Connecting; + } + case "Dialling": + { + return eCodecCallStatus.Dialing; + } + case "Disconnected": + { + return eCodecCallStatus.Disconnected; + } + case "Disconnecting": + { + return eCodecCallStatus.Disconnecting; + } + case "EarlyMedia": + { + return eCodecCallStatus.EarlyMedia; + } + case "Idle": + { + return eCodecCallStatus.Idle; + } + case "OnHold": + { + return eCodecCallStatus.OnHold; + } + case "Ringing": + { + return eCodecCallStatus.Ringing; + } + case "Preserved": + { + return eCodecCallStatus.Preserved; + } + case "RemotePreserved": + { + return eCodecCallStatus.RemotePreserved; + } + default: + return eCodecCallStatus.Unknown; + } + + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatusItemChangeEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatusItemChangeEventArgs.cs new file mode 100644 index 00000000..dba7606f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallStatusItemChangeEventArgs.cs @@ -0,0 +1,17 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// + /// + public class CodecCallStatusItemChangeEventArgs : EventArgs + { + public CodecActiveCallItem CallItem { get; private set; } + + public CodecCallStatusItemChangeEventArgs(CodecActiveCallItem item) + { + CallItem = item; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallType.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallType.cs new file mode 100644 index 00000000..e76e0bef --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecCallType.cs @@ -0,0 +1,38 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class CodecCallType + { + + /// + /// Takes the Cisco call type and converts to the matching enum + /// + /// + /// + public static eCodecCallType ConvertToTypeEnum(string s) + { + switch (s) + { + case "Audio": + { + return eCodecCallType.Audio; + } + case "Video": + { + return eCodecCallType.Video; + } + case "AudioCanEscalate": + { + return eCodecCallType.AudioCanEscalate; + } + case "ForwardAllCall": + { + return eCodecCallType.ForwardAllCall; + } + default: + return eCodecCallType.Unknown; + } + + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecDirectory.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecDirectory.cs new file mode 100644 index 00000000..20e5ef9a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecDirectory.cs @@ -0,0 +1,108 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using System.Linq; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents a codec directory + /// + public class CodecDirectory + { + /// + /// Represents the contents of the directory + /// We don't want to serialize this for messages to MobileControl. MC can combine Contacts and Folders to get the same data + /// + [JsonIgnore] + public List CurrentDirectoryResults { get; private set; } + + [JsonProperty("contacts")] + public List Contacts + { + get + { + return CurrentDirectoryResults.OfType().Cast().ToList(); + } + } + + [JsonProperty("folders")] + public List Folders + { + get + { + return CurrentDirectoryResults.OfType().Cast().ToList(); + } + } + + /// + /// Used to store the ID of the current folder for CurrentDirectoryResults + /// + [JsonProperty("resultsFolderId")] + public string ResultsFolderId { get; set; } + + public CodecDirectory() + { + CurrentDirectoryResults = new List(); + } + + /// + /// Adds folders to the directory + /// + /// + public void AddFoldersToDirectory(List folders) + { + if(folders != null) + CurrentDirectoryResults.AddRange(folders); + + SortDirectory(); + } + + /// + /// Adds contacts to the directory + /// + /// + public void AddContactsToDirectory(List contacts) + { + if(contacts != null) + CurrentDirectoryResults.AddRange(contacts); + + SortDirectory(); + } + + /// + /// Filters the CurrentDirectoryResults by the predicate + /// + /// + public void FilterContacts(Func predicate) + { + CurrentDirectoryResults = CurrentDirectoryResults.Where(predicate).ToList(); + } + + /// + /// Sorts the DirectoryResults list to display all folders alphabetically, then all contacts alphabetically + /// + private void SortDirectory() + { + var sortedFolders = new List(); + + sortedFolders.AddRange(CurrentDirectoryResults.Where(f => f is DirectoryFolder)); + + sortedFolders.OrderBy(f => f.Name); + + var sortedContacts = new List(); + + sortedContacts.AddRange(CurrentDirectoryResults.Where(c => c is DirectoryContact)); + + sortedFolders.OrderBy(c => c.Name); + + CurrentDirectoryResults.Clear(); + + CurrentDirectoryResults.AddRange(sortedFolders); + + CurrentDirectoryResults.AddRange(sortedContacts); + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/CodecScheduleAwareness.cs b/src/PepperDash.Essentials.Devices.Common/Codec/CodecScheduleAwareness.cs new file mode 100644 index 00000000..07b282bd --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/CodecScheduleAwareness.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class CodecScheduleAwareness + { + List _meetings; + + public event EventHandler MeetingEventChange; + + public event EventHandler MeetingsListHasChanged; + + private int _meetingWarningMinutes = 5; + + private Meeting _previousChangedMeeting; + + private eMeetingEventChangeType _previousChangeType = eMeetingEventChangeType.Unknown; + + public int MeetingWarningMinutes + { + get { return _meetingWarningMinutes; } + set { _meetingWarningMinutes = value; } + } + + /// + /// Setter triggers MeetingsListHasChanged event + /// + public List Meetings + { + get + { + return _meetings; + } + set + { + _meetings = value; + + var handler = MeetingsListHasChanged; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + } + + private CTimer _scheduleChecker; + + public CodecScheduleAwareness() + { + Meetings = new List(); + + _scheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000); + } + + public CodecScheduleAwareness(long pollTime) + { + Meetings = new List(); + + _scheduleChecker = new CTimer(CheckSchedule, null, pollTime, pollTime); + } + + /// + /// Helper method to fire MeetingEventChange. Should only fire once for each changeType on each meeting + /// + /// + /// + private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting) + { + Debug.Console(2, "*****************OnMeetingChange. id: {0} changeType: {1}**********************", meeting.Id, changeType); + if (changeType != (changeType & meeting.NotifiedChangeTypes)) + { + // Add this change type to the NotifiedChangeTypes + meeting.NotifiedChangeTypes |= changeType; + + var handler = MeetingEventChange; + if (handler != null) + { + handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting }); + } + } + else + { + Debug.Console(2, "Meeting: {0} already notified of changeType: {1}", meeting.Id, changeType); + } + } + + + /// + /// Checks the schedule to see if any MeetingEventChange updates should be fired + /// + /// + private void CheckSchedule(object o) + { + // Iterate the meeting list and check if any meeting need to do anything + + const double meetingTimeEpsilon = 0.05; + foreach (var m in Meetings) + { + var changeType = eMeetingEventChangeType.Unknown; + + if (eMeetingEventChangeType.MeetingStartWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStartWarning) && m.TimeToMeetingStart.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingStart.Seconds > 0) // Meeting is about to start + { + Debug.Console(2, "********************* MeetingStartWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingStart.TotalMinutes, m.TimeToMeetingStart.Seconds); + changeType = eMeetingEventChangeType.MeetingStartWarning; + } + else if (eMeetingEventChangeType.MeetingStart != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStart) && Math.Abs(m.TimeToMeetingStart.TotalMinutes) < meetingTimeEpsilon) // Meeting Start + { + Debug.Console(2, "********************* MeetingStart"); + changeType = eMeetingEventChangeType.MeetingStart; + } + else if (eMeetingEventChangeType.MeetingEndWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEndWarning) && m.TimeToMeetingEnd.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingEnd.Seconds > 0) // Meeting is about to end + { + Debug.Console(2, "********************* MeetingEndWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingEnd.TotalMinutes, m.TimeToMeetingEnd.Seconds); + changeType = eMeetingEventChangeType.MeetingEndWarning; + } + else if (eMeetingEventChangeType.MeetingEnd != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEnd) && Math.Abs(m.TimeToMeetingEnd.TotalMinutes) < meetingTimeEpsilon) // Meeting has ended + { + Debug.Console(2, "********************* MeetingEnd"); + changeType = eMeetingEventChangeType.MeetingEnd; + } + + if (changeType != eMeetingEventChangeType.Unknown) + { + OnMeetingChange(changeType, m); + } + } + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/ContactMethod.cs b/src/PepperDash.Essentials.Devices.Common/Codec/ContactMethod.cs new file mode 100644 index 00000000..704c40fc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/ContactMethod.cs @@ -0,0 +1,26 @@ +extern alias Full; +using Full::Newtonsoft.Json; +using Full::Newtonsoft.Json.Converters; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents a method of contact for a contact + /// + public class ContactMethod + { + [JsonProperty("contactMethodId")] + public string ContactMethodId { get; set; } + + [JsonProperty("number")] + public string Number { get; set; } + + [JsonProperty("device")] + [JsonConverter(typeof(StringEnumConverter))] + public eContactMethodDevice Device { get; set; } + + [JsonProperty("callType")] + [JsonConverter(typeof(StringEnumConverter))] + public eContactMethodCallType CallType { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryContact.cs b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryContact.cs new file mode 100644 index 00000000..c122a7c2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryContact.cs @@ -0,0 +1,26 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents a contact type DirectoryItem + /// + public class DirectoryContact : DirectoryItem + { + [JsonProperty("contactId")] + public string ContactId { get; set; } + + [JsonProperty("title")] + public string Title { get; set; } + + [JsonProperty("contactMethods")] + public List ContactMethods { get; set; } + + public DirectoryContact() + { + ContactMethods = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryEventArgs.cs new file mode 100644 index 00000000..acb86fd4 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryEventArgs.cs @@ -0,0 +1,13 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// + /// + public class DirectoryEventArgs : EventArgs + { + public CodecDirectory Directory { get; set; } + public bool DirectoryIsOnRoot { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryFolder.cs b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryFolder.cs new file mode 100644 index 00000000..db6ed368 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryFolder.cs @@ -0,0 +1,21 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents a folder type DirectoryItem + /// + public class DirectoryFolder : DirectoryItem + { + [JsonProperty("contacts")] + public List Contacts { get; set; } + + + public DirectoryFolder() + { + Contacts = new List(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryItem.cs b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryItem.cs new file mode 100644 index 00000000..3a4a645a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/DirectoryItem.cs @@ -0,0 +1,26 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Represents an item in the directory + /// + public class DirectoryItem : ICloneable + { + public object Clone() + { + return this.MemberwiseClone(); + } + + [JsonProperty("folderId")] + public string FolderId { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("parentFolderId")] + public string ParentFolderId { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/IHasDirectoryHistoryStack.cs b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDirectoryHistoryStack.cs new file mode 100644 index 00000000..79fc7246 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDirectoryHistoryStack.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public interface IHasDirectoryHistoryStack : IHasDirectory + { + Stack DirectoryBrowseHistoryStack { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturb.cs b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbMode.cs similarity index 76% rename from src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturb.cs rename to src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbMode.cs index 7bb9b924..392df714 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturb.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbMode.cs @@ -33,13 +33,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// void ToggleDoNotDisturbMode(); } - - public interface IHasDoNotDisturbModeWithTimeout : IHasDoNotDisturbMode - { - /// - /// Activates Do Not Disturb mode with a timeout - /// - /// - void ActivateDoNotDisturbMode(int timeout); - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbModeWithTimeout.cs b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbModeWithTimeout.cs new file mode 100644 index 00000000..d9800d18 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/IHasDoNotDisturbModeWithTimeout.cs @@ -0,0 +1,11 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public interface IHasDoNotDisturbModeWithTimeout : IHasDoNotDisturbMode + { + /// + /// Activates Do Not Disturb mode with a timeout + /// + /// + void ActivateDoNotDisturbMode(int timeout); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/IInvitableContact.cs b/src/PepperDash.Essentials.Devices.Common/Codec/IInvitableContact.cs new file mode 100644 index 00000000..dbbedc9a --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/IInvitableContact.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Used to decorate a contact to indicate it can be invided to a meeting + /// + public interface IInvitableContact + { + bool IsInvitableContact { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/InvitableDirectoryContact.cs b/src/PepperDash.Essentials.Devices.Common/Codec/InvitableDirectoryContact.cs new file mode 100644 index 00000000..0208f20d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/InvitableDirectoryContact.cs @@ -0,0 +1,17 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class InvitableDirectoryContact : DirectoryContact, IInvitableContact + { + [JsonProperty("isInvitableContact")] + public bool IsInvitableContact + { + get + { + return this is IInvitableContact; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/Meeting.cs b/src/PepperDash.Essentials.Devices.Common/Codec/Meeting.cs new file mode 100644 index 00000000..7f0d9fe8 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/Meeting.cs @@ -0,0 +1,112 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Generic class to represent a meeting (Cisco or Polycom OBTP or Fusion) + /// + public class Meeting + { + [JsonProperty("minutesBeforeMeeting")] + public int MinutesBeforeMeeting; + + [JsonProperty("id")] + public string Id { get; set; } + [JsonProperty("organizer")] + public string Organizer { get; set; } + [JsonProperty("title")] + public string Title { get; set; } + [JsonProperty("agenda")] + public string Agenda { get; set; } + + [JsonProperty("meetingWarningMinutes")] + public TimeSpan MeetingWarningMinutes + { + get { return TimeSpan.FromMinutes(MinutesBeforeMeeting); } + } + [JsonProperty("timeToMeetingStart")] + public TimeSpan TimeToMeetingStart + { + get + { + return StartTime - DateTime.Now; + } + } + [JsonProperty("timeToMeetingEnd")] + public TimeSpan TimeToMeetingEnd + { + get + { + return EndTime - DateTime.Now; + } + } + [JsonProperty("startTime")] + public DateTime StartTime { get; set; } + [JsonProperty("endTime")] + public DateTime EndTime { get; set; } + [JsonProperty("duration")] + public TimeSpan Duration + { + get + { + return EndTime - StartTime; + } + } + [JsonProperty("privacy")] + public eMeetingPrivacy Privacy { get; set; } + [JsonProperty("joinable")] + public bool Joinable + { + get + { + var joinable = StartTime.AddMinutes(-MinutesBeforeMeeting) <= DateTime.Now + && DateTime.Now <= EndTime.AddSeconds(-_joinableCooldownSeconds); + //Debug.Console(2, "Meeting Id: {0} joinable: {1}", Id, joinable); + return joinable; + } + } + //public string ConferenceNumberToDial { get; set; } + [JsonProperty("conferencePassword")] + public string ConferencePassword { get; set; } + [JsonProperty("isOneButtonToPushMeeting")] + public bool IsOneButtonToPushMeeting { get; set; } + + [JsonProperty("calls")] + public List Calls { get; private set; } + + /// + /// Tracks the change types that have already been notified for + /// + [JsonIgnore] + public eMeetingEventChangeType NotifiedChangeTypes { get; set; } + + [JsonIgnore] private readonly int _joinableCooldownSeconds; + + + public Meeting() + { + Calls = new List(); + _joinableCooldownSeconds = 300; + } + + public Meeting(int joinableCooldownSeconds) + { + Calls = new List(); + _joinableCooldownSeconds = joinableCooldownSeconds; + } + + + + #region Overrides of Object + + public override string ToString() + { + return String.Format("{0}:{1}: {2}-{3}", Title, Agenda, StartTime, EndTime); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/MeetingEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/Codec/MeetingEventArgs.cs new file mode 100644 index 00000000..8c0253a7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/MeetingEventArgs.cs @@ -0,0 +1,10 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class MeetingEventArgs : EventArgs + { + public eMeetingEventChangeType ChangeType { get; set; } + public Meeting Meeting { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallDirection.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallDirection.cs index a5e118df..f77ffd03 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallDirection.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallDirection.cs @@ -11,31 +11,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec { Unknown = 0, Incoming, Outgoing } - - public class CodecCallDirection - { - /// - /// Takes the Cisco call type and converts to the matching enum - /// - /// - /// - public static eCodecCallDirection ConvertToDirectionEnum(string s) - { - switch (s.ToLower()) - { - case "incoming": - { - return eCodecCallDirection.Incoming; - } - case "outgoing": - { - return eCodecCallDirection.Outgoing; - } - default: - return eCodecCallDirection.Unknown; - } - - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallStatus.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallStatus.cs index 610d928b..3320db98 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallStatus.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallStatus.cs @@ -21,69 +21,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec Preserved, RemotePreserved, } - - - public class CodecCallStatus - { - - /// - /// Takes the Cisco call type and converts to the matching enum - /// - /// - /// - public static eCodecCallStatus ConvertToStatusEnum(string s) - { - switch (s) - { - case "Connected": - { - return eCodecCallStatus.Connected; - } - case "Connecting": - { - return eCodecCallStatus.Connecting; - } - case "Dialling": - { - return eCodecCallStatus.Dialing; - } - case "Disconnected": - { - return eCodecCallStatus.Disconnected; - } - case "Disconnecting": - { - return eCodecCallStatus.Disconnecting; - } - case "EarlyMedia": - { - return eCodecCallStatus.EarlyMedia; - } - case "Idle": - { - return eCodecCallStatus.Idle; - } - case "OnHold": - { - return eCodecCallStatus.OnHold; - } - case "Ringing": - { - return eCodecCallStatus.Ringing; - } - case "Preserved": - { - return eCodecCallStatus.Preserved; - } - case "RemotePreserved": - { - return eCodecCallStatus.RemotePreserved; - } - default: - return eCodecCallStatus.Unknown; - } - - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallType.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallType.cs index dbab015b..bd797c19 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallType.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecCallType.cs @@ -15,40 +15,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec AudioCanEscalate, ForwardAllCall } - - public class CodecCallType - { - - /// - /// Takes the Cisco call type and converts to the matching enum - /// - /// - /// - public static eCodecCallType ConvertToTypeEnum(string s) - { - switch (s) - { - case "Audio": - { - return eCodecCallType.Audio; - } - case "Video": - { - return eCodecCallType.Video; - } - case "AudioCanEscalate": - { - return eCodecCallType.AudioCanEscalate; - } - case "ForwardAllCall": - { - return eCodecCallType.ForwardAllCall; - } - default: - return eCodecCallType.Unknown; - } - - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eCodecOccurrenceType.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecOccurrenceType.cs new file mode 100644 index 00000000..fab6e085 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eCodecOccurrenceType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public enum eCodecOccurrenceType + { + Unknown = 0, + Placed = 1, + Received = 2, + NoAnswer = 3, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodCallType.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodCallType.cs new file mode 100644 index 00000000..587d8312 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodCallType.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// + /// + public enum eContactMethodCallType + { + Unknown = 0, + Audio, + Video + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodDevice.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodDevice.cs new file mode 100644 index 00000000..72fb5359 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eContactMethodDevice.cs @@ -0,0 +1,14 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// + /// + public enum eContactMethodDevice + { + Unknown = 0, + Mobile, + Other, + Telephone, + Video + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingEventChangeType.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingEventChangeType.cs new file mode 100644 index 00000000..aadf9380 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingEventChangeType.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + [Flags] + public enum eMeetingEventChangeType + { + Unknown = 0, + MeetingStartWarning = 1, + MeetingStart = 2, + MeetingEndWarning = 4, + MeetingEnd = 8 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingPrivacy.cs b/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingPrivacy.cs index f163a864..ca19378c 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingPrivacy.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/eMeetingPrivacy.cs @@ -12,31 +12,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec Public, Private } - - public class CodecCallPrivacy - { - /// - /// Takes the Cisco privacy type and converts to the matching enum - /// - /// - /// - public static eMeetingPrivacy ConvertToDirectionEnum(string s) - { - switch (s.ToLower()) - { - case "public": - { - return eMeetingPrivacy.Public; - } - case "private": - { - return eMeetingPrivacy.Private; - } - default: - return eMeetingPrivacy.Unknown; - } - - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallFavorites.cs b/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallFavorites.cs index 50c1b2c9..15e18456 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallFavorites.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallFavorites.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -10,17 +9,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec { CodecCallFavorites CallFavorites { get; } } - - /// - /// Represents favorites entries for a codec device - /// - public class CodecCallFavorites - { - public List Favorites { get; set; } - - public CodecCallFavorites() - { - Favorites = new List(); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallHistory.cs b/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallHistory.cs index b0451d7b..a75e3e37 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallHistory.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/iHasCallHistory.cs @@ -1,17 +1,10 @@ extern alias Full; - -using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec; - -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Converters; namespace PepperDash.Essentials.Devices.Common.Codec { @@ -21,123 +14,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec void RemoveCallHistoryEntry(CodecCallHistory.CallHistoryEntry entry); } - - public enum eCodecOccurrenceType - { - Unknown = 0, - Placed = 1, - Received = 2, - NoAnswer = 3, - } - - /// - /// Represents the recent call history for a codec device - /// - public class CodecCallHistory - { - public event EventHandler RecentCallsListHasChanged; - - public List RecentCalls { get; private set; } - - /// - /// Item that gets added to the list when there are no recent calls in history - /// - CallHistoryEntry ListEmptyEntry; - - public CodecCallHistory() - { - ListEmptyEntry = new CallHistoryEntry() { Name = "No Recent Calls" }; - - RecentCalls = new List(); - - RecentCalls.Add(ListEmptyEntry); - } - - void OnRecentCallsListChange() - { - var handler = RecentCallsListHasChanged; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - - public void RemoveEntry(CallHistoryEntry entry) - { - RecentCalls.Remove(entry); - OnRecentCallsListChange(); - } - - /// - /// Generic call history entry, not device specific - /// - public class CallHistoryEntry : CodecActiveCallItem - { - [JsonConverter(typeof(IsoDateTimeConverter))] - [JsonProperty("startTime")] - public DateTime StartTime { get; set; } - [JsonConverter(typeof(StringEnumConverter))] - [JsonProperty("occurrenceType")] - public eCodecOccurrenceType OccurrenceType { get; set; } - [JsonProperty("occurrenceHistoryId")] - public string OccurrenceHistoryId { get; set; } - } - - /// - /// Converts a list of call history entries returned by a Cisco codec to the generic list type - /// - /// - /// - public void ConvertCiscoCallHistoryToGeneric(List entries) - { - var genericEntries = new List(); - - foreach (CiscoCallHistory.Entry entry in entries) - { - - genericEntries.Add(new CallHistoryEntry() - { - Name = entry.DisplayName.Value, - Number = entry.CallbackNumber.Value, - StartTime = entry.LastOccurrenceStartTime.Value, - OccurrenceHistoryId = entry.LastOccurrenceHistoryId.Value, - OccurrenceType = ConvertToOccurenceTypeEnum(entry.OccurrenceType.Value) - }); - } - - // Check if list is empty and if so, add an item to display No Recent Calls - if(genericEntries.Count == 0) - genericEntries.Add(ListEmptyEntry); - - RecentCalls = genericEntries; - OnRecentCallsListChange(); - } - - /// - /// Takes the Cisco occurence type and converts it to the matching enum - /// - /// DirectoryBrowseHistory { get; } } - - public interface IHasDirectoryHistoryStack : IHasDirectory - { - Stack DirectoryBrowseHistoryStack { get; } - } - - - /// - /// - /// - public class DirectoryEventArgs : EventArgs - { - public CodecDirectory Directory { get; set; } - public bool DirectoryIsOnRoot { get; set; } - } - - /// - /// Represents a codec directory - /// - public class CodecDirectory - { - /// - /// Represents the contents of the directory - /// We don't want to serialize this for messages to MobileControl. MC can combine Contacts and Folders to get the same data - /// - [JsonIgnore] - public List CurrentDirectoryResults { get; private set; } - - [JsonProperty("contacts")] - public List Contacts - { - get - { - return CurrentDirectoryResults.OfType().Cast().ToList(); - } - } - - [JsonProperty("folders")] - public List Folders - { - get - { - return CurrentDirectoryResults.OfType().Cast().ToList(); - } - } - - /// - /// Used to store the ID of the current folder for CurrentDirectoryResults - /// - [JsonProperty("resultsFolderId")] - public string ResultsFolderId { get; set; } - - public CodecDirectory() - { - CurrentDirectoryResults = new List(); - } - - /// - /// Adds folders to the directory - /// - /// - public void AddFoldersToDirectory(List folders) - { - if(folders != null) - CurrentDirectoryResults.AddRange(folders); - - SortDirectory(); - } - - /// - /// Adds contacts to the directory - /// - /// - public void AddContactsToDirectory(List contacts) - { - if(contacts != null) - CurrentDirectoryResults.AddRange(contacts); - - SortDirectory(); - } - - /// - /// Filters the CurrentDirectoryResults by the predicate - /// - /// - public void FilterContacts(Func predicate) - { - CurrentDirectoryResults = CurrentDirectoryResults.Where(predicate).ToList(); - } - - /// - /// Sorts the DirectoryResults list to display all folders alphabetically, then all contacts alphabetically - /// - private void SortDirectory() - { - var sortedFolders = new List(); - - sortedFolders.AddRange(CurrentDirectoryResults.Where(f => f is DirectoryFolder)); - - sortedFolders.OrderBy(f => f.Name); - - var sortedContacts = new List(); - - sortedContacts.AddRange(CurrentDirectoryResults.Where(c => c is DirectoryContact)); - - sortedFolders.OrderBy(c => c.Name); - - CurrentDirectoryResults.Clear(); - - CurrentDirectoryResults.AddRange(sortedFolders); - - CurrentDirectoryResults.AddRange(sortedContacts); - } - - } - - /// - /// Used to decorate a contact to indicate it can be invided to a meeting - /// - public interface IInvitableContact - { - bool IsInvitableContact { get; } - } - - public class InvitableDirectoryContact : DirectoryContact, IInvitableContact - { - [JsonProperty("isInvitableContact")] - public bool IsInvitableContact - { - get - { - return this is IInvitableContact; - } - } - } - - /// - /// Represents an item in the directory - /// - public class DirectoryItem : ICloneable - { - public object Clone() - { - return this.MemberwiseClone(); - } - - [JsonProperty("folderId")] - public string FolderId { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - [JsonProperty("parentFolderId")] - public string ParentFolderId { get; set; } - } - - /// - /// Represents a folder type DirectoryItem - /// - public class DirectoryFolder : DirectoryItem - { - [JsonProperty("contacts")] - public List Contacts { get; set; } - - - public DirectoryFolder() - { - Contacts = new List(); - } - } - - /// - /// Represents a contact type DirectoryItem - /// - public class DirectoryContact : DirectoryItem - { - [JsonProperty("contactId")] - public string ContactId { get; set; } - - [JsonProperty("title")] - public string Title { get; set; } - - [JsonProperty("contactMethods")] - public List ContactMethods { get; set; } - - public DirectoryContact() - { - ContactMethods = new List(); - } - } - - /// - /// Represents a method of contact for a contact - /// - public class ContactMethod - { - [JsonProperty("contactMethodId")] - public string ContactMethodId { get; set; } - - [JsonProperty("number")] - public string Number { get; set; } - - [JsonProperty("device")] - [JsonConverter(typeof(StringEnumConverter))] - public eContactMethodDevice Device { get; set; } - - [JsonProperty("callType")] - [JsonConverter(typeof(StringEnumConverter))] - public eContactMethodCallType CallType { get; set; } - } - - /// - /// - /// - public enum eContactMethodDevice - { - Unknown = 0, - Mobile, - Other, - Telephone, - Video - } - - /// - /// - /// - public enum eContactMethodCallType - { - Unknown = 0, - Audio, - Video - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs index 41140c34..2a3c9725 100644 --- a/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs +++ b/src/PepperDash.Essentials.Devices.Common/Codec/iHasScheduleAwareness.cs @@ -1,277 +1,13 @@ extern alias Full; - -using System; -using System.Collections.Generic; using System.Linq; using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -using Full.Newtonsoft.Json; namespace PepperDash.Essentials.Devices.Common.Codec { - [Flags] - public enum eMeetingEventChangeType - { - Unknown = 0, - MeetingStartWarning = 1, - MeetingStart = 2, - MeetingEndWarning = 4, - MeetingEnd = 8 - } - public interface IHasScheduleAwareness { CodecScheduleAwareness CodecSchedule { get; } void GetSchedule(); } - - public class CodecScheduleAwareness - { - List _meetings; - - public event EventHandler MeetingEventChange; - - public event EventHandler MeetingsListHasChanged; - - private int _meetingWarningMinutes = 5; - - private Meeting _previousChangedMeeting; - - private eMeetingEventChangeType _previousChangeType = eMeetingEventChangeType.Unknown; - - public int MeetingWarningMinutes - { - get { return _meetingWarningMinutes; } - set { _meetingWarningMinutes = value; } - } - - /// - /// Setter triggers MeetingsListHasChanged event - /// - public List Meetings - { - get - { - return _meetings; - } - set - { - _meetings = value; - - var handler = MeetingsListHasChanged; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - } - - private CTimer _scheduleChecker; - - public CodecScheduleAwareness() - { - Meetings = new List(); - - _scheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000); - } - - public CodecScheduleAwareness(long pollTime) - { - Meetings = new List(); - - _scheduleChecker = new CTimer(CheckSchedule, null, pollTime, pollTime); - } - - /// - /// Helper method to fire MeetingEventChange. Should only fire once for each changeType on each meeting - /// - /// - /// - private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting) - { - Debug.Console(2, "*****************OnMeetingChange. id: {0} changeType: {1}**********************", meeting.Id, changeType); - if (changeType != (changeType & meeting.NotifiedChangeTypes)) - { - // Add this change type to the NotifiedChangeTypes - meeting.NotifiedChangeTypes |= changeType; - - var handler = MeetingEventChange; - if (handler != null) - { - handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting }); - } - } - else - { - Debug.Console(2, "Meeting: {0} already notified of changeType: {1}", meeting.Id, changeType); - } - } - - - /// - /// Checks the schedule to see if any MeetingEventChange updates should be fired - /// - /// - private void CheckSchedule(object o) - { - // Iterate the meeting list and check if any meeting need to do anything - - const double meetingTimeEpsilon = 0.05; - foreach (var m in Meetings) - { - var changeType = eMeetingEventChangeType.Unknown; - - if (eMeetingEventChangeType.MeetingStartWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStartWarning) && m.TimeToMeetingStart.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingStart.Seconds > 0) // Meeting is about to start - { - Debug.Console(2, "********************* MeetingStartWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingStart.TotalMinutes, m.TimeToMeetingStart.Seconds); - changeType = eMeetingEventChangeType.MeetingStartWarning; - } - else if (eMeetingEventChangeType.MeetingStart != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingStart) && Math.Abs(m.TimeToMeetingStart.TotalMinutes) < meetingTimeEpsilon) // Meeting Start - { - Debug.Console(2, "********************* MeetingStart"); - changeType = eMeetingEventChangeType.MeetingStart; - } - else if (eMeetingEventChangeType.MeetingEndWarning != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEndWarning) && m.TimeToMeetingEnd.TotalMinutes <= m.MeetingWarningMinutes.TotalMinutes && m.TimeToMeetingEnd.Seconds > 0) // Meeting is about to end - { - Debug.Console(2, "********************* MeetingEndWarning. TotalMinutes: {0} Seconds: {1}", m.TimeToMeetingEnd.TotalMinutes, m.TimeToMeetingEnd.Seconds); - changeType = eMeetingEventChangeType.MeetingEndWarning; - } - else if (eMeetingEventChangeType.MeetingEnd != (m.NotifiedChangeTypes & eMeetingEventChangeType.MeetingEnd) && Math.Abs(m.TimeToMeetingEnd.TotalMinutes) < meetingTimeEpsilon) // Meeting has ended - { - Debug.Console(2, "********************* MeetingEnd"); - changeType = eMeetingEventChangeType.MeetingEnd; - } - - if (changeType != eMeetingEventChangeType.Unknown) - { - OnMeetingChange(changeType, m); - } - } - - } - } - - /// - /// Generic class to represent a meeting (Cisco or Polycom OBTP or Fusion) - /// - public class Meeting - { - [JsonProperty("minutesBeforeMeeting")] - public int MinutesBeforeMeeting; - - [JsonProperty("id")] - public string Id { get; set; } - [JsonProperty("organizer")] - public string Organizer { get; set; } - [JsonProperty("title")] - public string Title { get; set; } - [JsonProperty("agenda")] - public string Agenda { get; set; } - - [JsonProperty("meetingWarningMinutes")] - public TimeSpan MeetingWarningMinutes - { - get { return TimeSpan.FromMinutes(MinutesBeforeMeeting); } - } - [JsonProperty("timeToMeetingStart")] - public TimeSpan TimeToMeetingStart - { - get - { - return StartTime - DateTime.Now; - } - } - [JsonProperty("timeToMeetingEnd")] - public TimeSpan TimeToMeetingEnd - { - get - { - return EndTime - DateTime.Now; - } - } - [JsonProperty("startTime")] - public DateTime StartTime { get; set; } - [JsonProperty("endTime")] - public DateTime EndTime { get; set; } - [JsonProperty("duration")] - public TimeSpan Duration - { - get - { - return EndTime - StartTime; - } - } - [JsonProperty("privacy")] - public eMeetingPrivacy Privacy { get; set; } - [JsonProperty("joinable")] - public bool Joinable - { - get - { - var joinable = StartTime.AddMinutes(-MinutesBeforeMeeting) <= DateTime.Now - && DateTime.Now <= EndTime.AddSeconds(-_joinableCooldownSeconds); - //Debug.Console(2, "Meeting Id: {0} joinable: {1}", Id, joinable); - return joinable; - } - } - //public string ConferenceNumberToDial { get; set; } - [JsonProperty("conferencePassword")] - public string ConferencePassword { get; set; } - [JsonProperty("isOneButtonToPushMeeting")] - public bool IsOneButtonToPushMeeting { get; set; } - - [JsonProperty("calls")] - public List Calls { get; private set; } - - /// - /// Tracks the change types that have already been notified for - /// - [JsonIgnore] - public eMeetingEventChangeType NotifiedChangeTypes { get; set; } - - [JsonIgnore] private readonly int _joinableCooldownSeconds; - - - public Meeting() - { - Calls = new List(); - _joinableCooldownSeconds = 300; - } - - public Meeting(int joinableCooldownSeconds) - { - Calls = new List(); - _joinableCooldownSeconds = joinableCooldownSeconds; - } - - - - #region Overrides of Object - - public override string ToString() - { - return String.Format("{0}:{1}: {2}-{3}", Title, Agenda, StartTime, EndTime); - } - - #endregion - } - - public class Call - { - public string Number { get; set; } - public string Protocol { get; set; } - public string CallRate { get; set; } - public string CallType { get; set; } - } - - public class MeetingEventArgs : EventArgs - { - public eMeetingEventChangeType ChangeType { get; set; } - public Meeting Meeting { get; set; } - } - } diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDsp.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDsp.cs index f8a102df..b2663fa5 100644 --- a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDsp.cs +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDsp.cs @@ -5,7 +5,6 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using System.Text.RegularExpressions; @@ -375,22 +374,4 @@ namespace PepperDash.Essentials.Devices.Common.DSP public TesiraForteControlPoint ControlPoint { get; set; } } } - - public class BiampTesiraForteDspFactory : EssentialsDeviceFactory - { - public BiampTesiraForteDspFactory() - { - TypeNames = new List() {"biamptesira"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new BiampTesira Device"); - var comm = CommFactory.CreateCommForDevice(dc); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new BiampTesiraForteDsp(dc.Key, dc.Name, comm, props); - } - } - } diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspFactory.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspFactory.cs new file mode 100644 index 00000000..6559ead6 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.DSP +{ + public class BiampTesiraForteDspFactory : EssentialsDeviceFactory + { + public BiampTesiraForteDspFactory() + { + TypeNames = new List() {"biamptesira"}; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new BiampTesira Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new BiampTesiraForteDsp(dc.Key, dc.Name, comm, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteLevelControlBlockConfig.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteLevelControlBlockConfig.cs new file mode 100644 index 00000000..cdea369d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteLevelControlBlockConfig.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials.Devices.Common.DSP +{ + public class BiampTesiraForteLevelControlBlockConfig + { + public bool Enabled { get; set; } + public string Label { get; set; } + public string InstanceTag { get; set; } + public int Index1 { get; set; } + public int Index2 { get; set; } + public bool HasMute { get; set; } + public bool HasLevel { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs index 1b4ae8a1..ae9a7218 100644 --- a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraFortePropertiesConfig.cs @@ -26,15 +26,4 @@ namespace PepperDash.Essentials.Devices.Common.DSP public Dictionary LevelControlBlocks { get; set; } // public Dictionary DialerControlBlocks {get; set;} } - - public class BiampTesiraForteLevelControlBlockConfig - { - public bool Enabled { get; set; } - public string Label { get; set; } - public string InstanceTag { get; set; } - public int Index1 { get; set; } - public int Index2 { get; set; } - public bool HasMute { get; set; } - public bool HasLevel { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/IBiampTesiraDspLevelControl.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/IBiampTesiraDspLevelControl.cs new file mode 100644 index 00000000..6f360641 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/IBiampTesiraDspLevelControl.cs @@ -0,0 +1,17 @@ +using PepperDash.Essentials.Core; + +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; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/TesiraForteLevelControl.cs similarity index 96% rename from src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs rename to src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/TesiraForteLevelControl.cs index 15d424a2..d0f83115 100644 --- a/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs +++ b/src/PepperDash.Essentials.Devices.Common/DSP/BiampTesira/TesiraForteLevelControl.cs @@ -10,19 +10,6 @@ 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/src/PepperDash.Essentials.Devices.Common/DSP/DspBase.cs b/src/PepperDash.Essentials.Devices.Common/DSP/DspBase.cs index 7f28ae3d..29600b02 100644 --- a/src/PepperDash.Essentials.Devices.Common/DSP/DspBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/DSP/DspBase.cs @@ -40,19 +40,8 @@ namespace PepperDash.Essentials.Devices.Common.DSP // Typical presets: // call default preset to restore levels and mutes - public abstract class DspControlPoint - { - string Key { get; set; } - } - - public class DspDialerBase - { - - } - - - // Main program + // Main program // VTC // ATC // Mics, unusual diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/DspControlPoint.cs b/src/PepperDash.Essentials.Devices.Common/DSP/DspControlPoint.cs new file mode 100644 index 00000000..ccb758f7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DSP/DspControlPoint.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Devices.Common.DSP +{ + public abstract class DspControlPoint + { + string Key { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DSP/DspDialerBase.cs b/src/PepperDash.Essentials.Devices.Common/DSP/DspDialerBase.cs new file mode 100644 index 00000000..08f7f4be --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DSP/DspDialerBase.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials.Devices.Common.DSP +{ + public class DspDialerBase + { + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRDiscPlayerBase.cs b/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBase.cs similarity index 93% rename from src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRDiscPlayerBase.cs rename to src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBase.cs index 9e780a3b..9c63d843 100644 --- a/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRDiscPlayerBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBase.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -9,12 +8,9 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Linq; - using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Routing; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Common @@ -426,30 +422,4 @@ namespace PepperDash.Essentials.Devices.Common #endregion } - - public class IRBlurayBaseFactory : EssentialsDeviceFactory - { - public IRBlurayBaseFactory() - { - TypeNames = new List() { "discplayer", "bluray" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new IRBlurayPlayer Device"); - - if (dc.Properties["control"]["method"].Value() == "ir") - { - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new IRBlurayBase(dc.Key, dc.Name, irCont); - } - else if (dc.Properties["control"]["method"].Value() == "com") - { - Debug.Console(0, "[{0}] COM Device type not implemented YET!", dc.Key); - } - - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBaseFactory.cs b/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBaseFactory.cs new file mode 100644 index 00000000..d5cb4b81 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/DiscPlayer/IRBlurayBaseFactory.cs @@ -0,0 +1,34 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class IRBlurayBaseFactory : EssentialsDeviceFactory + { + public IRBlurayBaseFactory() + { + TypeNames = new List() { "discplayer", "bluray" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new IRBlurayPlayer Device"); + + if (dc.Properties["control"]["method"].Value() == "ir") + { + var irCont = IRPortHelper.GetIrOutputPortController(dc); + return new IRBlurayBase(dc.Key, dc.Name, irCont); + } + else if (dc.Properties["control"]["method"].Value() == "com") + { + Debug.Console(0, "[{0}] COM Device type not implemented YET!", dc.Key); + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/AvocorVTFDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplay.cs similarity index 97% rename from src/PepperDash.Essentials.Devices.Common/Display/AvocorVTFDisplay.cs rename to src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplay.cs index 20d9fbec..f3c4d7da 100644 --- a/src/PepperDash.Essentials.Devices.Common/Display/AvocorVTFDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplay.cs @@ -9,7 +9,6 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using Feedback = PepperDash.Essentials.Core.Feedback; @@ -726,24 +725,4 @@ namespace PepperDash.Essentials.Devices.Displays #endregion } - - public class AvocorDisplayFactory : EssentialsDeviceFactory - { - public AvocorDisplayFactory() - { - TypeNames = new List() { "avocorvtf" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new AvocorDisplay(dc.Key, dc.Name, comm, null); - else - return null; - - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplayFactory.cs b/src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplayFactory.cs new file mode 100644 index 00000000..1dc81032 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/AvocorDisplayFactory.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Displays +{ + public class AvocorDisplayFactory : EssentialsDeviceFactory + { + public AvocorDisplayFactory() + { + TypeNames = new List() { "avocorvtf" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var comm = CommFactory.CreateCommForDevice(dc); + if (comm != null) + return new AvocorDisplay(dc.Key, dc.Name, comm, null); + else + return null; + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort1.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort1.cs new file mode 100644 index 00000000..e8effffc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort1.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputDisplayPort1 { void InputDisplayPort1(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort2.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort2.cs new file mode 100644 index 00000000..d361ef1e --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputDisplayPort2.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputDisplayPort2 { void InputDisplayPort2(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi1.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi1.cs new file mode 100644 index 00000000..03be5004 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi1.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputHdmi1 { void InputHdmi1(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi2.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi2.cs new file mode 100644 index 00000000..ff0b26e2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi2.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputHdmi2 { void InputHdmi2(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi3.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi3.cs new file mode 100644 index 00000000..26220b3f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi3.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputHdmi3 { void InputHdmi3(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi4.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi4.cs new file mode 100644 index 00000000..711a6f8f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputHdmi4.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputHdmi4 { void InputHdmi4(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/IInputVga1.cs b/src/PepperDash.Essentials.Devices.Common/Display/IInputVga1.cs new file mode 100644 index 00000000..5013b8d5 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/IInputVga1.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Displays +{ + public interface IInputVga1 { void InputVga1(); } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/InputInterfaces.cs b/src/PepperDash.Essentials.Devices.Common/Display/InputInterfaces.cs deleted file mode 100644 index ce7113e1..00000000 --- a/src/PepperDash.Essentials.Devices.Common/Display/InputInterfaces.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -namespace PepperDash.Essentials.Devices.Displays -{ - public interface IInputHdmi1 { void InputHdmi1(); } - public interface IInputHdmi2 { void InputHdmi2(); } - public interface IInputHdmi3 { void InputHdmi3(); } - public interface IInputHdmi4 { void InputHdmi4(); } - public interface IInputDisplayPort1 { void InputDisplayPort1(); } - public interface IInputDisplayPort2 { void InputDisplayPort2(); } - public interface IInputVga1 { void InputVga1(); } - -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/NECPSXMDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Display/NECPSXMDisplay.cs index a674b11a..7389183e 100644 --- a/src/PepperDash.Essentials.Devices.Common/Display/NECPSXMDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Display/NECPSXMDisplay.cs @@ -7,7 +7,6 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; using Feedback = PepperDash.Essentials.Core.Feedback; @@ -365,23 +364,4 @@ namespace PepperDash.Essentials.Devices.Displays #endregion } - - public class NecPSXMDisplayFactory : EssentialsDeviceFactory - { - public NecPSXMDisplayFactory() - { - TypeNames = new List() { "necmpsx" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new NecPSXMDisplay(dc.Key, dc.Name, comm); - else - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/NecPSXMDisplayFactory.cs b/src/PepperDash.Essentials.Devices.Common/Display/NecPSXMDisplayFactory.cs new file mode 100644 index 00000000..5307ad57 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/NecPSXMDisplayFactory.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Displays +{ + public class NecPSXMDisplayFactory : EssentialsDeviceFactory + { + public NecPSXMDisplayFactory() + { + TypeNames = new List() { "necmpsx" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var comm = CommFactory.CreateCommForDevice(dc); + if (comm != null) + return new NecPSXMDisplay(dc.Key, dc.Name, comm); + else + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplay.cs index 9acc395e..f5c2aafd 100644 --- a/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplay.cs @@ -7,7 +7,6 @@ using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; using Feedback = PepperDash.Essentials.Core.Feedback; @@ -345,23 +344,4 @@ namespace PepperDash.Essentials.Devices.Displays #endregion } - - public class PanasonicThDisplayFactory : EssentialsDeviceFactory - { - public PanasonicThDisplayFactory() - { - TypeNames = new List() { "panasonicthef" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new PanasonicThDisplay(dc.Key, dc.Name, comm); - else - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplayFactory.cs b/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplayFactory.cs new file mode 100644 index 00000000..019fc586 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/PanasonicThDisplayFactory.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Displays +{ + public class PanasonicThDisplayFactory : EssentialsDeviceFactory + { + public PanasonicThDisplayFactory() + { + TypeNames = new List() { "panasonicthef" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var comm = CommFactory.CreateCommForDevice(dc); + if (comm != null) + return new PanasonicThDisplay(dc.Key, dc.Name, comm); + else + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDC.cs similarity index 96% rename from src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCDisplay.cs rename to src/PepperDash.Essentials.Devices.Common/Display/SamsungMDC.cs index 59c5fe31..2e783707 100644 --- a/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCDisplay.cs +++ b/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDC.cs @@ -11,12 +11,9 @@ using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using Feedback = PepperDash.Essentials.Core.Feedback; -using Full.Newtonsoft.Json.Linq; - namespace PepperDash.Essentials.Devices.Displays { /// @@ -643,23 +640,4 @@ namespace PepperDash.Essentials.Devices.Displays #endregion } - - public class SamsungMDCFactory : EssentialsDeviceFactory - { - public SamsungMDCFactory() - { - TypeNames = new List() { "samsungmdc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new SamsungMDC(dc.Key, dc.Name, comm, dc.Properties["id"].Value()); - else - return null; - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCFactory.cs b/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCFactory.cs new file mode 100644 index 00000000..5eae1cca --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Display/SamsungMDCFactory.cs @@ -0,0 +1,27 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Displays +{ + public class SamsungMDCFactory : EssentialsDeviceFactory + { + public SamsungMDCFactory() + { + TypeNames = new List() { "samsungmdc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var comm = CommFactory.CreateCommForDevice(dc); + if (comm != null) + return new SamsungMDC(dc.Key, dc.Name, comm, dc.Properties["id"].Value()); + else + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Controller.cs similarity index 57% rename from src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8.cs rename to src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Controller.cs index b262ef84..a90406ac 100644 --- a/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8.cs +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Controller.cs @@ -1,15 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.Lighting; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.CrestronIO; namespace PepperDash.Essentials.Devices.Common.Environment.Lighting @@ -58,49 +55,4 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lighting } } } - - /// - /// Wrapper class to - /// - public class Din8sw8Output : ISwitchedOutput - { - SwitchedLoadWithOverrideParameter SwitchedOutput; - - public BoolFeedback OutputIsOnFeedback { get; protected set; } - - public Din8sw8Output(SwitchedLoadWithOverrideParameter switchedOutput) - { - SwitchedOutput = switchedOutput; - - OutputIsOnFeedback = new BoolFeedback(new Func(() => SwitchedOutput.IsOn)); - } - - public void On() - { - SwitchedOutput.FullOn(); - } - - public void Off() - { - SwitchedOutput.FullOff(); - } - } - - public class Din8sw8ControllerFactory : EssentialsDeviceFactory - { - public Din8sw8ControllerFactory() - { - TypeNames = new List() { "din8sw8" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Din8sw8Controller Device"); - var comm = CommFactory.GetControlPropertiesConfig(dc); - - return new Din8sw8Controller(dc.Key, comm.CresnetIdInt); - - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8ControllerFactory.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8ControllerFactory.cs new file mode 100644 index 00000000..c89f26d5 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8ControllerFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.Environment.Lighting +{ + public class Din8sw8ControllerFactory : EssentialsDeviceFactory + { + public Din8sw8ControllerFactory() + { + TypeNames = new List() { "din8sw8" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Din8sw8Controller Device"); + var comm = CommFactory.GetControlPropertiesConfig(dc); + + return new Din8sw8Controller(dc.Key, comm.CresnetIdInt); + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Output.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Output.cs new file mode 100644 index 00000000..3c7b3e8c --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Crestron Lighting/Din8sw8Output.cs @@ -0,0 +1,34 @@ +using System; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.CrestronIO; + +namespace PepperDash.Essentials.Devices.Common.Environment.Lighting +{ + /// + /// Wrapper class to + /// + public class Din8sw8Output : ISwitchedOutput + { + SwitchedLoadWithOverrideParameter SwitchedOutput; + + public BoolFeedback OutputIsOnFeedback { get; protected set; } + + public Din8sw8Output(SwitchedLoadWithOverrideParameter switchedOutput) + { + SwitchedOutput = switchedOutput; + + OutputIsOnFeedback = new BoolFeedback(new Func(() => SwitchedOutput.IsOn)); + } + + public void On() + { + SwitchedOutput.FullOn(); + } + + public void Off() + { + SwitchedOutput.FullOff(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantum.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumArea.cs similarity index 83% rename from src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantum.cs rename to src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumArea.cs index f2d030e8..cf3584b6 100644 --- a/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantum.cs +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumArea.cs @@ -1,12 +1,10 @@ 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; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Lighting; using LightingBase = PepperDash.Essentials.Core.Lighting.LightingBase; @@ -235,52 +233,4 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron Communication.SendText(s + Delimiter); } } - - public enum eAction : int - { - SetLevel = 1, - Raise = 2, - Lower = 3, - Stop = 4, - Scene = 6, - DaylightMode = 7, - OccupancyState = 8, - OccupancyMode = 9, - OccupiedLevelOrScene = 12, - UnoccupiedLevelOrScene = 13, - HyperionShaddowSensorOverrideState = 26, - HyperionBrightnessSensorOverrideStatue = 27 - } - - public class LutronQuantumPropertiesConfig - { - public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } - public ControlPropertiesConfig Control { get; set; } - - public string IntegrationId { get; set; } - public List Scenes { get; set; } - - // Moved to use existing properties in Control object - // public string Username { get; set; } - // public string Password { get; set; } - } - - public class LutronQuantumAreaFactory : EssentialsDeviceFactory - { - public LutronQuantumAreaFactory() - { - TypeNames = new List() { "lutronqs" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new LutronQuantumArea Device"); - var comm = CommFactory.CreateCommForDevice(dc); - - var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); - - return new LutronQuantumArea(dc.Key, dc.Name, comm, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumAreaFactory.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumAreaFactory.cs new file mode 100644 index 00000000..b97a8634 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumAreaFactory.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.Environment.Lutron +{ + public class LutronQuantumAreaFactory : EssentialsDeviceFactory + { + public LutronQuantumAreaFactory() + { + TypeNames = new List() { "lutronqs" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new LutronQuantumArea Device"); + var comm = CommFactory.CreateCommForDevice(dc); + + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + + return new LutronQuantumArea(dc.Key, dc.Name, comm, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumPropertiesConfig.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumPropertiesConfig.cs new file mode 100644 index 00000000..b897fe12 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/LutronQuantumPropertiesConfig.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Lighting; + +namespace PepperDash.Essentials.Devices.Common.Environment.Lutron +{ + public class LutronQuantumPropertiesConfig + { + public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; } + public ControlPropertiesConfig Control { get; set; } + + public string IntegrationId { get; set; } + public List Scenes { get; set; } + + // Moved to use existing properties in Control object + // public string Username { get; set; } + // public string Password { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/eAction.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/eAction.cs new file mode 100644 index 00000000..c686cc10 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Lutron/eAction.cs @@ -0,0 +1,18 @@ +namespace PepperDash.Essentials.Devices.Common.Environment.Lutron +{ + public enum eAction : int + { + SetLevel = 1, + Raise = 2, + Lower = 3, + Stop = 4, + Scene = 6, + DaylightMode = 7, + OccupancyState = 8, + OccupancyMode = 9, + OccupiedLevelOrScene = 12, + UnoccupiedLevelOrScene = 13, + HyperionShaddowSensorOverrideState = 26, + HyperionBrightnessSensorOverrideStatue = 27 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShade.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShade.cs index 852d554f..7a249a4e 100644 --- a/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShade.cs +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShade.cs @@ -1,12 +1,10 @@ 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.Config; using PepperDash.Essentials.Core.CrestronIO; using PepperDash.Essentials.Core.Shades; @@ -97,35 +95,4 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy } } - - public class RelayControlledShadeConfigProperties - { - public int RelayPulseTime { get; set; } - public ShadeRelaysConfig Relays { get; set; } - public string StopOrPresetLabel { get; set; } - - public class ShadeRelaysConfig - { - public IOPortConfig Open { get; set; } - public IOPortConfig StopOrPreset { get; set; } - public IOPortConfig Close { get; set; } - } - } - - public class RelayControlledShadeFactory : EssentialsDeviceFactory - { - public RelayControlledShadeFactory() - { - TypeNames = new List() { "relaycontrolledshade" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); - - return new Environment.Somfy.RelayControlledShade(dc.Key, dc.Name, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeConfigProperties.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeConfigProperties.cs new file mode 100644 index 00000000..27640507 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeConfigProperties.cs @@ -0,0 +1,18 @@ +using PepperDash.Essentials.Core.CrestronIO; + +namespace PepperDash.Essentials.Devices.Common.Environment.Somfy +{ + public class RelayControlledShadeConfigProperties + { + public int RelayPulseTime { get; set; } + public ShadeRelaysConfig Relays { get; set; } + public string StopOrPresetLabel { get; set; } + + public class ShadeRelaysConfig + { + public IOPortConfig Open { get; set; } + public IOPortConfig StopOrPreset { get; set; } + public IOPortConfig Close { get; set; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeFactory.cs b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeFactory.cs new file mode 100644 index 00000000..ebedba06 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Environment/Somfy/RelayControlledShadeFactory.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.Environment.Somfy +{ + public class RelayControlledShadeFactory : EssentialsDeviceFactory + { + public RelayControlledShadeFactory() + { + TypeNames = new List() { "relaycontrolledshade" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + + return new Environment.Somfy.RelayControlledShade(dc.Key, dc.Name, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs index 697639e5..62c52787 100644 --- a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSource.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.Devices.Common @@ -40,19 +36,4 @@ namespace PepperDash.Essentials.Devices.Common #endregion } - - public class GenericSourceFactory : EssentialsDeviceFactory - { - public GenericSourceFactory() - { - TypeNames = new List() { "genericsource" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Generic Source Device"); - return new GenericSource(dc.Key, dc.Name); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Generic/GenericSourceFactory.cs b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSourceFactory.cs new file mode 100644 index 00000000..4fd2c3cd --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Generic/GenericSourceFactory.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class GenericSourceFactory : EssentialsDeviceFactory + { + public GenericSourceFactory() + { + TypeNames = new List() { "genericsource" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Source Device"); + return new GenericSource(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs b/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCore.cs similarity index 90% rename from src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs rename to src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCore.cs index 742ff6f6..7feb327d 100644 --- a/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs +++ b/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCore.cs @@ -1,11 +1,9 @@ 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.Config; using System.Text.RegularExpressions; @@ -231,22 +229,4 @@ namespace PepperDash.Essentials.Devices.Common // public QscDspControlPoint ControlPoint { get; set; } } } - - public class AnalogWayLiveCoreFactory : EssentialsDeviceFactory - { - public AnalogWayLiveCoreFactory() - { - TypeNames = new List() { "analogwaylivecore" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new AnalogWayLiveCore Device"); - var comm = CommFactory.CreateCommForDevice(dc); - var props = Newtonsoft.Json.JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new AnalogWayLiveCore(dc.Key, dc.Name, comm, props); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCoreFactory.cs b/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCoreFactory.cs new file mode 100644 index 00000000..b057931e --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/ImageProcessors/AnalogWay/AnalogWayLiveCoreFactory.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class AnalogWayLiveCoreFactory : EssentialsDeviceFactory + { + public AnalogWayLiveCoreFactory() + { + TypeNames = new List() { "analogwaylivecore" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new AnalogWayLiveCore Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new AnalogWayLiveCore(dc.Key, dc.Name, comm, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Power Controllers/DigitalLoggerFactory.cs b/src/PepperDash.Essentials.Devices.Common/Power Controllers/DigitalLoggerFactory.cs new file mode 100644 index 00000000..ba70f5f8 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Power Controllers/DigitalLoggerFactory.cs @@ -0,0 +1,25 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class DigitalLoggerFactory : EssentialsDeviceFactory + { + public DigitalLoggerFactory() + { + TypeNames = new List() { "digitallogger" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new DigitalLogger Device"); + var props = JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new DigitalLogger(dc.Key, dc.Name, props); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Power Controllers/Digitallogger.cs b/src/PepperDash.Essentials.Devices.Common/Power Controllers/Digitallogger.cs index ed885104..657c055c 100644 --- a/src/PepperDash.Essentials.Devices.Common/Power Controllers/Digitallogger.cs +++ b/src/PepperDash.Essentials.Devices.Common/Power Controllers/Digitallogger.cs @@ -13,7 +13,6 @@ using Crestron.SimplSharp.Net.Http; using Full.Newtonsoft.Json; using Full.Newtonsoft.Json.Linq; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials; @@ -337,20 +336,4 @@ namespace PepperDash.Essentials.Devices.Common } } - - public class DigitalLoggerFactory : EssentialsDeviceFactory - { - public DigitalLoggerFactory() - { - TypeNames = new List() { "digitallogger" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new DigitalLogger Device"); - var props = JsonConvert.DeserializeObject( - dc.Properties.ToString()); - return new DigitalLogger(dc.Key, dc.Name, props); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs index b7c7e349..380c8def 100644 --- a/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBase.cs @@ -1,7 +1,6 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -11,7 +10,6 @@ using Full.Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Presets; using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Core.DeviceTypeInterfaces; @@ -494,27 +492,4 @@ namespace PepperDash.Essentials.Devices.Common } } } - - public class IRSetTopBoxBaseFactory : EssentialsDeviceFactory - { - public IRSetTopBoxBaseFactory() - { - TypeNames = new List() { "settopbox" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new SetTopBox Device"); - var irCont = IRPortHelper.GetIrOutputPortController(dc); - var config = dc.Properties.ToObject(); - var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config); - - var listName = dc.Properties.Value("presetsList"); - if (listName != null) - stb.LoadPresets(listName); - return stb; - - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBaseFactory.cs b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBaseFactory.cs new file mode 100644 index 00000000..3f2393a0 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/SetTopBox/IRSetTopBoxBaseFactory.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class IRSetTopBoxBaseFactory : EssentialsDeviceFactory + { + public IRSetTopBoxBaseFactory() + { + TypeNames = new List() { "settopbox" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new SetTopBox Device"); + var irCont = IRPortHelper.GetIrOutputPortController(dc); + var config = dc.Properties.ToObject(); + var stb = new IRSetTopBoxBase(dc.Key, dc.Name, irCont, config); + + var listName = dc.Properties.Value("presetsList"); + if (listName != null) + stb.LoadPresets(listName); + return stb; + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs index 3e17f81d..94088559 100644 --- a/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs +++ b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPc.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; @@ -161,19 +160,4 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec #endregion } - - public class BlueJeansPcFactory : EssentialsDeviceFactory - { - public BlueJeansPcFactory() - { - TypeNames = new List() { "bluejeanspc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new BlueJeansPc Device"); - return new SoftCodec.BlueJeansPc(dc.Key, dc.Name); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPcFactory.cs b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPcFactory.cs new file mode 100644 index 00000000..8c3d01fc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/SoftCodec/BlueJeansPcFactory.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.SoftCodec +{ + public class BlueJeansPcFactory : EssentialsDeviceFactory + { + public BlueJeansPcFactory() + { + TypeNames = new List() { "bluejeanspc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new BlueJeansPc Device"); + return new SoftCodec.BlueJeansPc(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs index 33719295..b4bbaae6 100644 --- a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTV.cs @@ -1,17 +1,14 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.Reflection; -using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Full.Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; @@ -188,33 +185,4 @@ namespace PepperDash.Essentials.Devices.Common trilist.SetBoolSigAction(joinMap.PlayPause.JoinNumber, Play); } } - - public class AppleTVFactory : EssentialsDeviceFactory - { - public AppleTVFactory() - { - TypeNames = new List() { "appletv" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new AppleTV Device"); - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new AppleTV(dc.Key, dc.Name, irCont); - } - } - - public static class AppleTvIrCommands - { - - public static string Up = "+"; - public static string Down = "-"; - public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS; - public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS; - public static string Enter = IROutputStandardCommands.IROut_ENTER; - public static string PlayPause = "PLAY/PAUSE"; - public static string Rewind = "REWIND"; - public static string Menu = "Menu"; - public static string FastForward = "FASTFORWARD"; - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTVFactory.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTVFactory.cs new file mode 100644 index 00000000..b41f2a0b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTVFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class AppleTVFactory : EssentialsDeviceFactory + { + public AppleTVFactory() + { + TypeNames = new List() { "appletv" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new AppleTV Device"); + var irCont = IRPortHelper.GetIrOutputPortController(dc); + return new AppleTV(dc.Key, dc.Name, irCont); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTvIrCommands.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTvIrCommands.cs new file mode 100644 index 00000000..38d055fa --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/AppleTvIrCommands.cs @@ -0,0 +1,18 @@ +using Crestron.SimplSharpPro; + +namespace PepperDash.Essentials.Devices.Common +{ + public static class AppleTvIrCommands + { + + public static string Up = "+"; + public static string Down = "-"; + public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS; + public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS; + public static string Enter = IROutputStandardCommands.IROut_ENTER; + public static string PlayPause = "PLAY/PAUSE"; + public static string Rewind = "REWIND"; + public static string Menu = "Menu"; + public static string FastForward = "FASTFORWARD"; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku2.cs similarity index 85% rename from src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs rename to src/PepperDash.Essentials.Devices.Common/Streaming/Roku2.cs index 4e053b78..ef555c2f 100644 --- a/src/PepperDash.Essentials.Devices.Common/Streaming/Roku.cs +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku2.cs @@ -1,14 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials.Devices.Common @@ -147,21 +143,4 @@ namespace PepperDash.Essentials.Devices.Common #endregion } - - public class Roku2Factory : EssentialsDeviceFactory - { - public Roku2Factory() - { - TypeNames = new List() { "roku" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Roku Device"); - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new Roku2(dc.Key, dc.Name, irCont); - - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/Streaming/Roku2Factory.cs b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku2Factory.cs new file mode 100644 index 00000000..b454e083 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/Streaming/Roku2Factory.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common +{ + public class Roku2Factory : EssentialsDeviceFactory + { + public Roku2Factory() + { + TypeNames = new List() { "roku" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Roku Device"); + var irCont = IRPortHelper.GetIrOutputPortController(dc); + return new Roku2(dc.Key, dc.Name, irCont); + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BrandingLogoProperties.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BrandingLogoProperties.cs new file mode 100644 index 00000000..d24f86ea --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BrandingLogoProperties.cs @@ -0,0 +1,14 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class BrandingLogoProperties + { + [JsonProperty("enable")] + public bool Enable { get; set; } + + [JsonProperty("brandingUrl")] + public string BrandingUrl { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CameraInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CameraInfo.cs new file mode 100644 index 00000000..3d815ca1 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CameraInfo.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Describes configuration information for the near end cameras + /// + public class CameraInfo + { + public int CameraNumber { get; set; } + public string Name { get; set; } + public int SourceId { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCallHistory.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CallHistoryDataClasses.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCallHistory.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecBookings.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecBookings.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xConfiguration.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecConfiguration.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xConfiguration.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecConfiguration.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xEvent.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecEvents.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xEvent.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecEvents.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecPhonebook.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/PhonebookDataClasses.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecPhonebook.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xStatus.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecStatus.cs similarity index 95% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xStatus.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecStatus.cs index 6b7ee2e5..f9956116 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/xStatus.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCodecStatus.cs @@ -1,40 +1,13 @@ -extern alias Full; - -using System; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronXml.Serialization; -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Linq; - using PepperDash.Core; -using PepperDash.Essentials.Devices.Common.VideoCodec.CiscoCodec; using PepperDash.Essentials.Core.Presets; namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { - // Helper Classes for Proerties - public abstract class ValueProperty - { - /// - /// Triggered when Value is set - /// - public Action ValueChangedAction { get; set; } - - protected void OnValueChanged() - { - var a = ValueChangedAction; - if (a != null) - a(); - } - - } - - /// - /// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode - /// + /// + /// This class exists to capture serialized data sent back by a Cisco codec in JSON output mode + /// public class CiscoCodecStatus { @@ -177,8 +150,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Audio() { - Volume = new Volume(); - VolumeMute = new VolumeMute(); + Volume = new Volume(); + VolumeMute = new VolumeMute(); Microphones = new Microphones(); } } @@ -300,8 +273,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Camera() { - Manufacturer = new Manufacturer(); - Model = new Model(); + Manufacturer = new Manufacturer(); + Model = new Model(); DetectedConnector = new DectectedConnector(); } } @@ -320,7 +293,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco set { // If the incoming value is "Available" it sets the BoolValue true, otherwise sets it false - _Value = value; + _Value = value; BoolValue = value == "Available"; OnValueChanged(); } @@ -342,7 +315,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco set { // If the incoming value is "Active" it sets the BoolValue true, otherwise sets it false - _Value = value; + _Value = value; BoolValue = value == "Connected"; OnValueChanged(); } @@ -364,7 +337,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco set { // If the incoming value is "Active" it sets the BoolValue true, otherwise sets it false - _Value = value; + _Value = value; BoolValue = value == "Active"; OnValueChanged(); } @@ -378,7 +351,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public SpeakerTrack() { - Status = new Status2(); + Status = new Status2(); Availability = new Availability(); } } @@ -391,7 +364,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Cameras() { - Camera = new List(); + Camera = new List(); SpeakerTrack = new SpeakerTrack(); } } @@ -662,7 +635,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public LocalInstance() { - Source = new Source2(); + Source = new Source2(); SendingMode = new SendingMode(); } } @@ -676,7 +649,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Presentation() { - Mode = new Mode2(); + Mode = new Mode2(); LocalInstance = new List(); } } @@ -1306,7 +1279,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public RoomAnalytics() { - PeopleCount = new PeopleCount(); + PeopleCount = new PeopleCount(); PeoplePresence = new PeoplePresence(); } } @@ -2002,7 +1975,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Selfview() { - Mode = new Mode8(); + Mode = new Mode8(); PIPPosition = new PIPPosition3(); } } @@ -2020,8 +1993,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Video() { Selfview = new Selfview(); - Layout = new Layout(); - Input = new Input2(); + Layout = new Layout(); + Input = new Input2(); } } @@ -2145,7 +2118,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Call() { CallType = new CallType(); - Status = new CallStatus(); + Status = new CallStatus(); Duration = new Duration(); } } @@ -2197,28 +2170,28 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public RoomPreset() { - Defined = new Defined(); + Defined = new Defined(); Description = new Description2(); - Type = new Type5(); + Type = new Type5(); } public override PresetBase ConvertCodecPreset() { - try - { - var preset = new CodecRoomPreset(UInt16.Parse(id), Description.Value, Defined.BoolValue, true); + try + { + var preset = new CodecRoomPreset(UInt16.Parse(id), Description.Value, Defined.BoolValue, true); - Debug.Console(2, "Preset ID {0} Converted from Cisco Codec Preset to Essentials Preset"); + Debug.Console(2, "Preset ID {0} Converted from Cisco Codec Preset to Essentials Preset"); - return preset; - } - catch (Exception e) - { - Debug.Console(2, "Unable to convert preset: {0}. Error: {1}", id, e); - return null; - } + return preset; + } + catch (Exception e) + { + Debug.Console(2, "Unable to convert preset: {0}. Error: {1}", id, e); + return null; + } } -} + } @@ -2254,17 +2227,17 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public Status() { - Audio = new Audio(); - Call = new List(); - Standby = new Standby(); - Cameras = new Cameras(); + Audio = new Audio(); + Call = new List(); + Standby = new Standby(); + Cameras = new Cameras(); RoomAnalytics = new RoomAnalytics(); - RoomPreset = new List(); - Conference = new Conference2(); - SystemUnit = new SystemUnit(); - Video = new Video(); - Conference = new Conference2(); - Network = new List(); + RoomPreset = new List(); + Conference = new Conference2(); + SystemUnit = new SystemUnit(); + Video = new Video(); + Conference = new Conference2(); + Network = new List(); } } @@ -2278,4 +2251,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco } } } -} +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoFarEndCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoFarEndCamera.cs new file mode 100644 index 00000000..530c2584 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoFarEndCamera.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Devices.Common.Cameras; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + public class CiscoFarEndCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced + { + protected CiscoSparkCodec ParentCodec { get; private set; } + + protected string CallId { + get + { + return (ParentCodec as CiscoSparkCodec).GetCallId(); + } + } + + public CiscoFarEndCamera(string key, string name, CiscoSparkCodec codec) + : base(key, name) + { + Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom; + + ParentCodec = codec; + } + + #region IHasCameraPtzControl Members + + public void PositionHome() + { + // Not supported on far end camera + } + + #endregion + + #region IHasCameraPanControl Members + + public void PanLeft() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Left CallId: {0}", CallId)); + } + + public void PanRight() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Right CallId: {0}", CallId)); + } + + public void PanStop() + { + Stop(); + } + + #endregion + + #region IHasCameraTiltControl Members + + public void TiltDown() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Down CallId: {0}", CallId)); + } + + public void TiltUp() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Up CallId: {0}", CallId)); + } + + public void TiltStop() + { + Stop(); + } + + #endregion + + #region IHasCameraZoomControl Members + + public void ZoomIn() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomIn CallId: {0}", CallId)); + } + + public void ZoomOut() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomOut CallId: {0}", CallId)); + } + + public void ZoomStop() + { + Stop(); + } + + #endregion + + + void Stop() + { + ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Stop CallId: {0}", CallId)); + } + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCamera.cs similarity index 68% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCamera.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCamera.cs index 9e8b0554..801627bc 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoCamera.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCamera.cs @@ -1,111 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { - public class CiscoFarEndCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced - { - protected CiscoSparkCodec ParentCodec { get; private set; } - - protected string CallId { - get - { - return (ParentCodec as CiscoSparkCodec).GetCallId(); - } - } - - public CiscoFarEndCamera(string key, string name, CiscoSparkCodec codec) - : base(key, name) - { - Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom; - - ParentCodec = codec; - } - - #region IHasCameraPtzControl Members - - public void PositionHome() - { - // Not supported on far end camera - } - - #endregion - - #region IHasCameraPanControl Members - - public void PanLeft() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Left CallId: {0}", CallId)); - } - - public void PanRight() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Right CallId: {0}", CallId)); - } - - public void PanStop() - { - Stop(); - } - - #endregion - - #region IHasCameraTiltControl Members - - public void TiltDown() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Down CallId: {0}", CallId)); - } - - public void TiltUp() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: Up CallId: {0}", CallId)); - } - - public void TiltStop() - { - Stop(); - } - - #endregion - - #region IHasCameraZoomControl Members - - public void ZoomIn() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomIn CallId: {0}", CallId)); - } - - public void ZoomOut() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Move Value: ZoomOut CallId: {0}", CallId)); - } - - public void ZoomStop() - { - Stop(); - } - - #endregion - - - void Stop() - { - ParentCodec.EnqueueCommand(string.Format("xCommand Call FarEndControl Camera Stop CallId: {0}", CallId)); - } - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); - } - } - public class CiscoSparkCamera : CameraBase, IHasCameraPtzControl, IHasCameraFocusControl, IBridgeAdvanced { /// @@ -161,7 +59,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco CameraId = id; // Set default speeds - PanSpeed = 7; + PanSpeed = 7; TiltSpeed = 7; ZoomSpeed = 7; } diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index 1eccf076..302e8c36 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -24,10 +24,6 @@ using PepperDash.Essentials.Core.Queues; namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco { - enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration }; - public enum eExternalSourceType {camera, desktop, document_camera, mediaplayer, PC, whiteboard, other} - public enum eExternalSourceMode {Ready, NotReady, Hidden, Error} - public class CiscoSparkCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory, IHasScheduleAwareness, IOccupancyStatusProvider, IHasCodecLayouts, IHasCodecSelfView, ICommunicationMonitor, IRouting, IHasCodecCameras, IHasCameraAutoMode, IHasCodecRoomPresets, @@ -2468,148 +2464,4 @@ ConnectorID: {2}" #endregion } - - - - /// - /// Tracks the initial sycnronization state of the codec when making a connection - /// - public class CodecSyncState : IKeyed - { - bool _InitialSyncComplete; - private readonly CiscoSparkCodec _parent; - - public event EventHandler InitialSyncCompleted; - private readonly CrestronQueue _commandQueue; - - public string Key { get; private set; } - - public bool InitialSyncComplete - { - get { return _InitialSyncComplete; } - private set - { - if (value == true) - { - var handler = InitialSyncCompleted; - if (handler != null) - handler(this, new EventArgs()); - } - _InitialSyncComplete = value; - } - } - - public bool LoginMessageWasReceived { get; private set; } - - public bool JsonResponseModeSet { get; private set; } - - public bool InitialStatusMessageWasReceived { get; private set; } - - public bool InitialConfigurationMessageWasReceived { get; private set; } - - public bool FeedbackWasRegistered { get; private set; } - - public CodecSyncState(string key, CiscoSparkCodec parent) - { - Key = key; - _parent = parent; - _commandQueue = new CrestronQueue(50); - CodecDisconnected(); - } - - private void ProcessQueuedCommands() - { - while (InitialSyncComplete) - { - var query = _commandQueue.Dequeue(); - - _parent.SendText(query); - } - } - - public void AddCommandToQueue(string query) - { - _commandQueue.Enqueue(query); - } - - public void LoginMessageReceived() - { - LoginMessageWasReceived = true; - Debug.Console(1, this, "Login Message Received."); - CheckSyncStatus(); - } - - public void JsonResponseModeMessageReceived() - { - JsonResponseModeSet = true; - Debug.Console(1, this, "Json Response Mode Message Received."); - CheckSyncStatus(); - } - - public void InitialStatusMessageReceived() - { - InitialStatusMessageWasReceived = true; - Debug.Console(1, this, "Initial Codec Status Message Received."); - CheckSyncStatus(); - } - - public void InitialConfigurationMessageReceived() - { - InitialConfigurationMessageWasReceived = true; - Debug.Console(1, this, "Initial Codec Configuration Message Received."); - CheckSyncStatus(); - } - - public void FeedbackRegistered() - { - FeedbackWasRegistered = true; - Debug.Console(1, this, "Initial Codec Feedback Registration Successful."); - CheckSyncStatus(); - } - - public void CodecDisconnected() - { - _commandQueue.Clear(); - LoginMessageWasReceived = false; - JsonResponseModeSet = false; - InitialConfigurationMessageWasReceived = false; - InitialStatusMessageWasReceived = false; - FeedbackWasRegistered = false; - InitialSyncComplete = false; - } - - void CheckSyncStatus() - { - if (LoginMessageWasReceived && JsonResponseModeSet && InitialConfigurationMessageWasReceived && InitialStatusMessageWasReceived && FeedbackWasRegistered) - { - InitialSyncComplete = true; - Debug.Console(1, this, "Initial Codec Sync Complete!"); - Debug.Console(1, this, "{0} Command queued. Processing now...", _commandQueue.Count); - - // Invoke a thread for the queue - CrestronInvoke.BeginInvoke((o) => { - ProcessQueuedCommands(); - }); - } - else - InitialSyncComplete = false; - } - } - - public class CiscoSparkCodecFactory : EssentialsDeviceFactory - { - public CiscoSparkCodecFactory() - { - TypeNames = new List() { "ciscospark", "ciscowebex", "ciscowebexpro", "ciscoroomkit", "ciscosparkpluscodec" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Cisco Codec Device"); - - var comm = CommFactory.CreateCommForDevice(dc); - return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecFactory.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecFactory.cs new file mode 100644 index 00000000..2e4ca41d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecFactory.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + public class CiscoSparkCodecFactory : EssentialsDeviceFactory + { + public CiscoSparkCodecFactory() + { + TypeNames = new List() { "ciscospark", "ciscowebex", "ciscowebexpro", "ciscoroomkit", "ciscosparkpluscodec" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Cisco Codec Device"); + + var comm = CommFactory.CreateCommForDevice(dc); + return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs index 38b81654..2d29bab2 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CiscoSparkCodecPropertiesConfig.cs @@ -63,29 +63,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec CameraInfo = new List(); } } - - public class SharingProperties - { - [JsonProperty("autoShareContentWhileInCall")] - public bool AutoShareContentWhileInCall { get; set; } - } - - public class BrandingLogoProperties - { - [JsonProperty("enable")] - public bool Enable { get; set; } - - [JsonProperty("brandingUrl")] - public string BrandingUrl { get; set; } - } - - /// - /// Describes configuration information for the near end cameras - /// - public class CameraInfo - { - public int CameraNumber { get; set; } - public string Name { get; set; } - public int SourceId { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecRoomPreset.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecRoomPreset.cs new file mode 100644 index 00000000..88cc658b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecRoomPreset.cs @@ -0,0 +1,16 @@ +using PepperDash.Essentials.Core.Presets; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// 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 : PresetBase + { + public CodecRoomPreset(int id, string description, bool def, bool isDef) + : base(id, description, def, isDef) + { + + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecSyncState.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecSyncState.cs new file mode 100644 index 00000000..06b6d801 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/CodecSyncState.cs @@ -0,0 +1,131 @@ +using System; +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + /// + /// Tracks the initial sycnronization state of the codec when making a connection + /// + public class CodecSyncState : IKeyed + { + bool _InitialSyncComplete; + private readonly CiscoSparkCodec _parent; + + public event EventHandler InitialSyncCompleted; + private readonly CrestronQueue _commandQueue; + + public string Key { get; private set; } + + public bool InitialSyncComplete + { + get { return _InitialSyncComplete; } + private set + { + if (value == true) + { + var handler = InitialSyncCompleted; + if (handler != null) + handler(this, new EventArgs()); + } + _InitialSyncComplete = value; + } + } + + public bool LoginMessageWasReceived { get; private set; } + + public bool JsonResponseModeSet { get; private set; } + + public bool InitialStatusMessageWasReceived { get; private set; } + + public bool InitialConfigurationMessageWasReceived { get; private set; } + + public bool FeedbackWasRegistered { get; private set; } + + public CodecSyncState(string key, CiscoSparkCodec parent) + { + Key = key; + _parent = parent; + _commandQueue = new CrestronQueue(50); + CodecDisconnected(); + } + + private void ProcessQueuedCommands() + { + while (InitialSyncComplete) + { + var query = _commandQueue.Dequeue(); + + _parent.SendText(query); + } + } + + public void AddCommandToQueue(string query) + { + _commandQueue.Enqueue(query); + } + + public void LoginMessageReceived() + { + LoginMessageWasReceived = true; + Debug.Console(1, this, "Login Message Received."); + CheckSyncStatus(); + } + + public void JsonResponseModeMessageReceived() + { + JsonResponseModeSet = true; + Debug.Console(1, this, "Json Response Mode Message Received."); + CheckSyncStatus(); + } + + public void InitialStatusMessageReceived() + { + InitialStatusMessageWasReceived = true; + Debug.Console(1, this, "Initial Codec Status Message Received."); + CheckSyncStatus(); + } + + public void InitialConfigurationMessageReceived() + { + InitialConfigurationMessageWasReceived = true; + Debug.Console(1, this, "Initial Codec Configuration Message Received."); + CheckSyncStatus(); + } + + public void FeedbackRegistered() + { + FeedbackWasRegistered = true; + Debug.Console(1, this, "Initial Codec Feedback Registration Successful."); + CheckSyncStatus(); + } + + public void CodecDisconnected() + { + _commandQueue.Clear(); + LoginMessageWasReceived = false; + JsonResponseModeSet = false; + InitialConfigurationMessageWasReceived = false; + InitialStatusMessageWasReceived = false; + FeedbackWasRegistered = false; + InitialSyncComplete = false; + } + + void CheckSyncStatus() + { + if (LoginMessageWasReceived && JsonResponseModeSet && InitialConfigurationMessageWasReceived && InitialStatusMessageWasReceived && FeedbackWasRegistered) + { + InitialSyncComplete = true; + Debug.Console(1, this, "Initial Codec Sync Complete!"); + Debug.Console(1, this, "{0} Command queued. Processing now...", _commandQueue.Count); + + // Invoke a thread for the queue + CrestronInvoke.BeginInvoke((o) => { + ProcessQueuedCommands(); + }); + } + else + InitialSyncComplete = false; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/IHasCodecRoomPresets.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/IHasCodecRoomPresets.cs new file mode 100644 index 00000000..499a8fdb --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/IHasCodecRoomPresets.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Interface for camera presets + /// + public interface IHasCodecRoomPresets + { + event EventHandler CodecRoomPresetsListHasChanged; + + List NearEndPresets { get; } + + List FarEndRoomPresets { get; } + + void CodecRoomPresetSelect(int preset); + + void CodecRoomPresetStore(int preset, string description); + + void SelectFarEndPreset(int preset); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/RoomPresets.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/RoomPresets.cs index 8fc8a1d0..e18e45d9 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/RoomPresets.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/RoomPresets.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using PepperDash.Core; @@ -7,24 +6,6 @@ using PepperDash.Essentials.Core.Presets; namespace PepperDash.Essentials.Devices.Common.VideoCodec { - /// - /// Interface for camera presets - /// - public interface IHasCodecRoomPresets - { - event EventHandler CodecRoomPresetsListHasChanged; - - List NearEndPresets { get; } - - List FarEndRoomPresets { get; } - - void CodecRoomPresetSelect(int preset); - - void CodecRoomPresetStore(int preset, string description); - - void SelectFarEndPreset(int preset); - } - public static class RoomPresets { /// @@ -41,16 +22,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec .ToList(); } } - - /// - /// 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 : PresetBase - { - public CodecRoomPreset(int id, string description, bool def, bool isDef) - : base(id, description, def, isDef) - { - - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/SharingProperties.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/SharingProperties.cs new file mode 100644 index 00000000..0ed0c5a2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/SharingProperties.cs @@ -0,0 +1,11 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + public class SharingProperties + { + [JsonProperty("autoShareContentWhileInCall")] + public bool AutoShareContentWhileInCall { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/ValueProperty.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/ValueProperty.cs new file mode 100644 index 00000000..06b1b9ac --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/ValueProperty.cs @@ -0,0 +1,30 @@ +extern alias Full; + +using System; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronXml.Serialization; +using Full.Newtonsoft.Json; +using Full.Newtonsoft.Json.Linq; +using PepperDash.Essentials.Devices.Common.VideoCodec.CiscoCodec; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + // Helper Classes for Proerties + public abstract class ValueProperty + { + /// + /// Triggered when Value is set + /// + public Action ValueChangedAction { get; set; } + + protected void OnValueChanged() + { + var a = ValueChangedAction; + if (a != null) + a(); + } + + } +} diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eCommandType.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eCommandType.cs new file mode 100644 index 00000000..b68f280d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eCommandType.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration }; +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceMode.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceMode.cs new file mode 100644 index 00000000..1f96f5e1 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceMode.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + public enum eExternalSourceMode {Ready, NotReady, Hidden, Error} +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceType.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceType.cs new file mode 100644 index 00000000..66ebe390 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CiscoCodec/eExternalSourceType.cs @@ -0,0 +1,4 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco +{ + public enum eExternalSourceType {camera, desktop, document_camera, mediaplayer, PC, whiteboard, other} +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecCommandWithLabel.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecCommandWithLabel.cs new file mode 100644 index 00000000..e6e2459b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecCommandWithLabel.cs @@ -0,0 +1,17 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Represents a codec command that might need to have a friendly label applied for UI feedback purposes + /// + public class CodecCommandWithLabel + { + public string Command { get; private set; } + public string Label { get; private set; } + + public CodecCommandWithLabel(string command, string label) + { + Command = command; + Label = label; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecPhonebookSyncState.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecPhonebookSyncState.cs new file mode 100644 index 00000000..ca04ec0b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/CodecPhonebookSyncState.cs @@ -0,0 +1,107 @@ +using System; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Used to track the status of syncronizing the phonebook values when connecting to a codec or refreshing the phonebook info + /// + public class CodecPhonebookSyncState : IKeyed + { + private bool _InitialSyncComplete; + + public CodecPhonebookSyncState(string key) + { + Key = key; + + CodecDisconnected(); + } + + public bool InitialSyncComplete + { + get { return _InitialSyncComplete; } + private set + { + if (value == true) + { + var handler = InitialSyncCompleted; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + _InitialSyncComplete = value; + } + } + + public bool InitialPhonebookFoldersWasReceived { get; private set; } + + public bool NumberOfContactsWasReceived { get; private set; } + + public bool PhonebookRootEntriesWasRecieved { get; private set; } + + public bool PhonebookHasFolders { get; private set; } + + public int NumberOfContacts { get; private set; } + + #region IKeyed Members + + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; + + public void InitialPhonebookFoldersReceived() + { + InitialPhonebookFoldersWasReceived = true; + + CheckSyncStatus(); + } + + public void PhonebookRootEntriesReceived() + { + PhonebookRootEntriesWasRecieved = true; + + CheckSyncStatus(); + } + + public void SetPhonebookHasFolders(bool value) + { + PhonebookHasFolders = value; + + Debug.Console(1, this, "Phonebook has folders: {0}", PhonebookHasFolders); + } + + public void SetNumberOfContacts(int contacts) + { + NumberOfContacts = contacts; + NumberOfContactsWasReceived = true; + + Debug.Console(1, this, "Phonebook contains {0} contacts.", NumberOfContacts); + + CheckSyncStatus(); + } + + public void CodecDisconnected() + { + InitialPhonebookFoldersWasReceived = false; + PhonebookHasFolders = false; + NumberOfContacts = 0; + NumberOfContactsWasReceived = false; + } + + private void CheckSyncStatus() + { + if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) + { + InitialSyncComplete = true; + Debug.Console(1, this, "Initial Phonebook Sync Complete!"); + } + else + { + InitialSyncComplete = false; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/CodecParticipants.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/CodecParticipants.cs new file mode 100644 index 00000000..82a72abf --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/CodecParticipants.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + public class CodecParticipants + { + private List _currentParticipants; + + public List CurrentParticipants + { + get { return _currentParticipants; } + set + { + _currentParticipants = value; + OnParticipantsChanged(); + } + } + + public Participant Host + { + get + { + return _currentParticipants.FirstOrDefault(p => p.IsHost); + } + } + + public event EventHandler ParticipantsListHasChanged; + + public CodecParticipants() + { + _currentParticipants = new List(); + } + + public void OnParticipantsChanged() + { + var handler = ParticipantsListHasChanged; + + if (handler == null) return; + + handler(this, new EventArgs()); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasCodecLayouts.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasCodecLayouts.cs index d2393692..0182ffe2 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasCodecLayouts.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasCodecLayouts.cs @@ -1,6 +1,4 @@ extern alias Full; - -using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,8 +6,6 @@ using Crestron.SimplSharp; using PepperDash.Essentials.Core; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Devices.Common.VideoCodec { /// @@ -23,44 +19,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec void LocalLayoutToggleSingleProminent(); void MinMaxLayoutToggle(); } - - - /// - /// Defines the requirements for Zoom Room layout control - /// - public interface IHasZoomRoomLayouts : IHasCodecLayouts - { - event EventHandler LayoutInfoChanged; - - BoolFeedback LayoutViewIsOnFirstPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func - BoolFeedback LayoutViewIsOnLastPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func - BoolFeedback CanSwapContentWithThumbnailFeedback { get; } - BoolFeedback ContentSwappedWithThumbnailFeedback { get; } - - ZoomRoom.zConfiguration.eLayoutStyle LastSelectedLayout { get; } - ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; } - - void GetAvailableLayouts(); // Mot sure this is necessary if we're already subscribed to zStatus Call Layout - void SetLayout(ZoomRoom.zConfiguration.eLayoutStyle layoutStyle); - void SwapContentWithThumbnail(); - - void LayoutTurnNextPage(); - void LayoutTurnPreviousPage(); - } - - public class LayoutInfoChangedEventArgs : EventArgs - { - [JsonProperty("availableLayouts", NullValueHandling = NullValueHandling.Ignore)] - public ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; set; } - [JsonProperty("currentSelectedLayout", NullValueHandling = NullValueHandling.Ignore)] - public ZoomRoom.zConfiguration.eLayoutStyle CurrentSelectedLayout { get; set; } - [JsonProperty("canSwapContentWithThumbnail", NullValueHandling = NullValueHandling.Ignore)] - public bool CanSwapContentWithThumbnail { get; set; } - [JsonProperty("contentSwappedWithThumbnail", NullValueHandling = NullValueHandling.Ignore)] - public bool ContentSwappedWithThumbnail { get; set; } - [JsonProperty("layoutViewIsOnFirstPage", NullValueHandling = NullValueHandling.Ignore)] - public bool LayoutViewIsOnFirstPage { get; set; } - [JsonProperty("layoutViewIsOnLastPage", NullValueHandling = NullValueHandling.Ignore)] - public bool LayoutViewIsOnLastPage { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasHalfWakeMode.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasHalfWakeMode.cs new file mode 100644 index 00000000..d1db15f2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasHalfWakeMode.cs @@ -0,0 +1,16 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Describes a device that has Half Waek Mode capability + /// + public interface IHasHalfWakeMode : IHasStandbyMode + { + BoolFeedback HalfWakeModeIsOnFeedback { get; } + + BoolFeedback EnteringStandbyModeFeedback { get; } + + void HalfwakeActivate(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingInfo.cs index 304400fc..70786fcf 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingInfo.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingInfo.cs @@ -6,8 +6,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces { /// @@ -19,61 +17,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces MeetingInfo MeetingInfo { get; } } - - /// - /// Represents the information about a meeting in progress - /// Currently used for Zoom meetings - /// - public class MeetingInfo - { - [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] - public string Id { get; private set; } - [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] - public string Name { get; private set; } - [JsonProperty("host", NullValueHandling = NullValueHandling.Ignore)] - public string Host { get; private set; } - [JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)] - public string Password { get; private set; } - [JsonProperty("shareStatus", NullValueHandling = NullValueHandling.Ignore)] - public string ShareStatus { get; private set; } - [JsonProperty("isHost", NullValueHandling = NullValueHandling.Ignore)] - public Boolean IsHost { get; private set; } - [JsonProperty("isSharingMeeting", NullValueHandling = NullValueHandling.Ignore)] - public Boolean IsSharingMeeting { get; private set; } - [JsonProperty("waitingForHost", NullValueHandling = NullValueHandling.Ignore)] - public Boolean WaitingForHost { get; private set; } - [JsonProperty("isLocked", NullValueHandling = NullValueHandling.Ignore)] - public Boolean IsLocked { get; private set; } - [JsonProperty("isRecording", NullValueHandling = NullValueHandling.Ignore)] - public Boolean IsRecording { get; private set; } - [JsonProperty("canRecord", NullValueHandling = NullValueHandling.Ignore)] - public Boolean CanRecord { get; private set; } - - - public MeetingInfo(string id, string name, string host, string password, string shareStatus, bool isHost, bool isSharingMeeting, bool waitingForHost, bool isLocked, bool isRecording, bool canRecord) - { - Id = id; - Name = name; - Host = host; - Password = password; - ShareStatus = shareStatus; - IsHost = isHost; - IsSharingMeeting = isSharingMeeting; - WaitingForHost = waitingForHost; - IsLocked = isLocked; - IsRecording = isRecording; - CanRecord = CanRecord; - } - } - - public class MeetingInfoEventArgs : EventArgs - { - public MeetingInfo Info { get; private set; } - - public MeetingInfoEventArgs(MeetingInfo info) - { - Info = info; - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecording.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecording.cs index b05362c3..771a0865 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecording.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecording.cs @@ -15,15 +15,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces void StopRecording(); void ToggleRecording(); } - - public interface IHasMeetingRecordingWithPrompt : IHasMeetingRecording - { - BoolFeedback RecordConsentPromptIsVisible { get; } - - /// - /// Used to agree or disagree to the meeting being recorded when prompted - /// - /// - void RecordingPromptAcknowledgement(bool agree); - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecordingWithPrompt.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecordingWithPrompt.cs new file mode 100644 index 00000000..73cb72dd --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasMeetingRecordingWithPrompt.cs @@ -0,0 +1,15 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + public interface IHasMeetingRecordingWithPrompt : IHasMeetingRecording + { + BoolFeedback RecordConsentPromptIsVisible { get; } + + /// + /// Used to agree or disagree to the meeting being recorded when prompted + /// + /// + void RecordingPromptAcknowledgement(bool agree); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantAudioMute.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantAudioMute.cs new file mode 100644 index 00000000..c68abd38 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantAudioMute.cs @@ -0,0 +1,17 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + /// + /// Describes the ability to mute and unmute a participant's audio in a meeting + /// + public interface IHasParticipantAudioMute : IHasParticipantVideoMute + { + /// + /// Mute audio of all participants + /// + void MuteAudioForAllParticipants(); + + void MuteAudioForParticipant(int userId); + void UnmuteAudioForParticipant(int userId); + void ToggleAudioForParticipant(int userId); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantPinUnpin.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantPinUnpin.cs new file mode 100644 index 00000000..0b630ab2 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantPinUnpin.cs @@ -0,0 +1,17 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + /// + /// Describes the ability to pin and unpin a participant in a meeting + /// + public interface IHasParticipantPinUnpin : IHasParticipants + { + IntFeedback NumberOfScreensFeedback { get; } + int ScreenIndexToPinUserTo { get; } + + void PinParticipant(int userId, int screenIndex); + void UnPinParticipant(int userId); + void ToggleParticipantPinState(int userId, int screenIndex); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantVideoMute.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantVideoMute.cs new file mode 100644 index 00000000..aa754a4d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipantVideoMute.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + /// + /// Describes the ability to mute and unmute a participant's video in a meeting + /// + public interface IHasParticipantVideoMute : IHasParticipants + { + void MuteVideoForParticipant(int userId); + void UnmuteVideoForParticipant(int userId); + void ToggleVideoForParticipant(int userId); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipants.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipants.cs index 98c94bdc..b3818237 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipants.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasParticipants.cs @@ -1,8 +1,4 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using PepperDash.Core; -using PepperDash.Essentials.Core; +using PepperDash.Core; namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces { @@ -31,105 +27,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces /// void AdmitParticipantFromWaitingRoom(int userId); } - - /// - /// Describes the ability to mute and unmute a participant's video in a meeting - /// - public interface IHasParticipantVideoMute : IHasParticipants - { - void MuteVideoForParticipant(int userId); - void UnmuteVideoForParticipant(int userId); - void ToggleVideoForParticipant(int userId); - } - - /// - /// Describes the ability to mute and unmute a participant's audio in a meeting - /// - public interface IHasParticipantAudioMute : IHasParticipantVideoMute - { - /// - /// Mute audio of all participants - /// - void MuteAudioForAllParticipants(); - - void MuteAudioForParticipant(int userId); - void UnmuteAudioForParticipant(int userId); - void ToggleAudioForParticipant(int userId); - } - - /// - /// Describes the ability to pin and unpin a participant in a meeting - /// - public interface IHasParticipantPinUnpin : IHasParticipants - { - IntFeedback NumberOfScreensFeedback { get; } - int ScreenIndexToPinUserTo { get; } - - void PinParticipant(int userId, int screenIndex); - void UnPinParticipant(int userId); - void ToggleParticipantPinState(int userId, int screenIndex); - } - - public class CodecParticipants - { - private List _currentParticipants; - - public List CurrentParticipants - { - get { return _currentParticipants; } - set - { - _currentParticipants = value; - OnParticipantsChanged(); - } - } - - public Participant Host - { - get - { - return _currentParticipants.FirstOrDefault(p => p.IsHost); - } - } - - public event EventHandler ParticipantsListHasChanged; - - public CodecParticipants() - { - _currentParticipants = new List(); - } - - public void OnParticipantsChanged() - { - var handler = ParticipantsListHasChanged; - - if (handler == null) return; - - handler(this, new EventArgs()); - } - } - - /// - /// Represents a call participant - /// - public class Participant - { - public int UserId { get; set; } - public bool IsHost { get; set; } - public bool IsMyself { get; set; } - public string Name { get; set; } - public bool CanMuteVideo { get; set; } - public bool CanUnmuteVideo { get; set; } - public bool VideoMuteFb { get; set; } - public bool AudioMuteFb { get; set; } - public bool HandIsRaisedFb { get; set; } - public bool IsPinnedFb { get; set; } - public int ScreenIndexIsPinnedToFb { get; set; } - - public Participant() - { - // Initialize to -1 (no screen) - ScreenIndexIsPinnedToFb = -1; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs index a620af1e..3398148a 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasPresentationOnlyMeeting.cs @@ -8,11 +8,4 @@ void StartSharingOnlyMeeting(eSharingMeetingMode displayMode, uint duration, string password); void StartNormalMeetingFromSharingOnlyMeeting(); } - - public enum eSharingMeetingMode - { - None, - Laptop, - Ios, - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasStandbyMode.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasStandbyMode.cs index cc9dcd3d..90cd901d 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasStandbyMode.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasStandbyMode.cs @@ -19,16 +19,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec void StandbyDeactivate(); } - - /// - /// Describes a device that has Half Waek Mode capability - /// - public interface IHasHalfWakeMode : IHasStandbyMode - { - BoolFeedback HalfWakeModeIsOnFeedback { get; } - - BoolFeedback EnteringStandbyModeFeedback { get; } - - void HalfwakeActivate(); - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasZoomRoomLayouts.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasZoomRoomLayouts.cs new file mode 100644 index 00000000..9f0642d6 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/IHasZoomRoomLayouts.cs @@ -0,0 +1,28 @@ +using System; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Defines the requirements for Zoom Room layout control + /// + public interface IHasZoomRoomLayouts : IHasCodecLayouts + { + event EventHandler LayoutInfoChanged; + + BoolFeedback LayoutViewIsOnFirstPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func + BoolFeedback LayoutViewIsOnLastPageFeedback { get; } // TODO: #697 [*] Consider modifying to report button visibility in func + BoolFeedback CanSwapContentWithThumbnailFeedback { get; } + BoolFeedback ContentSwappedWithThumbnailFeedback { get; } + + ZoomRoom.zConfiguration.eLayoutStyle LastSelectedLayout { get; } + ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; } + + void GetAvailableLayouts(); // Mot sure this is necessary if we're already subscribed to zStatus Call Layout + void SetLayout(ZoomRoom.zConfiguration.eLayoutStyle layoutStyle); + void SwapContentWithThumbnail(); + + void LayoutTurnNextPage(); + void LayoutTurnPreviousPage(); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/LayoutInfoChangedEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/LayoutInfoChangedEventArgs.cs new file mode 100644 index 00000000..f6e0acdc --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/LayoutInfoChangedEventArgs.cs @@ -0,0 +1,22 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + public class LayoutInfoChangedEventArgs : EventArgs + { + [JsonProperty("availableLayouts", NullValueHandling = NullValueHandling.Ignore)] + public ZoomRoom.zConfiguration.eLayoutStyle AvailableLayouts { get; set; } + [JsonProperty("currentSelectedLayout", NullValueHandling = NullValueHandling.Ignore)] + public ZoomRoom.zConfiguration.eLayoutStyle CurrentSelectedLayout { get; set; } + [JsonProperty("canSwapContentWithThumbnail", NullValueHandling = NullValueHandling.Ignore)] + public bool CanSwapContentWithThumbnail { get; set; } + [JsonProperty("contentSwappedWithThumbnail", NullValueHandling = NullValueHandling.Ignore)] + public bool ContentSwappedWithThumbnail { get; set; } + [JsonProperty("layoutViewIsOnFirstPage", NullValueHandling = NullValueHandling.Ignore)] + public bool LayoutViewIsOnFirstPage { get; set; } + [JsonProperty("layoutViewIsOnLastPage", NullValueHandling = NullValueHandling.Ignore)] + public bool LayoutViewIsOnLastPage { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfo.cs new file mode 100644 index 00000000..83f51238 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfo.cs @@ -0,0 +1,52 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + /// + /// Represents the information about a meeting in progress + /// Currently used for Zoom meetings + /// + public class MeetingInfo + { + [JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)] + public string Id { get; private set; } + [JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)] + public string Name { get; private set; } + [JsonProperty("host", NullValueHandling = NullValueHandling.Ignore)] + public string Host { get; private set; } + [JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)] + public string Password { get; private set; } + [JsonProperty("shareStatus", NullValueHandling = NullValueHandling.Ignore)] + public string ShareStatus { get; private set; } + [JsonProperty("isHost", NullValueHandling = NullValueHandling.Ignore)] + public Boolean IsHost { get; private set; } + [JsonProperty("isSharingMeeting", NullValueHandling = NullValueHandling.Ignore)] + public Boolean IsSharingMeeting { get; private set; } + [JsonProperty("waitingForHost", NullValueHandling = NullValueHandling.Ignore)] + public Boolean WaitingForHost { get; private set; } + [JsonProperty("isLocked", NullValueHandling = NullValueHandling.Ignore)] + public Boolean IsLocked { get; private set; } + [JsonProperty("isRecording", NullValueHandling = NullValueHandling.Ignore)] + public Boolean IsRecording { get; private set; } + [JsonProperty("canRecord", NullValueHandling = NullValueHandling.Ignore)] + public Boolean CanRecord { get; private set; } + + + public MeetingInfo(string id, string name, string host, string password, string shareStatus, bool isHost, bool isSharingMeeting, bool waitingForHost, bool isLocked, bool isRecording, bool canRecord) + { + Id = id; + Name = name; + Host = host; + Password = password; + ShareStatus = shareStatus; + IsHost = isHost; + IsSharingMeeting = isSharingMeeting; + WaitingForHost = waitingForHost; + IsLocked = isLocked; + IsRecording = isRecording; + CanRecord = CanRecord; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfoEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfoEventArgs.cs new file mode 100644 index 00000000..976931cb --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/MeetingInfoEventArgs.cs @@ -0,0 +1,15 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + public class MeetingInfoEventArgs : EventArgs + { + public MeetingInfo Info { get; private set; } + + public MeetingInfoEventArgs(MeetingInfo info) + { + Info = info; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/Participant.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/Participant.cs new file mode 100644 index 00000000..ed438e5b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/Participant.cs @@ -0,0 +1,26 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + /// + /// Represents a call participant + /// + public class Participant + { + public int UserId { get; set; } + public bool IsHost { get; set; } + public bool IsMyself { get; set; } + public string Name { get; set; } + public bool CanMuteVideo { get; set; } + public bool CanUnmuteVideo { get; set; } + public bool VideoMuteFb { get; set; } + public bool AudioMuteFb { get; set; } + public bool HandIsRaisedFb { get; set; } + public bool IsPinnedFb { get; set; } + public int ScreenIndexIsPinnedToFb { get; set; } + + public Participant() + { + // Initialize to -1 (no screen) + ScreenIndexIsPinnedToFb = -1; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/VideoCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/VideoCodecInfo.cs new file mode 100644 index 00000000..e8507609 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/VideoCodecInfo.cs @@ -0,0 +1,26 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.Codec +{ + /// + /// Stores general information about a codec + /// + public abstract class VideoCodecInfo + { + [JsonProperty("multiSiteOptionIsEnabled", NullValueHandling = NullValueHandling.Ignore)] + public abstract bool MultiSiteOptionIsEnabled { get; } + [JsonProperty("ipAddress", NullValueHandling = NullValueHandling.Ignore)] + public abstract string IpAddress { get; } + [JsonProperty("sipPhoneNumber", NullValueHandling = NullValueHandling.Ignore)] + public abstract string SipPhoneNumber { get; } + [JsonProperty("e164Alias", NullValueHandling = NullValueHandling.Ignore)] + public abstract string E164Alias { get; } + [JsonProperty("h323Id", NullValueHandling = NullValueHandling.Ignore)] + public abstract string H323Id { get; } + [JsonProperty("sipUri", NullValueHandling = NullValueHandling.Ignore)] + public abstract string SipUri { get; } + [JsonProperty("autoAnswerEnabled", NullValueHandling = NullValueHandling.Ignore)] + public abstract bool AutoAnswerEnabled { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/eSharingMeetingMode.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/eSharingMeetingMode.cs new file mode 100644 index 00000000..93aec63b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/eSharingMeetingMode.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces +{ + public enum eSharingMeetingMode + { + None, + Laptop, + Ios, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/iVideoCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/iVideoCodecInfo.cs index 23c39325..5f9575ed 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/iVideoCodecInfo.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/Interfaces/iVideoCodecInfo.cs @@ -6,8 +6,6 @@ using System.Linq; using System.Text; using Crestron.SimplSharp; -using Full.Newtonsoft.Json; - namespace PepperDash.Essentials.Devices.Common.Codec { /// @@ -17,25 +15,4 @@ namespace PepperDash.Essentials.Devices.Common.Codec { VideoCodecInfo CodecInfo { get; } } - - /// - /// Stores general information about a codec - /// - public abstract class VideoCodecInfo - { - [JsonProperty("multiSiteOptionIsEnabled", NullValueHandling = NullValueHandling.Ignore)] - public abstract bool MultiSiteOptionIsEnabled { get; } - [JsonProperty("ipAddress", NullValueHandling = NullValueHandling.Ignore)] - public abstract string IpAddress { get; } - [JsonProperty("sipPhoneNumber", NullValueHandling = NullValueHandling.Ignore)] - public abstract string SipPhoneNumber { get; } - [JsonProperty("e164Alias", NullValueHandling = NullValueHandling.Ignore)] - public abstract string E164Alias { get; } - [JsonProperty("h323Id", NullValueHandling = NullValueHandling.Ignore)] - public abstract string H323Id { get; } - [JsonProperty("sipUri", NullValueHandling = NullValueHandling.Ignore)] - public abstract string SipUri { get; } - [JsonProperty("autoAnswerEnabled", NullValueHandling = NullValueHandling.Ignore)] - public abstract bool AutoAnswerEnabled { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockCodecInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockCodecInfo.cs new file mode 100644 index 00000000..91607266 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockCodecInfo.cs @@ -0,0 +1,52 @@ +using PepperDash.Essentials.Devices.Common.Codec; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + /// + /// Implementation for the mock VC + /// + public class MockCodecInfo : VideoCodecInfo + { + + public override bool MultiSiteOptionIsEnabled + { + get { return true; } + } + + public override string E164Alias + { + get { return "someE164alias"; } + } + + public override string H323Id + { + get { return "someH323Id"; } + } + + public override string IpAddress + { + get { return "xxx.xxx.xxx.xxx"; } + } + + public override string SipPhoneNumber + { + get { return "333-444-5555"; } + } + + public override string SipUri + { + get { return "mock@someurl.com"; } + } + + public override bool AutoAnswerEnabled + { + get { return _AutoAnswerEnabled; } + } + bool _AutoAnswerEnabled; + + public void SetAutoAnswer(bool value) + { + _AutoAnswerEnabled = value; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockFarEndVCCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockFarEndVCCamera.cs new file mode 100644 index 00000000..0cdf1de8 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockFarEndVCCamera.cs @@ -0,0 +1,92 @@ +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Devices.Common.VideoCodec; + +namespace PepperDash.Essentials.Devices.Common.Cameras +{ + public class MockFarEndVCCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced + { + protected VideoCodecBase ParentCodec { get; private set; } + + + public MockFarEndVCCamera(string key, string name, VideoCodecBase codec) + : base(key, name) + { + Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom; + + ParentCodec = codec; + } + + #region IHasCameraPtzControl Members + + public void PositionHome() + { + Debug.Console(1, this, "Resetting to home position"); + } + + #endregion + + #region IHasCameraPanControl Members + + public void PanLeft() + { + Debug.Console(1, this, "Panning Left"); + } + + public void PanRight() + { + Debug.Console(1, this, "Panning Right"); + } + + public void PanStop() + { + Debug.Console(1, this, "Stopping Pan"); + } + + #endregion + + #region IHasCameraTiltControl Members + + public void TiltDown() + { + Debug.Console(1, this, "Tilting Down"); + } + + public void TiltUp() + { + Debug.Console(1, this, "Tilting Up"); + } + + public void TiltStop() + { + Debug.Console(1, this, "Stopping Tilt"); + } + + #endregion + + #region IHasCameraZoomControl Members + + public void ZoomIn() + { + Debug.Console(1, this, "Zooming In"); + } + + public void ZoomOut() + { + Debug.Console(1, this, "Zooming Out"); + } + + public void ZoomStop() + { + Debug.Console(1, this, "Stopping Zoom"); + } + + #endregion + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs index 66dc6180..dff0cd45 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVC.cs @@ -783,67 +783,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec } } - - /// - /// Implementation for the mock VC - /// - public class MockCodecInfo : VideoCodecInfo - { - - public override bool MultiSiteOptionIsEnabled - { - get { return true; } - } - - public override string E164Alias - { - get { return "someE164alias"; } - } - - public override string H323Id - { - get { return "someH323Id"; } - } - - public override string IpAddress - { - get { return "xxx.xxx.xxx.xxx"; } - } - - public override string SipPhoneNumber - { - get { return "333-444-5555"; } - } - - public override string SipUri - { - get { return "mock@someurl.com"; } - } - - public override bool AutoAnswerEnabled - { - get { return _AutoAnswerEnabled; } - } - bool _AutoAnswerEnabled; - - public void SetAutoAnswer(bool value) - { - _AutoAnswerEnabled = value; - } - } - - public class MockVCFactory : EssentialsDeviceFactory - { - public MockVCFactory() - { - TypeNames = new List() { "mockvc" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new MockVC Device"); - return new VideoCodec.MockVC(dc); - } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs index 0c008849..f527021f 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCCamera.cs @@ -118,89 +118,4 @@ namespace PepperDash.Essentials.Devices.Common.Cameras LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); } } - - public class MockFarEndVCCamera : CameraBase, IHasCameraPtzControl, IAmFarEndCamera, IBridgeAdvanced - { - protected VideoCodecBase ParentCodec { get; private set; } - - - public MockFarEndVCCamera(string key, string name, VideoCodecBase codec) - : base(key, name) - { - Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom; - - ParentCodec = codec; - } - - #region IHasCameraPtzControl Members - - public void PositionHome() - { - Debug.Console(1, this, "Resetting to home position"); - } - - #endregion - - #region IHasCameraPanControl Members - - public void PanLeft() - { - Debug.Console(1, this, "Panning Left"); - } - - public void PanRight() - { - Debug.Console(1, this, "Panning Right"); - } - - public void PanStop() - { - Debug.Console(1, this, "Stopping Pan"); - } - - #endregion - - #region IHasCameraTiltControl Members - - public void TiltDown() - { - Debug.Console(1, this, "Tilting Down"); - } - - public void TiltUp() - { - Debug.Console(1, this, "Tilting Up"); - } - - public void TiltStop() - { - Debug.Console(1, this, "Stopping Tilt"); - } - - #endregion - - #region IHasCameraZoomControl Members - - public void ZoomIn() - { - Debug.Console(1, this, "Zooming In"); - } - - public void ZoomOut() - { - Debug.Console(1, this, "Zooming Out"); - } - - public void ZoomStop() - { - Debug.Console(1, this, "Stopping Zoom"); - } - - #endregion - - public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCFactory.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCFactory.cs new file mode 100644 index 00000000..7cf72232 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVCFactory.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec +{ + public class MockVCFactory : EssentialsDeviceFactory + { + public MockVCFactory() + { + TypeNames = new List() { "mockvc" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new MockVC Device"); + return new VideoCodec.MockVC(dc); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockCodecDirectory.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVideoCodecDirectory.cs similarity index 100% rename from src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockCodecDirectory.cs rename to src/PepperDash.Essentials.Devices.Common/VideoCodec/MockVC/MockVideoCodecDirectory.cs diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs index 3dd85100..84c57863 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/VideoCodecBase.cs @@ -1908,124 +1908,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec #endregion } - - - /// - /// Used to track the status of syncronizing the phonebook values when connecting to a codec or refreshing the phonebook info - /// - public class CodecPhonebookSyncState : IKeyed - { - private bool _InitialSyncComplete; - - public CodecPhonebookSyncState(string key) - { - Key = key; - - CodecDisconnected(); - } - - public bool InitialSyncComplete - { - get { return _InitialSyncComplete; } - private set - { - if (value == true) - { - var handler = InitialSyncCompleted; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - _InitialSyncComplete = value; - } - } - - public bool InitialPhonebookFoldersWasReceived { get; private set; } - - public bool NumberOfContactsWasReceived { get; private set; } - - public bool PhonebookRootEntriesWasRecieved { get; private set; } - - public bool PhonebookHasFolders { get; private set; } - - public int NumberOfContacts { get; private set; } - - #region IKeyed Members - - public string Key { get; private set; } - - #endregion - - public event EventHandler InitialSyncCompleted; - - public void InitialPhonebookFoldersReceived() - { - InitialPhonebookFoldersWasReceived = true; - - CheckSyncStatus(); - } - - public void PhonebookRootEntriesReceived() - { - PhonebookRootEntriesWasRecieved = true; - - CheckSyncStatus(); - } - - public void SetPhonebookHasFolders(bool value) - { - PhonebookHasFolders = value; - - Debug.Console(1, this, "Phonebook has folders: {0}", PhonebookHasFolders); - } - - public void SetNumberOfContacts(int contacts) - { - NumberOfContacts = contacts; - NumberOfContactsWasReceived = true; - - Debug.Console(1, this, "Phonebook contains {0} contacts.", NumberOfContacts); - - CheckSyncStatus(); - } - - public void CodecDisconnected() - { - InitialPhonebookFoldersWasReceived = false; - PhonebookHasFolders = false; - NumberOfContacts = 0; - NumberOfContactsWasReceived = false; - } - - private void CheckSyncStatus() - { - if (InitialPhonebookFoldersWasReceived && NumberOfContactsWasReceived && PhonebookRootEntriesWasRecieved) - { - InitialSyncComplete = true; - Debug.Console(1, this, "Initial Phonebook Sync Complete!"); - } - else - { - InitialSyncComplete = false; - } - } - } - /// - /// Represents a codec command that might need to have a friendly label applied for UI feedback purposes - /// - public class CodecCommandWithLabel - { - public string Command { get; private set; } - public string Label { get; private set; } - - public CodecCommandWithLabel(string command, string label) - { - Command = command; - Label = label; - } - } - - - } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs index 465e2d2b..39f7497c 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/IZoomWirelessShareInstructions.cs @@ -9,16 +9,6 @@ using PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { - public class ShareInfoEventArgs : EventArgs - { - public zStatus.Sharing SharingStatus { get; private set; } - - public ShareInfoEventArgs(zStatus.Sharing status) - { - SharingStatus = status; - } - } - public interface IZoomWirelessShareInstructions { event EventHandler ShareInfoChanged; diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/NotifiableObject.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/NotifiableObject.cs new file mode 100644 index 00000000..3471b29e --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/NotifiableObject.cs @@ -0,0 +1,33 @@ +extern alias Full; +using System.Text; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using Crestron.SimplSharp; + +using PepperDash.Core; +using Full.Newtonsoft.Json.Linq; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public abstract class NotifiableObject : INotifyPropertyChanged + { + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + protected void NotifyPropertyChanged(string propertyName) + { + var handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + else + { + Debug.Console(2, "PropertyChanged event is NULL"); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Response.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Response.cs new file mode 100644 index 00000000..04724cf9 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Response.cs @@ -0,0 +1,23 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// Represents a response from a ZoomRoom system + /// + public class Response + { + public Status Status { get; set; } + public bool Sync { get; set; } + [JsonProperty("topKey")] + public string TopKey { get; set; } + [JsonProperty("type")] + public string Type { get; set; } + + public Response() + { + Status = new Status(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs deleted file mode 100644 index 5e49b15f..00000000 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ /dev/null @@ -1,1820 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using Crestron.SimplSharp; - -using PepperDash.Core; -using PepperDash.Essentials.Devices.Common.Codec; - -using Full.Newtonsoft.Json; -using Full.Newtonsoft.Json.Linq; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; - -namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom -{ - public enum eZoomRoomResponseType - { - zEvent, - zStatus, - zConfiguration, - zCommand - } - - public abstract class NotifiableObject : INotifyPropertyChanged - { - #region INotifyPropertyChanged Members - - public event PropertyChangedEventHandler PropertyChanged; - - protected void NotifyPropertyChanged(string propertyName) - { - var handler = PropertyChanged; - if (handler != null) - { - handler(this, new PropertyChangedEventArgs(propertyName)); - } - else - { - Debug.Console(2, "PropertyChanged event is NULL"); - } - } - - #endregion - } - - /// - /// Used to track the current status of a ZoomRoom - /// - public class ZoomRoomStatus - { - public zStatus.Login Login { get; set; } - public zStatus.SystemUnit SystemUnit { get; set; } - public zStatus.Phonebook Phonebook { get; set; } - public zStatus.Call Call { get; set; } - public zStatus.Capabilities Capabilities { get; set; } - public zStatus.Sharing Sharing { get; set; } - public zStatus.NumberOfScreens NumberOfScreens { get; set; } - public zStatus.Layout Layout { get; set; } - public zStatus.Video Video { get; set; } - public zStatus.CameraShare CameraShare { get; set; } - public List AudioInputs { get; set; } - public List AudioOuputs { get; set; } - public List Cameras { get; set; } - public zEvent.PhoneCallStatus PhoneCall { get; set; } - public zEvent.NeedWaitForHost NeedWaitForHost { get; set; } - - public ZoomRoomStatus() - { - Login = new zStatus.Login(); - SystemUnit = new zStatus.SystemUnit(); - Phonebook = new zStatus.Phonebook(); - Call = new zStatus.Call(); - Capabilities = new zStatus.Capabilities(); - Sharing = new zStatus.Sharing(); - NumberOfScreens = new zStatus.NumberOfScreens(); - Layout = new zStatus.Layout(); - Video = new zStatus.Video(); - CameraShare = new zStatus.CameraShare(); - AudioInputs = new List(); - AudioOuputs = new List(); - Cameras = new List(); - PhoneCall = new zEvent.PhoneCallStatus(); - NeedWaitForHost = new zEvent.NeedWaitForHost(); - } - } - - /// - /// Used to track the current configuration of a ZoomRoom - /// - public class ZoomRoomConfiguration - { - public zConfiguration.Call Call { get; set; } - public zConfiguration.Audio Audio { get; set; } - public zConfiguration.Video Video { get; set; } - public zConfiguration.Client Client { get; set; } - public zConfiguration.Camera Camera { get; set; } - - public ZoomRoomConfiguration() - { - Call = new zConfiguration.Call(); - Audio = new zConfiguration.Audio(); - Video = new zConfiguration.Video(); - Client = new zConfiguration.Client(); - Camera = new zConfiguration.Camera(); - } - } - - /// - /// Represents a response from a ZoomRoom system - /// - public class Response - { - public Status Status { get; set; } - public bool Sync { get; set; } - [JsonProperty("topKey")] - public string TopKey { get; set; } - [JsonProperty("type")] - public string Type { get; set; } - - public Response() - { - Status = new Status(); - } - } - - public class Status - { - [JsonProperty("message")] - public string Message { get; set; } - [JsonProperty("state")] - public string State { get; set; } - } - - - /// - /// zStatus class stucture - /// - public class zStatus - { - public class Login - { - [JsonProperty("ZAAPI Release")] - public string ZAAPIRelease { get; set; } - [JsonProperty("Zoom Room Release")] - public string ZoomRoomRelease { get; set; } - } - - public class SystemUnit - { - [JsonProperty("email")] - public string Email { get; set; } - [JsonProperty("login_type")] - public string LoginType { get; set; } - [JsonProperty("meeting_number")] - public string MeetingNumber { get; set; } - [JsonProperty("platform")] - public string Platform { get; set; } - [JsonProperty("room_info")] - public RoomInfo RoomInfo { get; set; } - [JsonProperty("room_version")] - public string RoomVersion { get; set; } - - public SystemUnit() - { - RoomInfo = new RoomInfo(); - } - } - - public class RoomInfo - { - [JsonProperty("account_email")] - public string AccountEmail { get; set; } - [JsonProperty("display_version")] - public string DisplayVersion { get; set; } - [JsonProperty("is_auto_answer_enabled")] - public bool AutoAnswerIsEnabled { get; set; } - [JsonProperty("is_auto_answer_selected")] - public bool AutoAnswerIsSelected { get; set; } - [JsonProperty("room_name")] - public string RoomName { get; set; } - } - - public class CloudPbxInfo - { - [JsonProperty("company_number")] - public string CompanyNumber { get; set; } - [JsonProperty("extension")] - public string Extension { get; set; } - [JsonProperty("isValid")] - public bool IsValid { get; set; } - } - - public enum ePresence - { - PRESENCE_OFFLINE, - PRESENCE_ONLINE, - PRESENCE_AWAY, - PRESENCE_BUSY, - PRESENCE_DND - } - - public class Contact - { - [JsonProperty("avatarURL")] - public string AvatarURL { get; set; } - [JsonProperty("cloud_pbx_info")] - public CloudPbxInfo CloudPbxInfo { get; set; } - [JsonProperty("email")] - public string Email { get; set; } - [JsonProperty("firstName")] - public string FirstName { get; set; } - [JsonProperty("index")] - public int Index { get; set; } - [JsonProperty("isLegacy")] - public bool IsLegacy { get; set; } - [JsonProperty("isZoomRoom")] - public bool IsZoomRoom { get; set; } - [JsonProperty("jid")] - public string Jid { get; set; } - [JsonProperty("lastName")] - public string LastName { get; set; } - [JsonProperty("onDesktop")] - public bool OnDesktop { get; set; } - [JsonProperty("onMobile")] - public bool OnMobile { get; set; } - [JsonProperty("phoneNumber")] - public string PhoneNumber { get; set; } - [JsonProperty("presence")] - public ePresence Presence { get; set; } - [JsonProperty("presence_status")] - public int PresenceStatus { get; set; } - [JsonProperty("screenName")] - public string ScreenName { get; set; } - [JsonProperty("sip_phone_number")] - public string SipPhoneNumber { get; set; } - - - public Contact() - { - CloudPbxInfo = new CloudPbxInfo(); - } - } - - public class Phonebook - { - [JsonProperty("Contacts")] - public List Contacts { get; set; } - - public Phonebook() - { - Contacts = new List(); - } - - /// - /// Converts from zStatus.Contact types to generic directory items - /// - /// - public static CodecDirectory ConvertZoomContactsToGeneric(List zoomContacts) - { - var directory = new CodecDirectory(); - - var folders = new List(); - - var roomFolder = new DirectoryFolder(); - - var contactFolder = new DirectoryFolder(); - - var contacts = new List(); - - // Check if there are any zoom rooms - var zoomRooms = zoomContacts.FindAll(c => c.IsZoomRoom); - - if (zoomRooms.Count > 0) - { - // If so, setup a rooms and contacts folder and add them. - - directory.ResultsFolderId = "root"; - - roomFolder.Name = "Rooms"; - roomFolder.ParentFolderId = "root"; - roomFolder.FolderId = "rooms"; - - contactFolder.Name = "Contacts"; - contactFolder.ParentFolderId = "root"; - contactFolder.FolderId = "contacts"; - - folders.Add(roomFolder); - folders.Add(contactFolder); - - directory.AddFoldersToDirectory(folders); - } - - try - { - if (zoomContacts.Count == 0) - { - return directory; - } - - foreach (Contact c in zoomContacts) - { - var contact = new InvitableDirectoryContact { Name = c.ScreenName, ContactId = c.Jid }; - - contact.ContactMethods.Add(new ContactMethod() - { - Number = c.Jid, - Device = eContactMethodDevice.Video, - CallType = eContactMethodCallType.Video, - ContactMethodId = c.Jid - }); - - if (folders.Count > 0) - { - contact.ParentFolderId = c.IsZoomRoom - ? roomFolder.FolderId // "rooms" - : contactFolder.FolderId; // "contacts" - } - - contacts.Add(contact); - } - - directory.AddContactsToDirectory(contacts); - } - catch (Exception e) - { - Debug.Console(1, "Error converting Zoom Phonebook results to generic: {0}", e); - } - - return directory; - } - } - - public enum eCallStatus - { - UNKNOWN, - NOT_IN_MEETING, - CONNECTING_MEETING, - IN_MEETING, - LOGGED_OUT - } - - public class ClosedCaption - { - public bool Available { get; set; } - } - - public class Call : NotifiableObject - { - private eCallStatus _status; - private List _participants; - - public bool IsInCall; - - public eCallStatus Status - { - get - { - return _status; - } - set - { - if (value != _status) - { - _status = value; - IsInCall = _status == eCallStatus.IN_MEETING || _status == eCallStatus.CONNECTING_MEETING; - NotifyPropertyChanged("Status"); - } - } - } - public ClosedCaption ClosedCaption { get; set; } - public List Participants - { - get - { - return _participants; - } - set - { - _participants = value; - NotifyPropertyChanged("Participants"); - } - } - public zEvent.SharingState Sharing { get; set; } - - public CallRecordInfo CallRecordInfo { get; set; } - - private zCommand.InfoResult _info; - - public zCommand.InfoResult Info - { - get - { - return _info; - } - set - { - _info = value; - NotifyPropertyChanged("Info"); - } - } - - public Call() - { - ClosedCaption = new ClosedCaption(); - Participants = new List(); - Sharing = new zEvent.SharingState(); - CallRecordInfo = new CallRecordInfo(); - Info = new zCommand.InfoResult(); - } - } - - public class Capabilities - { - public bool aec_Setting_Stored_In_ZR { get; set; } - public bool can_Dtmf_For_Invite_By_Phone { get; set; } - public bool can_Mute_On_Entry { get; set; } - public bool can_Ringing_In_Pstn_Call { get; set; } - public bool can_Switch_To_Specific_Camera { get; set; } - public bool is_Airhost_Disabled { get; set; } - public bool pstn_Call_In_Local_resentation { get; set; } - public bool support_Claim_Host { get; set; } - public bool support_Out_Room_Display { get; set; } - public bool support_Pin_And_Spotlight { get; set; } - public bool supports_Audio_Checkup { get; set; } - public bool supports_CheckIn { get; set; } - public bool supports_Cloud_PBX { get; set; } - public bool supports_Encrypted_Connection { get; set; } - public bool supports_Expel_User_Permanently { get; set; } - public bool supports_H323_DTMF { get; set; } - public bool supports_Hdmi_Cec_Control { get; set; } - public bool supports_Highly_Reverberant_Room { get; set; } - public bool supports_Loading_Contacts_Dynamically { get; set; } - public bool supports_Loading_Participants_Dynamically { get; set; } - public bool supports_Mic_Record_Test { get; set; } - public bool supports_Multi_Share { get; set; } - public bool supports_ShareCamera { get; set; } - public bool supports_Share_For_Floating_And_Content_Only { get; set; } - public bool supports_Sip_Call_out { get; set; } - public bool supports_Software_Audio_Processing { get; set; } - public bool supports_Web_Settings_Push { get; set; } - } - - public enum eDisplayState - { - None, - Laptop, - IOS, - } - - public class Sharing : NotifiableObject - { - private eDisplayState _dispState; - private string _password; - private bool _isAirHostClientConnected; - private bool _isSharingBlackMagic; - private bool _isDirectPresentationConnected; - private bool _isBlackMagicConnected; - - - public string directPresentationPairingCode { get; set; } - /// - /// Laptop client sharing key - /// - public string directPresentationSharingKey { get; set; } - public eDisplayState dispState - { - get - { - return _dispState; - } - set - { - if (value != _dispState) - { - _dispState = value; - NotifyPropertyChanged("dispState"); - } - } - } - - public bool isAirHostClientConnected - { - get { return _isAirHostClientConnected; } - set - { - if (value != _isAirHostClientConnected) - { - _isAirHostClientConnected = value; - NotifyPropertyChanged("isAirHostClientConnected"); - } - } - } - - public bool isBlackMagicConnected - { - get { return _isBlackMagicConnected; } - set - { - if (value != _isBlackMagicConnected) - { - _isBlackMagicConnected = value; - NotifyPropertyChanged("isBlackMagicConnected"); - } - } - } - public bool isBlackMagicDataAvailable { get; set; } - - public bool isDirectPresentationConnected - { - get { return _isDirectPresentationConnected; } - set - { - if (value != _isDirectPresentationConnected) - { - _isDirectPresentationConnected = value; - NotifyPropertyChanged("isDirectPresentationConnected"); - } - } - } - - public bool isSharingBlackMagic - { - get { return _isSharingBlackMagic; } - set - { - if (value != _isSharingBlackMagic) - { - _isSharingBlackMagic = value; - NotifyPropertyChanged("isSharingBlackMagic"); - } - } - } - - /// - /// IOS Airplay code - /// - public string password - { - get - { - return _password; - } - set - { - if (value != _password) - { - _password = value; - NotifyPropertyChanged("password"); - } - } - } - public string serverName { get; set; } - public string wifiName { get; set; } - } - - public class NumberOfScreens : NotifiableObject - { - private int _numOfScreens; - - [JsonProperty("NumberOfCECScreens")] - public int NumOfCECScreens { get; set; } - [JsonProperty("NumberOfScreens")] - public int NumOfScreens - { - get - { - return _numOfScreens; - } - set - { - if (value != _numOfScreens) - { - _numOfScreens = value; - NotifyPropertyChanged("NumberOfScreens"); - } - } - } - } - - /// - /// AudioInputLine/AudioOutputLine/VideoCameraLine list item - /// - public class AudioVideoInputOutputLineItem - { - public string Alias { get; set; } - public string Name { get; set; } - public bool Selected { get; set; } - public bool combinedDevice { get; set; } - public string id { get; set; } - public bool manuallySelected { get; set; } - public int numberOfCombinedDevices { get; set; } - public int ptzComId { get; set; } - } - - public class Video - { - public bool Optimizable { get; set; } - } - - public class CameraShare : NotifiableObject - { - private bool _canControlCamera; - private bool _isSharing; - - [JsonProperty("can_Control_Camera")] - public bool CanControlCamera - { - get - { - return _canControlCamera; - } - set - { - if (value != _canControlCamera) - { - _canControlCamera = value; - NotifyPropertyChanged("CanControlCamera"); - } - } - } - public string id { get; set; } - public bool is_Mirrored { get; set; } - [JsonProperty("is_Sharing")] - public bool IsSharing - { - get - { - return _isSharing; - } - set - { - if (value != _isSharing) - { - _isSharing = value; - NotifyPropertyChanged("IsSharing"); - } - } - } - public int pan_Tilt_Speed { get; set; } - - } - - public class Layout : NotifiableObject - { - // backer variables - private bool _can_Switch_Speaker_View; - private bool _can_Switch_Wall_View; - private bool _can_Switch_Strip_View; - private bool _can_Switch_Share_On_All_Screens; - private bool _can_Switch_Floating_Share_Content; - private bool _is_In_First_Page; - private bool _is_In_Last_Page; - private string _video_type; - - - public bool can_Adjust_Floating_Video { get; set; } - - - public bool can_Switch_Floating_Share_Content - { - get - { - return _can_Switch_Floating_Share_Content; - } - set - { - if (value != _can_Switch_Floating_Share_Content) - { - _can_Switch_Floating_Share_Content = value; - NotifyPropertyChanged("can_Switch_Floating_Share_Content"); - } - } - } - - - /// - /// [on/off] // Set to On if it is possible to invoke zConfiguration Call Layout Style: ShareAll, to switch to the ShareAll mode, where the content sharing is shown full screen on all monitors. - /// - [JsonProperty("can_Switch_Share_On_All_Screens")] - public bool can_Switch_Share_On_All_Screens - { - get - { - return _can_Switch_Share_On_All_Screens; - } - set - { - if (value != _can_Switch_Share_On_All_Screens) - { - _can_Switch_Share_On_All_Screens = value; - NotifyPropertyChanged("can_Switch_Share_On_All_Screens"); - } - } - } - - /// - /// [on/off] // Set to On if it is possible to switch to Speaker view by invoking zConfiguration Call Layout Style: Speaker. The active speaker is shown full screen, and other video streams, like self-view, are shown in thumbnails. - /// - [JsonProperty("can_Switch_Speaker_View")] - public bool can_Switch_Speaker_View - { - get - { - return _can_Switch_Speaker_View; - } - set - { - if (value != _can_Switch_Speaker_View) - { - _can_Switch_Speaker_View = value; - NotifyPropertyChanged("can_Switch_Speaker_View"); - } - } - } - - /// - /// [on/off] On if it is possible to invoke zConfiguration Call Layout Style: Gallery, to switch to the Gallery mode, showing video participants in tiled windows: The Zoom Room shows up to a 5x5 array of tiled windows per page. - /// - [JsonProperty("can_Switch_Wall_View")] - public bool can_Switch_Wall_View - { - get - { - return _can_Switch_Wall_View; - } - set - { - if (value != _can_Switch_Wall_View) - { - _can_Switch_Wall_View = value; - NotifyPropertyChanged("can_Switch_Wall_View"); - } - } - } - - [JsonProperty("can_Switch_Strip_View")] - public bool can_Switch_Strip_View - { - get - { - return _can_Switch_Strip_View; - } - set - { - if (value != _can_Switch_Strip_View) - { - _can_Switch_Strip_View = value; - NotifyPropertyChanged("can_Switch_Strip_View"); - } - } - } - - [JsonProperty("is_In_First_Page")] - public bool is_In_First_Page - { - get - { - return _is_In_First_Page; - } - set - { - if (value != _is_In_First_Page) - { - _is_In_First_Page = value; - NotifyPropertyChanged("is_In_First_Page"); - } - } - } - - [JsonProperty("is_In_Last_Page")] - public bool is_In_Last_Page - { - get - { - return _is_In_Last_Page; - } - set - { - if (value != _is_In_Last_Page) - { - _is_In_Last_Page = value; - NotifyPropertyChanged("is_In_Last_Page"); - } - } - } - - public bool is_supported { get; set; } - public int video_Count_In_Current_Page { get; set; } - - /// - /// [Gallery | Strip] Indicates which mode applies: Strip or Gallery. - /// - [JsonProperty("video_type")] - public string video_type - { - get - { - return _video_type; - } - set - { - if (value != _video_type) - { - _video_type = value; - NotifyPropertyChanged("video_type"); - } - } - } - } - - public class CallRecordInfo : NotifiableObject - { - private bool _meetingIsBeingRecorded; - private bool _canRecord; - private bool _emailRequired; - - public bool amIRecording { get; set; } - - public bool canRecord - { - get - { - return _canRecord; - } - set - { - if (value != _canRecord) - { - _canRecord = value; - NotifyPropertyChanged("canRecord"); - } - } - } - - public bool emailRequired - { - get - { - return _emailRequired; - } - set - { - if (value != _emailRequired) - { - _emailRequired = value; - NotifyPropertyChanged("emailRequired"); - } - } - } - - public bool meetingIsBeingRecorded - { - get - { - return _meetingIsBeingRecorded; - } - set - { - //Debug.Console(2, "************************************setting value of meetingIsBeingRecorded to: {0}", value); - if (value != _meetingIsBeingRecorded) - { - _meetingIsBeingRecorded = value; - //Debug.Console(2, "********************************set value of meetingIsBeingRecorded to: {0}", _meetingIsBeingRecorded); - NotifyPropertyChanged("meetingIsBeingRecorded"); - } - } - } - - /// - /// Indicates if recording is allowed (when meeting capable and and email is not required to be entered by the user) - /// - public bool AllowRecord - { - get - { - return canRecord && !emailRequired; - } - } - - public CallRecordInfo() - { - Debug.Console(2, Debug.ErrorLogLevel.Notice, "********************************************* CallRecordInfo() ******************************************"); - } - } - } - - /// - /// zEvent Class Structure - /// - public class zEvent - { - public class StartLocalPresentMeeting - { - public bool Success { get; set; } - } - public class NeedWaitForHost - { - public bool Wait { get; set; } - } - - public class IncomingCallIndication - { - public string callerJID { get; set; } - public string calleeJID { get; set; } - public string meetingID { get; set; } - public string password { get; set; } - public string meetingOption { get; set; } - public long MeetingNumber { get; set; } - public string callerName { get; set; } - public string avatarURL { get; set; } - public int lifeTime { get; set; } - public bool accepted { get; set; } - } - - public class CallConnectError - { - public int error_code { get; set; } - public string error_message { get; set; } - } - - public class CallDisconnect - { - public bool Successful - { - get - { - return success == "on"; - } - } - - public string success { get; set; } - } - - public class Layout - { - public bool Sharethumb { get; set; } - } - - public class Call - { - public Layout Layout { get; set; } - } - - public class Client - { - public Call Call { get; set; } - } - - public enum eSharingState - { - None, - Connecting, - Sending, - Receiving, - Send_Receiving - } - - public class SharingState : NotifiableObject - { - private bool _paused; - private eSharingState _state; - - public bool IsSharing { get; private set; } - - [JsonProperty("paused")] - public bool Paused - { - get - { - return _paused; - } - set - { - if (value != _paused) - { - _paused = value; - NotifyPropertyChanged("Paused"); - } - } - } - [JsonProperty("state")] - public eSharingState State - { - get - { - return _state; - } - set - { - if (value != _state) - { - _state = value; - IsSharing = _state == eSharingState.Sending; - NotifyPropertyChanged("State"); - } - } - } - } - - public class PinStatusOfScreenNotification - { - - - [JsonProperty("can_be_pinned")] - public bool CanBePinned { get; set; } - [JsonProperty("can_pin_share")] - public bool CanPinShare { get; set; } - [JsonProperty("pinned_share_source_id")] - public int PinnedShareSourceId { get; set; } - [JsonProperty("pinned_user_id")] - public int PinnedUserId { get; set; } - [JsonProperty("screen_index")] - public int ScreenIndex { get; set; } - [JsonProperty("screen_layout")] - public int ScreenLayout { get; set; } - [JsonProperty("share_source_type")] - public int ShareSourceType { get; set; } - [JsonProperty("why_cannot_pin_share")] - public string WhyCannotPinShare { get; set; } - } - - public class PhoneCallStatus : NotifiableObject - { - private bool _isIncomingCall; - private string _peerDisplayName; - private string _peerNumber; - - private bool _offHook; - - public string CallId { get; set; } - public bool IsIncomingCall - { - get { return _isIncomingCall; } - set - { - if (value == _isIncomingCall) return; - - _isIncomingCall = value; - NotifyPropertyChanged("IsIncomingCall"); - } - } - - public string PeerDisplayName - { - get { return _peerDisplayName; } - set - { - if (value == _peerDisplayName) return; - _peerDisplayName = value; - NotifyPropertyChanged("PeerDisplayName"); - } - } - - public string PeerNumber - { - get { return _peerNumber; } - set - { - if (value == _peerNumber) return; - - _peerNumber = value; - NotifyPropertyChanged("PeerNumber"); - } - } - - public string PeerUri { get; set; } - - private ePhoneCallStatus _status; - public ePhoneCallStatus Status - { - get { return _status; } - set - { - _status = value; - OffHook = _status == ePhoneCallStatus.PhoneCallStatus_Accepted || - _status == ePhoneCallStatus.PhoneCallStatus_InCall || - _status == ePhoneCallStatus.PhoneCallStatus_Init || - _status == ePhoneCallStatus.PhoneCallStatus_Ringing; - } - } - - public bool OffHook - { - get { return _offHook; } - set - { - if (value == _offHook) return; - - _offHook = value; - NotifyPropertyChanged("OffHook"); - } - } - } - - public enum ePhoneCallStatus - { - PhoneCallStatus_Ringing, - PhoneCallStatus_Terminated, - PhoneCallStatus_Accepted, - PhoneCallStatus_InCall, - PhoneCallStatus_Init, - } - - public class MeetingNeedsPassword - { - [JsonProperty("needsPassword")] - public bool NeedsPassword { get; set; } - - [JsonProperty("wrongAndRetry")] - public bool WrongAndRetry { get; set; } - } - } - - /// - /// zConfiguration class structure - /// - public class zConfiguration - { - public class Sharing - { - [JsonProperty("optimize_video_sharing")] - public bool OptimizeVideoSharing { get; set; } - } - - public class Camera : NotifiableObject - { - private bool _mute; - - public bool Mute - { - get { return _mute; } - set - { - Debug.Console(1, "Camera Mute response received: {0}", value); - - if (value == _mute) return; - - _mute = value; - NotifyPropertyChanged("Mute"); - } - } - } - - public class Microphone : NotifiableObject - { - private bool _mute; - - public bool Mute - { - get - { - return _mute; - } - set - { - if (value != _mute) - { - _mute = value; - NotifyPropertyChanged("Mute"); - } - } - } - } - - [Flags] - public enum eLayoutStyle - { - None = 0, - Gallery = 1, - Speaker = 2, - Strip = 4, - ShareAll = 8, - } - - public enum eLayoutSize - { - Off, - Size1, - Size2, - Size3, - Strip - } - - public enum eLayoutPosition - { - Center, - Up, - Right, - UpRight, - Down, - DownRight, - Left, - UpLeft, - DownLeft - } - - public class Layout : NotifiableObject - { - private bool _shareThumb; - private eLayoutStyle _style; - private eLayoutSize _size; - private eLayoutPosition _position; - - public bool ShareThumb - { - get { return _shareThumb; } - set - { - if (value != _shareThumb) - { - _shareThumb = value; - NotifyPropertyChanged("ShareThumb"); - } - } - } - - public eLayoutStyle Style - { - get { return _style; } - set - { - if (value != _style) - { - _style = value; - NotifyPropertyChanged("Style"); - } - } - } - - public eLayoutSize Size - { - get { return _size; } - set - { - if (value != _size) - { - _size = value; - NotifyPropertyChanged("Size"); - } - } - } - - public eLayoutPosition Position - { - get { return _position; } - set - { - if (value != _position) - { - _position = value; - NotifyPropertyChanged("Position"); - } - } - } - } - - public class Lock : NotifiableObject - { - private bool _enable; - - public bool Enable - { - get - { - return _enable; - } - set - { - if (value != _enable) - { - _enable = value; - NotifyPropertyChanged("Enable"); - } - } - } - } - - public class ClosedCaption - { - public bool Visible { get; set; } - public int FontSize { get; set; } - } - - public class MuteUserOnEntry - { - public bool Enable { get; set; } - } - - public class Call - { - public Sharing Sharing { get; set; } - public Camera Camera { get; set; } - public Microphone Microphone { get; set; } - public Layout Layout { get; set; } - public Lock Lock { get; set; } - public MuteUserOnEntry MuteUserOnEntry { get; set; } - public ClosedCaption ClosedCaption { get; set; } - - - public Call() - { - Sharing = new Sharing(); - Camera = new Camera(); - Microphone = new Microphone(); - Layout = new Layout(); - Lock = new Lock(); - MuteUserOnEntry = new MuteUserOnEntry(); - ClosedCaption = new ClosedCaption(); - } - } - - public class Audio - { - public Input Input { get; set; } - public Output Output { get; set; } - - public Audio() - { - Input = new Input(); - Output = new Output(); - } - } - - public class Input : Output - { - [JsonProperty("reduce_reverb")] - public bool ReduceReverb { get; set; } - } - - public class Output : NotifiableObject - { - private int _volume; - - [JsonProperty("volume")] - public int Volume - { - get - { - return _volume; - } - set - { - if (value != _volume) - { - _volume = value; - NotifyPropertyChanged("Volume"); - } - } - } - [JsonProperty("selectedId")] - public string SelectedId { get; set; } - [JsonProperty("is_sap_disabled")] - public bool IsSapDisabled { get; set; } - } - - public class Video : NotifiableObject - { - private bool _hideConfSelfVideo; - - [JsonProperty("hide_conf_self_video")] - public bool HideConfSelfVideo - { - get - { - return _hideConfSelfVideo; - } - set - { - //if (value != _hideConfSelfVideo) - //{ - _hideConfSelfVideo = value; - NotifyPropertyChanged("HideConfSelfVideo"); - //} - } - } - - public VideoCamera Camera { get; set; } - - public Video() - { - Camera = new VideoCamera(); - } - } - - public class VideoCamera : NotifiableObject - { - private string _selectedId; - - [JsonProperty("selectedId")] - public string SelectedId - { - get - { - return _selectedId; - } - set - { - if (value != _selectedId) - { - _selectedId = value; - NotifyPropertyChanged("SelectedId"); - } - } - - } - public bool Mirror { get; set; } - } - - public class Client - { - public string appVersion { get; set; } - public string deviceSystem { get; set; } - - // This doesn't belong here, but there's a bug in the object structure of Zoom Room 5.6.3 that puts it here - public zConfiguration.Call Call { get; set; } - - public Client() - { - Call = new zConfiguration.Call(); - } - } - - } - - /// - /// zCommand class structure - /// - public class zCommand - { - public class BookingsListResult - { - [JsonProperty("accessRole")] - public string AccessRole { get; set; } - [JsonProperty("calendarChangeKey")] - public string CalendarChangeKey { get; set; } - [JsonProperty("calendarID")] - public string CalendarId { get; set; } - [JsonProperty("checkIn")] - public bool CheckIn { get; set; } - [JsonProperty("creatorEmail")] - public string CreatorEmail { get; set; } - [JsonProperty("creatorName")] - public string CreatorName { get; set; } - [JsonProperty("endTime")] - public DateTime EndTime { get; set; } - [JsonProperty("hostName")] - public string HostName { get; set; } - [JsonProperty("isInstantMeeting")] - public bool IsInstantMeeting { get; set; } - [JsonProperty("isPrivate")] - public bool IsPrivate { get; set; } - [JsonProperty("location")] - public string Location { get; set; } - [JsonProperty("meetingName")] - public string MeetingName { get; set; } - [JsonProperty("meetingNumber")] - public string MeetingNumber { get; set; } - [JsonProperty("scheduledFrom")] - public string ScheduledFrom { get; set; } - [JsonProperty("startTime")] - public DateTime StartTime { get; set; } - [JsonProperty("third_party")] - public ThirdParty ThirdParty { get; set; } - } - - public static List GetGenericMeetingsFromBookingResult(List bookings, - int minutesBeforeMeetingStart) - { - var rv = GetGenericMeetingsFromBookingResult(bookings); - - foreach (var meeting in rv) - { - meeting.MinutesBeforeMeeting = minutesBeforeMeetingStart; - } - - return rv; - } - /// - /// Extracts the necessary meeting values from the Zoom bookings response and converts them to the generic class - /// - /// - /// - public static List GetGenericMeetingsFromBookingResult(List bookings) - { - var meetings = new List(); - - if (Debug.Level > 0) - { - Debug.Console(1, "Meetings List:\n"); - } - - foreach (var b in bookings) - { - var meeting = new Meeting(); - - if (b.MeetingNumber != null) - meeting.Id = b.MeetingNumber; - if (b.CreatorName != null) - meeting.Organizer = b.CreatorName; - if (b.MeetingName != null) - meeting.Title = b.MeetingName; - //if (b.Agenda != null) - // meeting.Agenda = b.Agenda.Value; - if (b.StartTime != null) - meeting.StartTime = b.StartTime; - if (b.EndTime != null) - meeting.EndTime = b.EndTime; - - meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; - - // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. - var now = DateTime.Now; - if (meeting.StartTime < now && meeting.EndTime < now) - { - Debug.Console(1, "Skipping meeting {0}. Meeting is in the past.", meeting.Title); - continue; - } - - meetings.Add(meeting); - - if (Debug.Level > 0) - { - Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}", meeting.Title, meeting.Id, meeting.Organizer); - Debug.Console(1, " Start Time: {0}, End Time: {1}, Duration: {2}", meeting.StartTime, meeting.EndTime, meeting.Duration); - Debug.Console(1, " Joinable: {0}\n", meeting.Joinable); - } - } - - meetings.OrderBy(m => m.StartTime); - - return meetings; - } - - public class HandStatus - { - // example return of the "hand_status" object - // !!!! Note the properties contain ': ' within the property name !!! - //"hand_status": { - // "is_raise_hand: ": false, - // "is_valid: ": "on", - // "time_stamp: ": "11825083" - //}, - [JsonProperty("is_raise_hand: ")] - public bool IsRaiseHand { get; set; } - [JsonProperty("is_valid: ")] - public string IsValid { get; set; } - [JsonProperty("time_stamp: ")] - public string TimeStamp { get; set; } - /// - /// Retuns a boolean value if the participant hand state is raised and is valid (both need to be true) - /// - public bool HandIsRaisedAndValid - { - get { return IsValid != null && IsValid == "on" && IsRaiseHand; } - } - } - public class ListParticipant - { - [JsonProperty("audio_status state")] - public string AudioStatusState { get; set; } - [JsonProperty("audio_status type")] - public string AudioStatusType { get; set; } - [JsonProperty("avatar_url")] - public string AvatarUrl { get; set; } - [JsonProperty("camera_status am_i_controlling")] - public bool CameraStatusAmIControlling { get; set; } - [JsonProperty("camera_status can_i_request_control")] - public bool CameraStatusCanIRequestConrol { get; set; } - [JsonProperty("camera_status can_move_camera")] - public bool CameraStatusCanMoveCamera { get; set; } - [JsonProperty("camera_status can_switch_camera")] - public bool CameraStatusCanSwitchCamera { get; set; } - [JsonProperty("camera_status can_zoom_camera")] - public bool CameraStatusCanZoomCamera { get; set; } - [JsonProperty("can_edit_closed_caption")] - public bool CanEditClosedCaption { get; set; } - [JsonProperty("can_record")] - public bool CanRecord { get; set; } - [JsonProperty("event")] - public string Event { get; set; } - [JsonProperty("hand_status")] - public HandStatus HandStatus { get; set; } - [JsonProperty("isCohost")] - public bool IsCohost { get; set; } - [JsonProperty("is_client_support_closed_caption")] - public bool IsClientSupportClosedCaption { get; set; } - [JsonProperty("is_client_support_coHost")] - public bool IsClientSupportCoHost { get; set; } - [JsonProperty("is_host")] - public bool IsHost { get; set; } - [JsonProperty("is_myself")] - public bool IsMyself { get; set; } - [JsonProperty("is_recording")] - public bool IsRecording { get; set; } - [JsonProperty("is_video_can_mute_byHost")] - public bool IsVideoCanMuteByHost { get; set; } - [JsonProperty("is_video_can_unmute_byHost")] - public bool IsVideoCanUnmuteByHost { get; set; } - [JsonProperty("local_recording_disabled")] - public bool LocalRecordingDisabled { get; set; } - [JsonProperty("user_id")] - public int UserId { get; set; } - [JsonProperty("user_name")] - public string UserName { get; set; } - [JsonProperty("user_type")] - public string UserType { get; set; } - [JsonProperty("video_status has_source")] - public bool VideoStatusHasSource { get; set; } - [JsonProperty("video_status is_receiving")] - public bool VideoStatusIsReceiving { get; set; } - [JsonProperty("video_status is_sending")] - public bool VideoStatusIsSending { get; set; } - - public ListParticipant() - { - HandStatus = new HandStatus(); - } - - /// - /// Converts ZoomRoom pariticpant list response to an Essentials participant list - /// - /// - /// - public static List GetGenericParticipantListFromParticipantsResult( - List participants) - { - if (participants.Count == 0) - { - return new List(); - } - //return participants.Select(p => new Participant - // { - // UserId = p.UserId, - // Name = p.UserName, - // IsHost = p.IsHost, - // CanMuteVideo = p.IsVideoCanMuteByHost, - // CanUnmuteVideo = p.IsVideoCanUnmuteByHost, - // AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", - // VideoMuteFb = p.VideoStatusIsSending, - // HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, - // }).ToList(); - - var sortedParticipants = SortParticipantListByHandStatus(participants); - return sortedParticipants.Select(p => new Participant - { - UserId = p.UserId, - Name = p.UserName, - IsHost = p.IsHost, - IsMyself = p.IsMyself, - CanMuteVideo = p.IsVideoCanMuteByHost, - CanUnmuteVideo = p.IsVideoCanUnmuteByHost, - AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", - VideoMuteFb = !p.VideoStatusIsSending, - HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, - }).ToList(); - } - - /// - /// Will sort by hand-raise status and then alphabetically - /// - /// Zoom Room response list of participants - /// List - public static List SortParticipantListByHandStatus(List participants) - { - if (participants == null) - { - //Debug.Console(1, "SortParticiapntListByHandStatu(participants == null)"); - return null; - } - - // debug testing - //foreach (ListParticipant participant in participants) - //{ - // Debug.Console(1, "{0} | IsValid: {1} | IsRaiseHand: {2} | HandIsRaisedAndValid: {3}", - // participant.UserName, participant.HandStatus.IsValid, participant.HandStatus.IsRaiseHand.ToString(), participant.HandStatus.HandIsRaisedAndValid.ToString()); - //} - - List handRaisedParticipantsList = participants.Where(p => p.HandStatus.HandIsRaisedAndValid).ToList(); - - if (handRaisedParticipantsList != null) - { - IOrderedEnumerable orderByDescending = handRaisedParticipantsList.OrderByDescending(p => p.HandStatus.TimeStamp); - - //foreach (var participant in handRaisedParticipantsList) - // Debug.Console(1, "handRaisedParticipantList: {0} | {1}", participant.UserName, participant.UserId); - } - - List allOtherParticipantsList = participants.Where(p => !p.HandStatus.HandIsRaisedAndValid).ToList(); - - if (allOtherParticipantsList != null) - { - allOtherParticipantsList.OrderBy(p => p.UserName); - - //foreach (var participant in allOtherParticipantsList) - // Debug.Console(1, "allOtherParticipantsList: {0} | {1}", participant.UserName, participant.UserId); - } - - // merge the lists - List sortedList = handRaisedParticipantsList.Union(allOtherParticipantsList).ToList(); - - // return the sorted list - return sortedList; - } - - } - - public class CallinCountryList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class CalloutCountryList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class TollFreeCallinList - { - public int code { get; set; } - public string display_number { get; set; } - public string id { get; set; } - public string name { get; set; } - public string number { get; set; } - } - - public class Info - { - public List callin_country_list { get; set; } - public List callout_country_list { get; set; } - public List toll_free_callin_list { get; set; } - } - - public class ThirdParty - { - public string h323_address { get; set; } - public string meeting_number { get; set; } - public string service_provider { get; set; } - public string sip_address { get; set; } - } - - public class MeetingListItem - { - public string accessRole { get; set; } - public string calendarChangeKey { get; set; } - public string calendarID { get; set; } - public bool checkIn { get; set; } - public string creatorEmail { get; set; } - public string creatorName { get; set; } - public string endTime { get; set; } - public string hostName { get; set; } - public bool isInstantMeeting { get; set; } - public bool isPrivate { get; set; } - public string location { get; set; } - public string meetingName { get; set; } - public string meetingNumber { get; set; } - public string scheduledFrom { get; set; } - public string startTime { get; set; } - public ThirdParty third_party { get; set; } - - public MeetingListItem() - { - third_party = new ThirdParty(); - } - } - - public class InfoResult - { - public Info Info { get; set; } - public bool am_i_original_host { get; set; } - public string default_callin_country { get; set; } - public string dialIn { get; set; } - public string international_url { get; set; } - public string invite_email_content { get; set; } - public string invite_email_subject { get; set; } - public bool is_callin_country_list_available { get; set; } - public bool is_calling_room_system_enabled { get; set; } - public bool is_toll_free_callin_list_available { get; set; } - public bool is_view_only { get; set; } - public bool is_waiting_room { get; set; } - public bool is_webinar { get; set; } - public string meeting_id { get; set; } - public MeetingListItem meeting_list_item { get; set; } - public string meeting_password { get; set; } - public string meeting_type { get; set; } - public int my_userid { get; set; } - public int participant_id { get; set; } - public string real_meeting_id { get; set; } - public string schedule_option { get; set; } - public string schedule_option2 { get; set; } - public string support_callout_type { get; set; } - public string toll_free_number { get; set; } - public string user_type { get; set; } - - public InfoResult() - { - Info = new Info(); - meeting_list_item = new MeetingListItem(); - } - } - - public class Phonebook - { - public List Contacts { get; set; } - public int Limit { get; set; } - public int Offset { get; set; } - } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ShareInfoEventArgs.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ShareInfoEventArgs.cs new file mode 100644 index 00000000..4701ff5b --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ShareInfoEventArgs.cs @@ -0,0 +1,14 @@ +using System; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ShareInfoEventArgs : EventArgs + { + public zStatus.Sharing SharingStatus { get; private set; } + + public ShareInfoEventArgs(zStatus.Sharing status) + { + SharingStatus = status; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Status.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Status.cs new file mode 100644 index 00000000..23a0a638 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/Status.cs @@ -0,0 +1,13 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class Status + { + [JsonProperty("message")] + public string Message { get; set; } + [JsonProperty("state")] + public string State { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoom.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoom.cs index a9c6c0f2..16ffc31c 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoom.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoom.cs @@ -3695,249 +3695,4 @@ status.dispState); #endregion } - - /// - /// Zoom Room specific info object - /// - public class ZoomRoomInfo : VideoCodecInfo - { - public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) - { - Status = status; - Configuration = configuration; - } - - [JsonIgnore] - public ZoomRoomStatus Status { get; private set; } - [JsonIgnore] - public ZoomRoomConfiguration Configuration { get; private set; } - - public override bool AutoAnswerEnabled - { - get { return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; } - } - - public override string E164Alias - { - get - { - if (!string.IsNullOrEmpty(Status.SystemUnit.MeetingNumber)) - { - return Status.SystemUnit.MeetingNumber; - } - return string.Empty; - } - } - - public override string H323Id - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.h323_address)) - { - return Status.Call.Info.meeting_list_item.third_party.h323_address; - } - return string.Empty; - } - } - - public override string IpAddress - { - get - { - if (!string.IsNullOrEmpty(Status.SystemUnit.RoomInfo.AccountEmail)) - { - return Status.SystemUnit.RoomInfo.AccountEmail; - } - return string.Empty; - } - } - - public override bool MultiSiteOptionIsEnabled - { - get { return true; } - } - - public override string SipPhoneNumber - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.dialIn)) - { - return Status.Call.Info.dialIn; - } - return string.Empty; - } - } - - public override string SipUri - { - get - { - if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.sip_address)) - { - return Status.Call.Info.meeting_list_item.third_party.sip_address; - } - return string.Empty; - } - } - } - - /// - /// Tracks the initial sycnronization state when establishing a new connection - /// - public class ZoomRoomSyncState : IKeyed - { - private readonly ZoomRoom _parent; - private readonly CrestronQueue _syncQueries; - private bool _initialSyncComplete; - - public ZoomRoomSyncState(string key, ZoomRoom parent) - { - _parent = parent; - Key = key; - _syncQueries = new CrestronQueue(50); - CodecDisconnected(); - } - - public bool InitialSyncComplete - { - get { return _initialSyncComplete; } - private set - { - if (value) - { - var handler = InitialSyncCompleted; - if (handler != null) - { - handler(this, new EventArgs()); - } - } - _initialSyncComplete = value; - } - } - - public bool LoginResponseWasReceived { get; private set; } - - public bool FirstJsonResponseWasReceived { get; private set; } - - public bool InitialQueryMessagesWereSent { get; private set; } - - public bool LastQueryResponseWasReceived { get; private set; } - - public bool CamerasHaveBeenSetUp { get; private set; } - - #region IKeyed Members - - public string Key { get; private set; } - - #endregion - - public event EventHandler InitialSyncCompleted; - - public event EventHandler FirstJsonResponseReceived; - - public void StartSync() - { - DequeueQueries(); - } - - private void DequeueQueries() - { - while (!_syncQueries.IsEmpty) - { - var query = _syncQueries.Dequeue(); - - _parent.SendText(query); - } - - InitialQueryMessagesSent(); - } - - public void AddQueryToQueue(string query) - { - _syncQueries.Enqueue(query); - } - - public void LoginResponseReceived() - { - LoginResponseWasReceived = true; - Debug.Console(1, this, "Login Rsponse Received."); - CheckSyncStatus(); - } - - public void ReceivedFirstJsonResponse() - { - FirstJsonResponseWasReceived = true; - Debug.Console(1, this, "First JSON Response Received."); - - var handler = FirstJsonResponseReceived; - if (handler != null) - { - handler(this, null); - } - CheckSyncStatus(); - } - - public void InitialQueryMessagesSent() - { - InitialQueryMessagesWereSent = true; - Debug.Console(1, this, "Query Messages Sent."); - CheckSyncStatus(); - } - - public void LastQueryResponseReceived() - { - LastQueryResponseWasReceived = true; - Debug.Console(1, this, "Last Query Response Received."); - CheckSyncStatus(); - } - - public void CamerasSetUp() - { - CamerasHaveBeenSetUp = true; - Debug.Console(1, this, "Cameras Set Up."); - CheckSyncStatus(); - } - - public void CodecDisconnected() - { - _syncQueries.Clear(); - LoginResponseWasReceived = false; - FirstJsonResponseWasReceived = false; - InitialQueryMessagesWereSent = false; - LastQueryResponseWasReceived = false; - CamerasHaveBeenSetUp = false; - InitialSyncComplete = false; - } - - private void CheckSyncStatus() - { - if (LoginResponseWasReceived && FirstJsonResponseWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && - CamerasHaveBeenSetUp) - { - InitialSyncComplete = true; - Debug.Console(1, this, "Initial Codec Sync Complete!"); - } - else - { - InitialSyncComplete = false; - } - } - } - - public class ZoomRoomFactory : EssentialsDeviceFactory - { - public ZoomRoomFactory() - { - TypeNames = new List {"zoomroom"}; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new ZoomRoom Device"); - var comm = CommFactory.CreateCommForDevice(dc); - return new ZoomRoom(dc, comm); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs index bb0abeea..bed9733d 100644 --- a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomCamera.cs @@ -13,27 +13,6 @@ using Full.Newtonsoft.Json; namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom { - public enum eZoomRoomCameraState - { - Start, - Continue, - Stop, - RequestRemote, - GiveupRemote, - RequestedByFarEnd - } - - public enum eZoomRoomCameraAction - { - Left, - Right, - Up, - Down, - In, - Out - } - - public class ZoomRoomCamera : CameraBase, IHasCameraPtzControl, IBridgeAdvanced { protected ZoomRoom ParentCodec { get; private set; } @@ -217,15 +196,4 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); } } - - public class ZoomRoomFarEndCamera : ZoomRoomCamera, IAmFarEndCamera - { - - public ZoomRoomFarEndCamera(string key, string name, ZoomRoom codec, int id) - : base(key, name, codec) - { - Id = id; - } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomConfiguration.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomConfiguration.cs new file mode 100644 index 00000000..cde841a7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomConfiguration.cs @@ -0,0 +1,23 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// Used to track the current configuration of a ZoomRoom + /// + public class ZoomRoomConfiguration + { + public zConfiguration.Call Call { get; set; } + public zConfiguration.Audio Audio { get; set; } + public zConfiguration.Video Video { get; set; } + public zConfiguration.Client Client { get; set; } + public zConfiguration.Camera Camera { get; set; } + + public ZoomRoomConfiguration() + { + Call = new zConfiguration.Call(); + Audio = new zConfiguration.Audio(); + Video = new zConfiguration.Video(); + Client = new zConfiguration.Client(); + Camera = new zConfiguration.Camera(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFactory.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFactory.cs new file mode 100644 index 00000000..2aeb80f9 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFactory.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ZoomRoomFactory : EssentialsDeviceFactory + { + public ZoomRoomFactory() + { + TypeNames = new List {"zoomroom"}; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new ZoomRoom Device"); + var comm = CommFactory.CreateCommForDevice(dc); + return new ZoomRoom(dc, comm); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFarEndCamera.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFarEndCamera.cs new file mode 100644 index 00000000..938475e5 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomFarEndCamera.cs @@ -0,0 +1,15 @@ +using PepperDash.Essentials.Devices.Common.Cameras; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public class ZoomRoomFarEndCamera : ZoomRoomCamera, IAmFarEndCamera + { + + public ZoomRoomFarEndCamera(string key, string name, ZoomRoom codec, int id) + : base(key, name, codec) + { + Id = id; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomInfo.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomInfo.cs new file mode 100644 index 00000000..e0f5d0c3 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomInfo.cs @@ -0,0 +1,93 @@ +extern alias Full; +using Full::Newtonsoft.Json; +using PepperDash.Essentials.Devices.Common.Codec; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// Zoom Room specific info object + /// + public class ZoomRoomInfo : VideoCodecInfo + { + public ZoomRoomInfo(ZoomRoomStatus status, ZoomRoomConfiguration configuration) + { + Status = status; + Configuration = configuration; + } + + [JsonIgnore] + public ZoomRoomStatus Status { get; private set; } + [JsonIgnore] + public ZoomRoomConfiguration Configuration { get; private set; } + + public override bool AutoAnswerEnabled + { + get { return Status.SystemUnit.RoomInfo.AutoAnswerIsEnabled; } + } + + public override string E164Alias + { + get + { + if (!string.IsNullOrEmpty(Status.SystemUnit.MeetingNumber)) + { + return Status.SystemUnit.MeetingNumber; + } + return string.Empty; + } + } + + public override string H323Id + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.h323_address)) + { + return Status.Call.Info.meeting_list_item.third_party.h323_address; + } + return string.Empty; + } + } + + public override string IpAddress + { + get + { + if (!string.IsNullOrEmpty(Status.SystemUnit.RoomInfo.AccountEmail)) + { + return Status.SystemUnit.RoomInfo.AccountEmail; + } + return string.Empty; + } + } + + public override bool MultiSiteOptionIsEnabled + { + get { return true; } + } + + public override string SipPhoneNumber + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.dialIn)) + { + return Status.Call.Info.dialIn; + } + return string.Empty; + } + } + + public override string SipUri + { + get + { + if (!string.IsNullOrEmpty(Status.Call.Info.meeting_list_item.third_party.sip_address)) + { + return Status.Call.Info.meeting_list_item.third_party.sip_address; + } + return string.Empty; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomStatus.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomStatus.cs new file mode 100644 index 00000000..f8afebc6 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomStatus.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// Used to track the current status of a ZoomRoom + /// + public class ZoomRoomStatus + { + public zStatus.Login Login { get; set; } + public zStatus.SystemUnit SystemUnit { get; set; } + public zStatus.Phonebook Phonebook { get; set; } + public zStatus.Call Call { get; set; } + public zStatus.Capabilities Capabilities { get; set; } + public zStatus.Sharing Sharing { get; set; } + public zStatus.NumberOfScreens NumberOfScreens { get; set; } + public zStatus.Layout Layout { get; set; } + public zStatus.Video Video { get; set; } + public zStatus.CameraShare CameraShare { get; set; } + public List AudioInputs { get; set; } + public List AudioOuputs { get; set; } + public List Cameras { get; set; } + public zEvent.PhoneCallStatus PhoneCall { get; set; } + public zEvent.NeedWaitForHost NeedWaitForHost { get; set; } + + public ZoomRoomStatus() + { + Login = new zStatus.Login(); + SystemUnit = new zStatus.SystemUnit(); + Phonebook = new zStatus.Phonebook(); + Call = new zStatus.Call(); + Capabilities = new zStatus.Capabilities(); + Sharing = new zStatus.Sharing(); + NumberOfScreens = new zStatus.NumberOfScreens(); + Layout = new zStatus.Layout(); + Video = new zStatus.Video(); + CameraShare = new zStatus.CameraShare(); + AudioInputs = new List(); + AudioOuputs = new List(); + Cameras = new List(); + PhoneCall = new zEvent.PhoneCallStatus(); + NeedWaitForHost = new zEvent.NeedWaitForHost(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomSyncState.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomSyncState.cs new file mode 100644 index 00000000..c5161aa7 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/ZoomRoomSyncState.cs @@ -0,0 +1,149 @@ +using System; +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// Tracks the initial sycnronization state when establishing a new connection + /// + public class ZoomRoomSyncState : IKeyed + { + private readonly ZoomRoom _parent; + private readonly CrestronQueue _syncQueries; + private bool _initialSyncComplete; + + public ZoomRoomSyncState(string key, ZoomRoom parent) + { + _parent = parent; + Key = key; + _syncQueries = new CrestronQueue(50); + CodecDisconnected(); + } + + public bool InitialSyncComplete + { + get { return _initialSyncComplete; } + private set + { + if (value) + { + var handler = InitialSyncCompleted; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + _initialSyncComplete = value; + } + } + + public bool LoginResponseWasReceived { get; private set; } + + public bool FirstJsonResponseWasReceived { get; private set; } + + public bool InitialQueryMessagesWereSent { get; private set; } + + public bool LastQueryResponseWasReceived { get; private set; } + + public bool CamerasHaveBeenSetUp { get; private set; } + + #region IKeyed Members + + public string Key { get; private set; } + + #endregion + + public event EventHandler InitialSyncCompleted; + + public event EventHandler FirstJsonResponseReceived; + + public void StartSync() + { + DequeueQueries(); + } + + private void DequeueQueries() + { + while (!_syncQueries.IsEmpty) + { + var query = _syncQueries.Dequeue(); + + _parent.SendText(query); + } + + InitialQueryMessagesSent(); + } + + public void AddQueryToQueue(string query) + { + _syncQueries.Enqueue(query); + } + + public void LoginResponseReceived() + { + LoginResponseWasReceived = true; + Debug.Console(1, this, "Login Rsponse Received."); + CheckSyncStatus(); + } + + public void ReceivedFirstJsonResponse() + { + FirstJsonResponseWasReceived = true; + Debug.Console(1, this, "First JSON Response Received."); + + var handler = FirstJsonResponseReceived; + if (handler != null) + { + handler(this, null); + } + CheckSyncStatus(); + } + + public void InitialQueryMessagesSent() + { + InitialQueryMessagesWereSent = true; + Debug.Console(1, this, "Query Messages Sent."); + CheckSyncStatus(); + } + + public void LastQueryResponseReceived() + { + LastQueryResponseWasReceived = true; + Debug.Console(1, this, "Last Query Response Received."); + CheckSyncStatus(); + } + + public void CamerasSetUp() + { + CamerasHaveBeenSetUp = true; + Debug.Console(1, this, "Cameras Set Up."); + CheckSyncStatus(); + } + + public void CodecDisconnected() + { + _syncQueries.Clear(); + LoginResponseWasReceived = false; + FirstJsonResponseWasReceived = false; + InitialQueryMessagesWereSent = false; + LastQueryResponseWasReceived = false; + CamerasHaveBeenSetUp = false; + InitialSyncComplete = false; + } + + private void CheckSyncStatus() + { + if (LoginResponseWasReceived && FirstJsonResponseWasReceived && InitialQueryMessagesWereSent && LastQueryResponseWasReceived && + CamerasHaveBeenSetUp) + { + InitialSyncComplete = true; + Debug.Console(1, this, "Initial Codec Sync Complete!"); + } + else + { + InitialSyncComplete = false; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraAction.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraAction.cs new file mode 100644 index 00000000..2ae95b5f --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraAction.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public enum eZoomRoomCameraAction + { + Left, + Right, + Up, + Down, + In, + Out + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraState.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraState.cs new file mode 100644 index 00000000..5e6c56d9 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomCameraState.cs @@ -0,0 +1,12 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public enum eZoomRoomCameraState + { + Start, + Continue, + Stop, + RequestRemote, + GiveupRemote, + RequestedByFarEnd + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomResponseType.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomResponseType.cs new file mode 100644 index 00000000..6f86ca9d --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/eZoomRoomResponseType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + public enum eZoomRoomResponseType + { + zEvent, + zStatus, + zConfiguration, + zCommand + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zCommand.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zCommand.cs new file mode 100644 index 00000000..01d802d9 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zCommand.cs @@ -0,0 +1,403 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using System.Linq; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Devices.Common.Codec; +using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// zCommand class structure + /// + public class zCommand + { + public class BookingsListResult + { + [JsonProperty("accessRole")] + public string AccessRole { get; set; } + [JsonProperty("calendarChangeKey")] + public string CalendarChangeKey { get; set; } + [JsonProperty("calendarID")] + public string CalendarId { get; set; } + [JsonProperty("checkIn")] + public bool CheckIn { get; set; } + [JsonProperty("creatorEmail")] + public string CreatorEmail { get; set; } + [JsonProperty("creatorName")] + public string CreatorName { get; set; } + [JsonProperty("endTime")] + public DateTime EndTime { get; set; } + [JsonProperty("hostName")] + public string HostName { get; set; } + [JsonProperty("isInstantMeeting")] + public bool IsInstantMeeting { get; set; } + [JsonProperty("isPrivate")] + public bool IsPrivate { get; set; } + [JsonProperty("location")] + public string Location { get; set; } + [JsonProperty("meetingName")] + public string MeetingName { get; set; } + [JsonProperty("meetingNumber")] + public string MeetingNumber { get; set; } + [JsonProperty("scheduledFrom")] + public string ScheduledFrom { get; set; } + [JsonProperty("startTime")] + public DateTime StartTime { get; set; } + [JsonProperty("third_party")] + public ThirdParty ThirdParty { get; set; } + } + + public static List GetGenericMeetingsFromBookingResult(List bookings, + int minutesBeforeMeetingStart) + { + var rv = GetGenericMeetingsFromBookingResult(bookings); + + foreach (var meeting in rv) + { + meeting.MinutesBeforeMeeting = minutesBeforeMeetingStart; + } + + return rv; + } + /// + /// Extracts the necessary meeting values from the Zoom bookings response and converts them to the generic class + /// + /// + /// + public static List GetGenericMeetingsFromBookingResult(List bookings) + { + var meetings = new List(); + + if (Debug.Level > 0) + { + Debug.Console(1, "Meetings List:\n"); + } + + foreach (var b in bookings) + { + var meeting = new Meeting(); + + if (b.MeetingNumber != null) + meeting.Id = b.MeetingNumber; + if (b.CreatorName != null) + meeting.Organizer = b.CreatorName; + if (b.MeetingName != null) + meeting.Title = b.MeetingName; + //if (b.Agenda != null) + // meeting.Agenda = b.Agenda.Value; + if (b.StartTime != null) + meeting.StartTime = b.StartTime; + if (b.EndTime != null) + meeting.EndTime = b.EndTime; + + meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; + + // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. + var now = DateTime.Now; + if (meeting.StartTime < now && meeting.EndTime < now) + { + Debug.Console(1, "Skipping meeting {0}. Meeting is in the past.", meeting.Title); + continue; + } + + meetings.Add(meeting); + + if (Debug.Level > 0) + { + Debug.Console(1, "Title: {0}, ID: {1}, Organizer: {2}", meeting.Title, meeting.Id, meeting.Organizer); + Debug.Console(1, " Start Time: {0}, End Time: {1}, Duration: {2}", meeting.StartTime, meeting.EndTime, meeting.Duration); + Debug.Console(1, " Joinable: {0}\n", meeting.Joinable); + } + } + + meetings.OrderBy(m => m.StartTime); + + return meetings; + } + + public class HandStatus + { + // example return of the "hand_status" object + // !!!! Note the properties contain ': ' within the property name !!! + //"hand_status": { + // "is_raise_hand: ": false, + // "is_valid: ": "on", + // "time_stamp: ": "11825083" + //}, + [JsonProperty("is_raise_hand: ")] + public bool IsRaiseHand { get; set; } + [JsonProperty("is_valid: ")] + public string IsValid { get; set; } + [JsonProperty("time_stamp: ")] + public string TimeStamp { get; set; } + /// + /// Retuns a boolean value if the participant hand state is raised and is valid (both need to be true) + /// + public bool HandIsRaisedAndValid + { + get { return IsValid != null && IsValid == "on" && IsRaiseHand; } + } + } + public class ListParticipant + { + [JsonProperty("audio_status state")] + public string AudioStatusState { get; set; } + [JsonProperty("audio_status type")] + public string AudioStatusType { get; set; } + [JsonProperty("avatar_url")] + public string AvatarUrl { get; set; } + [JsonProperty("camera_status am_i_controlling")] + public bool CameraStatusAmIControlling { get; set; } + [JsonProperty("camera_status can_i_request_control")] + public bool CameraStatusCanIRequestConrol { get; set; } + [JsonProperty("camera_status can_move_camera")] + public bool CameraStatusCanMoveCamera { get; set; } + [JsonProperty("camera_status can_switch_camera")] + public bool CameraStatusCanSwitchCamera { get; set; } + [JsonProperty("camera_status can_zoom_camera")] + public bool CameraStatusCanZoomCamera { get; set; } + [JsonProperty("can_edit_closed_caption")] + public bool CanEditClosedCaption { get; set; } + [JsonProperty("can_record")] + public bool CanRecord { get; set; } + [JsonProperty("event")] + public string Event { get; set; } + [JsonProperty("hand_status")] + public HandStatus HandStatus { get; set; } + [JsonProperty("isCohost")] + public bool IsCohost { get; set; } + [JsonProperty("is_client_support_closed_caption")] + public bool IsClientSupportClosedCaption { get; set; } + [JsonProperty("is_client_support_coHost")] + public bool IsClientSupportCoHost { get; set; } + [JsonProperty("is_host")] + public bool IsHost { get; set; } + [JsonProperty("is_myself")] + public bool IsMyself { get; set; } + [JsonProperty("is_recording")] + public bool IsRecording { get; set; } + [JsonProperty("is_video_can_mute_byHost")] + public bool IsVideoCanMuteByHost { get; set; } + [JsonProperty("is_video_can_unmute_byHost")] + public bool IsVideoCanUnmuteByHost { get; set; } + [JsonProperty("local_recording_disabled")] + public bool LocalRecordingDisabled { get; set; } + [JsonProperty("user_id")] + public int UserId { get; set; } + [JsonProperty("user_name")] + public string UserName { get; set; } + [JsonProperty("user_type")] + public string UserType { get; set; } + [JsonProperty("video_status has_source")] + public bool VideoStatusHasSource { get; set; } + [JsonProperty("video_status is_receiving")] + public bool VideoStatusIsReceiving { get; set; } + [JsonProperty("video_status is_sending")] + public bool VideoStatusIsSending { get; set; } + + public ListParticipant() + { + HandStatus = new HandStatus(); + } + + /// + /// Converts ZoomRoom pariticpant list response to an Essentials participant list + /// + /// + /// + public static List GetGenericParticipantListFromParticipantsResult( + List participants) + { + if (participants.Count == 0) + { + return new List(); + } + //return participants.Select(p => new Participant + // { + // UserId = p.UserId, + // Name = p.UserName, + // IsHost = p.IsHost, + // CanMuteVideo = p.IsVideoCanMuteByHost, + // CanUnmuteVideo = p.IsVideoCanUnmuteByHost, + // AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", + // VideoMuteFb = p.VideoStatusIsSending, + // HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, + // }).ToList(); + + var sortedParticipants = SortParticipantListByHandStatus(participants); + return sortedParticipants.Select(p => new Participant + { + UserId = p.UserId, + Name = p.UserName, + IsHost = p.IsHost, + IsMyself = p.IsMyself, + CanMuteVideo = p.IsVideoCanMuteByHost, + CanUnmuteVideo = p.IsVideoCanUnmuteByHost, + AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED", + VideoMuteFb = !p.VideoStatusIsSending, + HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid, + }).ToList(); + } + + /// + /// Will sort by hand-raise status and then alphabetically + /// + /// Zoom Room response list of participants + /// List + public static List SortParticipantListByHandStatus(List participants) + { + if (participants == null) + { + //Debug.Console(1, "SortParticiapntListByHandStatu(participants == null)"); + return null; + } + + // debug testing + //foreach (ListParticipant participant in participants) + //{ + // Debug.Console(1, "{0} | IsValid: {1} | IsRaiseHand: {2} | HandIsRaisedAndValid: {3}", + // participant.UserName, participant.HandStatus.IsValid, participant.HandStatus.IsRaiseHand.ToString(), participant.HandStatus.HandIsRaisedAndValid.ToString()); + //} + + List handRaisedParticipantsList = participants.Where(p => p.HandStatus.HandIsRaisedAndValid).ToList(); + + if (handRaisedParticipantsList != null) + { + IOrderedEnumerable orderByDescending = handRaisedParticipantsList.OrderByDescending(p => p.HandStatus.TimeStamp); + + //foreach (var participant in handRaisedParticipantsList) + // Debug.Console(1, "handRaisedParticipantList: {0} | {1}", participant.UserName, participant.UserId); + } + + List allOtherParticipantsList = participants.Where(p => !p.HandStatus.HandIsRaisedAndValid).ToList(); + + if (allOtherParticipantsList != null) + { + allOtherParticipantsList.OrderBy(p => p.UserName); + + //foreach (var participant in allOtherParticipantsList) + // Debug.Console(1, "allOtherParticipantsList: {0} | {1}", participant.UserName, participant.UserId); + } + + // merge the lists + List sortedList = handRaisedParticipantsList.Union(allOtherParticipantsList).ToList(); + + // return the sorted list + return sortedList; + } + + } + + public class CallinCountryList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class CalloutCountryList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class TollFreeCallinList + { + public int code { get; set; } + public string display_number { get; set; } + public string id { get; set; } + public string name { get; set; } + public string number { get; set; } + } + + public class Info + { + public List callin_country_list { get; set; } + public List callout_country_list { get; set; } + public List toll_free_callin_list { get; set; } + } + + public class ThirdParty + { + public string h323_address { get; set; } + public string meeting_number { get; set; } + public string service_provider { get; set; } + public string sip_address { get; set; } + } + + public class MeetingListItem + { + public string accessRole { get; set; } + public string calendarChangeKey { get; set; } + public string calendarID { get; set; } + public bool checkIn { get; set; } + public string creatorEmail { get; set; } + public string creatorName { get; set; } + public string endTime { get; set; } + public string hostName { get; set; } + public bool isInstantMeeting { get; set; } + public bool isPrivate { get; set; } + public string location { get; set; } + public string meetingName { get; set; } + public string meetingNumber { get; set; } + public string scheduledFrom { get; set; } + public string startTime { get; set; } + public ThirdParty third_party { get; set; } + + public MeetingListItem() + { + third_party = new ThirdParty(); + } + } + + public class InfoResult + { + public Info Info { get; set; } + public bool am_i_original_host { get; set; } + public string default_callin_country { get; set; } + public string dialIn { get; set; } + public string international_url { get; set; } + public string invite_email_content { get; set; } + public string invite_email_subject { get; set; } + public bool is_callin_country_list_available { get; set; } + public bool is_calling_room_system_enabled { get; set; } + public bool is_toll_free_callin_list_available { get; set; } + public bool is_view_only { get; set; } + public bool is_waiting_room { get; set; } + public bool is_webinar { get; set; } + public string meeting_id { get; set; } + public MeetingListItem meeting_list_item { get; set; } + public string meeting_password { get; set; } + public string meeting_type { get; set; } + public int my_userid { get; set; } + public int participant_id { get; set; } + public string real_meeting_id { get; set; } + public string schedule_option { get; set; } + public string schedule_option2 { get; set; } + public string support_callout_type { get; set; } + public string toll_free_number { get; set; } + public string user_type { get; set; } + + public InfoResult() + { + Info = new Info(); + meeting_list_item = new MeetingListItem(); + } + } + + public class Phonebook + { + public List Contacts { get; set; } + public int Limit { get; set; } + public int Offset { get; set; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zConfiguration.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zConfiguration.cs new file mode 100644 index 00000000..3fe9ea74 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zConfiguration.cs @@ -0,0 +1,318 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// zConfiguration class structure + /// + public class zConfiguration + { + public class Sharing + { + [JsonProperty("optimize_video_sharing")] + public bool OptimizeVideoSharing { get; set; } + } + + public class Camera : NotifiableObject + { + private bool _mute; + + public bool Mute + { + get { return _mute; } + set + { + Debug.Console(1, "Camera Mute response received: {0}", value); + + if (value == _mute) return; + + _mute = value; + NotifyPropertyChanged("Mute"); + } + } + } + + public class Microphone : NotifiableObject + { + private bool _mute; + + public bool Mute + { + get + { + return _mute; + } + set + { + if (value != _mute) + { + _mute = value; + NotifyPropertyChanged("Mute"); + } + } + } + } + + [Flags] + public enum eLayoutStyle + { + None = 0, + Gallery = 1, + Speaker = 2, + Strip = 4, + ShareAll = 8, + } + + public enum eLayoutSize + { + Off, + Size1, + Size2, + Size3, + Strip + } + + public enum eLayoutPosition + { + Center, + Up, + Right, + UpRight, + Down, + DownRight, + Left, + UpLeft, + DownLeft + } + + public class Layout : NotifiableObject + { + private bool _shareThumb; + private eLayoutStyle _style; + private eLayoutSize _size; + private eLayoutPosition _position; + + public bool ShareThumb + { + get { return _shareThumb; } + set + { + if (value != _shareThumb) + { + _shareThumb = value; + NotifyPropertyChanged("ShareThumb"); + } + } + } + + public eLayoutStyle Style + { + get { return _style; } + set + { + if (value != _style) + { + _style = value; + NotifyPropertyChanged("Style"); + } + } + } + + public eLayoutSize Size + { + get { return _size; } + set + { + if (value != _size) + { + _size = value; + NotifyPropertyChanged("Size"); + } + } + } + + public eLayoutPosition Position + { + get { return _position; } + set + { + if (value != _position) + { + _position = value; + NotifyPropertyChanged("Position"); + } + } + } + } + + public class Lock : NotifiableObject + { + private bool _enable; + + public bool Enable + { + get + { + return _enable; + } + set + { + if (value != _enable) + { + _enable = value; + NotifyPropertyChanged("Enable"); + } + } + } + } + + public class ClosedCaption + { + public bool Visible { get; set; } + public int FontSize { get; set; } + } + + public class MuteUserOnEntry + { + public bool Enable { get; set; } + } + + public class Call + { + public Sharing Sharing { get; set; } + public Camera Camera { get; set; } + public Microphone Microphone { get; set; } + public Layout Layout { get; set; } + public Lock Lock { get; set; } + public MuteUserOnEntry MuteUserOnEntry { get; set; } + public ClosedCaption ClosedCaption { get; set; } + + + public Call() + { + Sharing = new Sharing(); + Camera = new Camera(); + Microphone = new Microphone(); + Layout = new Layout(); + Lock = new Lock(); + MuteUserOnEntry = new MuteUserOnEntry(); + ClosedCaption = new ClosedCaption(); + } + } + + public class Audio + { + public Input Input { get; set; } + public Output Output { get; set; } + + public Audio() + { + Input = new Input(); + Output = new Output(); + } + } + + public class Input : Output + { + [JsonProperty("reduce_reverb")] + public bool ReduceReverb { get; set; } + } + + public class Output : NotifiableObject + { + private int _volume; + + [JsonProperty("volume")] + public int Volume + { + get + { + return _volume; + } + set + { + if (value != _volume) + { + _volume = value; + NotifyPropertyChanged("Volume"); + } + } + } + [JsonProperty("selectedId")] + public string SelectedId { get; set; } + [JsonProperty("is_sap_disabled")] + public bool IsSapDisabled { get; set; } + } + + public class Video : NotifiableObject + { + private bool _hideConfSelfVideo; + + [JsonProperty("hide_conf_self_video")] + public bool HideConfSelfVideo + { + get + { + return _hideConfSelfVideo; + } + set + { + //if (value != _hideConfSelfVideo) + //{ + _hideConfSelfVideo = value; + NotifyPropertyChanged("HideConfSelfVideo"); + //} + } + } + + public VideoCamera Camera { get; set; } + + public Video() + { + Camera = new VideoCamera(); + } + } + + public class VideoCamera : NotifiableObject + { + private string _selectedId; + + [JsonProperty("selectedId")] + public string SelectedId + { + get + { + return _selectedId; + } + set + { + if (value != _selectedId) + { + _selectedId = value; + NotifyPropertyChanged("SelectedId"); + } + } + + } + public bool Mirror { get; set; } + } + + public class Client + { + public string appVersion { get; set; } + public string deviceSystem { get; set; } + + // This doesn't belong here, but there's a bug in the object structure of Zoom Room 5.6.3 that puts it here + public zConfiguration.Call Call { get; set; } + + public Client() + { + Call = new zConfiguration.Call(); + } + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zEvent.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zEvent.cs new file mode 100644 index 00000000..8e51c765 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zEvent.cs @@ -0,0 +1,232 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// zEvent Class Structure + /// + public class zEvent + { + public class StartLocalPresentMeeting + { + public bool Success { get; set; } + } + public class NeedWaitForHost + { + public bool Wait { get; set; } + } + + public class IncomingCallIndication + { + public string callerJID { get; set; } + public string calleeJID { get; set; } + public string meetingID { get; set; } + public string password { get; set; } + public string meetingOption { get; set; } + public long MeetingNumber { get; set; } + public string callerName { get; set; } + public string avatarURL { get; set; } + public int lifeTime { get; set; } + public bool accepted { get; set; } + } + + public class CallConnectError + { + public int error_code { get; set; } + public string error_message { get; set; } + } + + public class CallDisconnect + { + public bool Successful + { + get + { + return success == "on"; + } + } + + public string success { get; set; } + } + + public class Layout + { + public bool Sharethumb { get; set; } + } + + public class Call + { + public Layout Layout { get; set; } + } + + public class Client + { + public Call Call { get; set; } + } + + public enum eSharingState + { + None, + Connecting, + Sending, + Receiving, + Send_Receiving + } + + public class SharingState : NotifiableObject + { + private bool _paused; + private eSharingState _state; + + public bool IsSharing { get; private set; } + + [JsonProperty("paused")] + public bool Paused + { + get + { + return _paused; + } + set + { + if (value != _paused) + { + _paused = value; + NotifyPropertyChanged("Paused"); + } + } + } + [JsonProperty("state")] + public eSharingState State + { + get + { + return _state; + } + set + { + if (value != _state) + { + _state = value; + IsSharing = _state == eSharingState.Sending; + NotifyPropertyChanged("State"); + } + } + } + } + + public class PinStatusOfScreenNotification + { + + + [JsonProperty("can_be_pinned")] + public bool CanBePinned { get; set; } + [JsonProperty("can_pin_share")] + public bool CanPinShare { get; set; } + [JsonProperty("pinned_share_source_id")] + public int PinnedShareSourceId { get; set; } + [JsonProperty("pinned_user_id")] + public int PinnedUserId { get; set; } + [JsonProperty("screen_index")] + public int ScreenIndex { get; set; } + [JsonProperty("screen_layout")] + public int ScreenLayout { get; set; } + [JsonProperty("share_source_type")] + public int ShareSourceType { get; set; } + [JsonProperty("why_cannot_pin_share")] + public string WhyCannotPinShare { get; set; } + } + + public class PhoneCallStatus : NotifiableObject + { + private bool _isIncomingCall; + private string _peerDisplayName; + private string _peerNumber; + + private bool _offHook; + + public string CallId { get; set; } + public bool IsIncomingCall + { + get { return _isIncomingCall; } + set + { + if (value == _isIncomingCall) return; + + _isIncomingCall = value; + NotifyPropertyChanged("IsIncomingCall"); + } + } + + public string PeerDisplayName + { + get { return _peerDisplayName; } + set + { + if (value == _peerDisplayName) return; + _peerDisplayName = value; + NotifyPropertyChanged("PeerDisplayName"); + } + } + + public string PeerNumber + { + get { return _peerNumber; } + set + { + if (value == _peerNumber) return; + + _peerNumber = value; + NotifyPropertyChanged("PeerNumber"); + } + } + + public string PeerUri { get; set; } + + private ePhoneCallStatus _status; + public ePhoneCallStatus Status + { + get { return _status; } + set + { + _status = value; + OffHook = _status == ePhoneCallStatus.PhoneCallStatus_Accepted || + _status == ePhoneCallStatus.PhoneCallStatus_InCall || + _status == ePhoneCallStatus.PhoneCallStatus_Init || + _status == ePhoneCallStatus.PhoneCallStatus_Ringing; + } + } + + public bool OffHook + { + get { return _offHook; } + set + { + if (value == _offHook) return; + + _offHook = value; + NotifyPropertyChanged("OffHook"); + } + } + } + + public enum ePhoneCallStatus + { + PhoneCallStatus_Ringing, + PhoneCallStatus_Terminated, + PhoneCallStatus_Accepted, + PhoneCallStatus_InCall, + PhoneCallStatus_Init, + } + + public class MeetingNeedsPassword + { + [JsonProperty("needsPassword")] + public bool NeedsPassword { get; set; } + + [JsonProperty("wrongAndRetry")] + public bool WrongAndRetry { get; set; } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zStatus.cs b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zStatus.cs new file mode 100644 index 00000000..03423592 --- /dev/null +++ b/src/PepperDash.Essentials.Devices.Common/VideoCodec/ZoomRoom/zStatus.cs @@ -0,0 +1,761 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Devices.Common.Codec; + +namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom +{ + /// + /// zStatus class stucture + /// + public class zStatus + { + public class Login + { + [JsonProperty("ZAAPI Release")] + public string ZAAPIRelease { get; set; } + [JsonProperty("Zoom Room Release")] + public string ZoomRoomRelease { get; set; } + } + + public class SystemUnit + { + [JsonProperty("email")] + public string Email { get; set; } + [JsonProperty("login_type")] + public string LoginType { get; set; } + [JsonProperty("meeting_number")] + public string MeetingNumber { get; set; } + [JsonProperty("platform")] + public string Platform { get; set; } + [JsonProperty("room_info")] + public RoomInfo RoomInfo { get; set; } + [JsonProperty("room_version")] + public string RoomVersion { get; set; } + + public SystemUnit() + { + RoomInfo = new RoomInfo(); + } + } + + public class RoomInfo + { + [JsonProperty("account_email")] + public string AccountEmail { get; set; } + [JsonProperty("display_version")] + public string DisplayVersion { get; set; } + [JsonProperty("is_auto_answer_enabled")] + public bool AutoAnswerIsEnabled { get; set; } + [JsonProperty("is_auto_answer_selected")] + public bool AutoAnswerIsSelected { get; set; } + [JsonProperty("room_name")] + public string RoomName { get; set; } + } + + public class CloudPbxInfo + { + [JsonProperty("company_number")] + public string CompanyNumber { get; set; } + [JsonProperty("extension")] + public string Extension { get; set; } + [JsonProperty("isValid")] + public bool IsValid { get; set; } + } + + public enum ePresence + { + PRESENCE_OFFLINE, + PRESENCE_ONLINE, + PRESENCE_AWAY, + PRESENCE_BUSY, + PRESENCE_DND + } + + public class Contact + { + [JsonProperty("avatarURL")] + public string AvatarURL { get; set; } + [JsonProperty("cloud_pbx_info")] + public CloudPbxInfo CloudPbxInfo { get; set; } + [JsonProperty("email")] + public string Email { get; set; } + [JsonProperty("firstName")] + public string FirstName { get; set; } + [JsonProperty("index")] + public int Index { get; set; } + [JsonProperty("isLegacy")] + public bool IsLegacy { get; set; } + [JsonProperty("isZoomRoom")] + public bool IsZoomRoom { get; set; } + [JsonProperty("jid")] + public string Jid { get; set; } + [JsonProperty("lastName")] + public string LastName { get; set; } + [JsonProperty("onDesktop")] + public bool OnDesktop { get; set; } + [JsonProperty("onMobile")] + public bool OnMobile { get; set; } + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } + [JsonProperty("presence")] + public ePresence Presence { get; set; } + [JsonProperty("presence_status")] + public int PresenceStatus { get; set; } + [JsonProperty("screenName")] + public string ScreenName { get; set; } + [JsonProperty("sip_phone_number")] + public string SipPhoneNumber { get; set; } + + + public Contact() + { + CloudPbxInfo = new CloudPbxInfo(); + } + } + + public class Phonebook + { + [JsonProperty("Contacts")] + public List Contacts { get; set; } + + public Phonebook() + { + Contacts = new List(); + } + + /// + /// Converts from zStatus.Contact types to generic directory items + /// + /// + public static CodecDirectory ConvertZoomContactsToGeneric(List zoomContacts) + { + var directory = new CodecDirectory(); + + var folders = new List(); + + var roomFolder = new DirectoryFolder(); + + var contactFolder = new DirectoryFolder(); + + var contacts = new List(); + + // Check if there are any zoom rooms + var zoomRooms = zoomContacts.FindAll(c => c.IsZoomRoom); + + if (zoomRooms.Count > 0) + { + // If so, setup a rooms and contacts folder and add them. + + directory.ResultsFolderId = "root"; + + roomFolder.Name = "Rooms"; + roomFolder.ParentFolderId = "root"; + roomFolder.FolderId = "rooms"; + + contactFolder.Name = "Contacts"; + contactFolder.ParentFolderId = "root"; + contactFolder.FolderId = "contacts"; + + folders.Add(roomFolder); + folders.Add(contactFolder); + + directory.AddFoldersToDirectory(folders); + } + + try + { + if (zoomContacts.Count == 0) + { + return directory; + } + + foreach (Contact c in zoomContacts) + { + var contact = new InvitableDirectoryContact { Name = c.ScreenName, ContactId = c.Jid }; + + contact.ContactMethods.Add(new ContactMethod() + { + Number = c.Jid, + Device = eContactMethodDevice.Video, + CallType = eContactMethodCallType.Video, + ContactMethodId = c.Jid + }); + + if (folders.Count > 0) + { + contact.ParentFolderId = c.IsZoomRoom + ? roomFolder.FolderId // "rooms" + : contactFolder.FolderId; // "contacts" + } + + contacts.Add(contact); + } + + directory.AddContactsToDirectory(contacts); + } + catch (Exception e) + { + Debug.Console(1, "Error converting Zoom Phonebook results to generic: {0}", e); + } + + return directory; + } + } + + public enum eCallStatus + { + UNKNOWN, + NOT_IN_MEETING, + CONNECTING_MEETING, + IN_MEETING, + LOGGED_OUT + } + + public class ClosedCaption + { + public bool Available { get; set; } + } + + public class Call : NotifiableObject + { + private eCallStatus _status; + private List _participants; + + public bool IsInCall; + + public eCallStatus Status + { + get + { + return _status; + } + set + { + if (value != _status) + { + _status = value; + IsInCall = _status == eCallStatus.IN_MEETING || _status == eCallStatus.CONNECTING_MEETING; + NotifyPropertyChanged("Status"); + } + } + } + public ClosedCaption ClosedCaption { get; set; } + public List Participants + { + get + { + return _participants; + } + set + { + _participants = value; + NotifyPropertyChanged("Participants"); + } + } + public zEvent.SharingState Sharing { get; set; } + + public CallRecordInfo CallRecordInfo { get; set; } + + private zCommand.InfoResult _info; + + public zCommand.InfoResult Info + { + get + { + return _info; + } + set + { + _info = value; + NotifyPropertyChanged("Info"); + } + } + + public Call() + { + ClosedCaption = new ClosedCaption(); + Participants = new List(); + Sharing = new zEvent.SharingState(); + CallRecordInfo = new CallRecordInfo(); + Info = new zCommand.InfoResult(); + } + } + + public class Capabilities + { + public bool aec_Setting_Stored_In_ZR { get; set; } + public bool can_Dtmf_For_Invite_By_Phone { get; set; } + public bool can_Mute_On_Entry { get; set; } + public bool can_Ringing_In_Pstn_Call { get; set; } + public bool can_Switch_To_Specific_Camera { get; set; } + public bool is_Airhost_Disabled { get; set; } + public bool pstn_Call_In_Local_resentation { get; set; } + public bool support_Claim_Host { get; set; } + public bool support_Out_Room_Display { get; set; } + public bool support_Pin_And_Spotlight { get; set; } + public bool supports_Audio_Checkup { get; set; } + public bool supports_CheckIn { get; set; } + public bool supports_Cloud_PBX { get; set; } + public bool supports_Encrypted_Connection { get; set; } + public bool supports_Expel_User_Permanently { get; set; } + public bool supports_H323_DTMF { get; set; } + public bool supports_Hdmi_Cec_Control { get; set; } + public bool supports_Highly_Reverberant_Room { get; set; } + public bool supports_Loading_Contacts_Dynamically { get; set; } + public bool supports_Loading_Participants_Dynamically { get; set; } + public bool supports_Mic_Record_Test { get; set; } + public bool supports_Multi_Share { get; set; } + public bool supports_ShareCamera { get; set; } + public bool supports_Share_For_Floating_And_Content_Only { get; set; } + public bool supports_Sip_Call_out { get; set; } + public bool supports_Software_Audio_Processing { get; set; } + public bool supports_Web_Settings_Push { get; set; } + } + + public enum eDisplayState + { + None, + Laptop, + IOS, + } + + public class Sharing : NotifiableObject + { + private eDisplayState _dispState; + private string _password; + private bool _isAirHostClientConnected; + private bool _isSharingBlackMagic; + private bool _isDirectPresentationConnected; + private bool _isBlackMagicConnected; + + + public string directPresentationPairingCode { get; set; } + /// + /// Laptop client sharing key + /// + public string directPresentationSharingKey { get; set; } + public eDisplayState dispState + { + get + { + return _dispState; + } + set + { + if (value != _dispState) + { + _dispState = value; + NotifyPropertyChanged("dispState"); + } + } + } + + public bool isAirHostClientConnected + { + get { return _isAirHostClientConnected; } + set + { + if (value != _isAirHostClientConnected) + { + _isAirHostClientConnected = value; + NotifyPropertyChanged("isAirHostClientConnected"); + } + } + } + + public bool isBlackMagicConnected + { + get { return _isBlackMagicConnected; } + set + { + if (value != _isBlackMagicConnected) + { + _isBlackMagicConnected = value; + NotifyPropertyChanged("isBlackMagicConnected"); + } + } + } + public bool isBlackMagicDataAvailable { get; set; } + + public bool isDirectPresentationConnected + { + get { return _isDirectPresentationConnected; } + set + { + if (value != _isDirectPresentationConnected) + { + _isDirectPresentationConnected = value; + NotifyPropertyChanged("isDirectPresentationConnected"); + } + } + } + + public bool isSharingBlackMagic + { + get { return _isSharingBlackMagic; } + set + { + if (value != _isSharingBlackMagic) + { + _isSharingBlackMagic = value; + NotifyPropertyChanged("isSharingBlackMagic"); + } + } + } + + /// + /// IOS Airplay code + /// + public string password + { + get + { + return _password; + } + set + { + if (value != _password) + { + _password = value; + NotifyPropertyChanged("password"); + } + } + } + public string serverName { get; set; } + public string wifiName { get; set; } + } + + public class NumberOfScreens : NotifiableObject + { + private int _numOfScreens; + + [JsonProperty("NumberOfCECScreens")] + public int NumOfCECScreens { get; set; } + [JsonProperty("NumberOfScreens")] + public int NumOfScreens + { + get + { + return _numOfScreens; + } + set + { + if (value != _numOfScreens) + { + _numOfScreens = value; + NotifyPropertyChanged("NumberOfScreens"); + } + } + } + } + + /// + /// AudioInputLine/AudioOutputLine/VideoCameraLine list item + /// + public class AudioVideoInputOutputLineItem + { + public string Alias { get; set; } + public string Name { get; set; } + public bool Selected { get; set; } + public bool combinedDevice { get; set; } + public string id { get; set; } + public bool manuallySelected { get; set; } + public int numberOfCombinedDevices { get; set; } + public int ptzComId { get; set; } + } + + public class Video + { + public bool Optimizable { get; set; } + } + + public class CameraShare : NotifiableObject + { + private bool _canControlCamera; + private bool _isSharing; + + [JsonProperty("can_Control_Camera")] + public bool CanControlCamera + { + get + { + return _canControlCamera; + } + set + { + if (value != _canControlCamera) + { + _canControlCamera = value; + NotifyPropertyChanged("CanControlCamera"); + } + } + } + public string id { get; set; } + public bool is_Mirrored { get; set; } + [JsonProperty("is_Sharing")] + public bool IsSharing + { + get + { + return _isSharing; + } + set + { + if (value != _isSharing) + { + _isSharing = value; + NotifyPropertyChanged("IsSharing"); + } + } + } + public int pan_Tilt_Speed { get; set; } + + } + + public class Layout : NotifiableObject + { + // backer variables + private bool _can_Switch_Speaker_View; + private bool _can_Switch_Wall_View; + private bool _can_Switch_Strip_View; + private bool _can_Switch_Share_On_All_Screens; + private bool _can_Switch_Floating_Share_Content; + private bool _is_In_First_Page; + private bool _is_In_Last_Page; + private string _video_type; + + + public bool can_Adjust_Floating_Video { get; set; } + + + public bool can_Switch_Floating_Share_Content + { + get + { + return _can_Switch_Floating_Share_Content; + } + set + { + if (value != _can_Switch_Floating_Share_Content) + { + _can_Switch_Floating_Share_Content = value; + NotifyPropertyChanged("can_Switch_Floating_Share_Content"); + } + } + } + + + /// + /// [on/off] // Set to On if it is possible to invoke zConfiguration Call Layout Style: ShareAll, to switch to the ShareAll mode, where the content sharing is shown full screen on all monitors. + /// + [JsonProperty("can_Switch_Share_On_All_Screens")] + public bool can_Switch_Share_On_All_Screens + { + get + { + return _can_Switch_Share_On_All_Screens; + } + set + { + if (value != _can_Switch_Share_On_All_Screens) + { + _can_Switch_Share_On_All_Screens = value; + NotifyPropertyChanged("can_Switch_Share_On_All_Screens"); + } + } + } + + /// + /// [on/off] // Set to On if it is possible to switch to Speaker view by invoking zConfiguration Call Layout Style: Speaker. The active speaker is shown full screen, and other video streams, like self-view, are shown in thumbnails. + /// + [JsonProperty("can_Switch_Speaker_View")] + public bool can_Switch_Speaker_View + { + get + { + return _can_Switch_Speaker_View; + } + set + { + if (value != _can_Switch_Speaker_View) + { + _can_Switch_Speaker_View = value; + NotifyPropertyChanged("can_Switch_Speaker_View"); + } + } + } + + /// + /// [on/off] On if it is possible to invoke zConfiguration Call Layout Style: Gallery, to switch to the Gallery mode, showing video participants in tiled windows: The Zoom Room shows up to a 5x5 array of tiled windows per page. + /// + [JsonProperty("can_Switch_Wall_View")] + public bool can_Switch_Wall_View + { + get + { + return _can_Switch_Wall_View; + } + set + { + if (value != _can_Switch_Wall_View) + { + _can_Switch_Wall_View = value; + NotifyPropertyChanged("can_Switch_Wall_View"); + } + } + } + + [JsonProperty("can_Switch_Strip_View")] + public bool can_Switch_Strip_View + { + get + { + return _can_Switch_Strip_View; + } + set + { + if (value != _can_Switch_Strip_View) + { + _can_Switch_Strip_View = value; + NotifyPropertyChanged("can_Switch_Strip_View"); + } + } + } + + [JsonProperty("is_In_First_Page")] + public bool is_In_First_Page + { + get + { + return _is_In_First_Page; + } + set + { + if (value != _is_In_First_Page) + { + _is_In_First_Page = value; + NotifyPropertyChanged("is_In_First_Page"); + } + } + } + + [JsonProperty("is_In_Last_Page")] + public bool is_In_Last_Page + { + get + { + return _is_In_Last_Page; + } + set + { + if (value != _is_In_Last_Page) + { + _is_In_Last_Page = value; + NotifyPropertyChanged("is_In_Last_Page"); + } + } + } + + public bool is_supported { get; set; } + public int video_Count_In_Current_Page { get; set; } + + /// + /// [Gallery | Strip] Indicates which mode applies: Strip or Gallery. + /// + [JsonProperty("video_type")] + public string video_type + { + get + { + return _video_type; + } + set + { + if (value != _video_type) + { + _video_type = value; + NotifyPropertyChanged("video_type"); + } + } + } + } + + public class CallRecordInfo : NotifiableObject + { + private bool _meetingIsBeingRecorded; + private bool _canRecord; + private bool _emailRequired; + + public bool amIRecording { get; set; } + + public bool canRecord + { + get + { + return _canRecord; + } + set + { + if (value != _canRecord) + { + _canRecord = value; + NotifyPropertyChanged("canRecord"); + } + } + } + + public bool emailRequired + { + get + { + return _emailRequired; + } + set + { + if (value != _emailRequired) + { + _emailRequired = value; + NotifyPropertyChanged("emailRequired"); + } + } + } + + public bool meetingIsBeingRecorded + { + get + { + return _meetingIsBeingRecorded; + } + set + { + //Debug.Console(2, "************************************setting value of meetingIsBeingRecorded to: {0}", value); + if (value != _meetingIsBeingRecorded) + { + _meetingIsBeingRecorded = value; + //Debug.Console(2, "********************************set value of meetingIsBeingRecorded to: {0}", _meetingIsBeingRecorded); + NotifyPropertyChanged("meetingIsBeingRecorded"); + } + } + } + + /// + /// Indicates if recording is allowed (when meeting capable and and email is not required to be entered by the user) + /// + public bool AllowRecord + { + get + { + return canRecord && !emailRequired; + } + } + + public CallRecordInfo() + { + Debug.Console(2, Debug.ErrorLogLevel.Notice, "********************************************* CallRecordInfo() ******************************************"); + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Audio/EssentialsRoomVolumesConfig.cs b/src/PepperDash.Essentials/Audio/EssentialsRoomVolumesConfig.cs new file mode 100644 index 00000000..92c62136 --- /dev/null +++ b/src/PepperDash.Essentials/Audio/EssentialsRoomVolumesConfig.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials +{ + /// + /// + /// + public class EssentialsRoomVolumesConfig + { + public EssentialsVolumeLevelConfig Master { get; set; } + public EssentialsVolumeLevelConfig Program { get; set; } + public EssentialsVolumeLevelConfig AudioCallRx { get; set; } + public EssentialsVolumeLevelConfig AudioCallTx { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs b/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs index 70fcd36f..8d3a9175 100644 --- a/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs +++ b/src/PepperDash.Essentials/Audio/EssentialsVolumeLevelConfig.cs @@ -16,17 +16,6 @@ using PepperDash.Essentials.DM; namespace PepperDash.Essentials { - /// - /// - /// - public class EssentialsRoomVolumesConfig - { - public EssentialsVolumeLevelConfig Master { get; set; } - public EssentialsVolumeLevelConfig Program { get; set; } - public EssentialsVolumeLevelConfig AudioCallRx { get; set; } - public EssentialsVolumeLevelConfig AudioCallTx { get; set; } - } - /// /// /// diff --git a/src/PepperDash.Essentials/Devices/Amplifier.cs b/src/PepperDash.Essentials/Devices/Amplifier.cs index b2725109..7c0e0ff3 100644 --- a/src/PepperDash.Essentials/Devices/Amplifier.cs +++ b/src/PepperDash.Essentials/Devices/Amplifier.cs @@ -1,12 +1,8 @@ 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.Config; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials @@ -55,18 +51,4 @@ namespace PepperDash.Essentials #endregion } - - public class AmplifierFactory : EssentialsDeviceFactory - { - public AmplifierFactory() - { - TypeNames = new List() { "amplifier" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new Amplifier Device"); - return new Amplifier(dc.Key, dc.Name); - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/Devices/AmplifierFactory.cs b/src/PepperDash.Essentials/Devices/AmplifierFactory.cs new file mode 100644 index 00000000..dc315665 --- /dev/null +++ b/src/PepperDash.Essentials/Devices/AmplifierFactory.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials +{ + public class AmplifierFactory : EssentialsDeviceFactory + { + public AmplifierFactory() + { + TypeNames = new List() { "amplifier" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Amplifier Device"); + return new Amplifier(dc.Key, dc.Name); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/DisplayItem.cs b/src/PepperDash.Essentials/Room/Config/DisplayItem.cs new file mode 100644 index 00000000..1b4eec32 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/DisplayItem.cs @@ -0,0 +1,10 @@ +using PepperDash.Core; + +namespace PepperDash.Essentials.Room.Config +{ + public class DisplayItem : IKeyName + { + public string Key { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsAvRoomPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsAvRoomPropertiesConfig.cs new file mode 100644 index 00000000..fdfb663b --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsAvRoomPropertiesConfig.cs @@ -0,0 +1,27 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsAvRoomPropertiesConfig : EssentialsRoomPropertiesConfig + { + [JsonProperty("defaultAudioKey")] + public string DefaultAudioKey { get; set; } + [JsonProperty("sourceListKey")] + public string SourceListKey { get; set; } + [JsonProperty("destinationListKey")] + public string DestinationListKey { get; set; } + [JsonProperty("defaultSourceItem")] + public string DefaultSourceItem { get; set; } + /// + /// Indicates if the room supports advanced sharing + /// + [JsonProperty("supportsAdvancedSharing")] + public bool SupportsAdvancedSharing { get; set; } + /// + /// Indicates if non-tech users can change the share mode + /// + [JsonProperty("userCanChangeShareMode")] + public bool UserCanChangeShareMode { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsConferenceRoomPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsConferenceRoomPropertiesConfig.cs new file mode 100644 index 00000000..ca161975 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsConferenceRoomPropertiesConfig.cs @@ -0,0 +1,13 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig + { + [JsonProperty("videoCodecKey")] + public string VideoCodecKey { get; set; } + [JsonProperty("audioCodecKey")] + public string AudioCodecKey { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsEnvironmentPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsEnvironmentPropertiesConfig.cs new file mode 100644 index 00000000..6427336d --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsEnvironmentPropertiesConfig.cs @@ -0,0 +1,20 @@ +extern alias Full; +using System.Collections.Generic; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsEnvironmentPropertiesConfig + { + public bool Enabled { get; set; } + + [JsonProperty("deviceKeys")] + public List DeviceKeys { get; set; } + + public EssentialsEnvironmentPropertiesConfig() + { + DeviceKeys = new List(); + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsHelpPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsHelpPropertiesConfig.cs new file mode 100644 index 00000000..27e65394 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsHelpPropertiesConfig.cs @@ -0,0 +1,28 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + /// + /// Properties for the help text box + /// + public class EssentialsHelpPropertiesConfig + { + [JsonProperty("message")] + public string Message { get; set; } + + [JsonProperty("showCallButton")] + public bool ShowCallButton { get; set; } + + /// + /// Defaults to "Call Help Desk" + /// + [JsonProperty("callButtonText")] + public string CallButtonText { get; set; } + + public EssentialsHelpPropertiesConfig() + { + CallButtonText = "Call Help Desk"; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsLogoPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsLogoPropertiesConfig.cs new file mode 100644 index 00000000..a9d17de0 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsLogoPropertiesConfig.cs @@ -0,0 +1,40 @@ +extern alias Full; +using Crestron.SimplSharp; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + /// + /// Properties for the room's logo on panels + /// + public class EssentialsLogoPropertiesConfig + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + /// + /// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo + /// + public string GetLogoUrlLight() + { + if (Type == "url") + return Url; + if (Type == "system") + return string.Format("http://{0}:8080/logo.png", + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); + return null; + } + + public string GetLogoUrlDark() + { + if (Type == "url") + return Url; + if (Type == "system") + return string.Format("http://{0}:8080/logo-dark.png", + CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); + return null; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs index 22eccc24..4cd1be1b 100644 --- a/src/PepperDash.Essentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs +++ b/src/PepperDash.Essentials/Room/Config/EssentialsNDisplayRoomPropertiesConfig.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; - -using PepperDash.Core; using PepperDash.Essentials.Core; using Full.Newtonsoft.Json; @@ -31,11 +29,4 @@ namespace PepperDash.Essentials.Room.Config } } - - public class DisplayItem : IKeyName - { - public string Key { get; set; } - public string Name { get; set; } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsOneButtonMeetingPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsOneButtonMeetingPropertiesConfig.cs new file mode 100644 index 00000000..1067c067 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsOneButtonMeetingPropertiesConfig.cs @@ -0,0 +1,14 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + /// + /// + /// + public class EssentialsOneButtonMeetingPropertiesConfig + { + [JsonProperty("enable")] + public bool Enable { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsPresentationPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsPresentationRoomPropertiesConfig.cs similarity index 100% rename from src/PepperDash.Essentials/Room/Config/EssentialsPresentationPropertiesConfig.cs rename to src/PepperDash.Essentials/Room/Config/EssentialsPresentationRoomPropertiesConfig.cs diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomAddressPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomAddressPropertiesConfig.cs new file mode 100644 index 00000000..b89e99aa --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomAddressPropertiesConfig.cs @@ -0,0 +1,14 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomAddressPropertiesConfig + { + [JsonProperty("phoneNumber")] + public string PhoneNumber { get; set; } + + [JsonProperty("sipAddress")] + public string SipAddress { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfig.cs deleted file mode 100644 index 7d095e6f..00000000 --- a/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfig.cs +++ /dev/null @@ -1,413 +0,0 @@ -extern alias Full; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Crestron.SimplSharp; -using Full.Newtonsoft.Json; - -using PepperDash.Core; -using PepperDash.Essentials; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Room.Config -{ - public class EssentialsRoomConfigHelper - { - /// - /// Returns a room object from this config data - /// - /// - public static IKeyed GetRoomObject(DeviceConfig roomConfig) - { - var typeName = roomConfig.Type.ToLower(); - - switch (typeName) - { - case "huddle" : - { - return new EssentialsHuddleSpaceRoom(roomConfig); - } - case "huddlevtc1" : - { - return new EssentialsHuddleVtc1Room(roomConfig); - } - case "ddvc01bridge" : - { - return new Device(roomConfig.Key, roomConfig.Name); // placeholder device that does nothing. - } - case "dualdisplay" : - { - return new EssentialsDualDisplayRoom(roomConfig); - } - case "combinedhuddlevtc1" : - { - return new EssentialsCombinedHuddleVtc1Room(roomConfig); - } - case "techroom" : - { - return new EssentialsTechRoom(roomConfig); - } - default : - { - return Core.DeviceFactory.GetDevice(roomConfig); - } - } - } - - /// - /// Gets and operating, standalone emergegncy object that can be plugged into a room. - /// Returns null if there is no emergency defined - /// - public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, IEssentialsRoom room) - { - // This emergency - var emergency = props.Emergency; - if (emergency != null) - { - //switch on emergency type here. Right now only contact and shutdown - var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room); - DeviceManager.AddDevice(e); - } - return null; - } - - /// - /// - /// - /// - /// - /// - public static Core.Privacy.MicrophonePrivacyController GetMicrophonePrivacy( - EssentialsRoomPropertiesConfig props, IPrivacy room) - { - var microphonePrivacy = props.MicrophonePrivacy; - if (microphonePrivacy == null) - { - Debug.Console(0, "Cannot create microphone privacy with null properties"); - return null; - } - // Get the MicrophonePrivacy device from the device manager - var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as - Core.Privacy.MicrophonePrivacyController); - // Set this room as the IPrivacy device - if (mP == null) - { - Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); - return null; - } - mP.SetPrivacyDevice(room); - - var behaviour = props.MicrophonePrivacy.Behaviour.ToLower(); - - if (behaviour == null) - { - Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController"); - return null; - } - if (behaviour == "trackroomstate") - { - // Tie LED enable to room power state - var essRoom = room as IEssentialsRoom; - essRoom.OnFeedback.OutputChange += (o, a) => - { - if (essRoom.OnFeedback.BoolValue) - mP.EnableLeds = true; - else - mP.EnableLeds = false; - }; - - mP.EnableLeds = essRoom.OnFeedback.BoolValue; - } - else if (behaviour == "trackcallstate") - { - // Tie LED enable to room power state - var inCallRoom = room as IHasInCallFeedback; - inCallRoom.InCallFeedback.OutputChange += (o, a) => - { - if (inCallRoom.InCallFeedback.BoolValue) - mP.EnableLeds = true; - else - mP.EnableLeds = false; - }; - - mP.EnableLeds = inCallRoom.InCallFeedback.BoolValue; - } - - return mP; - } - - } - - /// - /// - /// - public class EssentialsRoomPropertiesConfig - { - [JsonProperty("addresses")] - public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } - - [JsonProperty("description")] - public string Description { get; set; } - - [JsonProperty("emergency")] - public EssentialsRoomEmergencyConfig Emergency { get; set; } - - [JsonProperty("help")] - public EssentialsHelpPropertiesConfig Help { get; set; } - - [JsonProperty("helpMessage")] - public string HelpMessage { get; set; } - - /// - /// Read this value to get the help message. It checks for the old and new config format. - /// - public string HelpMessageForDisplay - { - get - { - if(Help != null && !string.IsNullOrEmpty(Help.Message)) - { - return Help.Message; - } - else - { - return HelpMessage; - } - } - } - - [JsonProperty("environment")] - public EssentialsEnvironmentPropertiesConfig Environment { get; set; } - - [JsonProperty("logo")] - public EssentialsLogoPropertiesConfig LogoLight { get; set; } - - [JsonProperty("logoDark")] - public EssentialsLogoPropertiesConfig LogoDark { get; set; } - - [JsonProperty("microphonePrivacy")] - public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } - - [JsonProperty("occupancy")] - public EssentialsRoomOccSensorConfig Occupancy { get; set; } - - [JsonProperty("oneButtonMeeting")] - public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } - - [JsonProperty("shutdownVacancySeconds")] - public int ShutdownVacancySeconds { get; set; } - - [JsonProperty("shutdownPromptSeconds")] - public int ShutdownPromptSeconds { get; set; } - - [JsonProperty("tech")] - public EssentialsRoomTechConfig Tech { get; set; } - - [JsonProperty("volumes")] - public EssentialsRoomVolumesConfig Volumes { get; set; } - - [JsonProperty("fusion")] - public EssentialsRoomFusionConfig Fusion { get; set; } - - [JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)] - public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; } - - [JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")] - public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } - - /// - /// Indicates if this room represents a combination of other rooms - /// - [JsonProperty("isRoomCombinationScenario")] - public bool IsRoomCombinationScenario { get; set; } - - public EssentialsRoomPropertiesConfig() - { - LogoLight = new EssentialsLogoPropertiesConfig(); - LogoDark = new EssentialsLogoPropertiesConfig(); - } - } - - public class EssentialsRoomUiBehaviorConfig - { - [JsonProperty("disableActivityButtonsWhileWarmingCooling")] - public bool DisableActivityButtonsWhileWarmingCooling { get; set; } - } - - public class EssentialsAvRoomPropertiesConfig : EssentialsRoomPropertiesConfig - { - [JsonProperty("defaultAudioKey")] - public string DefaultAudioKey { get; set; } - [JsonProperty("sourceListKey")] - public string SourceListKey { get; set; } - [JsonProperty("destinationListKey")] - public string DestinationListKey { get; set; } - [JsonProperty("defaultSourceItem")] - public string DefaultSourceItem { get; set; } - /// - /// Indicates if the room supports advanced sharing - /// - [JsonProperty("supportsAdvancedSharing")] - public bool SupportsAdvancedSharing { get; set; } - /// - /// Indicates if non-tech users can change the share mode - /// - [JsonProperty("userCanChangeShareMode")] - public bool UserCanChangeShareMode { get; set; } - } - - public class EssentialsConferenceRoomPropertiesConfig : EssentialsAvRoomPropertiesConfig - { - [JsonProperty("videoCodecKey")] - public string VideoCodecKey { get; set; } - [JsonProperty("audioCodecKey")] - public string AudioCodecKey { get; set; } - } - - public class EssentialsEnvironmentPropertiesConfig - { - public bool Enabled { get; set; } - - [JsonProperty("deviceKeys")] - public List DeviceKeys { get; set; } - - public EssentialsEnvironmentPropertiesConfig() - { - DeviceKeys = new List(); - } - - } - - public class EssentialsRoomFusionConfig - { - public uint IpIdInt - { - get - { - try - { - return Convert.ToUInt32(IpId, 16); - } - catch (Exception) - { - throw new FormatException(string.Format("ERROR:Unable to convert IP ID: {0} to hex. Error:\n{1}", IpId)); - } - - } - } - - [JsonProperty("ipId")] - public string IpId { get; set; } - - [JsonProperty("joinMapKey")] - public string JoinMapKey { get; set; } - - } - - public class EssentialsRoomMicrophonePrivacyConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("behaviour")] - public string Behaviour { get; set; } - } - - /// - /// Properties for the help text box - /// - public class EssentialsHelpPropertiesConfig - { - [JsonProperty("message")] - public string Message { get; set; } - - [JsonProperty("showCallButton")] - public bool ShowCallButton { get; set; } - - /// - /// Defaults to "Call Help Desk" - /// - [JsonProperty("callButtonText")] - public string CallButtonText { get; set; } - - public EssentialsHelpPropertiesConfig() - { - CallButtonText = "Call Help Desk"; - } - } - - /// - /// - /// - public class EssentialsOneButtonMeetingPropertiesConfig - { - [JsonProperty("enable")] - public bool Enable { get; set; } - } - - public class EssentialsRoomAddressPropertiesConfig - { - [JsonProperty("phoneNumber")] - public string PhoneNumber { get; set; } - - [JsonProperty("sipAddress")] - public string SipAddress { get; set; } - } - - - /// - /// Properties for the room's logo on panels - /// - public class EssentialsLogoPropertiesConfig - { - [JsonProperty("type")] - public string Type { get; set; } - - [JsonProperty("url")] - public string Url { get; set; } - /// - /// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo - /// - public string GetLogoUrlLight() - { - if (Type == "url") - return Url; - if (Type == "system") - return string.Format("http://{0}:8080/logo.png", - CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); - return null; - } - - public string GetLogoUrlDark() - { - if (Type == "url") - return Url; - if (Type == "system") - return string.Format("http://{0}:8080/logo-dark.png", - CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)); - return null; - } - } - - /// - /// Represents occupancy sensor(s) setup for a room - /// - public class EssentialsRoomOccSensorConfig - { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } - - [JsonProperty("timeoutMinutes")] - public int TimeoutMinutes { get; set; } - } - - public class EssentialsRoomTechConfig - { - [JsonProperty("password")] - public string Password { get; set; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfigHelper.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfigHelper.cs new file mode 100644 index 00000000..362b9231 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomConfigHelper.cs @@ -0,0 +1,137 @@ +extern alias Full; +using System.Linq; +using System.Text; +using PepperDash.Core; +using PepperDash.Essentials; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomConfigHelper + { + /// + /// Returns a room object from this config data + /// + /// + public static IKeyed GetRoomObject(DeviceConfig roomConfig) + { + var typeName = roomConfig.Type.ToLower(); + + switch (typeName) + { + case "huddle" : + { + return new EssentialsHuddleSpaceRoom(roomConfig); + } + case "huddlevtc1" : + { + return new EssentialsHuddleVtc1Room(roomConfig); + } + case "ddvc01bridge" : + { + return new Device(roomConfig.Key, roomConfig.Name); // placeholder device that does nothing. + } + case "dualdisplay" : + { + return new EssentialsDualDisplayRoom(roomConfig); + } + case "combinedhuddlevtc1" : + { + return new EssentialsCombinedHuddleVtc1Room(roomConfig); + } + case "techroom" : + { + return new EssentialsTechRoom(roomConfig); + } + default : + { + return Core.DeviceFactory.GetDevice(roomConfig); + } + } + } + + /// + /// Gets and operating, standalone emergegncy object that can be plugged into a room. + /// Returns null if there is no emergency defined + /// + public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, IEssentialsRoom room) + { + // This emergency + var emergency = props.Emergency; + if (emergency != null) + { + //switch on emergency type here. Right now only contact and shutdown + var e = new EssentialsRoomEmergencyContactClosure(room.Key + "-emergency", props.Emergency, room); + DeviceManager.AddDevice(e); + } + return null; + } + + /// + /// + /// + /// + /// + /// + public static Core.Privacy.MicrophonePrivacyController GetMicrophonePrivacy( + EssentialsRoomPropertiesConfig props, IPrivacy room) + { + var microphonePrivacy = props.MicrophonePrivacy; + if (microphonePrivacy == null) + { + Debug.Console(0, "Cannot create microphone privacy with null properties"); + return null; + } + // Get the MicrophonePrivacy device from the device manager + var mP = (DeviceManager.GetDeviceForKey(props.MicrophonePrivacy.DeviceKey) as + Core.Privacy.MicrophonePrivacyController); + // Set this room as the IPrivacy device + if (mP == null) + { + Debug.Console(0, "ERROR: Selected device {0} is not MicrophonePrivacyController", props.MicrophonePrivacy.DeviceKey); + return null; + } + mP.SetPrivacyDevice(room); + + var behaviour = props.MicrophonePrivacy.Behaviour.ToLower(); + + if (behaviour == null) + { + Debug.Console(0, "WARNING: No behaviour defined for MicrophonePrivacyController"); + return null; + } + if (behaviour == "trackroomstate") + { + // Tie LED enable to room power state + var essRoom = room as IEssentialsRoom; + essRoom.OnFeedback.OutputChange += (o, a) => + { + if (essRoom.OnFeedback.BoolValue) + mP.EnableLeds = true; + else + mP.EnableLeds = false; + }; + + mP.EnableLeds = essRoom.OnFeedback.BoolValue; + } + else if (behaviour == "trackcallstate") + { + // Tie LED enable to room power state + var inCallRoom = room as IHasInCallFeedback; + inCallRoom.InCallFeedback.OutputChange += (o, a) => + { + if (inCallRoom.InCallFeedback.BoolValue) + mP.EnableLeds = true; + else + mP.EnableLeds = false; + }; + + mP.EnableLeds = inCallRoom.InCallFeedback.BoolValue; + } + + return mP; + } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyConfig.cs index 69d04579..ec0b00e8 100644 --- a/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyConfig.cs +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyConfig.cs @@ -15,22 +15,4 @@ namespace PepperDash.Essentials.Room.Config public string Behavior { get; set; } } - - /// - /// - /// - public class EssentialsRoomEmergencyTriggerConfig - { - /// - /// contact, - /// - public string Type { get; set; } - /// - /// Input number if contact - /// - public int Number { get; set; } - - public bool TriggerOnClose { get; set; } - - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyTriggerConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyTriggerConfig.cs new file mode 100644 index 00000000..f863fb50 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomEmergencyTriggerConfig.cs @@ -0,0 +1,20 @@ +namespace PepperDash.Essentials.Room.Config +{ + /// + /// + /// + public class EssentialsRoomEmergencyTriggerConfig + { + /// + /// contact, + /// + public string Type { get; set; } + /// + /// Input number if contact + /// + public int Number { get; set; } + + public bool TriggerOnClose { get; set; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomFusionConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomFusionConfig.cs new file mode 100644 index 00000000..1b5327ee --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomFusionConfig.cs @@ -0,0 +1,32 @@ +extern alias Full; +using System; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomFusionConfig + { + public uint IpIdInt + { + get + { + try + { + return Convert.ToUInt32(IpId, 16); + } + catch (Exception) + { + throw new FormatException(string.Format("ERROR:Unable to convert IP ID: {0} to hex. Error:\n{1}", IpId)); + } + + } + } + + [JsonProperty("ipId")] + public string IpId { get; set; } + + [JsonProperty("joinMapKey")] + public string JoinMapKey { get; set; } + + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomMicrophonePrivacyConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomMicrophonePrivacyConfig.cs new file mode 100644 index 00000000..1ab2c808 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomMicrophonePrivacyConfig.cs @@ -0,0 +1,14 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomMicrophonePrivacyConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("behaviour")] + public string Behaviour { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomOccSensorConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomOccSensorConfig.cs new file mode 100644 index 00000000..f82f75d1 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomOccSensorConfig.cs @@ -0,0 +1,17 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + /// + /// Represents occupancy sensor(s) setup for a room + /// + public class EssentialsRoomOccSensorConfig + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("timeoutMinutes")] + public int TimeoutMinutes { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomPropertiesConfig.cs new file mode 100644 index 00000000..2dbdfd98 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomPropertiesConfig.cs @@ -0,0 +1,95 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + /// + /// + /// + public class EssentialsRoomPropertiesConfig + { + [JsonProperty("addresses")] + public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } + + [JsonProperty("description")] + public string Description { get; set; } + + [JsonProperty("emergency")] + public EssentialsRoomEmergencyConfig Emergency { get; set; } + + [JsonProperty("help")] + public EssentialsHelpPropertiesConfig Help { get; set; } + + [JsonProperty("helpMessage")] + public string HelpMessage { get; set; } + + /// + /// Read this value to get the help message. It checks for the old and new config format. + /// + public string HelpMessageForDisplay + { + get + { + if(Help != null && !string.IsNullOrEmpty(Help.Message)) + { + return Help.Message; + } + else + { + return HelpMessage; + } + } + } + + [JsonProperty("environment")] + public EssentialsEnvironmentPropertiesConfig Environment { get; set; } + + [JsonProperty("logo")] + public EssentialsLogoPropertiesConfig LogoLight { get; set; } + + [JsonProperty("logoDark")] + public EssentialsLogoPropertiesConfig LogoDark { get; set; } + + [JsonProperty("microphonePrivacy")] + public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } + + [JsonProperty("occupancy")] + public EssentialsRoomOccSensorConfig Occupancy { get; set; } + + [JsonProperty("oneButtonMeeting")] + public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } + + [JsonProperty("shutdownVacancySeconds")] + public int ShutdownVacancySeconds { get; set; } + + [JsonProperty("shutdownPromptSeconds")] + public int ShutdownPromptSeconds { get; set; } + + [JsonProperty("tech")] + public EssentialsRoomTechConfig Tech { get; set; } + + [JsonProperty("volumes")] + public EssentialsRoomVolumesConfig Volumes { get; set; } + + [JsonProperty("fusion")] + public EssentialsRoomFusionConfig Fusion { get; set; } + + [JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)] + public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; } + + [JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")] + public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } + + /// + /// Indicates if this room represents a combination of other rooms + /// + [JsonProperty("isRoomCombinationScenario")] + public bool IsRoomCombinationScenario { get; set; } + + public EssentialsRoomPropertiesConfig() + { + LogoLight = new EssentialsLogoPropertiesConfig(); + LogoDark = new EssentialsLogoPropertiesConfig(); + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomTechConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomTechConfig.cs new file mode 100644 index 00000000..c75a01d1 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomTechConfig.cs @@ -0,0 +1,11 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomTechConfig + { + [JsonProperty("password")] + public string Password { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/EssentialsRoomUiBehaviorConfig.cs b/src/PepperDash.Essentials/Room/Config/EssentialsRoomUiBehaviorConfig.cs new file mode 100644 index 00000000..fe6abe6c --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/EssentialsRoomUiBehaviorConfig.cs @@ -0,0 +1,11 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class EssentialsRoomUiBehaviorConfig + { + [JsonProperty("disableActivityButtonsWhileWarmingCooling")] + public bool DisableActivityButtonsWhileWarmingCooling { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/SimplRoomPropertiesConfig.cs b/src/PepperDash.Essentials/Room/Config/SimplRoomPropertiesConfig.cs index ad508154..48c85965 100644 --- a/src/PepperDash.Essentials/Room/Config/SimplRoomPropertiesConfig.cs +++ b/src/PepperDash.Essentials/Room/Config/SimplRoomPropertiesConfig.cs @@ -21,12 +21,4 @@ namespace PepperDash.Essentials.Room.Config [JsonProperty("volumeSliderNames")] public List VolumeSliderNames { get; set; } } - - public class SimplSpeedDial - { - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("number")] - public string Number { get; set; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Config/SimplSpeedDial.cs b/src/PepperDash.Essentials/Room/Config/SimplSpeedDial.cs new file mode 100644 index 00000000..e1b1a3d4 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Config/SimplSpeedDial.cs @@ -0,0 +1,13 @@ +extern alias Full; +using Full::Newtonsoft.Json; + +namespace PepperDash.Essentials.Room.Config +{ + public class SimplSpeedDial + { + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("number")] + public string Number { get; set; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs b/src/PepperDash.Essentials/Room/Emergency/EssentialsRoomEmergencyContactClosure.cs similarity index 100% rename from src/PepperDash.Essentials/Room/Emergency/EsentialsRoomEmergencyContactClosure.cs rename to src/PepperDash.Essentials/Room/Emergency/EssentialsRoomEmergencyContactClosure.cs diff --git a/src/PepperDash.Essentials/Room/Types/EssentialsTechRoom.cs b/src/PepperDash.Essentials/Room/Types/EssentialsTechRoom.cs index 5ff997c1..112510ca 100644 --- a/src/PepperDash.Essentials/Room/Types/EssentialsTechRoom.cs +++ b/src/PepperDash.Essentials/Room/Types/EssentialsTechRoom.cs @@ -511,9 +511,4 @@ Params: {2}" #endregion } - - public class ScheduledEventEventArgs : EventArgs - { - public List ScheduledEvents; - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/Room/Types/ScheduledEventEventArgs.cs b/src/PepperDash.Essentials/Room/Types/ScheduledEventEventArgs.cs new file mode 100644 index 00000000..e21b32f6 --- /dev/null +++ b/src/PepperDash.Essentials/Room/Types/ScheduledEventEventArgs.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using PepperDash.Essentials.Room.Config; + +namespace PepperDash.Essentials +{ + public class ScheduledEventEventArgs : EventArgs + { + public List ScheduledEvents; + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UI/EssentialsTouchpanelController.cs b/src/PepperDash.Essentials/UI/EssentialsTouchpanelController.cs index 630f4f67..e67561df 100644 --- a/src/PepperDash.Essentials/UI/EssentialsTouchpanelController.cs +++ b/src/PepperDash.Essentials/UI/EssentialsTouchpanelController.cs @@ -1,20 +1,16 @@ extern alias Full; using System; -using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.UI; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.PageManagers; using PepperDash.Essentials.Core.UI; -using Full.Newtonsoft.Json; namespace PepperDash.Essentials { @@ -206,85 +202,4 @@ namespace PepperDash.Essentials } } } - - public class EssentialsTouchpanelControllerFactory : EssentialsDeviceFactory - { - public EssentialsTouchpanelControllerFactory() - { - TypeNames = new List() { "crestronapp", "tsw550", "tsw750", "tsw1050", "tsw560", "tsw760", "tsw1060", "tsw570", "tsw770", "ts770", "tsw1070", "ts1070", "xpanel" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - var panel = GetPanelForType(dc.Type, comm.IpIdInt, props.ProjectName); - - if (panel == null) - { - Debug.Console(0, "Unable to create Touchpanel for type {0}. Touchpanel Controller WILL NOT function correctly", dc.Type); - } - - Debug.Console(1, "Factory Attempting to create new EssentialsTouchpanelController"); - - var panelController = new EssentialsTouchpanelController(dc.Key, dc.Name, panel, props); - - return panelController; - } - - private BasicTriListWithSmartObject GetPanelForType(string type, uint id, string projectName) - { - type = type.ToLower(); - try - { - if (type == "crestronapp") - { - var app = new CrestronApp(id, Global.ControlSystem); - app.ParameterProjectName.Value = projectName; - return app; - } - else if (type == "xpanel") - return new XpanelForSmartGraphics(id, Global.ControlSystem); - else if (type == "tsw550") - return new Tsw550(id, Global.ControlSystem); - else if (type == "tsw552") - return new Tsw552(id, Global.ControlSystem); - else if (type == "tsw560") - return new Tsw560(id, Global.ControlSystem); - else if (type == "tsw750") - return new Tsw750(id, Global.ControlSystem); - else if (type == "tsw752") - return new Tsw752(id, Global.ControlSystem); - else if (type == "tsw760") - return new Tsw760(id, Global.ControlSystem); - else if (type == "tsw1050") - return new Tsw1050(id, Global.ControlSystem); - else if (type == "tsw1052") - return new Tsw1052(id, Global.ControlSystem); - else if (type == "tsw1060") - return new Tsw1060(id, Global.ControlSystem); - else if (type == "tsw570") - return new Tsw570(id, Global.ControlSystem); - else if (type == "tsw770") - return new Tsw770(id, Global.ControlSystem); - else if (type == "ts770") - return new Ts770(id, Global.ControlSystem); - else if (type == "tsw1070") - return new Tsw1070(id, Global.ControlSystem); - else if (type == "ts1070") - return new Ts1070(id, Global.ControlSystem); - else - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type); - return null; - } - } - catch (Exception e) - { - Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); - return null; - } - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UI/EssentialsTouchpanelControllerFactory.cs b/src/PepperDash.Essentials/UI/EssentialsTouchpanelControllerFactory.cs new file mode 100644 index 00000000..48c3c586 --- /dev/null +++ b/src/PepperDash.Essentials/UI/EssentialsTouchpanelControllerFactory.cs @@ -0,0 +1,93 @@ +extern alias Full; +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.UI; +using Full::Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials +{ + public class EssentialsTouchpanelControllerFactory : EssentialsDeviceFactory + { + public EssentialsTouchpanelControllerFactory() + { + TypeNames = new List() { "crestronapp", "tsw550", "tsw750", "tsw1050", "tsw560", "tsw760", "tsw1060", "tsw570", "tsw770", "ts770", "tsw1070", "ts1070", "xpanel" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + var panel = GetPanelForType(dc.Type, comm.IpIdInt, props.ProjectName); + + if (panel == null) + { + Debug.Console(0, "Unable to create Touchpanel for type {0}. Touchpanel Controller WILL NOT function correctly", dc.Type); + } + + Debug.Console(1, "Factory Attempting to create new EssentialsTouchpanelController"); + + var panelController = new EssentialsTouchpanelController(dc.Key, dc.Name, panel, props); + + return panelController; + } + + private BasicTriListWithSmartObject GetPanelForType(string type, uint id, string projectName) + { + type = type.ToLower(); + try + { + if (type == "crestronapp") + { + var app = new CrestronApp(id, Global.ControlSystem); + app.ParameterProjectName.Value = projectName; + return app; + } + else if (type == "xpanel") + return new XpanelForSmartGraphics(id, Global.ControlSystem); + else if (type == "tsw550") + return new Tsw550(id, Global.ControlSystem); + else if (type == "tsw552") + return new Tsw552(id, Global.ControlSystem); + else if (type == "tsw560") + return new Tsw560(id, Global.ControlSystem); + else if (type == "tsw750") + return new Tsw750(id, Global.ControlSystem); + else if (type == "tsw752") + return new Tsw752(id, Global.ControlSystem); + else if (type == "tsw760") + return new Tsw760(id, Global.ControlSystem); + else if (type == "tsw1050") + return new Tsw1050(id, Global.ControlSystem); + else if (type == "tsw1052") + return new Tsw1052(id, Global.ControlSystem); + else if (type == "tsw1060") + return new Tsw1060(id, Global.ControlSystem); + else if (type == "tsw570") + return new Tsw570(id, Global.ControlSystem); + else if (type == "tsw770") + return new Tsw770(id, Global.ControlSystem); + else if (type == "ts770") + return new Ts770(id, Global.ControlSystem); + else if (type == "tsw1070") + return new Tsw1070(id, Global.ControlSystem); + else if (type == "ts1070") + return new Ts1070(id, Global.ControlSystem); + else + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type); + return null; + } + } + catch (Exception e) + { + Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UI/JoinConstants/UIStringlJoin.cs b/src/PepperDash.Essentials/UI/JoinConstants/UIStringJoin.cs similarity index 100% rename from src/PepperDash.Essentials/UI/JoinConstants/UIStringlJoin.cs rename to src/PepperDash.Essentials/UI/JoinConstants/UIStringJoin.cs diff --git a/src/PepperDash.Essentials/UI/SubpageReferenceListCallStagingItem.cs b/src/PepperDash.Essentials/UI/SubpageReferenceListButtonAndModeItem.cs similarity index 100% rename from src/PepperDash.Essentials/UI/SubpageReferenceListCallStagingItem.cs rename to src/PepperDash.Essentials/UI/SubpageReferenceListButtonAndModeItem.cs diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs index 978206eb..4e0e0a63 100644 --- a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsEnvironmentDriver.cs @@ -247,10 +247,4 @@ namespace PepperDash.Essentials } } - - public interface IEnvironmentSubdriver - { - uint SubpageVisibleJoin { get; } - } - } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs index 5ec46a04..9be7c418 100644 --- a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsLightingDriver.cs @@ -201,10 +201,4 @@ namespace PepperDash.Essentials return joinOffset; } } - - enum eLightsDeviceType : uint - { - None = 0, - Scenes = 1, - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs index 9ab9ad54..4c7bd4ef 100644 --- a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/EssentialsShadeDriver.cs @@ -106,12 +106,4 @@ namespace PepperDash.Essentials } } } - - enum eShadeDeviceType : uint - { - None = 0, - OpenCloseStop = 1, - OpenClose = 2, - DiscreteLevel = 3 - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/IEnvironmentSubdriver.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/IEnvironmentSubdriver.cs new file mode 100644 index 00000000..f70892a6 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/IEnvironmentSubdriver.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials +{ + public interface IEnvironmentSubdriver + { + uint SubpageVisibleJoin { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eLightsDeviceType.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eLightsDeviceType.cs new file mode 100644 index 00000000..36508b92 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eLightsDeviceType.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials +{ + enum eLightsDeviceType : uint + { + None = 0, + Scenes = 1, + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eShadeDeviceType.cs b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eShadeDeviceType.cs new file mode 100644 index 00000000..4d706138 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/Environment Drivers/eShadeDeviceType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials +{ + enum eShadeDeviceType : uint + { + None = 0, + OpenCloseStop = 1, + OpenClose = 2, + DiscreteLevel = 3 + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs b/src/PepperDash.Essentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs index 6b9ae605..f5656eca 100644 --- a/src/PepperDash.Essentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs +++ b/src/PepperDash.Essentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs @@ -160,9 +160,4 @@ namespace PepperDash.Essentials CurrentChildDriver.BackButtonPressed(); } } - - public interface IHasScreenSaverController - { - ScreenSaverController ScreenSaverController { get; } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/Essentials/IHasScreenSaverController.cs b/src/PepperDash.Essentials/UIDrivers/Essentials/IHasScreenSaverController.cs new file mode 100644 index 00000000..074ce62b --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/Essentials/IHasScreenSaverController.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials +{ + public interface IHasScreenSaverController + { + ScreenSaverController ScreenSaverController { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 78aeb311..07cd1684 100644 --- a/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -1614,39 +1614,4 @@ namespace PepperDash.Essentials RefreshSourceInfo(); } } - - /// - /// For hanging off various common AV things that child drivers might need from a parent AV driver - /// - public interface IAVDriver - { - PanelDriverBase Parent { get; } - JoinedSigInterlock PopupInterlock { get; } - void ShowNotificationRibbon(string message, int timeout); - void HideNotificationRibbon(); - void ShowTech(); - uint StartPageVisibleJoin { get; } - } - - /// - /// For hanging off various common VC things that child drivers might need from a parent AV driver - /// - public interface IAVWithVCDriver : IAVDriver - { - IEssentialsHuddleVtc1Room CurrentRoom { get; } - - PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; } - /// - /// Exposes the ability to switch into call mode - /// - void ActivityCallButtonPressed(); - /// - /// Allows the codec to trigger the main UI to clear up if call is coming in. - /// - void PrepareForCodecIncomingCall(); - - uint CallListOrMeetingInfoPopoverVisibilityJoin { get; } - - SubpageReferenceList MeetingOrContactMethodModalSrl { get; } - } } diff --git a/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVDriver.cs b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVDriver.cs new file mode 100644 index 00000000..0a9436d7 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVDriver.cs @@ -0,0 +1,15 @@ +namespace PepperDash.Essentials +{ + /// + /// For hanging off various common AV things that child drivers might need from a parent AV driver + /// + public interface IAVDriver + { + PanelDriverBase Parent { get; } + JoinedSigInterlock PopupInterlock { get; } + void ShowNotificationRibbon(string message, int timeout); + void HideNotificationRibbon(); + void ShowTech(); + uint StartPageVisibleJoin { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVWithVCDriver.cs b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVWithVCDriver.cs new file mode 100644 index 00000000..a4ea4c71 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/EssentialsHuddleVTC/IAVWithVCDriver.cs @@ -0,0 +1,26 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials +{ + /// + /// For hanging off various common VC things that child drivers might need from a parent AV driver + /// + public interface IAVWithVCDriver : IAVDriver + { + IEssentialsHuddleVtc1Room CurrentRoom { get; } + + PepperDash.Essentials.Core.Touchpanels.Keyboards.HabaneroKeyboardController Keyboard { get; } + /// + /// Exposes the ability to switch into call mode + /// + void ActivityCallButtonPressed(); + /// + /// Allows the codec to trigger the main UI to clear up if call is coming in. + /// + void PrepareForCodecIncomingCall(); + + uint CallListOrMeetingInfoPopoverVisibilityJoin { get; } + + SubpageReferenceList MeetingOrContactMethodModalSrl { get; } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/JoinedSigInterlock.cs b/src/PepperDash.Essentials/UIDrivers/JoinedSigInterlock.cs index bdcaa84e..30b8424c 100644 --- a/src/PepperDash.Essentials/UIDrivers/JoinedSigInterlock.cs +++ b/src/PepperDash.Essentials/UIDrivers/JoinedSigInterlock.cs @@ -156,20 +156,4 @@ namespace PepperDash.Essentials handler(this, new StatusChangedEventArgs(prevJoin, newJoin, wasShown, isShown)); } } - - public class StatusChangedEventArgs : EventArgs - { - public uint PreviousJoin { get; set; } - public uint NewJoin { get; set; } - public bool WasShown { get; set; } - public bool IsShown { get; set; } - - public StatusChangedEventArgs(uint prevJoin, uint newJoin, bool wasShown, bool isShown) - { - PreviousJoin = prevJoin; - NewJoin = newJoin; - WasShown = wasShown; - IsShown = isShown; - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/enums and base.cs b/src/PepperDash.Essentials/UIDrivers/PanelDriverBase.cs similarity index 85% rename from src/PepperDash.Essentials/UIDrivers/enums and base.cs rename to src/PepperDash.Essentials/UIDrivers/PanelDriverBase.cs index dbb1a681..6480b051 100644 --- a/src/PepperDash.Essentials/UIDrivers/enums and base.cs +++ b/src/PepperDash.Essentials/UIDrivers/PanelDriverBase.cs @@ -5,44 +5,7 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials { - public enum eAvSubpageType - { - NoControls, - PowerOff, - SetupFullDistributed, - SourceWaitOverlay, - TopBar, - VolumePopup, - ZoneSource - } - - public enum eAvSourceSubpageType - { - AppleTv, - Radio, - Roku - } - - public enum eCommonSubpageType - { - GenericModal, - Home, - PanelSetup, - Weather - } - - public enum eAvSmartObjects - { - RoomList, - SourceList - } - - public enum eCommonSmartObjects - { - HomePageList - } - - /// + /// /// /// public abstract class PanelDriverBase diff --git a/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsList.cs b/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsList.cs index 2543e664..2864a7b2 100644 --- a/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsList.cs +++ b/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsList.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.SmartObjects; namespace PepperDash.Essentials @@ -45,50 +42,4 @@ namespace PepperDash.Essentials SetFeedback(itemToSet.Index, true); } } - - public class SmartObjectRoomsListItem - { - public IEssentialsHuddleSpaceRoom Room { get; private set; } - SmartObjectRoomsList Parent; - public uint Index { get; private set; } - - public SmartObjectRoomsListItem(IEssentialsHuddleSpaceRoom room, uint index, SmartObjectRoomsList parent, - Action buttonAction) - { - Room = room; - Parent = parent; - Index = index; - if (room == null) return; - - // Set "now" states - parent.SetItemMainText(index, room.Name); - UpdateItem(room.CurrentSourceInfo); - // Watch for later changes - room.CurrentSourceChange += new SourceInfoChangeHandler(room_CurrentSourceInfoChange); - parent.SetItemButtonAction(index, buttonAction); - } - - void room_CurrentSourceInfoChange(SourceListItem info, ChangeType type) - { - UpdateItem(info); - } - - /// - /// Helper to handle source events and startup syncing with room's current source - /// - /// - void UpdateItem(SourceListItem info) - { - if (info == null || info.Type == eSourceListItemType.Off) - { - Parent.SetItemStatusText(Index, ""); - Parent.SetItemIcon(Index, "Blank"); - } - else - { - Parent.SetItemStatusText(Index, info.PreferredName); - Parent.SetItemIcon(Index, info.AltIcon); - } - } - } } \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsListItem.cs b/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsListItem.cs new file mode 100644 index 00000000..d32a0b8c --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/SmartObjectRoomsListItem.cs @@ -0,0 +1,51 @@ +using System; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials +{ + public class SmartObjectRoomsListItem + { + public IEssentialsHuddleSpaceRoom Room { get; private set; } + SmartObjectRoomsList Parent; + public uint Index { get; private set; } + + public SmartObjectRoomsListItem(IEssentialsHuddleSpaceRoom room, uint index, SmartObjectRoomsList parent, + Action buttonAction) + { + Room = room; + Parent = parent; + Index = index; + if (room == null) return; + + // Set "now" states + parent.SetItemMainText(index, room.Name); + UpdateItem(room.CurrentSourceInfo); + // Watch for later changes + room.CurrentSourceChange += new SourceInfoChangeHandler(room_CurrentSourceInfoChange); + parent.SetItemButtonAction(index, buttonAction); + } + + void room_CurrentSourceInfoChange(SourceListItem info, ChangeType type) + { + UpdateItem(info); + } + + /// + /// Helper to handle source events and startup syncing with room's current source + /// + /// + void UpdateItem(SourceListItem info) + { + if (info == null || info.Type == eSourceListItemType.Off) + { + Parent.SetItemStatusText(Index, ""); + Parent.SetItemIcon(Index, "Blank"); + } + else + { + Parent.SetItemStatusText(Index, info.PreferredName); + Parent.SetItemIcon(Index, info.AltIcon); + } + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/StatusChangedEventArgs.cs b/src/PepperDash.Essentials/UIDrivers/StatusChangedEventArgs.cs new file mode 100644 index 00000000..a9f0237d --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/StatusChangedEventArgs.cs @@ -0,0 +1,20 @@ +using System; + +namespace PepperDash.Essentials +{ + public class StatusChangedEventArgs : EventArgs + { + public uint PreviousJoin { get; set; } + public uint NewJoin { get; set; } + public bool WasShown { get; set; } + public bool IsShown { get; set; } + + public StatusChangedEventArgs(uint prevJoin, uint newJoin, bool wasShown, bool isShown) + { + PreviousJoin = prevJoin; + NewJoin = newJoin; + WasShown = wasShown; + IsShown = isShown; + } + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/eAvSmartObjects.cs b/src/PepperDash.Essentials/UIDrivers/eAvSmartObjects.cs new file mode 100644 index 00000000..c699236a --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/eAvSmartObjects.cs @@ -0,0 +1,8 @@ +namespace PepperDash.Essentials +{ + public enum eAvSmartObjects + { + RoomList, + SourceList + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/eAvSourceSubpageType.cs b/src/PepperDash.Essentials/UIDrivers/eAvSourceSubpageType.cs new file mode 100644 index 00000000..4624bec9 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/eAvSourceSubpageType.cs @@ -0,0 +1,9 @@ +namespace PepperDash.Essentials +{ + public enum eAvSourceSubpageType + { + AppleTv, + Radio, + Roku + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/eAvSubpageType.cs b/src/PepperDash.Essentials/UIDrivers/eAvSubpageType.cs new file mode 100644 index 00000000..641764a9 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/eAvSubpageType.cs @@ -0,0 +1,13 @@ +namespace PepperDash.Essentials +{ + public enum eAvSubpageType + { + NoControls, + PowerOff, + SetupFullDistributed, + SourceWaitOverlay, + TopBar, + VolumePopup, + ZoneSource + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/eCommonSmartObjects.cs b/src/PepperDash.Essentials/UIDrivers/eCommonSmartObjects.cs new file mode 100644 index 00000000..aceed8c7 --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/eCommonSmartObjects.cs @@ -0,0 +1,7 @@ +namespace PepperDash.Essentials +{ + public enum eCommonSmartObjects + { + HomePageList + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials/UIDrivers/eCommonSubpageType.cs b/src/PepperDash.Essentials/UIDrivers/eCommonSubpageType.cs new file mode 100644 index 00000000..170167ea --- /dev/null +++ b/src/PepperDash.Essentials/UIDrivers/eCommonSubpageType.cs @@ -0,0 +1,10 @@ +namespace PepperDash.Essentials +{ + public enum eCommonSubpageType + { + GenericModal, + Home, + PanelSetup, + Weather + } +} \ No newline at end of file