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;
42 artdaq::FragmentPtrs Generate(
size_t n, std::vector<artdaq::Fragment::fragment_id_t> fragmentIds = std::vector<artdaq::Fragment::fragment_id_t>());
58 artdaq::Fragment::timestamp_t ts_;
59 artdaq::Fragment::sequence_id_t seq_;
60 std::set<artdaq::Fragment::fragment_id_t> fragmentIDs_;
66 metricMan->initialize(ps.get<fhicl::ParameterSet>(
"metrics", fhicl::ParameterSet()));
67 metricMan->do_start();
69 auto idlist = ps.get<std::vector<artdaq::Fragment::fragment_id_t>>(
"fragment_ids", {ps.get<artdaq::Fragment::fragment_id_t>(
"fragment_id", 1)});
70 for (
auto&
id : idlist)
72 fragmentIDs_.insert(
id);
76 artdaq::FragmentPtrs artdaqtest::FragmentBufferTestGenerator::Generate(
size_t n, std::vector<artdaq::Fragment::fragment_id_t> fragmentIds)
78 if (fragmentIds.size() == 0) std::copy(fragmentIDs_.begin(), fragmentIDs_.end(), std::back_inserter(fragmentIds));
80 artdaq::FragmentPtrs frags;
84 for (
auto&
id : fragmentIds)
86 TLOG(TLVL_DEBUG) <<
"Adding Fragment with ID " <<
id <<
", SeqID " << seq_ <<
", and timestamp " << ts_;
87 frags.emplace_back(
new artdaq::Fragment(seq_,
id, artdaq::Fragment::FirstUserFragmentType, ts_));
96 BOOST_AUTO_TEST_SUITE(FragmentBuffer_t)
100 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
101 TLOG(TLVL_INFO) <<
"IgnoreRequests test case BEGIN";
102 fhicl::ParameterSet ps;
103 ps.put<
int>(
"fragment_id", 1);
104 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
105 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
106 ps.put<std::string>(
"request_mode",
"ignored");
108 auto buffer = std::make_shared<artdaq::RequestBuffer>();
109 buffer->setRunning(
true);
114 buffer->push(53, 35);
118 fp.AddFragmentsToBuffer(gen.Generate(1));
120 artdaq::FragmentPtrs fps;
123 TRACE_REQUIRE_EQUAL(sts,
true);
124 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
125 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
126 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
127 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
129 TLOG(TLVL_INFO) <<
"IgnoreRequests test case END";
134 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
135 TLOG(TLVL_INFO) <<
"SingleMode test case BEGIN";
136 fhicl::ParameterSet ps;
137 ps.put<
int>(
"fragment_id", 1);
138 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
139 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
140 ps.put<std::string>(
"request_mode",
"single");
142 auto buffer = std::make_shared<artdaq::RequestBuffer>();
143 buffer->setRunning(
true);
149 fp.AddFragmentsToBuffer(gen.Generate(1));
152 artdaq::FragmentPtrs fps;
154 auto type = artdaq::Fragment::FirstUserFragmentType;
155 TRACE_REQUIRE_EQUAL(sts,
true);
156 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
157 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
158 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
159 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
160 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
166 TRACE_REQUIRE_EQUAL(sts,
true);
167 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
168 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
169 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
170 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
171 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
175 fp.AddFragmentsToBuffer(gen.Generate(2));
180 TRACE_REQUIRE_EQUAL(sts,
true);
181 TRACE_REQUIRE_EQUAL(fps.size(), 2);
182 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
183 auto ts = artdaq::Fragment::InvalidTimestamp;
184 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
185 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
186 auto emptyType = artdaq::Fragment::EmptyFragmentType;
187 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
189 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
190 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
191 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
192 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
195 TLOG(TLVL_INFO) <<
"SingleMode test case END";
200 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
201 TLOG(TLVL_INFO) <<
"BufferMode test case BEGIN";
202 fhicl::ParameterSet ps;
203 ps.put<
int>(
"fragment_id", 1);
204 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
205 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
206 ps.put<std::string>(
"request_mode",
"buffer");
208 auto buffer = std::make_shared<artdaq::RequestBuffer>();
209 buffer->setRunning(
true);
215 fp.AddFragmentsToBuffer(gen.Generate(1));
219 artdaq::FragmentPtrs fps;
221 TRACE_REQUIRE_EQUAL(sts,
true);
222 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
223 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
224 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
225 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
226 auto type = artdaq::Fragment::ContainerFragmentType;
227 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
228 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
229 auto cf = artdaq::ContainerFragment(*fps.front());
230 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
231 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
232 type = artdaq::Fragment::FirstUserFragmentType;
233 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
239 TRACE_REQUIRE_EQUAL(sts,
true);
240 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
241 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
242 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
243 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
244 type = artdaq::Fragment::ContainerFragmentType;
245 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
246 auto cf2 = artdaq::ContainerFragment(*fps.front());
247 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
248 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
249 type = artdaq::Fragment::EmptyFragmentType;
250 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
254 fp.AddFragmentsToBuffer(gen.Generate(2));
258 TRACE_REQUIRE_EQUAL(sts,
true);
259 TRACE_REQUIRE_EQUAL(fps.size(), 2);
261 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
262 auto ts = artdaq::Fragment::InvalidTimestamp;
263 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
264 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
265 auto emptyType = artdaq::Fragment::EmptyFragmentType;
266 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
267 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
269 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
270 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
271 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
272 type = artdaq::Fragment::ContainerFragmentType;
273 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
274 auto cf3 = artdaq::ContainerFragment(*fps.front());
275 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
276 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
277 type = artdaq::Fragment::FirstUserFragmentType;
278 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
282 TLOG(TLVL_INFO) <<
"BufferMode test case END";
287 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
288 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case BEGIN";
289 fhicl::ParameterSet ps;
290 ps.put<
int>(
"fragment_id", 1);
291 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
292 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
293 ps.put<std::string>(
"request_mode",
"buffer");
294 ps.put(
"buffer_mode_keep_latest",
true);
296 auto buffer = std::make_shared<artdaq::RequestBuffer>();
297 buffer->setRunning(
true);
303 fp.AddFragmentsToBuffer(gen.Generate(1));
307 artdaq::FragmentPtrs fps;
309 TRACE_REQUIRE_EQUAL(sts,
true);
310 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
311 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
312 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
313 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
314 auto type = artdaq::Fragment::ContainerFragmentType;
315 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
316 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
317 auto cf = artdaq::ContainerFragment(*fps.front());
318 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
319 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
320 type = artdaq::Fragment::FirstUserFragmentType;
321 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
327 TRACE_REQUIRE_EQUAL(sts,
true);
328 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
329 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
330 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
331 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
332 type = artdaq::Fragment::ContainerFragmentType;
333 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
334 auto cf2 = artdaq::ContainerFragment(*fps.front());
335 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
336 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
337 type = artdaq::Fragment::FirstUserFragmentType;
338 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
342 fp.AddFragmentsToBuffer(gen.Generate(2));
345 TRACE_REQUIRE_EQUAL(sts,
true);
346 TRACE_REQUIRE_EQUAL(fps.size(), 2);
348 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
349 auto ts = artdaq::Fragment::InvalidTimestamp;
350 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
351 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
352 auto emptyType = artdaq::Fragment::EmptyFragmentType;
353 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
354 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
356 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
357 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
358 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
359 type = artdaq::Fragment::ContainerFragmentType;
360 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
361 auto cf3 = artdaq::ContainerFragment(*fps.front());
362 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
363 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
364 type = artdaq::Fragment::FirstUserFragmentType;
365 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
369 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case END";
373 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
374 TLOG(TLVL_INFO) <<
"CircularBufferMode test case BEGIN";
375 fhicl::ParameterSet ps;
376 ps.put<
int>(
"fragment_id", 1);
377 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
378 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
379 ps.put<
bool>(
"circular_buffer_mode",
true);
380 ps.put<
int>(
"data_buffer_depth_fragments", 3);
381 ps.put<std::string>(
"request_mode",
"buffer");
383 auto buffer = std::make_shared<artdaq::RequestBuffer>();
384 buffer->setRunning(
true);
390 fp.AddFragmentsToBuffer(gen.Generate(1));
394 artdaq::FragmentPtrs fps;
396 TRACE_REQUIRE_EQUAL(sts,
true);
397 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
398 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
399 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
400 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
401 auto type = artdaq::Fragment::ContainerFragmentType;
402 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
403 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
404 auto cf = artdaq::ContainerFragment(*fps.front());
405 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
406 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
407 type = artdaq::Fragment::FirstUserFragmentType;
408 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
414 TRACE_REQUIRE_EQUAL(sts,
true);
415 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
416 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
417 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
418 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
419 type = artdaq::Fragment::ContainerFragmentType;
420 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
421 auto cf2 = artdaq::ContainerFragment(*fps.front());
422 TRACE_REQUIRE_EQUAL(cf2.block_count(), 0);
423 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
424 type = artdaq::Fragment::EmptyFragmentType;
425 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
429 fp.AddFragmentsToBuffer(gen.Generate(3));
433 TRACE_REQUIRE_EQUAL(sts,
true);
434 TRACE_REQUIRE_EQUAL(fps.size(), 2);
436 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
437 auto ts = artdaq::Fragment::InvalidTimestamp;
438 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
439 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
440 auto emptyType = artdaq::Fragment::EmptyFragmentType;
441 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
442 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
444 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
445 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
446 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
447 type = artdaq::Fragment::ContainerFragmentType;
448 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
449 auto cf3 = artdaq::ContainerFragment(*fps.front());
450 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
451 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
452 type = artdaq::Fragment::FirstUserFragmentType;
453 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
457 fp.AddFragmentsToBuffer(gen.Generate(5));
462 TRACE_REQUIRE_EQUAL(sts,
true);
463 TRACE_REQUIRE_EQUAL(fps.size(), 1);
465 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
466 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
467 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
468 type = artdaq::Fragment::ContainerFragmentType;
469 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
470 auto cf4 = artdaq::ContainerFragment(*fps.front());
471 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
472 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
473 type = artdaq::Fragment::FirstUserFragmentType;
474 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
475 TRACE_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
476 TRACE_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
477 TRACE_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
481 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
486 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
487 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
488 fhicl::ParameterSet ps;
489 ps.put<
int>(
"fragment_id", 1);
491 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
492 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
493 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
494 ps.put<
bool>(
"circular_buffer_mode",
true);
495 ps.put<std::string>(
"request_mode",
"window");
496 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
497 ps.put<
size_t>(
"window_close_timeout_us", 500000);
499 auto buffer = std::make_shared<artdaq::RequestBuffer>();
500 buffer->setRunning(
true);
506 fp.AddFragmentsToBuffer(gen.Generate(1));
511 artdaq::FragmentPtrs fps;
514 TRACE_REQUIRE_EQUAL(sts,
true);
515 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
516 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
517 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
518 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
519 auto type = artdaq::Fragment::ContainerFragmentType;
520 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
521 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
522 auto cf = artdaq::ContainerFragment(*fps.front());
523 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
524 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
525 type = artdaq::Fragment::FirstUserFragmentType;
526 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
534 TRACE_REQUIRE_EQUAL(sts,
true);
535 TRACE_REQUIRE_EQUAL(fps.size(), 0);
537 fp.AddFragmentsToBuffer(gen.Generate(1));
541 TRACE_REQUIRE_EQUAL(sts,
true);
542 TRACE_REQUIRE_EQUAL(fps.size(), 1);
543 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
544 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
545 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
546 type = artdaq::Fragment::ContainerFragmentType;
547 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
548 auto cf2 = artdaq::ContainerFragment(*fps.front());
549 TRACE_REQUIRE_EQUAL(cf2.block_count(), 1);
550 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
false);
551 type = artdaq::Fragment::FirstUserFragmentType;
552 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
559 TRACE_REQUIRE_EQUAL(sts,
true);
560 TRACE_REQUIRE_EQUAL(fps.size(), 0);
565 TRACE_REQUIRE_EQUAL(sts,
true);
566 TRACE_REQUIRE_EQUAL(fps.size(), 1);
570 TRACE_REQUIRE_EQUAL(list.size(), 1);
571 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
576 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
577 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
578 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
579 type = artdaq::Fragment::ContainerFragmentType;
580 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
581 auto cf3 = artdaq::ContainerFragment(*fps.front());
582 TRACE_REQUIRE_EQUAL(cf3.block_count(), 0);
583 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
true);
584 type = artdaq::Fragment::EmptyFragmentType;
585 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
590 fp.AddFragmentsToBuffer(gen.Generate(12));
595 TRACE_REQUIRE_EQUAL(list.size(), 1);
599 TRACE_REQUIRE_EQUAL(list.size(), 0);
600 TRACE_REQUIRE_EQUAL(sts,
true);
601 TRACE_REQUIRE_EQUAL(fps.size(), 1);
602 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
603 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
604 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
605 type = artdaq::Fragment::ContainerFragmentType;
606 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
607 auto cf4 = artdaq::ContainerFragment(*fps.front());
608 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
609 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
610 type = artdaq::Fragment::EmptyFragmentType;
611 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
618 TRACE_REQUIRE_EQUAL(sts,
true);
619 TRACE_REQUIRE_EQUAL(fps.size(), 1);
620 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
621 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
622 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
623 type = artdaq::Fragment::ContainerFragmentType;
624 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
625 auto cf5 = artdaq::ContainerFragment(*fps.front());
626 TRACE_REQUIRE_EQUAL(cf5.block_count(), 1);
627 TRACE_REQUIRE_EQUAL(cf5.missing_data(),
false);
628 type = artdaq::Fragment::FirstUserFragmentType;
629 TRACE_REQUIRE_EQUAL(cf5.fragment_type(), type);
634 TRACE_REQUIRE_EQUAL(list.size(), 1);
635 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
640 TRACE_REQUIRE_EQUAL(sts,
true);
641 TRACE_REQUIRE_EQUAL(fps.size(), 1);
642 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
643 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
644 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
645 type = artdaq::Fragment::ContainerFragmentType;
646 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
647 auto cf6 = artdaq::ContainerFragment(*fps.front());
648 TRACE_REQUIRE_EQUAL(cf6.block_count(), 1);
649 TRACE_REQUIRE_EQUAL(cf6.missing_data(),
false);
650 type = artdaq::Fragment::FirstUserFragmentType;
651 TRACE_REQUIRE_EQUAL(cf6.fragment_type(), type);
656 TRACE_REQUIRE_EQUAL(list.size(), 0);
660 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
671 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
672 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
673 fhicl::ParameterSet ps;
674 ps.put<
int>(
"fragment_id", 1);
676 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
677 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
678 ps.put<
bool>(
"circular_buffer_mode",
true);
679 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
680 ps.put<std::string>(
"request_mode",
"window");
682 auto buffer = std::make_shared<artdaq::RequestBuffer>();
683 buffer->setRunning(
true);
690 artdaq::FragmentPtrs fps;
692 artdaq::Fragment::type_t type;
696 fp.AddFragmentsToBuffer(gen.Generate(10));
701 TRACE_REQUIRE_EQUAL(sts,
true);
702 TRACE_REQUIRE_EQUAL(fps.size(), 1);
703 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
704 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
705 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
706 type = artdaq::Fragment::ContainerFragmentType;
707 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
708 auto cf4 = artdaq::ContainerFragment(*fps.front());
709 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
710 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
711 type = artdaq::Fragment::EmptyFragmentType;
712 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
714 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
718 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
719 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
721 fhicl::ParameterSet ps;
722 ps.put<
int>(
"fragment_id", 1);
723 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
724 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
725 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
726 ps.put<
bool>(
"circular_buffer_mode",
true);
727 ps.put<std::string>(
"request_mode",
"window");
729 auto buffer = std::make_shared<artdaq::RequestBuffer>();
730 buffer->setRunning(
true);
737 artdaq::FragmentPtrs fps;
739 artdaq::Fragment::type_t type;
742 fp.AddFragmentsToBuffer(gen.Generate(10));
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);
786 artdaq::FragmentPtrs fps;
788 artdaq::Fragment::type_t type;
791 fp.AddFragmentsToBuffer(gen.Generate(10));
800 TRACE_REQUIRE_EQUAL(sts,
true);
801 TRACE_REQUIRE_EQUAL(fps.size(), 1);
802 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
803 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
804 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
805 type = artdaq::Fragment::ContainerFragmentType;
806 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
807 auto cf = artdaq::ContainerFragment(*fps.front());
808 TRACE_REQUIRE_EQUAL(cf.block_count(), 4);
809 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
810 type = artdaq::Fragment::FirstUserFragmentType;
811 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
817 TRACE_REQUIRE_EQUAL(sts,
true);
818 TRACE_REQUIRE_EQUAL(fps.size(), 0);
820 fp.AddFragmentsToBuffer(gen.Generate(3));
824 TRACE_REQUIRE_EQUAL(sts,
true);
825 TRACE_REQUIRE_EQUAL(fps.size(), 1);
826 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
827 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
828 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
829 type = artdaq::Fragment::ContainerFragmentType;
830 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
831 auto cf2 = artdaq::ContainerFragment(*fps.front());
832 TRACE_REQUIRE_EQUAL(cf2.block_count(), 3);
833 TRACE_REQUIRE_EQUAL(cf2.missing_data(),
true);
834 type = artdaq::Fragment::FirstUserFragmentType;
835 TRACE_REQUIRE_EQUAL(cf2.fragment_type(), type);
841 TRACE_REQUIRE_EQUAL(sts,
true);
842 TRACE_REQUIRE_EQUAL(fps.size(), 0);
847 TRACE_REQUIRE_EQUAL(sts,
true);
848 TRACE_REQUIRE_EQUAL(fps.size(), 1);
849 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
850 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
851 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
852 type = artdaq::Fragment::ContainerFragmentType;
853 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
854 auto cf4 = artdaq::ContainerFragment(*fps.front());
855 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
856 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
857 type = artdaq::Fragment::FirstUserFragmentType;
858 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
860 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
864 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
865 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
866 fhicl::ParameterSet ps;
867 ps.put<
int>(
"fragment_id", 1);
868 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
869 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
870 ps.put<
bool>(
"circular_buffer_mode",
true);
871 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
872 ps.put<std::string>(
"request_mode",
"window");
874 auto buffer = std::make_shared<artdaq::RequestBuffer>();
875 buffer->setRunning(
true);
880 artdaq::FragmentPtrs fps;
882 artdaq::Fragment::type_t type;
887 fp.AddFragmentsToBuffer(gen.Generate(6));
892 TRACE_REQUIRE_EQUAL(sts,
true);
893 TRACE_REQUIRE_EQUAL(fps.size(), 1);
894 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
895 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
896 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
897 type = artdaq::Fragment::ContainerFragmentType;
898 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
899 auto cf4 = artdaq::ContainerFragment(*fps.front());
900 TRACE_REQUIRE_EQUAL(cf4.block_count(), 3);
901 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
false);
902 type = artdaq::Fragment::FirstUserFragmentType;
903 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
905 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
909 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
910 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
911 fhicl::ParameterSet ps;
912 ps.put<
int>(
"fragment_id", 1);
913 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
914 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
915 ps.put<
size_t>(
"window_close_timeout_us", 500000);
916 ps.put<
bool>(
"circular_buffer_mode",
true);
917 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
918 ps.put<std::string>(
"request_mode",
"window");
920 auto buffer = std::make_shared<artdaq::RequestBuffer>();
921 buffer->setRunning(
true);
926 artdaq::FragmentPtrs fps;
928 artdaq::Fragment::type_t type;
930 fp.AddFragmentsToBuffer(gen.Generate(6));
938 TRACE_REQUIRE_EQUAL(sts,
true);
939 TRACE_REQUIRE_EQUAL(fps.size(), 0);
941 fp.AddFragmentsToBuffer(gen.Generate(2));
944 TRACE_REQUIRE_EQUAL(sts,
true);
945 TRACE_REQUIRE_EQUAL(fps.size(), 1);
946 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
947 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
948 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
949 type = artdaq::Fragment::ContainerFragmentType;
950 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
951 auto cf = artdaq::ContainerFragment(*fps.front());
952 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
953 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
954 type = artdaq::Fragment::FirstUserFragmentType;
955 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
961 TRACE_REQUIRE_EQUAL(sts,
true);
962 TRACE_REQUIRE_EQUAL(fps.size(), 0);
967 TRACE_REQUIRE_EQUAL(sts,
true);
968 TRACE_REQUIRE_EQUAL(fps.size(), 1);
969 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
970 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
971 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
972 type = artdaq::Fragment::ContainerFragmentType;
973 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
974 auto cf4 = artdaq::ContainerFragment(*fps.front());
975 TRACE_REQUIRE_EQUAL(cf4.block_count(), 1);
976 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
977 type = artdaq::Fragment::FirstUserFragmentType;
978 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
980 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
984 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
985 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
986 fhicl::ParameterSet ps;
987 ps.put<
int>(
"fragment_id", 1);
988 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
989 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
990 ps.put<
size_t>(
"window_close_timeout_us", 500000);
991 ps.put<
bool>(
"circular_buffer_mode",
true);
992 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
993 ps.put<std::string>(
"request_mode",
"window");
995 auto buffer = std::make_shared<artdaq::RequestBuffer>();
996 buffer->setRunning(
true);
1001 artdaq::FragmentPtrs fps;
1003 artdaq::Fragment::type_t type;
1008 fp.AddFragmentsToBuffer(gen.Generate(10));
1010 buffer->push(1, 11);
1013 TRACE_REQUIRE_EQUAL(sts,
true);
1014 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1015 fp.AddFragmentsToBuffer(gen.Generate(1));
1018 TRACE_REQUIRE_EQUAL(sts,
true);
1019 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1021 fp.AddFragmentsToBuffer(gen.Generate(3));
1024 TRACE_REQUIRE_EQUAL(sts,
true);
1025 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1026 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1027 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1028 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1029 type = artdaq::Fragment::ContainerFragmentType;
1030 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1031 auto cf = artdaq::ContainerFragment(*fps.front());
1032 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1033 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1034 type = artdaq::Fragment::FirstUserFragmentType;
1035 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1038 buffer->push(2, 16);
1041 TRACE_REQUIRE_EQUAL(sts,
true);
1042 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1047 TRACE_REQUIRE_EQUAL(sts,
true);
1048 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1049 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1050 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
1051 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1052 type = artdaq::Fragment::ContainerFragmentType;
1053 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1054 auto cf4 = artdaq::ContainerFragment(*fps.front());
1055 TRACE_REQUIRE_EQUAL(cf4.block_count(), 0);
1056 TRACE_REQUIRE_EQUAL(cf4.missing_data(),
true);
1057 type = artdaq::Fragment::EmptyFragmentType;
1058 TRACE_REQUIRE_EQUAL(cf4.fragment_type(), type);
1060 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1065 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1066 TLOG(TLVL_INFO) <<
"SequenceIDMode test case BEGIN";
1067 fhicl::ParameterSet ps;
1068 ps.put<
int>(
"fragment_id", 1);
1069 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1070 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1071 ps.put<std::string>(
"request_mode",
"SequenceID");
1073 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1074 buffer->setRunning(
true);
1080 fp.AddFragmentsToBuffer(gen.Generate(1));
1086 artdaq::FragmentPtrs fps;
1088 auto type = artdaq::Fragment::FirstUserFragmentType;
1089 TRACE_REQUIRE_EQUAL(sts,
true);
1090 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1091 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1092 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1093 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1094 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1102 TRACE_REQUIRE_EQUAL(sts,
true);
1103 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1106 fp.AddFragmentsToBuffer(gen.Generate(1));
1109 TRACE_REQUIRE_EQUAL(sts,
true);
1110 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1111 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1112 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1113 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1114 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1119 fp.AddFragmentsToBuffer(gen.Generate(2));
1125 TRACE_REQUIRE_EQUAL(sts,
true);
1126 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1127 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1128 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1129 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1130 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1137 TRACE_REQUIRE_EQUAL(sts,
true);
1138 TRACE_REQUIRE_EQUAL(fps.size(), 1u);
1139 TRACE_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1140 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1141 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1142 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1144 TLOG(TLVL_INFO) <<
"SequenceIDMode test case END";
1149 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1150 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1151 fhicl::ParameterSet ps;
1152 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1153 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1154 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1155 ps.put<std::string>(
"request_mode",
"ignored");
1157 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1158 buffer->setRunning(
true);
1164 buffer->push(53, 35);
1165 fp.AddFragmentsToBuffer(gen.Generate(1));
1167 artdaq::FragmentPtrs fps;
1168 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1170 TRACE_REQUIRE_EQUAL(sts,
true);
1171 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1172 while (fps.size() > 0)
1174 ids[fps.front()->fragmentID()]++;
1175 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1176 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1180 TRACE_REQUIRE_EQUAL(ids[1], 1);
1181 TRACE_REQUIRE_EQUAL(ids[2], 1);
1182 TRACE_REQUIRE_EQUAL(ids[3], 1);
1187 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1192 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1193 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1194 fhicl::ParameterSet ps;
1195 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1196 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1197 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1198 ps.put<std::string>(
"request_mode",
"single");
1200 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1201 buffer->setRunning(
true);
1207 fp.AddFragmentsToBuffer(gen.Generate(1));
1212 artdaq::FragmentPtrs fps;
1213 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1215 auto type = artdaq::Fragment::FirstUserFragmentType;
1216 TRACE_REQUIRE_EQUAL(sts,
true);
1217 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1218 while (fps.size() > 0)
1220 ids[fps.front()->fragmentID()]++;
1221 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1222 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1223 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1226 TRACE_REQUIRE_EQUAL(ids[1], 1);
1227 TRACE_REQUIRE_EQUAL(ids[2], 1);
1228 TRACE_REQUIRE_EQUAL(ids[3], 1);
1237 TRACE_REQUIRE_EQUAL(sts,
true);
1238 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1239 while (fps.size() > 0)
1241 ids[fps.front()->fragmentID()]++;
1242 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1243 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1244 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1247 TRACE_REQUIRE_EQUAL(ids[1], 1);
1248 TRACE_REQUIRE_EQUAL(ids[2], 1);
1249 TRACE_REQUIRE_EQUAL(ids[3], 1);
1255 fp.AddFragmentsToBuffer(gen.Generate(2));
1261 TRACE_REQUIRE_EQUAL(sts,
true);
1262 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1263 auto ts = artdaq::Fragment::InvalidTimestamp;
1264 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1265 for (
auto ii = 0; ii < 3; ++ii)
1267 ids[fps.front()->fragmentID()]++;
1268 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1269 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1270 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1273 TRACE_REQUIRE_EQUAL(ids[1], 1);
1274 TRACE_REQUIRE_EQUAL(ids[2], 1);
1275 TRACE_REQUIRE_EQUAL(ids[3], 1);
1277 for (
auto ii = 0; ii < 3; ++ii)
1279 ids[fps.front()->fragmentID()]++;
1280 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1281 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1282 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1285 TRACE_REQUIRE_EQUAL(ids[1], 1);
1286 TRACE_REQUIRE_EQUAL(ids[2], 1);
1287 TRACE_REQUIRE_EQUAL(ids[3], 1);
1292 fp.AddFragmentsToBuffer(gen.Generate(1));
1298 TRACE_REQUIRE_EQUAL(sts,
true);
1299 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1300 for (
auto ii = 0; ii < 3; ++ii)
1302 ids[fps.front()->fragmentID()]++;
1303 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1304 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1305 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1308 TRACE_REQUIRE_EQUAL(ids[1], 1);
1309 TRACE_REQUIRE_EQUAL(ids[2], 1);
1310 TRACE_REQUIRE_EQUAL(ids[3], 1);
1314 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1319 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1320 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1321 fhicl::ParameterSet ps;
1322 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1323 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1324 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1325 ps.put<std::string>(
"request_mode",
"buffer");
1327 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1328 buffer->setRunning(
true);
1334 fp.AddFragmentsToBuffer(gen.Generate(1));
1339 artdaq::FragmentPtrs fps;
1340 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1342 TRACE_REQUIRE_EQUAL(sts,
true);
1343 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1344 auto type = artdaq::Fragment::ContainerFragmentType;
1345 while (fps.size() > 0)
1347 ids[fps.front()->fragmentID()]++;
1348 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1349 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1350 type = artdaq::Fragment::ContainerFragmentType;
1351 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1352 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1353 auto cf = artdaq::ContainerFragment(*fps.front());
1354 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1355 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1356 type = artdaq::Fragment::FirstUserFragmentType;
1357 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1360 TRACE_REQUIRE_EQUAL(ids[1], 1);
1361 TRACE_REQUIRE_EQUAL(ids[2], 1);
1362 TRACE_REQUIRE_EQUAL(ids[3], 1);
1370 TRACE_REQUIRE_EQUAL(sts,
true);
1371 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1372 while (fps.size() > 0)
1374 ids[fps.front()->fragmentID()]++;
1375 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1376 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1377 type = artdaq::Fragment::ContainerFragmentType;
1378 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1379 auto cf = artdaq::ContainerFragment(*fps.front());
1380 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1381 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1382 type = artdaq::Fragment::EmptyFragmentType;
1383 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1386 TRACE_REQUIRE_EQUAL(ids[1], 1);
1387 TRACE_REQUIRE_EQUAL(ids[2], 1);
1388 TRACE_REQUIRE_EQUAL(ids[3], 1);
1393 fp.AddFragmentsToBuffer(gen.Generate(2));
1398 TRACE_REQUIRE_EQUAL(sts,
true);
1399 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1401 auto ts = artdaq::Fragment::InvalidTimestamp;
1402 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1403 for (
auto ii = 0; ii < 3; ++ii)
1405 ids[fps.front()->fragmentID()]++;
1406 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1407 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1408 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1409 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1412 TRACE_REQUIRE_EQUAL(ids[1], 1);
1413 TRACE_REQUIRE_EQUAL(ids[2], 1);
1414 TRACE_REQUIRE_EQUAL(ids[3], 1);
1416 for (
auto ii = 0; ii < 3; ++ii)
1418 ids[fps.front()->fragmentID()]++;
1419 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1420 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1421 type = artdaq::Fragment::ContainerFragmentType;
1422 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1423 auto cf3 = artdaq::ContainerFragment(*fps.front());
1424 TRACE_REQUIRE_EQUAL(cf3.block_count(), 2);
1425 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1426 type = artdaq::Fragment::FirstUserFragmentType;
1427 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1430 TRACE_REQUIRE_EQUAL(ids[1], 1);
1431 TRACE_REQUIRE_EQUAL(ids[2], 1);
1432 TRACE_REQUIRE_EQUAL(ids[3], 1);
1438 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1443 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1444 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1445 fhicl::ParameterSet ps;
1446 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1447 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1448 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1449 ps.put<
bool>(
"circular_buffer_mode",
true);
1450 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1451 ps.put<std::string>(
"request_mode",
"buffer");
1453 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1454 buffer->setRunning(
true);
1460 fp.AddFragmentsToBuffer(gen.Generate(1));
1465 artdaq::FragmentPtrs fps;
1466 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1468 auto type = artdaq::Fragment::ContainerFragmentType;
1469 TRACE_REQUIRE_EQUAL(sts,
true);
1470 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1471 while (fps.size() > 0)
1473 ids[fps.front()->fragmentID()]++;
1474 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1475 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1476 type = artdaq::Fragment::ContainerFragmentType;
1477 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1478 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1479 auto cf = artdaq::ContainerFragment(*fps.front());
1480 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1481 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1482 type = artdaq::Fragment::FirstUserFragmentType;
1483 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1486 TRACE_REQUIRE_EQUAL(ids[1], 1);
1487 TRACE_REQUIRE_EQUAL(ids[2], 1);
1488 TRACE_REQUIRE_EQUAL(ids[3], 1);
1497 TRACE_REQUIRE_EQUAL(sts,
true);
1498 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1499 while (fps.size() > 0)
1501 ids[fps.front()->fragmentID()]++;
1502 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1503 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1504 type = artdaq::Fragment::ContainerFragmentType;
1505 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1506 auto cf = artdaq::ContainerFragment(*fps.front());
1507 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1508 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1509 type = artdaq::Fragment::EmptyFragmentType;
1510 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1513 TRACE_REQUIRE_EQUAL(ids[1], 1);
1514 TRACE_REQUIRE_EQUAL(ids[2], 1);
1515 TRACE_REQUIRE_EQUAL(ids[3], 1);
1521 fp.AddFragmentsToBuffer(gen.Generate(3));
1526 TRACE_REQUIRE_EQUAL(sts,
true);
1527 TRACE_REQUIRE_EQUAL(fps.size(), 6);
1529 auto ts = artdaq::Fragment::InvalidTimestamp;
1530 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1531 for (
auto ii = 0; ii < 3; ++ii)
1533 ids[fps.front()->fragmentID()]++;
1534 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1535 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1536 TRACE_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1537 TRACE_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1540 TRACE_REQUIRE_EQUAL(ids[1], 1);
1541 TRACE_REQUIRE_EQUAL(ids[2], 1);
1542 TRACE_REQUIRE_EQUAL(ids[3], 1);
1544 for (
auto ii = 0; ii < 3; ++ii)
1546 ids[fps.front()->fragmentID()]++;
1547 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1548 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1549 type = artdaq::Fragment::ContainerFragmentType;
1550 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1551 auto cf3 = artdaq::ContainerFragment(*fps.front());
1552 TRACE_REQUIRE_EQUAL(cf3.block_count(), 3);
1553 TRACE_REQUIRE_EQUAL(cf3.missing_data(),
false);
1554 type = artdaq::Fragment::FirstUserFragmentType;
1555 TRACE_REQUIRE_EQUAL(cf3.fragment_type(), type);
1558 TRACE_REQUIRE_EQUAL(ids[1], 1);
1559 TRACE_REQUIRE_EQUAL(ids[2], 1);
1560 TRACE_REQUIRE_EQUAL(ids[3], 1);
1566 fp.AddFragmentsToBuffer(gen.Generate(5));
1571 TRACE_REQUIRE_EQUAL(sts,
true);
1572 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1573 while (fps.size() > 0)
1575 ids[fps.front()->fragmentID()]++;
1576 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1577 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1578 type = artdaq::Fragment::ContainerFragmentType;
1579 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1580 auto cf = artdaq::ContainerFragment(*fps.front());
1581 TRACE_REQUIRE_EQUAL(cf.block_count(), 3);
1582 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1583 type = artdaq::Fragment::FirstUserFragmentType;
1584 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1585 TRACE_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1586 TRACE_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1587 TRACE_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1590 TRACE_REQUIRE_EQUAL(ids[1], 1);
1591 TRACE_REQUIRE_EQUAL(ids[2], 1);
1592 TRACE_REQUIRE_EQUAL(ids[3], 1);
1598 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1603 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1604 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1605 fhicl::ParameterSet ps;
1606 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1607 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1608 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1609 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1610 ps.put<
bool>(
"circular_buffer_mode",
true);
1611 ps.put<std::string>(
"request_mode",
"window");
1612 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
1613 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1615 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1616 buffer->setRunning(
true);
1622 fp.AddFragmentsToBuffer(gen.Generate(1));
1627 artdaq::FragmentPtrs fps;
1628 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1630 auto type = artdaq::Fragment::ContainerFragmentType;
1632 TRACE_REQUIRE_EQUAL(sts,
true);
1633 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1634 while (fps.size() > 0)
1636 ids[fps.front()->fragmentID()]++;
1637 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1638 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1639 type = artdaq::Fragment::ContainerFragmentType;
1640 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1641 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1642 auto cf = artdaq::ContainerFragment(*fps.front());
1643 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1644 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1645 type = artdaq::Fragment::FirstUserFragmentType;
1646 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1649 TRACE_REQUIRE_EQUAL(ids[1], 1);
1650 TRACE_REQUIRE_EQUAL(ids[2], 1);
1651 TRACE_REQUIRE_EQUAL(ids[3], 1);
1660 TRACE_REQUIRE_EQUAL(sts,
true);
1661 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1663 fp.AddFragmentsToBuffer(gen.Generate(1));
1667 TRACE_REQUIRE_EQUAL(sts,
true);
1668 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1669 while (fps.size() > 0)
1671 ids[fps.front()->fragmentID()]++;
1672 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1673 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1674 type = artdaq::Fragment::ContainerFragmentType;
1675 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1676 auto cf = artdaq::ContainerFragment(*fps.front());
1677 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1678 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1679 type = artdaq::Fragment::FirstUserFragmentType;
1680 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1683 TRACE_REQUIRE_EQUAL(ids[1], 1);
1684 TRACE_REQUIRE_EQUAL(ids[2], 1);
1685 TRACE_REQUIRE_EQUAL(ids[3], 1);
1693 TRACE_REQUIRE_EQUAL(sts,
true);
1694 TRACE_REQUIRE_EQUAL(fps.size(), 0);
1699 TRACE_REQUIRE_EQUAL(sts,
true);
1700 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1704 TRACE_REQUIRE_EQUAL(list.size(), 1);
1705 TRACE_REQUIRE_EQUAL(list.begin()->first, 4);
1710 while (fps.size() > 0)
1712 ids[fps.front()->fragmentID()]++;
1713 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1714 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1715 type = artdaq::Fragment::ContainerFragmentType;
1716 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1717 auto cf = artdaq::ContainerFragment(*fps.front());
1718 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1719 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1720 type = artdaq::Fragment::EmptyFragmentType;
1721 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1724 TRACE_REQUIRE_EQUAL(ids[1], 1);
1725 TRACE_REQUIRE_EQUAL(ids[2], 1);
1726 TRACE_REQUIRE_EQUAL(ids[3], 1);
1733 fp.AddFragmentsToBuffer(gen.Generate(12));
1738 TRACE_REQUIRE_EQUAL(list.size(), 1);
1742 TRACE_REQUIRE_EQUAL(list.size(), 0);
1743 TRACE_REQUIRE_EQUAL(sts,
true);
1744 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1745 while (fps.size() > 0)
1747 ids[fps.front()->fragmentID()]++;
1748 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1749 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1750 type = artdaq::Fragment::ContainerFragmentType;
1751 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1752 auto cf = artdaq::ContainerFragment(*fps.front());
1753 TRACE_REQUIRE_EQUAL(cf.block_count(), 0);
1754 TRACE_REQUIRE_EQUAL(cf.missing_data(),
true);
1755 type = artdaq::Fragment::EmptyFragmentType;
1756 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1759 TRACE_REQUIRE_EQUAL(ids[1], 1);
1760 TRACE_REQUIRE_EQUAL(ids[2], 1);
1761 TRACE_REQUIRE_EQUAL(ids[3], 1);
1766 buffer->push(7, 13);
1769 TRACE_REQUIRE_EQUAL(sts,
true);
1770 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1771 while (fps.size() > 0)
1773 ids[fps.front()->fragmentID()]++;
1774 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
1775 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
1776 type = artdaq::Fragment::ContainerFragmentType;
1777 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1778 auto cf = artdaq::ContainerFragment(*fps.front());
1779 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1780 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1781 type = artdaq::Fragment::FirstUserFragmentType;
1782 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1785 TRACE_REQUIRE_EQUAL(ids[1], 1);
1786 TRACE_REQUIRE_EQUAL(ids[2], 1);
1787 TRACE_REQUIRE_EQUAL(ids[3], 1);
1793 TRACE_REQUIRE_EQUAL(list.size(), 1);
1794 TRACE_REQUIRE_EQUAL(list.begin()->first, 7);
1796 buffer->push(6, 12);
1799 TRACE_REQUIRE_EQUAL(sts,
true);
1800 TRACE_REQUIRE_EQUAL(fps.size(), 3);
1801 while (fps.size() > 0)
1803 ids[fps.front()->fragmentID()]++;
1804 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
1805 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1806 type = artdaq::Fragment::ContainerFragmentType;
1807 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1808 auto cf = artdaq::ContainerFragment(*fps.front());
1809 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1810 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1811 type = artdaq::Fragment::FirstUserFragmentType;
1812 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1815 TRACE_REQUIRE_EQUAL(ids[1], 1);
1816 TRACE_REQUIRE_EQUAL(ids[2], 1);
1817 TRACE_REQUIRE_EQUAL(ids[3], 1);
1823 TRACE_REQUIRE_EQUAL(list.size(), 0);
1825 fp.AddFragmentsToBuffer(gen.Generate(1, {1, 2}));
1828 buffer->push(8, 15);
1830 sts = fp.applyRequests(fps);
1831 TRACE_REQUIRE_EQUAL(sts,
true);
1832 TRACE_REQUIRE_EQUAL(fps.size(), 2);
1833 while (fps.size() > 0)
1835 ids[fps.front()->fragmentID()]++;
1836 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1837 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1838 type = artdaq::Fragment::ContainerFragmentType;
1839 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1840 auto cf = artdaq::ContainerFragment(*fps.front());
1841 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1842 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1843 type = artdaq::Fragment::FirstUserFragmentType;
1844 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1847 TRACE_REQUIRE_EQUAL(ids[1], 1);
1848 TRACE_REQUIRE_EQUAL(ids[2], 1);
1849 TRACE_REQUIRE_EQUAL(ids[3], 0);
1852 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 8);
1854 gen.setTimestamp(14);
1855 fp.AddFragmentsToBuffer(gen.Generate(1, {3}));
1858 sts = fp.applyRequests(fps);
1859 TRACE_REQUIRE_EQUAL(sts,
true);
1860 TRACE_REQUIRE_EQUAL(fps.size(), 1);
1861 while (fps.size() > 0)
1863 ids[fps.front()->fragmentID()]++;
1864 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
1865 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
1866 type = artdaq::Fragment::ContainerFragmentType;
1867 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1868 auto cf = artdaq::ContainerFragment(*fps.front());
1869 TRACE_REQUIRE_EQUAL(cf.block_count(), 1);
1870 TRACE_REQUIRE_EQUAL(cf.missing_data(),
false);
1871 type = artdaq::Fragment::FirstUserFragmentType;
1872 TRACE_REQUIRE_EQUAL(cf.fragment_type(), type);
1875 TRACE_REQUIRE_EQUAL(ids[1], 0);
1876 TRACE_REQUIRE_EQUAL(ids[2], 0);
1877 TRACE_REQUIRE_EQUAL(ids[3], 1);
1880 TRACE_REQUIRE_EQUAL(fp.GetNextSequenceID(), 9);
1882 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
1887 artdaq::configureMessageFacility(
"FragmentBuffer_t",
true, MESSAGEFACILITY_DEBUG);
1888 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case BEGIN";
1889 fhicl::ParameterSet ps;
1890 ps.put<
int>(
"board_id", 1);
1891 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1892 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1893 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1894 ps.put<
bool>(
"separate_data_thread",
true);
1895 ps.put<
bool>(
"separate_monitoring_thread",
false);
1896 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1897 ps.put<std::string>(
"request_mode",
"SequenceID");
1899 auto buffer = std::make_shared<artdaq::RequestBuffer>();
1900 buffer->setRunning(
true);
1906 fp.AddFragmentsToBuffer(gen.Generate(1));
1912 artdaq::FragmentPtrs fps;
1913 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1915 auto type = artdaq::Fragment::FirstUserFragmentType;
1916 TRACE_REQUIRE_EQUAL(sts,
true);
1917 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1919 for (
auto ii = 0; ii < 3; ++ii)
1921 ids[fps.front()->fragmentID()]++;
1922 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1923 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1924 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1927 TRACE_REQUIRE_EQUAL(ids[1], 1);
1928 TRACE_REQUIRE_EQUAL(ids[2], 1);
1929 TRACE_REQUIRE_EQUAL(ids[3], 1);
1939 TRACE_REQUIRE_EQUAL(sts,
true);
1940 TRACE_REQUIRE_EQUAL(fps.size(), 0u);
1943 fp.AddFragmentsToBuffer(gen.Generate(1));
1946 TRACE_REQUIRE_EQUAL(sts,
true);
1947 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1948 for (
auto ii = 0; ii < 3; ++ii)
1950 ids[fps.front()->fragmentID()]++;
1951 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1952 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1953 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1956 TRACE_REQUIRE_EQUAL(ids[1], 1);
1957 TRACE_REQUIRE_EQUAL(ids[2], 1);
1958 TRACE_REQUIRE_EQUAL(ids[3], 1);
1965 fp.AddFragmentsToBuffer(gen.Generate(2));
1971 TRACE_REQUIRE_EQUAL(sts,
true);
1972 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1973 for (
auto ii = 0; ii < 3; ++ii)
1975 ids[fps.front()->fragmentID()]++;
1976 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
1977 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1978 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
1981 TRACE_REQUIRE_EQUAL(ids[1], 1);
1982 TRACE_REQUIRE_EQUAL(ids[2], 1);
1983 TRACE_REQUIRE_EQUAL(ids[3], 1);
1991 TRACE_REQUIRE_EQUAL(sts,
true);
1992 TRACE_REQUIRE_EQUAL(fps.size(), 3u);
1993 for (
auto ii = 0; ii < 3; ++ii)
1995 ids[fps.front()->fragmentID()]++;
1996 TRACE_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1997 TRACE_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1998 TRACE_REQUIRE_EQUAL(fps.front()->type(), type);
2001 TRACE_REQUIRE_EQUAL(ids[1], 1);
2002 TRACE_REQUIRE_EQUAL(ids[2], 1);
2003 TRACE_REQUIRE_EQUAL(ids[3], 1);
2006 TLOG(TLVL_INFO) <<
"SequenceIDMode_MultipleIDs test case END";
2008 BOOST_AUTO_TEST_SUITE_END()
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.
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.