From 975171609e1f800c2ca98dd7880ca5a88ae0e7ed Mon Sep 17 00:00:00 2001 From: Spud Date: Fri, 8 Apr 2022 21:31:08 -0700 Subject: [PATCH] [wpilib] Compressor: Rename enabled to isEnabled (#4147) This is a less confusing name, as enabled() can imply it enables the compressor. --- wpilibc/src/main/native/cpp/Compressor.cpp | 6 +++++- wpilibc/src/main/native/include/frc/Compressor.h | 15 ++++++++++++++- .../java/edu/wpi/first/wpilibj/Compressor.java | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Compressor.cpp b/wpilibc/src/main/native/cpp/Compressor.cpp index 3f7044759d..24460863d3 100644 --- a/wpilibc/src/main/native/cpp/Compressor.cpp +++ b/wpilibc/src/main/native/cpp/Compressor.cpp @@ -43,6 +43,10 @@ void Compressor::Stop() { } bool Compressor::Enabled() const { + return IsEnabled(); +} + +bool Compressor::IsEnabled() const { return m_module->GetCompressor(); } @@ -87,7 +91,7 @@ CompressorConfigType Compressor::GetConfigType() const { void Compressor::InitSendable(wpi::SendableBuilder& builder) { builder.SetSmartDashboardType("Compressor"); builder.AddBooleanProperty( - "Enabled", [=] { return Enabled(); }, nullptr); + "Enabled", [=] { return IsEnabled(); }, nullptr); builder.AddBooleanProperty( "Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr); } diff --git a/wpilibc/src/main/native/include/frc/Compressor.h b/wpilibc/src/main/native/include/frc/Compressor.h index d8125ede44..a686b1c797 100644 --- a/wpilibc/src/main/native/include/frc/Compressor.h +++ b/wpilibc/src/main/native/include/frc/Compressor.h @@ -78,11 +78,24 @@ class Compressor : public wpi::Sendable, /** * Check if compressor output is active. + * To (re)enable the compressor use EnableDigital() or EnableAnalog(...). * - * @return true if the compressor is on + * @return true if the compressor is on. + * @deprecated To avoid confusion in thinking this (re)enables the compressor + * use IsEnabled(). */ + WPI_DEPRECATED( + "To avoid confusion in thinking this (re)enables the compressor use " + "IsEnabled()") bool Enabled() const; + /** + * Returns whether the compressor is active or not. + * + * @return true if the compressor is on - otherwise false. + */ + bool IsEnabled() const; + /** * Check if the pressure switch is triggered. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java index a7d079b146..374e0fea0e 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/Compressor.java @@ -91,11 +91,23 @@ public class Compressor implements Sendable, AutoCloseable { } /** - * Get the status of the compressor. + * Get the status of the compressor. To (re)enable the compressor use enableDigital() or + * enableAnalog(...). * * @return true if the compressor is on + * @deprecated To avoid confusion in thinking this (re)enables the compressor use IsEnabled(). */ + @Deprecated(since = "2023", forRemoval = true) public boolean enabled() { + return isEnabled(); + } + + /** + * Returns whether the compressor is active or not. + * + * @return true if the compressor is on - otherwise false. + */ + public boolean isEnabled() { return m_module.getCompressor(); } @@ -184,7 +196,7 @@ public class Compressor implements Sendable, AutoCloseable { @Override public void initSendable(SendableBuilder builder) { builder.setSmartDashboardType("Compressor"); - builder.addBooleanProperty("Enabled", this::enabled, null); + builder.addBooleanProperty("Enabled", this::isEnabled, null); builder.addBooleanProperty("Pressure switch", this::getPressureSwitchValue, null); } }