mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
#592 Adds properties config class for occ sensors
This commit is contained in:
@@ -18,6 +18,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
public CenOdtCPoe OccSensor { get; private set; }
|
public CenOdtCPoe OccSensor { get; private set; }
|
||||||
|
|
||||||
|
public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
|
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; }
|
public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; }
|
||||||
@@ -71,9 +73,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CenOdtOccupancySensorBaseController(string key, string name, CenOdtCPoe sensor)
|
public CenOdtOccupancySensorBaseController(string key, string name, CenOdtCPoe sensor, GlsOccupancySensorPropertiesConfig config)
|
||||||
: base(key, name, sensor)
|
: base(key, name, sensor)
|
||||||
{
|
{
|
||||||
|
PropertiesConfig = config;
|
||||||
|
|
||||||
OccSensor = sensor;
|
OccSensor = sensor;
|
||||||
|
|
||||||
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
||||||
@@ -119,8 +123,64 @@ namespace PepperDash.Essentials.Core
|
|||||||
OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent);
|
OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent);
|
||||||
|
|
||||||
OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange);
|
OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange);
|
||||||
|
|
||||||
|
AddPostActivationAction(() =>
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies any sensor settings defined in config
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void ApplySettingsToSensorFromConfig()
|
||||||
|
{
|
||||||
|
if (PropertiesConfig.EnablePir != null)
|
||||||
|
{
|
||||||
|
SetPirEnable((bool)PropertiesConfig.EnablePir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableLedFlash != null)
|
||||||
|
{
|
||||||
|
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.ShortTimeoutState != null)
|
||||||
|
{
|
||||||
|
SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableRawStates != null)
|
||||||
|
{
|
||||||
|
EnableRawStates((bool)PropertiesConfig.EnableRawStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.InternalPhotoSensorMinChange != null)
|
||||||
|
{
|
||||||
|
SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableUsA != null)
|
||||||
|
{
|
||||||
|
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableUsB != null)
|
||||||
|
{
|
||||||
|
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.OrWhenVacatedState != null)
|
||||||
|
{
|
||||||
|
SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.AndWhenVacatedState != null)
|
||||||
|
{
|
||||||
|
SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs.
|
/// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -584,6 +644,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
var name = dc.Name;
|
var name = dc.Name;
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
|
||||||
|
var props = dc.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
|
||||||
|
|
||||||
var occSensor = new CenOdtCPoe(comm.IpIdInt, Global.ControlSystem);
|
var occSensor = new CenOdtCPoe(comm.IpIdInt, Global.ControlSystem);
|
||||||
|
|
||||||
if (occSensor == null)
|
if (occSensor == null)
|
||||||
@@ -592,7 +654,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CenOdtOccupancySensorBaseController(key, name, occSensor);
|
return new CenOdtOccupancySensorBaseController(key, name, occSensor, props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
|
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
|
||||||
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
||||||
{
|
{
|
||||||
|
public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; }
|
||||||
|
|
||||||
public GlsOccupancySensorBase OccSensor { get; private set; }
|
public GlsOccupancySensorBase OccSensor { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
|
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
|
||||||
@@ -60,6 +62,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
: base(key, config.Name)
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
PropertiesConfig = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
|
||||||
|
|
||||||
AddPreActivationAction(() =>
|
AddPreActivationAction(() =>
|
||||||
{
|
{
|
||||||
@@ -70,10 +73,53 @@ namespace PepperDash.Essentials.Core
|
|||||||
RegisterGlsOdtSensorBaseController(OccSensor);
|
RegisterGlsOdtSensorBaseController(OccSensor);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddPostActivationAction(() =>
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) { }
|
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) { }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies any sensor settings defined in config
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void ApplySettingsToSensorFromConfig()
|
||||||
|
{
|
||||||
|
if (PropertiesConfig.EnablePir != null)
|
||||||
|
{
|
||||||
|
SetPirEnable((bool)PropertiesConfig.EnablePir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableLedFlash != null)
|
||||||
|
{
|
||||||
|
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.ShortTimeoutState != null)
|
||||||
|
{
|
||||||
|
SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableRawStates != null)
|
||||||
|
{
|
||||||
|
EnableRawStates((bool)PropertiesConfig.EnableRawStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.InternalPhotoSensorMinChange != null)
|
||||||
|
{
|
||||||
|
SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.ExternalPhotoSensorMinChange != null)
|
||||||
|
{
|
||||||
|
SetExternalPhotoSensorMinChange((ushort)PropertiesConfig.ExternalPhotoSensorMinChange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void RegisterGlsOdtSensorBaseController(GlsOccupancySensorBase occSensor)
|
protected void RegisterGlsOdtSensorBaseController(GlsOccupancySensorBase occSensor)
|
||||||
{
|
{
|
||||||
OccSensor = occSensor;
|
OccSensor = occSensor;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines configuration properties for Crestron GLS series occupancy sensors
|
||||||
|
/// </summary>
|
||||||
|
public class GlsOccupancySensorPropertiesConfig
|
||||||
|
{
|
||||||
|
// Single Technology Sensors (PIR): GlsOccupancySensorBase
|
||||||
|
[JsonProperty("enablePir")]
|
||||||
|
public bool? EnablePir { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("enableLedFlash")]
|
||||||
|
public bool? EnableLedFlash { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("shortTimeoutState")]
|
||||||
|
public bool? ShortTimeoutState { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("enableRawStates")]
|
||||||
|
public bool? EnableRawStates { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("remoteTimeout")]
|
||||||
|
public ushort? RemoteTimeout { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("internalPhotoSensorMinChange")]
|
||||||
|
public ushort? InternalPhotoSensorMinChange { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("externalPhotoSensorMinChange")]
|
||||||
|
public ushort? ExternalPhotoSensorMinChange { get; set; }
|
||||||
|
|
||||||
|
// Dual Technology Sensors: GlsOdtCCn
|
||||||
|
[JsonProperty("enableUsA")]
|
||||||
|
public bool? EnableUsA { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("enableUsB")]
|
||||||
|
public bool? EnableUsB { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("orWhenVacatedState")]
|
||||||
|
public bool? OrWhenVacatedState { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("andWhenVacatedState")]
|
||||||
|
public bool? AndWhenVacatedState { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,6 +66,31 @@ namespace PepperDash.Essentials.Core
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void ApplySettingsToSensorFromConfig()
|
||||||
|
{
|
||||||
|
base.ApplySettingsToSensorFromConfig();
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableUsA != null)
|
||||||
|
{
|
||||||
|
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.EnableUsB != null)
|
||||||
|
{
|
||||||
|
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.OrWhenVacatedState != null)
|
||||||
|
{
|
||||||
|
SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PropertiesConfig.AndWhenVacatedState != null)
|
||||||
|
{
|
||||||
|
SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class.
|
/// 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.
|
/// Then calls the base delegate method to ensure any common event IDs are captured.
|
||||||
|
|||||||
@@ -227,6 +227,7 @@
|
|||||||
<Compile Include="Global\EthernetAdapterInfo.cs" />
|
<Compile Include="Global\EthernetAdapterInfo.cs" />
|
||||||
<Compile Include="Interfaces\ILogStrings.cs" />
|
<Compile Include="Interfaces\ILogStrings.cs" />
|
||||||
<Compile Include="Interfaces\ILogStringsWithLevel.cs" />
|
<Compile Include="Interfaces\ILogStringsWithLevel.cs" />
|
||||||
|
<Compile Include="Occupancy\GlsOccupancySensorPropertiesConfig.cs" />
|
||||||
<Compile Include="Queues\ComsMessage.cs" />
|
<Compile Include="Queues\ComsMessage.cs" />
|
||||||
<Compile Include="Queues\ProcessStringMessage.cs" />
|
<Compile Include="Queues\ProcessStringMessage.cs" />
|
||||||
<Compile Include="Queues\GenericQueue.cs" />
|
<Compile Include="Queues\GenericQueue.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user