diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs index c788f293..2b07c623 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs @@ -1,13 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Bridges; @@ -15,11 +11,11 @@ namespace PepperDash.Essentials.Core { [Description("Wrapper class for Single Technology GLS Occupancy Sensors")] [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0}")] - public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider + public abstract class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider { public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; } - public GlsOccupancySensorBase OccSensor { get; private set; } + protected GlsOccupancySensorBase OccSensor; public BoolFeedback RoomIsOccupiedFeedback { get; private set; } @@ -58,44 +54,12 @@ namespace PepperDash.Essentials.Core } } - public GlsOccupancySensorBaseController(string key, Func preActivationFunc, - DeviceConfig config) - : base(key, config.Name) + protected GlsOccupancySensorBaseController(string key, DeviceConfig config) + : this(key, config.Name, config) { - var props = config.Properties.ToObject(); - - if (props != null) - { - PropertiesConfig = props; - } - else - { - Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig"); - } - - AddPreActivationAction(() => - { - OccSensor = preActivationFunc(config); - - RegisterCrestronGenericBase(OccSensor); - - RegisterGlsOdtSensorBaseController(OccSensor); - - }); - - AddPostActivationAction(() => - { - OccSensor.OnlineStatusChange += (o, a) => - { - if (a.DeviceOnLine) - { - ApplySettingsToSensorFromConfig(); - } - }; - }); } - public GlsOccupancySensorBaseController(string key, string name, DeviceConfig config) + protected GlsOccupancySensorBaseController(string key, string name, DeviceConfig config) : base(key, name) { @@ -183,7 +147,7 @@ namespace PepperDash.Essentials.Core } } - protected void RegisterGlsOdtSensorBaseController(GlsOccupancySensorBase occSensor) + protected void RegisterGlsOccupancySensorBaseController(GlsOccupancySensorBase occSensor) { OccSensor = occSensor; @@ -253,8 +217,8 @@ namespace PepperDash.Essentials.Core switch (args.EventId) { - case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId: - case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId: + case GlsOccupancySensorBase.RoomVacantFeedbackEventId: + case GlsOccupancySensorBase.RoomOccupiedFeedbackEventId: Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); RoomIsOccupiedFeedback.FireUpdate(); break; @@ -298,60 +262,36 @@ namespace PepperDash.Essentials.Core } } - /// - /// Enables or disables the PIR sensor - /// - /// - public void SetPirEnable(bool state) - { - Debug.Console(1, this, "Setting EnablePir to: {0}", state); + /// + /// Enables or disables the PIR sensor + /// + /// + public void SetPirEnable(bool state) + { + Debug.Console(1, this, "Setting EnablePir to: {0}", state); - if (state) - { - OccSensor.EnablePir.BoolValue = state; - OccSensor.DisablePir.BoolValue = !state; - } - else - { - OccSensor.EnablePir.BoolValue = state; - OccSensor.DisablePir.BoolValue = !state; - } - } + OccSensor.EnablePir.BoolValue = state; + OccSensor.DisablePir.BoolValue = !state; + } - /// - /// Enables or disables the LED Flash - /// - /// - public void SetLedFlashEnable(bool state) - { - if (state) - { - OccSensor.EnableLedFlash.BoolValue = state; - OccSensor.DisableLedFlash.BoolValue = !state; - } - else - { - OccSensor.EnableLedFlash.BoolValue = state; - OccSensor.DisableLedFlash.BoolValue = !state; - } - } + /// + /// Enables or disables the LED Flash + /// + /// + public void SetLedFlashEnable(bool state) + { + OccSensor.EnableLedFlash.BoolValue = state; + OccSensor.DisableLedFlash.BoolValue = !state; + } - /// + /// /// Enables or disables short timeout based on state /// /// public void SetShortTimeoutState(bool state) { - if (state) - { OccSensor.EnableShortTimeout.BoolValue = state; OccSensor.DisableShortTimeout.BoolValue = !state; - } - else - { - OccSensor.EnableShortTimeout.BoolValue = state; - OccSensor.DisableShortTimeout.BoolValue = !state; - } } public void IncrementPirSensitivityInOccupiedState(bool pressRelease) @@ -406,11 +346,10 @@ namespace PepperDash.Essentials.Core OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; } - /// - /// Method to print current occ settings to console. - /// - /// - public virtual void GetSettings() + /// + /// Method to print current occ settings to console. + /// + public virtual void GetSettings() { var dash = new string('*', 50); CrestronConsole.PrintLine(string.Format("{0}\n", dash)); @@ -544,53 +483,6 @@ namespace PepperDash.Essentials.Core #endregion } - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region PreActivation - - private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); - return new GlsOirCCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); - return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - #endregion - - public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory - { - public GlsOccupancySensorBaseControllerFactory() - { - TypeNames = new List() { "glsoirccn" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - return new GlsOccupancySensorBaseController(dc.Key, GetGlsOirCCn, dc); - } - - } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs index e19c9ba7..f8afe49d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs @@ -17,7 +17,7 @@ namespace PepperDash.Essentials.Core [ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")] public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController { - public new GlsOdtCCn OccSensor { get; private set; } + private GlsOdtCCn _occSensor; public BoolFeedback OrWhenVacatedFeedback { get; private set; } @@ -42,31 +42,29 @@ namespace PepperDash.Essentials.Core { AddPreActivationAction(() => { - OccSensor = preActivationFunc(config); + _occSensor = preActivationFunc(config); - RegisterCrestronGenericBase(OccSensor); + RegisterCrestronGenericBase(_occSensor); - RegisterGlsOdtSensorBaseController(OccSensor); + RegisterGlsOccupancySensorBaseController(OccSensor); - AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); + AndWhenVacatedFeedback = new BoolFeedback(() => _occSensor.AndWhenVacatedFeedback.BoolValue); - OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); + OrWhenVacatedFeedback = new BoolFeedback(() => _occSensor.OrWhenVacatedFeedback.BoolValue); - UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue); + UltrasonicAEnabledFeedback = new BoolFeedback(() => _occSensor.UsAEnabledFeedback.BoolValue); - UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue); + UltrasonicBEnabledFeedback = new BoolFeedback(() => _occSensor.UsBEnabledFeedback.BoolValue); - RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyPirFeedback.BoolValue); + RawOccupancyPirFeedback = new BoolFeedback(() => _occSensor.RawOccupancyPirFeedback.BoolValue); - RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue); + RawOccupancyUsFeedback = new BoolFeedback(() => _occSensor.RawOccupancyUsFeedback.BoolValue); - UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue); - - UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); - - }); + UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); + UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); + }); } protected override void ApplySettingsToSensorFromConfig() @@ -114,45 +112,59 @@ namespace PepperDash.Essentials.Core /// protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) { - if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId) - AndWhenVacatedFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId) - OrWhenVacatedFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId) - UltrasonicAEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId) - UltrasonicBEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId) - UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId) - UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); + switch (args.EventId) + { + case GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId: + AndWhenVacatedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId: + OrWhenVacatedFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsAEnabledFeedbackEventId: + UltrasonicAEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsBEnabledFeedbackEventId: + UltrasonicBEnabledFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId: + UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId: + UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); + break; + } - base.OccSensor_GlsOccupancySensorChange(device, args); + base.OccSensor_GlsOccupancySensorChange(device, args); } - /// + /// /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. /// Then calls the base delegate method to ensure any common event IDs are captured. /// /// /// protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) - { - if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId) - RawOccupancyPirFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId) - RawOccupancyUsFeedback.FireUpdate(); + { + switch (args.EventId) + { + case GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId: + RawOccupancyPirFeedback.FireUpdate(); + break; + case GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId: + RawOccupancyUsFeedback.FireUpdate(); + break; + } - base.OccSensor_BaseEvent(device, args); - } + base.OccSensor_BaseEvent(device, args); + } - /// + /// /// Sets the OrWhenVacated state /// /// public void SetOrWhenVacatedState(bool state) { - OccSensor.OrWhenVacated.BoolValue = state; + _occSensor.OrWhenVacated.BoolValue = state; } /// @@ -161,7 +173,7 @@ namespace PepperDash.Essentials.Core /// public void SetAndWhenVacatedState(bool state) { - OccSensor.AndWhenVacated.BoolValue = state; + _occSensor.AndWhenVacated.BoolValue = state; } /// @@ -170,8 +182,8 @@ namespace PepperDash.Essentials.Core /// public void SetUsAEnable(bool state) { - OccSensor.EnableUsA.BoolValue = state; - OccSensor.DisableUsA.BoolValue = !state; + _occSensor.EnableUsA.BoolValue = state; + _occSensor.DisableUsA.BoolValue = !state; } @@ -181,28 +193,28 @@ namespace PepperDash.Essentials.Core /// public void SetUsBEnable(bool state) { - OccSensor.EnableUsB.BoolValue = state; - OccSensor.DisableUsB.BoolValue = !state; + _occSensor.EnableUsB.BoolValue = state; + _occSensor.DisableUsB.BoolValue = !state; } public void IncrementUsSensitivityInOccupiedState(bool pressRelease) { - OccSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + _occSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; } public void DecrementUsSensitivityInOccupiedState(bool pressRelease) { - OccSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + _occSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; } public void IncrementUsSensitivityInVacantState(bool pressRelease) { - OccSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; + _occSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; } public void DecrementUsSensitivityInVacantState(bool pressRelease) { - OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; + _occSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) @@ -218,62 +230,58 @@ namespace PepperDash.Essentials.Core base.GetSettings(); Debug.Console(0, this, "Ultrasonic Enabled A: {0} | B: {1}", - OccSensor.UsAEnabledFeedback.BoolValue, - OccSensor.UsBEnabledFeedback.BoolValue); + _occSensor.UsAEnabledFeedback.BoolValue, + _occSensor.UsBEnabledFeedback.BoolValue); Debug.Console(0, this, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", - OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue, - OccSensor.UsSensitivityInVacantStateFeedback.UShortValue); + _occSensor.UsSensitivityInOccupiedStateFeedback.UShortValue, + _occSensor.UsSensitivityInVacantStateFeedback.UShortValue); var dash = new string('*', 50); CrestronConsole.PrintLine(string.Format("{0}\n", dash)); } - - #region PreActivation - - private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) - { - var control = CommFactory.GetControlPropertiesConfig(dc); - var cresnetId = control.CresnetIdInt; - var branchId = control.ControlPortNumber; - var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; - - if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, Global.ControlSystem); - } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; - - if (cresnetBridge != null) - { - Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); - return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); - } - Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); - return null; - } - #endregion - - public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory - { - public GlsOdtOccupancySensorControllerFactory() - { - TypeNames = new List() { "glsodtccn" }; - } - - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); - - return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); - } - - } } + public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory + { + public GlsOdtOccupancySensorControllerFactory() + { + TypeNames = new List { "glsodtccn" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device"); + + return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc); + } + + private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = String.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey); + return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + } + } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs new file mode 100644 index 00000000..573d94ac --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOirOccupancySensorController.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + public class GlsOirOccupancySensorController:GlsOccupancySensorBaseController + { + private GlsOirCCn _occSensor; + + public GlsOirOccupancySensorController(string key, Func preActivationFunc,DeviceConfig config) : this(key,config.Name, preActivationFunc, config) + { + } + + public GlsOirOccupancySensorController(string key, string name, Func preActivationFunc, DeviceConfig config) : base(key, name, config) + { + AddPreActivationAction(() => + { + _occSensor = preActivationFunc(config); + + RegisterCrestronGenericBase(_occSensor); + + RegisterGlsOccupancySensorBaseController(_occSensor); + }); + } + + #region Overrides of CrestronGenericBridgeableBaseDevice + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #endregion + } + + public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory + { + public GlsOccupancySensorBaseControllerFactory() + { + TypeNames = new List { "glsoirccn" }; + } + + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new GlsOirOccupancySensorController Device"); + + return new GlsOirOccupancySensorController(dc.Key, GetGlsOirCCn, dc); + } + + private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc) + { + var control = CommFactory.GetControlPropertiesConfig(dc); + var cresnetId = control.CresnetIdInt; + var branchId = control.ControlPortNumber; + var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey; + + if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase)) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); + return new GlsOirCCn(cresnetId, Global.ControlSystem); + } + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; + + if (cresnetBridge != null) + { + Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey); + return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); + } + Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); + return null; + } + + } +} \ No newline at end of file