diff options
Diffstat (limited to 'src/policy_manager/zipc')
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.c | 80 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 167 |
2 files changed, 86 insertions, 161 deletions
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c index 32e18c5..6847e15 100644 --- a/src/policy_manager/zipc/dummy_stm.c +++ b/src/policy_manager/zipc/dummy_stm.c @@ -21,25 +21,6 @@ const char* gStmEventName[] = { "restriction_mode_on", }; -const int gStmEventNo[] = { - STM_EVT_NO_NONE, - STM_EVT_NO_ACTIVATE, - STM_EVT_NO_DEACTIVATE, - STM_EVT_NO_TRANS_GEAR_N, - STM_EVT_NO_TRANS_GEAR_NOT_N, - 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_TIMER_EXPIRED, - STM_EVT_NO_LAMP_OFF, - STM_EVT_NO_LAMP_ON, - STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF, - STM_EVT_NO_LIGHTSTATUS_BRAKE_ON, - STM_EVT_NO_RESTRICTION_MODE_OFF, - STM_EVT_NO_RESTRICTION_MODE_ON, -}; - const char* gStmCategoryName[] = { "none", "homescreen", @@ -52,18 +33,6 @@ const char* gStmCategoryName[] = { "system", }; -const int gStmCategoryNo[] = { - STM_CTG_NO_NONE, - STM_CTG_NO_HOMESCREEN, - STM_CTG_NO_MAP, - STM_CTG_NO_GENERAL, - STM_CTG_NO_SPLITABLE, - STM_CTG_NO_POPUP, - STM_CTG_NO_SYSTEM_ALERT, - STM_CTG_NO_RESTRICTION, - STM_CTG_NO_SYSTEM, -}; - const char* gStmAreaName[] = { "none", "fullscreen", @@ -76,18 +45,6 @@ const char* gStmAreaName[] = { "restriction.split.sub", }; -const int gStmAreaNo[] = { - STM_ARA_NO_NONE, - STM_ARA_NO_FULL, - STM_ARA_NO_NORMAL, - STM_ARA_NO_SPLIT_MAIN, - STM_ARA_NO_SPLIT_SUB, - STM_ARA_NO_POP_UP, - STM_ARA_NO_RESTRICTION_NORMAL, - STM_ARA_NO_RESTRICTION_SPLIT_MAIN, - STM_ARA_NO_RESTRICTION_SPLIT_SUB, -}; - // String for state const char* gStmTransGearStateName[] = { "neutral", @@ -200,9 +157,9 @@ int stmTransitionState(int event, stm_state_t* state) { int on_screen_state, restriction_state, apps_state; int trans_gear_state, parking_brake_state, lightstatus_brake_state, accel_pedal_state, car_state, lamp_state, restriction_mode_state; - event_no = event & STM_MSK_EVT_NO; - category_no = event & STM_MSK_CTG_NO; - area_no = event & STM_MSK_ARA_NO; + event_no = GET_EVENT_FROM_ID(event); + category_no = GET_CATEGORY_FROM_ID(event); + area_no = GET_AREA_FROM_ID(event); // Backup previous state g_prv_state = g_crr_state; @@ -394,7 +351,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; case STM_CTG_NO_MAP: switch (area_no) { - case STM_ARA_NO_FULL: + case STM_AREA_NO_FULL: // Apps layer switch (apps_state) { case gStmLayoutNoMapFll: @@ -406,7 +363,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; - case STM_ARA_NO_NORMAL: + case STM_AREA_NO_NORMAL: // Apps layer switch (apps_state) { case gStmLayoutNoMapNml: @@ -421,7 +378,7 @@ int stmTransitionState(int event, stm_state_t* state) { g_crr_state.layer[gStmLayerNoApps].changed = STM_TRUE; } break; - case STM_ARA_NO_SPLIT_MAIN: + case STM_AREA_NO_SPLIT_MAIN: // Apps layer switch (apps_state) { case gStmLayoutNoSplNml: @@ -438,7 +395,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; case STM_CTG_NO_GENERAL: switch (area_no) { - case STM_ARA_NO_NORMAL: + case STM_AREA_NO_NORMAL: // Apps layer switch (apps_state) { case gStmLayoutNoMapFll: @@ -457,7 +414,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; case STM_CTG_NO_SYSTEM: switch (area_no) { - case STM_ARA_NO_NORMAL: + case STM_AREA_NO_NORMAL: // Apps layer switch (apps_state) { case gStmLayoutNoMapFll: @@ -476,7 +433,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; case STM_CTG_NO_SPLITABLE: switch (area_no) { - case STM_ARA_NO_NORMAL: + case STM_AREA_NO_NORMAL: // Apps layer switch (apps_state) { case gStmLayoutNoMapNml: @@ -493,7 +450,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; - case STM_ARA_NO_SPLIT_MAIN: + case STM_AREA_NO_SPLIT_MAIN: // Apps layer switch (apps_state) { case gStmLayoutNoSplNml: @@ -509,7 +466,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; - case STM_ARA_NO_SPLIT_SUB: + case STM_AREA_NO_SPLIT_SUB: // Apps layer switch (apps_state) { case gStmLayoutNoMapNml: @@ -548,9 +505,9 @@ int stmTransitionState(int event, stm_state_t* state) { switch (category_no) { case STM_CTG_NO_MAP: switch (area_no) { - case STM_ARA_NO_FULL: - case STM_ARA_NO_NORMAL: - case STM_ARA_NO_SPLIT_MAIN: + case STM_AREA_NO_FULL: + case STM_AREA_NO_NORMAL: + case STM_AREA_NO_SPLIT_MAIN: // Apps layer switch (apps_state) { case gStmLayoutNoMapNml: @@ -565,7 +522,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; case STM_CTG_NO_SYSTEM: switch (area_no) { - case STM_ARA_NO_NORMAL: + case STM_AREA_NO_NORMAL: // Apps layer switch (apps_state) { case gStmLayoutNoMapFll: @@ -602,7 +559,7 @@ int stmTransitionState(int event, stm_state_t* state) { if (STM_EVT_NO_ACTIVATE == event_no) { if (gStmLightstatusBrakeStateNoOff == g_crr_state.car_element[gStmCarElementNoLightstatusBrake].state) { switch (area_no) { - case STM_ARA_NO_RESTRICTION_NORMAL: + case STM_AREA_NO_RESTRICTION_NORMAL: switch (restriction_state) { case gStmLayoutNoNone: if (g_crr_state.layer[gStmLayerNoApps].state == gStmLayoutNoSplNml) { @@ -619,7 +576,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; - case STM_ARA_NO_RESTRICTION_SPLIT_MAIN: + case STM_AREA_NO_RESTRICTION_SPLIT_MAIN: switch (restriction_state) { case gStmLayoutNoNone: g_crr_state.layer[gStmLayerNoRestriction].state = gStmLayoutNoRstSplMain; @@ -630,7 +587,7 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; - case STM_ARA_NO_RESTRICTION_SPLIT_SUB: + case STM_AREA_NO_RESTRICTION_SPLIT_SUB: switch (restriction_state) { case gStmLayoutNoNone: if (g_crr_state.layer[gStmLayerNoApps].state == gStmLayoutNoMapSpl) { @@ -731,3 +688,4 @@ int stmTransitionState(int event, stm_state_t* state) { void stmUndoState() { g_crr_state = g_prv_state; } + diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h index a994376..a7f3032 100644 --- a/src/policy_manager/zipc/dummy_stm.h +++ b/src/policy_manager/zipc/dummy_stm.h @@ -24,49 +24,77 @@ #define STM_FALSE 0 // Event number -#define STM_EVT_NO_NONE 0x01 -#define STM_EVT_NO_ACTIVATE 0x02 -#define STM_EVT_NO_DEACTIVATE 0x03 -#define STM_EVT_NO_TRANS_GEAR_N 0x04 -#define STM_EVT_NO_TRANS_GEAR_NOT_N 0x05 -#define STM_EVT_NO_PARKING_BRAKE_OFF 0x06 -#define STM_EVT_NO_PARKING_BRAKE_ON 0x07 -#define STM_EVT_NO_ACCEL_PEDAL_OFF 0x08 -#define STM_EVT_NO_ACCEL_PEDAL_ON 0x09 -#define STM_EVT_NO_TIMER_EXPIRED 0x0A -#define STM_EVT_NO_LAMP_OFF 0x0B -#define STM_EVT_NO_LAMP_ON 0x0C -#define STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF 0x0D -#define STM_EVT_NO_LIGHTSTATUS_BRAKE_ON 0x0E -#define STM_EVT_NO_RESTRICTION_MODE_OFF 0x0F -#define STM_EVT_NO_RESTRICTION_MODE_ON 0x10 +enum STM_EVT_NO { + STM_EVT_NO_NONE = 0, + STM_EVT_NO_ACTIVATE, + STM_EVT_NO_DEACTIVATE, + STM_EVT_NO_TRANS_GEAR_N, + STM_EVT_NO_TRANS_GEAR_NOT_N, + 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_TIMER_EXPIRED, + STM_EVT_NO_LAMP_OFF, + STM_EVT_NO_LAMP_ON, + STM_EVT_NO_LIGHTSTATUS_BRAKE_OFF, + STM_EVT_NO_LIGHTSTATUS_BRAKE_ON, + STM_EVT_NO_RESTRICTION_MODE_OFF, + STM_EVT_NO_RESTRICTION_MODE_ON, + + STM_EVT_NO_NUM, + + STM_EVT_NO_MIN = STM_EVT_NO_NONE, + STM_EVT_NO_MAX = STM_EVT_NO_NUM - 1, +}; // Category number -#define STM_CTG_NO_NONE 0x0100 -#define STM_CTG_NO_HOMESCREEN 0x0200 -#define STM_CTG_NO_MAP 0x0300 -#define STM_CTG_NO_GENERAL 0x0400 -#define STM_CTG_NO_SPLITABLE 0x0500 -#define STM_CTG_NO_POPUP 0x0600 -#define STM_CTG_NO_SYSTEM_ALERT 0x0700 -#define STM_CTG_NO_RESTRICTION 0x0800 -#define STM_CTG_NO_SYSTEM 0x0900 +enum STM_CTG_NO { + STM_CTG_NO_NONE = 0, + STM_CTG_NO_HOMESCREEN, + STM_CTG_NO_MAP, + STM_CTG_NO_GENERAL, + STM_CTG_NO_SPLITABLE, + STM_CTG_NO_POPUP, + STM_CTG_NO_SYSTEM_ALERT, + STM_CTG_NO_RESTRICTION, + STM_CTG_NO_SYSTEM, + + STM_CTG_NO_NUM, + + STM_CTG_NO_MIN = STM_CTG_NO_NONE, + STM_CTG_NO_MAX = STM_CTG_NO_NUM - 1, +}; // Area number -#define STM_ARA_NO_NONE 0x010000 -#define STM_ARA_NO_FULL 0x020000 -#define STM_ARA_NO_NORMAL 0x030000 -#define STM_ARA_NO_SPLIT_MAIN 0x040000 -#define STM_ARA_NO_SPLIT_SUB 0x050000 -#define STM_ARA_NO_POP_UP 0x060000 -#define STM_ARA_NO_RESTRICTION_NORMAL 0x070000 -#define STM_ARA_NO_RESTRICTION_SPLIT_MAIN 0x080000 -#define STM_ARA_NO_RESTRICTION_SPLIT_SUB 0x090000 - -// Mask -#define STM_MSK_EVT_NO 0x0000FF -#define STM_MSK_CTG_NO 0x00FF00 -#define STM_MSK_ARA_NO 0xFF0000 +enum STM_AREA_NO { + STM_AREA_NO_NONE = 0, + STM_AREA_NO_FULL, + STM_AREA_NO_NORMAL, + STM_AREA_NO_SPLIT_MAIN, + STM_AREA_NO_SPLIT_SUB, + STM_AREA_NO_POP_UP, + STM_AREA_NO_RESTRICTION_NORMAL, + STM_AREA_NO_RESTRICTION_SPLIT_MAIN, + STM_AREA_NO_RESTRICTION_SPLIT_SUB, + + STM_AREA_NO_NUM, + + STM_AREA_NO_MIN = STM_AREA_NO_NONE, + STM_AREA_NO_MAX = STM_AREA_NO_NUM - 1, +}; + +#define CREATE_EVENT_ID(evt, ctg, area) \ + ((evt) | ((ctg) << 8) | ((area) << 16)) + +#define GET_EVENT_FROM_ID(id) \ + ((id) & 0xFF) + +#define GET_CATEGORY_FROM_ID(id) \ + (((id) >> 8) & 0xFF) + +#define GET_AREA_FROM_ID(id) \ + (((id) >> 16) & 0xFF) // Enum for state enum stm_trans_gear_state_ { @@ -126,63 +154,6 @@ enum stm_layout_ { gStmLayoutNoMax = gStmLayoutNoNum - 1, }; -enum stm_event_ { - gStmEventNoNone = 0, - gStmEventNoActive, - gStmEventNoDeactive, - gStmEventNoTransGearN, - gStmEventNoTransGearNotN, - gStmEventNoParkingBrakeOff, - gStmEventNoParkingBrakeOn, - gStmEventNoAccelPedalOff, - gStmEventNoAccelPedalOn, - gStmEventNoTimerExpired, - gStmEventNoLampOff, - gStmEventNoLampOn, - gStmEventNoLightstatusBrakeOff, - gStmEventNoLightstatusBrakeOn, - gStmEventNoRestrictionModeOff, - gStmEventNoRestrictionModeOn, - - gStmEventNoNum, - - gStmEventNoMin = gStmEventNoNone, - gStmEventNoMax = gStmEventNoNum - 1, -}; - -enum stm_category_ { - gStmCategoryNoNone = 0, - gStmCategoryNoHomescreen, - gStmCategoryNoMap, - gStmCategoryNoGeneral, - gStmCategoryNoSplitable, - gStmCategoryNoPopup, - gStmCategoryNoSystemAlert, - gStmCategoryNoRestriction, - - gStmCategoryNoNum, - - gStmCategoryNoMin = gStmCategoryNoNone, - gStmCategoryNoMax = gStmCategoryNoNum - 1, -}; - -enum stm_area_ { - gStmAreaNoNone = 0, - gStmAreaNoFullscreen, - gStmAreaNoNormal, - gStmAreaNoSplitMain, - gStmAreaNoSplitSub, - gStmAreaNoOnScreen, - gStmAreaNoRestrictionNormal, - gStmAreaNoRestrictionSplitMain, - gStmAreaNoRestrictionSplitSub, - - gStmAreaNoNum, - - gStmAreaNoMin = gStmAreaNoNone, - gStmAreaNoMax = gStmAreaNoNum - 1, -}; - enum stm_layer_ { gStmLayerNoHomescreen = 0, gStmLayerNoApps, @@ -212,11 +183,8 @@ enum stm_car_element_ { // String for state extern const char* gStmEventName[]; -extern const int gStmEventNo[]; extern const char* gStmCategoryName[]; -extern const int gStmCategoryNo[]; extern const char* gStmAreaName[]; -extern const int gStmAreaNo[]; extern const char* gStmLayoutName[]; extern const char* gStmLayerName[]; extern const char* gStmCarElementName[]; @@ -238,5 +206,4 @@ void stmInitialize(); int stmTransitionState(int event_no, stm_state_t* state); void stmUndoState(); - #endif // TMCAGLWM_DUMMY_STM_HPP |