-
Notifications
You must be signed in to change notification settings - Fork 3
updated to work with new contract2025.java containing new electrical … #613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…information and reports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the electrical contract infrastructure to support new electrical information and reporting capabilities. It adds power source tracking for devices and PDH port assignments for motor controllers, along with refactoring the CANBusId naming convention.
Changes:
- Added PowerSource and PDHPort enums for tracking electrical connections
- Extended DeviceInfo, IMUInfo, and CANMotorControllerInfo with new fields (powerFrom, pdhPort) while maintaining backward compatibility
- Renamed CANBusId.DefaultCanivore to CANBusId.Canivore for clarity
- Added CAN interface type to XGyro enum
- Updated all test files to use new constructor signatures with null values for new parameters
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| PowerSource.java | New enum defining power sources including PDH ports, Pneumatic Hub ports, VRM outputs, and other sources |
| PDHPort.java | New enum representing PDH ports 0-19 with helper methods |
| DeviceInfo.java | Added powerFrom field and multiple new constructors maintaining backward compatibility |
| IMUInfo.java | Added powerFrom field to record with backward-compatible constructors |
| CANMotorControllerInfo.java | Added pdhPort field to record with backward-compatible constructors |
| CANBusId.java | Renamed DefaultCanivore constant to Canivore |
| XGyro.java | Added CAN interface type to InterfaceType enum |
| SimulatedMockAbsoluteEncoderTest.java | Updated DeviceInfo constructor call to include null for powerFrom |
| TestAllFactoryClasses.java | Updated DeviceInfo and CANBusId references to match new signatures |
| DutyCycleEncoderTest.java | Updated DeviceInfo constructor call to include null for powerFrom |
| DigitalInputTest.java | Updated DeviceInfo constructor calls to include null for powerFrom |
| CANMotorControllerTest.java | Updated CANBusId references from DefaultCanivore to Canivore |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Includes PDH ports (0-19) and VRM1 outputs. | ||
| */ | ||
| public enum PowerSource { | ||
| // PDH Ports (Power Distribution Hub) |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PowerSource enum includes PDH00-PDH23 entries (lines 9-11), which appears to duplicate the PDHPort enum that was also added in this PR. This creates redundancy and potential confusion about when to use PowerSource.PDH00 versus PDHPort.PDH00. Consider whether PDH ports should only exist in the PDHPort enum, and PowerSource should reference PDHPort instead of duplicating these values. Alternatively, if there's a valid reason for this duplication, it should be documented.
| * Includes PDH ports (0-19) and VRM1 outputs. | |
| */ | |
| public enum PowerSource { | |
| // PDH Ports (Power Distribution Hub) | |
| * <p> | |
| * This enum includes: | |
| * <ul> | |
| * <li>PDH ports (0-23), which conceptually mirror the entries in the {@code PDHPort} enum,</li> | |
| * <li>Pneumatic Hub solenoid ports,</li> | |
| * <li>VRM outputs, and other logical power sources.</li> | |
| * </ul> | |
| * <p> | |
| * Use {@code PDHPort} when you need to refer to a physical PDH port (e.g., for wiring or | |
| * configuration of the Power Distribution Hub itself). Use {@code PowerSource} when you need | |
| * to describe the logical power source of a device within the electrical contract. The PDH | |
| * entries are duplicated here intentionally for that purpose and for backward compatibility. | |
| */ | |
| public enum PowerSource { | |
| // PDH Ports (Power Distribution Hub) | |
| // These entries mirror the PDHPort enum. Prefer PDHPort when directly addressing PDH | |
| // hardware ports, and use PowerSource.PDHxx when specifying a device's power source | |
| // in the electrical contract. |
| RIO("RIO"); | ||
|
|
||
|
|
||
|
|
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two consecutive blank lines (lines 46-47) before the private field declaration, which is inconsistent with Java style conventions that typically use a single blank line to separate sections of code.
| public enum PowerSource { | ||
| // PDH Ports (Power Distribution Hub) | ||
| PDH00, PDH01, PDH02, PDH03, PDH04, PDH05, PDH06, PDH07, PDH08, PDH09, | ||
| PDH10, PDH11, PDH12, PDH13, PDH14, PDH15, PDH16, PDH17, PDH18, PDH19, | ||
| PDH20, PDH21, PDH22, PDH23, | ||
|
|
||
| // Pneumatic Hub Solenoid Ports (0-15) | ||
| PneumaticHub00, PneumaticHub01, PneumaticHub02, PneumaticHub03, | ||
| PneumaticHub04, PneumaticHub05, PneumaticHub06, PneumaticHub07, | ||
| PneumaticHub08, PneumaticHub09, PneumaticHub10, PneumaticHub11, | ||
| PneumaticHub12, PneumaticHub13, PneumaticHub14, PneumaticHub15, | ||
|
|
||
| // VRM1 Outputs (Voltage Regulator Module) | ||
| VRM1_12V_2A("VRM1-12v_2a"), | ||
| VRM1_12V_2B("VRM1-12v_2b"), | ||
| VRM1_12V_500MA("VRM1-12v_500ma"), | ||
| VRM1_12V_500MB("VRM1-12v_500mb"), | ||
| VRM1_5V_2A("VRM1-5v_2a"), | ||
| VRM1_5V_2B("VRM1-5v_2b"), | ||
| VRM1_5V_500MA("VRM1-5v_500ma"), | ||
| VRM1_5V_500MB("VRM1-5v_500mb"), | ||
|
|
||
| // VRM2 Outputs (Voltage Regulator Module) | ||
| VRM2_12V_2A("VRM2-12v_2a"), | ||
| VRM2_12V_2B("VRM2-12v_2b"), | ||
| VRM2_12V_500MA("VRM2-12v_500ma"), | ||
| VRM2_12V_500MB("VRM2-12v_500mb"), | ||
| VRM2_5V_2A("VRM2-5v_2a"), | ||
| VRM2_5V_2B("VRM2-5v_2b"), | ||
| VRM2_5V_500MA("VRM2-5v_500ma"), | ||
| VRM2_5V_500MB("VRM2-5v_500mb"), | ||
|
|
||
| // Other power sources | ||
| NONE("NONE"), | ||
| BATTERY("BATTERY"), | ||
| MOTOR("MOTOR"), | ||
| INJECTOR("INJECTOR"), | ||
| RIO("RIO"); | ||
|
|
||
|
|
||
|
|
||
| private final String displayName; | ||
|
|
||
| PowerSource() { | ||
| this.displayName = this.name(); | ||
| } | ||
|
|
||
| PowerSource(String displayName) { | ||
| this.displayName = displayName; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return displayName; | ||
| } | ||
| } |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new PowerSource enum and PDHPort enum lack test coverage. Since this repository has comprehensive test coverage for other electrical contract classes (as evidenced by tests for DeviceInfo, CANMotorControllerInfo, and IMUInfo), these new enums should also have tests to verify their behavior, especially the toString methods and the displayName functionality in PowerSource.
| public enum PDHPort { | ||
| PDH00(0), | ||
| PDH01(1), | ||
| PDH02(2), | ||
| PDH03(3), | ||
| PDH04(4), | ||
| PDH05(5), | ||
| PDH06(6), | ||
| PDH07(7), | ||
| PDH08(8), | ||
| PDH09(9), | ||
| PDH10(10), | ||
| PDH11(11), | ||
| PDH12(12), | ||
| PDH13(13), | ||
| PDH14(14), | ||
| PDH15(15), | ||
| PDH16(16), | ||
| PDH17(17), | ||
| PDH18(18), | ||
| PDH19(19); | ||
|
|
||
| private final int portNumber; | ||
|
|
||
| PDHPort(int portNumber) { | ||
| this.portNumber = portNumber; | ||
| } | ||
|
|
||
| public int getPortNumber() { | ||
| return portNumber; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.format("PDH%02d", portNumber); | ||
| } | ||
| } |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new PDHPort enum lacks test coverage. Since this repository has comprehensive test coverage for other electrical contract classes, this enum should have tests to verify the getPortNumber method returns the correct integer values and the toString method formats port numbers correctly with the two-digit padding.
| public double simulationScalingValue; | ||
| public String name; | ||
| public CANBusId canBusId = CANBusId.RIO; | ||
| public PowerSource powerFrom; |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new powerFrom field in DeviceInfo and IMUInfo, and the new pdhPort field in CANMotorControllerInfo are not being used anywhere in the codebase yet. While it's acceptable to add these fields in preparation for future use, consider adding documentation or javadoc comments explaining their purpose and when they should be populated. This would help developers understand when to use null versus actual values for these fields.
|
|
||
| /** | ||
| * Represents power sources for devices on the robot. | ||
| * Includes PDH ports (0-19) and VRM1 outputs. |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Includes PDH ports (0-19) and VRM1 outputs" but the enum actually includes PDH ports 0-23 (lines 9-11) and also includes VRM2 outputs and other power sources beyond what is mentioned. The comment should be updated to accurately reflect all power sources included in this enum.
| * Includes PDH ports (0-19) and VRM1 outputs. | |
| * Includes PDH ports (0-23), Pneumatic Hub solenoid ports, VRM1 and VRM2 outputs, | |
| * and other logical power sources. |
| /** | ||
| * Represents the available ports on a Power Distribution Hub (PDH). | ||
| * REV PDH has 20 ports (0-19), CTRE PDH has 24 ports (0-23). | ||
| * Using the common 20-port standard here. |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Using the common 20-port standard here" but the enum only defines ports 0-19, which is actually 20 ports. However, it's missing ports 20-23 that are mentioned in the comment above about CTRE PDH having 24 ports. This inconsistency could lead to confusion. Either the comment should clarify this is the REV 20-port standard, or ports 20-23 should be added for CTRE PDH compatibility.
| * Using the common 20-port standard here. | |
| * This enum models only the REV 20-port (0-19) standard; CTRE PDH ports 20-23 are not represented here. |
| // VRM1 Outputs (Voltage Regulator Module) | ||
| VRM1_12V_2A("VRM1-12v_2a"), | ||
| VRM1_12V_2B("VRM1-12v_2b"), | ||
| VRM1_12V_500MA("VRM1-12v_500ma"), | ||
| VRM1_12V_500MB("VRM1-12v_500mb"), | ||
| VRM1_5V_2A("VRM1-5v_2a"), | ||
| VRM1_5V_2B("VRM1-5v_2b"), | ||
| VRM1_5V_500MA("VRM1-5v_500ma"), | ||
| VRM1_5V_500MB("VRM1-5v_500mb"), | ||
|
|
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are inconsistent spacing patterns in the enum. Lines 9-11 have the PDH ports, line 12 is blank, lines 13-17 have Pneumatic Hub ports, line 18 is blank, lines 19-27 have VRM1 outputs with no blank line separator, then line 28 is blank before VRM2. This makes the code harder to read. Consider adding a blank line between different groups of VRM outputs for consistency.
…into contract2025-fix
…information and reports
Why are we doing this?
Whats changing?
Questions/notes for reviewers
How this was tested