additional/timers/TimerCPU.cpp

Go to the documentation of this file.
00001 //## begin module%392D808B02A1.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%392D808B02A1.cm
00004 
00005 //## begin module%392D808B02A1.cp preserve=no
00006 //## end module%392D808B02A1.cp
00007 
00008 //## Module: TimerCPU%392D808B02A1; Pseudo Package body
00009 //## Source file: C:\project\mpk\code\additional\timers\TimerCPU.cpp
00010 
00011 //## begin module%392D808B02A1.additionalIncludes preserve=no
00012 //## end module%392D808B02A1.additionalIncludes
00013 
00014 //## begin module%392D808B02A1.includes preserve=yes
00015 //## end module%392D808B02A1.includes
00016 
00017 // TimerCPU
00018 #include "additional\timers\TimerCPU.h"
00019 #include <assert.h>
00020 #define WIN32_LEAN_AND_MEAN
00021 #include <windows.h>
00022 //## begin module%392D808B02A1.additionalDeclarations preserve=yes
00023 //## end module%392D808B02A1.additionalDeclarations
00024 
00025 
00026 // Class TimerCPU 
00027 
00028 
00029 
00030 TimerCPU::TimerCPU ()
00031   //## begin TimerCPU::TimerCPU%959283380.hasinit preserve=no
00032   //## end TimerCPU::TimerCPU%959283380.hasinit
00033   //## begin TimerCPU::TimerCPU%959283380.initialization preserve=yes
00034   //## end TimerCPU::TimerCPU%959283380.initialization
00035 {
00036   //## begin TimerCPU::TimerCPU%959283380.body preserve=yes
00037         totalSoFar.QuadPart = 0;
00038         BOOL success = QueryPerformanceFrequency( &m_Frequency );
00039         assert( success );
00040 
00041   //## end TimerCPU::TimerCPU%959283380.body
00042 }
00043 
00044 
00045 TimerCPU::~TimerCPU()
00046 {
00047   //## begin TimerCPU::~TimerCPU%.body preserve=yes
00048   //## end TimerCPU::~TimerCPU%.body
00049 }
00050 
00051 
00052 
00053 //## Other Operations (implementation)
00054 void TimerCPU::Reset ()
00055 {
00056   //## begin TimerCPU::Reset%959283372.body preserve=yes
00057         this->totalSoFar.QuadPart = 0 ;
00058   //## end TimerCPU::Reset%959283372.body
00059 }
00060 
00061 void TimerCPU::Start ()
00062 {
00063   //## begin TimerCPU::Start%959283373.body preserve=yes
00064         LARGE_INTEGER currentTime;
00065         BOOL success = QueryPerformanceCounter( &currentTime );
00066         assert( success == TRUE );
00067         this->startTime.QuadPart = currentTime.QuadPart; ;
00068         TimerBase::Start();
00069   //## end TimerCPU::Start%959283373.body
00070 }
00071 
00072 double TimerCPU::ElapsedTime ()
00073 {
00074   //## begin TimerCPU::ElapsedTime%959283374.body preserve=yes
00075         LARGE_INTEGER currentTime;
00076         currentTime.QuadPart = 0;
00077         if( this->isTimerRunning == true )
00078         {
00079                 BOOL success = QueryPerformanceCounter( &currentTime );
00080                 assert( success == TRUE );
00081         }
00082         return ( this->totalSoFar.QuadPart + currentTime.QuadPart - startTime.QuadPart ) / double( m_Frequency.QuadPart );
00083   //## end TimerCPU::ElapsedTime%959283374.body
00084 }
00085 
00086 void TimerCPU::Stop ()
00087 {
00088   //## begin TimerCPU::Stop%959283375.body preserve=yes
00089         LARGE_INTEGER currentTime;
00090         currentTime.QuadPart = 0;
00091         BOOL success = QueryPerformanceCounter( &currentTime );
00092         assert( success == TRUE );
00093         this->totalSoFar.QuadPart +=  currentTime.QuadPart - startTime.QuadPart;
00094   //## end TimerCPU::Stop%959283375.body
00095 }
00096 
00097 // Additional Declarations
00098   //## begin TimerCPU%392D808B02A1.declarations preserve=yes
00099   //## end TimerCPU%392D808B02A1.declarations
00100 
00101 //## begin module%392D808B02A1.epilog preserve=yes
00102 //## end module%392D808B02A1.epilog

Generated on Sat Apr 1 21:30:30 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO