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
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 // Dataframe format version
45 static constexpr uint8_t version = 1;
46
47 static constexpr int s_bits_per_adc = 14;
48 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
49 static constexpr int s_num_adcs = 1024;
51
52 struct Header
53 {
54 // The following bitfields constitute what could be considered "word_t w0;"
63
70 };
71 static_assert(sizeof(Header) == 7 * sizeof(word_t));
72
76
84 uint16_t get_adc(int i) const; // NOLINT
85
87 void set_adc(int i, uint16_t val); // NOLINT
88
90 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
91
93 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
94
96 uint8_t get_channel() const { return header.channel; }
97
99 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
100};
101static_assert(sizeof(DAPHNEEthFrame) == sizeof(detdataformats::DAQEthHeader) + sizeof(DAPHNEEthFrame::Header) +
103
104static_assert(std::endian::native == std::endian::little,
105 "The DAPHNEEthFrame bitfield layout assumes little-endian architecture");
106
107static_assert(std::is_trivially_copyable_v<DAPHNEEthFrame>,
108 "DAPHNEEthFrame isn't trivially copyable and can't be safely std::memcpy'd");
109static_assert(std::is_standard_layout_v<DAPHNEEthFrame>,
110 "DAPHNEEthFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
111
112} // namespace dunedaq::fddetdataformats
113
115
116// NOLINTEND(build/unsigned)
117
118#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
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.
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.
DAQEthHeader is a versioned and unified structure for every FE electronics.