DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEEthStreamFrame.hpp
Go to the documentation of this file.
1
13
14#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_HPP_
15#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_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 <format>
28#include <stdexcept> // For std::out_of_range
29
31
32// NOLINTBEGIN(build/unsigned)
33
41
43{
44 // The definition of the format is in terms of 64-bit words
45 using word_t = uint64_t;
46
47 // Dataframe format version
48 static constexpr uint8_t version = 1;
49
50 static constexpr int s_bits_per_adc = 14;
51 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
52 static constexpr int s_adcs_per_channel = 280;
53 static constexpr int s_num_channels = 4;
55
57 {
58 word_t tbd : 52;
61 };
62 static_assert(sizeof(ChannelWord) == 8);
63
64 struct Header
65 {
67 };
68 static_assert(sizeof(Header) == sizeof(ChannelWord) * s_num_channels);
69
70 static constexpr std::size_t s_expected_bytes = sizeof(detdataformats::DAQEthHeader) + sizeof(Header) +
71 sizeof(word_t) * s_num_adc_words;
72
74 uint16_t get_adc(int i_adc, int i_channel) const;
75
77 void set_adc(int i_adc, int i_channel, uint16_t val); // NOLINT
78
80 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
81
83 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
84
86 uint8_t get_channel(const int i_channel) const;
87
89 void set_channel(const int i_channel, const uint8_t new_channel_val);
90
92 uint8_t get_channel0() const { return header.channel_words[0].channel; }
93
95 uint8_t get_channel1() const { return header.channel_words[1].channel; }
96
98 uint8_t get_channel2() const { return header.channel_words[2].channel; }
99
101 uint8_t get_channel3() const { return header.channel_words[3].channel; }
102
103 bool operator<(const DAPHNEEthStreamFrame& other) const {
104 return this->get_timestamp() < other.get_timestamp();
105 }
106
110};
111
112static_assert(std::endian::native == std::endian::little,
113 "The DAPHNEEthStreamFrame bitfield layout assumes little-endian architecture");
114
115 static_assert(AdaptableFrameConcept<DAPHNEEthStreamFrame>, "DAPHNEEthStreamFrame does not satisfy the AdaptableFrameConcept");
116
117} // namespace dunedaq::fddetdataformats
118
120
121// NOLINTEND(build/unsigned)
122
123#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_HPP_
DAQEthHeader is a versioned and unified structure for every FE electronics.
Struct for accessing raw DAPHNE eth stream frames.
uint8_t get_channel1() const
Get the channel 1 from the DAPHNE Stream frame header.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
uint8_t get_channel0() const
Get the channel 0 from the DAPHNE Stream frame header.
uint8_t get_channel(const int i_channel) const
Get the channel identifier of the frame.
void set_channel(const int i_channel, const uint8_t new_channel_val)
Set the channel identifier of the frame.
uint16_t get_adc(int i_adc, int i_channel) const
Get the i_adc-th ADC value of i_channel-th channel in the frame.
bool operator<(const DAPHNEEthStreamFrame &other) const
void set_adc(int i_adc, int i_channel, uint16_t val)
Set the i_adc-th ADC value of i_channel-th channel in the frame to val.
uint8_t get_channel3() const
Get the channel 3 from the DAPHNE Stream frame header.
uint8_t get_channel2() const
Get the channel 2 from the DAPHNE Stream frame header.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.