Class ParentDevice
- Direct Known Subclasses:
CoreCANcoder
,CorePigeon2
,CoreTalonFX
public abstract class ParentDevice extends CtreJniWrapper
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ParentDevice.MapGenerator<T>
-
Field Summary
Fields Modifier and Type Field Description protected static EmptyControl
_emptyControl
protected DeviceIdentifier
deviceIdentifier
-
Constructor Summary
Constructors Constructor Description ParentDevice(int deviceID, String model, String canbus)
-
Method Summary
Modifier and Type Method Description ControlRequest
getAppliedControl()
Get the latest applied control.long
getDeviceHash()
Gets a number unique for this device's hardware type and ID.int
getDeviceID()
String
getNetwork()
BooleanSupplier
getResetOccurredChecker()
boolean
hasResetOccurred()
protected <T> StatusSignal<T>
lookupStatusSignal(int spn, Class<T> classOfSignal, int mapIter, ParentDevice.MapGenerator<T> generator, String signalName, boolean reportOnConstruction)
protected <T> StatusSignal<T>
lookupStatusSignal(int spn, Class<T> classOfSignal, String signalName, boolean reportOnConstruction)
StatusCode
optimizeBusUtilization()
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.StatusCode
optimizeBusUtilization(double timeoutSeconds)
Deprecated, for removal: This API element is subject to removal in a future version.This overload is deprecated for removal in 2025.StatusCode
optimizeBusUtilization(double optimizedFreqHz, double timeoutSeconds)
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.static StatusCode
optimizeBusUtilizationForAll(double optimizedFreqHz, ParentDevice... devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.static StatusCode
optimizeBusUtilizationForAll(ParentDevice... devices)
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.protected StatusCode
setControlPrivate(ControlRequest request)
-
Field Details
-
Constructor Details
-
Method Details
-
getDeviceID
- Returns:
- The device ID of this device [0,62].
-
getNetwork
- Returns:
- Name of the network this device is on.
-
getDeviceHash
Gets a number unique for this device's hardware type and ID. This number is not unique across networks.This can be used to easily reference hardware devices on the same network in collections such as maps.
- Returns:
- Hash of this device.
-
getAppliedControl
Get the latest applied control. Caller can cast this to the derived class if they know its type. Otherwise, useControlRequest.getControlInfo()
to get info out of it.- Returns:
- Latest applied control
-
hasResetOccurred
- Returns:
- true if device has reset since the previous call of this routine.
-
getResetOccurredChecker
- Returns:
- a
BooleanSupplier
that checks for device resets.
-
optimizeBusUtilization
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)
will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.This function only needs to be called once in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using
BaseStatusSignal.setUpdateFrequency(double)
.This will wait up to 0.050 seconds (50ms) for each signal by default.
- Returns:
- Status code of the first failed update frequency set call, or OK if all succeeded
-
optimizeBusUtilization
Deprecated, for removal: This API element is subject to removal in a future version.This overload is deprecated for removal in 2025. UseoptimizeBusUtilization(double optimizedFreqHz, double timeoutSeconds)
with an optimizedFreqHz of 0 Hz instead.Optimizes the device's bus utilization by reducing the update frequencies of its status signals.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)
will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using
BaseStatusSignal.setUpdateFrequency(double)
.- Parameters:
timeoutSeconds
- Maximum amount of time to wait for each status frame when performing the action- Returns:
- Status code of the first failed update frequency set call, or OK if all succeeded
-
optimizeBusUtilization
Optimizes the device's bus utilization by reducing the update frequencies of its status signals.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)
will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using
BaseStatusSignal.setUpdateFrequency(double)
.- Parameters:
optimizedFreqHz
- The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz.timeoutSeconds
- Maximum amount of time to wait for each status frame when performing the action- Returns:
- Status code of the first failed update frequency set call, or OK if all succeeded
-
optimizeBusUtilizationForAll
Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)
will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using
BaseStatusSignal.setUpdateFrequency(double)
.This will wait up to 0.050 seconds (50ms) for each status frame.
- Parameters:
devices
- Devices for which to opimize bus utilization- Returns:
- Status code of the first failed optimize call, or OK if all succeeded
-
optimizeBusUtilizationForAll
public static StatusCode optimizeBusUtilizationForAll(double optimizedFreqHz, ParentDevice... devices)Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)
will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.This function only needs to be called once in the robot program for the provided devices. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.
To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using
BaseStatusSignal.setUpdateFrequency(double)
.This will wait up to 0.050 seconds (50ms) for each status frame.
- Parameters:
optimizedFreqHz
- The update frequency to apply to the optimized status signals. A frequency of 0 Hz (default) will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz.devices
- Devices for which to opimize bus utilization- Returns:
- Status code of the first failed optimize call, or OK if all succeeded
-
setControlPrivate
-
lookupStatusSignal
protected <T> StatusSignal<T> lookupStatusSignal(int spn, Class<T> classOfSignal, String signalName, boolean reportOnConstruction) -
lookupStatusSignal
protected <T> StatusSignal<T> lookupStatusSignal(int spn, Class<T> classOfSignal, int mapIter, ParentDevice.MapGenerator<T> generator, String signalName, boolean reportOnConstruction)
-