diff options
author | Jiu Shanheng <shanheng.jiu@qt.io> | 2024-09-10 19:15:25 +0900 |
---|---|---|
committer | Jiu Shanheng <shanheng.jiu@qt.io> | 2024-09-11 18:40:18 +0900 |
commit | 5c8f09d2c3c99f621b467ed5c1be4fac3a708e85 (patch) | |
tree | 9312e269961b14945a00db47ed236ca53ffbb149 /Application/cluster-service.cpp | |
parent | 17b016d08cf1680f58cbb9102f35949c8436207c (diff) |
This demo can now run on both Qt5 and Qt6, also added a macro to switch with or without the backend so that it can be developed easily on the Windows desktop.
Bug-AGL: SPEC-5243
Change-Id: I99b12ad9779a477784df13b83a850387747bb588
Signed-off-by: Jiu Shanheng <shanheng.jiu@qt.io>
Diffstat (limited to 'Application/cluster-service.cpp')
-rw-r--r-- | Application/cluster-service.cpp | 120 |
1 files changed, 76 insertions, 44 deletions
diff --git a/Application/cluster-service.cpp b/Application/cluster-service.cpp index 1bc86ad..37bd8cb 100644 --- a/Application/cluster-service.cpp +++ b/Application/cluster-service.cpp @@ -1,9 +1,12 @@ #include "cluster-service.hxx" -#include <cluster_api.h> -#include <cluster-api-sdevent.h> +#if ENABLE_CLUSTER_BACKEND +#include <climits> +#include <cluster-api-sdevent.h> +#include <cluster_api.h> #include <systemd/sd-daemon.h> #include <systemd/sd-event.h> +#endif //----------------------------------------------------------------------------------- QClusterService::QClusterService() @@ -21,8 +24,9 @@ Q_INVOKABLE int QClusterService::getSpAnalogVal() { uint32_t speed_u32 = 0; int retval = 0; - +#if ENABLE_CLUSTER_BACKEND speed_u32 = ::getSpAnalogVal(); +#endif if (speed_u32 > (uint32_t)INT_MAX) retval = INT_MAX; else @@ -35,8 +39,9 @@ Q_INVOKABLE int QClusterService::getTaAnalogVal() { uint32_t ta_u32 = 0; int retval = 0; - +#if ENABLE_CLUSTER_BACKEND ta_u32 = ::getTaAnalogVal(); +#endif if (ta_u32 > (uint32_t)INT_MAX) retval = INT_MAX; else @@ -49,8 +54,9 @@ Q_INVOKABLE int QClusterService::getTrcomTripAVal() { uint32_t tripa_u32 = 0; int retval = 0; - +#if ENABLE_CLUSTER_BACKEND tripa_u32 = ::getTrcomTripAVal(); +#endif if (tripa_u32 > (uint32_t)INT_MAX) retval = INT_MAX; else @@ -63,8 +69,9 @@ Q_INVOKABLE int QClusterService::getOTempVal() { int16_t tmp_val = -40; int retval = -40; - +#if ENABLE_CLUSTER_BACKEND tmp_val = ::getOTempVal(); +#endif retval = (int)tmp_val; return retval; @@ -72,272 +79,292 @@ Q_INVOKABLE int QClusterService::getOTempVal() //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getTurnR() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getTurnR(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getTurnL() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getTurnL(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getFrontRightSeatbelt() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getFrontRightSeatbelt(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getFrontLeftSeatbelt() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getFrontLeftSeatbelt(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getGeneralWarn() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getGeneralWarn(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getEngine() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getEngine(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getLowBattery() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getLowBattery(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getLdwOff() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getLdwOff(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getSrsAirbag() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getSrsAirbag(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getEspOff() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getEspOff(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getBrake() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getBrake(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getAbs() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getAbs(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getEspAct() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getEspAct(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getHillDescent() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getHillDescent(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getImmobi() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getImmobi(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getDoor() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getDoor(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getEps() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getEps(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getAutoHiBeamGreen() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getAutoHiBeamGreen(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE bool QClusterService::getHighbeam() { - IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; bool retval = false; +#if ENABLE_CLUSTER_BACKEND + IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF; on_off_flag = ::getHighbeam(); if (on_off_flag == IC_HMI_OFF) retval = false; else retval = true; - +#endif return retval; } //----------------------------------------------------------------------------------- Q_INVOKABLE QString QClusterService::getGearAtVal() { +#if ENABLE_CLUSTER_BACKEND IC_HMI_GEAR_AT_VAL gear_val = IC_HMI_AT_UNUSED; QString gear_string = QString(""); @@ -385,6 +412,9 @@ Q_INVOKABLE QString QClusterService::getGearAtVal() } return gear_string; +#else + return QStringLiteral("Test"); +#endif } //----------------------------------------------------------------------------------- /* @@ -395,6 +425,7 @@ static void ic_notify(uint64_t signal, IC_HMI_ON_OFF val)ui */ void QClusterService::run() { +#if ENABLE_CLUSTER_BACKEND sd_event *event = NULL; data_pool_client_handle_sdevent handle = NULL; int ret = -1; @@ -421,6 +452,7 @@ finish: (void) data_pool_client_cleanup_sdevent(handle); event = sd_event_unref(event); +#endif return; } |