category_no = ((event_data & STM_MSK_CTG_NO) >> 8) - 1;
area_no = ((event_data & STM_MSK_ARA_NO) >> 16) - 1;
- std::string req_role = pm::g_req_role_list[event_data];
std::string req_evt = std::string(stm::gStmEventName[event_no]);
std::string req_ctg = std::string(stm::gStmCategoryName[category_no]);
std::string req_area = std::string(stm::gStmAreaName[area_no]);
- HMI_DEBUG("wm:pm", "REQ: event:%s role%s category:%s area:%s",
+ 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());
// Store previous layers
}
}
+ // Erase role for the event_data from list
+ pm::g_req_role_list.erase(event_data);
+
// Check
for (auto itr : pm::g_crr_layers) {
pm::LayerState ls = itr.second;
}
}
-void createOutputInformation(stm::stm_state_t crr_state, json_object **json_out) {
+static void createOutputInformation(stm::stm_state_t crr_state, json_object **json_out) {
// Create result
// {
// "parking_brake": {
}
static int checkPolicyEntry(int event, uint64_t delay_ms, std::string role);
+static void controlTimerEvent(stm::stm_state_t crr_state) {
+ if (crr_state.car.is_changed) {
+ if (stm::gStmCarStateNoRun == crr_state.car.state) {
+ // Set delay event(restriction mode on)
+ checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_ON, 3000, "");
+ }
+ else if (stm::gStmCarStateNoStop == crr_state.car.state) {
+ // Stop timer for restriction on event
+ if (pm::event_source_list.find(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];
+ int ret = sd_event_source_set_enabled(event_source, SD_EVENT_OFF);
+ if (0 > ret) {
+ HMI_ERROR("wm:pm", "Failed to stop timer");
+ }
+ }
+
+ // Set event(restriction mode off)
+ checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_OFF, 0, "");
+ }
+ }
+}
+
static int checkPolicy(sd_event_source *source, void *data) {
HMI_DEBUG("wm:pm", "Call");
HMI_DEBUG("wm:pm", ">>>>>>>>>> START CHECK POLICY");
stm::stm_state_t crr_state;
int ret = stm::stmTransitionState(event_data, &crr_state);
if (0 > ret) {
- HMI_ERROR("wm:pm", "Error!!");
+ HMI_ERROR("wm:pm", "Failed transition state");
+ if (nullptr != pm::callback.onError) {
+ json_object* json_out = json_object_new_object();
+ 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::gStmEventName[event_no]));
+ json_object_object_add(json_out, "role",
+ json_object_new_string(pm::g_req_role_list[event_data].c_str()));
+ json_object_object_add(json_out, "area",
+ json_object_new_string(stm::gStmAreaName[area_no]));
+ pm::callback.onError(json_out);
+ json_object_put(json_out);
+ }
return -1;
}
json_object* json_out = json_object_new_object();
createOutputInformation(crr_state, &json_out);
- // Notify state is changed
+ // Notify changed state
if (nullptr != pm::callback.onStateTransitioned) {
pm::callback.onStateTransitioned(json_out);
}
- // Start/Stop timer event
- if (crr_state.car.is_changed) {
- if (stm::gStmCarStateNoRun == crr_state.car.state) {
- // Set delay event(restriction mode on)
- checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_ON, 3000, "");
- }
- else if (stm::gStmCarStateNoStop == crr_state.car.state) {
- // Set event(restriction mode off)
- checkPolicyEntry(STM_EVT_NO_RESTRICTION_MODE_OFF, 0, "");
-
- // Stop timer for restriction on event
- if (pm::event_source_list.find(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];
- int ret = sd_event_source_set_enabled(event_source, SD_EVENT_OFF);
- if (0 > ret) {
- HMI_ERROR("wm:pm", "Failed to stop timer");
- }
- }
- }
- }
+ // Start/Stop timer events
+ controlTimerEvent(crr_state);
// Release json_object
json_object_put(json_out);