[hal,wpilib] Rename REVPH compressor constants to all caps

This commit is contained in:
Peter Johnson
2026-03-14 12:11:25 -07:00
parent c18f811ea7
commit 68ca74c129
16 changed files with 72 additions and 72 deletions

View File

@@ -13,16 +13,16 @@
static_assert(
org_wpilib_hardware_hal_REVPHJNI_COMPRESSOR_CONFIG_TYPE_DISABLED ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDisabled);
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DISABLED);
static_assert(
org_wpilib_hardware_hal_REVPHJNI_COMPRESSOR_CONFIG_TYPE_DIGITAL ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDigital);
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL);
static_assert(
org_wpilib_hardware_hal_REVPHJNI_COMPRESSOR_CONFIG_TYPE_ANALOG ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kAnalog);
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_ANALOG);
static_assert(
org_wpilib_hardware_hal_REVPHJNI_COMPRESSOR_CONFIG_TYPE_HYBRID ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kHybrid);
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_HYBRID);
using namespace wpi::hal;

View File

@@ -19,13 +19,13 @@
*/
HAL_ENUM(HAL_REVPHCompressorConfigType) {
/** Disabled. */
HAL_REVPHCompressorConfigType_kDisabled = 0,
HAL_REVPH_COMPRESSOR_CONFIG_DISABLED = 0,
/** Digital. */
HAL_REVPHCompressorConfigType_kDigital = 1,
HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL = 1,
/** Analog. */
HAL_REVPHCompressorConfigType_kAnalog = 2,
HAL_REVPH_COMPRESSOR_CONFIG_ANALOG = 2,
/** Hybrid. */
HAL_REVPHCompressorConfigType_kHybrid = 3,
HAL_REVPH_COMPRESSOR_CONFIG_HYBRID = 3,
};
/**

View File

@@ -68,7 +68,7 @@ HAL_REVPHHandle HAL_InitializeREVPH(int32_t busId, int32_t module,
SimREVPHData[module].initialized = true;
// Enable closed loop
SimREVPHData[module].compressorConfigType =
HAL_REVPHCompressorConfigType_kDigital;
HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL;
return handle;
}
@@ -120,7 +120,7 @@ void HAL_SetREVPHClosedLoopControlDisabled(HAL_REVPHHandle handle,
return;
}
SimREVPHData[pcm->module].compressorConfigType =
HAL_REVPHCompressorConfigType_kDisabled;
HAL_REVPH_COMPRESSOR_CONFIG_DISABLED;
}
void HAL_SetREVPHClosedLoopControlDigital(HAL_REVPHHandle handle,
@@ -131,7 +131,7 @@ void HAL_SetREVPHClosedLoopControlDigital(HAL_REVPHHandle handle,
return;
}
SimREVPHData[pcm->module].compressorConfigType =
HAL_REVPHCompressorConfigType_kDigital;
HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL;
}
void HAL_SetREVPHClosedLoopControlAnalog(HAL_REVPHHandle handle,
@@ -144,7 +144,7 @@ void HAL_SetREVPHClosedLoopControlAnalog(HAL_REVPHHandle handle,
return;
}
SimREVPHData[pcm->module].compressorConfigType =
HAL_REVPHCompressorConfigType_kAnalog;
HAL_REVPH_COMPRESSOR_CONFIG_ANALOG;
}
void HAL_SetREVPHClosedLoopControlHybrid(HAL_REVPHHandle handle,
@@ -157,7 +157,7 @@ void HAL_SetREVPHClosedLoopControlHybrid(HAL_REVPHHandle handle,
return;
}
SimREVPHData[pcm->module].compressorConfigType =
HAL_REVPHCompressorConfigType_kHybrid;
HAL_REVPH_COMPRESSOR_CONFIG_HYBRID;
}
HAL_REVPHCompressorConfigType HAL_GetREVPHCompressorConfig(
@@ -165,7 +165,7 @@ HAL_REVPHCompressorConfigType HAL_GetREVPHCompressorConfig(
auto pcm = pcmHandles->Get(handle);
if (pcm == nullptr) {
*status = HAL_HANDLE_ERROR;
return HAL_REVPHCompressorConfigType_kDisabled;
return HAL_REVPH_COMPRESSOR_CONFIG_DISABLED;
}
return SimREVPHData[pcm->module].compressorConfigType;
}

View File

@@ -21,7 +21,7 @@ void REVPHData::ResetData() {
}
initialized.Reset(false);
compressorOn.Reset(false);
compressorConfigType.Reset(HAL_REVPHCompressorConfigType_kDisabled);
compressorConfigType.Reset(HAL_REVPH_COMPRESSOR_CONFIG_DISABLED);
pressureSwitch.Reset(false);
compressorCurrent.Reset(0.0);
}

View File

@@ -37,8 +37,8 @@ class REVPHData {
false};
SimDataValue<HAL_REVPHCompressorConfigType, MakeCompressorConfigTypeValue,
GetCompressorConfigTypeName>
compressorConfigType{HAL_REVPHCompressorConfigType::
HAL_REVPHCompressorConfigType_kDisabled};
compressorConfigType{
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DISABLED};
SimDataValue<HAL_Bool, HAL_MakeBoolean, GetPressureSwitchName> pressureSwitch{
false};
SimDataValue<double, HAL_MakeDouble, GetCompressorCurrentName>

View File

@@ -344,13 +344,13 @@ HAL_REVPHCompressorConfigType HAL_GetREVPHCompressorConfig(
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return HAL_REVPHCompressorConfigType_kDisabled;
return HAL_REVPH_COMPRESSOR_CONFIG_DISABLED;
}
PH_status_0_t status0 = HAL_ReadREVPHStatus0(ph->hcan, status);
if (*status != 0) {
return HAL_REVPHCompressorConfigType_kDisabled;
return HAL_REVPH_COMPRESSOR_CONFIG_DISABLED;
}
return static_cast<HAL_REVPHCompressorConfigType>(status0.compressor_config);

View File

@@ -16,7 +16,7 @@ HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(HAL_Bool, HALSIM, REVPHSolenoidOutput, false)
DEFINE_CAPI(HAL_Bool, Initialized, false)
DEFINE_CAPI(HAL_Bool, CompressorOn, false)
DEFINE_CAPI(HAL_REVPHCompressorConfigType, CompressorConfigType,
HAL_REVPHCompressorConfigType_kDisabled)
HAL_REVPH_COMPRESSOR_CONFIG_DISABLED)
DEFINE_CAPI(HAL_Bool, PressureSwitch, false)
DEFINE_CAPI(double, CompressorCurrent, 0)

View File

@@ -15,17 +15,17 @@
using namespace wpi;
static_assert(
static_cast<int>(CompressorConfigType::Disabled) ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDisabled);
static_cast<int>(CompressorConfigType::DISABLED) ==
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DISABLED);
static_assert(
static_cast<int>(CompressorConfigType::Digital) ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kDigital);
static_cast<int>(CompressorConfigType::DIGITAL) ==
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_DIGITAL);
static_assert(
static_cast<int>(CompressorConfigType::Analog) ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kAnalog);
static_cast<int>(CompressorConfigType::ANALOG) ==
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_ANALOG);
static_assert(
static_cast<int>(CompressorConfigType::Hybrid) ==
HAL_REVPHCompressorConfigType::HAL_REVPHCompressorConfigType_kHybrid);
static_cast<int>(CompressorConfigType::HYBRID) ==
HAL_REVPHCompressorConfigType::HAL_REVPH_COMPRESSOR_CONFIG_HYBRID);
std::shared_ptr<PneumaticsBase> PneumaticsBase::GetForType(
int busId, int module, PneumaticsModuleType moduleType) {

View File

@@ -128,8 +128,8 @@ CompressorConfigType PneumaticsControlModule::GetCompressorConfigType() const {
int32_t status = 0;
auto result = HAL_GetCTREPCMClosedLoopControl(m_handle, &status);
WPILIB_ReportError(status, "Module {}", m_module);
return result ? CompressorConfigType::Digital
: CompressorConfigType::Disabled;
return result ? CompressorConfigType::DIGITAL
: CompressorConfigType::DISABLED;
}
bool PneumaticsControlModule::GetPressureSwitch() const {

View File

@@ -10,13 +10,13 @@ namespace wpi {
*/
enum class CompressorConfigType {
/// Disabled.
Disabled = 0,
DISABLED = 0,
/// Digital.
Digital = 1,
DIGITAL = 1,
/// Analog.
Analog = 2,
ANALOG = 2,
/// Hybrid.
Hybrid = 3
HYBRID = 3
};
} // namespace wpi

