mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal,wpilib] Rename PowerDistribution constants to all caps
This commit is contained in:
@@ -13,11 +13,11 @@
|
||||
using namespace wpi::hal;
|
||||
|
||||
static_assert(org_wpilib_hardware_hal_PowerDistributionJNI_AUTOMATIC_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic);
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_AUTOMATIC);
|
||||
static_assert(org_wpilib_hardware_hal_PowerDistributionJNI_CTRE_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE);
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE);
|
||||
static_assert(org_wpilib_hardware_hal_PowerDistributionJNI_REV_TYPE ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kRev);
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_REV);
|
||||
static_assert(org_wpilib_hardware_hal_PowerDistributionJNI_DEFAULT_MODULE ==
|
||||
HAL_DEFAULT_POWER_DISTRIBUTION_MODULE);
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
*/
|
||||
HAL_ENUM(HAL_PowerDistributionType) {
|
||||
/** Automatically determines the module type */
|
||||
HAL_PowerDistributionType_kAutomatic = 0,
|
||||
HAL_POWER_DISTRIBUTION_AUTOMATIC = 0,
|
||||
/** CTRE (Cross The Road Electronics) Power Distribution Panel (PDP). */
|
||||
HAL_PowerDistributionType_kCTRE = 1,
|
||||
HAL_POWER_DISTRIBUTION_CTRE = 1,
|
||||
/** REV Power Distribution Hub (PDH). */
|
||||
HAL_PowerDistributionType_kRev = 2,
|
||||
HAL_POWER_DISTRIBUTION_REV = 2,
|
||||
};
|
||||
|
||||
/** Use the default module number for the selected module type */
|
||||
|
||||
@@ -30,7 +30,7 @@ extern "C" {
|
||||
HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
int32_t busId, int32_t module, HAL_PowerDistributionType type,
|
||||
const char* allocationLocation, int32_t* status) {
|
||||
if (type == HAL_PowerDistributionType_kAutomatic) {
|
||||
if (type == HAL_POWER_DISTRIBUTION_AUTOMATIC) {
|
||||
if (module != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastError(
|
||||
@@ -39,13 +39,13 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
}
|
||||
|
||||
// TODO Make this not matter
|
||||
type = HAL_PowerDistributionType_kCTRE;
|
||||
type = HAL_POWER_DISTRIBUTION_CTRE;
|
||||
module = 0;
|
||||
}
|
||||
|
||||
if (!HAL_CheckPowerDistributionModule(module, type)) {
|
||||
*status = RESOURCE_OUT_OF_RANGE;
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
if (type == HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE) {
|
||||
wpi::hal::SetLastErrorIndexOutOfRange(status,
|
||||
"Invalid Index for CTRE PDP", 0,
|
||||
kNumCTREPDPModules - 1, module);
|
||||
@@ -79,7 +79,7 @@ int32_t HAL_GetPowerDistributionModuleNumber(HAL_PowerDistributionHandle handle,
|
||||
|
||||
HAL_Bool HAL_CheckPowerDistributionModule(int32_t module,
|
||||
HAL_PowerDistributionType type) {
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
if (type == HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE) {
|
||||
return module < kNumCTREPDPModules && module >= 0;
|
||||
} else {
|
||||
return module <= kNumREVPDHModules && module >= 1;
|
||||
@@ -98,7 +98,7 @@ HAL_Bool HAL_CheckPowerDistributionChannel(HAL_PowerDistributionHandle handle,
|
||||
|
||||
HAL_PowerDistributionType HAL_GetPowerDistributionType(
|
||||
HAL_PowerDistributionHandle handle, int32_t* status) {
|
||||
return HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE;
|
||||
return HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE;
|
||||
}
|
||||
|
||||
int32_t HAL_GetPowerDistributionNumChannels(HAL_PowerDistributionHandle handle,
|
||||
|
||||
@@ -22,7 +22,7 @@ extern "C" {
|
||||
HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
int32_t busId, int32_t moduleNumber, HAL_PowerDistributionType type,
|
||||
const char* allocationLocation, int32_t* status) {
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic) {
|
||||
if (type == HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_AUTOMATIC) {
|
||||
if (moduleNumber != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
wpi::hal::SetLastError(
|
||||
@@ -57,7 +57,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
|
||||
return static_cast<HAL_PowerDistributionHandle>(pdhHandle);
|
||||
}
|
||||
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
if (type == HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE) {
|
||||
if (moduleNumber == HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
|
||||
moduleNumber = 0;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ HAL_Bool HAL_CheckPowerDistributionChannel(HAL_PowerDistributionHandle handle,
|
||||
|
||||
HAL_Bool HAL_CheckPowerDistributionModule(int32_t module,
|
||||
HAL_PowerDistributionType type) {
|
||||
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
if (type == HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE) {
|
||||
return HAL_CheckPDPModule(module);
|
||||
} else {
|
||||
return HAL_CheckREVPDHModuleNumber(module);
|
||||
@@ -111,9 +111,8 @@ HAL_Bool HAL_CheckPowerDistributionModule(int32_t module,
|
||||
|
||||
HAL_PowerDistributionType HAL_GetPowerDistributionType(
|
||||
HAL_PowerDistributionHandle handle, int32_t* status) {
|
||||
return IsCtre(handle)
|
||||
? HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE
|
||||
: HAL_PowerDistributionType::HAL_PowerDistributionType_kRev;
|
||||
return IsCtre(handle) ? HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE
|
||||
: HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_REV;
|
||||
}
|
||||
|
||||
int32_t HAL_GetPowerDistributionNumChannels(HAL_PowerDistributionHandle handle,
|
||||
|
||||
@@ -32,8 +32,8 @@ TEST(PdpSimTest, PdpInitialization) {
|
||||
|
||||
// Use out of range index
|
||||
gTestPdpCallbackName = "Unset";
|
||||
HAL_InitializePowerDistribution(
|
||||
0, INDEX_TO_TEST, HAL_PowerDistributionType_kCTRE, nullptr, &status);
|
||||
HAL_InitializePowerDistribution(0, INDEX_TO_TEST, HAL_POWER_DISTRIBUTION_CTRE,
|
||||
nullptr, &status);
|
||||
EXPECT_EQ(0, status);
|
||||
EXPECT_STREQ("Initialized", gTestPdpCallbackName.c_str());
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "wpi/util/sendable/SendableRegistry.hpp"
|
||||
|
||||
static_assert(static_cast<HAL_PowerDistributionType>(
|
||||
wpi::PowerDistribution::ModuleType::kCTRE) ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE);
|
||||
wpi::PowerDistribution::ModuleType::CTRE) ==
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE);
|
||||
static_assert(static_cast<HAL_PowerDistributionType>(
|
||||
wpi::PowerDistribution::ModuleType::kRev) ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kRev);
|
||||
wpi::PowerDistribution::ModuleType::REV) ==
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_REV);
|
||||
static_assert(wpi::PowerDistribution::kDefaultModule ==
|
||||
HAL_DEFAULT_POWER_DISTRIBUTION_MODULE);
|
||||
|
||||
@@ -32,14 +32,14 @@ PowerDistribution::PowerDistribution(int busId) {
|
||||
int32_t status = 0;
|
||||
m_handle = HAL_InitializePowerDistribution(
|
||||
busId, kDefaultModule,
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic,
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_AUTOMATIC,
|
||||
stack.c_str(), &status);
|
||||
WPILIB_CheckErrorStatus(status, "Module {}", kDefaultModule);
|
||||
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
|
||||
WPILIB_ReportError(status, "Module {}", m_module);
|
||||
|
||||
if (HAL_GetPowerDistributionType(m_handle, &status) ==
|
||||
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
|
||||
HAL_PowerDistributionType::HAL_POWER_DISTRIBUTION_CTRE) {
|
||||
HAL_ReportUsage("PDP", m_module, "");
|
||||
} else {
|
||||
HAL_ReportUsage("PDH", m_module, "");
|
||||
@@ -59,7 +59,7 @@ PowerDistribution::PowerDistribution(int busId, int module,
|
||||
m_module = HAL_GetPowerDistributionModuleNumber(m_handle, &status);
|
||||
WPILIB_ReportError(status, "Module {}", module);
|
||||
|
||||
if (moduleType == ModuleType::kCTRE) {
|
||||
if (moduleType == ModuleType::CTRE) {
|
||||
HAL_ReportUsage("PDP_CTRE", m_module, "");
|
||||
} else {
|
||||
HAL_ReportUsage("PDH_REV", m_module, "");
|
||||
|
||||
@@ -28,9 +28,9 @@ class PowerDistribution : public wpi::util::Sendable,
|
||||
*/
|
||||
enum class ModuleType {
|
||||
/// CTRE (Cross The Road Electronics) CTRE Power Distribution Panel (PDP).
|
||||
kCTRE = 1,
|
||||
CTRE = 1,
|
||||
/// REV Power Distribution Hub (PDH).
|
||||
kRev = 2
|
||||
REV = 2
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ TEST(PowerDistributionSimTest, Initialize) {
|
||||
BooleanCallback callback;
|
||||
|
||||
auto cb = sim.RegisterInitializedCallback(callback.GetCallback(), false);
|
||||
PowerDistribution pdp(0, 2, wpi::PowerDistribution::ModuleType::kCTRE);
|
||||
PowerDistribution pdp(0, 2, wpi::PowerDistribution::ModuleType::CTRE);
|
||||
EXPECT_TRUE(sim.GetInitialized());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_TRUE(callback.GetLastValue());
|
||||
@@ -36,7 +36,7 @@ TEST(PowerDistributionSimTest, Initialize) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetTemperature) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::CTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
DoubleCallback callback;
|
||||
@@ -51,7 +51,7 @@ TEST(PowerDistributionSimTest, SetTemperature) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetVoltage) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::CTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
DoubleCallback callback;
|
||||
@@ -66,7 +66,7 @@ TEST(PowerDistributionSimTest, SetVoltage) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetCurrent) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::CTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
for (int channel = 0; channel < HAL_GetNumCTREPDPChannels(); ++channel) {
|
||||
@@ -85,7 +85,7 @@ TEST(PowerDistributionSimTest, SetCurrent) {
|
||||
|
||||
TEST(PowerDistributionSimTest, GetAllCurrents) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kRev};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::REV};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
// setup
|
||||
|
||||
@@ -27,9 +27,9 @@ public class PowerDistribution implements Sendable, AutoCloseable {
|
||||
/** Power distribution module type. */
|
||||
public enum ModuleType {
|
||||
/** CTRE (Cross The Road Electronics) Power Distribution Panel (PDP). */
|
||||
kCTRE(PowerDistributionJNI.CTRE_TYPE),
|
||||
CTRE(PowerDistributionJNI.CTRE_TYPE),
|
||||
/** REV Power Distribution Hub (PDH). */
|
||||
kRev(PowerDistributionJNI.REV_TYPE);
|
||||
REV(PowerDistributionJNI.REV_TYPE);
|
||||
|
||||
/** ModuleType value. */
|
||||
public final int value;
|
||||
@@ -51,7 +51,7 @@ public class PowerDistribution implements Sendable, AutoCloseable {
|
||||
m_handle = PowerDistributionJNI.initialize(busId, module, moduleType.value);
|
||||
m_module = PowerDistributionJNI.getModuleNumber(m_handle);
|
||||
|
||||
if (moduleType == ModuleType.kCTRE) {
|
||||
if (moduleType == ModuleType.CTRE) {
|
||||
HAL.reportUsage("PDP", m_module, "");
|
||||
} else {
|
||||
HAL.reportUsage("PDH", m_module, "");
|
||||
@@ -198,9 +198,9 @@ public class PowerDistribution implements Sendable, AutoCloseable {
|
||||
public ModuleType getType() {
|
||||
int type = PowerDistributionJNI.getType(m_handle);
|
||||
if (type == PowerDistributionJNI.REV_TYPE) {
|
||||
return ModuleType.kRev;
|
||||
return ModuleType.REV;
|
||||
} else {
|
||||
return ModuleType.kCTRE;
|
||||
return ModuleType.CTRE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class PowerDistributionTest {
|
||||
@Test
|
||||
void testGetAllCurrents() {
|
||||
HAL.initialize(500, 0);
|
||||
PowerDistribution pdp = new PowerDistribution(0, 1, ModuleType.kRev);
|
||||
PowerDistribution pdp = new PowerDistribution(0, 1, ModuleType.REV);
|
||||
PDPSim sim = new PDPSim(pdp);
|
||||
|
||||
for (int i = 0; i < pdp.getNumChannels(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user