00001 #include "BDSpliceModule.h"
00002
00003 #include <JobControl/JobCModuleRegistry.h>
00004 #include <MessageService/MsgService.h>
00005 #include <RawData/RawBeamMonHeaderBlock.h>
00006 #include <DataUtil/GetRawBlock.h>
00007
00008 CVSID("$Id: BDSpliceModule.cxx,v 1.1 2005/08/05 14:42:08 bv Exp $");
00009 JOBMODULE(BDSpliceModule, "BDSplice", "Pass records based on their spill time");
00010
00011 BDSpliceModule::BDSpliceModule()
00012 : fBegin(VldTimeStamp::GetBOT())
00013 , fEnd(VldTimeStamp::GetEOT())
00014 {
00015 }
00016
00017 BDSpliceModule::~BDSpliceModule()
00018 {
00019 }
00020
00021
00022 const Registry& BDSpliceModule::DefaultConfig() const
00023 {
00024 static Registry r;
00025 if (r.Size()) return r;
00026 r.Set("BeginTime",0);
00027 r.Set("EndTime",(int)((time_t)-1));
00028 r.SetName(Form("%s.config.default",this->JobCModule::GetName()));
00029 return r;
00030 }
00031
00032 void BDSpliceModule::Config(const Registry& cfg)
00033 {
00034 int t;
00035 if (cfg.Get("BeginTime",t) && t != fBegin.GetSec())
00036 fBegin = VldTimeStamp(t);
00037 if (cfg.Get("EndTime",t) && t != fEnd.GetSec())
00038 fEnd = VldTimeStamp(t);
00039 }
00040
00041 JobCResult BDSpliceModule::Ana(const MomNavigator* mom)
00042 {
00043 static bool inrange = false;
00044
00045 const RawBeamMonHeaderBlock* header =
00046 DataUtil::GetRawBlock<RawBeamMonHeaderBlock>(mom);
00047
00048 if (!header) {
00049 MSG("BDSpliceModule",Msg::kWarning)
00050 << "No RawBeamMonHeaderBlock, failing record\n";
00051 return JobCResult::kFailed;
00052 }
00053
00054 VldTimeStamp now = header->GetTimeStamp();
00055
00056 JobCResult pf = JobCResult::kPassed;
00057
00058 if (now < fBegin) pf = JobCResult::kFailed;
00059 if (now > fEnd) pf = JobCResult::kFailed;
00060
00061 if (inrange && pf.Failed()) {
00062 MSG("BDSpliceModule",Msg::kInfo)
00063 << "Leaving range at " << now << endl;
00064 }
00065 if (!inrange && pf.Passed()) {
00066 MSG("BDSpliceModule",Msg::kInfo)
00067 << "Entering range at " << now << endl;
00068 }
00069 if (pf.Passed()) inrange = true;
00070 else inrange = false;
00071
00072 return pf;
00073 }
00074