Orocos Real-Time Toolkit  2.9.0
TimeService.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Apr 17 16:01:36 CEST 2002 TimeService.h
3 
4  TimeService.h - description
5  -------------------
6  begin : Wed April 17 2002
7  copyright : (C) 2002 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10 ***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18 
19 
20 
21 #ifndef RTT_TIME_SERVICE_HPP
22 #define RTT_TIME_SERVICE_HPP
23 
24 #include "Time.hpp"
25 #include "../rtt-config.h"
26 
27 namespace RTT
28 { namespace os {
29 
30 
36  {
37  public:
41  typedef double Seconds;
42 
46  typedef long secs;
47 
51  typedef long msecs;
52 
56  typedef long usecs;
57 
61  typedef long long nsecs;
62 
66  typedef long long ticks;
67 
68  public:
69  static TimeService* Instance();
70 
77  static bool Release();
78 
82  virtual ~TimeService();
83 
90  ticks ticksGet() const { return getTicks(); }
91 
97  ticks getTicks() const;
98 
106  ticks ticksGet( ticks &relativeTime ) const { return getTicks( relativeTime ); }
107 
114  ticks getTicks( ticks &relativeTime ) const;
115 
122  ticks ticksSince( ticks relativeTime ) const;
123 
133  Seconds secondsGet( ticks &relativeTime ) const { return getSeconds(relativeTime); }
134 
143  Seconds getSeconds( ticks &relativeTime ) const;
144 
151  Seconds secondsSince( ticks relativeTime ) const;
152 
157  Seconds secondsChange( Seconds delta );
158 
163  ticks ticksChange( ticks delta );
164 
170  void enableSystemClock( bool yes_no );
171 
176  bool systemClockEnabled() const;
177 
183  nsecs getNSecs() const;
184 
191  nsecs getNSecs( nsecs &relativeTime ) const;
192 
198  static ticks nsecs2ticks( const nsecs m );
199 
203  static nsecs ticks2nsecs( const ticks t );
204 
208  static const ticks InfiniteTicks;
209 
213  static const nsecs InfiniteNSecs;
214 
218  static const Seconds InfiniteSeconds;
219  protected:
220 
224  TimeService();
225 
226  private:
227 
231  static TimeService* _instance;
232 
236  ticks offset;
237 
238  bool use_clock;
239  };
240 }} // namespace RTT
241 
242 #endif
long secs
An integer representation of seconds.
Definition: TimeService.hpp:46
The TimeService is used for system-wide time keeping and conversions.
Definition: TimeService.hpp:35
long long ticks
The type for the systems clock tick.
Definition: TimeService.hpp:66
#define RTT_API
Definition: rtt-config.h:97
static const ticks InfiniteTicks
The largest number representable in ticks.
long usecs
An integer representation of microseconds.
Definition: TimeService.hpp:56
ticks ticksGet() const
Get current tick of the System clock.
Definition: TimeService.hpp:90
static const nsecs InfiniteNSecs
The largest number representable in nsecs.
Seconds secondsGet(ticks &relativeTime) const
Get the time in seconds passed since a certain moment.
static const Seconds InfiniteSeconds
The largest number representable in Seconds.
ticks ticksGet(ticks &relativeTime) const
Get clicks passed since a certain moment.
double Seconds
The type used to store SI unit time keeping.
Definition: TimeService.hpp:41
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
long long nsecs
An integer representation of nanoseconds.
Definition: TimeService.hpp:61
long msecs
An integer representation of miliseconds.
Definition: TimeService.hpp:51