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 <cstring> // memcpy
10#include <memory> // unique_ptr
11#include <tuple> // tie
12#include <vector>
13
14namespace dunedaq {
15namespace fdreadoutlibs {
16namespace types {
17
22const constexpr std::size_t kDUNEWIBEthSize = 7200;
23
25{
27 // data
29 // comparable based on first timestamp
30 bool operator<(const DUNEWIBEthTypeAdapter& 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 {
56 for (unsigned int i = 0; i < get_num_frames(); ++i) {
57 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
58 df->daq_header.crate_id = crate_id;
59 df->daq_header.slot_id = slot_id;
60 df->daq_header.stream_id = stream_id;
61 }
62 }
63
64 void fake_adc_pattern(int channel)
65 {
66 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
67 // Set the ADC to the uint16 maximum value
68 // AAA: setting only the first time sample
69 frame->set_adc(channel, 0, 16383);
70 }
71
72 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
73 {
74 // Set error bits in header
75 }
76
78 {
79 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
80 }
81
83 {
84 return reinterpret_cast<FrameType*>(data + kDUNEWIBEthSize); // NOLINT
85 }
86
87 size_t get_payload_size() { return kDUNEWIBEthSize; }
88
89 size_t get_num_frames() { return 1; }
90
91 size_t get_frame_size() { return kDUNEWIBEthSize; }
92
93 static const constexpr size_t fixed_payload_size = 7200;
97 static const constexpr uint64_t expected_tick_difference = 2048; // NOLINT(build/unsigned)
98 static const constexpr uint64_t samples_per_frame = 64; // NOLINT(build/unsigned)
99 static const constexpr float samples_tick_difference = 32; // NOLINT(build/unsigned)
100};
101
103 "Check your assumptions on DUNEWIBEthTypeAdapter");
104
105} // namespace types
106} // namespace fdreadoutlibs
107} // namespace dunedaq
108
109#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DUNEWIBETHTYPEADAPTER_HPP_ */
FragmentType
All defined Fragment types.
const constexpr std::size_t kDUNEWIBEthSize
For WIBEth the numbers are different. Header + (64 channels * 64 time slices) = 7200[Bytes].
The DUNE-DAQ namespace.
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:40
struct 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.
detdataformats::DAQEthHeader daq_header
void set_adc(int i_channel, int i_sample, uint16_t adc_val)
Set the i_channel-th ADC value in the i_sample-th time sample to adc_val.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
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)