CTRE Phoenix Pro C++ 23.0.12
ctre::phoenixpro::Timestamp Class Reference

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

#include <ctre/phoenixpro/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)
 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 is not currently implemented in this version of 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::phoenixpro::Timestamp::Timestamp ( units::time::second_t  time,
TimestampSource  source 
)
inline

Construct a new Timestamp for the given source.

Parameters
timeThe time in seconds
sourceThe timestamp source

◆ Timestamp() [2/2]

ctre::phoenixpro::Timestamp::Timestamp ( )
inline

Construct a new invalid Timestamp.

Member Function Documentation

◆ GetLatency()

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

Get the latency of this timestamp compared to now.

Returns
Difference between now and this timestamp

◆ GetSource()

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

Get the source of this timestamp.

Returns
Source of this timestamp

◆ GetTime()

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

Get the time in seconds as reported from this timestamp.

Returns
Time in seconds

◆ IsValid()

bool ctre::phoenixpro::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: