1 #ifndef ARTDAQ_PROTO_ARTDAQAPP_HH
2 #define ARTDAQ_PROTO_ARTDAQAPP_HH
4 #include "artdaq/DAQdata/Globals.hh"
6 #include "artdaq-core/Utilities/configureMessageFacility.hh"
7 #include "artdaq/Application/BoardReaderApp.hh"
8 #include "artdaq/Application/DataLoggerApp.hh"
9 #include "artdaq/Application/DispatcherApp.hh"
10 #include "artdaq/Application/EventBuilderApp.hh"
11 #include "artdaq/Application/RoutingMasterApp.hh"
12 #include "artdaq/Application/TaskType.hh"
13 #include "artdaq/BuildInfo/GetPackageBuildInfo.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};
43 fhicl::TableFragment<artdaq::PortManager::Config>
portsConfig;
56 portMan->UpdateConfiguration(config_ps);
58 if (config_ps.get<
bool>(
"replace_image_name", config_ps.get<
bool>(
"rin",
false)))
61 s = prctl(PR_SET_NAME, app_name.c_str(), NULL, NULL, NULL);
64 std::cerr <<
"Could not replace process image name with " << app_name <<
"!" << std::endl;
69 std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
70 artdaq::configureMessageFacility(mf_app_name.c_str());
72 if (config_ps.has_key(
"rank"))
74 my_rank = config_ps.get<
int>(
"rank");
76 TLOG_DEBUG(app_name +
"Main") <<
"Setting application name to " << app_name;
79 if (config_ps.has_key(
"partition_number"))
88 artdaq::setMsgFacAppName(app_name, config_ps.get<
int>(
"id"));
90 std::unique_ptr<artdaq::Commandable> comm(
nullptr);
93 case (detail::BoardReaderTask):
96 case (detail::EventBuilderTask):
99 case (detail::DataLoggerTask):
102 case (detail::DispatcherTask):
105 case (detail::RoutingMasterTask):
112 auto auto_run = config_ps.get<
bool>(
"auto_run",
false);
115 int run = config_ps.get<
int>(
"run_number", 101);
116 uint64_t timeout = config_ps.get<uint64_t>(
"transition_timeout", 30);
117 uint64_t timestamp = 0;
120 comm->
do_start(art::RunID(run), timeout, timestamp);
122 TLOG_INFO(app_name +
"Main") <<
"Running XMLRPC Commander. To stop, either Control-C or " << std::endl
123 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.stop" << std::endl
124 <<
"xmlrpc http://`hostname`:" << config_ps.get<
int>(
"id") <<
"/RPC2 daq.shutdown";
128 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 void CleanUpGlobals()
Clean up statically-allocated Manager class instances.
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.
fhicl::TableFragment< artdaq::PortManager::Config > portsConfig
Configuration for artdaq Ports.
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::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.
std::string TaskTypeToString(TaskType const &task)
Convert a TaskType to string representation
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation (if desired)
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.