NanoSliceWriter.cc
Go to the documentation of this file.
2 
4 NanoSliceWriter(uint8_t* address, uint32_t max_size_bytes,
5  uint16_t channel_number) :
6  NanoSlice(address), max_size_bytes_(max_size_bytes)
7 {
8  header_()->version = 1;
9  header_()->nanoslice_size = sizeof(Header);
10  header_()->channel_number = channel_number;
11  header_()->sample_count = 0;
12 
13  if (max_size_bytes_ < size()) {
15  }
16 }
17 
19 {
21 }
22 
24 {
25  if ((size() + sizeof(value)) > max_size_bytes_) {
26  return false;
27  }
29  ++(header_()->sample_count);
30  header_()->nanoslice_size += sizeof(value);
31  return true;
32 }
33 
35 {
36  int32_t size_diff = max_size_bytes_ - header_()->nanoslice_size;
38  return size_diff;
39 }
40 
42 {
43  return reinterpret_cast<Header *>(buffer_);
44 }
45 
47 {
48  return reinterpret_cast<uint16_t *>(buffer_ + sizeof(Header));
49 }
NanoSliceWriter(uint8_t *address, uint32_t max_size_bytes, uint16_t channel_number=0)
uint8_t channel
Definition: CRTFragment.hh:201
uint8_t * buffer_
Definition: NanoSlice.hh:56
void setChannelNumber(uint16_t channel)
bool addSample(uint16_t value)
Header::nanoslice_size_t size() const
Definition: NanoSlice.cc:5