Loading [MathJax]/extensions/tex2jax.js
CTRE Phoenix 6 C++ 23.2.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ctre::phoenix6::BaseStatusSignal Class Referenceabstract

Class that provides operations to retrieve information about a status signal. More...

#include <ctre/phoenix6/StatusSignal.hpp>

Inheritance diagram for ctre::phoenix6::BaseStatusSignal:
ctre::phoenix6::StatusSignal< units::angle::turn_t > ctre::phoenix6::StatusSignal< units::angle::degree_t > ctre::phoenix6::StatusSignal< units::angular_velocity::degrees_per_second_t > ctre::phoenix6::StatusSignal< units::dimensionless::scalar_t > ctre::phoenix6::StatusSignal< int > ctre::phoenix6::StatusSignal< T >

Public Member Functions

virtual ~BaseStatusSignal ()=0
 
ctre::phoenix::StatusCode SetUpdateFrequency (units::frequency::hertz_t frequencyHz, units::time::second_t timeoutSeconds=50_ms)
 Sets the rate at which the device will publish this signal. More...
 
const std::string & GetUnits () const
 Gets the units for this signal. More...
 
const AllTimestampsGetAllTimestamps () const
 Get the timestamps of this signals. More...
 
const TimestampGetTimestamp () const
 Get the best timestamp available to this signal. More...
 
ctre::phoenix::StatusCode GetError () const
 Get the error code from when we last received this signal. More...
 

Static Public Member Functions

static ctre::phoenix::StatusCode WaitForAll (units::time::second_t timeoutSeconds, std::initializer_list< BaseStatusSignal * > signals)
 Waits for new data on all provided signals up to timeout. More...
 
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. More...
 
template<typename U , typename U_PER_SEC >
static U GetLatencyCompensatedValue (StatusSignal< U > &signal, StatusSignal< U_PER_SEC > &signalSlope)
 
static ctre::phoenix::StatusCode IsAllGood (std::initializer_list< BaseStatusSignal * > signals)
 Checks if all signals have an OK error code. More...
 

Protected Member Functions

void CopyFrom (const BaseStatusSignal &other)
 
 BaseStatusSignal (hardware::DeviceIdentifier deviceIdentifier, uint16_t spn, std::string signalName)
 
 BaseStatusSignal (ctre::phoenix::StatusCode error)
 
ctre::phoenix::StatusCode SetUpdateFrequency (const char *canbus, uint32_t deviceHash, uint16_t spn, units::frequency::hertz_t frequencyHz, units::time::second_t timeoutSeconds)
 

Static Protected Member Functions

static ctre::phoenix::StatusCode Status_WaitForAll (std::initializer_list< BaseStatusSignal * > signals, const char *network, units::time::second_t timeoutSeconds)
 Wait for multiple signals to arrive. More...
 
static ctre::phoenix::StatusCode Status_WaitForAll (const std::vector< BaseStatusSignal * > &signals, const char *network, units::time::second_t timeoutSeconds)
 Wait for multiple signals to arrive. More...
 
static std::string Status_GetUnits (uint32_t signal)
 Gets signal units. More...
 
static ctre::phoenix::StatusCode Status_Get (const char *network, int deviceHash, uint32_t signal, bool bWaitForUpdate, units::time::second_t timeoutSeconds, double *outValue, double *hwtimestamp, double *swtimestamp, double *ecutimestamp, int32_t *timestampType)
 Get signal update. More...
 

Protected Attributes

hardware::DeviceIdentifier deviceIdentifier
 
uint16_t spn
 
std::string units
 
AllTimestamps timestamps {}
 
int timestampType
 
double baseValue = 0
 
ctre::phoenix::StatusCode error = ctre::phoenix::StatusCode::SigNotUpdated
 
std::string signalName
 

Friends

template<typename T >
class StatusSignal
 

Detailed Description

Class that provides operations to retrieve information about a status signal.

Constructor & Destructor Documentation

◆ BaseStatusSignal() [1/2]

ctre::phoenix6::BaseStatusSignal::BaseStatusSignal ( hardware::DeviceIdentifier  deviceIdentifier,
uint16_t  spn,
std::string  signalName 
)
inlineprotected

◆ BaseStatusSignal() [2/2]

ctre::phoenix6::BaseStatusSignal::BaseStatusSignal ( ctre::phoenix::StatusCode  error)
inlineprotected

◆ ~BaseStatusSignal()

virtual ctre::phoenix6::BaseStatusSignal::~BaseStatusSignal ( )
pure virtual

Member Function Documentation

◆ CopyFrom()

void ctre::phoenix6::BaseStatusSignal::CopyFrom ( const BaseStatusSignal other)
inlineprotected

◆ GetAllTimestamps()

const AllTimestamps & ctre::phoenix6::BaseStatusSignal::GetAllTimestamps ( ) const
inline

Get the timestamps of this signals.

Returns
All timestamps for this signal

◆ GetError()

ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::GetError ( ) const
inline

Get the error code from when we last received this signal.

Returns
Last cached Error Code

◆ GetLatencyCompensatedValue()

template<typename U , typename U_PER_SEC >
static U ctre::phoenix6::BaseStatusSignal::GetLatencyCompensatedValue ( StatusSignal< U > &  signal,
StatusSignal< U_PER_SEC > &  signalSlope 
)
inlinestatic

