artdaq  v3_00_01
BoardReaderMain.cc
1 #include "artdaq/DAQdata/Globals.hh"
2 #include "artdaq/Application/TaskType.hh"
3 #include "artdaq/Application/BoardReaderApp.hh"
4 #include "artdaq/Application/MPI2/MPISentry.hh"
6 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
7 #include "artdaq/Application/LoadParameterSet.hh"
8 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
9 #include "cetlib_except/exception.h"
10 
11 #include <boost/program_options.hpp>
12 #include <boost/lexical_cast.hpp>
13 
14 #include <iostream>
15 #include <memory>
16 
17 int main(int argc, char* argv[])
18 {
19 
20  // initialization
21  int const wanted_threading_level{ MPI_THREAD_FUNNELED };
22 
23  MPI_Comm local_group_comm;
24  std::unique_ptr<artdaq::MPISentry> mpiSentry;
25 
26  try
27  {
28  mpiSentry.reset(new artdaq::MPISentry(&argc, &argv, wanted_threading_level, artdaq::TaskType::BoardReaderTask, local_group_comm));
29  }
30  catch (cet::exception& errormsg)
31  {
32  TLOG_ERROR("BoardReaderMain") << errormsg << TLOG_ENDL;
33  TLOG_ERROR("BoardReaderMain") << "MPISentry error encountered in BoardReaderMain; exiting..." << TLOG_ENDL;
34  throw errormsg;
35  }
36 
37  fhicl::ParameterSet config_ps = LoadParameterSet(argc, argv);
38  app_name = config_ps.get<std::string>("application_name", "BoardReader");
39  std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<int>("id"));
40  artdaq::configureMessageFacility(mf_app_name.c_str());
41  TLOG_DEBUG(app_name + "Main") << "Setting application name to " << mf_app_name << TLOG_ENDL;
42 
43 
44  TLOG_INFO(app_name + "Main") << "artdaq version " <<
46  << ", built " <<
47  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() << TLOG_ENDL;
48 
49  // create the BoardReaderApp
50  artdaq::BoardReaderApp br_app(mpiSentry->rank(), app_name);
51 
52  auto commander = artdaq::MakeCommanderPlugin(config_ps, br_app);
53  TLOG_INFO(app_name + "Main") << "Running Commmander Server" << TLOG_ENDL;
54  commander->run_server();
55  TLOG_INFO(app_name + "Main") << "Commandable Server ended, exiting..." << TLOG_ENDL;
56 }
BoardReaderApp is an artdaq::Commandable derived class which controls the BoardReaderCore state machi...
The MPISentry class initializes and finalizes the MPI context that the artdaq applciations run in...
Definition: MPISentry.hh:15
int rank() const
Get the MPI rank of the application.
Definition: MPISentry.cc:113
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.