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