00001 #include "artdaq/Application/EventBuilderApp.hh"
00002
00003 artdaq::EventBuilderApp::EventBuilderApp()
00004 {
00005 }
00006
00007
00008
00009
00010
00011 bool artdaq::EventBuilderApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
00012 {
00013 report_string_ = "";
00014 external_request_status_ = true;
00015
00016
00017
00018
00019
00020
00021 if (event_builder_ptr_.get() == 0)
00022 {
00023 event_builder_ptr_.reset(new EventBuilderCore());
00024 external_request_status_ = event_builder_ptr_->initialize(pset);
00025 }
00026 if (! external_request_status_)
00027 {
00028 report_string_ = "Error initializing an EventBuilderCore named";
00029 report_string_.append(app_name + " with ");
00030 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
00031 }
00032
00033 return external_request_status_;
00034 }
00035
00036 bool artdaq::EventBuilderApp::do_start(art::RunID id, uint64_t, uint64_t)
00037 {
00038 report_string_ = "";
00039 external_request_status_ = event_builder_ptr_->start(id);
00040 if (! external_request_status_)
00041 {
00042 report_string_ = "Error starting ";
00043 report_string_.append(app_name + " for run ");
00044 report_string_.append("number ");
00045 report_string_.append(boost::lexical_cast<std::string>(id.run()));
00046 report_string_.append(".");
00047 }
00048
00049 return external_request_status_;
00050 }
00051
00052 bool artdaq::EventBuilderApp::do_stop(uint64_t, uint64_t)
00053 {
00054 report_string_ = "";
00055 external_request_status_ = event_builder_ptr_->stop();
00056 if (! external_request_status_)
00057 {
00058 report_string_ = "Error stopping ";
00059 report_string_.append(app_name + ".");
00060 }
00061 return external_request_status_;
00062 }
00063
00064 bool artdaq::EventBuilderApp::do_pause(uint64_t, uint64_t)
00065 {
00066 report_string_ = "";
00067 external_request_status_ = event_builder_ptr_->pause();
00068 if (! external_request_status_)
00069 {
00070 report_string_ = "Error pausing ";
00071 report_string_.append(app_name + ".");
00072 }
00073
00074 return external_request_status_;
00075 }
00076
00077 bool artdaq::EventBuilderApp::do_resume(uint64_t, uint64_t)
00078 {
00079 report_string_ = "";
00080 external_request_status_ = event_builder_ptr_->resume();
00081 if (! external_request_status_)
00082 {
00083 report_string_ = "Error resuming ";
00084 report_string_.append(app_name + ".");
00085 }
00086
00087 return external_request_status_;
00088 }
00089
00090 bool artdaq::EventBuilderApp::do_shutdown(uint64_t)
00091 {
00092 report_string_ = "";
00093 external_request_status_ = event_builder_ptr_->shutdown();
00094 if (! external_request_status_)
00095 {
00096 report_string_ = "Error shutting down ";
00097 report_string_.append(app_name + ".");
00098 }
00099 return external_request_status_;
00100 }
00101
00102 bool artdaq::EventBuilderApp::do_soft_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
00103 {
00104 report_string_ = "";
00105 external_request_status_ = event_builder_ptr_->soft_initialize(pset);
00106 if (! external_request_status_)
00107 {
00108 report_string_ = "Error soft-initializing ";
00109 report_string_.append(app_name + " with ");
00110 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
00111 }
00112 return external_request_status_;
00113 }
00114
00115 bool artdaq::EventBuilderApp::do_reinitialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
00116 {
00117 report_string_ = "";
00118 external_request_status_ = event_builder_ptr_->reinitialize(pset);
00119 if (! external_request_status_)
00120 {
00121 report_string_ = "Error reinitializing ";
00122 report_string_.append(app_name + " with ");
00123 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
00124 }
00125 return external_request_status_;
00126 }
00127
00128 void artdaq::EventBuilderApp::BootedEnter()
00129 {
00130 TLOG_DEBUG(app_name + "App") << "Booted state entry action called." ;
00131
00132
00133
00134
00135
00136
00137 }
00138
00139 std::string artdaq::EventBuilderApp::report(std::string const& which) const
00140 {
00141 std::string resultString;
00142
00143
00144 if (which == "transition_status")
00145 {
00146 if (report_string_.length() > 0) { return report_string_; }
00147 else { return "Success"; }
00148 }
00149
00152
00153
00154
00155
00156
00157
00158
00159 if (event_builder_ptr_.get() != nullptr)
00160 {
00161 resultString.append(event_builder_ptr_->report(which));
00162 }
00163 else
00164 {
00165 resultString.append("This EventBuilder has not yet been initialized and ");
00166 resultString.append("therefore can not provide reporting.");
00167 }
00168
00169 return resultString;
00170 }