00001 // ===================================================================== 00028 // ===================================================================== 00029 #ifndef CLDAQ__TSOFTWARETIMERMODULE_HH 00030 #define CLDAQ__TSOFTWARETIMERMODULE_HH 00031 00032 #include "Tglobals.h" 00033 #include "TSoftwareModule.hh" 00034 #include "TSystemTimer.hh" 00035 00036 class TDataElement; 00037 class TSystemTimer; 00038 00039 00059 class TSoftwareTimerModule 00060 : public TSoftwareModule 00061 { 00062 00063 public: 00064 enum { 00065 tRealElapsedTime, 00066 tRealElapsedTimeTotal, 00067 tSystemElapsedTime, 00068 tUserElapsedTime, 00069 tUnit, 00070 tNumberOfChannels 00071 }; 00072 00073 private: 00074 TSystemTimer theSystemTimer; 00075 Tdouble theRealElapsedTimeTotal; 00076 00077 public: 00078 TSoftwareTimerModule( Tint nchannel = tNumberOfChannels, const Tstring& unit = Tmsec ); 00079 TSoftwareTimerModule( const Tstring& unit, Tint nchannel = tNumberOfChannels ); 00080 TSoftwareTimerModule( const TSoftwareTimerModule& right ); 00081 ~TSoftwareTimerModule(); 00082 00083 public: 00084 Tint Clear(); 00085 Tint Update(); 00086 Tint Initialize(); 00087 Tvoid FillData( TDataElement& element, Tint channel ); 00088 00089 public: 00090 Tvoid Start(); 00091 Tvoid Pause(); 00092 Tvoid Stop(); 00093 Tvoid Lap(); 00094 Tvoid Restart(); 00095 00096 public: 00097 const TSystemTimer& GetSystemTimer() const; 00098 TSystemTimer& GetSystemTimer(); 00099 Tvoid SetSystemTimer( const TSystemTimer& timer ); 00100 Tdouble GetRealElapsedTimeTotal() const; 00101 Tvoid SetRealElapsedTimeTotal( Tdouble time ); 00102 00103 public: 00104 const TSoftwareTimerModule& operator=( const TSoftwareTimerModule& right ); 00105 Tbool operator==( const TSoftwareTimerModule& right ) const; 00106 Tbool operator!=( const TSoftwareTimerModule& right ) const; 00107 00108 #ifdef __CLDAQ_ROOT_DLL 00109 ClassDef(TSoftwareTimerModule,0) 00110 #endif 00111 00112 }; 00113 00114 inline const TSystemTimer& TSoftwareTimerModule::GetSystemTimer() const 00115 { 00116 return theSystemTimer; 00117 } 00118 00119 inline TSystemTimer& TSoftwareTimerModule::GetSystemTimer() 00120 { 00121 return theSystemTimer; 00122 } 00123 00124 inline Tvoid TSoftwareTimerModule::SetSystemTimer( const TSystemTimer& timer ) 00125 { 00126 theSystemTimer = timer; 00127 return; 00128 } 00129 00130 inline Tvoid TSoftwareTimerModule::Start() 00131 { 00132 theSystemTimer.Start(); 00133 return; 00134 } 00135 00136 inline Tvoid TSoftwareTimerModule::Pause() 00137 { 00138 theSystemTimer.Pause(); 00139 return; 00140 } 00141 00142 inline Tvoid TSoftwareTimerModule::Stop() 00143 { 00144 theSystemTimer.Stop(); 00145 theRealElapsedTimeTotal += theSystemTimer.GetRealElapsedTime(); 00146 return; 00147 } 00148 00149 inline Tvoid TSoftwareTimerModule::Lap() 00150 { 00151 theSystemTimer.Lap(); 00152 return; 00153 } 00154 00155 inline Tvoid TSoftwareTimerModule::Restart() 00156 { 00157 theSystemTimer.Restart(); 00158 return; 00159 } 00160 00161 inline Tdouble TSoftwareTimerModule::GetRealElapsedTimeTotal() const 00162 { 00163 return theRealElapsedTimeTotal; 00164 } 00165 00166 inline Tvoid TSoftwareTimerModule::SetRealElapsedTimeTotal( Tdouble time ) 00167 { 00168 theRealElapsedTimeTotal = time; 00169 return; 00170 } 00171 00172 #endif