From bfe87ae090c2619fda8148c3c0bd59017f6e8c00 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:35:09 -0500 Subject: [PATCH 1/6] Added new interface IHasCresnetBranches Added new CinCenCn2Controller InProgress #297 --- .../DinCenCn/DinCenCnController.cs | 57 +++++++++++++++++++ .../DinCenCn/IHasCresnetBranches.cs | 15 +++++ .../PepperDash_Essentials_Core.csproj | 2 + 3 files changed, 74 insertions(+) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs new file mode 100644 index 00000000..c3ce095f --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.GeneralIO; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using System.Linq; +using PepperDash_Essentials_Core.Crestron_IO.DinCenCn; + + +namespace PepperDash.Essentials.Core +{ + public class DinCenCn2Controller : CrestronGenericBaseDevice, IHasCresnetBranches + { + private readonly DinCenCn2 _device; + + public CrestronCollection CresnetBranches + { + get { + return _device != null ? _device.Branches : null; + } + } + + public DinCenCn2Controller(string key, string name, DinCenCn2 device, DeviceConfig config) + : base(key, name, device) + { + _device = device; + } + + public class DinCenCn2ControllerFactory : EssentialsDeviceFactory + { + public DinCenCn2ControllerFactory() + { + TypeNames = new List() { "dincencn2", "dincencn2poe", "din-cencn2", "din-cencn2-poe" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device"); + + var control = CommFactory.GetControlPropertiesConfig(dc); + var ipid = control.IpIdInt; + + if (dc.Type.ToLower().Contains("poe")) + { + return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2Poe(ipid, Global.ControlSystem), dc); + } + + return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2(ipid, Global.ControlSystem), dc); + } + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs new file mode 100644 index 00000000..da5281b4 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; + +namespace PepperDash_Essentials_Core.Crestron_IO.DinCenCn +{ + public interface IHasCresnetBranches + { + CrestronCollection CresnetBranches { get; } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 7e67f4e1..7aa344ba 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -172,6 +172,8 @@ + + From 4360dcdca94cdf46f7adf0f8513745bbd8063670 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:36:59 -0500 Subject: [PATCH 2/6] Update C2nRthsController to use IHasCresnetBranches Interface Inprogress #297 --- .../Crestron IO/C2nRts/C2nRthsController.cs | 4 ++-- .../Crestron IO/DinCenCn/DinCenCnController.cs | 8 +------- .../Crestron IO/DinCenCn/IHasCresnetBranches.cs | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs index 8416efac..e1aa545e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/C2nRts/C2nRthsController.cs @@ -118,12 +118,12 @@ namespace PepperDash.Essentials.Core.CrestronIO Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); return new C2nRths(cresnetId, Global.ControlSystem); } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge; + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; if (cresnetBridge != null) { Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey); - return new C2nRths(cresnetId, cresnetBridge.Branches[branchId]); + return new C2nRths(cresnetId, cresnetBridge.CresnetBranches[branchId]); } Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); return null; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs index c3ce095f..68fedc82 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/DinCenCnController.cs @@ -1,15 +1,9 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.GeneralIO; -using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; -using System.Linq; -using PepperDash_Essentials_Core.Crestron_IO.DinCenCn; namespace PepperDash.Essentials.Core diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs index da5281b4..11e1b707 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/DinCenCn/IHasCresnetBranches.cs @@ -6,7 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; -namespace PepperDash_Essentials_Core.Crestron_IO.DinCenCn +namespace PepperDash.Essentials.Core { public interface IHasCresnetBranches { From 82fb724bdd549902c4e2e3ec56ccb9bbc1786651 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:37:56 -0500 Subject: [PATCH 3/6] Update StatusSignController to use IHasCresnetBranches Interface InProgress #297 --- .../Crestron IO/StatusSign/StatusSignController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs index b269745e..6f0cf80e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Crestron IO/StatusSign/StatusSignController.cs @@ -188,12 +188,12 @@ namespace PepperDash.Essentials.Core.CrestronIO Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); return new StatusSign(cresnetId, Global.ControlSystem); } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge; + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; if (cresnetBridge != null) { Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey); - return new StatusSign(cresnetId, cresnetBridge.Branches[branchId]); + return new StatusSign(cresnetId, cresnetBridge.CresnetBranches[branchId]); } Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); return null; From 3eeca2fbedc2d97784186e46c65c1820605b0f42 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:38:56 -0500 Subject: [PATCH 4/6] Update GlsPartitionSensorController to use IHasCresnetBranches Interface InProgress #297 --- .../PartitionSensor/GlsPartitionSensorController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs index 44dfbb4b..8dd30eff 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs @@ -248,12 +248,12 @@ namespace PepperDash.Essentials.Core Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); return new GlsPartCn(cresnetId, Global.ControlSystem); } - var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge; + var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches; if (cresnetBridge != null) { Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey); - return new GlsPartCn(cresnetId, cresnetBridge.Branches[branchId]); + return new GlsPartCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); } Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); return null; From 7ed4f479a93741c157330479e247cbc0ef6572ac Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:40:11 -0500 Subject: [PATCH 5/6] Update GlsOccupancyBaseController to use IHasCresnetBranches Interface InProgress #297 --- .../Occupancy/GlsOccupancySensorBaseController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs index 10e18fd8..077be4f5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOccupancySensorBaseController.cs @@ -425,12 +425,12 @@ namespace PepperDash.Essentials.Core 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 ICresnetBridge; + 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.Branches[branchId]); + return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); } Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); return null; From ca75b751a7468f2f5d38e359021a64b1c1ebc69a Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 2 Jul 2020 15:42:14 -0500 Subject: [PATCH 6/6] Update GlsOccupancyController to use IHasCresnetBranches Interface Resolves #297 --- .../Occupancy/GlsOdtOccupancySensorController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs index 7199d292..4900ca93 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Occupancy/GlsOdtOccupancySensorController.cs @@ -184,12 +184,12 @@ namespace PepperDash.Essentials.Core 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 ICresnetBridge; + 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.Branches[branchId]); + return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]); } Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey); return null;