Apollo 10.0
自动驾驶开放平台
hmi.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
17#pragma once
18
19#include <memory>
20#include <string>
21
27
32namespace apollo {
33namespace dreamview {
34
35class HMI : public UpdaterBase {
36 public:
37 using DvCallback = std::function<nlohmann::json(
38 const std::string &function_name, const nlohmann::json &param_json)>;
39 HMI(WebSocketHandler *websocket, MapService *map_service,
40 WebSocketHandler *hmi_websocket);
41 void Start(DvCallback callback_api);
42 void StartStream(const double &time_interval_ms,
43 const std::string &channel_name = "",
44 nlohmann::json *subscribe_param = nullptr) override;
45 void PublishMessage(const std::string &channel_name = "") override;
46 void Stop();
47 void StopStream(const std::string &channel_name = "") override;
48 void OnTimer(const std::string &channel_name = "");
49 bool UpdateDynamicModelToStatus(const std::string &dynamic_model_name);
50 bool UpdateMapToStatus(const std::string &map_name = "");
53 bool UpdateCameraChannelToStatus(const std::string &channel_name);
54 bool UpdatePointChannelToStatus(const std::string &channel_name);
55 bool isProcessRunning(const std::string &process_name);
56
57 private:
58 // Send VehicleParam to the given conn, or broadcast if conn is null.
59 void SendVehicleParam(WebSocketHandler::Connection *conn = nullptr);
60 // void SendStatus(WebSocketHandler::Connection *conn = nullptr);
61
62 void RegisterMessageHandlers();
63 void RegisterDBMessageHandlers();
64 void RegisterFrontendConfMessageHandlers();
65
67 std::unique_ptr<HMIWorker> hmi_worker_;
68
69 // No ownership.
70 WebSocketHandler *websocket_;
71 MapService *map_service_;
72 WebSocketHandler *hmi_ws_;
73 double time_interval_ms_;
74 std::unique_ptr<cyber::Timer> timer_;
75};
76
77} // namespace dreamview
78} // namespace apollo
void StopStream(const std::string &channel_name="") override
Stop data flow.
Definition hmi.cc:75
void OnTimer(const std::string &channel_name="")
Definition hmi.cc:805
void StartStream(const double &time_interval_ms, const std::string &channel_name="", nlohmann::json *subscribe_param=nullptr) override
Start data flow.
Definition hmi.cc:56
bool UpdateMapToStatus(const std::string &map_name="")
Definition hmi.cc:825
std::function< nlohmann::json(const std::string &function_name, const nlohmann::json &param_json)> DvCallback
Definition hmi.h:37
bool UpdateDynamicModelToStatus(const std::string &dynamic_model_name)
bool UpdatePointChannelToStatus(const std::string &channel_name)
bool UpdateCameraChannelToStatus(const std::string &channel_name)
void PublishMessage(const std::string &channel_name="") override
Publish Message to dreamview frontend.
Definition hmi.cc:807
bool isProcessRunning(const std::string &process_name)
Definition hmi.cc:843
void Start(DvCallback callback_api)
The WebSocketHandler, built on top of CivetWebSocketHandler, is a websocket handler that handles diff...
The class of MonitorLogBuffer
class register implement
Definition arena_queue.h:37