diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs index 413f3568..c516c03e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/Ir/CenIoIr104Controller.cs @@ -16,46 +16,77 @@ namespace PepperDash.Essentials.Core /// Wrapper class for CEN-IO-IR-104 module /// [Description("Wrapper class for the CEN-IO-IR-104 module")] - public class CenIoIr104Controller : EssentialsDevice, IIROutputPorts - { - public CenIoIr104 Ir104 { get; private set; } + public class CenIoIr104Controller : EssentialsDevice, IIROutputPorts + { + private readonly CenIoIr104 _ir104; + /// + /// Constructor + /// + /// + /// + /// public CenIoIr104Controller(string key, string name, CenIoIr104 ir104) : base(key, name) { - Ir104 = ir104; + _ir104 = ir104; } #region IDigitalInputPorts Members + /// + /// IR port collection + /// public CrestronCollection IROutputPorts { - get { return Ir104.IROutputPorts; } + get { return _ir104.IROutputPorts; } } + /// + /// Number of relay ports property + /// public int NumberOfIROutputPorts { - get { return Ir104.NumberOfIROutputPorts; } + get { return _ir104.NumberOfIROutputPorts; } } #endregion } + /// + /// CEN-IO-IR-104 controller fatory + /// public class CenIoIr104ControllerFactory : EssentialsDeviceFactory { + /// + /// Constructor + /// public CenIoIr104ControllerFactory() { TypeNames = new List() { "cenioir104" }; } + /// + /// Build device CEN-IO-IR-104 + /// + /// + /// public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new CEN-IR-104 Device"); + Debug.Console(1, "Factory Attempting to create new CEN-IO-IR-104 Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + if (control == null) + { + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device"); + return null; + } - var control = CommFactory.GetControlPropertiesConfig(dc); var ipid = control.IpIdInt; - - return new CenIoIr104Controller(dc.Key, dc.Name, new Crestron.SimplSharpPro.GeneralIO.CenIoIr104(ipid, Global.ControlSystem)); + if(ipid != 0) return new CenIoIr104Controller(dc.Key, dc.Name, new CenIoIr104(ipid, Global.ControlSystem)); + + Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device using IP-ID-{0}", ipid); + return null; } }