LDMX Software
Public Member Functions | Private Attributes | List of all members
packing::rawdatafile::SubsystemPacket Class Reference

SubsystemPacket structure. More...

#include <SubsystemPacket.h>

Public Member Functions

 SubsystemPacket ()=default
 default constructor for reading
 
 SubsystemPacket (uint32_t event, uint16_t id, std::vector< uint32_t > data)
 constructor for writing
 
std::vector< uint32_t > header () const
 get the header words
 
std::vector< uint32_t > & data ()
 Get data.
 
const uint16_t & id () const
 
std::vector< uint32_t > tail () const
 get the tailing words
 
utility::Readerread (utility::Reader &r)
 read the subsystem packet from the input reader
 
utility::Writerwrite (utility::Writer &w) const
 write the subsystem packet to the input writer
 
utility::CRCadd (utility::CRC &c) const
 add the subsystem packet to the input crc
 

Private Attributes

uint32_t event_
 
uint16_t id_
 
std::vector< uint32_t > data_
 
bool crc_ok_
 
unsigned int crc_
 

Detailed Description

SubsystemPacket structure.

Definition at line 16 of file SubsystemPacket.h.

Constructor & Destructor Documentation

◆ SubsystemPacket()

packing::rawdatafile::SubsystemPacket::SubsystemPacket ( uint32_t  event,
uint16_t  id,
std::vector< uint32_t >  data 
)

constructor for writing

Definition at line 9 of file SubsystemPacket.cxx.

11 : event_{event}, id_{id}, data_{data} {
12 crc_ok_ = true;
13
14 utility::CRC crc;
15 crc << data_;
16
17 crc_ = crc.get();
18}
std::vector< uint32_t > & data()
Get data.

References packing::utility::CRC::get().

Member Function Documentation

◆ add()

utility::CRC & packing::rawdatafile::SubsystemPacket::add ( utility::CRC c) const

add the subsystem packet to the input crc

Definition at line 51 of file SubsystemPacket.cxx.

51 {
52 std::vector<uint32_t> head{header()}, t{tail()};
53 c << head << data_ << t;
54 return c;
55}
std::vector< uint32_t > tail() const
get the tailing words
std::vector< uint32_t > header() const
get the header words

References header(), and tail().

◆ data()

std::vector< uint32_t > & packing::rawdatafile::SubsystemPacket::data ( )
inline

Get data.

Definition at line 32 of file SubsystemPacket.h.

32{ return data_; }

◆ header()

std::vector< uint32_t > packing::rawdatafile::SubsystemPacket::header ( ) const

get the header words

Definition at line 20 of file SubsystemPacket.cxx.

20 {
21 uint32_t word = ((id_ & utility::mask<16>) << 16) +
22 ((data_.size() & utility::mask<15>) << 1) + crc_ok_;
23 return {word, event_};
24}

Referenced by add(), and write().

◆ id()

const uint16_t & packing::rawdatafile::SubsystemPacket::id ( ) const
inline

Definition at line 33 of file SubsystemPacket.h.

33{ return id_; }

◆ read()

utility::Reader & packing::rawdatafile::SubsystemPacket::read ( utility::Reader r)

read the subsystem packet from the input reader

Definition at line 28 of file SubsystemPacket.cxx.

28 {
29 uint32_t word;
30 r >> word;
31
32 id_ = (word >> 16) & utility::mask<16>;
33 uint32_t len = (word >> 1) & utility::mask<15>;
34 crc_ok_ = word & utility::mask<1>;
35
36 r >> event_;
37
38 r.read(data_, len);
39
40 r >> crc_;
41
42 return r;
43}

References packing::utility::Reader::read().

◆ tail()

std::vector< uint32_t > packing::rawdatafile::SubsystemPacket::tail ( ) const

get the tailing words

Definition at line 26 of file SubsystemPacket.cxx.

26{ return {crc_}; }

Referenced by add(), and write().

◆ write()

utility::Writer & packing::rawdatafile::SubsystemPacket::write ( utility::Writer w) const

write the subsystem packet to the input writer

Definition at line 45 of file SubsystemPacket.cxx.

45 {
46 std::vector<uint32_t> head{header()}, t{tail()};
47 w << head << data_ << t;
48 return w;
49}

References header(), and tail().

Member Data Documentation

◆ crc_

unsigned int packing::rawdatafile::SubsystemPacket::crc_
private

Definition at line 59 of file SubsystemPacket.h.

◆ crc_ok_

bool packing::rawdatafile::SubsystemPacket::crc_ok_
private

Definition at line 58 of file SubsystemPacket.h.

◆ data_

std::vector<uint32_t> packing::rawdatafile::SubsystemPacket::data_
private

Definition at line 57 of file SubsystemPacket.h.

◆ event_

uint32_t packing::rawdatafile::SubsystemPacket::event_
private

Definition at line 55 of file SubsystemPacket.h.

◆ id_

uint16_t packing::rawdatafile::SubsystemPacket::id_
private

Definition at line 56 of file SubsystemPacket.h.


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