diff options
author | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-17 16:48:33 +0900 |
---|---|---|
committer | Yuta Doi <yuta-d@witz-inc.co.jp> | 2018-05-17 16:52:10 +0900 |
commit | 9f61fdc39edd93c7da5b77b4bc92963e4df31b82 (patch) | |
tree | 4c9648fdef3435581a327ca0a7a11ad8d2e03148 /src/main.cpp | |
parent | a9f97575b05a5e49ace1f34e608bbb5aabdb8311 (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/main.cpp')
-rw-r--r-- | src/main.cpp | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3a60b94..1db33a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -664,50 +664,56 @@ void on_event(const char *event, struct json_object *object){ // If receive low can signal if (strstr(event, "low-can")) { + wm::LowCanClient *lcc = &(g_afb_instance->lcc_); + wm::App *app = &(g_afb_instance->app); + // Analyze low can signal - g_afb_instance->lcc_.analyzeCanSignal(object); + const char* signal_name = lcc->analyzeCanSignal(object); - if (g_afb_instance->lcc_.isChangedParkingBrakeState()) { - // If parking brake state is changed + // If car info is updated, set event name + const char *can_event = nullptr; + if (strstr(signal_name, lcc->kSignalName_[lcc->SignalNoParkingBrake])) { HMI_DEBUG("wm", "Parking Brake state is changed"); - // Get parking brake state - const char* parking_brake_state = g_afb_instance->lcc_.getCurrentParkingBrakeState(); - - // Allocate window resource - g_afb_instance->app.allocateWindowResource(parking_brake_state, nullptr, - nullptr, nullptr, - [](const char* errmsg){ - if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); - } - }); + // Set event + if (lcc->getCurrentParkingBrakeState()) { + can_event = "parking_brake_on"; + } + else { + can_event = "parking_brake_off"; + } } - if (g_afb_instance->lcc_.isChangedAccelPedalState()) { - // If accelerator pedal state is changed - HMI_DEBUG("wm", "Accelerator Pedal state is changed"); + else if (strstr(signal_name, lcc->kSignalName_[lcc->SignalNoAccelPedalPos])) { + // Update accel pedal position + app->setAccelPedalPos(lcc->getCurrentAccelPedalPosition()); - // Get parking brake state - const char* accel_pedal_state = g_afb_instance->lcc_.getCurrentAccelPedalState(); + if (lcc->isChangedAccelPedalState()) { + HMI_DEBUG("wm", "Accelerator Pedal state is changed"); - // Allocate window resource - g_afb_instance->app.allocateWindowResource(accel_pedal_state, nullptr, - nullptr, nullptr, - [](const char* errmsg){ - if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); + // Set event + if (lcc->getCurrentAccelPedalState()) { + can_event = "accel_pedal_on"; } - }); + else { + can_event = "accel_pedal_off"; + } + } + } + else if (strstr(signal_name, lcc->kSignalName_[lcc->SignalNoHeadlame])) { + HMI_DEBUG("wm", "Headlamp state is changed"); + + // Set event + if (lcc->getCurrentHeadlampState()) { + can_event = "headlamp_on"; + } + else { + can_event = "headlamp_off"; + } } - else if (g_afb_instance->lcc_.isChangedLampState()) { - // If lamp state is changed - HMI_DEBUG("wm", "Lamp state is changed"); - - // Get lamp state - const char* lamp_state = g_afb_instance->lcc_.getCurrentLampState(); - // Allocate window resource - g_afb_instance->app.allocateWindowResource(lamp_state, nullptr, + // Allocate window resource + if (nullptr != can_event) { + g_afb_instance->app.allocateWindowResource(can_event, nullptr, nullptr, nullptr, [](const char* errmsg){ if (errmsg != nullptr) { |