SRS-control 0.1.4
Loading...
Searching...
No Matches
ProtoToStructConverter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
5#include <srs/data/message.pb.h>
6
7namespace srs::process
8{
10 {
11 public:
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 {
26 return data_;
27 }
28
29 private:
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
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.