aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-06-07 15:39:51 -0400
committerScott Murray <scott.murray@konsulko.com>2022-06-07 15:50:29 -0400
commitb53c55799ff50fb51bec1bf75bac477fa4165336 (patch)
tree4200790f43db597c73de3acda9c71b76938a67e2 /app
parent70dfe121582cda2c82c794e5af6550b5c1a237c4 (diff)
Updates to restore to a functional state
Changes: - Add setenv of QT_QUICK_CONTROLS_STYLE and setting of the frameless window hint to match the previous behavior before the removal of the previous application framework. - Use the new VehicleSignals API from libqtappfw to replace the previous signal-composer usage. - Update the use of the Navigation API from libqtappfw for its rework to use VIS signals instead of the previous signal-composer usage. - The default unit for the vehicle speed has been switched to kilometers with switching driven by the appropriate VSS schema value. Bug-AGL: SPEC-4409, SPEC-4426 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I69b60a1e3207a54c34aaf114a1e89fce2cf0059f
Diffstat (limited to 'app')
-rw-r--r--app/app.pro2
-rw-r--r--app/main.cpp15
-rw-r--r--app/navigation_client.cpp13
-rw-r--r--app/navigation_client.h5
-rw-r--r--app/qml/InfoWindow.qml2
-rw-r--r--app/qml/Main.qml57
6 files changed, 71 insertions, 23 deletions
diff --git a/app/app.pro b/app/app.pro
index 8889208..398e063 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -2,7 +2,7 @@ TEMPLATE = app
TARGET = tbtnavi
QT = qml network quick positioning location widgets gui-private
-PKGCONFIG += qtappfw-navigation wayland-client
+PKGCONFIG += qtappfw-navigation qtappfw-vehicle-signals wayland-client
CONFIG += c++1z link_pkgconfig wayland-scanner
diff --git a/app/main.cpp b/app/main.cpp
index 1be4efa..827a561 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -8,6 +8,7 @@
#include <QtQml/QQmlContext>
#include <QtQuick/QQuickWindow>
#include <navigation.h>
+#include <vehiclesignals.h>
#include <QScreen>
#include "navigation_client.h"
@@ -91,6 +92,8 @@ int main(int argc, char *argv[])
QString graphic_role = QString("tbtnavi");
struct agl_shell_desktop *agl_shell_desktop = nullptr;
+ setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1);
+
QGuiApplication app(argc, argv);
QCoreApplication::setOrganizationDomain("automotivelinux.org");
QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
@@ -132,7 +135,17 @@ int main(int argc, char *argv[])
File_Operation file;
context->setContextProperty("fileOperation", &file);
- Navigation *navigation = new Navigation(context);
+ VehicleSignalsConfig vsConfig("tbtnavi");
+ VehicleSignals *vs = new VehicleSignals(vsConfig);
+ if (!vs) {
+ qFatal("Could not create VehicleSignals!");
+ }
+ context->setContextProperty("VehicleSignals", vs);
+
+ // Give the navigation client it's own vehicle signals connection
+ // to simplify state management wrt QML initialization, and keep the
+ // notification streams separate.
+ Navigation *navigation = new Navigation(new VehicleSignals(vsConfig), context);
engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml")));
diff --git a/app/navigation_client.cpp b/app/navigation_client.cpp
index 426bbeb..a8682da 100644
--- a/app/navigation_client.cpp
+++ b/app/navigation_client.cpp
@@ -1,10 +1,11 @@
+#include <QDebug>
#include "navigation_client.h"
navigation_client::navigation_client(Navigation *navigation, QObject *parent) :
m_navigation(navigation)
{
- QObject::connect(m_navigation, &Navigation::statusEvent, this, &navigation_client::statusEvent);
- QObject::connect(m_navigation, &Navigation::positionEvent, this, &navigation_client::positionEvent);
+ QObject::connect(m_navigation, &Navigation::statusEvent, this, &navigation_client::onStatusEvent);
+ QObject::connect(m_navigation, &Navigation::positionEvent, this, &navigation_client::onPositionEvent);
// connect the signal to qml inside function(addRoutePointsQml -> do_addRoutePoint)
QObject::connect(this, SIGNAL(addRoutePointsQml(QVariant, QVariant, QVariant, QVariant)),
@@ -23,21 +24,21 @@ navigation_client::navigation_client(Navigation *navigation, QObject *parent) :
navigation_client::~navigation_client(){}
-void navigation_client::statusEvent(QVariantMap data)
+void navigation_client::onStatusEvent(QVariantMap data)
{
if (!data.contains("state"))
return;
QString state = data["state"].toString();
- if (state == "arrived")
+ if (state == "Arrived")
emit arrivedestQml();
- if (state == "stopped" || state == "stop")
+ if (state == "Stopped")
emit stopdemoQml();
}
-void navigation_client::positionEvent(QVariantMap data)
+void navigation_client::onPositionEvent(QVariantMap data)
{
if (!data.contains("position"))
return;;
diff --git a/app/navigation_client.h b/app/navigation_client.h
index cdd9396..e884f69 100644
--- a/app/navigation_client.h
+++ b/app/navigation_client.h
@@ -24,8 +24,7 @@ signals:
void arrivedestQml();
private slots:
-
- void statusEvent(QVariantMap data);
- void positionEvent(QVariantMap data);
+ void onStatusEvent(QVariantMap data);
+ void onPositionEvent(QVariantMap data);
};
#endif // NAVIGATION_CLIENT_H
diff --git a/app/qml/InfoWindow.qml b/app/qml/InfoWindow.qml
index 4acba5d..7183040 100644
--- a/app/qml/InfoWindow.qml
+++ b/app/qml/InfoWindow.qml
@@ -53,7 +53,7 @@ Rectangle {
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
- text: "MPH"
+ text: tbtnavi.mphDisplay ? "MPH" : "KPH"
color: "white"
font.pixelSize: 32
font.bold: true
diff --git a/app/qml/Main.qml b/app/qml/Main.qml
index 188fa86..471d160 100644
--- a/app/qml/Main.qml
+++ b/app/qml/Main.qml
@@ -11,17 +11,54 @@ ApplicationWindow {
title: "Turn By Turn Navigation Demo"
height: Window.height
width: Window.width
+ flags: Qt.FramelessWindowHint
visible: true
property double vehicleSpeed: 0
property double engineSpeed: 0
+ property bool mphDisplay: false
+
+ Component.onCompleted : {
+ VehicleSignals.connect()
+ }
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
+
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Cluster.Mode")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
- onSignalEvent: {
- //console.log ("Received uid = " + uid + ", value = " + value)
- if (uid === "event.info" && value === "true") {
+ onGetSuccessResponse: {
+ //console.log("response path = " + path + ", value = " + value)
+ if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
+ }
+ }
+ }
+
+ onSignalNotification: {
+ //console.log("signal path = " + path + ", value = " + value)
+ if (path === "Vehicle.Speed") {
+ // value units are always km/h
+ if (mphDisplay)
+ vehicleSpeed = parseFloat(value) * 0.621504
+ else
+ vehicleSpeed = parseFloat(value)
+ } else if (path === "Vehicle.Powertrain.CombustionEngine.Engine.Speed") {
+ engineSpeed = parseFloat(value)
+ } else if (path === "Vehicle.Cabin.Infotainment.Cluster.Mode" && value === "true") {
console.log ("Switching views!")
console.log ("currentIndex = " + container.currentIndex)
if (container.currentIndex === 0) {
@@ -31,14 +68,12 @@ ApplicationWindow {
console.log ("Switching to map")
container.currentIndex = 0
}
- } else if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "km/h") {
- speed_tmp /= 1.609
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
}
- vehicleSpeed = speed_tmp
- } else if (uid === "event.engine.speed") {
- engineSpeed = parseFloat(value)
}
}
}