1 #include "artdaq-core/Core/SharedMemoryEventReceiver.hh"
2 #include "artdaq-core/Utilities/configureMessageFacility.hh"
3 #include "artdaq/DAQdata/Globals.hh"
5 #include <boost/program_options.hpp>
6 namespace bpo = boost::program_options;
10 int main(
int argc,
char* argv[])
13 artdaq::configureMessageFacility(
"PrintSharedMemory");
15 std::ostringstream descstr;
17 <<
" [-M <shared memory>] <-e>";
18 bpo::options_description desc(descstr.str());
19 desc.add_options()(
"key,M", bpo::value<std::string>(),
"Shared Memory to attach to")(
"events,e",
"Print event information")(
"help,h",
"produce help message");
20 bpo::variables_map vm;
23 bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm);
26 catch (bpo::error
const& e)
28 std::cerr <<
"Exception from command line processing in " << *argv
29 <<
": " << e.what() <<
"\n";
32 if (vm.count(
"help") != 0u)
34 std::cout << desc << std::endl;
38 fhicl::ParameterSet pset;
39 if (vm.count(
"key") != 0u)
41 pset.put(
"shared_memory_key", vm[
"key"].as<std::string>());
42 auto bkey = vm[
"key"].as<std::string>();
43 if (bkey[2] ==
'e' && bkey[3] ==
'e')
47 pset.put(
"broadcast_shared_memory_key", bkey);
48 pset.put(
"read_event_info",
true);
52 pset.put(
"read_event_info", vm.count(
"events") > 0);
57 std::cerr <<
"You must specify a shared_memory_key in FHiCL or provide one on the command line!" << std::endl;
61 TLOG() <<
"Going to read shared memory " << std::showbase << std::hex << pset.get<uint32_t>(
"shared_memory_key") <<
" Event Mode: " << std::boolalpha << pset.get<
bool>(
"read_event_info");
62 if (pset.get<
bool>(
"read_event_info",
false))
64 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")));
65 std::cout << t.toString() << std::endl;
69 artdaq::SharedMemoryManager t(pset.get<uint32_t>(
"shared_memory_key"), 0, 0, 0);
70 std::cout << t.toString() << std::endl;