feat(wip): still working on re-arranging base classes

This commit is contained in:
Nick Genovese
2023-11-06 15:46:07 -05:00
parent c66b239e02
commit ba9cc9f00c
4 changed files with 11 additions and 34 deletions

View File

@@ -2,24 +2,9 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.GeneralIO;
using Crestron.SimplSharp.Reflection;
using Full.Newtonsoft.Json;
using Full.Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.DSP;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Devices.Common.Environment;
namespace PepperDash.Essentials.Devices.Common
{

View File

@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
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;
namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
namespace PepperDash.Essentials.Devices.Common.Shades
{
/// <summary>
/// Controls a single shade using three relays
@@ -122,9 +118,9 @@ namespace PepperDash.Essentials.Devices.Common.Environment.Somfy
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());
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<RelayControlledShadeConfigProperties>(dc.Properties.ToString());
return new Environment.Somfy.RelayControlledShade(dc.Key, dc.Name, props);
return new RelayControlledShade(dc.Key, dc.Name, props);
}
}

View File

@@ -0,0 +1,73 @@
using System.Collections.Generic;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Shades;
namespace PepperDash.Essentials.Devices.Common.Shades
{
/// <summary>
/// Class that contains the shades to be controlled in a room
/// </summary>
public class ShadeController : EssentialsDevice, IShades
{
ShadeControllerConfigProperties Config;
public List<IShadesOpenCloseStop> Shades { get; private set; }
public ShadeController(string key, string name, ShadeControllerConfigProperties config)
: base(key, name)
{
Config = config;
Shades = new List<IShadesOpenCloseStop>();
}
public override bool CustomActivate()
{
foreach (var shadeConfig in Config.Shades)
{
var shade = DeviceManager.GetDeviceForKey(shadeConfig.Key) as ShadeBase;
if (shade != null)
{
AddShade(shade);
}
}
return base.CustomActivate();
}
void AddShade(IShadesOpenCloseStop shade)
{
Shades.Add(shade);
}
}
public class ShadeControllerConfigProperties
{
public List<ShadeConfig> Shades { get; set; }
public class ShadeConfig
{
public string Key { get; set; }
}
}
public class ShadeControllerFactory : EssentialsDeviceFactory<ShadeController>
{
public ShadeControllerFactory()
{
TypeNames = new List<string>() { "shadecontroller" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new ShadeController Device");
var props = Newtonsoft.Json.JsonConvert.DeserializeObject<ShadeControllerConfigProperties>(dc.Properties.ToString());
return new ShadeController(dc.Key, dc.Name, props);
}
}
}