Generic hardware access library
|
00001 #ifndef __StopWatch 00002 #define __StopWatch 00003 00004 #include <stdint.h> 00005 #include <vector> 00006 #include <iostream> 00007 #include <sys/time.h> 00008 00009 #include "hal/IllegalValueException.hh" 00010 00011 00012 namespace HAL { 00013 00014 class StopWatch { 00015 public: 00016 StopWatch( uint32_t laps ); 00017 00018 void start(); 00019 void stop(); 00020 void lap(); 00021 void reset(); 00022 uint32_t read(); 00023 uint32_t readLap( uint32_t lapIndex, std::ostream& os = std::cout ) 00024 throw( IllegalValueException ); 00025 private: 00026 void calibrate(); 00027 uint32_t subtractTime( timeval& stopTime, timeval& startTime ); 00028 double startStopOffset; 00029 double lapOffset; 00030 uint32_t lapCounter; 00031 uint32_t maxLaps; 00032 timeval startTime; 00033 timeval stopTime; 00034 std::vector< timeval > lapVector; 00035 }; 00036 00037 } /* namespace HAL */ 00038 00039 #endif /* __StopWatch */