DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
DAPHNEEthStreamTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHSTREAMTYPEADAPTER_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHSTREAMTYPEADAPTER_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/DAPHNEEthStreamFrame.hpp
"
7
8
9
10
namespace
dunedaq::fdreadoutlibs::types
{
11
14
const
constexpr
std::size_t
kDAPHNEEthStreamNumFrames
= 1;
15
const
constexpr
std::size_t
kDAPHNEEthStreamSize
=
kDAPHNEEthStreamNumFrames
*
sizeof
(
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
);
16
17
struct
DAPHNEEthStreamTypeAdapter
{
18
19
using
FrameType
=
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
;
20
21
char
data
[
kDAPHNEEthStreamSize
];
22
23
// comparable based on first timestamp
24
bool
operator<
(
const
DAPHNEEthStreamTypeAdapter
& other)
const
25
{
26
auto
thisptr =
reinterpret_cast<
const
FrameType
*
>
(&
data
);
// NOLINT
27
auto
otherptr =
reinterpret_cast<
const
FrameType
*
>
(&other.
data
);
// NOLINT
28
return
thisptr->get_timestamp() < otherptr->get_timestamp() ? true :
false
;
29
}
30
31
uint64_t
get_timestamp
()
const
{
// NOLINT(build/unsigned)
32
return
reinterpret_cast<
const
FrameType
*
>
(&
data
)->
get_timestamp
();
// NOLINT
33
}
34
35
void
set_timestamp
(uint64_t ts)
// NOLINT(build/unsigned)
36
{
37
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
38
frame->set_timestamp(ts);
39
}
40
41
void
fake_timestamps
(uint64_t first_timestamp, uint64_t
offset
= 280)
// NOLINT(build/unsigned)
42
{
43
uint64_t ts_next = first_timestamp;
// NOLINT(build/unsigned)
44
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
45
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
46
df->set_timestamp(ts_next);
47
ts_next +=
offset
;
48
}
49
}
50
51
void
fake_geoid
(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id) {
52
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
53
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
54
df->daq_header.crate_id = crate_id;
55
df->daq_header.slot_id = slot_id;
56
df->daq_header.stream_id = stream_id;
57
}
58
}
59
60
void
fake_adc_pattern
(
int
channel) {
61
// Set the ADC for the first sample to the 14-bit max value
62
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
63
frame->set_adc(0, channel, 0x3FFF);
64
}
65
66
67
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
68
{
69
// Set frame error bits in header
70
}
71
72
FrameType
*
begin
()
73
{
74
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
75
}
76
77
FrameType
*
end
()
78
{
79
return
reinterpret_cast<
FrameType
*
>
(
data
+
kDAPHNEEthStreamSize
);
// NOLINT
80
}
81
82
constexpr
size_t
get_payload_size
()
const
{
return
kDAPHNEEthStreamSize
; }
83
84
constexpr
size_t
get_num_frames
()
const
{
return
kDAPHNEEthStreamNumFrames
; }
85
86
constexpr
size_t
get_frame_size
()
const
{
return
sizeof
(
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
); }
87
88
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
89
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kDAPHNEEthStream
;
90
static
const
constexpr
uint64_t
expected_tick_difference
= 280;
// NOLINT(build/unsigned)
91
};
92
93
static_assert
(
sizeof
(
struct
DAPHNEEthStreamTypeAdapter
) ==
kDAPHNEEthStreamSize
,
94
"Check your assumptions on DAPHNEEthStreamTypeAdapter"
);
95
96
97
}
// namespace dunedaq::fdreadoutlibs::types
98
99
100
#endif
// FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNEETHSTREAMTYPEADAPTER_
DAPHNEEthStreamFrame.hpp
FragmentHeader.hpp
SourceID.hpp
offset
double offset
Definition
conversions-impl.hh:28
dunedaq::daqdataformats::FragmentType
FragmentType
All defined Fragment types.
Definition
FragmentHeader.hpp:114
dunedaq::daqdataformats::FragmentType::kDAPHNEEthStream
@ kDAPHNEEthStream
Definition
FragmentHeader.hpp:144
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kDAPHNEEthStreamNumFrames
const constexpr std::size_t kDAPHNEEthStreamNumFrames
Definition
DAPHNEEthStreamTypeAdapter.hpp:14
dunedaq::fdreadoutlibs::types::kDAPHNEEthStreamSize
const constexpr std::size_t kDAPHNEEthStreamSize
Definition
DAPHNEEthStreamTypeAdapter.hpp:15
dunedaq::daqdataformats::SourceID::Subsystem
Subsystem
The Subsystem enum describes the kind of source we're dealing with.
Definition
SourceID.hpp:40
dunedaq::daqdataformats::SourceID::Subsystem::kDetectorReadout
@ kDetectorReadout
Definition
SourceID.hpp:42
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
Struct for accessing raw DAPHNE eth stream frames.
Definition
DAPHNEEthStreamFrame.hpp:43
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter
Definition
DAPHNEEthStreamTypeAdapter.hpp:17
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int channel)
Definition
DAPHNEEthStreamTypeAdapter.hpp:60
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:31
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_num_frames
constexpr size_t get_num_frames() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:84
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
DAPHNEEthStreamTypeAdapter.hpp:51
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::data
char data[kDAPHNEEthStreamSize]
Definition
DAPHNEEthStreamTypeAdapter.hpp:21
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::end
FrameType * end()
Definition
DAPHNEEthStreamTypeAdapter.hpp:77
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t offset=280)
Definition
DAPHNEEthStreamTypeAdapter.hpp:41
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_frame_size
constexpr size_t get_frame_size() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:86
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DAPHNEEthStreamTypeAdapter.hpp:35
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::FrameType
dunedaq::fddetdataformats::DAPHNEEthStreamFrame FrameType
Definition
DAPHNEEthStreamTypeAdapter.hpp:19
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
DAPHNEEthStreamTypeAdapter.hpp:67
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
DAPHNEEthStreamTypeAdapter.hpp:88
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
DAPHNEEthStreamTypeAdapter.hpp:90
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::operator<
bool operator<(const DAPHNEEthStreamTypeAdapter &other) const
Definition
DAPHNEEthStreamTypeAdapter.hpp:24
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
DAPHNEEthStreamTypeAdapter.hpp:89
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_payload_size
constexpr size_t get_payload_size() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:82
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::begin
FrameType * begin()
Definition
DAPHNEEthStreamTypeAdapter.hpp:72
Generated on
for DUNE-DAQ by
1.17.0