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 "fhiclcpp/ParameterSet.h"
8 #include "artdaq-core/Utilities/configureMessageFacility.hh"
9 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
10 #include "artdaq/Application/BoardReaderApp.hh"
11 #include "artdaq/Application/EventBuilderApp.hh"
12 #include "artdaq/Application/DataLoggerApp.hh"
13 #include "artdaq/Application/DispatcherApp.hh"
14 #include "artdaq/Application/RoutingMasterApp.hh"
15 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
17 #include <sys/prctl.h>
22 static void runArtdaqApp(
detail::TaskType task, fhicl::ParameterSet
const& config_ps)
24 app_name = config_ps.get<std::string>(
"application_name", detail::TaskTypeToString(task));
26 if (config_ps.get<
bool>(
"replace_image_name", config_ps.get<
bool>(
"rin",
false)))
29 s = prctl(PR_SET_NAME, app_name.c_str(), NULL, NULL, NULL);
32 std::cerr <<
"Could not replace process image name with " << app_name <<
"!" << std::endl;
37 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
38 artdaq::configureMessageFacility(mf_app_name.c_str());
40 if (config_ps.has_key(
"rank")) {
41 my_rank = config_ps.get<
int>(
"rank");
43 TLOG_DEBUG(app_name +
"Main") <<
"Setting application name to " << app_name ;
45 TLOG_DEBUG(app_name +
"Main") <<
"artdaq version " <<
50 artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
52 std::unique_ptr<artdaq::Commandable> comm(
nullptr);
55 case(detail::BoardReaderTask):
58 case(detail::EventBuilderTask):
61 case(detail::DataLoggerTask):
64 case(detail::DispatcherTask):
67 case(detail::RoutingMasterTask):
74 auto auto_run = config_ps.get<
bool>(
"auto_run",
false);
76 int run = config_ps.get<
int>(
"run_number", 101);
77 uint64_t timeout = config_ps.get<uint64_t>(
"transition_timeout", 30);
78 uint64_t timestamp = 0;
81 comm->
do_start(art::RunID(run), timeout, timestamp);
83 TLOG_INFO(app_name +
"Main") <<
"Running XMLRPC Commander. To stop, either Control-C or " << std::endl
84 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.stop" << std::endl
85 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.shutdown" ;
89 commander->run_server();
94 #endif // ARTDAQ_PROTO_ARTDAQAPP_HH
virtual bool do_start(art::RunID, uint64_t, uint64_t)
Perform the start transition.
DispatcherApp is an artdaq::Commandable derived class which controls the DispatcherCore.
BoardReaderApp is an artdaq::Commandable derived class which controls the BoardReaderCore state machi...
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
DataLoggerApp is an artdaq::Commandable derived class which controls the DataLoggerCore.
EventBuilderApp is an artdaq::Commandable derived class which controls the EventBuilderCore.
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.
RoutingMasterApp is an artdaq::Commandable derived class which controls the RoutingMasterCore state m...
virtual bool do_initialize(fhicl::ParameterSet const &, uint64_t, uint64_t)
Perform the initialize transition.
TaskType
The types of applications in artdaq.