Class that provides operations to retrieve information about a status signal. More...
#include <ctre/phoenix6/StatusSignal.hpp>
Classes | |
struct | is_all_status_signal |
Type trait to verify that all types passed in are subclasses of BaseStatusSignal. More... | |
Public Member Functions | |
virtual | ~BaseStatusSignal ()=0 |
ctre::phoenix::StatusCode | SetUpdateFrequency (units::frequency::hertz_t frequencyHz, units::time::second_t timeoutSeconds=100_ms) |
Sets the rate at which the device will publish this signal. | |
units::frequency::hertz_t | GetAppliedUpdateFrequency () const |
Gets the rate at which the device will publish this signal. | |
const std::string & | GetName () const |
Gets the name of this signal. | |
const std::string & | GetUnits () const |
Gets the units for this signal. | |
double | GetValueAsDouble () const |
Gets the value of this signal as a double. | |
const AllTimestamps & | GetAllTimestamps () const |
Get the timestamps of this signals. | |
const Timestamp & | GetTimestamp () const |
Get the most accurate timestamp available for this signal. | |
ctre::phoenix::StatusCode | GetStatus () const |
Get the error code from when we last received this signal. | |
bool | HasUpdated () |
Check whether the signal has been updated since the last check. | |
Static Public Member Functions | |
template<typename... Signals, typename = std::enable_if_t<is_all_status_signal_v<Signals...>>> | |
static ctre::phoenix::StatusCode | WaitForAll (units::time::second_t timeoutSeconds, Signals &... signals) |
Waits for new data on all provided signals up to timeout. | |
static ctre::phoenix::StatusCode | WaitForAll (units::time::second_t timeoutSeconds, const std::vector< BaseStatusSignal * > &signals) |
Waits for new data on all provided signals up to timeout. | |
template<size_t N> | |
static ctre::phoenix::StatusCode | WaitForAll (units::time::second_t timeoutSeconds, const std::array< BaseStatusSignal *, N > &signals) |
Waits for new data on all provided signals up to timeout. | |
template<typename... Signals, typename = std::enable_if_t<is_all_status_signal_v<Signals...>>> | |
static ctre::phoenix::StatusCode | RefreshAll (Signals &... signals) |
Performs a non-blocking refresh on all provided signals. | |
static ctre::phoenix::StatusCode | RefreshAll (const std::vector< BaseStatusSignal * > &signals) |
Performs a non-blocking refresh on all provided signals. | |
template<size_t N> | |
static ctre::phoenix::StatusCode | RefreshAll (const std::array< BaseStatusSignal *, N > &signals) |
Performs a non-blocking refresh on all provided signals. | |
template<typename U , typename U_PER_SEC > | |
static U | GetLatencyCompensatedValue (StatusSignal< U > &signal, StatusSignal< U_PER_SEC > &signalSlope, units::time::second_t maxLatencySeconds=0.300_s) |
Performs latency compensation on signal using the signalSlope and signal's latency to determine the magnitude of compensation. | |
template<typename... Signals, typename = std::enable_if_t<is_all_status_signal_v<Signals...>>> | |
static bool | IsAllGood (Signals &... signals) |
Checks if all signals have an OK error code. | |
static bool | IsAllGood (const std::vector< BaseStatusSignal * > &signals) |
Checks if all signals have an OK error code. | |
template<size_t N> | |
static bool | IsAllGood (const std::array< BaseStatusSignal *, N > &signals) |
Checks if all signals have an OK error code. | |
template<typename... Signals, typename = std::enable_if_t<is_all_status_signal_v<Signals...>>> | |
static ctre::phoenix::StatusCode | SetUpdateFrequencyForAll (units::frequency::hertz_t frequencyHz, Signals &... signals) |
Sets the update frequency of all specified status signals to the provided common frequency. | |
static ctre::phoenix::StatusCode | SetUpdateFrequencyForAll (units::frequency::hertz_t frequencyHz, const std::vector< BaseStatusSignal * > &signals) |
Sets the update frequency of all specified status signals to the provided common frequency. | |
template<size_t N> | |
static ctre::phoenix::StatusCode | SetUpdateFrequencyForAll (units::frequency::hertz_t frequencyHz, const std::array< BaseStatusSignal *, N > &signals) |
Sets the update frequency of all specified status signals to the provided common frequency. | |
Protected Member Functions | |
BaseStatusSignal (hardware::DeviceIdentifier deviceIdentifier, uint16_t spn, std::string signalName, std::function< void()> checkFirmVersFunction) | |
BaseStatusSignal (ctre::phoenix::StatusCode error) | |
virtual void | UpdateUnits (uint16_t spn)=0 |
Static Protected Member Functions | |
static ctre::phoenix::StatusCode | Status_WaitForAll (BaseStatusSignal *const *signals, size_t count, const char *network, double timeoutSeconds) |
Wait for multiple signals to arrive. | |
static ctre::phoenix::StatusCode | Status_SetUpdateFrequency (const char *canbus, uint32_t deviceHash, uint16_t spn, double frequencyHz, double timeoutSeconds) |
static ctre::phoenix::StatusCode | Status_SetUpdateFrequencyForAll (BaseStatusSignal *const *signals, size_t count, double frequencyHz, double timeoutSeconds) |
static double | Status_GetAppliedUpdateFrequency (const char *canbus, uint32_t deviceHash, uint16_t spn) |
static std::string | Status_GetUnits (uint32_t signal) |
Gets signal units. | |
static ctre::phoenix::StatusCode | Status_Get (BaseStatusSignal &signal, const char *network, bool bWaitForUpdate, double timeoutSeconds) |
Get signal update. | |
template<typename Arr > | |
static ctre::phoenix::StatusCode | WaitForAllImpl (const char *location, units::time::second_t timeoutSeconds, const Arr &signals) |
Implementation of the WaitForAll API. | |
Protected Attributes | |
hardware::DeviceIdentifier | deviceIdentifier |
uint16_t | spn |
std::string | units |
AllTimestamps | timestamps {} |
double | baseValue = 0 |
ctre::phoenix::StatusCode | error = ctre::phoenix::StatusCode::SigNotUpdated |
std::string | signalName |
std::function< void()> | _checkFirmVersFunction |
units::time::second_t | _lastTimestamp {0_s} |
Static Protected Attributes | |
template<typename... Signals> | |
static constexpr bool | is_all_status_signal_v = is_all_status_signal<Signals...>::value |
Whether all types passed in are subclasses of BaseStatusSignal. | |
Friends | |
template<typename T > | |
class | StatusSignal |
Class that provides operations to retrieve information about a status signal.
|
inlineprotected |
|
inlineprotected |
|
pure virtual |
|
inline |
Get the timestamps of this signals.
|
inline |
Gets the rate at which the device will publish this signal.
This is typically the last value passed into SetUpdateFrequency. The returned value may be higher if another StatusSignal in the same status frame has been set to a higher update frequency.
|
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:
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. |
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. |
|
inline |
Gets the name of this signal.
|
inline |
Get the error code from when we last received this signal.
|
inline |
Get the most accurate timestamp available for this signal.
The timestamp sources from most to least accurate are:
Note that some of these sources may not be available.
|
inline |
Gets the units for this signal.
|
inline |
Gets the value of this signal as a double.
|
inline |
Check whether the signal has been updated since the last check.
Note that the signal must be refreshed before calling this routine.
|
inlinestatic |
Checks if all signals have an OK error code.
signals | Signals to check error code of, passed as an array of signal addresses. |
|
inlinestatic |
Checks if all signals have an OK error code.
signals | Signals to check error code of, passed as a vector or initializer list of signal addresses. |
|
inlinestatic |
Checks if all signals have an OK error code.
signals | Signals to check error code of, passed as a comma-separated list of signal references. |
|
inlinestatic |
Performs a non-blocking refresh on all provided signals.
This provides a performance improvement over separately calling Refresh() on each signal.
signals | Signals to refresh, passed as an array of signal addresses. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
inlinestatic |
Performs a non-blocking refresh on all provided signals.
This provides a performance improvement over separately calling Refresh() on each signal.
signals | Signals to refresh, passed as a vector or initializer list of signal addresses. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
inlinestatic |
Performs a non-blocking refresh on all provided signals.
This provides a performance improvement over separately calling Refresh() on each signal.
signals | Signals to refresh, passed as a comma-separated list of signal references. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
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.
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.
frequencyHz | Rate to publish the signal in Hz. |
timeoutSeconds | Maximum amount of time to wait when performing the action |
|
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.
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.
frequencyHz | Rate to publish the signal in Hz. |
signals | Signals to apply the update frequency to, passed as an array of signal addresses. |
|
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.
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.
frequencyHz | Rate to publish the signal in Hz. |
signals | Signals to apply the update frequency to, passed as a vector or initializer list of signal addresses. |
|
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.
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.
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. |
|
staticprotected |
Get signal update.
Caller either get last received, or wait for an update.
signal | Signal to update |
network | Name of bus (can, canfd, canivore-name, future protocols) |
bWaitForUpdate | If true, API will wait up to timeoutSeconds for an update. If false, routine will poll last received and use timeoutSeconds to return error code if too old. |
timeoutSeconds | How long to wait or how old the signal can be before error'ing |
|
staticprotected |
|
staticprotected |
Gets signal units.
signal | Signal to get |
|
staticprotected |
|
staticprotected |
|
staticprotected |
Wait for multiple signals to arrive.
signals | Signals to wait for |
count | Number of signals |
network | Network to wait for the signals on |
timeoutSeconds | Maximum time to wait for all these signals |
|
protectedpure virtual |
Implemented in ctre::phoenix6::StatusSignal< T >, ctre::phoenix6::StatusSignal< bool >, ctre::phoenix6::StatusSignal< ctre::unit::newton_meters_per_ampere_t >, ctre::phoenix6::StatusSignal< int >, ctre::phoenix6::StatusSignal< units::ampere_t >, ctre::phoenix6::StatusSignal< units::angle::degree_t >, ctre::phoenix6::StatusSignal< units::angle::turn_t >, ctre::phoenix6::StatusSignal< units::angular_velocity::degrees_per_second_t >, ctre::phoenix6::StatusSignal< units::degree_t >, ctre::phoenix6::StatusSignal< units::degrees_per_second_t >, ctre::phoenix6::StatusSignal< units::dimensionless::scalar_t >, ctre::phoenix6::StatusSignal< units::length::meter_t >, ctre::phoenix6::StatusSignal< units::turn_t >, and ctre::phoenix6::StatusSignal< units::turns_per_second_t >.
|
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.
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 an array of signal addresses. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
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.
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 vector or initializer list of signal addresses. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
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.
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. |
Any other value represents the StatusCode of the first failed signal. Call GetStatus() on each signal to determine which ones failed.
|
inlinestaticprotected |
Implementation of the WaitForAll API.
Arr | std::array or std::vector of BaseStatusSignal* |
location | Location of the calling function |
timeoutSeconds | Maximum time to wait for all the signals |
signals | Signals to wait on |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticconstexprprotected |
Whether all types passed in are subclasses of BaseStatusSignal.
|
protected |
|
protected |
|
protected |
|
protected |