DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEEthTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHTYPEADAPTER_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHTYPEADAPTER_
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
18
23const constexpr std::size_t kDAPHNEEthSize = 1864;
24
26{
29
30 bool operator<(const DAPHNEEthTypeAdapter& other) const
31 {
32 auto thisptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEEthFrame*>(&data); // NOLINT
33 auto otherptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEEthFrame*>(&other.data); // NOLINT
34
35 return std::forward_as_tuple(thisptr->get_timestamp(), thisptr->get_channel()) < std::forward_as_tuple(otherptr->get_timestamp(), otherptr->get_channel());
36 }
37
38 uint64_t get_timestamp() const // NOLINT(build/unsigned)
39 {
40 return reinterpret_cast<const FrameType*>(&data)->get_timestamp(); // NOLINT
41 }
42
43 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
44 {
45 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
46 frame->set_timestamp(ts);
47 }
48
49 void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset*/= 2048 ) // NOLINT(build/unsigned)
50 {
51 auto wef = reinterpret_cast<FrameType*>(((uint8_t*)(&data))); // NOLINT
52 wef->set_timestamp(first_timestamp);
53 }
54
55 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
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_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
65 {
66 // Set error bits in header
67 }
68
69 void fake_adc_pattern(int /*channel*/) {
70 }
71
73 {
74 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
75 }
76
78 {
79 return reinterpret_cast<FrameType*>(data + kDAPHNEEthSize); // NOLINT
80 }
81
82 size_t get_payload_size() { return kDAPHNEEthSize; }
83
84 size_t get_num_frames() { return 1; }
85
86 size_t get_frame_size() { return kDAPHNEEthSize; }
87
90 static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned)
91};
92
93static_assert(sizeof(struct dunedaq::fddetdataformats::DAPHNEEthFrame) == kDAPHNEEthSize,
94 "Check your assumptions on DAPHNEEthEthTypeAdapter");
95
96
97} // namespace types
98} // namespace fdreadoutlibs
99} // namespace dunedaq
100
101#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHTYPEADAPTER_ */
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
detdataformats::DAQEthHeader daq_header
FragmentType
This enumeration should list all defined Fragment types.
const constexpr std::size_t kDAPHNEEthSize
For DAPHNEEth the numbers are different. Header + (64 channels * 64 time slices) = 233[Bytes].
The DUNE-DAQ namespace.
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:43
bool operator<(const DAPHNEEthTypeAdapter &other) const
static const constexpr daqdataformats::FragmentType fragment_type
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)
static const constexpr daqdataformats::SourceID::Subsystem subsystem