1 #ifndef ARTDAQ_PROTO_ARTDAQAPP_HH
2 #define ARTDAQ_PROTO_ARTDAQAPP_HH
4 #include "artdaq/DAQdata/Globals.hh"
6 #include "artdaq/Application/TaskType.hh"
7 #include "artdaq-core/Utilities/configureMessageFacility.hh"
8 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
9 #include "artdaq/Application/BoardReaderApp.hh"
10 #include "artdaq/Application/EventBuilderApp.hh"
11 #include "artdaq/Application/DataLoggerApp.hh"
12 #include "artdaq/Application/DispatcherApp.hh"
13 #include "artdaq/Application/RoutingMasterApp.hh"
14 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
16 #include <sys/prctl.h>
25 fhicl::Atom<std::string> application_name{ fhicl::Name{
"application_name" }, fhicl::Comment{
"Name to use for metrics and logging" },
"BoardReader" };
26 fhicl::Atom<bool> replace_image_name{ fhicl::Name{
"replace_image_name" }, fhicl::Comment{
"Replace the application image name with application_name" },
false };
27 fhicl::Atom<int> rank{ fhicl::Name{
"rank" }, fhicl::Comment{
"The \"rank\" of the application, used for configuring data transfers" } };
28 fhicl::TableFragment<artdaq::CommanderInterface::Config> commanderPluginConfig;
29 fhicl::Atom<bool> auto_run{ fhicl::Name{
"auto_run"}, fhicl::Comment{
"Whether to automatically start a run"},
false };
30 fhicl::Atom<int> run_number{ fhicl::Name{
"run_number"}, fhicl::Comment{
"Run number to use for automatic run"}, 101 };
31 fhicl::Atom<uint64_t> transition_timeout{ fhicl::Name{
"trantition_timeout"}, fhicl::Comment{
"Timeout to use for automatic transitions"}, 30 };
33 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
34 using Parameters = fhicl::WrappedTable<Config>;
37 static void runArtdaqApp(
detail::TaskType task, fhicl::ParameterSet
const& config_ps)
39 app_name = config_ps.get<std::string>(
"application_name", detail::TaskTypeToString(task));
41 if (config_ps.get<
bool>(
"replace_image_name", config_ps.get<
bool>(
"rin",
false)))
44 s = prctl(PR_SET_NAME, app_name.c_str(), NULL, NULL, NULL);
47 std::cerr <<
"Could not replace process image name with " << app_name <<
"!" << std::endl;
52 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
53 artdaq::configureMessageFacility(mf_app_name.c_str());
55 if (config_ps.has_key(
"rank"))
57 my_rank = config_ps.get<
int>(
"rank");
59 TLOG_DEBUG(app_name +
"Main") <<
"Setting application name to " << app_name;
61 TLOG_DEBUG(app_name +
"Main") <<
"artdaq version " <<
66 artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
68 std::unique_ptr<artdaq::Commandable> comm(
nullptr);
71 case(detail::BoardReaderTask):
72 comm.reset(
new BoardReaderApp());
74 case(detail::EventBuilderTask):
75 comm.reset(
new EventBuilderApp());
77 case(detail::DataLoggerTask):
78 comm.reset(
new DataLoggerApp());
80 case(detail::DispatcherTask):
81 comm.reset(
new DispatcherApp());
83 case(detail::RoutingMasterTask):
84 comm.reset(
new RoutingMasterApp());
90 auto auto_run = config_ps.get<
bool>(
"auto_run",
false);
93 int run = config_ps.get<
int>(
"run_number", 101);
94 uint64_t timeout = config_ps.get<uint64_t>(
"transition_timeout", 30);
95 uint64_t timestamp = 0;
97 comm->do_initialize(config_ps, timeout, timestamp);
98 comm->do_start(art::RunID(run), timeout, timestamp);
100 TLOG_INFO(app_name +
"Main") <<
"Running XMLRPC Commander. To stop, either Control-C or " << std::endl
101 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.stop" << std::endl
102 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.shutdown";
106 commander->run_server();
111 #endif // ARTDAQ_PROTO_ARTDAQAPP_HH
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.
TaskType
The types of applications in artdaq.