aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-14 13:10:00 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-14 13:10:00 +0900
commitb126caef1760902eb863af8ea892c4db9b9663f9 (patch)
treeb70b06dd54bb585ab29d9109e9e608754ef1a0f8
parent3a3f1ddf5c67403d61341034d5d189d13a900474 (diff)
Add policy of switchng accel pedal status to dummy stm
Change-Id: Iea389d3899f2d01430400374ed0ab0f2fe882ec8 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/app.cpp7
-rw-r--r--src/layout_manager/layout.cpp32
-rw-r--r--src/main.cpp2
-rw-r--r--src/policy_manager/policy_manager.cpp13
-rw-r--r--src/policy_manager/zipc/dummy_stm.c34
-rw-r--r--src/policy_manager/zipc/dummy_stm.h25
6 files changed, 97 insertions, 16 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 07aab0b..296ce35 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -386,6 +386,13 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
}
}
+ // Check accelerator pedal state
+ json_object* json_accel_pedal;
+ if (!json_object_object_get_ex(json_out, "accel_pedal", &json_accel_pedal)) {
+ reply("Not found key \"accel_pedal\"");
+ return;
+ }
+
// Check car state
json_object* json_car;
if (!json_object_object_get_ex(json_out, "car", &json_car)) {
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;
diff --git a/src/main.cpp b/src/main.cpp
index 99e7a7c..762981f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -690,7 +690,6 @@ void on_event(const char *event, struct json_object *object){
// Get parking brake state
const char* accel_pedal_state = g_afb_instance->lcc_.getCurrentAccelPedalState();
-#if 0 // TODO: PolicyManager can not use accelerator pedal state
// Allocate window resource
g_afb_instance->app.allocateWindowResource(accel_pedal_state, nullptr,
nullptr, nullptr,
@@ -699,7 +698,6 @@ void on_event(const char *event, struct json_object *object){
HMI_ERROR("wm", errmsg);
}
});
-#endif
}
else if (g_afb_instance->lcc_.isChangedCarState()) {
// If car state is changed
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index 20c1e79..a40bb48 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -145,6 +145,19 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) {
stm::gStmParkingBrakeStateNo2Name[crr_state.parking_brake.state],
json_out);
+ // "accel_pedal": {
+ // "is_changed": <bool>,
+ // "state": <const char*>
+ // },
+ HMI_DEBUG("wm", "accelerator pedal state (is_changed:%d state:%d:%s)",
+ crr_state.accel_pedal.is_changed,
+ crr_state.accel_pedal.state,
+ stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state]);
+ this->addStateToJson("accel_pedal",
+ crr_state.accel_pedal.is_changed,
+ stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state],
+ json_out);
+
// "car": {
// "is_changed": <bool>,
// "state": <const char*>
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c
index 0246141..f174866 100644
--- a/src/policy_manager/zipc/dummy_stm.c
+++ b/src/policy_manager/zipc/dummy_stm.c
@@ -6,6 +6,8 @@ const char* gStmEventName[] = {
"deactivate",
"parking_brake_off",
"parking_brake_on",
+ "accel_pedal_off",
+ "accel_pedal_on",
"car_stop",
"car_run",
"timer_expired",
@@ -18,6 +20,8 @@ const int gStmEventNo[] = {
STM_EVT_NO_DEACTIVATE,
STM_EVT_NO_PARKING_BRAKE_OFF,
STM_EVT_NO_PARKING_BRAKE_ON,
+ STM_EVT_NO_ACCEL_PEDAL_OFF,
+ STM_EVT_NO_ACCEL_PEDAL_ON,
STM_EVT_NO_CAR_STOP,
STM_EVT_NO_CAR_RUN,
STM_EVT_NO_TIMER_EXPIRED,
@@ -73,6 +77,11 @@ const char* gStmParkingBrakeStateNo2Name[] = {
"parking_brake_on"
};
+const char* gStmAccelPedalStateNo2Name[] = {
+ "accel_pedal_off",
+ "accel_pedal_on"
+};
+
const char* gStmCarStateNo2Name[] = {
"car_stop",
"car_run"
@@ -112,6 +121,7 @@ void stmInitialize() {
g_prv_state.layer.apps.state = gStmLayoutNoNone;
g_prv_state.layer.homescreen.state = gStmLayoutNoNone;
g_prv_state.parking_brake.state = gStmParkingBrakeStateNoOn;
+ g_prv_state.accel_pedal.state = gStmAccelPedalStateNoOff;
g_prv_state.car.state = gStmCarStateNoStop;
g_prv_state.lamp.state = gStmLampStateNoOff;
@@ -121,7 +131,8 @@ void stmInitialize() {
int stmTransitionState(int event, stm_state_t* state) {
int event_no, category_no, area_no;
- int restriction_state, apps_state, parking_brake_state, car_state, lamp_state;
+ int restriction_state, apps_state;
+ int parking_brake_state, accel_pedal_state, car_state, lamp_state;
event_no = event & STM_MSK_EVT_NO;
category_no = event & STM_MSK_CTG_NO;
@@ -134,6 +145,7 @@ int stmTransitionState(int event, stm_state_t* state) {
restriction_state = g_prv_state.layer.restriction.state;
apps_state = g_prv_state.layer.apps.state;
parking_brake_state = g_prv_state.parking_brake.state;
+ accel_pedal_state = g_prv_state.accel_pedal.state;
car_state = g_prv_state.car.state;
lamp_state = g_prv_state.lamp.state;
@@ -143,6 +155,7 @@ int stmTransitionState(int event, stm_state_t* state) {
g_crr_state.layer.apps.is_changed = STM_FALSE;
g_crr_state.layer.homescreen.is_changed = STM_FALSE;
g_crr_state.parking_brake.is_changed = STM_FALSE;
+ g_crr_state.accel_pedal.is_changed = STM_FALSE;
g_crr_state.car.is_changed = STM_FALSE;
g_crr_state.lamp.is_changed = STM_FALSE;
@@ -364,6 +377,25 @@ int stmTransitionState(int event, stm_state_t* state) {
g_crr_state.parking_brake.is_changed = STM_TRUE;
}
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;
+ }
+ break;
case STM_EVT_NO_CAR_STOP:
if (gStmCarStateNoStop != car_state) {
g_crr_state.layer.apps.state = g_prv_apps_state_car_stop;
diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h
index 38d3912..4c71ac7 100644
--- a/src/policy_manager/zipc/dummy_stm.h
+++ b/src/policy_manager/zipc/dummy_stm.h
@@ -28,11 +28,13 @@
#define STM_EVT_NO_DEACTIVATE 0x02
#define STM_EVT_NO_PARKING_BRAKE_OFF 0x03
#define STM_EVT_NO_PARKING_BRAKE_ON 0x04
-#define STM_EVT_NO_CAR_STOP 0x05
-#define STM_EVT_NO_CAR_RUN 0x06
-#define STM_EVT_NO_TIMER_EXPIRED 0x07
-#define STM_EVT_NO_LAMP_OFF 0x08
-#define STM_EVT_NO_LAMP_ON 0x09
+#define STM_EVT_NO_ACCEL_PEDAL_OFF 0x05
+#define STM_EVT_NO_ACCEL_PEDAL_ON 0x06
+#define STM_EVT_NO_CAR_STOP 0x07
+#define STM_EVT_NO_CAR_RUN 0x08
+#define STM_EVT_NO_TIMER_EXPIRED 0x09
+#define STM_EVT_NO_LAMP_OFF 0x0A
+#define STM_EVT_NO_LAMP_ON 0x0B
// Category number
#define STM_CTG_NO_HOMESCREEN 0x0100
@@ -59,9 +61,9 @@
#define STM_MSK_ARA_NO 0xFF0000
// Number of events, categories and areas
-#define STM_NUM_EVT 9
-#define STM_NUM_CTG 7
-#define STM_NUM_ARA 8
+#define STM_NUM_EVT 11
+#define STM_NUM_CTG 7
+#define STM_NUM_ARA 8
// Enum for state
enum stm_parking_brake_state_ {
@@ -69,6 +71,11 @@ enum stm_parking_brake_state_ {
gStmParkingBrakeStateNoOn
};
+enum stm_accel_pedal_state_ {
+ gStmAccelPedalStateNoOff = 0,
+ gStmAccelPedalStateNoOn
+};
+
enum stm_car_state_ {
gStmCarStateNoStop = 0,
gStmCarStateNoRun
@@ -105,6 +112,7 @@ extern const int gStmAreaNo[];
// String for state
extern const char* gStmParkingBrakeStateNo2Name[];
+extern const char* gStmAccelPedalStateNo2Name[];
extern const char* gStmCarStateNo2Name[];
extern const char* gStmLampStateNo2Name[];
extern const char* gStmLayoutNo2Name[];
@@ -124,6 +132,7 @@ typedef struct stm_layer_state_ {
typedef struct {
stm_base_state parking_brake;
+ stm_base_state accel_pedal;
stm_base_state car;
stm_base_state lamp;
stm_layer_state layer;