DataBlockConstructor.cpp
Go to the documentation of this file.
1 /*
2  * File: DataBlockConstructor.cpp
3  * Author: denis
4  *
5  * Created on September 20, 2012, 2:18 PM
6  */
7 
8 #include <DAQDataFormats/RawDataBlock.h>
9 
11 
12 /// It is requred to
13 /// 1. include DAQDataFormats/DataFormatFirst.inc
14 /// 2. define CURRENT_CLASS
15 /// 3. define CURRENT_CLASS_VERSION for version of the class
16 /// OR define LAST_CLASS_VERSION for the main structure of the class
17 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
18 /// 5. include DAQDataFormats/DataFormatLast.inc
19 /// before the declaration of the DataFormat version class in the header.
20 #include "DAQDataFormats/DataFormatFirst.inc"
21 #define CURRENT_CLASS RawDataBlock
22 #define LAST_CLASS_VERSION 0
23 #define CURRENT_FIELDS_SUB_NAMESPACE datablock
24 #include "DAQDataFormats/DataFormatLast.inc"
25 
26 //#define DBSIZE daqdataformats::DEFAULT_DATABLOCK_SIZE
27 #define DBSIZE ((const uint32_t)0)
28 
29 namespace daqdataformats {
30 
33 {
34 }
36 
37 //------------------------------------------------------------------------------
39  RawDataBlock* datablock = constructDataBlock(ver);
40  fillDataFormat(datablock);
41  return datablock;
42 }
43 
44 //------------------------------------------------------------------------------
46 
47  RawDataBlock* datablock = constructDataBlock(ver);
48 
50  datablock->close();
51 
52 
53  return datablock;
54 }
55 
56 //------------------------------------------------------------------------------
58  return new daqdataformats::RawDataBlock(DBSIZE, (const uint32_t)0, ver);
59 }
60 
61 //------------------------------------------------------------------------------
64  _DataBlockHeaderConstructor.fillDataFormat(datablock->getHeader());
65 
66  /// initialize DB header
67  datablock->getHeader()->init();
68 
70 
71  /// adding microblock 2
72  for(uint32_t imicroslice = 0; imicroslice < millislice->getMicrosliceNumber(); ++imicroslice){
73  millislice->setFloatingMicroSlice(imicroslice);
74  datablock->addMicroBlock(millislice->getBuffer(), millislice->getFloatingMicroSlice()->getBuffer());
75  }
76 
77  /// adding microblock 1
79  datablock->addMicroBlock(microblock1->getBuffer());
80 
81 
82  datablock->close();
83 
84  delete millislice;
85  delete microblock1;
86 
87  return true;
88 }
89 
90 //------------------------------------------------------------------------------
91 // Gets the DataBlock version
93  return (version_t) nano->getHeader()->getVersion();
94 }
95 
96 }// end of namespaces
version_t getDataBlockVersion(const RawDataBlock *) const
Gets the DataBlock version.
microblock::MicroBlockConstructor _MicroBlockConstructor
daqdataformats::RawDataBlock * constructDataBlock(const daqdataformats::version_t) const
daqdataformats::RawDAQData * getFilledDataFormat(const daqdataformats::version_t) const
daqdataformats::RawDAQData * getEmptyDataFormat(const daqdataformats::version_t) const
method to create an empty dataformat with a given version
bool setFloatingMicroSlice(const uint32_t) const
static const version_t RAWMICROBLOCK_LATEST_VERSION
daqdataformats::RawMicroSlice * getFloatingMicroSlice() const
Definition: RawMilliSlice.h:48
void * getBuffer() const
Definition: RawDAQData.h:131
datablockheader::DataBlockHeaderConstructor _DataBlockHeaderConstructor
uint32_t getMicrosliceNumber() const
Definition: RawMilliSlice.h:63
bool close(bool produce_crc=false)
Definition: RawDataBlock.h:80
#define DBSIZE
int32_t version_t
Definition: RawDAQData.h:72
bool addMicroBlock(const void *microblock_buffer, const bool check_mc_flag=true)
Definition: RawDataBlock.h:42
bool fillDataFormat(daqdataformats::RawDAQData *) const
method to Fill the input dataformat
static const version_t DAQDATAFORMAT_UNKNOWN_VERSION
Definition: RawDAQData.h:81
Class to hold the data from the FEBs in correct formats.
daqdataformats::RawDAQData * getFilledDataFormat(const daqdataformats::version_t) const
static const version_t RAWDATABLOCKHEADER_LATEST_VERSION