DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEStreamFrame.hpp
Go to the documentation of this file.
1
14
15#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNESTREAMFRAME_HPP_
16#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNESTREAMFRAME_HPP_
17
18#include "Utils.hpp"
19
20#include "detdataformats/DAQHeader.hpp" // For unified DAQ header
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 <stdexcept> // For std::out_of_range
28
30
31// NOLINTBEGIN(build/unsigned)
32
34{
35public:
36 // The definition of the format is in terms of 32-bit words
37 using word_t = uint32_t;
38
39 static constexpr int s_bits_per_adc = 14;
40 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
41 static constexpr int s_channels_per_frame = 4;
42 static constexpr int s_adcs_per_channel = 64;
43 static constexpr int s_daphnes_per_frame = 1;
45
46 struct Header
47 {
50 };
51 static_assert(sizeof(Header) == 8);
52
53 struct Trailer
54 {
55 word_t tbd : 32;
56 };
57 static_assert(sizeof(Trailer) == 4);
58
61 word_t adc_words[s_num_adc_words]; // NOLINT (a false accusation from the linter that s_num_adc_words is a variable)
63
64 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
65
67 void set_timestamp(const uint64_t new_timestamp)
68 {
69 daq_header.timestamp_1 = new_timestamp;
70 daq_header.timestamp_2 = new_timestamp >> 32;
71 }
72
74 uint16_t get_adc(uint i_adc, uint i_channel) const;
75
77 void set_adc(uint i, uint chn, uint16_t val);
78
80 uint8_t get_channel0() const { return header.channel_0; }
81
83 uint8_t get_channel1() const { return header.channel_1; }
84
86 uint8_t get_channel2() const { return header.channel_2; }
87
89 uint8_t get_channel3() const { return header.channel_3; }
90};
91static_assert(sizeof(DAPHNEStreamFrame) == sizeof(detdataformats::DAQHeader) + sizeof(DAPHNEStreamFrame::Header) +
93 sizeof(DAPHNEStreamFrame::Trailer));
94
95static_assert(std::endian::native == std::endian::little,
96 "The DAPHNEStreamFrame bitfield layout assumes little-endian architecture");
97
98static_assert(std::is_trivially_copyable_v<DAPHNEStreamFrame>,
99 "DAPHNEStreamFrame isn't trivially copyable and can't be safely std::memcpy'd");
100static_assert(std::is_standard_layout_v<DAPHNEStreamFrame>,
101 "DAPHNEStreamFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
102
103} // namespace dunedaq::fddetdataformats
104
106
107// NOLINTEND(build/unsigned)
108
109#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNESTREAMFRAME_HPP_
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 64-bit timestamp of the frame.
uint16_t get_adc(uint i_adc, uint i_channel) const
Get the i ADC value of chn in the frame.
uint8_t get_channel2() const
Get the channel 2 from the DAPHNE Stream frame header.
uint8_t get_channel0() const
Get the channel 0 from the DAPHNE Stream frame header.
uint8_t get_channel3() const
Get the channel 3 from the DAPHNE Stream frame header.
void set_adc(uint i, uint chn, uint16_t val)
Set the i ADC value of chn in the frame to val.
DAQHeader is a versioned and unified structure for every FE electronics.
Definition DAQHeader.hpp:23