1 #define TRACE_NAME "CommandableFragmentGenerator_t"
3 #define BOOST_TEST_MODULE CommandableFragmentGenerator_t
4 #include <boost/test/auto_unit_test.hpp>
6 #include "artdaq-core/Data/ContainerFragment.hh"
7 #include "artdaq-core/Data/Fragment.hh"
8 #include "artdaq/DAQrate/RequestSender.hh"
9 #include "artdaq/Generators/CommandableFragmentGenerator.hh"
11 #define MULTICAST_MODE 0
13 namespace artdaqtest {
14 class CommandableFragmentGeneratorTest;
38 bool getNext_(artdaq::FragmentPtrs& frags)
override;
49 void start()
override;
64 void pause()
override;
109 auto start_time = std::chrono::steady_clock::now();
110 while (fireCount_ > 0) { usleep(1000); }
111 TLOG(TLVL_INFO) <<
"Waited " << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start_time).count() <<
" us for events to be picked up by CFG";
115 std::atomic<size_t> fireCount_;
116 std::atomic<bool> hwFail_;
117 artdaq::Fragment::timestamp_t ts_;
118 std::atomic<bool> hw_stop_;
119 std::atomic<uint64_t> enabled_ids_;
123 : CommandableFragmentGenerator(ps)
130 metricMan->initialize(ps.get<fhicl::ParameterSet>(
"metrics", fhicl::ParameterSet()));
131 metricMan->do_start();
136 while (fireCount_ > 0)
139 for (
auto&
id : fragmentIDs())
141 if (
id < 64 && ((enabled_ids_ & (0x1 <<
id)) != 0))
143 frags.emplace_back(
new artdaq::Fragment(ev_counter(),
id, artdaq::Fragment::FirstUserFragmentType, ts_));
163 BOOST_AUTO_TEST_SUITE(CommandableFragmentGenerator_t)
167 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
168 TLOG(TLVL_INFO) <<
"Simple test case BEGIN";
169 fhicl::ParameterSet ps;
170 ps.put<
int>(
"board_id", 1);
171 ps.put<
int>(
"fragment_id", 1);
173 artdaq::FragmentPtrs fps;
174 auto sts = testGen.getNext(fps);
175 BOOST_REQUIRE_EQUAL(sts,
true);
176 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
177 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
178 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
179 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
180 TLOG(TLVL_INFO) <<
"Simple test case END";
185 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
186 TLOG(TLVL_INFO) <<
"IgnoreRequests test case BEGIN";
187 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
188 const int DELAY_TIME = 1;
189 fhicl::ParameterSet ps;
190 ps.put<
int>(
"board_id", 1);
191 ps.put<
int>(
"fragment_id", 1);
192 ps.put<
int>(
"request_port", REQUEST_PORT);
194 ps.put<std::string>(
"request_address",
"227.18.12.29");
196 ps.put<std::string>(
"request_address",
"localhost");
198 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
199 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
200 ps.put<
bool>(
"separate_data_thread",
true);
201 ps.put<
bool>(
"separate_monitoring_thread",
false);
202 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
203 ps.put<std::string>(
"request_mode",
"ignored");
204 ps.put(
"request_delay_ms", DELAY_TIME);
205 ps.put(
"send_requests",
true);
213 artdaq::FragmentPtrs fps;
215 BOOST_REQUIRE_EQUAL(sts,
true);
216 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
217 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
218 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
219 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
222 TLOG(TLVL_INFO) <<
"IgnoreRequests test case END";
227 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
228 TLOG(TLVL_INFO) <<
"SingleMode test case BEGIN";
229 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
230 const int DELAY_TIME = 100;
231 fhicl::ParameterSet ps;
232 ps.put<
int>(
"board_id", 1);
233 ps.put<
int>(
"fragment_id", 1);
234 ps.put<
int>(
"request_port", REQUEST_PORT);
236 ps.put<std::string>(
"request_address",
"227.18.12.30");
238 ps.put<std::string>(
"request_address",
"localhost");
240 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
241 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
242 ps.put<
bool>(
"separate_data_thread",
true);
243 ps.put<
bool>(
"separate_monitoring_thread",
false);
244 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
245 ps.put<std::string>(
"request_mode",
"single");
246 ps.put(
"request_delay_ms", DELAY_TIME);
247 ps.put(
"send_requests",
true);
258 artdaq::FragmentPtrs fps;
260 auto type = artdaq::Fragment::FirstUserFragmentType;
261 BOOST_REQUIRE_EQUAL(sts,
true);
262 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
263 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
264 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
265 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
266 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
272 BOOST_REQUIRE_EQUAL(sts,
true);
273 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
274 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
275 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
276 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
277 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
286 BOOST_REQUIRE_EQUAL(sts,
true);
287 BOOST_REQUIRE_EQUAL(fps.size(), 2);
288 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
289 auto ts = artdaq::Fragment::InvalidTimestamp;
290 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
291 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
292 auto emptyType = artdaq::Fragment::EmptyFragmentType;
293 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
295 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
296 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
297 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
298 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
303 TLOG(TLVL_INFO) <<
"SingleMode test case END";
308 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
309 TLOG(TLVL_INFO) <<
"BufferMode test case BEGIN";
310 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
311 const int DELAY_TIME = 100;
312 fhicl::ParameterSet ps;
313 ps.put<
int>(
"board_id", 1);
314 ps.put<
int>(
"fragment_id", 1);
315 ps.put<
int>(
"request_port", REQUEST_PORT);
317 ps.put<std::string>(
"request_address",
"227.18.12.31");
319 ps.put<std::string>(
"request_address",
"localhost");
321 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
322 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
323 ps.put<
bool>(
"separate_data_thread",
true);
324 ps.put<
bool>(
"separate_monitoring_thread",
false);
325 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
326 ps.put<std::string>(
"request_mode",
"buffer");
327 ps.put(
"request_delay_ms", DELAY_TIME);
328 ps.put(
"send_requests",
true);
339 artdaq::FragmentPtrs fps;
341 BOOST_REQUIRE_EQUAL(sts,
true);
342 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
343 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
344 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
345 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
346 auto type = artdaq::Fragment::ContainerFragmentType;
347 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
348 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
349 auto cf = artdaq::ContainerFragment(*fps.front());
350 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
351 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
352 type = artdaq::Fragment::FirstUserFragmentType;
353 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
359 BOOST_REQUIRE_EQUAL(sts,
true);
360 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
361 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
362 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
363 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
364 type = artdaq::Fragment::ContainerFragmentType;
365 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
366 auto cf2 = artdaq::ContainerFragment(*fps.front());
367 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
368 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
369 type = artdaq::Fragment::EmptyFragmentType;
370 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
378 BOOST_REQUIRE_EQUAL(sts,
true);
379 BOOST_REQUIRE_EQUAL(fps.size(), 2);
381 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
382 auto ts = artdaq::Fragment::InvalidTimestamp;
383 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
384 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
385 auto emptyType = artdaq::Fragment::EmptyFragmentType;
386 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
387 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
389 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
390 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
391 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
392 type = artdaq::Fragment::ContainerFragmentType;
393 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
394 auto cf3 = artdaq::ContainerFragment(*fps.front());
395 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
396 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
397 type = artdaq::Fragment::FirstUserFragmentType;
398 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
405 TLOG(TLVL_INFO) <<
"BufferMode test case END";
410 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
411 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case BEGIN";
412 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
413 const int DELAY_TIME = 100;
414 fhicl::ParameterSet ps;
415 ps.put<
int>(
"board_id", 1);
416 ps.put<
int>(
"fragment_id", 1);
417 ps.put<
int>(
"request_port", REQUEST_PORT);
419 ps.put<std::string>(
"request_address",
"227.18.12.31");
421 ps.put<std::string>(
"request_address",
"localhost");
423 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
424 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
425 ps.put<
bool>(
"separate_data_thread",
true);
426 ps.put<
bool>(
"separate_monitoring_thread",
false);
427 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
428 ps.put<std::string>(
"request_mode",
"buffer");
429 ps.put(
"request_delay_ms", DELAY_TIME);
430 ps.put(
"send_requests",
true);
431 ps.put(
"buffer_mode_keep_latest",
true);
442 artdaq::FragmentPtrs fps;
444 BOOST_REQUIRE_EQUAL(sts,
true);
445 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
446 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
447 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
448 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
449 auto type = artdaq::Fragment::ContainerFragmentType;
450 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
451 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
452 auto cf = artdaq::ContainerFragment(*fps.front());
453 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
454 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
455 type = artdaq::Fragment::FirstUserFragmentType;
456 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
462 BOOST_REQUIRE_EQUAL(sts,
true);
463 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
464 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
465 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
466 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
467 type = artdaq::Fragment::ContainerFragmentType;
468 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
469 auto cf2 = artdaq::ContainerFragment(*fps.front());
470 BOOST_REQUIRE_EQUAL(cf2.block_count(), 1);
471 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
472 type = artdaq::Fragment::FirstUserFragmentType;
473 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
481 BOOST_REQUIRE_EQUAL(sts,
true);
482 BOOST_REQUIRE_EQUAL(fps.size(), 2);
484 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
485 auto ts = artdaq::Fragment::InvalidTimestamp;
486 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
487 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
488 auto emptyType = artdaq::Fragment::EmptyFragmentType;
489 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
490 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
492 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
493 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
494 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
495 type = artdaq::Fragment::ContainerFragmentType;
496 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
497 auto cf3 = artdaq::ContainerFragment(*fps.front());
498 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
499 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
500 type = artdaq::Fragment::FirstUserFragmentType;
501 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
508 TLOG(TLVL_INFO) <<
"BufferMode_KeepLatest test case END";
512 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
513 TLOG(TLVL_INFO) <<
"CircularBufferMode test case BEGIN";
514 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
515 const int DELAY_TIME = 100;
516 fhicl::ParameterSet ps;
517 ps.put<
int>(
"board_id", 1);
518 ps.put<
int>(
"fragment_id", 1);
519 ps.put<
int>(
"request_port", REQUEST_PORT);
521 ps.put<std::string>(
"request_address",
"227.18.12.31");
523 ps.put<std::string>(
"request_address",
"localhost");
525 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
526 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
527 ps.put<
bool>(
"separate_data_thread",
true);
528 ps.put<
bool>(
"circular_buffer_mode",
true);
529 ps.put<
int>(
"data_buffer_depth_fragments", 3);
530 ps.put<
bool>(
"separate_monitoring_thread",
false);
531 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
532 ps.put<std::string>(
"request_mode",
"buffer");
533 ps.put(
"request_delay_ms", DELAY_TIME);
534 ps.put(
"send_requests",
true);
545 artdaq::FragmentPtrs fps;
547 BOOST_REQUIRE_EQUAL(sts,
true);
548 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
549 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
550 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
551 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
552 auto type = artdaq::Fragment::ContainerFragmentType;
553 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
554 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
555 auto cf = artdaq::ContainerFragment(*fps.front());
556 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
557 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
558 type = artdaq::Fragment::FirstUserFragmentType;
559 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
565 BOOST_REQUIRE_EQUAL(sts,
true);
566 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
567 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
568 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
569 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
570 type = artdaq::Fragment::ContainerFragmentType;
571 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
572 auto cf2 = artdaq::ContainerFragment(*fps.front());
573 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
574 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
575 type = artdaq::Fragment::EmptyFragmentType;
576 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
584 BOOST_REQUIRE_EQUAL(sts,
true);
585 BOOST_REQUIRE_EQUAL(fps.size(), 2);
587 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
588 auto ts = artdaq::Fragment::InvalidTimestamp;
589 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
590 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
591 auto emptyType = artdaq::Fragment::EmptyFragmentType;
592 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
593 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
595 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
596 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
597 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
598 type = artdaq::Fragment::ContainerFragmentType;
599 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
600 auto cf3 = artdaq::ContainerFragment(*fps.front());
601 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
602 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
603 type = artdaq::Fragment::FirstUserFragmentType;
604 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
612 BOOST_REQUIRE_EQUAL(sts,
true);
613 BOOST_REQUIRE_EQUAL(fps.size(), 1);
615 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
616 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
617 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
618 type = artdaq::Fragment::ContainerFragmentType;
619 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
620 auto cf4 = artdaq::ContainerFragment(*fps.front());
621 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
622 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
623 type = artdaq::Fragment::FirstUserFragmentType;
624 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
625 BOOST_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
626 BOOST_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
627 BOOST_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
634 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
639 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
640 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
641 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
642 const int DELAY_TIME = 100;
643 fhicl::ParameterSet ps;
644 ps.put<
int>(
"board_id", 1);
645 ps.put<
int>(
"fragment_id", 1);
646 ps.put<
int>(
"request_port", REQUEST_PORT);
648 ps.put<std::string>(
"request_address",
"227.18.12.32");
650 ps.put<std::string>(
"request_address",
"localhost");
652 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
653 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
654 ps.put<
bool>(
"separate_data_thread",
true);
655 ps.put<
bool>(
"separate_monitoring_thread",
false);
656 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
657 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
658 ps.put<
bool>(
"circular_buffer_mode",
true);
659 ps.put<std::string>(
"request_mode",
"window");
660 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
661 ps.put<
size_t>(
"window_close_timeout_us", 500000);
662 ps.put(
"request_delay_ms", DELAY_TIME);
663 ps.put(
"send_requests",
true);
674 artdaq::FragmentPtrs fps;
677 BOOST_REQUIRE_EQUAL(sts,
true);
678 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
679 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
680 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
681 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
682 auto type = artdaq::Fragment::ContainerFragmentType;
683 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
684 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
685 auto cf = artdaq::ContainerFragment(*fps.front());
686 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
687 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
688 type = artdaq::Fragment::FirstUserFragmentType;
689 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
696 BOOST_REQUIRE_EQUAL(sts,
true);
697 BOOST_REQUIRE_EQUAL(fps.size(), 0);
703 BOOST_REQUIRE_EQUAL(sts,
true);
704 BOOST_REQUIRE_EQUAL(fps.size(), 1);
705 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
706 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
707 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
708 type = artdaq::Fragment::ContainerFragmentType;
709 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
710 auto cf2 = artdaq::ContainerFragment(*fps.front());
711 BOOST_REQUIRE_EQUAL(cf2.block_count(), 1);
712 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
713 type = artdaq::Fragment::FirstUserFragmentType;
714 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
720 BOOST_REQUIRE_EQUAL(sts,
true);
721 BOOST_REQUIRE_EQUAL(fps.size(), 0);
726 BOOST_REQUIRE_EQUAL(sts,
true);
727 BOOST_REQUIRE_EQUAL(fps.size(), 1);
731 BOOST_REQUIRE_EQUAL(list.size(), 1);
732 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
737 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
738 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
739 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
740 type = artdaq::Fragment::ContainerFragmentType;
741 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
742 auto cf3 = artdaq::ContainerFragment(*fps.front());
743 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
744 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
true);
745 type = artdaq::Fragment::EmptyFragmentType;
746 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
755 BOOST_REQUIRE_EQUAL(list.size(), 1);
759 BOOST_REQUIRE_EQUAL(list.size(), 0);
760 BOOST_REQUIRE_EQUAL(sts,
true);
761 BOOST_REQUIRE_EQUAL(fps.size(), 1);
762 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
763 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
764 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
765 type = artdaq::Fragment::ContainerFragmentType;
766 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
767 auto cf4 = artdaq::ContainerFragment(*fps.front());
768 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
769 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
770 type = artdaq::Fragment::EmptyFragmentType;
771 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
777 BOOST_REQUIRE_EQUAL(sts,
true);
778 BOOST_REQUIRE_EQUAL(fps.size(), 1);
779 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
780 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
781 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
782 type = artdaq::Fragment::ContainerFragmentType;
783 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
784 auto cf5 = artdaq::ContainerFragment(*fps.front());
785 BOOST_REQUIRE_EQUAL(cf5.block_count(), 1);
786 BOOST_REQUIRE_EQUAL(cf5.missing_data(),
false);
787 type = artdaq::Fragment::FirstUserFragmentType;
788 BOOST_REQUIRE_EQUAL(cf5.fragment_type(), type);
793 BOOST_REQUIRE_EQUAL(list.size(), 1);
794 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
798 BOOST_REQUIRE_EQUAL(sts,
true);
799 BOOST_REQUIRE_EQUAL(fps.size(), 1);
800 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
801 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
802 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
803 type = artdaq::Fragment::ContainerFragmentType;
804 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
805 auto cf6 = artdaq::ContainerFragment(*fps.front());
806 BOOST_REQUIRE_EQUAL(cf6.block_count(), 1);
807 BOOST_REQUIRE_EQUAL(cf6.missing_data(),
false);
808 type = artdaq::Fragment::FirstUserFragmentType;
809 BOOST_REQUIRE_EQUAL(cf6.fragment_type(), type);
814 BOOST_REQUIRE_EQUAL(list.size(), 0);
819 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
831 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
832 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
833 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
834 const int DELAY_TIME = 100;
835 fhicl::ParameterSet ps;
836 ps.put<
int>(
"board_id", 1);
837 ps.put<
int>(
"fragment_id", 1);
838 ps.put<
int>(
"request_port", REQUEST_PORT);
840 ps.put<std::string>(
"request_address",
"227.18.12.32");
842 ps.put<std::string>(
"request_address",
"localhost");
844 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
845 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
846 ps.put<
bool>(
"separate_data_thread",
true);
847 ps.put<
bool>(
"separate_monitoring_thread",
false);
848 ps.put<
bool>(
"circular_buffer_mode",
true);
849 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
850 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
851 ps.put<std::string>(
"request_mode",
"window");
852 ps.put(
"request_delay_ms", DELAY_TIME);
853 ps.put(
"send_requests",
true);
862 artdaq::FragmentPtrs fps;
864 artdaq::Fragment::type_t type;
873 BOOST_REQUIRE_EQUAL(sts,
true);
874 BOOST_REQUIRE_EQUAL(fps.size(), 1);
875 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
876 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
877 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
878 type = artdaq::Fragment::ContainerFragmentType;
879 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
880 auto cf4 = artdaq::ContainerFragment(*fps.front());
881 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
882 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
883 type = artdaq::Fragment::EmptyFragmentType;
884 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
887 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
891 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
892 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
893 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
894 const int DELAY_TIME = 100;
895 fhicl::ParameterSet ps;
896 ps.put<
int>(
"board_id", 1);
897 ps.put<
int>(
"fragment_id", 1);
898 ps.put<
int>(
"request_port", REQUEST_PORT);
900 ps.put<std::string>(
"request_address",
"227.18.12.32");
902 ps.put<std::string>(
"request_address",
"localhost");
904 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
905 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
906 ps.put<
bool>(
"separate_data_thread",
true);
907 ps.put<
bool>(
"separate_monitoring_thread",
false);
908 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
909 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
910 ps.put<
bool>(
"circular_buffer_mode",
true);
911 ps.put<std::string>(
"request_mode",
"window");
912 ps.put(
"request_delay_ms", DELAY_TIME);
913 ps.put(
"send_requests",
true);
922 artdaq::FragmentPtrs fps;
924 artdaq::Fragment::type_t type;
935 BOOST_REQUIRE_EQUAL(sts,
true);
936 BOOST_REQUIRE_EQUAL(fps.size(), 1);
937 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
938 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
939 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
940 type = artdaq::Fragment::ContainerFragmentType;
941 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
942 auto cf4 = artdaq::ContainerFragment(*fps.front());
943 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
944 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
945 type = artdaq::Fragment::FirstUserFragmentType;
946 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
950 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case END";
954 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
955 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case BEGIN";
956 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
957 const int DELAY_TIME = 100;
958 fhicl::ParameterSet ps;
959 ps.put<
int>(
"board_id", 1);
960 ps.put<
int>(
"fragment_id", 1);
961 ps.put<
int>(
"request_port", REQUEST_PORT);
963 ps.put<std::string>(
"request_address",
"227.18.12.32");
965 ps.put<std::string>(
"request_address",
"localhost");
967 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
968 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 4);
969 ps.put<
size_t>(
"window_close_timeout_us", 500000);
970 ps.put<
bool>(
"separate_data_thread",
true);
971 ps.put<
bool>(
"separate_monitoring_thread",
false);
972 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
973 ps.put<
bool>(
"circular_buffer_mode",
true);
974 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
975 ps.put<std::string>(
"request_mode",
"window");
976 ps.put(
"request_delay_ms", DELAY_TIME);
977 ps.put(
"send_requests",
true);
986 artdaq::FragmentPtrs fps;
988 artdaq::Fragment::type_t type;
999 BOOST_REQUIRE_EQUAL(sts,
true);
1000 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1001 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1002 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
1003 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1004 type = artdaq::Fragment::ContainerFragmentType;
1005 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1006 auto cf = artdaq::ContainerFragment(*fps.front());
1007 BOOST_REQUIRE_EQUAL(cf.block_count(), 4);
1008 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1009 type = artdaq::Fragment::FirstUserFragmentType;
1010 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1015 BOOST_REQUIRE_EQUAL(sts,
true);
1016 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1022 BOOST_REQUIRE_EQUAL(sts,
true);
1023 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1024 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1025 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1026 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1027 type = artdaq::Fragment::ContainerFragmentType;
1028 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1029 auto cf2 = artdaq::ContainerFragment(*fps.front());
1030 BOOST_REQUIRE_EQUAL(cf2.block_count(), 3);
1031 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
true);
1032 type = artdaq::Fragment::FirstUserFragmentType;
1033 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
1039 BOOST_REQUIRE_EQUAL(sts,
true);
1040 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1045 BOOST_REQUIRE_EQUAL(sts,
true);
1046 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1047 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1048 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
1049 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1050 type = artdaq::Fragment::ContainerFragmentType;
1051 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1052 auto cf4 = artdaq::ContainerFragment(*fps.front());
1053 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
1054 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1055 type = artdaq::Fragment::FirstUserFragmentType;
1056 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1060 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
1064 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1065 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
1066 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1067 const int DELAY_TIME = 100;
1068 fhicl::ParameterSet ps;
1069 ps.put<
int>(
"board_id", 1);
1070 ps.put<
int>(
"fragment_id", 1);
1071 ps.put<
int>(
"request_port", REQUEST_PORT);
1073 ps.put<std::string>(
"request_address",
"227.18.12.32");
1075 ps.put<std::string>(
"request_address",
"localhost");
1077 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1078 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1079 ps.put<
bool>(
"separate_data_thread",
true);
1080 ps.put<
bool>(
"separate_monitoring_thread",
false);
1081 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1082 ps.put<
bool>(
"circular_buffer_mode",
true);
1083 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1084 ps.put<std::string>(
"request_mode",
"window");
1085 ps.put(
"request_delay_ms", DELAY_TIME);
1086 ps.put(
"send_requests",
true);
1094 artdaq::FragmentPtrs fps;
1096 artdaq::Fragment::type_t type;
1106 BOOST_REQUIRE_EQUAL(sts,
true);
1107 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1108 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1109 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1110 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1111 type = artdaq::Fragment::ContainerFragmentType;
1112 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1113 auto cf4 = artdaq::ContainerFragment(*fps.front());
1114 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
1115 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
1116 type = artdaq::Fragment::FirstUserFragmentType;
1117 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1120 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
1124 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1125 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
1126 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1127 const int DELAY_TIME = 100;
1128 fhicl::ParameterSet ps;
1129 ps.put<
int>(
"board_id", 1);
1130 ps.put<
int>(
"fragment_id", 1);
1131 ps.put<
int>(
"request_port", REQUEST_PORT);
1133 ps.put<std::string>(
"request_address",
"227.18.12.32");
1135 ps.put<std::string>(
"request_address",
"localhost");
1137 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1138 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1139 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1140 ps.put<
bool>(
"separate_data_thread",
true);
1141 ps.put<
bool>(
"separate_monitoring_thread",
false);
1142 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1143 ps.put<
bool>(
"circular_buffer_mode",
true);
1144 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1145 ps.put<std::string>(
"request_mode",
"window");
1146 ps.put(
"request_delay_ms", DELAY_TIME);
1147 ps.put(
"send_requests",
true);
1155 artdaq::FragmentPtrs fps;
1157 artdaq::Fragment::type_t type;
1166 BOOST_REQUIRE_EQUAL(sts,
true);
1167 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1172 BOOST_REQUIRE_EQUAL(sts,
true);
1173 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1174 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1175 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1176 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1177 type = artdaq::Fragment::ContainerFragmentType;
1178 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1179 auto cf = artdaq::ContainerFragment(*fps.front());
1180 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1181 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1182 type = artdaq::Fragment::FirstUserFragmentType;
1183 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1189 BOOST_REQUIRE_EQUAL(sts,
true);
1190 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1195 BOOST_REQUIRE_EQUAL(sts,
true);
1196 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1197 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1198 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1199 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1200 type = artdaq::Fragment::ContainerFragmentType;
1201 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1202 auto cf4 = artdaq::ContainerFragment(*fps.front());
1203 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
1204 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1205 type = artdaq::Fragment::FirstUserFragmentType;
1206 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1210 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
1214 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1215 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
1216 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1217 const int DELAY_TIME = 100;
1218 fhicl::ParameterSet ps;
1219 ps.put<
int>(
"board_id", 1);
1220 ps.put<
int>(
"fragment_id", 1);
1221 ps.put<
int>(
"request_port", REQUEST_PORT);
1223 ps.put<std::string>(
"request_address",
"227.18.12.32");
1225 ps.put<std::string>(
"request_address",
"localhost");
1227 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1228 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1229 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1230 ps.put<
bool>(
"separate_data_thread",
true);
1231 ps.put<
bool>(
"separate_monitoring_thread",
false);
1232 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1233 ps.put<
bool>(
"circular_buffer_mode",
true);
1234 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1235 ps.put<std::string>(
"request_mode",
"window");
1236 ps.put(
"request_delay_ms", DELAY_TIME);
1237 ps.put(
"send_requests",
true);
1245 artdaq::FragmentPtrs fps;
1247 artdaq::Fragment::type_t type;
1257 BOOST_REQUIRE_EQUAL(sts,
true);
1258 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1262 BOOST_REQUIRE_EQUAL(sts,
true);
1263 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1268 BOOST_REQUIRE_EQUAL(sts,
true);
1269 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1270 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1271 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1272 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1273 type = artdaq::Fragment::ContainerFragmentType;
1274 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1275 auto cf = artdaq::ContainerFragment(*fps.front());
1276 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1277 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1278 type = artdaq::Fragment::FirstUserFragmentType;
1279 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1284 BOOST_REQUIRE_EQUAL(sts,
true);
1285 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1290 BOOST_REQUIRE_EQUAL(sts,
true);
1291 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1292 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1293 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
1294 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1295 type = artdaq::Fragment::ContainerFragmentType;
1296 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1297 auto cf4 = artdaq::ContainerFragment(*fps.front());
1298 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
1299 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1300 type = artdaq::Fragment::EmptyFragmentType;
1301 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1305 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1310 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1311 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case BEGIN";
1312 fhicl::ParameterSet ps;
1313 ps.put<
int>(
"board_id", 1);
1314 ps.put<
int>(
"fragment_id", 1);
1315 ps.put<
bool>(
"separate_data_thread",
false);
1316 ps.put<
bool>(
"separate_monitoring_thread",
false);
1317 ps.put<int64_t>(
"hardware_poll_interval_us", 10);
1320 gen.StartCmd(1, 0xFFFFFFFF, 1);
1322 artdaq::FragmentPtrs fps;
1323 auto sts = gen.getNext(fps);
1324 BOOST_REQUIRE_EQUAL(sts,
true);
1325 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1326 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1327 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1328 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1331 gen.setFireCount(1);
1334 sts = gen.getNext(fps);
1335 BOOST_REQUIRE_EQUAL(sts,
false);
1336 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1338 gen.StopCmd(0xFFFFFFFF, 1);
1340 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case END";
1345 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1346 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case BEGIN";
1347 fhicl::ParameterSet ps;
1348 ps.put<
int>(
"board_id", 1);
1349 ps.put<
int>(
"fragment_id", 1);
1350 ps.put<
bool>(
"separate_data_thread",
true);
1351 ps.put<
bool>(
"separate_monitoring_thread",
true);
1352 ps.put<int64_t>(
"hardware_poll_interval_us", 750000);
1355 gen.StartCmd(1, 0xFFFFFFFF, 1);
1358 artdaq::FragmentPtrs fps;
1359 auto sts = gen.getNext(fps);
1360 BOOST_REQUIRE_EQUAL(sts,
true);
1361 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1362 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1363 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1364 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1379 gen.setFireCount(1);
1380 sts = gen.getNext(fps);
1381 BOOST_REQUIRE_EQUAL(sts,
false);
1382 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1384 gen.StopCmd(0xFFFFFFFF, 1);
1386 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case END";
1391 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1392 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1393 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1394 const int DELAY_TIME = 1;
1395 fhicl::ParameterSet ps;
1396 ps.put<
int>(
"board_id", 1);
1397 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1398 ps.put<
int>(
"request_port", REQUEST_PORT);
1400 ps.put<std::string>(
"request_address",
"227.18.12.29");
1402 ps.put<std::string>(
"request_address",
"localhost");
1404 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1405 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1406 ps.put<
bool>(
"separate_data_thread",
true);
1407 ps.put<
bool>(
"separate_monitoring_thread",
false);
1408 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1409 ps.put<std::string>(
"request_mode",
"ignored");
1410 ps.put(
"request_delay_ms", DELAY_TIME);
1411 ps.put(
"send_requests",
true);
1419 artdaq::FragmentPtrs fps;
1420 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1422 BOOST_REQUIRE_EQUAL(sts,
true);
1423 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1424 while (fps.size() > 0)
1426 ids[fps.front()->fragmentID()]++;
1427 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1428 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1432 BOOST_REQUIRE_EQUAL(ids[1], 1);
1433 BOOST_REQUIRE_EQUAL(ids[2], 1);
1434 BOOST_REQUIRE_EQUAL(ids[3], 1);
1443 BOOST_REQUIRE_EQUAL(sts,
true);
1444 BOOST_REQUIRE_EQUAL(fps.size(), 2u);
1445 while (fps.size() > 0)
1447 ids[fps.front()->fragmentID()]++;
1448 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1449 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1452 BOOST_REQUIRE_EQUAL(ids[1], 1);
1453 BOOST_REQUIRE_EQUAL(ids[2], 1);
1457 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1462 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1463 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1464 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1465 const int DELAY_TIME = 100;
1466 fhicl::ParameterSet ps;
1467 ps.put<
int>(
"board_id", 1);
1468 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1469 ps.put<
int>(
"request_port", REQUEST_PORT);
1471 ps.put<std::string>(
"request_address",
"227.18.12.30");
1473 ps.put<std::string>(
"request_address",
"localhost");
1475 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1476 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1477 ps.put<
bool>(
"separate_data_thread",
true);
1478 ps.put<
bool>(
"separate_monitoring_thread",
false);
1479 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1480 ps.put<std::string>(
"request_mode",
"single");
1481 ps.put(
"request_delay_ms", DELAY_TIME);
1482 ps.put(
"send_requests",
true);
1493 artdaq::FragmentPtrs fps;
1494 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1496 auto type = artdaq::Fragment::FirstUserFragmentType;
1497 BOOST_REQUIRE_EQUAL(sts,
true);
1498 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1499 while (fps.size() > 0)
1501 ids[fps.front()->fragmentID()]++;
1502 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1503 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1504 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1507 BOOST_REQUIRE_EQUAL(ids[1], 1);
1508 BOOST_REQUIRE_EQUAL(ids[2], 1);
1509 BOOST_REQUIRE_EQUAL(ids[3], 1);
1517 BOOST_REQUIRE_EQUAL(sts,
true);
1518 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1519 while (fps.size() > 0)
1521 ids[fps.front()->fragmentID()]++;
1522 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1523 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1524 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1527 BOOST_REQUIRE_EQUAL(ids[1], 1);
1528 BOOST_REQUIRE_EQUAL(ids[2], 1);
1529 BOOST_REQUIRE_EQUAL(ids[3], 1);
1540 BOOST_REQUIRE_EQUAL(sts,
true);
1541 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1542 auto ts = artdaq::Fragment::InvalidTimestamp;
1543 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1544 for (
auto ii = 0; ii < 3; ++ii)
1546 ids[fps.front()->fragmentID()]++;
1547 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1548 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1549 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1552 BOOST_REQUIRE_EQUAL(ids[1], 1);
1553 BOOST_REQUIRE_EQUAL(ids[2], 1);
1554 BOOST_REQUIRE_EQUAL(ids[3], 1);
1556 for (
auto ii = 0; ii < 3; ++ii)
1558 ids[fps.front()->fragmentID()]++;
1559 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1560 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1561 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1564 BOOST_REQUIRE_EQUAL(ids[1], 1);
1565 BOOST_REQUIRE_EQUAL(ids[2], 1);
1566 BOOST_REQUIRE_EQUAL(ids[3], 1);
1577 BOOST_REQUIRE_EQUAL(sts,
true);
1578 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1579 for (
auto ii = 0; ii < 3; ++ii)
1581 ids[fps.front()->fragmentID()]++;
1582 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1583 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1584 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1587 BOOST_REQUIRE_EQUAL(ids[1], 1);
1588 BOOST_REQUIRE_EQUAL(ids[2], 1);
1589 BOOST_REQUIRE_EQUAL(ids[3], 1);
1595 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1600 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1601 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1602 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1603 const int DELAY_TIME = 100;
1604 fhicl::ParameterSet ps;
1605 ps.put<
int>(
"board_id", 1);
1606 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1607 ps.put<
int>(
"request_port", REQUEST_PORT);
1609 ps.put<std::string>(
"request_address",
"227.18.12.31");
1611 ps.put<std::string>(
"request_address",
"localhost");
1613 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1614 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1615 ps.put<
bool>(
"separate_data_thread",
true);
1616 ps.put<
bool>(
"separate_monitoring_thread",
false);
1617 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1618 ps.put<std::string>(
"request_mode",
"buffer");
1619 ps.put(
"request_delay_ms", DELAY_TIME);
1620 ps.put(
"send_requests",
true);
1631 artdaq::FragmentPtrs fps;
1632 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1634 BOOST_REQUIRE_EQUAL(sts,
true);
1635 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1636 auto type = artdaq::Fragment::ContainerFragmentType;
1637 while (fps.size() > 0)
1639 ids[fps.front()->fragmentID()]++;
1640 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1641 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1642 type = artdaq::Fragment::ContainerFragmentType;
1643 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1644 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1645 auto cf = artdaq::ContainerFragment(*fps.front());
1646 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1647 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1648 type = artdaq::Fragment::FirstUserFragmentType;
1649 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1652 BOOST_REQUIRE_EQUAL(ids[1], 1);
1653 BOOST_REQUIRE_EQUAL(ids[2], 1);
1654 BOOST_REQUIRE_EQUAL(ids[3], 1);
1661 BOOST_REQUIRE_EQUAL(sts,
true);
1662 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1663 while (fps.size() > 0)
1665 ids[fps.front()->fragmentID()]++;
1666 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1667 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1668 type = artdaq::Fragment::ContainerFragmentType;
1669 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1670 auto cf = artdaq::ContainerFragment(*fps.front());
1671 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1672 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1673 type = artdaq::Fragment::EmptyFragmentType;
1674 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1677 BOOST_REQUIRE_EQUAL(ids[1], 1);
1678 BOOST_REQUIRE_EQUAL(ids[2], 1);
1679 BOOST_REQUIRE_EQUAL(ids[3], 1);
1688 BOOST_REQUIRE_EQUAL(sts,
true);
1689 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1691 auto ts = artdaq::Fragment::InvalidTimestamp;
1692 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1693 for (
auto ii = 0; ii < 3; ++ii)
1695 ids[fps.front()->fragmentID()]++;
1696 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1697 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1698 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1699 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1702 BOOST_REQUIRE_EQUAL(ids[1], 1);
1703 BOOST_REQUIRE_EQUAL(ids[2], 1);
1704 BOOST_REQUIRE_EQUAL(ids[3], 1);
1706 for (
auto ii = 0; ii < 3; ++ii)
1708 ids[fps.front()->fragmentID()]++;
1709 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1710 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1711 type = artdaq::Fragment::ContainerFragmentType;
1712 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1713 auto cf3 = artdaq::ContainerFragment(*fps.front());
1714 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1715 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1716 type = artdaq::Fragment::FirstUserFragmentType;
1717 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1720 BOOST_REQUIRE_EQUAL(ids[1], 1);
1721 BOOST_REQUIRE_EQUAL(ids[2], 1);
1722 BOOST_REQUIRE_EQUAL(ids[3], 1);
1733 BOOST_REQUIRE_EQUAL(sts,
true);
1734 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1736 for (
auto ii = 0; ii < 3; ++ii)
1738 ids[fps.front()->fragmentID()]++;
1739 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1740 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1741 type = artdaq::Fragment::ContainerFragmentType;
1742 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1743 auto cf3 = artdaq::ContainerFragment(*fps.front());
1744 if (fps.front()->fragmentID() != 3)
1746 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1747 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1748 type = artdaq::Fragment::FirstUserFragmentType;
1749 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1753 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
1754 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1755 type = artdaq::Fragment::EmptyFragmentType;
1756 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1760 BOOST_REQUIRE_EQUAL(ids[1], 1);
1761 BOOST_REQUIRE_EQUAL(ids[2], 1);
1762 BOOST_REQUIRE_EQUAL(ids[3], 1);
1771 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1776 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1777 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1778 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1779 const int DELAY_TIME = 100;
1780 fhicl::ParameterSet ps;
1781 ps.put<
int>(
"board_id", 1);
1782 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1783 ps.put<
int>(
"request_port", REQUEST_PORT);
1785 ps.put<std::string>(
"request_address",
"227.18.12.31");
1787 ps.put<std::string>(
"request_address",
"localhost");
1789 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1790 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1791 ps.put<
bool>(
"separate_data_thread",
true);
1792 ps.put<
bool>(
"circular_buffer_mode",
true);
1793 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1794 ps.put<
bool>(
"separate_monitoring_thread",
false);
1795 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1796 ps.put<std::string>(
"request_mode",
"buffer");
1797 ps.put(
"request_delay_ms", DELAY_TIME);
1798 ps.put(
"send_requests",
true);
1809 artdaq::FragmentPtrs fps;
1810 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1812 auto type = artdaq::Fragment::ContainerFragmentType;
1813 BOOST_REQUIRE_EQUAL(sts,
true);
1814 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1815 while (fps.size() > 0)
1817 ids[fps.front()->fragmentID()]++;
1818 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1819 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1820 type = artdaq::Fragment::ContainerFragmentType;
1821 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1822 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1823 auto cf = artdaq::ContainerFragment(*fps.front());
1824 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1825 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1826 type = artdaq::Fragment::FirstUserFragmentType;
1827 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1830 BOOST_REQUIRE_EQUAL(ids[1], 1);
1831 BOOST_REQUIRE_EQUAL(ids[2], 1);
1832 BOOST_REQUIRE_EQUAL(ids[3], 1);
1840 BOOST_REQUIRE_EQUAL(sts,
true);
1841 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1842 while (fps.size() > 0)
1844 ids[fps.front()->fragmentID()]++;
1845 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1846 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1847 type = artdaq::Fragment::ContainerFragmentType;
1848 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1849 auto cf = artdaq::ContainerFragment(*fps.front());
1850 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1851 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1852 type = artdaq::Fragment::EmptyFragmentType;
1853 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1856 BOOST_REQUIRE_EQUAL(ids[1], 1);
1857 BOOST_REQUIRE_EQUAL(ids[2], 1);
1858 BOOST_REQUIRE_EQUAL(ids[3], 1);
1868 BOOST_REQUIRE_EQUAL(sts,
true);
1869 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1871 auto ts = artdaq::Fragment::InvalidTimestamp;
1872 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1873 for (
auto ii = 0; ii < 3; ++ii)
1875 ids[fps.front()->fragmentID()]++;
1876 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1877 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1878 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1879 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1882 BOOST_REQUIRE_EQUAL(ids[1], 1);
1883 BOOST_REQUIRE_EQUAL(ids[2], 1);
1884 BOOST_REQUIRE_EQUAL(ids[3], 1);
1886 for (
auto ii = 0; ii < 3; ++ii)
1888 ids[fps.front()->fragmentID()]++;
1889 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1890 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1891 type = artdaq::Fragment::ContainerFragmentType;
1892 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1893 auto cf3 = artdaq::ContainerFragment(*fps.front());
1894 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
1895 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1896 type = artdaq::Fragment::FirstUserFragmentType;
1897 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1900 BOOST_REQUIRE_EQUAL(ids[1], 1);
1901 BOOST_REQUIRE_EQUAL(ids[2], 1);
1902 BOOST_REQUIRE_EQUAL(ids[3], 1);
1912 BOOST_REQUIRE_EQUAL(sts,
true);
1913 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1914 while (fps.size() > 0)
1916 ids[fps.front()->fragmentID()]++;
1917 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1918 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1919 type = artdaq::Fragment::ContainerFragmentType;
1920 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1921 auto cf = artdaq::ContainerFragment(*fps.front());
1922 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1923 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1924 type = artdaq::Fragment::FirstUserFragmentType;
1925 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1926 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1927 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1928 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1931 BOOST_REQUIRE_EQUAL(ids[1], 1);
1932 BOOST_REQUIRE_EQUAL(ids[2], 1);
1933 BOOST_REQUIRE_EQUAL(ids[3], 1);
1946 BOOST_REQUIRE_EQUAL(sts,
true);
1947 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1948 while (fps.size() > 0)
1950 ids[fps.front()->fragmentID()]++;
1951 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 10);
1952 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1953 type = artdaq::Fragment::ContainerFragmentType;
1954 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1955 auto cf = artdaq::ContainerFragment(*fps.front());
1956 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1957 type = artdaq::Fragment::FirstUserFragmentType;
1958 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1960 if (fps.front()->fragmentID() != 3)
1962 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1963 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 12);
1964 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 13);
1965 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 14);
1969 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1970 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 10);
1974 BOOST_REQUIRE_EQUAL(ids[1], 1);
1975 BOOST_REQUIRE_EQUAL(ids[2], 1);
1976 BOOST_REQUIRE_EQUAL(ids[3], 1);
1985 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1990 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1991 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1992 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1993 const int DELAY_TIME = 100;
1994 fhicl::ParameterSet ps;
1995 ps.put<
int>(
"board_id", 1);
1996 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1997 ps.put<
int>(
"request_port", REQUEST_PORT);
1999 ps.put<std::string>(
"request_address",
"227.18.12.32");
2001 ps.put<std::string>(
"request_address",
"localhost");
2003 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
2004 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
2005 ps.put<
bool>(
"separate_data_thread",
true);
2006 ps.put<
bool>(
"separate_monitoring_thread",
false);
2007 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
2008 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
2009 ps.put<
bool>(
"circular_buffer_mode",
true);
2010 ps.put<std::string>(
"request_mode",
"window");
2011 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
2012 ps.put<
size_t>(
"window_close_timeout_us", 500000);
2013 ps.put(
"request_delay_ms", DELAY_TIME);
2014 ps.put(
"send_requests",
true);
2025 artdaq::FragmentPtrs fps;
2026 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
2028 auto type = artdaq::Fragment::ContainerFragmentType;
2030 BOOST_REQUIRE_EQUAL(sts,
true);
2031 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
2032 while (fps.size() > 0)
2034 ids[fps.front()->fragmentID()]++;
2035 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
2036 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
2037 type = artdaq::Fragment::ContainerFragmentType;
2038 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2039 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
2040 auto cf = artdaq::ContainerFragment(*fps.front());
2041 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2042 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2043 type = artdaq::Fragment::FirstUserFragmentType;
2044 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2047 BOOST_REQUIRE_EQUAL(ids[1], 1);
2048 BOOST_REQUIRE_EQUAL(ids[2], 1);
2049 BOOST_REQUIRE_EQUAL(ids[3], 1);
2057 BOOST_REQUIRE_EQUAL(sts,
true);
2058 BOOST_REQUIRE_EQUAL(fps.size(), 0);
2064 BOOST_REQUIRE_EQUAL(sts,
true);
2065 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
2066 while (fps.size() > 0)
2068 ids[fps.front()->fragmentID()]++;
2069 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
2070 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
2071 type = artdaq::Fragment::ContainerFragmentType;
2072 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2073 auto cf = artdaq::ContainerFragment(*fps.front());
2074 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2075 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2076 type = artdaq::Fragment::FirstUserFragmentType;
2077 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2080 BOOST_REQUIRE_EQUAL(ids[1], 1);
2081 BOOST_REQUIRE_EQUAL(ids[2], 1);
2082 BOOST_REQUIRE_EQUAL(ids[3], 1);
2089 BOOST_REQUIRE_EQUAL(sts,
true);
2090 BOOST_REQUIRE_EQUAL(fps.size(), 0);
2095 BOOST_REQUIRE_EQUAL(sts,
true);
2096 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2100 BOOST_REQUIRE_EQUAL(list.size(), 1);
2101 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
2106 while (fps.size() > 0)
2108 ids[fps.front()->fragmentID()]++;
2109 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
2110 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
2111 type = artdaq::Fragment::ContainerFragmentType;
2112 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2113 auto cf = artdaq::ContainerFragment(*fps.front());
2114 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
2115 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
2116 type = artdaq::Fragment::EmptyFragmentType;
2117 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2120 BOOST_REQUIRE_EQUAL(ids[1], 1);
2121 BOOST_REQUIRE_EQUAL(ids[2], 1);
2122 BOOST_REQUIRE_EQUAL(ids[3], 1);
2133 BOOST_REQUIRE_EQUAL(list.size(), 1);
2137 BOOST_REQUIRE_EQUAL(list.size(), 0);
2138 BOOST_REQUIRE_EQUAL(sts,
true);
2139 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2140 while (fps.size() > 0)
2142 ids[fps.front()->fragmentID()]++;
2143 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
2144 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
2145 type = artdaq::Fragment::ContainerFragmentType;
2146 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2147 auto cf = artdaq::ContainerFragment(*fps.front());
2148 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
2149 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
2150 type = artdaq::Fragment::EmptyFragmentType;
2151 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2154 BOOST_REQUIRE_EQUAL(ids[1], 1);
2155 BOOST_REQUIRE_EQUAL(ids[2], 1);
2156 BOOST_REQUIRE_EQUAL(ids[3], 1);
2163 BOOST_REQUIRE_EQUAL(sts,
true);
2164 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2165 while (fps.size() > 0)
2167 ids[fps.front()->fragmentID()]++;
2168 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
2169 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
2170 type = artdaq::Fragment::ContainerFragmentType;
2171 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2172 auto cf = artdaq::ContainerFragment(*fps.front());
2173 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2174 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2175 type = artdaq::Fragment::FirstUserFragmentType;
2176 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2179 BOOST_REQUIRE_EQUAL(ids[1], 1);
2180 BOOST_REQUIRE_EQUAL(ids[2], 1);
2181 BOOST_REQUIRE_EQUAL(ids[3], 1);
2187 BOOST_REQUIRE_EQUAL(list.size(), 1);
2188 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
2192 BOOST_REQUIRE_EQUAL(sts,
true);
2193 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2194 while (fps.size() > 0)
2196 ids[fps.front()->fragmentID()]++;
2197 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
2198 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
2199 type = artdaq::Fragment::ContainerFragmentType;
2200 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2201 auto cf = artdaq::ContainerFragment(*fps.front());
2202 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2203 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2204 type = artdaq::Fragment::FirstUserFragmentType;
2205 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2208 BOOST_REQUIRE_EQUAL(ids[1], 1);
2209 BOOST_REQUIRE_EQUAL(ids[2], 1);
2210 BOOST_REQUIRE_EQUAL(ids[3], 1);
2216 BOOST_REQUIRE_EQUAL(list.size(), 0);
2224 BOOST_REQUIRE_EQUAL(sts,
true);
2225 BOOST_REQUIRE_EQUAL(fps.size(), 2);
2226 while (fps.size() > 0)
2228 ids[fps.front()->fragmentID()]++;
2229 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2230 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2231 type = artdaq::Fragment::ContainerFragmentType;
2232 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2233 auto cf = artdaq::ContainerFragment(*fps.front());
2234 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2235 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2236 type = artdaq::Fragment::FirstUserFragmentType;
2237 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2240 BOOST_REQUIRE_EQUAL(ids[1], 1);
2241 BOOST_REQUIRE_EQUAL(ids[2], 1);
2242 BOOST_REQUIRE_EQUAL(ids[3], 0);
2253 BOOST_REQUIRE_EQUAL(sts,
true);
2254 BOOST_REQUIRE_EQUAL(fps.size(), 1);
2255 while (fps.size() > 0)
2257 ids[fps.front()->fragmentID()]++;
2258 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2259 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2260 type = artdaq::Fragment::ContainerFragmentType;
2261 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2262 auto cf = artdaq::ContainerFragment(*fps.front());
2263 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2264 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2265 type = artdaq::Fragment::FirstUserFragmentType;
2266 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2269 BOOST_REQUIRE_EQUAL(ids[1], 0);
2270 BOOST_REQUIRE_EQUAL(ids[2], 0);
2271 BOOST_REQUIRE_EQUAL(ids[3], 1);
2277 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
2281 BOOST_AUTO_TEST_SUITE_END()
bool getNext_(artdaq::FragmentPtrs &frags) override
Generate data and return it to CommandableFragmentGenerator.
void setEnabledIds(uint64_t bitmask)
Set the enabled IDs mask for the Fragment Generator.
CommandableFragmentGenerator derived class for testing.
The RequestSender contains methods used to send data requests and Routing tokens. ...
void StopCmd(uint64_t timeout, uint64_t timestamp)
Stop the CommandableFragmentGenerator.
CommandableFragmentGeneratorTest(const fhicl::ParameterSet &ps)
CommandableFragmentGeneratorTest Constructor.
void StartCmd(int run, uint64_t timeout, uint64_t timestamp)
Start the CommandableFragmentGenerator.
bool getNext(FragmentPtrs &output) overridefinal
getNext calls either applyRequests or getNext_ to get any data that is ready to be sent to the EventB...
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...
bool checkHWStatus_() override
Returns whether the hwFail flag has not been set.
void stopNoMutex() override
Perform immediate stop actions. No-Op.
void SetRunNumber(uint32_t run)
Set the run number to be used in request messages.
void start() override
Perform start actions. No-Op.
CommandableFragmentGenerator is a FragmentGenerator-derived abstract class that defines the interface...
void resume() override
Perform resume actions. No-Op.
void pause() override
Perform pause actions. No-Op.
size_t ev_counter() const
Get the current value of the event counter.
void setHwFail()
Set the hwFail flag.
void setTimestamp(artdaq::Fragment::timestamp_t ts)
Set the timestamp to be used for the next Fragment.
artdaq::Fragment::timestamp_t getTimestamp()
Get the timestamp that will be used for the next Fragment.
void stop() override
Perform stop actions. No-Op.
void AddRequest(Fragment::sequence_id_t seqID, Fragment::timestamp_t timestamp)
Add a request to the request list.
void waitForFrags()
Wait for all fragments generated to be read by the CommandableFragmentGenerator
void joinThreads()
Join any data-taking threads. Should be called when destructing CommandableFragmentGenerator.
void setFireCount(size_t count)
Have getNext_ generate count fragments.