1 #define TRACE_NAME "RequestSender"
3 #include <boost/program_options.hpp>
4 #include "fhiclcpp/make_ParameterSet.h"
5 namespace bpo = boost::program_options;
7 #include "artdaq/DAQrate/RequestSender.hh"
8 #include "artdaq/DAQrate/RequestReceiver.hh"
9 #include "artdaq-core/Utilities/configureMessageFacility.hh"
10 #include "artdaq/Application/LoadParameterSet.hh"
12 int main(
int argc,
char* argv[])
14 artdaq::configureMessageFacility(
"RequestSender");
18 fhicl::TableFragment<artdaq::RequestSender::Config> senderConfig;
19 fhicl::Atom<bool> use_receiver{ fhicl::Name{
"use_receiver"}, fhicl::Comment{
"Whether to setup a RequestReceiver to verify that requests are being sent"},
false };
20 fhicl::Atom<size_t> receiver_timeout_ms{ fhicl::Name{
"recevier_timeout_ms"}, fhicl::Comment{
"Amount of time to wait for the receiver to receive a request message"}, 1000 };
21 fhicl::Table<artdaq::RequestReceiver::Config> receiver_config{ fhicl::Name{
"receiver_config"}, fhicl::Comment{
"Configuration for RequestReceiver, if used"} };
22 fhicl::Atom<int> num_requests{ fhicl::Name{
"num_requests"}, fhicl::Comment{
"Number of requests to send"} };
23 fhicl::Atom<artdaq::Fragment::sequence_id_t> starting_sequence_id{ fhicl::Name{
"starting_sequence_id" }, fhicl::Comment{
"Sequence ID of first request" },1 };
24 fhicl::Atom<artdaq::Fragment::sequence_id_t> sequence_id_scale{ fhicl::Name{
"sequence_id_scale" }, fhicl::Comment{
"Amount to increment Sequence ID for each request" },1 };
25 fhicl::Atom<artdaq::Fragment::timestamp_t> starting_timestamp{ fhicl::Name{
"starting_timestamp"}, fhicl::Comment{
"Timestamp of first request"},1 };
26 fhicl::Atom<artdaq::Fragment::timestamp_t> timestamp_scale{ fhicl::Name{
"timestamp_scale"}, fhicl::Comment{
"Amount to increment timestamp for each request"}, 1 };
29 auto pset = LoadParameterSet<Config>(argc, argv,
"sender",
"This test application sends Data Request messages and optionally receives them to detect issues in the network transport");
35 std::unique_ptr<artdaq::RequestReceiver> receiver(
nullptr);
36 int num_requests = pset.get <
int>(
"num_requests", 1);
37 if (pset.get<
bool>(
"use_receiver",
false))
40 receiver->startRequestReception();
43 auto seq = pset.get<artdaq::Fragment::sequence_id_t>(
"starting_sequence_id", 1);
44 auto seq_scale = pset.get<artdaq::Fragment::sequence_id_t>(
"sequence_id_scale", 1);
45 auto ts = pset.get<artdaq::Fragment::timestamp_t>(
"starting_timestamp", 1);
46 auto ts_scale = pset.get<artdaq::Fragment::timestamp_t>(
"timestamp_scale", 1);
47 auto tmo = pset.get<
size_t>(
"recevier_timeout_ms", 1000);
49 for (
auto ii = 0; ii < num_requests; ++ii)
51 sender.AddRequest(seq, ts);
56 auto start_time = std::chrono::steady_clock::now();
58 while (!recvd && artdaq::TimeUtils::GetElapsedTimeMilliseconds(start_time) < tmo)
60 auto reqs = receiver->GetRequests();
63 TLOG(TLVL_INFO) <<
"Received Request for Sequence ID " << seq <<
", timestamp " << reqs[seq];
64 receiver->RemoveRequest(seq);
65 sender.RemoveRequest(seq);
The RequestSender contains methods used to send data requests and Routing tokens. ...
Receive data requests and make them available to CommandableFragmentGenerator or other interested par...