1 #ifndef artdaq_DAQrate_RequestSender_hh
2 #define artdaq_DAQrate_RequestSender_hh
4 #include "artdaq/DAQrate/detail/RequestMessage.hh"
6 #include "fhiclcpp/types/Atom.h"
7 #include "fhiclcpp/types/Comment.h"
8 #include "fhiclcpp/types/ConfigurationTable.h"
9 #include "fhiclcpp/types/Name.h"
10 #include "fhiclcpp/types/Table.h"
12 #include <arpa/inet.h>
13 #include <netinet/in.h>
14 #include <sys/socket.h>
15 #include <sys/types.h>
35 fhicl::Atom<bool>
send_requests{fhicl::Name{
"send_requests"}, fhicl::Comment{
"Enable sending Data Request messages"},
false};
37 fhicl::Atom<int>
request_port{fhicl::Name{
"request_port"}, fhicl::Comment{
"Port to send DataRequests on"}, 3001};
39 fhicl::Atom<size_t>
request_delay_ms{fhicl::Name{
"request_delay_ms"}, fhicl::Comment{
"How long to wait before sending new DataRequests"}, 10};
41 fhicl::Atom<size_t>
request_shutdown_timeout_us{fhicl::Name{
"request_shutdown_timeout_us"}, fhicl::Comment{
"How long to wait for pending requests to be sent at shutdown"}, 100000};
43 fhicl::Atom<std::string>
output_address{fhicl::Name{
"multicast_interface_ip"}, fhicl::Comment{
"Use this hostname for multicast output(to assign to the proper NIC)"},
"0.0.0.0"};
45 fhicl::Atom<std::string>
request_address{fhicl::Name{
"request_address"}, fhicl::Comment{
"Multicast address to send DataRequests to"},
"227.128.12.26"};
47 fhicl::Atom<size_t>
min_request_interval_ms{fhicl::Name{
"min_request_interval_ms"}, fhicl::Comment{
"Minimum time between automatic sends (ignored in EndOfRun RequetsMode)"}, 100};
104 void AddRequest(Fragment::sequence_id_t seqID, Fragment::timestamp_t timestamp);
130 std::atomic<bool> initialized_;
131 mutable std::mutex request_mutex_;
132 mutable std::mutex request_send_mutex_;
133 std::map<Fragment::sequence_id_t, Fragment::timestamp_t> active_requests_;
134 std::string request_address_;
136 size_t request_delay_;
137 size_t request_shutdown_timeout_us_;
139 struct sockaddr_in request_addr_;
140 std::string multicast_out_addr_;
142 std::chrono::steady_clock::time_point last_request_send_time_;
143 size_t min_request_interval_ms_;
145 std::atomic<int> request_sending_;
146 uint32_t run_number_;
149 void setup_requests_();
151 void do_send_request_();
void RemoveRequest(Fragment::sequence_id_t seqID)
Remove a request from the request list.
detail::RequestMessageMode GetRequestMode() const
Get the mode for RequestMessages.
fhicl::Atom< int > request_port
"request_port" (Default: 3001): Port to send DataRequests on
The RequestSender contains methods used to send data requests and Routing tokens. ...
virtual ~RequestSender()
RequestSender Destructor.
void SendRequest(bool endOfRunOnly=false)
Send a request message containing all current requests.
fhicl::Atom< bool > send_requests
"send_requests" (Default: false): Whether to send DataRequests when new sequence IDs are seen ...
RequestSender()=delete
Default Constructor is deleted.
fhicl::Atom< size_t > min_request_interval_ms
"min_request_interval_ms" (Default: 500): Minimum time between automatic sends (ignored in EndOfRun R...
void SetRunNumber(uint32_t run)
Set the run number to be used in request messages.
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation (if desired)
fhicl::Atom< std::string > output_address
"multicast_interface_ip" (Default: "0.0.0.0"): Use this hostname for multicast output (to assign to t...
void SetRequestMode(detail::RequestMessageMode mode)
Set the mode for RequestMessages. Used to indicate when RequestSender should enter "EndOfRun" mode...
RequestMessageMode
Mode used to indicate current run conditions to the request receiver.
fhicl::Atom< size_t > request_shutdown_timeout_us
"request_shutdown_timeout_us" (Default: 100000 us): How long to wait for pending requests to be sent ...
RequestSender & operator=(RequestSender const &)=delete
Copy Assignment operator is deleted.
fhicl::Atom< size_t > request_delay_ms
"request_delay_ms" (Default: 10): How long to wait before sending new DataRequests ...
bool RequestsInFlight()
Determine if the RequestSender is currently sending any requests.
fhicl::Atom< std::string > request_address
"request_address" (Default: "227.128.12.26"): Multicast address to send DataRequests to ...
void AddRequest(Fragment::sequence_id_t seqID, Fragment::timestamp_t timestamp)
Add a request to the request list.
Configuration of the RequestSender. May be used for parameter validation