Class ParentDevice
- All Implemented Interfaces:
CommonDevice
- Direct Known Subclasses:
CoreCANcoder,CoreCANdi,CoreCANdle,CoreCANrange,CorePigeon2,CoreTalonFX,CoreTalonFXS
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final EmptyControlprotected final DeviceIdentifier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ControlRequestGet the latest applied control.final longGets a number unique for this device's hardware type and ID.final intfinal CANBusfinal BooleanSupplierfinal booleanfinal booleanReturns whether the device is still connected to the robot.final booleanisConnected(double maxLatencySeconds) Returns whether the device is still connected to the robot.protected final <T> StatusSignal<T>lookupStatusSignal(int spn, String signalName, ParentDevice.MapGenerator unitsGenerator, Class<T> classOfSignal, DoubleFunction<T> toValue, boolean reportOnConstruction, boolean refresh) protected final <T> StatusSignal<T>lookupStatusSignal(int spn, String signalName, Class<T> classOfSignal, DoubleFunction<T> toValue, boolean reportOnConstruction, boolean refresh) final StatusCodeOptimizes the device's bus utilization by reducing the update frequencies of its status signals.final StatusCodeoptimizeBusUtilization(double optimizedFreqHz) Optimizes the device's bus utilization by reducing the update frequencies of its status signals.final StatusCodeoptimizeBusUtilization(double optimizedFreqHz, double timeoutSeconds) Optimizes the device's bus utilization by reducing the update frequencies of its status signals.final StatusCodeoptimizeBusUtilization(Frequency optimizedFreq) Optimizes the device's bus utilization by reducing the update frequencies of its status signals.final StatusCodeoptimizeBusUtilization(Frequency optimizedFreq, double timeoutSeconds) Optimizes the device's bus utilization by reducing the update frequencies of its status signals.static StatusCodeoptimizeBusUtilizationForAll(double optimizedFreqHz, CommonDevice... devices) Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.static StatusCodeoptimizeBusUtilizationForAll(CommonDevice... devices) Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.static StatusCodeoptimizeBusUtilizationForAll(Frequency optimizedFreq, CommonDevice... devices) Optimizes the bus utilization of the provided devices by reducing the update frequencies of their status signals.final StatusCodeResets the update frequencies of all the device's status signals to the defaults.final StatusCoderesetSignalFrequencies(double timeoutSeconds) Resets the update frequencies of all the device's status signals to the defaults.static StatusCoderesetSignalFrequenciesForAll(CommonDevice... devices) Resets the update frequencies of all the devices' status signals to the defaults.protected StatusCodesetControlPrivate(ControlRequest request)
-
Field Details
-
_emptyControl
-
deviceIdentifier
-
-
Constructor Details
-
ParentDevice
-
-
Method Details
-
getDeviceID
- Specified by:
getDeviceIDin interfaceCommonDevice- Returns:
- The device ID of this device [0,62].
-
getNetwork
- Specified by:
getNetworkin interfaceCommonDevice- Returns:
- 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.
- Specified by:
getDeviceHashin interfaceCommonDevice- 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.- Specified by:
getAppliedControlin interfaceCommonDevice- Returns:
- Latest applied control
-
hasResetOccurred
- Specified by:
hasResetOccurredin interfaceCommonDevice- Returns:
- true if device has reset since the previous call of this routine.
-
getResetOccurredChecker
- Specified by:
getResetOccurredCheckerin interfaceCommonDevice- Returns:
- a
BooleanSupplierthat checks for device resets.
-
isConnected
Returns whether the device is still connected to the robot. This is equivalent to refreshing and checking the latency of the Version status signal.This defaults to reporting a device as disconnected if it has not been seen for over 0.5 seconds.
- Specified by:
isConnectedin interfaceCommonDevice- Returns:
- true if the device is connected
-
isConnected
Returns whether the device is still connected to the robot. This is equivalent to refreshing and checking the latency of the Version status signal.- Specified by:
isConnectedin interfaceCommonDevice- Parameters:
maxLatencySeconds- The maximum latency of the Version status signal before the device is reported as disconnected- Returns:
- true if the device is connected
-
optimizeBusUtilization
Optimizes the device's bus utilization by reducing the update frequencies of its status signals. This API defaults to an optimized update frequency of 4 Hz to preserve log data.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)will be slowed down. 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, call
resetSignalFrequencies(). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) for each signal by default.
- Specified by:
optimizeBusUtilizationin interfaceCommonDevice- 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 slowed down. 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, call
resetSignalFrequencies(). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) for each signal by default.
- Specified by:
optimizeBusUtilizationin interfaceCommonDevice- Parameters:
optimizedFreqHz- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).- 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 slowed down. 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, call
resetSignalFrequencies(). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) for each signal by default.
- Specified by:
optimizeBusUtilizationin interfaceCommonDevice- Parameters:
optimizedFreq- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).- 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 slowed down. 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, call
resetSignalFrequencies(). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).- Specified by:
optimizeBusUtilizationin interfaceCommonDevice- Parameters:
optimizedFreqHz- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).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 slowed down. 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, call
resetSignalFrequencies(). Alternatively, remove this method call, redeploy the robot application, and power-cycle the device on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).- Specified by:
optimizeBusUtilizationin interfaceCommonDevice- Parameters:
optimizedFreq- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).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. This API defaults to an optimized update frequency of 4 Hz to preserve log data.All status signals that have not been explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)will be slowed down. 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, call
resetSignalFrequenciesForAll(com.ctre.phoenix6.hardware.traits.CommonDevice...). Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) 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, CommonDevice... 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 slowed down. 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, call
resetSignalFrequenciesForAll(com.ctre.phoenix6.hardware.traits.CommonDevice...). Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters:
optimizedFreqHz- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).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(Frequency optimizedFreq, CommonDevice... 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 slowed down. 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, call
resetSignalFrequenciesForAll(com.ctre.phoenix6.hardware.traits.CommonDevice...). Alternatively, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. The user can also override individual status update frequencies usingBaseStatusSignal.setUpdateFrequency(double).This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters:
optimizedFreq- The update frequency to apply to the optimized status signals. A frequency of 0 Hz will turn off the signals. Otherwise, the minimum supported signal frequency is 4 Hz (default).devices- Devices for which to opimize bus utilization- Returns:
- Status code of the first failed optimize call, or OK if all succeeded
-
resetSignalFrequencies
Resets the update frequencies of all the device's status signals to the defaults.This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)and status signals optimized out usingoptimizeBusUtilization().This will wait up to 0.100 seconds (100ms) for each signal by default.
- Specified by:
resetSignalFrequenciesin interfaceCommonDevice- Returns:
- Status code of the first failed update frequency set call, or OK if all succeeded
-
resetSignalFrequencies
Resets the update frequencies of all the device's status signals to the defaults.This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)and status signals optimized out usingoptimizeBusUtilization().- Specified by:
resetSignalFrequenciesin interfaceCommonDevice- 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
-
resetSignalFrequenciesForAll
Resets the update frequencies of all the devices' status signals to the defaults.This restores the default update frequency of all status signals, including status signals explicitly given an update frequency using
BaseStatusSignal.setUpdateFrequency(double)and status signals optimized out usingoptimizeBusUtilizationForAll(com.ctre.phoenix6.hardware.traits.CommonDevice...).This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters:
devices- Devices for which to restore default update frequencies- Returns:
- Status code of the first failed restore call, or OK if all succeeded
-
setControlPrivate
-
lookupStatusSignal
protected final <T> StatusSignal<T> lookupStatusSignal(int spn, String signalName, Class<T> classOfSignal, DoubleFunction<T> toValue, boolean reportOnConstruction, boolean refresh) -
lookupStatusSignal
protected final <T> StatusSignal<T> lookupStatusSignal(int spn, String signalName, ParentDevice.MapGenerator unitsGenerator, Class<T> classOfSignal, DoubleFunction<T> toValue, boolean reportOnConstruction, boolean refresh)
-