1 #ifndef artdaq_DAQrate_RequestSender_hh
2 #define artdaq_DAQrate_RequestSender_hh
4 #include "artdaq/DAQdata/Globals.hh"
5 #include "artdaq-core/Data/RawEvent.hh"
6 #include "artdaq-utilities/Plugins/MetricManager.hh"
7 #include "artdaq/DAQrate/detail/RequestMessage.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "fhiclcpp/types/Table.h"
16 #include <arpa/inet.h>
17 #include <netinet/in.h>
18 #include <sys/types.h>
19 #include <sys/socket.h>
38 fhicl::Atom<bool>
use_routing_master{ fhicl::Name{
"use_routing_master" }, fhicl::Comment{
"True if using the Routing Master" },
false };
40 fhicl::Atom<int>
routing_token_port{ fhicl::Name{
"routing_token_port" },fhicl::Comment{
"Port to send tokens on" },35555 };
42 fhicl::Atom<std::string>
routing_token_host{ fhicl::Name{
"routing_master_hostname" }, fhicl::Comment{
"Hostname or IP of RoutingMaster" },
"localhost" };
51 fhicl::Atom<bool>
send_requests{ fhicl::Name{
"send_requests" }, fhicl::Comment{
"Enable sending Data Request messages" },
false };
53 fhicl::Atom<int>
request_port{ fhicl::Name{
"request_port"}, fhicl::Comment{
"Port to send DataRequests on"},3001 };
55 fhicl::Atom<size_t>
request_delay_ms{ fhicl::Name{
"request_delay_ms"}, fhicl::Comment{
"How long to wait before sending new DataRequests"}, 10 };
57 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 };
59 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" };
61 fhicl::Atom<std::string>
request_address{ fhicl::Name{
"request_address"}, fhicl::Comment{
"Multicast address to send DataRequests to" },
"227.128.12.26" };
62 fhicl::Table<RoutingTokenConfig>
routing_token_config{ fhicl::Name{
"routing_token_config"}, fhicl::Comment{
"FHiCL table containing RoutingToken configuration"} };
64 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
65 using Parameters = fhicl::WrappedTable<Config>;
118 void AddRequest(Fragment::sequence_id_t seqID, Fragment::timestamp_t timestamp);
135 mutable std::mutex request_mutex_;
136 mutable std::mutex request_send_mutex_;
137 std::map<Fragment::sequence_id_t, Fragment::timestamp_t> active_requests_;
138 std::string request_address_;
140 size_t request_delay_;
141 size_t request_shutdown_timeout_us_;
143 struct sockaddr_in request_addr_;
144 std::string multicast_out_addr_;
147 bool send_routing_tokens_;
150 std::string token_address_;
151 std::atomic<int> request_sending_;
154 void setup_requests_();
156 void do_send_request_();
158 void setup_tokens_();
160 void send_routing_token_(
int nSlots);
void RemoveRequest(Fragment::sequence_id_t seqID)
Remove a request from the request list.
fhicl::Atom< bool > use_routing_master
"use_routing_master" (Default: false) : Whether to send tokens to a RoutingMaster ...
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.
void SendRoutingToken(int nSlots)
Send a RoutingToken message indicating that slots are available.
fhicl::Atom< bool > send_requests
"send_requests" (Default: false): Whether to send DataRequests when new sequence IDs are seen ...
Configuration for Routing token sending
RequestSender()=delete
Default Constructor is deleted.
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 ...
fhicl::Table< RoutingTokenConfig > routing_token_config
Configuration for sending RoutingTokens. See artdaq::RequestSender::RoutingTokenConfig.
fhicl::Atom< std::string > routing_token_host
"routing_master_hostname" (Default: "localhost") : Hostname or IP of RoutingMaster ...
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 ...
fhicl::Atom< int > routing_token_port
"routing_token_port" (Default: 35555) : Port to send tokens on
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