Belle II Software development
DeSerializer.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
9#ifndef DESERIALIZER_H
10#define DESERIALIZER_H
11
12#include <string>
13#include <stdlib.h>
14#include <sys/time.h>
15
16#include <framework/core/Module.h>
17#include <framework/datastore/StoreObjPtr.h>
18#include <framework/datastore/StoreArray.h>
19#include <framework/dataobjects/EventMetaData.h>
20
21#include <daq/slc/readout/RunInfoBuffer.h>
22#include <daq/rawdata/CprErrorMessage.h>
23#include <daq/rawdata/modules/DAQConsts.h>
24
25#include <rawdata/dataobjects/RawDataBlock.h>
26
27namespace Belle2 {
32
34
35
36 class DeSerializerModule : public Module {
37
38 // Public functions
39 public:
40
43 virtual ~DeSerializerModule() override;
44
46 void initialize() override;
47
48 void terminate() override;
49
51
53 virtual void openOutputFile();
54
56 virtual void dumpData(char* buf, int size);
57
59 virtual void printData(int* buf, int nwords);
60
62 virtual void printASCIIData(int* buf, int nwords);
63
64 protected :
65
66 // Event Meta Data
67 StoreObjPtr<EventMetaData> m_eventMetaDataPtr;
68
69 StoreArray<RawDataBlock> raw_datablkarray;
70
71
74
77
80
83
86
89
91 std::string m_dump_fname;
92
94 FILE* m_fp_dump = nullptr;
95
97 int* m_buffer = nullptr;
98
100 int* m_bufary[ NUM_PREALLOC_BUF ] = {};
101 // int* m_bufary[NUM_EVT_PER_BASF2LOOP];
102
104 virtual int* getPreAllocBuf();
105
107 virtual int* getNewBuffer(int nwords, int* delete_flag);
108
109 // For monitoring
110 timeval m_t0;
111 double m_totbytes;
112 double m_prev_totbytes = 0.0;
113 int m_ncycle = 0;
115 double cur_time = 0.0;
116
117 double m_start_time = 0.0;
118 double m_prev_time;
119 double time_array0[1000] = {};
120 double time_array1[1000] = {};
121 double time_array2[1000] = {};
122 double time_array3[1000] = {};
123 double time_array4[1000] = {};
124 double time_array5[1000] = {};
125 int prev_event;
126
128 static double getTimeSec();
129
131 void recordTime(int event, double* array);
132
134 int checkData(char* buf, int prev_eve, int* cur_eve);
135
137 static unsigned int calcSimpleChecksum(const int* buf, int nwords);
138
140 static unsigned int calcXORChecksum(const int* buf, int nwords);
141
142 virtual void clearNumUsedBuf()
143 {
144 m_num_usedbuf = 0;
145 return ;
146 }
147
149 void RateMonitor(unsigned int nevt, int subrun = -1, int run = -1);
150
151
154
155
158
160 std::string m_nodename;
161
164
167
169 unsigned int m_exprunsubrun_no;
170
173
176
179
182
185
187 static void shmOpen(char* path_cfg, char* path_sta);
188
190 static int* shmGet(int fd, int size_words);
191
193 int m_shmfd_cfg = 0;
194
196 int m_shmfd_sta = 0;
197
200
202 //int* m_cfg_buf;
204 //int* m_cfg_sta;
205
207
210
213
214
215#ifdef NONSTOP
217 int* m_ptr;
218
220 virtual void openRunPauseNshm();
221
223 virtual int checkRunPause();
224
226 virtual int checkRunRecovery();
227
228
230 virtual void resumeRun();
231
233 virtual void pauseRun();
234
236 virtual void waitResume();
237
239 void callCheckRunPause(std::string& err_str);
240
242 int CheckConnection(int socket);
243
244#endif
245
246 private:
247
248 public:
249 static RunInfoBuffer& getStatus()
250 {
251 return g_status;
252 }
253
254
255 };
256
258} // end namespace Belle2
259
260#endif // MODULEHELLO_H
static void shmOpen(char *path_cfg, char *path_sta)
open shared memory
void RateMonitor(unsigned int nevt, int subrun=-1, int run=-1)
monitor rate
unsigned int m_prev_exprunsubrun_no
run no.
static unsigned int calcSimpleChecksum(const int *buf, int nwords)
calculate checksum
void initialize() override
Module functions to be called from main process.
std::string m_nodename
Node name.
virtual int * getPreAllocBuf()
Getbuffer.
static int * shmGet(int fd, int size_words)
Get shared memory.
int BUF_SIZE_WORD
size of buffer for one event (word)
int m_shmfd_cfg
file descripter for shm
static RunInfoBuffer g_status
buffer class to communicate with NSM client
int checkData(char *buf, int prev_eve, int *cur_eve)
check data
void terminate() override
This method is called at the end of the event processing.
int n_basf2evt
No. of sent events.
DeSerializerModule()
Constructor / Destructor.
CprErrorMessage print_err
wrapper for B2LOG system
int m_shmfd_sta
file descripter for shm
virtual void dumpData(char *buf, int size)
dump binary data
virtual void printData(int *buf, int nwords)
dump error data
virtual int * getNewBuffer(int nwords, int *delete_flag)
Getbuffer.
double cur_time
for time monitoring
std::string m_dump_fname
dump filename
int m_shmflag
Use shared memory.
int monitor_numeve
buffer for shared memory
static unsigned int calcXORChecksum(const int *buf, int nwords)
calculate checksum
int m_prev_nevt
No. of prev sent events.
void recordTime(int event, double *array)
store time info.
int m_compressionLevel
Compression Level.
int * m_bufary[NUM_PREALLOC_BUF]
buffer
unsigned int m_exprunsubrun_no
run no.
virtual void printASCIIData(int *buf, int nwords)
dump error data
virtual void openOutputFile()
Module functions to be called from main process.
double max_seconds
time to stop a run
FILE * m_fp_dump
dump file descripter
int m_nodeid
Node(PC or COPPER) ID.
static double getTimeSec()
store time info.
Module()
Constructor.
Definition Module.cc:30
virtual void event()
This method is the core of the module.
Definition Module.h:157
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Abstract base class for different kinds of events.