DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIBEthFrame.hpp
Go to the documentation of this file.
1
13
14#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_WIBETHFRAME_HPP_
15#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_WIBETHFRAME_HPP_
16
19
21
22#include <algorithm> // For std::min
23#include <cassert> // For assert()
24#include <cstdint> // For uint32_t etc
25#include <cstdio>
26#include <cstdlib>
27#include <stdexcept> // For std::out_of_range
28
30
31// NOLINTBEGIN(build/unsigned)
32
40{
41
42 // The definition of the format is in terms of 64-bit words
43 using word_t = uint64_t;
44
45 static constexpr int s_bits_per_adc = 14;
46 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
47 static constexpr int s_time_samples_per_frame = 64;
48 static constexpr int s_channels_per_half_femb = 64;
49 static constexpr int s_half_fembs_per_frame = 1;
52
54 {
55 static constexpr std::size_t s_expected_bytes {8 + 8}; // 8 bytes for the bitfield section, 8 for the extra_data
56
74 };
75 static_assert(sizeof(WIBEthHeader) == WIBEthHeader::s_expected_bytes);
76
80
88 uint16_t get_adc(int i_channel, int i_sample = 0) const;
89
91 void set_adc(int i_channel, int i_sample, uint16_t adc_val);
92
94 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
95
97 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
98
100 uint8_t get_channel() const { return header.channel; }
101
103 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
104
105 bool operator<(const WIBEthFrame& other) const {
106 return this->get_timestamp() < other.get_timestamp();
107 }
108
112
113};
114
115static_assert(std::endian::native == std::endian::little,
116 "The WIBEthFrame bitfield layout assumes little-endian architecture");
117
118 static_assert(AdaptableFrameConcept<WIBEthFrame>, "WIBEthFrame does not satisfy the AdaptableFrameConcept");
119
120} // namespace dunedaq::fddetdataformats
121
122#include "detail/WIBEthFrame.hxx"
123
124// NOLINTEND(build/unsigned)
125
126#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_WIBETHFRAME_HPP_
DAQEthHeader is a versioned and unified structure for every FE electronics.
struct for accessing raw WIB eth frames, as used in ProtoDUNE-II
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
static constexpr int s_half_fembs_per_frame
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
word_t adc_words[s_time_samples_per_frame][s_num_adc_words_per_ts]
static constexpr size_t s_expected_bytes
uint8_t get_channel() const
Get the channel identifier of the frame.
uint16_t get_adc(int i_channel, int i_sample=0) const
Get the i_channel-th ADC value in the i_sample-th time sample.
detdataformats::DAQEthHeader daq_header
void set_adc(int i_channel, int i_sample, uint16_t adc_val)
Set the i_channel-th ADC value in the i_sample-th time sample to adc_val.
static constexpr int s_time_samples_per_frame
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
static constexpr int s_num_adc_words_per_ts
bool operator<(const WIBEthFrame &other) const
static constexpr int s_channels_per_half_femb