DABC (Data Acquisition Backbone Core)  2.9.9
LmdTypeDefs.h
Go to the documentation of this file.
1 // $Id: LmdTypeDefs.h 4464 2020-04-15 12:14:20Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef MBS_LmdTypeDefs
17 #define MBS_LmdTypeDefs
18 
19 #include <cstdint>
20 
21 #if defined(__MACH__) /* Apple OSX section */
22 #include <machine/endian.h>
23 #else
24 #include <endian.h>
25 #endif
26 
27 namespace mbs {
28 
29 #if BYTE_ORDER == LITTLE_ENDIAN
30 #define MBS_TYPE(typ, subtyp) ((int32_t) typ | ((int32_t) subtyp) << 16)
31 #else
32 #define MBS_TYPE(typ, subtyp) ((int32_t) subtyp | ((int32_t) typ) << 16)
33 #endif
34 
35 #pragma pack(push, 1)
36 
39  struct Header {
40  uint32_t iWords; // data words + 2
41  union {
42  struct {
43 #if BYTE_ORDER == LITTLE_ENDIAN
44  uint16_t i_type;
45  uint16_t i_subtype;
46 #else
47  uint16_t i_subtype;
48  uint16_t i_type;
49 #endif
50  };
51  uint32_t iType;
52  };
53 
54  // FullSize - size of data with header (8 bytes)
55  inline uint32_t FullSize() const { return 8 + iWords*2; }
56  inline void SetFullSize(uint32_t sz) { iWords = (sz - 8) /2; }
57 
58  inline uint32_t FullType() const { return iType; }
59  inline uint16_t Type() const { return i_type; }
60  inline uint16_t SubType() const { return i_subtype; }
61 
62  inline void SetFullType(uint32_t typ) { iType = typ; }
63  inline void SetTypePair(unsigned typ, unsigned subtyp) { iType = (typ & 0xffff) | ((subtyp << 16) & 0xffff0000); }
64 
65  inline bool isFullType(uint32_t typ) const { return iType == typ; }
66  inline bool isTypePair(unsigned typ, unsigned subtyp) const { return iType == ((typ & 0xffff) | ((subtyp << 16) & 0xffff0000)); }
67  };
68 
69  // ____________________________________________________________________
70 
73  struct FileHeader : public Header {
74  uint64_t iTableOffset;
75  uint32_t iElements;
76  uint32_t iOffsetSize;
77  uint32_t iTimeSpecSec;
78  uint32_t iTimeSpecNanoSec;
79  // struct timespec TimeSpec;
80  uint32_t iEndian;
81  uint32_t iWrittenEndian;
82  uint32_t iUsedWords;
83  uint32_t iFree3;
84  };
85 
86 #pragma pack(pop)
87 
88 }
89 
90 #endif
Support for MBS - standard GSI DAQ.
Definition: api.h:36
Structure of the LMD file header.
Definition: LmdTypeDefs.h:73
uint32_t iFree3
free[3]
Definition: LmdTypeDefs.h:83
uint64_t iTableOffset
optional offset to element offset table in file
Definition: LmdTypeDefs.h:74
uint32_t iWrittenEndian
one of LMD__ENDIAN_x
Definition: LmdTypeDefs.h:81
uint32_t iTimeSpecNanoSec
compatible with s_bufhe (2*32bit)
Definition: LmdTypeDefs.h:78
uint32_t iUsedWords
total words without header to read for type=100, free[2]
Definition: LmdTypeDefs.h:82
uint32_t iOffsetSize
Offset size, 4 or 8 [bytes].
Definition: LmdTypeDefs.h:76
uint32_t iEndian
compatible with s_bufhe free[0]
Definition: LmdTypeDefs.h:80
uint32_t iElements
compatible with s_bufhe
Definition: LmdTypeDefs.h:75
uint32_t iTimeSpecSec
compatible with s_bufhe (2*32bit)
Definition: LmdTypeDefs.h:77
Structure of any entry in LMD file.
Definition: LmdTypeDefs.h:39
uint32_t iWords
Definition: LmdTypeDefs.h:40
bool isTypePair(unsigned typ, unsigned subtyp) const
Definition: LmdTypeDefs.h:66
uint16_t i_subtype
Definition: LmdTypeDefs.h:45
bool isFullType(uint32_t typ) const
Definition: LmdTypeDefs.h:65
uint32_t iType
Definition: LmdTypeDefs.h:51
void SetFullSize(uint32_t sz)
Definition: LmdTypeDefs.h:56
uint32_t FullSize() const
Definition: LmdTypeDefs.h:55
uint16_t SubType() const
Definition: LmdTypeDefs.h:60
void SetFullType(uint32_t typ)
Definition: LmdTypeDefs.h:62
void SetTypePair(unsigned typ, unsigned subtyp)
Definition: LmdTypeDefs.h:63
uint16_t Type() const
Definition: LmdTypeDefs.h:59
uint16_t i_type
Definition: LmdTypeDefs.h:44
uint32_t FullType() const
Definition: LmdTypeDefs.h:58