Simulation time source. More...
#include <utils/time/simts.h>
Public Member Functions | |
SimulatorTimeSource () | |
Constructor. | |
virtual | ~SimulatorTimeSource () |
Destructor. | |
virtual void | get_time (timeval *tv) const |
Get the current time. | |
virtual timeval | conv_to_realtime (const timeval *tv) const |
Convert a time given w.r.t. | |
void | set_start (float initial_offset) |
Set start time. | |
void | set_sim_offset (float sim_offset) |
Set simulation offset. |
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.
Definition at line 32 of file simts.h.
fawkes::SimulatorTimeSource::SimulatorTimeSource | ( | ) |
Constructor.
Definition at line 43 of file simts.cpp.
References fawkes::Clock::get_systime(), and fawkes::Clock::instance().
fawkes::SimulatorTimeSource::~SimulatorTimeSource | ( | ) | [virtual] |
timeval fawkes::SimulatorTimeSource::conv_to_realtime | ( | const timeval * | tv | ) | const [virtual] |
Convert a time given w.r.t.
this time sources into system time.
tv | the time to convert |
Implements fawkes::TimeSource.
Definition at line 69 of file simts.cpp.
References fawkes::Time::in_sec().
void fawkes::SimulatorTimeSource::get_time | ( | timeval * | tv | ) | const [virtual] |
Get the current time.
tv | the current time is written to this timeval |
Implements fawkes::TimeSource.
Definition at line 58 of file simts.cpp.
References fawkes::Time::get_timeval().
void fawkes::SimulatorTimeSource::set_sim_offset | ( | float | sim_offset | ) |
Set simulation offset.
sim_offset | simulation offset in seconds. |
Definition at line 106 of file simts.cpp.
References fawkes::Clock::get_systime().
void fawkes::SimulatorTimeSource::set_start | ( | float | initial_offset | ) |
Set start time.
initial_offset | initial offset in seconds |
Definition at line 93 of file simts.cpp.
References fawkes::Clock::get_systime().