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