}
}
+ // 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)) {
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)) {
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];
}
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];
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;
// 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,
HMI_ERROR("wm", errmsg);
}
});
-#endif
}
else if (g_afb_instance->lcc_.isChangedCarState()) {
// If car state is changed
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*>
"deactivate",
"parking_brake_off",
"parking_brake_on",
+ "accel_pedal_off",
+ "accel_pedal_on",
"car_stop",
"car_run",
"timer_expired",
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,
"parking_brake_on"
};
+const char* gStmAccelPedalStateNo2Name[] = {
+ "accel_pedal_off",
+ "accel_pedal_on"
+};
+
const char* gStmCarStateNo2Name[] = {
"car_stop",
"car_run"
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;
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;
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;
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;
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;
#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
#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_ {
gStmParkingBrakeStateNoOn
};
+enum stm_accel_pedal_state_ {
+ gStmAccelPedalStateNoOff = 0,
+ gStmAccelPedalStateNoOn
+};
+
enum stm_car_state_ {
gStmCarStateNoStop = 0,
gStmCarStateNoRun
// String for state
extern const char* gStmParkingBrakeStateNo2Name[];
+extern const char* gStmAccelPedalStateNo2Name[];
extern const char* gStmCarStateNo2Name[];
extern const char* gStmLampStateNo2Name[];
extern const char* gStmLayoutNo2Name[];
typedef struct {
stm_base_state parking_brake;
+ stm_base_state accel_pedal;
stm_base_state car;
stm_base_state lamp;
stm_layer_state layer;