00001 #deinfe TRACE_NAME "requestReceiver" 00002 00003 #include <boost/program_options.hpp> 00004 #include "fhiclcpp/make_ParameterSet.h" 00005 namespace bpo = boost::program_options; 00006 00007 #include "artdaq/DAQrate/RequestReceiver.hh" 00008 #include "artdaq-core/Utilities/configureMessageFacility.hh" 00009 00010 int main(int argc, char* argv[]) 00011 { 00012 00013 artdaq::configureMessageFacility("requestReceiver"); 00014 00015 std::ostringstream descstr; 00016 descstr << argv[0] 00017 << " <-c <config-file>>"; 00018 bpo::options_description desc(descstr.str()); 00019 desc.add_options() 00020 ("config,c", bpo::value<std::string>(), "Configuration file.") 00021 ("help,h", "produce help message"); 00022 bpo::variables_map vm; 00023 try { 00024 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm); 00025 bpo::notify(vm); 00026 } 00027 catch (bpo::error const & e) { 00028 std::cerr << "Exception from command line processing in " << argv[0] 00029 << ": " << e.what() << "\n"; 00030 return -1; 00031 } 00032 if (vm.count("help")) { 00033 std::cout << desc << std::endl; 00034 return 1; 00035 } 00036 if (!vm.count("config")) { 00037 std::cerr << "Exception from command line processing in " << argv[0] 00038 << ": no configuration file given.\n" 00039 << "For usage and an options list, please do '" 00040 << argv[0] << " --help" 00041 << "'.\n"; 00042 return 2; 00043 } 00044 00045 fhicl::ParameterSet pset; 00046 if (getenv("FHICL_FILE_PATH") == nullptr) { 00047 std::cerr 00048 << "INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n"; 00049 setenv("FHICL_FILE_PATH", ".", 0); 00050 } 00051 cet::filepath_lookup_after1 lookup_policy("FHICL_FILE_PATH"); 00052 fhicl::make_ParameterSet(vm["config"].as<std::string>(), lookup_policy, pset); 00053 00054 int rc = 0; 00055 00056 artdaq::RequestReceiver recvr(pset); 00057 recvr.startRequestReceiverThread(); 00058 00059 while (true) 00060 { 00061 for (auto req : recvr.GetRequests()) 00062 { 00063 TLOG(TLVL_INFO) << "Received Request for Sequence ID " << std::to_string(req.first) << ", timestamp " << std::to_string(req.second) ; 00064 } 00065 recvr.ClearRequests(); 00066 usleep(10000); 00067 } 00068 00069 return rc; 00070 }