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
namespace
dunedaq::fdreadoutlibs::types
{
9
12
const
constexpr
std::size_t
kDAPHNEEthStreamNumFrames
= 1;
13
const
constexpr
std::size_t
kDAPHNEEthStreamSize
=
14
kDAPHNEEthStreamNumFrames
*
sizeof
(
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
);
15
16
struct
DAPHNEEthStreamTypeAdapter
17
{
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
32
{
// NOLINT(build/unsigned)
33
return
reinterpret_cast<
const
FrameType
*
>
(&
data
)->
get_timestamp
();
// NOLINT
34
}
35
36
void
set_timestamp
(uint64_t ts)
// NOLINT(build/unsigned)
37
{
38
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
39
frame->
set_timestamp
(ts);
40
}
41
42
void
fake_timestamps
(uint64_t first_timestamp, uint64_t
offset
= 280)
// NOLINT(build/unsigned)
43
{
44
uint64_t ts_next = first_timestamp;
// NOLINT(build/unsigned)
45
for
(
unsigned
int
i = 0; i <
get_num_frames
(); ++i) {
46
auto
df =
reinterpret_cast<
FrameType
*
>
((
reinterpret_cast<
uint8_t*
>
(&
data
)) + i *
get_frame_size
());
47
df->
set_timestamp
(ts_next);
48
ts_next +=
offset
;
49
}
50
}
51
52
void
fake_geoid
(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
53
{
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->
daq_header
.
crate_id
= crate_id;
57
df->daq_header.slot_id = slot_id;
58
df->daq_header.stream_id = stream_id;
59
}
60
}
61
62
void
fake_adc_pattern
(
int
channel)
63
{
64
// Set the ADC for the first sample to the 14-bit max value
65
auto
frame =
reinterpret_cast<
FrameType
*
>
(&
data
);
// NOLINT
66
frame->
set_adc
(0, channel, 0x3FFF);
67
}
68
69
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
70
{
71
// Set frame error bits in header
72
}
73
74
FrameType
*
begin
()
75
{
76
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
77
}
78
79
FrameType
*
end
()
80
{
81
return
reinterpret_cast<
FrameType
*
>
(
data
+
kDAPHNEEthStreamSize
);
// NOLINT
82
}
83
84
constexpr
size_t
get_payload_size
()
const
{
return
kDAPHNEEthStreamSize
; }
85
86
constexpr
size_t
get_num_frames
()
const
{
return
kDAPHNEEthStreamNumFrames
; }
87
88
constexpr
size_t
get_frame_size
()
const
{
return
sizeof
(
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
); }
89
90
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
91
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
92
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kDAPHNEEthStream
;
93
static
const
constexpr
uint64_t
expected_tick_difference
= 280;
// NOLINT(build/unsigned)
94
};
95
96
static_assert
(
sizeof
(
struct
DAPHNEEthStreamTypeAdapter
) ==
kDAPHNEEthStreamSize
,
97
"Check your assumptions on DAPHNEEthStreamTypeAdapter"
);
98
99
}
// namespace dunedaq::fdreadoutlibs::types
100
101
#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:12
dunedaq::fdreadoutlibs::types::kDAPHNEEthStreamSize
const constexpr std::size_t kDAPHNEEthStreamSize
Definition
DAPHNEEthStreamTypeAdapter.hpp:13
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::detdataformats::DAQEthHeader::crate_id
word_t crate_id
Definition
DAQEthHeader.hpp:26
dunedaq::fddetdataformats::DAPHNEEthStreamFrame
Struct for accessing raw DAPHNE eth stream frames.
Definition
DAPHNEEthStreamFrame.hpp:43
dunedaq::fddetdataformats::DAPHNEEthStreamFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
DAPHNEEthStreamFrame.hpp:105
dunedaq::fddetdataformats::DAPHNEEthStreamFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
DAPHNEEthStreamFrame.hpp:83
dunedaq::fddetdataformats::DAPHNEEthStreamFrame::set_adc
void set_adc(int i_adc, int i_channel, uint16_t val)
Set the i_adc-th ADC value of i_channel-th channel in the frame to val.
Definition
DAPHNEEthStreamFrame.hxx:37
dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
DAPHNEEthStreamFrame.hpp:80
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter
Definition
DAPHNEEthStreamTypeAdapter.hpp:17
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int channel)
Definition
DAPHNEEthStreamTypeAdapter.hpp:62
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:86
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_geoid
void fake_geoid(uint16_t crate_id, uint16_t slot_id, uint16_t stream_id)
Definition
DAPHNEEthStreamTypeAdapter.hpp:52
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::data
char data[kDAPHNEEthStreamSize]
Definition
DAPHNEEthStreamTypeAdapter.hpp:21
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::end
FrameType * end()
Definition
DAPHNEEthStreamTypeAdapter.hpp:79
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t offset=280)
Definition
DAPHNEEthStreamTypeAdapter.hpp:42
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_frame_size
constexpr size_t get_frame_size() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:88
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DAPHNEEthStreamTypeAdapter.hpp:36
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:69
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
DAPHNEEthStreamTypeAdapter.hpp:90
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
DAPHNEEthStreamTypeAdapter.hpp:93
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:92
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::get_payload_size
constexpr size_t get_payload_size() const
Definition
DAPHNEEthStreamTypeAdapter.hpp:84
dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter::begin
FrameType * begin()
Definition
DAPHNEEthStreamTypeAdapter.hpp:74
Generated on
for DUNE-DAQ by
1.18.0