00001
00002
00003
00004
00005
00006
00007
00009 #include <iostream>
00010 #include <cassert>
00011 using namespace std;
00012
00013 #include "TSystem.h"
00014
00015 #include "MessageService/MsgService.h"
00016 #include "Record/RecMinos.h"
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "Validity/VldContext.h"
00021 #include "Dispatcher/test/DDSPaceModule.h"
00022
00023
00024 ClassImp(DDSPaceModule)
00025
00026
00027
00028
00029 CVSID("$Id: DDSPaceModule.cxx,v 1.2 2005/02/01 18:42:18 tagg Exp $");
00030 JOBMODULE(DDSPaceModule, "DDSPaceModule",
00031 "A pace maker module for record sets.");
00032
00033
00034
00035
00036
00037
00038
00039
00040 DDSPaceModule::DDSPaceModule() : fVldStartTime(0,0) {
00041
00042
00043 fStopwatch.Reset();
00044 fStopwatch.Stop();
00045
00046 }
00047
00048
00049 const Registry& DDSPaceModule::DefaultConfig() const {
00050
00051
00052
00053
00054
00055
00056
00057
00058 MSG("DDSPace",Msg::kDebug) <<
00059 "DDSPaceModule::DefaultConfig" << endl;
00060
00061 static Registry r;
00062 std::string name = this->JobCModule::GetName();
00063 name += ".config.default";
00064 r.SetName(name.c_str());
00065
00066 r.UnLockValues();
00067 r.LockValues();
00068
00069 return r;
00070 }
00071
00072
00073
00074 void DDSPaceModule::Config(const Registry& ) {
00075
00076
00077
00078
00079
00080
00081
00082
00083 MSG("DDSPace",Msg::kDebug) << "DDSPaceModule::Config" << endl;
00084
00085
00086
00087
00088
00089 }
00090
00091
00092
00093 JobCResult DDSPaceModule::Ana(const MomNavigator *mom) {
00094
00095
00096
00097
00098
00099
00100
00101
00102 JobCResult result(JobCResult::kPassed);
00103 MSG("DDSPace",Msg::kDebug) << "DDSPaceModule::Ana" << endl;
00104
00105
00106 assert(mom);
00107
00108
00109
00110 TIter fiter = mom->FragmentIter();
00111 RecMinos* record = dynamic_cast<RecMinos*>(fiter());
00112 if ( !record ) {
00113 MSG("DDS",Msg::kWarning) << "First record not RecMinos record" << endl;
00114 result.SetWarning().SetFailed();
00115 return result;
00116 }
00117 VldTimeStamp vldCurrentTime = record->GetVldContext()->GetTimeStamp();
00118
00119 if ( fVldStartTime.GetSec() == 0 ) {
00120
00121 fVldStartTime = vldCurrentTime;
00122 fStopwatch.Start();
00123 }
00124
00125 Double_t vldtimediff = vldCurrentTime-fVldStartTime;
00126 Double_t realtime = fStopwatch.RealTime();
00127
00128 fStopwatch.Start(false);
00129
00130 Double_t timediff = vldtimediff - realtime;
00131 MSG("DDS",Msg::kDebug) << "Delta VldTime " << vldtimediff
00132 << " RealTime " << realtime << " => sleep for "
00133 << timediff << " seconds." << endl;
00134
00135 if ( timediff > 0 ) {
00136
00137 gSystem->Sleep((Int_t)(timediff*1000));
00138 }
00139
00140
00141 return result;
00142
00143 }
00144