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