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
20
21#include "detdataformats/DAQHeader.hpp" // For unified DAQ header
22
23#include <algorithm> // For std::min
24#include <cassert> // For assert()
25#include <cstdint> // For uint32_t etc
26#include <cstdio>
27#include <cstdlib>
28#include <stdexcept> // For std::out_of_range
29
31
32// NOLINTBEGIN(build/unsigned)
33
35{
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
59 static constexpr std::size_t s_expected_bytes { sizeof(detdataformats::DAQHeader) + sizeof(Header) +
60 sizeof(word_t) * s_num_adc_words +
61 sizeof(Trailer) };
62
63 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
64
66 void set_timestamp(const uint64_t new_timestamp)
67 {
68 daq_header.timestamp_1 = new_timestamp;
69 daq_header.timestamp_2 = new_timestamp >> 32;
70 }
71
73 uint16_t get_adc(int i_adc, int i_channel) const;
74
76 void set_adc(int i, int i_channel, uint16_t val);
77
78 uint8_t get_channel0() const { return header.channel_0; }
79
80 uint8_t get_channel1() const { return header.channel_1; }
81
82 uint8_t get_channel2() const { return header.channel_2; }
83
84 uint8_t get_channel3() const { return header.channel_3; }
85
86 bool operator<(const DAPHNEStreamFrame& other) const {
87 return this->get_timestamp() < other.get_timestamp();
88 }
89
92 word_t adc_words[s_num_adc_words]; // NOLINT (a false accusation from the linter that s_num_adc_words is a variable)
94
95};
96
97static_assert(std::endian::native == std::endian::little,
98 "The DAPHNEStreamFrame bitfield layout assumes little-endian architecture");
99
100 static_assert(AdaptableFrameConcept<DAPHNEStreamFrame>, "DAPHNEStreamFrame does not satisfy the AdaptableFrameConcept");
101
102} // namespace dunedaq::fddetdataformats
103
105
106// NOLINTEND(build/unsigned)
107
108#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNESTREAMFRAME_HPP_
DAQHeader is a versioned and unified structure for every FE electronics.
Definition DAQHeader.hpp:23
void set_adc(int i, int i_channel, uint16_t val)
Set the i ADC value of chn in the frame to val.
bool operator<(const DAPHNEStreamFrame &other) const
void set_timestamp(const uint64_t new_timestamp)
Set the 64-bit timestamp of the frame.
uint16_t get_adc(int i_adc, int i_channel) const
Get the i ADC value of chn in the frame.