Goby3  3.1.5a
2024.05.23
goby::time::SystemClock Struct Reference

Essentially the same as std::chrono::system_clock except the time returned by SystemClock::now() can be "warped" (made to run faster than real time) for simulation purposes. To do this, set the appropriate parameters in SimulatorSettings. More...

#include <goby/time/system_clock.h>

Public Types

typedef std::chrono::microseconds duration
 Duration type. More...
 
typedef duration::rep rep
 
typedef duration::period period
 
typedef std::chrono::time_point< SystemClocktime_point
 

Static Public Member Functions

static time_point now () noexcept
 Returns the current system time unless SimulatorSettings::using_sim_time is set to true, in which case a simulated time is returned that is sped up by the SimulatorSettings::warp_factor. More...
 
template<typename TimeType >
static TimeType now ()
 return the current system clock time in one of the representations supported by the convert() family of functions More...
 
static goby::time::SystemClock::time_point warp (const std::chrono::system_clock::time_point &real_time)
 
static std::chrono::system_clock::time_point unwarp (const goby::time::SystemClock::time_point &sim_time)
 

Static Public Attributes

static const bool is_steady = false
 

Detailed Description

Essentially the same as std::chrono::system_clock except the time returned by SystemClock::now() can be "warped" (made to run faster than real time) for simulation purposes. To do this, set the appropriate parameters in SimulatorSettings.

Definition at line 47 of file system_clock.h.

Member Typedef Documentation

◆ duration

typedef std::chrono::microseconds goby::time::SystemClock::duration

Duration type.

We use microseconds (not nanoseconds) to avoid overflow at higher warp values

Definition at line 52 of file system_clock.h.

◆ period

typedef duration::period goby::time::SystemClock::period

Definition at line 54 of file system_clock.h.

◆ rep

typedef duration::rep goby::time::SystemClock::rep

Definition at line 53 of file system_clock.h.

◆ time_point

typedef std::chrono::time_point<SystemClock> goby::time::SystemClock::time_point

Definition at line 55 of file system_clock.h.

Member Function Documentation

◆ now() [1/2]

template<typename TimeType >
TimeType goby::time::SystemClock::now
static

return the current system clock time in one of the representations supported by the convert() family of functions

Definition at line 382 of file convert.h.

◆ now() [2/2]

static time_point goby::time::SystemClock::now ( )
inlinestaticnoexcept

Returns the current system time unless SimulatorSettings::using_sim_time is set to true, in which case a simulated time is returned that is sped up by the SimulatorSettings::warp_factor.

When using simulated time, the returned time (t_sim) is computed relative to SimulatorSettings::reference_time (t_0) with an accelerated progression by a factor of the SimulatorSettings::warp_time (w) such that: t_sim = (t-t_0)*w + t_0 A note when using MOOS middleware's MOOSTimeWarp: the value returned by this function is the same as MOOSTime() when

Definition at line 63 of file system_clock.h.

◆ unwarp()

static std::chrono::system_clock::time_point goby::time::SystemClock::unwarp ( const goby::time::SystemClock::time_point sim_time)
static

◆ warp()

static goby::time::SystemClock::time_point goby::time::SystemClock::warp ( const std::chrono::system_clock::time_point &  real_time)
static

Member Data Documentation

◆ is_steady

const bool goby::time::SystemClock::is_steady = false
static

Definition at line 56 of file system_clock.h.


The documentation for this struct was generated from the following files:
goby::time::SimulatorSettings::reference_time
static std::chrono::system_clock::time_point reference_time
Reference time when calculating SystemClock::now(). If this is unset, the default is 1 January of the...
Definition: simulation.h:42