$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_01
$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/DataLoggerApp.hh" 00005 #include "artdaq/Application/DataLoggerCore.hh" 00006 #include "artdaq-core/Utilities/ExceptionHandler.hh" 00007 00008 #include <iostream> 00009 00010 artdaq::DataLoggerApp::DataLoggerApp() 00011 { 00012 } 00013 00014 // ******************************************************************* 00015 // *** The following methods implement the state machine operations. 00016 // ******************************************************************* 00017 00018 bool artdaq::DataLoggerApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t) 00019 { 00020 report_string_ = ""; 00021 00022 //DataLogger_ptr_.reset(nullptr); 00023 if (DataLogger_ptr_.get() == 0) 00024 { 00025 DataLogger_ptr_.reset(new DataLoggerCore()); 00026 } 00027 external_request_status_ = DataLogger_ptr_->initialize(pset); 00028 if (!external_request_status_) 00029 { 00030 report_string_ = "Error initializing "; 00031 report_string_.append(app_name + " "); 00032 report_string_.append("with ParameterSet = \"" + pset.to_string() + "\"."); 00033 } 00034 00035 return external_request_status_; 00036 } 00037 00038 bool artdaq::DataLoggerApp::do_start(art::RunID id, uint64_t, uint64_t) 00039 { 00040 report_string_ = ""; 00041 external_request_status_ = DataLogger_ptr_->start(id); 00042 if (!external_request_status_) 00043 { 00044 report_string_ = "Error starting "; 00045 report_string_.append(app_name + " "); 00046 report_string_.append("for run number "); 00047 report_string_.append(boost::lexical_cast<std::string>(id.run())); 00048 report_string_.append("."); 00049 } 00050 00051 return external_request_status_; 00052 } 00053 00054 bool artdaq::DataLoggerApp::do_stop(uint64_t, uint64_t) 00055 { 00056 report_string_ = ""; 00057 external_request_status_ = DataLogger_ptr_->stop(); 00058 if (!external_request_status_) 00059 { 00060 report_string_ = "Error stopping "; 00061 report_string_.append(app_name + "."); 00062 } 00063 00064 return external_request_status_; 00065 } 00066 00067 bool artdaq::DataLoggerApp::do_pause(uint64_t, uint64_t) 00068 { 00069 report_string_ = ""; 00070 external_request_status_ = DataLogger_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::DataLoggerApp::do_resume(uint64_t, uint64_t) 00081 { 00082 report_string_ = ""; 00083 external_request_status_ = DataLogger_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::DataLoggerApp::do_shutdown(uint64_t) 00094 { 00095 report_string_ = ""; 00096 external_request_status_ = DataLogger_ptr_->shutdown(); 00097 if (!external_request_status_) 00098 { 00099 report_string_ = "Error shutting down "; 00100 report_string_.append(app_name + "."); 00101 } 00102 00103 return external_request_status_; 00104 } 00105 00106 bool artdaq::DataLoggerApp::do_soft_initialize(fhicl::ParameterSet const&, uint64_t, uint64_t) 00107 { 00108 return true; 00109 } 00110 00111 bool artdaq::DataLoggerApp::do_reinitialize(fhicl::ParameterSet const&, uint64_t, uint64_t) 00112 { 00113 return true; 00114 } 00115 00116 std::string artdaq::DataLoggerApp::report(std::string const& which) const 00117 { 00118 std::string resultString; 00119 00120 // if all that is requested is the latest state change result, return it 00121 if (which == "transition_status") 00122 { 00123 if (report_string_.length() > 0) { return report_string_; } 00124 else { return "Success"; } 00125 } 00126 00129 //if (report_string_.length() > 0) { 00130 // resultString.append("*** Overall status message:\r\n"); 00131 // resultString.append(report_string_ + "\r\n"); 00132 // resultString.append("*** Requested report response:\r\n"); 00133 //} 00134 00135 // pass the request to the DataLoggerCore instance, if it's available 00136 if (DataLogger_ptr_.get() != 0) 00137 { 00138 resultString.append(DataLogger_ptr_->report(which)); 00139 } 00140 else 00141 { 00142 resultString.append("This DataLogger has not yet been initialized and "); 00143 resultString.append("therefore can not provide reporting."); 00144 } 00145 00146 return resultString; 00147 } 00148 00149 bool artdaq::DataLoggerApp::do_add_config_archive_entry(std::string const& key, std::string const& value) 00150 { 00151 report_string_ = ""; 00152 external_request_status_ = DataLogger_ptr_->add_config_archive_entry(key, value); 00153 if (!external_request_status_) 00154 { 00155 report_string_ = "Error adding config entry with key "; 00156 report_string_.append(key + " and value \""); 00157 report_string_.append(value + "\" in"); 00158 report_string_.append(app_name + "."); 00159 } 00160 00161 return external_request_status_; 00162 } 00163 00164 bool artdaq::DataLoggerApp::do_clear_config_archive() 00165 { 00166 report_string_ = ""; 00167 external_request_status_ = DataLogger_ptr_->clear_config_archive(); 00168 if (!external_request_status_) 00169 { 00170 report_string_ = "Error clearing the configuration archive in "; 00171 report_string_.append(app_name + "."); 00172 } 00173 00174 return external_request_status_; 00175 }