diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-10 13:10:28 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-10 13:10:28 +0900 |
commit | 2ea71aa957634ce69681ae34abace0566d52b744 (patch) | |
tree | b9d9ee097a78d3d21ee07d85193a2e2e6862fce6 /src/policy_manager/zipc | |
parent | 0dcb9ae1f99cffcafac62a324f8f054cc212a880 (diff) |
Modify for restriction role
- Add policy for restriction to dummy stm.
- Add the function which inputs json file
because json_object_from_file can not allows up to only 4KB file.
- Bug fix in json files.
- Delete unexpected characters.
- Delete description because it does not follow the format of json array.
Change-Id: I2f8fba1d1001cf244e2531fe3a1a738d5a48091b
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/policy_manager/zipc')
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.c | 118 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 26 |
2 files changed, 125 insertions, 19 deletions
diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c index 459f58c..07694cf 100644 --- a/src/policy_manager/zipc/dummy_stm.c +++ b/src/policy_manager/zipc/dummy_stm.c @@ -31,7 +31,8 @@ const char* gStmCategoryName[] = { "general", "splitable", "popup", - "system_alert" + "system_alert", + "restriction", }; const int gStmCategoryNo[] = { @@ -40,7 +41,8 @@ const int gStmCategoryNo[] = { STM_CTG_NO_GENERAL, STM_CTG_NO_SPLITABLE, STM_CTG_NO_POPUP, - STM_CTG_NO_SYSTEM_ALERT + STM_CTG_NO_SYSTEM_ALERT, + STM_CTG_NO_RESTRICTION, }; const char* gStmAreaName[] = { @@ -48,7 +50,10 @@ const char* gStmAreaName[] = { "normal", "split.main", "split.sub", - "onscreen" + "onscreen", + "restriction.normal", + "restriction.split.main", + "restriction.split.sub", }; const int gStmAreaNo[] = { @@ -56,7 +61,10 @@ const int gStmAreaNo[] = { STM_ARA_NO_NORMAL, STM_ARA_NO_SPLIT_MAIN, STM_ARA_NO_SPLIT_SUB, - STM_ARA_NO_ON_SCREEN + STM_ARA_NO_ON_SCREEN, + STM_ARA_NO_RESTRICTION_NORMAL, + STM_ARA_NO_RESTRICTION_SPLIT_MAIN, + STM_ARA_NO_RESTRICTION_SPLIT_SUB, }; // String for state @@ -86,15 +94,34 @@ const char* gStmLayoutNo2Name[] = { "s2", "g", "hs", + "restriction", + "restriction.split.main", + "restriction.split.sub", }; -stm_state_t g_crr_state = {0}; -stm_state_t g_prv_state = {0}; +stm_state_t g_crr_state; +stm_state_t g_prv_state; int g_prv_apps_state_car_stop = 0; +void stmInitialize() { + // Initialize previous state + memset(&g_prv_state, 0, sizeof(g_prv_state)); + + g_prv_state.layer.on_screen.state = gStmLayoutNoNone; + g_prv_state.layer.restriction.state = gStmLayoutNoNone; + g_prv_state.layer.apps.state = gStmLayoutNoNone; + g_prv_state.layer.homescreen.state = gStmLayoutNoNone; + g_prv_state.parking_brake.state = gStmParkingBrakeStateNoOn; + g_prv_state.car.state = gStmCarStateNoStop; + g_prv_state.lamp.state = gStmLampStateNoOff; + + // Initialize current state + g_crr_state = g_prv_state; +} + int stmTransitionState(int event, stm_state_t* state) { int event_no, category_no, area_no; - int apps_state, parking_brake_state, car_state, lamp_state; + int restriction_state, apps_state, parking_brake_state, car_state, lamp_state; event_no = event & STM_MSK_EVT_NO; category_no = event & STM_MSK_CTG_NO; @@ -104,13 +131,20 @@ int stmTransitionState(int event, stm_state_t* state) { g_prv_state = g_crr_state; // Get previous 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; car_state = g_prv_state.car.state; lamp_state = g_prv_state.lamp.state; - // Clear current state - memset(&g_crr_state, 0, sizeof(g_crr_state)); + // Clear flags + g_crr_state.layer.on_screen.is_changed = STM_FALSE; + g_crr_state.layer.restriction.is_changed = STM_FALSE; + 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.car.is_changed = STM_FALSE; + g_crr_state.lamp.is_changed = STM_FALSE; switch (event_no) { case STM_EVT_NO_ACTIVATE: @@ -250,9 +284,71 @@ int stmTransitionState(int event, stm_state_t* state) { break; } break; + case STM_CTG_NO_RESTRICTION: + switch (area_no) { + case STM_ARA_NO_RESTRICTION_NORMAL: + // restriction Layer + switch (restriction_state) { + case gStmLayoutNoNone: + g_crr_state.layer.restriction.state = gStmLayoutNoRestriction; + g_crr_state.layer.restriction.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + case STM_ARA_NO_RESTRICTION_SPLIT_MAIN: + // restriction Layer + switch (restriction_state) { + case gStmLayoutNoNone: + g_crr_state.layer.restriction.state = gStmLayoutNoRestrictionSplitMain; + g_crr_state.layer.restriction.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + case STM_ARA_NO_RESTRICTION_SPLIT_SUB: + // restriction Layer + switch (restriction_state) { + case gStmLayoutNoNone: + g_crr_state.layer.restriction.state = gStmLayoutNoRestrictionSplitSub; + g_crr_state.layer.restriction.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + default: + // nop + break; + } + break; default: - // nop - break; + // nop + break; + } + case STM_EVT_NO_DEACTIVATE: + switch (category_no) { + case STM_CTG_NO_RESTRICTION: + // restriction Layer + switch (restriction_state) { + case gStmLayoutNoRestriction: + case gStmLayoutNoRestrictionSplitMain: + case gStmLayoutNoRestrictionSplitSub: + g_crr_state.layer.restriction.state = gStmLayoutNoNone; + g_crr_state.layer.restriction.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + default: + // nop + break; } break; case STM_EVT_NO_PARKING_BRAKE_OFF: diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h index ae438db..38d3912 100644 --- a/src/policy_manager/zipc/dummy_stm.h +++ b/src/policy_manager/zipc/dummy_stm.h @@ -41,13 +41,17 @@ #define STM_CTG_NO_SPLITABLE 0x0400 #define STM_CTG_NO_POPUP 0x0500 #define STM_CTG_NO_SYSTEM_ALERT 0x0600 +#define STM_CTG_NO_RESTRICTION 0x0700 // Area number -#define STM_ARA_NO_FULL 0x010000 -#define STM_ARA_NO_NORMAL 0x020000 -#define STM_ARA_NO_SPLIT_MAIN 0x030000 -#define STM_ARA_NO_SPLIT_SUB 0x040000 -#define STM_ARA_NO_ON_SCREEN 0x050000 +#define STM_ARA_NO_FULL 0x010000 +#define STM_ARA_NO_NORMAL 0x020000 +#define STM_ARA_NO_SPLIT_MAIN 0x030000 +#define STM_ARA_NO_SPLIT_SUB 0x040000 +#define STM_ARA_NO_ON_SCREEN 0x050000 +#define STM_ARA_NO_RESTRICTION_NORMAL 0x060000 +#define STM_ARA_NO_RESTRICTION_SPLIT_MAIN 0x070000 +#define STM_ARA_NO_RESTRICTION_SPLIT_SUB 0x080000 // Mask #define STM_MSK_EVT_NO 0x0000FF @@ -56,8 +60,8 @@ // Number of events, categories and areas #define STM_NUM_EVT 9 -#define STM_NUM_CTG 6 -#define STM_NUM_ARA 5 +#define STM_NUM_CTG 7 +#define STM_NUM_ARA 8 // Enum for state enum stm_parking_brake_state_ { @@ -85,7 +89,10 @@ enum stm_layout_ { gStmLayoutNoS1, gStmLayoutNoS2, gStmLayoutNoG, - gStmLayoutNoHs + gStmLayoutNoHs, + gStmLayoutNoRestriction, + gStmLayoutNoRestrictionSplitMain, + gStmLayoutNoRestrictionSplitSub, }; @@ -110,6 +117,7 @@ typedef struct stm_base_state_ { typedef struct stm_layer_state_ { stm_base_state on_screen; + stm_base_state restriction; stm_base_state apps; stm_base_state homescreen; } stm_layer_state; @@ -121,6 +129,8 @@ typedef struct { stm_layer_state layer; } stm_state_t; + +void stmInitialize(); int stmTransitionState(int event_no, stm_state_t* state); |