From c94a3cfb7d0dfc606c96c3cf08a5674b6e7ca1da Mon Sep 17 00:00:00 2001 From: "Iryna Lytvynenko (GitHub)" Date: Wed, 4 Aug 2021 22:28:33 +0300 Subject: Feature/sdl 0236 tire status mismatch (#3583) * Temporary commit with link to rpc_spec fork * Indicate that the structure is included in the Common interface * Mark the parameters as non mandatory * Update link to rpc_spec fork * Fix Message Helper linkage to VehicleInfoPlugin * Fix versioning for TirePressure param * Bump version up to 8.0 * Add link to rpc_spec fork * Address review comments Co-authored-by: Dmitriy Boltovskiy Co-authored-by: Yana Chernysheva Co-authored-by: Andrii Kalinich --- src/appMain/sdl_preloaded_pt.json | 221 ++++++++++++++++++++- .../include/application_manager/message_helper.h | 11 + .../application_manager/smart_object_keys.h | 7 + .../rpc_plugins/vehicle_info_plugin/CMakeLists.txt | 2 +- .../commands/mobile/get_vehicle_data_request.cc | 6 + .../mobile/on_vehicle_data_notification.cc | 10 +- .../vehicle_info_plugin/test/CMakeLists.txt | 2 +- .../src/message_helper/message_helper.cc | 39 ++++ .../application_manager/src/smart_object_keys.cc | 7 + .../application_manager/mock_message_helper.h | 4 + .../test/mock_message_helper.cc | 7 + 11 files changed, 305 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 50bbce6a97..e018a597f7 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -3616,7 +3616,16 @@ "name": "pressureTelltale", "key": "OEM_REF_PRES_TEL", "type": "WarningLightStatus", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "pressureTelltale", + "key": "OEM_REF_PRES_TEL", + "type": "WarningLightStatus", + "mandatory": false, + "since": "8.0" }, { "name": "leftFront", @@ -3646,7 +3655,40 @@ ], "key": "OEM_REF_LEFT_FR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "leftFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_FR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "rightFront", @@ -3676,7 +3718,40 @@ ], "key": "OEM_REF_RIGHT_FR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "rightFront", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_FR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_FR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_FR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_FR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "leftRear", @@ -3706,7 +3781,40 @@ ], "key": "OEM_REF_LEFT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "leftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_LEFT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "rightRear", @@ -3736,7 +3844,40 @@ ], "key": "OEM_REF_RIGHT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "rightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_RIGHT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "innerLeftRear", @@ -3766,7 +3907,40 @@ ], "key": "OEM_REF_IN_LEFT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "innerLeftRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_LEFT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_LEFT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_LEFT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_LEFT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" }, { "name": "innerRightRear", @@ -3796,7 +3970,40 @@ ], "key": "OEM_REF_IN_RIGHT_REAR", "type": "Struct", - "mandatory": true + "mandatory": true, + "since": "2.0", + "until": "8.0" + }, + { + "name": "innerRightRear", + "params": [ + { + "name": "status", + "key": "OEM_REF_IN_RIGHT_REAR_ST", + "type": "ComponentVolumeStatus", + "mandatory": true + }, + { + "name": "tpms", + "key": "OEM_REF_IN_RIGHT_REAR_TMPS", + "type": "TPMS", + "mandatory": false, + "since": "5.0" + }, + { + "name": "pressure", + "key": "OEM_REF_IN_RIGHT_REAR_PRES", + "type": "Float", + "mandatory": false, + "minvalue": 0, + "maxvalue": 2000, + "since": "5.0" + } + ], + "key": "OEM_REF_IN_RIGHT_REAR", + "type": "Struct", + "mandatory": false, + "since": "8.0" } ], "key": "OEM_REF_TIRE_PRES", diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index 4aea48c086..2adef91c2e 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -1113,6 +1113,17 @@ class MessageHelper { ApplicationManager& app_mngr, const WindowID window_id); + /** + * @brief AddDefaultParamsToTireStatus adds missing default sub-params to + * tirePressure param, if version of related application requires presence of + * all sub-params in response + * @param application shared pointer to related application + * @param response_from_hmi reference to response from HMI + */ + static void AddDefaultParamsToTireStatus( + ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi); + private: /** * @brief Allows to fill SO according to the current permissions. diff --git a/src/components/application_manager/include/application_manager/smart_object_keys.h b/src/components/application_manager/include/application_manager/smart_object_keys.h index 5572dfd55d..5a79059f1f 100644 --- a/src/components/application_manager/include/application_manager/smart_object_keys.h +++ b/src/components/application_manager/include/application_manager/smart_object_keys.h @@ -308,6 +308,13 @@ extern const char* vin; extern const char* gearStatus; extern const char* prndl; extern const char* tire_pressure; +extern const char* pressure_telltale; +extern const char* left_front; +extern const char* right_front; +extern const char* left_rear; +extern const char* right_rear; +extern const char* inner_left_rear; +extern const char* inner_right_rear; extern const char* odometer; extern const char* belt_status; extern const char* electronic_park_brake_status; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt index a741c32129..e858967619 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/CMakeLists.txt @@ -45,7 +45,6 @@ collect_sources(VEHICLE_INFO_PLUGIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src") set(LIBRARIES HMI_API MOBILE_API - MessageHelper ApplicationManager v4_protocol_v1_2_no_extra SmartObjects @@ -63,6 +62,7 @@ target_link_libraries("vehicle_info_plugin_static" ${LIBRARIES}) add_library(vehicle_info_plugin SHARED "src/vehicle_info_plugin.cc" ) target_link_libraries(vehicle_info_plugin vehicle_info_plugin_static) +target_link_libraries(vehicle_info_plugin MessageHelper) set(INSTALL_DESTINATION bin) diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc index 17a450ca89..18149fbe02 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/get_vehicle_data_request.cc @@ -126,6 +126,12 @@ void GetVehicleDataRequest::on_event(const event_engine::Event& event) { std::string response_info; GetInfo(message, response_info); + if (message[strings::msg_params].keyExists(strings::tire_pressure)) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + MessageHelper::AddDefaultParamsToTireStatus(app, message); + } + auto data_not_available_with_params = [this, &result_code, &message]() { if (hmi_apis::Common_Result::DATA_NOT_AVAILABLE != result_code) { return false; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc index e062728217..0ae38a9398 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/on_vehicle_data_notification.cc @@ -89,16 +89,22 @@ void OnVehicleDataNotification::Run() { SDL_LOG_ERROR("NULL pointer"); continue; } + + smart_objects::SmartObject output_message = *message_; + if (strings::tire_pressure == name) { + MessageHelper::AddDefaultParamsToTireStatus(app, output_message); + } + notified_app_it = find(notify_apps.begin(), notify_apps.end(), app); if (notified_app_it == notify_apps.end()) { notify_apps.push_back(app); smart_objects::SmartObject msg_param = smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_param[name] = (*message_)[strings::msg_params][name]; + msg_param[name] = output_message[strings::msg_params][name]; appSO.push_back(msg_param); } else { size_t idx = std::distance(notify_apps.begin(), notified_app_it); - appSO[idx][name] = (*message_)[strings::msg_params][name]; + appSO[idx][name] = output_message[strings::msg_params][name]; } } } diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt index c9697d71f2..1073974324 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/test/CMakeLists.txt @@ -64,7 +64,7 @@ set(LIBRARIES HMI_API MOBILE_API connectionHandler - vehicle_info_plugin + vehicle_info_plugin_static SmartObjects formatters jsoncpp diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 6dbb7b35ae..dde580adeb 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -62,6 +62,7 @@ #include "utils/file_system.h" #include "utils/logger.h" #include "utils/macro.h" +#include "utils/semantic_version.h" #include "formatters/CFormatterJsonBase.h" #include "formatters/CFormatterJsonSDLRPCv1.h" @@ -3483,4 +3484,42 @@ WindowID MessageHelper::ExtractWindowIdFromSmartObject( return mobile_apis::PredefinedWindows::DEFAULT_WINDOW; } +void MessageHelper::AddDefaultParamsToTireStatus( + ApplicationSharedPtr app, smart_objects::SmartObject& response_from_hmi) { + const utils::SemanticVersion max_version_with_mandatory_params(8, 0, 0); + + if (!app) { + SDL_LOG_ERROR("Application not found"); + return; + } + + if (app->msg_version() >= max_version_with_mandatory_params) { + SDL_LOG_DEBUG( + "Tire status parameters are " + "non-mandatory for this app version, no need in default values"); + return; + } + + smart_objects::SmartObject& tire_status = + response_from_hmi[strings::msg_params][strings::tire_pressure]; + + if (!tire_status.keyExists(strings::pressure_telltale)) { + tire_status[strings::pressure_telltale] = + mobile_apis::WarningLightStatus::WLS_NOT_USED; + } + + const std::vector tires{strings::left_front, + strings::right_front, + strings::left_rear, + strings::right_rear, + strings::inner_left_rear, + strings::inner_right_rear}; + for (const std::string& tire : tires) { + if (!tire_status.keyExists(tire)) { + tire_status[tire][strings::status] = + mobile_apis::ComponentVolumeStatus::CVS_UNKNOWN; + } + } +} + } // namespace application_manager diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index a680653d6c..b7c40987ad 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -275,6 +275,13 @@ const char* vin = "vin"; const char* gearStatus = "gearStatus"; const char* prndl = "prndl"; const char* tire_pressure = "tirePressure"; +const char* pressure_telltale = "pressureTelltale"; +const char* left_front = "leftFront"; +const char* right_front = "rightFront"; +const char* left_rear = "leftRear"; +const char* right_rear = "rightRear"; +const char* inner_left_rear = "innerLeftRear"; +const char* inner_right_rear = "innerRightRear"; const char* odometer = "odometer"; const char* belt_status = "beltStatus"; const char* electronic_park_brake_status = "electronicParkBrakeStatus"; diff --git a/src/components/application_manager/test/include/application_manager/mock_message_helper.h b/src/components/application_manager/test/include/application_manager/mock_message_helper.h index dd84ce4c40..82a0574c7f 100644 --- a/src/components/application_manager/test/include/application_manager/mock_message_helper.h +++ b/src/components/application_manager/test/include/application_manager/mock_message_helper.h @@ -394,6 +394,10 @@ class MockMessageHelper { application_manager::ApplicationManager& app_mngr, const application_manager::WindowID window_id)); + MOCK_METHOD2(AddDefaultParamsToTireStatus, + void(application_manager::ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi)); + static MockMessageHelper* message_helper_mock(); }; diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index f96a0eca5c..3cab2be0fb 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -689,4 +689,11 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateResponseMessageFromHmi( return MockMessageHelper::message_helper_mock()->CreateResponseMessageFromHmi( function_id, correlation_id, result_code); } + +void MessageHelper::AddDefaultParamsToTireStatus( + application_manager::ApplicationSharedPtr application, + smart_objects::SmartObject& response_from_hmi) { + return MockMessageHelper::message_helper_mock()->AddDefaultParamsToTireStatus( + application, response_from_hmi); +} } // namespace application_manager -- cgit v1.2.1