$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
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 // Start server thread 00030 boost::thread commanderThread([&] { commander->run_server(); }); 00031 while (!commander->GetStatus()) usleep(10000); 00032 sleep(1); 00033 00034 uint64_t arg = 0; 00035 fhicl::ParameterSet pset; 00036 00037 TLOG(TLVL_DEBUG) << "Sending init"; 00038 std::string sts = commander->send_init(pset, arg, arg); 00039 TLOG(TLVL_DEBUG) << "init res=" << sts << ", sending soft_init"; 00040 sts = commander->send_soft_init(pset,arg,arg); 00041 TLOG(TLVL_DEBUG) << "soft_init res=" << sts << ", sending legal_commands"; 00042 00043 sts = commander->send_legal_commands(); 00044 TLOG(TLVL_DEBUG) << "legal_commands res=" << sts << ", sending meta_command"; 00045 sts = commander->send_meta_command("test","test"); 00046 TLOG(TLVL_DEBUG) << "meta_command res=" << sts << ", sending report"; 00047 sts = commander->send_report("test"); 00048 TLOG(TLVL_DEBUG) << "report res=" << sts << ", sending start"; 00049 00050 sts = commander->send_start(art::RunID(0x7357),arg,arg); 00051 TLOG(TLVL_DEBUG) << "start res=" << sts << ", sending status"; 00052 sts = commander->send_status(); 00053 TLOG(TLVL_DEBUG) << "status res=" << sts << ", sending pause"; 00054 sts = commander->send_pause(arg,arg); 00055 TLOG(TLVL_DEBUG) << "pause res=" << sts << ", sending resume"; 00056 sts = commander->send_resume(arg,arg); 00057 TLOG(TLVL_DEBUG) << "resume res=" << sts << ", sending rollover_subrun"; 00058 sts = commander->send_rollover_subrun(arg, arg); 00059 TLOG(TLVL_DEBUG) << "rollover_subrun res=" << sts << ", sending stop"; 00060 sts = commander->send_stop(arg,arg); 00061 TLOG(TLVL_DEBUG) << "stop res=" << sts << ", sending reinit"; 00062 sts = commander->send_reinit(pset, arg, arg); 00063 TLOG(TLVL_DEBUG) << "reinit res=" << sts << ", sending trace_set"; 00064 00065 sts = commander->send_trace_set("TRACE", "M", 0x7357); 00066 TLOG(TLVL_DEBUG) << "trace_set res=" << sts << ", sending trace_get"; 00067 sts = commander->send_trace_get("TRACE"); 00068 TLOG(TLVL_DEBUG) << "trace_get res=" << sts << ", sending register_monitor"; 00069 00070 sts = commander->send_register_monitor("test"); 00071 TLOG(TLVL_DEBUG) << "register_monitor res=" << sts << ", sending unregister_monitor"; 00072 sts = commander->send_unregister_monitor("test"); 00073 TLOG(TLVL_DEBUG) << "unregister_monitor res=" << sts << ", sending shutdown"; 00074 00075 sts = commander->send_shutdown(arg); 00076 TLOG(TLVL_DEBUG) << "shutdown res=" << sts << ", DONE"; 00077 00078 if(commanderThread.joinable()) commanderThread.join(); 00079 }