StopWatch.h
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  * 
00004  * Copyright (c) 2012 
00005  * 
00006  * SCHUNK GmbH & Co. KG
00007  *  
00008  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00009  * 
00010  * Project name: Drivers for "Amtec M5 Protocol" Electronics V4
00011  *                                                                        
00012  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00013  * 
00014  * Email:robotics@schunk.com
00015  * 
00016  * ToDo: 
00017  * 
00018  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00019  * 
00020  * Redistribution and use in source and binary forms, with or without 
00021  * modification, are permitted provided that the following conditions are met: 
00022  * 
00023  *  * Redistributions of source code must retain the above copyright 
00024  *    notice, this list of conditions and the following disclaimer. 
00025  *  * Redistributions in binary form must reproduce the above copyright 
00026  *    notice, this list of conditions and the following disclaimer in the 
00027  *    documentation and/or other materials provided with the distribution. 
00028  *  * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 
00029  *    contributors may be used to endorse or promote products derived from 
00030  *    this software without specific prior written permission. 
00031  * 
00032  * This program is free software: you can redistribute it and/or modify 
00033  * it under the terms of the GNU Lesser General Public License LGPL as 
00034  * published by the Free Software Foundation, either version 3 of the 
00035  * License, or (at your option) any later version. 
00036  * 
00037  * This program is distributed in the hope that it will be useful, 
00038  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00039  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00040  * GNU Lesser General Public License LGPL for more details. 
00041  * 
00042  * You should have received a copy of the GNU Lesser General Public 
00043  * License LGPL along with this program. 
00044  * If not, see <http://www.gnu.org/licenses/>.
00045  * 
00046  ******************************************************************************/
00047 
00048 
00049 #ifndef UTIL_STOPWATCH_H
00050 #define UTIL_STOPWATCH_H
00051 
00052 // ---- local includes ------------------------------------------------------ ;
00053 
00054 #include "../Util/Message.h"
00055 
00056 // ---- global includes ----------------------------------------------------- ;
00057 
00058 // ---- remap, typedefs ----------------------------------------------------- ;
00059 
00060 enum util_TimeMeasurementType{
00061         util_CPU_TIME,
00062         util_REAL_TIME
00063 };
00064 
00065 // ---- class definition ---------------------------------------------------- ;
00066 
00067 /*
00068         stopwatch features
00069         This class allows to measure discrete time intervalls in your program.
00070 */
00071 class CStopWatch : public CMessage
00072 {
00073 
00074         protected:
00075 
00076         // ---- protected datas  ------------------------------------------------ ;
00077 
00078                 long m_iFirst;
00079                 long m_iLast;
00080                 double m_fOverflowTime;
00081 
00082                 #if defined(__QNX__)
00083                 timespec m_FirstTime;
00084                 timespec m_LastTime;
00085                 timespec m_TempTime;
00086                 timespec m_ActualTime;
00087                 #elif defined(_WIN32)
00088                 double  frequencyE;
00089                 LARGE_INTEGER m_FirstTime;
00090                 LARGE_INTEGER m_LastTime;
00091                 LARGE_INTEGER m_TempTime;
00092                 LARGE_INTEGER m_ActualTime;
00093                 #else
00094                 timeval m_FirstTime;
00095                 timeval m_LastTime;
00096                 timeval m_TempTime;
00097                 timeval m_ActualTime;
00098                 #endif
00099  
00100                 bool m_bStartFlag;
00101                 bool m_bStopFlag;
00102   
00103                 util_TimeMeasurementType m_iTimeType;
00104   
00105         // ---- auxiliary functions ----------------------------------------------- ;
00106 
00107         public:
00108 
00109         // ---- public datas ------------------------------------------------------ ;
00110 
00111         // ---- constructor/destructor -------------------------------------------- ;
00112 
00113                 // default constructor with timetype util_REAL_TIME
00114                 CStopWatch();
00115         
00116         
00117                 // constructor
00118                 CStopWatch(util_TimeMeasurementType iTimeType);
00119 
00120                 // copy constructor
00121                 CStopWatch(const CStopWatch& );
00122 
00123         // ---- operators --------------------------------------------------------- ;
00124 
00125                 // assignment operator
00126                 CStopWatch& operator=(const CStopWatch& );
00127 
00128         // ---- query functions --------------------------------------------------- ;
00129 
00130                 // returns the time type
00131                 util_TimeMeasurementType timeType() const;
00132  
00133         // ---- modify functions -------------------------------------------------- ;
00134 
00135                 //  sets the time type
00136                 void timeType(const util_TimeMeasurementType& riTimeType);
00137    
00138         // ---- I/O --------------------------------------------------------------- ;
00139 
00140                 // returns the difference between start and stop time in [s]
00141                 double executionTime();
00142 
00143                 // returns the real time in [s]
00144                 double realTime();
00145         
00146                 // returns the real time resolution in [s]
00147                 double realTimeResolution();
00148 
00149         // ---- exec functions ---------------------------------------------------- ;
00150 
00151                 // sets start time to current clock value
00152                 void start();
00153         
00154                 // sets stop time to current clock value
00155                 void stop();
00156   
00157                 // continues after a call of stop()
00158                 void cont();
00159 
00160                 // wait realtime in [ms]
00161                 void wait(unsigned int uiTime);
00162         
00163                 // returns the current date
00164                 void date(char* acDate) const;
00165         
00166                 // returns the current weekday
00167                 void weekday(char* acWeekday) const;
00168   
00169                 // tests, if there is an overflow at clock counter
00170                 void testOverflow();
00171 };
00172 
00173 // ---- extern I/O ---------------------------------------------------------- ;
00174 
00175 // ---- public inline functions --------------------------------------------- ;
00176 
00177 inline util_TimeMeasurementType CStopWatch::timeType() const
00178 { 
00179         return(m_iTimeType);
00180 };
00181 
00182 inline void CStopWatch::timeType(const util_TimeMeasurementType& riTimeType) 
00183 {
00184         m_iTimeType = riTimeType;
00185 };
00186 
00187 // -------------------------------------------------------------------------- ;
00188 
00189 #endif // UTIL_STOPWATCH_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Thu Aug 27 2015 15:06:52