otsdaq-mu2e-stm  5.02.01
udp_config.hh
1 #ifndef UDP_CONFIG_HH_
2 #define UDP_CONFIG_HH_
3 
4 // Include config files
5 #include "Mu2e-STMDAQ/config/config.hh"
6 #include "Mu2e-STMDAQ/config/include/master_config.hh"
7 
8 // UDP configurable variables
9 struct udp_info{
10 
11  const std::string channel;
12 
13  // Receiving UDP socket IP address
14  const std::string rcv_ip;
15  // Receiving UDP socket port
16  const uint16_t rcv_port;
17  // Sending UDP socket IP address
18  const std::string snd_ip;
19  // Sending UDP socket port
20  const uint16_t snd_port;
21 
22  // The recvmmsg timout
23  const int recv_timeout_s; // seconds
24  const int recv_timeout_us; // microseconds
25 
26  // The poll timout
27  const int poll_timeout_ms; // milliseconds
28 
29 
30  const int idle_timeout_ms;
31 
32  // Constructor
33  udp_info(Config& cfg,
34  const std::shared_ptr<AsyncLogger> logger,
35  master_info master_config) :
36  channel((master_config.ch_num) ? "stm.udp.labr." : "stm.udp.hpge."), // Channel descriptor
37  rcv_ip(cfg.getValue<std::string>(channel+"fw.ip")), // Receiving IP address
38  rcv_port(cfg.getValue<int>(channel+"fw.port")), // Receiving port
39  snd_ip(cfg.getValue<std::string>(channel+"sw.ip")), // Receiving IP address
40  snd_port(cfg.getValue<int>(channel+"sw.port")), // Receiving port
41  recv_timeout_s(cfg.getValue<int>("stm.udp.recv_timeout_secs")), // recvmmsg timeout (s)
42  recv_timeout_us(cfg.getValue<int>("stm.udp.recv_timeout_usecs")), // recvmmsg timeout (us)
43  poll_timeout_ms(cfg.getValue<int>("stm.udp.poll_timeout_ms")), // poll timeout (ms)
44  idle_timeout_ms(cfg.getValue<int>("stm.udp.idle_timeout_ms")) // idle timeout (ms)
45  {
46 
47  // Notify user
48  if (logger){
49  logger->log("Config:udp_info: UDP receive socket IP address: = " +
50  rcv_ip + ", port = " + std::to_string(rcv_port) + ".",1);
51  logger->log("Config:udp_info: UDP send socket IP address: = " +
52  snd_ip + ", port = " + std::to_string(snd_port) + ".",1);
53  logger->log("Config:udp_info: RECVMMSG timeout: = " +
54  std::to_string(recv_timeout_s) + " s + " +
55  std::to_string(recv_timeout_us) + " us.",1);
56  logger->log("Config:udp_info: Poll timeout: = " +
57  std::to_string(poll_timeout_ms) + " ms.",1);
58  }
59 
60  }
61 
62 };
63 
64 #endif
Definition: config.hh:19