aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-14 17:04:28 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-14 17:04:28 +0900
commit701f1ff00b3b6cf5f5a50b4cf3f65e176cb26460 (patch)
tree0a5978ce85085f52357531cb5438d3ec1f47afe2
parentb126caef1760902eb863af8ea892c4db9b9663f9 (diff)
Change the policy of switchng car run/stop in dummy stm
Change-Id: Ie3770060828f32749e7c47076d901263454e43c2 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/layout_manager/layout.cpp27
-rw-r--r--src/policy_manager/zipc/dummy_stm.c46
2 files changed, 42 insertions, 31 deletions
diff --git a/src/layout_manager/layout.cpp b/src/layout_manager/layout.cpp
index e469e30..6bec42d 100644
--- a/src/layout_manager/layout.cpp
+++ b/src/layout_manager/layout.cpp
@@ -69,21 +69,6 @@ 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)) {
@@ -127,11 +112,8 @@ 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))
- || ((is_accel_pedal_state_changed)
- && ("accel_pedal_on" == accel_pedal_state))) {
+ if ((is_car_state_changed) && ("car_run" == car_state)) {
HMI_DEBUG("wm:lm", "Store current state for state of car stop");
this->prv_layers_car_stop_[layer] = this->crr_layers_[layer];
}
@@ -157,11 +139,8 @@ 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))
- || ((is_accel_pedal_state_changed)
- && ("accel_pedal_off" == accel_pedal_state))) {
+ if ((is_car_state_changed) && ("car_stop" == car_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];
@@ -188,7 +167,7 @@ bool LayoutManager::updateLayout(json_object* obj,
}
// Update role in new area
- if (is_car_state_changed || is_accel_pedal_state_changed) {
+ if (is_car_state_changed) {
// Updating role is not necessary
// because new_role is not specified
// when car or accel pedal state is changed
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c
index f174866..d695486 100644
--- a/src/policy_manager/zipc/dummy_stm.c
+++ b/src/policy_manager/zipc/dummy_stm.c
@@ -110,6 +110,7 @@ const char* gStmLayoutNo2Name[] = {
stm_state_t g_crr_state;
stm_state_t g_prv_state;
+int g_prv_restriction_state_car_stop = 0;
int g_prv_apps_state_car_stop = 0;
void stmInitialize() {
@@ -379,19 +380,12 @@ int stmTransitionState(int event, stm_state_t* state) {
break;
case STM_EVT_NO_ACCEL_PEDAL_OFF:
if (gStmAccelPedalStateNoOff != accel_pedal_state) {
- g_crr_state.layer.apps.state = g_prv_apps_state_car_stop;
- g_crr_state.layer.apps.is_changed = STM_TRUE;
-
g_crr_state.accel_pedal.state = gStmAccelPedalStateNoOff;
g_crr_state.accel_pedal.is_changed = STM_TRUE;
}
break;
case STM_EVT_NO_ACCEL_PEDAL_ON:
if (gStmAccelPedalStateNoOn != accel_pedal_state) {
- g_prv_apps_state_car_stop = apps_state;
- g_crr_state.layer.apps.state = gStmLayoutNoM1;
- g_crr_state.layer.apps.is_changed = STM_TRUE;
-
g_crr_state.accel_pedal.state = gStmAccelPedalStateNoOn;
g_crr_state.accel_pedal.is_changed = STM_TRUE;
}
@@ -432,6 +426,44 @@ int stmTransitionState(int event, stm_state_t* state) {
break;
}
+ // Set car state
+ if (g_crr_state.parking_brake.is_changed
+ || g_crr_state.accel_pedal.is_changed) {
+ if ((gStmParkingBrakeStateNoOff == g_crr_state.parking_brake.state)
+ && (gStmAccelPedalStateNoOn == g_crr_state.accel_pedal.state)){
+ if (gStmCarStateNoRun != car_state) {
+ // Car state is changed stop -> run
+ g_crr_state.car.state = gStmCarStateNoRun;
+ g_crr_state.car.is_changed = STM_TRUE;
+
+ // Update restriction layer
+ g_prv_restriction_state_car_stop = restriction_state;
+ g_crr_state.layer.restriction.state = gStmLayoutNoNone;
+ g_crr_state.layer.restriction.is_changed = STM_TRUE;
+
+ // Update apps layer
+ g_prv_apps_state_car_stop = apps_state;
+ g_crr_state.layer.apps.state = gStmLayoutNoM1;
+ g_crr_state.layer.apps.is_changed = STM_TRUE;
+ }
+ }
+ else {
+ if (gStmCarStateNoStop != car_state) {
+ // Car state is changed run -> stop
+ g_crr_state.car.state = gStmCarStateNoStop;
+ g_crr_state.car.is_changed = STM_TRUE;
+
+ // Update restriction layer
+ g_crr_state.layer.restriction.state = g_prv_restriction_state_car_stop;
+ g_crr_state.layer.restriction.is_changed = STM_TRUE;
+
+ // Update apps layer
+ g_crr_state.layer.apps.state = g_prv_apps_state_car_stop;
+ g_crr_state.layer.apps.is_changed = STM_TRUE;
+ }
+ }
+ }
+
// Copy current state for return
memcpy(state, &g_crr_state, sizeof(g_crr_state));