mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 19:34:51 +00:00
feat: add circuitType property to IOPortConfig and implement state inversion in digital input devices
This commit is contained in:
@@ -21,6 +21,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
public class GenericDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IHasFeedback
|
||||
{
|
||||
private DigitalInput inputPort;
|
||||
private bool invertState;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InputStateFeedback
|
||||
@@ -41,7 +42,10 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
IOPortConfig config)
|
||||
: base(key, name)
|
||||
{
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => inputPort.State);
|
||||
invertState = !string.IsNullOrEmpty(config.CircuitType) &&
|
||||
config.CircuitType.Equals("NC", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => invertState ? !inputPort.State : inputPort.State);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider, IHasFeedback
|
||||
{
|
||||
private Versiport inputPort;
|
||||
private bool invertState;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InputStateFeedback
|
||||
@@ -47,7 +48,10 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
public GenericVersiportDigitalInputDevice(string key, string name, Func<IOPortConfig, Versiport> postActivationFunc, IOPortConfig config) :
|
||||
base(key, name)
|
||||
{
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => inputPort.DigitalIn);
|
||||
invertState = !string.IsNullOrEmpty(config.CircuitType) &&
|
||||
config.CircuitType.Equals("NC", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
InputStateFeedback = new BoolFeedback("inputState", () => invertState ? !inputPort.DigitalIn : inputPort.DigitalIn);
|
||||
PartitionPresentFeedback = new BoolFeedback("partitionPresent", () => !inputPort.DigitalIn);
|
||||
|
||||
AddPostActivationAction(() =>
|
||||
|
||||
@@ -37,5 +37,12 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
||||
/// </summary>
|
||||
[JsonProperty("minimumChange")]
|
||||
public int MinimumChange { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the circuit type: "NO" (Normally Open) or "NC" (Normally Closed)
|
||||
/// If set to "NC", the input state will be inverted. Defaults to "NO" if not specified.
|
||||
/// </summary>
|
||||
[JsonProperty("circuitType")]
|
||||
public string CircuitType { get; set; } = "NO";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user