1 #define TRACE_NAME "commander_test"
3 #include "artdaq/ExternalComms/CommanderInterface.hh"
5 #include "artdaq/Application/LoadParameterSet.hh"
6 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
8 #include <boost/thread.hpp>
9 #include "artdaq/DAQdata/Globals.hh"
11 int main(
int argc,
char** argv)
15 fhicl::TableFragment<artdaq::CommanderInterface::Config> commanderPluginConfig;
17 fhicl::Atom<std::string> partition_number{fhicl::Name{
"partition_number"}, fhicl::Comment{
"Partition to run in"},
""};
19 artdaq::configureMessageFacility(
"transfer_driver");
20 fhicl::ParameterSet config_ps = LoadParameterSet<Config>(argc, argv,
"commander_test",
"A test driver for CommanderInterface plugins");
24 auto id_rand = seedAndRandom();
25 if (config_ps.has_key(
"id"))
27 TLOG(TLVL_DEBUG) <<
"Ignoring set id and using random!";
28 config_ps.erase(
"id");
30 config_ps.put(
"id", artdaq::Globals::partition_number_ * 1000 + (id_rand % 1000));
37 boost::thread commanderThread([&] { commander->run_server(); });
38 while (!commander->GetStatus()) usleep(10000);
42 fhicl::ParameterSet pset;
44 TLOG(TLVL_DEBUG) <<
"Sending init";
45 std::string sts = commander->send_init(pset, arg, arg);
46 TLOG(TLVL_DEBUG) <<
"init res=" << sts <<
", sending soft_init";
47 sts = commander->send_soft_init(pset, arg, arg);
48 TLOG(TLVL_DEBUG) <<
"soft_init res=" << sts <<
", sending legal_commands";
50 sts = commander->send_legal_commands();
51 TLOG(TLVL_DEBUG) <<
"legal_commands res=" << sts <<
", sending meta_command";
52 sts = commander->send_meta_command(
"test",
"test");
53 TLOG(TLVL_DEBUG) <<
"meta_command res=" << sts <<
", sending report";
54 sts = commander->send_report(
"test");
55 TLOG(TLVL_DEBUG) <<
"report res=" << sts <<
", sending start";
57 sts = commander->send_start(art::RunID(0x7357), arg, arg);
58 TLOG(TLVL_DEBUG) <<
"start res=" << sts <<
", sending status";
59 sts = commander->send_status();
60 TLOG(TLVL_DEBUG) <<
"status res=" << sts <<
", sending pause";
61 sts = commander->send_pause(arg, arg);
62 TLOG(TLVL_DEBUG) <<
"pause res=" << sts <<
", sending resume";
63 sts = commander->send_resume(arg, arg);
64 TLOG(TLVL_DEBUG) <<
"resume res=" << sts <<
", sending rollover_subrun";
65 sts = commander->send_rollover_subrun(arg, arg);
66 TLOG(TLVL_DEBUG) <<
"rollover_subrun res=" << sts <<
", sending stop";
67 sts = commander->send_stop(arg, arg);
68 TLOG(TLVL_DEBUG) <<
"stop res=" << sts <<
", sending reinit";
69 sts = commander->send_reinit(pset, arg, arg);
70 TLOG(TLVL_DEBUG) <<
"reinit res=" << sts <<
", sending trace_set";
72 sts = commander->send_trace_set(
"TRACE",
"M", 0x7357);
73 TLOG(TLVL_DEBUG) <<
"trace_set res=" << sts <<
", sending trace_get";
74 sts = commander->send_trace_get(
"TRACE");
75 TLOG(TLVL_DEBUG) <<
"trace_get res=" << sts <<
", sending register_monitor";
77 sts = commander->send_register_monitor(
"test");
78 TLOG(TLVL_DEBUG) <<
"register_monitor res=" << sts <<
", sending unregister_monitor";
79 sts = commander->send_unregister_monitor(
"test");
80 TLOG(TLVL_DEBUG) <<
"unregister_monitor res=" << sts <<
", sending shutdown";
82 sts = commander->send_shutdown(arg);
83 TLOG(TLVL_DEBUG) <<
"shutdown res=" << sts <<
", DONE";
85 if (commanderThread.joinable()) commanderThread.join();
Commandable is the base class for all artdaq components which implement the artdaq state machine...
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.
static int partition_number_
The partition number of the current application.