CbmRoot
CbmMQTsaSampler.h
Go to the documentation of this file.
1 
8 #ifndef CBMMQTSASAMPLER_H_
9 #define CBMMQTSASAMPLER_H_
10 
11 
12 #include "MicrosliceDescriptor.hpp"
13 #include "StorableTimeslice.hpp"
14 #include "Timeslice.hpp"
15 #include "TimesliceSource.hpp"
16 //#include "Message.hpp"
17 
18 #include "FairMQDevice.h"
19 
20 #include <ctime>
21 #include <string>
22 #include <vector>
23 
24 class CbmMQTsaSampler : public FairMQDevice {
25 public:
27  virtual ~CbmMQTsaSampler();
28 
29 protected:
30  uint64_t fMaxTimeslices;
31 
32  std::string fFileName;
33  std::string fDirName;
34 
35  std::vector<std::string> fInputFileList;
36  uint64_t fFileCounter;
37  std::string fHost;
38  uint64_t fPort;
39 
40  uint64_t fTSNumber;
41  uint64_t fTSCounter;
42  uint64_t fMessageCounter;
43 
44  int fMaxMemory = 0;
45 
46  virtual void InitTask();
47  virtual bool ConditionalRun();
48 
49 private:
50  bool OpenNextFile();
51 
52  bool CheckTimeslice(const fles::Timeslice& ts);
53  void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc);
54  bool SendData(const fles::StorableTimeslice& component);
55  void CalcRuntime();
56  bool IsChannelNameAllowed(std::string);
57  bool CreateAndSendComponent(const fles::Timeslice&, int);
58  bool SendData(const fles::StorableTimeslice&, int);
59 
60  fles::TimesliceSource* fSource;
61  std::chrono::steady_clock::time_point fTime;
62 
63 
64  // The vector fAllowedChannels contain the list of defined channel names
65  // which are used for connecting the different devices. For the time
66  // being the correct connection are done checking the names. A connection
67  // using the name stscomponent will receive timeslices containing the
68  // sts component only. The corresponding system ids are defined in the
69  // vector fSysId. At startup it is checked which channels are defined
70  // in the startup script such that later on only timeslices whith the
71  // corresponding data are send to the correct channels.
72  // TODO: Up to now we have three disconnected vectors which is very
73  // error prone. Find a better solution
74 
75  std::vector<std::string> fAllowedChannels = {"stscomponent",
76  "trdcomponent",
77  "tofcomponent"};
78  std::vector<int> fSysId = {16, 64, 96};
79 
80 
81  std::vector<int> fComponentsToSend = {0, 0, 0};
82  std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}};
83 };
84 
85 #endif /* CBMMQTSASAMPLER_H_ */
CbmMQTsaSampler::fTime
std::chrono::steady_clock::time_point fTime
Definition: CbmMQTsaSampler.h:61
CbmMQTsaSampler::fTSNumber
uint64_t fTSNumber
Definition: CbmMQTsaSampler.h:40
CbmMQTsaSampler::fAllowedChannels
std::vector< std::string > fAllowedChannels
Definition: CbmMQTsaSampler.h:75
CbmMQTsaSampler::IsChannelNameAllowed
bool IsChannelNameAllowed(std::string)
Definition: CbmMQTsaSampler.cxx:222
CbmMQTsaSampler::fHost
std::string fHost
Definition: CbmMQTsaSampler.h:37
CbmMQTsaSampler::fSysId
std::vector< int > fSysId
Definition: CbmMQTsaSampler.h:78
CbmMQTsaSampler::SendData
bool SendData(const fles::StorableTimeslice &component)
CbmMQTsaSampler::fFileName
std::string fFileName
Definition: CbmMQTsaSampler.h:32
CbmMQTsaSampler::fComponentsToSend
std::vector< int > fComponentsToSend
Definition: CbmMQTsaSampler.h:81
CbmMQTsaSampler::InitTask
virtual void InitTask()
Definition: CbmMQTsaSampler.cxx:55
CbmMQTsaSampler::fMaxMemory
int fMaxMemory
Definition: CbmMQTsaSampler.h:44
CbmMQTsaSampler::fTSCounter
uint64_t fTSCounter
Definition: CbmMQTsaSampler.h:41
CbmMQTsaSampler::CheckTimeslice
bool CheckTimeslice(const fles::Timeslice &ts)
Definition: CbmMQTsaSampler.cxx:387
CbmMQTsaSampler::fFileCounter
uint64_t fFileCounter
Definition: CbmMQTsaSampler.h:36
CbmMQTsaSampler::fMaxTimeslices
uint64_t fMaxTimeslices
Definition: CbmMQTsaSampler.h:30
CbmMQTsaSampler::PrintMicroSliceDescriptor
void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor &mdsc)
Definition: CbmMQTsaSampler.cxx:369
CbmMQTsaSampler::~CbmMQTsaSampler
virtual ~CbmMQTsaSampler()
Definition: CbmMQTsaSampler.cxx:358
CbmMQTsaSampler::fSource
fles::TimesliceSource * fSource
Definition: CbmMQTsaSampler.h:60
CbmMQTsaSampler
Definition: CbmMQTsaSampler.h:24
CbmMQTsaSampler::CbmMQTsaSampler
CbmMQTsaSampler()
Definition: CbmMQTsaSampler.cxx:40
CbmMQTsaSampler::fMessageCounter
uint64_t fMessageCounter
Definition: CbmMQTsaSampler.h:42
CbmMQTsaSampler::fInputFileList
std::vector< std::string > fInputFileList
List of input files.
Definition: CbmMQTsaSampler.h:35
CbmMQTsaSampler::CalcRuntime
void CalcRuntime()
Definition: CbmMQTsaSampler.cxx:360
CbmMQTsaSampler::ConditionalRun
virtual bool ConditionalRun()
Definition: CbmMQTsaSampler.cxx:245
CbmMQTsaSampler::OpenNextFile
bool OpenNextFile()
Definition: CbmMQTsaSampler.cxx:197
CbmMQTsaSampler::fChannelsToSend
std::vector< std::vector< std::string > > fChannelsToSend
Definition: CbmMQTsaSampler.h:82
CbmMQTsaSampler::CreateAndSendComponent
bool CreateAndSendComponent(const fles::Timeslice &, int)
Definition: CbmMQTsaSampler.cxx:287
CbmMQTsaSampler::fDirName
std::string fDirName
Definition: CbmMQTsaSampler.h:33
CbmMQTsaSampler::fPort
uint64_t fPort
Definition: CbmMQTsaSampler.h:38