Apollo 10.0
自动驾驶开放平台
udp_bridge_multi_receiver_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <netinet/in.h>
19#include <sys/socket.h>
20
21#include <cstdlib>
22#include <iostream>
23#include <memory>
24#include <string>
25#include <vector>
26
27#include "modules/bridge/proto/udp_bridge_remote_info.pb.h"
28#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
29
32#include "cyber/cyber.h"
33#include "cyber/init.h"
40
41namespace apollo {
42namespace bridge {
44 public:
47
48 bool Init() override;
49 std::string Name() const { return FLAGS_bridge_module_name; }
50 std::shared_ptr<ProtoDiserializedBufBase> CreateBridgeProtoBuf(
51 const BridgeHeader &header);
52 bool IsProtoExist(const BridgeHeader &header);
53 bool IsTimeout(double time_stamp);
54 void MsgDispatcher();
55 bool InitSession(uint16_t port);
56 bool MsgHandle(int fd);
57
58 private:
59 bool RemoveInvalidBuf(uint32_t msg_id, const std::string &msg_name);
60
61 private:
62 common::monitor::MonitorLogBuffer monitor_logger_buffer_;
63 std::shared_ptr<UDPListener<UDPBridgeMultiReceiverComponent>> listener_ =
64 std::make_shared<UDPListener<UDPBridgeMultiReceiverComponent>>();
65 unsigned int bind_port_ = 0;
66 bool enable_timeout_ = true;
67 std::mutex mutex_;
68 std::vector<std::shared_ptr<ProtoDiserializedBufBase>> proto_list_;
69};
70
71CYBER_REGISTER_COMPONENT(UDPBridgeMultiReceiverComponent)
72
73} // namespace bridge
74} // namespace apollo
std::shared_ptr< ProtoDiserializedBufBase > CreateBridgeProtoBuf(const BridgeHeader &header)
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
The class of MonitorLogBuffer
class register implement
Definition arena_queue.h:37