$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 00002 //#include "artdaq/Application/Commandable.hh" 00003 //#include "fhiclcpp/make_ParameterSet.h" 00004 //#include "otsdaq-core/DataManager/DataManager.h" 00005 //#include "otsdaq-core/DataManager/DataManagerSingleton.h" 00006 #include "otsdaq-core/DataProcessorPlugins/ARTDAQConsumer.h" 00007 //#include "otsdaq-core/Macros/CoutMacros.h" 00008 #include "otsdaq-core/Macros/ProcessorPluginMacros.h" 00009 //#include "otsdaq-core/MessageFacility/MessageFacility.h" 00010 // 00011 //#include <cstdint> 00012 //#include <fstream> 00013 //#include <iostream> 00014 //#include <set> 00015 00016 using namespace ots; 00017 // 00018 //#define ARTDAQ_FCL_PATH std::string(getenv("USER_DATA")) + "/" + "ARTDAQConfigurations/" 00019 //#define ARTDAQ_FILE_PREAMBLE "boardReader" 00020 00021 //======================================================================================================================== 00022 ARTDAQConsumer::ARTDAQConsumer(std::string supervisorApplicationUID, 00023 std::string bufferUID, 00024 std::string processorUID, 00025 const ConfigurationTree& theXDAQContextConfigTree, 00026 const std::string& configurationPath) 00027 : WorkLoop(processorUID) 00028 , DataConsumer(supervisorApplicationUID, bufferUID, processorUID, LowConsumerPriority) 00029 , ARTDAQReaderProcessorBase(supervisorApplicationUID, 00030 bufferUID, 00031 processorUID, 00032 theXDAQContextConfigTree, 00033 configurationPath) 00034 // : WorkLoop(processorUID) 00035 // , DataConsumer(supervisorApplicationUID, bufferUID, processorUID, 00036 // LowConsumerPriority) , Configurable(theXDAQContextConfigTree, configurationPath) 00037 { 00038 __COUT__ << "ARTDAQ Consumer constructed." << __E__; 00039 //__COUT__ << "Configuration string:-" << 00040 // theXDAQContextConfigTree.getNode(configurationPath).getNode("ConfigurationString").getValue<std::string>() 00041 //<< "-" << __E__; 00042 // 00043 // std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE + "-"; 00044 // std::string uid = 00045 // theXDAQContextConfigTree.getNode(configurationPath).getValue(); 00046 // 00047 // __COUT__ << "uid: " << uid << __E__; 00048 // for(unsigned int i = 0; i < uid.size(); ++i) 00049 // if((uid[i] >= 'a' && uid[i] <= 'z') || (uid[i] >= 'A' && uid[i] <= 'Z') || 00050 // (uid[i] >= '0' && uid[i] <= '9')) // only allow alpha numeric in file name 00051 // filename += uid[i]; 00052 // filename += ".fcl"; 00053 // 00054 // __COUT__ << __E__; 00055 // __COUT__ << __E__; 00056 // __COUT__ << "filename: " << filename << __E__; 00057 // 00058 // std::string fileFclString; 00059 // { 00060 // std::ifstream in(filename, std::ios::in | std::ios::binary); 00061 // if(in) 00062 // { 00063 // std::string contents; 00064 // in.seekg(0, std::ios::end); 00065 // fileFclString.resize(in.tellg()); 00066 // in.seekg(0, std::ios::beg); 00067 // in.read(&fileFclString[0], fileFclString.size()); 00068 // in.close(); 00069 // } 00070 // } 00071 // //__COUT__ << fileFclString << __E__; 00072 // 00073 // // find fragment_receiver { 00074 // // and insert e.g., 00075 // // SupervisorApplicationUID:"ARTDataManager0" 00076 // // BufferUID:"ART_S0_DM0_DataBuffer0" 00077 // // ProcessorUID:"ART_S0_DM0_DB0_ARTConsumer0" 00078 // size_t fcli = 00079 // fileFclString.find("fragment_receiver: {") + +strlen("fragment_receiver: {"); 00080 // if(fcli == std::string::npos) 00081 // { 00082 // __SS__ << "Could not find 'fragment_receiver: {' in Board Reader fcl string!" 00083 // << __E__; 00084 // __COUT__ << "\n" << ss.str(); 00085 // __SS_THROW__; 00086 // } 00087 // 00088 // // get the parent IDs from configurationPath 00089 // __COUT__ << "configurationPath " << configurationPath << __E__; 00090 // 00091 // std::string consumerID, bufferID, appID; 00092 // unsigned int backSteps; // at 2, 4, and 7 are the important parent IDs 00093 // size_t backi = -1, backj; 00094 // backSteps = 7; 00095 // for(unsigned int i = 0; i < backSteps; i++) 00096 // { 00097 // //__COUT__ << "backsteps: " << i+1 << __E__; 00098 // 00099 // backj = backi; 00100 // backi = configurationPath.rfind('/', backi - 1); 00101 // 00102 // //__COUT__ << "backi:" << backi << " backj:" << backj << __E__; 00103 // //__COUT__ << "substr: " << configurationPath.substr(backi+1,backj-backi-1) << 00104 // // __E__; 00105 // 00106 // if(i + 1 == 2) 00107 // consumerID = configurationPath.substr(backi + 1, backj - backi - 1); 00108 // else if(i + 1 == 4) 00109 // bufferID = configurationPath.substr(backi + 1, backj - backi - 1); 00110 // else if(i + 1 == 7) 00111 // appID = configurationPath.substr(backi + 1, backj - backi - 1); 00112 // } 00113 // 00114 // // insert parent IDs into fcl string 00115 // fileFclString = fileFclString.substr(0, fcli) + "\n\t\t" + 00116 // "SupervisorApplicationUID: \"" + appID + "\"\n\t\t" + 00117 // "BufferUID: \"" + bufferID + "\"\n\t\t" + "ProcessorUID: \"" + 00118 // consumerID + "\"\n" + fileFclString.substr(fcli); 00119 // 00120 // __COUT__ << fileFclString << __E__; 00121 // 00122 // fhicl::make_ParameterSet(fileFclString, fhiclConfiguration_); 00123 // 00124 // // 00125 // fhicl::make_ParameterSet(theXDAQContextConfigTree.getNode(configurationPath).getNode("ConfigurationString").getValue<std::string>(), 00126 // // fhiclConfiguration_); 00127 } 00128 00129 //======================================================================================================================== 00130 // ARTDAQConsumer::ARTDAQConsumer(std::string interfaceID, MPI_Comm local_group_comm, 00131 // std::string name) :FEVInterface (feId, 0) ,local_group_comm_(local_group_comm) 00132 //,name_ (name) 00133 //{} 00134 00135 //======================================================================================================================== 00136 ARTDAQConsumer::~ARTDAQConsumer(void) 00137 { 00138 halt(); 00139 __COUT__ << "Destructed." << __E__; 00140 } 00141 // 00143 // void ARTDAQConsumer::initLocalGroup(int rank) 00144 //{ 00145 // name_ = "BoardReader_" + DataConsumer::processorUID_; 00146 // configure(rank); 00147 //} 00148 // 00149 //#define ARTDAQ_FCL_PATH std::string(getenv("USER_DATA")) + "/" + "ARTDAQConfigurations/" 00150 //#define ARTDAQ_FILE_PREAMBLE "boardReader" 00151 // 00153 // void ARTDAQConsumer::configure(int rank) 00154 //{ 00155 // __COUT__ << "\tConfigure" << __E__; 00156 // 00157 // report_string_ = ""; 00158 // external_request_status_ = true; 00159 // 00160 // // in the following block, we first destroy the existing BoardReader 00161 // // instance, then create a new one. Doing it in one step does not 00162 // // produce the desired result since that creates a new instance and 00163 // // then deletes the old one, and we need the opposite order. 00164 // fragment_receiver_ptr_.reset(nullptr); 00165 // __COUT__ << "\tNew core" << __E__; 00166 // my_rank = rank; 00167 // app_name = name_; 00168 // fragment_receiver_ptr_.reset(new artdaq::BoardReaderApp()); 00169 // // FIXME These are passed as parameters 00170 // uint64_t timeout = 45; 00171 // // uint64_t timestamp = 184467440737095516; 00172 // uint64_t timestamp = 184467440737095516; 00173 // __COUT__ << "\tInitialize: " 00174 // << __E__; //<< fhiclConfiguration_.to_string() << __E__; 00175 // external_request_status_ = 00176 // fragment_receiver_ptr_->initialize(fhiclConfiguration_, timeout, timestamp); 00177 // __COUT__ << "\tDone Initialize" << __E__; 00178 // if(!external_request_status_) 00179 // { 00180 // report_string_ = "Error initializing "; 00181 // report_string_.append(name_ + " "); 00182 // report_string_.append("with ParameterSet = \"" + fhiclConfiguration_.to_string() + 00183 // "\"."); 00184 // } 00185 // __COUT__ << "\tDone Configure" << __E__; 00186 //} 00187 // 00189 // void ARTDAQConsumer::halt(void) 00190 //{ 00191 // __COUT__ << "\tHalt" << __E__; 00192 // // FIXME These are passed as parameters 00193 // uint64_t timeout = 45; 00194 // // uint64_t timestamp = 184467440737095516; 00195 // report_string_ = ""; 00196 // external_request_status_ = fragment_receiver_ptr_->shutdown(timeout); 00197 // if(!external_request_status_) 00198 // { 00199 // report_string_ = "Error shutting down "; 00200 // report_string_.append(name_ + "."); 00201 // } 00202 //} 00203 // 00204 //======================================================================================================================== 00205 void ARTDAQConsumer::pauseProcessingData(void) { ARTDAQReaderProcessorBase::pause(); } 00206 // __COUT__ << "\tPause" << __E__; 00207 // // FIXME These are passed as parameters 00208 // uint64_t timeout = 45; 00209 // uint64_t timestamp = 184467440737095516; 00210 // report_string_ = ""; 00211 // external_request_status_ = fragment_receiver_ptr_->pause(timeout, timestamp); 00212 // if(!external_request_status_) 00213 // { 00214 // report_string_ = "Error pausing "; 00215 // report_string_.append(name_ + "."); 00216 // } 00217 //} 00218 // 00219 //======================================================================================================================== 00220 void ARTDAQConsumer::resumeProcessingData(void) { ARTDAQReaderProcessorBase::resume(); } 00221 // __COUT__ << "\tResume" << __E__; 00222 // // FIXME These are passed as parameters 00223 // uint64_t timeout = 45; 00224 // uint64_t timestamp = 184467440737095516; 00225 // report_string_ = ""; 00226 // external_request_status_ = fragment_receiver_ptr_->resume(timeout, timestamp); 00227 // if(!external_request_status_) 00228 // { 00229 // report_string_ = "Error resuming "; 00230 // report_string_.append(name_ + "."); 00231 // } 00232 //} 00233 // 00234 //======================================================================================================================== 00235 void ARTDAQConsumer::startProcessingData(std::string runNumber) 00236 { 00237 ARTDAQReaderProcessorBase::start(runNumber); 00238 } 00239 // __COUT__ << "\tStart" << __E__; 00240 // 00241 // art::RunID runId((art::RunNumber_t)boost::lexical_cast<art::RunNumber_t>(runNumber)); 00242 // 00243 // // FIXME These are passed as parameters 00244 // uint64_t timeout = 45; 00245 // uint64_t timestamp = 184467440737095516; 00246 // 00247 // report_string_ = ""; 00248 // __COUT__ << "\tStart run: " << runId << __E__; 00249 // external_request_status_ = fragment_receiver_ptr_->start(runId, timeout, timestamp); 00250 // __COUT__ << "\tStart already crashed " << __E__; 00251 // if(!external_request_status_) 00252 // { 00253 // report_string_ = "Error starting "; 00254 // report_string_.append(name_ + " "); 00255 // report_string_.append("for run number "); 00256 // report_string_.append(boost::lexical_cast<std::string>(runId.run())); 00257 // report_string_.append(", timeout "); 00258 // report_string_.append(boost::lexical_cast<std::string>(timeout)); 00259 // report_string_.append(", timestamp "); 00260 // report_string_.append(boost::lexical_cast<std::string>(timestamp)); 00261 // report_string_.append("."); 00262 // } 00263 // 00264 // __COUT__ << "STARTING BOARD READER THREAD" << __E__; 00265 //} 00266 // 00267 //======================================================================================================================== 00268 void ARTDAQConsumer::stopProcessingData(void) { ARTDAQReaderProcessorBase::stop(); } 00269 // __COUT__ << "\tStop" << __E__; 00270 // // FIXME These are passed as parameters 00271 // uint64_t timeout = 45; 00272 // uint64_t timestamp = 184467440737095516; 00273 // report_string_ = ""; 00274 // 00275 // auto sts = fragment_receiver_ptr_->status(); 00276 // if(sts == "Ready") 00277 // return; // Already stopped/never started 00278 // 00279 // external_request_status_ = fragment_receiver_ptr_->stop(timeout, timestamp); 00280 // if(!external_request_status_) 00281 // { 00282 // report_string_ = "Error stopping "; 00283 // report_string_.append(name_ + "."); 00284 // // return false; 00285 // } 00286 //} 00287 00288 DEFINE_OTS_PROCESSOR(ARTDAQConsumer)