00001 #define BOOST_TEST_MODULE CommandableFragmentGenerator_t
00002 #include <boost/test/auto_unit_test.hpp>
00003
00004 #include "artdaq-core/Data/Fragment.hh"
00005 #include "artdaq-core/Data/ContainerFragment.hh"
00006 #include "artdaq/Application/CommandableFragmentGenerator.hh"
00007 #include "artdaq/DAQrate/RequestSender.hh"
00008
00009 #define MULTICAST_MODE 0
00010
00011 namespace artdaqtest
00012 {
00013 class CommandableFragmentGeneratorTest;
00014 }
00015
00019 class artdaqtest::CommandableFragmentGeneratorTest :
00020 public artdaq::CommandableFragmentGenerator
00021 {
00022 public:
00026 explicit CommandableFragmentGeneratorTest(const fhicl::ParameterSet& ps);
00027
00028 virtual ~CommandableFragmentGeneratorTest() { joinThreads(); };
00029
00030 protected:
00038 bool getNext_(artdaq::FragmentPtrs& frags) override;
00039
00044 bool checkHWStatus_() override { return !hwFail_.load(); }
00045
00049 void start() override;
00050
00054 void stopNoMutex() override;
00055
00059 void stop() override;
00060
00064 void pause() override;
00065
00069 void resume() override;
00070
00071 public:
00076 void setFireCount(size_t count) { fireCount_ = count; }
00077
00081 void setHwFail() { hwFail_ = true; }
00082
00086 void waitForFrags() {
00087 auto start_time = std::chrono::steady_clock::now();
00088 while (fireCount_ > 0) { usleep(1000); }
00089 TLOG_INFO("CommandableFragmentGenerator_t") << "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" << TLOG_ENDL;
00090 }
00091 private:
00092 std::atomic<size_t> fireCount_;
00093 std::atomic<bool> hwFail_;
00094 artdaq::Fragment::timestamp_t ts_;
00095 bool hw_stop_;
00096 };
00097
00098 artdaqtest::CommandableFragmentGeneratorTest::CommandableFragmentGeneratorTest(const fhicl::ParameterSet& ps)
00099 : CommandableFragmentGenerator(ps)
00100 , fireCount_(1)
00101 , hwFail_(false)
00102 , ts_(0)
00103 , hw_stop_(false)
00104 {}
00105
00106 bool
00107 artdaqtest::CommandableFragmentGeneratorTest::getNext_(artdaq::FragmentPtrs& frags)
00108 {
00109 while (fireCount_ > 0)
00110 {
00111 frags.emplace_back(new artdaq::Fragment(ev_counter(), fragment_id(), artdaq::Fragment::FirstUserFragmentType, ++ts_));
00112 fireCount_--;
00113 }
00114
00115 return !hw_stop_;
00116 }
00117
00118 void
00119 artdaqtest::CommandableFragmentGeneratorTest::start() { hw_stop_ = false; }
00120
00121 void
00122 artdaqtest::CommandableFragmentGeneratorTest::stopNoMutex() {}
00123
00124 void
00125 artdaqtest::CommandableFragmentGeneratorTest::stop() { hw_stop_ = true; }
00126
00127 void
00128 artdaqtest::CommandableFragmentGeneratorTest::pause() {}
00129
00130 void
00131 artdaqtest::CommandableFragmentGeneratorTest::resume() {}
00132
00133 BOOST_AUTO_TEST_SUITE(CommandableFragmentGenerator_t)
00134
00135 BOOST_AUTO_TEST_CASE(Simple)
00136 {
00137 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00138 TLOG_INFO("CommandableFragmentGenerator_t") << "Simple test case BEGIN" << TLOG_ENDL;
00139 fhicl::ParameterSet ps;
00140 ps.put<int>("board_id", 1);
00141 ps.put<int>("fragment_id", 1);
00142 artdaqtest::CommandableFragmentGeneratorTest testGen(ps);
00143 artdaq::FragmentPtrs fps;
00144 auto sts = testGen.getNext(fps);
00145 BOOST_REQUIRE_EQUAL(sts, true);
00146 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00147 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00148 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00149 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00150 TLOG_INFO("CommandableFragmentGenerator_t") << "Simple test case END" << TLOG_ENDL;
00151 }
00152
00153 BOOST_AUTO_TEST_CASE(IgnoreRequests)
00154 {
00155 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00156 TLOG_INFO("CommandableFragmentGenerator_t") << "IgnoreRequests test case BEGIN" << TLOG_ENDL;
00157 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00158 const int DELAY_TIME = 1;
00159 fhicl::ParameterSet ps;
00160 ps.put<int>("board_id", 1);
00161 ps.put<int>("fragment_id", 1);
00162 ps.put<int>("request_port", REQUEST_PORT);
00163 #if MULTICAST_MODE
00164 ps.put<std::string>("request_address", "227.18.12.29");
00165 #else
00166 ps.put<std::string>("request_address", "localhost");
00167 #endif
00168 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00169 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 0);
00170 ps.put<bool>("separate_data_thread", true);
00171 ps.put<bool>("separate_monitoring_thread", false);
00172 ps.put<int64_t>("hardware_poll_interval_us", 0);
00173 ps.put<std::string>("request_mode", "ignored");
00174 ps.put("request_delay_ms", DELAY_TIME);
00175 ps.put("send_requests", true);
00176
00177 artdaq::RequestSender t(ps);
00178 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00179 gen.StartCmd(1, 0xFFFFFFFF, 1);
00180 t.AddRequest(53, 35);
00181
00182 artdaq::FragmentPtrs fps;
00183 auto sts = gen.getNext(fps);
00184 BOOST_REQUIRE_EQUAL(sts, true);
00185 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00186 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00187 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00188 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00189 gen.StopCmd(0xFFFFFFFF, 1);
00190 gen.joinThreads();
00191 TLOG_INFO("CommandableFragmentGenerator_t") << "IgnoreRequests test case END" << TLOG_ENDL;
00192 }
00193
00194 BOOST_AUTO_TEST_CASE(SingleMode)
00195 {
00196 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00197 TLOG_INFO("CommandableFragmentGenerator_t") << "SingleMode test case BEGIN" << TLOG_ENDL;
00198 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00199 const int DELAY_TIME = 100;
00200 fhicl::ParameterSet ps;
00201 ps.put<int>("board_id", 1);
00202 ps.put<int>("fragment_id", 1);
00203 ps.put<int>("request_port", REQUEST_PORT);
00204 #if MULTICAST_MODE
00205 ps.put<std::string>("request_address", "227.18.12.30");
00206 #else
00207 ps.put<std::string>("request_address", "localhost");
00208 #endif
00209 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00210 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 0);
00211 ps.put<bool>("separate_data_thread", true);
00212 ps.put<bool>("separate_monitoring_thread", false);
00213 ps.put<int64_t>("hardware_poll_interval_us", 0);
00214 ps.put<std::string>("request_mode", "single");
00215 ps.put("request_delay_ms", DELAY_TIME);
00216 ps.put("send_requests", true);
00217
00218 artdaq::RequestSender t(ps);
00219 t.AddRequest(1, 1);
00220
00221 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00222 gen.StartCmd(1, 0xFFFFFFFF, 1);
00223 gen.waitForFrags();
00224
00225 artdaq::FragmentPtrs fps;
00226 auto sts = gen.getNext(fps);
00227 auto type = artdaq::Fragment::FirstUserFragmentType;
00228 BOOST_REQUIRE_EQUAL(sts, true);
00229 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00230 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00231 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00232 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00233 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00234 fps.clear();
00235
00236 t.AddRequest(2, 5);
00237 sts = gen.getNext(fps);
00238 BOOST_REQUIRE_EQUAL(sts, true);
00239 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00240 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00241 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
00242 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00243 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00244 fps.clear();
00245
00246 gen.setFireCount(2);
00247 gen.waitForFrags();
00248 t.AddRequest(4, 7);
00249 sts = gen.getNext(fps);
00250 BOOST_REQUIRE_EQUAL(sts, true);
00251 BOOST_REQUIRE_EQUAL(fps.size(), 2);
00252 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00253 auto ts = artdaq::Fragment::InvalidTimestamp;
00254 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
00255 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00256 auto emptyType = artdaq::Fragment::EmptyFragmentType;
00257 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
00258 fps.pop_front();
00259 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00260 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
00261 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
00262 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00263 fps.clear();
00264
00265 gen.StopCmd(0xFFFFFFFF, 1);
00266 gen.joinThreads();
00267 TLOG_INFO("CommandableFragmentGenerator_t") << "SingleMode test case END" << TLOG_ENDL;
00268 }
00269
00270 BOOST_AUTO_TEST_CASE(BufferMode)
00271 {
00272 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00273 TLOG_INFO("CommandableFragmentGenerator_t") << "BufferMode test case BEGIN" << TLOG_ENDL;
00274 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00275 const int DELAY_TIME = 100;
00276 fhicl::ParameterSet ps;
00277 ps.put<int>("board_id", 1);
00278 ps.put<int>("fragment_id", 1);
00279 ps.put<int>("request_port", REQUEST_PORT);
00280 #if MULTICAST_MODE
00281 ps.put<std::string>("request_address", "227.18.12.31");
00282 #else
00283 ps.put<std::string>("request_address", "localhost");
00284 #endif
00285 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00286 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 0);
00287 ps.put<bool>("separate_data_thread", true);
00288 ps.put<bool>("separate_monitoring_thread", false);
00289 ps.put<int64_t>("hardware_poll_interval_us", 0);
00290 ps.put<std::string>("request_mode", "buffer");
00291 ps.put("request_delay_ms", DELAY_TIME);
00292 ps.put("send_requests", true);
00293
00294 artdaq::RequestSender t(ps);
00295 t.AddRequest(1, 1);
00296
00297 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00298 gen.StartCmd(1, 0xFFFFFFFF, 1);
00299
00300
00301 artdaq::FragmentPtrs fps;
00302 auto sts = gen.getNext(fps);
00303 BOOST_REQUIRE_EQUAL(sts, true);
00304 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00305 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00306 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00307 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00308 auto type = artdaq::Fragment::ContainerFragmentType;
00309 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00310 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 * sizeof(artdaq::detail::RawEventHeader) + sizeof(artdaq::ContainerFragment::Metadata));
00311 auto cf = artdaq::ContainerFragment(*fps.front());
00312 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
00313 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00314 type = artdaq::Fragment::FirstUserFragmentType;
00315 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00316 fps.clear();
00317
00318 t.AddRequest(2, 5);
00319 sts = gen.getNext(fps);
00320 BOOST_REQUIRE_EQUAL(sts, true);
00321 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00322 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00323 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
00324 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00325 type = artdaq::Fragment::ContainerFragmentType;
00326 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00327 auto cf2 = artdaq::ContainerFragment(*fps.front());
00328 BOOST_REQUIRE_EQUAL(cf2.block_count(), 0);
00329 BOOST_REQUIRE_EQUAL(cf2.missing_data(), false);
00330 type = artdaq::Fragment::EmptyFragmentType;
00331 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
00332 fps.clear();
00333
00334 gen.setFireCount(2);
00335 gen.waitForFrags();
00336 t.AddRequest(4, 7);
00337 sts = gen.getNext(fps);
00338 BOOST_REQUIRE_EQUAL(sts, true);
00339 BOOST_REQUIRE_EQUAL(fps.size(), 2);
00340
00341 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00342 auto ts = artdaq::Fragment::InvalidTimestamp;
00343 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
00344 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00345 auto emptyType = artdaq::Fragment::EmptyFragmentType;
00346 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
00347 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
00348 fps.pop_front();
00349 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00350 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 7);
00351 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
00352 type = artdaq::Fragment::ContainerFragmentType;
00353 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00354 auto cf3 = artdaq::ContainerFragment(*fps.front());
00355 BOOST_REQUIRE_EQUAL(cf3.block_count(), 2);
00356 BOOST_REQUIRE_EQUAL(cf3.missing_data(), false);
00357 type = artdaq::Fragment::FirstUserFragmentType;
00358 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
00359 fps.clear();
00360
00361
00362 gen.StopCmd(0xFFFFFFFF, 1);
00363 gen.joinThreads();
00364
00365
00366 TLOG_INFO("CommandableFragmentGenerator_t") << "BufferMode test case END" << TLOG_ENDL;
00367 }
00368
00369 BOOST_AUTO_TEST_CASE(WindowMode_Function)
00370 {
00371 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00372 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_Function test case BEGIN" << TLOG_ENDL;
00373 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00374 const int DELAY_TIME = 100;
00375 fhicl::ParameterSet ps;
00376 ps.put<int>("board_id", 1);
00377 ps.put<int>("fragment_id", 1);
00378 ps.put<int>("request_port", REQUEST_PORT);
00379 #if MULTICAST_MODE
00380 ps.put<std::string>("request_address", "227.18.12.32");
00381 #else
00382 ps.put<std::string>("request_address", "localhost");
00383 #endif
00384 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00385 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 0);
00386 ps.put<bool>("separate_data_thread", true);
00387 ps.put<bool>("separate_monitoring_thread", false);
00388 ps.put<int64_t>("hardware_poll_interval_us", 0);
00389 ps.put<size_t>("data_buffer_depth_fragments", 5);
00390 ps.put<std::string>("request_mode", "window");
00391 ps.put("request_delay_ms", DELAY_TIME);
00392 ps.put("send_requests", true);
00393
00394 artdaq::RequestSender t(ps);
00395 t.AddRequest(1, 1);
00396
00397 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00398 gen.StartCmd(1, 0xFFFFFFFF, 1);
00399
00400 artdaq::FragmentPtrs fps;
00401 auto sts = gen.getNext(fps);
00402 BOOST_REQUIRE_EQUAL(sts, true);
00403 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00404 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00405 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00406 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00407 auto type = artdaq::Fragment::ContainerFragmentType;
00408 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00409 BOOST_REQUIRE_GE(fps.front()->sizeBytes(), 2 * sizeof(artdaq::detail::RawEventHeader) + sizeof(artdaq::ContainerFragment::Metadata));
00410 auto cf = artdaq::ContainerFragment(*fps.front());
00411 BOOST_REQUIRE_EQUAL(cf.block_count(), 1);
00412 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00413 type = artdaq::Fragment::FirstUserFragmentType;
00414 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00415 fps.clear();
00416
00417
00418 t.AddRequest(2, 2);
00419 sts = gen.getNext(fps);
00420 BOOST_REQUIRE_EQUAL(sts, true);
00421 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00422
00423 gen.setFireCount(1);
00424 gen.waitForFrags();
00425 sts = gen.getNext(fps);
00426 BOOST_REQUIRE_EQUAL(sts, true);
00427 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00428 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00429 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
00430 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00431 type = artdaq::Fragment::ContainerFragmentType;
00432 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00433 auto cf2 = artdaq::ContainerFragment(*fps.front());
00434 BOOST_REQUIRE_EQUAL(cf2.block_count(), 1);
00435 BOOST_REQUIRE_EQUAL(cf2.missing_data(), false);
00436 type = artdaq::Fragment::FirstUserFragmentType;
00437 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
00438 fps.clear();
00439
00440
00441 gen.setFireCount(2);
00442 gen.waitForFrags();
00443 t.AddRequest(4, 3);
00444 sts = gen.getNext(fps);
00445 BOOST_REQUIRE_EQUAL(sts, true);
00446 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00447
00448 usleep(1500000);
00449 sts = gen.getNext(fps);
00450 BOOST_REQUIRE_EQUAL(sts, true);
00451 BOOST_REQUIRE_EQUAL(fps.size(), 2);
00452
00453
00454 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00455 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
00456 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
00457 type = artdaq::Fragment::ContainerFragmentType;
00458 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00459 auto cf3 = artdaq::ContainerFragment(*fps.front());
00460 BOOST_REQUIRE_EQUAL(cf3.block_count(), 1);
00461 BOOST_REQUIRE_EQUAL(cf3.missing_data(), false);
00462 type = artdaq::Fragment::FirstUserFragmentType;
00463 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
00464 fps.pop_front();
00465
00466 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00467 auto ts = artdaq::Fragment::InvalidTimestamp;
00468 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
00469 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00470 auto emptyType = artdaq::Fragment::EmptyFragmentType;
00471 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
00472 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
00473 fps.clear();
00474
00475
00476 gen.setFireCount(10);
00477 gen.waitForFrags();
00478 t.AddRequest(5, 4);
00479 sts = gen.getNext(fps);
00480 BOOST_REQUIRE_EQUAL(sts, true);
00481 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00482 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00483 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
00484 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
00485 type = artdaq::Fragment::ContainerFragmentType;
00486 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00487 auto cf4 = artdaq::ContainerFragment(*fps.front());
00488 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00489 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00490 type = artdaq::Fragment::EmptyFragmentType;
00491 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00492 fps.clear();
00493
00494 gen.StopCmd(0xFFFFFFFF, 1);
00495 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_Function test case END" << TLOG_ENDL;
00496 gen.joinThreads();
00497
00498 }
00499
00500
00501
00502
00503
00504
00505
00506 BOOST_AUTO_TEST_CASE(WindowMode_RequestBeforeBuffer)
00507 {
00508 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00509 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestBeforeBuffer test case BEGIN" << TLOG_ENDL;
00510 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00511 const int DELAY_TIME = 100;
00512 fhicl::ParameterSet ps;
00513 ps.put<int>("board_id", 1);
00514 ps.put<int>("fragment_id", 1);
00515 ps.put<int>("request_port", REQUEST_PORT);
00516 #if MULTICAST_MODE
00517 ps.put<std::string>("request_address", "227.18.12.32");
00518 #else
00519 ps.put<std::string>("request_address", "localhost");
00520 #endif
00521 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00522 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00523 ps.put<bool>("separate_data_thread", true);
00524 ps.put<bool>("separate_monitoring_thread", false);
00525 ps.put<int64_t>("hardware_poll_interval_us", 0);
00526 ps.put<size_t>("data_buffer_depth_fragments", 5);
00527 ps.put<std::string>("request_mode", "window");
00528 ps.put("request_delay_ms", DELAY_TIME);
00529 ps.put("send_requests", true);
00530
00531 artdaq::RequestSender t(ps);
00532
00533 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00534 gen.StartCmd(1, 0xFFFFFFFF, 1);
00535
00536 artdaq::FragmentPtrs fps;
00537 int sts;
00538 artdaq::Fragment::type_t type;
00539
00540
00541
00542 gen.setFireCount(9);
00543 gen.waitForFrags();
00544 t.AddRequest(1, 1);
00545
00546 sts = gen.getNext(fps);
00547 BOOST_REQUIRE_EQUAL(sts, true);
00548 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00549 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00550 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00551 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00552 type = artdaq::Fragment::ContainerFragmentType;
00553 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00554 auto cf4 = artdaq::ContainerFragment(*fps.front());
00555 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00556 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00557 type = artdaq::Fragment::EmptyFragmentType;
00558 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00559
00560 gen.StopCmd(0xFFFFFFFF, 1);
00561 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestBeforeBuffer test case END" << TLOG_ENDL;
00562
00563 }
00564 BOOST_AUTO_TEST_CASE(WindowMode_RequestStartsBeforeBuffer)
00565 {
00566 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00567 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestStartsBeforeBuffer test case BEGIN" << TLOG_ENDL;
00568 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00569 const int DELAY_TIME = 100;
00570 fhicl::ParameterSet ps;
00571 ps.put<int>("board_id", 1);
00572 ps.put<int>("fragment_id", 1);
00573 ps.put<int>("request_port", REQUEST_PORT);
00574 #if MULTICAST_MODE
00575 ps.put<std::string>("request_address", "227.18.12.32");
00576 #else
00577 ps.put<std::string>("request_address", "localhost");
00578 #endif
00579 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00580 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00581 ps.put<bool>("separate_data_thread", true);
00582 ps.put<bool>("separate_monitoring_thread", false);
00583 ps.put<int64_t>("hardware_poll_interval_us", 0);
00584 ps.put<size_t>("data_buffer_depth_fragments", 5);
00585 ps.put<std::string>("request_mode", "window");
00586 ps.put("request_delay_ms", DELAY_TIME);
00587 ps.put("send_requests", true);
00588
00589 artdaq::RequestSender t(ps);
00590
00591 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00592 gen.StartCmd(1, 0xFFFFFFFF, 1);
00593
00594 artdaq::FragmentPtrs fps;
00595 int sts;
00596 artdaq::Fragment::type_t type;
00597
00598 gen.waitForFrags();
00599 gen.setFireCount(9);
00600 gen.waitForFrags();
00601
00602
00603
00604 t.AddRequest(1, 4);
00605
00606 sts = gen.getNext(fps);
00607 BOOST_REQUIRE_EQUAL(sts, true);
00608 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00609 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00610 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
00611 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00612 type = artdaq::Fragment::ContainerFragmentType;
00613 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00614 auto cf4 = artdaq::ContainerFragment(*fps.front());
00615 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00616 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00617 type = artdaq::Fragment::FirstUserFragmentType;
00618 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00619
00620 gen.StopCmd(0xFFFFFFFF, 1);
00621 gen.joinThreads();
00622 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestStartsBeforeBuffer test case END" << TLOG_ENDL;
00623
00624 }
00625 BOOST_AUTO_TEST_CASE(WindowMode_RequestOutsideBuffer)
00626 {
00627 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00628 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestOutsideBuffer test case BEGIN" << TLOG_ENDL;
00629 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00630 const int DELAY_TIME = 100;
00631 fhicl::ParameterSet ps;
00632 ps.put<int>("board_id", 1);
00633 ps.put<int>("fragment_id", 1);
00634 ps.put<int>("request_port", REQUEST_PORT);
00635 #if MULTICAST_MODE
00636 ps.put<std::string>("request_address", "227.18.12.32");
00637 #else
00638 ps.put<std::string>("request_address", "localhost");
00639 #endif
00640 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00641 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 4);
00642 ps.put<size_t>("window_close_timeout_us", 500000);
00643 ps.put<bool>("separate_data_thread", true);
00644 ps.put<bool>("separate_monitoring_thread", false);
00645 ps.put<int64_t>("hardware_poll_interval_us", 0);
00646 ps.put<size_t>("data_buffer_depth_fragments", 5);
00647 ps.put<std::string>("request_mode", "window");
00648 ps.put("request_delay_ms", DELAY_TIME);
00649 ps.put("send_requests", true);
00650
00651 artdaq::RequestSender t(ps);
00652
00653 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00654 gen.StartCmd(1, 0xFFFFFFFF, 1);
00655
00656 artdaq::FragmentPtrs fps;
00657 int sts;
00658 artdaq::Fragment::type_t type;
00659
00660 gen.waitForFrags();
00661 gen.setFireCount(9);
00662 gen.waitForFrags();
00663
00664
00665
00666
00667 t.AddRequest(1, 6);
00668 sts = gen.getNext(fps);
00669 BOOST_REQUIRE_EQUAL(sts, true);
00670 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00671 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00672 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
00673 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00674 type = artdaq::Fragment::ContainerFragmentType;
00675 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00676 auto cf = artdaq::ContainerFragment(*fps.front());
00677 BOOST_REQUIRE_EQUAL(cf.block_count(), 4);
00678 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00679 type = artdaq::Fragment::FirstUserFragmentType;
00680 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00681 fps.clear();
00682
00683 t.AddRequest(2, 9);
00684 sts = gen.getNext(fps);
00685 BOOST_REQUIRE_EQUAL(sts, true);
00686 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00687
00688 gen.setFireCount(3);
00689 gen.waitForFrags();
00690
00691 sts = gen.getNext(fps);
00692 BOOST_REQUIRE_EQUAL(sts, true);
00693 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00694 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00695 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
00696 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00697 type = artdaq::Fragment::ContainerFragmentType;
00698 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00699 auto cf2 = artdaq::ContainerFragment(*fps.front());
00700 BOOST_REQUIRE_EQUAL(cf2.block_count(), 3);
00701 BOOST_REQUIRE_EQUAL(cf2.missing_data(), true);
00702 type = artdaq::Fragment::FirstUserFragmentType;
00703 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
00704 fps.clear();
00705
00706
00707
00708 t.AddRequest(3, 12);
00709
00710 sts = gen.getNext(fps);
00711 BOOST_REQUIRE_EQUAL(sts, true);
00712 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00713
00714 usleep(550000);
00715
00716 sts = gen.getNext(fps);
00717 BOOST_REQUIRE_EQUAL(sts, true);
00718 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00719 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00720 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
00721 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00722 type = artdaq::Fragment::ContainerFragmentType;
00723 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00724 auto cf4 = artdaq::ContainerFragment(*fps.front());
00725 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00726 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00727 type = artdaq::Fragment::FirstUserFragmentType;
00728 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00729
00730 gen.StopCmd(0xFFFFFFFF, 1);
00731 gen.joinThreads();
00732 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestOutsideBuffer test case END" << TLOG_ENDL;
00733
00734 }
00735 BOOST_AUTO_TEST_CASE(WindowMode_RequestInBuffer)
00736 {
00737 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00738 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestInBuffer test case BEGIN" << TLOG_ENDL;
00739 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00740 const int DELAY_TIME = 100;
00741 fhicl::ParameterSet ps;
00742 ps.put<int>("board_id", 1);
00743 ps.put<int>("fragment_id", 1);
00744 ps.put<int>("request_port", REQUEST_PORT);
00745 #if MULTICAST_MODE
00746 ps.put<std::string>("request_address", "227.18.12.32");
00747 #else
00748 ps.put<std::string>("request_address", "localhost");
00749 #endif
00750 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00751 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00752 ps.put<bool>("separate_data_thread", true);
00753 ps.put<bool>("separate_monitoring_thread", false);
00754 ps.put<int64_t>("hardware_poll_interval_us", 0);
00755 ps.put<size_t>("data_buffer_depth_fragments", 5);
00756 ps.put<std::string>("request_mode", "window");
00757 ps.put("request_delay_ms", DELAY_TIME);
00758 ps.put("send_requests", true);
00759
00760 artdaq::RequestSender t(ps);
00761
00762 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00763 gen.StartCmd(1, 0xFFFFFFFF, 1);
00764
00765 artdaq::FragmentPtrs fps;
00766 int sts;
00767 artdaq::Fragment::type_t type;
00768 gen.waitForFrags();
00769
00770
00771
00772 gen.setFireCount(5);
00773 gen.waitForFrags();
00774 t.AddRequest(1, 3);
00775
00776 sts = gen.getNext(fps);
00777 BOOST_REQUIRE_EQUAL(sts, true);
00778 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00779 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00780 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
00781 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00782 type = artdaq::Fragment::ContainerFragmentType;
00783 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00784 auto cf4 = artdaq::ContainerFragment(*fps.front());
00785 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
00786 BOOST_REQUIRE_EQUAL(cf4.missing_data(), false);
00787 type = artdaq::Fragment::FirstUserFragmentType;
00788 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00789
00790 gen.StopCmd(0xFFFFFFFF, 1);
00791 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestInBuffer test case END" << TLOG_ENDL;
00792
00793 }
00794 BOOST_AUTO_TEST_CASE(WindowMode_RequestEndsAfterBuffer)
00795 {
00796 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00797 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestEndsAfterBuffer test case BEGIN" << TLOG_ENDL;
00798 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00799 const int DELAY_TIME = 100;
00800 fhicl::ParameterSet ps;
00801 ps.put<int>("board_id", 1);
00802 ps.put<int>("fragment_id", 1);
00803 ps.put<int>("request_port", REQUEST_PORT);
00804 #if MULTICAST_MODE
00805 ps.put<std::string>("request_address", "227.18.12.32");
00806 #else
00807 ps.put<std::string>("request_address", "localhost");
00808 #endif
00809 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00810 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00811 ps.put<size_t>("window_close_timeout_us", 500000);
00812 ps.put<bool>("separate_data_thread", true);
00813 ps.put<bool>("separate_monitoring_thread", false);
00814 ps.put<int64_t>("hardware_poll_interval_us", 0);
00815 ps.put<size_t>("data_buffer_depth_fragments", 5);
00816 ps.put<std::string>("request_mode", "window");
00817 ps.put("request_delay_ms", DELAY_TIME);
00818 ps.put("send_requests", true);
00819
00820 artdaq::RequestSender t(ps);
00821
00822 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00823 gen.StartCmd(1, 0xFFFFFFFF, 1);
00824
00825 artdaq::FragmentPtrs fps;
00826 int sts;
00827 artdaq::Fragment::type_t type;
00828 gen.waitForFrags();
00829 gen.setFireCount(5);
00830 gen.waitForFrags();
00831
00832
00833
00834 t.AddRequest(1, 5);
00835 sts = gen.getNext(fps);
00836 BOOST_REQUIRE_EQUAL(sts, true);
00837 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00838
00839 gen.setFireCount(2);
00840 gen.waitForFrags();
00841 sts = gen.getNext(fps);
00842 BOOST_REQUIRE_EQUAL(sts, true);
00843 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00844 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00845 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
00846 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00847 type = artdaq::Fragment::ContainerFragmentType;
00848 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00849 auto cf = artdaq::ContainerFragment(*fps.front());
00850 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
00851 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00852 type = artdaq::Fragment::FirstUserFragmentType;
00853 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00854 fps.clear();
00855
00856 t.AddRequest(2, 8);
00857
00858 sts = gen.getNext(fps);
00859 BOOST_REQUIRE_EQUAL(sts, true);
00860 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00861
00862 usleep(550000);
00863
00864 sts = gen.getNext(fps);
00865 BOOST_REQUIRE_EQUAL(sts, true);
00866 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00867 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00868 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
00869 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00870 type = artdaq::Fragment::ContainerFragmentType;
00871 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00872 auto cf4 = artdaq::ContainerFragment(*fps.front());
00873 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00874 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00875 type = artdaq::Fragment::FirstUserFragmentType;
00876 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00877
00878 gen.StopCmd(0xFFFFFFFF, 1);
00879 gen.joinThreads();
00880 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestEndsAfterBuffer test case END" << TLOG_ENDL;
00881
00882 }
00883 BOOST_AUTO_TEST_CASE(WindowMode_RequestAfterBuffer)
00884 {
00885 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00886 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestAfterBuffer test case BEGIN" << TLOG_ENDL;
00887 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00888 const int DELAY_TIME = 100;
00889 fhicl::ParameterSet ps;
00890 ps.put<int>("board_id", 1);
00891 ps.put<int>("fragment_id", 1);
00892 ps.put<int>("request_port", REQUEST_PORT);
00893 #if MULTICAST_MODE
00894 ps.put<std::string>("request_address", "227.18.12.32");
00895 #else
00896 ps.put<std::string>("request_address", "localhost");
00897 #endif
00898 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00899 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00900 ps.put<size_t>("window_close_timeout_us", 500000);
00901 ps.put<bool>("separate_data_thread", true);
00902 ps.put<bool>("separate_monitoring_thread", false);
00903 ps.put<int64_t>("hardware_poll_interval_us", 0);
00904 ps.put<size_t>("data_buffer_depth_fragments", 5);
00905 ps.put<std::string>("request_mode", "window");
00906 ps.put("request_delay_ms", DELAY_TIME);
00907 ps.put("send_requests", true);
00908
00909 artdaq::RequestSender t(ps);
00910
00911 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00912 gen.StartCmd(1, 0xFFFFFFFF, 1);
00913
00914 artdaq::FragmentPtrs fps;
00915 int sts;
00916 artdaq::Fragment::type_t type;
00917 gen.waitForFrags();
00918
00919
00920
00921 gen.setFireCount(9);
00922 gen.waitForFrags();
00923 t.AddRequest(1, 11);
00924
00925 sts = gen.getNext(fps);
00926 BOOST_REQUIRE_EQUAL(sts, true);
00927 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00928 gen.setFireCount(1);
00929 gen.waitForFrags();
00930 sts = gen.getNext(fps);
00931 BOOST_REQUIRE_EQUAL(sts, true);
00932 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00933
00934 gen.setFireCount(3);
00935 gen.waitForFrags();
00936 sts = gen.getNext(fps);
00937 BOOST_REQUIRE_EQUAL(sts, true);
00938 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00939 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00940 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
00941 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00942 type = artdaq::Fragment::ContainerFragmentType;
00943 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00944 auto cf = artdaq::ContainerFragment(*fps.front());
00945 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
00946 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00947 type = artdaq::Fragment::FirstUserFragmentType;
00948 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00949 fps.clear();
00950
00951 t.AddRequest(2, 16);
00952 sts = gen.getNext(fps);
00953 BOOST_REQUIRE_EQUAL(sts, true);
00954 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00955
00956 usleep(550000);
00957
00958 sts = gen.getNext(fps);
00959 BOOST_REQUIRE_EQUAL(sts, true);
00960 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00961 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00962 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
00963 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00964 type = artdaq::Fragment::ContainerFragmentType;
00965 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00966 auto cf4 = artdaq::ContainerFragment(*fps.front());
00967 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00968 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00969 type = artdaq::Fragment::EmptyFragmentType;
00970 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00971
00972 gen.StopCmd(0xFFFFFFFF, 1);
00973 gen.joinThreads();
00974 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestAfterBuffer test case END" << TLOG_ENDL;
00975
00976 }
00977
00978 BOOST_AUTO_TEST_CASE(HardwareFailure_NonThreaded)
00979 {
00980 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00981 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_NonThreaded test case BEGIN" << TLOG_ENDL;
00982 fhicl::ParameterSet ps;
00983 ps.put<int>("board_id", 1);
00984 ps.put<int>("fragment_id", 1);
00985 ps.put<bool>("separate_data_thread", false);
00986 ps.put<bool>("separate_monitoring_thread", false);
00987 ps.put<int64_t>("hardware_poll_interval_us", 10);
00988
00989 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00990 gen.StartCmd(1, 0xFFFFFFFF, 1);
00991
00992 artdaq::FragmentPtrs fps;
00993 auto sts = gen.getNext(fps);
00994 BOOST_REQUIRE_EQUAL(sts, true);
00995 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00996 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00997 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00998 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00999 fps.clear();
01000
01001 gen.setFireCount(1);
01002 gen.setHwFail();
01003 usleep(10000);
01004 sts = gen.getNext(fps);
01005 BOOST_REQUIRE_EQUAL(sts, false);
01006 BOOST_REQUIRE_EQUAL(fps.size(), 0);
01007
01008 gen.StopCmd(0xFFFFFFFF, 1);
01009 gen.joinThreads();
01010 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_NonThreaded test case END" << TLOG_ENDL;
01011 }
01012
01013 BOOST_AUTO_TEST_CASE(HardwareFailure_Threaded)
01014 {
01015 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
01016 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_Threaded test case BEGIN" << TLOG_ENDL;
01017 fhicl::ParameterSet ps;
01018 ps.put<int>("board_id", 1);
01019 ps.put<int>("fragment_id", 1);
01020 ps.put<bool>("separate_data_thread", true);
01021 ps.put<bool>("separate_monitoring_thread", true);
01022 ps.put<int64_t>("hardware_poll_interval_us", 750000);
01023
01024 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
01025 gen.StartCmd(1, 0xFFFFFFFF, 1);
01026
01027
01028
01029 artdaq::FragmentPtrs fps;
01030 auto sts = gen.getNext(fps);
01031 BOOST_REQUIRE_EQUAL(sts, true);
01032 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
01033 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
01034 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
01035 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
01036 fps.clear();
01037
01038 gen.setFireCount(1);
01039 gen.setHwFail();
01040 sts = gen.getNext(fps);
01041 BOOST_REQUIRE_EQUAL(sts, true);
01042 BOOST_REQUIRE_EQUAL(fps.size(), 1);
01043 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
01044 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
01045 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
01046
01047 fps.clear();
01048 sleep(1);
01049 gen.setFireCount(1);
01050 sts = gen.getNext(fps);
01051 BOOST_REQUIRE_EQUAL(sts, false);
01052 BOOST_REQUIRE_EQUAL(fps.size(), 0);
01053
01054 gen.StopCmd(0xFFFFFFFF, 1);
01055 gen.joinThreads();
01056 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_Threaded test case END" << TLOG_ENDL;
01057 }
01058
01059 BOOST_AUTO_TEST_SUITE_END()