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