SatCat5
satcat5::datetime::Clock Class Reference

Detailed Description

Real-time clock for tracking date/time.

The global SATCAT5_CLOCK measures relative time only. This object tracks that TimeRef to indicate the current date/time.

To use this class:

  • Obtain the current date/time from an external source.
  • Convert to the SatCat5 internal format and call set.
  • Call now, gps, or ptp at any point to obtain the current date/time in the designated format.

Definition at line 169 of file datetime.h.

#include <datetime.h>

Inheritance diagram for satcat5::datetime::Clock:
[legend]
Collaboration diagram for satcat5::datetime::Clock:
[legend]

Public Member Functions

 Clock ()
 Constructor defaults to T = 0 (unknown).
 
u32 uptime_msec () const
 Get elapsed time since startup, in milliseconds. More...
 
u32 uptime_usec () const
 Get elapsed time since startup, in microseconds. More...
 
void reset (bool full=false)
 Reset internals after changes to SATCAT5_CLOCK. More...
 
void set (s64 gps)
 Set current GPS time. More...
 
s64 now () const
 Current time as milliseconds since GPS epoch.
 
satcat5::datetime::GpsTime gps () const
 Current time as GPS week number and time-of-week.
 
satcat5::ptp::Time ptp () const
 Current time as Precision Time Protocol timestamp.
 
satcat5::datetime::RtcTime rtc () const
 Current time as ISL12082 real-time clock timestamp.
 

Protected Member Functions

void timer_event () override
 Child class MUST override this method.
 
void timer_once (unsigned msec)
 Configure a one-time notification after X milliseconds.
 
void timer_every (unsigned msec)
 Configure a repeating notification every X milliseconds.
 
void timer_stop ()
 Stop all future notifications.
 
unsigned timer_interval () const
 Accessor for recurring timer interval, if one is set.
 
unsigned timer_remaining () const
 Accessor for time to next event, if one is set.
 

Static Protected Member Functions

static unsigned count_timer ()
 Count all objects of this type, including idle timers.
 

Protected Attributes

satcat5::util::TimeVal m_tref
 
u32 m_tcount
 
s64 m_gps
 

Private Member Functions

void query (unsigned elapsed_msec)
 

Private Attributes

satcat5::poll::Timerm_next
 
unsigned m_trem
 
unsigned m_tnext
 

Member Function Documentation

◆ reset()

void Clock::reset ( bool  full = false)

Reset internals after changes to SATCAT5_CLOCK.

Optionally reset uptime and GPS time.

Definition at line 49 of file datetime.cc.

◆ set()

void Clock::set ( s64  gps)

Set current GPS time.

(0 = Unknown) For conversion

See also
from_gps, from_ptp, or from_rtc.

Definition at line 54 of file datetime.cc.

◆ uptime_msec()

u32 satcat5::datetime::Clock::uptime_msec ( ) const
inline

Get elapsed time since startup, in milliseconds.

Returns
Uptime in milliseconds, wraps every ~49 days. This value is useful for ICMP timestamps, or for elapsed-time that exceeds the dynamic range of a satcat5::util::TimeVal.

Definition at line 178 of file datetime.h.

◆ uptime_usec()

u32 Clock::uptime_usec ( ) const

Get elapsed time since startup, in microseconds.

Returns
Uptime in microseconds, wraps every ~1.2 hours.

Definition at line 44 of file datetime.cc.


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