artdaq  v3_00_01
datalogger.cc
1 #include "artdaq/DAQdata/Globals.hh"
2 #include "artdaq-core/Data/Fragment.hh"
3 #include "artdaq-core/Utilities/ExceptionHandler.hh"
4 
5 #include "artdaq-utilities/Plugins/MetricManager.hh"
6 #include "cetlib/container_algorithms.h"
7 #include "cetlib/filepath_maker.h"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "fhiclcpp/make_ParameterSet.h"
10 #include <boost/program_options.hpp>
11 
12 #include <signal.h>
13 #include <iostream>
14 #include <memory>
15 #include <utility>
16 #include "artdaq/Application/DataLoggerApp.hh"
17 #include "artdaq/ExternalComms/MakeCommanderPlugin.hh"
18 #include "artdaq/Application/LoadParameterSet.hh"
19 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
20 
21 int main(int argc, char * argv[])
22 {
23  artdaq::configureMessageFacility("datalogger");
24 
25  fhicl::ParameterSet config = LoadParameterSet(argc, argv);
26 
27  std::string name = config.get<std::string>("application_name", "DataLogger");
28  auto rank = config.get<int>("rank", 0);
29  TLOG_DEBUG(name + "Main") << "Setting application name to " << name << TLOG_ENDL;
30 
31  TLOG_DEBUG(name + "Main") << "artdaq version " <<
33  << ", built " <<
34  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp() << TLOG_ENDL;
35 
36  artdaq::setMsgFacAppName(name, config.get<int>("id"));
37 
38  // create the DataLoggerApp
39  artdaq::DataLoggerApp dl_app(rank, name);
40 
41  auto auto_run = config.get<bool>("auto_run", false);
42  if (auto_run) {
43  int run = config.get<int>("run_number", 101);
44  uint64_t timeout = config.get<uint64_t>("transition_timeout", 30);
45  uint64_t timestamp = 0;
46 
47  dl_app.do_initialize(config, timeout, timestamp);
48  dl_app.do_start(art::RunID(run), timeout, timestamp);
49 
50  TLOG_INFO(name) << "Running XMLRPC Commander. To stop, either Control-C or " << std::endl
51  << "xmlrpc http://`hostname`:" << config.get<int>("id") << "/RPC2 daq.stop" << std::endl
52  << "xmlrpc http://`hostname`:" << config.get<int>("id") << "/RPC2 daq.shutdown" << TLOG_ENDL;
53  }
54 
55  auto commander = artdaq::MakeCommanderPlugin(config, dl_app);
56  commander->run_server();
57 
58 }
static artdaq::PackageBuildInfo getPackageBuildInfo()
Gets the version number and build timestmap for artdaq.
DataLoggerApp is an artdaq::Commandable derived class which controls the DataLoggerCore.
std::unique_ptr< artdaq::CommanderInterface > MakeCommanderPlugin(const fhicl::ParameterSet &commander_pset, artdaq::Commandable &commandable)
Load a CommanderInterface plugin.