Belle II Software development
HistoServer2.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <string>
11
12#include <daq/dataflow/EvtSocket.h>
13#include <daq/dataflow/EvtSocketManager.h>
14
15#include <daq/dqm/HistoManager2.h>
16#include <map>
17#include <vector>
18
19// ROOT socket
20#include <TServerSocket.h>
21#include <TSocket.h>
22#include <TObject.h>
23
24namespace Belle2 {
29
30 class HistoServer2 {
31 public:
32 enum {c_maxBufSize = 160000000 };
34 enum { c_mergeIntervall = 5000 };
35
36 public:
37 HistoServer2(int port, const std::string& mapfile);
38 ~HistoServer2();
39
40 int init();
41
42 int server(); // Loop
43
44 private:
45 EvtSocketRecv* m_sock;
46 EvtSocketManager* m_man;
47 int m_port;
48 int m_force_exit;
49
51 TServerSocket* m_root_server_sock = nullptr;
52 TSocket* m_root_socket = nullptr;
53 bool recv_root_message(std::vector<TObject*>& objlist,
54 std::vector<std::string>& strlist,
55 int& fd);
56 void handle_objects(std::vector<TObject*>& objlist,
57 std::vector<std::string>& strlist,
58 int fd,
59 bool& updated);
60
62 void write_state(void);
63 private:
64 std::string m_filename;
65 HistoManager2* m_hman;
66
68 std::map <std::string, std::pair<int, bool>> m_units_connected;
69 std::map <std::string, time_t> m_unit_last_conn_time;
70 std::map <std::string, time_t> m_unit_last_packet_time;
71 std::map <std::string, time_t> m_unit_last_content_time;
72 time_t m_last_merge_time{};
73 };
74
75}
76
TServerSocket * m_root_server_sock
ROOT TSocket receiver.
std::map< std::string, std::pair< int, bool > > m_units_connected
connection IP, state and last update time
void write_state(void)
Write connection state to a file.
Abstract base class for different kinds of events.