◆ GetTimestamp()

const Timestamp & ctre::phoenix6::BaseStatusSignal::GetTimestamp ( ) const
inline

Get the best timestamp available to this signal.

Returns
Best available timestamp for this signal

◆ GetUnits()

const std::string & ctre::phoenix6::BaseStatusSignal::GetUnits ( ) const
inline

Gets the units for this signal.

Returns
String representation of units for this signal

◆ IsAllGood()

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::IsAllGood ( std::initializer_list< BaseStatusSignal * >  signals)
inlinestatic

Checks if all signals have an OK error code.

Parameters
signalsSignals to check error code of.
Returns
True if all signals are OK, false otherwise

◆ SetUpdateFrequency() [1/2]

ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::SetUpdateFrequency ( const char *  canbus,
uint32_t  deviceHash,
uint16_t  spn,
units::frequency::hertz_t  frequencyHz,
units::time::second_t  timeoutSeconds 
)
protected

◆ SetUpdateFrequency() [2/2]

ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::SetUpdateFrequency ( units::frequency::hertz_t  frequencyHz,
units::time::second_t  timeoutSeconds = 50_ms 
)
inline

Sets the rate at which the device will publish this signal.

The minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz.

Parameters
frequencyHzRate to publish the signal in Hz.
timeoutSecondsMaximum amount of time to wait when performing the action
Returns
Status code of setting the update frequency

◆ Status_Get()

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::Status_Get ( const char *  network,
int  deviceHash,
uint32_t  signal,
bool  bWaitForUpdate,
units::time::second_t  timeoutSeconds,
double *  outValue,
double *  hwtimestamp,
double *  swtimestamp,
double *  ecutimestamp,
int32_t *  timestampType 
)
staticprotected

Get signal update.

Caller either get last received, or wait for an update.

Parameters
networkName of bus (can, canfd, canivore-name, future protocols)
deviceHashHash id of the device (based on device id and model)
signalSignal to get
bWaitForUpdateIf 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.
timeoutSecondsHow long to wait or how old the signal can be before error'ing
outValueValue of the signal
hwtimestampTimestamp of the signal
swtimestampTimestamp of the signal
ecutimestampTimestamp of the signal
timestampTypeWhich type of timestamp was gotten
Returns
Status of the get

◆ Status_GetUnits()

static std::string ctre::phoenix6::BaseStatusSignal::Status_GetUnits ( uint32_t  signal)
staticprotected

Gets signal units.

Parameters
signalSignal to get
Returns
Units of the signal

◆ Status_WaitForAll() [1/2]

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::Status_WaitForAll ( const std::vector< BaseStatusSignal * > &  signals,
const char *  network,
units::time::second_t  timeoutSeconds 
)
staticprotected

Wait for multiple signals to arrive.

Parameters
signalsSignals to wait for
networkNetwork to wait for the signals on
timeoutSecondsMaximum time to wait for all these signals
Returns
Status of the wait

◆ Status_WaitForAll() [2/2]

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::Status_WaitForAll ( std::initializer_list< BaseStatusSignal * >  signals,
const char *  network,
units::time::second_t  timeoutSeconds 
)
staticprotected

Wait for multiple signals to arrive.

Parameters
signalsSignals to wait for
networkNetwork to wait for the signals on
timeoutSecondsMaximum time to wait for all these signals
Returns
Status of the wait

◆ WaitForAll() [1/2]

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::WaitForAll ( units::time::second_t  timeoutSeconds,
const std::vector< BaseStatusSignal * > &  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.

Parameters
timeoutSecondsMaximum time to wait for all the signals to arrive. Pass zero to refresh all signals without blocking.
signalsSignals to wait on, passed as vector of signal addresses.
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 GetError() on each signal to determine which ones failed.

◆ WaitForAll() [2/2]

static ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::WaitForAll ( units::time::second_t  timeoutSeconds,
std::initializer_list< BaseStatusSignal * >  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.

Parameters
timeoutSecondsMaximum time to wait for all the signals to arrive. Pass zero to refresh all signals without blocking.
signalsSignals to wait on, passed as initializer list of signal addresses.
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 GetError() on each signal to determine which ones failed.

Friends And Related Function Documentation

◆ StatusSignal

template<typename T >
friend class StatusSignal
friend

Member Data Documentation

◆ baseValue

double ctre::phoenix6::BaseStatusSignal::baseValue = 0
protected

◆ deviceIdentifier

hardware::DeviceIdentifier ctre::phoenix6::BaseStatusSignal::deviceIdentifier
protected

◆ error

ctre::phoenix::StatusCode ctre::phoenix6::BaseStatusSignal::error = ctre::phoenix::StatusCode::SigNotUpdated
protected

◆ signalName

std::string ctre::phoenix6::BaseStatusSignal::signalName
protected

◆ spn

uint16_t ctre::phoenix6::BaseStatusSignal::spn
protected

◆ timestamps

AllTimestamps ctre::phoenix6::BaseStatusSignal::timestamps {}
protected

◆ timestampType

int ctre::phoenix6::BaseStatusSignal::timestampType
protected

◆ units

std::string ctre::phoenix6::BaseStatusSignal::units
protected

The documentation for this class was generated from the following file: