CTRE Phoenix Pro C++ 23.0.12
ctre::phoenixpro::BaseStatusSignalValue Class Referenceabstract

#include <ctre/phoenixpro/StatusSignalValue.hpp>

Inheritance diagram for ctre::phoenixpro::BaseStatusSignalValue:
ctre::phoenixpro::StatusSignalValue< units::angle::turn_t > ctre::phoenixpro::StatusSignalValue< units::angle::degree_t > ctre::phoenixpro::StatusSignalValue< units::angular_velocity::degrees_per_second_t > ctre::phoenixpro::StatusSignalValue< units::dimensionless::scalar_t > ctre::phoenixpro::StatusSignalValue< int > ctre::phoenixpro::StatusSignalValue< T >

Public Member Functions

virtual ~BaseStatusSignalValue ()=0
 
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< BaseStatusSignalValue * > signals)
 Wait for all provided signals up to timeout. More...
 
static ctre::phoenix::StatusCode WaitForAll (units::time::second_t timeoutSeconds, const std::vector< BaseStatusSignalValue * > &signals)
 Wait for all provided signals up to timeout. More...
 
template<typename U , typename U_PER_SEC >
static U GetLatencyCompensatedValue (StatusSignalValue< U > &signal, StatusSignalValue< U_PER_SEC > &signalSlope)
 
static ctre::phoenix::StatusCode IsAllGood (std::initializer_list< BaseStatusSignalValue * > signals)
 Check if all signals have an OK error code. More...
 

Protected Member Functions

void CopyFrom (const BaseStatusSignalValue &other)
 
 BaseStatusSignalValue (hardware::DeviceIdentifier deviceIdentifier, uint16_t spn, std::string signalName)
 
 BaseStatusSignalValue (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< BaseStatusSignalValue * > 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< BaseStatusSignalValue * > &signals, const char *network, units::time::second_t timeoutSeconds)
 Wait for multiple signals to arrive. More...
 
static ctre::phoenix::StatusCode Status_Get (const char *network, int deviceHash, uint32_t signal, bool bWaitForUpdate, units::time::second_t timeoutSeconds, double *outValue, std::string *units, 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 StatusSignalValue
 

Constructor & Destructor Documentation

◆ BaseStatusSignalValue() [1/2]

ctre::phoenixpro::BaseStatusSignalValue::BaseStatusSignalValue ( hardware::DeviceIdentifier  deviceIdentifier,
uint16_t  spn,
std::string  signalName 
)
inlineprotected

◆ BaseStatusSignalValue() [2/2]

ctre::phoenixpro::BaseStatusSignalValue::BaseStatusSignalValue ( ctre::phoenix::StatusCode  error)
inlineprotected

◆ ~BaseStatusSignalValue()

virtual ctre::phoenixpro::BaseStatusSignalValue::~BaseStatusSignalValue ( )
pure virtual

Member Function Documentation

◆ CopyFrom()

void ctre::phoenixpro::BaseStatusSignalValue::CopyFrom ( const BaseStatusSignalValue other)
inlineprotected

◆ GetAllTimestamps()

const AllTimestamps & ctre::phoenixpro::BaseStatusSignalValue::GetAllTimestamps ( ) const
inline

Get the timestamps of this signals.

Returns
All timestamps for this signal

◆ GetError()

ctre::phoenix::StatusCode ctre::phoenixpro::BaseStatusSignalValue::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::phoenixpro::BaseStatusSignalValue::GetLatencyCompensatedValue ( StatusSignalValue< U > &  signal,
StatusSignalValue< U_PER_SEC > &  signalSlope 
)
inlinestatic

◆ GetTimestamp()

const Timestamp & ctre::phoenixpro::BaseStatusSignalValue::GetTimestamp ( ) const
inline

Get the best timestamp available to this signal.

Returns
Best available timestamp for this signal

◆ GetUnits()

const std::string & ctre::phoenixpro::BaseStatusSignalValue::GetUnits ( ) const
inline

Gets the units for this signal.

Returns
String representation of units for this signal

◆ IsAllGood()

static ctre::phoenix::StatusCode ctre::phoenixpro::BaseStatusSignalValue::IsAllGood ( std::initializer_list< BaseStatusSignalValue * >  signals)
inlinestatic

Check 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()

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

◆ Status_Get()

static ctre::phoenix::StatusCode ctre::phoenixpro::BaseStatusSignalValue::Status_Get ( const char *  network,
int  deviceHash,
uint32_t  signal,
bool  bWaitForUpdate,
units::time::second_t  timeoutSeconds,
double *  outValue,
std::string *  units,
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
unitsUnit that corresponds with 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_WaitForAll() [1/2]

static ctre::phoenix::StatusCode ctre::phoenixpro::BaseStatusSignalValue::Status_WaitForAll ( const std::vector< BaseStatusSignalValue * > &  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::phoenixpro::BaseStatusSignalValue::Status_WaitForAll ( std::initializer_list< BaseStatusSignalValue * >  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::phoenixpro::BaseStatusSignalValue::WaitForAll ( units::time::second_t  timeoutSeconds,
const std::vector< BaseStatusSignalValue * > &  signals 
)
inlinestatic

Wait for 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.

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
timeoutSecondsHow long to wait for all the signals to arrive. Pass zero to just 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. 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::phoenixpro::BaseStatusSignalValue::WaitForAll ( units::time::second_t  timeoutSeconds,
std::initializer_list< BaseStatusSignalValue * >  signals 
)
inlinestatic

Wait for 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.

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
timeoutSecondsHow long to wait for all the signals to arrive. Pass zero to just 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. 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

◆ StatusSignalValue

template<typename T >
friend class StatusSignalValue
friend

Member Data Documentation

◆ baseValue

double ctre::phoenixpro::BaseStatusSignalValue::baseValue = 0
protected

◆ deviceIdentifier

hardware::DeviceIdentifier ctre::phoenixpro::BaseStatusSignalValue::deviceIdentifier
protected

◆ error

ctre::phoenix::StatusCode ctre::phoenixpro::BaseStatusSignalValue::error = ctre::phoenix::StatusCode::SigNotUpdated
protected

◆ signalName

std::string ctre::phoenixpro::BaseStatusSignalValue::signalName
protected

◆ spn

uint16_t ctre::phoenixpro::BaseStatusSignalValue::spn
protected

◆ timestamps

AllTimestamps ctre::phoenixpro::BaseStatusSignalValue::timestamps {}
protected

◆ timestampType

int ctre::phoenixpro::BaseStatusSignalValue::timestampType
protected

◆ units

std::string ctre::phoenixpro::BaseStatusSignalValue::units
protected

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