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>
31 fhicl::Atom<std::string>
application_name{ fhicl::Name{
"application_name" }, fhicl::Comment{
"Name to use for metrics and logging" },
"BoardReader" };
33 fhicl::Atom<bool>
replace_image_name{ fhicl::Name{
"replace_image_name" }, fhicl::Comment{
"Replace the application image name with application_name" },
false };
35 fhicl::Atom<int>
rank{ fhicl::Name{
"rank" }, fhicl::Comment{
"The \"rank\" of the application, used for configuring data transfers" } };
37 fhicl::Atom<bool>
auto_run{ fhicl::Name{
"auto_run"}, fhicl::Comment{
"Whether to automatically start a run"},
false };
40 fhicl::Atom<int>
run_number{ fhicl::Name{
"run_number"}, fhicl::Comment{
"Run number to use for automatic run"}, 101 };
42 fhicl::Atom<uint64_t>
transition_timeout{ fhicl::Name{
"transition_timeout"}, fhicl::Comment{
"Timeout to use for automatic transitions"}, 30 };
44 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
45 using Parameters = fhicl::WrappedTable<Config>;
57 if (config_ps.get<
bool>(
"replace_image_name", config_ps.get<
bool>(
"rin",
false)))
60 s = prctl(PR_SET_NAME, app_name.c_str(), NULL, NULL, NULL);
63 std::cerr <<
"Could not replace process image name with " << app_name <<
"!" << std::endl;
68 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
69 artdaq::configureMessageFacility(mf_app_name.c_str());
71 if (config_ps.has_key(
"rank"))
73 my_rank = config_ps.get<
int>(
"rank");
75 TLOG_DEBUG(app_name +
"Main") <<
"Setting application name to " << app_name;
78 if (config_ps.has_key(
"partition_number"))
84 TLOG_DEBUG(app_name +
"Main") <<
"artdaq version " <<
89 artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
91 std::unique_ptr<artdaq::Commandable> comm(
nullptr);
94 case(detail::BoardReaderTask):
97 case(detail::EventBuilderTask):
100 case(detail::DataLoggerTask):
103 case(detail::DispatcherTask):
106 case(detail::RoutingMasterTask):
113 auto auto_run = config_ps.get<
bool>(
"auto_run",
false);
116 int run = config_ps.get<
int>(
"run_number", 101);
117 uint64_t timeout = config_ps.get<uint64_t>(
"transition_timeout", 30);
118 uint64_t timestamp = 0;
121 comm->
do_start(art::RunID(run), timeout, timestamp);
123 TLOG_INFO(app_name +
"Main") <<
"Running XMLRPC Commander. To stop, either Control-C or " << std::endl
124 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.stop" << std::endl
125 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.shutdown";
129 commander->run_server();
134 #endif // ARTDAQ_PROTO_ARTDAQAPP_HH
virtual bool do_start(art::RunID, uint64_t, uint64_t)
Perform the start transition.
fhicl::Atom< int > run_number
"run_number" (Default: 101): Run number to use for automatic run
DispatcherApp is an artdaq::Commandable derived class which controls the DispatcherCore.
BoardReaderApp is an artdaq::Commandable derived class which controls the BoardReaderCore state machi...
fhicl::Atom< bool > auto_run
"auto_run" (Default: false): Whether to automatically start a run
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
Class representing an artdaq application. Used by all "main" functions to start artdaq.
DataLoggerApp is an artdaq::Commandable derived class which controls the DataLoggerCore.
EventBuilderApp is an artdaq::Commandable derived class which controls the EventBuilderCore.
fhicl::Atom< uint64_t > transition_timeout
"transition_timeout" (Default: 30): Timeout to use for automatic transitions
fhicl::Atom< std::string > application_name
"application_name" (Default: artdaq::detail::TaskTypeToString(task)): Name to use for metrics and log...
std::string TaskTypeToString(TaskType task)
Convert a TaskType to string representation
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...
fhicl::TableFragment< artdaq::CommanderInterface::Config > commanderPluginConfig
fhicl::Atom< int > rank
"rank": The "rank" of the application, used for configuring data transfers
static void runArtdaqApp(detail::TaskType task, fhicl::ParameterSet const &config_ps)
Run an artdaq Application
static int partition_number_
The partition number of the current application.
fhicl::Atom< bool > replace_image_name
"replace_image_name" (Default: false): Replace the application image name with application_name ...
Configuration of artdaqapp. May be used for parameter validation
virtual bool do_initialize(fhicl::ParameterSet const &, uint64_t, uint64_t)
Perform the initialize transition.
TaskType
The types of applications in artdaq.