View File

@@ -105,11 +105,11 @@ TEST(CTREPCMSimTest, SetEnableDigital) {
sim.RegisterClosedLoopEnabledCallback(callback.GetCallback(), false);
pcm.DisableCompressor();
EXPECT_EQ(pcm.GetCompressorConfigType(), CompressorConfigType::Disabled);
EXPECT_EQ(pcm.GetCompressorConfigType(), CompressorConfigType::DISABLED);
pcm.EnableCompressorDigital();
EXPECT_TRUE(sim.GetClosedLoopEnabled());
EXPECT_EQ(pcm.GetCompressorConfigType(), CompressorConfigType::Digital);
EXPECT_EQ(pcm.GetCompressorConfigType(), CompressorConfigType::DIGITAL);
EXPECT_TRUE(callback.WasTriggered());
EXPECT_TRUE(callback.GetLastValue());
}

View File

@@ -105,15 +105,15 @@ TEST(REVPHSimTest, SetEnableDigital) {
sim.RegisterCompressorConfigTypeCallback(callback.GetCallback(), false);
ph.DisableCompressor();
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Disabled);
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::DISABLED);
ph.EnableCompressorDigital();
EXPECT_EQ(sim.GetCompressorConfigType(),
static_cast<int>(CompressorConfigType::Digital));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Digital);
static_cast<int>(CompressorConfigType::DIGITAL));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::DIGITAL);
EXPECT_TRUE(callback.WasTriggered());
EXPECT_EQ(callback.GetLastValue(),
static_cast<int>(CompressorConfigType::Digital));
static_cast<int>(CompressorConfigType::DIGITAL));
}
TEST(REVPHSimTest, SetEnableAnalog) {
@@ -126,15 +126,15 @@ TEST(REVPHSimTest, SetEnableAnalog) {
sim.RegisterCompressorConfigTypeCallback(callback.GetCallback(), false);
ph.DisableCompressor();
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Disabled);
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::DISABLED);
ph.EnableCompressorAnalog(1_psi, 2_psi);
EXPECT_EQ(sim.GetCompressorConfigType(),
static_cast<int>(CompressorConfigType::Analog));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Analog);
static_cast<int>(CompressorConfigType::ANALOG));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::ANALOG);
EXPECT_TRUE(callback.WasTriggered());
EXPECT_EQ(callback.GetLastValue(),
static_cast<int>(CompressorConfigType::Analog));
static_cast<int>(CompressorConfigType::ANALOG));
}
TEST(REVPHSimTest, SetEnableHybrid) {
@@ -147,15 +147,15 @@ TEST(REVPHSimTest, SetEnableHybrid) {
sim.RegisterCompressorConfigTypeCallback(callback.GetCallback(), false);
ph.DisableCompressor();
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Disabled);
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::DISABLED);
ph.EnableCompressorHybrid(1_psi, 2_psi);
EXPECT_EQ(sim.GetCompressorConfigType(),
static_cast<int>(CompressorConfigType::Hybrid));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::Hybrid);
static_cast<int>(CompressorConfigType::HYBRID));
EXPECT_EQ(ph.GetCompressorConfigType(), CompressorConfigType::HYBRID);
EXPECT_TRUE(callback.WasTriggered());
EXPECT_EQ(callback.GetLastValue(),
static_cast<int>(CompressorConfigType::Hybrid));
static_cast<int>(CompressorConfigType::HYBRID));
}
TEST(REVPHSimTest, SetPressureSwitchEnabled) {

View File

@@ -9,13 +9,13 @@ import org.wpilib.hardware.hal.REVPHJNI;
/** Compressor config type. */
public enum CompressorConfigType {
/** Disabled. */
Disabled(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DISABLED),
DISABLED(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DISABLED),
/** Digital. */
Digital(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL),
DIGITAL(REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL),
/** Analog. */
Analog(REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG),
ANALOG(REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG),
/** Hybrid. */
Hybrid(REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID);
HYBRID(REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID);
/** CompressorConfigType value. */
public final int value;
@@ -32,10 +32,10 @@ public enum CompressorConfigType {
*/
public static CompressorConfigType fromValue(int value) {
return switch (value) {
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID -> Hybrid;
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG -> Analog;
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL -> Digital;
default -> Disabled;
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_HYBRID -> HYBRID;
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_ANALOG -> ANALOG;
case REVPHJNI.COMPRESSOR_CONFIG_TYPE_DIGITAL -> DIGITAL;
default -> DISABLED;
};
}

View File

@@ -338,8 +338,8 @@ public class PneumaticsControlModule implements PneumaticsBase {
@Override
public CompressorConfigType getCompressorConfigType() {
return CTREPCMJNI.getClosedLoopControl(m_handle)
? CompressorConfigType.Digital
: CompressorConfigType.Disabled;
? CompressorConfigType.DIGITAL
: CompressorConfigType.DISABLED;
}
/**

View File

@@ -118,11 +118,11 @@ class CTREPCMSimTest {
try (PneumaticsControlModule pcm = new PneumaticsControlModule(0);
CallbackStore cb = sim.registerClosedLoopEnabledCallback(callback, false)) {
pcm.disableCompressor();
assertEquals(pcm.getCompressorConfigType(), CompressorConfigType.Disabled);
assertEquals(pcm.getCompressorConfigType(), CompressorConfigType.DISABLED);
pcm.enableCompressorDigital();
assertTrue(sim.getClosedLoopEnabled());
assertEquals(pcm.getCompressorConfigType(), CompressorConfigType.Digital);
assertEquals(pcm.getCompressorConfigType(), CompressorConfigType.DIGITAL);
assertTrue(callback.wasTriggered());
assertTrue(callback.getSetValue());
}

View File

@@ -119,13 +119,13 @@ class REVPHSimTest {
try (PneumaticHub ph = new PneumaticHub(1);
CallbackStore cb = sim.registerCompressorConfigTypeCallback(callback, false)) {
ph.disableCompressor();
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Disabled);
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.DISABLED);
ph.enableCompressorDigital();
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.Digital.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Digital);
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.DIGITAL.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.DIGITAL);
assertTrue(callback.wasTriggered());
assertEquals(callback.getSetValue(), CompressorConfigType.Digital.getValue());
assertEquals(callback.getSetValue(), CompressorConfigType.DIGITAL.getValue());
}
}
@@ -139,13 +139,13 @@ class REVPHSimTest {
try (PneumaticHub ph = new PneumaticHub(1);
CallbackStore cb = sim.registerCompressorConfigTypeCallback(callback, false)) {
ph.disableCompressor();
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Disabled);
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.DISABLED);
ph.enableCompressorAnalog(1, 2);
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.Analog.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Analog);
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.ANALOG.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.ANALOG);
assertTrue(callback.wasTriggered());
assertEquals(callback.getSetValue(), CompressorConfigType.Analog.getValue());
assertEquals(callback.getSetValue(), CompressorConfigType.ANALOG.getValue());
}
}
@@ -159,13 +159,13 @@ class REVPHSimTest {
try (PneumaticHub ph = new PneumaticHub(1);
CallbackStore cb = sim.registerCompressorConfigTypeCallback(callback, false)) {
ph.disableCompressor();
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Disabled);
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.DISABLED);
ph.enableCompressorHybrid(1, 2);
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.Hybrid.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.Hybrid);
assertEquals(sim.getCompressorConfigType(), CompressorConfigType.HYBRID.getValue());
assertEquals(ph.getCompressorConfigType(), CompressorConfigType.HYBRID);
assertTrue(callback.wasTriggered());
assertEquals(callback.getSetValue(), CompressorConfigType.Hybrid.getValue());
assertEquals(callback.getSetValue(), CompressorConfigType.HYBRID.getValue());
}
}