artdaq  v3_01_00
requestReceiver.cc
1 #deinfe TRACE_NAME "requestReceiver"
2 
3 #include <boost/program_options.hpp>
4 #include "fhiclcpp/make_ParameterSet.h"
5 namespace bpo = boost::program_options;
6 
7 #include "artdaq/DAQrate/RequestReceiver.hh"
8 #include "artdaq-core/Utilities/configureMessageFacility.hh"
9 
10 int main(int argc, char* argv[])
11 {
12 
13  artdaq::configureMessageFacility("requestReceiver");
14 
15  std::ostringstream descstr;
16  descstr << argv[0]
17  << " <-c <config-file>>";
18  bpo::options_description desc(descstr.str());
19  desc.add_options()
20  ("config,c", bpo::value<std::string>(), "Configuration file.")
21  ("help,h", "produce help message");
22  bpo::variables_map vm;
23  try {
24  bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
25  bpo::notify(vm);
26  }
27  catch (bpo::error const & e) {
28  std::cerr << "Exception from command line processing in " << argv[0]
29  << ": " << e.what() << "\n";
30  return -1;
31  }
32  if (vm.count("help")) {
33  std::cout << desc << std::endl;
34  return 1;
35  }
36  if (!vm.count("config")) {
37  std::cerr << "Exception from command line processing in " << argv[0]
38  << ": no configuration file given.\n"
39  << "For usage and an options list, please do '"
40  << argv[0] << " --help"
41  << "'.\n";
42  return 2;
43  }
44 
45  fhicl::ParameterSet pset;
46  if (getenv("FHICL_FILE_PATH") == nullptr) {
47  std::cerr
48  << "INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
49  setenv("FHICL_FILE_PATH", ".", 0);
50  }
51  cet::filepath_lookup_after1 lookup_policy("FHICL_FILE_PATH");
52  fhicl::make_ParameterSet(vm["config"].as<std::string>(), lookup_policy, pset);
53 
54  int rc = 0;
55 
56  artdaq::RequestReceiver recvr(pset);
57  recvr.startRequestReceiverThread();
58 
59  while (true)
60  {
61  for (auto req : recvr.GetRequests())
62  {
63  TLOG(TLVL_INFO) << "Received Request for Sequence ID " << std::to_string(req.first) << ", timestamp " << std::to_string(req.second) ;
64  }
65  recvr.ClearRequests();
66  usleep(10000);
67  }
68 
69  return rc;
70 }