Parent class for all devices.
More...
#include <ctre/phoenix6/hardware/ParentDevice.hpp>
Parent class for all devices.
◆ ParentDevice() [1/2]
| ctre::phoenix6::hardware::ParentDevice::ParentDevice |
( |
int | deviceID, |
|
|
std::string | model, |
|
|
CANBus | canbus ) |
◆ ~ParentDevice()
| virtual ctre::phoenix6::hardware::ParentDevice::~ParentDevice |
( |
| ) |
|
|
pure virtual |
◆ ParentDevice() [2/2]
| ctre::phoenix6::hardware::ParentDevice::ParentDevice |
( |
ParentDevice const & | | ) |
|
|
delete |
◆ GetAppliedControl() [1/2]
Get the latest applied control.
Caller can cast this to the derived class if they know its type. Otherwise, use controls::ControlRequest::GetControlInfo to get info out of it.
This returns a shared pointer to avoid becoming a dangling pointer due to parallel operations changing the underlying data. Make sure to save the shared_ptr to a variable before chaining function calls, otherwise the data may be freed early.
- Returns
- Latest applied control
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ GetAppliedControl() [2/2]
Get the latest applied control.
Caller can cast this to the derived class if they know its type. Otherwise, use controls::ControlRequest::GetControlInfo to get info out of it.
This returns a shared pointer to avoid becoming a dangling pointer due to parallel operations changing the underlying data. Make sure to save the shared_ptr to a variable before chaining function calls, otherwise the data may be freed early.
- Returns
- Latest applied control
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ GetDeviceHash()
| uint64_t ctre::phoenix6::hardware::ParentDevice::GetDeviceHash |
( |
| ) |
const |
|
inlinefinalvirtual |
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.
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ GetDeviceID()
| int ctre::phoenix6::hardware::ParentDevice::GetDeviceID |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ GetGenericSignal()
| StatusSignal< double > & ctre::phoenix6::hardware::ParentDevice::GetGenericSignal |
( |
uint32_t | signal, |
|
|
bool | refresh = true ) |
|
inline |
This is a reserved routine for internal testing.
Use the other get routines to retrieve signal values.
- Parameters
-
| signal | Signal to get. |
| refresh | Whether to refresh |
- Returns
- StatusSignalValue holding value
◆ GetNetwork()
| CANBus ctre::phoenix6::hardware::ParentDevice::GetNetwork |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ GetResetOccurredChecker()
| std::function< bool()> ctre::phoenix6::hardware::ParentDevice::GetResetOccurredChecker |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ HasResetOccurred()
| bool ctre::phoenix6::hardware::ParentDevice::HasResetOccurred |
( |
| ) |
|
|
inlinefinalvirtual |
◆ IsConnected()
| bool ctre::phoenix6::hardware::ParentDevice::IsConnected |
( |
units::second_t | maxLatencySeconds = 500_ms | ) |
|
|
inlinefinalvirtual |
Returns whether the device is still connected to the robot.
This is equivalent to refreshing and checking the latency of the Version status signal.
- Parameters
-
| maxLatencySeconds | The maximum latency of the Version status signal before the device is reported as disconnected |
- Returns
- true if the device is connected
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ LookupStatusSignal() [1/2]
template<typename T >
| StatusSignal< T > & ctre::phoenix6::hardware::ParentDevice::LookupStatusSignal |
( |
uint16_t | spn, |
|
|
std::string | signalName, |
|
|
bool | reportOnConstruction, |
|
|
bool | refresh ) |
|
inlineprotected |
◆ LookupStatusSignal() [2/2]
template<typename T >
| StatusSignal< T > & ctre::phoenix6::hardware::ParentDevice::LookupStatusSignal |
( |
uint16_t | spn, |
|
|
std::string | signalName, |
|
|
std::function< std::map< uint16_t, std::string >()> | mapFiller, |
|
|
bool | reportOnConstruction, |
|
|
bool | refresh ) |
|
inlineprotected |
◆ operator=()
◆ OptimizeBusUtilization()
| ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::OptimizeBusUtilization |
( |
units::frequency::hertz_t | optimizedFreqHz = 4_Hz, |
|
|
units::time::second_t | timeoutSeconds = 100_ms ) |
|
finalvirtual |
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 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 using BaseStatusSignal::SetUpdateFrequency.
- 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
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ OptimizeBusUtilizationForAll() [1/4]
| static ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::OptimizeBusUtilizationForAll |
( |
Devices &... | devices | ) |
|
|
inlinestatic |
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 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. 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 using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
| devices | Devices for which to optimize bus utilization, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [2/4]
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 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. 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 using BaseStatusSignal::SetUpdateFrequency.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
| devices | Devices for which to optimize bus utilization, passed as a span of device pointers. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [3/4]
| static ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::OptimizeBusUtilizationForAll |
( |
units::frequency::hertz_t | optimizedFreqHz, |
|
|
Devices &... | devices ) |
|
inlinestatic |
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 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. 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 using BaseStatusSignal::SetUpdateFrequency.
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 optimize bus utilization, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ OptimizeBusUtilizationForAll() [4/4]
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 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. 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 using BaseStatusSignal::SetUpdateFrequency.
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 optimize bus utilization, passed as a span of device pointers. |
- Returns
- Status code of the first failed optimize call, or OK if all succeeded
◆ ResetSignalFrequencies()
| ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::ResetSignalFrequencies |
( |
units::time::second_t | timeoutSeconds = 100_ms | ) |
|
|
finalvirtual |
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 and status signals optimized out using OptimizeBusUtilization.
- 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
Implements ctre::phoenix6::hardware::traits::CommonDevice.
◆ ResetSignalFrequenciesForAll() [1/2]
| static ctre::phoenix::StatusCode ctre::phoenix6::hardware::ParentDevice::ResetSignalFrequenciesForAll |
( |
Devices &... | devices | ) |
|
|
inlinestatic |
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 and status signals optimized out using OptimizeBusUtilizationForAll.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
| devices | Devices for which to restore default update frequencies, passed as a comma-separated list of device references. |
- Returns
- Status code of the first failed restore call, or OK if all succeeded
◆ ResetSignalFrequenciesForAll() [2/2]
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 and status signals optimized out using OptimizeBusUtilizationForAll.
This will wait up to 0.100 seconds (100ms) for each status frame.
- Parameters
-
| devices | Devices for which to restore default update frequencies, passed as a span of device pointers. |
- Returns
- Status code of the first failed restore call, or OK if all succeeded
◆ SetControlPrivate()
◆ _emptyControl
◆ deviceIdentifier
The documentation for this class was generated from the following file: