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 TRACE_REQUIRE_EQUAL(l, r) \
18 TLOG(TLVL_DEBUG) << __LINE__ << ": Checking if " << #l << " (" << l << ") equals " << #r << " (" << r << ")...YES!"; \
22 TLOG(TLVL_ERROR) << __LINE__ << ": Checking if " << #l << " (" << l << ") equals " << #r << " (" << r << ")...NO!"; \
24 BOOST_REQUIRE_EQUAL(l, r); \
27 namespace artdaqtest {
28 class FragmentBufferTestGenerator;
48 artdaq::FragmentPtrs
Generate(
size_t n, std::vector<artdaq::Fragment::fragment_id_t> fragmentIds = std::vector<artdaq::Fragment::fragment_id_t>());
64 artdaq::Fragment::timestamp_t ts_;
65 artdaq::Fragment::sequence_id_t seq_;
66 std::set<artdaq::Fragment::fragment_id_t> fragmentIDs_;
72 metricMan->initialize(ps.get<fhicl::ParameterSet>(
"metrics", fhicl::ParameterSet()));
73 metricMan->do_start();
75 auto idlist = ps.get<std::vector<artdaq::Fragment::fragment_id_t>>(
"fragment_ids", {ps.get<artdaq::Fragment::fragment_id_t>(
"fragment_id", 1)});
76 for (
auto&
id : idlist)
78 fragmentIDs_.insert(
id);
84 if (fragmentIds.size() == 0) std::copy(fragmentIDs_.begin(), fragmentIDs_.end(), std::back_inserter(fragmentIds));
86 artdaq::FragmentPtrs frags;
90 for (
auto&
id : fragmentIds)
92 TLOG(TLVL_DEBUG) <<
"Adding Fragment with ID " <<
id <<
", SeqID " << seq_ <<
", and timestamp " << ts_;
93 frags.emplace_back(
new artdaq::Fragment(seq_,
id, artdaq::Fragment::FirstUserFragmentType, ts_));
102 BOOST_AUTO_TEST_SUITE(FragmentBuffer_t)
106 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
107 TLOG(TLVL_INFO) <<
"IgnoreRequests test case BEGIN";
108 fhicl::ParameterSet ps;
109 ps.put<
int>(
"fragment_id", 1);
110 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
111 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
112 ps.put<std::string>(
"request_mode",
"ignored");
114 auto buffer = std::make_shared<artdaq::RequestBuffer>();
115 buffer->setRunning(
true);
120 buffer->push(53, 35);
126 artdaq::FragmentPtrs fps;
129 TRACE_REQUIRE_EQUAL(sts,
true);
130 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
131 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
132 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
133 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
135 TLOG(TLVL_INFO) <<
"IgnoreRequests test case END";
140 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
141 TLOG(TLVL_INFO) <<
"SingleMode test case BEGIN";
142 fhicl::ParameterSet ps;
143 ps.put<
int>(
"fragment_id", 1);
144 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
145 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
146 ps.put<std::string>(
"request_mode",
"single");
148 auto buffer = std::make_shared<artdaq::RequestBuffer>();
149 buffer->setRunning(
true);
158 artdaq::FragmentPtrs fps;
160 auto type = artdaq::Fragment::FirstUserFragmentType;
161 TRACE_REQUIRE_EQUAL(sts,
true);
162 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
163 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
164 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
165 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
166 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
172 TRACE_REQUIRE_EQUAL(sts,
true);
173 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
174 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
175 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
176 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
177 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
186 TRACE_REQUIRE_EQUAL(sts,
true);
187 TRACE_REQUIRE_EQUAL(fps.size(), 2);
188 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
189 auto ts = artdaq::Fragment::InvalidTimestamp;
190 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
191 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
192 auto emptyType = artdaq::Fragment::EmptyFragmentType;
193 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
195 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
196 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
197 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
198 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
201 TLOG(TLVL_INFO) <<
"SingleMode test case END";
206 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
207 TLOG(TLVL_INFO) <<
"BufferMode test case BEGIN";
208 fhicl::ParameterSet ps;
209 ps.put<
int>(
"fragment_id", 1);
210 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
211 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
212 ps.put<std::string>(
"request_mode",
"buffer");
214 auto buffer = std::make_shared<artdaq::RequestBuffer>();
215 buffer->setRunning(
true);
225 artdaq::FragmentPtrs fps;
227 TRACE_REQUIRE_EQUAL(sts,
true);
228 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
229 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
230 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
231 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
232 auto type = artdaq::Fragment::ContainerFragmentType;
233 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
234 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
235 auto cf = artdaq::ContainerFragment(*fps.front());
236 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
237 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
238 type = artdaq::Fragment::FirstUserFragmentType;
239 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
245 TRACE_REQUIRE_EQUAL(sts,
true);
246 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
247 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
248 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
249 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
250 type = artdaq::Fragment::ContainerFragmentType;
251 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
252 auto cf2 = artdaq::ContainerFragment(*fps.front());
253 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
254 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
255 type = artdaq::Fragment::EmptyFragmentType;
256 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
264 TRACE_REQUIRE_EQUAL(sts,
true);
265 TRACE_REQUIRE_EQUAL(fps.size(), 2);
267 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
268 auto ts = artdaq::Fragment::InvalidTimestamp;
269 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
270 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
271 auto emptyType = artdaq::Fragment::EmptyFragmentType;
272 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
273 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
275 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
276 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
277 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
278 type = artdaq::Fragment::ContainerFragmentType;
279 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
280 auto cf3 = artdaq::ContainerFragment(*fps.front());
281 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
282 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
283 type = artdaq::Fragment::FirstUserFragmentType;
284 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
288 TLOG(TLVL_INFO) <<
"BufferMode test case END";
293 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
294 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case BEGIN";
295 fhicl::ParameterSet ps;
296 ps.put<
int>(
"fragment_id", 1);
297 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
298 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
299 ps.put<std::string>(
"request_mode",
"buffer");
300 ps.put(
"buffer_mode_keep_latest",
true);
302 auto buffer = std::make_shared<artdaq::RequestBuffer>();
303 buffer->setRunning(
true);
313 artdaq::FragmentPtrs fps;
315 TRACE_REQUIRE_EQUAL(sts,
true);
316 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
317 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
318 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
319 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
320 auto type = artdaq::Fragment::ContainerFragmentType;
321 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
322 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
323 auto cf = artdaq::ContainerFragment(*fps.front());
324 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
325 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
326 type = artdaq::Fragment::FirstUserFragmentType;
327 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
333 TRACE_REQUIRE_EQUAL(sts,
true);
334 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
335 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
336 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
337 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
338 type = artdaq::Fragment::ContainerFragmentType;
339 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
340 auto cf2 = artdaq::ContainerFragment(*fps.front());
341 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
342 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
343 type = artdaq::Fragment::FirstUserFragmentType;
344 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
351 TRACE_REQUIRE_EQUAL(sts,
true);
352 TRACE_REQUIRE_EQUAL(fps.size(), 2);
354 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
355 auto ts = artdaq::Fragment::InvalidTimestamp;
356 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
357 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
358 auto emptyType = artdaq::Fragment::EmptyFragmentType;
359 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
360 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
362 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
363 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
364 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
365 type = artdaq::Fragment::ContainerFragmentType;
366 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
367 auto cf3 = artdaq::ContainerFragment(*fps.front());
368 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
369 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
370 type = artdaq::Fragment::FirstUserFragmentType;
371 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
375 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case END";
379 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
380 TLOG(TLVL_INFO) <<
"CircularBufferMode test case BEGIN";
381 fhicl::ParameterSet ps;
382 ps.put<
int>(
"fragment_id", 1);
383 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
384 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
385 ps.put<
bool>(
"circular_buffer_mode",
true);
386 ps.put<
int>(
"data_buffer_depth_fragments", 3);
387 ps.put<std::string>(
"request_mode",
"buffer");
389 auto buffer = std::make_shared<artdaq::RequestBuffer>();
390 buffer->setRunning(
true);
400 artdaq::FragmentPtrs fps;
402 TRACE_REQUIRE_EQUAL(sts,
true);
403 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
404 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
405 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
406 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
407 auto type = artdaq::Fragment::ContainerFragmentType;
408 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
409 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
410 auto cf = artdaq::ContainerFragment(*fps.front());
411 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
412 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
413 type = artdaq::Fragment::FirstUserFragmentType;
414 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
420 TRACE_REQUIRE_EQUAL(sts,
true);
421 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
422 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
423 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
424 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
425 type = artdaq::Fragment::ContainerFragmentType;
426 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
427 auto cf2 = artdaq::ContainerFragment(*fps.front());
428 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
429 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
430 type = artdaq::Fragment::EmptyFragmentType;
431 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
439 TRACE_REQUIRE_EQUAL(sts,
true);
440 TRACE_REQUIRE_EQUAL(fps.size(), 2);
442 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
443 auto ts = artdaq::Fragment::InvalidTimestamp;
444 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
445 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
446 auto emptyType = artdaq::Fragment::EmptyFragmentType;
447 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
448 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
450 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
451 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
452 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
453 type = artdaq::Fragment::ContainerFragmentType;
454 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
455 auto cf3 = artdaq::ContainerFragment(*fps.front());
456 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
457 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
458 type = artdaq::Fragment::FirstUserFragmentType;
459 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
468 TRACE_REQUIRE_EQUAL(sts,
true);
469 TRACE_REQUIRE_EQUAL(fps.size(), 1);
471 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
472 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
473 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
474 type = artdaq::Fragment::ContainerFragmentType;
475 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
476 auto cf4 = artdaq::ContainerFragment(*fps.front());
477 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
478 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
479 type = artdaq::Fragment::FirstUserFragmentType;
480 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
481 TRACE_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
482 TRACE_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
483 TRACE_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
487 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
492 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
493 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
494 fhicl::ParameterSet ps;
495 ps.put<
int>(
"fragment_id", 1);
497 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
498 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
499 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
500 ps.put<
bool>(
"circular_buffer_mode",
true);
501 ps.put<std::string>(
"request_mode",
"window");
502 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
503 ps.put<
size_t>(
"window_close_timeout_us", 500000);
505 auto buffer = std::make_shared<artdaq::RequestBuffer>();
506 buffer->setRunning(
true);
516 artdaq::FragmentPtrs fps;
519 TRACE_REQUIRE_EQUAL(sts,
true);
520 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
521 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
522 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
523 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
524 auto type = artdaq::Fragment::ContainerFragmentType;
525 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
526 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
527 auto cf = artdaq::ContainerFragment(*fps.front());
528 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
529 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
530 type = artdaq::Fragment::FirstUserFragmentType;
531 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
539 TRACE_REQUIRE_EQUAL(sts,
true);
540 TRACE_REQUIRE_EQUAL(fps.size(), 0);
546 TRACE_REQUIRE_EQUAL(sts,
true);
547 TRACE_REQUIRE_EQUAL(fps.size(), 1);
548 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
549 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
550 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
551 type = artdaq::Fragment::ContainerFragmentType;
552 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
553 auto cf2 = artdaq::ContainerFragment(*fps.front());
554 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
555 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
556 type = artdaq::Fragment::FirstUserFragmentType;
557 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
564 TRACE_REQUIRE_EQUAL(sts,
true);
565 TRACE_REQUIRE_EQUAL(fps.size(), 0);
570 TRACE_REQUIRE_EQUAL(sts,
true);
571 TRACE_REQUIRE_EQUAL(fps.size(), 1);
575 TRACE_REQUIRE_EQUAL(list.size(), 1);
576 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
581 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
582 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
583 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
584 type = artdaq::Fragment::ContainerFragmentType;
585 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
586 auto cf3 = artdaq::ContainerFragment(*fps.front());
587 TRACE_REQUIRE_EQUAL(cf3.block_count(), 0);
588 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
true);
589 type = artdaq::Fragment::EmptyFragmentType;
590 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
600 TRACE_REQUIRE_EQUAL(list.size(), 1);
604 TRACE_REQUIRE_EQUAL(list.size(), 0);
605 TRACE_REQUIRE_EQUAL(sts,
true);
606 TRACE_REQUIRE_EQUAL(fps.size(), 1);
607 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
608 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
609 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
610 type = artdaq::Fragment::ContainerFragmentType;
611 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
612 auto cf4 = artdaq::ContainerFragment(*fps.front());
613 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
614 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
615 type = artdaq::Fragment::EmptyFragmentType;
616 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
623 TRACE_REQUIRE_EQUAL(sts,
true);
624 TRACE_REQUIRE_EQUAL(fps.size(), 1);
625 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
626 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
627 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
628 type = artdaq::Fragment::ContainerFragmentType;
629 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
630 auto cf5 = artdaq::ContainerFragment(*fps.front());
631 TRACE_REQUIRE_EQUAL(cf5.block_count(), 1);
632 TRACE_REQUIRE_EQUAL(cf5.missing_data(),
false);
633 type = artdaq::Fragment::FirstUserFragmentType;
634 TRACE_REQUIRE_EQUAL(cf5.fragment_type(), type);
639 TRACE_REQUIRE_EQUAL(list.size(), 1);
640 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
645 TRACE_REQUIRE_EQUAL(sts,
true);
646 TRACE_REQUIRE_EQUAL(fps.size(), 1);
647 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
648 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
649 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
650 type = artdaq::Fragment::ContainerFragmentType;
651 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
652 auto cf6 = artdaq::ContainerFragment(*fps.front());
653 TRACE_REQUIRE_EQUAL(cf6.block_count(), 1);
654 TRACE_REQUIRE_EQUAL(cf6.missing_data(),
false);
655 type = artdaq::Fragment::FirstUserFragmentType;
656 TRACE_REQUIRE_EQUAL(cf6.fragment_type(), type);
661 TRACE_REQUIRE_EQUAL(list.size(), 0);
665 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
676 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
677 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
678 fhicl::ParameterSet ps;
679 ps.put<
int>(
"fragment_id", 1);
681 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
682 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
683 ps.put<
bool>(
"circular_buffer_mode",
true);
684 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
685 ps.put<std::string>(
"request_mode",
"window");
687 auto buffer = std::make_shared<artdaq::RequestBuffer>();
688 buffer->setRunning(
true);
693 artdaq::FragmentPtrs fps;
695 artdaq::Fragment::type_t type;
704 TRACE_REQUIRE_EQUAL(sts,
true);
705 TRACE_REQUIRE_EQUAL(fps.size(), 1);
706 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
707 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
708 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
709 type = artdaq::Fragment::ContainerFragmentType;
710 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
711 auto cf4 = artdaq::ContainerFragment(*fps.front());
712 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
713 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
714 type = artdaq::Fragment::EmptyFragmentType;
715 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
717 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
721 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
722 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
724 fhicl::ParameterSet ps;
725 ps.put<
int>(
"fragment_id", 1);
726 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
727 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
728 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
729 ps.put<
bool>(
"circular_buffer_mode",
true);
730 ps.put<std::string>(
"request_mode",
"window");
732 auto buffer = std::make_shared<artdaq::RequestBuffer>();
733 buffer->setRunning(
true);
738 artdaq::FragmentPtrs fps;
740 artdaq::Fragment::type_t type;
749 TRACE_REQUIRE_EQUAL(sts,
true);
750 TRACE_REQUIRE_EQUAL(fps.size(), 1);
751 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
752 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
753 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
754 type = artdaq::Fragment::ContainerFragmentType;
755 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
756 auto cf4 = artdaq::ContainerFragment(*fps.front());
757 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
758 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
759 type = artdaq::Fragment::FirstUserFragmentType;
760 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
762 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case END";
766 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
767 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case BEGIN";
768 fhicl::ParameterSet ps;
769 ps.put<
int>(
"fragment_id", 1);
770 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
771 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 4);
772 ps.put<
size_t>(
"window_close_timeout_us", 500000);
773 ps.put<
bool>(
"circular_buffer_mode",
true);
774 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
775 ps.put<std::string>(
"request_mode",
"window");
777 auto buffer = std::make_shared<artdaq::RequestBuffer>();
778 buffer->setRunning(
true);
783 artdaq::FragmentPtrs fps;
785 artdaq::Fragment::type_t type;
795 TRACE_REQUIRE_EQUAL(sts,
true);
796 TRACE_REQUIRE_EQUAL(fps.size(), 1);
797 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
798 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
799 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
800 type = artdaq::Fragment::ContainerFragmentType;
801 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
802 auto cf = artdaq::ContainerFragment(*fps.front());
803 TRACE_REQUIRE_EQUAL(cf.block_count(), 4);
804 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
805 type = artdaq::Fragment::FirstUserFragmentType;
806 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
812 TRACE_REQUIRE_EQUAL(sts,
true);
813 TRACE_REQUIRE_EQUAL(fps.size(), 0);
818 TRACE_REQUIRE_EQUAL(sts,
true);
819 TRACE_REQUIRE_EQUAL(fps.size(), 1);
820 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
821 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
822 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
823 type = artdaq::Fragment::ContainerFragmentType;
824 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
825 auto cf2 = artdaq::ContainerFragment(*fps.front());
826 TRACE_REQUIRE_EQUAL(cf2.block_count(), 3);
827 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
true);
828 type = artdaq::Fragment::FirstUserFragmentType;
829 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
835 TRACE_REQUIRE_EQUAL(sts,
true);
836 TRACE_REQUIRE_EQUAL(fps.size(), 0);
841 TRACE_REQUIRE_EQUAL(sts,
true);
842 TRACE_REQUIRE_EQUAL(fps.size(), 1);
843 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
844 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
845 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
846 type = artdaq::Fragment::ContainerFragmentType;
847 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
848 auto cf4 = artdaq::ContainerFragment(*fps.front());
849 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
850 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
851 type = artdaq::Fragment::FirstUserFragmentType;
852 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
854 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
858 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
859 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
860 fhicl::ParameterSet ps;
861 ps.put<
int>(
"fragment_id", 1);
862 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
863 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
864 ps.put<
bool>(
"circular_buffer_mode",
true);
865 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
866 ps.put<std::string>(
"request_mode",
"window");
868 auto buffer = std::make_shared<artdaq::RequestBuffer>();
869 buffer->setRunning(
true);
874 artdaq::FragmentPtrs fps;
876 artdaq::Fragment::type_t type;
885 TRACE_REQUIRE_EQUAL(sts,
true);
886 TRACE_REQUIRE_EQUAL(fps.size(), 1);
887 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
888 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
889 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
890 type = artdaq::Fragment::ContainerFragmentType;
891 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
892 auto cf4 = artdaq::ContainerFragment(*fps.front());
893 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
894 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
895 type = artdaq::Fragment::FirstUserFragmentType;
896 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
898 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
902 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
903 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
904 fhicl::ParameterSet ps;
905 ps.put<
int>(
"fragment_id", 1);
906 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
907 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
908 ps.put<
size_t>(
"window_close_timeout_us", 500000);
909 ps.put<
bool>(
"circular_buffer_mode",
true);
910 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
911 ps.put<std::string>(
"request_mode",
"window");
913 auto buffer = std::make_shared<artdaq::RequestBuffer>();
914 buffer->setRunning(
true);
919 artdaq::FragmentPtrs fps;
921 artdaq::Fragment::type_t type;
930 TRACE_REQUIRE_EQUAL(sts,
true);
931 TRACE_REQUIRE_EQUAL(fps.size(), 0);
936 TRACE_REQUIRE_EQUAL(sts,
true);
937 TRACE_REQUIRE_EQUAL(fps.size(), 1);
938 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
939 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
940 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
941 type = artdaq::Fragment::ContainerFragmentType;
942 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
943 auto cf = artdaq::ContainerFragment(*fps.front());
944 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
945 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
946 type = artdaq::Fragment::FirstUserFragmentType;
947 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
953 TRACE_REQUIRE_EQUAL(sts,
true);
954 TRACE_REQUIRE_EQUAL(fps.size(), 0);
959 TRACE_REQUIRE_EQUAL(sts,
true);
960 TRACE_REQUIRE_EQUAL(fps.size(), 1);
961 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
962 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
963 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
964 type = artdaq::Fragment::ContainerFragmentType;
965 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
966 auto cf4 = artdaq::ContainerFragment(*fps.front());
967 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
968 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
969 type = artdaq::Fragment::FirstUserFragmentType;
970 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
972 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
976 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
977 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
978 fhicl::ParameterSet ps;
979 ps.put<
int>(
"fragment_id", 1);
980 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
981 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
982 ps.put<
size_t>(
"window_close_timeout_us", 500000);
983 ps.put<
bool>(
"circular_buffer_mode",
true);
984 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
985 ps.put<std::string>(
"request_mode",
"window");
987 auto buffer = std::make_shared<artdaq::RequestBuffer>();
988 buffer->setRunning(
true);
993 artdaq::FragmentPtrs fps;
995 artdaq::Fragment::type_t type;
1001 buffer->push(1, 11);
1004 TRACE_REQUIRE_EQUAL(sts,
true);
1005 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1009 TRACE_REQUIRE_EQUAL(sts,
true);
1010 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1015 TRACE_REQUIRE_EQUAL(sts,
true);
1016 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1017 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1018 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1019 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1020 type = artdaq::Fragment::ContainerFragmentType;
1021 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1022 auto cf = artdaq::ContainerFragment(*fps.front());
1023 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1024 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1025 type = artdaq::Fragment::FirstUserFragmentType;
1026 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1029 buffer->push(2, 16);
1032 TRACE_REQUIRE_EQUAL(sts,
true);
1033 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1038 TRACE_REQUIRE_EQUAL(sts,
true);
1039 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1040 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1041 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
1042 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1043 type = artdaq::Fragment::ContainerFragmentType;
1044 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1045 auto cf4 = artdaq::ContainerFragment(*fps.front());
1046 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
1047 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
1048 type = artdaq::Fragment::EmptyFragmentType;
1049 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
1051 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1056 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1057 TLOG(TLVL_INFO) <<
"SequenceIDMode test case BEGIN";
1058 fhicl::ParameterSet ps;
1059 ps.put<
int>(
"fragment_id", 1);
1060 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1061 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1062 ps.put<std::string>(
"request_mode",
"SequenceID");
1064 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1065 buffer->setRunning(
true);
1076 artdaq::FragmentPtrs fps;
1078 auto type = artdaq::Fragment::FirstUserFragmentType;
1079 TRACE_REQUIRE_EQUAL(sts,
true);
1080 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1081 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1082 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1083 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1084 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1092 TRACE_REQUIRE_EQUAL(sts,
true);
1093 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1099 TRACE_REQUIRE_EQUAL(sts,
true);
1100 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1101 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1102 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1103 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1104 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1115 TRACE_REQUIRE_EQUAL(sts,
true);
1116 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1117 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1118 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1119 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1120 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1127 TRACE_REQUIRE_EQUAL(sts,
true);
1128 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1129 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1130 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1131 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1132 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1134 TLOG(TLVL_INFO) <<
"SequenceIDMode test case END";
1139 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1140 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1141 fhicl::ParameterSet ps;
1142 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1143 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1144 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1145 ps.put<std::string>(
"request_mode",
"ignored");
1147 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1148 buffer->setRunning(
true);
1153 buffer->push(53, 35);
1156 artdaq::FragmentPtrs fps;
1157 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1159 TRACE_REQUIRE_EQUAL(sts,
true);
1160 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1161 while (fps.size() > 0)
1163 ids[fps.front()->fragmentID()]++;
1164 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1165 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1169 TRACE_REQUIRE_EQUAL(ids[1], 1);
1170 TRACE_REQUIRE_EQUAL(ids[2], 1);
1171 TRACE_REQUIRE_EQUAL(ids[3], 1);
1176 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1181 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1182 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1183 fhicl::ParameterSet ps;
1184 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1185 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1186 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1187 ps.put<std::string>(
"request_mode",
"single");
1189 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1190 buffer->setRunning(
true);
1200 artdaq::FragmentPtrs fps;
1201 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1203 auto type = artdaq::Fragment::FirstUserFragmentType;
1204 TRACE_REQUIRE_EQUAL(sts,
true);
1205 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1206 while (fps.size() > 0)
1208 ids[fps.front()->fragmentID()]++;
1209 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1210 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1211 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1214 TRACE_REQUIRE_EQUAL(ids[1], 1);
1215 TRACE_REQUIRE_EQUAL(ids[2], 1);
1216 TRACE_REQUIRE_EQUAL(ids[3], 1);
1225 TRACE_REQUIRE_EQUAL(sts,
true);
1226 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1227 while (fps.size() > 0)
1229 ids[fps.front()->fragmentID()]++;
1230 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1231 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1232 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1235 TRACE_REQUIRE_EQUAL(ids[1], 1);
1236 TRACE_REQUIRE_EQUAL(ids[2], 1);
1237 TRACE_REQUIRE_EQUAL(ids[3], 1);
1249 TRACE_REQUIRE_EQUAL(sts,
true);
1250 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1251 auto ts = artdaq::Fragment::InvalidTimestamp;
1252 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1253 for (
auto ii = 0; ii < 3; ++ii)
1255 ids[fps.front()->fragmentID()]++;
1256 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1257 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1258 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1261 TRACE_REQUIRE_EQUAL(ids[1], 1);
1262 TRACE_REQUIRE_EQUAL(ids[2], 1);
1263 TRACE_REQUIRE_EQUAL(ids[3], 1);
1265 for (
auto ii = 0; ii < 3; ++ii)
1267 ids[fps.front()->fragmentID()]++;
1268 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1269 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1270 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1273 TRACE_REQUIRE_EQUAL(ids[1], 1);
1274 TRACE_REQUIRE_EQUAL(ids[2], 1);
1275 TRACE_REQUIRE_EQUAL(ids[3], 1);
1286 TRACE_REQUIRE_EQUAL(sts,
true);
1287 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1288 for (
auto ii = 0; ii < 3; ++ii)
1290 ids[fps.front()->fragmentID()]++;
1291 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1292 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1293 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1296 TRACE_REQUIRE_EQUAL(ids[1], 1);
1297 TRACE_REQUIRE_EQUAL(ids[2], 1);
1298 TRACE_REQUIRE_EQUAL(ids[3], 1);
1302 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1307 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1308 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1309 fhicl::ParameterSet ps;
1310 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1311 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1312 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1313 ps.put<std::string>(
"request_mode",
"buffer");
1315 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1316 buffer->setRunning(
true);
1326 artdaq::FragmentPtrs fps;
1327 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1329 TRACE_REQUIRE_EQUAL(sts,
true);
1330 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1331 auto type = artdaq::Fragment::ContainerFragmentType;
1332 while (fps.size() > 0)
1334 ids[fps.front()->fragmentID()]++;
1335 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1336 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1337 type = artdaq::Fragment::ContainerFragmentType;
1338 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1339 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1340 auto cf = artdaq::ContainerFragment(*fps.front());
1341 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1342 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1343 type = artdaq::Fragment::FirstUserFragmentType;
1344 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1347 TRACE_REQUIRE_EQUAL(ids[1], 1);
1348 TRACE_REQUIRE_EQUAL(ids[2], 1);
1349 TRACE_REQUIRE_EQUAL(ids[3], 1);
1357 TRACE_REQUIRE_EQUAL(sts,
true);
1358 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1359 while (fps.size() > 0)
1361 ids[fps.front()->fragmentID()]++;
1362 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1363 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1364 type = artdaq::Fragment::ContainerFragmentType;
1365 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1366 auto cf = artdaq::ContainerFragment(*fps.front());
1367 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1368 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1369 type = artdaq::Fragment::EmptyFragmentType;
1370 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1373 TRACE_REQUIRE_EQUAL(ids[1], 1);
1374 TRACE_REQUIRE_EQUAL(ids[2], 1);
1375 TRACE_REQUIRE_EQUAL(ids[3], 1);
1385 TRACE_REQUIRE_EQUAL(sts,
true);
1386 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1388 auto ts = artdaq::Fragment::InvalidTimestamp;
1389 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1390 for (
auto ii = 0; ii < 3; ++ii)
1392 ids[fps.front()->fragmentID()]++;
1393 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1394 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1395 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1396 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1399 TRACE_REQUIRE_EQUAL(ids[1], 1);
1400 TRACE_REQUIRE_EQUAL(ids[2], 1);
1401 TRACE_REQUIRE_EQUAL(ids[3], 1);
1403 for (
auto ii = 0; ii < 3; ++ii)
1405 ids[fps.front()->fragmentID()]++;
1406 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1407 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1408 type = artdaq::Fragment::ContainerFragmentType;
1409 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1410 auto cf3 = artdaq::ContainerFragment(*fps.front());
1411 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
1412 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1413 type = artdaq::Fragment::FirstUserFragmentType;
1414 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1417 TRACE_REQUIRE_EQUAL(ids[1], 1);
1418 TRACE_REQUIRE_EQUAL(ids[2], 1);
1419 TRACE_REQUIRE_EQUAL(ids[3], 1);
1425 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1430 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1431 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1432 fhicl::ParameterSet ps;
1433 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1434 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1435 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1436 ps.put<
bool>(
"circular_buffer_mode",
true);
1437 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1438 ps.put<std::string>(
"request_mode",
"buffer");
1440 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1441 buffer->setRunning(
true);
1451 artdaq::FragmentPtrs fps;
1452 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1454 auto type = artdaq::Fragment::ContainerFragmentType;
1455 TRACE_REQUIRE_EQUAL(sts,
true);
1456 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1457 while (fps.size() > 0)
1459 ids[fps.front()->fragmentID()]++;
1460 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1461 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1462 type = artdaq::Fragment::ContainerFragmentType;
1463 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1464 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1465 auto cf = artdaq::ContainerFragment(*fps.front());
1466 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1467 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1468 type = artdaq::Fragment::FirstUserFragmentType;
1469 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1472 TRACE_REQUIRE_EQUAL(ids[1], 1);
1473 TRACE_REQUIRE_EQUAL(ids[2], 1);
1474 TRACE_REQUIRE_EQUAL(ids[3], 1);
1483 TRACE_REQUIRE_EQUAL(sts,
true);
1484 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1485 while (fps.size() > 0)
1487 ids[fps.front()->fragmentID()]++;
1488 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1489 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1490 type = artdaq::Fragment::ContainerFragmentType;
1491 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1492 auto cf = artdaq::ContainerFragment(*fps.front());
1493 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1494 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1495 type = artdaq::Fragment::EmptyFragmentType;
1496 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1499 TRACE_REQUIRE_EQUAL(ids[1], 1);
1500 TRACE_REQUIRE_EQUAL(ids[2], 1);
1501 TRACE_REQUIRE_EQUAL(ids[3], 1);
1512 TRACE_REQUIRE_EQUAL(sts,
true);
1513 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1515 auto ts = artdaq::Fragment::InvalidTimestamp;
1516 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1517 for (
auto ii = 0; ii < 3; ++ii)
1519 ids[fps.front()->fragmentID()]++;
1520 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1521 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1522 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1523 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1526 TRACE_REQUIRE_EQUAL(ids[1], 1);
1527 TRACE_REQUIRE_EQUAL(ids[2], 1);
1528 TRACE_REQUIRE_EQUAL(ids[3], 1);
1530 for (
auto ii = 0; ii < 3; ++ii)
1532 ids[fps.front()->fragmentID()]++;
1533 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1534 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1535 type = artdaq::Fragment::ContainerFragmentType;
1536 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1537 auto cf3 = artdaq::ContainerFragment(*fps.front());
1538 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
1539 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1540 type = artdaq::Fragment::FirstUserFragmentType;
1541 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1544 TRACE_REQUIRE_EQUAL(ids[1], 1);
1545 TRACE_REQUIRE_EQUAL(ids[2], 1);
1546 TRACE_REQUIRE_EQUAL(ids[3], 1);
1557 TRACE_REQUIRE_EQUAL(sts,
true);
1558 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1559 while (fps.size() > 0)
1561 ids[fps.front()->fragmentID()]++;
1562 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1563 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1564 type = artdaq::Fragment::ContainerFragmentType;
1565 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1566 auto cf = artdaq::ContainerFragment(*fps.front());
1567 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1568 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1569 type = artdaq::Fragment::FirstUserFragmentType;
1570 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1571 TRACE_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1572 TRACE_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1573 TRACE_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1576 TRACE_REQUIRE_EQUAL(ids[1], 1);
1577 TRACE_REQUIRE_EQUAL(ids[2], 1);
1578 TRACE_REQUIRE_EQUAL(ids[3], 1);
1584 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1589 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1590 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1591 fhicl::ParameterSet ps;
1592 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1593 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1594 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1595 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1596 ps.put<
bool>(
"circular_buffer_mode",
true);
1597 ps.put<std::string>(
"request_mode",
"window");
1598 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
1599 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1601 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1602 buffer->setRunning(
true);
1612 artdaq::FragmentPtrs fps;
1613 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1615 auto type = artdaq::Fragment::ContainerFragmentType;
1617 TRACE_REQUIRE_EQUAL(sts,
true);
1618 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1619 while (fps.size() > 0)
1621 ids[fps.front()->fragmentID()]++;
1622 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1623 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1624 type = artdaq::Fragment::ContainerFragmentType;
1625 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1626 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1627 auto cf = artdaq::ContainerFragment(*fps.front());
1628 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1629 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1630 type = artdaq::Fragment::FirstUserFragmentType;
1631 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1634 TRACE_REQUIRE_EQUAL(ids[1], 1);
1635 TRACE_REQUIRE_EQUAL(ids[2], 1);
1636 TRACE_REQUIRE_EQUAL(ids[3], 1);
1645 TRACE_REQUIRE_EQUAL(sts,
true);
1646 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1652 TRACE_REQUIRE_EQUAL(sts,
true);
1653 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1654 while (fps.size() > 0)
1656 ids[fps.front()->fragmentID()]++;
1657 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1658 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1659 type = artdaq::Fragment::ContainerFragmentType;
1660 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1661 auto cf = artdaq::ContainerFragment(*fps.front());
1662 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1663 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1664 type = artdaq::Fragment::FirstUserFragmentType;
1665 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1668 TRACE_REQUIRE_EQUAL(ids[1], 1);
1669 TRACE_REQUIRE_EQUAL(ids[2], 1);
1670 TRACE_REQUIRE_EQUAL(ids[3], 1);
1678 TRACE_REQUIRE_EQUAL(sts,
true);
1679 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1684 TRACE_REQUIRE_EQUAL(sts,
true);
1685 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1689 TRACE_REQUIRE_EQUAL(list.size(), 1);
1690 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
1695 while (fps.size() > 0)
1697 ids[fps.front()->fragmentID()]++;
1698 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1699 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1700 type = artdaq::Fragment::ContainerFragmentType;
1701 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1702 auto cf = artdaq::ContainerFragment(*fps.front());
1703 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1704 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1705 type = artdaq::Fragment::EmptyFragmentType;
1706 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1709 TRACE_REQUIRE_EQUAL(ids[1], 1);
1710 TRACE_REQUIRE_EQUAL(ids[2], 1);
1711 TRACE_REQUIRE_EQUAL(ids[3], 1);
1723 TRACE_REQUIRE_EQUAL(list.size(), 1);
1727 TRACE_REQUIRE_EQUAL(list.size(), 0);
1728 TRACE_REQUIRE_EQUAL(sts,
true);
1729 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1730 while (fps.size() > 0)
1732 ids[fps.front()->fragmentID()]++;
1733 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1734 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1735 type = artdaq::Fragment::ContainerFragmentType;
1736 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1737 auto cf = artdaq::ContainerFragment(*fps.front());
1738 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1739 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1740 type = artdaq::Fragment::EmptyFragmentType;
1741 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1744 TRACE_REQUIRE_EQUAL(ids[1], 1);
1745 TRACE_REQUIRE_EQUAL(ids[2], 1);
1746 TRACE_REQUIRE_EQUAL(ids[3], 1);
1751 buffer->push(7, 13);
1754 TRACE_REQUIRE_EQUAL(sts,
true);
1755 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1756 while (fps.size() > 0)
1758 ids[fps.front()->fragmentID()]++;
1759 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
1760 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
1761 type = artdaq::Fragment::ContainerFragmentType;
1762 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1763 auto cf = artdaq::ContainerFragment(*fps.front());
1764 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1765 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1766 type = artdaq::Fragment::FirstUserFragmentType;
1767 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1770 TRACE_REQUIRE_EQUAL(ids[1], 1);
1771 TRACE_REQUIRE_EQUAL(ids[2], 1);
1772 TRACE_REQUIRE_EQUAL(ids[3], 1);
1778 TRACE_REQUIRE_EQUAL(list.size(), 1);
1779 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
1781 buffer->push(6, 12);
1784 TRACE_REQUIRE_EQUAL(sts,
true);
1785 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1786 while (fps.size() > 0)
1788 ids[fps.front()->fragmentID()]++;
1789 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
1790 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1791 type = artdaq::Fragment::ContainerFragmentType;
1792 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1793 auto cf = artdaq::ContainerFragment(*fps.front());
1794 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1795 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1796 type = artdaq::Fragment::FirstUserFragmentType;
1797 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1800 TRACE_REQUIRE_EQUAL(ids[1], 1);
1801 TRACE_REQUIRE_EQUAL(ids[2], 1);
1802 TRACE_REQUIRE_EQUAL(ids[3], 1);
1808 TRACE_REQUIRE_EQUAL(list.size(), 0);
1812 buffer->push(8, 15);
1814 sts = fp.applyRequests(fps);
1815 TRACE_REQUIRE_EQUAL(sts,
true);
1816 TRACE_REQUIRE_EQUAL(fps.size(), 2);
1817 while (fps.size() > 0)
1819 ids[fps.front()->fragmentID()]++;
1820 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1821 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1822 type = artdaq::Fragment::ContainerFragmentType;
1823 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1824 auto cf = artdaq::ContainerFragment(*fps.front());
1825 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1826 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1827 type = artdaq::Fragment::FirstUserFragmentType;
1828 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1831 TRACE_REQUIRE_EQUAL(ids[1], 1);
1832 TRACE_REQUIRE_EQUAL(ids[2], 1);
1833 TRACE_REQUIRE_EQUAL(ids[3], 0);
1836 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 8);
1838 gen.setTimestamp(14);
1839 fp.AddFragmentsToBuffer(gen.Generate(1, {3}));
1841 sts = fp.applyRequests(fps);
1842 TRACE_REQUIRE_EQUAL(sts,
true);
1843 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1844 while (fps.size() > 0)
1846 ids[fps.front()->fragmentID()]++;
1847 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1848 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1849 type = artdaq::Fragment::ContainerFragmentType;
1850 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1851 auto cf = artdaq::ContainerFragment(*fps.front());
1852 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1853 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1854 type = artdaq::Fragment::FirstUserFragmentType;
1855 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1858 TRACE_REQUIRE_EQUAL(ids[1], 0);
1859 TRACE_REQUIRE_EQUAL(ids[2], 0);
1860 TRACE_REQUIRE_EQUAL(ids[3], 1);
1863 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 9);
1865 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
1870 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1871 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case BEGIN";
1872 fhicl::ParameterSet ps;
1873 ps.put<
int>(
"board_id", 1);
1874 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1875 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1876 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1877 ps.put<
bool>(
"separate_data_thread",
true);
1878 ps.put<
bool>(
"separate_monitoring_thread",
false);
1879 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1880 ps.put<std::string>(
"request_mode",
"SequenceID");
1882 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1883 buffer->setRunning(
true);
1894 artdaq::FragmentPtrs fps;
1895 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1897 auto type = artdaq::Fragment::FirstUserFragmentType;
1898 TRACE_REQUIRE_EQUAL(sts,
true);
1899 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1901 for (
auto ii = 0; ii < 3; ++ii)
1903 ids[fps.front()->fragmentID()]++;
1904 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1905 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1906 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1909 TRACE_REQUIRE_EQUAL(ids[1], 1);
1910 TRACE_REQUIRE_EQUAL(ids[2], 1);
1911 TRACE_REQUIRE_EQUAL(ids[3], 1);
1921 TRACE_REQUIRE_EQUAL(sts,
true);
1922 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1928 TRACE_REQUIRE_EQUAL(sts,
true);
1929 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1930 for (
auto ii = 0; ii < 3; ++ii)
1932 ids[fps.front()->fragmentID()]++;
1933 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1934 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1935 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1938 TRACE_REQUIRE_EQUAL(ids[1], 1);
1939 TRACE_REQUIRE_EQUAL(ids[2], 1);
1940 TRACE_REQUIRE_EQUAL(ids[3], 1);
1953 TRACE_REQUIRE_EQUAL(sts,
true);
1954 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1955 for (
auto ii = 0; ii < 3; ++ii)
1957 ids[fps.front()->fragmentID()]++;
1958 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1959 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1960 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1963 TRACE_REQUIRE_EQUAL(ids[1], 1);
1964 TRACE_REQUIRE_EQUAL(ids[2], 1);
1965 TRACE_REQUIRE_EQUAL(ids[3], 1);
1973 TRACE_REQUIRE_EQUAL(sts,
true);
1974 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1975 for (
auto ii = 0; ii < 3; ++ii)
1977 ids[fps.front()->fragmentID()]++;
1978 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1979 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1980 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1983 TRACE_REQUIRE_EQUAL(ids[1], 1);
1984 TRACE_REQUIRE_EQUAL(ids[2], 1);
1985 TRACE_REQUIRE_EQUAL(ids[3], 1);
1988 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case END";
1993 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1994 TLOG(TLVL_INFO) <<
"IgnoreRequests_StateMachine test case BEGIN";
1995 fhicl::ParameterSet ps;
1996 ps.put<
int>(
"fragment_id", 1);
1997 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1998 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1999 ps.put<std::string>(
"request_mode",
"ignored");
2001 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2002 buffer->setRunning(
true);
2007 buffer->push(53, 35);
2013 artdaq::FragmentPtrs fps;
2016 TRACE_REQUIRE_EQUAL(sts,
true);
2017 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2018 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2019 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2020 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2026 TRACE_REQUIRE_EQUAL(sts,
true);
2027 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2033 TRACE_REQUIRE_EQUAL(sts,
true);
2034 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2035 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2036 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
2037 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
2045 TRACE_REQUIRE_EQUAL(sts,
false);
2046 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2048 TLOG(TLVL_INFO) <<
"IgnoreRequests_StateMachine test case END";
2053 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
2054 TLOG(TLVL_INFO) <<
"SingleMode_StateMachine test case BEGIN";
2055 fhicl::ParameterSet ps;
2056 ps.put<
int>(
"fragment_id", 1);
2057 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2058 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2059 ps.put<std::string>(
"request_mode",
"single");
2061 auto type = artdaq::Fragment::FirstUserFragmentType;
2062 auto buffer = std::make_shared<artdaq::RequestBuffer>();
2063 buffer->setRunning(
true);
2072 artdaq::FragmentPtrs fps;
2074 TRACE_REQUIRE_EQUAL(sts,
true);
2075 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2076 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2077 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2078 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2079 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2086 TRACE_REQUIRE_EQUAL(sts,
true);
2087 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
2092 TRACE_REQUIRE_EQUAL(sts,
true);
2093 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2094 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2095 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2096 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2097 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2104 TRACE_REQUIRE_EQUAL(sts,
true);
2105 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
2106 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
2107 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
2108 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
2109 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2113 buffer->setRunning(
false);
2118 TRACE_REQUIRE_EQUAL(sts,
false);
2119 TRACE_REQUIRE_EQUAL(fps.size(), 0);
2121 TLOG(TLVL_INFO) <<
"SingleMode_StateMachine test case END";
2124 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.