00001 #include "art/Framework/Art/artapp.h"
00002 #include "artdaq-core/Data/Fragment.hh"
00003 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
00004 #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
00005 #include "artdaq/Application/MPI2/MPISentry.hh"
00006 #include "cetlib/exception.h"
00007 #include "fhiclcpp/make_ParameterSet.h"
00008 #include "artdaq/Application/LoadParameterSet.hh"
00009
00010 #include <cstddef>
00011 #include <iostream>
00012 #include <string>
00013 #include <vector>
00014
00015 using artdaq::FragmentPtrs;
00016 using artdaq::GenericFragmentSimulator;
00017 using artdaq::SharedMemoryEventManager;
00018 using std::size_t;
00019
00020
00021 int main(int argc, char* argv[])
00022 {
00023 auto pset = LoadParameterSet(argc, argv);
00024 artdaq::MPISentry mpiSentry(&argc, &argv);
00025 int rc = -1;
00026 try
00027 {
00028 size_t const NUM_FRAGS_PER_EVENT = 5;
00029 SharedMemoryEventManager::run_id_t const RUN_ID = 2112;
00030 size_t const NUM_EVENTS = 100;
00031 pset.put("expected_fragments_per_event", NUM_FRAGS_PER_EVENT);
00032 pset.put("run_number", RUN_ID);
00033 pset.put("print_event_store_stats", true);
00034 pset.put("event_queue_wait_time", 10.0);
00035 pset.put("max_event_size_bytes", 0x100000);
00036 pset.put("buffer_count", 10);
00037 pset.put("send_init_fragments", false);
00038
00039 auto temp = pset.to_string() + " source.waiting_time: 10";
00040 pset = fhicl::ParameterSet();
00041 fhicl::make_ParameterSet(temp, pset);
00042
00043
00044
00045
00046 GenericFragmentSimulator sim(pset);
00047 SharedMemoryEventManager events(pset, pset);
00048 events.startRun(RUN_ID);
00049 FragmentPtrs frags;
00050 size_t event_count = 0;
00051 while (frags.clear() , event_count++ < NUM_EVENTS && sim.getNext(frags))
00052 {
00053 TLOG_DEBUG("daq_flow_t") << "Number of fragments: " << frags.size() << TLOG_ENDL;
00054 assert(frags.size() == NUM_FRAGS_PER_EVENT);
00055 for (auto&& frag : frags)
00056 {
00057 assert(frag != nullptr);
00058 artdaq::FragmentPtr tempFrag;
00059 auto sts = events.AddFragment(std::move(frag), 1000000, tempFrag);
00060 if (!sts)
00061 {
00062 TLOG_ERROR("daq_flow_t") << "Fragment was not added after 1s. Check art thread status!" << TLOG_ENDL;
00063 exit(1);
00064 }
00065 }
00066 }
00067
00068 bool endSucceeded = events.endOfData();
00069 if (endSucceeded)
00070 {
00071 rc = 0;
00072 }
00073 else
00074 {
00075 rc = 15;
00076 }
00077 }
00078 catch (cet::exception& x)
00079 {
00080 std::cerr << argv[0] << " failure\n" << x << std::endl;
00081 rc = 1;
00082 }
00083 catch (std::string& x)
00084 {
00085 std::cerr << argv[0] << " failure\n" << x << std::endl;
00086 rc = 2;
00087 }
00088 catch (char const* x)
00089 {
00090 std::cerr << argv[0] << " failure\n" << x << std::endl;
00091 rc = 3;
00092 }
00093 return rc;
00094 }