From 8e6442b3cda80ec0e71925dc060a79d8482dc5af Mon Sep 17 00:00:00 2001 From: Aaron Xiao Date: Wed, 25 Oct 2017 16:28:39 -0700 Subject: [PATCH] Dreamview: Reuse monitor::HardwareStatus in HMIStatus. (#851) --- modules/dreamview/backend/hmi/hmi_status_helper.cc | 5 +++-- modules/dreamview/backend/hmi/hmi_status_helper.h | 12 +++++++----- modules/dreamview/proto/BUILD | 3 +++ modules/dreamview/proto/hmi_status.proto | 9 +++------ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/dreamview/backend/hmi/hmi_status_helper.cc b/modules/dreamview/backend/hmi/hmi_status_helper.cc index aacd73290b..ba86e1fda4 100644 --- a/modules/dreamview/backend/hmi/hmi_status_helper.cc +++ b/modules/dreamview/backend/hmi/hmi_status_helper.cc @@ -22,9 +22,10 @@ namespace apollo { namespace dreamview { void HMIStatusHelper::ReportHardwareStatus( - const google::protobuf::Map &hw_status) { + const std::string &hardware_name, + const monitor::HardwareStatus &hw_status) { HMIStatus hmi_status; - *hmi_status.mutable_hardware() = hw_status; + hmi_status.mutable_hardware()->insert({hardware_name, hw_status}); common::adapter::AdapterManager::PublishHMIStatus(hmi_status); } diff --git a/modules/dreamview/backend/hmi/hmi_status_helper.h b/modules/dreamview/backend/hmi/hmi_status_helper.h index e8e22179dd..569e226d97 100644 --- a/modules/dreamview/backend/hmi/hmi_status_helper.h +++ b/modules/dreamview/backend/hmi/hmi_status_helper.h @@ -20,6 +20,7 @@ #include #include "modules/dreamview/proto/hmi_status.pb.h" +#include "modules/monitor/proto/hardware_status.pb.h" /** * @namespace apollo::dreamview @@ -38,15 +39,16 @@ class HMIStatusHelper { public: /* * @brief Report hardware status to HMI. - * @param hw_status the map of hardware name and hardware status entries. + * @param hardware_name the name of the hardware. + * @param hw_status the status of the hardware. */ - static void ReportHardwareStatus( - const google::protobuf::Map &hw_status); + static void ReportHardwareStatus(const std::string &hardware_name, + const monitor::HardwareStatus &hw_status); /* * @brief Report module status to HMI. - * @param module_status the status of the module - * @param module_status the status of the module + * @param module_name the name of the module. + * @param module_status the status of the module. */ static void ReportModuleStatus(const std::string &module_name, const ModuleStatus &module_status); diff --git a/modules/dreamview/proto/BUILD b/modules/dreamview/proto/BUILD index ae75b97f81..420fa18280 100644 --- a/modules/dreamview/proto/BUILD +++ b/modules/dreamview/proto/BUILD @@ -38,4 +38,7 @@ cc_proto_library( proto_library( name = "hmi_status_proto_lib", srcs = ["hmi_status.proto"], + deps = [ + "//modules/monitor/proto:hardware_status_proto_lib", + ] ) diff --git a/modules/dreamview/proto/hmi_status.proto b/modules/dreamview/proto/hmi_status.proto index f9e32cc3ab..761c921adf 100644 --- a/modules/dreamview/proto/hmi_status.proto +++ b/modules/dreamview/proto/hmi_status.proto @@ -2,6 +2,8 @@ syntax = "proto2"; package apollo.dreamview; +import "modules/monitor/proto/hardware_status.proto"; + message ModuleStatus { enum Status { UNINITIALIZED = 0; @@ -13,14 +15,9 @@ message ModuleStatus { optional Status status = 1 [default = UNINITIALIZED]; } -message HardwareStatus { - // Defined in modules/monitor/common/interface/hw_status.h. - optional int32 status = 1 [default = -1]; -} - message HMIStatus { optional string current_map = 1; optional string current_vehicle = 2; map modules = 3; - map hardware = 4; + map hardware = 4; } -- GitLab