home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-29 | 949 b | 59 lines | [TEXT/KAHL] |
- #include <Timer.h>
-
- #include "stopwatch.h"
-
- const long stopwatch::starting_value = 0x80000000; // max # of microseconds
-
- stopwatch::stopwatch()
- {
- tmAddr = 0; // no Task
- tmWakeUp = 0; // see IM VI 23-7 'you should set tmWakeUp and tmReserved to zero
- tmReserved = 0; // when you first install an extended Time Manager task.
- InsXTime( (QElem *)(TMTask *)this);
- running = false;
- }
-
- stopwatch::~stopwatch()
- {
- if( running)
- {
- (void)stop();
- }
- };
-
- long stopwatch::read()
- {
- long result = 0;
- if( running)
- {
- result = stop();
- InsXTime( (QElem *)(TMTask *)this);
- restart( 0);
- }
- return result;
- }
-
- long stopwatch::stop()
- {
- long result = 0;
- if( running)
- {
- RmvTime( (QElem *)(TMTask *)this);
- running = false;
- if( tmCount != 0)
- {
- result = tmCount - starting_value;
- }
- }
- return result;
- }
-
- void stopwatch::restart( unsigned long to_go)
- {
- if( !running)
- {
- PrimeTime( (QElem *)(TMTask *)this, to_go);
- running = true;
- }
- }
-