StopWatch.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
3  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef UTIL_STOPWATCH_H
19 #define UTIL_STOPWATCH_H
20 
21 // ---- local includes ------------------------------------------------------ ;
22 
23 #include "../Util/Message.h"
24 
25 // ---- global includes ----------------------------------------------------- ;
26 
27 // ---- remap, typedefs ----------------------------------------------------- ;
28 
32 };
33 
34 // ---- class definition ---------------------------------------------------- ;
35 
36 /*
37  stopwatch features
38  This class allows to measure discrete time intervalls in your program.
39 */
40 class CStopWatch : public CMessage
41 {
42 
43  protected:
44 
45  // ---- protected datas ------------------------------------------------ ;
46 
47  long m_iFirst;
48  long m_iLast;
50 
51  #if defined(__QNX__)
52  timespec m_FirstTime;
53  timespec m_LastTime;
54  timespec m_TempTime;
55  timespec m_ActualTime;
56  #elif defined(_WIN32)
57  double frequencyE;
58  LARGE_INTEGER m_FirstTime;
59  LARGE_INTEGER m_LastTime;
60  LARGE_INTEGER m_TempTime;
61  LARGE_INTEGER m_ActualTime;
62  #else
63  timeval m_FirstTime;
64  timeval m_LastTime;
65  timeval m_TempTime;
66  timeval m_ActualTime;
67  #endif
68 
71 
73 
74  // ---- auxiliary functions ----------------------------------------------- ;
75 
76  public:
77 
78  // ---- public datas ------------------------------------------------------ ;
79 
80  // ---- constructor/destructor -------------------------------------------- ;
81 
82  // default constructor with timetype util_REAL_TIME
83  CStopWatch();
84 
85 
86  // constructor
88 
89  // copy constructor
90  CStopWatch(const CStopWatch& );
91 
92  // ---- operators --------------------------------------------------------- ;
93 
94  // assignment operator
96 
97  // ---- query functions --------------------------------------------------- ;
98 
99  // returns the time type
101 
102  // ---- modify functions -------------------------------------------------- ;
103 
104  // sets the time type
105  void timeType(const util_TimeMeasurementType& riTimeType);
106 
107  // ---- I/O --------------------------------------------------------------- ;
108 
109  // returns the difference between start and stop time in [s]
110  double executionTime();
111 
112  // returns the real time in [s]
113  double realTime();
114 
115  // returns the real time resolution in [s]
116  double realTimeResolution();
117 
118  // ---- exec functions ---------------------------------------------------- ;
119 
120  // sets start time to current clock value
121  void start();
122 
123  // sets stop time to current clock value
124  void stop();
125 
126  // continues after a call of stop()
127  void cont();
128 
129  // wait realtime in [ms]
130  void wait(unsigned int uiTime);
131 
132  // returns the current date
133  void date(char* acDate) const;
134 
135  // returns the current weekday
136  void weekday(char* acWeekday) const;
137 
138  // tests, if there is an overflow at clock counter
139  void testOverflow();
140 };
141 
142 // ---- extern I/O ---------------------------------------------------------- ;
143 
144 // ---- public inline functions --------------------------------------------- ;
145 
147 {
148  return(m_iTimeType);
149 };
150 
151 inline void CStopWatch::timeType(const util_TimeMeasurementType& riTimeType)
152 {
153  m_iTimeType = riTimeType;
154 };
155 
156 // -------------------------------------------------------------------------- ;
157 
158 #endif // UTIL_STOPWATCH_H
CStopWatch & operator=(const CStopWatch &)
Definition: StopWatch.cpp:135
void wait(unsigned int uiTime)
Definition: StopWatch.cpp:333
long m_iLast
Definition: StopWatch.h:48
void weekday(char *acWeekday) const
Definition: StopWatch.cpp:400
long m_iFirst
Definition: StopWatch.h:47
void stop()
Definition: StopWatch.cpp:236
timeval m_FirstTime
Definition: StopWatch.h:63
util_TimeMeasurementType
Definition: StopWatch.h:29
timeval m_LastTime
Definition: StopWatch.h:64
util_TimeMeasurementType m_iTimeType
Definition: StopWatch.h:72
void cont()
Definition: StopWatch.cpp:268
double executionTime()
Definition: StopWatch.cpp:166
double realTime()
Definition: StopWatch.cpp:299
void start()
Definition: StopWatch.cpp:211
timeval m_TempTime
Definition: StopWatch.h:65
bool m_bStartFlag
Definition: StopWatch.h:69
void date(char *acDate) const
Definition: StopWatch.cpp:379
util_TimeMeasurementType timeType() const
Definition: StopWatch.h:146
double realTimeResolution()
Definition: StopWatch.cpp:315
timeval m_ActualTime
Definition: StopWatch.h:66
double m_fOverflowTime
Definition: StopWatch.h:49
void testOverflow()
Definition: StopWatch.cpp:422
bool m_bStopFlag
Definition: StopWatch.h:70


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19