aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/app.cpp14
-rw-r--r--src/app.hpp4
-rw-r--r--src/policy_manager/policy_manager.cpp160
3 files changed, 103 insertions, 75 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 7d2f121..a30a963 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -96,11 +96,12 @@ struct result<layer_map> load_layer_map(char const *filename) {
namespace rm {
App *context;
static void eventHandler(json_object* json_out) {
- context->updateWindowResource(json_out);
+ context->updateWindowResources(json_out);
}
} // namespace rm
-void App::updateWindowResource(json_object* json_out) {
+
+void App::updateCarStates(json_object* json_out) {
// Check parking brake state
json_object* json_parking_brake;
if (!json_object_object_get_ex(json_out, "parking_brake", &json_parking_brake)) {
@@ -238,7 +239,9 @@ void App::updateWindowResource(json_object* json_out) {
return;
}
}
+}
+void App::updateLayers(json_object* json_out) {
// Get displayed roles from current layout
json_object* json_layers;
if (!json_object_object_get_ex(json_out, "layers", &json_layers)) {
@@ -320,6 +323,13 @@ void App::updateWindowResource(json_object* json_out) {
}
}
+void App::updateWindowResources(json_object* json_out) {
+ // Update car states
+ this->updateCarStates(json_out);
+
+ // Update layers
+ this->updateLayers(json_out);
+}
/**
* App Impl
diff --git a/src/app.hpp b/src/app.hpp
index 207a7e5..84b02c0 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -248,7 +248,7 @@ struct App {
void surface_removed(uint32_t surface_id);
void setAccelPedalPos(double val);
- void updateWindowResource(json_object* json_out);
+ void updateWindowResources(json_object* json_out);
private:
typedef std::map<std::string, std::string> RoleState;
@@ -261,6 +261,8 @@ private:
CarInfo crr_car_info_;
std::map<std::string, RoleState> crr_layer_state;
+ void updateCarStates(json_object* json_out);
+ void updateLayers(json_object* json_out);
void setSurfaceSize(const char* role, const char* area);
int loadAppDb();
const char* convertDrawingNameToRole(char const *drawing_name);
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index 0f7dc27..c15936d 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -203,73 +203,12 @@ static void addStateToJson(const char* layer_name, unsigned int changed,
json_object_object_add(*json_out, "areas", json_areas);
}
-static int checkPolicyEntry(int event, uint64_t delay_ms, std::string role);
-static int checkPolicy(sd_event_source *source, void *data) {
- HMI_DEBUG("wm:pm", "Call");
- HMI_DEBUG("wm:pm", ">>>>>>>>>> START CHECK POLICY");
-
- int event_data = *((int*)data);
-
+static void updateLocalState(int event_data, stm::stm_state_t crr_state) {
int event_no, category_no, area_no;
+
event_no = (event_data & STM_MSK_EVT_NO) - 1;
category_no = ((event_data & STM_MSK_CTG_NO) >> 8) - 1;
area_no = ((event_data & STM_MSK_ARA_NO) >> 16) - 1;
- HMI_DEBUG("wm:pm", ">>>>>>>>>> event:%s category:%s area:%s",
- stm::gStmEventName[event_no],
- stm::gStmCategoryName[category_no],
- stm::gStmAreaName[area_no]);
-
- // Transition state
- stm::stm_state_t crr_state;
- int ret = stm::stmTransitionState(event_data, &crr_state);
- if (0 > ret) {
- HMI_ERROR("wm:pm", "Error!!");
- return -1;
- }
-
- HMI_DEBUG("wm:pm", "parking brake state (is_changed:%d state:%d:%s)",
- crr_state.parking_brake.is_changed,
- crr_state.parking_brake.state,
- stm::gStmParkingBrakeStateNo2Name[crr_state.parking_brake.state]);
- HMI_DEBUG("wm:pm", "accelerator pedal state (is_changed:%d state:%d:%s)",
- crr_state.accel_pedal.is_changed,
- crr_state.accel_pedal.state,
- stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state]);
- HMI_DEBUG("wm:pm", "lightstatus brake state (is_changed:%d state:%d:%s)",
- crr_state.lightstatus_brake.is_changed,
- crr_state.lightstatus_brake.state,
- stm::gStmLightstatusBrakeStateNo2Name[crr_state.lightstatus_brake.state]);
- HMI_DEBUG("wm:pm", "car state (is_changed:%d state:%d:%s)",
- crr_state.car.is_changed,
- crr_state.car.state,
- stm::gStmCarStateNo2Name[crr_state.car.state]);
- HMI_DEBUG("wm:pm", "lamp state (is_changed:%d state:%d:%s)",
- crr_state.lamp.is_changed,
- crr_state.lamp.state,
- stm::gStmLampStateNo2Name[crr_state.lamp.state]);
- HMI_DEBUG("wm:pm", "restriction mode state (is_changed:%d state:%d:%s)",
- crr_state.restriction_mode.is_changed,
- crr_state.restriction_mode.state,
- stm::gStmRestrictionModeStateNo2Name[crr_state.restriction_mode.state]);
- HMI_DEBUG("wm:pm", "homescreen state (is_changed:%d state:%d:%s)",
- crr_state.layer[stm::gStmLayerNoHomescreen].is_changed,
- crr_state.layer[stm::gStmLayerNoHomescreen].state,
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoHomescreen].state]);
- HMI_DEBUG("wm:pm", "apps state (is_changed:%d state:%d:%s)",
- crr_state.layer[stm::gStmLayerNoApps].is_changed,
- crr_state.layer[stm::gStmLayerNoApps].state,
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoApps].state]);
- HMI_DEBUG("wm:pm", "restriction state (is_changed:%d state:%d:%s)",
- crr_state.layer[stm::gStmLayerNoRestriction].is_changed,
- crr_state.layer[stm::gStmLayerNoRestriction].state,
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoRestriction].state]);
- HMI_DEBUG("wm:pm", "on_screen state (is_changed:%d state:%d:%s)",
- crr_state.layer[stm::gStmLayerNoOnScreen].is_changed,
- crr_state.layer[stm::gStmLayerNoOnScreen].state,
- stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoOnScreen].state]);
-
- // Store previous layers
- pm::g_prv_layers = pm::g_crr_layers;
std::string req_role = pm::g_req_role_list[event_data];
std::string req_evt = std::string(stm::gStmEventName[event_no]);
@@ -278,6 +217,9 @@ static int checkPolicy(sd_event_source *source, void *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
+ pm::g_prv_layers = pm::g_crr_layers;
+
// Update layers
for (int layer_no = stm::gStmLayerNoMin;
layer_no <= stm::gStmLayerNoMax; layer_no++) {
@@ -477,9 +419,9 @@ static int checkPolicy(sd_event_source *source, void *data) {
HMI_DEBUG("wm:pm", ">>> >>> >>> >>> ROLE:%s", as.role.c_str());
}
}
+}
- json_object* json_out = json_object_new_object();
-
+void createOutputInformation(stm::stm_state_t crr_state, json_object **json_out) {
// Create result
// {
// "parking_brake": {
@@ -489,7 +431,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("parking_brake",
crr_state.parking_brake.is_changed,
stm::gStmParkingBrakeStateNo2Name[crr_state.parking_brake.state],
- &json_out);
+ json_out);
// "accel_pedal": {
// "is_changed": <bool>,
@@ -498,7 +440,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("accel_pedal",
crr_state.accel_pedal.is_changed,
stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state],
- &json_out);
+ json_out);
// "lightstatus_brake": {
// "is_changed": <bool>,
@@ -507,7 +449,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("lightstatus_brake",
crr_state.lightstatus_brake.is_changed,
stm::gStmLightstatusBrakeStateNo2Name[crr_state.lightstatus_brake.state],
- &json_out);
+ json_out);
// "car": {
// "is_changed": <bool>,
@@ -516,7 +458,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("car",
crr_state.car.is_changed,
stm::gStmCarStateNo2Name[crr_state.car.state],
- &json_out);
+ json_out);
// "lamp": {
// "is_changed": <bool>,
@@ -525,7 +467,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("lamp",
crr_state.lamp.is_changed,
stm::gStmLampStateNo2Name[crr_state.lamp.state],
- &json_out);
+ json_out);
// "restriction_mode": {
// "is_changed": <bool>,
@@ -534,7 +476,7 @@ static int checkPolicy(sd_event_source *source, void *data) {
addStateToJson("restriction_mode",
crr_state.restriction_mode.is_changed,
stm::gStmRestrictionModeStateNo2Name[crr_state.restriction_mode.state],
- &json_out);
+ json_out);
// Create layout information
//
@@ -568,13 +510,87 @@ static int checkPolicy(sd_event_source *source, void *data) {
}
// Add json array of layer
- json_object_object_add(json_out, "layers", json_layer);
+ json_object_object_add(*json_out, "layers", json_layer);
+}
+
+static int checkPolicyEntry(int event, uint64_t delay_ms, std::string role);
+static int checkPolicy(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_no, category_no, area_no;
+ event_no = (event_data & STM_MSK_EVT_NO) - 1;
+ category_no = ((event_data & STM_MSK_CTG_NO) >> 8) - 1;
+ area_no = ((event_data & STM_MSK_ARA_NO) >> 16) - 1;
+ HMI_DEBUG("wm:pm", ">>>>>>>>>> event:%s category:%s area:%s",
+ stm::gStmEventName[event_no],
+ stm::gStmCategoryName[category_no],
+ stm::gStmAreaName[area_no]);
+
+ // Transition state
+ stm::stm_state_t crr_state;
+ int ret = stm::stmTransitionState(event_data, &crr_state);
+ if (0 > ret) {
+ HMI_ERROR("wm:pm", "Error!!");
+ return -1;
+ }
+
+ HMI_DEBUG("wm:pm", "parking brake state (is_changed:%d state:%d:%s)",
+ crr_state.parking_brake.is_changed,
+ crr_state.parking_brake.state,
+ stm::gStmParkingBrakeStateNo2Name[crr_state.parking_brake.state]);
+ HMI_DEBUG("wm:pm", "accelerator pedal state (is_changed:%d state:%d:%s)",
+ crr_state.accel_pedal.is_changed,
+ crr_state.accel_pedal.state,
+ stm::gStmAccelPedalStateNo2Name[crr_state.accel_pedal.state]);
+ HMI_DEBUG("wm:pm", "lightstatus brake state (is_changed:%d state:%d:%s)",
+ crr_state.lightstatus_brake.is_changed,
+ crr_state.lightstatus_brake.state,
+ stm::gStmLightstatusBrakeStateNo2Name[crr_state.lightstatus_brake.state]);
+ HMI_DEBUG("wm:pm", "car state (is_changed:%d state:%d:%s)",
+ crr_state.car.is_changed,
+ crr_state.car.state,
+ stm::gStmCarStateNo2Name[crr_state.car.state]);
+ HMI_DEBUG("wm:pm", "lamp state (is_changed:%d state:%d:%s)",
+ crr_state.lamp.is_changed,
+ crr_state.lamp.state,
+ stm::gStmLampStateNo2Name[crr_state.lamp.state]);
+ HMI_DEBUG("wm:pm", "restriction mode state (is_changed:%d state:%d:%s)",
+ crr_state.restriction_mode.is_changed,
+ crr_state.restriction_mode.state,
+ stm::gStmRestrictionModeStateNo2Name[crr_state.restriction_mode.state]);
+ HMI_DEBUG("wm:pm", "homescreen state (is_changed:%d state:%d:%s)",
+ crr_state.layer[stm::gStmLayerNoHomescreen].is_changed,
+ crr_state.layer[stm::gStmLayerNoHomescreen].state,
+ stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoHomescreen].state]);
+ HMI_DEBUG("wm:pm", "apps state (is_changed:%d state:%d:%s)",
+ crr_state.layer[stm::gStmLayerNoApps].is_changed,
+ crr_state.layer[stm::gStmLayerNoApps].state,
+ stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoApps].state]);
+ HMI_DEBUG("wm:pm", "restriction state (is_changed:%d state:%d:%s)",
+ crr_state.layer[stm::gStmLayerNoRestriction].is_changed,
+ crr_state.layer[stm::gStmLayerNoRestriction].state,
+ stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoRestriction].state]);
+ HMI_DEBUG("wm:pm", "on_screen state (is_changed:%d state:%d:%s)",
+ crr_state.layer[stm::gStmLayerNoOnScreen].is_changed,
+ crr_state.layer[stm::gStmLayerNoOnScreen].state,
+ stm::gStmLayoutNo2Name[crr_state.layer[stm::gStmLayerNoOnScreen].state]);
+
+ // Update state which is managed by PolicyManager
+ updateLocalState(event_data, crr_state);
+
+ // Create output information for ResourceManager
+ json_object* json_out = json_object_new_object();
+ createOutputInformation(crr_state, &json_out);
// Notify state is changed
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)