os/Time.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Jan 18 14:11:39 CET 2006 Time.hpp
3 
4  Time.hpp - description
5  -------------------
6  begin : Wed January 18 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@mech.kuleuven.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef OS_TIME_HPP
40 #define OS_TIME_HPP
41 
42 #include <cmath>
43 
44 //rint function support implemented for MSVC
45 #include "rint.h"
46 
47 namespace RTT
48 {
49 
53  typedef double Seconds;
57  typedef long secs;
61  typedef long msecs;
65  typedef long usecs;
69  typedef long long nsecs;
73  typedef long long psecs;
74 
75  const long MSECS_IN_SECS = 1000;
76  const long USECS_IN_SECS = 1000 * MSECS_IN_SECS;
77  const long NSECS_IN_SECS = 1000 * USECS_IN_SECS;
78  const long long PSECS_IN_SECS = 1000LL * NSECS_IN_SECS;
79 
80  const long USECS_IN_MSECS = 1000;
81  const long NSECS_IN_MSECS = 1000 * USECS_IN_MSECS;
82  const long PSECS_IN_MSECS = 1000 * NSECS_IN_MSECS;
83 
84  const long NSECS_IN_USECS = 1000;
85  const long PSECS_IN_USECS = 1000 * NSECS_IN_USECS;
86 
87  const long PSECS_IN_NSECS = 1000;
88 
89  inline msecs secs_to_msecs(const secs s) { return s * MSECS_IN_SECS; }
90  inline usecs secs_to_usecs(const secs s) { return s * USECS_IN_SECS; }
91  inline nsecs secs_to_nsecs(const secs s) { return s * NSECS_IN_SECS; }
92  inline psecs secs_to_psecs(const secs s) { return s * PSECS_IN_SECS; }
93 
94  inline usecs msecs_to_usecs(const msecs ms) { return ms * USECS_IN_MSECS; }
95  inline nsecs msecs_to_nsecs(const msecs ms) { return ms * NSECS_IN_MSECS; }
96  inline psecs msecs_to_psecs(const msecs ms) { return ms * PSECS_IN_MSECS; }
97 
98  inline nsecs usecs_to_nsecs(const usecs us) { return us * NSECS_IN_USECS; }
99  inline psecs usecs_to_psecs(const usecs us) { return us * PSECS_IN_USECS; }
100 
101  inline psecs nsecs_to_psecs(const nsecs ns) { return ns * PSECS_IN_NSECS; }
102 
103  inline msecs Seconds_to_msecs(const Seconds s) { return msecs( rint( s * secs_to_msecs(1) ) ); }
104  inline Seconds msecs_to_Seconds(const msecs ns) { return Seconds( ns ) / Seconds(MSECS_IN_SECS); }
105  inline usecs Seconds_to_usecs(const Seconds s) { return usecs( rint( s * secs_to_usecs(1) ) ); }
106  inline Seconds usecs_to_Seconds(const usecs ns) { return Seconds( ns ) / Seconds(USECS_IN_SECS); }
107  inline nsecs Seconds_to_nsecs(const Seconds s) { return nsecs( rint( s * secs_to_nsecs(1) ) ); }
108  inline Seconds nsecs_to_Seconds(const nsecs ns) { return Seconds( ns ) / Seconds(NSECS_IN_SECS); }
109  inline psecs Seconds_to_psecs(const Seconds s) { return psecs( rint( s * secs_to_psecs(1) ) ); }
110  inline Seconds psecs_to_Seconds(const psecs ps) { return Seconds( ps ) / Seconds(PSECS_IN_SECS); }
111 }
112 
113 #endif
usecs Seconds_to_usecs(const Seconds s)
Definition: os/Time.hpp:105
const long NSECS_IN_SECS
Definition: os/Time.hpp:77
const long MSECS_IN_SECS
Definition: os/Time.hpp:75
Seconds msecs_to_Seconds(const msecs ns)
Definition: os/Time.hpp:104
double Seconds
Definition: os/Time.hpp:53
nsecs usecs_to_nsecs(const usecs us)
Definition: os/Time.hpp:98
Seconds nsecs_to_Seconds(const nsecs ns)
Definition: os/Time.hpp:108
psecs msecs_to_psecs(const msecs ms)
Definition: os/Time.hpp:96
msecs Seconds_to_msecs(const Seconds s)
Definition: os/Time.hpp:103
psecs nsecs_to_psecs(const nsecs ns)
Definition: os/Time.hpp:101
const long long PSECS_IN_SECS
Definition: os/Time.hpp:78
long secs
Definition: os/Time.hpp:57
long long psecs
Definition: os/Time.hpp:73
const long NSECS_IN_MSECS
Definition: os/Time.hpp:81
const long PSECS_IN_NSECS
Definition: os/Time.hpp:87
nsecs msecs_to_nsecs(const msecs ms)
Definition: os/Time.hpp:95
psecs usecs_to_psecs(const usecs us)
Definition: os/Time.hpp:99
psecs Seconds_to_psecs(const Seconds s)
Definition: os/Time.hpp:109
long usecs
Definition: os/Time.hpp:65
const long USECS_IN_SECS
Definition: os/Time.hpp:76
psecs secs_to_psecs(const secs s)
Definition: os/Time.hpp:92
const long USECS_IN_MSECS
Definition: os/Time.hpp:80
const long PSECS_IN_USECS
Definition: os/Time.hpp:85
usecs secs_to_usecs(const secs s)
Definition: os/Time.hpp:90
long msecs
Definition: os/Time.hpp:61
Seconds psecs_to_Seconds(const psecs ps)
Definition: os/Time.hpp:110
nsecs secs_to_nsecs(const secs s)
Definition: os/Time.hpp:91
nsecs Seconds_to_nsecs(const Seconds s)
Definition: os/Time.hpp:107
const long NSECS_IN_USECS
Definition: os/Time.hpp:84
Seconds usecs_to_Seconds(const usecs ns)
Definition: os/Time.hpp:106
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
long long nsecs
Definition: os/Time.hpp:69
msecs secs_to_msecs(const secs s)
Definition: os/Time.hpp:89
const long PSECS_IN_MSECS
Definition: os/Time.hpp:82
usecs msecs_to_usecs(const msecs ms)
Definition: os/Time.hpp:94


rtt
Author(s): RTT Developers
autogenerated on Fri Oct 25 2019 03:59:44