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