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;
83 void setEnabledIds(uint64_t bitmask) { enabled_ids_ = bitmask; }
85 void setTimestamp(artdaq::Fragment::timestamp_t ts) { ts_ = ts; }
86 artdaq::Fragment::timestamp_t getTimestamp() {
return ts_; }
93 auto start_time = std::chrono::steady_clock::now();
94 while (fireCount_ > 0) { usleep(1000); }
95 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";
99 std::atomic<size_t> fireCount_;
100 std::atomic<bool> hwFail_;
101 artdaq::Fragment::timestamp_t ts_;
102 std::atomic<bool> hw_stop_;
103 std::atomic<uint64_t> enabled_ids_;
107 : CommandableFragmentGenerator(ps)
114 metricMan->initialize(ps.get<fhicl::ParameterSet>(
"metrics", fhicl::ParameterSet()));
115 metricMan->do_start();
120 while (fireCount_ > 0)
123 for (
auto&
id : fragmentIDs())
125 if (
id < 64 && ((enabled_ids_ & (0x1 <<
id)) != 0))
127 frags.emplace_back(
new artdaq::Fragment(ev_counter(),
id, artdaq::Fragment::FirstUserFragmentType, ts_));
147 BOOST_AUTO_TEST_SUITE(CommandableFragmentGenerator_t)
149 BOOST_AUTO_TEST_CASE(Simple)
151 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
152 TLOG(TLVL_INFO) <<
"Simple test case BEGIN";
153 fhicl::ParameterSet ps;
154 ps.put<
int>(
"board_id", 1);
155 ps.put<
int>(
"fragment_id", 1);
157 artdaq::FragmentPtrs fps;
158 auto sts = testGen.getNext(fps);
159 BOOST_REQUIRE_EQUAL(sts,
true);
160 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
161 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
162 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
163 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
164 TLOG(TLVL_INFO) <<
"Simple test case END";
167 BOOST_AUTO_TEST_CASE(IgnoreRequests)
169 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
170 TLOG(TLVL_INFO) <<
"IgnoreRequests test case BEGIN";
171 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
172 const int DELAY_TIME = 1;
173 fhicl::ParameterSet ps;
174 ps.put<
int>(
"board_id", 1);
175 ps.put<
int>(
"fragment_id", 1);
176 ps.put<
int>(
"request_port", REQUEST_PORT);
178 ps.put<std::string>(
"request_address",
"227.18.12.29");
180 ps.put<std::string>(
"request_address",
"localhost");
182 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
183 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
184 ps.put<
bool>(
"separate_data_thread",
true);
185 ps.put<
bool>(
"separate_monitoring_thread",
false);
186 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
187 ps.put<std::string>(
"request_mode",
"ignored");
188 ps.put(
"request_delay_ms", DELAY_TIME);
189 ps.put(
"send_requests",
true);
193 gen.StartCmd(1, 0xFFFFFFFF, 1);
195 t.AddRequest(53, 35);
197 artdaq::FragmentPtrs fps;
198 auto sts = gen.getNext(fps);
199 BOOST_REQUIRE_EQUAL(sts,
true);
200 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
201 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
202 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
203 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
204 gen.StopCmd(0xFFFFFFFF, 1);
206 TLOG(TLVL_INFO) <<
"IgnoreRequests test case END";
209 BOOST_AUTO_TEST_CASE(SingleMode)
211 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
212 TLOG(TLVL_INFO) <<
"SingleMode test case BEGIN";
213 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
214 const int DELAY_TIME = 100;
215 fhicl::ParameterSet ps;
216 ps.put<
int>(
"board_id", 1);
217 ps.put<
int>(
"fragment_id", 1);
218 ps.put<
int>(
"request_port", REQUEST_PORT);
220 ps.put<std::string>(
"request_address",
"227.18.12.30");
222 ps.put<std::string>(
"request_address",
"localhost");
224 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
225 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
226 ps.put<
bool>(
"separate_data_thread",
true);
227 ps.put<
bool>(
"separate_monitoring_thread",
false);
228 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
229 ps.put<std::string>(
"request_mode",
"single");
230 ps.put(
"request_delay_ms", DELAY_TIME);
231 ps.put(
"send_requests",
true);
238 gen.StartCmd(1, 0xFFFFFFFF, 1);
240 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
242 artdaq::FragmentPtrs fps;
243 auto sts = gen.getNext(fps);
244 auto type = artdaq::Fragment::FirstUserFragmentType;
245 BOOST_REQUIRE_EQUAL(sts,
true);
246 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
247 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
248 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
249 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
250 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
251 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
255 sts = gen.getNext(fps);
256 BOOST_REQUIRE_EQUAL(sts,
true);
257 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
258 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
259 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
260 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
261 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
262 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
268 sts = gen.getNext(fps);
269 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
270 BOOST_REQUIRE_EQUAL(sts,
true);
271 BOOST_REQUIRE_EQUAL(fps.size(), 2);
272 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
273 auto ts = artdaq::Fragment::InvalidTimestamp;
274 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
275 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
276 auto emptyType = artdaq::Fragment::EmptyFragmentType;
277 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
279 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
280 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
281 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
282 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
285 gen.StopCmd(0xFFFFFFFF, 1);
287 TLOG(TLVL_INFO) <<
"SingleMode test case END";
290 BOOST_AUTO_TEST_CASE(BufferMode)
292 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
293 TLOG(TLVL_INFO) <<
"BufferMode test case BEGIN";
294 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
295 const int DELAY_TIME = 100;
296 fhicl::ParameterSet ps;
297 ps.put<
int>(
"board_id", 1);
298 ps.put<
int>(
"fragment_id", 1);
299 ps.put<
int>(
"request_port", REQUEST_PORT);
301 ps.put<std::string>(
"request_address",
"227.18.12.31");
303 ps.put<std::string>(
"request_address",
"localhost");
305 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
306 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
307 ps.put<
bool>(
"separate_data_thread",
true);
308 ps.put<
bool>(
"separate_monitoring_thread",
false);
309 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
310 ps.put<std::string>(
"request_mode",
"buffer");
311 ps.put(
"request_delay_ms", DELAY_TIME);
312 ps.put(
"send_requests",
true);
319 gen.StartCmd(1, 0xFFFFFFFF, 1);
321 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
323 artdaq::FragmentPtrs fps;
324 auto sts = gen.getNext(fps);
325 BOOST_REQUIRE_EQUAL(sts,
true);
326 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
327 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
328 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
329 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
330 auto type = artdaq::Fragment::ContainerFragmentType;
331 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
332 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
333 auto cf = artdaq::ContainerFragment(*fps.front());
334 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
335 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
336 type = artdaq::Fragment::FirstUserFragmentType;
337 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
338 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
342 sts = gen.getNext(fps);
343 BOOST_REQUIRE_EQUAL(sts,
true);
344 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
345 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
346 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
347 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
348 type = artdaq::Fragment::ContainerFragmentType;
349 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
350 auto cf2 = artdaq::ContainerFragment(*fps.front());
351 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
352 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
353 type = artdaq::Fragment::EmptyFragmentType;
354 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
355 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
361 sts = gen.getNext(fps);
362 BOOST_REQUIRE_EQUAL(sts,
true);
363 BOOST_REQUIRE_EQUAL(fps.size(), 2);
365 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
366 auto ts = artdaq::Fragment::InvalidTimestamp;
367 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
368 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
369 auto emptyType = artdaq::Fragment::EmptyFragmentType;
370 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
371 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
373 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
374 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
375 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
376 type = artdaq::Fragment::ContainerFragmentType;
377 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
378 auto cf3 = artdaq::ContainerFragment(*fps.front());
379 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
380 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
381 type = artdaq::Fragment::FirstUserFragmentType;
382 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
384 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
386 gen.StopCmd(0xFFFFFFFF, 1);
389 TLOG(TLVL_INFO) <<
"BufferMode test case END";
392 BOOST_AUTO_TEST_CASE(CircularBufferMode)
394 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
395 TLOG(TLVL_INFO) <<
"CircularBufferMode test case BEGIN";
396 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
397 const int DELAY_TIME = 100;
398 fhicl::ParameterSet ps;
399 ps.put<
int>(
"board_id", 1);
400 ps.put<
int>(
"fragment_id", 1);
401 ps.put<
int>(
"request_port", REQUEST_PORT);
403 ps.put<std::string>(
"request_address",
"227.18.12.31");
405 ps.put<std::string>(
"request_address",
"localhost");
407 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
408 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
409 ps.put<
bool>(
"separate_data_thread",
true);
410 ps.put<
bool>(
"circular_buffer_mode",
true);
411 ps.put<
int>(
"data_buffer_depth_fragments", 3);
412 ps.put<
bool>(
"separate_monitoring_thread",
false);
413 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
414 ps.put<std::string>(
"request_mode",
"buffer");
415 ps.put(
"request_delay_ms", DELAY_TIME);
416 ps.put(
"send_requests",
true);
423 gen.StartCmd(1, 0xFFFFFFFF, 1);
425 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
427 artdaq::FragmentPtrs fps;
428 auto sts = gen.getNext(fps);
429 BOOST_REQUIRE_EQUAL(sts,
true);
430 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
431 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
432 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
433 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
434 auto type = artdaq::Fragment::ContainerFragmentType;
435 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
436 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
437 auto cf = artdaq::ContainerFragment(*fps.front());
438 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
439 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
440 type = artdaq::Fragment::FirstUserFragmentType;
441 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
442 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
446 sts = gen.getNext(fps);
447 BOOST_REQUIRE_EQUAL(sts,
true);
448 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
449 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
450 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
451 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
452 type = artdaq::Fragment::ContainerFragmentType;
453 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
454 auto cf2 = artdaq::ContainerFragment(*fps.front());
455 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
456 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
457 type = artdaq::Fragment::EmptyFragmentType;
458 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
459 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
465 sts = gen.getNext(fps);
466 BOOST_REQUIRE_EQUAL(sts,
true);
467 BOOST_REQUIRE_EQUAL(fps.size(), 2);
469 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
470 auto ts = artdaq::Fragment::InvalidTimestamp;
471 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
472 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
473 auto emptyType = artdaq::Fragment::EmptyFragmentType;
474 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
475 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
477 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
478 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
479 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
480 type = artdaq::Fragment::ContainerFragmentType;
481 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
482 auto cf3 = artdaq::ContainerFragment(*fps.front());
483 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
484 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
485 type = artdaq::Fragment::FirstUserFragmentType;
486 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
488 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
493 sts = gen.getNext(fps);
494 BOOST_REQUIRE_EQUAL(sts,
true);
495 BOOST_REQUIRE_EQUAL(fps.size(), 1);
497 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
498 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
499 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
500 type = artdaq::Fragment::ContainerFragmentType;
501 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
502 auto cf4 = artdaq::ContainerFragment(*fps.front());
503 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
504 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
505 type = artdaq::Fragment::FirstUserFragmentType;
506 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
507 BOOST_REQUIRE_EQUAL(cf4.at(0)->timestamp(), 7);
508 BOOST_REQUIRE_EQUAL(cf4.at(1)->timestamp(), 8);
509 BOOST_REQUIRE_EQUAL(cf4.at(2)->timestamp(), 9);
511 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
513 gen.StopCmd(0xFFFFFFFF, 1);
516 TLOG(TLVL_INFO) <<
"CircularBufferMode test case END";
519 BOOST_AUTO_TEST_CASE(WindowMode_Function)
521 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
522 TLOG(TLVL_INFO) <<
"WindowMode_Function test case BEGIN";
523 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
524 const int DELAY_TIME = 100;
525 fhicl::ParameterSet ps;
526 ps.put<
int>(
"board_id", 1);
527 ps.put<
int>(
"fragment_id", 1);
528 ps.put<
int>(
"request_port", REQUEST_PORT);
530 ps.put<std::string>(
"request_address",
"227.18.12.32");
532 ps.put<std::string>(
"request_address",
"localhost");
534 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
535 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
536 ps.put<
bool>(
"separate_data_thread",
true);
537 ps.put<
bool>(
"separate_monitoring_thread",
false);
538 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
539 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
540 ps.put<
bool>(
"circular_buffer_mode",
true);
541 ps.put<std::string>(
"request_mode",
"window");
542 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
543 ps.put<
size_t>(
"window_close_timeout_us", 500000);
544 ps.put(
"request_delay_ms", DELAY_TIME);
545 ps.put(
"send_requests",
true);
552 gen.StartCmd(1, 0xFFFFFFFF, 1);
554 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
556 artdaq::FragmentPtrs fps;
557 auto sts = gen.getNext(fps);
558 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
559 BOOST_REQUIRE_EQUAL(sts,
true);
560 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
561 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
562 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
563 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
564 auto type = artdaq::Fragment::ContainerFragmentType;
565 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
566 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
567 auto cf = artdaq::ContainerFragment(*fps.front());
568 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
569 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
570 type = artdaq::Fragment::FirstUserFragmentType;
571 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
576 sts = gen.getNext(fps);
577 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
578 BOOST_REQUIRE_EQUAL(sts,
true);
579 BOOST_REQUIRE_EQUAL(fps.size(), 0);
583 sts = gen.getNext(fps);
584 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
585 BOOST_REQUIRE_EQUAL(sts,
true);
586 BOOST_REQUIRE_EQUAL(fps.size(), 1);
587 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
588 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
589 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
590 type = artdaq::Fragment::ContainerFragmentType;
591 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
592 auto cf2 = artdaq::ContainerFragment(*fps.front());
593 BOOST_REQUIRE_EQUAL(cf2.block_count(), 1);
594 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
false);
595 type = artdaq::Fragment::FirstUserFragmentType;
596 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
601 sts = gen.getNext(fps);
602 BOOST_REQUIRE_EQUAL(sts,
true);
603 BOOST_REQUIRE_EQUAL(fps.size(), 0);
604 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
607 sts = gen.getNext(fps);
608 BOOST_REQUIRE_EQUAL(sts,
true);
609 BOOST_REQUIRE_EQUAL(fps.size(), 1);
612 auto list = gen.GetSentWindowList(1);
613 BOOST_REQUIRE_EQUAL(list.size(), 1);
614 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
615 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
619 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
620 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
621 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
622 type = artdaq::Fragment::ContainerFragmentType;
623 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
624 auto cf3 = artdaq::ContainerFragment(*fps.front());
625 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
626 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
true);
627 type = artdaq::Fragment::EmptyFragmentType;
628 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
629 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
633 gen.setFireCount(12);
636 list = gen.GetSentWindowList(1);
637 BOOST_REQUIRE_EQUAL(list.size(), 1);
638 sts = gen.getNext(fps);
639 list = gen.GetSentWindowList(1);
640 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
641 BOOST_REQUIRE_EQUAL(list.size(), 0);
642 BOOST_REQUIRE_EQUAL(sts,
true);
643 BOOST_REQUIRE_EQUAL(fps.size(), 1);
644 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
645 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
646 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
647 type = artdaq::Fragment::ContainerFragmentType;
648 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
649 auto cf4 = artdaq::ContainerFragment(*fps.front());
650 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
651 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
652 type = artdaq::Fragment::EmptyFragmentType;
653 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
658 sts = gen.getNext(fps);
659 BOOST_REQUIRE_EQUAL(sts,
true);
660 BOOST_REQUIRE_EQUAL(fps.size(), 1);
661 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
662 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
663 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
664 type = artdaq::Fragment::ContainerFragmentType;
665 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
666 auto cf5 = artdaq::ContainerFragment(*fps.front());
667 BOOST_REQUIRE_EQUAL(cf5.block_count(), 1);
668 BOOST_REQUIRE_EQUAL(cf5.missing_data(),
false);
669 type = artdaq::Fragment::FirstUserFragmentType;
670 BOOST_REQUIRE_EQUAL(cf5.fragment_type(), type);
671 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
674 list = gen.GetSentWindowList(1);
675 BOOST_REQUIRE_EQUAL(list.size(), 1);
676 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
679 sts = gen.getNext(fps);
680 BOOST_REQUIRE_EQUAL(sts,
true);
681 BOOST_REQUIRE_EQUAL(fps.size(), 1);
682 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
683 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
684 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
685 type = artdaq::Fragment::ContainerFragmentType;
686 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
687 auto cf6 = artdaq::ContainerFragment(*fps.front());
688 BOOST_REQUIRE_EQUAL(cf6.block_count(), 1);
689 BOOST_REQUIRE_EQUAL(cf6.missing_data(),
false);
690 type = artdaq::Fragment::FirstUserFragmentType;
691 BOOST_REQUIRE_EQUAL(cf6.fragment_type(), type);
693 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 8);
695 list = gen.GetSentWindowList(1);
696 BOOST_REQUIRE_EQUAL(list.size(), 0);
700 gen.StopCmd(0xFFFFFFFF, 1);
701 TLOG(TLVL_INFO) <<
"WindowMode_Function test case END";
711 BOOST_AUTO_TEST_CASE(WindowMode_RequestBeforeBuffer)
713 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
714 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case BEGIN";
715 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
716 const int DELAY_TIME = 100;
717 fhicl::ParameterSet ps;
718 ps.put<
int>(
"board_id", 1);
719 ps.put<
int>(
"fragment_id", 1);
720 ps.put<
int>(
"request_port", REQUEST_PORT);
722 ps.put<std::string>(
"request_address",
"227.18.12.32");
724 ps.put<std::string>(
"request_address",
"localhost");
726 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
727 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
728 ps.put<
bool>(
"separate_data_thread",
true);
729 ps.put<
bool>(
"separate_monitoring_thread",
false);
730 ps.put<
bool>(
"circular_buffer_mode",
true);
731 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
732 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
733 ps.put<std::string>(
"request_mode",
"window");
734 ps.put(
"request_delay_ms", DELAY_TIME);
735 ps.put(
"send_requests",
true);
741 gen.StartCmd(1, 0xFFFFFFFF, 1);
744 artdaq::FragmentPtrs fps;
746 artdaq::Fragment::type_t type;
754 sts = gen.getNext(fps);
755 BOOST_REQUIRE_EQUAL(sts,
true);
756 BOOST_REQUIRE_EQUAL(fps.size(), 1);
757 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
758 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
759 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
760 type = artdaq::Fragment::ContainerFragmentType;
761 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
762 auto cf4 = artdaq::ContainerFragment(*fps.front());
763 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
764 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
765 type = artdaq::Fragment::EmptyFragmentType;
766 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
768 gen.StopCmd(0xFFFFFFFF, 1);
769 TLOG(TLVL_INFO) <<
"WindowMode_RequestBeforeBuffer test case END";
771 BOOST_AUTO_TEST_CASE(WindowMode_RequestStartsBeforeBuffer)
773 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
774 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case BEGIN";
775 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
776 const int DELAY_TIME = 100;
777 fhicl::ParameterSet ps;
778 ps.put<
int>(
"board_id", 1);
779 ps.put<
int>(
"fragment_id", 1);
780 ps.put<
int>(
"request_port", REQUEST_PORT);
782 ps.put<std::string>(
"request_address",
"227.18.12.32");
784 ps.put<std::string>(
"request_address",
"localhost");
786 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
787 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
788 ps.put<
bool>(
"separate_data_thread",
true);
789 ps.put<
bool>(
"separate_monitoring_thread",
false);
790 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
791 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
792 ps.put<
bool>(
"circular_buffer_mode",
true);
793 ps.put<std::string>(
"request_mode",
"window");
794 ps.put(
"request_delay_ms", DELAY_TIME);
795 ps.put(
"send_requests",
true);
801 gen.StartCmd(1, 0xFFFFFFFF, 1);
804 artdaq::FragmentPtrs fps;
806 artdaq::Fragment::type_t type;
816 sts = gen.getNext(fps);
817 BOOST_REQUIRE_EQUAL(sts,
true);
818 BOOST_REQUIRE_EQUAL(fps.size(), 1);
819 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
820 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
821 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
822 type = artdaq::Fragment::ContainerFragmentType;
823 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
824 auto cf4 = artdaq::ContainerFragment(*fps.front());
825 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
826 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
827 type = artdaq::Fragment::FirstUserFragmentType;
828 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
830 gen.StopCmd(0xFFFFFFFF, 1);
832 TLOG(TLVL_INFO) <<
"WindowMode_RequestStartsBeforeBuffer test case END";
834 BOOST_AUTO_TEST_CASE(WindowMode_RequestOutsideBuffer)
836 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
837 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case BEGIN";
838 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
839 const int DELAY_TIME = 100;
840 fhicl::ParameterSet ps;
841 ps.put<
int>(
"board_id", 1);
842 ps.put<
int>(
"fragment_id", 1);
843 ps.put<
int>(
"request_port", REQUEST_PORT);
845 ps.put<std::string>(
"request_address",
"227.18.12.32");
847 ps.put<std::string>(
"request_address",
"localhost");
849 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
850 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 4);
851 ps.put<
size_t>(
"window_close_timeout_us", 500000);
852 ps.put<
bool>(
"separate_data_thread",
true);
853 ps.put<
bool>(
"separate_monitoring_thread",
false);
854 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
855 ps.put<
bool>(
"circular_buffer_mode",
true);
856 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
857 ps.put<std::string>(
"request_mode",
"window");
858 ps.put(
"request_delay_ms", DELAY_TIME);
859 ps.put(
"send_requests",
true);
865 gen.StartCmd(1, 0xFFFFFFFF, 1);
868 artdaq::FragmentPtrs fps;
870 artdaq::Fragment::type_t type;
880 sts = gen.getNext(fps);
881 BOOST_REQUIRE_EQUAL(sts,
true);
882 BOOST_REQUIRE_EQUAL(fps.size(), 1);
883 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
884 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
885 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
886 type = artdaq::Fragment::ContainerFragmentType;
887 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
888 auto cf = artdaq::ContainerFragment(*fps.front());
889 BOOST_REQUIRE_EQUAL(cf.block_count(), 4);
890 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
891 type = artdaq::Fragment::FirstUserFragmentType;
892 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
896 sts = gen.getNext(fps);
897 BOOST_REQUIRE_EQUAL(sts,
true);
898 BOOST_REQUIRE_EQUAL(fps.size(), 0);
903 sts = gen.getNext(fps);
904 BOOST_REQUIRE_EQUAL(sts,
true);
905 BOOST_REQUIRE_EQUAL(fps.size(), 1);
906 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
907 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
908 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
909 type = artdaq::Fragment::ContainerFragmentType;
910 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
911 auto cf2 = artdaq::ContainerFragment(*fps.front());
912 BOOST_REQUIRE_EQUAL(cf2.block_count(), 3);
913 BOOST_REQUIRE_EQUAL(cf2.missing_data(),
true);
914 type = artdaq::Fragment::FirstUserFragmentType;
915 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
920 sts = gen.getNext(fps);
921 BOOST_REQUIRE_EQUAL(sts,
true);
922 BOOST_REQUIRE_EQUAL(fps.size(), 0);
926 sts = gen.getNext(fps);
927 BOOST_REQUIRE_EQUAL(sts,
true);
928 BOOST_REQUIRE_EQUAL(fps.size(), 1);
929 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
930 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
931 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
932 type = artdaq::Fragment::ContainerFragmentType;
933 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
934 auto cf4 = artdaq::ContainerFragment(*fps.front());
935 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
936 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
937 type = artdaq::Fragment::FirstUserFragmentType;
938 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
940 gen.StopCmd(0xFFFFFFFF, 1);
942 TLOG(TLVL_INFO) <<
"WindowMode_RequestOutsideBuffer test case END";
944 BOOST_AUTO_TEST_CASE(WindowMode_RequestInBuffer)
946 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
947 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case BEGIN";
948 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
949 const int DELAY_TIME = 100;
950 fhicl::ParameterSet ps;
951 ps.put<
int>(
"board_id", 1);
952 ps.put<
int>(
"fragment_id", 1);
953 ps.put<
int>(
"request_port", REQUEST_PORT);
955 ps.put<std::string>(
"request_address",
"227.18.12.32");
957 ps.put<std::string>(
"request_address",
"localhost");
959 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
960 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
961 ps.put<
bool>(
"separate_data_thread",
true);
962 ps.put<
bool>(
"separate_monitoring_thread",
false);
963 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
964 ps.put<
bool>(
"circular_buffer_mode",
true);
965 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
966 ps.put<std::string>(
"request_mode",
"window");
967 ps.put(
"request_delay_ms", DELAY_TIME);
968 ps.put(
"send_requests",
true);
974 gen.StartCmd(1, 0xFFFFFFFF, 1);
976 artdaq::FragmentPtrs fps;
978 artdaq::Fragment::type_t type;
987 sts = gen.getNext(fps);
988 BOOST_REQUIRE_EQUAL(sts,
true);
989 BOOST_REQUIRE_EQUAL(fps.size(), 1);
990 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
991 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
992 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
993 type = artdaq::Fragment::ContainerFragmentType;
994 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
995 auto cf4 = artdaq::ContainerFragment(*fps.front());
996 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
997 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
false);
998 type = artdaq::Fragment::FirstUserFragmentType;
999 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1001 gen.StopCmd(0xFFFFFFFF, 1);
1002 TLOG(TLVL_INFO) <<
"WindowMode_RequestInBuffer test case END";
1004 BOOST_AUTO_TEST_CASE(WindowMode_RequestEndsAfterBuffer)
1006 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1007 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case BEGIN";
1008 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1009 const int DELAY_TIME = 100;
1010 fhicl::ParameterSet ps;
1011 ps.put<
int>(
"board_id", 1);
1012 ps.put<
int>(
"fragment_id", 1);
1013 ps.put<
int>(
"request_port", REQUEST_PORT);
1015 ps.put<std::string>(
"request_address",
"227.18.12.32");
1017 ps.put<std::string>(
"request_address",
"localhost");
1019 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1020 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1021 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1022 ps.put<
bool>(
"separate_data_thread",
true);
1023 ps.put<
bool>(
"separate_monitoring_thread",
false);
1024 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1025 ps.put<
bool>(
"circular_buffer_mode",
true);
1026 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1027 ps.put<std::string>(
"request_mode",
"window");
1028 ps.put(
"request_delay_ms", DELAY_TIME);
1029 ps.put(
"send_requests",
true);
1035 gen.StartCmd(1, 0xFFFFFFFF, 1);
1037 artdaq::FragmentPtrs fps;
1039 artdaq::Fragment::type_t type;
1041 gen.setFireCount(5);
1047 sts = gen.getNext(fps);
1048 BOOST_REQUIRE_EQUAL(sts,
true);
1049 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1051 gen.setFireCount(2);
1053 sts = gen.getNext(fps);
1054 BOOST_REQUIRE_EQUAL(sts,
true);
1055 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1056 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1057 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1058 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1059 type = artdaq::Fragment::ContainerFragmentType;
1060 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1061 auto cf = artdaq::ContainerFragment(*fps.front());
1062 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1063 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1064 type = artdaq::Fragment::FirstUserFragmentType;
1065 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1070 sts = gen.getNext(fps);
1071 BOOST_REQUIRE_EQUAL(sts,
true);
1072 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1076 sts = gen.getNext(fps);
1077 BOOST_REQUIRE_EQUAL(sts,
true);
1078 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1079 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1080 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1081 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1082 type = artdaq::Fragment::ContainerFragmentType;
1083 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1084 auto cf4 = artdaq::ContainerFragment(*fps.front());
1085 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
1086 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1087 type = artdaq::Fragment::FirstUserFragmentType;
1088 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1090 gen.StopCmd(0xFFFFFFFF, 1);
1092 TLOG(TLVL_INFO) <<
"WindowMode_RequestEndsAfterBuffer test case END";
1094 BOOST_AUTO_TEST_CASE(WindowMode_RequestAfterBuffer)
1096 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1097 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case BEGIN";
1098 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1099 const int DELAY_TIME = 100;
1100 fhicl::ParameterSet ps;
1101 ps.put<
int>(
"board_id", 1);
1102 ps.put<
int>(
"fragment_id", 1);
1103 ps.put<
int>(
"request_port", REQUEST_PORT);
1105 ps.put<std::string>(
"request_address",
"227.18.12.32");
1107 ps.put<std::string>(
"request_address",
"localhost");
1109 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1110 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 3);
1111 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1112 ps.put<
bool>(
"separate_data_thread",
true);
1113 ps.put<
bool>(
"separate_monitoring_thread",
false);
1114 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1115 ps.put<
bool>(
"circular_buffer_mode",
true);
1116 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1117 ps.put<std::string>(
"request_mode",
"window");
1118 ps.put(
"request_delay_ms", DELAY_TIME);
1119 ps.put(
"send_requests",
true);
1125 gen.StartCmd(1, 0xFFFFFFFF, 1);
1127 artdaq::FragmentPtrs fps;
1129 artdaq::Fragment::type_t type;
1134 gen.setFireCount(9);
1136 t.AddRequest(1, 11);
1138 sts = gen.getNext(fps);
1139 BOOST_REQUIRE_EQUAL(sts,
true);
1140 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1141 gen.setFireCount(1);
1143 sts = gen.getNext(fps);
1144 BOOST_REQUIRE_EQUAL(sts,
true);
1145 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1147 gen.setFireCount(3);
1149 sts = gen.getNext(fps);
1150 BOOST_REQUIRE_EQUAL(sts,
true);
1151 BOOST_REQUIRE_EQUAL(fps.size(), 1);
1152 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1153 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
1154 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1155 type = artdaq::Fragment::ContainerFragmentType;
1156 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1157 auto cf = artdaq::ContainerFragment(*fps.front());
1158 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1159 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1160 type = artdaq::Fragment::FirstUserFragmentType;
1161 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1164 t.AddRequest(2, 16);
1165 sts = gen.getNext(fps);
1166 BOOST_REQUIRE_EQUAL(sts,
true);
1167 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1171 sts = gen.getNext(fps);
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(), 16);
1176 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1177 type = artdaq::Fragment::ContainerFragmentType;
1178 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1179 auto cf4 = artdaq::ContainerFragment(*fps.front());
1180 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
1181 BOOST_REQUIRE_EQUAL(cf4.missing_data(),
true);
1182 type = artdaq::Fragment::EmptyFragmentType;
1183 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
1185 gen.StopCmd(0xFFFFFFFF, 1);
1187 TLOG(TLVL_INFO) <<
"WindowMode_RequestAfterBuffer test case END";
1190 BOOST_AUTO_TEST_CASE(HardwareFailure_NonThreaded)
1192 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1193 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case BEGIN";
1194 fhicl::ParameterSet ps;
1195 ps.put<
int>(
"board_id", 1);
1196 ps.put<
int>(
"fragment_id", 1);
1197 ps.put<
bool>(
"separate_data_thread",
false);
1198 ps.put<
bool>(
"separate_monitoring_thread",
false);
1199 ps.put<int64_t>(
"hardware_poll_interval_us", 10);
1202 gen.StartCmd(1, 0xFFFFFFFF, 1);
1204 artdaq::FragmentPtrs fps;
1205 auto sts = gen.getNext(fps);
1206 BOOST_REQUIRE_EQUAL(sts,
true);
1207 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1208 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1209 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1210 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1213 gen.setFireCount(1);
1216 sts = gen.getNext(fps);
1217 BOOST_REQUIRE_EQUAL(sts,
false);
1218 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1220 gen.StopCmd(0xFFFFFFFF, 1);
1222 TLOG(TLVL_INFO) <<
"HardwareFailure_NonThreaded test case END";
1225 BOOST_AUTO_TEST_CASE(HardwareFailure_Threaded)
1227 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1228 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case BEGIN";
1229 fhicl::ParameterSet ps;
1230 ps.put<
int>(
"board_id", 1);
1231 ps.put<
int>(
"fragment_id", 1);
1232 ps.put<
bool>(
"separate_data_thread",
true);
1233 ps.put<
bool>(
"separate_monitoring_thread",
true);
1234 ps.put<int64_t>(
"hardware_poll_interval_us", 750000);
1237 gen.StartCmd(1, 0xFFFFFFFF, 1);
1240 artdaq::FragmentPtrs fps;
1241 auto sts = gen.getNext(fps);
1242 BOOST_REQUIRE_EQUAL(sts,
true);
1243 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
1244 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
1245 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1246 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1261 gen.setFireCount(1);
1262 sts = gen.getNext(fps);
1263 BOOST_REQUIRE_EQUAL(sts,
false);
1264 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1266 gen.StopCmd(0xFFFFFFFF, 1);
1268 TLOG(TLVL_INFO) <<
"HardwareFailure_Threaded test case END";
1271 BOOST_AUTO_TEST_CASE(IgnoreRequests_MultipleIDs)
1273 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1274 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case BEGIN";
1275 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1276 const int DELAY_TIME = 1;
1277 fhicl::ParameterSet ps;
1278 ps.put<
int>(
"board_id", 1);
1279 ps.put<std::vector<int>>(
"fragment_ids", { 1,2,3 });
1280 ps.put<
int>(
"request_port", REQUEST_PORT);
1282 ps.put<std::string>(
"request_address",
"227.18.12.29");
1284 ps.put<std::string>(
"request_address",
"localhost");
1286 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1287 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1288 ps.put<
bool>(
"separate_data_thread",
true);
1289 ps.put<
bool>(
"separate_monitoring_thread",
false);
1290 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1291 ps.put<std::string>(
"request_mode",
"ignored");
1292 ps.put(
"request_delay_ms", DELAY_TIME);
1293 ps.put(
"send_requests",
true);
1297 gen.StartCmd(1, 0xFFFFFFFF, 1);
1299 t.AddRequest(53, 35);
1301 artdaq::FragmentPtrs fps;
1302 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1303 auto sts = gen.getNext(fps);
1304 BOOST_REQUIRE_EQUAL(sts,
true);
1305 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1306 while (fps.size() > 0)
1308 ids[fps.front()->fragmentID()]++;
1309 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1310 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1314 BOOST_REQUIRE_EQUAL(ids[1], 1);
1315 BOOST_REQUIRE_EQUAL(ids[2], 1);
1316 BOOST_REQUIRE_EQUAL(ids[3], 1);
1320 gen.setEnabledIds(0x6);
1321 gen.setFireCount(1);
1323 sts = gen.getNext(fps);
1325 BOOST_REQUIRE_EQUAL(sts,
true);
1326 BOOST_REQUIRE_EQUAL(fps.size(), 2u);
1327 while (fps.size() > 0)
1329 ids[fps.front()->fragmentID()]++;
1330 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
1331 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1334 BOOST_REQUIRE_EQUAL(ids[1], 1);
1335 BOOST_REQUIRE_EQUAL(ids[2], 1);
1337 gen.StopCmd(0xFFFFFFFF, 1);
1339 TLOG(TLVL_INFO) <<
"IgnoreRequests_MultipleIDs test case END";
1342 BOOST_AUTO_TEST_CASE(SingleMode_MultipleIDs)
1344 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1345 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case BEGIN";
1346 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1347 const int DELAY_TIME = 100;
1348 fhicl::ParameterSet ps;
1349 ps.put<
int>(
"board_id", 1);
1350 ps.put<std::vector<int>>(
"fragment_ids", { 1,2,3 });
1351 ps.put<
int>(
"request_port", REQUEST_PORT);
1353 ps.put<std::string>(
"request_address",
"227.18.12.30");
1355 ps.put<std::string>(
"request_address",
"localhost");
1357 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1358 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1359 ps.put<
bool>(
"separate_data_thread",
true);
1360 ps.put<
bool>(
"separate_monitoring_thread",
false);
1361 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1362 ps.put<std::string>(
"request_mode",
"single");
1363 ps.put(
"request_delay_ms", DELAY_TIME);
1364 ps.put(
"send_requests",
true);
1371 gen.StartCmd(1, 0xFFFFFFFF, 1);
1373 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
1375 artdaq::FragmentPtrs fps;
1376 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1377 auto sts = gen.getNext(fps);
1378 auto type = artdaq::Fragment::FirstUserFragmentType;
1379 BOOST_REQUIRE_EQUAL(sts,
true);
1380 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1381 while (fps.size() > 0)
1383 ids[fps.front()->fragmentID()]++;
1384 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1385 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1386 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1389 BOOST_REQUIRE_EQUAL(ids[1], 1);
1390 BOOST_REQUIRE_EQUAL(ids[2], 1);
1391 BOOST_REQUIRE_EQUAL(ids[3], 1);
1394 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
1398 sts = gen.getNext(fps);
1399 BOOST_REQUIRE_EQUAL(sts,
true);
1400 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1401 while (fps.size() > 0)
1403 ids[fps.front()->fragmentID()]++;
1404 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1405 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1406 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1409 BOOST_REQUIRE_EQUAL(ids[1], 1);
1410 BOOST_REQUIRE_EQUAL(ids[2], 1);
1411 BOOST_REQUIRE_EQUAL(ids[3], 1);
1414 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
1417 gen.setFireCount(2);
1420 sts = gen.getNext(fps);
1421 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
1422 BOOST_REQUIRE_EQUAL(sts,
true);
1423 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1424 auto ts = artdaq::Fragment::InvalidTimestamp;
1425 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1426 for (
auto ii = 0; ii < 3; ++ii)
1428 ids[fps.front()->fragmentID()]++;
1429 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1430 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1431 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1434 BOOST_REQUIRE_EQUAL(ids[1], 1);
1435 BOOST_REQUIRE_EQUAL(ids[2], 1);
1436 BOOST_REQUIRE_EQUAL(ids[3], 1);
1438 for (
auto ii = 0; ii < 3; ++ii)
1440 ids[fps.front()->fragmentID()]++;
1441 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1442 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1443 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1446 BOOST_REQUIRE_EQUAL(ids[1], 1);
1447 BOOST_REQUIRE_EQUAL(ids[2], 1);
1448 BOOST_REQUIRE_EQUAL(ids[3], 1);
1453 gen.setEnabledIds(0x6);
1454 gen.setFireCount(1);
1457 sts = gen.getNext(fps);
1458 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
1459 BOOST_REQUIRE_EQUAL(sts,
true);
1460 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1461 for (
auto ii = 0; ii < 3; ++ii)
1463 ids[fps.front()->fragmentID()]++;
1464 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
1465 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1466 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1469 BOOST_REQUIRE_EQUAL(ids[1], 1);
1470 BOOST_REQUIRE_EQUAL(ids[2], 1);
1471 BOOST_REQUIRE_EQUAL(ids[3], 1);
1475 gen.StopCmd(0xFFFFFFFF, 1);
1477 TLOG(TLVL_INFO) <<
"SingleMode_MultipleIDs test case END";
1480 BOOST_AUTO_TEST_CASE(BufferMode_MultipleIDs)
1482 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1483 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case BEGIN";
1484 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1485 const int DELAY_TIME = 100;
1486 fhicl::ParameterSet ps;
1487 ps.put<
int>(
"board_id", 1);
1488 ps.put<std::vector<int>>(
"fragment_ids", { 1,2,3 });
1489 ps.put<
int>(
"request_port", REQUEST_PORT);
1491 ps.put<std::string>(
"request_address",
"227.18.12.31");
1493 ps.put<std::string>(
"request_address",
"localhost");
1495 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1496 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1497 ps.put<
bool>(
"separate_data_thread",
true);
1498 ps.put<
bool>(
"separate_monitoring_thread",
false);
1499 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1500 ps.put<std::string>(
"request_mode",
"buffer");
1501 ps.put(
"request_delay_ms", DELAY_TIME);
1502 ps.put(
"send_requests",
true);
1509 gen.StartCmd(1, 0xFFFFFFFF, 1);
1511 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
1513 artdaq::FragmentPtrs fps;
1514 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1515 auto sts = gen.getNext(fps);
1516 BOOST_REQUIRE_EQUAL(sts,
true);
1517 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1518 auto type = artdaq::Fragment::ContainerFragmentType;
1519 while (fps.size() > 0)
1521 ids[fps.front()->fragmentID()]++;
1522 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1523 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1524 type = artdaq::Fragment::ContainerFragmentType;
1525 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1526 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1527 auto cf = artdaq::ContainerFragment(*fps.front());
1528 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1529 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1530 type = artdaq::Fragment::FirstUserFragmentType;
1531 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1534 BOOST_REQUIRE_EQUAL(ids[1], 1);
1535 BOOST_REQUIRE_EQUAL(ids[2], 1);
1536 BOOST_REQUIRE_EQUAL(ids[3], 1);
1538 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
1542 sts = gen.getNext(fps);
1543 BOOST_REQUIRE_EQUAL(sts,
true);
1544 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1545 while (fps.size() > 0)
1547 ids[fps.front()->fragmentID()]++;
1548 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1549 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1550 type = artdaq::Fragment::ContainerFragmentType;
1551 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1552 auto cf = artdaq::ContainerFragment(*fps.front());
1553 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1554 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1555 type = artdaq::Fragment::EmptyFragmentType;
1556 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1559 BOOST_REQUIRE_EQUAL(ids[1], 1);
1560 BOOST_REQUIRE_EQUAL(ids[2], 1);
1561 BOOST_REQUIRE_EQUAL(ids[3], 1);
1563 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
1566 gen.setFireCount(2);
1569 sts = gen.getNext(fps);
1570 BOOST_REQUIRE_EQUAL(sts,
true);
1571 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1573 auto ts = artdaq::Fragment::InvalidTimestamp;
1574 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1575 for (
auto ii = 0; ii < 3; ++ii)
1577 ids[fps.front()->fragmentID()]++;
1578 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1579 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1580 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1581 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1584 BOOST_REQUIRE_EQUAL(ids[1], 1);
1585 BOOST_REQUIRE_EQUAL(ids[2], 1);
1586 BOOST_REQUIRE_EQUAL(ids[3], 1);
1588 for (
auto ii = 0; ii < 3; ++ii)
1590 ids[fps.front()->fragmentID()]++;
1591 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1592 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1593 type = artdaq::Fragment::ContainerFragmentType;
1594 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1595 auto cf3 = artdaq::ContainerFragment(*fps.front());
1596 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1597 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1598 type = artdaq::Fragment::FirstUserFragmentType;
1599 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1602 BOOST_REQUIRE_EQUAL(ids[1], 1);
1603 BOOST_REQUIRE_EQUAL(ids[2], 1);
1604 BOOST_REQUIRE_EQUAL(ids[3], 1);
1608 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
1610 gen.setEnabledIds(0x6);
1611 gen.setFireCount(2);
1614 sts = gen.getNext(fps);
1615 BOOST_REQUIRE_EQUAL(sts,
true);
1616 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1618 for (
auto ii = 0; ii < 3; ++ii)
1620 ids[fps.front()->fragmentID()]++;
1621 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1622 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1623 type = artdaq::Fragment::ContainerFragmentType;
1624 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1625 auto cf3 = artdaq::ContainerFragment(*fps.front());
1626 if (fps.front()->fragmentID() != 3)
1628 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
1629 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1630 type = artdaq::Fragment::FirstUserFragmentType;
1631 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1635 BOOST_REQUIRE_EQUAL(cf3.block_count(), 0);
1636 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1637 type = artdaq::Fragment::EmptyFragmentType;
1638 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1642 BOOST_REQUIRE_EQUAL(ids[1], 1);
1643 BOOST_REQUIRE_EQUAL(ids[2], 1);
1644 BOOST_REQUIRE_EQUAL(ids[3], 1);
1648 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
1650 gen.StopCmd(0xFFFFFFFF, 1);
1653 TLOG(TLVL_INFO) <<
"BufferMode_MultipleIDs test case END";
1656 BOOST_AUTO_TEST_CASE(CircularBufferMode_MultipleIDs)
1658 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1659 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case BEGIN";
1660 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1661 const int DELAY_TIME = 100;
1662 fhicl::ParameterSet ps;
1663 ps.put<
int>(
"board_id", 1);
1664 ps.put<std::vector<int>>(
"fragment_ids", { 1,2,3 });
1665 ps.put<
int>(
"request_port", REQUEST_PORT);
1667 ps.put<std::string>(
"request_address",
"227.18.12.31");
1669 ps.put<std::string>(
"request_address",
"localhost");
1671 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1672 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1673 ps.put<
bool>(
"separate_data_thread",
true);
1674 ps.put<
bool>(
"circular_buffer_mode",
true);
1675 ps.put<
int>(
"data_buffer_depth_fragments", 3);
1676 ps.put<
bool>(
"separate_monitoring_thread",
false);
1677 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1678 ps.put<std::string>(
"request_mode",
"buffer");
1679 ps.put(
"request_delay_ms", DELAY_TIME);
1680 ps.put(
"send_requests",
true);
1687 gen.StartCmd(1, 0xFFFFFFFF, 1);
1689 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
1691 artdaq::FragmentPtrs fps;
1692 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1693 auto sts = gen.getNext(fps);
1694 auto type = artdaq::Fragment::ContainerFragmentType;
1695 BOOST_REQUIRE_EQUAL(sts,
true);
1696 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1697 while (fps.size() > 0)
1699 ids[fps.front()->fragmentID()]++;
1700 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
1701 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1702 type = artdaq::Fragment::ContainerFragmentType;
1703 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1704 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1705 auto cf = artdaq::ContainerFragment(*fps.front());
1706 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1707 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1708 type = artdaq::Fragment::FirstUserFragmentType;
1709 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1712 BOOST_REQUIRE_EQUAL(ids[1], 1);
1713 BOOST_REQUIRE_EQUAL(ids[2], 1);
1714 BOOST_REQUIRE_EQUAL(ids[3], 1);
1717 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
1721 sts = gen.getNext(fps);
1722 BOOST_REQUIRE_EQUAL(sts,
true);
1723 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1724 while (fps.size() > 0)
1726 ids[fps.front()->fragmentID()]++;
1727 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
1728 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
1729 type = artdaq::Fragment::ContainerFragmentType;
1730 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1731 auto cf = artdaq::ContainerFragment(*fps.front());
1732 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1733 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1734 type = artdaq::Fragment::EmptyFragmentType;
1735 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1738 BOOST_REQUIRE_EQUAL(ids[1], 1);
1739 BOOST_REQUIRE_EQUAL(ids[2], 1);
1740 BOOST_REQUIRE_EQUAL(ids[3], 1);
1743 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
1746 gen.setFireCount(3);
1749 sts = gen.getNext(fps);
1750 BOOST_REQUIRE_EQUAL(sts,
true);
1751 BOOST_REQUIRE_EQUAL(fps.size(), 6);
1753 auto ts = artdaq::Fragment::InvalidTimestamp;
1754 auto emptyType = artdaq::Fragment::EmptyFragmentType;
1755 for (
auto ii = 0; ii < 3; ++ii)
1757 ids[fps.front()->fragmentID()]++;
1758 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
1759 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
1760 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
1761 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
1764 BOOST_REQUIRE_EQUAL(ids[1], 1);
1765 BOOST_REQUIRE_EQUAL(ids[2], 1);
1766 BOOST_REQUIRE_EQUAL(ids[3], 1);
1768 for (
auto ii = 0; ii < 3; ++ii)
1770 ids[fps.front()->fragmentID()]++;
1771 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
1772 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1773 type = artdaq::Fragment::ContainerFragmentType;
1774 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1775 auto cf3 = artdaq::ContainerFragment(*fps.front());
1776 BOOST_REQUIRE_EQUAL(cf3.block_count(), 3);
1777 BOOST_REQUIRE_EQUAL(cf3.missing_data(),
false);
1778 type = artdaq::Fragment::FirstUserFragmentType;
1779 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
1782 BOOST_REQUIRE_EQUAL(ids[1], 1);
1783 BOOST_REQUIRE_EQUAL(ids[2], 1);
1784 BOOST_REQUIRE_EQUAL(ids[3], 1);
1788 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 5);
1790 gen.setFireCount(5);
1793 sts = gen.getNext(fps);
1794 BOOST_REQUIRE_EQUAL(sts,
true);
1795 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1796 while (fps.size() > 0)
1798 ids[fps.front()->fragmentID()]++;
1799 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
1800 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
1801 type = artdaq::Fragment::ContainerFragmentType;
1802 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1803 auto cf = artdaq::ContainerFragment(*fps.front());
1804 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1805 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1806 type = artdaq::Fragment::FirstUserFragmentType;
1807 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1808 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 7);
1809 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 8);
1810 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 9);
1813 BOOST_REQUIRE_EQUAL(ids[1], 1);
1814 BOOST_REQUIRE_EQUAL(ids[2], 1);
1815 BOOST_REQUIRE_EQUAL(ids[3], 1);
1819 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
1821 gen.setFireCount(1);
1823 gen.setEnabledIds(0x6);
1824 gen.setFireCount(4);
1826 t.AddRequest(6, 10);
1827 sts = gen.getNext(fps);
1828 BOOST_REQUIRE_EQUAL(sts,
true);
1829 BOOST_REQUIRE_EQUAL(fps.size(), 3u);
1830 while (fps.size() > 0)
1832 ids[fps.front()->fragmentID()]++;
1833 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 10);
1834 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
1835 type = artdaq::Fragment::ContainerFragmentType;
1836 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1837 auto cf = artdaq::ContainerFragment(*fps.front());
1838 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1839 type = artdaq::Fragment::FirstUserFragmentType;
1840 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1842 if (fps.front()->fragmentID() != 3)
1844 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
1845 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 12);
1846 BOOST_REQUIRE_EQUAL(cf.at(1)->timestamp(), 13);
1847 BOOST_REQUIRE_EQUAL(cf.at(2)->timestamp(), 14);
1851 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1852 BOOST_REQUIRE_EQUAL(cf.at(0)->timestamp(), 10);
1856 BOOST_REQUIRE_EQUAL(ids[1], 1);
1857 BOOST_REQUIRE_EQUAL(ids[2], 1);
1858 BOOST_REQUIRE_EQUAL(ids[3], 1);
1862 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 7);
1864 gen.StopCmd(0xFFFFFFFF, 1);
1867 TLOG(TLVL_INFO) <<
"CircularBufferMode_MultipleIDs test case END";
1870 BOOST_AUTO_TEST_CASE(WindowMode_Function_MultipleIDs)
1872 artdaq::configureMessageFacility(
"CommandableFragmentGenerator_t");
1873 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case BEGIN";
1874 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
1875 const int DELAY_TIME = 100;
1876 fhicl::ParameterSet ps;
1877 ps.put<
int>(
"board_id", 1);
1878 ps.put<std::vector<int>>(
"fragment_ids", { 1,2,3 });
1879 ps.put<
int>(
"request_port", REQUEST_PORT);
1881 ps.put<std::string>(
"request_address",
"227.18.12.32");
1883 ps.put<std::string>(
"request_address",
"localhost");
1885 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_offset", 0);
1886 ps.put<artdaq::Fragment::timestamp_t>(
"request_window_width", 0);
1887 ps.put<
bool>(
"separate_data_thread",
true);
1888 ps.put<
bool>(
"separate_monitoring_thread",
false);
1889 ps.put<int64_t>(
"hardware_poll_interval_us", 0);
1890 ps.put<
size_t>(
"data_buffer_depth_fragments", 5);
1891 ps.put<
bool>(
"circular_buffer_mode",
true);
1892 ps.put<std::string>(
"request_mode",
"window");
1893 ps.put<
size_t>(
"missing_request_window_timeout_us", 500000);
1894 ps.put<
size_t>(
"window_close_timeout_us", 500000);
1895 ps.put(
"request_delay_ms", DELAY_TIME);
1896 ps.put(
"send_requests",
true);
1903 gen.StartCmd(1, 0xFFFFFFFF, 1);
1905 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 1);
1907 artdaq::FragmentPtrs fps;
1908 std::map<artdaq::Fragment::fragment_id_t, size_t> ids;
1909 auto sts = gen.getNext(fps);
1910 auto type = artdaq::Fragment::ContainerFragmentType;
1911 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
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(), 1);
1918 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
1919 type = artdaq::Fragment::ContainerFragmentType;
1920 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1921 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 *
sizeof(artdaq::detail::RawFragmentHeader) +
sizeof(artdaq::ContainerFragment::Metadata));
1922 auto cf = artdaq::ContainerFragment(*fps.front());
1923 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
1924 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1925 type = artdaq::Fragment::FirstUserFragmentType;
1926 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1929 BOOST_REQUIRE_EQUAL(ids[1], 1);
1930 BOOST_REQUIRE_EQUAL(ids[2], 1);
1931 BOOST_REQUIRE_EQUAL(ids[3], 1);
1937 sts = gen.getNext(fps);
1938 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 2);
1939 BOOST_REQUIRE_EQUAL(sts,
true);
1940 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1942 gen.setFireCount(1);
1944 sts = gen.getNext(fps);
1945 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
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(), 2);
1952 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
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.block_count(), 1);
1957 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
1958 type = artdaq::Fragment::FirstUserFragmentType;
1959 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
1962 BOOST_REQUIRE_EQUAL(ids[1], 1);
1963 BOOST_REQUIRE_EQUAL(ids[2], 1);
1964 BOOST_REQUIRE_EQUAL(ids[3], 1);
1970 sts = gen.getNext(fps);
1971 BOOST_REQUIRE_EQUAL(sts,
true);
1972 BOOST_REQUIRE_EQUAL(fps.size(), 0);
1973 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
1976 sts = gen.getNext(fps);
1977 BOOST_REQUIRE_EQUAL(sts,
true);
1978 BOOST_REQUIRE_EQUAL(fps.size(), 3);
1981 auto list = gen.GetSentWindowList(1);
1982 BOOST_REQUIRE_EQUAL(list.size(), 1);
1983 BOOST_REQUIRE_EQUAL(list.begin()->first, 4);
1984 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
1988 while (fps.size() > 0)
1990 ids[fps.front()->fragmentID()]++;
1991 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
1992 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
1993 type = artdaq::Fragment::ContainerFragmentType;
1994 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
1995 auto cf = artdaq::ContainerFragment(*fps.front());
1996 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
1997 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
1998 type = artdaq::Fragment::EmptyFragmentType;
1999 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2002 BOOST_REQUIRE_EQUAL(ids[1], 1);
2003 BOOST_REQUIRE_EQUAL(ids[2], 1);
2004 BOOST_REQUIRE_EQUAL(ids[3], 1);
2007 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 3);
2011 gen.setFireCount(12);
2014 list = gen.GetSentWindowList(1);
2015 BOOST_REQUIRE_EQUAL(list.size(), 1);
2016 sts = gen.getNext(fps);
2017 list = gen.GetSentWindowList(1);
2018 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
2019 BOOST_REQUIRE_EQUAL(list.size(), 0);
2020 BOOST_REQUIRE_EQUAL(sts,
true);
2021 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2022 while (fps.size() > 0)
2024 ids[fps.front()->fragmentID()]++;
2025 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
2026 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
2027 type = artdaq::Fragment::ContainerFragmentType;
2028 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2029 auto cf = artdaq::ContainerFragment(*fps.front());
2030 BOOST_REQUIRE_EQUAL(cf.block_count(), 0);
2031 BOOST_REQUIRE_EQUAL(cf.missing_data(),
true);
2032 type = artdaq::Fragment::EmptyFragmentType;
2033 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2036 BOOST_REQUIRE_EQUAL(ids[1], 1);
2037 BOOST_REQUIRE_EQUAL(ids[2], 1);
2038 BOOST_REQUIRE_EQUAL(ids[3], 1);
2043 t.AddRequest(7, 13);
2044 sts = gen.getNext(fps);
2045 BOOST_REQUIRE_EQUAL(sts,
true);
2046 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2047 while (fps.size() > 0)
2049 ids[fps.front()->fragmentID()]++;
2050 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 13);
2051 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 7);
2052 type = artdaq::Fragment::ContainerFragmentType;
2053 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2054 auto cf = artdaq::ContainerFragment(*fps.front());
2055 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2056 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2057 type = artdaq::Fragment::FirstUserFragmentType;
2058 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2061 BOOST_REQUIRE_EQUAL(ids[1], 1);
2062 BOOST_REQUIRE_EQUAL(ids[2], 1);
2063 BOOST_REQUIRE_EQUAL(ids[3], 1);
2065 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 6);
2068 list = gen.GetSentWindowList(1);
2069 BOOST_REQUIRE_EQUAL(list.size(), 1);
2070 BOOST_REQUIRE_EQUAL(list.begin()->first, 7);
2072 t.AddRequest(6, 12);
2073 sts = gen.getNext(fps);
2074 BOOST_REQUIRE_EQUAL(sts,
true);
2075 BOOST_REQUIRE_EQUAL(fps.size(), 3);
2076 while (fps.size() > 0)
2078 ids[fps.front()->fragmentID()]++;
2079 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
2080 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 6);
2081 type = artdaq::Fragment::ContainerFragmentType;
2082 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2083 auto cf = artdaq::ContainerFragment(*fps.front());
2084 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2085 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2086 type = artdaq::Fragment::FirstUserFragmentType;
2087 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2090 BOOST_REQUIRE_EQUAL(ids[1], 1);
2091 BOOST_REQUIRE_EQUAL(ids[2], 1);
2092 BOOST_REQUIRE_EQUAL(ids[3], 1);
2095 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 8);
2097 list = gen.GetSentWindowList(1);
2098 BOOST_REQUIRE_EQUAL(list.size(), 0);
2100 gen.setEnabledIds(0x6);
2101 gen.setFireCount(1);
2104 t.AddRequest(8, 15);
2105 sts = gen.getNext(fps);
2106 BOOST_REQUIRE_EQUAL(sts,
true);
2107 BOOST_REQUIRE_EQUAL(fps.size(), 2);
2108 while (fps.size() > 0)
2110 ids[fps.front()->fragmentID()]++;
2111 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2112 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2113 type = artdaq::Fragment::ContainerFragmentType;
2114 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2115 auto cf = artdaq::ContainerFragment(*fps.front());
2116 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2117 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2118 type = artdaq::Fragment::FirstUserFragmentType;
2119 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2122 BOOST_REQUIRE_EQUAL(ids[1], 1);
2123 BOOST_REQUIRE_EQUAL(ids[2], 1);
2124 BOOST_REQUIRE_EQUAL(ids[3], 0);
2127 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 8);
2129 gen.setEnabledIds(0x8);
2130 gen.setTimestamp(14);
2131 gen.setFireCount(1);
2134 sts = gen.getNext(fps);
2135 BOOST_REQUIRE_EQUAL(sts,
true);
2136 BOOST_REQUIRE_EQUAL(fps.size(), 1);
2137 while (fps.size() > 0)
2139 ids[fps.front()->fragmentID()]++;
2140 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 15);
2141 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 8);
2142 type = artdaq::Fragment::ContainerFragmentType;
2143 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
2144 auto cf = artdaq::ContainerFragment(*fps.front());
2145 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
2146 BOOST_REQUIRE_EQUAL(cf.missing_data(),
false);
2147 type = artdaq::Fragment::FirstUserFragmentType;
2148 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
2151 BOOST_REQUIRE_EQUAL(ids[1], 0);
2152 BOOST_REQUIRE_EQUAL(ids[2], 0);
2153 BOOST_REQUIRE_EQUAL(ids[3], 1);
2156 BOOST_REQUIRE_EQUAL(gen.ev_counter(), 9);
2158 gen.StopCmd(0xFFFFFFFF, 1);
2159 TLOG(TLVL_INFO) <<
"WindowMode_Function_MultipleIDs test case END";
2163 BOOST_AUTO_TEST_SUITE_END()
bool getNext_(artdaq::FragmentPtrs &frags) override
Generate data and return it to CommandableFragmentGenerator.
CommandableFragmentGenerator derived class for testing.
The RequestSender contains methods used to send data requests and Routing tokens. ...
CommandableFragmentGeneratorTest(const fhicl::ParameterSet &ps)
CommandableFragmentGeneratorTest Constructor.
bool checkHWStatus_() override
Returns whether the hwFail flag has not been set.
void stopNoMutex() override
Perform immediate stop actions. No-Op.
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.
void setHwFail()
Set the hwFail flag.
void stop() override
Perform stop actions. No-Op.
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.