diff options
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) { |