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