1 #define TRACE_NAME "FragmentBuffer_t"
3 #define BOOST_TEST_MODULE FragmentBuffer_t
4 #include <boost/test/unit_test.hpp>
6 #include "artdaq-core/Data/ContainerFragment.hh"
7 #include "artdaq-core/Data/Fragment.hh"
8 #include "artdaq/DAQrate/FragmentBuffer.hh"
9 #include "artdaq/DAQrate/RequestSender.hh"
11 #define MESSAGEFACILITY_DEBUG true
13 #define RATE_TEST_COUNT 100000
14 #define TRACE_REQUIRE_EQUAL(l, r) \
19 TLOG(TLVL_DEBUG) << __LINE__ << ": Checking if " << #l << " (" << l << ") equals " << #r << " (" << r << ")...YES!"; \
23 TLOG(TLVL_ERROR) << __LINE__ << ": Checking if " << #l << " (" << l << ") equals " << #r << " (" << r << ")...NO!"; \
25 BOOST_REQUIRE_EQUAL(l, r); \
28 namespace artdaqtest {
29 class FragmentBufferTestGenerator;
49 artdaq::FragmentPtrs
Generate(
size_t n, std::vector<artdaq::Fragment::fragment_id_t> fragmentIds = std::vector<artdaq::Fragment::fragment_id_t>());
65 artdaq::Fragment::timestamp_t ts_;
66 artdaq::Fragment::sequence_id_t seq_;
67 std::set<artdaq::Fragment::fragment_id_t> fragmentIDs_;
73 metricMan->initialize(ps.get<fhicl::ParameterSet>(
"metrics", fhicl::ParameterSet()));
74 metricMan->do_start();
76 auto idlist = ps.get<std::vector<artdaq::Fragment::fragment_id_t>>(
"fragment_ids", {ps.get<artdaq::Fragment::fragment_id_t>(
"fragment_id", 1)});
77 for (
auto&
id : idlist)
79 fragmentIDs_.insert(
id);
85 if (fragmentIds.size() == 0) std::copy(fragmentIDs_.begin(), fragmentIDs_.end(), std::back_inserter(fragmentIds));
87 artdaq::FragmentPtrs frags;
91 for (
auto&
id : fragmentIds)
93 TLOG(TLVL_DEBUG) <<
"Adding Fragment with ID " <<
id <<
", SeqID " << seq_ <<
", and timestamp " << ts_;
94 frags.emplace_back(
new artdaq::Fragment(seq_,
id, artdaq::Fragment::FirstUserFragmentType, ts_));
103 BOOST_AUTO_TEST_SUITE(FragmentBuffer_t)
107 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
108 TLOG(TLVL_INFO) <<
"IgnoreRequests test case BEGIN";
109 fhicl::ParameterSet ps;
110 ps.put<
int>(
"fragment_id", 1);
111 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
112 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
113 ps.put<std::string>(
"request_mode",
"ignored");
115 auto buffer = std::make_shared<artdaq::RequestBuffer>();
116 buffer->setRunning(
true);
121 buffer->push(53, 35);
127 artdaq::FragmentPtrs fps;
130 TRACE_REQUIRE_EQUAL(sts,
true);
131 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
132 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
133 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
134 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
136 TLOG(TLVL_INFO) <<
"IgnoreRequests test case END";
141 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
142 TLOG(TLVL_INFO) <<
"SingleMode test case BEGIN";
143 fhicl::ParameterSet ps;
144 ps.put<
int>(
"fragment_id", 1);
145 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
146 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
147 ps.put<std::string>(
"request_mode",
"single");
149 auto buffer = std::make_shared<artdaq::RequestBuffer>();
150 buffer->setRunning(
true);
159 artdaq::FragmentPtrs fps;
161 auto type = artdaq::Fragment::FirstUserFragmentType;
162 TRACE_REQUIRE_EQUAL(sts,
true);
163 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
164 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
165 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
166 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
167 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
173 TRACE_REQUIRE_EQUAL(sts,
true);
174 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
175 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
176 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
177 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
178 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
187 TRACE_REQUIRE_EQUAL(sts,
true);
188 TRACE_REQUIRE_EQUAL(fps.size(), 2);
189 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
190 auto ts = artdaq::Fragment::InvalidTimestamp;
191 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
192 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
193 auto emptyType = artdaq::Fragment::EmptyFragmentType;
194 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
196 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
197 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
198 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
199 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
202 TLOG(TLVL_INFO) <<
"SingleMode test case END";
207 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
208 TLOG(TLVL_INFO) <<
"BufferMode test case BEGIN";
209 fhicl::ParameterSet ps;
210 ps.put<
int>(
"fragment_id", 1);
211 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
212 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
213 ps.put<std::string>(
"request_mode",
"buffer");
215 auto buffer = std::make_shared<artdaq::RequestBuffer>();
216 buffer->setRunning(
true);
226 artdaq::FragmentPtrs fps;
228 TRACE_REQUIRE_EQUAL(sts,
true);
229 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
230 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
231 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
232 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
233 auto type = artdaq::Fragment::ContainerFragmentType;
234 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
235 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
236 auto cf = artdaq::ContainerFragment(*fps.front());
237 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
238 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
239 type = artdaq::Fragment::FirstUserFragmentType;
240 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
246 TRACE_REQUIRE_EQUAL(sts,
true);
247 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
248 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
249 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
250 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
251 type = artdaq::Fragment::ContainerFragmentType;
252 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
253 auto cf2 = artdaq::ContainerFragment(*fps.front());
254 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
255 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
256 type = artdaq::Fragment::EmptyFragmentType;
257 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
265 TRACE_REQUIRE_EQUAL(sts,
true);
266 TRACE_REQUIRE_EQUAL(fps.size(), 2);
268 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
269 auto ts = artdaq::Fragment::InvalidTimestamp;
270 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
271 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
272 auto emptyType = artdaq::Fragment::EmptyFragmentType;
273 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
274 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
276 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
277 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
278 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
279 type = artdaq::Fragment::ContainerFragmentType;
280 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
281 auto cf3 = artdaq::ContainerFragment(*fps.front());
282 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
283 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
284 type = artdaq::Fragment::FirstUserFragmentType;
285 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
289 TLOG(TLVL_INFO) <<
"BufferMode test case END";
294 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
295 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case BEGIN";
296 fhicl::ParameterSet ps;
297 ps.put<
int>(
"fragment_id", 1);
298 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
299 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
300 ps.put<std::string>(
"request_mode",
"buffer");
301 ps.put(
"buffer_mode_keep_latest",
true);
303 auto buffer = std::make_shared<artdaq::RequestBuffer>();
304 buffer->setRunning(
true);
314 artdaq::FragmentPtrs fps;
316 TRACE_REQUIRE_EQUAL(sts,
true);
317 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
318 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
319 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
320 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
321 auto type = artdaq::Fragment::ContainerFragmentType;
322 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
323 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
324 auto cf = artdaq::ContainerFragment(*fps.front());
325 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
326 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
327 type = artdaq::Fragment::FirstUserFragmentType;
328 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
334 TRACE_REQUIRE_EQUAL(sts,
true);
335 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
336 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
337 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
338 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
339 type = artdaq::Fragment::ContainerFragmentType;
340 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
341 auto cf2 = artdaq::ContainerFragment(*fps.front());
342 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
343 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
344 type = artdaq::Fragment::FirstUserFragmentType;
345 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
352 TRACE_REQUIRE_EQUAL(sts,
true);
353 TRACE_REQUIRE_EQUAL(fps.size(), 2);
355 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
356 auto ts = artdaq::Fragment::InvalidTimestamp;
357 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
358 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
359 auto emptyType = artdaq::Fragment::EmptyFragmentType;
360 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
361 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
363 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
364 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
365 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
366 type = artdaq::Fragment::ContainerFragmentType;
367 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
368 auto cf3 = artdaq::ContainerFragment(*fps.front());
369 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
370 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
371 type = artdaq::Fragment::FirstUserFragmentType;
372 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
376 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case END";
380 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
381 TLOG(TLVL_INFO) <<
"CircularBufferMode test case BEGIN";
382 fhicl::ParameterSet ps;
383 ps.put<
int>(
"fragment_id", 1);
384 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
385 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
386 ps.put<
bool>(
"circular_buffer_mode",
true);
387 ps.put<
int>(
"data_buffer_depth_fragments", 3);
388 ps.put<std::string>(
"request_mode",
"buffer");
390 auto buffer = std::make_shared<artdaq::RequestBuffer>();
391 buffer->setRunning(
true);
401 artdaq::FragmentPtrs fps;
403 TRACE_REQUIRE_EQUAL(sts,
true);
404 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
405 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
406 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
407 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
408 auto type = artdaq::Fragment::ContainerFragmentType;
409 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
410 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
411 auto cf = artdaq::ContainerFragment(*fps.front());
412 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
413 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
414 type = artdaq::Fragment::FirstUserFragmentType;
415 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
421 TRACE_REQUIRE_EQUAL(sts,
true);
422 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
423 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
424 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
425 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
426 type = artdaq::Fragment::ContainerFragmentType;
427 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
428 auto cf2 = artdaq::ContainerFragment(*fps.front());
429 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
430 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
431 type = artdaq::Fragment::EmptyFragmentType;
432 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
440 TRACE_REQUIRE_EQUAL(sts,
true);
441 TRACE_REQUIRE_EQUAL(fps.size(), 2);
443 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
444 auto ts = artdaq::Fragment::InvalidTimestamp;
445 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
446 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
447 auto emptyType = artdaq::Fragment::EmptyFragmentType;
448 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
449 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
451 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
452 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
453 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
454 type = artdaq::Fragment::ContainerFragmentType;
455 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
456 auto cf3 = artdaq::ContainerFragment(*fps.front());
457 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
458 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
459 type = artdaq::Fragment::FirstUserFragmentType;
460 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
469 TRACE_REQUIRE_EQUAL(sts,
true);
470 TRACE_REQUIRE_EQUAL(fps.size(), 1);
472 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
473 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
474 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
475 type = artdaq::Fragment::ContainerFragmentType;
476 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
477 auto cf4 = artdaq::ContainerFragment(*fps.front());
478 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
479 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
480 type = artdaq::Fragment::FirstUserFragmentType;
481 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
482 TRACE_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
483 TRACE_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
484 TRACE_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
488 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
493 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
494 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
495 fhicl::ParameterSet ps;
496 ps.put<
int>(
"fragment_id", 1);
498 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
499 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
500 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
501 ps.put<
bool>(
"circular_buffer_mode",
true);
502 ps.put<std::string>(
"request_mode",
"window");
503 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
504 ps.put<
size_t>(
"window_close_timeout_us", 500000);
506 auto buffer = std::make_shared<artdaq::RequestBuffer>();
507 buffer->setRunning(
true);
517 artdaq::FragmentPtrs fps;
520 TRACE_REQUIRE_EQUAL(sts,
true);
521 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
522 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
523 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
524 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
525 auto type = artdaq::Fragment::ContainerFragmentType;
526 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
527 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
528 auto cf = artdaq::ContainerFragment(*fps.front());
529 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
530 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
531 type = artdaq::Fragment::FirstUserFragmentType;
532 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
540 TRACE_REQUIRE_EQUAL(sts,
true);
541 TRACE_REQUIRE_EQUAL(fps.size(), 0);
547 TRACE_REQUIRE_EQUAL(sts,
true);
548 TRACE_REQUIRE_EQUAL(fps.size(), 1);
549 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
550 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
551 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
552 type = artdaq::Fragment::ContainerFragmentType;
553 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
554 auto cf2 = artdaq::ContainerFragment(*fps.front());
555 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
556 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
557 type = artdaq::Fragment::FirstUserFragmentType;
558 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
565 TRACE_REQUIRE_EQUAL(sts,
true);
566 TRACE_REQUIRE_EQUAL(fps.size(), 0);
571 TRACE_REQUIRE_EQUAL(sts,
true);
572 TRACE_REQUIRE_EQUAL(fps.size(), 1);
576 TRACE_REQUIRE_EQUAL(list.size(), 1);
577 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
582 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
583 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
584 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
585 type = artdaq::Fragment::ContainerFragmentType;
586 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
587 auto cf3 = artdaq::ContainerFragment(*fps.front());
588 TRACE_REQUIRE_EQUAL(cf3.block_count(), 0);
589 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
true);
590 type = artdaq::Fragment::EmptyFragmentType;
591 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
601 TRACE_REQUIRE_EQUAL(list.size(), 1);
605 TRACE_REQUIRE_EQUAL(list.size(), 0);
606 TRACE_REQUIRE_EQUAL(sts,
true);
607 TRACE_REQUIRE_EQUAL(fps.size(), 1);
608 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
609 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
610 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
611 type = artdaq::Fragment::ContainerFragmentType;
612 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
613 auto cf4 = artdaq::ContainerFragment(*fps.front());
614 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
615 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
616 type = artdaq::Fragment::EmptyFragmentType;
617 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
624 TRACE_REQUIRE_EQUAL(sts,
true);
625 TRACE_REQUIRE_EQUAL(fps.size(), 1);
626 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
627 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
628 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
629 type = artdaq::Fragment::ContainerFragmentType;
630 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
631 auto cf5 = artdaq::ContainerFragment(*fps.front());
632 TRACE_REQUIRE_EQUAL(cf5.block_count(), 1);
633 TRACE_REQUIRE_EQUAL(cf5.missing_data(),
false);
634 type = artdaq::Fragment::FirstUserFragmentType;
635 TRACE_REQUIRE_EQUAL(cf5.fragment_type(), type);
640 TRACE_REQUIRE_EQUAL(list.size(), 1);
641 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
646 TRACE_REQUIRE_EQUAL(sts,
true);
647 TRACE_REQUIRE_EQUAL(fps.size(), 1);
648 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
649 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
650 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
651 type = artdaq::Fragment::ContainerFragmentType;
652 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
653 auto cf6 = artdaq::ContainerFragment(*fps.front());
654 TRACE_REQUIRE_EQUAL(cf6.block_count(), 1);
655 TRACE_REQUIRE_EQUAL(cf6.missing_data(),
false);
656 type = artdaq::Fragment::FirstUserFragmentType;
657 TRACE_REQUIRE_EQUAL(cf6.fragment_type(), type);
662 TRACE_REQUIRE_EQUAL(list.size(), 0);
666 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
677 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
678 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
679 fhicl::ParameterSet ps;
680 ps.put<
int>(
"fragment_id", 1);
682 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
683 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
684 ps.put<
bool>(
"circular_buffer_mode",
true);
685 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
686 ps.put<std::string>(
"request_mode",
"window");
688 auto buffer = std::make_shared<artdaq::RequestBuffer>();
689 buffer->setRunning(
true);
694 artdaq::FragmentPtrs fps;
696 artdaq::Fragment::type_t type;
705 TRACE_REQUIRE_EQUAL(sts,
true);
706 TRACE_REQUIRE_EQUAL(fps.size(), 1);
707 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
708 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
709 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
710 type = artdaq::Fragment::ContainerFragmentType;
711 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
712 auto cf4 = artdaq::ContainerFragment(*fps.front());
713 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
714 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
715 type = artdaq::Fragment::EmptyFragmentType;
716 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
718 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
722 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
723 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
725 fhicl::ParameterSet ps;
726 ps.put<
int>(
"fragment_id", 1);
727 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
728 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
729 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
730 ps.put<
bool>(
"circular_buffer_mode",
true);
731 ps.put<std::string>(
"request_mode",
"window");
733 auto buffer = std::make_shared<artdaq::RequestBuffer>();
734 buffer->setRunning(
true);
739 artdaq::FragmentPtrs fps;
741 artdaq::Fragment::type_t type;
750 TRACE_REQUIRE_EQUAL(sts,
true);
751 TRACE_REQUIRE_EQUAL(fps.size(), 1);
752 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
753 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
754 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
755 type = artdaq::Fragment::ContainerFragmentType;
756 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
757 auto cf4 = artdaq::ContainerFragment(*fps.front());
758 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
759 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
760 type = artdaq::Fragment::FirstUserFragmentType;
761 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
763 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case END";
767 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
768 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case BEGIN";
769 fhicl::ParameterSet ps;
770 ps.put<
int>(
"fragment_id", 1);
771 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
772 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 4);
773 ps.put<
size_t>(
"window_close_timeout_us", 500000);
774 ps.put<
bool>(
"circular_buffer_mode",
true);
775 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
776 ps.put<std::string>(
"request_mode",
"window");
778 auto buffer = std::make_shared<artdaq::RequestBuffer>();
779 buffer->setRunning(
true);
784 artdaq::FragmentPtrs fps;
786 artdaq::Fragment::type_t type;
796 TRACE_REQUIRE_EQUAL(sts,
true);
797 TRACE_REQUIRE_EQUAL(fps.size(), 1);
798 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
799 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
800 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
801 type = artdaq::Fragment::ContainerFragmentType;
802 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
803 auto cf = artdaq::ContainerFragment(*fps.front());
804 TRACE_REQUIRE_EQUAL(cf.block_count(), 4);
805 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
806 type = artdaq::Fragment::FirstUserFragmentType;
807 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
813 TRACE_REQUIRE_EQUAL(sts,
true);
814 TRACE_REQUIRE_EQUAL(fps.size(), 0);
819 TRACE_REQUIRE_EQUAL(sts,
true);
820 TRACE_REQUIRE_EQUAL(fps.size(), 1);
821 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
822 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
823 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
824 type = artdaq::Fragment::ContainerFragmentType;
825 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
826 auto cf2 = artdaq::ContainerFragment(*fps.front());
827 TRACE_REQUIRE_EQUAL(cf2.block_count(), 3);
828 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
true);
829 type = artdaq::Fragment::FirstUserFragmentType;
830 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
836 TRACE_REQUIRE_EQUAL(sts,
true);
837 TRACE_REQUIRE_EQUAL(fps.size(), 0);
842 TRACE_REQUIRE_EQUAL(sts,
true);
843 TRACE_REQUIRE_EQUAL(fps.size(), 1);
844 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
845 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
846 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
847 type = artdaq::Fragment::ContainerFragmentType;
848 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
849 auto cf4 = artdaq::ContainerFragment(*fps.front());
850 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
851 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
852 type = artdaq::Fragment::FirstUserFragmentType;
853 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
855 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
859 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
860 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
861 fhicl::ParameterSet ps;
862 ps.put<
int>(
"fragment_id", 1);
863 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
864 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
865 ps.put<
bool>(
"circular_buffer_mode",
true);
866 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
867 ps.put<std::string>(
"request_mode",
"window");
869 auto buffer = std::make_shared<artdaq::RequestBuffer>();
870 buffer->setRunning(
true);
875 artdaq::FragmentPtrs fps;
877 artdaq::Fragment::type_t type;
886 TRACE_REQUIRE_EQUAL(sts,
true);
887 TRACE_REQUIRE_EQUAL(fps.size(), 1);
888 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
889 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
890 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
891 type = artdaq::Fragment::ContainerFragmentType;
892 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
893 auto cf4 = artdaq::ContainerFragment(*fps.front());
894 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
895 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
896 type = artdaq::Fragment::FirstUserFragmentType;
897 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
899 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
903 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
904 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
905 fhicl::ParameterSet ps;
906 ps.put<
int>(
"fragment_id", 1);
907 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
908 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
909 ps.put<
size_t>(
"window_close_timeout_us", 500000);
910 ps.put<
bool>(
"circular_buffer_mode",
true);
911 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
912 ps.put<std::string>(
"request_mode",
"window");
914 auto buffer = std::make_shared<artdaq::RequestBuffer>();
915 buffer->setRunning(
true);
920 artdaq::FragmentPtrs fps;
922 artdaq::Fragment::type_t type;
931 TRACE_REQUIRE_EQUAL(sts,
true);
932 TRACE_REQUIRE_EQUAL(fps.size(), 0);
937 TRACE_REQUIRE_EQUAL(sts,
true);
938 TRACE_REQUIRE_EQUAL(fps.size(), 1);
939 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
940 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
941 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
942 type = artdaq::Fragment::ContainerFragmentType;
943 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
944 auto cf = artdaq::ContainerFragment(*fps.front());
945 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
946 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
947 type = artdaq::Fragment::FirstUserFragmentType;
948 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
954 TRACE_REQUIRE_EQUAL(sts,
true);
955 TRACE_REQUIRE_EQUAL(fps.size(), 0);
960 TRACE_REQUIRE_EQUAL(sts,
true);
961 TRACE_REQUIRE_EQUAL(fps.size(), 1);
962 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
963 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
964 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
965 type = artdaq::Fragment::ContainerFragmentType;
966 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
967 auto cf4 = artdaq::ContainerFragment(*fps.front());
968 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
969 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
970 type = artdaq::Fragment::FirstUserFragmentType;
971 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
973 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
977 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
978 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
979 fhicl::ParameterSet ps;
980 ps.put<
int>(
"fragment_id", 1);
981 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
982 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
983 ps.put<
size_t>(
"window_close_timeout_us", 500000);
984 ps.put<
bool>(
"circular_buffer_mode",
true);
985 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
986 ps.put<std::string>(
"request_mode",
"window");
988 auto buffer = std::make_shared<artdaq::RequestBuffer>();
989 buffer->setRunning(
true);
994 artdaq::FragmentPtrs fps;
996 artdaq::Fragment::type_t type;
1002 buffer->push(1, 11);
1005 TRACE_REQUIRE_EQUAL(sts,
true);
1006 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1010 TRACE_REQUIRE_EQUAL(sts,
true);
1011 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1016 TRACE_REQUIRE_EQUAL(sts,
true);
1017 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1018 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1019 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1020 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1021 type = artdaq::Fragment::ContainerFragmentType;
1022 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1023 auto cf = artdaq::ContainerFragment(*fps.front());
1024 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1025 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1026 type = artdaq::Fragment::FirstUserFragmentType;
1027 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1030 buffer->push(2, 16);
1033 TRACE_REQUIRE_EQUAL(sts,
true);
1034 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1039 TRACE_REQUIRE_EQUAL(sts,
true);
1040 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1041 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1042 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
1043 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1044 type = artdaq::Fragment::ContainerFragmentType;
1045 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1046 auto cf4 = artdaq::ContainerFragment(*fps.front());
1047 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
1048 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
1049 type = artdaq::Fragment::EmptyFragmentType;
1050 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
1052 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1057 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1058 TLOG(TLVL_INFO) <<
"SequenceIDMode test case BEGIN";
1059 fhicl::ParameterSet ps;
1060 ps.put<
int>(
"fragment_id", 1);
1061 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1062 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1063 ps.put<std::string>(
"request_mode",
"SequenceID");
1065 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1066 buffer->setRunning(
true);
1077 artdaq::FragmentPtrs fps;
1079 auto type = artdaq::Fragment::FirstUserFragmentType;
1080 TRACE_REQUIRE_EQUAL(sts,
true);
1081 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1082 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1083 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1084 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1085 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1093 TRACE_REQUIRE_EQUAL(sts,
true);
1094 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1100 TRACE_REQUIRE_EQUAL(sts,
true);
1101 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1102 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1103 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1104 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1105 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1116 TRACE_REQUIRE_EQUAL(sts,
true);
1117 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1118 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1119 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1120 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1121 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1128 TRACE_REQUIRE_EQUAL(sts,
true);
1129 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1130 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1131 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1132 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1133 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1135 TLOG(TLVL_INFO) <<
"SequenceIDMode test case END";
1140 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1141 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1142 fhicl::ParameterSet ps;
1143 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1144 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1145 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1146 ps.put<std::string>(
"request_mode",
"ignored");
1148 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1149 buffer->setRunning(
true);
1154 buffer->push(53, 35);
1157 artdaq::FragmentPtrs fps;
1158 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1160 TRACE_REQUIRE_EQUAL(sts,
true);
1161 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1162 while (fps.size() > 0)
1164 ids[fps.front()->fragmentID()]++;
1165 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1166 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1170 TRACE_REQUIRE_EQUAL(ids[1], 1);
1171 TRACE_REQUIRE_EQUAL(ids[2], 1);
1172 TRACE_REQUIRE_EQUAL(ids[3], 1);
1177 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1182 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1183 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1184 fhicl::ParameterSet ps;
1185 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1186 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1187 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1188 ps.put<std::string>(
"request_mode",
"single");
1190 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1191 buffer->setRunning(
true);
1201 artdaq::FragmentPtrs fps;
1202 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1204 auto type = artdaq::Fragment::FirstUserFragmentType;
1205 TRACE_REQUIRE_EQUAL(sts,
true);
1206 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1207 while (fps.size() > 0)
1209 ids[fps.front()->fragmentID()]++;
1210 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1211 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1212 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1215 TRACE_REQUIRE_EQUAL(ids[1], 1);
1216 TRACE_REQUIRE_EQUAL(ids[2], 1);
1217 TRACE_REQUIRE_EQUAL(ids[3], 1);
1226 TRACE_REQUIRE_EQUAL(sts,
true);
1227 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1228 while (fps.size() > 0)
1230 ids[fps.front()->fragmentID()]++;
1231 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1232 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1233 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1236 TRACE_REQUIRE_EQUAL(ids[1], 1);
1237 TRACE_REQUIRE_EQUAL(ids[2], 1);
1238 TRACE_REQUIRE_EQUAL(ids[3], 1);
1250 TRACE_REQUIRE_EQUAL(sts,
true);
1251 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1252 auto ts = artdaq::Fragment::InvalidTimestamp;
1253 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1254 for (
auto ii = 0; ii < 3; ++ii)
1256 ids[fps.front()->fragmentID()]++;
1257 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1258 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1259 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1262 TRACE_REQUIRE_EQUAL(ids[1], 1);
1263 TRACE_REQUIRE_EQUAL(ids[2], 1);
1264 TRACE_REQUIRE_EQUAL(ids[3], 1);
1266 for (
auto ii = 0; ii < 3; ++ii)
1268 ids[fps.front()->fragmentID()]++;
1269 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1270 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1271 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1274 TRACE_REQUIRE_EQUAL(ids[1], 1);
1275 TRACE_REQUIRE_EQUAL(ids[2], 1);
1276 TRACE_REQUIRE_EQUAL(ids[3], 1);
1287 TRACE_REQUIRE_EQUAL(sts,
true);
1288 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1289 for (
auto ii = 0; ii < 3; ++ii)
1291 ids[fps.front()->fragmentID()]++;
1292 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1293 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1294 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1297 TRACE_REQUIRE_EQUAL(ids[1], 1);
1298 TRACE_REQUIRE_EQUAL(ids[2], 1);
1299 TRACE_REQUIRE_EQUAL(ids[3], 1);
1303 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1308 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1309 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1310 fhicl::ParameterSet ps;
1311 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1312 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1313 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1314 ps.put<std::string>(
"request_mode",
"buffer");
1316 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1317 buffer->setRunning(
true);
1327 artdaq::FragmentPtrs fps;
1328 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1330 TRACE_REQUIRE_EQUAL(sts,
true);
1331 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1332 auto type = artdaq::Fragment::ContainerFragmentType;
1333 while (fps.size() > 0)
1335 ids[fps.front()->fragmentID()]++;
1336 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1337 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1338 type = artdaq::Fragment::ContainerFragmentType;
1339 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1340 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1341 auto cf = artdaq::ContainerFragment(*fps.front());
1342 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1343 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1344 type = artdaq::Fragment::FirstUserFragmentType;
1345 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1348 TRACE_REQUIRE_EQUAL(ids[1], 1);
1349 TRACE_REQUIRE_EQUAL(ids[2], 1);
1350 TRACE_REQUIRE_EQUAL(ids[3], 1);
1358 TRACE_REQUIRE_EQUAL(sts,
true);
1359 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1360 while (fps.size() > 0)
1362 ids[fps.front()->fragmentID()]++;
1363 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1364 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1365 type = artdaq::Fragment::ContainerFragmentType;
1366 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1367 auto cf = artdaq::ContainerFragment(*fps.front());
1368 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1369 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1370 type = artdaq::Fragment::EmptyFragmentType;
1371 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1374 TRACE_REQUIRE_EQUAL(ids[1], 1);
1375 TRACE_REQUIRE_EQUAL(ids[2], 1);
1376 TRACE_REQUIRE_EQUAL(ids[3], 1);
1386 TRACE_REQUIRE_EQUAL(sts,
true);
1387 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1389 auto ts = artdaq::Fragment::InvalidTimestamp;
1390 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1391 for (
auto ii = 0; ii < 3; ++ii)
1393 ids[fps.front()->fragmentID()]++;
1394 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1395 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1396 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1397 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1400 TRACE_REQUIRE_EQUAL(ids[1], 1);
1401 TRACE_REQUIRE_EQUAL(ids[2], 1);
1402 TRACE_REQUIRE_EQUAL(ids[3], 1);
1404 for (
auto ii = 0; ii < 3; ++ii)
1406 ids[fps.front()->fragmentID()]++;
1407 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1408 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1409 type = artdaq::Fragment::ContainerFragmentType;
1410 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1411 auto cf3 = artdaq::ContainerFragment(*fps.front());
1412 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
1413 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1414 type = artdaq::Fragment::FirstUserFragmentType;
1415 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1418 TRACE_REQUIRE_EQUAL(ids[1], 1);
1419 TRACE_REQUIRE_EQUAL(ids[2], 1);
1420 TRACE_REQUIRE_EQUAL(ids[3], 1);
1426 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1431 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1432 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1433 fhicl::ParameterSet ps;
1434 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1435 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1436 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1437 ps.put<
bool>(
"circular_buffer_mode",
true);
1438 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1439 ps.put<std::string>(
"request_mode",
"buffer");
1441 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1442 buffer->setRunning(
true);
1452 artdaq::FragmentPtrs fps;
1453 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1455 auto type = artdaq::Fragment::ContainerFragmentType;
1456 TRACE_REQUIRE_EQUAL(sts,
true);
1457 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1458 while (fps.size() > 0)
1460 ids[fps.front()->fragmentID()]++;
1461 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1462 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1463 type = artdaq::Fragment::ContainerFragmentType;
1464 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1465 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1466 auto cf = artdaq::ContainerFragment(*fps.front());
1467 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1468 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1469 type = artdaq::Fragment::FirstUserFragmentType;
1470 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1473 TRACE_REQUIRE_EQUAL(ids[1], 1);
1474 TRACE_REQUIRE_EQUAL(ids[2], 1);
1475 TRACE_REQUIRE_EQUAL(ids[3], 1);
1484 TRACE_REQUIRE_EQUAL(sts,
true);
1485 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1486 while (fps.size() > 0)
1488 ids[fps.front()->fragmentID()]++;
1489 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1490 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1491 type = artdaq::Fragment::ContainerFragmentType;
1492 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1493 auto cf = artdaq::ContainerFragment(*fps.front());
1494 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1495 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1496 type = artdaq::Fragment::EmptyFragmentType;
1497 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1500 TRACE_REQUIRE_EQUAL(ids[1], 1);
1501 TRACE_REQUIRE_EQUAL(ids[2], 1);
1502 TRACE_REQUIRE_EQUAL(ids[3], 1);
1513 TRACE_REQUIRE_EQUAL(sts,
true);
1514 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1516 auto ts = artdaq::Fragment::InvalidTimestamp;
1517 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1518 for (
auto ii = 0; ii < 3; ++ii)
1520 ids[fps.front()->fragmentID()]++;
1521 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1522 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1523 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1524 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1527 TRACE_REQUIRE_EQUAL(ids[1], 1);
1528 TRACE_REQUIRE_EQUAL(ids[2], 1);
1529 TRACE_REQUIRE_EQUAL(ids[3], 1);
1531 for (
auto ii = 0; ii < 3; ++ii)
1533 ids[fps.front()->fragmentID()]++;
1534 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1535 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1536 type = artdaq::Fragment::ContainerFragmentType;
1537 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1538 auto cf3 = artdaq::ContainerFragment(*fps.front());
1539 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
1540 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1541 type = artdaq::Fragment::FirstUserFragmentType;
1542 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1545 TRACE_REQUIRE_EQUAL(ids[1], 1);
1546 TRACE_REQUIRE_EQUAL(ids[2], 1);
1547 TRACE_REQUIRE_EQUAL(ids[3], 1);
1558 TRACE_REQUIRE_EQUAL(sts,
true);
1559 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1560 while (fps.size() > 0)
1562 ids[fps.front()->fragmentID()]++;
1563 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1564 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1565 type = artdaq::Fragment::ContainerFragmentType;
1566 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1567 auto cf = artdaq::ContainerFragment(*fps.front());
1568 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1569 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1570 type = artdaq::Fragment::FirstUserFragmentType;
1571 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1572 TRACE_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1573 TRACE_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1574 TRACE_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1577 TRACE_REQUIRE_EQUAL(ids[1], 1);
1578 TRACE_REQUIRE_EQUAL(ids[2], 1);
1579 TRACE_REQUIRE_EQUAL(ids[3], 1);
1585 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1590 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1591 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1592 fhicl::ParameterSet ps;
1593 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1594 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1595 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1596 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1597 ps.put<
bool>(
"circular_buffer_mode",
true);
1598 ps.put<std::string>(
"request_mode",
"window");
1599 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
1600 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1602 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1603 buffer->setRunning(
true);
1613 artdaq::FragmentPtrs fps;
1614 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1616 auto type = artdaq::Fragment::ContainerFragmentType;
1618 TRACE_REQUIRE_EQUAL(sts,
true);
1619 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1620 while (fps.size() > 0)
1622 ids[fps.front()->fragmentID()]++;
1623 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1624 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1625 type = artdaq::Fragment::ContainerFragmentType;
1626 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1627 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1628 auto cf = artdaq::ContainerFragment(*fps.front());
1629 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1630 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1631 type = artdaq::Fragment::FirstUserFragmentType;
1632 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1635 TRACE_REQUIRE_EQUAL(ids[1], 1);
1636 TRACE_REQUIRE_EQUAL(ids[2], 1);
1637 TRACE_REQUIRE_EQUAL(ids[3], 1);
1646 TRACE_REQUIRE_EQUAL(sts,
true);
1647 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1653 TRACE_REQUIRE_EQUAL(sts,
true);
1654 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1655 while (fps.size() > 0)
1657 ids[fps.front()->fragmentID()]++;
1658 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1659 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1660 type = artdaq::Fragment::ContainerFragmentType;
1661 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1662 auto cf = artdaq::ContainerFragment(*fps.front());
1663 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1664 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1665 type = artdaq::Fragment::FirstUserFragmentType;
1666 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1669 TRACE_REQUIRE_EQUAL(ids[1], 1);
1670 TRACE_REQUIRE_EQUAL(ids[2], 1);
1671 TRACE_REQUIRE_EQUAL(ids[3], 1);
1679 TRACE_REQUIRE_EQUAL(sts,
true);
1680 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1685 TRACE_REQUIRE_EQUAL(sts,
true);
1686 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1690 TRACE_REQUIRE_EQUAL(list.size(), 1);
1691 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
1696 while (fps.size() > 0)
1698 ids[fps.front()->fragmentID()]++;
1699 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1700 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1701 type = artdaq::Fragment::ContainerFragmentType;
1702 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1703 auto cf = artdaq::ContainerFragment(*fps.front());
1704 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1705 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1706 type = artdaq::Fragment::EmptyFragmentType;
1707 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1710 TRACE_REQUIRE_EQUAL(ids[1], 1);
1711 TRACE_REQUIRE_EQUAL(ids[2], 1);
1712 TRACE_REQUIRE_EQUAL(ids[3], 1);
1724 TRACE_REQUIRE_EQUAL(list.size(), 1);
1728 TRACE_REQUIRE_EQUAL(list.size(), 0);
1729 TRACE_REQUIRE_EQUAL(sts,
true);
1730 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1731 while (fps.size() > 0)
1733 ids[fps.front()->fragmentID()]++;
1734 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1735 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1736 type = artdaq::Fragment::ContainerFragmentType;
1737 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1738 auto cf = artdaq::ContainerFragment(*fps.front());
1739 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1740 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1741 type = artdaq::Fragment::EmptyFragmentType;
1742 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1745 TRACE_REQUIRE_EQUAL(ids[1], 1);
1746 TRACE_REQUIRE_EQUAL(ids[2], 1);
1747 TRACE_REQUIRE_EQUAL(ids[3], 1);
1752 buffer->push(7, 13);
1755 TRACE_REQUIRE_EQUAL(sts,
true);
1756 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1757 while (fps.size() > 0)
1759 ids[fps.front()->fragmentID()]++;
1760 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
1761 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
1762 type = artdaq::Fragment::ContainerFragmentType;
1763 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1764 auto cf = artdaq::ContainerFragment(*fps.front());
1765 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1766 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1767 type = artdaq::Fragment::FirstUserFragmentType;
1768 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1771 TRACE_REQUIRE_EQUAL(ids[1], 1);
1772 TRACE_REQUIRE_EQUAL(ids[2], 1);
1773 TRACE_REQUIRE_EQUAL(ids[3], 1);
1779 TRACE_REQUIRE_EQUAL(list.size(), 1);
1780 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
1782 buffer->push(6, 12);
1785 TRACE_REQUIRE_EQUAL(sts,
true);
1786 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1787 while (fps.size() > 0)
1789 ids[fps.front()->fragmentID()]++;
1790 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
1791 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1792 type = artdaq::Fragment::ContainerFragmentType;
1793 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1794 auto cf = artdaq::ContainerFragment(*fps.front());
1795 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1796 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1797 type = artdaq::Fragment::FirstUserFragmentType;
1798 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1801 TRACE_REQUIRE_EQUAL(ids[1], 1);
1802 TRACE_REQUIRE_EQUAL(ids[2], 1);
1803 TRACE_REQUIRE_EQUAL(ids[3], 1);
1809 TRACE_REQUIRE_EQUAL(list.size(), 0);
1813 buffer->push(8, 15);
1815 sts = fp.applyRequests(fps);
1816 TRACE_REQUIRE_EQUAL(sts,
true);
1817 TRACE_REQUIRE_EQUAL(fps.size(), 2);
1818 while (fps.size() > 0)
1820 ids[fps.front()->fragmentID()]++;
1821 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1822 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1823 type = artdaq::Fragment::ContainerFragmentType;
1824 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1825 auto cf = artdaq::ContainerFragment(*fps.front());
1826 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1827 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1828 type = artdaq::Fragment::FirstUserFragmentType;
1829 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1832 TRACE_REQUIRE_EQUAL(ids[1], 1);
1833 TRACE_REQUIRE_EQUAL(ids[2], 1);
1834 TRACE_REQUIRE_EQUAL(ids[3], 0);
1837 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 8);
1839 gen.setTimestamp(14);
1840 fp.AddFragmentsToBuffer(gen.Generate(1, {3}));
1842 sts = fp.applyRequests(fps);
1843 TRACE_REQUIRE_EQUAL(sts,
true);
1844 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1845 while (fps.size() > 0)
1847 ids[fps.front()->fragmentID()]++;
1848 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1849 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1850 type = artdaq::Fragment::ContainerFragmentType;
1851 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1852 auto cf = artdaq::ContainerFragment(*fps.front());
1853 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1854 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1855 type = artdaq::Fragment::FirstUserFragmentType;
1856 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1859 TRACE_REQUIRE_EQUAL(ids[1], 0);
1860 TRACE_REQUIRE_EQUAL(ids[2], 0);
1861 TRACE_REQUIRE_EQUAL(ids[3], 1);
1864 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 9);
1866 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
1871 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1872 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case BEGIN";
1873 fhicl::ParameterSet ps;
1874 ps.put<
int>(
"board_id", 1);
1875 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1876 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1877 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1878 ps.put<
bool>(
"separate_data_thread",
true);
1879 ps.put<
bool>(
"separate_monitoring_thread",
false);
1880 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1881 ps.put<std::string>(
"request_mode",
"SequenceID");
1883 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1884 buffer->setRunning(
true);
1895 artdaq::FragmentPtrs fps;
1896 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1898 auto type = artdaq::Fragment::FirstUserFragmentType;
1899 TRACE_REQUIRE_EQUAL(sts,
true);
1900 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1902 for (
auto ii = 0; ii < 3; ++ii)
1904 ids[fps.front()->fragmentID()]++;
1905 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1906 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1907 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1910 TRACE_REQUIRE_EQUAL(ids[1], 1);
1911 TRACE_REQUIRE_EQUAL(ids[2], 1);
1912 TRACE_REQUIRE_EQUAL(ids[3], 1);
1922 TRACE_REQUIRE_EQUAL(sts,
true);
1923 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1929 TRACE_REQUIRE_EQUAL(sts,
true);
1930 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1931 for (
auto ii = 0; ii < 3; ++ii)
1933 ids[fps.front()->fragmentID()]++;
1934 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1935 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1936 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1939 TRACE_REQUIRE_EQUAL(ids[1], 1);
1940 TRACE_REQUIRE_EQUAL(ids[2], 1);
1941 TRACE_REQUIRE_EQUAL(ids[3], 1);
1954 TRACE_REQUIRE_EQUAL(sts,
true);
1955 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1956 for (
auto ii = 0; ii < 3; ++ii)
1958 ids[fps.front()->fragmentID()]++;
1959 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1960 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1961 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1964 TRACE_REQUIRE_EQUAL(ids[1], 1);
1965 TRACE_REQUIRE_EQUAL(ids[2], 1);
1966 TRACE_REQUIRE_EQUAL(ids[3], 1);
1974 TRACE_REQUIRE_EQUAL(sts,
true);
1975 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1976 for (
auto ii = 0; ii < 3; ++ii)
1978 ids[fps.front()->fragmentID()]++;
1979 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1980 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1981 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1984 TRACE_REQUIRE_EQUAL(ids[1], 1);
1985 TRACE_REQUIRE_EQUAL(ids[2], 1);
1986 TRACE_REQUIRE_EQUAL(ids[3], 1);
1989 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case END";
1994 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1995 TLOG(TLVL_INFO) <<
"IgnoreRequests_StateMachine test case BEGIN";
1996 fhicl::ParameterSet ps;
1997 ps.put<
int>(
"fragment_id", 1);
1998 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1999 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2000 ps.put<std::string>(
"request_mode",
"ignored");
2002 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2003 buffer->setRunning(
true);
2008 buffer->push(53, 35);
2014 artdaq::FragmentPtrs fps;
2017 TRACE_REQUIRE_EQUAL(sts,
true);
2018 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2019 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2020 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2021 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2027 TRACE_REQUIRE_EQUAL(sts,
true);
2028 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2034 TRACE_REQUIRE_EQUAL(sts,
true);
2035 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2036 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2037 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
2038 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
2046 TRACE_REQUIRE_EQUAL(sts,
false);
2047 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2049 TLOG(TLVL_INFO) <<
"IgnoreRequests_StateMachine test case END";
2054 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
2055 TLOG(TLVL_INFO) <<
"SingleMode_StateMachine test case BEGIN";
2056 fhicl::ParameterSet ps;
2057 ps.put<
int>(
"fragment_id", 1);
2058 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2059 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2060 ps.put<std::string>(
"request_mode",
"single");
2062 auto type = artdaq::Fragment::FirstUserFragmentType;
2063 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2064 buffer->setRunning(
true);
2073 artdaq::FragmentPtrs fps;
2075 TRACE_REQUIRE_EQUAL(sts,
true);
2076 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2077 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2078 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2079 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2080 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2087 TRACE_REQUIRE_EQUAL(sts,
true);
2088 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2093 TRACE_REQUIRE_EQUAL(sts,
true);
2094 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2095 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2096 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2097 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2098 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2105 TRACE_REQUIRE_EQUAL(sts,
true);
2106 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2107 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2108 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
2109 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
2110 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2114 buffer->setRunning(
false);
2119 TRACE_REQUIRE_EQUAL(sts,
false);
2120 TRACE_REQUIRE_EQUAL(fps.size(), 0);
2122 TLOG(TLVL_INFO) <<
"SingleMode_StateMachine test case END";
2127 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
2128 TLOG(TLVL_INFO) <<
"WindowMode_RateTests test case BEGIN";
2129 fhicl::ParameterSet ps;
2130 ps.put<
int>(
"fragment_id", 1);
2132 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2133 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2134 ps.put<
size_t>(
"data_buffer_depth_fragments", 2 * RATE_TEST_COUNT);
2135 ps.put<
bool>(
"circular_buffer_mode",
false);
2136 ps.put<std::string>(
"request_mode",
"window");
2137 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
2138 ps.put<
size_t>(
"window_close_timeout_us", 500000);
2140 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2141 buffer->setRunning(
true);
2146 auto beginop = std::chrono::steady_clock::now();
2148 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests BEGIN";
2150 for (; req_seq < RATE_TEST_COUNT + 1; ++req_seq)
2152 buffer->push(req_seq, req_seq);
2154 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests END.Time elapsed = " << artdaq::TimeUtils::GetElapsedTime(beginop)
2155 <<
"(" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs/s) ";
2157 beginop = std::chrono::steady_clock::now();
2158 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments BEGIN";
2160 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2161 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" frags/s)";
2165 beginop = std::chrono::steady_clock::now();
2166 TLOG(TLVL_INFO) <<
"Applying requests BEGIN";
2167 artdaq::FragmentPtrs fps;
2169 TLOG(TLVL_INFO) <<
"Applying requests END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2170 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs/s)";
2172 TRACE_REQUIRE_EQUAL(sts,
true);
2173 TRACE_REQUIRE_EQUAL(fps.size(), RATE_TEST_COUNT);
2174 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2175 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2176 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2177 auto type = artdaq::Fragment::ContainerFragmentType;
2178 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2179 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
2180 auto cf = artdaq::ContainerFragment(*fps.front());
2181 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
2182 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
2183 type = artdaq::Fragment::FirstUserFragmentType;
2184 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
2187 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests BEGIN";
2188 for (; req_seq < (2 * RATE_TEST_COUNT) + 1; ++req_seq)
2190 buffer->push(req_seq, req_seq);
2192 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests END. Time elapsed = " << artdaq::TimeUtils::GetElapsedTime(beginop)
2193 <<
"(" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs/s) ";
2195 beginop = std::chrono::steady_clock::now();
2196 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments Individually BEGIN";
2197 for (
int ii = 0; ii < RATE_TEST_COUNT; ++ii)
2199 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments Individually END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2200 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" frags/s)";
2202 TLOG(TLVL_INFO) <<
"WindowMode_RateTests test case END";
2207 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
2208 TLOG(TLVL_INFO) <<
"CircularBufferMode_RateTests test case BEGIN";
2209 fhicl::ParameterSet ps;
2210 ps.put<
int>(
"fragment_id", 1);
2211 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2212 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2213 ps.put<
size_t>(
"data_buffer_depth_fragments", RATE_TEST_COUNT / 2);
2214 ps.put<
bool>(
"circular_buffer_mode",
true);
2215 ps.put<std::string>(
"request_mode",
"window");
2216 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
2217 ps.put<
size_t>(
"window_close_timeout_us", 500000);
2219 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2220 buffer->setRunning(
true);
2225 auto beginop = std::chrono::steady_clock::now();
2227 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests BEGIN";
2228 for (
size_t ii = 1; ii < RATE_TEST_COUNT + 1; ++ii)
2230 buffer->push(ii, ii);
2232 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests END. Time elapsed = " << artdaq::TimeUtils::GetElapsedTime(beginop)
2233 <<
"(" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs / s) ";
2235 beginop = std::chrono::steady_clock::now();
2236 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments BEGIN";
2238 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2239 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" frags/s)";
2243 beginop = std::chrono::steady_clock::now();
2244 TLOG(TLVL_INFO) <<
"Applying requests BEGIN";
2245 artdaq::FragmentPtrs fps;
2247 TLOG(TLVL_INFO) <<
"Applying requests END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2248 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs/s)";
2250 TRACE_REQUIRE_EQUAL(sts,
true);
2251 TRACE_REQUIRE_EQUAL(fps.size(), RATE_TEST_COUNT);
2252 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2253 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2254 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2255 auto type = artdaq::Fragment::ContainerFragmentType;
2256 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2257 auto cf = artdaq::ContainerFragment(*fps.front());
2258 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
2259 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
2260 type = artdaq::Fragment::EmptyFragmentType;
2261 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
2264 TLOG(TLVL_INFO) <<
"CircularBufferMode_RateTests test case END";
2269 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
2270 TLOG(TLVL_INFO) <<
"WindowMode_RateTests_threaded test case BEGIN";
2271 fhicl::ParameterSet ps;
2272 ps.put<
int>(
"fragment_id", 1);
2273 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2274 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2275 ps.put<
size_t>(
"data_buffer_depth_fragments", RATE_TEST_COUNT);
2276 ps.put<
bool>(
"circular_buffer_mode",
false);
2277 ps.put<std::string>(
"request_mode",
"window");
2278 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
2279 ps.put<
size_t>(
"window_close_timeout_us", 500000);
2281 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2282 buffer->setRunning(
true);
2287 std::atomic<int> thread_sync = 0;
2288 auto gen_requests = [&]() {
2290 while (thread_sync < 3) {}
2291 auto beginop = std::chrono::steady_clock::now();
2292 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests BEGIN";
2293 for (
size_t ii = 1; ii < RATE_TEST_COUNT + 1; ++ii)
2295 buffer->push(ii, ii);
2297 TLOG(TLVL_INFO) <<
"Generating " << RATE_TEST_COUNT <<
" requests END. Time elapsed = " << artdaq::TimeUtils::GetElapsedTime(beginop)
2298 <<
"(" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" reqs / s) ";
2301 auto gen_frags = [&]() {
2303 while (thread_sync < 3) {}
2304 auto beginop = std::chrono::steady_clock::now();
2305 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments BEGIN";
2306 for (
int ii = 0; ii < RATE_TEST_COUNT; ++ii)
2308 TLOG(TLVL_INFO) <<
"Generating/adding " << RATE_TEST_COUNT <<
" Fragments END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop)
2309 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(beginop) <<
" frags/s)";
2312 auto apply_requests = [&]() {
2314 while (thread_sync < 3) {}
2315 artdaq::FragmentPtrs fps;
2316 auto begin_test = std::chrono::steady_clock::now();
2317 while (fps.size() < RATE_TEST_COUNT)
2319 auto beginop = std::chrono::steady_clock::now();
2320 TLOG(TLVL_INFO) <<
"Applying requests BEGIN";
2322 TRACE_REQUIRE_EQUAL(sts,
true);
2323 TLOG(TLVL_INFO) <<
"Applying requests END. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(beginop);
2325 TLOG(TLVL_INFO) <<
"All request replies received. Time elapsed=" << artdaq::TimeUtils::GetElapsedTime(begin_test)
2326 <<
" (" << RATE_TEST_COUNT / artdaq::TimeUtils::GetElapsedTime(begin_test) <<
" reqs/s)";
2329 TRACE_REQUIRE_EQUAL(fps.size(), RATE_TEST_COUNT);
2330 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2331 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2332 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2333 auto type = artdaq::Fragment::ContainerFragmentType;
2334 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2338 std::thread t1(gen_requests);
2339 std::thread t2(gen_frags);
2340 std::thread t3(apply_requests);
2346 TLOG(TLVL_INFO) <<
"WindowMode_RateTests_threaded test case END";
2348 BOOST_AUTO_TEST_SUITE_END()
void AddFragmentsToBuffer(FragmentPtrs frags)
Add Fragments to the FragmentBuffer.
bool applyRequests(FragmentPtrs &frags)
See if any requests have been received, and add the corresponding data Fragment objects to the output...
void SetRequestBuffer(std::shared_ptr< RequestBuffer > buffer)
Set the pointer to the RequestBuffer used to retrieve requests.
std::map< Fragment::sequence_id_t, std::chrono::steady_clock::time_point > GetSentWindowList(Fragment::fragment_id_t id)
Get the map of Window-mode requests fulfilled by this Fragment Geneerator for the given Fragment ID...
CommandableFragmentGenerator derived class for testing.
void Stop()
Inform the FragmentBuffer that it should stop.
artdaq::FragmentPtrs Generate(size_t n, std::vector< artdaq::Fragment::fragment_id_t > fragmentIds=std::vector< artdaq::Fragment::fragment_id_t >())
Generate Fragments.
void Reset(bool stop)
Reset the FragmentBuffer (flushes all Fragments from buffers)
artdaq::Fragment::sequence_id_t GetNextSequenceID() const
Get the next sequence ID expected by this FragmentBuffer. This is used to track sent windows and miss...
FragmentBuffer is a FragmentGenerator-derived abstract class that defines the interface for a Fragmen...
artdaq::Fragment::timestamp_t getTimestamp()
Get the timestamp that will be used for the next Fragment.
FragmentBufferTestGenerator(const fhicl::ParameterSet &ps)
FragmentBufferTestGenerator Constructor.
void setTimestamp(artdaq::Fragment::timestamp_t ts)
Set the timestamp to be used for the next Fragment.