X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.cpp;h=f7ec927570057de5950e64f1e91ab915bf280cbe;hb=208368fcc1c61319fa2728d950688523b0557b1f;hp=762981f8e9391f9c6381f1a5de99b5024453edcf;hpb=b126caef1760902eb863af8ea892c4db9b9663f9;p=apps%2Fagl-service-windowmanager.git diff --git a/src/main.cpp b/src/main.cpp index 762981f..f7ec927 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,10 +40,10 @@ typedef struct wmClientCtxt{ struct afb_instance { std::unique_ptr display; - wm::LowCanClient lcc_; + wm::LowCanClient lcc; wm::App app; - afb_instance() : display{new wl::display}, lcc_{}, app{this->display.get()} {} + afb_instance() : display{new wl::display}, lcc{}, app{this->display.get()} {} int init(); }; @@ -53,7 +53,7 @@ std::mutex binding_m; int afb_instance::init() { // Initialize LowCanClient class - this->lcc_.initialize(); + this->lcc.initialize(); // Initialize App class return this->app.init(); @@ -304,13 +304,8 @@ void windowmanager_activatesurface(afb_req req) noexcept { return; } - const char* a_role = afb_req_value(req, "role"); - if(!a_role){ - a_role = ""; - } - - g_afb_instance->app.allocateWindowResource("activate", a_drawing_name, - a_drawing_area, a_role, + g_afb_instance->app.allocateWindowResource("activate", + a_drawing_name, a_drawing_area, [&req](const char* errmsg){ if (errmsg != nullptr) { HMI_ERROR("wm", errmsg); @@ -344,13 +339,8 @@ void windowmanager_deactivatesurface(afb_req req) noexcept { return; } - const char* a_role = afb_req_value(req, "role"); - if(!a_role){ - a_role = ""; - } - - g_afb_instance->app.allocateWindowResource("deactivate", a_drawing_name, - nullptr, a_role, + g_afb_instance->app.allocateWindowResource("deactivate", + a_drawing_name, nullptr, [&req](const char* errmsg){ if (errmsg != nullptr) { HMI_ERROR("wm", errmsg); @@ -664,66 +654,67 @@ 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 if (g_afb_instance->lcc_.isChangedCarState()) { - // If car state is changed - HMI_DEBUG("wm", "Car state is changed"); - - // Get car state - const char* car_state = g_afb_instance->lcc_.getCurrentCarState(); - - // Allocate window resource - g_afb_instance->app.allocateWindowResource(car_state, nullptr, - nullptr, nullptr, - [](const char* errmsg){ - if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); + 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 (strstr(signal_name, lcc->kSignalName[lcc->SignalNoLightstatusBrake])) { + HMI_DEBUG("wm", "Lightstatus Brake state is changed"); + + // Set event + if (lcc->getCurrentLightstatusBrakeState()) { + can_event = "lightstatus_brake_on"; + } + else { + can_event = "lightstatus_brake_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, [](const char* errmsg){ if (errmsg != nullptr) {