$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_01
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #define TRACE_NAME "DispatcherApp" 00002 00003 #include "artdaq/Application/DispatcherApp.hh" 00004 #include "artdaq/Application/DispatcherCore.hh" 00005 #include "artdaq-core/Utilities/ExceptionHandler.hh" 00006 00007 #include <iostream> 00008 00009 artdaq::DispatcherApp::DispatcherApp() 00010 { 00011 } 00012 00013 // ******************************************************************* 00014 // *** The following methods implement the state machine operations. 00015 // ******************************************************************* 00016 00017 bool artdaq::DispatcherApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t) 00018 { 00019 report_string_ = ""; 00020 00021 //Dispatcher_ptr_.reset(nullptr); 00022 if (Dispatcher_ptr_.get() == 0) 00023 { 00024 Dispatcher_ptr_.reset(new DispatcherCore()); 00025 } 00026 external_request_status_ = Dispatcher_ptr_->initialize(pset); 00027 if (!external_request_status_) 00028 { 00029 report_string_ = "Error initializing "; 00030 report_string_.append(app_name + " "); 00031 report_string_.append("with ParameterSet = \"" + pset.to_string() + "\"."); 00032 } 00033 00034 return external_request_status_; 00035 } 00036 00037 bool artdaq::DispatcherApp::do_start(art::RunID id, uint64_t, uint64_t) 00038 { 00039 report_string_ = ""; 00040 external_request_status_ = Dispatcher_ptr_->start(id); 00041 if (!external_request_status_) 00042 { 00043 report_string_ = "Error starting "; 00044 report_string_.append(app_name + " "); 00045 report_string_.append("for run number "); 00046 report_string_.append(boost::lexical_cast<std::string>(id.run())); 00047 report_string_.append("."); 00048 } 00049 00050 return external_request_status_; 00051 } 00052 00053 bool artdaq::DispatcherApp::do_stop(uint64_t, uint64_t) 00054 { 00055 report_string_ = ""; 00056 external_request_status_ = Dispatcher_ptr_->stop(); 00057 if (!external_request_status_) 00058 { 00059 report_string_ = "Error stopping "; 00060 report_string_.append(app_name + "."); 00061 } 00062 00063 return external_request_status_; 00064 } 00065 00066 bool artdaq::DispatcherApp::do_pause(uint64_t, uint64_t) 00067 { 00068 report_string_ = ""; 00069 external_request_status_ = Dispatcher_ptr_->pause(); 00070 if (!external_request_status_) 00071 { 00072 report_string_ = "Error pausing "; 00073 report_string_.append(app_name + "."); 00074 } 00075 return external_request_status_; 00076 } 00077 00078 bool artdaq::DispatcherApp::do_resume(uint64_t, uint64_t) 00079 { 00080 report_string_ = ""; 00081 external_request_status_ = Dispatcher_ptr_->resume(); 00082 if (!external_request_status_) 00083 { 00084 report_string_ = "Error resuming "; 00085 report_string_.append(app_name + "."); 00086 } 00087 00088 return external_request_status_; 00089 } 00090 00091 bool artdaq::DispatcherApp::do_shutdown(uint64_t) 00092 { 00093 report_string_ = ""; 00094 external_request_status_ = Dispatcher_ptr_->shutdown(); 00095 if (!external_request_status_) 00096 { 00097 report_string_ = "Error shutting down "; 00098 report_string_.append(app_name + "."); 00099 } 00100 00101 return external_request_status_; 00102 } 00103 00104 bool artdaq::DispatcherApp::do_soft_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t) 00105 { 00106 return true; 00107 } 00108 00109 bool artdaq::DispatcherApp::do_reinitialize(fhicl::ParameterSet const&, uint64_t, uint64_t) 00110 { 00111 return true; 00112 } 00113 00114 std::string artdaq::DispatcherApp::report(std::string const& which) const 00115 { 00116 std::string resultString; 00117 00118 // if all that is requested is the latest state change result, return it 00119 if (which == "transition_status") 00120 { 00121 if (report_string_.length() > 0) { return report_string_; } 00122 else { return "Success"; } 00123 } 00124 00127 //if (report_string_.length() > 0) { 00128 // resultString.append("*** Overall status message:\r\n"); 00129 // resultString.append(report_string_ + "\r\n"); 00130 // resultString.append("*** Requested report response:\r\n"); 00131 //} 00132 00133 // pass the request to the DispatcherCore instance, if it's available 00134 if (Dispatcher_ptr_.get() != 0) 00135 { 00136 resultString.append(Dispatcher_ptr_->report(which)); 00137 } 00138 else 00139 { 00140 resultString.append("This Dispatcher has not yet been initialized and "); 00141 resultString.append("therefore can not provide reporting."); 00142 } 00143 00144 return resultString; 00145 } 00146 00147 std::string artdaq::DispatcherApp::register_monitor(fhicl::ParameterSet const& info) 00148 { 00149 TLOG(TLVL_DEBUG) << "DispatcherApp::register_monitor called with argument \"" << info.to_string() << "\"" ; 00150 00151 if (Dispatcher_ptr_) 00152 { 00153 try 00154 { 00155 return Dispatcher_ptr_->register_monitor(info); 00156 } 00157 catch (...) 00158 { 00159 ExceptionHandler(ExceptionHandlerRethrow::no, 00160 "Error in call to DispatcherCore's register_monitor function"); 00161 00162 return "Error in artdaq::DispatcherApp::register_monitor: an exception was thrown in the call to DispatcherCore::register_monitor, possibly due to a problem with the argument"; 00163 } 00164 } 00165 else 00166 { 00167 return "Error in artdaq::DispatcherApp::register_monitor: DispatcherCore object wasn't initialized"; 00168 } 00169 } 00170 00171 00172 std::string artdaq::DispatcherApp::unregister_monitor(std::string const& label) 00173 { 00174 TLOG(TLVL_DEBUG) << "DispatcherApp::unregister_monitor called with argument \"" << label << "\"" ; 00175 00176 if (Dispatcher_ptr_) 00177 { 00178 try 00179 { 00180 return Dispatcher_ptr_->unregister_monitor(label); 00181 } 00182 catch (...) 00183 { 00184 ExceptionHandler(ExceptionHandlerRethrow::no, 00185 "Error in call to DispatcherCore's unregister_monitor function"); 00186 00187 return "Error in artdaq::DispatcherApp::unregister_monitor: an exception was thrown in the call to DispatcherCore::unregister_monitor, possibly due to a problem with the argument"; 00188 } 00189 } 00190 else 00191 { 00192 return "Error in artdaq::DispatcherApp::unregister_monitor: DispatcherCore object wasn't initialized"; 00193 } 00194 }