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
17#include "Utils.hpp"
18
20
21#include <algorithm> // For std::min
22#include <cassert> // For assert()
23#include <cstdint> // For uint32_t etc
24#include <cstdio>
25#include <cstdlib>
26#include <stdexcept> // For std::out_of_range
27
29
30// NOLINTBEGIN(build/unsigned)
31
39{
40public:
41 // The definition of the format is in terms of 64-bit words
42 using word_t = uint64_t;
43
44 static constexpr int s_bits_per_adc = 14;
45 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
46 static constexpr int s_time_samples_per_frame = 64;
47 static constexpr int s_channels_per_half_femb = 64;
48 static constexpr int s_half_fembs_per_frame = 1;
51
72 static_assert(sizeof(WIBEthHeader) == 8 + 8); // 8 bytes for the bitfield section, 8 for the extra_data
73
77
85 uint16_t get_adc(int i_channel, int i_sample = 0) const;
86
88 void set_adc(int i_channel, int i_sample, uint16_t adc_val);
89
91 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
92
94 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
95
97 uint8_t get_channel() const { return header.channel; }
98
100 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
101};
102static_assert(sizeof(WIBEthFrame) == sizeof(detdataformats::DAQEthHeader) + sizeof(WIBEthFrame::WIBEthHeader) +
105
106static_assert(std::endian::native == std::endian::little,
107 "The WIBEthFrame bitfield layout assumes little-endian architecture");
108
109static_assert(std::is_trivially_copyable_v<WIBEthFrame>,
110 "WIBEthFrame isn't trivially copyable and can't be safely std::memcpy'd");
111static_assert(std::is_standard_layout_v<WIBEthFrame>,
112 "WIBEthFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
113
114} // namespace dunedaq::fddetdataformats
115
116#include "detail/WIBEthFrame.hxx"
117
118// NOLINTEND(build/unsigned)
119
120#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_WIBETHFRAME_HPP_
Class 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]
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
static constexpr int s_channels_per_half_femb
DAQEthHeader is a versioned and unified structure for every FE electronics.