From 898dab1d9a2499872d2960c27d4323afbae46475 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:21:45 -0500 Subject: [PATCH 1/3] feature: add several interfaces for battery status on devices refactor: mark existing PDU interfaces in PepperDash_Essentials_Core.Devices as obsolete refactor: replicate existing PDU interfaces in PepperDash.Essentials.Core --- .../Devices/PduInterfaces.cs | 5 +- .../Devices/PowerInterfaces.cs | 87 +++++++++++++++++++ .../PepperDash_Essentials_Core.csproj | 1 + 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs index 0f3b3fbf..94aa71ac 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -8,6 +9,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that is able to control it'spower and has a configurable reboot time /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback { /// @@ -24,6 +26,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that contains a collection of IHasPowerReboot Devices /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasControlledPowerOutlets : IKeyName { /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs new file mode 100644 index 00000000..bbb9460b --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -0,0 +1,87 @@ +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Interface for any device that has a battery that can be monitored + /// + public interface IHasBatteryStats : IKeyName + { + int BatteryPercentage { get; } + int BatteryCautionThresholdPercentage { get; } + int BatteryWarningThresholdPercentage { get; } + BoolFeedback BatteryIsWarningFeedback { get; } + BoolFeedback BatteryIsCautionFeedback { get; } + BoolFeedback BatteryIsOkFeedback { get; } + IntFeedback BatteryPercentageFeedback { get; } + } + + /// + /// Interface for any device that has a battery that can be monitored and the ability to charge and discharge + /// + public interface IHasBatteryCharging : IHasBatteryStats + { + BoolFeedback BatteryIsCharging { get; } + } + + /// + /// Interface for any device that has multiple batteries that can be monitored + /// + public interface IHasBatteries : IKeyName + { + ReadOnlyDictionary Batteries { get; } + } + + public interface IHasBatteryStatsExtended : IHasBatteryStats + { + int InputVoltage { get; } + int OutputVoltage { get; } + int InptuCurrent { get; } + int OutputCurrent { get; } + + IntFeedback InputVoltageFeedback { get; } + IntFeedback OutputVoltageFeedback { get; } + IntFeedback InputCurrentFeedback { get; } + IntFeedback OutputCurrentFeedback { get; } + } + + /// + /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored + /// + public interface IHasPowerCycleWithBatteries : IHasPowerCycle + { + + } + + /// + /// Interface for any device that is able to control it's power and has a configurable reboot time + /// + public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback + { + /// + /// Delay between power off and power on for reboot + /// + int PowerCycleTimeMs { get; } + + /// + /// Reboot outlet + /// + void PowerCycle(); + } + + /// + /// Interface for any device that contains a collection of IHasPowerReboot Devices + /// + public interface IHasControlledPowerOutlets : IKeyName + { + /// + /// Collection of IPduOutlets + /// + ReadOnlyDictionary PduOutlets { get; } + + } + + + +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index e0859077..7930f49e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -200,6 +200,7 @@ + From 7c7f0878983c45b7b4c226bd3e3951bd281b9a41 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:29:34 -0500 Subject: [PATCH 2/3] feature: added additional parameters to IHasPowerCycleWithBatteries --- .../PepperDashEssentialsBase/Devices/PowerInterfaces.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs index bbb9460b..06cb9ddb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -49,7 +49,7 @@ namespace PepperDash.Essentials.Core /// /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored /// - public interface IHasPowerCycleWithBatteries : IHasPowerCycle + public interface IHasPowerCycleWithBatteries : IHasPowerCycle, IHasBatteryStats { } From 7f916d1d2feebc30f14a176c882677ab2d939ffe Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:31:50 -0500 Subject: [PATCH 3/3] refactor: change IHasPowerCycleWithBatteries to IHasPowerCycleWithBattery for clarity --- .../PepperDashEssentialsBase/Devices/PowerInterfaces.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs index 06cb9ddb..1fc6672a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -49,7 +49,7 @@ namespace PepperDash.Essentials.Core /// /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored /// - public interface IHasPowerCycleWithBatteries : IHasPowerCycle, IHasBatteryStats + public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats { }