00001 #include "artdaq/TransferPlugins/TransferInterface.hh" 00002 #include "cetlib_except/exception.h" 00003 00004 artdaq::TransferInterface::TransferInterface(const fhicl::ParameterSet& ps, Role role) 00005 : role_(role) 00006 , source_rank_(ps.get<int>("source_rank", my_rank)) 00007 , destination_rank_(ps.get<int>("destination_rank", my_rank)) 00008 , unique_label_(ps.get<std::string>("unique_label", "transfer_between_" + std::to_string(source_rank_) + "_and_" + std::to_string(destination_rank_))) 00009 , buffer_count_(ps.get<size_t>("buffer_count", 10)) 00010 , max_fragment_size_words_(ps.get<size_t>("max_fragment_size_words", 1024)) 00011 { 00012 TLOG_DEBUG(uniqueLabel()) << "TransferInterface constructor has " << ps.to_string() << TLOG_ENDL; 00013 } 00014 00015 int artdaq::TransferInterface::receiveFragment(artdaq::Fragment& frag, size_t receive_timeout) 00016 { 00017 auto ret = RECV_TIMEOUT; 00018 00019 TLOG_TRACE("TransferInterface") << "Receiving Fragment Header from rank " << source_rank() << TLOG_ENDL; 00020 ret = receiveFragmentHeader(*reinterpret_cast<detail::RawFragmentHeader*>(frag.headerAddress()), receive_timeout); 00021 00022 TLOG_TRACE("TransferInterface") << "Done receiving Header, ret is " << ret << ", should be " << source_rank() << TLOG_ENDL; 00023 if (ret == RECV_TIMEOUT) return ret; 00024 00025 frag.autoResize(); 00026 00027 TLOG_TRACE("TransferInterface") << "Receiving Fragment Body from rank " << source_rank() << TLOG_ENDL; 00028 auto bodyret = receiveFragmentData(frag.headerAddress() + detail::RawFragmentHeader::num_words(), frag.sizeBytes() - detail::RawFragmentHeader::num_words() * sizeof(RawDataType)); 00029 TLOG_TRACE("TransferInterface") << "Done receiving Body, ret is " << bodyret << ", should be " << source_rank() << TLOG_ENDL; 00030 00031 if (bodyret != ret) throw cet::exception("TransferInterface") << "Got different return codes from receiveFragmentHeader and receiveFragmentData!"; 00032 00033 return ret; 00034 }