DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEFrameTypeAdapter.hpp
Go to the documentation of this file.
1#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEFRAMETYPEADAPTER_HPP_
2#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEFRAMETYPEADAPTER_HPP_
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
18const constexpr std::size_t kTDEFrameSize = sizeof(dunedaq::fddetdataformats::TDE16Frame);
20
21{
23
24 //char data[kTDEFrameSize];
26
27 bool operator<(const TDEFrameTypeAdapter& other) const
28 {
29 uint64_t ts = data.get_timestamp();
30 uint32_t ch = data.get_channel();
31 uint64_t ots = other.data.get_timestamp();
32 //uint32_t och = 0xffff;
33 uint32_t och = other.data.get_channel();;
34
35 return std::tie(ts,ch) < std::tie(ots,och);
36 }
37
38 uint64_t get_timestamp() const // NOLINT(build/unsigned)
39 {
40 return data.get_timestamp(); // NOLINT
41 }
42
43 void set_timestamp(uint64_t ts) // NOLINT(build/unsigned)
44 {
45 data.set_timestamp(ts); // NOLINT
46 }
47
48 void fake_timestamps(uint64_t first_timestamp, uint64_t) // NOLINT(build/unsigned)
49 {
50 data.set_timestamp(first_timestamp);
51 }
52
53 void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t /*link_id*/) {
54 for (unsigned int i = 0; i < get_num_frames(); ++i) {
55 auto df = reinterpret_cast<FrameType*>((reinterpret_cast<uint8_t*>(&data)) + i * get_frame_size());
56 df->get_daq_header()->crate_id = crate_id;
57 df->get_daq_header()->slot_id = slot_id;
58 }
59 }
60
61 void fake_adc_pattern(int /*channel*/) {
62 }
63
64 void fake_frame_errors(std::vector<uint16_t>* /*fake_errors*/) // NOLINT(build/unsigned)
65 {
66 }
67
68 size_t get_payload_size() { return sizeof(FrameType); }
69
70 size_t get_num_frames() { return 1; }
71
72 size_t get_frame_size() { return sizeof(FrameType); }
73
75 {
76 return &data; // NOLINT
77 }
78
80 {
81 return (reinterpret_cast<FrameType*>(reinterpret_cast<char*>(&data)+kTDEFrameSize)); // NOLINT
82 }
83
87
88};
89
91 "Check your assumptions on TDEFrameTypeAdapter");
92
93} // namespace types
94} // namespace fdreadoutlibs
95} // namespace dunedaq
96
97#endif /* FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_TDEFRAMETYPEADAPTER_HPP_ */
const detdataformats::DAQEthHeader * get_daq_header() const
void set_timestamp(const uint64_t new_timestamp)
FragmentType
This enumeration should list all defined Fragment types.
static constexpr int tot_adc16_samples
static constexpr int ticks_between_adc_samples
const constexpr std::size_t kTDEFrameSize
The DUNE-DAQ namespace.
Definition DataStore.hpp:57
PDS Frame with unphysical timestamp detected with ch
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
static const constexpr daqdataformats::FragmentType fragment_type
bool operator<(const TDEFrameTypeAdapter &other) const
dunedaq::fddetdataformats::TDE16Frame FrameType
static const constexpr daqdataformats::SourceID::Subsystem subsystem
void fake_timestamps(uint64_t first_timestamp, uint64_t)
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t)