DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DUNEWIBEthTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_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 kDUNEWIBEthSize = 7200;
24{
26 // data
28 // comparable based on first timestamp
29 bool operator<(const DUNEWIBEthTypeAdapter& other) const
30 {
31 auto thisptr = reinterpret_cast<const FrameType*>(&data); // NOLINT
32 auto otherptr = reinterpret_cast<const FrameType*>(&other.data); // NOLINT
33 return thisptr->get_timestamp() < otherptr->get_timestamp() ? true : false;
34 }
35
36 uint64_t get_timestamp() const // NOLINT(build/unsigned)
37 {
38 return reinterpret_cast<const FrameType*>(&data)->get_timestamp(); // NOLINT
39 }
40
41 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
42 {
43 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
44 frame->set_timestamp(ts);
45 }
46
47 void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset*/= 2048 ) // NOLINT(build/unsigned)
48 {
49 auto wef = reinterpret_cast<FrameType*>(((uint8_t*)(&data))); // NOLINT
50 wef->set_timestamp(first_timestamp);
51 }
52
53 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
54 for (unsigned int i = 0; i < get_num_frames(); ++i) {
55 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
56 df->daq_header.crate_id = crate_id;
57 df->daq_header.slot_id = slot_id;
58 df->daq_header.stream_id = stream_id;
59 }
60 }
61
62 void fake_adc_pattern(int channel) {
63 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
64 // Set the ADC to the uint16 maximum value
65 // AAA: setting only the first time sample
66 frame->set_adc(channel, 0, 16383);
67 }
68
69 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
70 {
71 // Set error bits in header
72 }
73
75 {
76 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
77 }
78
80 {
81 return reinterpret_cast<FrameType*>(data + kDUNEWIBEthSize); // NOLINT
82 }
83
84 size_t get_payload_size() { return kDUNEWIBEthSize; }
85
86 size_t get_num_frames() { return 1; }
87
88 size_t get_frame_size() { return kDUNEWIBEthSize; }
89
90 static const constexpr size_t fixed_payload_size = 7200;
93 static const constexpr uint64_t expected_tick_difference = 2048; // NOLINT(build/unsigned)
94 static const constexpr uint64_t samples_per_frame = 64; // NOLINT(build/unsigned)
95 static const constexpr uint64_t samples_tick_difference = 32; // NOLINT(build/unsigned)
96};
97
98static_assert(sizeof(struct dunedaq::fddetdataformats::WIBEthFrame) == kDUNEWIBEthSize,
99 "Check your assumptions on DUNEWIBEthTypeAdapter");
100
101
102} // namespace types
103} // namespace fdreadoutlibs
104} // namespace dunedaq
105
106#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_ */
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
void set_adc(int i, int sample, uint16_t val)
Set the ith ADC value in the frame to val.
detdataformats::DAQEthHeader daq_header
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
FragmentType
This enumeration should list all defined Fragment types.
const constexpr std::size_t kDUNEWIBEthSize
For WIBEth 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
bool operator<(const DUNEWIBEthTypeAdapter &other) const
static const constexpr daqdataformats::FragmentType fragment_type
static const constexpr daqdataformats::SourceID::Subsystem subsystem
void fake_timestamps(uint64_t first_timestamp, uint64_t=2048)
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)