DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DAPHNEStreamSuperChunkTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
3
7
9
14const constexpr std::size_t kDAPHNEStreamNumFrames = 12;
16const constexpr std::size_t kDAPHNEStreamSuperChunkSize =
18
20{
21
23
25
26 // comparable based on first timestamp
28 {
29 auto thisptr = reinterpret_cast<const FrameType*>(&data); // NOLINT
30 auto otherptr = reinterpret_cast<const FrameType*>(&other.data); // NOLINT
31 return thisptr->get_timestamp() < otherptr->get_timestamp();
32 }
33
34 uint64_t get_timestamp() const // NOLINT(build/unsigned)
35 {
36 return reinterpret_cast<const FrameType*>(&data)->get_timestamp(); // NOLINT
37 }
38
39 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
40 {
41 auto frame = reinterpret_cast<FrameType*>(&data); // NOLINT
42 frame->set_timestamp(ts);
43 }
44
45 void fake_timestamps(uint64_t first_timestamp, uint64_t offset = 64) // NOLINT(build/unsigned)
46 {
47 uint64_t ts_next = first_timestamp; // NOLINT(build/unsigned)
48 for (unsigned int i = 0; i < get_num_frames(); ++i) {
49 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
50 df->set_timestamp(ts_next);
51 ts_next += offset;
52 }
53 }
54
55 void fake_geoid(uint16_t /*crate_id*/, uint16_t /*slot_id*/, uint16_t /*link_id*/) {}
56
57 void fake_adc_pattern(int /*channel*/) {}
58
59 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT
60 {
61 // Set frame error bits in header
62 }
63
65 {
66 return reinterpret_cast<FrameType*>(&data[0]); // NOLINT
67 }
68
70 {
71 return reinterpret_cast<FrameType*>(data + kDAPHNEStreamSuperChunkSize); // NOLINT
72 }
73
74 constexpr size_t get_payload_size() const { return get_num_frames() * get_frame_size(); } // 12*472 -> 5664
75
76 constexpr size_t get_num_frames() const { return kDAPHNEStreamNumFrames; }
77
78 constexpr size_t get_frame_size() const { return kDAPHNEStreamFrameSize; }
79
83 static const constexpr uint64_t expected_tick_difference = 64; // NOLINT(build/unsigned)
84};
85
87 "Check your assumptions on DAPHNESuperChunkTypeAdapter");
88
89} // namespace dunedaq::fdreadoutlibs::types
90
91#endif // FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
double offset
FragmentType
All defined Fragment types.
const constexpr std::size_t kDAPHNEStreamSuperChunkSize
const constexpr std::size_t kDAPHNEStreamNumFrames
For DAPHNE Stream the numbers are similar to DUNE-WIB 12[DAPHNE frames] x 472[Bytes] = 5664[Bytes].
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition SourceID.hpp:40
void set_timestamp(const uint64_t new_timestamp)
Set the 64-bit timestamp of the frame.
bool operator<(const DAPHNEStreamSuperChunkTypeAdapter &other) const
static const constexpr daqdataformats::SourceID::Subsystem subsystem