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(), 0);
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 auto ts = artdaq::Fragment::InvalidTimestamp;
00456 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), ts);
00457 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00458 auto emptyType = artdaq::Fragment::EmptyFragmentType;
00459 BOOST_REQUIRE_EQUAL(fps.front()->type(), emptyType);
00460 BOOST_REQUIRE_EQUAL(fps.front()->size(), artdaq::detail::RawFragmentHeader::num_words());
00461 fps.pop_front();
00462 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00463 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
00464 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 4);
00465 type = artdaq::Fragment::ContainerFragmentType;
00466 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00467 auto cf3 = artdaq::ContainerFragment(*fps.front());
00468 BOOST_REQUIRE_EQUAL(cf3.block_count(), 1);
00469 BOOST_REQUIRE_EQUAL(cf3.missing_data(), false);
00470 type = artdaq::Fragment::FirstUserFragmentType;
00471 BOOST_REQUIRE_EQUAL(cf3.fragment_type(), type);
00472 fps.clear();
00473
00474
00475 gen.setFireCount(10);
00476 gen.waitForFrags();
00477 t.AddRequest(5, 4);
00478 sts = gen.getNext(fps);
00479 BOOST_REQUIRE_EQUAL(sts, true);
00480 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00481 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00482 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
00483 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 5);
00484 type = artdaq::Fragment::ContainerFragmentType;
00485 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00486 auto cf4 = artdaq::ContainerFragment(*fps.front());
00487 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00488 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00489 type = artdaq::Fragment::EmptyFragmentType;
00490 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00491 fps.clear();
00492
00493 gen.StopCmd(0xFFFFFFFF, 1);
00494 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_Function test case END" << TLOG_ENDL;
00495 gen.joinThreads();
00496
00497 }
00498
00499
00500
00501
00502
00503
00504
00505 BOOST_AUTO_TEST_CASE(WindowMode_RequestBeforeBuffer)
00506 {
00507 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00508 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestBeforeBuffer test case BEGIN" << TLOG_ENDL;
00509 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00510 const int DELAY_TIME = 100;
00511 fhicl::ParameterSet ps;
00512 ps.put<int>("board_id", 1);
00513 ps.put<int>("fragment_id", 1);
00514 ps.put<int>("request_port", REQUEST_PORT);
00515 #if MULTICAST_MODE
00516 ps.put<std::string>("request_address", "227.18.12.32");
00517 #else
00518 ps.put<std::string>("request_address", "localhost");
00519 #endif
00520 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00521 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00522 ps.put<bool>("separate_data_thread", true);
00523 ps.put<bool>("separate_monitoring_thread", false);
00524 ps.put<int64_t>("hardware_poll_interval_us", 0);
00525 ps.put<size_t>("data_buffer_depth_fragments", 5);
00526 ps.put<std::string>("request_mode", "window");
00527 ps.put("request_delay_ms", DELAY_TIME);
00528 ps.put("send_requests", true);
00529
00530 artdaq::RequestSender t(ps);
00531
00532 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00533 gen.StartCmd(1, 0xFFFFFFFF, 1);
00534
00535 artdaq::FragmentPtrs fps;
00536 int sts;
00537 artdaq::Fragment::type_t type;
00538
00539
00540
00541 gen.setFireCount(9);
00542 gen.waitForFrags();
00543 t.AddRequest(1, 1);
00544
00545 sts = gen.getNext(fps);
00546 BOOST_REQUIRE_EQUAL(sts, true);
00547 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00548 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00549 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00550 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00551 type = artdaq::Fragment::ContainerFragmentType;
00552 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00553 auto cf4 = artdaq::ContainerFragment(*fps.front());
00554 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00555 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00556 type = artdaq::Fragment::EmptyFragmentType;
00557 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00558
00559 gen.StopCmd(0xFFFFFFFF, 1);
00560 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestBeforeBuffer test case END" << TLOG_ENDL;
00561
00562 }
00563 BOOST_AUTO_TEST_CASE(WindowMode_RequestStartsBeforeBuffer)
00564 {
00565 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00566 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestStartsBeforeBuffer test case BEGIN" << TLOG_ENDL;
00567 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00568 const int DELAY_TIME = 100;
00569 fhicl::ParameterSet ps;
00570 ps.put<int>("board_id", 1);
00571 ps.put<int>("fragment_id", 1);
00572 ps.put<int>("request_port", REQUEST_PORT);
00573 #if MULTICAST_MODE
00574 ps.put<std::string>("request_address", "227.18.12.32");
00575 #else
00576 ps.put<std::string>("request_address", "localhost");
00577 #endif
00578 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00579 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00580 ps.put<bool>("separate_data_thread", true);
00581 ps.put<bool>("separate_monitoring_thread", false);
00582 ps.put<int64_t>("hardware_poll_interval_us", 0);
00583 ps.put<size_t>("data_buffer_depth_fragments", 5);
00584 ps.put<std::string>("request_mode", "window");
00585 ps.put("request_delay_ms", DELAY_TIME);
00586 ps.put("send_requests", true);
00587
00588 artdaq::RequestSender t(ps);
00589
00590 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00591 gen.StartCmd(1, 0xFFFFFFFF, 1);
00592
00593 artdaq::FragmentPtrs fps;
00594 int sts;
00595 artdaq::Fragment::type_t type;
00596
00597 gen.waitForFrags();
00598 gen.setFireCount(9);
00599 gen.waitForFrags();
00600
00601
00602
00603 t.AddRequest(1, 4);
00604
00605 sts = gen.getNext(fps);
00606 BOOST_REQUIRE_EQUAL(sts, true);
00607 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00608 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00609 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 4);
00610 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00611 type = artdaq::Fragment::ContainerFragmentType;
00612 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00613 auto cf4 = artdaq::ContainerFragment(*fps.front());
00614 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00615 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00616 type = artdaq::Fragment::FirstUserFragmentType;
00617 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00618
00619 gen.StopCmd(0xFFFFFFFF, 1);
00620 gen.joinThreads();
00621 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestStartsBeforeBuffer test case END" << TLOG_ENDL;
00622
00623 }
00624 BOOST_AUTO_TEST_CASE(WindowMode_RequestOutsideBuffer)
00625 {
00626 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00627 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestOutsideBuffer test case BEGIN" << TLOG_ENDL;
00628 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00629 const int DELAY_TIME = 100;
00630 fhicl::ParameterSet ps;
00631 ps.put<int>("board_id", 1);
00632 ps.put<int>("fragment_id", 1);
00633 ps.put<int>("request_port", REQUEST_PORT);
00634 #if MULTICAST_MODE
00635 ps.put<std::string>("request_address", "227.18.12.32");
00636 #else
00637 ps.put<std::string>("request_address", "localhost");
00638 #endif
00639 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00640 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 4);
00641 ps.put<size_t>("window_close_timeout_us", 500000);
00642 ps.put<bool>("separate_data_thread", true);
00643 ps.put<bool>("separate_monitoring_thread", false);
00644 ps.put<int64_t>("hardware_poll_interval_us", 0);
00645 ps.put<size_t>("data_buffer_depth_fragments", 5);
00646 ps.put<std::string>("request_mode", "window");
00647 ps.put("request_delay_ms", DELAY_TIME);
00648 ps.put("send_requests", true);
00649
00650 artdaq::RequestSender t(ps);
00651
00652 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00653 gen.StartCmd(1, 0xFFFFFFFF, 1);
00654
00655 artdaq::FragmentPtrs fps;
00656 int sts;
00657 artdaq::Fragment::type_t type;
00658
00659 gen.waitForFrags();
00660 gen.setFireCount(9);
00661 gen.waitForFrags();
00662
00663
00664
00665
00666 t.AddRequest(1, 6);
00667 sts = gen.getNext(fps);
00668 BOOST_REQUIRE_EQUAL(sts, true);
00669 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00670 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00671 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 6);
00672 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00673 type = artdaq::Fragment::ContainerFragmentType;
00674 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00675 auto cf = artdaq::ContainerFragment(*fps.front());
00676 BOOST_REQUIRE_EQUAL(cf.block_count(), 4);
00677 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00678 type = artdaq::Fragment::FirstUserFragmentType;
00679 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00680 fps.clear();
00681
00682 t.AddRequest(2, 9);
00683 sts = gen.getNext(fps);
00684 BOOST_REQUIRE_EQUAL(sts, true);
00685 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00686
00687 gen.setFireCount(3);
00688 gen.waitForFrags();
00689
00690 sts = gen.getNext(fps);
00691 BOOST_REQUIRE_EQUAL(sts, true);
00692 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00693 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00694 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 9);
00695 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00696 type = artdaq::Fragment::ContainerFragmentType;
00697 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00698 auto cf2 = artdaq::ContainerFragment(*fps.front());
00699 BOOST_REQUIRE_EQUAL(cf2.block_count(), 3);
00700 BOOST_REQUIRE_EQUAL(cf2.missing_data(), true);
00701 type = artdaq::Fragment::FirstUserFragmentType;
00702 BOOST_REQUIRE_EQUAL(cf2.fragment_type(), type);
00703 fps.clear();
00704
00705
00706
00707 t.AddRequest(3, 12);
00708
00709 sts = gen.getNext(fps);
00710 BOOST_REQUIRE_EQUAL(sts, true);
00711 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00712
00713 usleep(550000);
00714
00715 sts = gen.getNext(fps);
00716 BOOST_REQUIRE_EQUAL(sts, true);
00717 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00718 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00719 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 12);
00720 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 3);
00721 type = artdaq::Fragment::ContainerFragmentType;
00722 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00723 auto cf4 = artdaq::ContainerFragment(*fps.front());
00724 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00725 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00726 type = artdaq::Fragment::FirstUserFragmentType;
00727 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00728
00729 gen.StopCmd(0xFFFFFFFF, 1);
00730 gen.joinThreads();
00731 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestOutsideBuffer test case END" << TLOG_ENDL;
00732
00733 }
00734 BOOST_AUTO_TEST_CASE(WindowMode_RequestInBuffer)
00735 {
00736 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00737 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestInBuffer test case BEGIN" << TLOG_ENDL;
00738 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00739 const int DELAY_TIME = 100;
00740 fhicl::ParameterSet ps;
00741 ps.put<int>("board_id", 1);
00742 ps.put<int>("fragment_id", 1);
00743 ps.put<int>("request_port", REQUEST_PORT);
00744 #if MULTICAST_MODE
00745 ps.put<std::string>("request_address", "227.18.12.32");
00746 #else
00747 ps.put<std::string>("request_address", "localhost");
00748 #endif
00749 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00750 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00751 ps.put<bool>("separate_data_thread", true);
00752 ps.put<bool>("separate_monitoring_thread", false);
00753 ps.put<int64_t>("hardware_poll_interval_us", 0);
00754 ps.put<size_t>("data_buffer_depth_fragments", 5);
00755 ps.put<std::string>("request_mode", "window");
00756 ps.put("request_delay_ms", DELAY_TIME);
00757 ps.put("send_requests", true);
00758
00759 artdaq::RequestSender t(ps);
00760
00761 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00762 gen.StartCmd(1, 0xFFFFFFFF, 1);
00763
00764 artdaq::FragmentPtrs fps;
00765 int sts;
00766 artdaq::Fragment::type_t type;
00767 gen.waitForFrags();
00768
00769
00770
00771 gen.setFireCount(5);
00772 gen.waitForFrags();
00773 t.AddRequest(1, 3);
00774
00775 sts = gen.getNext(fps);
00776 BOOST_REQUIRE_EQUAL(sts, true);
00777 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00778 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00779 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 3);
00780 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00781 type = artdaq::Fragment::ContainerFragmentType;
00782 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00783 auto cf4 = artdaq::ContainerFragment(*fps.front());
00784 BOOST_REQUIRE_EQUAL(cf4.block_count(), 3);
00785 BOOST_REQUIRE_EQUAL(cf4.missing_data(), false);
00786 type = artdaq::Fragment::FirstUserFragmentType;
00787 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00788
00789 gen.StopCmd(0xFFFFFFFF, 1);
00790 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestInBuffer test case END" << TLOG_ENDL;
00791
00792 }
00793 BOOST_AUTO_TEST_CASE(WindowMode_RequestEndsAfterBuffer)
00794 {
00795 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00796 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestEndsAfterBuffer test case BEGIN" << TLOG_ENDL;
00797 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00798 const int DELAY_TIME = 100;
00799 fhicl::ParameterSet ps;
00800 ps.put<int>("board_id", 1);
00801 ps.put<int>("fragment_id", 1);
00802 ps.put<int>("request_port", REQUEST_PORT);
00803 #if MULTICAST_MODE
00804 ps.put<std::string>("request_address", "227.18.12.32");
00805 #else
00806 ps.put<std::string>("request_address", "localhost");
00807 #endif
00808 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00809 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00810 ps.put<size_t>("window_close_timeout_us", 500000);
00811 ps.put<bool>("separate_data_thread", true);
00812 ps.put<bool>("separate_monitoring_thread", false);
00813 ps.put<int64_t>("hardware_poll_interval_us", 0);
00814 ps.put<size_t>("data_buffer_depth_fragments", 5);
00815 ps.put<std::string>("request_mode", "window");
00816 ps.put("request_delay_ms", DELAY_TIME);
00817 ps.put("send_requests", true);
00818
00819 artdaq::RequestSender t(ps);
00820
00821 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00822 gen.StartCmd(1, 0xFFFFFFFF, 1);
00823
00824 artdaq::FragmentPtrs fps;
00825 int sts;
00826 artdaq::Fragment::type_t type;
00827 gen.waitForFrags();
00828 gen.setFireCount(5);
00829 gen.waitForFrags();
00830
00831
00832
00833 t.AddRequest(1, 5);
00834 sts = gen.getNext(fps);
00835 BOOST_REQUIRE_EQUAL(sts, true);
00836 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00837
00838 gen.setFireCount(2);
00839 gen.waitForFrags();
00840 sts = gen.getNext(fps);
00841 BOOST_REQUIRE_EQUAL(sts, true);
00842 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00843 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00844 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 5);
00845 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00846 type = artdaq::Fragment::ContainerFragmentType;
00847 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00848 auto cf = artdaq::ContainerFragment(*fps.front());
00849 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
00850 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00851 type = artdaq::Fragment::FirstUserFragmentType;
00852 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00853 fps.clear();
00854
00855 t.AddRequest(2, 8);
00856
00857 sts = gen.getNext(fps);
00858 BOOST_REQUIRE_EQUAL(sts, true);
00859 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00860
00861 usleep(550000);
00862
00863 sts = gen.getNext(fps);
00864 BOOST_REQUIRE_EQUAL(sts, true);
00865 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00866 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00867 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 8);
00868 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00869 type = artdaq::Fragment::ContainerFragmentType;
00870 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00871 auto cf4 = artdaq::ContainerFragment(*fps.front());
00872 BOOST_REQUIRE_EQUAL(cf4.block_count(), 1);
00873 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00874 type = artdaq::Fragment::FirstUserFragmentType;
00875 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00876
00877 gen.StopCmd(0xFFFFFFFF, 1);
00878 gen.joinThreads();
00879 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestEndsAfterBuffer test case END" << TLOG_ENDL;
00880
00881 }
00882 BOOST_AUTO_TEST_CASE(WindowMode_RequestAfterBuffer)
00883 {
00884 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00885 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestAfterBuffer test case BEGIN" << TLOG_ENDL;
00886 const int REQUEST_PORT = (seedAndRandom() % (32768 - 1024)) + 1024;
00887 const int DELAY_TIME = 100;
00888 fhicl::ParameterSet ps;
00889 ps.put<int>("board_id", 1);
00890 ps.put<int>("fragment_id", 1);
00891 ps.put<int>("request_port", REQUEST_PORT);
00892 #if MULTICAST_MODE
00893 ps.put<std::string>("request_address", "227.18.12.32");
00894 #else
00895 ps.put<std::string>("request_address", "localhost");
00896 #endif
00897 ps.put<artdaq::Fragment::timestamp_t>("request_window_offset", 0);
00898 ps.put<artdaq::Fragment::timestamp_t>("request_window_width", 3);
00899 ps.put<size_t>("window_close_timeout_us", 500000);
00900 ps.put<bool>("separate_data_thread", true);
00901 ps.put<bool>("separate_monitoring_thread", false);
00902 ps.put<int64_t>("hardware_poll_interval_us", 0);
00903 ps.put<size_t>("data_buffer_depth_fragments", 5);
00904 ps.put<std::string>("request_mode", "window");
00905 ps.put("request_delay_ms", DELAY_TIME);
00906 ps.put("send_requests", true);
00907
00908 artdaq::RequestSender t(ps);
00909
00910 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00911 gen.StartCmd(1, 0xFFFFFFFF, 1);
00912
00913 artdaq::FragmentPtrs fps;
00914 int sts;
00915 artdaq::Fragment::type_t type;
00916 gen.waitForFrags();
00917
00918
00919
00920 gen.setFireCount(9);
00921 gen.waitForFrags();
00922 t.AddRequest(1, 11);
00923
00924 sts = gen.getNext(fps);
00925 BOOST_REQUIRE_EQUAL(sts, true);
00926 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00927 gen.setFireCount(1);
00928 gen.waitForFrags();
00929 sts = gen.getNext(fps);
00930 BOOST_REQUIRE_EQUAL(sts, true);
00931 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00932
00933 gen.setFireCount(3);
00934 gen.waitForFrags();
00935 sts = gen.getNext(fps);
00936 BOOST_REQUIRE_EQUAL(sts, true);
00937 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00938 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00939 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 11);
00940 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00941 type = artdaq::Fragment::ContainerFragmentType;
00942 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00943 auto cf = artdaq::ContainerFragment(*fps.front());
00944 BOOST_REQUIRE_EQUAL(cf.block_count(), 3);
00945 BOOST_REQUIRE_EQUAL(cf.missing_data(), false);
00946 type = artdaq::Fragment::FirstUserFragmentType;
00947 BOOST_REQUIRE_EQUAL(cf.fragment_type(), type);
00948 fps.clear();
00949
00950 t.AddRequest(2, 16);
00951 sts = gen.getNext(fps);
00952 BOOST_REQUIRE_EQUAL(sts, true);
00953 BOOST_REQUIRE_EQUAL(fps.size(), 0);
00954
00955 usleep(550000);
00956
00957 sts = gen.getNext(fps);
00958 BOOST_REQUIRE_EQUAL(sts, true);
00959 BOOST_REQUIRE_EQUAL(fps.size(), 1);
00960 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00961 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 16);
00962 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 2);
00963 type = artdaq::Fragment::ContainerFragmentType;
00964 BOOST_REQUIRE_EQUAL(fps.front()->type(), type);
00965 auto cf4 = artdaq::ContainerFragment(*fps.front());
00966 BOOST_REQUIRE_EQUAL(cf4.block_count(), 0);
00967 BOOST_REQUIRE_EQUAL(cf4.missing_data(), true);
00968 type = artdaq::Fragment::EmptyFragmentType;
00969 BOOST_REQUIRE_EQUAL(cf4.fragment_type(), type);
00970
00971 gen.StopCmd(0xFFFFFFFF, 1);
00972 gen.joinThreads();
00973 TLOG_INFO("CommandableFragmentGenerator_t") << "WindowMode_RequestAfterBuffer test case END" << TLOG_ENDL;
00974
00975 }
00976
00977 BOOST_AUTO_TEST_CASE(HardwareFailure_NonThreaded)
00978 {
00979 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
00980 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_NonThreaded test case BEGIN" << TLOG_ENDL;
00981 fhicl::ParameterSet ps;
00982 ps.put<int>("board_id", 1);
00983 ps.put<int>("fragment_id", 1);
00984 ps.put<bool>("separate_data_thread", false);
00985 ps.put<bool>("separate_monitoring_thread", false);
00986 ps.put<int64_t>("hardware_poll_interval_us", 10);
00987
00988 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
00989 gen.StartCmd(1, 0xFFFFFFFF, 1);
00990
00991 artdaq::FragmentPtrs fps;
00992 auto sts = gen.getNext(fps);
00993 BOOST_REQUIRE_EQUAL(sts, true);
00994 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
00995 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
00996 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
00997 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
00998 fps.clear();
00999
01000 gen.setFireCount(1);
01001 gen.setHwFail();
01002 usleep(10000);
01003 sts = gen.getNext(fps);
01004 BOOST_REQUIRE_EQUAL(sts, false);
01005 BOOST_REQUIRE_EQUAL(fps.size(), 0);
01006
01007 gen.StopCmd(0xFFFFFFFF, 1);
01008 gen.joinThreads();
01009 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_NonThreaded test case END" << TLOG_ENDL;
01010 }
01011
01012 BOOST_AUTO_TEST_CASE(HardwareFailure_Threaded)
01013 {
01014 artdaq::configureMessageFacility("CommandableFragmentGenerator_t");
01015 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_Threaded test case BEGIN" << TLOG_ENDL;
01016 fhicl::ParameterSet ps;
01017 ps.put<int>("board_id", 1);
01018 ps.put<int>("fragment_id", 1);
01019 ps.put<bool>("separate_data_thread", true);
01020 ps.put<bool>("separate_monitoring_thread", true);
01021 ps.put<int64_t>("hardware_poll_interval_us", 750000);
01022
01023 artdaqtest::CommandableFragmentGeneratorTest gen(ps);
01024 gen.StartCmd(1, 0xFFFFFFFF, 1);
01025
01026
01027
01028 artdaq::FragmentPtrs fps;
01029 auto sts = gen.getNext(fps);
01030 BOOST_REQUIRE_EQUAL(sts, true);
01031 BOOST_REQUIRE_EQUAL(fps.size(), 1u);
01032 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
01033 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 1);
01034 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
01035 fps.clear();
01036
01037 gen.setFireCount(1);
01038 gen.setHwFail();
01039 sts = gen.getNext(fps);
01040 BOOST_REQUIRE_EQUAL(sts, true);
01041 BOOST_REQUIRE_EQUAL(fps.size(), 1);
01042 BOOST_REQUIRE_EQUAL(fps.front()->fragmentID(), 1);
01043 BOOST_REQUIRE_EQUAL(fps.front()->timestamp(), 2);
01044 BOOST_REQUIRE_EQUAL(fps.front()->sequenceID(), 1);
01045
01046 fps.clear();
01047 sleep(1);
01048 gen.setFireCount(1);
01049 sts = gen.getNext(fps);
01050 BOOST_REQUIRE_EQUAL(sts, false);
01051 BOOST_REQUIRE_EQUAL(fps.size(), 0);
01052
01053 gen.StopCmd(0xFFFFFFFF, 1);
01054 gen.joinThreads();
01055 TLOG_INFO("CommandableFragmentGenerator_t") << "HardwareFailure_Threaded test case END" << TLOG_ENDL;
01056 }
01057
01058 BOOST_AUTO_TEST_SUITE_END()