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) <<
"CircularBufferMode 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>(
"circular_buffer_mode",
true);
427 ps.put<
int>(
"data_buffer_depth_fragments", 3);
428 ps.put<
bool>(
"separate_monitoring_thread",
false);
429 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
430 ps.put<std::string>(
"request_mode",
"buffer");
431 ps.put(
"request_delay_ms", DELAY_TIME);
432 ps.put(
"send_requests",
true);
443 artdaq::FragmentPtrs fps;
445 BOOST_REQUIRE_EQUAL(sts,
true);
446 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
447 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
448 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
449 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
450 auto type = artdaq::Fragment::ContainerFragmentType;
451 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
452 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
453 auto cf = artdaq::ContainerFragment(*fps.front());
454 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
455 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
456 type = artdaq::Fragment::FirstUserFragmentType;
457 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
463 BOOST_REQUIRE_EQUAL(sts,
true);
464 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
465 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
466 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
467 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
468 type = artdaq::Fragment::ContainerFragmentType;
469 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
470 auto cf2 = artdaq::ContainerFragment(*fps.front());
471 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
472 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
473 type = artdaq::Fragment::EmptyFragmentType;
474 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
482 BOOST_REQUIRE_EQUAL(sts,
true);
483 BOOST_REQUIRE_EQUAL(fps.size(), 2);
485 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
486 auto ts = artdaq::Fragment::InvalidTimestamp;
487 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
488 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
489 auto emptyType = artdaq::Fragment::EmptyFragmentType;
490 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
491 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
493 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
494 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
495 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
496 type = artdaq::Fragment::ContainerFragmentType;
497 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
498 auto cf3 = artdaq::ContainerFragment(*fps.front());
499 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
500 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
501 type = artdaq::Fragment::FirstUserFragmentType;
502 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
510 BOOST_REQUIRE_EQUAL(sts,
true);
511 BOOST_REQUIRE_EQUAL(fps.size(), 1);
513 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
514 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
515 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
516 type = artdaq::Fragment::ContainerFragmentType;
517 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
518 auto cf4 = artdaq::ContainerFragment(*fps.front());
519 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
520 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
521 type = artdaq::Fragment::FirstUserFragmentType;
522 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
523 BOOST_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
524 BOOST_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
525 BOOST_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
532 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
537 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
538 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
539 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
540 const int DELAY_TIME = 100;
541 fhicl::ParameterSet ps;
542 ps.put<
int>(
"board_id", 1);
543 ps.put<
int>(
"fragment_id", 1);
544 ps.put<
int>(
"request_port", REQUEST_PORT);
546 ps.put<std::string>(
"request_address",
"227.18.12.32");
548 ps.put<std::string>(
"request_address",
"localhost");
550 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
551 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
552 ps.put<
bool>(
"separate_data_thread",
true);
553 ps.put<
bool>(
"separate_monitoring_thread",
false);
554 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
555 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
556 ps.put<
bool>(
"circular_buffer_mode",
true);
557 ps.put<std::string>(
"request_mode",
"window");
558 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
559 ps.put<
size_t>(
"window_close_timeout_us", 500000);
560 ps.put(
"request_delay_ms", DELAY_TIME);
561 ps.put(
"send_requests",
true);
572 artdaq::FragmentPtrs fps;
575 BOOST_REQUIRE_EQUAL(sts,
true);
576 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
577 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
578 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
579 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
580 auto type = artdaq::Fragment::ContainerFragmentType;
581 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
582 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
583 auto cf = artdaq::ContainerFragment(*fps.front());
584 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
585 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
586 type = artdaq::Fragment::FirstUserFragmentType;
587 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
594 BOOST_REQUIRE_EQUAL(sts,
true);
595 BOOST_REQUIRE_EQUAL(fps.size(), 0);
601 BOOST_REQUIRE_EQUAL(sts,
true);
602 BOOST_REQUIRE_EQUAL(fps.size(), 1);
603 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
604 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
605 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
606 type = artdaq::Fragment::ContainerFragmentType;
607 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
608 auto cf2 = artdaq::ContainerFragment(*fps.front());
609 BOOST_REQUIRE_EQUAL(cf2.block_count(), 1);
610 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
611 type = artdaq::Fragment::FirstUserFragmentType;
612 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
618 BOOST_REQUIRE_EQUAL(sts,
true);
619 BOOST_REQUIRE_EQUAL(fps.size(), 0);
624 BOOST_REQUIRE_EQUAL(sts,
true);
625 BOOST_REQUIRE_EQUAL(fps.size(), 1);
629 BOOST_REQUIRE_EQUAL(list.size(), 1);
630 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
635 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
636 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
637 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
638 type = artdaq::Fragment::ContainerFragmentType;
639 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
640 auto cf3 = artdaq::ContainerFragment(*fps.front());
641 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
642 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
true);
643 type = artdaq::Fragment::EmptyFragmentType;
644 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
653 BOOST_REQUIRE_EQUAL(list.size(), 1);
657 BOOST_REQUIRE_EQUAL(list.size(), 0);
658 BOOST_REQUIRE_EQUAL(sts,
true);
659 BOOST_REQUIRE_EQUAL(fps.size(), 1);
660 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
661 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
662 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
663 type = artdaq::Fragment::ContainerFragmentType;
664 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
665 auto cf4 = artdaq::ContainerFragment(*fps.front());
666 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
667 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
668 type = artdaq::Fragment::EmptyFragmentType;
669 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
675 BOOST_REQUIRE_EQUAL(sts,
true);
676 BOOST_REQUIRE_EQUAL(fps.size(), 1);
677 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
678 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
679 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
680 type = artdaq::Fragment::ContainerFragmentType;
681 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
682 auto cf5 = artdaq::ContainerFragment(*fps.front());
683 BOOST_REQUIRE_EQUAL(cf5.block_count(), 1);
684 BOOST_REQUIRE_EQUAL(cf5.missing_data(),
false);
685 type = artdaq::Fragment::FirstUserFragmentType;
686 BOOST_REQUIRE_EQUAL(cf5.fragment_type(), type);
691 BOOST_REQUIRE_EQUAL(list.size(), 1);
692 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
696 BOOST_REQUIRE_EQUAL(sts,
true);
697 BOOST_REQUIRE_EQUAL(fps.size(), 1);
698 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
699 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
700 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
701 type = artdaq::Fragment::ContainerFragmentType;
702 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
703 auto cf6 = artdaq::ContainerFragment(*fps.front());
704 BOOST_REQUIRE_EQUAL(cf6.block_count(), 1);
705 BOOST_REQUIRE_EQUAL(cf6.missing_data(),
false);
706 type = artdaq::Fragment::FirstUserFragmentType;
707 BOOST_REQUIRE_EQUAL(cf6.fragment_type(), type);
712 BOOST_REQUIRE_EQUAL(list.size(), 0);
717 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
729 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
730 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
731 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
732 const int DELAY_TIME = 100;
733 fhicl::ParameterSet ps;
734 ps.put<
int>(
"board_id", 1);
735 ps.put<
int>(
"fragment_id", 1);
736 ps.put<
int>(
"request_port", REQUEST_PORT);
738 ps.put<std::string>(
"request_address",
"227.18.12.32");
740 ps.put<std::string>(
"request_address",
"localhost");
742 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
743 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
744 ps.put<
bool>(
"separate_data_thread",
true);
745 ps.put<
bool>(
"separate_monitoring_thread",
false);
746 ps.put<
bool>(
"circular_buffer_mode",
true);
747 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
748 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
749 ps.put<std::string>(
"request_mode",
"window");
750 ps.put(
"request_delay_ms", DELAY_TIME);
751 ps.put(
"send_requests",
true);
760 artdaq::FragmentPtrs fps;
762 artdaq::Fragment::type_t type;
771 BOOST_REQUIRE_EQUAL(sts,
true);
772 BOOST_REQUIRE_EQUAL(fps.size(), 1);
773 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
774 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
775 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
776 type = artdaq::Fragment::ContainerFragmentType;
777 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
778 auto cf4 = artdaq::ContainerFragment(*fps.front());
779 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
780 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
781 type = artdaq::Fragment::EmptyFragmentType;
782 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
785 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
789 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
790 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
791 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
792 const int DELAY_TIME = 100;
793 fhicl::ParameterSet ps;
794 ps.put<
int>(
"board_id", 1);
795 ps.put<
int>(
"fragment_id", 1);
796 ps.put<
int>(
"request_port", REQUEST_PORT);
798 ps.put<std::string>(
"request_address",
"227.18.12.32");
800 ps.put<std::string>(
"request_address",
"localhost");
802 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
803 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
804 ps.put<
bool>(
"separate_data_thread",
true);
805 ps.put<
bool>(
"separate_monitoring_thread",
false);
806 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
807 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
808 ps.put<
bool>(
"circular_buffer_mode",
true);
809 ps.put<std::string>(
"request_mode",
"window");
810 ps.put(
"request_delay_ms", DELAY_TIME);
811 ps.put(
"send_requests",
true);
820 artdaq::FragmentPtrs fps;
822 artdaq::Fragment::type_t type;
833 BOOST_REQUIRE_EQUAL(sts,
true);
834 BOOST_REQUIRE_EQUAL(fps.size(), 1);
835 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
836 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
837 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
838 type = artdaq::Fragment::ContainerFragmentType;
839 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
840 auto cf4 = artdaq::ContainerFragment(*fps.front());
841 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
842 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
843 type = artdaq::Fragment::FirstUserFragmentType;
844 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
848 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case END";
852 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
853 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case BEGIN";
854 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
855 const int DELAY_TIME = 100;
856 fhicl::ParameterSet ps;
857 ps.put<
int>(
"board_id", 1);
858 ps.put<
int>(
"fragment_id", 1);
859 ps.put<
int>(
"request_port", REQUEST_PORT);
861 ps.put<std::string>(
"request_address",
"227.18.12.32");
863 ps.put<std::string>(
"request_address",
"localhost");
865 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
866 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 4);
867 ps.put<
size_t>(
"window_close_timeout_us", 500000);
868 ps.put<
bool>(
"separate_data_thread",
true);
869 ps.put<
bool>(
"separate_monitoring_thread",
false);
870 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
871 ps.put<
bool>(
"circular_buffer_mode",
true);
872 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
873 ps.put<std::string>(
"request_mode",
"window");
874 ps.put(
"request_delay_ms", DELAY_TIME);
875 ps.put(
"send_requests",
true);
884 artdaq::FragmentPtrs fps;
886 artdaq::Fragment::type_t type;
897 BOOST_REQUIRE_EQUAL(sts,
true);
898 BOOST_REQUIRE_EQUAL(fps.size(), 1);
899 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
900 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
901 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
902 type = artdaq::Fragment::ContainerFragmentType;
903 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
904 auto cf = artdaq::ContainerFragment(*fps.front());
905 BOOST_REQUIRE_EQUAL(cf.block_count(), 4);
906 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
907 type = artdaq::Fragment::FirstUserFragmentType;
908 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
913 BOOST_REQUIRE_EQUAL(sts,
true);
914 BOOST_REQUIRE_EQUAL(fps.size(), 0);
920 BOOST_REQUIRE_EQUAL(sts,
true);
921 BOOST_REQUIRE_EQUAL(fps.size(), 1);
922 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
923 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
924 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
925 type = artdaq::Fragment::ContainerFragmentType;
926 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
927 auto cf2 = artdaq::ContainerFragment(*fps.front());
928 BOOST_REQUIRE_EQUAL(cf2.block_count(), 3);
929 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
true);
930 type = artdaq::Fragment::FirstUserFragmentType;
931 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
937 BOOST_REQUIRE_EQUAL(sts,
true);
938 BOOST_REQUIRE_EQUAL(fps.size(), 0);
943 BOOST_REQUIRE_EQUAL(sts,
true);
944 BOOST_REQUIRE_EQUAL(fps.size(), 1);
945 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
946 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
947 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
948 type = artdaq::Fragment::ContainerFragmentType;
949 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
950 auto cf4 = artdaq::ContainerFragment(*fps.front());
951 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
952 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
953 type = artdaq::Fragment::FirstUserFragmentType;
954 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
958 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
962 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
963 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
964 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
965 const int DELAY_TIME = 100;
966 fhicl::ParameterSet ps;
967 ps.put<
int>(
"board_id", 1);
968 ps.put<
int>(
"fragment_id", 1);
969 ps.put<
int>(
"request_port", REQUEST_PORT);
971 ps.put<std::string>(
"request_address",
"227.18.12.32");
973 ps.put<std::string>(
"request_address",
"localhost");
975 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
976 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
977 ps.put<
bool>(
"separate_data_thread",
true);
978 ps.put<
bool>(
"separate_monitoring_thread",
false);
979 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
980 ps.put<
bool>(
"circular_buffer_mode",
true);
981 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
982 ps.put<std::string>(
"request_mode",
"window");
983 ps.put(
"request_delay_ms", DELAY_TIME);
984 ps.put(
"send_requests",
true);
992 artdaq::FragmentPtrs fps;
994 artdaq::Fragment::type_t type;
1004 BOOST_REQUIRE_EQUAL(sts,
true);
1005 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1006 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1007 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1008 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1009 type = artdaq::Fragment::ContainerFragmentType;
1010 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1011 auto cf4 = artdaq::ContainerFragment(*fps.front());
1012 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
1013 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
1014 type = artdaq::Fragment::FirstUserFragmentType;
1015 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1018 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
1022 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1023 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
1024 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1025 const int DELAY_TIME = 100;
1026 fhicl::ParameterSet ps;
1027 ps.put<
int>(
"board_id", 1);
1028 ps.put<
int>(
"fragment_id", 1);
1029 ps.put<
int>(
"request_port", REQUEST_PORT);
1031 ps.put<std::string>(
"request_address",
"227.18.12.32");
1033 ps.put<std::string>(
"request_address",
"localhost");
1035 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1036 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1037 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1038 ps.put<
bool>(
"separate_data_thread",
true);
1039 ps.put<
bool>(
"separate_monitoring_thread",
false);
1040 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1041 ps.put<
bool>(
"circular_buffer_mode",
true);
1042 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1043 ps.put<std::string>(
"request_mode",
"window");
1044 ps.put(
"request_delay_ms", DELAY_TIME);
1045 ps.put(
"send_requests",
true);
1053 artdaq::FragmentPtrs fps;
1055 artdaq::Fragment::type_t type;
1064 BOOST_REQUIRE_EQUAL(sts,
true);
1065 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1070 BOOST_REQUIRE_EQUAL(sts,
true);
1071 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1072 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1073 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1074 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1075 type = artdaq::Fragment::ContainerFragmentType;
1076 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1077 auto cf = artdaq::ContainerFragment(*fps.front());
1078 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1079 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1080 type = artdaq::Fragment::FirstUserFragmentType;
1081 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1087 BOOST_REQUIRE_EQUAL(sts,
true);
1088 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1093 BOOST_REQUIRE_EQUAL(sts,
true);
1094 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1095 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1096 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1097 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1098 type = artdaq::Fragment::ContainerFragmentType;
1099 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1100 auto cf4 = artdaq::ContainerFragment(*fps.front());
1101 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
1102 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1103 type = artdaq::Fragment::FirstUserFragmentType;
1104 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1108 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
1112 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1113 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
1114 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1115 const int DELAY_TIME = 100;
1116 fhicl::ParameterSet ps;
1117 ps.put<
int>(
"board_id", 1);
1118 ps.put<
int>(
"fragment_id", 1);
1119 ps.put<
int>(
"request_port", REQUEST_PORT);
1121 ps.put<std::string>(
"request_address",
"227.18.12.32");
1123 ps.put<std::string>(
"request_address",
"localhost");
1125 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1126 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1127 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1128 ps.put<
bool>(
"separate_data_thread",
true);
1129 ps.put<
bool>(
"separate_monitoring_thread",
false);
1130 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1131 ps.put<
bool>(
"circular_buffer_mode",
true);
1132 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1133 ps.put<std::string>(
"request_mode",
"window");
1134 ps.put(
"request_delay_ms", DELAY_TIME);
1135 ps.put(
"send_requests",
true);
1143 artdaq::FragmentPtrs fps;
1145 artdaq::Fragment::type_t type;
1155 BOOST_REQUIRE_EQUAL(sts,
true);
1156 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1160 BOOST_REQUIRE_EQUAL(sts,
true);
1161 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1166 BOOST_REQUIRE_EQUAL(sts,
true);
1167 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1168 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1169 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1170 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1171 type = artdaq::Fragment::ContainerFragmentType;
1172 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1173 auto cf = artdaq::ContainerFragment(*fps.front());
1174 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1175 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1176 type = artdaq::Fragment::FirstUserFragmentType;
1177 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1182 BOOST_REQUIRE_EQUAL(sts,
true);
1183 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1188 BOOST_REQUIRE_EQUAL(sts,
true);
1189 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1190 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1191 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
1192 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1193 type = artdaq::Fragment::ContainerFragmentType;
1194 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1195 auto cf4 = artdaq::ContainerFragment(*fps.front());
1196 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
1197 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1198 type = artdaq::Fragment::EmptyFragmentType;
1199 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1203 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1208 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1209 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case BEGIN";
1210 fhicl::ParameterSet ps;
1211 ps.put<
int>(
"board_id", 1);
1212 ps.put<
int>(
"fragment_id", 1);
1213 ps.put<
bool>(
"separate_data_thread",
false);
1214 ps.put<
bool>(
"separate_monitoring_thread",
false);
1215 ps.put<int64_t>(
"hardware_poll_interval_us", 10);
1218 gen.StartCmd(1, 0xFFFFFFFF, 1);
1220 artdaq::FragmentPtrs fps;
1221 auto sts = gen.getNext(fps);
1222 BOOST_REQUIRE_EQUAL(sts,
true);
1223 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1224 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1225 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1226 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1229 gen.setFireCount(1);
1232 sts = gen.getNext(fps);
1233 BOOST_REQUIRE_EQUAL(sts,
false);
1234 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1236 gen.StopCmd(0xFFFFFFFF, 1);
1238 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case END";
1243 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1244 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case BEGIN";
1245 fhicl::ParameterSet ps;
1246 ps.put<
int>(
"board_id", 1);
1247 ps.put<
int>(
"fragment_id", 1);
1248 ps.put<
bool>(
"separate_data_thread",
true);
1249 ps.put<
bool>(
"separate_monitoring_thread",
true);
1250 ps.put<int64_t>(
"hardware_poll_interval_us", 750000);
1253 gen.StartCmd(1, 0xFFFFFFFF, 1);
1256 artdaq::FragmentPtrs fps;
1257 auto sts = gen.getNext(fps);
1258 BOOST_REQUIRE_EQUAL(sts,
true);
1259 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1260 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1261 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1262 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1277 gen.setFireCount(1);
1278 sts = gen.getNext(fps);
1279 BOOST_REQUIRE_EQUAL(sts,
false);
1280 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1282 gen.StopCmd(0xFFFFFFFF, 1);
1284 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case END";
1289 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1290 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1291 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1292 const int DELAY_TIME = 1;
1293 fhicl::ParameterSet ps;
1294 ps.put<
int>(
"board_id", 1);
1295 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1296 ps.put<
int>(
"request_port", REQUEST_PORT);
1298 ps.put<std::string>(
"request_address",
"227.18.12.29");
1300 ps.put<std::string>(
"request_address",
"localhost");
1302 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1303 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1304 ps.put<
bool>(
"separate_data_thread",
true);
1305 ps.put<
bool>(
"separate_monitoring_thread",
false);
1306 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1307 ps.put<std::string>(
"request_mode",
"ignored");
1308 ps.put(
"request_delay_ms", DELAY_TIME);
1309 ps.put(
"send_requests",
true);
1317 artdaq::FragmentPtrs fps;
1318 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1320 BOOST_REQUIRE_EQUAL(sts,
true);
1321 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1322 while (fps.size() > 0)
1324 ids[fps.front()->fragmentID()]++;
1325 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1326 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1330 BOOST_REQUIRE_EQUAL(ids[1], 1);
1331 BOOST_REQUIRE_EQUAL(ids[2], 1);
1332 BOOST_REQUIRE_EQUAL(ids[3], 1);
1341 BOOST_REQUIRE_EQUAL(sts,
true);
1342 BOOST_REQUIRE_EQUAL(fps.size(), 2u);
1343 while (fps.size() > 0)
1345 ids[fps.front()->fragmentID()]++;
1346 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1347 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1350 BOOST_REQUIRE_EQUAL(ids[1], 1);
1351 BOOST_REQUIRE_EQUAL(ids[2], 1);
1355 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1360 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1361 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1362 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1363 const int DELAY_TIME = 100;
1364 fhicl::ParameterSet ps;
1365 ps.put<
int>(
"board_id", 1);
1366 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1367 ps.put<
int>(
"request_port", REQUEST_PORT);
1369 ps.put<std::string>(
"request_address",
"227.18.12.30");
1371 ps.put<std::string>(
"request_address",
"localhost");
1373 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1374 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1375 ps.put<
bool>(
"separate_data_thread",
true);
1376 ps.put<
bool>(
"separate_monitoring_thread",
false);
1377 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1378 ps.put<std::string>(
"request_mode",
"single");
1379 ps.put(
"request_delay_ms", DELAY_TIME);
1380 ps.put(
"send_requests",
true);
1391 artdaq::FragmentPtrs fps;
1392 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1394 auto type = artdaq::Fragment::FirstUserFragmentType;
1395 BOOST_REQUIRE_EQUAL(sts,
true);
1396 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1397 while (fps.size() > 0)
1399 ids[fps.front()->fragmentID()]++;
1400 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1401 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1402 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1405 BOOST_REQUIRE_EQUAL(ids[1], 1);
1406 BOOST_REQUIRE_EQUAL(ids[2], 1);
1407 BOOST_REQUIRE_EQUAL(ids[3], 1);
1415 BOOST_REQUIRE_EQUAL(sts,
true);
1416 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1417 while (fps.size() > 0)
1419 ids[fps.front()->fragmentID()]++;
1420 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1421 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1422 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1425 BOOST_REQUIRE_EQUAL(ids[1], 1);
1426 BOOST_REQUIRE_EQUAL(ids[2], 1);
1427 BOOST_REQUIRE_EQUAL(ids[3], 1);
1438 BOOST_REQUIRE_EQUAL(sts,
true);
1439 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1440 auto ts = artdaq::Fragment::InvalidTimestamp;
1441 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1442 for (
auto ii = 0; ii < 3; ++ii)
1444 ids[fps.front()->fragmentID()]++;
1445 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1446 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1447 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1450 BOOST_REQUIRE_EQUAL(ids[1], 1);
1451 BOOST_REQUIRE_EQUAL(ids[2], 1);
1452 BOOST_REQUIRE_EQUAL(ids[3], 1);
1454 for (
auto ii = 0; ii < 3; ++ii)
1456 ids[fps.front()->fragmentID()]++;
1457 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1458 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1459 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1462 BOOST_REQUIRE_EQUAL(ids[1], 1);
1463 BOOST_REQUIRE_EQUAL(ids[2], 1);
1464 BOOST_REQUIRE_EQUAL(ids[3], 1);
1475 BOOST_REQUIRE_EQUAL(sts,
true);
1476 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1477 for (
auto ii = 0; ii < 3; ++ii)
1479 ids[fps.front()->fragmentID()]++;
1480 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1481 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1482 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1485 BOOST_REQUIRE_EQUAL(ids[1], 1);
1486 BOOST_REQUIRE_EQUAL(ids[2], 1);
1487 BOOST_REQUIRE_EQUAL(ids[3], 1);
1493 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1498 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1499 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1500 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1501 const int DELAY_TIME = 100;
1502 fhicl::ParameterSet ps;
1503 ps.put<
int>(
"board_id", 1);
1504 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1505 ps.put<
int>(
"request_port", REQUEST_PORT);
1507 ps.put<std::string>(
"request_address",
"227.18.12.31");
1509 ps.put<std::string>(
"request_address",
"localhost");
1511 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1512 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1513 ps.put<
bool>(
"separate_data_thread",
true);
1514 ps.put<
bool>(
"separate_monitoring_thread",
false);
1515 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1516 ps.put<std::string>(
"request_mode",
"buffer");
1517 ps.put(
"request_delay_ms", DELAY_TIME);
1518 ps.put(
"send_requests",
true);
1529 artdaq::FragmentPtrs fps;
1530 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1532 BOOST_REQUIRE_EQUAL(sts,
true);
1533 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1534 auto type = artdaq::Fragment::ContainerFragmentType;
1535 while (fps.size() > 0)
1537 ids[fps.front()->fragmentID()]++;
1538 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1539 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1540 type = artdaq::Fragment::ContainerFragmentType;
1541 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1542 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1543 auto cf = artdaq::ContainerFragment(*fps.front());
1544 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1545 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1546 type = artdaq::Fragment::FirstUserFragmentType;
1547 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1550 BOOST_REQUIRE_EQUAL(ids[1], 1);
1551 BOOST_REQUIRE_EQUAL(ids[2], 1);
1552 BOOST_REQUIRE_EQUAL(ids[3], 1);
1559 BOOST_REQUIRE_EQUAL(sts,
true);
1560 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1561 while (fps.size() > 0)
1563 ids[fps.front()->fragmentID()]++;
1564 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1565 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1566 type = artdaq::Fragment::ContainerFragmentType;
1567 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1568 auto cf = artdaq::ContainerFragment(*fps.front());
1569 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1570 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1571 type = artdaq::Fragment::EmptyFragmentType;
1572 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1575 BOOST_REQUIRE_EQUAL(ids[1], 1);
1576 BOOST_REQUIRE_EQUAL(ids[2], 1);
1577 BOOST_REQUIRE_EQUAL(ids[3], 1);
1586 BOOST_REQUIRE_EQUAL(sts,
true);
1587 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1589 auto ts = artdaq::Fragment::InvalidTimestamp;
1590 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1591 for (
auto ii = 0; ii < 3; ++ii)
1593 ids[fps.front()->fragmentID()]++;
1594 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1595 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1596 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1597 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1600 BOOST_REQUIRE_EQUAL(ids[1], 1);
1601 BOOST_REQUIRE_EQUAL(ids[2], 1);
1602 BOOST_REQUIRE_EQUAL(ids[3], 1);
1604 for (
auto ii = 0; ii < 3; ++ii)
1606 ids[fps.front()->fragmentID()]++;
1607 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1608 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1609 type = artdaq::Fragment::ContainerFragmentType;
1610 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1611 auto cf3 = artdaq::ContainerFragment(*fps.front());
1612 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1613 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1614 type = artdaq::Fragment::FirstUserFragmentType;
1615 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1618 BOOST_REQUIRE_EQUAL(ids[1], 1);
1619 BOOST_REQUIRE_EQUAL(ids[2], 1);
1620 BOOST_REQUIRE_EQUAL(ids[3], 1);
1631 BOOST_REQUIRE_EQUAL(sts,
true);
1632 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1634 for (
auto ii = 0; ii < 3; ++ii)
1636 ids[fps.front()->fragmentID()]++;
1637 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1638 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1639 type = artdaq::Fragment::ContainerFragmentType;
1640 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1641 auto cf3 = artdaq::ContainerFragment(*fps.front());
1642 if (fps.front()->fragmentID() != 3)
1644 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1645 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1646 type = artdaq::Fragment::FirstUserFragmentType;
1647 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1651 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
1652 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1653 type = artdaq::Fragment::EmptyFragmentType;
1654 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1658 BOOST_REQUIRE_EQUAL(ids[1], 1);
1659 BOOST_REQUIRE_EQUAL(ids[2], 1);
1660 BOOST_REQUIRE_EQUAL(ids[3], 1);
1669 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1674 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1675 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1676 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1677 const int DELAY_TIME = 100;
1678 fhicl::ParameterSet ps;
1679 ps.put<
int>(
"board_id", 1);
1680 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1681 ps.put<
int>(
"request_port", REQUEST_PORT);
1683 ps.put<std::string>(
"request_address",
"227.18.12.31");
1685 ps.put<std::string>(
"request_address",
"localhost");
1687 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1688 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1689 ps.put<
bool>(
"separate_data_thread",
true);
1690 ps.put<
bool>(
"circular_buffer_mode",
true);
1691 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1692 ps.put<
bool>(
"separate_monitoring_thread",
false);
1693 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1694 ps.put<std::string>(
"request_mode",
"buffer");
1695 ps.put(
"request_delay_ms", DELAY_TIME);
1696 ps.put(
"send_requests",
true);
1707 artdaq::FragmentPtrs fps;
1708 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1710 auto type = artdaq::Fragment::ContainerFragmentType;
1711 BOOST_REQUIRE_EQUAL(sts,
true);
1712 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1713 while (fps.size() > 0)
1715 ids[fps.front()->fragmentID()]++;
1716 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1717 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1718 type = artdaq::Fragment::ContainerFragmentType;
1719 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1720 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1721 auto cf = artdaq::ContainerFragment(*fps.front());
1722 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1723 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1724 type = artdaq::Fragment::FirstUserFragmentType;
1725 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1728 BOOST_REQUIRE_EQUAL(ids[1], 1);
1729 BOOST_REQUIRE_EQUAL(ids[2], 1);
1730 BOOST_REQUIRE_EQUAL(ids[3], 1);
1738 BOOST_REQUIRE_EQUAL(sts,
true);
1739 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1740 while (fps.size() > 0)
1742 ids[fps.front()->fragmentID()]++;
1743 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1744 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1745 type = artdaq::Fragment::ContainerFragmentType;
1746 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1747 auto cf = artdaq::ContainerFragment(*fps.front());
1748 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1749 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1750 type = artdaq::Fragment::EmptyFragmentType;
1751 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1754 BOOST_REQUIRE_EQUAL(ids[1], 1);
1755 BOOST_REQUIRE_EQUAL(ids[2], 1);
1756 BOOST_REQUIRE_EQUAL(ids[3], 1);
1766 BOOST_REQUIRE_EQUAL(sts,
true);
1767 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1769 auto ts = artdaq::Fragment::InvalidTimestamp;
1770 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1771 for (
auto ii = 0; ii < 3; ++ii)
1773 ids[fps.front()->fragmentID()]++;
1774 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1775 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1776 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1777 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1780 BOOST_REQUIRE_EQUAL(ids[1], 1);
1781 BOOST_REQUIRE_EQUAL(ids[2], 1);
1782 BOOST_REQUIRE_EQUAL(ids[3], 1);
1784 for (
auto ii = 0; ii < 3; ++ii)
1786 ids[fps.front()->fragmentID()]++;
1787 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1788 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1789 type = artdaq::Fragment::ContainerFragmentType;
1790 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1791 auto cf3 = artdaq::ContainerFragment(*fps.front());
1792 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
1793 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1794 type = artdaq::Fragment::FirstUserFragmentType;
1795 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1798 BOOST_REQUIRE_EQUAL(ids[1], 1);
1799 BOOST_REQUIRE_EQUAL(ids[2], 1);
1800 BOOST_REQUIRE_EQUAL(ids[3], 1);
1810 BOOST_REQUIRE_EQUAL(sts,
true);
1811 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1812 while (fps.size() > 0)
1814 ids[fps.front()->fragmentID()]++;
1815 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1816 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1817 type = artdaq::Fragment::ContainerFragmentType;
1818 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1819 auto cf = artdaq::ContainerFragment(*fps.front());
1820 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1821 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1822 type = artdaq::Fragment::FirstUserFragmentType;
1823 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1824 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1825 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1826 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1829 BOOST_REQUIRE_EQUAL(ids[1], 1);
1830 BOOST_REQUIRE_EQUAL(ids[2], 1);
1831 BOOST_REQUIRE_EQUAL(ids[3], 1);
1844 BOOST_REQUIRE_EQUAL(sts,
true);
1845 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1846 while (fps.size() > 0)
1848 ids[fps.front()->fragmentID()]++;
1849 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 10);
1850 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1851 type = artdaq::Fragment::ContainerFragmentType;
1852 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1853 auto cf = artdaq::ContainerFragment(*fps.front());
1854 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1855 type = artdaq::Fragment::FirstUserFragmentType;
1856 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1858 if (fps.front()->fragmentID() != 3)
1860 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1861 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 12);
1862 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 13);
1863 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 14);
1867 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1868 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 10);
1872 BOOST_REQUIRE_EQUAL(ids[1], 1);
1873 BOOST_REQUIRE_EQUAL(ids[2], 1);
1874 BOOST_REQUIRE_EQUAL(ids[3], 1);
1883 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1888 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1889 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1890 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1891 const int DELAY_TIME = 100;
1892 fhicl::ParameterSet ps;
1893 ps.put<
int>(
"board_id", 1);
1894 ps.put<std::vector<int>>(
"fragment_ids", {1, 2, 3});
1895 ps.put<
int>(
"request_port", REQUEST_PORT);
1897 ps.put<std::string>(
"request_address",
"227.18.12.32");
1899 ps.put<std::string>(
"request_address",
"localhost");
1901 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1902 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1903 ps.put<
bool>(
"separate_data_thread",
true);
1904 ps.put<
bool>(
"separate_monitoring_thread",
false);
1905 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1906 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1907 ps.put<
bool>(
"circular_buffer_mode",
true);
1908 ps.put<std::string>(
"request_mode",
"window");
1909 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
1910 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1911 ps.put(
"request_delay_ms", DELAY_TIME);
1912 ps.put(
"send_requests",
true);
1923 artdaq::FragmentPtrs fps;
1924 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1926 auto type = artdaq::Fragment::ContainerFragmentType;
1928 BOOST_REQUIRE_EQUAL(sts,
true);
1929 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1930 while (fps.size() > 0)
1932 ids[fps.front()->fragmentID()]++;
1933 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1934 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1935 type = artdaq::Fragment::ContainerFragmentType;
1936 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1937 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1938 auto cf = artdaq::ContainerFragment(*fps.front());
1939 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1940 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1941 type = artdaq::Fragment::FirstUserFragmentType;
1942 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1945 BOOST_REQUIRE_EQUAL(ids[1], 1);
1946 BOOST_REQUIRE_EQUAL(ids[2], 1);
1947 BOOST_REQUIRE_EQUAL(ids[3], 1);
1955 BOOST_REQUIRE_EQUAL(sts,
true);
1956 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1962 BOOST_REQUIRE_EQUAL(sts,
true);
1963 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1964 while (fps.size() > 0)
1966 ids[fps.front()->fragmentID()]++;
1967 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1968 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1969 type = artdaq::Fragment::ContainerFragmentType;
1970 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1971 auto cf = artdaq::ContainerFragment(*fps.front());
1972 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1973 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1974 type = artdaq::Fragment::FirstUserFragmentType;
1975 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1978 BOOST_REQUIRE_EQUAL(ids[1], 1);
1979 BOOST_REQUIRE_EQUAL(ids[2], 1);
1980 BOOST_REQUIRE_EQUAL(ids[3], 1);
1987 BOOST_REQUIRE_EQUAL(sts,
true);
1988 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1993 BOOST_REQUIRE_EQUAL(sts,
true);
1994 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1998 BOOST_REQUIRE_EQUAL(list.size(), 1);
1999 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
2004 while (fps.size() > 0)
2006 ids[fps.front()->fragmentID()]++;
2007 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
2008 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
2009 type = artdaq::Fragment::ContainerFragmentType;
2010 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2011 auto cf = artdaq::ContainerFragment(*fps.front());
2012 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
2013 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
2014 type = artdaq::Fragment::EmptyFragmentType;
2015 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2018 BOOST_REQUIRE_EQUAL(ids[1], 1);
2019 BOOST_REQUIRE_EQUAL(ids[2], 1);
2020 BOOST_REQUIRE_EQUAL(ids[3], 1);
2031 BOOST_REQUIRE_EQUAL(list.size(), 1);
2035 BOOST_REQUIRE_EQUAL(list.size(), 0);
2036 BOOST_REQUIRE_EQUAL(sts,
true);
2037 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2038 while (fps.size() > 0)
2040 ids[fps.front()->fragmentID()]++;
2041 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
2042 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
2043 type = artdaq::Fragment::ContainerFragmentType;
2044 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2045 auto cf = artdaq::ContainerFragment(*fps.front());
2046 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
2047 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
2048 type = artdaq::Fragment::EmptyFragmentType;
2049 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2052 BOOST_REQUIRE_EQUAL(ids[1], 1);
2053 BOOST_REQUIRE_EQUAL(ids[2], 1);
2054 BOOST_REQUIRE_EQUAL(ids[3], 1);
2061 BOOST_REQUIRE_EQUAL(sts,
true);
2062 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2063 while (fps.size() > 0)
2065 ids[fps.front()->fragmentID()]++;
2066 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
2067 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
2068 type = artdaq::Fragment::ContainerFragmentType;
2069 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2070 auto cf = artdaq::ContainerFragment(*fps.front());
2071 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2072 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2073 type = artdaq::Fragment::FirstUserFragmentType;
2074 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2077 BOOST_REQUIRE_EQUAL(ids[1], 1);
2078 BOOST_REQUIRE_EQUAL(ids[2], 1);
2079 BOOST_REQUIRE_EQUAL(ids[3], 1);
2085 BOOST_REQUIRE_EQUAL(list.size(), 1);
2086 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
2090 BOOST_REQUIRE_EQUAL(sts,
true);
2091 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2092 while (fps.size() > 0)
2094 ids[fps.front()->fragmentID()]++;
2095 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
2096 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
2097 type = artdaq::Fragment::ContainerFragmentType;
2098 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2099 auto cf = artdaq::ContainerFragment(*fps.front());
2100 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2101 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2102 type = artdaq::Fragment::FirstUserFragmentType;
2103 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2106 BOOST_REQUIRE_EQUAL(ids[1], 1);
2107 BOOST_REQUIRE_EQUAL(ids[2], 1);
2108 BOOST_REQUIRE_EQUAL(ids[3], 1);
2114 BOOST_REQUIRE_EQUAL(list.size(), 0);
2122 BOOST_REQUIRE_EQUAL(sts,
true);
2123 BOOST_REQUIRE_EQUAL(fps.size(), 2);
2124 while (fps.size() > 0)
2126 ids[fps.front()->fragmentID()]++;
2127 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2128 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2129 type = artdaq::Fragment::ContainerFragmentType;
2130 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2131 auto cf = artdaq::ContainerFragment(*fps.front());
2132 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2133 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2134 type = artdaq::Fragment::FirstUserFragmentType;
2135 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2138 BOOST_REQUIRE_EQUAL(ids[1], 1);
2139 BOOST_REQUIRE_EQUAL(ids[2], 1);
2140 BOOST_REQUIRE_EQUAL(ids[3], 0);
2151 BOOST_REQUIRE_EQUAL(sts,
true);
2152 BOOST_REQUIRE_EQUAL(fps.size(), 1);
2153 while (fps.size() > 0)
2155 ids[fps.front()->fragmentID()]++;
2156 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2157 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2158 type = artdaq::Fragment::ContainerFragmentType;
2159 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2160 auto cf = artdaq::ContainerFragment(*fps.front());
2161 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2162 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2163 type = artdaq::Fragment::FirstUserFragmentType;
2164 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2167 BOOST_REQUIRE_EQUAL(ids[1], 0);
2168 BOOST_REQUIRE_EQUAL(ids[2], 0);
2169 BOOST_REQUIRE_EQUAL(ids[3], 1);
2175 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
2179 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.