CTRE Phoenix Pro C++ 23.0.12
ctre::phoenixpro::StatusSignalValue< T > Class Template Reference

#include <ctre/phoenixpro/StatusSignalValue.hpp>

Inheritance diagram for ctre::phoenixpro::StatusSignalValue< T >:
ctre::phoenixpro::BaseStatusSignalValue

Public Member Functions

std::string ToString () const
 
GetValue () const
 Gets the cached value from this status signal value. More...
 
StatusSignalValue< T > & Refresh (bool ReportOnError=true)
 Refreshes this status signal value. More...
 
StatusSignalValue< T > & WaitForUpdate (units::time::second_t timeoutSec, bool ReportOnError=true)
 Waits up to timeoutSec to get the up-to-date status signal value. More...
 
SignalMeasurement< T > GetDataCopy () const
 Get a basic data-only container with this information, to be used for things such as data logging. More...
 
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...
 
std::function< T()> AsSupplier ()
 Returns a lambda that calls Refresh and GetValue on this object. More...
 
- Public Member Functions inherited from ctre::phoenixpro::BaseStatusSignalValue
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...
 

Friends

class hardware::ParentDevice
 
std::ostream & operator<< (std::ostream &os, const StatusSignalValue< T > &data)
 

Additional Inherited Members

- Static Public Member Functions inherited from ctre::phoenixpro::BaseStatusSignalValue
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 inherited from ctre::phoenixpro::BaseStatusSignalValue
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 inherited from ctre::phoenixpro::BaseStatusSignalValue
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 inherited from ctre::phoenixpro::BaseStatusSignalValue
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
 

Member Function Documentation

◆ AsSupplier()

template<typename T >
std::function< T()> ctre::phoenixpro::StatusSignalValue< T >::AsSupplier ( )
inline

Returns a lambda that calls Refresh and GetValue on this object.

This is useful for command-based programming.

Returns
std::function<T()> that calls Refresh() and returns this value.

◆ GetDataCopy()

template<typename T >
SignalMeasurement< T > ctre::phoenixpro::StatusSignalValue< T >::GetDataCopy ( ) const
inline

Get a basic data-only container with this information, to be used for things such as data logging.

Returns
Basic structure with all relevant information

◆ GetValue()

template<typename T >
T ctre::phoenixpro::StatusSignalValue< T >::GetValue ( ) const
inline

Gets the cached value from this status signal value.

Gets the cached value. To make sure the value is up-to-date call Refresh() or WaitForUpdate()

Returns
Cached value

◆ Refresh()

template<typename T >
StatusSignalValue< T > & ctre::phoenixpro::StatusSignalValue< T >::Refresh ( bool  ReportOnError = true)
inline

Refreshes this status signal value.

If the user application caches this StatusSignalValue object instead of periodically fetching it from the hardware device, this function must be called to fetch fresh data.

This performs a non-blocking refresh operation. If you want to wait until you receive the signal, call WaitForUpdate() instead.

Parameters
ReportOnErrorReport to the Driver Station if this refresh returns a StatusCode other than OK
Returns
Reference to itself

◆ SetUpdateFrequency()

template<typename T >
ctre::phoenix::StatusCode ctre::phoenixpro::StatusSignalValue< T >::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

◆ ToString()

template<typename T >
std::string ctre::phoenixpro::StatusSignalValue< T >::ToString ( ) const
inline

◆ WaitForUpdate()

template<typename T >
StatusSignalValue< T > & ctre::phoenixpro::StatusSignalValue< T >::WaitForUpdate ( units::time::second_t  timeoutSec,
bool  ReportOnError = true 
)
inline

Waits up to timeoutSec to get the up-to-date status signal value.

This performs a blocking refresh operation. If you want to non-blocking refresh the signal, call Refresh() instead.

Parameters
timeoutSecTimeout to wait for an update on the signal
ReportOnErrorReport to the Driver Station if this refresh returns a StatusCode other than OK
Returns
Reference to itself

Friends And Related Function Documentation

◆ hardware::ParentDevice

template<typename T >
friend class hardware::ParentDevice
friend

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const StatusSignalValue< T > &  data 
)
friend

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