Belle II Software development
Serializer.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 SERIALIZER_H
10#define SERIALIZER_H
11
12#include <string>
13
14#include <framework/core/Module.h>
15
16#include <daq/dataflow/EvtSocket.h>
17
18#include <daq/rawdata/CprErrorMessage.h>
19#include <daq/dataobjects/SendHeader.h>
20#include <daq/dataobjects/SendTrailer.h>
21#include <rawdata/dataobjects/RawDataBlock.h>
22
23#include <rawdata/dataobjects/RawHeader_latest.h>
24
25#include <sys/mman.h>
26
27namespace Belle2 {
35 class SerializerModule : public Module {
36
37 // Public functions
38 public:
39
42 virtual ~SerializerModule();
43
45 void initialize() override;
46
48 void beginRun() override;
49 void event() override;
50 void endRun() override;
51 void terminate() override;
52
53 virtual int sendByWriteV(RawDataBlock* rawdblk);
54 // virtual void Connect(const char* hostname, const int port);
55 virtual void Accept();
56
57 virtual void fillSendHeaderTrailer(SendHeader* hdr, SendTrailer* trl, RawDataBlock* rawdblk);
58 // Data members
59
61 unsigned int calcXORChecksum(int* buf, int nwords);
62
65
67 void shmOpen(char* path_cfg, char* path_sta);
68
70 int* shmGet(int fd, int size_words);
71
73 int Send(int socket, char* buf, int size_bytes);
74
76 void printData(int* buf, int nwords);
77
79 int CheckConnection(int socket);
80
83
86
89
92
93
94 protected :
95
96 enum {
97 COPPER = 1,
98 ROPC = 2
99 };
100
103
106
109
110 int* m_buffer;
111
112 // Parameters for EvtSocket
113
115 std::string m_hostname_local;
116
119
122
125
126 double m_start_time;
127
128 double m_prev_time;
129
130 unsigned int m_prev_nevt;
131
132 double m_prev_totbytes;
133
134 double time_array0[1000];
135 double time_array1[1000];
136 double time_array2[1000];
137
139 std::string p_method;
140 int p_method_val;
141
143 double getTimeSec();
144
146 void recordTime(int event, double* array);
147
150
152 unsigned long long m_totbytes;
153
156
157#ifdef NONSTOP
159 int* m_ptr;
160
162 virtual void openRunPauseNshm();
163
165 virtual int checkRunPause();
166
168 virtual void resumeRun();
169
171 void callCheckRunPause(std::string& err_str);
172
173#endif
174
177
178 };
179
181} // end namespace Belle2
182
183#endif // MODULEHELLO_H
Base class for Modules.
Definition: Module.h:72
The RawDataBlock class Base class for rawdata handling.
Definition: RawDataBlock.h:27
The Raw Header class ver.1 ( the latest version since May, 2014 ) This class defines the format of th...
A class definition of an input module for Sequential ROOT I/O.
Definition: Serializer.h:35
void shmOpen(char *path_cfg, char *path_sta)
open shared memory
Definition: Serializer.cc:136
int CheckConnection(int socket)
Check socket status.
unsigned long long m_totbytes
sent data size
Definition: Serializer.h:152
int m_port_to
Destination port.
Definition: Serializer.h:118
std::string m_hostname_local
Destination Host.
Definition: Serializer.h:115
SerializerModule()
Constructor / Destructor.
Definition: Serializer.cc:35
void initialize() override
Module functions to be called from main process.
Definition: Serializer.cc:61
unsigned int calcXORChecksum(int *buf, int nwords)
calculate checksum
Definition: Serializer.cc:477
int m_socket
Socket ID.
Definition: Serializer.h:121
int * shmGet(int fd, int size_words)
Get shared memory.
Definition: Serializer.cc:130
void event() override
This method is the core of the module.
Definition: Serializer.cc:595
int m_start_flag
start flag
Definition: Serializer.h:155
int BUF_SIZE_WORD
size of buffer for one event (word)
Definition: Serializer.h:102
int m_shmfd_cfg
file descripter for shm
Definition: Serializer.h:82
int * m_cfg_buf
buffer for shared memory
Definition: Serializer.h:88
void endRun() override
This method is called if the current run ends.
Definition: Serializer.cc:110
EvtSocketSend * m_sock
EvtSocket.
Definition: Serializer.h:124
void terminate() override
This method is called at the end of the event processing.
Definition: Serializer.cc:117
int n_basf2evt
No. of sent events.
Definition: Serializer.h:108
CprErrorMessage print_err
error message program
Definition: Serializer.h:149
int m_shmfd_sta
file descripter for shm
Definition: Serializer.h:85
void printData(int *buf, int nwords)
print data contents
Definition: Serializer.cc:487
void beginRun() override
Module functions to be called from event process.
Definition: Serializer.cc:102
int m_shmflag
Use shared memory.
Definition: Serializer.h:64
void recordTime(int event, double *array)
store time info.
Definition: Serializer.cc:468
int * m_cfg_sta
buffer for shared memory
Definition: Serializer.h:91
int m_compressionLevel
Compression parameter.
Definition: Serializer.h:105
std::string p_method
How to handle data.
Definition: Serializer.h:139
int Send(int socket, char *buf, int size_bytes)
send buffer
Definition: Serializer.cc:322
double getTimeSec()
store time info.
Definition: Serializer.cc:460
RawHeader_latest tmp_header
which format is used
Definition: Serializer.h:176
Abstract base class for different kinds of events.