diff --git a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs index 8cd3f30c..7b14b797 100644 --- a/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs +++ b/Essentials Devices Common/Essentials Devices Common/Factory/DeviceFactory.cs @@ -158,7 +158,7 @@ namespace PepperDash.Essentials.Devices.Common else if (typeName == "digitalinput") { var props = JsonConvert.DeserializeObject(properties.ToString()); - + IDigitalInputPorts portDevice; if (props.PortDeviceKey == "processor") @@ -167,25 +167,61 @@ namespace PepperDash.Essentials.Devices.Common portDevice = DeviceManager.GetDeviceForKey(props.PortDeviceKey) as IDigitalInputPorts; 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 { var cs = (portDevice as CrestronControlSystem); + if (cs == null) + { + Debug.Console(0, "ERROR: Port device for [{0}] is not control system", props.PortDeviceKey); + return null; + } - if (cs != null) - if (cs.SupportsDigitalInput && props.PortNumber <= cs.NumberOfDigitalInputPorts) - { - DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber]; + 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; + } - if (!digitalInput.Registered) - { - if(digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success) - return new GenericDigitalInputDevice(key, digitalInput); - else - Debug.Console(0, "Attempt to register digital input {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey); - } - } - // Future: Check if portDevice is 3-series card or other non control system that supports versiports + DigitalInput digitalInput = cs.DigitalInputPorts[props.PortNumber]; + + if (!digitalInput.Registered) + { + if (digitalInput.Register() == eDeviceRegistrationUnRegistrationResponse.Success) + return new GenericDigitalInputDevice(key, digitalInput); + else + 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; + } + } + } } } diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 6b94b1b9..d9531639 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -179,7 +179,7 @@ namespace PepperDash.Essentials if (newDev != null) DeviceManager.AddDevice(newDev); 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) { diff --git a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs index 920723d2..4c7a52f9 100644 --- a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs +++ b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ [assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")] -[assembly: AssemblyVersion("1.0.22.*")] +[assembly: AssemblyVersion("1.0.23.*")] diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 16a55bd2..ceffc266 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index b63174a8..6a81378d 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