mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Added versiport creation to factory; rearrange success/failure cases to be more descriptive and easier to follow in code
This commit is contained in:
@@ -167,25 +167,61 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts;
|
portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts;
|
||||||
|
|
||||||
if (portDevice == null)
|
if (portDevice == null)
|
||||||
Debug.Console(0, "Unable to add digital input device with key '{0}'. Port Device does not support digital inputs", key);
|
Debug.Console(0, "ERROR: Unable to add digital input device with key '{0}'. Port Device does not support digital inputs", key);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cs = (portDevice as CrestronControlSystem);
|
var cs = (portDevice as CrestronControlSystem);
|
||||||
|
if (cs == null)
|
||||||
if (cs != null)
|
|
||||||
if (cs.SupportsDigitalInput && props.PortNumber <= cs.NumberOfDigitalInputPorts)
|
|
||||||
{
|
{
|
||||||
|
Debug.Console(0, "ERROR: Port device for [{0}] is not control system", props.PortDeviceKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cs.SupportsDigitalInput)
|
||||||
|
{
|
||||||
|
if (props.PortNumber > cs.NumberOfDigitalInputPorts)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "WARNING: Cannot register DIO port {0} on {1}. Out of range",
|
||||||
|
props.PortNumber, props.PortDeviceKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber];
|
DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber];
|
||||||
|
|
||||||
if (!digitalInput.Registered)
|
if (!digitalInput.Registered)
|
||||||
{
|
{
|
||||||
if(digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
|
if (digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
return new GenericDigitalInputDevice(key, digitalInput);
|
return new GenericDigitalInputDevice(key, digitalInput);
|
||||||
else
|
else
|
||||||
Debug.Console(0, "Attempt to register digital input {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey);
|
Debug.Console(0, "WARNING: Attempt to register digital input {0} on device with key '{1}' failed.",
|
||||||
|
props.PortNumber, props.PortDeviceKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cs.SupportsVersiport)
|
||||||
|
{
|
||||||
|
if (props.PortNumber > cs.NumberOfVersiPorts)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "WARNING: Cannot register Vesiport {0} on {1}. Out of range",
|
||||||
|
props.PortNumber, props.PortDeviceKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Versiport vp = cs.VersiPorts[props.PortNumber];
|
||||||
|
|
||||||
|
if (!vp.Registered)
|
||||||
|
{
|
||||||
|
if (vp.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
|
{
|
||||||
|
return new GenericVersiportInputDevice(key, vp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, "WARNING: Attempt to register versiport {0} on device with key '{1}' failed.",
|
||||||
|
props.PortNumber, props.PortDeviceKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Future: Check if portDevice is 3-series card or other non control system that supports versiports
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ namespace PepperDash.Essentials
|
|||||||
if (newDev != null)
|
if (newDev != null)
|
||||||
DeviceManager.AddDevice(newDev);
|
DeviceManager.AddDevice(newDev);
|
||||||
else
|
else
|
||||||
Debug.Console(0, "WARNING: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
|
Debug.Console(0, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
||||||
[assembly: AssemblyVersion("1.0.22.*")]
|
[assembly: AssemblyVersion("1.0.23.*")]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user