DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEEthFrame.hpp
Go to the documentation of this file.
1
13
14#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
15#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_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 <limits>
28#include <tuple>
29#include <stdexcept> // For std::out_of_range
30
32
33// NOLINTBEGIN(build/unsigned)
34
42{
43 // The definition of the format is in terms of 64-bit words
44 using word_t = uint64_t;
45
46 // Dataframe format version
47 static constexpr uint8_t version = 1;
48
49 static constexpr int s_bits_per_adc = 14;
50 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
51 static constexpr int s_num_adcs = 1024;
53
54 struct Header
55 {
56 static constexpr size_t s_expected_bytes { 7 * sizeof(word_t) };
57
58 // The following bitfields constitute what could be considered "word_t w0;"
67
74 };
75 static_assert(sizeof(Header) == Header::s_expected_bytes);
76
78
86 uint16_t get_adc(int i) const; // NOLINT
87
89 void set_adc(int i, uint16_t val); // NOLINT
90
92 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
93
95 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
96
98 uint8_t get_channel() const { return header.channel; }
99
101 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
102
103 bool operator<(const DAPHNEEthFrame& other) const {
104 return std::tuple(this->get_timestamp(), this->get_channel()) < std::tuple(other.get_timestamp(), other.get_channel());
105 }
106
110};
111
112 static_assert(std::endian::native == std::endian::little,
113 "The DAPHNEEthFrame bitfield layout assumes little-endian architecture");
114
115 static_assert(AdaptableFrameConcept<DAPHNEEthFrame>, "DAPHNEEthFrame does not satisfy the AdaptableFrameConcept");
116
117} // namespace dunedaq::fddetdataformats
118
120
121// NOLINTEND(build/unsigned)
122
123#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
DAQEthHeader is a versioned and unified structure for every FE electronics.
Struct for accessing raw DAPHNE eth frames.
void set_adc(int i, uint16_t val)
Set the ith ADC value in the frame to val.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
bool operator<(const DAPHNEEthFrame &other) const
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
detdataformats::DAQEthHeader daq_header
uint8_t get_channel() const
Get the channel identifier of the frame.
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.