PennMicroSliceWriter.cc
Go to the documentation of this file.
2 
4 PennMicroSliceWriter(uint8_t* address, uint32_t max_size_bytes) :
5  //uint8_t sequence_id) :
6  PennMicroSlice(address), max_size_bytes_(max_size_bytes)
7 {
8  header_()->format_version = 0xE1;
9  //header_()->sequence_id = sequence_id;
10  header_()->block_size = sizeof(Header);
11 
12  if (max_size_bytes_ < size()) {
14  }
15 }
16 
17 /*
18 void dune::PennMicroSliceWriter::setSequenceId(uint8_t sequence_id)
19 {
20  header_()->sequence_id = sequence_id;
21 }
22 */
23 
24 /*
25 bool dune::PennMicroSliceWriter::addSample(uint16_t value)
26 {
27  if ((size() + sizeof(value)) > max_size_bytes_) {
28  return false;
29  }
30  data_()[header_()->sample_count] = value;
31  ++(header_()->sample_count);
32  header_()->nanoslice_size += sizeof(value);
33  return true;
34 }
35 */
36 
37 bool dune::PennMicroSliceWriter::addData(uint16_t* data, uint16_t data_size)
38 {
39  if ((size() + data_size) > max_size_bytes_) {
40  return false;
41  }
42  for(uint16_t i = 0; i < data_size; i++) {
43  uint16_t value = data[i];
44  data_()[i] = value;
45  header_()->block_size += sizeof(value);
46  }
47  return true;
48 }
49 
51 {
52  int32_t size_diff = max_size_bytes_ - header_()->block_size;
54  return size_diff;
55 }
56 
58 {
59  return reinterpret_cast<Header *>(buffer_);
60 }
61 
63 {
64  // This is not really a good solution.
65  return reinterpret_cast<uint16_t *>(buffer_ + sizeof(Header));
66 }
bool addData(uint16_t *data, uint16_t data_size)
PennMicroSliceWriter(uint8_t *address, uint32_t max_size_bytes)
dune::PennMicroSlice::microslice_size_t size() const
Header of ethernet packet.