From d3562bf22dd1a433e03ecd5e1729182a7cb9939b Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 20 Apr 2020 23:12:27 -0600 Subject: [PATCH] Updating more device factories in Essentials and Devices.Common --- .../MobileControlSystemController.cs | 18 +- .../RoomBridges/MobileControlBridgeBase.cs | 2 +- .../MobileControlSIMPLRoomBridge.cs | 31 ++++ PepperDashEssentials/Bridges/BridgeFactory.cs | 27 +-- PepperDashEssentials/ControlSystem.cs | 30 +-- PepperDashEssentials/Devices/Amplifier.cs | 17 +- PepperDashEssentials/Factory/DeviceFactory.cs | 94 ++-------- .../Factory/UiDeviceFactory.cs | 171 +----------------- .../UI/EssentialsTouchpanelController.cs | 131 +++++++++++++- .../Bridges/BridgeBase.cs | 125 ++----------- .../Comm and IR/ConsoleCommMockDevice.cs | 21 ++- .../Devices/PC/InRoomPc.cs | 18 +- .../Devices/PC/Laptop.cs | 17 +- .../Display/BasicIrDisplay.cs | 24 +++ .../Display/MockDisplay.cs | 17 +- .../RoomOnToDefaultSourceWhenOccupied.cs | 15 ++ .../Endpoints/DGEs/DgeController.cs | 33 ++++ .../Audio/GenericAudioOut.cs | 20 +- .../Cameras/CameraVisca.cs | 19 ++ .../Crestron/Gateways/CenRfgwController.cs | 18 ++ .../DSP/BiampTesira/BiampTesiraForteDsp.cs | 19 ++ .../Essentials Devices Common/DSP/DspBase.cs | 2 +- .../DiscPlayer/IRDiscPlayerBase.cs | 33 +++- .../Factory/DeviceFactory.cs | 139 +++++--------- .../Generic/GenericSource.cs | 18 +- .../AnalogWay/AnalongWayLiveCore.cs | 21 ++- .../Power Controllers/Digitallogger.cs | 17 ++ .../Streaming/AppleTV.cs | 17 ++ 28 files changed, 617 insertions(+), 497 deletions(-) diff --git a/PepperDashEssentials/AppServer/MobileControlSystemController.cs b/PepperDashEssentials/AppServer/MobileControlSystemController.cs index b29ca61d..cc18ba55 100644 --- a/PepperDashEssentials/AppServer/MobileControlSystemController.cs +++ b/PepperDashEssentials/AppServer/MobileControlSystemController.cs @@ -21,7 +21,7 @@ using PepperDash.Essentials.AppServer.Messengers; namespace PepperDash.Essentials { - public class MobileControlSystemController : Device + public class MobileControlSystemController : EssentialsDevice { WebSocketClient WSClient; @@ -865,4 +865,20 @@ namespace PepperDash.Essentials CrestronConsole.ConsoleCommandResponse("Usage: mobilehttprequest:N get/post url\r"); } } + + public class MobileControlSystemControllerFactory : EssentialsDeviceFactory + { + public MobileControlSystemControllerFactory() + { + TypeNames = new List() { "appserver" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new MobileControlSystemController Device"); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + return new MobileControlSystemController(dc.Key, dc.Name, props); + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlBridgeBase.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlBridgeBase.cs index d7258070..fa5cb93d 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlBridgeBase.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlBridgeBase.cs @@ -12,7 +12,7 @@ namespace PepperDash.Essentials /// /// /// - public abstract class MobileControlBridgeBase: Device + public abstract class MobileControlBridgeBase: EssentialsDevice { public MobileControlSystemController Parent { get; private set; } diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs index a8589b92..25eebf42 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlSIMPLRoomBridge.cs @@ -825,4 +825,35 @@ namespace PepperDash.Essentials.Room.MobileControl EISC.StringInput[JoinMap.ServerUrl.JoinNumber].StringValue = Parent.Config.ClientAppUrl; } } + + public class MobileControlSIMPLRoomBridgeFactory : EssentialsDeviceFactory + { + public MobileControlSIMPLRoomBridgeFactory() + { + TypeNames = new List() { "mobilecontrolbridge-ddvc01", "mobilecontrolbridge-simpl" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new MobileControlSIMPLRoomBridge Device"); + + var comm = CommFactory.GetControlPropertiesConfig(dc); + + var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlSIMPLRoomBridge(dc.Key, dc.Name, comm.IpIdInt); + bridge.AddPreActivationAction(() => + { + var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as MobileControlSystemController; + if (parent == null) + { + Debug.Console(0, bridge, "ERROR: Cannot connect bridge. System controller not present"); + } + Debug.Console(0, bridge, "Linking to parent controller"); + bridge.AddParent(parent); + parent.AddBridge(bridge); + }); + + return bridge; + } + } + } \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/BridgeFactory.cs b/PepperDashEssentials/Bridges/BridgeFactory.cs index d9b34755..6371ca08 100644 --- a/PepperDashEssentials/Bridges/BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/BridgeFactory.cs @@ -15,30 +15,17 @@ using Crestron.SimplSharpPro.EthernetCommunication; namespace PepperDash.Essentials { + /// + /// Responsible for loading all of the device types for this library + /// public class BridgeFactory { - public static IKeyed GetDevice(DeviceConfig dc) + public BridgeFactory() { - // ? why is this static JTA 2018-06-13? - - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; - var propAnon = new { }; - - var typeName = dc.Type.ToLower(); - var groupName = dc.Group.ToLower(); - - //Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); - - if (typeName == "eiscapi") - { - return new EiscApi(dc); - } - - return null; + var bridgeFactory = new BridgeFactory() as IDeviceFactory; + bridgeFactory.LoadTypeFactories(); } + } diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 9cc2922f..f2e64529 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -94,6 +94,13 @@ namespace PepperDash.Essentials // Instantiate the Device Factories new CoreDeviceFactory(); new DmDeviceFactory(); + new UiDeviceFactory(); + + new DeviceFactory(); + new BridgeFactory(); + + new PepperDash.Essentials.Devices.Common.DeviceFactory(); + } @@ -365,32 +372,15 @@ namespace PepperDash.Essentials } // Try local factories first - var newDev = DeviceFactory.GetDevice(devConf); + IKeyed newDev = null; - if (newDev == null) - newDev = BridgeFactory.GetDevice(devConf); - - // Then associated library factories if (newDev == null) newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); - if (newDev == null) - newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf); + // if (newDev == null) newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); - - //if (newDev == null) // might want to consider the ability to override an essentials "type" - //{ - // // iterate plugin factories - // foreach (var f in FactoryObjects) - // { - // var cresFactory = f as IGetCrestronDevice; - // if (cresFactory != null) - // { - // newDev = cresFactory.GetDevice(devConf, this); - // } - // } - //} + // if (newDev != null) DeviceManager.AddDevice(newDev); diff --git a/PepperDashEssentials/Devices/Amplifier.cs b/PepperDashEssentials/Devices/Amplifier.cs index 20d8efa0..b2725109 100644 --- a/PepperDashEssentials/Devices/Amplifier.cs +++ b/PepperDashEssentials/Devices/Amplifier.cs @@ -6,11 +6,12 @@ using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; namespace PepperDash.Essentials { - public class Amplifier : Device, IRoutingSinkNoSwitching + public class Amplifier : EssentialsDevice, IRoutingSinkNoSwitching { public event SourceInfoChangeHandler CurrentSourceChange; @@ -54,4 +55,18 @@ 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/PepperDashEssentials/Factory/DeviceFactory.cs b/PepperDashEssentials/Factory/DeviceFactory.cs index 1e0e8ffb..944a9b2f 100644 --- a/PepperDashEssentials/Factory/DeviceFactory.cs +++ b/PepperDashEssentials/Factory/DeviceFactory.cs @@ -10,88 +10,34 @@ using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; +using PepperDash.Essentials.Room.MobileControl; namespace PepperDash.Essentials { - public class DeviceFactory + /// + /// Responsible for loading all of the device types for this library + /// + public class DeviceFactory { - public static IKeyed GetDevice(DeviceConfig dc) - { - var key = dc.Key; - var name = dc.Name; - var type = dc.Type; - var properties = dc.Properties; + public DeviceFactory() + { + var ampFactory = new AmplifierFactory() as IDeviceFactory; + ampFactory.LoadTypeFactories(); - var typeName = dc.Type.ToLower(); + var mockDisplayFactory = new MockDisplayFactory() as IDeviceFactory; + mockDisplayFactory.LoadTypeFactories(); - if (typeName == "amplifier") - { - return new Amplifier(dc.Key, dc.Name); - } - else if (dc.Group.ToLower() == "touchpanel") // typeName.StartsWith("tsw")) - { - return UiDeviceFactory.GetUiDevice(dc); - } + var consoleCommMockFactroy = new ConsoleCommMockDeviceFactory() as IDeviceFactory; + consoleCommMockFactroy.LoadTypeFactories(); - else if (typeName == "mockdisplay") - { - return new MockDisplay(key, name); - } + var mcSystemControllerFactory = new MobileControlSystemControllerFactory() as IDeviceFactory; + mcSystemControllerFactory.LoadTypeFactories(); - else if (typeName == "generic") - { - return new Device(key, name); - } + var mcSIMPLRoomBridgeFactory = new MobileControlSIMPLRoomBridgeFactory() as IDeviceFactory; + mcSIMPLRoomBridgeFactory.LoadTypeFactories(); - //// MOVE into something else??? - //else if (typeName == "basicirdisplay") - //{ - // var ir = IRPortHelper.GetIrPort(properties); - // if (ir != null) - // return new BasicIrDisplay(key, name, ir.Port, ir.FileName); - //} - - else if (typeName == "commmock") - { - var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new ConsoleCommMockDevice(key, name, props, comm); - } - - else if (typeName == "appserver") - { - var props = JsonConvert.DeserializeObject(properties.ToString()); - return new MobileControlSystemController(key, name, props); - } - - else if (typeName == "mobilecontrolbridge-ddvc01") - { - var comm = CommFactory.GetControlPropertiesConfig(dc); - - var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlSIMPLRoomBridge(key, name, comm.IpIdInt); - bridge.AddPreActivationAction(() => - { - var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as MobileControlSystemController; - if (parent == null) - { - Debug.Console(0, bridge, "ERROR: Cannot connect bridge. System controller not present"); - } - Debug.Console(0, bridge, "Linking to parent controller"); - bridge.AddParent(parent); - parent.AddBridge(bridge); - }); - - return bridge; - } - - else if (typeName == "roomonwhenoccupancydetectedfeature") - { - return new RoomOnToDefaultSourceWhenOccupied(dc); - } - - return null; - } + var roomOnToDefSourceWhenOcc = new RoomOnToDefaultSourceWhenOccupiedFactory() as IDeviceFactory; + roomOnToDefSourceWhenOcc.LoadTypeFactories(); + } } - } diff --git a/PepperDashEssentials/Factory/UiDeviceFactory.cs b/PepperDashEssentials/Factory/UiDeviceFactory.cs index 6176b6d1..fad8026f 100644 --- a/PepperDashEssentials/Factory/UiDeviceFactory.cs +++ b/PepperDashEssentials/Factory/UiDeviceFactory.cs @@ -18,173 +18,18 @@ using PepperDash.Essentials.DM.Endpoints.DGEs; namespace PepperDash.Essentials { + /// + /// Responsible for loading all of the UI device types for this library + /// public class UiDeviceFactory { - public static IKeyed GetUiDevice(DeviceConfig config) + public UiDeviceFactory() { - var comm = CommFactory.GetControlPropertiesConfig(config); + var dgeControllerFactory = new DgeControllerFactory() as IDeviceFactory; + dgeControllerFactory.LoadTypeFactories(); - var typeName = config.Type.ToLower(); - - EssentialsTouchpanelController panelController = null; - - var props = JsonConvert.DeserializeObject(config.Properties.ToString()); - - if (typeName.Contains("dge")) - { - Dge100 dgeDevice = null; - if (typeName == "dge100") - dgeDevice = new Dge100(comm.IpIdInt, Global.ControlSystem); - else if (typeName == "dmdge200c") - dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new DgeController(config.Key + "-comPorts", config.Name, dgeDevice, config, props); - - DeviceManager.AddDevice(dgeController); - - panelController = new EssentialsTouchpanelController(config.Key, config.Name, dgeController.DigitalGraphicsEngine, - props.ProjectName, props.SgdFile); - } - else - { - panelController = new EssentialsTouchpanelController(config.Key, config.Name, config.Type, props, comm.IpIdInt); - } - - panelController.AddPostActivationAction(() => - { - var mainDriver = new EssentialsPanelMainInterfaceDriver(panelController.Panel, props); - // Then the sub drivers - - // spin up different room drivers depending on room type - var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey); - if (room is EssentialsHuddleSpaceRoom) - { - - // Header Driver - Debug.Console(0, panelController, "Adding header driver"); - mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props); - - // AV Driver - Debug.Console(0, panelController, "Adding huddle space AV driver"); - var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props); - avDriver.DefaultRoomKey = props.DefaultRoomKey; - mainDriver.AvDriver = avDriver; - avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom; - - // Environment Driver - if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0) - { - Debug.Console(0, panelController, "Adding environment driver"); - mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); - - mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment); - } - - mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); - - panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted. - - if (panelController.Panel is TswFt5ButtonSystem) - { - var tsw = panelController.Panel as TswFt5ButtonSystem; - // Wire up hard keys - tsw.Power.UserObject = new Action(b => { if (!b) avDriver.PowerButtonPressed(); }); - //tsw.Home.UserObject = new Action(b => { if (!b) HomePressed(); }); - if(mainDriver.EnvironmentDriver != null) - tsw.Lights.UserObject = new Action(b => - { - if (!b) - { - //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); - mainDriver.EnvironmentDriver.Toggle(); - } - }); - tsw.Up.UserObject = new Action(avDriver.VolumeUpPress); - tsw.Down.UserObject = new Action(avDriver.VolumeDownPress); - } - } - //else if (room is EssentialsPresentationRoom) - //{ - // Debug.Console(0, panelController, "Adding presentation room driver"); - // var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props); - // avDriver.CurrentRoom = room as EssentialsPresentationRoom; - // avDriver.DefaultRoomKey = props.DefaultRoomKey; - // mainDriver.AvDriver = avDriver ; - // mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props); - // panelController.LoadAndShowDriver(mainDriver); - - // if (panelController.Panel is TswFt5ButtonSystem) - // { - // var tsw = panelController.Panel as TswFt5ButtonSystem; - // // Wire up hard keys - // tsw.Power.UserObject = new Action(b => { if (!b) avDriver.PowerButtonPressed(); }); - // //tsw.Home.UserObject = new Action(b => { if (!b) HomePressed(); }); - // tsw.Up.UserObject = new Action(avDriver.VolumeUpPress); - // tsw.Down.UserObject = new Action(avDriver.VolumeDownPress); - // } - //} - else if (room is EssentialsHuddleVtc1Room) - { - Debug.Console(0, panelController, "Adding huddle space VTC AV driver"); - - // Header Driver - mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props); - - // AV Driver - var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props); - - var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(panelController.Panel, avDriver, - (room as EssentialsHuddleVtc1Room).VideoCodec, mainDriver.HeaderDriver); - avDriver.SetVideoCodecDriver(codecDriver); - avDriver.DefaultRoomKey = props.DefaultRoomKey; - mainDriver.AvDriver = avDriver; - avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room; - - // Environment Driver - if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0) - { - Debug.Console(0, panelController, "Adding environment driver"); - mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); - - mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment); - } - - mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); - - panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted. - - if (panelController.Panel is TswFt5ButtonSystem) - { - var tsw = panelController.Panel as TswFt5ButtonSystem; - // Wire up hard keys - tsw.Power.UserObject = new Action(b => { if (!b) avDriver.EndMeetingPress(); }); - //tsw.Home.UserObject = new Action(b => { if (!b) HomePressed(); }); - if (mainDriver.EnvironmentDriver != null) - tsw.Lights.UserObject = new Action(b => - { - if (!b) - { - //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); - mainDriver.EnvironmentDriver.Toggle(); - } - }); - tsw.Up.UserObject = new Action(avDriver.VolumeUpPress); - tsw.Down.UserObject = new Action(avDriver.VolumeDownPress); - } - } - else - { - Debug.Console(0, panelController, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey); - } - }); - - return panelController; + var essentialsTouchpanelControllerFactory = new EssentialsTouchpanelControllerFactory() as IDeviceFactory; + essentialsTouchpanelControllerFactory.LoadTypeFactories(); } } diff --git a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs index df1ecdce..d008eee0 100644 --- a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs +++ b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs @@ -9,11 +9,12 @@ 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; namespace PepperDash.Essentials { - public class EssentialsTouchpanelController : Device, IHasBasicTriListWithSmartObject + public class EssentialsTouchpanelController : EssentialsDevice, IHasBasicTriListWithSmartObject { public BasicTriListWithSmartObject Panel { get; private set; } @@ -197,4 +198,132 @@ namespace PepperDash.Essentials (uo as Action)(args.Button.State == eButtonState.Pressed); } } + + public class EssentialsTouchpanelControllerFactory : EssentialsDeviceFactory + { + public EssentialsTouchpanelControllerFactory() + { + TypeNames = new List() { "tsw550", "tsw750", "tsw1050", "tsw560", "tsw760", "tsw1060", "xpanel" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = Newtonsoft.Json.JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); + + var panelController = new EssentialsTouchpanelController(dc.Key, dc.Name, dc.Type, props, comm.IpIdInt); + + panelController.AddPostActivationAction(() => + { + var mainDriver = new EssentialsPanelMainInterfaceDriver(panelController.Panel, props); + // Then the sub drivers + + // spin up different room drivers depending on room type + var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey); + if (room is EssentialsHuddleSpaceRoom) + { + + // Header Driver + Debug.Console(0, panelController, "Adding header driver"); + mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props); + + // AV Driver + Debug.Console(0, panelController, "Adding huddle space AV driver"); + var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props); + avDriver.DefaultRoomKey = props.DefaultRoomKey; + mainDriver.AvDriver = avDriver; + avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom; + + // Environment Driver + if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0) + { + Debug.Console(0, panelController, "Adding environment driver"); + mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); + + mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment); + } + + mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); + + panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted. + + if (panelController.Panel is TswFt5ButtonSystem) + { + var tsw = panelController.Panel as TswFt5ButtonSystem; + // Wire up hard keys + tsw.Power.UserObject = new Action(b => { if (!b) avDriver.PowerButtonPressed(); }); + //tsw.Home.UserObject = new Action(b => { if (!b) HomePressed(); }); + if (mainDriver.EnvironmentDriver != null) + tsw.Lights.UserObject = new Action(b => + { + if (!b) + { + //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); + mainDriver.EnvironmentDriver.Toggle(); + } + }); + tsw.Up.UserObject = new Action(avDriver.VolumeUpPress); + tsw.Down.UserObject = new Action(avDriver.VolumeDownPress); + } + } + else if (room is EssentialsHuddleVtc1Room) + { + Debug.Console(0, panelController, "Adding huddle space VTC AV driver"); + + // Header Driver + mainDriver.HeaderDriver = new EssentialsHeaderDriver(mainDriver, props); + + // AV Driver + var avDriver = new EssentialsHuddleVtc1PanelAvFunctionsDriver(mainDriver, props); + + var codecDriver = new PepperDash.Essentials.UIDrivers.VC.EssentialsVideoCodecUiDriver(panelController.Panel, avDriver, + (room as EssentialsHuddleVtc1Room).VideoCodec, mainDriver.HeaderDriver); + avDriver.SetVideoCodecDriver(codecDriver); + avDriver.DefaultRoomKey = props.DefaultRoomKey; + mainDriver.AvDriver = avDriver; + avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room; + + // Environment Driver + if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0) + { + Debug.Console(0, panelController, "Adding environment driver"); + mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); + + mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment); + } + + mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); + + panelController.LoadAndShowDriver(mainDriver); // This is a little convoluted. + + if (panelController.Panel is TswFt5ButtonSystem) + { + var tsw = panelController.Panel as TswFt5ButtonSystem; + // Wire up hard keys + tsw.Power.UserObject = new Action(b => { if (!b) avDriver.EndMeetingPress(); }); + //tsw.Home.UserObject = new Action(b => { if (!b) HomePressed(); }); + if (mainDriver.EnvironmentDriver != null) + tsw.Lights.UserObject = new Action(b => + { + if (!b) + { + //mainDriver.AvDriver.PopupInterlock.ShowInterlockedWithToggle(mainDriver.EnvironmentDriver.BackgroundSubpageJoin); + mainDriver.EnvironmentDriver.Toggle(); + } + }); + tsw.Up.UserObject = new Action(avDriver.VolumeUpPress); + tsw.Down.UserObject = new Action(avDriver.VolumeDownPress); + } + } + else + { + Debug.Console(0, panelController, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey); + } + }); + + return panelController; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs index c0afb5f9..8ce690fc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs @@ -123,117 +123,6 @@ namespace PepperDash.Essentials.Core.Bridges var bridge = device as IBridgeAdvanced; if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); } - - //if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. - //{ - // (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is IBridgeAdvanced) - //{ - // Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); - // (device as IBridgeAdvanced).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); - //} - //else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) - //{ - // (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is GenericComm) - //{ - // (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is CameraBase) - //{ - // (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); - // continue; - //} - //else if (device is PepperDash.Essentials.Core.DisplayBase) - //{ - // (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmChassisController) - //{ - // (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmBladeChassisController) - //{ - // (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmpsRoutingController) - //{ - // (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmpsAudioOutputController) - //{ - // (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmTxControllerBase) - //{ - // (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DmRmcControllerBase) - //{ - // (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is GenericRelayDevice) - //{ - // (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is IRSetTopBoxBase) - //{ - // (device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is IDigitalInput) - //{ - // (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is AppleTV) - //{ - // (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is HdMdxxxCEController) - //{ - // (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is LightingBase) - //{ - // (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is DigitalLogger) - //{ - // (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController) - //{ - // (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is StatusSignController) - //{ - // (device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} - //else if (device is C2nRthsController) - //{ - // (device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); - // continue; - //} } Debug.Console(1, this, "Devices Linked."); @@ -403,5 +292,19 @@ namespace PepperDash.Essentials.Core.Bridges } + public class EiscApiFactory : EssentialsDeviceFactory + { + public EiscApiFactory() + { + TypeNames = new List() { "eiscapi" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new EiscApi Device"); + + return new EiscApi(dc); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/ConsoleCommMockDevice.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/ConsoleCommMockDevice.cs index d833aafa..f360e52b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/ConsoleCommMockDevice.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Config/Comm and IR/ConsoleCommMockDevice.cs @@ -5,10 +5,12 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + namespace PepperDash.Essentials.Core { - public class ConsoleCommMockDevice : Device, ICommunicationMonitor + public class ConsoleCommMockDevice : EssentialsDevice, ICommunicationMonitor { public IBasicCommunication Communication { get; private set; } public CommunicationGather PortGather { get; private set; } @@ -71,4 +73,21 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs index 9a13106f..03e884f0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/InRoomPc.cs @@ -4,6 +4,7 @@ using System.Linq; using Crestron.SimplSharpPro; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Core; @@ -12,7 +13,7 @@ namespace PepperDash.Essentials.Core.Devices /// /// This DVD class should cover most IR, one-way DVD and Bluray fuctions /// - public class InRoomPc : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking + public class InRoomPc : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking { public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } public string IconName { get; set; } @@ -63,4 +64,19 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs index a1a8b30b..a2864d77 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PC/Laptop.cs @@ -4,6 +4,7 @@ using System.Linq; using Crestron.SimplSharpPro; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Routing; using PepperDash.Core; @@ -12,7 +13,7 @@ namespace PepperDash.Essentials.Core.Devices /// /// This DVD class should cover most IR, one-way DVD and Bluray fuctions /// - public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking + public class Laptop : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking { public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } public string IconName { get; set; } @@ -63,4 +64,18 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs index 740c241d..f462cae5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/BasicIrDisplay.cs @@ -8,6 +8,7 @@ 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; @@ -208,4 +209,27 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs index fc43174c..86068d9b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Display/MockDisplay.cs @@ -12,7 +12,7 @@ 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 { @@ -182,4 +182,19 @@ 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/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs index fcb04420..11debb03 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs @@ -522,4 +522,19 @@ namespace PepperDash.Essentials.Core [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/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeController.cs index 0fc00323..6b586ac3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeController.cs @@ -63,4 +63,37 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs #endregion } + + public class DgeControllerFactory : EssentialsDeviceFactory + { + public DgeControllerFactory() + { + TypeNames = new List() { "dge100", "dmdge200c" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var typeName = dc.Type.ToLower(); + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Debug.Console(1, "Factory Attempting to create new DgeControllerm Device"); + + Dge100 dgeDevice = null; + if (typeName == "dge100") + dgeDevice = new Dge100(comm.IpIdInt, Global.ControlSystem); + else if (typeName == "dmdge200c") + dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); + + if (dgeDevice == null) + { + Debug.Console(1, "Unable to create DGE device"); + return null; + } + + var dgeController = new DgeController(dc.Key + "-comPorts", dc.Name, dgeDevice, dc, props); + + return dgeController; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs index d89a36fc..70596904 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Audio/GenericAudioOut.cs @@ -6,6 +6,8 @@ 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 @@ -13,7 +15,7 @@ namespace PepperDash.Essentials.Devices.Common /// /// Represents and audio endpoint /// - public class GenericAudioOut : Device, IRoutingSinkNoSwitching + public class GenericAudioOut : EssentialsDevice, IRoutingSinkNoSwitching { public event SourceInfoChangeHandler CurrentSourceChange; @@ -98,4 +100,20 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs index 7d5fa182..c95c294b 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Cameras/CameraVisca.cs @@ -7,6 +7,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.Devices.Common.Codec; using System.Text.RegularExpressions; using Crestron.SimplSharp.Reflection; @@ -244,4 +245,22 @@ 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); + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Crestron/Gateways/CenRfgwController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Crestron/Gateways/CenRfgwController.cs index ee37674a..04f6eb17 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Crestron/Gateways/CenRfgwController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Crestron/Gateways/CenRfgwController.cs @@ -8,6 +8,8 @@ using Crestron.SimplSharpPro.Gateways; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; + namespace PepperDash.Essentials.Devices.Common { @@ -112,4 +114,20 @@ namespace PepperDash.Essentials.Devices.Common { Ethernet, EthernetShared, Cresnet } + + public class CenRfgwControllerFactory : EssentialsDeviceFactory + { + public CenRfgwControllerFactory() + { + TypeNames = new List() { "cenrfgwex", "cenerfgwpoe" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CEN-GWEXER Device"); + return CenRfgwController.GetNewExGatewayController(dc.Key, dc.Name, + dc.Properties.Value("id"), dc.Properties.Value("gatewayType")); + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs index 27a29145..86850fea 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDsp.cs @@ -5,6 +5,7 @@ using System.Text; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using System.Text.RegularExpressions; @@ -373,4 +374,22 @@ 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); + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs index 0f572642..cad57761 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DSP/DspBase.cs @@ -9,7 +9,7 @@ using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Devices.Common.DSP { - public abstract class DspBase : Device + public abstract class DspBase : EssentialsDevice { public Dictionary LevelControlPoints { get; private set; } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs index 0f4a65ac..581ea3b5 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/DiscPlayer/IRDiscPlayerBase.cs @@ -5,13 +5,18 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + + using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Routing; +using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Devices.Common { - public class IRBlurayBase : Device, IDiscPlayerControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking + public class IRBlurayBase : EssentialsDevice, IDiscPlayerControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking { public IrOutputPortController IrPort { get; private set; } @@ -311,4 +316,30 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs index 58f97b03..fc07a6dc 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 @@ -18,12 +18,51 @@ using PepperDash.Essentials.Devices.Common.VideoCodec; using PepperDash.Essentials.Devices.Common.Occupancy; using PepperDash.Essentials.Devices.Common.Environment; - - namespace PepperDash.Essentials.Devices.Common { public class DeviceFactory { + public DeviceFactory() + { + var appleTVFactory = new AppleTVFactory() as IDeviceFactory; + appleTVFactory.LoadTypeFactories(); + + var analogWayLCFactory = new AnalogWayLiveCoreFactory() as IDeviceFactory; + analogWayLCFactory.LoadTypeFactories(); + + var basicIrDisplayFactory = new BasicIrDisplayFactory() as IDeviceFactory; + basicIrDisplayFactory.LoadTypeFactories(); + + var biampTesiraFactory = new BiampTesiraForteDspFactory() as IDeviceFactory; + biampTesiraFactory.LoadTypeFactories(); + + var cameraViscaFactory = new Cameras.CameraViscaFactory() as IDeviceFactory; + cameraViscaFactory.LoadTypeFactories(); + + var cenRfGwFactory = new CenRfgwControllerFactory() as IDeviceFactory; + cenRfGwFactory.LoadTypeFactories(); + + var irBlurayFactory = new IRBlurayBaseFactory() as IDeviceFactory; + irBlurayFactory.LoadTypeFactories(); + + var digitalLoggerFactory = new DigitalLoggerFactory() as IDeviceFactory; + digitalLoggerFactory.LoadTypeFactories(); + + var genericAudioOutFactory = new GenericAudioOutWithVolumeFactory() as IDeviceFactory; + genericAudioOutFactory.LoadTypeFactories(); + + var genericSourceFactory = new GenericSourceFactory() as IDeviceFactory; + genericSourceFactory.LoadTypeFactories(); + + var inRoomPcFactory = new Core.Devices.InRoomPcFactory() as IDeviceFactory; + inRoomPcFactory.LoadTypeFactories(); + + var laptopFactory = new Core.Devices.LaptopFactory() as IDeviceFactory; + laptopFactory.LoadTypeFactories(); + + + } + public static IKeyed GetDevice(DeviceConfig dc) { var key = dc.Key; @@ -36,100 +75,8 @@ namespace PepperDash.Essentials.Devices.Common var typeName = dc.Type.ToLower(); var groupName = dc.Group.ToLower(); - if (typeName == "appletv") - { - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new AppleTV(key, name, irCont); - } - else if (typeName == "analogwaylivecore") - { - var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new AnalogWayLiveCore(key, name, comm, props); - } - else if (typeName == "basicirdisplay") - { - var ir = IRPortHelper.GetIrPort(properties); - if (ir != null) - { - var display = new BasicIrDisplay(key, name, ir.Port, ir.FileName); - display.IrPulseTime = 200; // Set default pulse time for IR commands. - return display; - } - } - - else if (typeName == "biamptesira") - { - var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new BiampTesiraForteDsp(key, name, comm, props); - } - - - else if (typeName == "cameravisca") - { - var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new Cameras.CameraVisca(key, name, comm, props); - } - - else if (typeName == "cenrfgwex") - { - return CenRfgwController.GetNewExGatewayController(key, name, - properties.Value("id"), properties.Value("gatewayType")); - } - - else if (typeName == "cenerfgwpoe") - { - return CenRfgwController.GetNewErGatewayController(key, name, - properties.Value("id"), properties.Value("gatewayType")); - } - - else if (groupName == "discplayer") // (typeName == "irbluray") - { - if (properties["control"]["method"].Value() == "ir") - { - var irCont = IRPortHelper.GetIrOutputPortController(dc); - return new IRBlurayBase(key, name, irCont); - } - else if (properties["control"]["method"].Value() == "com") - { - Debug.Console(0, "[{0}] COM Device type not implemented YET!", key); - } - } - else if (typeName == "digitallogger") - { - // var comm = CommFactory.CreateCommForDevice(dc); - var props = JsonConvert.DeserializeObject( - properties.ToString()); - return new DigitalLogger(key, name, props); - } - else if (typeName == "genericaudiooutwithvolume") - { - var zone = dc.Properties.Value("zone"); - return new GenericAudioOutWithVolume(key, name, - dc.Properties.Value("volumeDeviceKey"), zone); - } - - else if (groupName == "genericsource") - { - return new GenericSource(key, name); - } - - else if (typeName == "inroompc") - { - return new Core.Devices.InRoomPc(key, name); - } - - else if (typeName == "laptop") - { - return new Core.Devices.Laptop(key, name); - } - - else if (typeName == "bluejeanspc") + // TODO: Continue from here + if (typeName == "bluejeanspc") { return new SoftCodec.BlueJeansPc(key, name); } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs index 4627fd7b..697639e5 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.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 GenericSource : Device, IUiDisplayInfo, IRoutingOutputs, IUsageTracking + public class GenericSource : EssentialsDevice, IUiDisplayInfo, IRoutingOutputs, IUsageTracking { public uint DisplayUiType { get { return DisplayUiConstants.TypeNoControls; } } @@ -39,4 +40,19 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs index c2178bdb..97d8a8dd 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/ImageProcessors/AnalogWay/AnalongWayLiveCore.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 AnalogWayLiveCore : Device + public class AnalogWayLiveCore : 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 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs index ce9536ef..670aef5f 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Power Controllers/Digitallogger.cs @@ -11,6 +11,7 @@ using Crestron.SimplSharp.Net.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Devices; @@ -338,4 +339,20 @@ 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/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 83d2073b..2c37b320 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -8,6 +8,7 @@ using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Routing; using PepperDash_Essentials_Core.Devices; @@ -167,4 +168,20 @@ namespace PepperDash.Essentials.Devices.Common trilist.SetBoolSigAction(joinMap.PlayPause, 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); + } + } + } \ No newline at end of file