mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
fix: added null checks in BuildDevice with debug statements if null
This commit is contained in:
@@ -18,44 +18,75 @@ namespace PepperDash.Essentials.Core
|
|||||||
[Description("Wrapper class for the CEN-IO-IR-104 module")]
|
[Description("Wrapper class for the CEN-IO-IR-104 module")]
|
||||||
public class CenIoIr104Controller : EssentialsDevice, IIROutputPorts
|
public class CenIoIr104Controller : EssentialsDevice, IIROutputPorts
|
||||||
{
|
{
|
||||||
public CenIoIr104 Ir104 { get; private set; }
|
private readonly CenIoIr104 _ir104;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="ir104"></param>
|
||||||
public CenIoIr104Controller(string key, string name, CenIoIr104 ir104)
|
public CenIoIr104Controller(string key, string name, CenIoIr104 ir104)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
{
|
||||||
Ir104 = ir104;
|
_ir104 = ir104;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IDigitalInputPorts Members
|
#region IDigitalInputPorts Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IR port collection
|
||||||
|
/// </summary>
|
||||||
public CrestronCollection<IROutputPort> IROutputPorts
|
public CrestronCollection<IROutputPort> IROutputPorts
|
||||||
{
|
{
|
||||||
get { return Ir104.IROutputPorts; }
|
get { return _ir104.IROutputPorts; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of relay ports property
|
||||||
|
/// </summary>
|
||||||
public int NumberOfIROutputPorts
|
public int NumberOfIROutputPorts
|
||||||
{
|
{
|
||||||
get { return Ir104.NumberOfIROutputPorts; }
|
get { return _ir104.NumberOfIROutputPorts; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// CEN-IO-IR-104 controller fatory
|
||||||
|
/// </summary>
|
||||||
public class CenIoIr104ControllerFactory : EssentialsDeviceFactory<CenIoIr104Controller>
|
public class CenIoIr104ControllerFactory : EssentialsDeviceFactory<CenIoIr104Controller>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public CenIoIr104ControllerFactory()
|
public CenIoIr104ControllerFactory()
|
||||||
{
|
{
|
||||||
TypeNames = new List<string>() { "cenioir104" };
|
TypeNames = new List<string>() { "cenioir104" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Build device CEN-IO-IR-104
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
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);
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
var ipid = control.IpIdInt;
|
if (control == null)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory failed to create a new CEN-IO-IR-104 Device");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new CenIoIr104Controller(dc.Key, dc.Name, new Crestron.SimplSharpPro.GeneralIO.CenIoIr104(ipid, Global.ControlSystem));
|
var ipid = control.IpIdInt;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user