9 #ifndef RAWHEADER_LATEST_H
10 #define RAWHEADER_LATEST_H
14 #include <rawdata/switch_basf2_standalone.h>
166 MAGIC_WORD = 0x7F7F0000,
167 MAGIC_MASK = 0xFFFF0000,
169 FORMAT_VERSION__MASK = 0x0000FF00,
170 FORMAT_VERSION_SHIFT = 8
174 EXP_MASK = 0xFFC00000,
176 RUNNO_MASK = 0x003FFF00,
178 SUBRUNNO_MASK = 0x000000FF
182 RAWHEADER_NWORDS = 56
186 HDR_NWORDS_MASK = 0x000000FF
192 POS_VERSION_HDRNWORDS = 1,
195 POS_TTCTIME_TRGTYPE = 4,
198 POS_TRUNC_MASK_DATATYPE = 7,
219 TTCTIME_MASK = 0x7FFFFFF0,
227 B2LINK_PACKET_CRC_ERROR = 0x1,
228 B2LINK_EVENT_CRC_ERROR = 0x2
244 B2FATAL(
"m_buffer is NULL. Exiting...");
251 B2FATAL(
"m_buffer is NULL. Data is corrupted or header info has not yet filled. Exiting...");
274 m_buffer[ POS_NODE_ID ] = (int)node_id;
280 m_buffer[ POS_TRUNC_MASK_DATATYPE ] =
281 (data_type & 0x7FFFFFFF) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x80000000);
287 m_buffer[ POS_TRUNC_MASK_DATATYPE ] = (trunc_mask << 31) | (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
294 m_buffer[ POS_TTCTIME_TRGTYPE ] = word1;
303 memcpy(&(
m_buffer[ POS_EXP_RUN_NO ]), (
char*)exprun_buf,
sizeof(
int) * 1);
323 return RAWHEADER_NWORDS;
329 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & EXP_MASK)
337 return (((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]) & RUNNO_MASK)
344 return (
m_buffer[ POS_EXP_RUN_NO ] & SUBRUNNO_MASK);
350 return ((
unsigned int)(
m_buffer[ POS_EXP_RUN_NO ]));
363 return (
unsigned int)
m_buffer[ POS_NODE_ID ];
369 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] & 0x7FFFFFFF);
375 return (
m_buffer[ POS_TRUNC_MASK_DATATYPE ] >> 23) & 0x1;
381 return (
unsigned int)(
m_buffer[ POS_TRUNC_MASK_DATATYPE ]);
387 m_buffer[ POS_TRUNC_MASK_DATATYPE ] |= (int)error_bit_flag;
395 if ((temp_err_flag & B2LINK_PACKET_CRC_ERROR) == 0) {
405 if ((temp_err_flag & B2LINK_EVENT_CRC_ERROR) == 0) {
421 return (
unsigned int)(
m_buffer[ POS_TTCTIME_TRGTYPE ]);
439 return (
unsigned int)(
m_buffer[ POS_TTUTIME ]);
445 tv->tv_usec = (int)(((
double)
GetTTCtime()) / 127.216);