Package frc.spectrumLib.util
Class CanDeviceId
java.lang.Object
frc.spectrumLib.util.CanDeviceId
Identifies a CAN device by its numeric device ID and the CAN bus name it lives on. Equality and
hashing consider both fields, so two instances with the same device number on different buses are
treated as distinct.
-
Constructor Summary
ConstructorsConstructorDescriptionCanDeviceId(int deviceNumber) Creates a CAN device identifier on the default CAN bus (empty string).CanDeviceId(int deviceNumber, String bus) Creates a CAN device identifier with an explicit bus name. -
Method Summary
Modifier and TypeMethodDescriptionbooleanequals(CanDeviceId other) Type-safe equality check against anotherCanDeviceId.booleangetBus()Returns the CAN bus name this device is on.intReturns the numeric CAN device ID.inthashCode()
-
Constructor Details
-
CanDeviceId
Creates a CAN device identifier with an explicit bus name.- Parameters:
deviceNumber- the numeric CAN ID assigned to the devicebus- the name of the CAN bus (e.g."rio"or"canivore")
-
CanDeviceId
public CanDeviceId(int deviceNumber) Creates a CAN device identifier on the default CAN bus (empty string).- Parameters:
deviceNumber- the numeric CAN ID assigned to the device
-
-
Method Details
-
getDeviceNumber
public int getDeviceNumber()Returns the numeric CAN device ID.- Returns:
- the device number
-
getBus
Returns the CAN bus name this device is on.- Returns:
- the bus name, or an empty string for the default bus
-
equals
Type-safe equality check against anotherCanDeviceId.- Parameters:
other- the other instance to compare- Returns:
trueif both the device number and bus name match
-
hashCode
public int hashCode() -
equals
-