1 #include "otsdaq/EventBuilderApp/EventBuilderInterface.h"
2 #include "otsdaq-core/MessageFacility/MessageFacility.h"
3 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
12 EventBuilderInterface::EventBuilderInterface(
int mpi_rank, std::string name) :
25 EventBuilderInterface::~EventBuilderInterface(
void)
29 void EventBuilderInterface::configure(fhicl::ParameterSet
const& pset)
31 std::cout << __COUT_HDR_FL__ <<
"\tConfigure" << std::endl;
33 external_request_status_ =
true;
40 if (event_builder_ptr_.get() == 0) {
41 event_builder_ptr_.reset(
new artdaq::EventBuilderCore(mpi_rank_, name_));
42 external_request_status_ = event_builder_ptr_->initialize(pset);
44 std::cout << __COUT_HDR_FL__ <<
"CANNOT RECONFIGURE!!!" << std::endl;
46 if (! external_request_status_) {
47 report_string_ =
"Error initializing an EventBuilderCore named";
48 report_string_.append(name_ +
" with ");
49 report_string_.append(
"ParameterSet = \"" + pset.to_string() +
"\".");
56 void EventBuilderInterface::halt(
void)
58 std::cout << __COUT_HDR_FL__ <<
"\tHalt" << std::endl;
61 external_request_status_ = event_builder_ptr_->shutdown();
62 if (! external_request_status_) {
63 report_string_ =
"Error shutting down ";
64 report_string_.append(name_ +
".");
69 void EventBuilderInterface::pause(
void)
71 std::cout << __COUT_HDR_FL__ <<
"\tPause" << std::endl;
73 external_request_status_ = event_builder_ptr_->pause();
74 if (! external_request_status_) {
75 report_string_ =
"Error pausing ";
76 report_string_.append(name_ +
".");
79 if (event_building_future_.valid()) {
80 event_building_future_.get();
85 void EventBuilderInterface::resume(
void)
87 std::cout << __COUT_HDR_FL__ <<
"\tResume" << std::endl;
89 external_request_status_ = event_builder_ptr_->resume();
90 if (! external_request_status_) {
91 report_string_ =
"Error resuming ";
92 report_string_.append(name_ +
".");
95 event_building_future_ =
96 std::async(std::launch::async, &artdaq::EventBuilderCore::process_fragments,
97 event_builder_ptr_.get());
102 void EventBuilderInterface::start(std::string runNumber)
104 std::cout << __COUT_HDR_FL__ <<
"\tStart" << std::endl;
107 art::RunID runId((art::RunNumber_t)boost::lexical_cast<art::RunNumber_t>(runNumber));
110 external_request_status_ = event_builder_ptr_->start(runId);
111 if (! external_request_status_) {
112 report_string_ =
"Error starting ";
113 report_string_.append(name_ +
" for run ");
114 report_string_.append(
"number ");
115 report_string_.append(boost::lexical_cast<std::string>(runId.run()));
116 report_string_.append(
".");
119 event_building_future_ = std::async(std::launch::async, &artdaq::EventBuilderCore::process_fragments, event_builder_ptr_.get());
125 void EventBuilderInterface::stop(
void)
127 std::cout << __COUT_HDR_FL__ <<
"\tStart" << std::endl;
129 external_request_status_ = event_builder_ptr_->stop();
130 if (! external_request_status_) {
131 report_string_ =
"Error stopping ";
132 report_string_.append(name_ +
".");
135 if (event_building_future_.valid()) {
136 event_building_future_.get();