Class that provides operations to retrieve information about a status signal.
More...
|
| static std::string | Status_GetUnits (uint32_t signal) |
| |
| static ctre::phoenix::StatusCode | Status_Get (BaseStatusSignal &signal, char const *network, bool bWaitForUpdate, double timeoutSeconds) |
| |
| static ctre::phoenix::StatusCode | Status_WaitForAll (std::span< BaseStatusSignal *const > signals, char const *network, double timeoutSeconds) |
| |
| static ctre::phoenix::StatusCode | Status_SetUpdateFrequency (char const *canbus, uint32_t deviceHash, uint16_t spn, double frequencyHz, double timeoutSeconds) |
| |
| static ctre::phoenix::StatusCode | Status_SetUpdateFrequencyForAll (std::span< BaseStatusSignal *const > signals, double frequencyHz, double timeoutSeconds) |
| |
| static double | Status_GetAppliedUpdateFrequency (char const *canbus, uint32_t deviceHash, uint16_t spn) |
| |
| static ctre::phoenix::StatusCode | WaitForAllImpl (char const *location, units::time::second_t timeoutSeconds, std::span< BaseStatusSignal *const > signals) |
| |
Class that provides operations to retrieve information about a status signal.
template<typename U , typename U_PER_SEC >
requires units::traits::is_unit_t_v<U> && units::traits::is_unit_t_v<U_PER_SEC> && units::traits::is_convertible_unit_v< typename units::traits::unit_t_traits<U>::unit_type, units::compound_unit<typename units::traits::unit_t_traits<U_PER_SEC>::unit_type, units::seconds> >
| static U ctre::phoenix6::BaseStatusSignal::GetLatencyCompensatedValue |
( |
StatusSignal< U > const & | signal, |
|
|
StatusSignal< U_PER_SEC > const & | signalSlope, |
|
|
units::time::second_t | maxLatencySeconds = 0.300_s ) |
|
inlinestatic |
Performs latency compensation on signal using the signalSlope and signal's latency to determine the magnitude of compensation.
The caller must refresh these StatusSignals beforehand; this function only does the math required for latency compensation.
Example usage:
static U GetLatencyCompensatedValue(StatusSignal< U > const &signal, StatusSignal< U_PER_SEC > const &signalSlope, units::time::second_t maxLatencySeconds=0.300_s)
Performs latency compensation on signal using the signalSlope and signal's latency to determine the m...
Definition StatusSignal.hpp:278
- Template Parameters
-
| U | Type of signal's underlying type. This is the type that the function will return. |
| U_PER_SEC | Type of signalSlope's underlying type. This must be the derivative of U. |
- Parameters
-
| signal | Signal to be latency compensated. Caller must make sure this signal is up to date either by calling Refresh() or WaitForUpdate(). |
| signalSlope | Derivative of signal that informs compensation magnitude. Caller must make sure this signal is up to date either by calling Refresh() or WaitForUpdate(). |
| maxLatencySeconds | The maximum amount of latency to compensate for in seconds. A negative or zero value disables the max latency cap. This is used to cap the contribution of latency compensation for stale signals, such as after the device has been disconnected from the CAN bus. |
- Returns
- Latency compensated value from the signal StatusSignal.
| ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::SetUpdateFrequency |
( |
units::frequency::hertz_t | frequencyHz, |
|
|
units::time::second_t | timeoutSeconds = 100_ms ) |
|
inline |
Sets the rate at which the device will publish this signal.
A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency.
If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.
- Parameters
-
| frequencyHz | Rate to publish the signal in Hz. |
| timeoutSeconds | Maximum amount of time to wait when performing the action |
- Returns
- Status code of setting the update frequency
| static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::SetUpdateFrequencyForAll |
( |
units::frequency::hertz_t | frequencyHz, |
|
|
Signals &... | signals ) |
|
inlinestatic |
Sets the update frequency of all specified status signals to the provided common frequency.
A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency.
If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.
This will wait up to 0.100 seconds (100ms) for each signal.
- Parameters
-
| frequencyHz | Rate to publish the signal in Hz. |
| signals | Signals to apply the update frequency to, passed as a comma-separated list of signal references. |
- Returns
- Status code of the first failed update frequency set call, or OK if all succeeded
Sets the update frequency of all specified status signals to the provided common frequency.
A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz. Additionally, some update frequencies are not supported and will be promoted up to the next highest supported frequency.
If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.
This will wait up to 0.100 seconds (100ms) for each signal.
- Parameters
-
| frequencyHz | Rate to publish the signal in Hz. |
| signals | Signals to apply the update frequency to, passed as a span of signal pointers. |
- Returns
- Status code of the first failed update frequency set call, or OK if all succeeded
| static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::WaitForAll |
( |
units::time::second_t | timeoutSeconds, |
|
|
Signals &... | signals ) |
|
inlinestatic |
Waits for new data on all provided signals up to timeout.
This API is typically used with CANivore Bus signals as they will be synced using the CANivore Timesync feature and arrive simultaneously. Signals on a roboRIO bus cannot be synced and may require a significantly longer blocking call to receive all signals.
Note that CANivore Timesync requires Phoenix Pro.
This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling Refresh() on every signal. This is equivalent to calling RefreshAll.
If a signal arrives multiple times while waiting, such as when not using CANivore Timesync, the newest signal data is fetched. Additionally, if this function times out, the newest signal data is fetched for all signals (when possible). We recommend checking the individual status codes using GetStatus() when this happens.
- Parameters
-
| timeoutSeconds | Maximum time to wait for all the signals to arrive. Pass zero to refresh all signals without blocking. |
| signals | Signals to wait on, passed as a comma-separated list of signal references. |
- Returns
- An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks, RxTimeout if it took longer than timeoutSeconds to receive all the signals, MultiSignalNotSupported if using the roboRIO bus with more than one signal and a non-zero timeout. An OK status code means that all signals arrived within timeoutSeconds and they are all OK.
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
Waits for new data on all provided signals up to timeout.
This API is typically used with CANivore Bus signals as they will be synced using the CANivore Timesync feature and arrive simultaneously. Signals on a roboRIO bus cannot be synced and may require a significantly longer blocking call to receive all signals.
Note that CANivore Timesync requires Phoenix Pro.
This can also be used with a timeout of zero to refresh many signals at once, which is faster than calling Refresh() on every signal. This is equivalent to calling RefreshAll.
If a signal arrives multiple times while waiting, such as when not using CANivore Timesync, the newest signal data is fetched. Additionally, if this function times out, the newest signal data is fetched for all signals (when possible). We recommend checking the individual status codes using GetStatus() when this happens.
- Parameters
-
| timeoutSeconds | Maximum time to wait for all the signals to arrive. Pass zero to refresh all signals without blocking. |
| signals | Signals to wait on, passed as a span of signal pointers. |
- Returns
- An InvalidParamValue if signals array is empty, InvalidNetwork if signals are on different CAN bus networks, RxTimeout if it took longer than timeoutSeconds to receive all the signals, MultiSignalNotSupported if using the roboRIO bus with more than one signal and a non-zero timeout. An OK status code means that all signals arrived within timeoutSeconds and they are all OK.
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.