From 56c339bb084bdd07ca5b3e03785be7aa042691c1 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 22 Apr 2020 16:17:07 -0600 Subject: [PATCH] Finishes converting all existing types to new DeviceFactory mechanism. #106 --- PepperDashEssentials/Bridges/BridgeFactory.cs | 5 +- PepperDashEssentials/ControlSystem.cs | 6 +- .../Inputs/GenericDigitalInputDevice.cs | 92 +++++ .../Inputs/GenericVersiportInputDevice.cs | 2 +- .../Crestron IO/Relay/GenericRelayDevice.cs | 71 ++++ .../Factory/DeviceFactory.cs | 2 +- .../MicrophonePrivacyController.cs | 20 +- .../Shades/ShadeBase.cs | 2 +- .../Shades/ShadeController.cs | 20 +- .../AudioCodec/AudioCodecBase.cs | 2 +- .../AudioCodec/MockAC/MockAC.cs | 17 + .../Display/AvocorVTFDisplay.cs | 21 ++ .../Display/DeviceFactory.cs | 55 +-- .../Display/NECPSXMDisplay.cs | 20 ++ .../Display/PanasonicThDisplay.cs | 30 +- .../Display/SamsungMDCDisplay.cs | 22 ++ .../Environment/Crestron Lighting/Din8sw8.cs | 20 +- .../Environment/Lutron/LutronQuantum.cs | 20 ++ .../Environment/Somfy/RelayControlledShade.cs | 18 + .../Factory/DeviceFactory.cs | 322 +++--------------- .../ImageProcessors/TVOneCorio.cs | 21 +- .../GlsOccupancySensorBaseController.cs | 35 ++ .../GlsOdtOccupancySensorController.cs | 34 ++ .../SetTopBox/IRSetTopBoxBase.cs | 24 ++ .../SoftCodec/BlueJeansPc.cs | 15 + .../Streaming/Roku.cs | 20 +- .../VideoCodec/CiscoCodec/CiscoSparkCodec.cs | 15 + .../VideoCodec/MockVC/MockVC.cs | 15 + .../VideoCodec/ZoomRoom/ZoomRoom.cs | 16 + 29 files changed, 626 insertions(+), 336 deletions(-) diff --git a/PepperDashEssentials/Bridges/BridgeFactory.cs b/PepperDashEssentials/Bridges/BridgeFactory.cs index 6371ca08..a4ed136a 100644 --- a/PepperDashEssentials/Bridges/BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/BridgeFactory.cs @@ -22,13 +22,12 @@ namespace PepperDash.Essentials { public BridgeFactory() { - var bridgeFactory = new BridgeFactory() as IDeviceFactory; - bridgeFactory.LoadTypeFactories(); + var eiscApiFactory = new EiscApiFactory() as IDeviceFactory; + eiscApiFactory.LoadTypeFactories(); } } - public class CommBridge : Device { public CommBridgeProperties Properties { get; private set; } diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f2e64529..563818c7 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -100,7 +100,7 @@ namespace PepperDash.Essentials new BridgeFactory(); new PepperDash.Essentials.Devices.Common.DeviceFactory(); - + new PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory(); } @@ -378,8 +378,8 @@ namespace PepperDash.Essentials newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); // - if (newDev == null) - newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); + //if (newDev == null) + // newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); // if (newDev != null) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs index 7abda21e..74a813d6 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericDigitalInputDevice.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.CrestronIO @@ -67,4 +68,95 @@ namespace PepperDash.Essentials.Core.CrestronIO } } } + + public class GenericDigitalInputDeviceFactory : EssentialsDeviceFactory + { + public GenericDigitalInputDeviceFactory() + { + TypeNames = new List() { "digitalinput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Digtal Input Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + IDigitalInputPorts portDevice; + + if (props.PortDeviceKey == "processor") + portDevice = Global.ControlSystem as IDigitalInputPorts; + else + portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts; + + if (portDevice == null) + Debug.Console(0, "ERROR: Unable to add digital input device with key '{0}'. Port Device does not support digital inputs", dc.Key); + else + { + var cs = (portDevice as CrestronControlSystem); + if (cs == null) + { + Debug.Console(0, "ERROR: Port device for [{0}] is not control system", props.PortDeviceKey); + return null; + } + + if (cs.SupportsVersiport) + { + Debug.Console(1, "Attempting to add Digital Input device to Versiport port '{0}'", props.PortNumber); + + if (props.PortNumber > cs.NumberOfVersiPorts) + { + Debug.Console(0, "WARNING: Cannot add Vesiport {0} on {1}. Out of range", + props.PortNumber, props.PortDeviceKey); + return null; + } + + Versiport vp = cs.VersiPorts[props.PortNumber]; + + if (!vp.Registered) + { + var regSuccess = vp.Register(); + if (regSuccess == eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(1, "Successfully Created Digital Input Device on Versiport"); + return new GenericVersiportDigitalInputDevice(dc.Key, vp, props); + } + else + { + Debug.Console(0, "WARNING: Attempt to register versiport {0} on device with key '{1}' failed: {2}", + props.PortNumber, props.PortDeviceKey, regSuccess); + return null; + } + } + } + else if (cs.SupportsDigitalInput) + { + Debug.Console(1, "Attempting to add Digital Input device to Digital Input port '{0}'", props.PortNumber); + + if (props.PortNumber > cs.NumberOfDigitalInputPorts) + { + Debug.Console(0, "WARNING: Cannot register DIO port {0} on {1}. Out of range", + props.PortNumber, props.PortDeviceKey); + return null; + } + + DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber]; + + if (!digitalInput.Registered) + { + if (digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + { + Debug.Console(1, "Successfully Created Digital Input Device on Digital Input"); + return new GenericDigitalInputDevice(dc.Key, digitalInput); + } + else + Debug.Console(0, "WARNING: Attempt to register digital input {0} on device with key '{1}' failed.", + props.PortNumber, props.PortDeviceKey); + } + } + } + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs index 4c5359b9..90ff4fa0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Inputs/GenericVersiportInputDevice.cs @@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.CrestronIO /// /// Represents a generic digital input deviced tied to a versiport /// - public class GenericVersiportDigitalInputDevice : Device, IDigitalInput + public class GenericVersiportDigitalInputDevice : EssentialsDevice, IDigitalInput { public Versiport InputPort { get; private set; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs index 95d64976..a085155c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Relay/GenericRelayDevice.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Devices; namespace PepperDash.Essentials.Core.CrestronIO @@ -101,4 +102,74 @@ namespace PepperDash.Essentials.Core.CrestronIO OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]); } } + + public class GenericRelayDeviceFactory : EssentialsDeviceFactory + { + public GenericRelayDeviceFactory() + { + TypeNames = new List() { "relayoutput" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new Generic Relay Device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + var key = dc.Key; + + IRelayPorts portDevice; + + if (props.PortDeviceKey == "processor") + portDevice = Global.ControlSystem as IRelayPorts; + else + portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IRelayPorts; + + if (portDevice == null) + Debug.Console(0, "Unable to add relay device with key '{0}'. Port Device does not support relays", key); + else + { + var cs = (portDevice as CrestronControlSystem); + + if (cs != null) + { + // The relay is on a control system processor + if (!cs.SupportsRelay || props.PortNumber > cs.NumberOfRelayPorts) + { + Debug.Console(0, "Port Device: {0} does not support relays or does not have enough relays"); + return null; + } + } + else + { + // The relay is on another device type + + if (props.PortNumber > portDevice.NumberOfRelayPorts) + { + Debug.Console(0, "Port Device: {0} does not have enough relays"); + return null; + } + } + + Relay relay = portDevice.RelayPorts[props.PortNumber]; + + if (!relay.Registered) + { + if (relay.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + return new GenericRelayDevice(key, relay); + else + Debug.Console(0, "Attempt to register relay {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); + } + else + { + return new GenericRelayDevice(key, relay); + } + + // Future: Check if portDevice is 3-series card or other non control system that supports versiports + } + + return null; + + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 80725cc3..4e12ab05 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -105,7 +105,7 @@ namespace PepperDash.Essentials.Core Debug.Console(0, "Device Types:"); - foreach (var type in types) + foreach (var type in types.OrderBy(t => t.Key)) { var description = type.Value.Description; var cType = "Not Specified by Plugin"; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs index e238c40e..ece2c65f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Microphone Privacy/MicrophonePrivacyController.cs @@ -6,6 +6,7 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.CrestronIO; @@ -15,7 +16,7 @@ namespace PepperDash.Essentials.Core.Privacy /// Used for applications where one or more microphones with momentary contact closure outputs are used to /// toggle the privacy state of the room. Privacy state feedback is represented /// - public class MicrophonePrivacyController : Device + public class MicrophonePrivacyController : EssentialsDevice { MicrophonePrivacyControllerConfig Config; @@ -225,4 +226,21 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs index 636a5440..d30b716a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeBase.cs @@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.Shades /// /// Base class for a shade device /// - public abstract class ShadeBase : Device, IShadesOpenClose + public abstract class ShadeBase : EssentialsDevice, IShadesOpenClose { public ShadeBase(string key, string name) : base(key, name) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs index b226af05..fc50f631 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Shades/ShadeController.cs @@ -5,13 +5,14 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core.Shades { /// /// Class that contains the shades to be controlled in a room /// - public class ShadeController : Device, IShades + public class ShadeController : EssentialsDevice, IShades { ShadeControllerConfigProperties Config; @@ -55,4 +56,21 @@ namespace PepperDash.Essentials.Core.Shades 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs index 15a998a4..56998d46 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/AudioCodecBase.cs @@ -10,7 +10,7 @@ using PepperDash.Essentials.Devices.Common.Codec; namespace PepperDash.Essentials.Devices.Common.AudioCodec { - public abstract class AudioCodecBase : Device, IHasDialer, IUsageTracking, IAudioCodecInfo + public abstract class AudioCodecBase : EssentialsDevice, IHasDialer, IUsageTracking, IAudioCodecInfo { public event EventHandler CallStatusChange; diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs index e0645624..84880654 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/AudioCodec/MockAC/MockAC.cs @@ -6,6 +6,7 @@ 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 @@ -111,4 +112,20 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs index 805a3a12..823d1751 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/AvocorVTFDisplay.cs @@ -9,6 +9,7 @@ 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; @@ -725,4 +726,24 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/DeviceFactory.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/DeviceFactory.cs index 8b4941d7..099e1204 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/DeviceFactory.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/DeviceFactory.cs @@ -14,51 +14,20 @@ namespace PepperDash.Essentials.Devices.Displays { public class DisplayDeviceFactory { - public static IKeyed GetDevice(DeviceConfig dc) - { - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; + public DisplayDeviceFactory() + { + var necFactory = new NecPSXMDisplayFactory() as IDeviceFactory; + necFactory.LoadTypeFactories(); - var typeName = dc.Type.ToLower(); + var panasonicThFactory = new PanasonicThDisplayFactory() as IDeviceFactory; + panasonicThFactory.LoadTypeFactories(); - try - { - if (typeName == "necmpsx") - { - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new NecPSXMDisplay(dc.Key, dc.Name, comm); - } - if (typeName == "panasonicthef") - { - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new PanasonicThefDisplay(dc.Key, dc.Name, comm); - } - else if(typeName == "samsungmdc") - { - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new SamsungMDC(dc.Key, dc.Name, comm, dc.Properties["id"].Value()); - } - if (typeName == "avocorvtf") - { - var comm = CommFactory.CreateCommForDevice(dc); - if (comm != null) - return new AvocorDisplay(dc.Key, dc.Name, comm, null); - } - - } - catch (Exception e) - { - Debug.Console(0, "Displays factory: Exception creating device type {0}, key {1}: \nCONFIG JSON: {2} \nERROR: {3}\n\n", - dc.Type, dc.Key, JsonConvert.SerializeObject(dc), e); - return null; - } + var samsungMdcFactory = new SamsungMDCFactory() as IDeviceFactory; + samsungMdcFactory.LoadTypeFactories(); + + var avocorFactory = new AvocorDisplayFactory() as IDeviceFactory; + avocorFactory.LoadTypeFactories(); + } - return null; - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs index 316d0ed7..b95233bc 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/NECPSXMDisplay.cs @@ -7,6 +7,7 @@ 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; @@ -361,4 +362,23 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs index a493b517..9d461420 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/PanasonicThDisplay.cs @@ -7,6 +7,7 @@ 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; @@ -16,7 +17,7 @@ namespace PepperDash.Essentials.Devices.Displays /// /// /// - public class PanasonicThefDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor + public class PanasonicThDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, ICommunicationMonitor { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -73,7 +74,7 @@ namespace PepperDash.Essentials.Devices.Displays /// /// Constructor for IBasicCommunication /// - public PanasonicThefDisplay(string key, string name, IBasicCommunication comm) + public PanasonicThDisplay(string key, string name, IBasicCommunication comm) : base(key, name) { Communication = comm; @@ -82,7 +83,7 @@ namespace PepperDash.Essentials.Devices.Displays /// /// Constructor for TCP /// - public PanasonicThefDisplay(string key, string name, string hostname, int port) + public PanasonicThDisplay(string key, string name, string hostname, int port) : base(key, name) { Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000); @@ -93,7 +94,7 @@ namespace PepperDash.Essentials.Devices.Displays /// /// Constructor for COM /// - public PanasonicThefDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec) + public PanasonicThDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec) : base(key, name) { Communication = new ComPortController(key + "-com", port, spec); @@ -132,7 +133,7 @@ namespace PepperDash.Essentials.Devices.Displays //}; } - ~PanasonicThefDisplay() + ~PanasonicThDisplay() { PortGather = null; } @@ -343,4 +344,23 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs index 4fbce220..3df4a20d 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Display/SamsungMDCDisplay.cs @@ -9,9 +9,12 @@ 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 Newtonsoft.Json.Linq; + namespace PepperDash.Essentials.Devices.Displays { /// @@ -637,4 +640,23 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs index e371d2d1..b262ef84 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Crestron Lighting/Din8sw8.cs @@ -9,11 +9,12 @@ 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 { - public class Din8sw8Controller : Device, ISwitchedOutputCollection + public class Din8sw8Controller : EssentialsDevice, ISwitchedOutputCollection { // Need to figure out some sort of interface to make these switched outputs behave like processor relays so they can be used interchangably @@ -85,4 +86,21 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs index a752a5b4..7d1b00fb 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Lutron/LutronQuantum.cs @@ -6,6 +6,7 @@ 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; @@ -264,4 +265,23 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Lutron // 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs index 22e06d03..a78e5045 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Environment/Somfy/RelayControlledShade.cs @@ -6,6 +6,7 @@ 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; @@ -110,4 +111,21 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs index fc07a6dc..8904b8c3 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs @@ -60,280 +60,56 @@ namespace PepperDash.Essentials.Devices.Common var laptopFactory = new Core.Devices.LaptopFactory() as IDeviceFactory; laptopFactory.LoadTypeFactories(); + var blueJeansPcFactory = new SoftCodec.BlueJeansPcFactory() as IDeviceFactory; + blueJeansPcFactory.LoadTypeFactories(); + var mockAcFactory = new AudioCodec.MockACFactory() as IDeviceFactory; + mockAcFactory.LoadTypeFactories(); + + var mockVcFactory = new VideoCodec.MockVCFactory() as IDeviceFactory; + mockVcFactory.LoadTypeFactories(); + + var ciscoCodecFactory = new VideoCodec.Cisco.CiscoSparkCodecFactory() as IDeviceFactory; + ciscoCodecFactory.LoadTypeFactories(); + + var zoomRoomFactory = new VideoCodec.ZoomRoom.ZoomRoomFactory() as IDeviceFactory; + zoomRoomFactory.LoadTypeFactories(); + + var digitalInputFactory = new GenericDigitalInputDeviceFactory() as IDeviceFactory; + digitalInputFactory.LoadTypeFactories(); + + var relayFactory = new GenericRelayDeviceFactory() as IDeviceFactory; + relayFactory.LoadTypeFactories(); + + var micPrivacyFactory = new Core.Privacy.MicrophonePrivacyControllerFactory() as IDeviceFactory; + micPrivacyFactory.LoadTypeFactories(); + + var rokuFactory = new Roku2Factory() as IDeviceFactory; + rokuFactory.LoadTypeFactories(); + + var setTopBoxFactory = new IRSetTopBoxBaseFactory() as IDeviceFactory; + setTopBoxFactory.LoadTypeFactories(); + + var tvOneCorioFactory = new TVOneCorioFactory() as IDeviceFactory; + tvOneCorioFactory.LoadTypeFactories(); + + var glsOccSensorBaseFactory = new GlsOccupancySensorBaseControllerFactory() as IDeviceFactory; + glsOccSensorBaseFactory.LoadTypeFactories(); + + var glsOdtOccSensorFactory = new GlsOdtOccupancySensorControllerFactory() as IDeviceFactory; + glsOdtOccSensorFactory.LoadTypeFactories(); + + var lutronQuantumFactory = new Environment.Lutron.LutronQuantumAreaFactory() as IDeviceFactory; + lutronQuantumFactory.LoadTypeFactories(); + + var din8sw8ControllerFactory = new Environment.Lighting.Din8sw8ControllerFactory() as IDeviceFactory; + din8sw8ControllerFactory.LoadTypeFactories(); + + var shadeControllerFactory = new Core.Shades.ShadeControllerFactory() as IDeviceFactory; + shadeControllerFactory.LoadTypeFactories(); + + var relayControlledShadeFactory = new Environment.Somfy.RelayControlledShadeFactory() as IDeviceFactory; + relayControlledShadeFactory.LoadTypeFactories(); } - - public static IKeyed GetDevice(DeviceConfig dc) - { - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - var propAnon = new {}; - JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon); - - var typeName = dc.Type.ToLower(); - var groupName = dc.Group.ToLower(); - - // TODO: Continue from here - if (typeName == "bluejeanspc") - { - return new SoftCodec.BlueJeansPc(key, name); - } - - else if (typeName == "mockvc") - { - return new VideoCodec.MockVC(dc); - } - - else if (typeName == "mockac") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - return new AudioCodec.MockAC(key, name, props); - } - - else if (typeName.StartsWith("ciscospark")) - { - var comm = CommFactory.CreateCommForDevice(dc); - return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm); - } - - else if (typeName == "zoomroom") - { - var comm = CommFactory.CreateCommForDevice(dc); - return new VideoCodec.ZoomRoom.ZoomRoom(dc, comm); - } - - else if (typeName == "digitalinput") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - - IDigitalInputPorts portDevice; - - if (props.PortDeviceKey == "processor") - portDevice = Global.ControlSystem as IDigitalInputPorts; - else - portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts; - - if (portDevice == null) - Debug.Console(0, "ERROR: Unable to add digital input device with key '{0}'. Port Device does not support digital inputs", key); - else - { - var cs = (portDevice as CrestronControlSystem); - if (cs == null) - { - Debug.Console(0, "ERROR: Port device for [{0}] is not control system", props.PortDeviceKey); - return null; - } - - if (cs.SupportsVersiport) - { - Debug.Console(1, "Attempting to add Digital Input device to Versiport port '{0}'", props.PortNumber); - - if (props.PortNumber > cs.NumberOfVersiPorts) - { - Debug.Console(0, "WARNING: Cannot add Vesiport {0} on {1}. Out of range", - props.PortNumber, props.PortDeviceKey); - return null; - } - - Versiport vp = cs.VersiPorts[props.PortNumber]; - - if (!vp.Registered) - { - var regSuccess = vp.Register(); - if (regSuccess == eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(1, "Successfully Created Digital Input Device on Versiport"); - return new GenericVersiportDigitalInputDevice(key, vp, props); - } - else - { - Debug.Console(0, "WARNING: Attempt to register versiport {0} on device with key '{1}' failed: {2}", - props.PortNumber, props.PortDeviceKey, regSuccess); - return null; - } - } - } - else if (cs.SupportsDigitalInput) - { - Debug.Console(1, "Attempting to add Digital Input device to Digital Input port '{0}'", props.PortNumber); - - if (props.PortNumber > cs.NumberOfDigitalInputPorts) - { - Debug.Console(0, "WARNING: Cannot register DIO port {0} on {1}. Out of range", - props.PortNumber, props.PortDeviceKey); - return null; - } - - DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber]; - - if (!digitalInput.Registered) - { - if (digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success) - { - Debug.Console(1, "Successfully Created Digital Input Device on Digital Input"); - return new GenericDigitalInputDevice(key, digitalInput); - } - else - Debug.Console(0, "WARNING: Attempt to register digital input {0} on device with key '{1}' failed.", - props.PortNumber, props.PortDeviceKey); - } - } - } - } - - else if (typeName == "relayoutput") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - - IRelayPorts portDevice; - - if (props.PortDeviceKey == "processor") - portDevice = Global.ControlSystem as IRelayPorts; - else - portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IRelayPorts; - - if (portDevice == null) - Debug.Console(0, "Unable to add relay device with key '{0}'. Port Device does not support relays", key); - else - { - var cs = (portDevice as CrestronControlSystem); - - if (cs != null) - { - // The relay is on a control system processor - if (!cs.SupportsRelay || props.PortNumber > cs.NumberOfRelayPorts) - { - Debug.Console(0, "Port Device: {0} does not support relays or does not have enough relays"); - return null; - } - } - else - { - // The relay is on another device type - - if (props.PortNumber > portDevice.NumberOfRelayPorts) - { - Debug.Console(0, "Port Device: {0} does not have enough relays"); - return null; - } - } - - Relay relay = portDevice.RelayPorts[props.PortNumber]; - - if (!relay.Registered) - { - if (relay.Register() == eDeviceRegistrationUnRegistrationResponse.Success) - return new GenericRelayDevice(key, relay); - else - Debug.Console(0, "Attempt to register relay {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); - } - else - { - return new GenericRelayDevice(key, relay); - } - - // Future: Check if portDevice is 3-series card or other non control system that supports versiports - } - } - - else if (typeName == "microphoneprivacycontroller") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - - return new Core.Privacy.MicrophonePrivacyController(key, props); - } - else if (typeName == "roku") - { - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new Roku2(key, name, irCont); - } - - else if (groupName == "settopbox") //(typeName == "irstbbase") - { - var irCont = IRPortHelper.GetIrOutputPortController(dc); - var config = dc.Properties.ToObject(); - var stb = new IRSetTopBoxBase(key, name, irCont, config); - - //stb.HasDvr = properties.Value("hasDvr"); - var listName = properties.Value("presetsList"); - if (listName != null) - stb.LoadPresets(listName); - return stb; - } - else if (typeName == "tvonecorio") - { - var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new TVOneCorio(key, name, comm, props); - } - - - else if (typeName == "glsoirccn") - { - var comm = CommFactory.GetControlPropertiesConfig(dc); - - GlsOccupancySensorBase occSensor = null; - - occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem); - - if (occSensor != null) - return new GlsOccupancySensorBaseController(key, name, occSensor); - else - Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); - } - - else if (typeName == "glsodtccn") - { - var comm = CommFactory.GetControlPropertiesConfig(dc); - - var occSensor = new GlsOdtCCn(comm.CresnetIdInt, Global.ControlSystem); - - if (occSensor != null) - return new GlsOdtOccupancySensorController(key, name, occSensor); - else - Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); - } - - else if (groupName == "lighting") - { - if (typeName == "lutronqs") - { - var comm = CommFactory.CreateCommForDevice(dc); - - var props = JsonConvert.DeserializeObject(properties.ToString()); - - return new Environment.Lutron.LutronQuantumArea(key, name, comm, props); - } - else if (typeName == "din8sw8") - { - var comm = CommFactory.GetControlPropertiesConfig(dc); - - return new Environment.Lighting.Din8sw8Controller(key, comm.CresnetIdInt); - } - - } - - else if (groupName == "environment") - { - if (typeName == "shadecontroller") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - - return new Core.Shades.ShadeController(key, name, props); - } - else if (typeName == "relaycontrolledshade") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - - return new Environment.Somfy.RelayControlledShade(key, name, props); - } - - } - - return null; - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs index a3dd9745..b5a1004f 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/TVOneCorio.cs @@ -5,13 +5,14 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using System.Text.RegularExpressions; namespace PepperDash.Essentials.Devices.Common { - public class TVOneCorio : Device + public class TVOneCorio : EssentialsDevice { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -238,4 +239,22 @@ namespace PepperDash.Essentials.Devices.Common // public QscDspControlPoint ControlPoint { get; set; } } } + + public class TVOneCorioFactory : EssentialsDeviceFactory + { + public TVOneCorioFactory() + { + TypeNames = new List() { "tvonecorio" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new TVOneCorio Device"); + var comm = CommFactory.CreateCommForDevice(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject( + dc.Properties.ToString()); + return new TVOneCorio(dc.Key, dc.Name, comm, props); + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs index 5fe0c8df..4c13ea0a 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.GeneralIO; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Common.Occupancy @@ -365,4 +366,38 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); } } + + public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory + { + public GlsOccupancySensorBaseControllerFactory() + { + TypeNames = new List() { "glsoirccn" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + var typeName = dc.Type.ToLower(); + var key = dc.Key; + var name = dc.Name; + var comm = CommFactory.GetControlPropertiesConfig(dc); + + GlsOccupancySensorBase occSensor = null; + + occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem); + + if (occSensor != null) + { + return new GlsOccupancySensorBaseController(key, name, occSensor); + } + else + { + Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); + return null; + } + + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs index 37a2acb4..f7c1f937 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.GeneralIO; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.Devices.Common.Occupancy @@ -159,4 +160,37 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); } } + + 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"); + + var typeName = dc.Type.ToLower(); + var key = dc.Key; + var name = dc.Name; + var comm = CommFactory.GetControlPropertiesConfig(dc); + + var occSensor = new GlsOdtCCn(comm.CresnetIdInt, Global.ControlSystem); + + if (occSensor != null) + { + return new GlsOdtOccupancySensorController(key, name, occSensor); + } + else + { + Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key); + return null; + } + + + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs index 5e25fce9..0d78968b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs @@ -9,6 +9,7 @@ using 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.Devices; @@ -462,4 +463,27 @@ namespace PepperDash.Essentials.Devices.Common trilist.SetBoolSigAction(joinMap.Record, stbTransport.Record); } } + + 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs index 462ae5cb..78043111 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SoftCodec/BlueJeansPc.cs @@ -161,4 +161,19 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec #endregion } + + public class BlueJeansPcFactory : EssentialsDeviceFactory + { + public BlueJeansPcFactory() + { + TypeNames = new List() { "mockvc" }; + } + + 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs index 1c162040..49f96c31 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/Roku.cs @@ -8,11 +8,12 @@ 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 { - public class Roku2 : Device, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs + public class Roku2 : EssentialsDevice, IDPad, ITransport, IUiDisplayInfo, IRoutingOutputs { [Api] public IrOutputPortController IrPort { get; private set; } @@ -145,4 +146,21 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index f8f7b298..cad7a18c 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -1843,4 +1843,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco } } + public class CiscoSparkCodecFactory : EssentialsDeviceFactory + { + public CiscoSparkCodecFactory() + { + TypeNames = new List() { "ciscospark", "ciscowebex", "ciscowebexpro", "ciscoroomkit" }; + } + + 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs index d6580b67..dc32ecd8 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs @@ -770,4 +770,19 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec _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/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs index 84881df3..13fa895d 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ZoomRoom.cs @@ -1676,4 +1676,20 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom 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 VideoCodec.ZoomRoom.ZoomRoom(dc, comm); + } + } + } \ No newline at end of file