DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEEthTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_
3
7
8#include <cstdint> // uint_t types
9#include <memory> // unique_ptr
10#include <vector>
11#include <cstring> // memcpy
12#include <tuple> // tie
13
14namespace dunedaq {
15namespace fdreadoutlibs {
16namespace types {
17
22const constexpr std::size_t kTDEEthSize = 7200;
24{
26
27 // data
29 // comparable based on first timestamp
30 bool operator<(const TDEEthTypeAdapter& other) const
31 {
32 auto thisptr = reinterpret_cast<const FrameType*>(&data); // NOLINT
33 auto otherptr = reinterpret_cast<const FrameType*>(&other.data); // NOLINT
34 return thisptr->get_timestamp() < otherptr->get_timestamp() ? true : false;
35 }
36
37 uint64_t get_timestamp() const // NOLINT(build/unsigned)
38 {
39 return reinterpret_cast<const FrameType*>(&data)->get_timestamp(); // NOLINT
40 }
41
42 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
43 {
44 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
45 frame->set_timestamp(ts);
46 }
47
48 void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset*/ = 2048 ) // NOLINT(build/unsigned)
49 {
50 auto wef = reinterpret_cast<FrameType*>(((uint8_t*)(&data))); // NOLINT
51 wef->set_timestamp(first_timestamp);
52 }
53
54 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
55 for (unsigned int i = 0; i < get_num_frames(); ++i) {
56 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
57 df->daq_header.crate_id = crate_id;
58 df->daq_header.slot_id = slot_id;
59 df->daq_header.stream_id = stream_id;
60 }
61 }
62
63 void fake_adc_pattern(int channel) {
64 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
65 // Set the ADC to the uint16 maximum value
66 // AAA: setting only the first time sample
67 frame->set_adc(channel, 0, 16383);
68 }
69
70 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
71 {
72 // Set error bits in header
73 }
74
76 {
77 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
78 }
79
81 {
82 return reinterpret_cast<FrameType*>(data + kTDEEthSize); // NOLINT
83 }
84
85 size_t get_payload_size() { return kTDEEthSize; }
86
87 size_t get_num_frames() { return 1; }
88
89 size_t get_frame_size() { return kTDEEthSize; }
90
91 static const constexpr size_t fixed_payload_size = 7200;
94 // NOTE: the expected_tick_difference is different from WIBs because of the TDE sampling rate
95 static const constexpr uint64_t expected_tick_difference = 2000; // NOLINT(build/unsigned)
96 static const constexpr uint64_t samples_per_frame = 64; // NOLINT(build/unsigned)
97 // NOTE: this is actually 31.25
98 static const constexpr uint64_t samples_tick_difference = 32; // NOLINT(build/unsigned)
99};
100
101static_assert(sizeof(struct dunedaq::fddetdataformats::TDEEthFrame) == kTDEEthSize,
102 "Check your assumptions on TDEEthTypeAdapter");
103
104
105} // namespace types
106} // namespace fdreadoutlibs
107} // namespace dunedaq
108
109#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEETHTYPEADAPTER_HPP_ */
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
void set_adc(int i, int sample, 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.
detdataformats::DAQEthHeader daq_header
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
FragmentType
This enumeration should list all defined Fragment types.
const constexpr std::size_t kTDEEthSize
For TDEEth the numbers are different. Header + (64 channels * 64 time slices) = 7200[Bytes].
Including Qt Headers.
PDS Frame with unphysical timestamp detected with ts
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:43
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
static const constexpr uint64_t samples_tick_difference
void fake_timestamps(uint64_t first_timestamp, uint64_t=2048)
static const constexpr daqdataformats::FragmentType fragment_type
static const constexpr daqdataformats::SourceID::Subsystem subsystem
static const constexpr uint64_t expected_tick_difference
bool operator<(const TDEEthTypeAdapter &other) const