Finishes converting all existing types to new DeviceFactory mechanism. #106

This commit is contained in:
Neil Dorin
2020-04-22 16:17:07 -06:00
parent 2170a79399
commit 4f6ae386b4
29 changed files with 626 additions and 334 deletions

View File

@@ -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<Din8sw8Controller>
{
public Din8sw8ControllerFactory()
{
TypeNames = new List<string>() { "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);
}
}
}

View File

@@ -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<LutronQuantumArea>
{
public LutronQuantumAreaFactory()
{
TypeNames = new List<string>() { "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<Environment.Lutron.LutronQuantumPropertiesConfig>(dc.Properties.ToString());
return new LutronQuantumArea(dc.Key, dc.Name, comm, props);
}
}
}

View File

@@ -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<RelayControlledShade>
{
public RelayControlledShadeFactory()
{
TypeNames = new List<string>() { "relaycontrolledshade" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<Environment.Somfy.RelayControlledShadeConfigProperties>(dc.Properties.ToString());
return new Environment.Somfy.RelayControlledShade(dc.Key, dc.Name, props);
}
}
}