mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Move GlsPartitionSensorController into PepperDash.Essentials.Core
Add GlsPartitionSensorControllerFactory to GlsPartitionSensorController Updates GlsPartitionSensorController to register device in PreActivate Resolves #292
This commit is contained in:
@@ -7,12 +7,28 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash_Essentials_Core.Bridges.JoinMaps;
|
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")]
|
[Description("Wrapper class for GLS Cresnet Partition Sensor")]
|
||||||
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
|
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
|
||||||
{
|
{
|
||||||
private readonly GlsPartCn _partitionSensor;
|
private GlsPartCn _partitionSensor;
|
||||||
|
|
||||||
public StringFeedback NameFeedback { get; private set; }
|
public StringFeedback NameFeedback { get; private set; }
|
||||||
public BoolFeedback EnableFeedback { get; private set; }
|
public BoolFeedback EnableFeedback { get; private set; }
|
||||||
@@ -25,16 +41,13 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
public bool TestPartitionSensedFeedback { get; private set; }
|
public bool TestPartitionSensedFeedback { get; private set; }
|
||||||
public int TestSensitivityFeedback { get; private set; }
|
public int TestSensitivityFeedback { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
public GlsPartitionSensorController(string key, Func<DeviceConfig, GlsPartCn> preActivationFunc, DeviceConfig config)
|
||||||
/// </summary>
|
: base(key, config.Name)
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <param name="hardware"></param>
|
|
||||||
public GlsPartitionSensorController(string key, string name, GlsPartCn hardware)
|
|
||||||
: base(key, name, hardware)
|
|
||||||
{
|
{
|
||||||
_partitionSensor = hardware;
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
_partitionSensor = preActivationFunc(config);
|
||||||
|
|
||||||
NameFeedback = new StringFeedback(() => Name);
|
NameFeedback = new StringFeedback(() => Name);
|
||||||
EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
|
EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
|
||||||
@@ -43,9 +56,9 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
|
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)
|
private void PartitionSensor_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index);
|
Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index);
|
||||||
@@ -218,5 +231,48 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
PartitionNotSensedFeedback.FireUpdate();
|
PartitionNotSensedFeedback.FireUpdate();
|
||||||
SensitivityFeedback.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<GlsPartitionSensorController>
|
||||||
|
{
|
||||||
|
public GlsPartitionSensorControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,6 +215,7 @@
|
|||||||
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
||||||
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
||||||
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
||||||
|
<Compile Include="PartitionSensor\GlsPartitionSensorController.cs" />
|
||||||
<Compile Include="Plugins\PluginLoader.cs" />
|
<Compile Include="Plugins\PluginLoader.cs" />
|
||||||
<Compile Include="Presets\PresetBase.cs" />
|
<Compile Include="Presets\PresetBase.cs" />
|
||||||
<Compile Include="Plugins\IPluginDeviceFactory.cs" />
|
<Compile Include="Plugins\IPluginDeviceFactory.cs" />
|
||||||
|
|||||||
@@ -116,8 +116,6 @@
|
|||||||
<Compile Include="ImageProcessors\TVOneCorioPropertiesConfig.cs" />
|
<Compile Include="ImageProcessors\TVOneCorioPropertiesConfig.cs" />
|
||||||
<Compile Include="Occupancy\CenOdtOccupancySensorBaseController.cs" />
|
<Compile Include="Occupancy\CenOdtOccupancySensorBaseController.cs" />
|
||||||
<Compile Include="Occupancy\GlsOdtOccupancySensorController.cs" />
|
<Compile Include="Occupancy\GlsOdtOccupancySensorController.cs" />
|
||||||
<Compile Include="PartitionSensor\GlsPartitionSensorController.cs" />
|
|
||||||
<Compile Include="PartitionSensor\GlsPartitionSensorControllerFactory.cs" />
|
|
||||||
<Compile Include="Power Controllers\Digitallogger.cs" />
|
<Compile Include="Power Controllers\Digitallogger.cs" />
|
||||||
<Compile Include="Power Controllers\DigitalLoggerPropertiesConfig.cs" />
|
<Compile Include="Power Controllers\DigitalLoggerPropertiesConfig.cs" />
|
||||||
<Compile Include="ImageProcessors\AnalogWay\AnalongWayLiveCore.cs" />
|
<Compile Include="ImageProcessors\AnalogWay\AnalongWayLiveCore.cs" />
|
||||||
|
|||||||
@@ -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<GlsPartitionSensorController>
|
|
||||||
{
|
|
||||||
public GlsPartitionSensorControllerFactory()
|
|
||||||
{
|
|
||||||
TypeNames = new List<string>() { "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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user