aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-06-20 17:44:29 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-06-20 17:44:29 +0900
commitd3125b444d35384eb6db60462c184717e20fca82 (patch)
tree533c467a43630b60fb4aada1fac06048213012b1
parentf509e0a79eef109e77532b9e391f07609e296b87 (diff)
Segment process for control timer event
Change-Id: Ie13b7067095c7be0f2cac26150b9cc37650c374e Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/policy_manager/policy_manager.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index bb5b14c..6ae80c6 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -424,7 +424,7 @@ static void updateLocalState(int event_data, stm::stm_state_t crr_state) {
}
}
-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": {
@@ -517,6 +517,31 @@ void createOutputInformation(stm::stm_state_t crr_state, json_object **json_out)
}
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");
@@ -601,34 +626,13 @@ static int checkPolicy(sd_event_source *source, void *data) {
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);