|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
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. | |
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.
| 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.
| int eventBuilderParser::clear | ( | ) |
Empty all member vectors; returns 0.
| 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).
| int eventBuilderParser::get_frame_size | ( | ) |
Return the size of raw_data in bytes.
| 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.
| int eventBuilderParser::load_frame | ( | std::vector< uint8_t > & | incoming_data | ) |
Copy incoming_data into raw_data; returns 0.
| 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.
| int eventBuilderParser::print_frame | ( | ) |
Print the subframe sizes, positions and nested-batcher flags, then the nested batchers, to stdout; returns 0.
| int eventBuilderParser::print_raw | ( | ) |
Print up to the first 32 bytes of raw_data to stdout; returns 0.
| int eventBuilderParser::print_sub_batcher | ( | ) |
Call print_frame() on each nested batcher parser; returns 0.
| int eventBuilderParser::print_vector | ( | std::vector< T > & | my_vector | ) |
Print up to the first 32 elements of my_vector to stdout; returns 0.
| 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.
| int eventBuilderParser::resolve_sub_frames | ( | ) |
Does nothing; returns 1.
| bool eventBuilderParser::DEBUG |
Debug flag; not initialized and not read in AxiBatcherParser.cc.
| 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.
| std::vector<uint16_t> eventBuilderParser::frame_sizes_reverse_order |
Subframe sizes read from the subframe tails, last subframe first.
| std::vector<std::vector<uint8_t> > eventBuilderParser::frames |
Bytes of each subframe, last subframe first.
| 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.
| 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.
| std::vector<uint8_t> eventBuilderParser::main_header |
Copy of the first HEADER_WIDTH bytes of raw_data, set by parse_array().
| std::vector<uint8_t> eventBuilderParser::raw_data |
Bytes of the frame being parsed, set by load_frame().
| 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.
| std::vector<eventBuilderParser> eventBuilderParser::sub_frames |
Parsers for the subframes that are themselves batcher frames, filled by check_for_subframes().
| int eventBuilderParser::version |
Low 4 bits of the first byte of raw_data, set by parse_array().