Fawkes API  Fawkes Development Version
fawkes::SimulatorTimeSource Class Reference

Simulation time source. More...

#include <>>

Inheritance diagram for fawkes::SimulatorTimeSource:

Public Member Functions

 SimulatorTimeSource ()
 Constructor. More...
 
virtual ~SimulatorTimeSource ()
 Destructor. More...
 
virtual void get_time (timeval *tv) const
 Get the current time. More...
 
virtual timeval conv_to_realtime (const timeval *tv) const
 Convert a time given w.r.t. More...
 
virtual timeval conv_native_to_exttime (const timeval *tv) const
 Convert a native time to the external time. More...
 
void set_start (float initial_offset)
 Set start time. More...
 
void set_sim_offset (float sim_offset)
 Set simulation offset. More...
 
- Public Member Functions inherited from fawkes::TimeSource
virtual ~TimeSource ()
 Destructor. More...
 

Detailed Description

Simulation time source.

This class is an utility to provide a generic time source for time in a simulated environment. It can be restarted at an arbitrary time with an arbitrary offset. It will then read the current real system time and save the initial offset. Each time you query the time source it will return a given fixed time. The time is advanced by setting a new offset (usually in every cycle).

This implementation is rather primitive at the moment and could use some love.

Author
Tim Niemueller

Definition at line 32 of file simts.h.

Constructor & Destructor Documentation

◆ SimulatorTimeSource()

fawkes::SimulatorTimeSource::SimulatorTimeSource ( )

Constructor.

Definition at line 43 of file simts.cpp.

References fawkes::Clock::get_systime(), and fawkes::Clock::instance().

◆ ~SimulatorTimeSource()

fawkes::SimulatorTimeSource::~SimulatorTimeSource ( )
virtual

Destructor.

Definition at line 52 of file simts.cpp.

Member Function Documentation

◆ conv_native_to_exttime()

timeval fawkes::SimulatorTimeSource::conv_native_to_exttime ( const timeval *  tv) const
virtual

Convert a native time to the external time.

When communicating with another instance which provides times in some timeformat native to the underlying time source (e.g. received from a simulation) it must be converted to a Fawkes time.

Parameters
tvtime in external time source native format
Returns
time in Fawkes comparable to other times generated using the external timesource.

Implements fawkes::TimeSource.

Definition at line 90 of file simts.cpp.

◆ conv_to_realtime()

timeval fawkes::SimulatorTimeSource::conv_to_realtime ( const timeval *  tv) const
virtual

Convert a time given w.r.t.

this time sources into system time.

Parameters
tvthe time to convert
Returns
the converted time

Implements fawkes::TimeSource.

Definition at line 69 of file simts.cpp.

References fawkes::Time::in_sec().

◆ get_time()

void fawkes::SimulatorTimeSource::get_time ( timeval *  tv) const
virtual

Get the current time.

Parameters
tvthe current time is written to this timeval

Implements fawkes::TimeSource.

Definition at line 58 of file simts.cpp.

References fawkes::Time::get_timeval().

◆ set_sim_offset()

void fawkes::SimulatorTimeSource::set_sim_offset ( float  sim_offset)

Set simulation offset.

Parameters
sim_offsetsimulation offset in seconds.

Definition at line 113 of file simts.cpp.

References fawkes::Clock::get_systime().

◆ set_start()

void fawkes::SimulatorTimeSource::set_start ( float  initial_offset)

Set start time.

Parameters
initial_offsetinitial offset in seconds

Definition at line 100 of file simts.cpp.

References fawkes::Clock::get_systime().


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