aboutsummaryrefslogtreecommitdiffstats
path: root/Application
diff options
context:
space:
mode:
Diffstat (limited to 'Application')
-rw-r--r--Application/cluster-service.cpp427
-rw-r--r--Application/cluster-service.hxx47
-rw-r--r--Application/main.cpp73
3 files changed, 513 insertions, 34 deletions
diff --git a/Application/cluster-service.cpp b/Application/cluster-service.cpp
new file mode 100644
index 0000000..1bc86ad
--- /dev/null
+++ b/Application/cluster-service.cpp
@@ -0,0 +1,427 @@
+#include "cluster-service.hxx"
+#include <cluster_api.h>
+#include <cluster-api-sdevent.h>
+
+#include <systemd/sd-daemon.h>
+#include <systemd/sd-event.h>
+
+//-----------------------------------------------------------------------------------
+QClusterService::QClusterService()
+{
+
+}
+//-----------------------------------------------------------------------------------
+QClusterService::~QClusterService()
+{
+
+
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE int QClusterService::getSpAnalogVal()
+{
+ uint32_t speed_u32 = 0;
+ int retval = 0;
+
+ speed_u32 = ::getSpAnalogVal();
+ if (speed_u32 > (uint32_t)INT_MAX)
+ retval = INT_MAX;
+ else
+ retval = (int)speed_u32;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE int QClusterService::getTaAnalogVal()
+{
+ uint32_t ta_u32 = 0;
+ int retval = 0;
+
+ ta_u32 = ::getTaAnalogVal();
+ if (ta_u32 > (uint32_t)INT_MAX)
+ retval = INT_MAX;
+ else
+ retval = (int)ta_u32;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE int QClusterService::getTrcomTripAVal()
+{
+ uint32_t tripa_u32 = 0;
+ int retval = 0;
+
+ tripa_u32 = ::getTrcomTripAVal();
+ if (tripa_u32 > (uint32_t)INT_MAX)
+ retval = INT_MAX;
+ else
+ retval = (int)tripa_u32;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE int QClusterService::getOTempVal()
+{
+ int16_t tmp_val = -40;
+ int retval = -40;
+
+ tmp_val = ::getOTempVal();
+ retval = (int)tmp_val;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getTurnR()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getTurnR();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getTurnL()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getTurnL();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getFrontRightSeatbelt()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getFrontRightSeatbelt();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getFrontLeftSeatbelt()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getFrontLeftSeatbelt();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getGeneralWarn()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getGeneralWarn();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getEngine()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getEngine();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getLowBattery()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getLowBattery();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getLdwOff()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getLdwOff();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getSrsAirbag()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getSrsAirbag();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getEspOff()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getEspOff();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getBrake()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getBrake();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getAbs()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getAbs();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getEspAct()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getEspAct();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getHillDescent()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getHillDescent();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getImmobi()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getImmobi();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getDoor()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getDoor();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getEps()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getEps();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getAutoHiBeamGreen()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getAutoHiBeamGreen();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE bool QClusterService::getHighbeam()
+{
+ IC_HMI_ON_OFF on_off_flag = IC_HMI_OFF;
+ bool retval = false;
+
+ on_off_flag = ::getHighbeam();
+ if (on_off_flag == IC_HMI_OFF)
+ retval = false;
+ else
+ retval = true;
+
+ return retval;
+}
+//-----------------------------------------------------------------------------------
+Q_INVOKABLE QString QClusterService::getGearAtVal()
+{
+ IC_HMI_GEAR_AT_VAL gear_val = IC_HMI_AT_UNUSED;
+ QString gear_string = QString("");
+
+ gear_val = ::getGearAtVal();
+
+ switch (gear_val) {
+ case IC_HMI_AT_OFF :
+ gear_string = QString("Off");
+ break;
+ case IC_HMI_AT_PARKING :
+ gear_string = QString("P");
+ break;
+ case IC_HMI_AT_REVERSE :
+ gear_string = QString("R");
+ break;
+ case IC_HMI_AT_NEUTRAL :
+ gear_string = QString("N");
+ break;
+ case IC_HMI_AT_DRIVE :
+ gear_string = QString("D");
+ break;
+ case IC_HMI_AT_SECOND :
+ gear_string = QString("S");
+ break;
+ case IC_HMI_AT_LOW_GEAR :
+ gear_string = QString("L");
+ break;
+ case IC_HMI_AT_FIRST :
+ gear_string = QString("F");
+ break;
+ case IC_HMI_AT_MANUAL :
+ gear_string = QString("M");
+ break;
+ case IC_HMI_AT_BRAKE :
+ gear_string = QString("B");
+ break;
+ case IC_HMI_AT_ALL_ON :
+ case IC_HMI_AT_ALL_OFF :
+ case IC_HMI_AT_UNUSED :
+ gear_string = QString("Error");
+ break;
+ default:
+ gear_string = QString("Off");
+ break;
+ }
+
+ return gear_string;
+}
+//-----------------------------------------------------------------------------------
+/*
+static void ic_notify(uint64_t signal, IC_HMI_ON_OFF val)ui
+{
+ fprintf(stdout, "Signal change notify %016lx , val=%1d\r", signal, val);
+}
+*/
+void QClusterService::run()
+{
+ sd_event *event = NULL;
+ data_pool_client_handle_sdevent handle = NULL;
+ int ret = -1;
+
+ ret = sd_event_default(&event);
+ if (ret < 0)
+ goto finish;
+
+ do {
+ ret = data_pool_client_setup_sdevent(event, &handle);
+ if (ret == 0)
+ break;
+ this->msleep(10);
+ } while(true);
+
+ //(void) registerIcHmi(IC_HMI_TT_TURN_R, ic_notify);
+ //(void) registerIcHmi(IC_HMI_TT_TURN_L, ic_notify);
+
+ ret = sd_event_loop(event);
+ if (ret < 0) {
+ //TODO
+ }
+finish:
+ (void) data_pool_client_cleanup_sdevent(handle);
+ event = sd_event_unref(event);
+
+ return;
+}
+
+//-----------------------------------------------------------------------------------
diff --git a/Application/cluster-service.hxx b/Application/cluster-service.hxx
new file mode 100644
index 0000000..06dc5f8
--- /dev/null
+++ b/Application/cluster-service.hxx
@@ -0,0 +1,47 @@
+#ifndef CLUSTERSERVICE_HXX
+#define CLUSTERSERVICE_HXX
+
+#include <QThread>
+
+class QClusterService : public QThread
+{
+ Q_OBJECT
+
+protected :
+ virtual void run();
+
+public:
+ // class I/F for QML
+ Q_INVOKABLE int getSpAnalogVal();
+ Q_INVOKABLE int getTaAnalogVal();
+ Q_INVOKABLE int getTrcomTripAVal();
+ Q_INVOKABLE int getOTempVal();
+ Q_INVOKABLE bool getTurnR();
+ Q_INVOKABLE bool getTurnL();
+ Q_INVOKABLE bool getFrontRightSeatbelt();
+ Q_INVOKABLE bool getFrontLeftSeatbelt();
+ Q_INVOKABLE bool getGeneralWarn();
+ Q_INVOKABLE bool getEngine();
+ Q_INVOKABLE bool getLowBattery();
+ Q_INVOKABLE bool getLdwOff();
+ Q_INVOKABLE bool getSrsAirbag();
+ Q_INVOKABLE bool getEspOff();
+ Q_INVOKABLE bool getBrake();
+ Q_INVOKABLE bool getAbs();
+ Q_INVOKABLE bool getEspAct();
+ Q_INVOKABLE bool getHillDescent();
+ Q_INVOKABLE bool getImmobi();
+ Q_INVOKABLE bool getDoor();
+ Q_INVOKABLE bool getEps();
+ Q_INVOKABLE bool getAutoHiBeamGreen();
+ Q_INVOKABLE bool getHighbeam();
+
+ Q_INVOKABLE QString getGearAtVal();
+
+
+ // class I/F for C++
+ QClusterService();
+ virtual ~QClusterService();
+};
+
+#endif // CLUSTERSERVICE_HXX
diff --git a/Application/main.cpp b/Application/main.cpp
index 3631708..51b0c39 100644
--- a/Application/main.cpp
+++ b/Application/main.cpp
@@ -14,37 +14,42 @@
* limitations under the License.
*/
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QSurfaceFormat>
-#include <QDir>
-#include <QQmlContext>
-#include <QDebug>
-
-
-int main(int argc, char *argv[])
-{
- QSurfaceFormat defaultFormat;
- defaultFormat.setSwapBehavior(QSurfaceFormat::TripleBuffer);
- defaultFormat.setRenderableType(QSurfaceFormat::OpenGLES);
- defaultFormat.setProfile(QSurfaceFormat::NoProfile);
- defaultFormat.setVersion(2,0);
- defaultFormat.setSwapInterval(1);
- defaultFormat.setDepthBufferSize(8);
- defaultFormat.setAlphaBufferSize(8);
- QSurfaceFormat::setDefaultFormat(defaultFormat);
-
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- engine.rootContext()->setContextProperty("CurDirPath", QString(QCoreApplication::applicationDirPath()));
- const QUrl url(QStringLiteral("qrc:/main.qml"));
- QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
- &app, [url](QObject *obj, const QUrl &objUrl) {
- if (!obj && url == objUrl)
- QCoreApplication::exit(-1);
- }, Qt::QueuedConnection);
- engine.load(url);
-
- return app.exec();
-}
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QSurfaceFormat>
+#include <QDir>
+#include <QQmlContext>
+#include <QDebug>
+
+#include "cluster-service.hxx"
+
+int main(int argc, char *argv[])
+{
+ QSurfaceFormat defaultFormat;
+ defaultFormat.setSwapBehavior(QSurfaceFormat::TripleBuffer);
+ defaultFormat.setRenderableType(QSurfaceFormat::OpenGLES);
+ defaultFormat.setProfile(QSurfaceFormat::NoProfile);
+ defaultFormat.setVersion(2,0);
+ defaultFormat.setSwapInterval(1);
+ defaultFormat.setDepthBufferSize(8);
+ defaultFormat.setAlphaBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(defaultFormat);
+
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("CurDirPath", QString(QCoreApplication::applicationDirPath()));
+ const QUrl url(QStringLiteral("qrc:/main.qml"));
+ QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
+ &app, [url](QObject *obj, const QUrl &objUrl) {
+ if (!obj && url == objUrl)
+ QCoreApplication::exit(-1);
+ }, Qt::QueuedConnection);
+ engine.load(url);
+
+ QClusterService cluster_service;
+ cluster_service.start();
+ engine.rootContext()->setContextProperty("cluster_service", &cluster_service);
+
+ return app.exec();
+}