DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNESuperChunkTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_
3
7
8#include <cstdint> // uint_t types
9#include <memory> // unique_ptr
10#include <vector>
11#include <cstring> // memcpy
12#include <tuple> // forward_as_tuple
13
14namespace dunedaq {
15namespace fdreadoutlibs {
16namespace types {
17
22const constexpr std::size_t kDAPHNENumFrames = 3;
23const constexpr std::size_t kDAPHNEFrameSize = 1864;
24const constexpr std::size_t kDAPHNESuperChunkSize = kDAPHNENumFrames * kDAPHNEFrameSize; // for 12: 22368
26{
28 // data
30 // comparable based on first timestamp and first channel
31 bool operator<(const DAPHNESuperChunkTypeAdapter& other) const
32 {
33 auto thisptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEFrame*>(&data); // NOLINT
34 auto otherptr = reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEFrame*>(&other.data); // NOLINT
35
36 return std::forward_as_tuple(thisptr->get_timestamp(), thisptr->get_channel()) < std::forward_as_tuple(otherptr->get_timestamp(), otherptr->get_channel());
37 }
38
39 uint64_t get_timestamp() const // NOLINT(build/unsigned)
40 {
41 return reinterpret_cast<const dunedaq::fddetdataformats::DAPHNEFrame*>(&data)->get_timestamp(); // NOLINT
42 }
43
44 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
45 {
46 auto frame = reinterpret_cast<dunedaq::fddetdataformats::DAPHNEFrame*>(&data); // NOLINT
47 frame->daq_header.timestamp_1 = ts;
48 frame->daq_header.timestamp_2 = ts >> 32;
49 }
50
51 void fake_timestamps(uint64_t first_timestamp, uint64_t offset = expected_tick_difference) // NOLINT(build/unsigned)
52 {
53 uint64_t ts_next = first_timestamp; // NOLINT(build/unsigned)
54 for (unsigned int i = 0; i < get_num_frames(); ++i) {
55 auto df = reinterpret_cast<dunedaq::fddetdataformats::DAPHNEFrame*>(((uint8_t*)(&data)) + i * get_frame_size()); // NOLINT
56 df->daq_header.timestamp_1 = ts_next;
57 df->daq_header.timestamp_2 = ts_next >> 32;
58 ts_next += offset;
59 }
60 }
61
62 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t link_id) {
63 for (unsigned int i = 0; i < get_num_frames(); ++i) {
64 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
65 df->daq_header.slot_id = slot_id;
66 df->daq_header.link_id = link_id;
67 df->daq_header.crate_id = crate_id;
68 }
69 }
70
71 void fake_adc_pattern(int /*channel*/) {
72 }
73
74 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
75 {
76 // Set frame error bits in header
77 }
78
80 {
81 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
82 }
83
85 {
86 return reinterpret_cast<FrameType*>(data + kDAPHNESuperChunkSize); // NOLINT
87 }
88
90
91 size_t get_num_frames() { return kDAPHNENumFrames; }
92
93 size_t get_frame_size() { return kDAPHNEFrameSize; }
94
97 static const constexpr uint64_t expected_tick_difference = 1024; // NOLINT(build/unsigned)
98};
99
100static_assert(sizeof(struct DAPHNESuperChunkTypeAdapter) == kDAPHNESuperChunkSize,
101 "Check your assumptions on DAPHNESuperChunkTypeAdapter");
102
103
104} // namespace types
105} // namespace fdreadoutlibs
106} // namespace dunedaq
107
108#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESUPERCHUNKTYPEADAPTER_ */
109
detdataformats::DAQHeader daq_header
double offset
FragmentType
This enumeration should list all defined Fragment types.
const constexpr std::size_t kDAPHNENumFrames
For DAPHNE the numbers are different. 12[DAPHNE frames] x 454[32-bit words] x 4[Bytes per word] = 217...
const constexpr std::size_t kDAPHNEFrameSize
const constexpr std::size_t kDAPHNESuperChunkSize
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 link_id)
bool operator<(const DAPHNESuperChunkTypeAdapter &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 offset=expected_tick_difference)