Apollo  6.0
Open source self driving car software
udp_bridge_multi_receiver_component.h
Go to the documentation of this file.
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/canbus/proto/chassis.pb.h"
29 
32 #include "cyber/cyber.h"
33 #include "cyber/init.h"
40 
41 namespace apollo {
42 namespace 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 
71 } // namespace bridge
72 } // namespace apollo
Definition: udp_bridge_multi_receiver_component.h:43
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: bridge_header.h:33
std::shared_ptr< ProtoDiserializedBufBase > CreateBridgeProtoBuf(const BridgeHeader &header)
The class of MonitorLogBuffer.
bool IsProtoExist(const BridgeHeader &header)
This class help collect MonitorMessage pb to monitor topic. The messages can be published automatical...
Definition: monitor_log_buffer.h:60
The Component can process up to four channels of messages. The message type is specified when the com...
Definition: component.h:58
std::string Name() const
Definition: udp_bridge_multi_receiver_component.h:49