diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
similarity index 63%
rename from essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorController.cs
rename to essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
index 29847144..714f729f 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorController.cs
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs
@@ -7,12 +7,28 @@ using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash_Essentials_Core.Bridges.JoinMaps;
-namespace PepperDash.Essentials.Devices.Common.PartitionSensor
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+using Crestron.SimplSharpPro;
+using Crestron.SimplSharpPro.Gateways;
+using Newtonsoft.Json;
+using Crestron.SimplSharpPro.DeviceSupport;
+
+
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.Core.Config;
+using PepperDash_Essentials_Core;
+
+namespace PepperDash.Essentials.Core
{
[Description("Wrapper class for GLS Cresnet Partition Sensor")]
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
{
- private readonly GlsPartCn _partitionSensor;
+ private GlsPartCn _partitionSensor;
public StringFeedback NameFeedback { get; private set; }
public BoolFeedback EnableFeedback { get; private set; }
@@ -25,27 +41,24 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
public bool TestPartitionSensedFeedback { get; private set; }
public int TestSensitivityFeedback { get; private set; }
- ///
- /// Constructor
- ///
- ///
- ///
- ///
- public GlsPartitionSensorController(string key, string name, GlsPartCn hardware)
- : base(key, name, hardware)
+
+ public GlsPartitionSensorController(string key, Func preActivationFunc, DeviceConfig config)
+ : base(key, config.Name)
{
- _partitionSensor = hardware;
+ AddPreActivationAction(() =>
+ {
+ _partitionSensor = preActivationFunc(config);
- NameFeedback = new StringFeedback(() => Name);
- EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
- PartitionSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
- PartitionNotSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionNotSensedFeedback.BoolValue);
- SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
+ NameFeedback = new StringFeedback(() => Name);
+ EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
+ PartitionSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
+ PartitionNotSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionNotSensedFeedback.BoolValue);
+ SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
- if (_partitionSensor != null) _partitionSensor.BaseEvent += PartitionSensor_BaseEvent;
+ if (_partitionSensor != null) _partitionSensor.BaseEvent += PartitionSensor_BaseEvent;
+ });
}
-
private void PartitionSensor_BaseEvent(GenericBase device, BaseEventArgs args)
{
Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index);
@@ -218,5 +231,48 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
PartitionNotSensedFeedback.FireUpdate();
SensitivityFeedback.FireUpdate();
}
+
+ #region PreActivation
+
+ private static GlsPartCn GetGlsPartCnDevice(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 GlsPartCn");
+ return new GlsPartCn(cresnetId, Global.ControlSystem);
+ }
+ var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge;
+
+ if (cresnetBridge != null)
+ {
+ Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn");
+ return new GlsPartCn(cresnetId, cresnetBridge.Branches[branchId]);
+ }
+ Debug.Console(0, "Device {0} is not a valid cresnet master", branchId);
+ return null;
+ }
+ #endregion
+
+
+ public class GlsPartitionSensorControllerFactory : EssentialsDeviceFactory
+ {
+ public GlsPartitionSensorControllerFactory()
+ {
+ TypeNames = new List() { "glspartcn" };
+ }
+
+ public override EssentialsDevice BuildDevice(DeviceConfig dc)
+ {
+ Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
+
+ return new GlsPartitionSensorController(dc.Key, GetGlsPartCnDevice, dc);
+ }
+ }
+
}
}
\ 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 a1efc7ff..98343f35 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -215,6 +215,7 @@
+
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
index 78a6e565..ba12a129 100644
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
+++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj
@@ -116,8 +116,6 @@
-
-
diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorControllerFactory.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorControllerFactory.cs
deleted file mode 100644
index a60637f7..00000000
--- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/PartitionSensor/GlsPartitionSensorControllerFactory.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Collections.Generic;
-using Crestron.SimplSharpPro.GeneralIO;
-using PepperDash.Core;
-using PepperDash.Essentials.Core;
-using PepperDash.Essentials.Core.Config;
-
-namespace PepperDash.Essentials.Devices.Common.PartitionSensor
-{
- public class GlsPartitionSensorControllerFactory : EssentialsDeviceFactory
- {
- public GlsPartitionSensorControllerFactory()
- {
- TypeNames = new List() { "glspartcn" };
- }
-
- public override EssentialsDevice BuildDevice(DeviceConfig dc)
- {
- Debug.Console(2, "Factory Attempting to create new GLS-PART-CN Device");
-
- var comm = CommFactory.GetControlPropertiesConfig(dc);
- if (comm == null)
- {
- Debug.Console(0, "ERROR: Control Properties Config for {0} is null", dc.Key);
- return null;
- }
-
- var sensor = new GlsPartCn(comm.CresnetIdInt, Global.ControlSystem);
- return new GlsPartitionSensorController(dc.Key, dc.Name, sensor);
- }
- }
-}
\ No newline at end of file