$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #define TRACE_NAME (app_name + "_DataLoggerApp").c_str() // include these 2 first - 00002 #include "artdaq/DAQdata/Globals.hh" 00003 00004 #include "artdaq/Application/EventBuilderApp.hh" 00005 00006 artdaq::EventBuilderApp::EventBuilderApp() 00007 { 00008 } 00009 00010 // ******************************************************************* 00011 // *** The following methods implement the state machine operations. 00012 // ******************************************************************* 00013 00014 bool artdaq::EventBuilderApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t) 00015 { 00016 report_string_ = ""; 00017 external_request_status_ = true; 00018 00019 // in the following block, we first destroy the existing EventBuilder 00020 // instance, then create a new one. Doing it in one step does not 00021 // produce the desired result since that creates a new instance and 00022 // then deletes the old one, and we need the opposite order. 00023 //event_builder_ptr_.reset(nullptr); 00024 if (event_builder_ptr_.get() == 0) 00025 { 00026 event_builder_ptr_.reset(new EventBuilderCore()); 00027 external_request_status_ = event_builder_ptr_->initialize(pset); 00028 } 00029 if (! external_request_status_) 00030 { 00031 report_string_ = "Error initializing an EventBuilderCore named"; 00032 report_string_.append(app_name + " with "); 00033 report_string_.append("ParameterSet = \"" + pset.to_string() + "\"."); 00034 } 00035 00036 return external_request_status_; 00037 } 00038 00039 bool artdaq::EventBuilderApp::do_start(art::RunID id, uint64_t, uint64_t) 00040 { 00041 report_string_ = ""; 00042 external_request_status_ = event_builder_ptr_->start(id); 00043 if (! external_request_status_) 00044 { 00045 report_string_ = "Error starting "; 00046 report_string_.append(app_name + " for run "); 00047 report_string_.append("number "); 00048 report_string_.append(boost::lexical_cast<std::string>(id.run())); 00049 report_string_.append("."); 00050 } 00051 00052 return external_request_status_; 00053 } 00054 00055 bool artdaq::EventBuilderApp::do_stop(uint64_t, uint64_t) 00056 { 00057 report_string_ = ""; 00058 external_request_status_ = event_builder_ptr_->stop(); 00059 if (! external_request_status_) 00060 { 00061 report_string_ = "Error stopping "; 00062 report_string_.append(app_name + "."); 00063 } 00064 return external_request_status_; 00065 } 00066 00067 bool artdaq::EventBuilderApp::do_pause(uint64_t, uint64_t) 00068 { 00069 report_string_ = ""; 00070 external_request_status_ = event_builder_ptr_->pause(); 00071 if (! external_request_status_) 00072 { 00073 report_string_ = "Error pausing "; 00074 report_string_.append(app_name + "."); 00075 } 00076 00077 return external_request_status_; 00078 } 00079 00080 bool artdaq::EventBuilderApp::do_resume(uint64_t, uint64_t) 00081 { 00082 report_string_ = ""; 00083 external_request_status_ = event_builder_ptr_->resume(); 00084 if (! external_request_status_) 00085 { 00086 report_string_ = "Error resuming "; 00087 report_string_.append(app_name + "."); 00088 } 00089 00090 return external_request_status_; 00091 } 00092 00093 bool artdaq::EventBuilderApp::do_shutdown(uint64_t) 00094 { 00095 report_string_ = ""; 00096 external_request_status_ = event_builder_ptr_->shutdown(); 00097 if (! external_request_status_) 00098 { 00099 report_string_ = "Error shutting down "; 00100 report_string_.append(app_name + "."); 00101 } 00102 return external_request_status_; 00103 } 00104 00105 bool artdaq::EventBuilderApp::do_soft_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t) 00106 { 00107 report_string_ = ""; 00108 external_request_status_ = event_builder_ptr_->soft_initialize(pset); 00109 if (! external_request_status_) 00110 { 00111 report_string_ = "Error soft-initializing "; 00112 report_string_.append(app_name + " with "); 00113 report_string_.append("ParameterSet = \"" + pset.to_string() + "\"."); 00114 } 00115 return external_request_status_; 00116 } 00117 00118 bool artdaq::EventBuilderApp::do_reinitialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t) 00119 { 00120 report_string_ = ""; 00121 external_request_status_ = event_builder_ptr_->reinitialize(pset); 00122 if (! external_request_status_) 00123 { 00124 report_string_ = "Error reinitializing "; 00125 report_string_.append(app_name + " with "); 00126 report_string_.append("ParameterSet = \"" + pset.to_string() + "\"."); 00127 } 00128 return external_request_status_; 00129 } 00130 00131 bool artdaq::EventBuilderApp::do_rollover_subrun(uint64_t boundary, uint32_t subrun) 00132 { 00133 TLOG(TLVL_DEBUG) << "do_rollover_subrun BEGIN boundary=" << boundary << ", subrun=" << subrun; 00134 report_string_ = ""; 00135 external_request_status_ = event_builder_ptr_->rollover_subrun(boundary, subrun); 00136 if (!external_request_status_) 00137 { 00138 report_string_ = "Error rolling over subrun in "; 00139 report_string_.append(app_name + "!"); 00140 } 00141 TLOG(TLVL_DEBUG) << "do_rollover_subrun END sts=" << std::boolalpha << external_request_status_; 00142 return external_request_status_; 00143 } 00144 00145 void artdaq::EventBuilderApp::BootedEnter() 00146 { 00147 TLOG_DEBUG(app_name + "App") << "Booted state entry action called." ; 00148 00149 // the destruction of any existing EventBuilderCore has to happen in the 00150 // Booted Entry action rather than the Initialized Exit action because the 00151 // Initialized Exit action is only called after the "init" transition guard 00152 // condition is executed. 00153 //event_builder_ptr_.reset(nullptr); 00154 } 00155 00156 std::string artdaq::EventBuilderApp::report(std::string const& which) const 00157 { 00158 std::string resultString; 00159 00160 // if all that is requested is the latest state change result, return it 00161 if (which == "transition_status") 00162 { 00163 if (report_string_.length() > 0) { return report_string_; } 00164 else { return "Success"; } 00165 } 00166 00169 //if (report_string_.length() > 0) { 00170 // resultString.append("*** Overall status message:\r\n"); 00171 // resultString.append(report_string_ + "\r\n"); 00172 // resultString.append("*** Requested report response:\r\n"); 00173 //} 00174 00175 // pass the request to the EventBuilderCore instance, if it's available 00176 if (event_builder_ptr_.get() != nullptr) 00177 { 00178 resultString.append(event_builder_ptr_->report(which)); 00179 } 00180 else 00181 { 00182 resultString.append("This EventBuilder has not yet been initialized and "); 00183 resultString.append("therefore can not provide reporting."); 00184 } 00185 00186 return resultString; 00187 } 00188 00189 bool artdaq::EventBuilderApp::do_add_config_archive_entry(std::string const& key, std::string const& value) 00190 { 00191 report_string_ = ""; 00192 external_request_status_ = event_builder_ptr_->add_config_archive_entry(key, value); 00193 if (!external_request_status_) 00194 { 00195 report_string_ = "Error adding config entry with key "; 00196 report_string_.append(key + " and value \""); 00197 report_string_.append(value + "\" in"); 00198 report_string_.append(app_name + "."); 00199 } 00200 00201 return external_request_status_; 00202 } 00203 00204 bool artdaq::EventBuilderApp::do_clear_config_archive() 00205 { 00206 report_string_ = ""; 00207 external_request_status_ = event_builder_ptr_->clear_config_archive(); 00208 if (!external_request_status_) 00209 { 00210 report_string_ = "Error clearing the configuration archive in "; 00211 report_string_.append(app_name + "."); 00212 } 00213 00214 return external_request_status_; 00215 }