Skip to content

Conversation

@stephenjust
Copy link
Contributor

…information and reports

Why are we doing this?

Whats changing?

Questions/notes for reviewers

How this was tested

  • unit tests added
  • tested on robot

Copilot AI review requested due to automatic review settings January 17, 2026 22:42
@stephenjust stephenjust requested a review from a team as a code owner January 17, 2026 22:42
Copy link

Copilot AI left a 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.

Comment on lines +5 to +8
* Includes PDH ports (0-19) and VRM1 outputs.
*/
public enum PowerSource {
// PDH Ports (Power Distribution Hub)
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
RIO("RIO");



Copy link

Copilot AI Jan 17, 2026

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.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +62
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;
}
}
Copy link

Copilot AI Jan 17, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +44
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);
}
}
Copy link

Copilot AI Jan 17, 2026

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.

Copilot uses AI. Check for mistakes.
public double simulationScalingValue;
public String name;
public CANBusId canBusId = CANBusId.RIO;
public PowerSource powerFrom;
Copy link

Copilot AI Jan 17, 2026

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.

Copilot uses AI. Check for mistakes.

/**
* Represents power sources for devices on the robot.
* Includes PDH ports (0-19) and VRM1 outputs.
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
/**
* 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.
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +28
// 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"),

Copy link

Copilot AI Jan 17, 2026

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants