1 #include "artdaq-core/Data/Fragment.hh"
2 #include "artdaq-core/Utilities/ExceptionHandler.hh"
3 #include "artdaq/TransferPlugins/TransferInterface.hh"
5 #include "cetlib/BasicPluginFactory.h"
6 #include "cetlib/filepath_maker.h"
7 #include "fhiclcpp/ParameterSet.h"
8 #include "fhiclcpp/make_ParameterSet.h"
10 #include <boost/asio.hpp>
11 #include <boost/lexical_cast.hpp>
26 fhicl::ParameterSet ReadParameterSet(
const std::string& fhicl_filename)
28 if (std::getenv(
"FHICL_FILE_PATH") ==
nullptr)
31 <<
"INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
32 setenv(
"FHICL_FILE_PATH",
".", 0);
35 fhicl::ParameterSet pset;
36 cet::filepath_lookup_after1 lookup_policy(
"FHICL_FILE_PATH");
37 fhicl::make_ParameterSet(fhicl_filename, lookup_policy, pset);
42 int main(
int argc,
char* argv[])
47 std::cerr <<
"Usage: <fhicl document> <number of sends (should be greater than 1) > <fragment payload size>" << std::endl;
51 auto fhicl_filename = boost::lexical_cast<std::string>(argv[1]);
52 auto num_sends = boost::lexical_cast<
size_t>(argv[2]);
53 auto fragment_size = boost::lexical_cast<
size_t>(argv[3]);
57 std::cerr <<
"Logic in the program requires requested # of sends to be greater than 1" << std::endl;
61 std::unique_ptr<artdaq::TransferInterface> transfer;
63 auto pset = ReadParameterSet(fhicl_filename);
67 static cet::BasicPluginFactory bpf(
"transfer",
"make");
70 bpf.makePlugin<std::unique_ptr<artdaq::TransferInterface>,
71 const fhicl::ParameterSet&,
73 pset.get<std::string>(
"transfer_plugin_type"),
79 artdaq::ExceptionHandler(artdaq::ExceptionHandlerRethrow::no,
80 "Error creating transfer plugin");
84 std::unique_ptr<artdaq::Fragment> frag = artdaq::Fragment::FragmentBytes(fragment_size);
86 struct ArbitraryMetadata
88 const uint64_t val1 = 0;
89 const uint32_t val2 = 0;
92 ArbitraryMetadata arbitraryMetadata;
94 frag->setMetadata(arbitraryMetadata);
99 std::iota(reinterpret_cast<uint64_t*>(frag->dataBeginBytes()),
100 reinterpret_cast<uint64_t*>(frag->dataEndBytes()),
103 auto timeout = pset.get<
size_t>(
"send_timeout_usecs", std::numeric_limits<size_t>::max());
105 for (
size_t i_i = 0; i_i < num_sends; ++i_i)
107 frag->setSequenceID(i_i + 1);
108 frag->setFragmentID(0);
109 frag->setUserType(artdaq::Fragment::FirstUserFragmentType);
111 transfer->transfer_fragment_min_blocking_mode(*frag, timeout);
114 std::cout <<
"# of sent fragments attempted == " << num_sends << std::endl;
This TransferInterface is a Sender.
Role
Used to determine if a TransferInterface is a Sender or Receiver.