From 55be85ed4bdfea6fc037d781b8cd8f58487718d1 Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Fri, 27 Apr 2018 19:01:36 +0900 Subject: Add PolicyManager, related classes and some config files - PolicyManager Decide next layout by using occured event and current state based on policy table. This PolicyManger is reference and the OEMs can replace it. - LayoutManager Change the current layout to the layout which decided by PolicyManager. NOTE: The functions of this class had been included in App class. The part of function of this class remain there yet. - LowCanClient Receive the CAN signal from low level CAN service. - app.db Define the applications name and its role. This file will be deleted when the names and roles can be given by other module. - layout.cb Define the layouts and areas which are included by the layout. - role.db Define the roles of the applications. Change-Id: I2f84bdf5e68355e022f516cee9a1db88efe58825 Signed-off-by: Yuta Doi --- src/policy_manager/zipc/dummy_stm.c | 212 ++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/policy_manager/zipc/dummy_stm.c (limited to 'src/policy_manager/zipc/dummy_stm.c') diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c new file mode 100644 index 0000000..3c9cba2 --- /dev/null +++ b/src/policy_manager/zipc/dummy_stm.c @@ -0,0 +1,212 @@ + +#include +#include "dummy_stm.h" + +stm_state_t g_crr_state = {0}; +stm_state_t g_prv_state = {0}; +int g_prv_apps_state_car_stop = 0; + +int stmTransitionState(int event, stm_state_t* state) { + int event_no, category_no, area_no; + int apps_state, car_state, lamp_state; + + event_no = event & STM_MSK_EVT_NO; + category_no = event & STM_MSK_CTG_NO; + area_no = event & STM_MSK_ARA_NO; + + // Backup previous state + g_prv_state = g_crr_state; + + // Get previous state + apps_state = g_prv_state.layer.apps.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)); + + switch (event_no) { + case STM_EVT_NO_ACTIVATE: + switch (category_no) { + case STM_CTG_NO_HOMESCREEN: + // Apps layer + g_crr_state.layer.apps.state = gStmLayoutNoNone; + g_crr_state.layer.apps.is_changed = STM_TRUE; + + // Homescreen layer + g_crr_state.layer.homescreen.state = gStmLayoutNoHs; + g_crr_state.layer.homescreen.is_changed = STM_TRUE; + break; + case STM_CTG_NO_MAP: + switch (area_no) { + case STM_ARA_NO_FULL: + // Apps layer + switch (apps_state) { + case gStmLayoutNoMf: + // nop + break; + default: + g_crr_state.layer.apps.state = gStmLayoutNoMf; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + } + break; + case STM_ARA_NO_NORMAL: + // Apps layer + switch (apps_state) { + case gStmLayoutNoM1: + // nop + break; + case gStmLayoutNoS1: + g_crr_state.layer.apps.state = gStmLayoutNoM2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + default: + g_crr_state.layer.apps.state = gStmLayoutNoM1; + g_crr_state.layer.apps.is_changed = STM_TRUE; + } + break; + case STM_ARA_NO_SPLIT_MAIN: + // Apps layer + switch (apps_state) { + case gStmLayoutNoS1: + case gStmLayoutNoS2: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + } + break; + case STM_CTG_NO_GENERAL: + switch (area_no) { + case STM_ARA_NO_NORMAL: + // Apps layer + switch (apps_state) { + case gStmLayoutNoMf: + // nop + break; + default: + g_crr_state.layer.apps.state = gStmLayoutNoG; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + } + break; + default: + // nop + break; + } + break; + case STM_CTG_NO_SPLITABLE: + switch (area_no) { + case STM_ARA_NO_NORMAL: + // Apps layer + switch (apps_state) { + case gStmLayoutNoMf: + // nop + break; + case gStmLayoutNoS1: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + default: + g_crr_state.layer.apps.state = gStmLayoutNoS1; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + } + break; + case STM_ARA_NO_SPLIT_MAIN: + // Apps layer + switch (apps_state) { + case gStmLayoutNoS1: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + case gStmLayoutNoS2: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + case STM_ARA_NO_SPLIT_SUB: + // Apps layer + switch (apps_state) { + case gStmLayoutNoM1: + g_crr_state.layer.apps.state = gStmLayoutNoM2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + case gStmLayoutNoM2: + g_crr_state.layer.apps.state = gStmLayoutNoM2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + case gStmLayoutNoS1: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + case gStmLayoutNoS2: + g_crr_state.layer.apps.state = gStmLayoutNoS2; + g_crr_state.layer.apps.is_changed = STM_TRUE; + break; + default: + // nop + break; + } + break; + default: + // nop + break; + } + break; + default: + // nop + break; + } + 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; + g_crr_state.lamp.is_changed = STM_TRUE; + } + break; + case STM_EVT_NO_LAMP_ON: + if (gStmLampStateNoOn != lamp_state) { + g_crr_state.lamp.state = gStmLampStateNoOn; + g_crr_state.lamp.is_changed = STM_TRUE; + } + break; + default: + // nop + break; + } + + // Copy current state for return + memcpy(state, &g_crr_state, sizeof(g_crr_state)); + + return 0; +} + -- cgit 1.2.3-korg