QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MonotonicClock Namespace Reference

Functions

uint64_t nowUs ()
 
template<typename Rep , typename Period >
constexpr std::optional< std::chrono::duration< Rep, Period > > age (std::chrono::duration< Rep, Period > timestamp, std::chrono::duration< Rep, Period > now)
 Age of timestamp at now, both in the same unit; empty for a missing or future timestamp.
 
constexpr std::optional< std::chrono::microseconds > age (uint64_t timestampUs, uint64_t nowUs)
 
constexpr std::chrono::microseconds remaining (uint64_t timestampUs, uint64_t nowUs, std::chrono::microseconds lifetime)
 Time left before a receipt reaches lifetime; zero for a missing, future or expired one.
 
constexpr bool fresh (uint64_t timestampUs, uint64_t nowUs, std::chrono::microseconds lifetime)
 Whether a receipt is younger than lifetime.
 
constexpr bool withinAge (uint64_t timestampUs, uint64_t nowUs, std::chrono::microseconds maximumAge)
 Whether a receipt is at most maximumAge old, its limit included.
 

Detailed Description

Timestamps from one monotonic clock domain. A zero (or negative) timestamp means "never", and a timestamp later than now has no age.

Function Documentation

◆ age() [1/2]

template<typename Rep , typename Period >
constexpr std::optional< std::chrono::duration< Rep, Period > > MonotonicClock::age ( std::chrono::duration< Rep, Period >  timestamp,
std::chrono::duration< Rep, Period >  now 
)
constexpr

Age of timestamp at now, both in the same unit; empty for a missing or future timestamp.

Definition at line 19 of file MonotonicClock.h.

Referenced by age(), NTRIPConnectionStats::correctionAgeSec(), NTRIPSourceTableController::fetch(), remaining(), GPSCorrectionSelector::submit(), and withinAge().

◆ age() [2/2]

constexpr std::optional< std::chrono::microseconds > MonotonicClock::age ( uint64_t  timestampUs,
uint64_t  nowUs 
)
constexpr

Definition at line 28 of file MonotonicClock.h.

References age(), and nowUs().

◆ fresh()

constexpr bool MonotonicClock::fresh ( uint64_t  timestampUs,
uint64_t  nowUs,
std::chrono::microseconds  lifetime 
)
constexpr

Whether a receipt is younger than lifetime.

Definition at line 44 of file MonotonicClock.h.

References nowUs(), and remaining().

Referenced by NTRIPSourceTableController::fetch(), GPSIntegrityReport::freshAt(), and GPSInputMonitor::update().

◆ nowUs()

uint64_t MonotonicClock::nowUs ( )
inline

◆ remaining()

constexpr std::chrono::microseconds MonotonicClock::remaining ( uint64_t  timestampUs,
uint64_t  nowUs,
std::chrono::microseconds  lifetime 
)
constexpr

Time left before a receipt reaches lifetime; zero for a missing, future or expired one.

Definition at line 34 of file MonotonicClock.h.

References age(), and nowUs().

Referenced by fresh().

◆ withinAge()

constexpr bool MonotonicClock::withinAge ( uint64_t  timestampUs,
uint64_t  nowUs,
std::chrono::microseconds  maximumAge 
)
constexpr

Whether a receipt is at most maximumAge old, its limit included.

Definition at line 50 of file MonotonicClock.h.

References age(), and nowUs().

Referenced by NMEA::NavigationEpochAssembler::expireUntimedMetadata().