diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs new file mode 100644 index 00000000..bbd496b4 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/CenIoCom/CenIoComController.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core.CrestronIO +{ + /// + /// Wrapper class for CEN-IO-COM-Xxx expander module + /// + [Description("Wrapper class for the CEN-IO-COM-102 & CEN-IO-COM-202 expander module")] + public class CenIoComController : CrestronGenericBaseDevice, IComPorts + { + private readonly CenIoCom _cenIoCom; + + public CenIoComController(string key, string name, CenIoCom cenIo) + :base(key, name, cenIo) + { + _cenIoCom = cenIo; + } + + #region Implementation of IComPorts + + public CrestronCollection ComPorts + { + get { return _cenIoCom.ComPorts; } + } + + public int NumberOfComPorts + { + get { return _cenIoCom.NumberOfComPorts; } + } + + #endregion + + } + + public class CenIoCom102ControllerFactory : EssentialsDeviceFactory + { + private const string CenIoCom102Type = "ceniocom102"; + private const string CenIoCom202Type = "ceniocom202"; + + public CenIoCom102ControllerFactory() + { + TypeNames = new List { CenIoCom102Type, CenIoCom202Type }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new CEN-IO-COM-Xxx Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-COM-Xxx Device, control properties not found"); + return null; + } + + var ipid = control.IpIdInt; + if (ipid < 2) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-COM-Xxx Device, invalid IP-ID found"); + return null; + } + + switch (dc.Type) + { + case CenIoCom102Type: + { + return new CenIoComController(dc.Key, dc.Name, new CenIoCom102(ipid, Global.ControlSystem)); + } + case CenIoCom202Type: + { + return new CenIoComController(dc.Key, dc.Name, new CenIoCom202(ipid, Global.ControlSystem)); + } + default: + { + Debug.Console(1, "Factory failed to create a new CEN-IO-COM-Xxx Device, invalid type '{0}'", dc.Type); + return null; + } + } + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index aa2359bf..6b7a3ad9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -185,6 +185,7 @@ + diff --git a/packages.config b/packages.config index 761b11cb..fa36e07d 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - +