00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TSoftwareTimerModule.hh"
00017 #include "TDataSegment.hh"
00018 #include "TDataElement.hh"
00019
00020 TSoftwareTimerModule::TSoftwareTimerModule( const Tstring& unit, Tint nchannel )
00021 : TSoftwareModule( nchannel ), theSystemTimer( unit ),
00022 theRealElapsedTimeTotal( 0.0 )
00023 {
00024 Start();
00025 }
00026
00027 TSoftwareTimerModule::TSoftwareTimerModule( Tint nchannel, const Tstring& unit )
00028 : TSoftwareModule( nchannel ), theSystemTimer( unit ),
00029 theRealElapsedTimeTotal( 0.0 )
00030 {
00031 Start();
00032 }
00033
00034 TSoftwareTimerModule::TSoftwareTimerModule( const TSoftwareTimerModule& right )
00035 : TSoftwareModule( right ),
00036 theSystemTimer( right.theSystemTimer ),
00037 theRealElapsedTimeTotal( right.theRealElapsedTimeTotal )
00038 {
00039 Stop();
00040 Start();
00041 }
00042
00043 TSoftwareTimerModule::~TSoftwareTimerModule()
00044 {;}
00045
00046 Tint TSoftwareTimerModule::Clear()
00047 {
00048 theRealElapsedTimeTotal = 0.0;
00049 return theStatus = tStatusSuccess;
00050 }
00051
00052 Tint TSoftwareTimerModule::Update()
00053 {
00054 return theStatus = tStatusSuccess;
00055 }
00056
00057 Tint TSoftwareTimerModule::Initialize()
00058 {
00059 Stop();
00060 theRealElapsedTimeTotal = 0.0;
00061 Start();
00062 return theStatus = tStatusSuccess;
00063 }
00064
00065 Tvoid TSoftwareTimerModule::FillData( TDataElement& element, Tint channel )
00066 {
00067 Stop();
00068 if ( channel < 0 || channel >= theNumberOfChannels ) {
00069 Tcerr << "TSoftwareTimerModule::FillData: invalid ID " << channel << Tendl;
00070 theStatus = -EFAULT;
00071 element.FillData( &theStatus, tTypeInt, 1 );
00072 } else {
00073 Tdouble dblbuf;
00074 Tstring strbuf;
00075 switch( channel ) {
00076 case tSystemElapsedTime:
00077 dblbuf = theSystemTimer.GetSystemElapsedTime();
00078 element.FillData( &dblbuf, tTypeDouble, 1 );
00079 break;
00080 case tUserElapsedTime:
00081 dblbuf = theSystemTimer.GetUserElapsedTime();
00082 element.FillData( &dblbuf, tTypeDouble, 1 );
00083 break;
00084 case tUnit:
00085 strbuf = theSystemTimer.GetUnit();
00086 element.FillData( &strbuf, tTypeString, 1 );
00087 break;
00088 case tRealElapsedTimeTotal:
00089 dblbuf = theRealElapsedTimeTotal;
00090 element.FillData( &dblbuf, tTypeDouble, 1 );
00091 break;
00092 case tRealElapsedTime:
00093 default:
00094 dblbuf = theSystemTimer.GetRealElapsedTime();
00095 element.FillData( &dblbuf, tTypeDouble, 1 );
00096 break;
00097 }
00098 }
00099 Start();
00100 return;
00101 }
00102
00103 const TSoftwareTimerModule& TSoftwareTimerModule::operator=( const TSoftwareTimerModule& right )
00104 {
00105 *( (TSoftwareModule*)this ) = *( (TSoftwareModule*)(&right) );
00106 theSystemTimer = right.theSystemTimer;
00107 Stop();
00108 Start();
00109 return *this;
00110 }
00111
00112 Tbool TSoftwareTimerModule::operator==( const TSoftwareTimerModule& right ) const
00113 {
00114 Tbool retval = Ttrue;
00115 retval &= ( *( (TSoftwareModule*)this ) == *( (TSoftwareModule*)(&right) ) );
00116 retval &= ( theSystemTimer.GetBeginOfRealTime() == right.theSystemTimer.GetBeginOfRealTime() );
00117 retval &= ( theSystemTimer.GetStatus() == right.theSystemTimer.GetStatus() );
00118 return retval;
00119 }
00120
00121 Tbool TSoftwareTimerModule::operator!=( const TSoftwareTimerModule& right ) const
00122 {
00123 Tbool retval = Tfalse;
00124 retval |= ( *( (TSoftwareModule*)this ) != *( (TSoftwareModule*)(&right) ) );
00125 retval |= ( theSystemTimer.GetBeginOfRealTime() != right.theSystemTimer.GetBeginOfRealTime() );
00126 retval |= ( theSystemTimer.GetStatus() != right.theSystemTimer.GetStatus() );
00127 return retval;
00128 }
00129
00130 #ifdef __CLDAQ_ROOT_DLL
00131 ClassImp(TSoftwareTimerModule)
00132 #endif