diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-05-31 09:52:01 +0900 |
---|---|---|
committer | Zheng Wenlong <wenlong_zheng@nexty-ele.com> | 2018-06-07 00:03:43 +0000 |
commit | 8191d78a13d838fa232c3a38311be52bb0044477 (patch) | |
tree | 8f79baa96b5f4c8f7ee84750ef8bf5ef8578ff18 | |
parent | b6d8274063b1b6f45996ce10f6fa17c284b2a07b (diff) |
Use low-can api to display vehicle speed and engine speedflounder_5.99.1flounder/5.99.15.99.1
Modify dashboard to use low-can api,
Just to display vehicle speed and engine speed this time.
Will use tire press next time.
Change-Id: I9e3dc3ea35ff0c0a6a59742be4e2e745b1859a8b
Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
-rw-r--r-- | app/Dashboard.qml | 49 | ||||
-rw-r--r-- | package/config.xml | 1 |
2 files changed, 30 insertions, 20 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml index a4ee8eb..41ffbf8 100644 --- a/app/Dashboard.qml +++ b/app/Dashboard.qml @@ -1,4 +1,5 @@ /* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION * Copyright (C) 2016 The Qt Company Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,13 +28,15 @@ ApplicationWindow { id: translator } - WebSocket { - property string api_str: "api/canivi" - 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 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 engineSpeed: 0 + WebSocket { id: websocket url: bindingAddress @@ -45,16 +48,22 @@ ApplicationWindow { */ if (message_json[0] == msgid_enu.event) { - if (message_json[1] == "canivi/VehicleSpeed") - speed.text = message_json[2].data.value - else - if (message_json[1] == "canivi/EngineSpeed") - tachometer.value = message_json[2].data.value / 7000 - return - } else - if (message_json[0] != msgid_enu.retok) { - console.log ("Return value is not ok !") - return + + 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 + } } /* refresh happen */ } @@ -66,9 +75,9 @@ ApplicationWindow { if (websocket.status == WebSocket.Open) { status_str = "Socket opened; sending message..." if (verb_str == "subscribe") { - request_str ='[' + msgid_enu.call + ',"99999","' + api_str +'/'+ verb_str +'",{ \"event\" : \"VehicleSpeed\" } ]'; + 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\" : \"EngineSpeed\" } ]'; + request_str ='[' + msgid_enu.call + ',"99999","' + api_str +'/'+ verb_str +'",{ \"event\" : \"engine.speed\" } ]'; websocket.sendTextMessage (request_str) } } else @@ -85,7 +94,7 @@ ApplicationWindow { anchors.left: parent.left anchors.top: parent.top anchors.margins: 20 - text: '0' + text: speed_val.toFixed(0) /* KPH */ font.pixelSize: 256 } Label { @@ -160,7 +169,7 @@ ApplicationWindow { ProgressBar { id: tachometer Layout.fillWidth: true - value: 0 + value: engineSpeed / 65535 Label { anchors.left: parent.left anchors.top: parent.bottom diff --git a/package/config.xml b/package/config.xml index e284a1a..8e1f43d 100644 --- a/package/config.xml +++ b/package/config.xml @@ -9,6 +9,7 @@ <feature name="urn:AGL:widget:required-api"> <param name="windowmanager" value="ws"/> <param name="homescreen" value="ws"/> + <param name="low-can" value="ws"/> </feature> <feature name="urn:AGL:widget:required-permission"> <param name="urn:AGL:permission::public:no-htdocs" value="required"/> |