diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-06-26 09:41:41 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-06-26 09:41:41 +0900 |
commit | d0a74715ab98c79fda0a968a4b34ea0fb999461f (patch) | |
tree | 52d6e8b330bf93fffd7a1868628beba17392e81c | |
parent | 68a3537de96da4601756b3ab580b1071cb36547e (diff) |
Remove namespace stmsandbox/yuta-d/dev_pm
Change-Id: Id2342c88b532f4d299c011d5ab41450ba670c0ec
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r-- | src/policy_manager/policy_manager.cpp | 219 | ||||
-rw-r--r-- | src/policy_manager/policy_manager.hpp | 21 | ||||
-rw-r--r-- | src/policy_manager/zipc/dummy_stm.h | 7 |
3 files changed, 118 insertions, 129 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp index 347f810..f0b9e9e 100644 --- a/src/policy_manager/policy_manager.cpp +++ b/src/policy_manager/policy_manager.cpp @@ -25,22 +25,20 @@ #include "policy_manager.hpp" #include "hmi-debug.h" -namespace stm { extern "C" { #include "dummy_stm.h" } -} // namespace stm namespace pm { static PolicyManager *g_context; static int transitionStateWrapper(sd_event_source *source, void *data) { - int ret = pm::g_context->transitionState(source, data); + int ret = g_context->transitionState(source, data); return ret; } static int timerEventWrapper(sd_event_source *source, uint64_t usec, void *data) { - int ret = pm::g_context->timerEvent(source, usec, data); + int ret = g_context->timerEvent(source, usec, data); return ret; } @@ -64,19 +62,19 @@ int PolicyManager::initialize() { int ret = 0; // Create convert map - for (int i = stm::StmEvtNoMin; i <= stm::StmEvtNoMax; i++) { - HMI_DEBUG("wm:pm", "event name:%s no:%d", stm::kStmEventName[i], i); - this->eventname2no[stm::kStmEventName[i]] = i; + for (int i = StmEvtNoMin; i <= StmEvtNoMax; i++) { + HMI_DEBUG("wm:pm", "event name:%s no:%d", kStmEventName[i], i); + this->eventname2no[kStmEventName[i]] = i; } - for (int i = stm::StmCtgNoMin; i <= stm::StmCtgNoMax; i++) { - HMI_DEBUG("wm:pm", "category name:%s no:%d", stm::kStmCategoryName[i], i); - this->categoryname2no[stm::kStmCategoryName[i]] = i; + for (int i = StmCtgNoMin; i <= StmCtgNoMax; i++) { + HMI_DEBUG("wm:pm", "category name:%s no:%d", kStmCategoryName[i], i); + this->categoryname2no[kStmCategoryName[i]] = i; } - for (int i = stm::StmAreaNoMin; i <= stm::StmAreaNoMax; i++) { - HMI_DEBUG("wm:pm", "area name:%s no:%d", stm::kStmAreaName[i], i); - this->areaname2no[stm::kStmAreaName[i]] = i; + for (int i = StmAreaNoMin; i <= StmAreaNoMax; i++) { + HMI_DEBUG("wm:pm", "area name:%s no:%d", kStmAreaName[i], i); + this->areaname2no[kStmAreaName[i]] = i; } // Load role.db @@ -97,7 +95,7 @@ int PolicyManager::initialize() { this->initializeState(); // Initialize StateTransitioner - stm::stmInitialize(); + stmInitialize(); // Initialize sd_event loop ret = this->initializeSdEventLoop(); @@ -106,6 +104,7 @@ int PolicyManager::initialize() { return ret; } + // Store instance pm::g_context = this; return ret; @@ -116,8 +115,8 @@ void PolicyManager::initializeCarElementState() { init_car_ele.state = "none"; init_car_ele.changed = false; - for (int i = stm::StmCarElementNoMin; i <= stm::StmCarElementNoMax; i++) { - const char* car_ele_name = stm::kStmCarElementName[i]; + for (int i = StmCarElementNoMin; i <= StmCarElementNoMax; i++) { + const char* car_ele_name = kStmCarElementName[i]; this->crr_car_elements[car_ele_name] = init_car_ele; } @@ -127,14 +126,14 @@ void PolicyManager::initializeCarElementState() { void PolicyManager::initializeLayerState() { AreaState init_area; LayoutState init_layout; - init_area.name = stm::kStmAreaName[stm::StmAreaNoNone]; + init_area.name = kStmAreaName[StmAreaNoNone]; init_area.category = ""; init_area.role = ""; - init_layout.name = stm::kStmLayoutName[stm::StmLayoutNoNone]; + init_layout.name = kStmLayoutName[StmLayoutNoNone]; init_layout.area_list.push_back(init_area); - for (int i = stm::StmLayerNoMin; i <= stm::StmLayerNoMax; i++) { - const char* layer_name = stm::kStmLayerName[i]; + for (int i = StmLayerNoMin; i <= StmLayerNoMax; i++) { + const char* layer_name = kStmLayerName[i]; this->crr_layers[layer_name].name = layer_name; this->crr_layers[layer_name].layout_state = init_layout; this->crr_layers[layer_name].changed = false; @@ -168,7 +167,7 @@ int PolicyManager::initializeSdEventLoop() { } void PolicyManager::addStateToJson(const char* name, bool changed, - std::string state, json_object** json_out) { + std::string state, json_object** json_out) { if ((nullptr == name) || (nullptr == json_out)) { HMI_ERROR("wm:pm", "Invalid argument!!!"); return; @@ -180,7 +179,7 @@ void PolicyManager::addStateToJson(const char* name, bool changed, } void PolicyManager::addStateToJson(const char* layer_name, bool changed, - AreaList area_list, json_object** json_out) { + AreaList area_list, json_object** json_out) { if ((nullptr == layer_name) || (nullptr == json_out)) { HMI_ERROR("wm:pm", "Invalid argument!!!"); return; @@ -192,7 +191,7 @@ void PolicyManager::addStateToJson(const char* layer_name, bool changed, json_tmp = json_object_new_object(); json_object_object_add(json_tmp, "name", json_object_new_string(as.name.c_str())); json_object_object_add(json_tmp, "role", json_object_new_string(as.role.c_str())); - json_object_array_add(json_areas, json_tmp); + json_object_array_add(json_areas, json_tmp); } json_object_object_add(*json_out, "name", json_object_new_string(layer_name)); @@ -200,7 +199,7 @@ void PolicyManager::addStateToJson(const char* layer_name, bool changed, json_object_object_add(*json_out, "areas", json_areas); } -void PolicyManager::updateCarElementState(stm::StmState crr_state) { +void PolicyManager::updateCarElementState(StmState crr_state) { int car_state_no; std::string car_state; bool changed; @@ -210,12 +209,12 @@ void PolicyManager::updateCarElementState(stm::StmState crr_state) { // Update car elements HMI_DEBUG("wm:pm", ">>> CAR ELEMENT"); - for (int car_ele_no = stm::StmCarElementNoMin; - car_ele_no <= stm::StmCarElementNoMax; car_ele_no++) { - const char* car_ele_name = stm::kStmCarElementName[car_ele_no]; + for (int car_ele_no = StmCarElementNoMin; + car_ele_no <= StmCarElementNoMax; car_ele_no++) { + const char* car_ele_name = kStmCarElementName[car_ele_no]; car_state_no = crr_state.car_element[car_ele_no].state; - car_state = stm::kStmCarStateNameList[car_ele_no][car_state_no]; + car_state = kStmCarStateNameList[car_ele_no][car_state_no]; changed = (crr_state.car_element[car_ele_no].changed) ? true : false; this->crr_car_elements[car_ele_name].state = car_state; @@ -227,17 +226,17 @@ void PolicyManager::updateCarElementState(stm::StmState crr_state) { } } -void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { +void PolicyManager::updateLayerState(int event_id, StmState crr_state) { int event_no, category_no, area_no; - event_no = STM_GET_EVENT_FROM_ID(event_data); - category_no = STM_GET_CATEGORY_FROM_ID(event_data); - area_no = STM_GET_AREA_FROM_ID(event_data); + event_no = STM_GET_EVENT_FROM_ID(event_id); + category_no = STM_GET_CATEGORY_FROM_ID(event_id); + area_no = STM_GET_AREA_FROM_ID(event_id); - std::string req_evt = stm::kStmEventName[event_no]; - std::string req_ctg = stm::kStmCategoryName[category_no]; - std::string req_area = stm::kStmAreaName[area_no]; - std::string req_role = this->req_role_list[event_data]; + std::string req_evt = kStmEventName[event_no]; + std::string req_ctg = kStmCategoryName[category_no]; + std::string req_area = kStmAreaName[area_no]; + std::string req_role = this->req_role_list[event_id]; 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()); @@ -245,16 +244,16 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { this->prv_layers = this->crr_layers; // Update layers - for (int layer_no = stm::StmLayerNoMin; - layer_no <= stm::StmLayerNoMax; layer_no++) { - const char* layer_name = stm::kStmLayerName[layer_no]; + for (int layer_no = StmLayerNoMin; + layer_no <= StmLayerNoMax; layer_no++) { + const char* layer_name = kStmLayerName[layer_no]; HMI_DEBUG("wm:pm", "LAYER:%s", layer_name); #if 1 // If restriction mode is changed off -> on, // store current state for state of restriction mode off - if ((crr_state.car_element[stm::StmCarElementNoRestrictionMode].changed) - && (stm::StmRestrictionModeSttNoOn == crr_state.car_element[stm::StmCarElementNoRestrictionMode].state)) { + if ((crr_state.car_element[StmCarElementNoRestrictionMode].changed) + && (StmRestrictionModeSttNoOn == crr_state.car_element[StmCarElementNoRestrictionMode].state)) { HMI_DEBUG("wm:pm", "Store current state for state of restriction mode off"); this->prv_layers_car_stop[layer_name] = this->crr_layers[layer_name]; } @@ -262,7 +261,7 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { // If car state is changed car_stop -> car_run, // store current state for state of car stop if ((crr_state.car.changed) - && (stm::StmRunningNoRun == crr_state.car.state)) { + && (StmRunningNoRun == crr_state.car.state)) { HMI_DEBUG("wm:pm", "Store current state for state of car stop"); this->prv_layers_car_stop[layer_name] = this->crr_layers[layer_name]; } @@ -279,18 +278,18 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { // Get current layout name of this layer int crr_layout_state_no = crr_state.layer[layer_no].state; - std::string crr_layout_name = std::string(stm::kStmLayoutName[crr_layout_state_no]); + std::string crr_layout_name = std::string(kStmLayoutName[crr_layout_state_no]); LayoutState crr_layout_state; #if 1 - if ((crr_state.car_element[stm::StmCarElementNoRestrictionMode].changed) - && (stm::StmRestrictionModeSttNoOff == crr_state.car_element[stm::StmCarElementNoRestrictionMode].state)) { + if ((crr_state.car_element[StmCarElementNoRestrictionMode].changed) + && (StmRestrictionModeSttNoOff == crr_state.car_element[StmCarElementNoRestrictionMode].state)) { // If restriction mode is changed on -> off, // restore state of restriction mode off HMI_DEBUG("wm:pm", "Restriction mode is changed on -> off, so restore state of restriction mode off"); #else - if ((crr_state.car_element[stm::StmCarElementNoRunning].changed) - && (stm::StmCarElementNoStop == crr_state.car_element[stm::StmCarElementNoRunning].state)) { + if ((crr_state.car_element[StmCarElementNoRunning].changed) + && (StmCarElementNoStop == crr_state.car_element[StmCarElementNoRunning].state)) { // If car state is changed car_run -> car_stop, // restore state of car stop HMI_DEBUG("wm:pm", "Car state is changed car_run -> car_stop, so restore state of car stop"); @@ -298,12 +297,12 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { crr_layout_state = this->prv_layers_car_stop[layer_name].layout_state; crr_layout_name = crr_layout_state.name; if ((prv_layout_name == crr_layout_name) - && (stm::kStmAreaName[stm::StmAreaNoNone] == crr_layout_name)) { + && (kStmAreaName[StmAreaNoNone] == crr_layout_name)) { changed = 0; } } else if ((prv_layout_name == crr_layout_name) - && (stm::kStmAreaName[stm::StmAreaNoNone] == crr_layout_name)) { + && (kStmAreaName[StmAreaNoNone] == crr_layout_name)) { // Copy previous layout state for current crr_layout_state = prv_layout_state; changed = 0; @@ -328,9 +327,9 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { // Create candidate list std::map<std::string, AreaList> cand_list; - for (int ctg_no=stm::StmCtgNoMin; - ctg_no<=stm::StmCtgNoMax; ctg_no++) { - const char* ctg = stm::kStmCategoryName[ctg_no]; + for (int ctg_no=StmCtgNoMin; + ctg_no<=StmCtgNoMax; ctg_no++) { + const char* ctg = kStmCategoryName[ctg_no]; HMI_DEBUG("wm:pm", "ctg:%s", ctg); // Create candidate list for category from the previous displayed categories @@ -447,8 +446,8 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { this->crr_layers[layer_name].changed = (changed) ? true : false; } - // Erase role for the event_data from list - this->req_role_list.erase(event_data); + // Erase role for the event_id from list + this->req_role_list.erase(event_id); // Check for (auto itr : this->crr_layers) { @@ -465,12 +464,12 @@ void PolicyManager::updateLayerState(int event_data, stm::StmState crr_state) { } } -void PolicyManager::updateState(int event_data, stm::StmState crr_state) { +void PolicyManager::updateState(int event_id, StmState crr_state) { this->updateCarElementState(crr_state); - this->updateLayerState(event_data, crr_state); + this->updateLayerState(event_id, crr_state); } -void PolicyManager::createOutputInformation(stm::StmState crr_state, json_object **json_out) { +void PolicyManager::createOutputInformation(StmState crr_state, json_object **json_out) { json_object* json_tmp; // Create car element information @@ -485,14 +484,14 @@ void PolicyManager::createOutputInformation(stm::StmState crr_state, json_object // }, json_object* json_car_ele = json_object_new_array(); const char* car_ele_name; - for (int car_ele_no = stm::StmCarElementNoMin; - car_ele_no <= stm::StmCarElementNoMax; car_ele_no++) { - car_ele_name = stm::kStmCarElementName[car_ele_no]; + for (int car_ele_no = StmCarElementNoMin; + car_ele_no <= StmCarElementNoMax; car_ele_no++) { + car_ele_name = kStmCarElementName[car_ele_no]; json_tmp = json_object_new_object(); this->addStateToJson(car_ele_name, - this->crr_car_elements[car_ele_name].changed, - this->crr_car_elements[car_ele_name].state, - &json_tmp); + this->crr_car_elements[car_ele_name].changed, + this->crr_car_elements[car_ele_name].state, + &json_tmp); json_object_array_add(json_car_ele, json_tmp); } json_object_object_add(*json_out, "car_elements", json_car_ele); @@ -515,32 +514,32 @@ void PolicyManager::createOutputInformation(stm::StmState crr_state, json_object // ... json_object* json_layer = json_object_new_array(); const char* layer_name; - for (int layer_no = stm::StmLayerNoMin; - layer_no <= stm::StmLayerNoMax; layer_no++) { - layer_name = stm::kStmLayerName[layer_no]; + for (int layer_no = StmLayerNoMin; + layer_no <= StmLayerNoMax; layer_no++) { + layer_name = kStmLayerName[layer_no]; json_tmp = json_object_new_object(); this->addStateToJson(layer_name, - this->crr_layers[layer_name].changed, - this->crr_layers[layer_name].layout_state.area_list, - &json_tmp); + this->crr_layers[layer_name].changed, + this->crr_layers[layer_name].layout_state.area_list, + &json_tmp); json_object_array_add(json_layer, json_tmp); } json_object_object_add(*json_out, "layers", json_layer); } -void PolicyManager::controlTimerEvent(stm::StmState crr_state) { - if (crr_state.car_element[stm::StmCarElementNoRunning].changed) { - if (stm::StmRunningNoRun == crr_state.car_element[stm::StmCarElementNoRunning].state) { +void PolicyManager::controlTimerEvent(StmState crr_state) { + if (crr_state.car_element[StmCarElementNoRunning].changed) { + if (StmRunningNoRun == crr_state.car_element[StmCarElementNoRunning].state) { // Set delay event(restriction mode on) - this->setStateTransitionProcessToSystemd(stm::StmEvtNoRestrictionModeOn, 3000, ""); + this->setStateTransitionProcessToSystemd(StmEvtNoRestrictionModeOn, 3000, ""); } - else if (stm::StmRunningNoStop == crr_state.car_element[stm::StmCarElementNoRunning].state) { + else if (StmRunningNoStop == crr_state.car_element[StmCarElementNoRunning].state) { // Stop timer for restriction on event - if (this->event_source_list.find(stm::StmEvtNoRestrictionModeOn) + if (this->event_source_list.find(StmEvtNoRestrictionModeOn) != this->event_source_list.end()) { HMI_DEBUG("wm:pm", "Stop timer for restriction on"); sd_event_source *event_source - = this->event_source_list[stm::StmEvtNoRestrictionModeOn]; + = this->event_source_list[StmEvtNoRestrictionModeOn]; int ret = sd_event_source_set_enabled(event_source, SD_EVENT_OFF); if (0 > ret) { HMI_ERROR("wm:pm", "Failed to stop timer"); @@ -548,7 +547,7 @@ void PolicyManager::controlTimerEvent(stm::StmState crr_state) { } // Set event(restriction mode off) - this->setStateTransitionProcessToSystemd(stm::StmEvtNoRestrictionModeOff, 0, ""); + this->setStateTransitionProcessToSystemd(StmEvtNoRestrictionModeOff, 0, ""); } } } @@ -557,20 +556,20 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) { HMI_DEBUG("wm:pm", "Call"); HMI_DEBUG("wm:pm", ">>>>>>>>>> START CHECK POLICY"); - int event_data = *((int*)data); + int event_id = *((int*)data); int event_no, category_no, area_no; - event_no = STM_GET_EVENT_FROM_ID(event_data); - category_no = STM_GET_CATEGORY_FROM_ID(event_data); - area_no = STM_GET_AREA_FROM_ID(event_data); + event_no = STM_GET_EVENT_FROM_ID(event_id); + category_no = STM_GET_CATEGORY_FROM_ID(event_id); + area_no = STM_GET_AREA_FROM_ID(event_id); HMI_DEBUG("wm:pm", ">>>>>>>>>> event:%s category:%s area:%s", - stm::kStmEventName[event_no], - stm::kStmCategoryName[category_no], - stm::kStmAreaName[area_no]); + kStmEventName[event_no], + kStmCategoryName[category_no], + kStmAreaName[area_no]); // Transition state - stm::StmState crr_state; - int ret = stm::stmTransitionState(event_data, &crr_state); + StmState crr_state; + int ret = stmTransitionState(event_id, &crr_state); if (0 > ret) { HMI_ERROR("wm:pm", "Failed transition state"); if (nullptr != this->callback.onError) { @@ -578,11 +577,11 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) { json_object_object_add(json_out, "message", json_object_new_string("Failed to transition state")); json_object_object_add(json_out, "event", - json_object_new_string(stm::kStmEventName[event_no])); + json_object_new_string(kStmEventName[event_no])); json_object_object_add(json_out, "role", - json_object_new_string(this->req_role_list[event_data].c_str())); + json_object_new_string(this->req_role_list[event_id].c_str())); json_object_object_add(json_out, "area", - json_object_new_string(stm::kStmAreaName[area_no])); + json_object_new_string(kStmAreaName[area_no])); this->callback.onError(json_out); json_object_put(json_out); } @@ -590,7 +589,7 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) { } // Update state which is managed by PolicyManager - this->updateState(event_data, crr_state); + this->updateState(event_id, crr_state); // Create output information for ResourceManager json_object* json_out = json_object_new_object(); @@ -614,8 +613,8 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) { sd_event_source_unref(source); // Remove event source from list - if (this->event_source_list.find(event_data) != this->event_source_list.end()) { - this->event_source_list.erase(event_data); + if (this->event_source_list.find(event_id) != this->event_source_list.end()) { + this->event_source_list.erase(event_id); } HMI_DEBUG("wm:pm", ">>>>>>>>>> FINISH CHECK POLICY"); @@ -629,20 +628,20 @@ int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data return ret; } -int PolicyManager::setStateTransitionProcessToSystemd(int event, uint64_t delay_ms, std::string role) +int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t delay_ms, std::string role) { HMI_DEBUG("wm:pm", "Call"); - HMI_DEBUG("wm:pm", "event:0x%x delay:%d role:%s", event, delay_ms, role.c_str()); + HMI_DEBUG("wm:pm", "event_id:0x%x delay:%d role:%s", event_id, delay_ms, role.c_str()); // Store requested role - this->req_role_list[event] = role; + this->req_role_list[event_id] = role; if (0 == delay_ms) { int ret = sd_event_add_defer(this->event_loop, NULL, - &pm::transitionStateWrapper, new int(event)); + &pm::transitionStateWrapper, new int(event_id)); if (0 > ret) { HMI_ERROR("wm:pm", "Faild to sd_event_add_defer: errno:%d", ret); - this->req_role_list.erase(event); + this->req_role_list.erase(event_id); return -1; } } @@ -659,15 +658,15 @@ int PolicyManager::setStateTransitionProcessToSystemd(int event, uint64_t delay_ // Set timer struct sd_event_source* event_source; int ret = sd_event_add_time(this->event_loop, &event_source, CLOCK_MONOTONIC, usec, 1, - &pm::timerEventWrapper, new int(event)); + &pm::timerEventWrapper, new int(event_id)); if (0 > ret) { HMI_ERROR("wm:pm", "Faild to sd_event_add_time: errno:%d", ret); - this->req_role_list.erase(event); + this->req_role_list.erase(event_id); return -1; } // Store event source - this->event_source_list[event] = event_source; + this->event_source_list[event_id] = event_source; } return 0; @@ -691,7 +690,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::StmEvtNoNone; + int event_no = StmEvtNoNone; if (nullptr != event) { // Convert name to number auto itr = this->eventname2no.find(event); @@ -711,7 +710,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::StmCtgNoNone; + int category_no = StmCtgNoNone; if (nullptr != role) { HMI_DEBUG("wm:pm", "role(%s)", role); @@ -727,13 +726,13 @@ int PolicyManager::setInputEventData(json_object* json_in) { } } - if (stm::StmCtgNoNone == category_no) { + if (StmCtgNoNone == category_no) { role = ""; } // Get areat from json_object const char* area = this->getStringFromJson(json_in, "area"); - int area_no = stm::StmAreaNoNone; + int area_no = StmAreaNoNone; if (nullptr != area) { auto itr = this->areaname2no.find(area); if (this->areaname2no.end() != itr) { @@ -743,8 +742,8 @@ int PolicyManager::setInputEventData(json_object* json_in) { } // If role is set and area is not set, use default area - if ((stm::StmAreaNoNone == area_no) - && (stm::StmCtgNoNone != category_no)) { + if ((StmAreaNoNone == area_no) + && (StmCtgNoNone != 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); @@ -782,7 +781,7 @@ void PolicyManager::undoState() { HMI_DEBUG("wm:pm", "Call"); // Undo state of STM - stm::stmUndoState(); + stmUndoState(); this->crr_layers = this->prv_layers; } @@ -942,9 +941,9 @@ int PolicyManager::loadLayoutDb() { LayoutState layout_state; AreaState area_state; std::map<std::string, int> category_num; - for (int ctg_no = stm::StmCtgNoMin; - ctg_no <= stm::StmCtgNoMax; ctg_no++) { - const char* ctg_name = stm::kStmCategoryName[ctg_no]; + for (int ctg_no = StmCtgNoMin; + ctg_no <= StmCtgNoMax; ctg_no++) { + const char* ctg_name = kStmCategoryName[ctg_no]; category_num[ctg_name] = 0; } diff --git a/src/policy_manager/policy_manager.hpp b/src/policy_manager/policy_manager.hpp index 47f7d26..6f87e00 100644 --- a/src/policy_manager/policy_manager.hpp +++ b/src/policy_manager/policy_manager.hpp @@ -25,10 +25,8 @@ struct json_object; struct sd_event; struct sd_event_source; - -namespace stm { struct StmState; -} + class PolicyManager { @@ -99,14 +97,13 @@ private: std::unordered_map<std::string, std::string> category2role; std::unordered_map<std::string, std::string> role2defaultarea; - std::queue<EventInfo> event_info_queue; - struct sd_event* event_loop; - CallbackTable callback; - + std::queue<EventInfo> event_info_queue; std::map<int, struct sd_event_source*> event_source_list; std::map<int, std::string> req_role_list; + CallbackTable callback; + std::unordered_map<std::string, CarElement> prv_car_elements; std::unordered_map<std::string, CarElement> crr_car_elements; @@ -121,11 +118,11 @@ private: void initializeCarElementState(); void initializeLayerState(); int initializeSdEventLoop(); - void updateState(int event_data, stm::StmState crr_state); - void updateCarElementState(stm::StmState crr_state); - void updateLayerState(int event_data, stm::StmState crr_state); - void createOutputInformation(stm::StmState crr_state, json_object **json_out); - void controlTimerEvent(stm::StmState crr_state); + void updateState(int event_data, StmState crr_state); + void updateCarElementState(StmState crr_state); + void updateLayerState(int event_data, StmState crr_state); + void createOutputInformation(StmState crr_state, json_object **json_out); + void controlTimerEvent(StmState crr_state); int setStateTransitionProcessToSystemd(int event, uint64_t delay_ms, std::string role); // Load role.db diff --git a/src/policy_manager/zipc/dummy_stm.h b/src/policy_manager/zipc/dummy_stm.h index 9a1df3c..8da05e2 100644 --- a/src/policy_manager/zipc/dummy_stm.h +++ b/src/policy_manager/zipc/dummy_stm.h @@ -201,13 +201,6 @@ typedef struct StmState { StmBaseState layer[StmLayerNoNum]; } StmState; -#if 0 -struct stm_state_t { - stm_base_state car_element[gStmCarElementNoNum]; - stm_base_state layer[gStmLayerNoNum]; -}; -typedef struct stm_state_t stm_state_t; -#endif // API void stmInitialize(); |