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