$treeview $search $mathjax $extrastylesheet
artdaq
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 00002 #include <sstream> 00003 #include <boost/program_options.hpp> 00004 namespace bpo = boost::program_options; 00005 00006 #include "fhiclcpp/make_ParameterSet.h" 00007 #include "artdaq/DAQdata/Globals.hh" 00008 #include "artdaq-core/Core/SharedMemoryEventReceiver.hh" 00009 00010 int main(int argc, char* argv[]) 00011 { 00012 00013 artdaq::configureMessageFacility("PrintSharedMemory"); 00014 00015 std::ostringstream descstr; 00016 descstr << argv[0] 00017 << " <-c <config-file>> <other-options> [<source-file>]+"; 00018 bpo::options_description desc(descstr.str()); 00019 desc.add_options() 00020 ("config,c", bpo::value<std::string>(), "Configuration file.") 00021 ("events,e", "Print event information") 00022 ("key,M", bpo::value<std::string>(), "Shared Memory to attach to") 00023 ("help,h", "produce help message"); 00024 bpo::variables_map vm; 00025 try { 00026 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm); 00027 bpo::notify(vm); 00028 } 00029 catch (bpo::error const & e) { 00030 std::cerr << "Exception from command line processing in " << argv[0] 00031 << ": " << e.what() << "\n"; 00032 return -1; 00033 } 00034 if (vm.count("help")) { 00035 std::cout << desc << std::endl; 00036 return 1; 00037 } 00038 if (!vm.count("config") && !vm.count("key")) { 00039 std::cerr << "Exception from command line processing in " << argv[0] 00040 << ": no configuration file given.\n" 00041 << "For usage and an options list, please do '" 00042 << argv[0] << " --help" 00043 << "'.\n"; 00044 return 2; 00045 } 00046 00047 fhicl::ParameterSet pset; 00048 if(vm.count("key")) 00049 { 00050 pset.put("shared_memory_key", vm["key"].as<std::string>()); 00051 pset.put("buffer_count", 1); 00052 pset.put("max_event_size_bytes", 1024); 00053 pset.put("ReadEventInfo", vm.count("events") > 0); 00054 } 00055 else { 00056 if (getenv("FHICL_FILE_PATH") == nullptr) { 00057 std::cerr 00058 << "INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n"; 00059 setenv("FHICL_FILE_PATH", ".", 0); 00060 } 00061 cet::filepath_lookup_after1 lookup_policy("FHICL_FILE_PATH"); 00062 fhicl::make_ParameterSet(vm["config"].as<std::string>(), lookup_policy, pset); 00063 } 00064 00065 if (!pset.has_key("shared_memory_key")) std::cerr << "You must specify a shared_memory_key in FHiCL or provide one on the command line!" << std::endl; 00066 00067 if(pset.get<bool>("ReadEventInfo", false)) 00068 { 00069 artdaq::SharedMemoryEventReceiver t(pset.get<uint32_t>("shared_memory_key"), pset.get<uint32_t>("broadcast_shared_memory_key", pset.get<uint32_t>("shared_memory_key"))); 00070 std::cout << t.toString() << std::endl; 00071 } 00072 else 00073 { 00074 artdaq::SharedMemoryManager t(pset.get<uint32_t>("shared_memory_key"), 00075 pset.get<size_t>("buffer_count"), 00076 pset.get<size_t>("max_event_size_bytes"), 00077 pset.get<size_t>("stale_buffer_timeout_usec", 1000000)); 00078 std::cout << t.toString() << std::endl; 00079 } 00080 }