aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-06-22 20:48:32 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-06-22 20:48:32 +0900
commit7815511e8cee7d44fc73bc5939a44b2c213dbe7a (patch)
tree05af114f23f56cfc1eb60b7111d6a3e502580f4c
parentfdb31e2fa50280efc789b1854f5df831b1870c9d (diff)
Modify definition in stm
Change-Id: I97e30f4d03fe9c67fb95e338ee123c912a6e8eb1 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/policy_manager/policy_manager.cpp79
-rw-r--r--src/policy_manager/zipc/dummy_stm.c80
-rw-r--r--src/policy_manager/zipc/dummy_stm.h167
3 files changed, 126 insertions, 200 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index 89a939c..1c2acb4 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -92,19 +92,19 @@ int PolicyManager::initialize() {
int ret = 0;
// Create convert map
- for (int i = stm::gStmEventNoMin; i <= stm::gStmEventNoMax; i++) {
- HMI_DEBUG("wm:pm", "event name:%s no:%d", stm::gStmEventName[i], stm::gStmEventNo[i]);
- this->eventname2no[stm::gStmEventName[i]] = stm::gStmEventNo[i];
+ for (int i = stm::STM_EVT_NO_MIN; i <= stm::STM_EVT_NO_MAX; i++) {
+ HMI_DEBUG("wm:pm", "event name:%s no:%d", stm::gStmEventName[i], i);
+ this->eventname2no[stm::gStmEventName[i]] = i;
}
- for (int i = stm::gStmCategoryNoMin; i <= stm::gStmCategoryNoMax; i++) {
- HMI_DEBUG("wm:pm", "category name:%s no:%d", stm::gStmCategoryName[i], stm::gStmCategoryNo[i]);
- this->categoryname2no[stm::gStmCategoryName[i]] = stm::gStmCategoryNo[i];
+ for (int i = stm::STM_CTG_NO_MIN; i <= stm::STM_CTG_NO_MAX; i++) {
+ HMI_DEBUG("wm:pm", "category name:%s no:%d", stm::gStmCategoryName[i], i);
+ this->categoryname2no[stm::gStmCategoryName[i]] = i;
}
- for (int i = stm::gStmAreaNoMin; i <= stm::gStmAreaNoMax; i++) {
- HMI_DEBUG("wm:pm", "area name:%s no:%d", stm::gStmAreaName[i], stm::gStmAreaNo[i]);
- this->areaname2no[stm::gStmAreaName[i]] = stm::gStmAreaNo[i];
+ for (int i = stm::STM_AREA_NO_MIN; i <= stm::STM_AREA_NO_MAX; i++) {
+ HMI_DEBUG("wm:pm", "area name:%s no:%d", stm::gStmAreaName[i], i);
+ this->areaname2no[stm::gStmAreaName[i]] = i;
}
// Load role.db
@@ -153,7 +153,7 @@ static void initializeLocalCarElementState() {
static void initializeLocalLayerState() {
pm::AreaState init_area;
pm::LayoutState init_layout;
- init_area.name = stm::gStmAreaName[stm::gStmAreaNoNone];
+ init_area.name = stm::gStmAreaName[stm::STM_AREA_NO_NONE];
init_area.category = "";
init_area.role = "";
init_layout.name = stm::gStmLayoutName[stm::gStmLayoutNoNone];
@@ -256,13 +256,13 @@ static void updateLocalCarElementState(stm::stm_state_t crr_state) {
static void updateLocalLayerState(int event_data, stm::stm_state_t crr_state) {
int event_no, category_no, area_no;
- event_no = (event_data & STM_MSK_EVT_NO) - 1;
- category_no = ((event_data & STM_MSK_CTG_NO) >> 8) - 1;
- area_no = ((event_data & STM_MSK_ARA_NO) >> 16) - 1;
+ event_no = GET_EVENT_FROM_ID(event_data);
+ category_no = GET_CATEGORY_FROM_ID(event_data);
+ area_no = GET_AREA_FROM_ID(event_data);
- std::string req_evt = std::string((event_no < 0) ? "-" : stm::gStmEventName[event_no]);
- std::string req_ctg = std::string((category_no < 0) ? "-" : stm::gStmCategoryName[category_no]);
- std::string req_area = std::string((area_no < 0) ? "-" : stm::gStmAreaName[area_no]);
+ std::string req_evt = stm::gStmEventName[event_no];
+ std::string req_ctg = stm::gStmCategoryName[category_no];
+ std::string req_area = stm::gStmAreaName[area_no];
std::string req_role = pm::g_req_role_list[event_data];
HMI_DEBUG("wm:pm", "REQ: event:%s role:%s category:%s area:%s",
req_evt.c_str(), req_role.c_str(), req_ctg.c_str(), req_area.c_str());
@@ -324,12 +324,12 @@ static void updateLocalLayerState(int event_data, stm::stm_state_t crr_state) {
crr_layout_state = pm::g_prv_layers_car_stop[layer_name].layout_state;
crr_layout_name = crr_layout_state.name;
if ((prv_layout_name == crr_layout_name)
- && (stm::gStmAreaName[stm::gStmAreaNoNone] == crr_layout_name)) {
+ && (stm::gStmAreaName[stm::STM_AREA_NO_NONE] == crr_layout_name)) {
changed = 0;
}
}
else if ((prv_layout_name == crr_layout_name)
- && (stm::gStmAreaName[stm::gStmAreaNoNone] == crr_layout_name)) {
+ && (stm::gStmAreaName[stm::STM_AREA_NO_NONE] == crr_layout_name)) {
// Copy previous layout state for current
crr_layout_state = prv_layout_state;
changed = 0;
@@ -354,8 +354,8 @@ static void updateLocalLayerState(int event_data, stm::stm_state_t crr_state) {
// Create candidate list
std::map<std::string, pm::AreaList> cand_list;
- for (int ctg_no=stm::gStmCategoryNoMin;
- ctg_no<=stm::gStmCategoryNoMax; ctg_no++) {
+ for (int ctg_no=stm::STM_CTG_NO_MIN;
+ ctg_no<=stm::STM_CTG_NO_MAX; ctg_no++) {
const char* ctg = stm::gStmCategoryName[ctg_no];
HMI_DEBUG("wm:pm", "ctg:%s", ctg);
@@ -559,15 +559,15 @@ static void controlTimerEvent(stm::stm_state_t crr_state) {
if (crr_state.car_element[stm::gStmCarElementNoRunning].changed) {
if (stm::gStmRunningNoRun == crr_state.car_element[stm::gStmCarElementNoRunning].state) {
// Set delay event(restriction mode on)
- checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_ON, 3000, "");
+ checkPolicyEntry(stm::STM_EVT_NO_RESTRICTION_MODE_ON, 3000, "");
}
else if (stm::gStmRunningNoStop == crr_state.car_element[stm::gStmCarElementNoRunning].state) {
// Stop timer for restriction on event
- if (pm::event_source_list.find(STM_EVT_NO_RESTRICTION_MODE_ON)
+ if (pm::event_source_list.find(stm::STM_EVT_NO_RESTRICTION_MODE_ON)
!= pm::event_source_list.end()) {
HMI_DEBUG("wm:pm", "Stop timer for restriction on");
sd_event_source *event_source
- = pm::event_source_list[STM_EVT_NO_RESTRICTION_MODE_ON];
+ = pm::event_source_list[stm::STM_EVT_NO_RESTRICTION_MODE_ON];
int ret = sd_event_source_set_enabled(event_source, SD_EVENT_OFF);
if (0 > ret) {
HMI_ERROR("wm:pm", "Failed to stop timer");
@@ -575,7 +575,7 @@ static void controlTimerEvent(stm::stm_state_t crr_state) {
}
// Set event(restriction mode off)
- checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_OFF, 0, "");
+ checkPolicyEntry(stm::STM_EVT_NO_RESTRICTION_MODE_OFF, 0, "");
}
}
}
@@ -587,13 +587,13 @@ static int checkPolicy(sd_event_source *source, void *data) {
int event_data = *((int*)data);
int event_no, category_no, area_no;
- event_no = (event_data & STM_MSK_EVT_NO) - 1;
- category_no = ((event_data & STM_MSK_CTG_NO) >> 8) - 1;
- area_no = ((event_data & STM_MSK_ARA_NO) >> 16) - 1;
+ event_no = GET_EVENT_FROM_ID(event_data);
+ category_no = GET_CATEGORY_FROM_ID(event_data);
+ area_no = GET_AREA_FROM_ID(event_data);
HMI_DEBUG("wm:pm", ">>>>>>>>>> event:%s category:%s area:%s",
- (event_no < 0) ? "-" : stm::gStmEventName[event_no],
- (category_no < 0) ? "-" : stm::gStmCategoryName[category_no],
- (area_no < 0) ? "-" : stm::gStmAreaName[area_no]);
+ stm::gStmEventName[event_no],
+ stm::gStmCategoryName[category_no],
+ stm::gStmAreaName[area_no]);
// Transition state
stm::stm_state_t crr_state;
@@ -718,7 +718,7 @@ int PolicyManager::setInputEventData(json_object* json_in) {
// Get event from json_object
const char* event = this->getStringFromJson(json_in, "event");
- int event_no = stm::gStmEventNoNone;
+ int event_no = stm::STM_EVT_NO_NONE;
if (nullptr != event) {
// Convert name to number
auto itr = this->eventname2no.find(event);
@@ -738,7 +738,7 @@ int PolicyManager::setInputEventData(json_object* json_in) {
// Get role from json_object
const char* role = this->getStringFromJson(json_in, "role");
- int category_no = stm::gStmCategoryNoNone;
+ int category_no = stm::STM_CTG_NO_NONE;
if (nullptr != role) {
HMI_DEBUG("wm:pm", "role(%s)", role);
@@ -754,13 +754,13 @@ int PolicyManager::setInputEventData(json_object* json_in) {
}
}
- if (stm::gStmCategoryNoNone == category_no) {
+ if (stm::STM_CTG_NO_NONE == category_no) {
role = "";
}
// Get areat from json_object
const char* area = this->getStringFromJson(json_in, "area");
- int area_no = stm::gStmAreaNoNone;
+ int area_no = stm::STM_AREA_NO_NONE;
if (nullptr != area) {
auto itr = this->areaname2no.find(area);
if (this->areaname2no.end() != itr) {
@@ -770,8 +770,8 @@ int PolicyManager::setInputEventData(json_object* json_in) {
}
// If role is set and area is not set, use default area
- if ((stm::gStmAreaNoNone == area_no)
- && (stm::gStmCategoryNoNone != category_no)) {
+ if ((stm::STM_AREA_NO_NONE == area_no)
+ && (stm::STM_CTG_NO_NONE != category_no)) {
std::string def_area = this->role2defaultarea[role];
area_no = this->areaname2no[def_area];
HMI_DEBUG("wm:pm", "area(%s:%d)", def_area.c_str(), area_no);
@@ -779,7 +779,8 @@ int PolicyManager::setInputEventData(json_object* json_in) {
// Set event info to the queue
EventInfo event_info;
- event_info.event = (event_no | category_no | area_no);
+ int event_id = CREATE_EVENT_ID(event_no, category_no, area_no);
+ event_info.event = event_id;
event_info.role = std::string(role);
event_info.delay = 0;
this->event_info_queue.push(event_info);
@@ -968,8 +969,8 @@ int PolicyManager::loadLayoutDb() {
pm::LayoutState layout_state;
pm::AreaState area_state;
std::map<std::string, int> category_num;
- for (int ctg_no = stm::gStmCategoryNoMin;
- ctg_no <= stm::gStmCategoryNoMax; ctg_no++) {
+ for (int ctg_no = stm::STM_CTG_NO_MIN;
+ ctg_no <= stm::STM_CTG_NO_MAX; ctg_no++) {
const char* ctg_name = stm::gStmCategoryName[ctg_no];
category_num[ctg_name] = 0;
}
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