aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-05-17 16:48:33 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-05-17 16:48:33 +0900
commiteaea3b4b5b814505e3564513e92a53fb03748d3b (patch)
tree4c9648fdef3435581a327ca0a7a11ad8d2e03148 /src/app.cpp
parenta9f97575b05a5e49ace1f34e608bbb5aabdb8311 (diff)
App (ResourceManager) class has the current car info
and LowCanClient does not check whether CAN signal value is changed Change-Id: I41dfd0772f8fb4db70c4b5c0caa35791600abc54 Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 296ce35..ac789ad 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -119,6 +119,13 @@ App::App(wl::display *d)
} 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() {
@@ -369,15 +376,16 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
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 {
@@ -393,6 +401,24 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
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)) {
@@ -402,15 +428,16 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
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 {
@@ -428,15 +455,16 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
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 {
@@ -1066,6 +1094,10 @@ void App::setSurfaceSize(const char* role, const char* area) {
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");