Fawkes API  Fawkes Development Version
simts.h
1 
2 /***************************************************************************
3  * simts.h - Simulator time source
4  *
5  * Created: Mon Feb 25 15:44:00 2008
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __UTILS_TIME_SIMTS_H_
25 #define __UTILS_TIME_SIMTS_H_
26 
27 #include <utils/time/clock.h>
28 #include <utils/time/timesource.h>
29 
30 namespace fawkes {
31 
33 {
34  public:
36  virtual ~SimulatorTimeSource();
37 
38  virtual void get_time(timeval* tv) const;
39  virtual timeval conv_to_realtime(const timeval* tv) const;
40  virtual timeval conv_native_to_exttime(const timeval* tv) const;
41 
42  void set_start(float initial_offset);
43  void set_sim_offset(float sim_offset);
44 
45  private:
46  Clock *clock;
47  Time start_time; // sim AND realtime
48  Time current_simtime;
49  Time current_realtime;
50  float start_simoffset;
51  float current_simoffset;
52 };
53 
54 } // end namespace fawkes
55 
56 #endif
virtual timeval conv_to_realtime(const timeval *tv) const
Convert a time given w.r.t.
Definition: simts.cpp:69
virtual void get_time(timeval *tv) const
Get the current time.
Definition: simts.cpp:58
Fawkes library namespace.
SimulatorTimeSource()
Constructor.
Definition: simts.cpp:43
This is supposed to be the central clock in Fawkes.
Definition: clock.h:34
void set_start(float initial_offset)
Set start time.
Definition: simts.cpp:100
A class for handling time.
Definition: time.h:91
TimeSource interface.
Definition: timesource.h:36
virtual ~SimulatorTimeSource()
Destructor.
Definition: simts.cpp:52
Simulation time source.
Definition: simts.h:32
void set_sim_offset(float sim_offset)
Set simulation offset.
Definition: simts.cpp:113
virtual timeval conv_native_to_exttime(const timeval *tv) const
Convert a native time to the external time.
Definition: simts.cpp:90