summaryrefslogtreecommitdiffstats
path: root/app/Dashboard.qml
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-12-18 10:53:42 -0500
committerScott Murray <scott.murray@konsulko.com>2019-12-18 10:53:42 -0500
commitd81bd39e4f4d48534d7c47b50451d84126fc244e (patch)
tree91ff26d441f52c6f1a4345dfbeba767dde62ae90 /app/Dashboard.qml
parentf85c9d866866de0df4d36535342402dfc13cc759 (diff)
Switch from using the vehicle and engine speeds messages from the low-can binding directly to using the abstracted events from the signal-composer binding instead. Bug-AGL: SPEC-3042 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I36f4d1c7f8565daf43014f47811cd5d3fdfd1dd6
Diffstat (limited to 'app/Dashboard.qml')
-rw-r--r--app/Dashboard.qml67
1 files changed, 13 insertions, 54 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml
index d343d8a..7371667 100644
--- a/app/Dashboard.qml
+++ b/app/Dashboard.qml
@@ -18,7 +18,6 @@
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
-import QtWebSockets 1.0
import Translator 1.0
ApplicationWindow {
@@ -31,65 +30,25 @@ ApplicationWindow {
id: translator
}
- property string api_str: "low-can"
- property string verb_str: "subscribe"
- property var msgid_enu: { "call":2, "retok":3, "reterr":4, "event":5 }
- property string request_str: ""
- property string status_str: ""
-
- property double speed_val: 0
+ property double vehicleSpeed: 0
property double engineSpeed: 0
- WebSocket {
- id: websocket
- url: bindingAddress
-
- onTextMessageReceived: {
- var message_json = JSON.parse (message);
- /*
- console.log ("Raw response: " + message)
- console.log ("JSON response: " + message_json)
- */
- if (message_json[0] == msgid_enu.event) {
+ Connections {
+ target: SignalComposer
- var property_name = message_json[2].event.split("/")[1]
- if(property_name === "messages.vehicle.average.speed") {
- speed_val = message_json[2].data.value
- }
- else if (property_name === "messages.engine.speed") {
- engineSpeed = message_json[2].data.value
- tachometer.value = engineSpeed / 7000
- }
- }
- else
- {
- if (message_json[0] != msgid_enu.retok) {
- console.log ("Return value is not ok !")
- return
+ onSignalEvent: {
+ if (uid === "event.vehicle.speed") {
+ var speed_tmp = parseFloat(value)
+ if(units == "km/h") {
+ speed_tmp /= 1.609
}
+ vehicleSpeed = speed_tmp
}
- /* refresh happen */
- }
- onStatusChanged: {
- if (websocket.status == WebSocket.Error) {
- status_str = "Error: " + websocket.errorString
- }
- else
- if (websocket.status == WebSocket.Open) {
- status_str = "Socket opened; sending message..."
- if (verb_str == "subscribe") {
- request_str ='[' + msgid_enu.call + ',"99998","' + api_str +'/'+ verb_str +'",{ \"event\" : \"vehicle.average.speed\" } ]';
- websocket.sendTextMessage (request_str)
- request_str ='[' + msgid_enu.call + ',"99999","' + api_str +'/'+ verb_str +'",{ \"event\" : \"engine.speed\" } ]';
- websocket.sendTextMessage (request_str)
- }
- } else
- if (websocket.status == WebSocket.Closed) {
- status_str = "Socket closed"
+ else if (uid === "event.engine.speed") {
+ engineSpeed = parseFloat(value)
+ tachometer.value = engineSpeed / 7000
}
- console.log (status_str)
}
- active: true
}
Item {
@@ -104,7 +63,7 @@ ApplicationWindow {
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 20
- text: speed_val.toFixed(0) /* MPH */
+ text: vehicleSpeed.toFixed(0) /* MPH */
font.pixelSize: 256
}
Label {