Fawkes API
Fawkes Development Version
|
This is supposed to be the central clock in Fawkes. More...
#include <utils/time/clock.h>
Public Types | |
enum | TimesourceSelector { DEFAULT, REALTIME, EXTERNAL } |
Select the time source. More... | |
Public Member Functions | |
virtual | ~Clock () |
Destructor. More... | |
void | register_ext_timesource (TimeSource *ts, bool make_default=false) |
Register an external time source. More... | |
void | set_ext_default_timesource (bool ext_is_default) |
Set/unset the external time source as the default time source. More... | |
bool | is_ext_default_timesource () const |
Checks whether the external time source is the default time soucre. More... | |
bool | has_ext_timesource () const |
Check whether an external time source is registered. More... | |
Time | ext_to_realtime (const Time &t) |
Convert a time given w.r.t. More... | |
Time | native_to_time (const Time &t) |
Convert some native time to a Fawkes time. More... | |
void | remove_ext_timesource (TimeSource *ts=0) |
Remove external time source. More... | |
void | get_time (struct timeval *tv) const |
Returns the time of the selected time source. More... | |
void | get_time (struct timeval *tv, TimesourceSelector sel) const |
Returns the time of the selected time source. More... | |
void | get_time (Time &time) const |
Returns the time of the selected time source. More... | |
void | get_time (Time &time, TimesourceSelector sel) const |
Returns the time of the selected time source. More... | |
void | get_time (Time *time) const |
Returns the time of the selected time source. More... | |
void | get_time (Time *time, TimesourceSelector sel) const |
Returns the time of the selected time source. More... | |
void | get_systime (struct timeval *tv) const |
Returns the system time. More... | |
void | get_systime (Time &time) const |
Returns the time of the selected time source. More... | |
void | get_systime (Time *time) const |
Returns the time of the selected time source. More... | |
Time | now () const |
Get the current time. More... | |
float | elapsed (Time *t) const |
How much time has elapsed since t? Calculated as "now - t" in seconds. More... | |
float | sys_elapsed (Time *t) const |
How much system time has elapsed since t? Use only for system time criteria like timeouts. More... | |
Static Public Member Functions | |
static Clock * | instance () |
Clock initializer. More... | |
static void | finalize () |
Finalize. More... | |
This is supposed to be the central clock in Fawkes.
It is implemented as a singleton to ensure that there is only one object. So-called TimeSources can be registered at the Clock their current time can be retrieved through the Clock.
float fawkes::Clock::elapsed | ( | Time * | t | ) | const |
How much time has elapsed since t? Calculated as "now - t" in seconds.
t | time |
Definition at line 282 of file clock.cpp.
Referenced by FvAqtVisionThreads::empty_time().
Convert a time given w.r.t.
the external time source into the system time.
t | the time that is converted to the system time |
Definition at line 308 of file clock.cpp.
References fawkes::TimeSource::conv_to_realtime(), fawkes::Time::get_timeval(), and fawkes::Time::set_time().
void fawkes::Clock::get_systime | ( | struct timeval * | tv | ) | const |
Returns the system time.
tv | pointer to a timeval struct where the time is written to |
Definition at line 239 of file clock.cpp.
Referenced by FvAqtVisionThreads::FvAqtVisionThreads(), fawkes::GazsimTimesource::GazsimTimesource(), OpenPRSAgentThread::loop(), fawkes::TimeWait::mark_start(), fawkes::GazsimTimesource::on_time_sync_msg(), FvAqtVisionThreads::remove_thread(), FvAqtVisionThreads::remove_waiting_thread(), FestivalSynthThread::say(), fawkes::SimulatorTimeSource::set_sim_offset(), fawkes::SimulatorTimeSource::set_start(), fawkes::SimulatorTimeSource::SimulatorTimeSource(), fawkes::Time::stamp_systime(), fawkes::TimeWait::wait_systime(), and fawkes::Time::wait_systime().
void fawkes::Clock::get_systime | ( | Time & | time | ) | const |
void fawkes::Clock::get_systime | ( | Time * | time | ) | const |
void fawkes::Clock::get_time | ( | struct timeval * | tv | ) | const |
Returns the time of the selected time source.
tv | pointer to a timeval struct where the time is written to |
Definition at line 176 of file clock.cpp.
References fawkes::TimeSource::get_time().
Referenced by fawkes::Watch::clock_time(), get_time(), OpenPRSAgentThread::loop(), fawkes::TimeWait::mark_start(), fawkes::Watch::pause(), fawkes::Watch::reset(), fawkes::Time::stamp(), fawkes::Watch::start(), fawkes::Watch::stop(), fawkes::Time::Time(), fawkes::TimeWait::wait(), and fawkes::Watch::watch_time().
void fawkes::Clock::get_time | ( | struct timeval * | tv, |
TimesourceSelector | sel | ||
) | const |
void fawkes::Clock::get_time | ( | Time & | time | ) | const |
Returns the time of the selected time source.
time | reference to a time where the result is stored |
Definition at line 193 of file clock.cpp.
References get_time().
void fawkes::Clock::get_time | ( | Time & | time, |
TimesourceSelector | sel | ||
) | const |
Returns the time of the selected time source.
time | reference to a time where the result is stored |
sel | allows to select the time source |
Definition at line 206 of file clock.cpp.
References get_time().
void fawkes::Clock::get_time | ( | Time * | time | ) | const |
Returns the time of the selected time source.
time | pointer to a Time instance |
Definition at line 216 of file clock.cpp.
References get_time().
void fawkes::Clock::get_time | ( | Time * | time, |
TimesourceSelector | sel | ||
) | const |
Returns the time of the selected time source.
time | pointer to a Time instance where the time is stored |
sel | allows to select the time source |
Definition at line 229 of file clock.cpp.
References get_time().
bool fawkes::Clock::has_ext_timesource | ( | ) | const |
|
static |
Clock initializer.
This one is static and has to be called to instantiate a Clock object. In further calls it just returns a pointer to the Clock object.
Definition at line 65 of file clock.cpp.
Referenced by fawkes::FawkesMainThread::FawkesMainThread(), fawkes::LaserOccupancyGrid::get_cell_costs(), fawkes::Interface::Interface(), fawkes::LaserOccupancyGrid::reset_old(), fawkes::SimulatorTimeSource::SimulatorTimeSource(), fawkes::Time::Time(), and fawkes::TimeWait::wait().
bool fawkes::Clock::is_ext_default_timesource | ( | ) | const |
Convert some native time to a Fawkes time.
If communicating with some entity using some native time format (e.g. a simulation giving offset timestamps from the simulation start) it is necessary to convert them to a time that the time is comparable to other times generated using the clock (and hence external timesource).
t | the time that is to be converted to the a Fawkes time |
Definition at line 333 of file clock.cpp.
References fawkes::TimeSource::conv_native_to_exttime(), fawkes::Time::get_timeval(), and fawkes::Time::set_time().
Time fawkes::Clock::now | ( | ) | const |
Get the current time.
Definition at line 269 of file clock.cpp.
References fawkes::Time::stamp().
Referenced by VisLocalizationThread::init(), RobotinoActThread::init(), LaserSimThread::loop(), DepthcamSimThread::loop(), VisLocalizationThread::loop(), LocalizationSimThread::loop(), ClipsAgentThread::loop(), RobotinoActThread::loop(), RobotinoSimThread::loop(), and fawkes::LaserOccupancyGrid::reset_old().
void fawkes::Clock::register_ext_timesource | ( | TimeSource * | ts, |
bool | make_default = false |
||
) |
Register an external time source.
ts | a pointer to the external time source |
make_default | if true, this time source is made the default timesource which means that for every call of get_time() the time of the external time source is returned |
Definition at line 92 of file clock.cpp.
Referenced by fawkes::TimeSourceAspectIniFin::init(), and GazsimTimesourceThread::init().
void fawkes::Clock::remove_ext_timesource | ( | TimeSource * | ts = 0 | ) |
Remove external time source.
If an external timesource is currently set it is removed. The time source will not be deleted but only the reference to it is removed.
ts | only remove time source if it equals ts, if NULL remove no matter what. |
Definition at line 108 of file clock.cpp.
Referenced by fawkes::TimeSourceAspectIniFin::finalize(), and GazsimTimesourceThread::finalize().
void fawkes::Clock::set_ext_default_timesource | ( | bool | ext_is_default | ) |
float fawkes::Clock::sys_elapsed | ( | Time * | t | ) | const |
How much system time has elapsed since t? Use only for system time criteria like timeouts.
t | time |
Definition at line 295 of file clock.cpp.
References fawkes::time_diff_sec().