} catch (std::exception &e) {
HMI_ERROR("wm", "Loading of configuration failed: %s", e.what());
}
+
+ // Initialize current car info
+ this->crr_car_info_.parking_brake_stt = true;
+ this->crr_car_info_.accel_pedal_stt = false;
+ this->crr_car_info_.accel_pedal_pos = 0;
+ this->crr_car_info_.car_stt = "stop";
+ this->crr_car_info_.headlamp_stt = false;
}
int App::init() {
// This process will be removed
// because the area "normal.full" and "normalfull" will be prohibited
{
- if (nullptr == drawing_area) {
- new_area = "normal";
- }
- else if (0 == strcmp("normal.full", drawing_area)) {
- new_area = "normal";
- }
- else if (0 == strcmp("restriction.split.sub", drawing_area)) {
- new_area = "restriction.split.sub";
- }
- else if (0 == strcmp("homescreen", new_role)) {
- // Now homescreen specifies "normalfull"
- new_area = "full";
+ if (0 == strcmp("Restriction", drawing_name)) {
+ new_area = drawing_area;
}
else {
- new_area = "normal";
+ if (nullptr == drawing_area) {
+ new_area = "normal";
+ }
+ else if (0 == strcmp("normal.full", drawing_area)) {
+ new_area = "normal";
+ }
+ else if (0 == strcmp("restriction.split.sub", drawing_area)) {
+ new_area = "restriction.split.sub";
+ }
+ else if (0 == strcmp("homescreen", new_role)) {
+ // Now homescreen specifies "normalfull"
+ new_area = "full";
+ }
+ else {
+ new_area = "normal";
+ }
}
HMI_DEBUG("wm", "drawing_area:%s, new_area: %s", drawing_area, new_area);
}
json_bool is_changed;
is_changed = jh::getBoolFromJson(json_parking_brake, "is_changed");
if (is_changed) {
- // Update parking brake state
std::string parking_brake_state = jh::getStringFromJson(json_parking_brake, "state");
HMI_DEBUG("wm", "parking_brake_state: %s", parking_brake_state.c_str());
- // Emit parking brake event
+ // Update state and emit event
if ("parking_brake_off" == parking_brake_state) {
+ this->crr_car_info_.parking_brake_stt = false;
this->emitParkingBrakeOff();
}
else if ("parking_brake_on" == parking_brake_state) {
+ this->crr_car_info_.parking_brake_stt = true;
this->emitParkingBrakeOn();
}
else {
}
}
+ // Check accelerator pedal state
+ json_object* json_accel_pedal;
+ if (!json_object_object_get_ex(json_out, "accel_pedal", &json_accel_pedal)) {
+ reply("Not found key \"accel_pedal\"");
+ return;
+ }
+
+ is_changed = jh::getBoolFromJson(json_accel_pedal, "is_changed");
+ if (is_changed) {
+ std::string accel_pedal_state = jh::getStringFromJson(json_accel_pedal, "state");
+ HMI_DEBUG("wm", "accel_pedal_state: %s", accel_pedal_state.c_str());
+
+ // Update state
+ if ("accel_pedal_off" == accel_pedal_state) {
+ this->crr_car_info_.accel_pedal_stt = false;
+ }
+ else if ("accel_pedal_on" == accel_pedal_state) {
+ this->crr_car_info_.accel_pedal_stt = true;
+ }
+ else {
+ reply("Unknown accel pedal state");
+ return;
+ }
+ }
+
// Check car state
json_object* json_car;
if (!json_object_object_get_ex(json_out, "car", &json_car)) {
is_changed = jh::getBoolFromJson(json_car, "is_changed");
if (is_changed) {
- // Update car state
std::string car_state = jh::getStringFromJson(json_car, "state");
HMI_DEBUG("wm", "car_state: %s", car_state.c_str());
// Emit car event
if ("car_stop" == car_state) {
+ this->crr_car_info_.car_stt = "stop";
this->emitCarStop();
}
else if ("car_run" == car_state) {
+ this->crr_car_info_.car_stt = "run";
this->emitCarRun();
}
else {
is_changed = jh::getBoolFromJson(json_lamp, "is_changed");
if (is_changed) {
- // Update car state
std::string lamp_state = jh::getStringFromJson(json_lamp, "state");
HMI_DEBUG("wm", "lamp_state: %s", lamp_state.c_str());
- // Emit lamp event
+ // Update state and emit event
if ("lamp_off" == lamp_state) {
+ this->crr_car_info_.headlamp_stt = false;
this->emitHeadlampOff();
}
else if ("lamp_on" == lamp_state) {
+ this->crr_car_info_.headlamp_stt = true;
this->emitHeadlampOn();
}
else {
}
// <<< FOR CES DEMO
+ this->layout_commit();
+
this->emit_deactivated(label);
this->emit_invisible(label);
}
// Set destination to the display rectangle
int surface_id = this->role2surfaceid_[role];
+
+ if (!this->controller->surface_exists(surface_id)) {
+ // Block until all pending request are processed by wayland display server
+ // because waiting for the surface of new app is created
+ this->display->roundtrip();
+ }
auto &s = this->controller->surfaces[surface_id];
s->set_destination_rectangle(size.x, size.y, size.w, size.h);
this->layout_commit();
this->enqueue_flushdraw(surface_id);
}
+void App::setAccelPedalPos(double val) {
+ this->crr_car_info_.accel_pedal_pos = val;
+}
+
extern const char* kDefaultAppDb;
int App::loadAppDb() {
HMI_DEBUG("wm", "Call");
}
// Load app.db
- HMI_DEBUG("wm", "file_name:%s", file_name.c_str());
- json_object* json_obj = json_object_from_file(file_name.c_str());
- if (nullptr == json_obj) {
+ json_object* json_obj;
+ int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj);
+ if (0 > ret) {
HMI_ERROR("wm", "Could not open app.db, so use default role information");
json_obj = json_tokener_parse(kDefaultAppDb);
}