diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-11-11 01:05:35 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-11-11 01:05:35 -0800 |
commit | ee6e9af318150dc061787108fef94b230a63d218 (patch) | |
tree | 383ee62af2b18c9c2951161b45e957354b8fa66f /app | |
parent | ca2db695f1258e0b325c7454a8f79c6d7b2eb48b (diff) |
ondemandnavi: add agl-service-navigation interface
Switch from the application providing DBus objects to consumers
with using afb binding with proper JSON responses.
Bug-AGL: SPEC-2880
Change-Id: If587ddeaea9a0f28e71c2bee790acbf53425de9f
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/BtnGuidance.qml | 2 | ||||
-rw-r--r-- | app/app.pro | 2 | ||||
-rw-r--r-- | app/main.cpp | 29 | ||||
-rw-r--r-- | app/navigation.qml | 44 |
4 files changed, 52 insertions, 25 deletions
diff --git a/app/BtnGuidance.qml b/app/BtnGuidance.qml index 2744019..11955f5 100644 --- a/app/BtnGuidance.qml +++ b/app/BtnGuidance.qml @@ -38,7 +38,7 @@ Item { map.initDestination(startFromCurrentPosition) if(btn_guidance.sts_guide != 0){ - map.qmlSignalStopDemo() + navigation.broadcastStatus("stop"); } if(map.center !== map.currentpostion){ diff --git a/app/app.pro b/app/app.pro index c53e922..b31250a 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,6 +1,6 @@ TARGET = navigation QT = quick qml -PKGCONFIG += qlibhomescreen qlibwindowmanager +PKGCONFIG += qlibhomescreen qlibwindowmanager qtappfw QT += positioning QT += core diff --git a/app/main.cpp b/app/main.cpp index cbd121c..b2b9185 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,6 +27,7 @@ #include <QtQml/QQmlContext> #include <QtQuickControls2/QQuickStyle> #include <QQuickWindow> +#include <navigation.h> #include "markermodel.h" #include "guidance_module.h" #include "file_operation.h" @@ -47,10 +48,29 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); parser.process(app); + + // Load qml + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + + File_Operation file; + context->setContextProperty("fileOperation", &file); + QStringList positionalArguments = parser.positionalArguments(); if (positionalArguments.length() == 2) { port = positionalArguments.takeFirst().toInt(); token = positionalArguments.takeFirst(); + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), token); + bindingAddress.setQuery(query); + + Navigation *navigation = new Navigation(bindingAddress, context); + context->setContextProperty("navigation", navigation); } fprintf(stderr, "[navigation] app_name: %s, port: %d, token: %s.\n", graphic_role.toStdString().c_str(), @@ -81,17 +101,12 @@ int main(int argc, char *argv[]) qDebug("Surface %s got showWindow\n", graphic_role.toStdString().c_str()); qwmHandler->activateWindow(graphic_role); }); - // Load qml - QQmlApplicationEngine engine; MarkerModel model; - engine.rootContext()->setContextProperty("markerModel", &model); + context->setContextProperty("markerModel", &model); Guidance_Module guidance; - engine.rootContext()->setContextProperty("guidanceModule", &guidance); - - File_Operation file; - engine.rootContext()->setContextProperty("fileOperation", &file); + context->setContextProperty("guidanceModule", &guidance); engine.load(QUrl(QStringLiteral("qrc:/navigation.qml"))); QObject *root = engine.rootObjects().first(); diff --git a/app/navigation.qml b/app/navigation.qml index c23d1d5..2b30581 100644 --- a/app/navigation.qml +++ b/app/navigation.qml @@ -61,7 +61,25 @@ ApplicationWindow { } } - Map{ + Connections { + target: navigation + + onWaypointsEvent: { + // only support one waypoint currently + map.doSetWaypointsSlot(data.points[0].latitude, data.points[0].longitude, true) + } + + onStatusEvent: { + if (data.state == "stop") { + map.doPauseSimulationSlot() + } + if (data.state == "start") { + btn_guidance.startGuidance() + } + } + } + + Map { id: map property int pathcounter : 0 property int segmentcounter : 0 @@ -74,12 +92,6 @@ ApplicationWindow { property variant currentpostion : QtPositioning.coordinate(car_position_lat, car_position_lon) property int last_segmentcounter : -1 - signal qmlSignalRouteInfo(double srt_lat,double srt_lon,double end_lat,double end_lon); - signal qmlSignalPosInfo(double lat,double lon,double drc,double dst); - signal qmlSignalStopDemo(); - signal qmlSignalArrived(); - signal qmlCheckDirection(double cur_dir,double next_dir,double is_rot); - width: parent.width height: parent.height plugin: fileOperation.isOSMEnabled() ? osm : mapbox @@ -320,7 +332,7 @@ ApplicationWindow { } routeModel.update() - map.qmlSignalRouteInfo(car_position_lat, car_position_lon,coord.latitude,coord.longitude) + navigation.broadcastRouteInfo(car_position_lat, car_position_lon,coord.latitude,coord.longitude) // update icon_end_point icon_end_point.coordinate = coord @@ -336,7 +348,7 @@ ApplicationWindow { // reset currentpostion map.currentpostion = QtPositioning.coordinate(car_position_lat, car_position_lon) car_accumulated_distance = 0 - map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance) + navigation.broadcastPosition(car_position_lat, car_position_lon,car_direction,car_accumulated_distance) routeQuery.clearWaypoints(); routeQuery.addWaypoint(map.currentpostion) @@ -539,7 +551,7 @@ ApplicationWindow { { map.currentpostion = routeModel.get(0).path[pathcounter] car_accumulated_distance += next_distance - map.qmlSignalPosInfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance) + navigation.broadcastPosition(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance) if(pathcounter < routeModel.get(0).path.length - 1){ pathcounter++ } @@ -547,14 +559,14 @@ ApplicationWindow { { // Arrive at your destination btn_guidance.sts_guide = 0 - map.qmlSignalArrived() + navigation.broadcastStatus("arrived") } }else{ setNextCoordinate(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,root.car_moving_distance) if(pathcounter != 0){ car_accumulated_distance += root.car_moving_distance } - map.qmlSignalPosInfo(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance) + navigation.broadcastPosition(map.currentpostion.latitude, map.currentpostion.longitude,next_direction,car_accumulated_distance) } if(btn_present_position.state === "Flowing") @@ -593,12 +605,12 @@ ApplicationWindow { function doGetRouteInfoSlot(){ if(btn_guidance.sts_guide == 0){ // idle - map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance); + navigation.broadcastPosition(car_position_lat, car_position_lon,car_direction,car_accumulated_distance); }else if(btn_guidance.sts_guide == 1){ // Routing - map.qmlSignalPosInfo(car_position_lat, car_position_lon,car_direction,car_accumulated_distance); - map.qmlSignalRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude); + navigation.broadcastPosition(car_position_lat, car_position_lon,car_direction,car_accumulated_distance); + navigation.broadcastRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude); }else if(btn_guidance.sts_guide == 2){ // onGuide - map.qmlSignalRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude); + navigation.broadcastRouteInfo(car_position_lat, car_position_lon,routeQuery.waypoints[1].latitude,routeQuery.waypoints[1].longitude); } } |