diff options
Diffstat (limited to 'src/policy_manager/policy_manager.cpp')
-rw-r--r-- | src/policy_manager/policy_manager.cpp | 135 |
1 files changed, 35 insertions, 100 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); |