"parking_brake_on",
"accel_pedal_off",
"accel_pedal_on",
- "car_stop",
- "car_run",
"timer_expired",
"lamp_off",
"lamp_on"
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,
STM_EVT_NO_LAMP_OFF,
STM_EVT_NO_LAMP_ON
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() {
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;
- g_crr_state.layer.apps.is_changed = STM_TRUE;
-
- g_crr_state.car.state = gStmCarStateNoStop;
- g_crr_state.car.is_changed = STM_TRUE;
- }
- break;
- case STM_EVT_NO_CAR_RUN:
- if (gStmCarStateNoRun != car_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.car.state = gStmCarStateNoRun;
- g_crr_state.car.is_changed = STM_TRUE;
- }
- break;
case STM_EVT_NO_LAMP_OFF:
if (gStmLampStateNoOff != lamp_state) {
g_crr_state.lamp.state = gStmLampStateNoOff;
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));