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 <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 kDAPHNEEthSize = 1864;
23
25{
28
29 bool operator<(const DAPHNEEthTypeAdapter& other) const
30 {
31 auto thisptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEEthFrame*>(&data); // NOLINT
32 auto otherptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEEthFrame*>(&other.data); // NOLINT
33
34 return std::forward_as_tuple(thisptr->get_timestamp(), thisptr->get_channel()) <
35 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 {
57 for (unsigned int i = 0; i < get_num_frames(); ++i) {
58 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
59 df->daq_header.crate_id = crate_id;
60 df->daq_header.slot_id = slot_id;
61 df->daq_header.stream_id = stream_id;
62 }
63 }
64
65 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
66 {
67 // Set error bits in header
68 }
69
70 void fake_adc_pattern(int /*channel*/) {}
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
91 static const constexpr uint64_t expected_tick_difference = 1024; // NOLINT(build/unsigned)
92};
93
95 "Check your assumptions on DAPHNEEthEthTypeAdapter");
96
97} // namespace types
98} // namespace fdreadoutlibs
99} // namespace dunedaq
100
101#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHTYPEADAPTER_ */
FragmentType
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:40
Struct for accessing raw DAPHNE eth frames.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
detdataformats::DAQEthHeader daq_header
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
dunedaq::fddetdataformats::DAPHNEEthFrame FrameType