otsdaq-mu2e-stm  5.02.01
tcp_config.hh
1 #ifndef TCP_CONFIG_HH_
2 #define TCP_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 // TCP configurable variables
9 struct tcp_cfg_info{
10 
11  const std::string channel;
12 
13  // Sending TCP socket IP address
14  const std::string snd_ip;
15  // Sending TCP socket port
16  const uint16_t snd_port;
17 
18  // Server connection attempt timers
19  const int reconnect_period_ms; // milliseconds
20  const int disconnected_log_period; // seconds
21 
22  // The poll timout
23  const int poll_timeout_ms; // milliseconds
24 
25  // Constructor
26  tcp_cfg_info(Config& cfg,
27  const std::shared_ptr<AsyncLogger> logger,
28  master_info master_config) :
29  channel((master_config.ch_num) ? "stm.tcp.labr." : "stm.tcp.hpge."), // Channel descriptor
30  snd_ip(cfg.getValue<std::string>(channel+"ip")), // Receiving IP address
31  snd_port(cfg.getValue<int>(channel+"port")), // Receiving port
32  reconnect_period_ms(cfg.getValue<int>("stm.tcp.reconnect_period_ms")),
33  disconnected_log_period(cfg.getValue<int>("stm.tcp.disconnected_log_period")),
34  poll_timeout_ms(cfg.getValue<int>("stm.tcp.poll_timeout_ms")) // poll timeout (ms)
35  {
36 
37  // Notify user
38  if (logger){
39  logger->log("Config:tcp_info: TCP send socket IP address: = " +
40  snd_ip + ", port = " + std::to_string(snd_port) + ".",1);
41  logger->log("Config:tcp_info: Server reconnection attempt period = " +
42  std::to_string(reconnect_period_ms) + " ms (no connection logged every " +
43  std::to_string(disconnected_log_period) + " s).",1);
44  logger->log("Config:tcp_info: Poll timeout: = " +
45  std::to_string(poll_timeout_ms) + " ms.",1);
46  }
47 
48  }
49 
50 };
51 
52 #endif
Definition: config.hh:19