Data element structures

All structures are defined independent on endianess. When bytes must be swapped, always 4 bytes are swapped. Fields 8 bytes long must be handled separately. Structures in sMbs.h
Definitions
#define LMD__TYPE_FILE_HEADER_101_1   0x00010065
#define LMD__TYPE_EVENT_HEADER_10_1   0x0001000a
#define LMD__TYPE_FILE_INDEX_101_2    0x00020065
#define LMD__TYPE_BUFFER_HEADER_10_1  0x0001000a
#define LMD__TYPE_BUFFER_HEADER_100_1 0x00010064
#define LMD__TYPE_TIME_STAMP_11_1     0x0001000b
#define LMD__INDEX         1
#define LMD__OVERWRITE     1
#define LMD__LARGE_FILE    1
#define LMD__BUFFER        1
#define LMD__NO_INDEX      0
#define LMD__NO_OVERWRITE  0
#define LMD__NO_LARGE_FILE 0
#define LMD__NO_BUFFER     0
#define LMD__NO_VERBOSE    0
#define LMD__VERBOSE       1
#define LMD__ENDIAN_BIG    2
#define LMD__ENDIAN_LITTLE 1
#define LMD__ENDIAN_UNKNOWN 0

// to avoid dependency of compiling 
typedef  uint64_t lmdoff_t; 

// must #include stdint.h
// on Lynx, define int32_t, uint32_t, int16_t
sMbsTransportInfo
Structure used to talk between client and server.
Client connects to server (MBS) and reads this structure first.
Structure maps the MBS transport info buffer.
typedef struct{
  uint32_t iEndian;      // byte order. Set to 1 by sender 
  uint32_t iMaxBytes;    // maximum buffer size                   
  uint32_t iBuffers;     // buffers per stream
  uint32_t iStreams;     // number of streams (=0 for DABC mode)                   
} sMbsTransportInfo;
sMbsBufferHeader
Buffer header, maps s_bufhe, some fields used in different way. The main difference is the usage of iUsedWords for the data length.
typedef struct{
  uint32_t iMaxWords;    // compatible with s_bufhe (total buffer size - header)
  uint32_t iType;        // compatible with s_bufhe, low=type (=100), high=subtype
  uint32_t iUsed;        // not used for iMaxWords>MAX__DLEN (16360), low 16bits only
  uint32_t iBuffer;      // compatible with s_bufhe
  uint32_t iElements;    // compatible with s_bufhe
  uint32_t iTemp;        // Used volatile
  uint32_t iTimeSpecSec; // compatible with s_bufhe (2*32bit) (struct timespec)
  uint32_t iTimeSpecNanoSec; // compatible with s_bufhe (2*32bit) (struct timespec)
  uint32_t iEndian;      // compatible with s_bufhe free[0]
  uint32_t iWrittenEndian; // LMD__ENDIAN_BIG, LMD__ENDIAN_LITTLE, LMD__ENDIAN_UNKNOWN
  uint32_t iUsedWords;   // total words without header, free[2]
  uint32_t iFree3;       // free[3]
} sMbsBufferHeader;
sMbsFileHeader
File header, maps s_bufhe, some fields used in different way.
typedef struct{
  uint32_t iMaxWords;    // Size of largest element in file
  uint32_t iType;        // compatible with s_bufhe, low=type (=100), high=subtype
  lmdoff_t iTableOffset; // optional offset to element index table in file
  uint32_t iElements;    // Number of elements in file
  uint32_t iOffsetSize;  // Offset size, 4 or 8 [bytes]
  uint32_t iTimeSpecSec; // compatible with s_bufhe (2*32bit) (struct timespec)
  uint32_t iTimeSpecNanoSec; // compatible with s_bufhe (2*32bit) (struct timespec)
  uint32_t iEndian;      // compatible with s_bufhe free[0]
  uint32_t iWrittenEndian; // LMD__ENDIAN_BIG, LMD__ENDIAN_LITTLE, LMD__ENDIAN_UNKNOWN
  uint32_t iUsedWords;   // total words following header, free[2]
  uint32_t iFree3;       // free[3]
} sMbsFileHeader;
sMbsTimeStamp
typedef struct{
  uint32_t iMaxWords; 
  uint32_t iType; 
  uint32_t iTimeSpecSec;
  uint32_t iTimeSpecNanoSec;
} sMbsTimeStamp;
sMbsHeader
Maps s_evhe
typedef struct{
  uint32_t iWords;       // following data words
  uint32_t iType;        // compatible with s_ve10_1, low=type (=10), high=subtype
} sMbsHeader;
sMbsEventHeader
Type 10,1 event header. Maps s_ve10_1.
typedef struct{
  uint32_t iWords;       // data words + 4
  uint32_t iType;        // compatible with s_ve10_1, low=type (=10), high=subtype
  uint32_t iTrigger;
  uint32_t iEventNumber;
} sMbsEventHeader;
sMbsSubeventHeader
Type 10,1 subevent header. Maps s_ves10_1
typedef struct{
  uint32_t iWords;       // data words + 2
  uint32_t iType;        // compatible with s_ves10_1, low=type (=10), high=subtype
  uint32_t iSubeventID;  // 2 low bytes=procid, next byte=subcrate, high byte control 
} sMbsSubeventHeader;

fLmd control structure

Structures in fLmd.h
Definitions
#define LMD__SUCCESS        0
#define LMD__FAILURE        1
#define LMD__CLOSE_ERR      3
#define GETLMD__NOFILE      2
#define GETLMD__NOLMDFILE   4
#define GETLMD__EOFILE      5
#define GETLMD__NOMORE      6
#define GETLMD__NOBUFFER    7
#define GETLMD__TOOBIG      8
#define GETLMD__OUTOF_RANGE 9
#define GETLMD__SIZE_ERROR 10
#define LMD__TIMEOUT         50
#define PUTLMD__FILE_EXIST  101
#define PUTLMD__TOOBIG      102
#define PUTLMD__OPEN_ERR    103
#define PUTLMD__EXCEED      104
#define PORT__TRANS        6000
#define PORT__STREAM       6002
sLmdControl
Internal control structure used by all functions.
typedef struct
{
  FILE    *fFile;        /* file descripter or server No.    */
  int16_t *pBuffer;      /* pointer to internal buffer  */
  uint32_t iBufferWords; /* internal buffer size      */
  uint32_t iLeftWords;   /* left words in buffer */
  uint32_t iInternHeader;/* has intern allocated header buffer */
  uint32_t iInternBuffer;/* has intern allocated buffer */
  uint32_t iElements;    /* events since open     */
  uint64_t iBytes;       /* bytes since open  */
  char     cFile[512];   /* channel name */
  uint32_t iSwap;
  uint32_t iVerbose;
  char     *cHeader;     /* header data buffer */
  uint32_t *pOffset;     /* offset table */
  lmdoff_t *pLongOffset; /* long offset table */
  lmdoff_t oTableOffset; /* greater zero when Long offset in file */
  uint32_t iOffsetSize;  // Offset size, 4 or 8 [bytes]
  uint32_t iOffsetEntries;/* offset table length */
  sMbsFileHeader *pMbsFileHeader;
  sMbsHeader     *pMbsHeader;
  struct s_tcpcomm *pTCP;
  uint32_t iTCP;
  uint32_t iPort;
  uint32_t iTcpTimeout;
} sLmdControl;
Functions
Description
-- HansEssel - 25 Oct 2007

This topic: DABC > Daq4FAIR > MbsSupport > MbsDataFormats
Topic revision: 2008-10-15, HansEssel
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback | Legal notice | Privacy Policy (german)