From 54dcb5de087e4e0d53869accb9e80723ea860505 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 30 Jan 2025 15:21:12 -0500 Subject: [PATCH] feat: implement IPartitionStateProvider to Generic VersaPortInput --- .../CrestronIO/GenericVersiportInputDevice.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs index 5ed1bfa8..c9133a60 100644 --- a/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs +++ b/src/PepperDash.Essentials.Core/CrestronIO/GenericVersiportInputDevice.cs @@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Core.CrestronIO /// /// Represents a generic digital input deviced tied to a versiport /// - public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput + public class GenericVersiportDigitalInputDevice : EssentialsBridgeableDevice, IDigitalInput, IPartitionStateProvider { public Versiport InputPort { get; private set; } @@ -35,10 +35,15 @@ namespace PepperDash.Essentials.Core.CrestronIO } } + public BoolFeedback PartitionPresentFeedback { get; } + + public bool PartitionPresent => !InputStateFeedbackFunc(); + public GenericVersiportDigitalInputDevice(string key, string name, Func postActivationFunc, IOPortConfig config) : base(key, name) { InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc); + PartitionPresentFeedback = new BoolFeedback(() => !InputStateFeedbackFunc()); AddPostActivationAction(() => { @@ -52,7 +57,8 @@ namespace PepperDash.Essentials.Core.CrestronIO InputPort.VersiportChange += InputPort_VersiportChange; - + InputStateFeedback.FireUpdate(); + PartitionPresentFeedback.FireUpdate(); Debug.LogMessage(LogEventLevel.Debug, this, "Created GenericVersiportDigitalInputDevice on port '{0}'. DisablePullUpResistor: '{1}'", config.PortNumber, InputPort.DisablePullUpResistor); @@ -65,7 +71,10 @@ namespace PepperDash.Essentials.Core.CrestronIO Debug.LogMessage(LogEventLevel.Debug, this, "Versiport change: {0}", args.Event); if(args.Event == eVersiportEvent.DigitalInChange) + { InputStateFeedback.FireUpdate(); + PartitionPresentFeedback.FireUpdate(); + } }