From 227f01f3bd6aec78cff386ff5a08218680c54815 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 13 Mar 2026 01:04:29 -0700 Subject: [PATCH] [hal,wpilib] Rename DriverStation constants to all caps --- .../command2/button/CommandGenericHID.java | 18 +-- .../frc2/command/button/CommandGenericHID.cpp | 18 +-- .../native/cpp/wpi/command/POVButtonTest.cpp | 6 +- .../command/button/RobotModeTriggersTest.cpp | 6 +- .../command3/button/CommandGenericHID.java | 18 +-- .../hardware/hal/AllianceStationID.java | 14 +- .../wpilib/hardware/hal/DriverStationJNI.java | 40 ++--- hal/src/main/native/cpp/DashboardOpMode.cpp | 12 +- .../main/native/cpp/jni/DriverStationJNI.cpp | 53 ++++--- .../jni/simulation/DriverStationDataJNI.cpp | 4 +- .../include/wpi/hal/DriverStationTypes.h | 69 ++++----- .../include/wpi/hal/DriverStationTypes.hpp | 8 +- hal/src/main/native/sim/DriverStation.cpp | 8 +- .../native/sim/mockdata/DriverStationData.cpp | 10 +- .../mockdata/DriverStationDataInternal.hpp | 2 +- .../native/systemcore/FIRSTDriverStation.cpp | 25 +-- .../systemcore/mockdata/DriverStationData.cpp | 4 +- .../python/semiwrap/DriverStationTypes_c.yml | 8 +- .../cpp/mockdata/DriverStationDataTest.cpp | 24 +-- robotpyExamples/DigitalCommunication/robot.py | 2 +- robotpyExamples/I2CCommunication/robot.py | 2 +- .../src/main/native/cpp/DSCommPacket.cpp | 26 ++-- .../wpi/halsim/ds_socket/DSCommPacket.hpp | 2 +- .../src/test/native/cpp/DSCommPacketTest.cpp | 10 +- .../src/main/native/cpp/DriverStationGui.cpp | 80 +++++----- .../native/cpp/WSProvider_DriverStation.cpp | 26 ++-- .../main/native/cpp/WSProvider_Joystick.cpp | 14 +- .../cpp/driverstation/DriverStation.cpp | 106 ++++++------- .../native/cpp/driverstation/GenericHID.cpp | 20 +-- .../main/native/cpp/system/DataLogManager.cpp | 8 +- .../wpi/driverstation/DriverStation.hpp | 58 +++---- .../main/python/semiwrap/DriverStation.yml | 2 +- .../src/test/native/cpp/TimedRobotTest.cpp | 12 +- .../cpp/simulation/DriverStationSimTest.cpp | 42 ++--- .../src/main/cpp/examples/HAL/c/Robot.c | 16 +- .../DigitalCommunication/cpp/Robot.cpp | 2 +- .../snippets/I2CCommunication/cpp/Robot.cpp | 2 +- .../ArmSimulation/cpp/ArmSimulationTest.cpp | 2 +- .../cpp/ElevatorSimulationTest.cpp | 2 +- .../cpp/DigitalCommunicationTest.cpp | 38 ++--- .../cpp/I2CCommunicationTest.cpp | 38 ++--- .../wpilib/driverstation/DriverStation.java | 144 +++++++++--------- .../org/wpilib/driverstation/GenericHID.java | 18 +-- .../wpilib/simulation/DriverStationSim.java | 38 ++--- .../org/wpilib/system/DataLogManager.java | 8 +- .../org/wpilib/hal/MatchInfoDataTest.java | 2 +- .../simulation/DriverStationSimTest.java | 28 ++-- .../snippets/digitalcommunication/Robot.java | 2 +- .../snippets/i2ccommunication/Robot.java | 2 +- .../DigitalCommunicationTest.java | 2 +- .../I2CCommunicationTest.java | 4 +- 51 files changed, 555 insertions(+), 550 deletions(-) diff --git a/commandsv2/src/main/java/org/wpilib/command2/button/CommandGenericHID.java b/commandsv2/src/main/java/org/wpilib/command2/button/CommandGenericHID.java index 70d2641c1d..6d64ca990a 100644 --- a/commandsv2/src/main/java/org/wpilib/command2/button/CommandGenericHID.java +++ b/commandsv2/src/main/java/org/wpilib/command2/button/CommandGenericHID.java @@ -106,7 +106,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the up direction of a POV on the HID. */ public Trigger povUp() { - return pov(POVDirection.Up); + return pov(POVDirection.UP); } /** @@ -117,7 +117,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the up right direction of a POV on the HID. */ public Trigger povUpRight() { - return pov(POVDirection.UpRight); + return pov(POVDirection.UP_RIGHT); } /** @@ -128,7 +128,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the right direction of a POV on the HID. */ public Trigger povRight() { - return pov(POVDirection.Right); + return pov(POVDirection.RIGHT); } /** @@ -139,7 +139,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the down right direction of a POV on the HID. */ public Trigger povDownRight() { - return pov(POVDirection.DownRight); + return pov(POVDirection.DOWN_RIGHT); } /** @@ -150,7 +150,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the down direction of a POV on the HID. */ public Trigger povDown() { - return pov(POVDirection.Down); + return pov(POVDirection.DOWN); } /** @@ -161,7 +161,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the down left POV direction of a POV on the HID. */ public Trigger povDownLeft() { - return pov(POVDirection.DownLeft); + return pov(POVDirection.DOWN_LEFT); } /** @@ -172,7 +172,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the left direction of a POV on the HID. */ public Trigger povLeft() { - return pov(POVDirection.Left); + return pov(POVDirection.LEFT); } /** @@ -183,7 +183,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the up left direction of a POV on the HID. */ public Trigger povUpLeft() { - return pov(POVDirection.UpLeft); + return pov(POVDirection.UP_LEFT); } /** @@ -194,7 +194,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the center position of a POV on the HID. */ public Trigger povCenter() { - return pov(POVDirection.Center); + return pov(POVDirection.CENTER); } /** diff --git a/commandsv2/src/main/native/cpp/frc2/command/button/CommandGenericHID.cpp b/commandsv2/src/main/native/cpp/frc2/command/button/CommandGenericHID.cpp index aecb68dfc9..e8808a9f5c 100644 --- a/commandsv2/src/main/native/cpp/frc2/command/button/CommandGenericHID.cpp +++ b/commandsv2/src/main/native/cpp/frc2/command/button/CommandGenericHID.cpp @@ -28,39 +28,39 @@ Trigger CommandGenericHID::POV(int pov, wpi::DriverStation::POVDirection angle, } Trigger CommandGenericHID::POVUp(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kUp, loop); + return POV(wpi::DriverStation::POVDirection::UP, loop); } Trigger CommandGenericHID::POVUpRight(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kUpRight, loop); + return POV(wpi::DriverStation::POVDirection::UP_RIGHT, loop); } Trigger CommandGenericHID::POVRight(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kRight, loop); + return POV(wpi::DriverStation::POVDirection::RIGHT, loop); } Trigger CommandGenericHID::POVDownRight(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kDownRight, loop); + return POV(wpi::DriverStation::POVDirection::DOWN_RIGHT, loop); } Trigger CommandGenericHID::POVDown(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kDown, loop); + return POV(wpi::DriverStation::POVDirection::DOWN, loop); } Trigger CommandGenericHID::POVDownLeft(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kDownLeft, loop); + return POV(wpi::DriverStation::POVDirection::DOWN_LEFT, loop); } Trigger CommandGenericHID::POVLeft(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kLeft, loop); + return POV(wpi::DriverStation::POVDirection::LEFT, loop); } Trigger CommandGenericHID::POVUpLeft(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kUpLeft, loop); + return POV(wpi::DriverStation::POVDirection::UP_LEFT, loop); } Trigger CommandGenericHID::POVCenter(wpi::EventLoop* loop) const { - return POV(wpi::DriverStation::POVDirection::kCenter, loop); + return POV(wpi::DriverStation::POVDirection::CENTER, loop); } Trigger CommandGenericHID::AxisLessThan(int axis, double threshold, diff --git a/commandsv2/src/test/native/cpp/wpi/command/POVButtonTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/POVButtonTest.cpp index 1a2a58ecd6..d21c01c01f 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/POVButtonTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/POVButtonTest.cpp @@ -19,7 +19,7 @@ class POVButtonTest : public CommandTestBase {}; TEST_F(POVButtonTest, SetPOV) { wpi::sim::JoystickSim joysim(1); - joysim.SetPOV(wpi::DriverStation::kUp); + joysim.SetPOV(wpi::DriverStation::POVDirection::UP); joysim.NotifyNewData(); auto& scheduler = CommandScheduler::GetInstance(); @@ -28,11 +28,11 @@ TEST_F(POVButtonTest, SetPOV) { WaitUntilCommand command([&finished] { return finished; }); wpi::Joystick joy(1); - POVButton(&joy, wpi::DriverStation::kRight).OnTrue(&command); + POVButton(&joy, wpi::DriverStation::POVDirection::RIGHT).OnTrue(&command); scheduler.Run(); EXPECT_FALSE(scheduler.IsScheduled(&command)); - joysim.SetPOV(wpi::DriverStation::kRight); + joysim.SetPOV(wpi::DriverStation::POVDirection::RIGHT); joysim.NotifyNewData(); scheduler.Run(); diff --git a/commandsv2/src/test/native/cpp/wpi/command/button/RobotModeTriggersTest.cpp b/commandsv2/src/test/native/cpp/wpi/command/button/RobotModeTriggersTest.cpp index 3035e83257..dacf5cd74e 100644 --- a/commandsv2/src/test/native/cpp/wpi/command/button/RobotModeTriggersTest.cpp +++ b/commandsv2/src/test/native/cpp/wpi/command/button/RobotModeTriggersTest.cpp @@ -16,7 +16,7 @@ class RobotModeTriggersTest : public CommandTestBase {}; TEST(RobotModeTriggersTest, Autonomous) { DriverStationSim::ResetData(); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_AUTONOMOUS); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); Trigger autonomous = RobotModeTriggers::Autonomous(); @@ -25,7 +25,7 @@ TEST(RobotModeTriggersTest, Autonomous) { TEST(RobotModeTriggersTest, Teleop) { DriverStationSim::ResetData(); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); Trigger teleop = RobotModeTriggers::Teleop(); @@ -42,7 +42,7 @@ TEST(RobotModeTriggersTest, Disabled) { TEST(RobotModeTriggersTest, TestMode) { DriverStationSim::ResetData(); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TEST); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TEST); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); Trigger test = RobotModeTriggers::Test(); diff --git a/commandsv3/src/main/java/org/wpilib/command3/button/CommandGenericHID.java b/commandsv3/src/main/java/org/wpilib/command3/button/CommandGenericHID.java index 432cfc42dc..bc6596d3c7 100644 --- a/commandsv3/src/main/java/org/wpilib/command3/button/CommandGenericHID.java +++ b/commandsv3/src/main/java/org/wpilib/command3/button/CommandGenericHID.java @@ -120,7 +120,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 0 degree angle of a POV on the HID. */ public Trigger povUp() { - return pov(POVDirection.Up); + return pov(POVDirection.UP); } /** @@ -131,7 +131,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 45 degree angle of a POV on the HID. */ public Trigger povUpRight() { - return pov(POVDirection.UpRight); + return pov(POVDirection.UP_RIGHT); } /** @@ -142,7 +142,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 90 degree angle of a POV on the HID. */ public Trigger povRight() { - return pov(POVDirection.Right); + return pov(POVDirection.RIGHT); } /** @@ -153,7 +153,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 135 degree angle of a POV on the HID. */ public Trigger povDownRight() { - return pov(POVDirection.DownRight); + return pov(POVDirection.DOWN_RIGHT); } /** @@ -164,7 +164,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 180 degree angle of a POV on the HID. */ public Trigger povDown() { - return pov(POVDirection.Down); + return pov(POVDirection.DOWN); } /** @@ -175,7 +175,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 225 degree angle of a POV on the HID. */ public Trigger povDownLeft() { - return pov(POVDirection.DownLeft); + return pov(POVDirection.DOWN_LEFT); } /** @@ -186,7 +186,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 270 degree angle of a POV on the HID. */ public Trigger povLeft() { - return pov(POVDirection.Left); + return pov(POVDirection.LEFT); } /** @@ -197,7 +197,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the 315 degree angle of a POV on the HID. */ public Trigger povUpLeft() { - return pov(POVDirection.UpLeft); + return pov(POVDirection.UP_LEFT); } /** @@ -208,7 +208,7 @@ public class CommandGenericHID { * @return a Trigger instance based around the center position of a POV on the HID. */ public Trigger povCenter() { - return pov(POVDirection.Center); + return pov(POVDirection.CENTER); } /** diff --git a/hal/src/main/java/org/wpilib/hardware/hal/AllianceStationID.java b/hal/src/main/java/org/wpilib/hardware/hal/AllianceStationID.java index 9854f3e067..0190366569 100644 --- a/hal/src/main/java/org/wpilib/hardware/hal/AllianceStationID.java +++ b/hal/src/main/java/org/wpilib/hardware/hal/AllianceStationID.java @@ -7,17 +7,17 @@ package org.wpilib.hardware.hal; /** Alliance station ID. */ public enum AllianceStationID { /** Unknown. */ - Unknown, + UNKNOWN, /** Red 1. */ - Red1, + RED_1, /** Red 2. */ - Red2, + RED_2, /** Red 3. */ - Red3, + RED_3, /** Blue 1. */ - Blue1, + BLUE_1, /** Blue 2. */ - Blue2, + BLUE_2, /** Blue 3. */ - Blue3 + BLUE_3 } diff --git a/hal/src/main/java/org/wpilib/hardware/hal/DriverStationJNI.java b/hal/src/main/java/org/wpilib/hardware/hal/DriverStationJNI.java index 7d76707488..c90f407d6e 100644 --- a/hal/src/main/java/org/wpilib/hardware/hal/DriverStationJNI.java +++ b/hal/src/main/java/org/wpilib/hardware/hal/DriverStationJNI.java @@ -93,25 +93,25 @@ public class DriverStationJNI extends JNIWrapper { private static native int nativeGetAllianceStation(); /** Unknown Alliance Station ID. */ - public static final int kUnknownAllianceStation = 0; + public static final int ALLIANCE_STATION_UNKNOWN = 0; /** Red Alliance Station 1 ID. */ - public static final int kRed1AllianceStation = 1; + public static final int ALLIANCE_STATION_RED_1 = 1; /** Red Alliance Station 2 ID. */ - public static final int kRed2AllianceStation = 2; + public static final int ALLIANCE_STATION_RED_2 = 2; /** Red Alliance Station 3 ID. */ - public static final int kRed3AllianceStation = 3; + public static final int ALLIANCE_STATION_RED_3 = 3; /** Blue Alliance Station 1 ID. */ - public static final int kBlue1AllianceStation = 4; + public static final int ALLIANCE_STATION_BLUE_1 = 4; /** Blue Alliance Station 2 ID. */ - public static final int kBlue2AllianceStation = 5; + public static final int ALLIANCE_STATION_BLUE_2 = 5; /** Blue Alliance Station 3 ID. */ - public static final int kBlue3AllianceStation = 6; + public static final int ALLIANCE_STATION_BLUE_3 = 6; /** * Gets the current alliance station ID. @@ -121,33 +121,33 @@ public class DriverStationJNI extends JNIWrapper { */ public static AllianceStationID getAllianceStation() { return switch (nativeGetAllianceStation()) { - case kUnknownAllianceStation -> AllianceStationID.Unknown; - case kRed1AllianceStation -> AllianceStationID.Red1; - case kRed2AllianceStation -> AllianceStationID.Red2; - case kRed3AllianceStation -> AllianceStationID.Red3; - case kBlue1AllianceStation -> AllianceStationID.Blue1; - case kBlue2AllianceStation -> AllianceStationID.Blue2; - case kBlue3AllianceStation -> AllianceStationID.Blue3; + case ALLIANCE_STATION_UNKNOWN -> AllianceStationID.UNKNOWN; + case ALLIANCE_STATION_RED_1 -> AllianceStationID.RED_1; + case ALLIANCE_STATION_RED_2 -> AllianceStationID.RED_2; + case ALLIANCE_STATION_RED_3 -> AllianceStationID.RED_3; + case ALLIANCE_STATION_BLUE_1 -> AllianceStationID.BLUE_1; + case ALLIANCE_STATION_BLUE_2 -> AllianceStationID.BLUE_2; + case ALLIANCE_STATION_BLUE_3 -> AllianceStationID.BLUE_3; default -> null; }; } /** The maximum number of axes. */ - public static final int kMaxJoystickAxes = 12; + public static final int MAX_JOYSTICK_AXES = 12; - public static final int kMaxJoystickButtons = 64; + public static final int MAX_JOYSTICK_BUTTONS = 64; /** The maximum number of POVs. */ - public static final int kMaxJoystickPOVs = 8; + public static final int MAX_JOYSTICK_POVS = 8; /** The maximum number of joysticks. */ - public static final int kMaxJoysticks = 6; + public static final int MAX_JOYSTICKS = 6; /** The maximum number of touchpads. */ - public static final int kMaxJoystickTouchpads = 2; + public static final int MAX_JOYSTICK_TOUCHPADS = 2; /** The maximum number of fingers per touchpad. */ - public static final int kMaxJoystickTouchpadFingers = 2; + public static final int MAX_JOYSTICK_TOUCHPAD_FINGERS = 2; /** * Get all joystick data. diff --git a/hal/src/main/native/cpp/DashboardOpMode.cpp b/hal/src/main/native/cpp/DashboardOpMode.cpp index e17cf579da..556aa7f2fd 100644 --- a/hal/src/main/native/cpp/DashboardOpMode.cpp +++ b/hal/src/main/native/cpp/DashboardOpMode.cpp @@ -120,9 +120,9 @@ void hal::InitializeDashboardOpMode() { void hal::SetDashboardOpModeOptions(std::span options) { std::scoped_lock lock{gInstance->mutex}; - gInstance->autoOpModes.SetOptions(options, HAL_ROBOTMODE_AUTONOMOUS); - gInstance->teleopOpModes.SetOptions(options, HAL_ROBOTMODE_TELEOPERATED); - gInstance->testOpModes.SetOptions(options, HAL_ROBOTMODE_TEST); + gInstance->autoOpModes.SetOptions(options, HAL_ROBOT_MODE_AUTONOMOUS); + gInstance->teleopOpModes.SetOptions(options, HAL_ROBOT_MODE_TELEOPERATED); + gInstance->testOpModes.SetOptions(options, HAL_ROBOT_MODE_TEST); } void hal::StartDashboardOpMode() { @@ -150,11 +150,11 @@ int64_t hal::GetDashboardSelectedOpMode(HAL_RobotMode robotMode) { } std::scoped_lock lock{gInstance->mutex}; switch (robotMode) { - case HAL_ROBOTMODE_AUTONOMOUS: + case HAL_ROBOT_MODE_AUTONOMOUS: return gInstance->autoOpModes.GetSelected(); - case HAL_ROBOTMODE_TELEOPERATED: + case HAL_ROBOT_MODE_TELEOPERATED: return gInstance->teleopOpModes.GetSelected(); - case HAL_ROBOTMODE_TEST: + case HAL_ROBOT_MODE_TEST: return gInstance->testOpModes.GetSelected(); default: return 0; diff --git a/hal/src/main/native/cpp/jni/DriverStationJNI.cpp b/hal/src/main/native/cpp/jni/DriverStationJNI.cpp index 4e97fad8f0..c48190d3eb 100644 --- a/hal/src/main/native/cpp/jni/DriverStationJNI.cpp +++ b/hal/src/main/native/cpp/jni/DriverStationJNI.cpp @@ -17,32 +17,35 @@ #include "wpi/util/jni_util.hpp" static_assert( - org_wpilib_hardware_hal_DriverStationJNI_kUnknownAllianceStation == - HAL_AllianceStationID_kUnknown); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kRed1AllianceStation == - HAL_AllianceStationID_kRed1); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kRed2AllianceStation == - HAL_AllianceStationID_kRed2); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kRed3AllianceStation == - HAL_AllianceStationID_kRed3); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kBlue1AllianceStation == - HAL_AllianceStationID_kBlue1); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kBlue2AllianceStation == - HAL_AllianceStationID_kBlue2); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kBlue3AllianceStation == - HAL_AllianceStationID_kBlue3); - -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoystickAxes == - HAL_kMaxJoystickAxes); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoystickPOVs == - HAL_kMaxJoystickPOVs); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoysticks == - HAL_kMaxJoysticks); -static_assert(org_wpilib_hardware_hal_DriverStationJNI_kMaxJoystickTouchpads == - HAL_kMaxJoystickTouchpads); + org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_UNKNOWN == + HAL_ALLIANCE_STATION_UNKNOWN); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_RED_1 == + HAL_ALLIANCE_STATION_RED_1); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_RED_2 == + HAL_ALLIANCE_STATION_RED_2); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_RED_3 == + HAL_ALLIANCE_STATION_RED_3); static_assert( - org_wpilib_hardware_hal_DriverStationJNI_kMaxJoystickTouchpadFingers == - HAL_kMaxJoystickTouchpadFingers); + org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_BLUE_1 == + HAL_ALLIANCE_STATION_BLUE_1); +static_assert( + org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_BLUE_2 == + HAL_ALLIANCE_STATION_BLUE_2); +static_assert( + org_wpilib_hardware_hal_DriverStationJNI_ALLIANCE_STATION_BLUE_3 == + HAL_ALLIANCE_STATION_BLUE_3); + +static_assert(org_wpilib_hardware_hal_DriverStationJNI_MAX_JOYSTICK_AXES == + HAL_MAX_JOYSTICK_AXES); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_MAX_JOYSTICK_POVS == + HAL_MAX_JOYSTICK_POVS); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_MAX_JOYSTICKS == + HAL_MAX_JOYSTICKS); +static_assert(org_wpilib_hardware_hal_DriverStationJNI_MAX_JOYSTICK_TOUCHPADS == + HAL_MAX_JOYSTICK_TOUCHPADS); +static_assert( + org_wpilib_hardware_hal_DriverStationJNI_MAX_JOYSTICK_TOUCHPAD_FINGERS == + HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS); using namespace wpi::hal; using namespace wpi::util::java; diff --git a/hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp b/hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp index 1709ee5e8c..73877062ab 100644 --- a/hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp +++ b/hal/src/main/native/cpp/jni/simulation/DriverStationDataJNI.cpp @@ -485,7 +485,7 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setJoystickAxes auto arrayRef = jArrayRef.array(); auto arraySize = arrayRef.size(); int maxCount = - arraySize < HAL_kMaxJoystickAxes ? arraySize : HAL_kMaxJoystickAxes; + arraySize < HAL_MAX_JOYSTICK_AXES ? arraySize : HAL_MAX_JOYSTICK_AXES; axes.available = availableAxes; for (int i = 0; i < maxCount; i++) { axes.axes[i] = arrayRef[i]; @@ -511,7 +511,7 @@ Java_org_wpilib_hardware_hal_simulation_DriverStationDataJNI_setJoystickPOVs auto arrayRef = jArrayRef.array(); auto arraySize = arrayRef.size(); int maxCount = - arraySize < HAL_kMaxJoystickPOVs ? arraySize : HAL_kMaxJoystickPOVs; + arraySize < HAL_MAX_JOYSTICK_POVS ? arraySize : HAL_MAX_JOYSTICK_POVS; povs.available = availablePovs; for (int i = 0; i < maxCount; i++) { povs.povs[i] = static_cast(arrayRef[i]); diff --git a/hal/src/main/native/include/wpi/hal/DriverStationTypes.h b/hal/src/main/native/include/wpi/hal/DriverStationTypes.h index 5d0108690b..b403cf95e1 100644 --- a/hal/src/main/native/include/wpi/hal/DriverStationTypes.h +++ b/hal/src/main/native/include/wpi/hal/DriverStationTypes.h @@ -30,33 +30,33 @@ typedef struct HAL_ControlWord HAL_ControlWord; HAL_ENUM(HAL_AllianceStationID) { /** Unknown Alliance Station */ - HAL_AllianceStationID_kUnknown = 0, + HAL_ALLIANCE_STATION_UNKNOWN = 0, /** Red Alliance Station 1 */ - HAL_AllianceStationID_kRed1, + HAL_ALLIANCE_STATION_RED_1, /** Red Alliance Station 2 */ - HAL_AllianceStationID_kRed2, + HAL_ALLIANCE_STATION_RED_2, /** Red Alliance Station 3 */ - HAL_AllianceStationID_kRed3, + HAL_ALLIANCE_STATION_RED_3, /** Blue Alliance Station 1 */ - HAL_AllianceStationID_kBlue1, + HAL_ALLIANCE_STATION_BLUE_1, /** Blue Alliance Station 2 */ - HAL_AllianceStationID_kBlue2, + HAL_ALLIANCE_STATION_BLUE_2, /** Blue Alliance Station 3 */ - HAL_AllianceStationID_kBlue3, + HAL_ALLIANCE_STATION_BLUE_3, }; HAL_ENUM(HAL_MatchType) { - HAL_kMatchType_none = 0, - HAL_kMatchType_practice, - HAL_kMatchType_qualification, - HAL_kMatchType_elimination, + HAL_MATCH_TYPE_NONE = 0, + HAL_MATCH_TYPE_PRACTICE, + HAL_MATCH_TYPE_QUALIFICATION, + HAL_MATCH_TYPE_ELIMINATION, }; HAL_ENUM(HAL_RobotMode) { - HAL_ROBOTMODE_UNKNOWN = 0, - HAL_ROBOTMODE_AUTONOMOUS, - HAL_ROBOTMODE_TELEOPERATED, - HAL_ROBOTMODE_TEST, + HAL_ROBOT_MODE_UNKNOWN = 0, + HAL_ROBOT_MODE_AUTONOMOUS, + HAL_ROBOT_MODE_TELEOPERATED, + HAL_ROBOT_MODE_TEST, }; /** @@ -64,63 +64,64 @@ HAL_ENUM(HAL_RobotMode) { * HAL_JoystickTouchpads struct. This is used for allocating buffers, not * bounds checking, since there are usually less touchpads in practice. */ -#define HAL_kMaxJoystickTouchpads 2 +#define HAL_MAX_JOYSTICK_TOUCHPADS 2 /** * The maximum number of fingers that will be stored in a single * HAL_JoystickTouchpad struct. This is used for allocating buffers, not * bounds checking, since there are usually less fingers in practice. */ -#define HAL_kMaxJoystickTouchpadFingers 2 +#define HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS 2 /** * The maximum number of axes that will be stored in a single HAL_JoystickAxes * struct. This is used for allocating buffers, not bounds checking, since there * are usually less axes in practice. */ -#define HAL_kMaxJoystickAxes 12 +#define HAL_MAX_JOYSTICK_AXES 12 /** * The maximum number of POVs that will be stored in a single HAL_JoystickPOVs * struct. This is used for allocating buffers, not bounds checking, since there * are usually less POVs in practice. */ -#define HAL_kMaxJoystickPOVs 8 +#define HAL_MAX_JOYSTICK_POVS 8 /** * The maximum number of joysticks. */ -#define HAL_kMaxJoysticks 6 +#define HAL_MAX_JOYSTICKS 6 struct HAL_JoystickAxes { uint16_t available; - float axes[HAL_kMaxJoystickAxes]; - int16_t raw[HAL_kMaxJoystickAxes]; + float axes[HAL_MAX_JOYSTICK_AXES]; + int16_t raw[HAL_MAX_JOYSTICK_AXES]; }; typedef struct HAL_JoystickAxes HAL_JoystickAxes; HAL_ENUM_WITH_UNDERLYING_TYPE(HAL_JoystickPOV, uint8_t){ /** Centered */ - HAL_JoystickPOV_kCentered = 0x00u, + HAL_JOYSTICK_POV_CENTERED = 0x00u, /** Up */ - HAL_JoystickPOV_kUp = 0x01u, + HAL_JOYSTICK_POV_UP = 0x01u, /** Right */ - HAL_JoystickPOV_kRight = 0x02u, + HAL_JOYSTICK_POV_RIGHT = 0x02u, /** Down */ - HAL_JoystickPOV_kDown = 0x04u, + HAL_JOYSTICK_POV_DOWN = 0x04u, /** Left */ - HAL_JoystickPOV_kLeft = 0x08u, + HAL_JOYSTICK_POV_LEFT = 0x08u, /** Right-Up */ - HAL_JoystickPOV_kRightUp = HAL_JoystickPOV_kRight | HAL_JoystickPOV_kUp, + HAL_JOYSTICK_POV_RIGHT_UP = HAL_JOYSTICK_POV_RIGHT | HAL_JOYSTICK_POV_UP, /** Right-Down */ - HAL_JoystickPOV_kRightDown = HAL_JoystickPOV_kRight | HAL_JoystickPOV_kDown, + HAL_JOYSTICK_POV_RIGHT_DOWN = HAL_JOYSTICK_POV_RIGHT | + HAL_JOYSTICK_POV_DOWN, /** Left-Up */ - HAL_JoystickPOV_kLeftUp = HAL_JoystickPOV_kLeft | HAL_JoystickPOV_kUp, + HAL_JOYSTICK_POV_LEFT_UP = HAL_JOYSTICK_POV_LEFT | HAL_JOYSTICK_POV_UP, /** Left-Down */ - HAL_JoystickPOV_kLeftDown = HAL_JoystickPOV_kLeft | HAL_JoystickPOV_kDown, + HAL_JOYSTICK_POV_LEFT_DOWN = HAL_JOYSTICK_POV_LEFT | HAL_JOYSTICK_POV_DOWN, }; struct HAL_JoystickPOVs { uint8_t available; - HAL_JoystickPOV povs[HAL_kMaxJoystickPOVs]; + HAL_JoystickPOV povs[HAL_MAX_JOYSTICK_POVS]; }; typedef struct HAL_JoystickPOVs HAL_JoystickPOVs; @@ -139,13 +140,13 @@ typedef struct HAL_JoystickTouchpadFinger HAL_JoystickTouchpadFinger; struct HAL_JoystickTouchpad { uint8_t count; - HAL_JoystickTouchpadFinger fingers[HAL_kMaxJoystickTouchpadFingers]; + HAL_JoystickTouchpadFinger fingers[HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS]; }; typedef struct HAL_JoystickTouchpad HAL_JoystickTouchpad; struct HAL_JoystickTouchpads { uint8_t count; - HAL_JoystickTouchpad touchpads[HAL_kMaxJoystickTouchpads]; + HAL_JoystickTouchpad touchpads[HAL_MAX_JOYSTICK_TOUCHPADS]; }; typedef struct HAL_JoystickTouchpads HAL_JoystickTouchpads; diff --git a/hal/src/main/native/include/wpi/hal/DriverStationTypes.hpp b/hal/src/main/native/include/wpi/hal/DriverStationTypes.hpp index e015791a26..49a5f43e47 100644 --- a/hal/src/main/native/include/wpi/hal/DriverStationTypes.hpp +++ b/hal/src/main/native/include/wpi/hal/DriverStationTypes.hpp @@ -14,13 +14,13 @@ namespace wpi::hal { */ enum class RobotMode { /// Unknown. - UNKNOWN = HAL_ROBOTMODE_UNKNOWN, + UNKNOWN = HAL_ROBOT_MODE_UNKNOWN, /// Autonomous. - AUTONOMOUS = HAL_ROBOTMODE_AUTONOMOUS, + AUTONOMOUS = HAL_ROBOT_MODE_AUTONOMOUS, /// Teleoperated. - TELEOPERATED = HAL_ROBOTMODE_TELEOPERATED, + TELEOPERATED = HAL_ROBOT_MODE_TELEOPERATED, /// Test. - TEST = HAL_ROBOTMODE_TEST + TEST = HAL_ROBOT_MODE_TEST }; /** diff --git a/hal/src/main/native/sim/DriverStation.cpp b/hal/src/main/native/sim/DriverStation.cpp index 84e32f171c..805d1d2329 100644 --- a/hal/src/main/native/sim/DriverStation.cpp +++ b/hal/src/main/native/sim/DriverStation.cpp @@ -80,7 +80,7 @@ void JoystickDataCache::Update() { } #define CHECK_JOYSTICK_NUMBER(stickNum) \ - if ((stickNum) < 0 || (stickNum) >= HAL_kMaxJoysticks) \ + if ((stickNum) < 0 || (stickNum) >= HAL_MAX_JOYSTICKS) \ return PARAMETER_OUT_OF_RANGE static HAL_ControlWord newestControlWord; @@ -98,7 +98,7 @@ struct TcpCache { void CloneTo(TcpCache* other) { std::memcpy(other, this, sizeof(*this)); } HAL_MatchInfo matchInfo; - HAL_JoystickDescriptor descriptors[HAL_kMaxJoysticks]; + HAL_JoystickDescriptor descriptors[HAL_MAX_JOYSTICKS]; }; static_assert(std::is_standard_layout_v); } // namespace @@ -109,7 +109,7 @@ static TcpCache tcpCurrent; void TcpCache::Update() { SimDriverStationData->GetMatchInfo(&matchInfo); - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { SimDriverStationData->GetJoystickDescriptor(i, &descriptors[i]); } } @@ -259,7 +259,7 @@ int32_t HAL_SetOpModeOptions(const struct HAL_OpModeOption* options, HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status) { if (gShutdown) { - return HAL_AllianceStationID_kUnknown; + return HAL_ALLIANCE_STATION_UNKNOWN; } std::scoped_lock lock{driverStation->cacheMutex}; return currentRead->allianceStation; diff --git a/hal/src/main/native/sim/mockdata/DriverStationData.cpp b/hal/src/main/native/sim/mockdata/DriverStationData.cpp index a0c3162075..aa44866234 100644 --- a/hal/src/main/native/sim/mockdata/DriverStationData.cpp +++ b/hal/src/main/native/sim/mockdata/DriverStationData.cpp @@ -46,7 +46,7 @@ DriverStationData::~DriverStationData() { void DriverStationData::ResetData() { enabled.Reset(false); - robotMode.Reset(HAL_ROBOTMODE_UNKNOWN); + robotMode.Reset(HAL_ROBOT_MODE_UNKNOWN); eStop.Reset(false); fmsAttached.Reset(false); dsAttached.Reset(false); @@ -413,7 +413,7 @@ void DriverStationData::SetJoystickAxis(int32_t stick, int32_t axis, if (stick < 0 || stick >= kNumJoysticks) { return; } - if (axis < 0 || axis >= HAL_kMaxJoystickAxes) { + if (axis < 0 || axis >= HAL_MAX_JOYSTICK_AXES) { return; } std::scoped_lock lock(m_joystickDataMutex); @@ -426,7 +426,7 @@ void DriverStationData::SetJoystickPOV(int32_t stick, int32_t pov, if (stick < 0 || stick >= kNumJoysticks) { return; } - if (pov < 0 || pov >= HAL_kMaxJoystickPOVs) { + if (pov < 0 || pov >= HAL_MAX_JOYSTICK_POVS) { return; } std::scoped_lock lock(m_joystickDataMutex); @@ -510,10 +510,10 @@ void DriverStationData::SetJoystickTouchpadFinger(int32_t stick, if (stick < 0 || stick >= kNumJoysticks) { return; } - if (touchpad < 0 || touchpad >= HAL_kMaxJoystickTouchpads) { + if (touchpad < 0 || touchpad >= HAL_MAX_JOYSTICK_TOUCHPADS) { return; } - if (finger < 0 || finger >= HAL_kMaxJoystickTouchpadFingers) { + if (finger < 0 || finger >= HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS) { return; } std::scoped_lock lock(m_joystickDataMutex); diff --git a/hal/src/main/native/sim/mockdata/DriverStationDataInternal.hpp b/hal/src/main/native/sim/mockdata/DriverStationDataInternal.hpp index 1fd620a8fd..828fee96fb 100644 --- a/hal/src/main/native/sim/mockdata/DriverStationDataInternal.hpp +++ b/hal/src/main/native/sim/mockdata/DriverStationDataInternal.hpp @@ -168,7 +168,7 @@ class DriverStationData { SimDataValue enabled{false}; SimDataValue robotMode{ - HAL_ROBOTMODE_UNKNOWN}; + HAL_ROBOT_MODE_UNKNOWN}; SimDataValue eStop{false}; SimDataValue fmsAttached{ false}; diff --git a/hal/src/main/native/systemcore/FIRSTDriverStation.cpp b/hal/src/main/native/systemcore/FIRSTDriverStation.cpp index 8c7bcb231c..6e36a6be62 100644 --- a/hal/src/main/native/systemcore/FIRSTDriverStation.cpp +++ b/hal/src/main/native/systemcore/FIRSTDriverStation.cpp @@ -45,21 +45,22 @@ static_assert(sizeof(int32_t) >= sizeof(int), "WPILIB_NetworkComm status variable is larger than 32 bits"); -static_assert(MRC_MAX_NUM_AXES == HAL_kMaxJoystickAxes); -static_assert(MRC_MAX_NUM_POVS == HAL_kMaxJoystickPOVs); -static_assert(MRC_MAX_NUM_JOYSTICKS == HAL_kMaxJoysticks); -static_assert(MRC_MAX_NUM_TOUCHPADS == HAL_kMaxJoystickTouchpads); -static_assert(MRC_MAX_NUM_TOUCHPAD_FINGERS == HAL_kMaxJoystickTouchpadFingers); +static_assert(MRC_MAX_NUM_AXES == HAL_MAX_JOYSTICK_AXES); +static_assert(MRC_MAX_NUM_POVS == HAL_MAX_JOYSTICK_POVS); +static_assert(MRC_MAX_NUM_JOYSTICKS == HAL_MAX_JOYSTICKS); +static_assert(MRC_MAX_NUM_TOUCHPADS == HAL_MAX_JOYSTICK_TOUCHPADS); +static_assert(MRC_MAX_NUM_TOUCHPAD_FINGERS == + HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS); namespace { struct JoystickDataCache { JoystickDataCache() { std::memset(this, 0, sizeof(*this)); } void Update(const mrc::ControlData& data); - HAL_JoystickAxes axes[HAL_kMaxJoysticks]; - HAL_JoystickPOVs povs[HAL_kMaxJoysticks]; - HAL_JoystickButtons buttons[HAL_kMaxJoysticks]; - HAL_JoystickTouchpads touchpads[HAL_kMaxJoysticks]; + HAL_JoystickAxes axes[HAL_MAX_JOYSTICKS]; + HAL_JoystickPOVs povs[HAL_MAX_JOYSTICKS]; + HAL_JoystickButtons buttons[HAL_MAX_JOYSTICKS]; + HAL_JoystickTouchpads touchpads[HAL_MAX_JOYSTICKS]; HAL_AllianceStationID allianceStation; float matchTime; HAL_ControlWord controlWord; @@ -301,7 +302,7 @@ void JoystickDataCache::Update(const mrc::ControlData& data) { } } // Mark remaining sticks as unavailable - for (size_t i = sticks.size(); i < HAL_kMaxJoysticks; i++) { + for (size_t i = sticks.size(); i < HAL_MAX_JOYSTICKS; i++) { axes[i].available = 0; povs[i].available = 0; buttons[i].available = 0; @@ -310,7 +311,7 @@ void JoystickDataCache::Update(const mrc::ControlData& data) { } #define CHECK_JOYSTICK_NUMBER(stickNum) \ - if ((stickNum) < 0 || (stickNum) >= HAL_kMaxJoysticks) \ + if ((stickNum) < 0 || (stickNum) >= HAL_MAX_JOYSTICKS) \ return PARAMETER_OUT_OF_RANGE static HAL_ControlWord newestControlWord; @@ -327,7 +328,7 @@ struct TcpCache { void CloneTo(TcpCache* other) { std::memcpy(other, this, sizeof(*this)); } HAL_MatchInfo matchInfo; - HAL_JoystickDescriptor descriptors[HAL_kMaxJoysticks]; + HAL_JoystickDescriptor descriptors[HAL_MAX_JOYSTICKS]; }; static_assert(std::is_standard_layout_v); } // namespace diff --git a/hal/src/main/native/systemcore/mockdata/DriverStationData.cpp b/hal/src/main/native/systemcore/mockdata/DriverStationData.cpp index bbc85531c4..66f7d3e030 100644 --- a/hal/src/main/native/systemcore/mockdata/DriverStationData.cpp +++ b/hal/src/main/native/systemcore/mockdata/DriverStationData.cpp @@ -15,12 +15,12 @@ void HALSIM_ResetDriverStationData(void) {} RETURN) DEFINE_CAPI(HAL_Bool, Enabled, false) -DEFINE_CAPI(HAL_RobotMode, RobotMode, HAL_ROBOTMODE_UNKNOWN) +DEFINE_CAPI(HAL_RobotMode, RobotMode, HAL_ROBOT_MODE_UNKNOWN) DEFINE_CAPI(HAL_Bool, EStop, false) DEFINE_CAPI(HAL_Bool, FmsAttached, false) DEFINE_CAPI(HAL_Bool, DsAttached, false) DEFINE_CAPI(HAL_AllianceStationID, AllianceStationId, - HAL_AllianceStationID_kRed1) + HAL_ALLIANCE_STATION_RED_1) DEFINE_CAPI(double, MatchTime, 0) DEFINE_CAPI(int64_t, OpMode, 0) diff --git a/hal/src/main/python/semiwrap/DriverStationTypes_c.yml b/hal/src/main/python/semiwrap/DriverStationTypes_c.yml index 7189fc01de..676ffd90f3 100644 --- a/hal/src/main/python/semiwrap/DriverStationTypes_c.yml +++ b/hal/src/main/python/semiwrap/DriverStationTypes_c.yml @@ -6,14 +6,14 @@ extra_includes: enums: HAL_AllianceStationID: - value_prefix: HAL_AllianceStationID + value_prefix: HAL_ALLIANCE_STATION HAL_JoystickPOV: - value_prefix: HAL_JoystickPOV + value_prefix: HAL_JOYSTICK_POV HAL_MatchType: - value_prefix: HAL_kMatchType + value_prefix: HAL_MATCH_TYPE HAL_RobotMode: rename: _RobotMode - value_prefix: HAL_ROBOTMODE + value_prefix: HAL_ROBOT_MODE classes: HAL_ControlWord: rename: _ControlWord diff --git a/hal/src/test/native/cpp/mockdata/DriverStationDataTest.cpp b/hal/src/test/native/cpp/mockdata/DriverStationDataTest.cpp index 978abbaca7..b7bb63f1ff 100644 --- a/hal/src/test/native/cpp/mockdata/DriverStationDataTest.cpp +++ b/hal/src/test/native/cpp/mockdata/DriverStationDataTest.cpp @@ -25,12 +25,12 @@ TEST(DriverStationTest, Joystick) { HAL_GetJoystickButtons(joystickNum, &buttons); EXPECT_EQ(0, axes.available); - for (int i = 0; i < HAL_kMaxJoystickAxes; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICK_AXES; ++i) { EXPECT_EQ(0, axes.axes[i]); } EXPECT_EQ(0, povs.available); - for (int i = 0; i < HAL_kMaxJoystickPOVs; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICK_POVS; ++i) { EXPECT_EQ(0, povs.povs[i]); } @@ -53,9 +53,9 @@ TEST(DriverStationTest, Joystick) { } set_povs.available = 0x7; - set_povs.povs[0] = HAL_JoystickPOV_kUp; - set_povs.povs[1] = HAL_JoystickPOV_kRight; - set_povs.povs[2] = HAL_JoystickPOV_kDown; + set_povs.povs[0] = HAL_JOYSTICK_POV_UP; + set_povs.povs[1] = HAL_JOYSTICK_POV_RIGHT; + set_povs.povs[2] = HAL_JOYSTICK_POV_DOWN; set_buttons.available = 0xFF; set_buttons.buttons = 0xDEADBEEF; @@ -82,9 +82,9 @@ TEST(DriverStationTest, Joystick) { EXPECT_NEAR(0, axes.axes[6], 0.000001); // Should not have been set, still 0 EXPECT_EQ(0x7, povs.available); - EXPECT_EQ(HAL_JoystickPOV_kUp, povs.povs[0]); - EXPECT_EQ(HAL_JoystickPOV_kRight, povs.povs[1]); - EXPECT_EQ(HAL_JoystickPOV_kDown, povs.povs[2]); + EXPECT_EQ(HAL_JOYSTICK_POV_UP, povs.povs[0]); + EXPECT_EQ(HAL_JOYSTICK_POV_RIGHT, povs.povs[1]); + EXPECT_EQ(HAL_JOYSTICK_POV_DOWN, povs.povs[2]); EXPECT_EQ(0, povs.povs[3]); // Should not have been set, still 0 EXPECT_EQ(0, povs.povs[4]); // Should not have been set, still 0 EXPECT_EQ(0, povs.povs[5]); // Should not have been set, still 0 @@ -104,12 +104,12 @@ TEST(DriverStationTest, Joystick) { HAL_GetJoystickButtons(joystickNum, &buttons); EXPECT_EQ(0, axes.available); - for (int i = 0; i < HAL_kMaxJoystickAxes; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICK_AXES; ++i) { EXPECT_EQ(0, axes.axes[i]); } EXPECT_EQ(0, povs.available); - for (int i = 0; i < HAL_kMaxJoystickPOVs; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICK_POVS; ++i) { EXPECT_EQ(0, povs.povs[i]); } @@ -124,7 +124,7 @@ TEST(DriverStationTest, EventInfo) { wpi::util::format_to_n_c_str(info.eventName, sizeof(info.eventName), eventName); info.matchNumber = 5; - info.matchType = HAL_MatchType::HAL_kMatchType_qualification; + info.matchType = HAL_MatchType::HAL_MATCH_TYPE_QUALIFICATION; info.replayNumber = 42; HALSIM_SetMatchInfo(&info); @@ -135,7 +135,7 @@ TEST(DriverStationTest, EventInfo) { EXPECT_EQ(eventName, dataBack.eventName); EXPECT_EQ(5, dataBack.matchNumber); - EXPECT_EQ(HAL_MatchType::HAL_kMatchType_qualification, dataBack.matchType); + EXPECT_EQ(HAL_MatchType::HAL_MATCH_TYPE_QUALIFICATION, dataBack.matchType); EXPECT_EQ(42, dataBack.replayNumber); } diff --git a/robotpyExamples/DigitalCommunication/robot.py b/robotpyExamples/DigitalCommunication/robot.py index 2922ad994f..ccc1ff5ae0 100755 --- a/robotpyExamples/DigitalCommunication/robot.py +++ b/robotpyExamples/DigitalCommunication/robot.py @@ -33,7 +33,7 @@ class MyRobot(wpilib.TimedRobot): setAlliance = False alliance = wpilib.DriverStation.getAlliance() if alliance: - setAlliance = alliance == wpilib.DriverStation.Alliance.kRed + setAlliance = alliance == wpilib.DriverStation.Alliance.RED # pull alliance port high if on red alliance, pull low if on blue alliance self.allianceOutput.set(setAlliance) diff --git a/robotpyExamples/I2CCommunication/robot.py b/robotpyExamples/I2CCommunication/robot.py index 8c56394c92..ceaef0034d 100755 --- a/robotpyExamples/I2CCommunication/robot.py +++ b/robotpyExamples/I2CCommunication/robot.py @@ -44,7 +44,7 @@ class MyRobot(wpilib.TimedRobot): alliance = wpilib.DriverStation.getAlliance() if alliance is not None: allianceString = ( - "R" if alliance == wpilib.DriverStation.Alliance.kRed else "B" + "R" if alliance == wpilib.DriverStation.Alliance.RED else "B" ) enabledString = "E" if wpilib.DriverStation.isEnabled() else "D" diff --git a/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp b/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp index d681c2ccd2..d83cc6eb6f 100644 --- a/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp +++ b/simulation/halsim_ds_socket/src/main/native/cpp/DSCommPacket.cpp @@ -18,24 +18,24 @@ using namespace halsim; HAL_JoystickPOV DegreesToPOV(int degrees) { switch (degrees) { case 0: - return HAL_JoystickPOV_kUp; + return HAL_JOYSTICK_POV_UP; case 45: - return HAL_JoystickPOV_kRightUp; + return HAL_JOYSTICK_POV_RIGHT_UP; case 90: - return HAL_JoystickPOV_kRight; + return HAL_JOYSTICK_POV_RIGHT; case 135: - return HAL_JoystickPOV_kRightDown; + return HAL_JOYSTICK_POV_RIGHT_DOWN; case 180: - return HAL_JoystickPOV_kDown; + return HAL_JOYSTICK_POV_DOWN; case 225: - return HAL_JoystickPOV_kLeftDown; + return HAL_JOYSTICK_POV_LEFT_DOWN; case 270: - return HAL_JoystickPOV_kLeft; + return HAL_JOYSTICK_POV_LEFT; case 315: - return HAL_JoystickPOV_kLeftUp; + return HAL_JOYSTICK_POV_LEFT_UP; case -1: default: - return HAL_JoystickPOV_kCentered; + return HAL_JOYSTICK_POV_CENTERED; } } @@ -54,11 +54,11 @@ DSCommPacket::DSCommPacket() { void DSCommPacket::SetControl(uint8_t control, uint8_t request) { HAL_RobotMode robotMode; if ((control & kAutonomous) != 0) { - robotMode = HAL_ROBOTMODE_AUTONOMOUS; + robotMode = HAL_ROBOT_MODE_AUTONOMOUS; } else if ((control & kTest) != 0) { - robotMode = HAL_ROBOTMODE_TEST; + robotMode = HAL_ROBOT_MODE_TEST; } else { - robotMode = HAL_ROBOTMODE_TELEOPERATED; + robotMode = HAL_ROBOT_MODE_TELEOPERATED; } m_control_word = HAL_MakeControlWord( wpi::hal::GetDashboardSelectedOpMode(robotMode), robotMode, @@ -256,7 +256,7 @@ void DSCommPacket::ReadJoystickDescriptionTag(std::span data) { } void DSCommPacket::SendJoysticks(void) { - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { DSCommJoystickPacket& packet = m_joystick_packets[i]; HALSIM_SetJoystickAxes(i, &packet.axes); HALSIM_SetJoystickPOVs(i, &packet.povs); diff --git a/simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommPacket.hpp b/simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommPacket.hpp index 461afe3173..16e55860ce 100644 --- a/simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommPacket.hpp +++ b/simulation/halsim_ds_socket/src/main/native/include/wpi/halsim/ds_socket/DSCommPacket.hpp @@ -63,7 +63,7 @@ class DSCommPacket { HAL_ControlWord m_control_word; HAL_AllianceStationID m_alliance_station; HAL_MatchInfo matchInfo; - std::array m_joystick_packets; + std::array m_joystick_packets; double m_match_time = -1; }; diff --git a/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp b/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp index d2be694c55..e3f62f224e 100644 --- a/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp +++ b/simulation/halsim_ds_socket/src/test/native/cpp/DSCommPacketTest.cpp @@ -34,7 +34,7 @@ class DSCommPacketTest : public ::testing::Test { }; TEST_F(DSCommPacketTest, EmptyJoystickTag) { - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { uint8_t arr[2]; auto& data = ReadJoystickTag(arr, 0); ASSERT_EQ(data.axes.available, 0); @@ -44,7 +44,7 @@ TEST_F(DSCommPacketTest, EmptyJoystickTag) { } TEST_F(DSCommPacketTest, BlankJoystickTag) { - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { uint8_t arr[5]; arr[0] = 4; arr[1] = 2; @@ -59,7 +59,7 @@ TEST_F(DSCommPacketTest, BlankJoystickTag) { } TEST_F(DSCommPacketTest, MainJoystickTag) { - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { // Just random data std::array _buttons{{0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1}}; @@ -94,7 +94,7 @@ TEST_F(DSCommPacketTest, MainJoystickTag) { } TEST_F(DSCommPacketTest, DescriptorTag) { - for (int i = 0; i < HAL_kMaxJoysticks; i++) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; i++) { uint8_t arr[] = {// Size (2), tag 0, 0, 7, // Joystick index, Is Xbox, Type @@ -123,7 +123,7 @@ TEST_F(DSCommPacketTest, MatchInfoTag) { arr[1] = sizeof(arr) - 2; auto& matchInfo = ReadNewMatchInfoTag(arr); ASSERT_STREQ(matchInfo.eventName, "WCBC"); - ASSERT_EQ(matchInfo.matchType, HAL_MatchType::HAL_kMatchType_qualification); + ASSERT_EQ(matchInfo.matchType, HAL_MatchType::HAL_MATCH_TYPE_QUALIFICATION); ASSERT_EQ(matchInfo.matchNumber, 18); ASSERT_EQ(matchInfo.replayNumber, 1); } diff --git a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp index 750b4edaf7..6a8b9b0d55 100644 --- a/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/DriverStationGui.cpp @@ -200,11 +200,11 @@ class JoystickModel { int axisCount; int buttonCount; int povCount; - std::unique_ptr axes[HAL_kMaxJoystickAxes]; + std::unique_ptr axes[HAL_MAX_JOYSTICK_AXES]; // use pointer instead of unique_ptr to allow it to be passed directly // to DrawLEDSources() wpi::glass::BooleanSource* buttons[32]; - std::unique_ptr povs[HAL_kMaxJoystickPOVs]; + std::unique_ptr povs[HAL_MAX_JOYSTICK_POVS]; private: static void CallbackFunc(const char*, void* param, const HAL_Value*); @@ -276,7 +276,7 @@ static std::vector> gKeyboardJoysticks; // robot joysticks static std::vector gRobotJoysticks; -static std::unique_ptr gJoystickSources[HAL_kMaxJoysticks]; +static std::unique_ptr gJoystickSources[HAL_MAX_JOYSTICKS]; // FMS static std::unique_ptr gFMSModel; @@ -323,13 +323,13 @@ static void UpdateOpModes(const char* name, void* param, for (auto&& o : std::span{opmodes, opmodes + count}) { OpModes* vec; switch (HAL_OpMode_GetRobotMode(o.id)) { - case HAL_ROBOTMODE_AUTONOMOUS: + case HAL_ROBOT_MODE_AUTONOMOUS: vec = &gAutoOpModes; break; - case HAL_ROBOTMODE_TELEOPERATED: + case HAL_ROBOT_MODE_TELEOPERATED: vec = &gTeleopOpModes; break; - case HAL_ROBOTMODE_TEST: + case HAL_ROBOT_MODE_TEST: vec = &gTestOpModes; break; default: @@ -488,9 +488,9 @@ void GlfwSystemJoystick::GetData(HALJoystickData* data, bool mapGamepad) const { data->desc.gamepadType = 1; // Standard std::strncpy(data->desc.name, m_name, sizeof(data->desc.name) - 1); data->desc.name[sizeof(data->desc.name) - 1] = '\0'; - int axesCount = (std::min)(m_axisCount, HAL_kMaxJoystickAxes); + int axesCount = (std::min)(m_axisCount, HAL_MAX_JOYSTICK_AXES); int buttonCount = (std::min)(m_buttonCount, 64); - int povsCount = (std::min)(m_hatCount, HAL_kMaxJoystickPOVs); + int povsCount = (std::min)(m_hatCount, HAL_MAX_JOYSTICK_POVS); if (buttonCount < 64) { data->buttons.available = (1ULL << buttonCount) - 1; @@ -669,8 +669,8 @@ void KeyboardJoystick::SettingsDisplay() { if (ImGui::InputInt("Count", &m_axisCount)) { if (m_axisCount < 0) { m_axisCount = 0; - } else if (m_axisCount > HAL_kMaxJoystickAxes) { - m_axisCount = HAL_kMaxJoystickAxes; + } else if (m_axisCount > HAL_MAX_JOYSTICK_AXES) { + m_axisCount = HAL_MAX_JOYSTICK_AXES; } } while (m_axisCount > static_cast(m_axisConfig.size())) { @@ -726,8 +726,8 @@ void KeyboardJoystick::SettingsDisplay() { if (m_povCount < 0) { m_povCount = 0; } - if (m_povCount > HAL_kMaxJoystickPOVs) { - m_povCount = HAL_kMaxJoystickPOVs; + if (m_povCount > HAL_MAX_JOYSTICK_POVS) { + m_povCount = HAL_MAX_JOYSTICK_POVS; } } while (m_povCount > static_cast(m_povConfig.size())) { @@ -837,23 +837,23 @@ void KeyboardJoystick::Update() { for (int i = 0; i < povsCount; ++i) { auto& config = m_povConfig[i]; auto& povValue = m_data.povs.povs[i]; - povValue = HAL_JoystickPOV_kCentered; + povValue = HAL_JOYSTICK_POV_CENTERED; if (IsKeyDown(io, config.keyUp)) { - povValue = HAL_JoystickPOV_kUp; + povValue = HAL_JOYSTICK_POV_UP; } else if (IsKeyDown(io, config.keyUpRight)) { - povValue = HAL_JoystickPOV_kRightUp; + povValue = HAL_JOYSTICK_POV_RIGHT_UP; } else if (IsKeyDown(io, config.keyRight)) { - povValue = HAL_JoystickPOV_kRight; + povValue = HAL_JOYSTICK_POV_RIGHT; } else if (IsKeyDown(io, config.keyDownRight)) { - povValue = HAL_JoystickPOV_kRightDown; + povValue = HAL_JOYSTICK_POV_RIGHT_DOWN; } else if (IsKeyDown(io, config.keyDown)) { - povValue = HAL_JoystickPOV_kDown; + povValue = HAL_JOYSTICK_POV_DOWN; } else if (IsKeyDown(io, config.keyDownLeft)) { - povValue = HAL_JoystickPOV_kLeftDown; + povValue = HAL_JOYSTICK_POV_LEFT_DOWN; } else if (IsKeyDown(io, config.keyLeft)) { - povValue = HAL_JoystickPOV_kLeft; + povValue = HAL_JOYSTICK_POV_LEFT; } else if (IsKeyDown(io, config.keyUpLeft)) { - povValue = HAL_JoystickPOV_kLeftUp; + povValue = HAL_JOYSTICK_POV_LEFT_UP; } } @@ -1082,7 +1082,7 @@ static void DriverStationSetEnabled(bool enabled) { static void DriverStationExecute() { // update sources - for (int i = 0; i < HAL_kMaxJoysticks; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; ++i) { auto& source = gJoystickSources[i]; uint16_t axesAvailable; uint8_t povsAvailable; @@ -1196,17 +1196,17 @@ static void DriverStationExecute() { } if (ImGui::Selectable( "Autonomous", - isAttached && robotMode == HAL_ROBOTMODE_AUTONOMOUS)) { - DriverStationSetRobotMode(HAL_ROBOTMODE_AUTONOMOUS); + isAttached && robotMode == HAL_ROBOT_MODE_AUTONOMOUS)) { + DriverStationSetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS); } if (ImGui::Selectable( "Teleoperated", - isAttached && robotMode == HAL_ROBOTMODE_TELEOPERATED)) { - DriverStationSetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + isAttached && robotMode == HAL_ROBOT_MODE_TELEOPERATED)) { + DriverStationSetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); } if (ImGui::Selectable("Test", - isAttached && robotMode == HAL_ROBOTMODE_TEST)) { - DriverStationSetRobotMode(HAL_ROBOTMODE_TEST); + isAttached && robotMode == HAL_ROBOT_MODE_TEST)) { + DriverStationSetRobotMode(HAL_ROBOT_MODE_TEST); } // OpMode bool canEnable = isAttached && started; @@ -1217,13 +1217,13 @@ static void DriverStationExecute() { } else { OpModes* modes; switch (robotMode) { - case HAL_ROBOTMODE_AUTONOMOUS: + case HAL_ROBOT_MODE_AUTONOMOUS: modes = &gAutoOpModes; break; - case HAL_ROBOTMODE_TELEOPERATED: + case HAL_ROBOT_MODE_TELEOPERATED: modes = &gTeleopOpModes; break; - case HAL_ROBOTMODE_TEST: + case HAL_ROBOT_MODE_TEST: modes = &gTestOpModes; break; default: @@ -1286,9 +1286,9 @@ static void DriverStationExecute() { } // Update HAL - if (isAttached && robotMode != HAL_ROBOTMODE_AUTONOMOUS) { + if (isAttached && robotMode != HAL_ROBOT_MODE_AUTONOMOUS) { for (int i = 0, end = gRobotJoysticks.size(); - i < end && i < HAL_kMaxJoysticks; ++i) { + i < end && i < HAL_MAX_JOYSTICKS; ++i) { gRobotJoysticks[i].SetHAL(i); } } @@ -1305,7 +1305,7 @@ static void DriverStationExecute() { FMSSimModel::FMSSimModel() { m_matchTime.SetValue(-1.0); - m_allianceStationId.SetValue(HAL_AllianceStationID_kRed1); + m_allianceStationId.SetValue(HAL_ALLIANCE_STATION_RED_1); } void FMSSimModel::UpdateHAL() { @@ -1415,10 +1415,10 @@ static void DisplaySystemJoysticks() { static void DisplayJoysticks() { bool disableDS = IsDSDisabled(); // imgui doesn't size columns properly with autoresize, so force it - ImGui::Dummy(ImVec2(ImGui::GetFontSize() * 10 * HAL_kMaxJoysticks, 0)); + ImGui::Dummy(ImVec2(ImGui::GetFontSize() * 10 * HAL_MAX_JOYSTICKS, 0)); - ImGui::Columns(HAL_kMaxJoysticks, "Joysticks", false); - for (int i = 0; i < HAL_kMaxJoysticks; ++i) { + ImGui::Columns(HAL_MAX_JOYSTICKS, "Joysticks", false); + for (int i = 0; i < HAL_MAX_JOYSTICKS; ++i) { auto& joy = gRobotJoysticks[i]; char label[128]; joy.name.GetLabel(label, sizeof(label), "Joystick", i); @@ -1459,7 +1459,7 @@ static void DisplayJoysticks() { } ImGui::Separator(); - for (int i = 0; i < HAL_kMaxJoysticks; ++i) { + for (int i = 0; i < HAL_MAX_JOYSTICKS; ++i) { auto& joy = gRobotJoysticks[i]; auto source = gJoystickSources[i].get(); @@ -1603,8 +1603,8 @@ void DriverStationGui::GlobalInit() { } auto& robotJoystickStorage = storageRoot.GetChildArray("robotJoysticks"); - robotJoystickStorage.resize(HAL_kMaxJoysticks); - for (int i = 0; i < HAL_kMaxJoysticks; ++i) { + robotJoystickStorage.resize(HAL_MAX_JOYSTICKS); + for (int i = 0; i < HAL_MAX_JOYSTICKS; ++i) { if (!robotJoystickStorage[i]) { robotJoystickStorage[i] = std::make_unique(); } diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp index 51b1d7222a..ff10f68ac1 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_DriverStation.cpp @@ -63,25 +63,25 @@ void HALSimWSProviderDriverStation::RegisterCallbacks() { [](const char* name, void* param, const struct HAL_Value* value) { std::string station; switch (static_cast(value->data.v_enum)) { - case HAL_AllianceStationID_kRed1: + case HAL_ALLIANCE_STATION_RED_1: station = "red1"; break; - case HAL_AllianceStationID_kBlue1: + case HAL_ALLIANCE_STATION_BLUE_1: station = "blue1"; break; - case HAL_AllianceStationID_kRed2: + case HAL_ALLIANCE_STATION_RED_2: station = "red2"; break; - case HAL_AllianceStationID_kBlue2: + case HAL_ALLIANCE_STATION_BLUE_2: station = "blue2"; break; - case HAL_AllianceStationID_kRed3: + case HAL_ALLIANCE_STATION_RED_3: station = "red3"; break; - case HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_BLUE_3: station = "blue3"; break; - case HAL_AllianceStationID_kUnknown: + case HAL_ALLIANCE_STATION_UNKNOWN: station = "unknown"; break; } @@ -144,17 +144,17 @@ void HALSimWSProviderDriverStation::OnNetValueChanged( if ((it = json.find(">station")) != json.end()) { auto& station = it.value().get_ref(); if (station == "red1") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kRed1); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_RED_1); } else if (station == "red2") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kRed2); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_RED_2); } else if (station == "red3") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kRed3); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_RED_3); } else if (station == "blue1") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kBlue1); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_BLUE_1); } else if (station == "blue2") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kBlue2); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_BLUE_2); } else if (station == "blue3") { - HALSIM_SetDriverStationAllianceStationId(HAL_AllianceStationID_kBlue3); + HALSIM_SetDriverStationAllianceStationId(HAL_ALLIANCE_STATION_BLUE_3); } } diff --git a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp index 2a029f61f5..9411f2df6a 100644 --- a/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp +++ b/simulation/halsim_ws_core/src/main/native/cpp/WSProvider_Joystick.cpp @@ -16,7 +16,7 @@ namespace wpilibws { extern std::atomic* gDSSocketConnected; void HALSimWSProviderJoystick::Initialize(WSRegisterFunc webregisterFunc) { - CreateProviders("Joystick", HAL_kMaxJoysticks, + CreateProviders("Joystick", HAL_MAX_JOYSTICKS, webregisterFunc); } @@ -106,9 +106,9 @@ void HALSimWSProviderJoystick::OnNetValueChanged(const wpi::util::json& json) { wpi::util::json::const_iterator it; if ((it = json.find(">axes")) != json.end()) { HAL_JoystickAxes axes{}; - wpi::util::json::size_type axesCount = - std::min(it.value().size(), - static_cast(HAL_kMaxJoystickAxes)); + wpi::util::json::size_type axesCount = std::min( + it.value().size(), + static_cast(HAL_MAX_JOYSTICK_AXES)); axes.available = (1 << axesCount) - 1; for (wpi::util::json::size_type i = 0; i < axesCount; i++) { axes.axes[i] = it.value()[i]; @@ -137,9 +137,9 @@ void HALSimWSProviderJoystick::OnNetValueChanged(const wpi::util::json& json) { if ((it = json.find(">povs")) != json.end()) { HAL_JoystickPOVs povs{}; - wpi::util::json::size_type povsCount = - std::min(it.value().size(), - static_cast(HAL_kMaxJoystickPOVs)); + wpi::util::json::size_type povsCount = std::min( + it.value().size(), + static_cast(HAL_MAX_JOYSTICK_POVS)); povs.available = (1 << povsCount) - 1; for (wpi::util::json::size_type i = 0; i < povsCount; i++) { povs.povs[i] = it.value()[i]; diff --git a/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp b/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp index 10bb378499..2e07237044 100644 --- a/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp +++ b/wpilibc/src/main/native/cpp/driverstation/DriverStation.cpp @@ -138,7 +138,7 @@ class DataLogSender { wpi::log::StringLogEntry m_logOpMode; bool m_logJoysticks; - std::array m_joysticks; + std::array m_joysticks; }; struct Instance { @@ -151,10 +151,10 @@ struct Instance { // Joystick button rising/falling edge flags wpi::util::mutex buttonEdgeMutex; - std::array + std::array previousButtonStates; - std::array joystickButtonsPressed; - std::array joystickButtonsReleased; + std::array joystickButtonsPressed; + std::array joystickButtonsReleased; bool silenceJoystickWarning = false; @@ -212,7 +212,7 @@ Instance::Instance() { // All joysticks should default to having zero axes, povs and buttons, so // uninitialized memory doesn't get sent to motor controllers. - for (unsigned int i = 0; i < DriverStation::kJoystickPorts; i++) { + for (unsigned int i = 0; i < DriverStation::JOYSTICK_PORTS; i++) { joystickButtonsPressed[i] = 0; joystickButtonsReleased[i] = 0; previousButtonStates[i].available = 0; @@ -227,7 +227,7 @@ Instance::~Instance() { } bool DriverStation::GetStickButton(int stick, int button) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } @@ -253,7 +253,7 @@ bool DriverStation::GetStickButton(int stick, int button) { std::optional DriverStation::GetStickButtonIfAvailable(int stick, int button) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } @@ -276,7 +276,7 @@ std::optional DriverStation::GetStickButtonIfAvailable(int stick, } bool DriverStation::GetStickButtonPressed(int stick, int button) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } @@ -307,7 +307,7 @@ bool DriverStation::GetStickButtonPressed(int stick, int button) { } bool DriverStation::GetStickButtonReleased(int stick, int button) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } @@ -338,11 +338,11 @@ bool DriverStation::GetStickButtonReleased(int stick, int button) { } double DriverStation::GetStickAxis(int stick, int axis) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0.0; } - if (axis < 0 || axis >= HAL_kMaxJoystickAxes) { + if (axis < 0 || axis >= HAL_MAX_JOYSTICK_AXES) { WPILIB_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis); return 0.0; } @@ -363,16 +363,16 @@ double DriverStation::GetStickAxis(int stick, int axis) { DriverStation::TouchpadFinger DriverStation::GetStickTouchpadFinger( int stick, int touchpad, int finger) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return TouchpadFinger{false, 0.0f, 0.0f}; } - if (touchpad < 0 || touchpad >= HAL_kMaxJoystickTouchpads) { + if (touchpad < 0 || touchpad >= HAL_MAX_JOYSTICK_TOUCHPADS) { WPILIB_ReportError(warn::BadJoystickAxis, "touchpad {} out of range", touchpad); return TouchpadFinger{false, 0.0f, 0.0f}; } - if (finger < 0 || finger >= HAL_kMaxJoystickTouchpadFingers) { + if (finger < 0 || finger >= HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS) { WPILIB_ReportError(warn::BadJoystickAxis, "finger {} out of range", finger); return TouchpadFinger{false, 0.0f, 0.0f}; } @@ -399,16 +399,16 @@ DriverStation::TouchpadFinger DriverStation::GetStickTouchpadFinger( bool DriverStation::GetStickTouchpadFingerAvailable(int stick, int touchpad, int finger) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } - if (touchpad < 0 || touchpad >= HAL_kMaxJoystickTouchpads) { + if (touchpad < 0 || touchpad >= HAL_MAX_JOYSTICK_TOUCHPADS) { WPILIB_ReportError(warn::BadJoystickAxis, "touchpad {} out of range", touchpad); return false; } - if (finger < 0 || finger >= HAL_kMaxJoystickTouchpadFingers) { + if (finger < 0 || finger >= HAL_MAX_JOYSTICK_TOUCHPAD_FINGERS) { WPILIB_ReportError(warn::BadJoystickAxis, "finger {} out of range", finger); return false; } @@ -428,11 +428,11 @@ bool DriverStation::GetStickTouchpadFingerAvailable(int stick, int touchpad, std::optional DriverStation::GetStickAxisIfAvailable(int stick, int axis) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0.0; } - if (axis < 0 || axis >= HAL_kMaxJoystickAxes) { + if (axis < 0 || axis >= HAL_MAX_JOYSTICK_AXES) { WPILIB_ReportError(warn::BadJoystickAxis, "axis {} out of range", axis); return 0.0; } @@ -450,13 +450,13 @@ std::optional DriverStation::GetStickAxisIfAvailable(int stick, } DriverStation::POVDirection DriverStation::GetStickPOV(int stick, int pov) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); - return kCenter; + return POVDirection::CENTER; } - if (pov < 0 || pov >= HAL_kMaxJoystickPOVs) { + if (pov < 0 || pov >= HAL_MAX_JOYSTICK_POVS) { WPILIB_ReportError(warn::BadJoystickAxis, "POV {} out of range", pov); - return kCenter; + return POVDirection::CENTER; } uint16_t mask = 1 << pov; @@ -467,14 +467,14 @@ DriverStation::POVDirection DriverStation::GetStickPOV(int stick, int pov) { if ((povs.available & mask) == 0) { ReportJoystickWarning(stick, "Joystick POV {} on port {} not available", pov, stick); - return kCenter; + return POVDirection::CENTER; } return static_cast(povs.povs[pov]); } uint64_t DriverStation::GetStickButtons(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0; } @@ -490,7 +490,7 @@ int DriverStation::GetStickAxesMaximumIndex(int stick) { } int DriverStation::GetStickAxesAvailable(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0; } @@ -506,7 +506,7 @@ int DriverStation::GetStickPOVsMaximumIndex(int stick) { } int DriverStation::GetStickPOVsAvailable(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0; } @@ -522,7 +522,7 @@ int DriverStation::GetStickButtonsMaximumIndex(int stick) { } uint64_t DriverStation::GetStickButtonsAvailable(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0; } @@ -534,7 +534,7 @@ uint64_t DriverStation::GetStickButtonsAvailable(int stick) { } bool DriverStation::GetJoystickIsGamepad(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return false; } @@ -546,7 +546,7 @@ bool DriverStation::GetJoystickIsGamepad(int stick) { } int DriverStation::GetJoystickGamepadType(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return -1; } @@ -558,7 +558,7 @@ int DriverStation::GetJoystickGamepadType(int stick) { } int DriverStation::GetJoystickSupportedOutputs(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); return 0; } @@ -570,7 +570,7 @@ int DriverStation::GetJoystickSupportedOutputs(int stick) { } std::string DriverStation::GetJoystickName(int stick) { - if (stick < 0 || stick >= kJoystickPorts) { + if (stick < 0 || stick >= JOYSTICK_PORTS) { WPILIB_ReportError(warn::BadJoystickIndex, "stick {} out of range", stick); } @@ -723,14 +723,14 @@ std::optional DriverStation::GetAlliance() { int32_t status = 0; auto allianceStationID = HAL_GetAllianceStation(&status); switch (allianceStationID) { - case HAL_AllianceStationID_kRed1: - case HAL_AllianceStationID_kRed2: - case HAL_AllianceStationID_kRed3: - return kRed; - case HAL_AllianceStationID_kBlue1: - case HAL_AllianceStationID_kBlue2: - case HAL_AllianceStationID_kBlue3: - return kBlue; + case HAL_ALLIANCE_STATION_RED_1: + case HAL_ALLIANCE_STATION_RED_2: + case HAL_ALLIANCE_STATION_RED_3: + return Alliance::RED; + case HAL_ALLIANCE_STATION_BLUE_1: + case HAL_ALLIANCE_STATION_BLUE_2: + case HAL_ALLIANCE_STATION_BLUE_3: + return Alliance::BLUE; default: return {}; } @@ -740,14 +740,14 @@ std::optional DriverStation::GetLocation() { int32_t status = 0; auto allianceStationID = HAL_GetAllianceStation(&status); switch (allianceStationID) { - case HAL_AllianceStationID_kRed1: - case HAL_AllianceStationID_kBlue1: + case HAL_ALLIANCE_STATION_RED_1: + case HAL_ALLIANCE_STATION_BLUE_1: return 1; - case HAL_AllianceStationID_kRed2: - case HAL_AllianceStationID_kBlue2: + case HAL_ALLIANCE_STATION_RED_2: + case HAL_ALLIANCE_STATION_BLUE_2: return 2; - case HAL_AllianceStationID_kRed3: - case HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_RED_3: + case HAL_ALLIANCE_STATION_BLUE_3: return 3; default: return {}; @@ -781,7 +781,7 @@ void DriverStation::RefreshData() { HAL_JoystickButtons currentButtons; std::unique_lock lock(inst.buttonEdgeMutex); - for (int32_t i = 0; i < DriverStation::kJoystickPorts; i++) { + for (int32_t i = 0; i < DriverStation::JOYSTICK_PORTS; i++) { HAL_GetJoystickButtons(i, ¤tButtons); // If buttons weren't pressed and are now, set flags in m_buttonsPressed @@ -866,23 +866,23 @@ void SendMatchData() { bool isRedAlliance = false; int stationNumber = 1; switch (alliance) { - case HAL_AllianceStationID::HAL_AllianceStationID_kBlue1: + case HAL_ALLIANCE_STATION_BLUE_1: isRedAlliance = false; stationNumber = 1; break; - case HAL_AllianceStationID::HAL_AllianceStationID_kBlue2: + case HAL_ALLIANCE_STATION_BLUE_2: isRedAlliance = false; stationNumber = 2; break; - case HAL_AllianceStationID::HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_BLUE_3: isRedAlliance = false; stationNumber = 3; break; - case HAL_AllianceStationID::HAL_AllianceStationID_kRed1: + case HAL_ALLIANCE_STATION_RED_1: isRedAlliance = true; stationNumber = 1; break; - case HAL_AllianceStationID::HAL_AllianceStationID_kRed2: + case HAL_ALLIANCE_STATION_RED_2: isRedAlliance = true; stationNumber = 2; break; @@ -989,7 +989,7 @@ void JoystickLogSender::AppendButtons(HAL_JoystickButtons buttons, void JoystickLogSender::AppendPOVs(const HAL_JoystickPOVs& povs, uint64_t timestamp) { int count = availableToCount(povs.available); - int64_t povsArr[HAL_kMaxJoystickPOVs]; + int64_t povsArr[HAL_MAX_JOYSTICK_POVS]; for (int i = 0; i < count; ++i) { povsArr[i] = povs.povs[i]; } diff --git a/wpilibc/src/main/native/cpp/driverstation/GenericHID.cpp b/wpilibc/src/main/native/cpp/driverstation/GenericHID.cpp index 4337135ba8..393c31e746 100644 --- a/wpilibc/src/main/native/cpp/driverstation/GenericHID.cpp +++ b/wpilibc/src/main/native/cpp/driverstation/GenericHID.cpp @@ -14,7 +14,7 @@ using namespace wpi; GenericHID::GenericHID(int port) { - if (port < 0 || port >= DriverStation::kJoystickPorts) { + if (port < 0 || port >= DriverStation::JOYSTICK_PORTS) { throw WPILIB_MakeError(warn::BadJoystickIndex, "port {} out of range", port); } @@ -58,39 +58,39 @@ BooleanEvent GenericHID::POV(int pov, DriverStation::POVDirection angle, } BooleanEvent GenericHID::POVUp(EventLoop* loop) const { - return POV(DriverStation::kUp, loop); + return POV(DriverStation::POVDirection::UP, loop); } BooleanEvent GenericHID::POVUpRight(EventLoop* loop) const { - return POV(DriverStation::kUpRight, loop); + return POV(DriverStation::POVDirection::UP_RIGHT, loop); } BooleanEvent GenericHID::POVRight(EventLoop* loop) const { - return POV(DriverStation::kRight, loop); + return POV(DriverStation::POVDirection::RIGHT, loop); } BooleanEvent GenericHID::POVDownRight(EventLoop* loop) const { - return POV(DriverStation::kDownRight, loop); + return POV(DriverStation::POVDirection::DOWN_RIGHT, loop); } BooleanEvent GenericHID::POVDown(EventLoop* loop) const { - return POV(DriverStation::kDown, loop); + return POV(DriverStation::POVDirection::DOWN, loop); } BooleanEvent GenericHID::POVDownLeft(EventLoop* loop) const { - return POV(DriverStation::kDownLeft, loop); + return POV(DriverStation::POVDirection::DOWN_LEFT, loop); } BooleanEvent GenericHID::POVLeft(EventLoop* loop) const { - return POV(DriverStation::kLeft, loop); + return POV(DriverStation::POVDirection::LEFT, loop); } BooleanEvent GenericHID::POVUpLeft(EventLoop* loop) const { - return POV(DriverStation::kUpLeft, loop); + return POV(DriverStation::POVDirection::UP_LEFT, loop); } BooleanEvent GenericHID::POVCenter(EventLoop* loop) const { - return POV(DriverStation::kCenter, loop); + return POV(DriverStation::POVDirection::CENTER, loop); } BooleanEvent GenericHID::AxisLessThan(int axis, double threshold, diff --git a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp index 8e8bf0657f..a4ea1eb186 100644 --- a/wpilibc/src/main/native/cpp/system/DataLogManager.cpp +++ b/wpilibc/src/main/native/cpp/system/DataLogManager.cpp @@ -246,17 +246,17 @@ void Thread::Main() { // match info comes through TCP, so we need to double-check we've // actually received it auto matchType = DriverStation::GetMatchType(); - if (matchType != DriverStation::kNone) { + if (matchType != DriverStation::MatchType::NONE) { // rename per match info char matchTypeChar; switch (matchType) { - case DriverStation::kPractice: + case DriverStation::MatchType::PRACTICE: matchTypeChar = 'P'; break; - case DriverStation::kQualification: + case DriverStation::MatchType::QUALIFICATION: matchTypeChar = 'Q'; break; - case DriverStation::kElimination: + case DriverStation::MatchType::ELIMINATION: matchTypeChar = 'E'; break; default: diff --git a/wpilibc/src/main/native/include/wpi/driverstation/DriverStation.hpp b/wpilibc/src/main/native/include/wpi/driverstation/DriverStation.hpp index 5636178740..7eede90a3f 100644 --- a/wpilibc/src/main/native/include/wpi/driverstation/DriverStation.hpp +++ b/wpilibc/src/main/native/include/wpi/driverstation/DriverStation.hpp @@ -35,49 +35,49 @@ class DriverStation final { /** * The robot alliance that the robot is a part of. */ - enum Alliance { + enum class Alliance { /// Red alliance. - kRed, + RED, /// Blue alliance. - kBlue + BLUE }; /** * The type of robot match that the robot is part of. */ - enum MatchType { + enum class MatchType { /// None. - kNone, + NONE, /// Practice. - kPractice, + PRACTICE, /// Qualification. - kQualification, + QUALIFICATION, /// Elimination. - kElimination + ELIMINATION }; /** * A controller POV direction. */ - enum POVDirection : uint8_t { + enum class POVDirection : uint8_t { /// POV center. - kCenter = HAL_JoystickPOV_kCentered, + CENTER = HAL_JOYSTICK_POV_CENTERED, /// POV up. - kUp = HAL_JoystickPOV_kUp, + UP = HAL_JOYSTICK_POV_UP, /// POV up right. - kUpRight = HAL_JoystickPOV_kRightUp, + UP_RIGHT = HAL_JOYSTICK_POV_RIGHT_UP, /// POV right. - kRight = HAL_JoystickPOV_kRight, + RIGHT = HAL_JOYSTICK_POV_RIGHT, /// POV down right. - kDownRight = HAL_JoystickPOV_kRightDown, + DOWN_RIGHT = HAL_JOYSTICK_POV_RIGHT_DOWN, /// POV down. - kDown = HAL_JoystickPOV_kDown, + DOWN = HAL_JOYSTICK_POV_DOWN, /// POV down left. - kDownLeft = HAL_JoystickPOV_kLeftDown, + DOWN_LEFT = HAL_JOYSTICK_POV_LEFT_DOWN, /// POV left. - kLeft = HAL_JoystickPOV_kLeft, + LEFT = HAL_JOYSTICK_POV_LEFT, /// POV up left. - kUpLeft = HAL_JoystickPOV_kLeftUp, + UP_LEFT = HAL_JOYSTICK_POV_LEFT_UP, }; struct TouchpadFinger final { @@ -91,28 +91,28 @@ class DriverStation final { * * @param angle The POVDirection to convert. * @return The angle clockwise from straight up, or std::nullopt if the - * POVDirection is kCenter. + * POVDirection is CENTER. */ static constexpr std::optional GetAngle( POVDirection angle) { switch (angle) { - case kCenter: + case POVDirection::CENTER: return std::nullopt; - case kUp: + case POVDirection::UP: return wpi::math::Rotation2d{0_deg}; - case kUpRight: + case POVDirection::UP_RIGHT: return wpi::math::Rotation2d{45_deg}; - case kRight: + case POVDirection::RIGHT: return wpi::math::Rotation2d{90_deg}; - case kDownRight: + case POVDirection::DOWN_RIGHT: return wpi::math::Rotation2d{135_deg}; - case kDown: + case POVDirection::DOWN: return wpi::math::Rotation2d{180_deg}; - case kDownLeft: + case POVDirection::DOWN_LEFT: return wpi::math::Rotation2d{225_deg}; - case kLeft: + case POVDirection::LEFT: return wpi::math::Rotation2d{270_deg}; - case kUpLeft: + case POVDirection::UP_LEFT: return wpi::math::Rotation2d{315_deg}; default: return std::nullopt; @@ -120,7 +120,7 @@ class DriverStation final { } /// Number of Joystick ports. - static constexpr int kJoystickPorts = 6; + static constexpr int JOYSTICK_PORTS = 6; /** * The state of one joystick button. Button indexes begin at 0. diff --git a/wpilibc/src/main/python/semiwrap/DriverStation.yml b/wpilibc/src/main/python/semiwrap/DriverStation.yml index 38d03cd81b..8230983d4b 100644 --- a/wpilibc/src/main/python/semiwrap/DriverStation.yml +++ b/wpilibc/src/main/python/semiwrap/DriverStation.yml @@ -5,7 +5,7 @@ extra_includes: classes: wpi::DriverStation: attributes: - kJoystickPorts: + JOYSTICK_PORTS: enums: Alliance: MatchType: diff --git a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp index 94d34c5249..dc2f594f44 100644 --- a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp +++ b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp @@ -162,7 +162,7 @@ TEST_F(TimedRobotTest, AutonomousMode) { wpi::sim::WaitForProgramStart(); wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_AUTONOMOUS); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(1u, robot.m_simulationInitCount); @@ -234,7 +234,7 @@ TEST_F(TimedRobotTest, TeleopMode) { wpi::sim::WaitForProgramStart(); wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(1u, robot.m_simulationInitCount); @@ -305,7 +305,7 @@ TEST_F(TimedRobotTest, TestMode) { wpi::sim::WaitForProgramStart(); wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TEST); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TEST); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(1u, robot.m_simulationInitCount); @@ -426,7 +426,7 @@ TEST_F(TimedRobotTest, ModeChange) { // Transition to autonomous wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_AUTONOMOUS); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS); wpi::sim::DriverStationSim::NotifyNewData(); wpi::sim::StepTiming(kPeriod); @@ -443,7 +443,7 @@ TEST_F(TimedRobotTest, ModeChange) { // Transition to teleop wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::NotifyNewData(); wpi::sim::StepTiming(kPeriod); @@ -460,7 +460,7 @@ TEST_F(TimedRobotTest, ModeChange) { // Transition to test wpi::sim::DriverStationSim::SetEnabled(true); - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TEST); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TEST); wpi::sim::DriverStationSim::NotifyNewData(); wpi::sim::StepTiming(kPeriod); diff --git a/wpilibc/src/test/native/cpp/simulation/DriverStationSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/DriverStationSimTest.cpp index 6e2a35f442..504e33f53f 100644 --- a/wpilibc/src/test/native/cpp/simulation/DriverStationSimTest.cpp +++ b/wpilibc/src/test/native/cpp/simulation/DriverStationSimTest.cpp @@ -22,7 +22,7 @@ TEST(DriverStationTest, Enabled) { BooleanCallback callback; auto cb = DriverStationSim::RegisterEnabledCallback(callback.GetCallback(), false); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); DriverStationSim::SetEnabled(true); DriverStationSim::NotifyNewData(); EXPECT_TRUE(DriverStationSim::GetEnabled()); @@ -39,13 +39,13 @@ TEST(DriverStationTest, AutonomousMode) { EnumCallback callback; auto cb = DriverStationSim::RegisterRobotModeCallback(callback.GetCallback(), false); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_AUTONOMOUS); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS); DriverStationSim::NotifyNewData(); - EXPECT_EQ(DriverStationSim::GetRobotMode(), HAL_ROBOTMODE_AUTONOMOUS); + EXPECT_EQ(DriverStationSim::GetRobotMode(), HAL_ROBOT_MODE_AUTONOMOUS); EXPECT_TRUE(DriverStation::IsAutonomous()); EXPECT_EQ(DriverStation::GetRobotMode(), RobotMode::AUTONOMOUS); EXPECT_TRUE(callback.WasTriggered()); - EXPECT_EQ(callback.GetLastValue(), HAL_ROBOTMODE_AUTONOMOUS); + EXPECT_EQ(callback.GetLastValue(), HAL_ROBOT_MODE_AUTONOMOUS); } TEST(DriverStationTest, Mode) { @@ -56,13 +56,13 @@ TEST(DriverStationTest, Mode) { EnumCallback callback; auto cb = DriverStationSim::RegisterRobotModeCallback(callback.GetCallback(), false); - DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TEST); + DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TEST); DriverStationSim::NotifyNewData(); - EXPECT_EQ(DriverStationSim::GetRobotMode(), HAL_ROBOTMODE_TEST); + EXPECT_EQ(DriverStationSim::GetRobotMode(), HAL_ROBOT_MODE_TEST); EXPECT_TRUE(DriverStation::IsTest()); EXPECT_EQ(DriverStation::GetRobotMode(), RobotMode::TEST); EXPECT_TRUE(callback.WasTriggered()); - EXPECT_EQ(callback.GetLastValue(), HAL_ROBOTMODE_TEST); + EXPECT_EQ(callback.GetLastValue(), HAL_ROBOT_MODE_TEST); } TEST(DriverStationTest, Estop) { @@ -125,14 +125,14 @@ TEST(DriverStationTest, AllianceStationId) { EnumCallback callback; - HAL_AllianceStationID allianceStation = HAL_AllianceStationID_kBlue2; + HAL_AllianceStationID allianceStation = HAL_ALLIANCE_STATION_BLUE_2; DriverStationSim::SetAllianceStationId(allianceStation); auto cb = DriverStationSim::RegisterAllianceStationIdCallback( callback.GetCallback(), false); // Unknown - allianceStation = HAL_AllianceStationID_kUnknown; + allianceStation = HAL_ALLIANCE_STATION_UNKNOWN; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); @@ -142,61 +142,61 @@ TEST(DriverStationTest, AllianceStationId) { EXPECT_EQ(allianceStation, callback.GetLastValue()); // B1 - allianceStation = HAL_AllianceStationID_kBlue1; + allianceStation = HAL_ALLIANCE_STATION_BLUE_1; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::BLUE, DriverStation::GetAlliance()); EXPECT_EQ(1, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); // B2 - allianceStation = HAL_AllianceStationID_kBlue2; + allianceStation = HAL_ALLIANCE_STATION_BLUE_2; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::BLUE, DriverStation::GetAlliance()); EXPECT_EQ(2, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); // B3 - allianceStation = HAL_AllianceStationID_kBlue3; + allianceStation = HAL_ALLIANCE_STATION_BLUE_3; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::BLUE, DriverStation::GetAlliance()); EXPECT_EQ(3, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); // R1 - allianceStation = HAL_AllianceStationID_kRed1; + allianceStation = HAL_ALLIANCE_STATION_RED_1; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::RED, DriverStation::GetAlliance()); EXPECT_EQ(1, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); // R2 - allianceStation = HAL_AllianceStationID_kRed2; + allianceStation = HAL_ALLIANCE_STATION_RED_2; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::RED, DriverStation::GetAlliance()); EXPECT_EQ(2, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); // R3 - allianceStation = HAL_AllianceStationID_kRed3; + allianceStation = HAL_ALLIANCE_STATION_RED_3; DriverStationSim::SetAllianceStationId(allianceStation); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId()); - EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance()); + EXPECT_EQ(DriverStation::Alliance::RED, DriverStation::GetAlliance()); EXPECT_EQ(3, DriverStation::GetLocation()); EXPECT_TRUE(callback.WasTriggered()); EXPECT_EQ(allianceStation, callback.GetLastValue()); diff --git a/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c b/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c index fb5acb8e59..cce9c30b7c 100644 --- a/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c +++ b/wpilibcExamples/src/main/cpp/examples/HAL/c/Robot.c @@ -29,7 +29,7 @@ HAL_RobotMode getDSMode(void) { // We send the observes, otherwise the DS disables HAL_ObserveUserProgram(word); return HAL_ControlWord_IsEnabled(word) ? HAL_ControlWord_GetRobotMode(word) - : HAL_ROBOTMODE_UNKNOWN; + : HAL_ROBOT_MODE_UNKNOWN; } int main(void) { @@ -44,19 +44,19 @@ int main(void) { // Create an opmode per robot mode static struct HAL_OpModeOption opmodes[] = { - {HAL_MAKE_OPMODEID(HAL_ROBOTMODE_AUTONOMOUS, 0), + {HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_AUTONOMOUS, 0), {"Auto", 4}, {"", 0}, {"", 0}, -1, -1}, - {HAL_MAKE_OPMODEID(HAL_ROBOTMODE_TELEOPERATED, 0), + {HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_TELEOPERATED, 0), {"Teleop", 6}, {"", 0}, {"", 0}, -1, -1}, - {HAL_MAKE_OPMODEID(HAL_ROBOTMODE_TEST, 0), + {HAL_MAKE_OPMODEID(HAL_ROBOT_MODE_TEST, 0), {"Test", 4}, {"", 0}, {"", 0}, @@ -104,9 +104,9 @@ int main(void) { HAL_RobotMode dsMode = getDSMode(); switch (dsMode) { - case HAL_ROBOTMODE_UNKNOWN: + case HAL_ROBOT_MODE_UNKNOWN: break; - case HAL_ROBOTMODE_TELEOPERATED: + case HAL_ROBOT_MODE_TELEOPERATED: status = 0; if (HAL_GetDIO(dio, &status)) { HAL_SetPWMPulseTimeMicroseconds(pwmPort, 2000, &status); @@ -114,9 +114,9 @@ int main(void) { HAL_SetPWMPulseTimeMicroseconds(pwmPort, 1500, &status); } break; - case HAL_ROBOTMODE_AUTONOMOUS: + case HAL_ROBOT_MODE_AUTONOMOUS: break; - case HAL_ROBOTMODE_TEST: + case HAL_ROBOT_MODE_TEST: break; default: break; diff --git a/wpilibcExamples/src/main/cpp/snippets/DigitalCommunication/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/snippets/DigitalCommunication/cpp/Robot.cpp index 4005704bbf..2dcf3c4a71 100644 --- a/wpilibcExamples/src/main/cpp/snippets/DigitalCommunication/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/snippets/DigitalCommunication/cpp/Robot.cpp @@ -9,7 +9,7 @@ void Robot::RobotPeriodic() { // pull alliance port high if on red alliance, pull low if on blue alliance m_allianceOutput.Set(wpi::DriverStation::GetAlliance() == - wpi::DriverStation::kRed); + wpi::DriverStation::Alliance::RED); // pull enabled port high if enabled, low if disabled m_enabledOutput.Set(wpi::DriverStation::IsEnabled()); diff --git a/wpilibcExamples/src/main/cpp/snippets/I2CCommunication/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/snippets/I2CCommunication/cpp/Robot.cpp index 8bc4e8ae52..46977bdd62 100644 --- a/wpilibcExamples/src/main/cpp/snippets/I2CCommunication/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/snippets/I2CCommunication/cpp/Robot.cpp @@ -25,7 +25,7 @@ void Robot::RobotPeriodic() { std::string allianceString = "U"; auto alliance = wpi::DriverStation::GetAlliance(); if (alliance.has_value()) { - if (alliance == wpi::DriverStation::Alliance::kRed) { + if (alliance == wpi::DriverStation::Alliance::RED) { allianceString = "R"; } else { allianceString = "B"; diff --git a/wpilibcExamples/src/test/cpp/examples/ArmSimulation/cpp/ArmSimulationTest.cpp b/wpilibcExamples/src/test/cpp/examples/ArmSimulation/cpp/ArmSimulationTest.cpp index b27c4a79d8..69c2c1c498 100644 --- a/wpilibcExamples/src/test/cpp/examples/ArmSimulation/cpp/ArmSimulationTest.cpp +++ b/wpilibcExamples/src/test/cpp/examples/ArmSimulation/cpp/ArmSimulationTest.cpp @@ -56,7 +56,7 @@ TEST_P(ArmSimulationTest, Teleop) { // teleop init { - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::SetEnabled(true); wpi::sim::DriverStationSim::NotifyNewData(); diff --git a/wpilibcExamples/src/test/cpp/examples/ElevatorSimulation/cpp/ElevatorSimulationTest.cpp b/wpilibcExamples/src/test/cpp/examples/ElevatorSimulation/cpp/ElevatorSimulationTest.cpp index d939a5707a..fdc95a76d4 100644 --- a/wpilibcExamples/src/test/cpp/examples/ElevatorSimulation/cpp/ElevatorSimulationTest.cpp +++ b/wpilibcExamples/src/test/cpp/examples/ElevatorSimulation/cpp/ElevatorSimulationTest.cpp @@ -52,7 +52,7 @@ class ElevatorSimulationTest : public testing::Test { TEST_F(ElevatorSimulationTest, Teleop) { // teleop init { - wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOTMODE_TELEOPERATED); + wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::SetEnabled(true); wpi::sim::DriverStationSim::NotifyNewData(); diff --git a/wpilibcExamples/src/test/cpp/snippets/DigitalCommunication/cpp/DigitalCommunicationTest.cpp b/wpilibcExamples/src/test/cpp/snippets/DigitalCommunication/cpp/DigitalCommunicationTest.cpp index 432c943b3a..8ddb1e0164 100644 --- a/wpilibcExamples/src/test/cpp/snippets/DigitalCommunication/cpp/DigitalCommunicationTest.cpp +++ b/wpilibcExamples/src/test/cpp/snippets/DigitalCommunication/cpp/DigitalCommunicationTest.cpp @@ -57,15 +57,15 @@ TEST_P(AllianceTest, Alliance) { bool isRed = false; switch (alliance) { - case HAL_AllianceStationID_kBlue1: - case HAL_AllianceStationID_kBlue2: - case HAL_AllianceStationID_kBlue3: - case HAL_AllianceStationID_kUnknown: + case HAL_ALLIANCE_STATION_BLUE_1: + case HAL_ALLIANCE_STATION_BLUE_2: + case HAL_ALLIANCE_STATION_BLUE_3: + case HAL_ALLIANCE_STATION_UNKNOWN: isRed = false; break; - case HAL_AllianceStationID_kRed1: - case HAL_AllianceStationID_kRed2: - case HAL_AllianceStationID_kRed3: + case HAL_ALLIANCE_STATION_RED_1: + case HAL_ALLIANCE_STATION_RED_2: + case HAL_ALLIANCE_STATION_RED_3: isRed = true; break; } @@ -75,25 +75,25 @@ TEST_P(AllianceTest, Alliance) { INSTANTIATE_TEST_SUITE_P( DigitalCommunicationTests, AllianceTest, testing::Values( - HAL_AllianceStationID_kRed1, HAL_AllianceStationID_kRed2, - HAL_AllianceStationID_kRed3, HAL_AllianceStationID_kBlue1, - HAL_AllianceStationID_kBlue2, HAL_AllianceStationID_kBlue3, - HAL_AllianceStationID_kUnknown), + HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2, + HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1, + HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3, + HAL_ALLIANCE_STATION_UNKNOWN), [](const testing::TestParamInfo& info) { switch (info.param) { - case HAL_AllianceStationID_kBlue1: + case HAL_ALLIANCE_STATION_BLUE_1: return std::string{"Blue1"}; - case HAL_AllianceStationID_kBlue2: + case HAL_ALLIANCE_STATION_BLUE_2: return std::string{"Blue2"}; - case HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_BLUE_3: return std::string{"Blue3"}; - case HAL_AllianceStationID_kRed1: + case HAL_ALLIANCE_STATION_RED_1: return std::string{"Red1"}; - case HAL_AllianceStationID_kRed2: + case HAL_ALLIANCE_STATION_RED_2: return std::string{"Red2"}; - case HAL_AllianceStationID_kRed3: + case HAL_ALLIANCE_STATION_RED_3: return std::string{"Red3"}; - case HAL_AllianceStationID_kUnknown: + case HAL_ALLIANCE_STATION_UNKNOWN: return std::string{"Unknown"}; } return std::string{"Error"}; @@ -122,7 +122,7 @@ class AutonomousTest : public DigitalCommunicationTest {}; TEST_P(AutonomousTest, Autonomous) { auto autonomous = GetParam(); wpi::sim::DriverStationSim::SetRobotMode( - autonomous ? HAL_ROBOTMODE_AUTONOMOUS : HAL_ROBOTMODE_TELEOPERATED); + autonomous ? HAL_ROBOT_MODE_AUTONOMOUS : HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_TRUE(m_autonomousOutput.GetInitialized()); diff --git a/wpilibcExamples/src/test/cpp/snippets/I2CCommunication/cpp/I2CCommunicationTest.cpp b/wpilibcExamples/src/test/cpp/snippets/I2CCommunication/cpp/I2CCommunicationTest.cpp index b03ae5bf3d..e4ee455067 100644 --- a/wpilibcExamples/src/test/cpp/snippets/I2CCommunication/cpp/I2CCommunicationTest.cpp +++ b/wpilibcExamples/src/test/cpp/snippets/I2CCommunication/cpp/I2CCommunicationTest.cpp @@ -65,17 +65,17 @@ TEST_P(AllianceTest, Alliance) { char expected = 'U'; switch (alliance) { - case HAL_AllianceStationID_kBlue1: - case HAL_AllianceStationID_kBlue2: - case HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_BLUE_1: + case HAL_ALLIANCE_STATION_BLUE_2: + case HAL_ALLIANCE_STATION_BLUE_3: expected = 'B'; break; - case HAL_AllianceStationID_kRed1: - case HAL_AllianceStationID_kRed2: - case HAL_AllianceStationID_kRed3: + case HAL_ALLIANCE_STATION_RED_1: + case HAL_ALLIANCE_STATION_RED_2: + case HAL_ALLIANCE_STATION_RED_3: expected = 'R'; break; - case HAL_AllianceStationID_kUnknown: + case HAL_ALLIANCE_STATION_UNKNOWN: expected = 'U'; break; } @@ -85,25 +85,25 @@ TEST_P(AllianceTest, Alliance) { INSTANTIATE_TEST_SUITE_P( I2CCommunicationTests, AllianceTest, testing::Values( - HAL_AllianceStationID_kRed1, HAL_AllianceStationID_kRed2, - HAL_AllianceStationID_kRed3, HAL_AllianceStationID_kBlue1, - HAL_AllianceStationID_kBlue2, HAL_AllianceStationID_kBlue3, - HAL_AllianceStationID_kUnknown), + HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2, + HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1, + HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3, + HAL_ALLIANCE_STATION_UNKNOWN), [](const testing::TestParamInfo& info) { switch (info.param) { - case HAL_AllianceStationID_kBlue1: + case HAL_ALLIANCE_STATION_BLUE_1: return std::string{"Blue1"}; - case HAL_AllianceStationID_kBlue2: + case HAL_ALLIANCE_STATION_BLUE_2: return std::string{"Blue2"}; - case HAL_AllianceStationID_kBlue3: + case HAL_ALLIANCE_STATION_BLUE_3: return std::string{"Blue3"}; - case HAL_AllianceStationID_kRed1: + case HAL_ALLIANCE_STATION_RED_1: return std::string{"Red1"}; - case HAL_AllianceStationID_kRed2: + case HAL_ALLIANCE_STATION_RED_2: return std::string{"Red2"}; - case HAL_AllianceStationID_kRed3: + case HAL_ALLIANCE_STATION_RED_3: return std::string{"Red3"}; - case HAL_AllianceStationID_kUnknown: + case HAL_ALLIANCE_STATION_UNKNOWN: return std::string{"Unknown"}; } return std::string{"Error"}; @@ -132,7 +132,7 @@ class AutonomousTest : public I2CCommunicationTest {}; TEST_P(AutonomousTest, Autonomous) { auto autonomous = GetParam(); wpi::sim::DriverStationSim::SetRobotMode( - autonomous ? HAL_ROBOTMODE_AUTONOMOUS : HAL_ROBOTMODE_TELEOPERATED); + autonomous ? HAL_ROBOT_MODE_AUTONOMOUS : HAL_ROBOT_MODE_TELEOPERATED); wpi::sim::DriverStationSim::NotifyNewData(); EXPECT_TRUE(HALSIM_GetI2CInitialized(m_port)); diff --git a/wpilibj/src/main/java/org/wpilib/driverstation/DriverStation.java b/wpilibj/src/main/java/org/wpilib/driverstation/DriverStation.java index efee531d3b..9d787ca818 100644 --- a/wpilibj/src/main/java/org/wpilib/driverstation/DriverStation.java +++ b/wpilibj/src/main/java/org/wpilib/driverstation/DriverStation.java @@ -67,7 +67,7 @@ public final class DriverStation { private static class HALJoystickTouchpad { public final HALJoystickTouchpadFinger[] m_fingers = - new HALJoystickTouchpadFinger[DriverStationJNI.kMaxJoystickTouchpadFingers]; + new HALJoystickTouchpadFinger[DriverStationJNI.MAX_JOYSTICK_TOUCHPAD_FINGERS]; public int m_count; HALJoystickTouchpad() { @@ -79,7 +79,7 @@ public final class DriverStation { private static class HALJoystickTouchpads { public final HALJoystickTouchpad[] m_touchpads = - new HALJoystickTouchpad[DriverStationJNI.kMaxJoystickTouchpads]; + new HALJoystickTouchpad[DriverStationJNI.MAX_JOYSTICK_TOUCHPADS]; public int m_count; HALJoystickTouchpads() { @@ -129,21 +129,21 @@ public final class DriverStation { /** The robot alliance that the robot is a part of. */ public enum Alliance { /** Red alliance. */ - Red, + RED, /** Blue alliance. */ - Blue + BLUE } /** The type of robot match that the robot is part of. */ public enum MatchType { /** None. */ - None, + NONE, /** Practice. */ - Practice, + PRACTICE, /** Qualification. */ - Qualification, + QUALIFICATION, /** Elimination. */ - Elimination + ELIMINATION } /** Represents a finger on a touchpad. */ @@ -175,23 +175,23 @@ public final class DriverStation { /** A controller POV direction. */ public enum POVDirection { /** POV center. */ - Center(0x00), + CENTER(0x00), /** POV up. */ - Up(0x01), + UP(0x01), /** POV up right. */ - UpRight(0x01 | 0x02), + UP_RIGHT(0x01 | 0x02), /** POV right. */ - Right(0x02), + RIGHT(0x02), /** POV down right. */ - DownRight(0x02 | 0x04), + DOWN_RIGHT(0x02 | 0x04), /** POV down. */ - Down(0x04), + DOWN(0x04), /** POV down left. */ - DownLeft(0x04 | 0x08), + DOWN_LEFT(0x04 | 0x08), /** POV left. */ - Left(0x08), + LEFT(0x08), /** POV up left. */ - UpLeft(0x01 | 0x08); + UP_LEFT(0x01 | 0x08); private static final double INVALID_POV_VALUE_INTERVAL = 1.0; private static double s_nextMessageTime; @@ -214,7 +214,7 @@ public final class DriverStation { reportError("Invalid POV value " + value + "!", false); s_nextMessageTime = currentTime + INVALID_POV_VALUE_INTERVAL; } - return Center; + return CENTER; } /** The corresponding HAL value. */ @@ -232,15 +232,15 @@ public final class DriverStation { */ public Optional getAngle() { return switch (this) { - case Center -> Optional.empty(); - case Up -> Optional.of(Rotation2d.fromDegrees(0)); - case UpRight -> Optional.of(Rotation2d.fromDegrees(45)); - case Right -> Optional.of(Rotation2d.fromDegrees(90)); - case DownRight -> Optional.of(Rotation2d.fromDegrees(135)); - case Down -> Optional.of(Rotation2d.fromDegrees(180)); - case DownLeft -> Optional.of(Rotation2d.fromDegrees(225)); - case Left -> Optional.of(Rotation2d.fromDegrees(270)); - case UpLeft -> Optional.of(Rotation2d.fromDegrees(315)); + case CENTER -> Optional.empty(); + case UP -> Optional.of(Rotation2d.fromDegrees(0)); + case UP_RIGHT -> Optional.of(Rotation2d.fromDegrees(45)); + case RIGHT -> Optional.of(Rotation2d.fromDegrees(90)); + case DOWN_RIGHT -> Optional.of(Rotation2d.fromDegrees(135)); + case DOWN -> Optional.of(Rotation2d.fromDegrees(180)); + case DOWN_LEFT -> Optional.of(Rotation2d.fromDegrees(225)); + case LEFT -> Optional.of(Rotation2d.fromDegrees(270)); + case UP_LEFT -> Optional.of(Rotation2d.fromDegrees(315)); }; } } @@ -319,14 +319,14 @@ public final class DriverStation { AllianceStationID allianceID = DriverStationJNI.getAllianceStation(); final int stationNumber = switch (allianceID) { - case Blue1, Red1 -> 1; - case Blue2, Red2 -> 2; - case Blue3, Red3, Unknown -> 3; + case BLUE_1, RED_1 -> 1; + case BLUE_2, RED_2 -> 2; + case BLUE_3, RED_3, UNKNOWN -> 3; }; final boolean isRedAlliance = switch (allianceID) { - case Blue1, Blue2, Blue3 -> false; - case Red1, Red2, Red3, Unknown -> true; + case BLUE_1, BLUE_2, BLUE_3 -> false; + case RED_1, RED_2, RED_3, UNKNOWN -> true; }; String currentEventName; @@ -483,8 +483,8 @@ public final class DriverStation { float[] m_sizedAxes; long[] m_sizedPOVs; final HALJoystickButtons m_prevButtons = new HALJoystickButtons(); - final HALJoystickAxes m_prevAxes = new HALJoystickAxes(DriverStationJNI.kMaxJoystickAxes); - final HALJoystickPOVs m_prevPOVs = new HALJoystickPOVs(DriverStationJNI.kMaxJoystickPOVs); + final HALJoystickAxes m_prevAxes = new HALJoystickAxes(DriverStationJNI.MAX_JOYSTICK_AXES); + final HALJoystickPOVs m_prevPOVs = new HALJoystickPOVs(DriverStationJNI.MAX_JOYSTICK_POVS); final BooleanArrayLogEntry m_logButtons; final FloatArrayLogEntry m_logAxes; final IntegerArrayLogEntry m_logPOVs; @@ -594,15 +594,15 @@ public final class DriverStation { for (int i = 0; i < kJoystickPorts; i++) { m_joystickButtons[i] = new HALJoystickButtons(); - m_joystickAxes[i] = new HALJoystickAxes(DriverStationJNI.kMaxJoystickAxes); - m_joystickAxesRaw[i] = new HALJoystickAxesRaw(DriverStationJNI.kMaxJoystickAxes); - m_joystickPOVs[i] = new HALJoystickPOVs(DriverStationJNI.kMaxJoystickPOVs); + m_joystickAxes[i] = new HALJoystickAxes(DriverStationJNI.MAX_JOYSTICK_AXES); + m_joystickAxesRaw[i] = new HALJoystickAxesRaw(DriverStationJNI.MAX_JOYSTICK_AXES); + m_joystickPOVs[i] = new HALJoystickPOVs(DriverStationJNI.MAX_JOYSTICK_POVS); m_joystickTouchpads[i] = new HALJoystickTouchpads(); m_joystickButtonsCache[i] = new HALJoystickButtons(); - m_joystickAxesCache[i] = new HALJoystickAxes(DriverStationJNI.kMaxJoystickAxes); - m_joystickAxesRawCache[i] = new HALJoystickAxesRaw(DriverStationJNI.kMaxJoystickAxes); - m_joystickPOVsCache[i] = new HALJoystickPOVs(DriverStationJNI.kMaxJoystickPOVs); + m_joystickAxesCache[i] = new HALJoystickAxes(DriverStationJNI.MAX_JOYSTICK_AXES); + m_joystickAxesRawCache[i] = new HALJoystickAxesRaw(DriverStationJNI.MAX_JOYSTICK_AXES); + m_joystickPOVsCache[i] = new HALJoystickPOVs(DriverStationJNI.MAX_JOYSTICK_POVS); m_joystickTouchpadsCache[i] = new HALJoystickTouchpads(); } @@ -699,7 +699,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) { + if (button < 0 || button >= DriverStationJNI.MAX_JOYSTICK_BUTTONS) { throw new IllegalArgumentException("Joystick Button is out of range"); } @@ -730,7 +730,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) { + if (button < 0 || button >= DriverStationJNI.MAX_JOYSTICK_BUTTONS) { throw new IllegalArgumentException("Joystick Button is out of range"); } @@ -758,7 +758,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) { + if (button < 0 || button >= DriverStationJNI.MAX_JOYSTICK_BUTTONS) { throw new IllegalArgumentException("Joystick Button is out of range"); } @@ -795,7 +795,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (button < 0 || button >= DriverStationJNI.kMaxJoystickButtons) { + if (button < 0 || button >= DriverStationJNI.MAX_JOYSTICK_BUTTONS) { throw new IllegalArgumentException("Joystick Button is out of range"); } @@ -833,7 +833,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (axis < 0 || axis >= DriverStationJNI.kMaxJoystickAxes) { + if (axis < 0 || axis >= DriverStationJNI.MAX_JOYSTICK_AXES) { throw new IllegalArgumentException("Joystick axis is out of range"); } @@ -864,10 +864,10 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (touchpad < 0 || touchpad >= DriverStationJNI.kMaxJoystickTouchpads) { + if (touchpad < 0 || touchpad >= DriverStationJNI.MAX_JOYSTICK_TOUCHPADS) { throw new IllegalArgumentException("Joystick touchpad is out of range"); } - if (finger < 0 || finger >= DriverStationJNI.kMaxJoystickTouchpadFingers) { + if (finger < 0 || finger >= DriverStationJNI.MAX_JOYSTICK_TOUCHPAD_FINGERS) { throw new IllegalArgumentException("Joystick touchpad finger is out of range"); } @@ -910,10 +910,10 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (touchpad < 0 || touchpad >= DriverStationJNI.kMaxJoystickTouchpads) { + if (touchpad < 0 || touchpad >= DriverStationJNI.MAX_JOYSTICK_TOUCHPADS) { throw new IllegalArgumentException("Joystick touchpad is out of range"); } - if (finger < 0 || finger >= DriverStationJNI.kMaxJoystickTouchpadFingers) { + if (finger < 0 || finger >= DriverStationJNI.MAX_JOYSTICK_TOUCHPAD_FINGERS) { throw new IllegalArgumentException("Joystick touchpad finger is out of range"); } @@ -946,7 +946,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (axis < 0 || axis >= DriverStationJNI.kMaxJoystickAxes) { + if (axis < 0 || axis >= DriverStationJNI.MAX_JOYSTICK_AXES) { throw new IllegalArgumentException("Joystick axis is out of range"); } @@ -975,7 +975,7 @@ public final class DriverStation { if (stick < 0 || stick >= kJoystickPorts) { throw new IllegalArgumentException("Joystick index is out of range, should be 0-5"); } - if (pov < 0 || pov >= DriverStationJNI.kMaxJoystickPOVs) { + if (pov < 0 || pov >= DriverStationJNI.MAX_JOYSTICK_POVS) { throw new IllegalArgumentException("Joystick POV is out of range"); } @@ -991,7 +991,7 @@ public final class DriverStation { } reportJoystickWarning(stick, "Joystick POV " + pov + " on port " + stick + " not available"); - return POVDirection.Center; + return POVDirection.CENTER; } /** @@ -1602,10 +1602,10 @@ public final class DriverStation { m_cacheDataMutex.unlock(); } return switch (matchType) { - case 1 -> MatchType.Practice; - case 2 -> MatchType.Qualification; - case 3 -> MatchType.Elimination; - default -> MatchType.None; + case 1 -> MatchType.PRACTICE; + case 2 -> MatchType.QUALIFICATION; + case 3 -> MatchType.ELIMINATION; + default -> MatchType.NONE; }; } @@ -1639,23 +1639,23 @@ public final class DriverStation { private static Map> m_allianceMap = Map.of( - AllianceStationID.Unknown, Optional.empty(), - AllianceStationID.Red1, Optional.of(Alliance.Red), - AllianceStationID.Red2, Optional.of(Alliance.Red), - AllianceStationID.Red3, Optional.of(Alliance.Red), - AllianceStationID.Blue1, Optional.of(Alliance.Blue), - AllianceStationID.Blue2, Optional.of(Alliance.Blue), - AllianceStationID.Blue3, Optional.of(Alliance.Blue)); + AllianceStationID.UNKNOWN, Optional.empty(), + AllianceStationID.RED_1, Optional.of(Alliance.RED), + AllianceStationID.RED_2, Optional.of(Alliance.RED), + AllianceStationID.RED_3, Optional.of(Alliance.RED), + AllianceStationID.BLUE_1, Optional.of(Alliance.BLUE), + AllianceStationID.BLUE_2, Optional.of(Alliance.BLUE), + AllianceStationID.BLUE_3, Optional.of(Alliance.BLUE)); private static Map m_stationMap = Map.of( - AllianceStationID.Unknown, OptionalInt.empty(), - AllianceStationID.Red1, OptionalInt.of(1), - AllianceStationID.Red2, OptionalInt.of(2), - AllianceStationID.Red3, OptionalInt.of(3), - AllianceStationID.Blue1, OptionalInt.of(1), - AllianceStationID.Blue2, OptionalInt.of(2), - AllianceStationID.Blue3, OptionalInt.of(3)); + AllianceStationID.UNKNOWN, OptionalInt.empty(), + AllianceStationID.RED_1, OptionalInt.of(1), + AllianceStationID.RED_2, OptionalInt.of(2), + AllianceStationID.RED_3, OptionalInt.of(3), + AllianceStationID.BLUE_1, OptionalInt.of(1), + AllianceStationID.BLUE_2, OptionalInt.of(2), + AllianceStationID.BLUE_3, OptionalInt.of(3)); /** * Get the current alliance from the FMS. @@ -1667,7 +1667,7 @@ public final class DriverStation { public static Optional getAlliance() { AllianceStationID allianceStationID = DriverStationJNI.getAllianceStation(); if (allianceStationID == null) { - allianceStationID = AllianceStationID.Unknown; + allianceStationID = AllianceStationID.UNKNOWN; } return m_allianceMap.get(allianceStationID); @@ -1683,7 +1683,7 @@ public final class DriverStation { public static OptionalInt getLocation() { AllianceStationID allianceStationID = DriverStationJNI.getAllianceStation(); if (allianceStationID == null) { - allianceStationID = AllianceStationID.Unknown; + allianceStationID = AllianceStationID.UNKNOWN; } return m_stationMap.get(allianceStationID); diff --git a/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java b/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java index 2f63a1026e..afee0c9185 100644 --- a/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java +++ b/wpilibj/src/main/java/org/wpilib/driverstation/GenericHID.java @@ -228,7 +228,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the up direction a POV on the HID. */ public BooleanEvent povUp(EventLoop loop) { - return pov(POVDirection.Up, loop); + return pov(POVDirection.UP, loop); } /** @@ -239,7 +239,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the up right direction of a POV on the HID. */ public BooleanEvent povUpRight(EventLoop loop) { - return pov(POVDirection.UpRight, loop); + return pov(POVDirection.UP_RIGHT, loop); } /** @@ -250,7 +250,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the right direction of a POV on the HID. */ public BooleanEvent povRight(EventLoop loop) { - return pov(POVDirection.Right, loop); + return pov(POVDirection.RIGHT, loop); } /** @@ -261,7 +261,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the down right direction of a POV on the HID. */ public BooleanEvent povDownRight(EventLoop loop) { - return pov(POVDirection.DownRight, loop); + return pov(POVDirection.DOWN_RIGHT, loop); } /** @@ -272,7 +272,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the down direction of a POV on the HID. */ public BooleanEvent povDown(EventLoop loop) { - return pov(POVDirection.Down, loop); + return pov(POVDirection.DOWN, loop); } /** @@ -283,7 +283,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the down left direction of a POV on the HID. */ public BooleanEvent povDownLeft(EventLoop loop) { - return pov(POVDirection.DownLeft, loop); + return pov(POVDirection.DOWN_LEFT, loop); } /** @@ -294,7 +294,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the left direction of a POV on the HID. */ public BooleanEvent povLeft(EventLoop loop) { - return pov(POVDirection.Left, loop); + return pov(POVDirection.LEFT, loop); } /** @@ -305,7 +305,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the up left direction of a POV on the HID. */ public BooleanEvent povUpLeft(EventLoop loop) { - return pov(POVDirection.UpLeft, loop); + return pov(POVDirection.UP_LEFT, loop); } /** @@ -316,7 +316,7 @@ public class GenericHID { * @return a BooleanEvent instance based around the center of a POV on the HID. */ public BooleanEvent povCenter(EventLoop loop) { - return pov(POVDirection.Center, loop); + return pov(POVDirection.CENTER, loop); } /** diff --git a/wpilibj/src/main/java/org/wpilib/simulation/DriverStationSim.java b/wpilibj/src/main/java/org/wpilib/simulation/DriverStationSim.java index 00562c255b..3c7fac77d1 100644 --- a/wpilibj/src/main/java/org/wpilib/simulation/DriverStationSim.java +++ b/wpilibj/src/main/java/org/wpilib/simulation/DriverStationSim.java @@ -195,14 +195,14 @@ public final class DriverStationSim { */ public static AllianceStationID getAllianceStationId() { return switch (DriverStationDataJNI.getAllianceStationId()) { - case DriverStationJNI.kUnknownAllianceStation -> AllianceStationID.Unknown; - case DriverStationJNI.kRed1AllianceStation -> AllianceStationID.Red1; - case DriverStationJNI.kRed2AllianceStation -> AllianceStationID.Red2; - case DriverStationJNI.kRed3AllianceStation -> AllianceStationID.Red3; - case DriverStationJNI.kBlue1AllianceStation -> AllianceStationID.Blue1; - case DriverStationJNI.kBlue2AllianceStation -> AllianceStationID.Blue2; - case DriverStationJNI.kBlue3AllianceStation -> AllianceStationID.Blue3; - default -> AllianceStationID.Unknown; + case DriverStationJNI.ALLIANCE_STATION_UNKNOWN -> AllianceStationID.UNKNOWN; + case DriverStationJNI.ALLIANCE_STATION_RED_1 -> AllianceStationID.RED_1; + case DriverStationJNI.ALLIANCE_STATION_RED_2 -> AllianceStationID.RED_2; + case DriverStationJNI.ALLIANCE_STATION_RED_3 -> AllianceStationID.RED_3; + case DriverStationJNI.ALLIANCE_STATION_BLUE_1 -> AllianceStationID.BLUE_1; + case DriverStationJNI.ALLIANCE_STATION_BLUE_2 -> AllianceStationID.BLUE_2; + case DriverStationJNI.ALLIANCE_STATION_BLUE_3 -> AllianceStationID.BLUE_3; + default -> AllianceStationID.UNKNOWN; }; } @@ -214,13 +214,13 @@ public final class DriverStationSim { public static void setAllianceStationId(AllianceStationID allianceStationId) { int allianceStation = switch (allianceStationId) { - case Unknown -> DriverStationJNI.kUnknownAllianceStation; - case Red1 -> DriverStationJNI.kRed1AllianceStation; - case Red2 -> DriverStationJNI.kRed2AllianceStation; - case Red3 -> DriverStationJNI.kRed3AllianceStation; - case Blue1 -> DriverStationJNI.kBlue1AllianceStation; - case Blue2 -> DriverStationJNI.kBlue2AllianceStation; - case Blue3 -> DriverStationJNI.kBlue3AllianceStation; + case UNKNOWN -> DriverStationJNI.ALLIANCE_STATION_UNKNOWN; + case RED_1 -> DriverStationJNI.ALLIANCE_STATION_RED_1; + case RED_2 -> DriverStationJNI.ALLIANCE_STATION_RED_2; + case RED_3 -> DriverStationJNI.ALLIANCE_STATION_RED_3; + case BLUE_1 -> DriverStationJNI.ALLIANCE_STATION_BLUE_1; + case BLUE_2 -> DriverStationJNI.ALLIANCE_STATION_BLUE_2; + case BLUE_3 -> DriverStationJNI.ALLIANCE_STATION_BLUE_3; }; DriverStationDataJNI.setAllianceStationId(allianceStation); } @@ -526,10 +526,10 @@ public final class DriverStationSim { public static void setMatchType(DriverStation.MatchType type) { int matchType = switch (type) { - case Practice -> 1; - case Qualification -> 2; - case Elimination -> 3; - case None -> 0; + case PRACTICE -> 1; + case QUALIFICATION -> 2; + case ELIMINATION -> 3; + case NONE -> 0; }; DriverStationDataJNI.setMatchType(matchType); } diff --git a/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java b/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java index 21b8b20fbf..027325a122 100644 --- a/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java +++ b/wpilibj/src/main/java/org/wpilib/system/DataLogManager.java @@ -417,13 +417,13 @@ public final class DataLogManager { // match info comes through TCP, so we need to double-check we've // actually received it DriverStation.MatchType matchType = DriverStation.getMatchType(); - if (matchType != DriverStation.MatchType.None) { + if (matchType != DriverStation.MatchType.NONE) { // rename per match info char matchTypeChar = switch (matchType) { - case Practice -> 'P'; - case Qualification -> 'Q'; - case Elimination -> 'E'; + case PRACTICE -> 'P'; + case QUALIFICATION -> 'Q'; + case ELIMINATION -> 'E'; default -> '_'; }; m_log.setFilename( diff --git a/wpilibj/src/test/java/org/wpilib/hal/MatchInfoDataTest.java b/wpilibj/src/test/java/org/wpilib/hal/MatchInfoDataTest.java index 2e2309ab1e..21df648a4a 100644 --- a/wpilibj/src/test/java/org/wpilib/hal/MatchInfoDataTest.java +++ b/wpilibj/src/test/java/org/wpilib/hal/MatchInfoDataTest.java @@ -17,7 +17,7 @@ import org.wpilib.simulation.DriverStationSim; class MatchInfoDataTest { @Test void testSetMatchInfo() { - MatchType matchType = MatchType.Qualification; + MatchType matchType = MatchType.QUALIFICATION; DriverStationDataJNI.setMatchInfo("Event Name", 174, 191, matchType.ordinal()); DriverStationSim.notifyNewData(); diff --git a/wpilibj/src/test/java/org/wpilib/simulation/DriverStationSimTest.java b/wpilibj/src/test/java/org/wpilib/simulation/DriverStationSimTest.java index 575bef9139..7ccc6c3360 100644 --- a/wpilibj/src/test/java/org/wpilib/simulation/DriverStationSimTest.java +++ b/wpilibj/src/test/java/org/wpilib/simulation/DriverStationSimTest.java @@ -137,12 +137,12 @@ class DriverStationSimTest { EnumCallback callback = new EnumCallback(); - AllianceStationID allianceStation = AllianceStationID.Blue2; + AllianceStationID allianceStation = AllianceStationID.BLUE_2; DriverStationSim.setAllianceStationId(allianceStation); try (CallbackStore cb = DriverStationSim.registerAllianceStationIdCallback(callback, false)) { // Unknown - allianceStation = AllianceStationID.Unknown; + allianceStation = AllianceStationID.UNKNOWN; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); @@ -152,61 +152,61 @@ class DriverStationSimTest { assertEquals(allianceStation.ordinal(), callback.getSetValue()); // B1 - allianceStation = AllianceStationID.Blue1; + allianceStation = AllianceStationID.BLUE_1; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Blue, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.BLUE, DriverStation.getAlliance().get()); assertEquals(1, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); // B2 - allianceStation = AllianceStationID.Blue2; + allianceStation = AllianceStationID.BLUE_2; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Blue, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.BLUE, DriverStation.getAlliance().get()); assertEquals(2, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); // B3 - allianceStation = AllianceStationID.Blue3; + allianceStation = AllianceStationID.BLUE_3; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Blue, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.BLUE, DriverStation.getAlliance().get()); assertEquals(3, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); // R1 - allianceStation = AllianceStationID.Red1; + allianceStation = AllianceStationID.RED_1; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Red, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.RED, DriverStation.getAlliance().get()); assertEquals(1, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); // R2 - allianceStation = AllianceStationID.Red2; + allianceStation = AllianceStationID.RED_2; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Red, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.RED, DriverStation.getAlliance().get()); assertEquals(2, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); // R3 - allianceStation = AllianceStationID.Red3; + allianceStation = AllianceStationID.RED_3; DriverStationSim.setAllianceStationId(allianceStation); DriverStationSim.notifyNewData(); assertEquals(allianceStation, DriverStationSim.getAllianceStationId()); - assertEquals(DriverStation.Alliance.Red, DriverStation.getAlliance().get()); + assertEquals(DriverStation.Alliance.RED, DriverStation.getAlliance().get()); assertEquals(3, DriverStation.getLocation().getAsInt()); assertTrue(callback.wasTriggered()); assertEquals(allianceStation.ordinal(), callback.getSetValue()); diff --git a/wpilibjExamples/src/main/java/org/wpilib/snippets/digitalcommunication/Robot.java b/wpilibjExamples/src/main/java/org/wpilib/snippets/digitalcommunication/Robot.java index 3f460065ba..e1d7867ab4 100644 --- a/wpilibjExamples/src/main/java/org/wpilib/snippets/digitalcommunication/Robot.java +++ b/wpilibjExamples/src/main/java/org/wpilib/snippets/digitalcommunication/Robot.java @@ -30,7 +30,7 @@ public class Robot extends TimedRobot { boolean setAlliance = false; Optional alliance = DriverStation.getAlliance(); if (alliance.isPresent()) { - setAlliance = alliance.get() == DriverStation.Alliance.Red; + setAlliance = alliance.get() == DriverStation.Alliance.RED; } // pull alliance port high if on red alliance, pull low if on blue alliance diff --git a/wpilibjExamples/src/main/java/org/wpilib/snippets/i2ccommunication/Robot.java b/wpilibjExamples/src/main/java/org/wpilib/snippets/i2ccommunication/Robot.java index 9ebac234d6..ae2618fdcc 100644 --- a/wpilibjExamples/src/main/java/org/wpilib/snippets/i2ccommunication/Robot.java +++ b/wpilibjExamples/src/main/java/org/wpilib/snippets/i2ccommunication/Robot.java @@ -53,7 +53,7 @@ public class Robot extends TimedRobot { String allianceString = "U"; Optional alliance = DriverStation.getAlliance(); if (alliance.isPresent()) { - allianceString = alliance.get() == DriverStation.Alliance.Red ? "R" : "B"; + allianceString = alliance.get() == DriverStation.Alliance.RED ? "R" : "B"; } stateMessage diff --git a/wpilibjExamples/src/test/java/org/wpilib/snippets/digitalcommunication/DigitalCommunicationTest.java b/wpilibjExamples/src/test/java/org/wpilib/snippets/digitalcommunication/DigitalCommunicationTest.java index af4f6348da..51051b649f 100644 --- a/wpilibjExamples/src/test/java/org/wpilib/snippets/digitalcommunication/DigitalCommunicationTest.java +++ b/wpilibjExamples/src/test/java/org/wpilib/snippets/digitalcommunication/DigitalCommunicationTest.java @@ -69,7 +69,7 @@ class DigitalCommunicationTest { SimHooks.stepTiming(0.02); - assertEquals(alliance.name().startsWith("Red"), m_allianceOutput.getValue()); + assertEquals(alliance.name().startsWith("RED"), m_allianceOutput.getValue()); } @ValueSource(booleans = {true, false}) diff --git a/wpilibjExamples/src/test/java/org/wpilib/snippets/i2ccommunication/I2CCommunicationTest.java b/wpilibjExamples/src/test/java/org/wpilib/snippets/i2ccommunication/I2CCommunicationTest.java index efeed7923b..7e6d36d17c 100644 --- a/wpilibjExamples/src/test/java/org/wpilib/snippets/i2ccommunication/I2CCommunicationTest.java +++ b/wpilibjExamples/src/test/java/org/wpilib/snippets/i2ccommunication/I2CCommunicationTest.java @@ -76,8 +76,8 @@ class I2CCommunicationTest { SimHooks.stepTiming(0.02); String str = assertTimeoutPreemptively(Duration.ofMillis(20L), () -> m_future.get()); - char expected = alliance.name().startsWith("Red") ? 'R' : 'B'; - if (alliance.name().startsWith("Unknown")) { + char expected = alliance.name().startsWith("RED") ? 'R' : 'B'; + if (alliance.name().startsWith("UNKNOWN")) { expected = 'U'; }