diff options
Diffstat (limited to 'src/policy_manager/zipc')
-rw-r--r-- | src/policy_manager/zipc/category.db | 32 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.c | 212 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 127 |
3 files changed, 371 insertions, 0 deletions
diff --git a/src/policy_manager/zipc/category.db b/src/policy_manager/zipc/category.db new file mode 100644 index 0000000..4867260 --- /dev/null +++ b/src/policy_manager/zipc/category.db @@ -0,0 +1,32 @@ +{ + "categories":[ + { + "name": "homescreen", + "role": "homescreen" + }, + { + "name": "map", + "role": "map" + }, + { + "name": "general", + "role": "poi | music | radio | video | browser | sdl | phone | settings | mixer | hvac | dashboard | fallback" + }, + { + "name": "pop_up", + "role": "incoming_call" + }, + { + "name": "system_alert", + "role": "system_alert" + }, + { + "name": "tbt", + "role": "tbt" + }, + { + "name": "splitable", + "role": "test_splitable1 | test_splitable2" + } + ] +} 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 <string.h> +#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; +} + diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h new file mode 100644 index 0000000..18af99b --- /dev/null +++ b/src/policy_manager/zipc/dummy_stm.h @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_DUMMY_STM_HPP +#define TMCAGLWM_DUMMY_STM_HPP + +// TODO: This file should be existed in STM + +// +#define STM_TRUE 1 +#define STM_FALSE 0 + +// Event number +#define STM_EVT_NO_ACTIVATE 0x01 +#define STM_EVT_NO_DEACTIVATE 0x02 +#define STM_EVT_NO_CAR_STOP 0x03 +#define STM_EVT_NO_CAR_RUN 0x04 +#define STM_EVT_NO_TIMER_EXPIRED 0x05 +#define STM_EVT_NO_LAMP_OFF 0x06 +#define STM_EVT_NO_LAMP_ON 0x07 + +// Category number +#define STM_CTG_NO_HOMESCREEN 0x0100 +#define STM_CTG_NO_MAP 0x0200 +#define STM_CTG_NO_GENERAL 0x0300 +#define STM_CTG_NO_SPLITABLE 0x0400 +#define STM_CTG_NO_POPUP 0x0500 +#define STM_CTG_NO_SYSTEM_ALERT 0x0600 + +// 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 + +// Mask +#define STM_MSK_EVT_NO 0x0000FF +#define STM_MSK_CTG_NO 0x00FF00 +#define STM_MSK_ARA_NO 0xFF0000 + +// Enum for state +enum stm_car_state_ { + gStmCarStateNoStop = 0, + gStmCarStateNoRun +}; + +enum stm_lamp_state_ { + gStmLampStateNoOff = 0, + gStmLampStateNoOn +}; + +enum stm_layout_ { + gStmLayoutNoNone = 0, + gStmLayoutNoPu, + gStmLayoutNoSa, + gStmLayoutNoM1, + gStmLayoutNoM2, + gStmLayoutNoMf, + gStmLayoutNoS1, + gStmLayoutNoS2, + gStmLayoutNoG, + gStmLayoutNoHs +}; + + +#if 0 +// String for state +const char* gStmCarStateNo2Name[] { + "car_stop", + "car_run" +}; + +const char* gStmLampStateNo2Name[] { + "lamp_off", + "lamp_on" +}; + +const char* gStmLayoutNo2Name[] { + "none", + "pu", + "sa", + "m1", + "m2", + "mf", + "s1", + "s2", + "g", + "hs", +}; +#endif + +typedef struct stm_base_state_ { + int is_changed; + int state; +} stm_base_state; + +typedef struct stm_layer_state_ { + stm_base_state on_screen; + stm_base_state apps; + stm_base_state homescreen; +} stm_layer_state; + +// Struct for state +typedef struct { + stm_base_state car; + stm_base_state lamp; + stm_layer_state layer; +} stm_state_t; + +int stmTransitionState(int event_no, stm_state_t* state); + + +#endif // TMCAGLWM_DUMMY_STM_HPP |