1 #define TRACE_NAME "BoardReaderApp"
3 #include "artdaq/Application/BoardReaderApp.hh"
6 : fragment_receiver_ptr_(nullptr)
18 external_request_status_ =
true;
24 TLOG_DEBUG(name_ +
"App") <<
"Initializing first deleting old instance " << (
void*)fragment_receiver_ptr_.get() << TLOG_ENDL;
25 fragment_receiver_ptr_.reset(
nullptr);
27 TLOG_DEBUG(name_ +
"App") <<
"Initializing new BoardReaderCore at " << (
void*)fragment_receiver_ptr_.get() <<
" with pset " << pset.to_string() << TLOG_ENDL;
28 external_request_status_ = fragment_receiver_ptr_->initialize(pset, timeout, timestamp);
29 if (! external_request_status_)
31 report_string_ =
"Error initializing ";
32 report_string_.append(name_ +
" ");
33 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
36 TLOG_DEBUG(name_ +
"App") <<
"do_initialize(fhicl::ParameterSet, uint64_t, uint64_t): "
37 <<
"Done initializing." << TLOG_ENDL;
38 return external_request_status_;
44 external_request_status_ = fragment_receiver_ptr_->start(
id, timeout, timestamp);
45 if (! external_request_status_)
47 report_string_ =
"Error starting ";
48 report_string_.append(name_ +
" ");
49 report_string_.append(
"for run number ");
50 report_string_.append(boost::lexical_cast<std::string>(
id.run()));
51 report_string_.append(
", timeout ");
52 report_string_.append(boost::lexical_cast<std::string>(timeout));
53 report_string_.append(
", timestamp ");
54 report_string_.append(boost::lexical_cast<std::string>(timestamp));
55 report_string_.append(
".");
58 boost::thread::attributes attrs;
59 attrs.set_stack_size(4096 * 2000);
66 return external_request_status_;
72 external_request_status_ = fragment_receiver_ptr_->stop(timeout, timestamp);
73 if (! external_request_status_)
75 report_string_ =
"Error stopping ";
76 report_string_.append(name_ +
".");
80 int number_of_fragments_sent = fragment_receiver_ptr_->GetFragmentsProcessed();
81 TLOG_DEBUG(name_ +
"App") <<
"do_stop(uint64_t, uint64_t): "
82 <<
"Number of fragments sent = " << number_of_fragments_sent
85 return external_request_status_;
91 external_request_status_ = fragment_receiver_ptr_->pause(timeout, timestamp);
92 if (! external_request_status_)
94 report_string_ =
"Error pausing ";
95 report_string_.append(name_ +
".");
98 int number_of_fragments_sent = fragment_receiver_ptr_->GetFragmentsProcessed();
99 TLOG_DEBUG(name_ +
"App") <<
"do_pause(uint64_t, uint64_t): "
100 <<
"Number of fragments sent = " << number_of_fragments_sent
103 return external_request_status_;
109 external_request_status_ = fragment_receiver_ptr_->resume(timeout, timestamp);
110 if (! external_request_status_)
112 report_string_ =
"Error resuming ";
113 report_string_.append(name_ +
".");
116 boost::thread::attributes attrs;
117 attrs.set_stack_size(4096 * 2000);
124 return external_request_status_;
130 external_request_status_ = fragment_receiver_ptr_->shutdown(timeout);
131 if (! external_request_status_)
133 report_string_ =
"Error shutting down ";
134 report_string_.append(name_ +
".");
136 return external_request_status_;
142 external_request_status_ = fragment_receiver_ptr_->soft_initialize(pset, timeout, timestamp);
143 if (! external_request_status_)
145 report_string_ =
"Error soft-initializing ";
146 report_string_.append(name_ +
" ");
147 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
149 return external_request_status_;
154 external_request_status_ = fragment_receiver_ptr_->reinitialize(pset, timeout, timestamp);
155 if (! external_request_status_)
157 report_string_ =
"Error reinitializing ";
158 report_string_.append(name_ +
" ");
159 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
161 return external_request_status_;
166 TLOG_DEBUG(name_ +
"App") <<
"Booted state entry action called." << TLOG_ENDL;
172 fragment_receiver_ptr_.reset(
nullptr);
177 std::string resultString;
180 if (which ==
"transition_status")
182 if (report_string_.length() > 0) {
return report_string_; }
183 else {
return "Success"; }
195 if (fragment_receiver_ptr_.get() != 0)
197 resultString.append(fragment_receiver_ptr_->report(which));
201 resultString.append(
"This BoardReader has not yet been initialized and ");
202 resultString.append(
"therefore can not provide reporting.");
bool do_soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Soft-Initialize the BoardReaderCore.
bool do_resume(uint64_t timeout, uint64_t timestamp) override
Resume the BoardReaderCore.
bool do_stop(uint64_t timeout, uint64_t timestamp) override
Stop the BoardReaderCore.
BoardReaderCore implements the state machine for the BoardReader artdaq application. It contains a CommandableFragmentGenerator, which generates Fragments which are then sent to a DataSenderManager by BoardReaderCore.
bool do_shutdown(uint64_t timeout) override
Shutdown the BoardReaderCore.
bool do_reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Reinitialize the BoardReaderCore.
std::string report(std::string const &which) const override
If which is "transition_status", report the status of the last transition. Otherwise pass through to ...
void BootedEnter() override
Action taken upon entering the "Booted" state.
void process_fragments()
Main working loop of the BoardReaderCore.
bool do_start(art::RunID id, uint64_t timeout, uint64_t timestamp) override
Start the BoardReaderCore.
BoardReaderApp(int rank, std::string name)
BoardReaderApp Constructor.
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Initialize the BoardReaderCore.
bool do_pause(uint64_t timeout, uint64_t timestamp) override
Pause the BoardReaderCore.