srs-control
0.2.2
Toggle main menu visibility
Loading...
Searching...
No Matches
ProtoToStructConverter.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
srs/data/SRSDataStructs.hpp
"
4
#include "srs/data/message.pb.h"
5
#include <cstdint>
6
7
namespace
srs::process
8
{
9
class
Proto2StructConverter
10
{
11
public
:
12
Proto2StructConverter
() =
default
;
13
14
static
void
convert
(
const
proto::Data&
proto
,
StructData
& struct_data)
15
{
16
reset_struct_data
(struct_data);
17
18
set_header
(
proto
, struct_data);
19
set_hit_data
(
proto
, struct_data);
20
set_marker_data
(
proto
, struct_data);
21
}
22
23
auto
convert
(
const
proto::Data&
proto
) ->
const
StructData
&
24
{
25
convert
(
proto
,
data_
);
26
return
data_
;
27
}
28
29
private
:
30
StructData
data_
;
31
32
static
void
set_header
(
const
proto::Data&
proto
,
StructData
& struct_data)
33
{
34
const
auto
& proto_header =
proto
.header();
35
36
auto
& header = struct_data.
header
;
37
header.
frame_counter
= proto_header.frame_counter();
38
header.fec_id =
static_cast<
uint8_t
>
(proto_header.fec_id());
39
header.udp_timestamp = proto_header.udp_timestamp();
40
header.overflow = proto_header.overflow();
41
}
42
43
static
void
set_marker_data
(
const
proto::Data&
proto
,
StructData
& struct_data)
44
{
45
const
auto
& proto_marker_data =
proto
.marker_data();
46
struct_data.
marker_data
.reserve(
static_cast<
uint64_t
>
(proto_marker_data.size()));
47
48
for
(
const
auto
& proto_marker : proto_marker_data)
49
{
50
auto
& marker_data = struct_data.
marker_data
.emplace_back();
51
marker_data.srs_timestamp = proto_marker.srs_timestamp();
52
marker_data.vmm_id =
static_cast<
uint8_t
>
(proto_marker.vmm_id());
53
}
54
}
55
56
static
void
set_hit_data
(
const
proto::Data&
proto
,
StructData
& struct_data)
57
{
58
const
auto
& proto_hit_data =
proto
.hit_data();
59
struct_data.
hit_data
.reserve(
static_cast<
uint64_t
>
(proto_hit_data.size()));
60
61
for
(
const
auto
& proto_hit : proto_hit_data)
62
{
63
auto
& hit_data = struct_data.
hit_data
.emplace_back();
64
65
hit_data.is_over_threshold = proto_hit.is_over_threshold();
66
hit_data.channel_num =
static_cast<
uint8_t
>
(proto_hit.channel_num());
67
hit_data.tdc =
static_cast<
uint8_t
>
(proto_hit.tdc());
68
hit_data.offset =
static_cast<
uint8_t
>
(proto_hit.offset());
69
hit_data.vmm_id =
static_cast<
uint8_t
>
(proto_hit.vmm_id());
70
hit_data.adc =
static_cast<
uint8_t
>
(proto_hit.adc());
71
hit_data.bc_id =
static_cast<
uint16_t
>
(proto_hit.bc_id());
72
}
73
}
74
};
75
76
}
// namespace srs::process
SRSDataStructs.hpp
srs::process::Proto2StructConverter::set_hit_data
static void set_hit_data(const proto::Data &proto, StructData &struct_data)
Definition
ProtoToStructConverter.hpp:56
srs::process::Proto2StructConverter::data_
StructData data_
Definition
ProtoToStructConverter.hpp:30
srs::process::Proto2StructConverter::convert
static void convert(const proto::Data &proto, StructData &struct_data)
Definition
ProtoToStructConverter.hpp:14
srs::process::Proto2StructConverter::set_header
static void set_header(const proto::Data &proto, StructData &struct_data)
Definition
ProtoToStructConverter.hpp:32
srs::process::Proto2StructConverter::Proto2StructConverter
Proto2StructConverter()=default
srs::process::Proto2StructConverter::set_marker_data
static void set_marker_data(const proto::Data &proto, StructData &struct_data)
Definition
ProtoToStructConverter.hpp:43
srs::process::Proto2StructConverter::convert
auto convert(const proto::Data &proto) -> const StructData &
Definition
ProtoToStructConverter.hpp:23
srs::process
Definition
ConverterConcepts.hpp:6
srs::process::DataConvertOptions::proto
@ proto
Definition
DataConvertOptions.hpp:20
srs::reset_struct_data
void reset_struct_data(StructData &struct_data)
Definition
SRSDataStructs.hpp:71
srs::ReceiveDataHeader::frame_counter
uint32_t frame_counter
The counting value for current UDP data frame.
Definition
SRSDataStructs.hpp:16
srs::StructData
Definition
SRSDataStructs.hpp:59
srs::StructData::header
ReceiveDataHeader header
Header data.
Definition
SRSDataStructs.hpp:60
srs::StructData::marker_data
std::vector< MarkerData > marker_data
Marker data.
Definition
SRSDataStructs.hpp:61
srs::StructData::hit_data
std::vector< HitData > hit_data
Hit data.
Definition
SRSDataStructs.hpp:62
backend
srs
converters
ProtoToStructConverter.hpp
Impressum
Datenschutzerklärung
Generated by
1.17.0