using System.Collections.Generic; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.GeneralIO; using PepperDash.Core; using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.Core { /// /// Wrapper class for CEN-IO-RY-104 relay module /// [Description("Wrapper class for the CEN-IO-RY-104 relay module")] public class CenIoRy104Controller : CrestronGenericBaseDevice, IRelayPorts { private readonly CenIoRy104 _ry104; /// /// Constructor /// /// /// /// public CenIoRy104Controller(string key, string name, CenIoRy104 ry104) : base(key, name, ry104) { _ry104 = ry104; } /// /// Relay port collection /// public CrestronCollection RelayPorts { get { return _ry104.RelayPorts; } } /// /// Number of relay ports property /// public int NumberOfRelayPorts { get { return _ry104.NumberOfRelayPorts; } } } /// /// CEN-IO-RY Controller factory /// public class CenIoRy104ControllerFactory : EssentialsDeviceFactory { /// /// Constructor /// public CenIoRy104ControllerFactory() { TypeNames = new List() { "ceniory104" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create a new CEN-IO-RY-104 Device"); var controlPropertiesConfig = CommFactory.GetControlPropertiesConfig(dc); if (controlPropertiesConfig == null) { Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device, control properties not found"); return null; } var ipid = controlPropertiesConfig.IpIdInt; if (ipid != 0) return new CenIoRy104Controller(dc.Key, dc.Name, new CenIoRy104(ipid, Global.ControlSystem)); Debug.Console(1, "Factory failed to create a new CEN-IO-RY-104 Device using IP-ID-{0}", ipid); return null; } } }