1 #include "otsdaq-core/GatewaySupervisor/ARTDAQCommandable.h"
2 #include "otsdaq-core/GatewaySupervisor/GatewaySupervisor.h"
3 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
5 ots::ARTDAQCommandable::ARTDAQCommandable(GatewaySupervisor * super)
6 : artdaq::Commandable()
7 , theSupervisor_(super)
8 , theCommander_(nullptr)
11 ots::ARTDAQCommandable::~ARTDAQCommandable()
13 if (theCommander_ !=
nullptr)
15 theCommander_->send_shutdown(0);
16 if (commanderThread_.joinable()) commanderThread_.join();
20 void ots::ARTDAQCommandable::init(
int commanderId, std::string commanderType)
22 fhicl::ParameterSet ps;
23 ps.put<
int>(
"id", commanderId);
24 ps.put<std::string>(
"commanderPluginType", commanderType);
26 theCommander_ = artdaq::MakeCommanderPlugin(ps, *
this);
27 boost::thread::attributes attrs;
28 attrs.set_stack_size(4096 * 2000);
29 commanderThread_ = boost::thread(attrs, boost::bind(&artdaq::CommanderInterface::run_server, theCommander_.get()));
34 std::vector<std::string> parameters;
35 parameters.push_back(ps.get<std::string>(
"config_name"));
37 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Initialize",
38 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
39 "ARTDAQCommandable", parameters);
41 ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Configure",
42 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
43 "ARTDAQCommandable", parameters);
50 std::vector<std::string> parameters;
51 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Start",
52 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
53 "ARTDAQCommandable", parameters);
60 std::vector<std::string> parameters;
61 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Stop",
62 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
63 "ARTDAQCommandable", parameters);
70 std::vector<std::string> parameters;
71 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Pause",
72 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
73 "ARTDAQCommandable", parameters);
80 std::vector<std::string> parameters;
81 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Resume",
82 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
83 "ARTDAQCommandable", parameters);
90 std::vector<std::string> parameters;
91 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Halt",
92 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
93 "ARTDAQCommandable", parameters);
95 ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr,
"Shutdown",
96 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
97 "ARTDAQCommandable", parameters);
104 std::vector<std::string> parameters;
105 parameters.push_back(args);
106 auto ret = theSupervisor_->attemptStateMachineTransition(
nullptr,
nullptr, command,
107 theSupervisor_->activeStateMachineName_, theSupervisor_->activeStateMachineWindowName_,
108 "ARTDAQCommandable", parameters);
109 report_string_ = ret;
bool do_shutdown(uint64_t) override
Perform the shutdown transition.
bool do_meta_command(std::string const &, std::string const &) override
Run a module-defined command with the given parameter string.
bool do_stop(uint64_t, uint64_t) override
Perform the stop transition.
bool do_start(art::RunID, uint64_t, uint64_t) override
Perform the start transition.
bool do_resume(uint64_t, uint64_t) override
Perform the resume transition.
bool do_initialize(fhicl::ParameterSet const &, uint64_t, uint64_t) override
Perform the initialize transition.
bool do_pause(uint64_t, uint64_t) override
Perform the pause transition.