DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fdreadoutlibs
include
fdreadoutlibs
DAPHNEStreamSuperChunkTypeAdapter.hpp
Go to the documentation of this file.
1
#ifndef FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
2
#define FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
3
4
#include "
daqdataformats/FragmentHeader.hpp
"
5
#include "
daqdataformats/SourceID.hpp
"
6
#include "
fddetdataformats/DAPHNEStreamFrame.hpp
"
7
8
9
10
namespace
dunedaq::fdreadoutlibs::types
{
11
16
const
constexpr
std::size_t
kDAPHNEStreamNumFrames
= 12;
17
const
constexpr
std::size_t
kDAPHNEStreamFrameSize
=
sizeof
(
dunedaq::fddetdataformats::DAPHNEStreamFrame
);
18
const
constexpr
std::size_t
kDAPHNEStreamSuperChunkSize
=
kDAPHNEStreamNumFrames
*
kDAPHNEStreamFrameSize
;
// for 12: 5664
19
20
struct
DAPHNEStreamSuperChunkTypeAdapter
{
21
22
using
FrameType
=
dunedaq::fddetdataformats::DAPHNEStreamFrame
;
23
24
char
data
[
kDAPHNEStreamSuperChunkSize
];
25
26
// comparable based on first timestamp
27
bool
operator<
(
const
DAPHNEStreamSuperChunkTypeAdapter
& other)
const
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
58
void
fake_adc_pattern
(
int
/*channel*/
) {
59
}
60
61
62
void
fake_frame_errors
(std::vector<uint16_t>*
/*fake_errors*/
)
// NOLINT
63
{
64
// Set frame error bits in header
65
}
66
67
FrameType
*
begin
()
68
{
69
return
reinterpret_cast<
FrameType
*
>
(&
data
[0]);
// NOLINT
70
}
71
72
FrameType
*
end
()
73
{
74
return
reinterpret_cast<
FrameType
*
>
(
data
+
kDAPHNEStreamSuperChunkSize
);
// NOLINT
75
}
76
77
constexpr
size_t
get_payload_size
()
const
{
return
get_num_frames
() *
get_frame_size
(); }
// 12*472 -> 5664
78
79
constexpr
size_t
get_num_frames
()
const
{
return
kDAPHNEStreamNumFrames
; }
80
81
constexpr
size_t
get_frame_size
()
const
{
return
kDAPHNEStreamFrameSize
; }
82
83
static
const
constexpr
daqdataformats::SourceID::Subsystem
subsystem
=
daqdataformats::SourceID::Subsystem::kDetectorReadout
;
84
static
const
constexpr
daqdataformats::FragmentType
fragment_type
=
daqdataformats::FragmentType::kDAPHNEStream
;
85
static
const
constexpr
uint64_t
expected_tick_difference
= 64;
// NOLINT(build/unsigned)
86
};
87
88
static_assert
(
sizeof
(
struct
DAPHNEStreamSuperChunkTypeAdapter
) ==
kDAPHNEStreamSuperChunkSize
,
89
"Check your assumptions on DAPHNESuperChunkTypeAdapter"
);
90
91
92
}
// namespace dunedaq::fdreadoutlibs::types
93
94
95
#endif
// FDREADOUTLIBS_INCLUDE_FDREADOUTLIBS_DAPHNESTREAMSUPERCHUNKTYPEADAPTER_
DAPHNEStreamFrame.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::kDAPHNEStream
@ kDAPHNEStream
Definition
FragmentHeader.hpp:138
dunedaq::fdreadoutlibs::types
Definition
CRTBernTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kDAPHNEStreamSuperChunkSize
const constexpr std::size_t kDAPHNEStreamSuperChunkSize
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:18
dunedaq::fdreadoutlibs::types::kDAPHNEStreamNumFrames
const constexpr std::size_t kDAPHNEStreamNumFrames
For DAPHNE Stream the numbers are similar to DUNE-WIB 12[DAPHNE frames] x 472[Bytes] = 5664[Bytes].
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:16
dunedaq::fdreadoutlibs::types::kDAPHNEStreamFrameSize
const constexpr std::size_t kDAPHNEStreamFrameSize
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:17
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::DAPHNEStreamFrame
Definition
DAPHNEStreamFrame.hpp:35
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:20
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::fake_geoid
void fake_geoid(uint16_t, uint16_t, uint16_t)
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:55
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::fake_adc_pattern
void fake_adc_pattern(int)
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:58
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::begin
FrameType * begin()
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:67
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::operator<
bool operator<(const DAPHNEStreamSuperChunkTypeAdapter &other) const
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:27
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::get_frame_size
constexpr size_t get_frame_size() const
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:81
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::get_timestamp
uint64_t get_timestamp() const
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:34
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::fragment_type
static const constexpr daqdataformats::FragmentType fragment_type
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:84
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::get_num_frames
constexpr size_t get_num_frames() const
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:79
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::end
FrameType * end()
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:72
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::get_payload_size
constexpr size_t get_payload_size() const
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:77
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::expected_tick_difference
static const constexpr uint64_t expected_tick_difference
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:85
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::subsystem
static const constexpr daqdataformats::SourceID::Subsystem subsystem
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:83
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::data
char data[kDAPHNEStreamSuperChunkSize]
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:24
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::fake_timestamps
void fake_timestamps(uint64_t first_timestamp, uint64_t offset=64)
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:45
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::fake_frame_errors
void fake_frame_errors(std::vector< uint16_t > *)
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:62
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::FrameType
dunedaq::fddetdataformats::DAPHNEStreamFrame FrameType
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:22
dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter::set_timestamp
void set_timestamp(uint64_t ts)
Definition
DAPHNEStreamSuperChunkTypeAdapter.hpp:39
Generated on
for DUNE-DAQ by
1.17.0