CbmRoot
Loading...
Searching...
No Matches
CbmMqHistoServer.h
Go to the documentation of this file.
1/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau [committer] */
4
5#ifndef CBMMQHISTOSERVER_H
6#define CBMMQHISTOSERVER_H
7
8#include "FairMQDevice.h"
9
10#include "THttpServer.h"
11#include "TObjArray.h"
12#include <thread>
13
14#include <memory>
15#include <string>
16
17class TNamed;
18class TCanvas;
19
20class CbmMqHistoServer : public FairMQDevice {
21public:
23
24 virtual ~CbmMqHistoServer();
25
26 void UpdateHttpServer();
27
28protected:
29 virtual void InitTask();
30
31 bool ReceiveData(FairMQMessagePtr& msg, int index);
32
33 bool ReceiveHistoConfig(FairMQMessagePtr& msg, int index);
34
35 bool ReceiveCanvasConfig(FairMQMessagePtr& msg, int index);
36
37 bool ReceiveConfigAndData(FairMQParts& msg, int index);
38
39 virtual void PreRun();
40
41 virtual void PostRun();
42
43private:
45 std::string fsChannelNameHistosInput = "histogram-in";
46 std::string fsChannelNameHistosConfig = "histo-conf";
47 std::string fsChannelNameCanvasConfig = "canvas-conf";
48 std::string fsHistoFileName = "MqHistos.root";
49 uint32_t fuHttpServerPort = 8098;
50
52 TObjArray fArrayHisto;
54 std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
58 std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
59 std::vector<bool> fvbCanvasReady = {};
60 bool fbAllCanvasReady = false;
61
62 std::vector<std::pair<TNamed*, std::string>> fvHistos = {};
63 std::vector<bool> fvbHistoRegistered = {};
65 std::vector<std::pair<TCanvas*, std::string>> fvCanvas = {};
66 std::vector<bool> fvbCanvasRegistered = {};
68
70 int fNMessages = 0;
71
72 THttpServer* fServer = nullptr;
73
74 std::thread fThread;
75 bool fStopThread = false;
76
77 template<class HistoT>
78 bool ReadHistogram(HistoT* pHist);
79 int FindHistogram(const std::string& name);
80 bool PrepareCanvas(uint32_t uCanvIdx);
81
82 bool ResetHistograms();
83 bool SaveHistograms();
84};
85
86#endif // CBMMQHISTOSERVER_H
virtual void PostRun()
std::string fsChannelNameHistosInput
Parameters.
int fNMessages
Internal status.
bool PrepareCanvas(uint32_t uCanvIdx)
virtual void InitTask()
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string with ( HistoName, FolderPath ) to send to the histogram server.
std::string fsChannelNameHistosConfig
THttpServer * fServer
bool ReceiveData(FairMQMessagePtr &msg, int index)
std::vector< bool > fvbCanvasRegistered
Vector of Canvas pointers and folder path.
TObjArray fArrayHisto
Array of histograms with unique names.
int FindHistogram(const std::string &name)
std::vector< bool > fvbCanvasReady
virtual void PreRun()
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
bool ReceiveConfigAndData(FairMQParts &msg, int index)
bool ReceiveCanvasConfig(FairMQMessagePtr &msg, int index)
bool ReceiveHistoConfig(FairMQMessagePtr &msg, int index)
std::vector< bool > fvbHistoRegistered
Vector of Histos pointers and folder path.
std::string fsChannelNameCanvasConfig
bool ReadHistogram(HistoT *pHist)
std::vector< std::pair< TNamed *, std::string > > fvHistos
std::vector< std::pair< TCanvas *, std::string > > fvCanvas
std::string fsHistoFileName