RawDataBlock.h
Go to the documentation of this file.
1 #ifndef RAWDATABLOCKK_H
2 #define RAWDATABLOCKK_H
3 #include "DAQDataFormats/RawDataBlockV2.h"
4 #include "DAQDataFormats/RawMicroBlock.h"
5 #include "DAQDataFormats/Macros.h"
6 
7 #include <stdarg.h> // va_start
8 
9 /// It is requred to
10 /// 1. include DAQDataFormats/DataFormatFirst.inc
11 /// 2. define CURRENT_CLASS
12 /// 3. define CURRENT_CLASS_VERSION for version of the class
13 /// OR define LAST_CLASS_VERSION for the main structure of the class
14 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
15 /// 5. include DAQDataFormats/DataFormatLast.inc
16 /// before the declaration of the DataFormat version class in the header.
17 #include "DAQDataFormats/DataFormatFirst.inc"
18 #define CURRENT_CLASS RawDataBlock
19 #define LAST_CLASS_VERSION 2
20 #define CURRENT_FIELDS_SUB_NAMESPACE datablock
21 #include "DAQDataFormats/DataFormatLast.inc"
22 
23 namespace daqdataformats {
24 
25  static const uint32_t DEFAULT_DATABLOCK_SIZE = 262144; /* Maximum MicroBlock Buffer Size 64k */
26 
27  class RawDataBlock : public PREVIOUS_VERSION_CLASS_NAME {
28 
29  public:
30 
31  /// Constructors
32  /// I had to put version at the end, so that it would be compatible with the old BufferNodeEVB and DataLogger codes
33  RawDataBlock (const uint32_t buffersize = DEFAULT_DATABLOCK_SIZE, const uint32_t tlvl=0, const version_t version=datablockheader::RAWDATABLOCKHEADER_LATEST_VERSION); //! The default constructor
34  RawDataBlock (const RawDataBlock& copy_in); //! Deep copy constructor
35  RawDataBlock (const void* datablock_buffer, const version_t version = rawdaqdataformat::DAQDATAFORMAT_UNKNOWN_VERSION, const uint32_t buffersize = DEFAULT_DATABLOCK_SIZE); //! Shallow copy constructor
36  /// Destructor
37  ~RawDataBlock();
38 
39  /// Add the MicroBlock to _Buffer.
40  /// If check_mc_flag = true, the method checks whether the microslice
41  /// in the microblock is MC generatedand adds an appropriate flag to the DataBlock Header.
42  bool addMicroBlock(const void* microblock_buffer,
43  const bool check_mc_flag=true
44  )
45  {RETURN_FUNCTION(addMicroBlock1)(microblock_buffer, check_mc_flag);}
46  /// Add the MicroBlock of a known size to _Buffer.
47  /// If check_mc_flag = true, the method checks whether the microslice
48  /// in the microblock is MC generatedand adds an appropriate flag to the DataBlock Header.
49  bool addMicroBlock(const void* microblock_buffer,
50  const uint32_t microblock_size,
51  const bool check_mc_flag=true
52  )
53  {RETURN_FUNCTION(addMicroBlock2)(microblock_buffer, microblock_size, check_mc_flag);}
54  /// Add the MicroBlock to _Buffer by passing the references of
55  /// the MilliSlice and the MicroSlice. MilliSlice is the one that contains the MicroSlice.
56  /// If check_mc_flag = true, the method checks whether the microslice
57  /// in the microblock is MC generatedand adds an appropriate flag to the DataBlock Header.
58  bool addMicroBlock(const void* millislice_buffer,
59  const void* microslice_buffer,
60  const version_t microblock_version=microblock::RAWMICROBLOCK_LATEST_VERSION,
61  const bool check_mc_flag=true
62  )
63  {RETURN_FUNCTION(addMicroBlock3)(millislice_buffer,microslice_buffer, microblock_version, check_mc_flag);}
64  /// Add the MicroBlock to _Buffer by passing the references of
65  /// the MilliSlice and the MicroSlice of a known size.
66  /// MilliSlice is the one that contains the MicroSlice.
67  /// If check_mc_flag = true, the method checks whether the microslice
68  /// in the microblock is MC generatedand adds an appropriate flag to the DataBlock Header.
69  bool addMicroBlock(const void* millislice_buffer,
70  const void* microslice_buffer,
71  const uint32_t microslice_size,
72  const version_t microblock_version=microblock::RAWMICROBLOCK_LATEST_VERSION,
73  const bool check_mc_flag = true
74  )
75  {RETURN_FUNCTION(addMicroBlock4)(millislice_buffer, microslice_buffer, microslice_size, microblock_version, check_mc_flag);}
76 
77  bool addDCMData(const void* dcmdata_buffer) {RETURN_FUNCTION(addDCMData1)(dcmdata_buffer);}
78  bool addDCMData(const void* dcmdata_buffer, const uint32_t dcmdata_size){RETURN_FUNCTION(addDCMData2)(dcmdata_buffer,dcmdata_size);}
79 
80  bool close(bool produce_crc=false) {RETURN_FUNCTION(close)(produce_crc);}
81 
84  readDataStatus readData(const int fd){RETURN_FUNCTION(readDataFromFileDescriptor)(fd);}
85 
86 
87  IMPLEMENT_GET_MAIN(Version, uint32_t);
88  IMPLEMENT_GET_MAIN(Marker, uint32_t);
89  IMPLEMENT_GET_MAIN(DataSize, uint32_t);
90  IMPLEMENT_GET_MAIN(CRC, uint32_t)
91 
92  IMPLEMENT_GET_AND_SET_MAIN(TrigNumLo, uint32_t)
93  IMPLEMENT_GET_AND_SET_MAIN(TrigNumHi, uint32_t)
94  IMPLEMENT_GET_AND_SET_MAIN(TrigNum, uint64_t)
95  IMPLEMENT_GET_MAIN(NumMicroBlocks, uint16_t)
96  IMPLEMENT_GET_AND_SET_MAIN(BuffId, uint16_t)
97  IMPLEMENT_GET_AND_SET_MAIN(MonteCarloFlag, bool)
98  IMPLEMENT_IS_MAIN(CRCCalculationUsed)
99  IMPLEMENT_IS_AND_SET_MAIN(ConnectionInitialization)
100  IMPLEMENT_IS_AND_SET_MAIN(CloseConnection)
101  IMPLEMENT_IS_AND_SET_MAIN(MissingData)
102 
104 
105  protected:
106  IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(setFloatingMicroBlockToBufferSource, const, bool, const void*)
107 
108  bool setFunctionPointers();
109 
110  /// These functions are not allowed to be executed as public
111  bool addMicroBlock1(const void* /*microblock_buffer*/,
112  const bool /*check_mc_flag*/
113  ){return functionIsNotAllowed(__FUNCTION__, "Function is private.");}
114  bool addMicroBlock2(const void* /*microblock_buffer*/,
115  const uint32_t /*microblock_size*/,
116  const bool /*check_mc_flag*/
117  ){return functionIsNotAllowed(__FUNCTION__, "Function is private.");}
118  bool addMicroBlock3(const void* /*millislice_buffer*/,
119  const void* /*microslice_buffer*/,
120  const version_t /*microblock_version*/,
121  const bool /*check_mc_flag*/
122  ){return functionIsNotAllowed(__FUNCTION__, "Function is private.");}
123  bool addMicroBlock4(const void* /*millislice_buffer*/,
124  const void* /*microslice_buffer*/,
125  const uint32_t /*microslice_size*/,
126  const version_t /*microblock_version*/,
127  const bool /*check_mc_flag*/
128  ){return functionIsNotAllowed(__FUNCTION__, "Function is private.");}
129 
130  bool addDCMData1(const void*) { return functionIsNotAllowed(__FUNCTION__, "Function is private.");}
131  bool addDCMData2(const void*, const uint32_t) { return functionIsNotAllowed(__FUNCTION__,"Function is private.");}
132 
133 // allowed on a function-definition
134  };// end of class definition
135 
136 } // END NAMESPCE daqdataformats
137 #endif /* RAWDATABLOCK_H */
IMPLEMENT_GET_MAIN(Version, uint32_t)
RawDataBlock(const uint32_t buffersize=DEFAULT_DATABLOCK_SIZE, const uint32_t tlvl=0, const version_t version=datablockheader::RAWDATABLOCKHEADER_LATEST_VERSION)
bool addDCMData(const void *dcmdata_buffer)
Definition: RawDataBlock.h:77
static const version_t RAWMICROBLOCK_LATEST_VERSION
static const uint32_t DEFAULT_DATABLOCK_SIZE
Definition: RawDataBlock.h:25
#define IMPLEMENT_IS_MAIN(FUNC)
Definition: Macros.h:212
IMPLEMENT_MAIN_STANDARD IMPLEMENT_MAIN_setBufferSource readDataStatus readData(const int fd)
Definition: RawDataBlock.h:84
bool addDCMData(const void *dcmdata_buffer, const uint32_t dcmdata_size)
Definition: RawDataBlock.h:78
bool addMicroBlock3(const void *, const void *, const version_t, const bool)
Definition: RawDataBlock.h:118
#define IMPLEMENT_MAIN_STANDARD
Definition: Macros.h:230
bool addMicroBlock4(const void *, const void *, const uint32_t, const version_t, const bool)
Definition: RawDataBlock.h:123
#define IMPLEMENT_MAIN_setBufferSource
Definition: Macros.h:228
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
bool close(bool produce_crc=false)
Definition: RawDataBlock.h:80
bool addMicroBlock(const void *millislice_buffer, const void *microslice_buffer, const version_t microblock_version=microblock::RAWMICROBLOCK_LATEST_VERSION, const bool check_mc_flag=true)
Definition: RawDataBlock.h:58
#define IMPLEMENT_FUNCTION_RETURNING_FUNCTION_POINTER_1PAR(FUNC, CONSTNESS, OUTPUT, INP1)
Definition: Macros.h:183
bool addMicroBlock(const void *microblock_buffer, const uint32_t microblock_size, const bool check_mc_flag=true)
Definition: RawDataBlock.h:49
const XML_Char * version
Definition: expat.h:187
#define IMPLEMENT_FIGUREOUT_VERSION_STATIC(CLASS)
This should be in the header.
Definition: Macros.h:295
int32_t version_t
Definition: RawDAQData.h:72
bool addMicroBlock2(const void *, const uint32_t, const bool)
Definition: RawDataBlock.h:114
#define IMPLEMENT_GET_AND_SET_MAIN(FUNC, UNITS)
Definition: Macros.h:217
bool addMicroBlock(const void *microblock_buffer, const bool check_mc_flag=true)
Definition: RawDataBlock.h:42
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
bool addMicroBlock1(const void *, const bool)
These functions are not allowed to be executed as public.
Definition: RawDataBlock.h:111
bool addDCMData1(const void *)
Definition: RawDataBlock.h:130
Class to hold the data from the FEBs in correct formats.
#define IMPLEMENT_IS_AND_SET_MAIN(FUNC)
Definition: Macros.h:220
bool addMicroBlock(const void *millislice_buffer, const void *microslice_buffer, const uint32_t microslice_size, const version_t microblock_version=microblock::RAWMICROBLOCK_LATEST_VERSION, const bool check_mc_flag=true)
Definition: RawDataBlock.h:69
static const version_t RAWDATABLOCKHEADER_LATEST_VERSION
bool addDCMData2(const void *, const uint32_t)
Definition: RawDataBlock.h:131