summaryrefslogtreecommitdiffstats
path: root/app/ValueSource.qml
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-06-07 15:33:50 -0400
committerScott Murray <scott.murray@konsulko.com>2022-06-07 15:43:22 -0400
commit202cc44bc311a20a7016759d1a4e7bcba6064f7d (patch)
tree23501093ffb20f2e98b18431e81472171bc3dd6b /app/ValueSource.qml
parent00fa784cdb2570f742511820b885b1c3e18b6d01 (diff)
Add VIS vehicle signal support
Use the new VehicleSignals API from libqtappfw to replace the previous signal-composer usage. Additionally, 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 Change-Id: I3c40ea004e1c66e9775865aaa424e24778cb0f53 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'app/ValueSource.qml')
-rw-r--r--app/ValueSource.qml80
1 files changed, 56 insertions, 24 deletions
diff --git a/app/ValueSource.qml b/app/ValueSource.qml
index 80ef95c..24a3a5f 100644
--- a/app/ValueSource.qml
+++ b/app/ValueSource.qml
@@ -53,7 +53,7 @@ import QtQuick 2.2
Item {
id: valueSource
property real kph: 0
- property bool mphDisplay: true
+ property bool mphDisplay: false
property real speedScaling: mphDisplay == true ? 0.621504 : 1.0
property real rpm: 1
property real fuel: 0.85
@@ -96,46 +96,78 @@ Item {
return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow;
}
+ Component.onCompleted : {
+ if(!runAnimation) {
+ VehicleSignals.connect()
+ }
+ }
+
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
- onSignalEvent: {
- if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "mph") {
- speed_tmp *= 1.609
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
+ VehicleSignals.subscribe("Vehicle.ADAS.CruiseControl.IsActive")
+ VehicleSignals.subscribe("Vehicle.ADAS.CruiseControl.IsSet")
+ VehicleSignals.subscribe("Vehicle.ADAS.LaneDepartureDetection.IsActive")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Cluster.Mode")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
+
+ onGetSuccessResponse: {
+ //console.log("response path = " + path + ", value = " + value)
+ if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ valueSource.mphDisplay = false
+ } else if (value === "mi") {
+ valueSource.mphDisplay = true
}
+ }
+ }
+
+ onSignalNotification: {
+ //console.log("signal path = " + path + ", value = " + value)
+ if (path === "Vehicle.Speed") {
+ // units are always km/h
+ // Checking Vehicle.Cabin.Infotainment.HMI.DistanceUnit for the
+ // display unit would likely be a worthwhile enhancement.
if(!runAnimation) {
- valueSource.kph = speed_tmp
+ valueSource.kph = parseFloat(value)
}
- }
- else if (uid === "event.engine.speed") {
+ } else if (path === "Vehicle.Powertrain.CombustionEngine.Engine.Speed") {
if(!runAnimation) {
valueSource.rpm = parseFloat(value) / 1000
}
- }
- else if (uid === "event.cruise.enable" && value === "true") {
+ } else if (path === "Vehicle.ADAS.CruiseControl.IsActive" && value === "true") {
if(valueSource.cruiseEnabled) {
valueSource.cruiseEnabled = false
valueSource.cruiseSet = false
} else {
valueSource.cruiseEnabled = true
}
- }
- else if ((uid === "event.cruise.set" || uid === "event.cruise.resume") &&
- value === "true") {
- if(valueSource.cruiseEnabled) {
- valueSource.cruiseSet = true
+ } else if (path === "Vehicle.ADAS.CruiseControl.IsSet") {
+ if (value === "true") {
+ if(valueSource.cruiseEnabled)
+ valueSource.cruiseSet = true
+ } else {
+ valueSource.cruiseSet = false
}
- }
- else if (uid === "event.cruise.cancel" && value === "true") {
- valueSource.cruiseSet = false
- }
- else if (uid === "event.lane_departure_warning.enable" && value === "true") {
+ } else if (path === "Vehicle.ADAS.LaneDepartureDetection.IsActive" && value === "true") {
valueSource.laneDepartureWarnEnabled = !valueSource.laneDepartureWarnEnabled
- }
- else if (uid === "event.info" && value === "true") {
+ } else if (path === "Vehicle.Cabin.Infotainment.Cluster.Mode" && value === "true") {
valueSource.displayNumericSpeeds = !valueSource.displayNumericSpeeds
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ valueSource.mphDisplay = false
+ } else if (value === "mi") {
+ valueSource.mphDisplay = true
+ }
}
}
}