artdaq  v3_03_00
EventBuilderApp.cc
1 #define TRACE_NAME (app_name + "_DataLoggerApp").c_str() // include these 2 first -
2 #include "artdaq/DAQdata/Globals.hh"
3 
4 #include "artdaq/Application/EventBuilderApp.hh"
5 
7 {
8 }
9 
10 // *******************************************************************
11 // *** The following methods implement the state machine operations.
12 // *******************************************************************
13 
14 bool artdaq::EventBuilderApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
15 {
16  report_string_ = "";
17  external_request_status_ = true;
18 
19  // in the following block, we first destroy the existing EventBuilder
20  // instance, then create a new one. Doing it in one step does not
21  // produce the desired result since that creates a new instance and
22  // then deletes the old one, and we need the opposite order.
23  //event_builder_ptr_.reset(nullptr);
24  if (event_builder_ptr_.get() == 0)
25  {
26  event_builder_ptr_.reset(new EventBuilderCore());
27  external_request_status_ = event_builder_ptr_->initialize(pset);
28  }
29  if (! external_request_status_)
30  {
31  report_string_ = "Error initializing an EventBuilderCore named";
32  report_string_.append(app_name + " with ");
33  report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
34  }
35 
36  return external_request_status_;
37 }
38 
39 bool artdaq::EventBuilderApp::do_start(art::RunID id, uint64_t, uint64_t)
40 {
41  report_string_ = "";
42  external_request_status_ = event_builder_ptr_->start(id);
43  if (! external_request_status_)
44  {
45  report_string_ = "Error starting ";
46  report_string_.append(app_name + " for run ");
47  report_string_.append("number ");
48  report_string_.append(boost::lexical_cast<std::string>(id.run()));
49  report_string_.append(".");
50  }
51 
52  return external_request_status_;
53 }
54 
55 bool artdaq::EventBuilderApp::do_stop(uint64_t, uint64_t)
56 {
57  report_string_ = "";
58  external_request_status_ = event_builder_ptr_->stop();
59  if (! external_request_status_)
60  {
61  report_string_ = "Error stopping ";
62  report_string_.append(app_name + ".");
63  }
64  return external_request_status_;
65 }
66 
67 bool artdaq::EventBuilderApp::do_pause(uint64_t, uint64_t)
68 {
69  report_string_ = "";
70  external_request_status_ = event_builder_ptr_->pause();
71  if (! external_request_status_)
72  {
73  report_string_ = "Error pausing ";
74  report_string_.append(app_name + ".");
75  }
76 
77  return external_request_status_;
78 }
79 
80 bool artdaq::EventBuilderApp::do_resume(uint64_t, uint64_t)
81 {
82  report_string_ = "";
83  external_request_status_ = event_builder_ptr_->resume();
84  if (! external_request_status_)
85  {
86  report_string_ = "Error resuming ";
87  report_string_.append(app_name + ".");
88  }
89 
90  return external_request_status_;
91 }
92 
94 {
95  report_string_ = "";
96  external_request_status_ = event_builder_ptr_->shutdown();
97  if (! external_request_status_)
98  {
99  report_string_ = "Error shutting down ";
100  report_string_.append(app_name + ".");
101  }
102  return external_request_status_;
103 }
104 
105 bool artdaq::EventBuilderApp::do_soft_initialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
106 {
107  report_string_ = "";
108  external_request_status_ = event_builder_ptr_->soft_initialize(pset);
109  if (! external_request_status_)
110  {
111  report_string_ = "Error soft-initializing ";
112  report_string_.append(app_name + " with ");
113  report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
114  }
115  return external_request_status_;
116 }
117 
118 bool artdaq::EventBuilderApp::do_reinitialize(fhicl::ParameterSet const& pset, uint64_t, uint64_t)
119 {
120  report_string_ = "";
121  external_request_status_ = event_builder_ptr_->reinitialize(pset);
122  if (! external_request_status_)
123  {
124  report_string_ = "Error reinitializing ";
125  report_string_.append(app_name + " with ");
126  report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
127  }
128  return external_request_status_;
129 }
130 
132 {
133  TLOG(TLVL_DEBUG) << "do_rollover_subrun BEGIN boundary=" << boundary;
134  report_string_ = "";
135  external_request_status_ = event_builder_ptr_->rollover_subrun(boundary);
136  if (!external_request_status_)
137  {
138  report_string_ = "Error rolling over subrun in ";
139  report_string_.append(app_name + "!");
140  }
141  TLOG(TLVL_DEBUG) << "do_rollover_subrun END sts=" << std::boolalpha << external_request_status_;
142  return external_request_status_;
143 }
144 
146 {
147  TLOG_DEBUG(app_name + "App") << "Booted state entry action called." ;
148 
149  // the destruction of any existing EventBuilderCore has to happen in the
150  // Booted Entry action rather than the Initialized Exit action because the
151  // Initialized Exit action is only called after the "init" transition guard
152  // condition is executed.
153  //event_builder_ptr_.reset(nullptr);
154 }
155 
156 std::string artdaq::EventBuilderApp::report(std::string const& which) const
157 {
158  std::string resultString;
159 
160  // if all that is requested is the latest state change result, return it
161  if (which == "transition_status")
162  {
163  if (report_string_.length() > 0) { return report_string_; }
164  else { return "Success"; }
165  }
166 
169  //if (report_string_.length() > 0) {
170  // resultString.append("*** Overall status message:\r\n");
171  // resultString.append(report_string_ + "\r\n");
172  // resultString.append("*** Requested report response:\r\n");
173  //}
174 
175  // pass the request to the EventBuilderCore instance, if it's available
176  if (event_builder_ptr_.get() != nullptr)
177  {
178  resultString.append(event_builder_ptr_->report(which));
179  }
180  else
181  {
182  resultString.append("This EventBuilder has not yet been initialized and ");
183  resultString.append("therefore can not provide reporting.");
184  }
185 
186  return resultString;
187 }
188 
189 bool artdaq::EventBuilderApp::do_add_config_archive_entry(std::string const& key, std::string const& value)
190 {
191  report_string_ = "";
192  external_request_status_ = event_builder_ptr_->add_config_archive_entry(key, value);
193  if (!external_request_status_)
194  {
195  report_string_ = "Error adding config entry with key ";
196  report_string_.append(key + " and value \"");
197  report_string_.append(value + "\" in");
198  report_string_.append(app_name + ".");
199  }
200 
201  return external_request_status_;
202 }
203 
205 {
206  report_string_ = "";
207  external_request_status_ = event_builder_ptr_->clear_config_archive();
208  if (!external_request_status_)
209  {
210  report_string_ = "Error clearing the configuration archive in ";
211  report_string_.append(app_name + ".");
212  }
213 
214  return external_request_status_;
215 }
bool do_resume(uint64_t, uint64_t) override
Resume the EventBuilderCore.
void BootedEnter() override
Action taken upon entering the &quot;Booted&quot; state.
std::string report(std::string const &which) const override
If which is &quot;transition_status&quot;, report the status of the last transition. Otherwise pass through to ...
bool do_reinitialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t) override
Reinitialize the EventBuilderCore.
bool do_shutdown(uint64_t) override
Shutdown the EventBuilderCore.
bool do_pause(uint64_t, uint64_t) override
Pause the EventBuilderCore.
bool do_soft_initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t) override
Soft-Initialize the EventBuilderCore.
bool do_add_config_archive_entry(std::string const &, std::string const &) override
Add the specified configuration archive entry to the EventBuilderCore.
EventBuilderApp()
EventBuilderApp Constructor.
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t, uint64_t) override
Initialize the EventBuilderCore.
bool do_clear_config_archive() override
Clear the configuration archive list in the EventBuilderCore.
bool do_start(art::RunID id, uint64_t, uint64_t) override
Start the EventBuilderCore.
bool do_rollover_subrun(uint64_t eventNum) override
Rollover the subrun after the given event.
EventBuilderCore implements the state machine for the EventBuilder artdaq application. EventBuilderCore receives Fragment objects from the DataReceiverManager, and sends them to the EventStore.
bool do_stop(uint64_t, uint64_t) override
Stop the EventBuilderCore.