diff options
author | 2018-05-09 13:34:19 +0900 | |
---|---|---|
committer | 2018-05-09 13:34:19 +0900 | |
commit | a660fd2bc4e232dd8bb61febd1eae1e26d674804 (patch) | |
tree | 36362f2462d4eb37d3b5eacf300896e4d3c1c5e1 /src/policy_manager | |
parent | a98320a337645609da7060b20478969196cc2f4e (diff) |
Add parking brake ON/OFF event
Change-Id: I3b9face35972a275918ac4f95f4a97df035ee924
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/policy_manager')
-rw-r--r-- | src/policy_manager/policy_manager.cpp | 135 | ||||
-rw-r--r-- | src/policy_manager/policy_manager.hpp | 6 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.c | 89 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 64 |
4 files changed, 157 insertions, 137 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp index 61d1d7c..47d9eac 100644 --- a/src/policy_manager/policy_manager.cpp +++ b/src/policy_manager/policy_manager.cpp @@ -20,92 +20,14 @@ #include <istream> #include <json-c/json.h> #include "policy_manager.hpp" +#if 0 +extern "C" { #include "dummy_stm.h" +} +#endif #include "hmi-debug.h" -namespace { - -static const char* kEventName[] = { - "activate", - "deactivate", - "car_stop", - "car_run", - "timer_expired", - "lamp_off", - "lamp_on" -}; - -static const int kEventNo[] = { - STM_EVT_NO_ACTIVATE, - STM_EVT_NO_DEACTIVATE, - STM_EVT_NO_CAR_STOP, - STM_EVT_NO_CAR_RUN, - STM_EVT_NO_TIMER_EXPIRED, - STM_EVT_NO_LAMP_OFF, - STM_EVT_NO_LAMP_ON -}; - -static const char* kCategoryName[] = { - "homescreen", - "map", - "general", - "splitable", - "popup", - "system_alert" -}; - -static const int kCategoryNo[] = { - 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 -}; - -static const char* kAreaName[] = { - "full", - "normal", - "split.main", - "split.sub", - "onscreen" -}; - -static const int kAreaNo[] = { - STM_ARA_NO_FULL, - STM_ARA_NO_NORMAL, - STM_ARA_NO_SPLIT_MAIN, - STM_ARA_NO_SPLIT_SUB, - STM_ARA_NO_ON_SCREEN -}; - -// 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", -}; - -} // namespace - PolicyManager::PolicyManager() : eventname2no_(), categoryname2no_(), @@ -124,19 +46,19 @@ int PolicyManager::initialize() { int ret = 0; // Create convert map - for (unsigned int i=0; i<(sizeof(kEventNo)/sizeof(int)); i++) { - HMI_DEBUG("wm:pm", "event name:%s no:%d", kEventName[i], kEventNo[i]); - this->eventname2no_[kEventName[i]] = kEventNo[i]; + for (unsigned int i=0; i<STM_NUM_EVT; 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 (unsigned int i=0; i<(sizeof(kCategoryNo)/sizeof(int)); i++) { - HMI_DEBUG("wm:pm", "category name:%s no:%d", kCategoryName[i], kCategoryNo[i]); - this->categoryname2no_[kCategoryName[i]] = kCategoryNo[i]; + for (unsigned int i=0; i<STM_NUM_CTG; 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 (unsigned int i=0; i<(sizeof(kAreaNo)/sizeof(int)); i++) { - HMI_DEBUG("wm:pm", "area name:%s no:%d", kAreaName[i], kAreaNo[i]); - this->areaname2no_[kAreaName[i]] = kAreaNo[i]; + for (unsigned int i=0; i<STM_NUM_ARA; i++) { + HMI_DEBUG("wm:pm", "area name:%s no:%d", stm::gStmAreaName[i], stm::gStmAreaNo[i]); + this->areaname2no_[stm::gStmAreaName[i]] = stm::gStmAreaNo[i]; } // Load role.db @@ -210,30 +132,43 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) { // Create result // { + // "parking_brake": { + // "is_changed": <bool>, + // "state": <const char*> + // }, + HMI_DEBUG("wm", "parking brake state (is_changed:%d state:%d:%s)", + this->current_state_.parking_brake.is_changed, + this->current_state_.parking_brake.state, + stm::gStmCarStateNo2Name[this->current_state_.parking_brake.state]); + this->addStateToJson("parking_brake", + this->current_state_.parking_brake.is_changed, + stm::gStmParkingBrakeStateNo2Name[this->current_state_.parking_brake.state], + json_out); + // "car": { // "is_changed": <bool>, // "state": <const char*> // }, - HMI_DEBUG("wm", "@@@@@ car state (is_changed:%d state:%d:%s)", + HMI_DEBUG("wm", "car state (is_changed:%d state:%d:%s)", this->current_state_.car.is_changed, this->current_state_.car.state, - gStmCarStateNo2Name[this->current_state_.car.state]); + stm::gStmCarStateNo2Name[this->current_state_.car.state]); this->addStateToJson("car", this->current_state_.car.is_changed, - gStmCarStateNo2Name[this->current_state_.car.state], + stm::gStmCarStateNo2Name[this->current_state_.car.state], json_out); // "lamp": { // "is_changed": <bool>, // "state": <const char*> // }, - HMI_DEBUG("wm", "@@@@@ lamp state (is_changed:%d state:%d:%s)", + HMI_DEBUG("wm", "lamp state (is_changed:%d state:%d:%s)", this->current_state_.lamp.is_changed, this->current_state_.lamp.state, - gStmLampStateNo2Name[this->current_state_.lamp.state]); + stm::gStmLampStateNo2Name[this->current_state_.lamp.state]); this->addStateToJson("lamp", this->current_state_.lamp.is_changed, - gStmLampStateNo2Name[this->current_state_.lamp.state], + stm::gStmLampStateNo2Name[this->current_state_.lamp.state], json_out); // "layers": [ @@ -247,7 +182,7 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) { json_object* json_tmp = json_object_new_object(); this->addStateToJson("on_screen", this->current_state_.layer.on_screen.is_changed, - gStmLayoutNo2Name[this->current_state_.layer.on_screen.state], + stm::gStmLayoutNo2Name[this->current_state_.layer.on_screen.state], &json_tmp); json_object_array_add(json_layer, json_tmp); @@ -260,7 +195,7 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) { json_tmp = json_object_new_object(); this->addStateToJson("apps", this->current_state_.layer.apps.is_changed, - gStmLayoutNo2Name[this->current_state_.layer.apps.state], + stm::gStmLayoutNo2Name[this->current_state_.layer.apps.state], &json_tmp); json_object_array_add(json_layer, json_tmp); @@ -275,7 +210,7 @@ int PolicyManager::checkPolicy(json_object* json_in, json_object** json_out) { json_tmp = json_object_new_object(); this->addStateToJson("homescreen", this->current_state_.layer.homescreen.is_changed, - gStmLayoutNo2Name[this->current_state_.layer.homescreen.state], + stm::gStmLayoutNo2Name[this->current_state_.layer.homescreen.state], &json_tmp); json_object_array_add(json_layer, json_tmp); diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp index 500120c..e3ee621 100644 --- a/src/policy_manager/policy_manager.hpp +++ b/src/policy_manager/policy_manager.hpp @@ -21,11 +21,11 @@ #include <unordered_map> #include <vector> -//namespace stm { +namespace stm { extern "C" { #include "dummy_stm.h" } -//} // namespace stm +} // namespace stm class PolicyManager { @@ -52,7 +52,7 @@ private: std::unordered_map<std::string, std::string> category2role_; std::unordered_map<std::string, std::string> role2defaultarea_; - stm_state_t current_state_; + stm::stm_state_t current_state_; // Load role.db int loadRoleDb(); diff --git a/src/policy_manager/zipc/dummy_stm.c b/src/policy_manager/zipc/dummy_stm.c index 3c9cba2..78e25d7 100644 --- a/src/policy_manager/zipc/dummy_stm.c +++ b/src/policy_manager/zipc/dummy_stm.c @@ -1,7 +1,93 @@ - #include <string.h> #include "dummy_stm.h" +const char* gStmEventName[] = { + "activate", + "deactivate", + "parking_brake_off", + "parking_brake_on", + "car_stop", + "car_run", + "timer_expired", + "lamp_off", + "lamp_on" +}; + +const int gStmEventNo[] = { + STM_EVT_NO_ACTIVATE, + STM_EVT_NO_DEACTIVATE, + STM_EVT_NO_PARKING_BRAKE_OFF, + STM_EVT_NO_PARKING_BRAKE_ON, + STM_EVT_NO_CAR_STOP, + STM_EVT_NO_CAR_RUN, + STM_EVT_NO_TIMER_EXPIRED, + STM_EVT_NO_LAMP_OFF, + STM_EVT_NO_LAMP_ON +}; + +const char* gStmCategoryName[] = { + "homescreen", + "map", + "general", + "splitable", + "popup", + "system_alert" +}; + +const int gStmCategoryNo[] = { + 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 +}; + +const char* gStmAreaName[] = { + "full", + "normal", + "split.main", + "split.sub", + "onscreen" +}; + +const int gStmAreaNo[] = { + STM_ARA_NO_FULL, + STM_ARA_NO_NORMAL, + STM_ARA_NO_SPLIT_MAIN, + STM_ARA_NO_SPLIT_SUB, + STM_ARA_NO_ON_SCREEN +}; + +// String for state +const char* gStmParkingBrakeStateNo2Name[] = { + "parking_brake_off", + "parking_brake_on" +}; + +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", +}; + stm_state_t g_crr_state = {0}; stm_state_t g_prv_state = {0}; int g_prv_apps_state_car_stop = 0; @@ -209,4 +295,3 @@ int stmTransitionState(int event, stm_state_t* state) { return 0; } - diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h index 18af99b..ae438db 100644 --- a/src/policy_manager/zipc/dummy_stm.h +++ b/src/policy_manager/zipc/dummy_stm.h @@ -24,13 +24,15 @@ #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 +#define STM_EVT_NO_ACTIVATE 0x01 +#define STM_EVT_NO_DEACTIVATE 0x02 +#define STM_EVT_NO_PARKING_BRAKE_OFF 0x03 +#define STM_EVT_NO_PARKING_BRAKE_ON 0x04 +#define STM_EVT_NO_CAR_STOP 0x05 +#define STM_EVT_NO_CAR_RUN 0x06 +#define STM_EVT_NO_TIMER_EXPIRED 0x07 +#define STM_EVT_NO_LAMP_OFF 0x08 +#define STM_EVT_NO_LAMP_ON 0x09 // Category number #define STM_CTG_NO_HOMESCREEN 0x0100 @@ -52,7 +54,17 @@ #define STM_MSK_CTG_NO 0x00FF00 #define STM_MSK_ARA_NO 0xFF0000 +// Number of events, categories and areas +#define STM_NUM_EVT 9 +#define STM_NUM_CTG 6 +#define STM_NUM_ARA 5 + // Enum for state +enum stm_parking_brake_state_ { + gStmParkingBrakeStateNoOff = 0, + gStmParkingBrakeStateNoOn +}; + enum stm_car_state_ { gStmCarStateNoStop = 0, gStmCarStateNoRun @@ -77,32 +89,20 @@ enum stm_layout_ { }; -#if 0 -// String for state -const char* gStmCarStateNo2Name[] { - "car_stop", - "car_run" -}; +extern const char* gStmEventName[]; +extern const int gStmEventNo[]; +extern const char* gStmCategoryName[]; +extern const int gStmCategoryNo[]; +extern const char* gStmAreaName[]; +extern const int gStmAreaNo[]; -const char* gStmLampStateNo2Name[] { - "lamp_off", - "lamp_on" -}; - -const char* gStmLayoutNo2Name[] { - "none", - "pu", - "sa", - "m1", - "m2", - "mf", - "s1", - "s2", - "g", - "hs", -}; -#endif +// String for state +extern const char* gStmParkingBrakeStateNo2Name[]; +extern const char* gStmCarStateNo2Name[]; +extern const char* gStmLampStateNo2Name[]; +extern const char* gStmLayoutNo2Name[]; +// Struct for state typedef struct stm_base_state_ { int is_changed; int state; @@ -114,8 +114,8 @@ typedef struct stm_layer_state_ { stm_base_state homescreen; } stm_layer_state; -// Struct for state typedef struct { + stm_base_state parking_brake; stm_base_state car; stm_base_state lamp; stm_layer_state layer; |