DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEEthStreamFrame.hpp
Go to the documentation of this file.
1
14
15#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_HPP_
16#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_HPP_
17
18#include "Utils.hpp"
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{
44public:
45 // The definition of the format is in terms of 64-bit words
46 using word_t = uint64_t;
47
48 // Dataframe format version
49 static constexpr uint8_t version = 1;
50
51 static constexpr int s_bits_per_adc = 14;
52 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
53 static constexpr int s_adcs_per_channel = 280;
54 static constexpr int s_num_channels = 4;
56
58 {
59 word_t tbd : 52;
62 };
63 static_assert(sizeof(ChannelWord) == 8);
64
65 struct Header
66 {
68 };
69 static_assert(sizeof(Header) == sizeof(ChannelWord) * s_num_channels);
70
74
76 uint16_t get_adc(uint i_adc, uint i_channel) const;
77
79
80 // WARNING: ORDER OF CHANNEL AND ADC IS REVERSED RELATIVE TO get_adc
81 void set_adc(uint i_channel, uint i_adc, uint16_t val); // NOLINT
82
84 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
85
87 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
88
90 uint8_t get_channel(const uint i_channel) const;
91
93 void set_channel(const uint i_channel, const uint8_t new_channel_val);
94
96 uint8_t get_channel0() const { return header.channel_words[0].channel; }
97
99 uint8_t get_channel1() const { return header.channel_words[1].channel; }
100
102 uint8_t get_channel2() const { return header.channel_words[2].channel; }
103
105 uint8_t get_channel3() const { return header.channel_words[3].channel; }
106};
107static_assert(sizeof(DAPHNEEthStreamFrame) ==
108 sizeof(detdataformats::DAQEthHeader) + sizeof(DAPHNEEthStreamFrame::Header) +
110
111static_assert(std::endian::native == std::endian::little,
112 "The DAPHNEEthStreamFrame bitfield layout assumes little-endian architecture");
113
114static_assert(std::is_trivially_copyable_v<DAPHNEEthStreamFrame>,
115 "DAPHNEEthStreamFrame isn't trivially copyable and can't be safely std::memcpy'd");
116static_assert(std::is_standard_layout_v<DAPHNEEthStreamFrame>,
117 "DAPHNEEthStreamFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
118
119} // namespace dunedaq::fddetdataformats
120
122
123// NOLINTEND(build/unsigned)
124
125#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHSTREAMFRAME_HPP_
Class for accessing raw DAPHNE eth stream frames, as used in ProtoDUNE-II.
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.
void set_adc(uint i_channel, uint i_adc, uint16_t val)
Set the i_adc-th ADC value of i_channel-th channel in the frame to val.
uint16_t get_adc(uint i_adc, uint i_channel) const
Get the i_adc-th ADC value of i_channel-th channel in the frame.
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.
uint8_t get_channel(const uint i_channel) const
Get the channel identifier of the frame.
void set_channel(const uint i_channel, const uint8_t new_channel_val)
Set the channel identifier of the frame.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
DAQEthHeader is a versioned and unified structure for every FE electronics.