lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
eventBuilderParser Class Reference

Parser for AxiStream batcher frames: splits a byte buffer into subframes by walking the subframe tails back from the end, and recursively parses subframes that are themselves batcher frames. More...

#include <AxiBatcherParser.hh>

Public Member Functions

uint16_t frame_to_position (int position)
 Return the little-endian 16-bit value at byte position of raw_data (a subframe size field).
 
int get_frame_size ()
 Return the size of raw_data in bytes.
 
int load_frame (std::vector< uint8_t > &incoming_data)
 Copy incoming_data into raw_data; returns 0.
 
int parse_array ()
 Parse raw_data: record the version and main header, walk back from the end reading the size, offsets and bytes of each subframe, then call check_for_subframes().
 
int check_for_subframes ()
 Flag each frame as a nested batcher frame or not (by comparing its first two bytes with main_header) and parse the nested ones into sub_frames.
 
int resolve_sub_frames ()
 Does nothing; returns 1.
 
int clear ()
 Empty all member vectors; returns 0.
 
bool is_damaged (uint8_t start, uint8_t end)
 Return true, after calling clear(), if start is not below end or end is not inside raw_data; otherwise false.
 
int print_raw ()
 Print up to the first 32 bytes of raw_data to stdout; returns 0.
 
int print_frame ()
 Print the subframe sizes, positions and nested-batcher flags, then the nested batchers, to stdout; returns 0.
 
template<class T >
int print_vector2d (std::vector< T > &my_vector)
 Print up to 32 elements of each entry of my_vector (or a note for entries flagged as nested batchers) to stdout; returns 0.
 
int print_sub_batcher ()
 Call print_frame() on each nested batcher parser; returns 0.
 
template<class T >
int print_vector (std::vector< T > &my_vector)
 Print up to the first 32 elements of my_vector to stdout; returns 0.
 

Public Attributes

std::vector< uint8_t > raw_data
 Bytes of the frame being parsed, set by load_frame().
 
std::vector< uint8_t > main_header
 Copy of the first HEADER_WIDTH bytes of raw_data, set by parse_array().
 
std::vector< uint16_t > frame_sizes_reverse_order
 Subframe sizes read from the subframe tails, last subframe first.
 
std::vector< std::vector< uint16_t > > frame_positions_reverse_order
 Start and end byte offsets of each subframe in raw_data, last subframe first.
 
std::vector< std::vector< uint8_t > > frames
 Bytes of each subframe, last subframe first.
 
std::vector< eventBuilderParser > sub_frames
 Parsers for the subframes that are themselves batcher frames, filled by check_for_subframes().
 
std::vector< short > is_sub_frame
 One entry per subframe: 1 if it starts with the same two bytes as main_header (parsed as a nested batcher frame), else 0.
 
int spsft = 16
 Offset (16) from the end of a subframe to its 16-bit size field; the code comment calls it the size position in the subframe tail.
 
int HEADER_WIDTH = 16
 Width in bytes (16) of the main header copied by parse_array() and of each subframe tail counted while parsing.
 
int version
 Low 4 bits of the first byte of raw_data, set by parse_array().
 
bool DEBUG
 Debug flag; not initialized and not read in AxiBatcherParser.cc.
 

Detailed Description

Parser for AxiStream batcher frames: splits a byte buffer into subframes by walking the subframe tails back from the end, and recursively parses subframes that are themselves batcher frames.

Member Function Documentation

◆ check_for_subframes()

int eventBuilderParser::check_for_subframes ( )

Flag each frame as a nested batcher frame or not (by comparing its first two bytes with main_header) and parse the nested ones into sub_frames.

Returns 1, flagging none, if any frame is shorter than 2 bytes; otherwise 0.

◆ clear()

int eventBuilderParser::clear ( )

Empty all member vectors; returns 0.

◆ frame_to_position()

uint16_t eventBuilderParser::frame_to_position ( int  position)

Return the little-endian 16-bit value at byte position of raw_data (a subframe size field).

◆ get_frame_size()

int eventBuilderParser::get_frame_size ( )

Return the size of raw_data in bytes.

◆ is_damaged()

bool eventBuilderParser::is_damaged ( uint8_t  start,
uint8_t  end 
)

Return true, after calling clear(), if start is not below end or end is not inside raw_data; otherwise false.

start and end are uint8_t, so the 16-bit offsets passed by parse_array() are truncated.

◆ load_frame()

int eventBuilderParser::load_frame ( std::vector< uint8_t > &  incoming_data)

Copy incoming_data into raw_data; returns 0.

◆ parse_array()

int eventBuilderParser::parse_array ( )

Parse raw_data: record the version and main header, walk back from the end reading the size, offsets and bytes of each subframe, then call check_for_subframes().

Returns 0, or 1 after clear() if a frame looks damaged.

◆ print_frame()

int eventBuilderParser::print_frame ( )

Print the subframe sizes, positions and nested-batcher flags, then the nested batchers, to stdout; returns 0.

◆ print_raw()

int eventBuilderParser::print_raw ( )

Print up to the first 32 bytes of raw_data to stdout; returns 0.

◆ print_sub_batcher()

int eventBuilderParser::print_sub_batcher ( )

Call print_frame() on each nested batcher parser; returns 0.

◆ print_vector()

template<class T >
int eventBuilderParser::print_vector ( std::vector< T > &  my_vector)

Print up to the first 32 elements of my_vector to stdout; returns 0.

◆ print_vector2d()

template<class T >
int eventBuilderParser::print_vector2d ( std::vector< T > &  my_vector)

Print up to 32 elements of each entry of my_vector (or a note for entries flagged as nested batchers) to stdout; returns 0.

◆ resolve_sub_frames()

int eventBuilderParser::resolve_sub_frames ( )

Does nothing; returns 1.

Member Data Documentation

◆ DEBUG

bool eventBuilderParser::DEBUG

Debug flag; not initialized and not read in AxiBatcherParser.cc.

◆ frame_positions_reverse_order

std::vector<std::vector<uint16_t> > eventBuilderParser::frame_positions_reverse_order

Start and end byte offsets of each subframe in raw_data, last subframe first.

◆ frame_sizes_reverse_order

std::vector<uint16_t> eventBuilderParser::frame_sizes_reverse_order

Subframe sizes read from the subframe tails, last subframe first.

◆ frames

std::vector<std::vector<uint8_t> > eventBuilderParser::frames

Bytes of each subframe, last subframe first.

◆ HEADER_WIDTH

int eventBuilderParser::HEADER_WIDTH = 16

Width in bytes (16) of the main header copied by parse_array() and of each subframe tail counted while parsing.

◆ is_sub_frame

std::vector<short> eventBuilderParser::is_sub_frame

One entry per subframe: 1 if it starts with the same two bytes as main_header (parsed as a nested batcher frame), else 0.

◆ main_header

std::vector<uint8_t> eventBuilderParser::main_header

Copy of the first HEADER_WIDTH bytes of raw_data, set by parse_array().

◆ raw_data

std::vector<uint8_t> eventBuilderParser::raw_data

Bytes of the frame being parsed, set by load_frame().

◆ spsft

int eventBuilderParser::spsft = 16

Offset (16) from the end of a subframe to its 16-bit size field; the code comment calls it the size position in the subframe tail.

◆ sub_frames

std::vector<eventBuilderParser> eventBuilderParser::sub_frames

Parsers for the subframes that are themselves batcher frames, filled by check_for_subframes().

◆ version

int eventBuilderParser::version

Low 4 bits of the first byte of raw_data, set by parse_array().


The documentation for this class was generated from the following file: