From b126caef1760902eb863af8ea892c4db9b9663f9 Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Mon, 14 May 2018 13:10:00 +0900 Subject: Add policy of switchng accel pedal status to dummy stm Change-Id: Iea389d3899f2d01430400374ed0ab0f2fe882ec8 Signed-off-by: Yuta Doi --- src/layout_manager/layout.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/layout_manager/layout.cpp') diff --git a/src/layout_manager/layout.cpp b/src/layout_manager/layout.cpp index faab316..e469e30 100644 --- a/src/layout_manager/layout.cpp +++ b/src/layout_manager/layout.cpp @@ -69,6 +69,21 @@ bool LayoutManager::updateLayout(json_object* obj, bool ret = false; + // Check accelerator pedal state change + json_object* json_accel_pedal; + if (!json_object_object_get_ex(obj, "accel_pedal", &json_accel_pedal)) { + HMI_ERROR("wm:lm", "Parse Error!!"); + return -1; + } + + json_bool is_accel_pedal_state_changed; + std::string accel_pedal_state = ""; + is_accel_pedal_state_changed = jh::getBoolFromJson(json_accel_pedal, "is_changed"); + if (is_accel_pedal_state_changed) { + // If car state is changed, get car state + accel_pedal_state = jh::getStringFromJson(json_accel_pedal, "state"); + } + // Check car state change json_object* json_car; if (!json_object_object_get_ex(obj, "car", &json_car)) { @@ -112,8 +127,11 @@ bool LayoutManager::updateLayout(json_object* obj, std::string prv_layout_name = this->prv_layers_[layer].begin()->first; // If car state is changed car_stop -> car_run, + // OR accel pedal state is changed accel_pedal_off -> accel_pedal_on, // store current state for state of car stop - if ((is_car_state_changed) && ("car_run" == car_state)) { + if (((is_car_state_changed) && ("car_run" == car_state)) + || ((is_accel_pedal_state_changed) + && ("accel_pedal_on" == accel_pedal_state))) { HMI_DEBUG("wm:lm", "Store current state for state of car stop"); this->prv_layers_car_stop_[layer] = this->crr_layers_[layer]; } @@ -139,8 +157,11 @@ bool LayoutManager::updateLayout(json_object* obj, HMI_DEBUG("wm:lm", "crr state: %s", crr_layout_name); TypeLayouts crr_layout; - if ((is_car_state_changed) && ("car_stop" == car_state)) { + if (((is_car_state_changed) && ("car_stop" == car_state)) + || ((is_accel_pedal_state_changed) + && ("accel_pedal_off" == accel_pedal_state))) { // If car state is changed car_run -> car_stop, + // OR accel pedal state is changed accel_pedal_on -> accel_pedal_off, // restore state of car stop HMI_DEBUG("wm:lm", "Restore state of car stop"); crr_layout = this->prv_layers_car_stop_[layer]; @@ -166,16 +187,17 @@ bool LayoutManager::updateLayout(json_object* obj, crr_layout[crr_layout_name] = this->layout_define_[crr_layout_name]; } - if (is_car_state_changed) { + // Update role in new area + if (is_car_state_changed || is_accel_pedal_state_changed) { // Updating role is not necessary - // because new_role is not specified when car state is changed + // because new_role is not specified + // when car or accel pedal state is changed } else { // Get new_area for new role std::string new_area = this->getAreaName(this->layout_define_[crr_layout_name], new_role, category); - // Update role in new area TypeRolCtg crr_role; crr_role["role"] = std::string(new_role); crr_layout[crr_layout_name][new_area] = crr_role; -- cgit 1.2.3-korg