CbmRoot
CbmMqHistoServer.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef CBMMQHISTOSERVER_H
9 #define CBMMQHISTOSERVER_H
10 
11 #include "FairMQDevice.h"
12 
13 #include "THttpServer.h"
14 #include "TObjArray.h"
15 
16 #include <memory>
17 #include <string>
18 #include <thread>
19 
20 class TNamed;
21 class TCanvas;
22 
23 class CbmMqHistoServer : public FairMQDevice {
24 public:
26 
27  virtual ~CbmMqHistoServer();
28 
29  void UpdateHttpServer();
30 
31 protected:
32  virtual void InitTask();
33 
34  bool ReceiveData(FairMQMessagePtr& msg, int index);
35 
36  bool ReceiveHistoConfig(FairMQMessagePtr& msg, int index);
37 
38  bool ReceiveCanvasConfig(FairMQMessagePtr& msg, int index);
39 
40  virtual void PreRun();
41 
42  virtual void PostRun();
43 
44 private:
49  std::string fsHistoFileName;
50  uint32_t fuHttpServerPort;
51 
53  TObjArray fArrayHisto;
55  std::vector<std::pair<std::string, std::string>> fvpsHistosFolder;
59  std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig;
60  std::vector<bool> fvbCanvasReady;
62 
63  std::vector<std::pair<TNamed*, std::string>>
65  std::vector<bool> fvbHistoRegistered;
67  std::vector<std::pair<TCanvas*, std::string>>
69  std::vector<bool> fvbCanvasRegistered;
71 
74 
75  THttpServer* fServer;
76 
77  std::thread fThread;
79 
80  template<class HistoT>
81  bool ReadHistogram(HistoT* pHist);
82  int FindHistogram(const std::string& name);
83  bool PrepareCanvas(uint32_t uCanvIdx);
84 
85  bool ResetHistograms();
86  bool SaveHistograms();
87 };
88 
89 #endif // CBMMQHISTOSERVER_H
CbmMqHistoServer::fThread
std::thread fThread
Definition: CbmMqHistoServer.h:77
CbmMqHistoServer::fbAllCanvasRegistered
bool fbAllCanvasRegistered
Definition: CbmMqHistoServer.h:70
CbmMqHistoServer::fsChannelNameHistosInput
std::string fsChannelNameHistosInput
Parameters.
Definition: CbmMqHistoServer.h:46
CbmMqHistoServer::ReceiveCanvasConfig
bool ReceiveCanvasConfig(FairMQMessagePtr &msg, int index)
Definition: CbmMqHistoServer.cxx:179
CbmMqHistoServer::fServer
THttpServer * fServer
Definition: CbmMqHistoServer.h:75
CbmMqHistoServer::UpdateHttpServer
void UpdateHttpServer()
Definition: CbmMqHistoServer.cxx:218
CbmMqHistoServer::ReceiveHistoConfig
bool ReceiveHistoConfig(FairMQMessagePtr &msg, int index)
Definition: CbmMqHistoServer.cxx:147
CbmMqHistoServer::fvHistos
std::vector< std::pair< TNamed *, std::string > > fvHistos
Definition: CbmMqHistoServer.h:64
CbmMqHistoServer::FindHistogram
int FindHistogram(const std::string &name)
Definition: CbmMqHistoServer.cxx:287
CbmMqHistoServer::ReadHistogram
bool ReadHistogram(HistoT *pHist)
Definition: CbmMqHistoServer.cxx:233
CbmMqHistoServer::fNMessages
int fNMessages
Internal status.
Definition: CbmMqHistoServer.h:73
CbmMqHistoServer::ResetHistograms
bool ResetHistograms()
Definition: CbmMqHistoServer.cxx:297
CbmMqHistoServer::PostRun
virtual void PostRun()
Definition: CbmMqHistoServer.cxx:227
CbmMqHistoServer::fStopThread
bool fStopThread
Definition: CbmMqHistoServer.h:78
CbmMqHistoServer::ReceiveData
bool ReceiveData(FairMQMessagePtr &msg, int index)
Definition: CbmMqHistoServer.cxx:79
CbmMqHistoServer::fvbHistoRegistered
std::vector< bool > fvbHistoRegistered
Vector of Histos pointers and folder path.
Definition: CbmMqHistoServer.h:65
CbmMqHistoServer::CbmMqHistoServer
CbmMqHistoServer()
Definition: CbmMqHistoServer.cxx:36
CbmMqHistoServer::InitTask
virtual void InitTask()
Definition: CbmMqHistoServer.cxx:54
CbmMqHistoServer::~CbmMqHistoServer
virtual ~CbmMqHistoServer()
Definition: CbmMqHistoServer.cxx:52
CbmMqHistoServer::fsHistoFileName
std::string fsHistoFileName
Definition: CbmMqHistoServer.h:49
CbmMqHistoServer::fvCanvas
std::vector< std::pair< TCanvas *, std::string > > fvCanvas
Definition: CbmMqHistoServer.h:68
CbmMqHistoServer::PreRun
virtual void PreRun()
Definition: CbmMqHistoServer.cxx:213
CbmMqHistoServer
Definition: CbmMqHistoServer.h:23
CbmMqHistoServer::fuHttpServerPort
uint32_t fuHttpServerPort
Definition: CbmMqHistoServer.h:50
CbmMqHistoServer::fsChannelNameCanvasConfig
std::string fsChannelNameCanvasConfig
Definition: CbmMqHistoServer.h:48
CbmMqHistoServer::fvpsCanvasConfig
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
Definition: CbmMqHistoServer.h:59
CbmMqHistoServer::PrepareCanvas
bool PrepareCanvas(uint32_t uCanvIdx)
Definition: CbmMqHistoServer.cxx:303
CbmMqHistoServer::fbAllHistosRegistered
bool fbAllHistosRegistered
Definition: CbmMqHistoServer.h:66
CbmMqHistoServer::fsChannelNameHistosConfig
std::string fsChannelNameHistosConfig
Definition: CbmMqHistoServer.h:47
CbmMqHistoServer::fArrayHisto
TObjArray fArrayHisto
Array of histograms with unique names.
Definition: CbmMqHistoServer.h:53
CbmMqHistoServer::SaveHistograms
bool SaveHistograms()
Definition: CbmMqHistoServer.cxx:383
CbmMqHistoServer::fvbCanvasRegistered
std::vector< bool > fvbCanvasRegistered
Vector of Canvas pointers and folder path.
Definition: CbmMqHistoServer.h:69
CbmMqHistoServer::fbAllCanvasReady
bool fbAllCanvasReady
Definition: CbmMqHistoServer.h:61
CbmMqHistoServer::fvbCanvasReady
std::vector< bool > fvbCanvasReady
Definition: CbmMqHistoServer.h:60
CbmMqHistoServer::fvpsHistosFolder
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string with ( HistoName, FolderPath ) to send to the histogram server.
Definition: CbmMqHistoServer.h:55