Merge branch 'main' into hotfix/dge-device-info

This commit is contained in:
Andrew Welker
2021-02-04 11:25:10 -07:00
committed by GitHub
7 changed files with 1475 additions and 1105 deletions

View File

@@ -597,12 +597,21 @@ namespace PepperDash.Essentials
if (VideoCodec.UsageTracker.InUseTracker.InUseFeedback.BoolValue) if (VideoCodec.UsageTracker.InUseTracker.InUseFeedback.BoolValue)
{ {
Debug.Console(1, this, "Video Codec in use, deactivating standby on codec"); Debug.Console(1, this, "Video Codec in use, deactivating standby on codec");
VideoCodec.StandbyDeactivate();
} }
if (VideoCodec.StandbyIsOnFeedback.BoolValue) if (VideoCodec.StandbyIsOnFeedback.BoolValue)
{ {
VideoCodec.StandbyDeactivate(); VideoCodec.StandbyDeactivate();
} }
else
{
Debug.Console(1, this, "Video codec not in standby. No need to wake.");
}
}
else
{
Debug.Console(1, this, "Room OnFeedback state: {0}", OnFeedback.BoolValue);
} }
// report back when done // report back when done

View File

@@ -14,10 +14,13 @@ using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
[Description("Wrapper class for CEN-ODT-C-POE")] [Description("Wrapper class for CEN-ODT-C-POE")]
[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 CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider public class CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
{ {
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 +74,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);
@@ -120,12 +125,81 @@ namespace PepperDash.Essentials.Core
OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange); OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange);
AddPostActivationAction(() =>
{
OccSensor.OnlineStatusChange += (o, a) =>
{
if (a.DeviceOnLine)
{
ApplySettingsToSensorFromConfig();
}
};
if (OccSensor.IsOnline)
{
ApplySettingsToSensorFromConfig();
}
});
} }
/// <summary>
/// Applies any sensor settings defined in config
/// </summary>
protected virtual void ApplySettingsToSensorFromConfig()
{
Debug.Console(1, this, "Checking config for settings to apply");
if (PropertiesConfig.EnablePir != null)
{
SetPirEnable((bool)PropertiesConfig.EnablePir);
}
if (PropertiesConfig.EnableLedFlash != null)
{
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
}
if (PropertiesConfig.RemoteTimeout != null)
{
SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout);
}
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.
@@ -432,6 +506,41 @@ namespace PepperDash.Essentials.Core
} }
} }
/// <summary>
/// Method to print current settings to console
/// </summary>
public void GetSettings()
{
var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, this, "Vacancy Detected: {0}",
OccSensor.VacancyDetectedFeedback.BoolValue);
Debug.Console(0, Key, "Timeout Current: {0} | Remote: {1}",
OccSensor.CurrentTimeoutFeedback.UShortValue,
OccSensor.RemoteTimeout.UShortValue);
Debug.Console(0, Key, "Short Timeout Enabled: {0}",
OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue,
OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback,
OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback);
Debug.Console(0, Key, "Ultrasonic Enabled A: {0} | B: {1}",
OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue,
OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue);
Debug.Console(0, Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}",
OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback,
OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
@@ -558,6 +667,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)
@@ -566,7 +677,7 @@ namespace PepperDash.Essentials.Core
return null; return null;
} }
return new CenOdtOccupancySensorBaseController(key, name, occSensor); return new CenOdtOccupancySensorBaseController(key, name, occSensor, props);
} }
} }
} }

View File

