00001 #define TRACE_NAME "commander_test"
00002
00003 #include "artdaq/ExternalComms/CommanderInterface.hh"
00004
00005 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
00006 #include "artdaq/Application/LoadParameterSet.hh"
00007
00008 #include "artdaq/DAQdata/Globals.hh"
00009 #include <boost/thread.hpp>
00010
00011 int main(int argc, char** argv)
00012 {
00013 struct Config
00014 {
00015 fhicl::TableFragment<artdaq::CommanderInterface::Config> commanderPluginConfig;
00016
00017 fhicl::Atom<std::string> partition_number{ fhicl::Name{ "partition_number" }, fhicl::Comment{ "Partition to run in" }, "" };
00018 };
00019 artdaq::configureMessageFacility("transfer_driver");
00020 fhicl::ParameterSet config_ps = LoadParameterSet<Config>(argc, argv, "commander_test", "A test driver for CommanderInterface plugins");
00021
00022
00023 if (config_ps.has_key("partition_number")) artdaq::Globals::partition_number_ = config_ps.get<int>("partition_number");
00024
00025 std::unique_ptr<artdaq::Commandable> cmdble(new artdaq::Commandable());
00026
00027 auto commander = artdaq::MakeCommanderPlugin(config_ps, *cmdble.get());
00028
00029
00030 boost::thread commanderThread([&] { commander->run_server(); });
00031 while (!commander->GetStatus()) usleep(10000);
00032
00033 uint64_t arg = 0;
00034 fhicl::ParameterSet pset;
00035
00036 TLOG(TLVL_DEBUG) << "Sending init";
00037 std::string sts = commander->send_init(pset, arg, arg);
00038 TLOG(TLVL_DEBUG) << "init res=" << sts << ", sending soft_init";
00039 sts = commander->send_soft_init(pset,arg,arg);
00040 TLOG(TLVL_DEBUG) << "soft_init res=" << sts << ", sending legal_commands";
00041
00042 sts = commander->send_legal_commands();
00043 TLOG(TLVL_DEBUG) << "legal_commands res=" << sts << ", sending meta_command";
00044 sts = commander->send_meta_command("test","test");
00045 TLOG(TLVL_DEBUG) << "meta_command res=" << sts << ", sending report";
00046 sts = commander->send_report("test");
00047 TLOG(TLVL_DEBUG) << "report res=" << sts << ", sending start";
00048
00049 sts = commander->send_start(art::RunID(0x7357),arg,arg);
00050 TLOG(TLVL_DEBUG) << "start res=" << sts << ", sending status";
00051 sts = commander->send_status();
00052 TLOG(TLVL_DEBUG) << "status res=" << sts << ", sending pause";
00053 sts = commander->send_pause(arg,arg);
00054 TLOG(TLVL_DEBUG) << "pause res=" << sts << ", sending resume";
00055 sts = commander->send_resume(arg,arg);
00056 TLOG(TLVL_DEBUG) << "resume res=" << sts << ", sending rollover_subrun";
00057 sts = commander->send_rollover_subrun(arg);
00058 TLOG(TLVL_DEBUG) << "rollover_subrun res=" << sts << ", sending stop";
00059 sts = commander->send_stop(arg,arg);
00060 TLOG(TLVL_DEBUG) << "stop res=" << sts << ", sending reinit";
00061 sts = commander->send_reinit(pset, arg, arg);
00062 TLOG(TLVL_DEBUG) << "reinit res=" << sts << ", sending trace_set";
00063
00064 sts = commander->send_trace_set("TRACE", "M", 0x7357);
00065 TLOG(TLVL_DEBUG) << "trace_set res=" << sts << ", sending trace_get";
00066 sts = commander->send_trace_get("TRACE");
00067 TLOG(TLVL_DEBUG) << "trace_get res=" << sts << ", sending register_monitor";
00068
00069 sts = commander->send_register_monitor("test");
00070 TLOG(TLVL_DEBUG) << "register_monitor res=" << sts << ", sending unregister_monitor";
00071 sts = commander->send_unregister_monitor("test");
00072 TLOG(TLVL_DEBUG) << "unregister_monitor res=" << sts << ", sending shutdown";
00073
00074 sts = commander->send_shutdown(arg);
00075 TLOG(TLVL_DEBUG) << "shutdown res=" << sts << ", DONE";
00076
00077 if(commanderThread.joinable()) commanderThread.join();
00078 }