PolicyManager can judge the current car state
[apps/agl-service-windowmanager.git] / src / policy_manager / zipc / dummy_stm.c
index f174866..968b086 100644 (file)
@@ -8,8 +8,6 @@ const char* gStmEventName[] = {
     "parking_brake_on",
     "accel_pedal_off",
     "accel_pedal_on",
-    "car_stop",
-    "car_run",
     "timer_expired",
     "lamp_off",
     "lamp_on"
@@ -22,8 +20,6 @@ const int gStmEventNo[] = {
     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
@@ -110,6 +106,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,42 +376,16 @@ 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;
         }
         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;
@@ -432,6 +403,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));