00001 #include <iostream>
00002 #include <boost/program_options.hpp>
00003 #include <boost/lexical_cast.hpp>
00004 #include "artdaq/Application/TaskType.hh"
00005 #include "artdaq/Application/RoutingMasterApp.hh"
00006 #include "artdaq/ExternalComms/xmlrpc_commander.hh"
00007 #include "artdaq/Application/MPI2/MPISentry.hh"
00008 #include "artdaq/DAQrate/quiet_mpi.hh"
00009 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
00010 #include "cetlib/exception.h"
00011 #include "artdaq/DAQdata/Globals.hh"
00012
00013 int main(int argc, char* argv[])
00014 {
00015 artdaq::configureMessageFacility("routingmaster");
00016
00017
00018
00019 int const wanted_threading_level{ MPI_THREAD_FUNNELED };
00020
00021 MPI_Comm local_group_comm;
00022 std::unique_ptr<artdaq::MPISentry> mpiSentry;
00023
00024 try
00025 {
00026 mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::RoutingMasterTask, local_group_comm));
00027 }
00028 catch (cet::exception& errormsg)
00029 {
00030 TLOG_ERROR("RoutingMasterMain") << errormsg << TLOG_ENDL;
00031 TLOG_ERROR("RoutingMasterMain") << "MPISentry error encountered in RoutingMasterMain; exiting..." << TLOG_ENDL;
00032 throw errormsg;
00033 }
00034
00035
00036
00037 std::string usage = std::string(argv[0]) + " -p port_number -n name <other-options>";
00038 boost::program_options::options_description desc(usage);
00039
00040 desc.add_options()
00041 ("port,p", boost::program_options::value<unsigned short>(), "Port number")
00042 ("name,n", boost::program_options::value<std::string>(), "Application Nickname")
00043 ("help,h", "produce help message");
00044
00045 boost::program_options::variables_map vm;
00046 try
00047 {
00048 boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).run(), vm);
00049 boost::program_options::notify(vm);
00050 }
00051 catch (boost::program_options::error const& e)
00052 {
00053 TLOG_ERROR("Option") << "exception from command line processing in " << argv[0] << ": " << e.what() << TLOG_ENDL;
00054 return 1;
00055 }
00056
00057 if (vm.count("help"))
00058 {
00059 std::cout << desc << std::endl;
00060 return 0;
00061 }
00062
00063 if (!vm.count("port"))
00064 {
00065 TLOG_ERROR("Option") << argv[0] << " port number not supplied" << std::endl << "For usage and an options list, please do '" << argv[0] << " --help'" << TLOG_ENDL;
00066 return 1;
00067 }
00068
00069 std::string name = "RoutingMaster";
00070 if (vm.count("name"))
00071 {
00072 name = vm["name"].as<std::string>();
00073 TLOG_DEBUG(name + "Main") << "Setting application name to " << name << TLOG_ENDL;
00074 }
00075
00076 artdaq::setMsgFacAppName(name, vm["port"].as<unsigned short>());
00077 TLOG_DEBUG(name + "Main") << "artdaq version " <<
00078 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
00079 << ", built " <<
00080 artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() << TLOG_ENDL;
00081
00082
00083 artdaq::RoutingMasterApp rm_app(mpiSentry->rank(), name);
00084
00085
00086 artdaq::xmlrpc_commander commander(vm["port"].as<unsigned short>(), rm_app);
00087 commander.run();
00088 }