00001 #include "artdaq/Application/Commandable.hh"
00002 #include "artdaq/Application/MPI2/MPISentry.hh"
00003 #include "artdaq/DAQdata/configureMessageFacility.hh"
00004 #include "artdaq/DAQrate/quiet_mpi.hh"
00005 #include "artdaq/DAQdata/Globals.hh"
00006 #include "artdaq/ExternalComms/xmlrpc_commander.hh"
00007
00008 #include <boost/program_options.hpp>
00009 #include <boost/lexical_cast.hpp>
00010
00011 #include <iostream>
00012
00013 int main(int argc, char* argv[])
00014 {
00015
00016 int const wanted_threading_level{MPI_THREAD_FUNNELED};
00017 artdaq::MPISentry mpiSentry(&argc, &argv, wanted_threading_level);
00018 artdaq::configureMessageFacility("commandable");
00019 TLOG_DEBUG("Commandable::main")
00020 << "MPI initialized with requested thread support level of "
00021 << wanted_threading_level << ", actual support level = "
00022 << mpiSentry.threading_level() << "." << TLOG_ENDL;
00023 TLOG_DEBUG("Commandable::main")
00024 << "size = "
00025 << mpiSentry.procs()
00026 << ", rank = "
00027 << mpiSentry.rank() << TLOG_ENDL;
00028
00029
00030 std::string usage = std::string(argv[0]) + " -p port_number <other-options>";
00031 boost::program_options::options_description desc(usage);
00032
00033 desc.add_options()
00034 ("port,p", boost::program_options::value<unsigned short>(), "Port number")
00035 ("help,h", "produce help message");
00036
00037 boost::program_options::variables_map vm;
00038 try
00039 {
00040 boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).run(), vm);
00041 boost::program_options::notify(vm);
00042 }
00043 catch (boost::program_options::error const& e)
00044 {
00045 TLOG_ERROR("Option") << "exception from command line processing in " << argv[0] << ": " << e.what() << TLOG_ENDL;
00046 return 1;
00047 }
00048
00049 if (vm.count("help"))
00050 {
00051 std::cout << desc << std::endl;
00052 return 0;
00053 }
00054
00055 if (!vm.count("port"))
00056 {
00057 TLOG_ERROR("Option") << argv[0] << " port number not suplied" << std::endl << "For usage and an options list, please do '" << argv[0] << " --help'" << TLOG_ENDL;
00058 return 1;
00059 }
00060
00061 artdaq::setMsgFacAppName("Commandable", vm["port"].as<unsigned short>());
00062
00063
00064 artdaq::Commandable commandable;
00065
00066
00067 artdaq::xmlrpc_commander commander(vm["port"].as<unsigned short>(), commandable);
00068 commander.run();
00069 }