00001 #define TRACE_NAME "daq_flow_t"
00002
00003 #include "art/Framework/Art/artapp.h"
00004 #include "artdaq-core/Data/Fragment.hh"
00005 #include "artdaq/DAQdata/GenericFragmentSimulator.hh"
00006 #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
00007 #include "cetlib_except/exception.h"
00008 #include "fhiclcpp/make_ParameterSet.h"
00009 #include "artdaq/Application/LoadParameterSet.hh"
00010
00011 #include <cstddef>
00012 #include <iostream>
00013 #include <string>
00014 #include <vector>
00015
00016 using artdaq::FragmentPtrs;
00017 using artdaq::GenericFragmentSimulator;
00018 using artdaq::SharedMemoryEventManager;
00019 using std::size_t;
00020
00021
00022 int main(int argc, char* argv[])
00023 {
00024 auto pset = LoadParameterSet(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(TLVL_DEBUG) << "Number of fragments: " << frags.size() ;
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(TLVL_ERROR) << "Fragment was not added after 1s. Check art thread status!" ;
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 }