Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
clb_common_header.hh File Reference
#include <utility>
#include <ostream>
#include <stdint.h>
#include <cassert>
#include <cstdlib>
#include <arpa/inet.h>
#include "utctime.hh"

Go to the source code of this file.

Classes

struct  CLBCommonHeader
 

Typedefs

typedef uint64_t frame_idx_t
 

Functions

std::ostream & operator<< (std::ostream &stream, const CLBCommonHeader &header)
 
std::pair< uint32_t, bool > seq_number (CLBCommonHeader const &header, uint64_t start_run_ms, int ts_duration_ms)
 
frame_idx_t data2idx (CLBCommonHeader const &header, uint64_t start_run_ms, int ts_duration_ms)
 
uint32_t dom_id (frame_idx_t idx)
 
bool validTimeStamp (CLBCommonHeader const &header)
 
bool isTrailer (CLBCommonHeader const &header)
 

Typedef Documentation

◆ frame_idx_t

typedef uint64_t frame_idx_t

Definition at line 85 of file clb_common_header.hh.

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream & stream,
const CLBCommonHeader & header )
inline

Definition at line 72 of file clb_common_header.hh.

73{
74 return stream << "DataType: " << header.dataType() << '\n'
75 << "RunNumber: " << header.runNumber() << '\n'
76 << "UDPSequenceNumber: " << header.udpSequenceNumber() << '\n'
77 << "Timestamp: \n" << header.timeStamp() << '\n'
78 << "DOMIdentifier: " << header.domIdentifier() << '\n'
79 << "DOMStatus1: " << header.domStatus(1) << '\n'
80 << "DOMStatus2: " << header.domStatus(2) << '\n'
81 << "DOMStatus3: " << header.domStatus(3) << '\n'
82 << "DOMStatus4: " << header.domStatus(4);
83}
uint32_t dataType() const
uint32_t udpSequenceNumber() const
UTCTime timeStamp() const
uint32_t runNumber() const
uint32_t domIdentifier() const
uint32_t domStatus(int n=1) const

◆ seq_number()

std::pair< uint32_t, bool > seq_number ( CLBCommonHeader const & header,
uint64_t start_run_ms,
int ts_duration_ms )
inline

Definition at line 88 of file clb_common_header.hh.

92{
93 uint64_t const tstamp_ms = header.timeStamp().inMilliSeconds();
94
95 return std::make_pair(
96 (tstamp_ms - start_run_ms) / ts_duration_ms,
97 tstamp_ms > start_run_ms);
98}

◆ data2idx()

frame_idx_t data2idx ( CLBCommonHeader const & header,
uint64_t start_run_ms,
int ts_duration_ms )
inline

Definition at line 101 of file clb_common_header.hh.

105{
106 std::pair<uint32_t, bool> const seq_num = seq_number(header, start_run_ms, ts_duration_ms);
107 frame_idx_t value = seq_num.first;
108 value <<= 32;
109 value += header.domIdentifier();
110 return value;
111}
std::pair< uint32_t, bool > seq_number(CLBCommonHeader const &header, uint64_t start_run_ms, int ts_duration_ms)
uint64_t frame_idx_t

◆ dom_id()

uint32_t dom_id ( frame_idx_t idx)
inline

Definition at line 114 of file clb_common_header.hh.

115{
116 frame_idx_t const mask = 0x00000000FFFFFFFF;
117
118 return idx & mask;
119}

◆ validTimeStamp()

bool validTimeStamp ( CLBCommonHeader const & header)
inline

Definition at line 122 of file clb_common_header.hh.

123{
124 const static uint32_t mask = 0x80000000;
125
126 return header.domStatus() & mask;
127}

◆ isTrailer()

bool isTrailer ( CLBCommonHeader const & header)
inline

Definition at line 130 of file clb_common_header.hh.

131{
132 const static uint32_t mask = 0x80000000;
133
134 return header.domStatus(2) & mask;
135}