@@ -14,8 +14,11 @@ using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")] [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 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; }
@@ -59,7 +62,16 @@ namespace PepperDash.Essentials.Core
DeviceConfig config) DeviceConfig config)
: base(key, config.Name) : base(key, config.Name)
{ {
var props = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
if (props != null)
{
PropertiesConfig = props;
}
else
{
Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig");
}
AddPreActivationAction(() => AddPreActivationAction(() =>
{ {
@@ -70,9 +82,106 @@ namespace PepperDash.Essentials.Core
RegisterGlsOdtSensorBaseController(OccSensor); RegisterGlsOdtSensorBaseController(OccSensor);
}); });
AddPostActivationAction(() =>
{
OccSensor.OnlineStatusChange += (o, a) =>
{
if (a.DeviceOnLine)
{
ApplySettingsToSensorFromConfig();
}
};
});
} }
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) {} public GlsOccupancySensorBaseController(string key, string name, DeviceConfig config)
: base(key, name)
{
var props = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
if (props != null)
{
PropertiesConfig = props;
}
else
{
Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig");
}
AddPostActivationAction(() =>
{
OccSensor.OnlineStatusChange += (o, a) =>
{
if (a.DeviceOnLine)
{
ApplySettingsToSensorFromConfig();
}
};
if (OccSensor.IsOnline)
{
ApplySettingsToSensorFromConfig();
}
});
}
/// <summary>
/// Applies any sensor settings defined in config
/// </summary>
protected virtual void ApplySettingsToSensorFromConfig()
{
Debug.Console(1, this, "Attempting to apply settings to sensor from config");
if (PropertiesConfig.EnablePir != null)
{
Debug.Console(1, this, "EnablePir found, attempting to set value from config");
SetPirEnable((bool)PropertiesConfig.EnablePir);
}
else
{
Debug.Console(1, this, "EnablePir null, no value specified in config");
}
if (PropertiesConfig.EnableLedFlash != null)
{
Debug.Console(1, this, "EnableLedFlash found, attempting to set value from config");
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
}
if (PropertiesConfig.RemoteTimeout != null)
{
Debug.Console(1, this, "RemoteTimeout found, attempting to set value from config");
SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout);
}
else
{
Debug.Console(1, this, "RemoteTimeout null, no value specified in config");
}
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)
{ {
@@ -195,6 +304,8 @@ namespace PepperDash.Essentials.Core
/// <param name="state"></param> /// <param name="state"></param>
public void SetPirEnable(bool state) public void SetPirEnable(bool state)
{ {
Debug.Console(1, this, "Setting EnablePir to: {0}", state);
if (state) if (state)
{ {
OccSensor.EnablePir.BoolValue = state; OccSensor.EnablePir.BoolValue = state;
@@ -280,6 +391,8 @@ namespace PepperDash.Essentials.Core
public void SetRemoteTimeout(ushort time) public void SetRemoteTimeout(ushort time)
{ {
Debug.Console(1, this, "Setting RemoteTimout to: {0}", time);
OccSensor.RemoteTimeout.UShortValue = time; OccSensor.RemoteTimeout.UShortValue = time;
} }
@@ -293,7 +406,32 @@ namespace PepperDash.Essentials.Core
OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value;
} }
/// <summary>
/// Method to print current occ settings to console.
/// </summary>
/// <param name="key"></param>
public virtual void GetSettings()
{
var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, this, "Vacancy Detected: {0}",
OccSensor.VacancyDetectedFeedback.BoolValue);
Debug.Console(0, this, "Timeout Current: {0} | Local: {1}",
OccSensor.CurrentTimeoutFeedback.UShortValue,
OccSensor.LocalTimeoutFeedback.UShortValue);
Debug.Console(0, this, "Short Timeout Enabled: {0}",
OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, this, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
OccSensor.PirEnabledFeedback.BoolValue,
OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue,
OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
}
protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist, protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist,
uint joinStart, string joinMapKey, EiscApiAdvanced bridge) uint joinStart, string joinMapKey, EiscApiAdvanced bridge)

View File

@@ -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; }
}
}

View File

@@ -14,6 +14,7 @@ using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
[Description("Wrapper class for Dual Technology GLS Occupancy Sensors")] [Description("Wrapper class for Dual Technology GLS Occupancy Sensors")]
[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 class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController
{ {
public new GlsOdtCCn OccSensor { get; private set; } public new GlsOdtCCn OccSensor { get; private set; }
@@ -37,7 +38,7 @@ namespace PepperDash.Essentials.Core
public GlsOdtOccupancySensorController(string key, Func<DeviceConfig, GlsOdtCCn> preActivationFunc, public GlsOdtOccupancySensorController(string key, Func<DeviceConfig, GlsOdtCCn> preActivationFunc,
DeviceConfig config) DeviceConfig config)
: base(key, config.Name) : base(key, config.Name, config)
{ {
AddPreActivationAction(() => AddPreActivationAction(() =>
{ {
@@ -64,6 +65,45 @@ namespace PepperDash.Essentials.Core
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
}); });
}
protected override void ApplySettingsToSensorFromConfig()
{
base.ApplySettingsToSensorFromConfig();
if (PropertiesConfig.EnableUsA != null)
{
Debug.Console(1, this, "EnableUsA found, attempting to set value from config");
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
}
else
{
Debug.Console(1, this, "EnableUsA null, no value specified in config");
}
if (PropertiesConfig.EnableUsB != null)
{
Debug.Console(1, this, "EnableUsB found, attempting to set value from config");
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
}
else
{
Debug.Console(1, this, "EnablePir null, no value specified in config");
}
if (PropertiesConfig.OrWhenVacatedState != null)
{
SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState);
}
if (PropertiesConfig.AndWhenVacatedState != null)
{
SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState);
}
} }
/// <summary> /// <summary>
@@ -170,6 +210,26 @@ namespace PepperDash.Essentials.Core
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
} }
/// <summary>
/// Method to print occ sensor settings to console.
/// </summary>
public override void GetSettings()
{
base.GetSettings();
Debug.Console(0, this, "Ultrasonic Enabled A: {0} | B: {1}",
OccSensor.UsAEnabledFeedback.BoolValue,
OccSensor.UsBEnabledFeedback.BoolValue);
Debug.Console(0, this, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}",
OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue,
OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
}
#region PreActivation #region PreActivation
private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc) private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc)

View File

@@ -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" />

View File

@@ -1369,7 +1369,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
set set
{ {
// If the incoming value is "On" it sets the BoolValue true, otherwise sets it false // If the incoming value is "On" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "On"; BoolValue = value == "On" || value == "Standby";
OnValueChanged(); OnValueChanged();
} }
} }