1 #include "artdaq/Application/RoutingMasterApp.hh"
19 external_request_status_ =
true;
25 routing_master_ptr_.reset(
nullptr);
27 external_request_status_ = routing_master_ptr_->initialize(pset, timeout, timestamp);
28 if (!external_request_status_)
30 report_string_ =
"Error initializing ";
31 report_string_.append(app_name +
" ");
32 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
35 return external_request_status_;
41 external_request_status_ = routing_master_ptr_->start(
id, timeout, timestamp);
42 if (!external_request_status_)
44 report_string_ =
"Error starting ";
45 report_string_.append(app_name +
" ");
46 report_string_.append(
"for run number ");
47 report_string_.append(boost::lexical_cast<std::string>(
id.run()));
48 report_string_.append(
", timeout ");
49 report_string_.append(boost::lexical_cast<std::string>(timeout));
50 report_string_.append(
", timestamp ");
51 report_string_.append(boost::lexical_cast<std::string>(timestamp));
52 report_string_.append(
".");
55 routing_master_future_ =
57 routing_master_ptr_.get());
59 return external_request_status_;
65 external_request_status_ = routing_master_ptr_->stop(timeout, timestamp);
66 if (!external_request_status_)
68 report_string_ =
"Error stopping ";
69 report_string_.append(app_name +
".");
73 if (routing_master_future_.valid())
75 int number_of_table_entries_sent = routing_master_future_.get();
76 TLOG_DEBUG(app_name +
"App") <<
"do_stop(uint64_t, uint64_t): "
77 <<
"Number of table entries sent = " << number_of_table_entries_sent
81 return external_request_status_;
87 external_request_status_ = routing_master_ptr_->pause(timeout, timestamp);
88 if (!external_request_status_)
90 report_string_ =
"Error pausing ";
91 report_string_.append(app_name +
".");
94 if (routing_master_future_.valid())
96 int number_of_table_entries_sent = routing_master_future_.get();
97 TLOG_DEBUG(app_name +
"App") <<
"do_pause(uint64_t, uint64_t): "
98 <<
"Number of table entries sent = " << number_of_table_entries_sent
102 return external_request_status_;
108 external_request_status_ = routing_master_ptr_->resume(timeout, timestamp);
109 if (!external_request_status_)
111 report_string_ =
"Error resuming ";
112 report_string_.append(app_name +
".");
115 routing_master_future_ =
117 routing_master_ptr_.get());
119 return external_request_status_;
125 external_request_status_ = routing_master_ptr_->shutdown(timeout);
126 if (!external_request_status_)
128 report_string_ =
"Error shutting down ";
129 report_string_.append(app_name +
".");
131 return external_request_status_;
137 external_request_status_ = routing_master_ptr_->soft_initialize(pset, timeout, timestamp);
138 if (!external_request_status_)
140 report_string_ =
"Error soft-initializing ";
141 report_string_.append(app_name +
" ");
142 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
144 return external_request_status_;
149 external_request_status_ = routing_master_ptr_->reinitialize(pset, timeout, timestamp);
150 if (!external_request_status_)
152 report_string_ =
"Error reinitializing ";
153 report_string_.append(app_name +
" ");
154 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
156 return external_request_status_;
161 TLOG_DEBUG(app_name +
"App") <<
"Booted state entry action called." << TLOG_ENDL;
167 routing_master_ptr_.reset(
nullptr);
172 std::string resultString;
175 if (which ==
"transition_status")
177 if (report_string_.length() > 0) {
return report_string_; }
178 else {
return "Success"; }
190 if (routing_master_ptr_.get() != 0)
192 resultString.append(routing_master_ptr_->report(which));
196 resultString.append(
"This RoutingMaster has not yet been initialized and ");
197 resultString.append(
"therefore can not provide reporting.");
bool do_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Initialize the RoutingMasterCore.
bool do_pause(uint64_t timeout, uint64_t timestamp) override
Pause the RoutingMasterCore.
size_t process_event_table()
Main loop of the RoutingMasterCore. Determines when to send the next table update, asks the RoutingMasterPolicy for the table to send, and sends it.
bool do_resume(uint64_t timeout, uint64_t timestamp) override
Resume the RoutingMasterCore.
RoutingMasterApp(int rank, std::string name)
RoutingMasterApp Constructor.
bool do_stop(uint64_t timeout, uint64_t timestamp) override
Stop the RoutingMasterCore.
std::string report(std::string const &) const override
If which is "transition_status", report the status of the last transition. Otherwise pass through to ...
bool do_shutdown(uint64_t timeout) override
Shutdown the RoutingMasterCore.
bool do_soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Soft-Initialize the RoutingMasterCore.
bool do_reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp) override
Reinitialize the RoutingMasterCore.
bool do_start(art::RunID id, uint64_t timeout, uint64_t timestamp) override
Start the RoutingMasterCore.
void BootedEnter() override
Action taken upon entering the "Booted" state.
RoutingMasterCore implements the state machine for the RoutingMaster artdaq application. RoutingMasterCore collects tokens from receivers, and at regular intervals uses these tokens to build Routing Tables that are sent to the senders.