CTRE Phoenix 6 C++ 24.2.0
ctre::phoenix6::Timestamp Class Reference

Information about the timestamp of a signal. More...

#include <ctre/phoenix6/Timestamp.hpp>

Public Types

enum class  TimestampSource { System = 0 , CANivore = 1 , Device = 2 }
 Source of the timestamp. More...
 

Public Member Functions

 Timestamp (units::time::second_t time, TimestampSource source, bool valid=true)
 Construct a new Timestamp for the given source. More...
 
 Timestamp ()
 Construct a new invalid Timestamp. More...
 
units::time::second_t GetTime () const
 Get the time in seconds as reported from this timestamp. More...
 
TimestampSource GetSource () const
 Get the source of this timestamp. More...
 
units::time::second_t GetLatency () const
 Get the latency of this timestamp compared to now. More...
 
bool IsValid () const
 Returns if this Timestamp is valid or not. More...
 

Detailed Description

Information about the timestamp of a signal.

Member Enumeration Documentation

◆ TimestampSource

Source of the timestamp.

Enumerator
System 

Timestamp as reported by the system.

This timestamp is captured when the system receives the signal value.

This timestamp is present on all systems and is guaranteed to be monotonic. However, this timestamp is the least accurate due to processing delays within the system.

CANivore 

Timestamp as reported by the CANivore.

This timestamp is captured when the CANivore receives the signal value.

The CANivore is synchronized to the system monotonic clock and benefits from reduced latency over the TimestampSource::System timestamp.

On the native roboRIO CAN bus, this timestamp is equivalent to the TimestampSource::System timestamp.

When used with CANivore, the only inaccuracy in this measurement is latency from CAN bus arbitration.

Device 

This timestamp source requires Phoenix Pro.

Timestamp as reported by the device. This timestamp is captured when the device transmits the signal value. Because it is timestamped in the device, it is the most accurate timestamp source.

This timestamp is synchronized to the CANivore clock, which is itself synchronized to the system monotonic clock. As a result, this timestamp source requires a CANivore.

It can be assumed there is no latency between this timestamp and when the data was taken.

Constructor & Destructor Documentation

◆ Timestamp() [1/2]

ctre::phoenix6::Timestamp::Timestamp ( units::time::second_t  time,
TimestampSource  source,
bool  valid = true 
)
inline

Construct a new Timestamp for the given source.

Parameters
timeThe time in seconds
sourceThe timestamp source
validWhether the timestamp is valid

◆ Timestamp() [2/2]

ctre::phoenix6::Timestamp::Timestamp ( )
inline

Construct a new invalid Timestamp.

Member Function Documentation

◆ GetLatency()

units::time::second_t ctre::phoenix6::Timestamp::GetLatency ( ) const
inline

Get the latency of this timestamp compared to now.

Returns
Difference between now and this timestamp

◆ GetSource()

TimestampSource ctre::phoenix6::Timestamp::GetSource ( ) const
inline

Get the source of this timestamp.

Returns
Source of this timestamp

◆ GetTime()

units::time::second_t ctre::phoenix6::Timestamp::GetTime ( ) const
inline

Get the time in seconds as reported from this timestamp.

Returns
Time in seconds

◆ IsValid()

bool ctre::phoenix6::Timestamp::IsValid ( ) const
inline

Returns if this Timestamp is valid or not.

Returns
true when this is valid

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