8#include <daq/dqm/HistoServer.h>
10#include <framework/pcore/MsgHandler.h>
17HistoServer::HistoServer(
int port,
const string& filename)
21 m_filename = filename;
24HistoServer::~HistoServer()
31int HistoServer:: init()
36 m_memfile =
new DqmMemFile(m_filename,
"write", DqmMemFile::c_memFileSize);
47int HistoServer::server()
53 char* buffer =
new char[c_maxBufSize];
57 while (m_force_exit == 0) {
59 int exam_stat = m_man->examine();
61 }
else if (exam_stat == 1) {
63 vector<int>& recvsock = m_man->connected_socket_list();
64 for (vector<int>::iterator it = recvsock.begin();
65 it != recvsock.end(); ++it) {
67 if (m_man->connected(fd)) {
68 int is = sio.get(fd, buffer, c_maxBufSize);
71 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
72 printf(
"[%s] HistoServer: fd %d disconnected\n", mbstr, fd);
80 vector<TObject*> objlist;
81 vector<string> strlist;
82 msghdl.decode_msg(hmsg, objlist, strlist);
83 int nobjs = (hmsg->
header())->reserved[1];
87 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
88 printf(
"[%s] HistoServer : received nobjs = %d\n", mbstr, nobjs);
89 for (
int i = 0; i < nobjs; i++) {
92 string objname = strlist.at(i);
93 if (objname ==
string(
"DQMRC:CLEAR")) {
97 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
98 printf(
"[%s] HistoServer: CLEAR\n", mbstr);
102 if (objname ==
string(
"DQMRC:MERGE")) {
105 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
106 printf(
"[%s] HistoServer: MERGE\n", mbstr);
110 auto lpos = objname.find(
"DQMRC:SAVE:");
111 if (lpos != string::npos) {
112 auto filename = objname.substr(11);
113 m_hman->filedump(filename);
116 lpos = objname.find(
"SUBDIR:");
117 if (lpos != string::npos) {
118 subdir = objname.substr(7);
119 if (subdir ==
"EXIT") subdir =
"";
122 m_hman->update(subdir, strlist.at(i), fd, (TH1*)objlist.at(i));
130 if (loop_counter % c_mergeIntervall == 0 && updated) {
132 strftime(mbstr,
sizeof(mbstr),
"%c", localtime(&now));
133 printf(
"[%s] HistoServer: merging histograms\n", mbstr);
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
A class to encode/decode an EvtMessage.
Abstract base class for different kinds of events.