Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dune::PennMilliSliceWriter Class Reference

#include <PennMilliSliceWriter.hh>

Inheritance diagram for dune::PennMilliSliceWriter:
dune::PennMilliSlice

Public Member Functions

 PennMilliSliceWriter (uint8_t *address, uint32_t max_size_bytes)
 
int32_t finalize (bool override=false, uint32_t data_size_bytes=0, uint16_t sequence_id=0, uint16_t payload_count=0, uint16_t payload_count_counter=0, uint16_t payload_count_trigger=0, uint16_t payload_count_timestamp=0, uint64_t end_timestamp=0, uint32_t width_in_ticks=0, uint32_t overlap_in_ticks=0)
 
- Public Member Functions inherited from dune::PennMilliSlice
 PennMilliSlice (uint8_t *address)
 
Header::millislice_size_t size () const
 
Header::sequence_id_t sequenceID () const
 
Header::version_t version () const
 
Header::timestamp_t endTimestamp () const
 
Header::ticks_t widthTicks () const
 
Header::ticks_t overlapTicks () const
 
Header::payload_count_t payloadCount () const
 
Header::payload_count_t payloadCount (Header::payload_count_t &counter, Header::payload_count_t &trigger, Header::payload_count_t &timestamp ) const
 
uint8_t * payload (uint32_t index, dune::PennMicroSlice::Payload_Header::data_packet_type_t &data_packet_type, dune::PennMicroSlice::Payload_Header::short_nova_timestamp_t &short_nova_timestamp, size_t &payload_size) const
 
uint8_t * payload (uint32_t index, dune::PennMicroSlice::Payload_Header *&data_header) const
 
uint8_t * get_next_payload (uint32_t &index, dune::PennMicroSlice::Payload_Header::data_packet_type_t &data_packet_type, dune::PennMicroSlice::Payload_Header::short_nova_timestamp_t &short_nova_timestamp, size_t &payload_size)
 
uint8_t * get_next_payload (uint32_t &index, dune::PennMicroSlice::Payload_Header *&data_header)
 
uint8_t * get_next_timestamp (dune::PennMicroSlice::Payload_Header *&data_header)
 

Protected Member Functions

void finalizeLatestMicroSlice_ ()
 
Headerheader_ ()
 
uint8_t * data_ (int index)
 
- Protected Member Functions inherited from dune::PennMilliSlice
Header const * header_ () const
 
uint8_t * data_ (int index) const
 

Protected Attributes

uint32_t max_size_bytes_
 
std::shared_ptr< PennMicroSliceWriterlatest_microslice_ptr_
 
- Protected Attributes inherited from dune::PennMilliSlice
uint8_t * buffer_
 
uint8_t * current_payload_
 
uint32_t current_word_id_
 

Detailed Description

Definition at line 11 of file PennMilliSliceWriter.hh.

Constructor & Destructor Documentation

dune::PennMilliSliceWriter::PennMilliSliceWriter ( uint8_t *  address,
uint32_t  max_size_bytes 
)

Definition at line 4 of file PennMilliSliceWriter.cc.

4  :
5  PennMilliSlice(address), max_size_bytes_(max_size_bytes)
6 {
7  header_()->sequence_id = 0;
8  header_()->version = 0xFFFF;
9  header_()->millislice_size = sizeof(Header);
10  header_()->payload_count = 0;
14  header_()->end_timestamp = 0;
15  header_()->width_in_ticks = 0;
17 }
PennMilliSlice(uint8_t *address)

Member Function Documentation

uint8_t * dune::PennMilliSliceWriter::data_ ( int  index)
protected

Definition at line 102 of file PennMilliSliceWriter.cc.

103 {
104  uint8_t* ms_ptr = buffer_ + sizeof(Header);
105  for (int idx = 0; idx < index; ++idx) {
106  PennMicroSlice tmp_ms(ms_ptr);
107  ms_ptr += tmp_ms.size();
108  }
109  return ms_ptr;
110 }
int32_t dune::PennMilliSliceWriter::finalize ( bool  override = false,
uint32_t  data_size_bytes = 0,
uint16_t  sequence_id = 0,
uint16_t  payload_count = 0,
uint16_t  payload_count_counter = 0,
uint16_t  payload_count_trigger = 0,
uint16_t  payload_count_timestamp = 0,
uint64_t  end_timestamp = 0,
uint32_t  width_in_ticks = 0,
uint32_t  overlap_in_ticks = 0 
)

Definition at line 42 of file PennMilliSliceWriter.cc.

50 {
51  // first, we need to finalize the last MicroSlice, in case that
52  // hasn't already been done
54 
55  //Override the current size if requested
56  if(override) {
57  header_()->millislice_size = sizeof(Header) + data_size_bytes;
58 #ifdef PENN_DONT_REBLOCK_USLICES
59  header_()->microslice_count = microslice_count;
60 #endif
61  header_()->payload_count = payload_count;
62  header_()->payload_count_counter = payload_count_counter;
63  header_()->payload_count_trigger = payload_count_trigger;
64  header_()->payload_count_timestamp = payload_count_timestamp;
65  header_()->end_timestamp = end_timestamp;
66  header_()->width_in_ticks = width_in_ticks;
67  header_()->overlap_in_ticks = overlap_in_ticks;
68  header_()->sequence_id = sequence_id;
69  }
70 
71 #ifdef ENABLE_PENNMILLISLICE_CHECKSUM
72  //Calculate checksum
73  //TODO decide if a footer is the right place to put the checksum. Alternative is associate it with the fragment
74  uint8_t* end_ptr = buffer_ + header_()->millislice_size;
75  *(reinterpret_cast<dune::PennMilliSliceWriter::checksum_t *>(end_ptr)) = calculateChecksum();
76  header_()->millislice_size += sizeof(dune::PennMilliSliceWriter::checksum_t);
77 #endif
78  // next, we update our maximum size so that no more MicroSlices
79  // can be added
80  int32_t size_diff = max_size_bytes_ - header_()->millislice_size;
82  return size_diff;
83 }
void dune::PennMilliSliceWriter::finalizeLatestMicroSlice_ ( )
protected

Definition at line 85 of file PennMilliSliceWriter.cc.

86 {
87  if (
88 #ifdef PENN_DONT_REBLOCK_USLICES
89  header_()->microslice_count > 0 &&
90 #endif
91  latest_microslice_ptr_.get() != 0) {
92  int size_change = latest_microslice_ptr_->finalize();
93  header_()->millislice_size -= size_change;
94  }
95 }
std::shared_ptr< PennMicroSliceWriter > latest_microslice_ptr_
dune::PennMilliSliceWriter::Header * dune::PennMilliSliceWriter::header_ ( )
protected

Definition at line 97 of file PennMilliSliceWriter.cc.

98 {
99  return reinterpret_cast<Header *>(buffer_);
100 }

Member Data Documentation

std::shared_ptr<PennMicroSliceWriter> dune::PennMilliSliceWriter::latest_microslice_ptr_
protected

Definition at line 59 of file PennMilliSliceWriter.hh.

uint32_t dune::PennMilliSliceWriter::max_size_bytes_
protected

Definition at line 58 of file PennMilliSliceWriter.hh.


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