StopWatch.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
00003  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *   http://www.apache.org/licenses/LICENSE-2.0
00010 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef UTIL_STOPWATCH_H
00019 #define UTIL_STOPWATCH_H
00020 
00021 // ---- local includes ------------------------------------------------------ ;
00022 
00023 #include "../Util/Message.h"
00024 
00025 // ---- global includes ----------------------------------------------------- ;
00026 
00027 // ---- remap, typedefs ----------------------------------------------------- ;
00028 
00029 enum util_TimeMeasurementType{
00030         util_CPU_TIME,
00031         util_REAL_TIME
00032 };
00033 
00034 // ---- class definition ---------------------------------------------------- ;
00035 
00036 /*
00037         stopwatch features
00038         This class allows to measure discrete time intervalls in your program.
00039 */
00040 class CStopWatch : public CMessage
00041 {
00042 
00043         protected:
00044 
00045         // ---- protected datas  ------------------------------------------------ ;
00046 
00047                 long m_iFirst;
00048                 long m_iLast;
00049                 double m_fOverflowTime;
00050 
00051                 #if defined(__QNX__)
00052                 timespec m_FirstTime;
00053                 timespec m_LastTime;
00054                 timespec m_TempTime;
00055                 timespec m_ActualTime;
00056                 #elif defined(_WIN32)
00057                 double  frequencyE;
00058                 LARGE_INTEGER m_FirstTime;
00059                 LARGE_INTEGER m_LastTime;
00060                 LARGE_INTEGER m_TempTime;
00061                 LARGE_INTEGER m_ActualTime;
00062                 #else
00063                 timeval m_FirstTime;
00064                 timeval m_LastTime;
00065                 timeval m_TempTime;
00066                 timeval m_ActualTime;
00067                 #endif
00068  
00069                 bool m_bStartFlag;
00070                 bool m_bStopFlag;
00071   
00072                 util_TimeMeasurementType m_iTimeType;
00073   
00074         // ---- auxiliary functions ----------------------------------------------- ;
00075 
00076         public:
00077 
00078         // ---- public datas ------------------------------------------------------ ;
00079 
00080         // ---- constructor/destructor -------------------------------------------- ;
00081 
00082                 // default constructor with timetype util_REAL_TIME
00083                 CStopWatch();
00084         
00085         
00086                 // constructor
00087                 CStopWatch(util_TimeMeasurementType iTimeType);
00088 
00089                 // copy constructor
00090                 CStopWatch(const CStopWatch& );
00091 
00092         // ---- operators --------------------------------------------------------- ;
00093 
00094                 // assignment operator
00095                 CStopWatch& operator=(const CStopWatch& );
00096 
00097         // ---- query functions --------------------------------------------------- ;
00098 
00099                 // returns the time type
00100                 util_TimeMeasurementType timeType() const;
00101  
00102         // ---- modify functions -------------------------------------------------- ;
00103 
00104                 //  sets the time type
00105                 void timeType(const util_TimeMeasurementType& riTimeType);
00106    
00107         // ---- I/O --------------------------------------------------------------- ;
00108 
00109                 // returns the difference between start and stop time in [s]
00110                 double executionTime();
00111 
00112                 // returns the real time in [s]
00113                 double realTime();
00114         
00115                 // returns the real time resolution in [s]
00116                 double realTimeResolution();
00117 
00118         // ---- exec functions ---------------------------------------------------- ;
00119 
00120                 // sets start time to current clock value
00121                 void start();
00122         
00123                 // sets stop time to current clock value
00124                 void stop();
00125   
00126                 // continues after a call of stop()
00127                 void cont();
00128 
00129                 // wait realtime in [ms]
00130                 void wait(unsigned int uiTime);
00131         
00132                 // returns the current date
00133                 void date(char* acDate) const;
00134         
00135                 // returns the current weekday
00136                 void weekday(char* acWeekday) const;
00137   
00138                 // tests, if there is an overflow at clock counter
00139                 void testOverflow();
00140 };
00141 
00142 // ---- extern I/O ---------------------------------------------------------- ;
00143 
00144 // ---- public inline functions --------------------------------------------- ;
00145 
00146 inline util_TimeMeasurementType CStopWatch::timeType() const
00147 { 
00148         return(m_iTimeType);
00149 };
00150 
00151 inline void CStopWatch::timeType(const util_TimeMeasurementType& riTimeType) 
00152 {
00153         m_iTimeType = riTimeType;
00154 };
00155 
00156 // -------------------------------------------------------------------------- ;
00157 
00158 #endif // UTIL_STOPWATCH_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13