1 #include "otsdaq/AggregatorApp/AggregatorInterface.h"
2 #include "otsdaq-core/MessageFacility/MessageFacility.h"
3 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
12 AggregatorInterface::AggregatorInterface(
int mpi_rank, std::string name) :
25 AggregatorInterface::~AggregatorInterface(
void)
29 void AggregatorInterface::configure(fhicl::ParameterSet
const& pset)
31 std::cout << __COUT_HDR_FL__ <<
"\tConfigure" << std::endl;
35 if (aggregator_ptr_.get() == 0) {
36 aggregator_ptr_.reset(
new artdaq::AggregatorCore(mpi_rank_, name_));
37 external_request_status_ = aggregator_ptr_->initialize(pset);
39 std::cout << __COUT_HDR_FL__ <<
"CANNOT RECONFIGURE!" << std::endl;
41 if (!external_request_status_) {
42 report_string_ =
"Error initializing ";
43 report_string_.append(name_ +
" ");
44 report_string_.append(
"with ParameterSet = \"" + pset.to_string() +
"\".");
49 void AggregatorInterface::halt(
void)
51 std::cout << __COUT_HDR_FL__ <<
"\tHalt" << std::endl;
53 external_request_status_ = aggregator_ptr_->shutdown();
54 if (!external_request_status_) {
55 report_string_ =
"Error shutting down ";
56 report_string_.append(name_ +
".");
61 void AggregatorInterface::pause(
void)
63 std::cout << __COUT_HDR_FL__ <<
"\tPause" << std::endl;
65 external_request_status_ = aggregator_ptr_->pause();
66 if (!external_request_status_) {
67 report_string_ =
"Error pausing ";
68 report_string_.append(name_ +
".");
71 if (aggregator_future_.valid()) {
72 aggregator_future_.get();
77 void AggregatorInterface::resume(
void)
79 std::cout << __COUT_HDR_FL__ <<
"\tResume" << std::endl;
81 external_request_status_ = aggregator_ptr_->resume();
82 if (!external_request_status_) {
83 report_string_ =
"Error resuming ";
84 report_string_.append(name_ +
".");
88 std::async(std::launch::async, &artdaq::AggregatorCore::process_fragments, aggregator_ptr_.get());
93 void AggregatorInterface::start(std::string runNumber)
95 std::cout << __COUT_HDR_FL__ <<
"\tStart" << std::endl;
98 art::RunID runId((art::RunNumber_t)boost::lexical_cast<art::RunNumber_t>(runNumber));
101 external_request_status_ = aggregator_ptr_->start(runId);
102 if (!external_request_status_) {
103 report_string_ =
"Error starting ";
104 report_string_.append(name_ +
" ");
105 report_string_.append(
"for run number ");
106 report_string_.append(boost::lexical_cast<std::string>(runId.run()));
107 report_string_.append(
".");
110 aggregator_future_ = std::async(std::launch::async, &artdaq::AggregatorCore::process_fragments, aggregator_ptr_.get());
114 void AggregatorInterface::stop(
void)
116 std::cout << __COUT_HDR_FL__ <<
"\tStop" << std::endl;
118 external_request_status_ = aggregator_ptr_->stop();
119 if (!external_request_status_) {
120 report_string_ =
"Error stopping ";
121 report_string_.append(name_ +
".");
124 if (aggregator_future_.valid()) {
125 aggregator_future_.get();