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