Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/TimerPulseTest.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__TimerPulseTest_CPP__
00002 #define __J2K__TimerPulseTest_CPP__
00003 
00004 #include <j2k/nto/TimerPulse.hpp>
00005 
00006 // 200 ms
00007 #define WAITING  200000000
00008 
00009 class TimerPulseTest : public TimerPulse {
00010 public:
00011 
00012  TimerPulseTest( ULONG clk = WAITING )
00013   : TimerPulse( clk ), loop( 0 ), avg( 0 ) 
00014  { 
00015 
00016  }
00017 
00018  virtual void tick( int signo )
00019  {
00020     if (avg < 1 ) {
00021       avg = loop;
00022     } else {
00023       avg = ( avg + loop ) / 2;
00024     }
00025 
00026     printf( "Enter handler with signal %d/%d [%d/%d].\n", \
00027              signo, TimerSignalEvent, loop, avg );
00028 
00029     loop = 0;
00030     printf( "End signal handler.\n" );
00031    fflush( stdout );
00032  }
00033 
00034  virtual void start() 
00035  {
00036    printf( "Timer started.\n" );
00037    fflush( stdout );
00038 
00039    TimerPulse::start();
00040  }
00041 
00042  size_t loop;
00043  size_t avg;
00044 
00045  virtual ~TimerPulseTest() { }
00046 
00047 
00048 };
00049 
00050 TimerPulseTest t( WAITING );
00051 
00052 int main() {
00053   t.start();
00054 
00055   for(;;) {  // Infinite loop
00056     t.loop++;
00057   }
00058 
00059   return 0;
00060 }
00061 
00062 #endif

Generated on Sun Oct 14 18:46:25 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001