diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-21 19:58:50 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-21 20:01:53 +0900 |
commit | cfcc176e4cbbd890bcd67e2b8afb61fbff10d131 (patch) | |
tree | 8022ce046039dd759c93e9f3c140a66497ea13db /src/app.cpp | |
parent | b6512a47584376d8016a7e5a91cca8bb5c945db9 (diff) |
Add lightstatus brake ON/OFF event
Change-Id: Id2c61fc6e102394f5ba08effe0cfac448b337176
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src/app.cpp')
-rw-r--r-- | src/app.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app.cpp b/src/app.cpp index 7191727..1d6b504 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -382,11 +382,15 @@ void App::allocateWindowResource(char const *event, char const *drawing_name, // Update state and emit event if ("parking_brake_off" == parking_brake_state) { this->crr_car_info_.parking_brake_stt = false; +#if 0 // FOR ALS: using lightstatus brake, so do not emit parking brake event this->emitParkingBrakeOff(); +#endif } else if ("parking_brake_on" == parking_brake_state) { this->crr_car_info_.parking_brake_stt = true; +#if 0 // FOR ALS: using lightstatus brake, so do not emit parking brake event this->emitParkingBrakeOn(); +#endif } else { reply("Unknown parking brake state"); @@ -419,6 +423,33 @@ void App::allocateWindowResource(char const *event, char const *drawing_name, } } + // Check lightstatus brake state + json_object* json_lightstatus_brake; + if (!json_object_object_get_ex(json_out, "lightstatus_brake", &json_lightstatus_brake)) { + reply("Not found key \"lightstatus_brake\""); + return; + } + + is_changed = jh::getBoolFromJson(json_lightstatus_brake, "is_changed"); + if (is_changed) { + std::string lightstatus_brake_state = jh::getStringFromJson(json_lightstatus_brake, "state"); + HMI_DEBUG("wm", "lightstatus_brake_state: %s", lightstatus_brake_state.c_str()); + + // Update state and emit event + if ("lightstatus_brake_off" == lightstatus_brake_state) { + this->crr_car_info_.lightstatus_brake_stt = false; + this->emitLightstatusBrakeOff(); + } + else if ("lightstatus_brake_on" == lightstatus_brake_state) { + this->crr_car_info_.lightstatus_brake_stt = true; + this->emitLightstatusBrakeOn(); + } + else { + reply("Unknown lightstatus brake state"); + return; + } + } + // Check car state json_object* json_car; if (!json_object_object_get_ex(json_out, "car", &json_car)) { @@ -666,6 +697,16 @@ void App::emitParkingBrakeOn() { this->send_event(kListEventName[Event_ParkingBrakeOn]); } +void App::emitLightstatusBrakeOff() { + // Send LightstatusBrakeOff event for all application + this->send_event(kListEventName[Event_LightstatusBrakeOff]); +} + +void App::emitLightstatusBrakeOn() { + // Send LightstatusBrakeOn event for all application + this->send_event(kListEventName[Event_LightstatusBrakeOn]); +} + void App::emitCarStop() { // Send CarStop event for all application this->send_event(kListEventName[Event_CarStop]); |