RawDataBlockHeaderV0.h
Go to the documentation of this file.
1 #ifndef RAQDATABLOCKHEADERV0_H
2 #define RAQDATABLOCKHEADERV0_H
3 #include "DAQDataFormats/RawDAQData.h"
4 #include "DAQDataFormats/Macros.h"
5 #include "DAQDataFormats/BitFields.h"
6 
7 /// It is requred to
8 /// 1. include DAQDataFormats/DataFormatFirst.inc
9 /// 2. define CURRENT_CLASS
10 /// 3. define CURRENT_CLASS_VERSION for version of the class
11 /// OR define LAST_CLASS_VERSION for the main structure of the class
12 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
13 /// 5. include DAQDataFormats/DataFormatLast.inc
14 /// before the declaration of the DataFormat version class in the header.
15 #include "DAQDataFormats/DataFormatFirst.inc"
16 #define CURRENT_CLASS RawDataBlockHeader
17 #define CURRENT_CLASS_VERSION 0
18 #define CURRENT_FIELDS_SUB_NAMESPACE datablockheader
19 #include "DAQDataFormats/DataFormatLast.inc"
20 
21 namespace daqdataformats {
23  static const uint32_t DataBlock_Marker = 0xDABC;
24  }
25 
26  namespace VERSION_NAMESPACE {
28 
29  static const uint32_t DATABLOCKHEADER_SIZE = 5;
30 
32  MASK_Marker = 0xFFFF0000, //! Marker Mask (16 bits)
33  MASK_Version = 0x00000FFF, //! Version Mask (12 bits)
34  MASK_DataSize = 0xFFFFFFFF, //! Data Size Mask (32 bits)
35  MASK_NumMicroBlocks = 0xFFFF0000, //! NBlocks Mask (16 bits)
36  MASK_BuffId = 0x0000FFFF, //! Buffer Node ID Mask (16 bits)
37  MASK_TrigNumLo = 0xFFFFFFFF, //! Trigger Number Mask Low (32 bits)
38  MASK_TrigNumHi = 0x000000FF, //! Trigger Number Mask High (8 bits)
39  MASK_MissingData = 0x08000000, //! Is DataBlock Missing Data? (1 bit)
40  MASK_MonteCarloFlag = 0x10000000, //! SIM flag (1 bit)
41  MASK_CRCCalculationUsed = 0x20000000, //! Is CRC calculation used? (1 bit)
42  MASK_ConnectionInitialization = 0x40000000, //! Initialization Connection bit Mask (1 bit)
43  MASK_CloseConnection = 0x80000000 //! Close Connection bit (1 bit)
44  };
45 
47  WORD_Version = 0,
59  };
60 
61  DEFINE_SHIFT_FROM_MASK(Version);
62  DEFINE_SHIFT_FROM_MASK(Marker);
63  DEFINE_SHIFT_FROM_MASK(DataSize);
64  DEFINE_SHIFT_FROM_MASK(NumMicroBlocks);
65  DEFINE_SHIFT_FROM_MASK(BuffId);
66  DEFINE_SHIFT_FROM_MASK(TrigNumLo);
67  DEFINE_SHIFT_FROM_MASK(TrigNumHi);
68  DEFINE_SHIFT_FROM_MASK(MissingData);
69  DEFINE_SHIFT_FROM_MASK(MonteCarloFlag);
70  DEFINE_SHIFT_FROM_MASK(CRCCalculationUsed);
71  DEFINE_SHIFT_FROM_MASK(ConnectionInitialization);
72  DEFINE_SHIFT_FROM_MASK(CloseConnection);
73  }// end of namespace datablockheader
74 
75  class RawDataBlockHeader: public PREVIOUS_VERSION_CLASS_NAME {
76  public:
77  RawDataBlockHeader (const version_t); ///< The default constructor
79  ~RawDataBlockHeader(); ///< Destructor
80 
81  void init ();
83  void print (std::ostream& os=std::cout) const;
85  void* readData(const void* pointer){return RawDAQData::readDataGeneral(pointer);};
87 
88  protected:
89 
90  IMPLEMENT_FIRST_GET_AND_SET(Version , uint32_t);
91  IMPLEMENT_FIRST_GET_AND_SET(Marker , uint32_t);
92  IMPLEMENT_FIRST_GET_AND_SET(TrigNumLo , uint32_t);
93  IMPLEMENT_FIRST_GET_AND_SET(TrigNumHi , uint32_t);
94  IMPLEMENT_FIRST_GET_AND_SET(NumMicroBlocks, uint16_t);
95  IMPLEMENT_FIRST_GET_AND_SET(BuffId , uint16_t);
96  IMPLEMENT_FIRST_GET_AND_SET(DataSize , uint32_t);
97  IMPLEMENT_FIRST_GET_AND_SET_BOOL(MonteCarloFlag);
98 
99  IMPLEMENT_FIRST_IS_AND_SET(CRCCalculationUsed);
100  IMPLEMENT_FIRST_IS_AND_SET(ConnectionInitialization);
101  IMPLEMENT_FIRST_IS_AND_SET(CloseConnection);
102  IMPLEMENT_FIRST_IS_AND_SET(MissingData);
103 
104  INIT_FIRST(getTrigNum , const, uint64_t, );
105  INIT_FIRST(setTrigNum , , bool , const uint64_t);
106 
107  INIT_FIRST(addDataSize , , bool , const uint32_t);
108  INIT_FIRST(advanceNumMicroBlocks, , bool, );
109  INIT_FIRST(checkMarker , const, bool, );
110  };
111 
112 
113 }} // END NAMESPACE daqdataformats
114 #endif /* RAQDATABLOCKHEADERV0_H */
void * readDataGeneral(const void *buffer)
General ReadData method when the sizeofdata is known.
Definition: RawDAQData.cpp:186
#define IMPLEMENT_FIRST_IS_AND_SET(FUNC)
Definition: Macros.h:177
#define VERSION_NAMESPACE
#define CURRENT_FIELDS_SUB_NAMESPACE
#define INIT_FIRST(FUNC, CONSTNESS, OUTPUT_UNITS,...)
Definition: Macros.h:239
#define IMPLEMENT_FIRST_GET_AND_SET(FUNC, UNITS)
Definition: Macros.h:171
bool print
OStream cout
Definition: OStream.cxx:6
void * readData(const void *buffer)
Shallow copy constructor.
Definition: RawDAQData.cpp:181
int32_t version_t
Definition: RawDAQData.h:72
Class to hold the data from the FEBs in correct formats.
#define IMPLEMENT_FIRST_GET_AND_SET_BOOL(FUNC)
Definition: Macros.h:174