summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/app.pro7
-rw-r--r--app/dbus_client.cpp116
-rw-r--r--app/dbus_client.h46
-rw-r--r--app/file_operation.cpp35
-rw-r--r--app/file_operation.h6
-rw-r--r--app/main.cpp28
-rw-r--r--app/org.agl.naviapi.xml28
-rw-r--r--app/qcheapruler.cpp30
-rw-r--r--app/qcheapruler.hpp6
-rw-r--r--app/qml/Main.qml163
-rw-r--r--app/qml/MapWindow.qml141
-rw-r--r--app/qml/TbtBoard.qml2
-rw-r--r--package/config.xml2
13 files changed, 320 insertions, 290 deletions
diff --git a/app/app.pro b/app/app.pro
index 594eca3..275b29e 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,7 +1,7 @@
TARGET = tbtnavi
TEMPLATE = app
-QT += qml network quick positioning location sql widgets dbus
+QT += qml network quick positioning location sql widgets
CONFIG += c++14
@@ -14,12 +14,10 @@ ios|android {
SOURCES += \
main.cpp \
qcheapruler.cpp \
- dbus_client.cpp \
file_operation.cpp
HEADERS += \
qcheapruler.hpp \
- dbus_client.h \
file_operation.h
INCLUDEPATH += \
@@ -31,6 +29,3 @@ OTHER_FILES += \
RESOURCES += \
images/images.qrc \
app.qrc
-
-DBUS_ADAPTORS += org.agl.naviapi.xml
-DBUS_INTERFACES += org.agl.naviapi.xml
diff --git a/app/dbus_client.cpp b/app/dbus_client.cpp
deleted file mode 100644
index 6b5b5fb..0000000
--- a/app/dbus_client.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "dbus_client.h"
-
-dbus_client::dbus_client(const QString &pathName,
- const QString &objName,
- const QString &serverName,
- QObject *parent) :
- m_serverName(serverName),
- m_pathName(pathName + serverName),
- m_objName(objName + serverName)
-{
- //DBus & api ini
- initDBus();
- initAPIs(parent);
-}
-
-dbus_client::~dbus_client(){}
-
-void dbus_client::initDBus(){
-
- new NaviapiAdaptor(this);
-
- //make a connect session to navigation service(add route info)
- if (!QDBusConnection::sessionBus().connect(
- QString(),
- QString(),
- m_pathName,
- "signalRouteInfo",
- this,
- SLOT(addRoutePointsSlot(double, double, double, double)))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalRouteInfo failed";
- }
-
- //make a connect session to navigation service(current postion info)
- if (!QDBusConnection::sessionBus().connect(
- QString(),
- QString(),
- m_pathName,
- "signalPosInfo",
- this,
- SLOT(positionSlot(double, double, double, double)))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalPosInfo failed";
- }
-
- //make a connect session to navigation service(when demo stopped)
- if (!QDBusConnection::sessionBus().connect(
- QString(),
- QString(),
- m_pathName,
- "signalStopDemo",
- this,
- SLOT(stopdemoSlot()))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalStopDemo failed";
- }
-
- //make a connect session to navigation service(when arrived destination)
- if (!QDBusConnection::sessionBus().connect(
- QString(),
- QString(),
- m_pathName,
- "signalArrvied",
- this,
- SLOT(arrivedestSlot()))) { //slot
- qDebug() << m_serverName << "sessionBus.connect(): signalArrvied failed";
- }
-}
-
-void dbus_client::initAPIs(QObject *parent){
- //connect the signal to qml inside function(addRoutePointsQml -> do_addRoutePoint)
- if(!QObject::connect(this, SIGNAL(addRoutePointsQml(QVariant, QVariant, QVariant, QVariant)),
- parent, SLOT(do_addRoutePoint(QVariant, QVariant, QVariant, QVariant)))) {
- qDebug() << m_serverName << "SIGNAL:addRoutePointsQml to qmlSLOT:do_addRoutePoint connect is failed";
- }
-
- //connect the signal to qml inside function(positionQml -> do_setCoordinate)
- if(!QObject::connect(this, SIGNAL(positionQml(QVariant, QVariant,QVariant, QVariant)),
- parent, SLOT(do_setCoordinate(QVariant, QVariant,QVariant, QVariant)))) {
- qDebug() << m_serverName << "SIGNAL:positionQml to qmlSLOT:do_setCoordinate connect is failed";
- }
-
- //connect the signal to qml inside function(stopdemoQml -> do_stopnavidemo)
- if(!QObject::connect(this, SIGNAL(stopdemoQml()),
- parent, SLOT(do_stopnavidemo()))) {
- qDebug() << m_serverName << "SIGNAL:stopdemoQml to qmlSLOT:do_stopnavidemo connect is failed";
- }
-
- //connect the signal to qml inside function(arrivedestQml -> do_arrivedest)
- if(!QObject::connect(this, SIGNAL(arrivedestQml()),
- parent, SLOT(do_arrivedest()))) {
- qDebug() << m_serverName << "SIGNAL:arrivedestQml to qmlSLOT:do_arrivedest connect is failed";
- }
-}
-
-//Signal&&Method
-//addRoutePointsSlot -> addRoutePointsQml(use for qml)
-void dbus_client::addRoutePointsSlot(double route_Lat_s, double route_Lon_s, double route_Lat_e, double route_Lon_e)
-{
- emit addRoutePointsQml(route_Lat_s, route_Lon_s, route_Lat_e, route_Lon_e);
-}
-
-//positionSlot -> positionQml(use for qml)
-void dbus_client::positionSlot(double cur_Lat_p, double cur_Lon_p,double cur_direction, double cur_distance)
-{
- emit positionQml(cur_Lat_p, cur_Lon_p,cur_direction,cur_distance);
-}
-
-//stopdemoSlot -> stopdemoQml(use for qml)
-void dbus_client::stopdemoSlot()
-{
- emit stopdemoQml();
-}
-
-//arrivedestSlot -> arrivedestQml(use for qml)
-void dbus_client::arrivedestSlot()
-{
- emit arrivedestQml();
-}
diff --git a/app/dbus_client.h b/app/dbus_client.h
deleted file mode 100644
index 0abae31..0000000
--- a/app/dbus_client.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef DBUS_CLIENT_H
-#define DBUS_CLIENT_H
-
-#include "naviapi_interface.h"
-#include "naviapi_adaptor.h"
-#include <QtQml/QQmlApplicationEngine>
-
-class dbus_client : public QObject{
- Q_OBJECT
- QString m_serverName;
- QString m_pathName;
- QString m_objName;
-
-public:
- dbus_client(const QString &pathName,
- const QString &objName,
- const QString &serverName,
- QObject *parent = nullptr);
- ~dbus_client();
-
-private:
- //DBus & API init
- void initDBus();
- void initAPIs(QObject*);
-
-signals:
- //notify add routepoints signal to qml
- void addRoutePointsQml(QVariant, QVariant, QVariant, QVariant);
- //notify current position signal to qml
- void positionQml(QVariant, QVariant,QVariant, QVariant);
- //notify stop demo signal to qml
- void stopdemoQml();
- //notify arrive destination signal to qml
- void arrivedestQml();
-
-private slots:
- //receive add routepoints notify from navigation service
- void addRoutePointsSlot(double route_Lat_s, double route_Lon_s, double route_Lat_e, double route_Lon_e);
- //receive current position notify from navigation service
- void positionSlot(double cur_Lat_p, double cur_Lon_p,double cur_direction, double cur_distance);
- //receive stop demo notify from navigation service
- void stopdemoSlot();
- //receive arrive destination notify from navigation service
- void arrivedestSlot();
-};
-#endif // DBUS_CLIENT_H
diff --git a/app/file_operation.cpp b/app/file_operation.cpp
index a191c76..b51477e 100644
--- a/app/file_operation.cpp
+++ b/app/file_operation.cpp
@@ -12,9 +12,9 @@ void File_Operation::initFileOperation(){
m_mapAccessToken = "";
m_car_speed = 60; // set default Km/h
- m_update_interval = 100; // set default millisecond
- m_start_latitude = 35.692396; // set default coordinate Tokyo Hilton
- m_start_longitute = 139.691102;
+ m_start_latitude = 36.136261; // set default coordinate Tokyo Hilton
+ m_start_longitute = -115.151254;
+ m_mapStyleUrls = "mapbox://styles/mapbox/streets-v10"; // set default map style
QFile file(NAVI_CONFIG_FILEPATH);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
@@ -32,12 +32,6 @@ void File_Operation::initFileOperation(){
fprintf(stderr,"Failed to find mapAccessToken data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
return;
}
- if(jsonObj.contains("mapStyle")){
- m_mapStyle = jsonObj["mapStyle"].toString();
- }else{
- fprintf(stderr,"Failed to find mapStyle data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
- return;
- }
if(jsonObj.contains("speed")){
m_car_speed = jsonObj["speed"].toDouble();
@@ -46,13 +40,6 @@ void File_Operation::initFileOperation(){
return;
}
- if(jsonObj.contains("interval")){
- m_update_interval = jsonObj["interval"].toInt();
- }else{
- fprintf(stderr,"Failed to find interval data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
- return;
- }
-
if(jsonObj.contains("latitude")){
m_start_latitude = jsonObj["latitude"].toDouble();
}else{
@@ -67,6 +54,13 @@ void File_Operation::initFileOperation(){
return;
}
+ if(jsonObj.contains("mapStyleUrls")){
+ m_mapStyleUrls = jsonObj["mapStyleUrls"].toString();
+ }else{
+ fprintf(stderr,"Failed to find mapStyleUrls data \"%s\": %m", qPrintable(NAVI_CONFIG_FILEPATH));
+ return;
+ }
+
file.close();
return;
@@ -75,18 +69,15 @@ void File_Operation::initFileOperation(){
QString File_Operation::getMapAccessToken() {
return m_mapAccessToken;
}
-QString File_Operation::getMapStyle() {
- return m_mapStyle;
-}
double File_Operation::getCarSpeed(){
return m_car_speed;
}
-int File_Operation::getUpdateInterval(){
- return m_update_interval;
-}
double File_Operation::getStartLatitude(){
return m_start_latitude;
}
double File_Operation::getStartLongitute(){
return m_start_longitute;
}
+QString File_Operation::getMapStyleUrls() {
+ return m_mapStyleUrls;
+}
diff --git a/app/file_operation.h b/app/file_operation.h
index 65df54a..9fbbd6c 100644
--- a/app/file_operation.h
+++ b/app/file_operation.h
@@ -16,22 +16,20 @@ class File_Operation: public QObject{
Q_OBJECT
QString m_mapAccessToken;
- QString m_mapStyle;
double m_car_speed; // set Km/h
- int m_update_interval; // set millisecond
double m_start_latitude;
double m_start_longitute;
+ QString m_mapStyleUrls;
public:
File_Operation();
~File_Operation();
Q_INVOKABLE QString getMapAccessToken();
- Q_INVOKABLE QString getMapStyle();
Q_INVOKABLE double getCarSpeed();
- Q_INVOKABLE int getUpdateInterval();
Q_INVOKABLE double getStartLatitude();
Q_INVOKABLE double getStartLongitute();
+ Q_INVOKABLE QString getMapStyleUrls();
private:
void initFileOperation();
diff --git a/app/main.cpp b/app/main.cpp
index 4f13346..6122733 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -9,7 +9,6 @@
#include <QtDBus/QDBusConnection>
#include "qcheapruler.hpp"
-#include "dbus_client.h"
#include "file_operation.h"
#ifdef HAVE_QLIBHOMESCREEN
@@ -21,12 +20,6 @@
int main(int argc, char *argv[])
{
- if (!QDBusConnection::sessionBus().isConnected()) {
- qWarning("Cannot connect to the D-Bus session bus.\n"
- "Please check your system settings and try again.\n");
- return 1;
- }
-
QString myname = QString("tbtnavi");
QGuiApplication app(argc, argv);
@@ -43,12 +36,25 @@ int main(int argc, char *argv[])
parser.process(app);
QStringList positionalArguments = parser.positionalArguments();
+ //make the bindingAddress for websocket
QQmlApplicationEngine engine;
+ QUrl bindingAddress;
int port = 0;
QString secret;
if (positionalArguments.length() == 2) {
port = positionalArguments.takeFirst().toInt();
secret = positionalArguments.takeFirst();
+
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), secret);
+ bindingAddress.setQuery(query);
+ engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
+ }else {
+ engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
}
#ifdef HAVE_QLIBWINDOWMANAGER
@@ -76,9 +82,11 @@ int main(int argc, char *argv[])
#endif
qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler");
+ //read the config info from /etc/naviconfig.ini
File_Operation file;
engine.rootContext()->setContextProperty("fileOperation", &file);
+ //load the qml file
engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml")));
QObject *root = engine.rootObjects().first();
@@ -86,12 +94,6 @@ int main(int argc, char *argv[])
#ifdef HAVE_QLIBHOMESCREEN
qhs->setQuickWindow(window);
#endif
- //make the DBus connection info
- QString pathBase = "org.agl.";
- QString objBase = "/org/agl/";
- QString serverName = "naviapi";
- QObject *mapWindow = root->findChild<QObject*>("mapwindow");
- dbus_client dbus(pathBase, objBase, serverName, mapWindow);
#ifdef HAVE_QLIBWINDOWMANAGER
// QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
diff --git a/app/org.agl.naviapi.xml b/app/org.agl.naviapi.xml
deleted file mode 100644
index d1538e7..0000000
--- a/app/org.agl.naviapi.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name="org.agl.naviapi">
- <!-- void signalRouteInfo() -->
- <signal name="signalRouteInfo">
- <arg name="start_latitude" type="d" direction="out"/>
- <arg name="start_longitude" type="d" direction="out"/>
- <arg name="end_latitude" type="d" direction="out"/>
- <arg name="end_longitude" type="d" direction="out"/>
- </signal>
- <!-- void signalPosInfo() -->
- <signal name="signalPosInfo">
- <arg name="latitude" type="d" direction="out"/>
- <arg name="longitude" type="d" direction="out"/>
- <arg name="direction" type="d" direction="out"/>
- <arg name="distance" type="d" direction="out"/>
- </signal>
- <!-- void signalStopDemo() -->
- <signal name="signalStopDemo">
- </signal>
- <!-- void signalArrvied() -->
- <signal name="signalArrvied">
- </signal>
- <!-- void getRouteInfo() -->
- <signal name="getRouteInfo">
- </signal>
- </interface>
-</node>
diff --git a/app/qcheapruler.cpp b/app/qcheapruler.cpp
index 890fd63..6e2f59c 100644
--- a/app/qcheapruler.cpp
+++ b/app/qcheapruler.cpp
@@ -1,13 +1,12 @@
#include "qcheapruler.hpp"
-#include "naviapi_adaptor.h"
#include <QString>
QCheapRuler::QCheapRuler()
{
//set the default current position
- // m_currentPosition = QGeoCoordinate(36.136261, -115.151254);
- m_currentPosition = QGeoCoordinate(35.692396, 139.691102);
+ m_currentPosition = QGeoCoordinate(36.136261, -115.151254);
+ //m_currentPosition = QGeoCoordinate(35.692396, 139.691102);
}
QCheapRuler::~QCheapRuler()
@@ -26,6 +25,14 @@ double QCheapRuler::currentDistance() const
return m_currentDistance;
}
+//get the current Coordinate
+void QCheapRuler::setCurrentCoordinate(QString m_latitude,QString m_longitude)
+{
+ double latitude = m_latitude.toDouble();
+ double longitude = m_longitude.toDouble();
+ setCurrentPosition(latitude,longitude);
+}
+
//set current position below the coordinate info from navigation service
void QCheapRuler::setCurrentPosition(double latitude, double longitude)
{
@@ -39,10 +46,12 @@ void QCheapRuler::setCurrentPosition(double latitude, double longitude)
}
}
-void QCheapRuler::setCurrentDistance(double distance)
+void QCheapRuler::setCurrentDistance(QString strdistance)
{
+ double distance = strdistance.toDouble();
//set current distance info and notify the changes when the info has changed
//but it will not send notify when it start or stop demo
+
if((m_currentDistance != distance)
&&(distance != 0.0))
{
@@ -59,7 +68,7 @@ QGeoCoordinate QCheapRuler::currentPosition() const
QJSValue QCheapRuler::path() const
{
- // Should neveer be called.
+ // Should never be called.
return QJSValue();
}
@@ -95,17 +104,6 @@ void QCheapRuler::setPath(const QJSValue &value)
emit pathChanged();
}
-//init the route and postion info when start in the first time.(can be called by qml)
-void QCheapRuler::initRouteInfo()
-{
- //send "getRouteInfo" message to the navigation service
- QDBusMessage message = QDBusMessage::createSignal("/", "org.agl.naviapi", "getRouteInfo");
- if(!QDBusConnection::sessionBus().send(message))
- {
- qDebug() << "initRouteInfo" << "sessionBus.send(): getRouteInfo failed";
- }
-}
-
//init the CheapRuler class
cr::CheapRuler QCheapRuler::ruler() const
{
diff --git a/app/qcheapruler.hpp b/app/qcheapruler.hpp
index 9e9c664..8d3d7bb 100644
--- a/app/qcheapruler.hpp
+++ b/app/qcheapruler.hpp
@@ -31,11 +31,11 @@ public:
QGeoCoordinate currentPosition() const;
QJSValue path() const;
void setPath(const QJSValue &value);
+ void setCurrentPosition(double, double);
//functions that can called by qml(Q_INVOKABLE)
- Q_INVOKABLE void initRouteInfo();
- Q_INVOKABLE void setCurrentPosition(double, double);
- Q_INVOKABLE void setCurrentDistance(double);
+ Q_INVOKABLE void setCurrentCoordinate(QString,QString);
+ Q_INVOKABLE void setCurrentDistance(QString);
signals:
//notify signals to qml
diff --git a/app/qml/Main.qml b/app/qml/Main.qml
index 4139cb9..2162e2e 100644
--- a/app/qml/Main.qml
+++ b/app/qml/Main.qml
@@ -1,5 +1,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.2
+import QtWebSockets 1.0
+import QtPositioning 5.0
import "qrc:/qml"
@@ -11,6 +13,167 @@ ApplicationWindow {
width: 640
visible: true
+ property string tbt_navi_request_str: ""
+ property string api_str: "naviapi"
+ property string verb_getrouteinfo: "navicore_getrouteinfo"
+ property string verb_getallsessions: "navicore_getallsessions"
+ property string verb_subscribe: "subscribe"
+ property string verb_unsubscribe: "unsubscribe"
+ property string event_setdemorouteinfo: "naviapi/navicore_setdemorouteinfo"
+ property string event_arrivedest: "naviapi/navicore_arrivedest"
+ property string event_stopdemo: "naviapi/navicore_stopdemo"
+ property string event_setdestpos: "naviapi/navicore_setdestpos"
+ property string event_gps: "naviapi/navicore_gps"
+ property string event_getdestdir: "naviapi/navicore_getdestdir"
+ property var msgid_enu: { "call":2, "retok":3, "reterr":4, "event":5 }
+
+ WebSocket {
+ id: websocket
+ url: bindingAddress
+
+ onStatusChanged: {
+ if (websocket.status === WebSocket.Error){
+ console.log ("Error: " + websocket.errorString)
+ websocket.active = false
+ countdown.start()
+ }else if (websocket.status === WebSocket.Open){
+ console.log ("Socket Open")
+ do_getallsessions()
+ }else if (websocket.status === WebSocket.Closed){
+ console.log ("Socket closed")
+ }
+ }
+
+ onTextMessageReceived: {
+ console.log("tbtnavi:onTextMessageReceived: " + message)
+ var message_json = JSON.parse(message)
+
+ //analyse the infomation from the naviapi service
+ if (message_json[0] === msgid_enu.event)
+ {
+ //set route infomation during the route demo
+ if(message_json[2].event === event_setdemorouteinfo)
+ {
+ var latitude = message_json[2].data[0].DemoLatitude
+ var longitude = message_json[2].data[0].DemoLongitude
+ var distance = message_json[2].data[0].DemoDistance
+ var direction = message_json[2].data[0].DemoDirection
+ console.log("tbtnavi: distance = " + distance + "direction = " + direction)
+ mapwindow.do_setDirection(direction)
+ mapwindow.do_setNextCrossDistance(distance)
+ }
+ //when arrive the destination
+ else if(message_json[2].event === event_arrivedest)
+ {
+ mapwindow.do_arrivedest()
+ }
+ //when the demo stopped
+ else if(message_json[2].event === event_stopdemo)
+ {
+ mapwindow.do_stopnavidemo()
+ mapwindow.do_setCoordinate(35.6673965582,139.7491882778)
+ mapwindow.startPoint = QtPositioning.coordinate(35.6673965582,139.7491882778);
+ }
+ //when add destination
+ else if(message_json[2].event === event_setdestpos)
+ {
+ var allroutes = message_json[2].data[0].AllRoutes
+ var destlat = message_json[2].data[0].DestinationLatitude
+ var destlon = message_json[2].data[0].DestinationLongitude
+ mapwindow.do_setdest(allroutes,destlat,destlon)
+ }
+ else if(message_json[2].event === event_gps){
+ console.log ("tbt:Receive Event======event_gps")
+ var lat = message_json[2].data.latitude
+ var lon = message_json[2].data.longitude
+ console.log ("tbt:Receive Event lat====== " + lat+" "+"lon======"+lon)
+ mapwindow.do_setCoordinate(lat,lon)
+
+ }
+ else if(message_json[2].event === event_getdestdir){
+ var state = message_json[2].data.state
+ mapwindow.do_setTbtState(state)
+ }
+ }
+ else if (message_json[0] === msgid_enu.retok)
+ {
+ //when connect successed request the route infomation
+ if(message_json[2].request.info === verb_getallsessions)
+ {
+ do_getrouteinfo()
+ }
+ //add destination
+ else if(message_json[2].request.info === verb_getrouteinfo)
+ {
+ var routes = message_json[2].response[0].AllRoutes
+ var currentlat = message_json[2].response[0].CurrentLatitude
+ var currentlon = message_json[2].response[0].CurrentLongitude
+ var destposlat = message_json[2].response[0].DestinationLatitude
+ var destposlon = message_json[2].response[0].DestinationLongitude
+ mapwindow.do_addRoutePoint(currentlat,currentlon,destposlat,destposlon,routes)
+ }
+ }
+ else{
+ console.log("Raw response: " + message)
+ }
+ }
+ active: false
+ }
+
+ Timer {
+ id: countdown
+ repeat: false
+ interval: 3000
+ triggeredOnStart: false
+ onTriggered: {
+ websocket.active = true
+ }
+ }
+
+ onVisibleChanged: {
+ if (visible){
+ if (!websocket.active){
+ websocket.active = true
+ }
+ }
+ else {
+ countdown.stop()
+ if (websocket.active){
+ do_unsubscribe("setdemopos")
+ do_unsubscribe("stopdemo")
+ do_unsubscribe("arrivedest")
+ }
+ }
+ }
+
+ //make a connect to the naviapi service
+ function do_getallsessions() {
+ tbt_navi_request_str = '[' + msgid_enu.call + ',"99999","' + api_str+'/'+verb_getallsessions + '", {} ]'
+ console.log (tbt_navi_request_str)
+ websocket.sendTextMessage (tbt_navi_request_str)
+ }
+
+ //get route information
+ function do_getrouteinfo() {
+ tbt_navi_request_str = '[' + msgid_enu.call + ',"99999","' + api_str+'/'+verb_getrouteinfo+ '", {}]'
+ console.log (tbt_navi_request_str)
+ websocket.sendTextMessage (tbt_navi_request_str)
+ }
+
+ //subscribe
+ function do_subscribe( event ) {
+ tbt_navi_request_str = '[' + msgid_enu.call + ',"99999","' + api_str+'/'+verb_subscribe + '", {"value":"' + event + '"} ]'
+ console.log (tbt_navi_request_str)
+ websocket.sendTextMessage (tbt_navi_request_str)
+ }
+
+ //unsubscribe
+ function do_unsubscribe( event ) {
+ tbt_navi_request_str = '[' + msgid_enu.call + ',"99999","' + api_str+'/'+verb_unsubscribe + '", {"value":"' + event + '"} ]'
+ console.log (tbt_navi_request_str)
+ websocket.sendTextMessage (tbt_navi_request_str)
+ }
+
Item {
anchors.centerIn: parent
width: parent.width
diff --git a/app/qml/MapWindow.qml b/app/qml/MapWindow.qml
index 8a41390..8321515 100644
--- a/app/qml/MapWindow.qml
+++ b/app/qml/MapWindow.qml
@@ -7,7 +7,7 @@ import com.mapbox.cheap_ruler 1.0
Item {
id: mapWindow
- property int disOffset: 70
+ property int disOffset: fileOperation.getCarSpeed() // set Km/h
property real rotateAngle: 0
property var startPoint
property var endPoint
@@ -29,28 +29,18 @@ Item {
name: "mapboxgl"
PluginParameter {
- name: "mapboxgl.mapping.items.insert_before"
- value: "road-label-small"
- }
-
- PluginParameter {
name: "mapboxgl.mapping.additional_style_urls"
- value: "mapbox://styles/mapbox/streets-v9"
+ value: fileOperation.getMapStyleUrls()
}
PluginParameter {
name: "mapboxgl.access_token"
value: fileOperation.getMapAccessToken()
}
-
- PluginParameter {
- name: "mapboxgl.mapping.cache.directory"
- value: "/home/0/app-data/navigation/"
- }
}
center: ruler.currentPosition
- zoomLevel: 20
+ zoomLevel: 18
tilt: 60
gesture.acceptedGestures:MapGestureArea.NoGesture
copyrightsVisible: false
@@ -166,7 +156,7 @@ Item {
CheapRuler {
id: ruler
- onCurrentDistanceChanged: {
+ /* onCurrentDistanceChanged: {
var total = 0;
var i = 0;
var alldistance = ruler.distance * 1000;
@@ -181,20 +171,21 @@ Item {
}
//show the tbt board(it will be always show when demo start)
- tbt_board.visible = true
+// tbt_board.visible = true
// Set turn instruction
tbt_board.do_setTurnInstructions(routeModel.get(0).segments[i].maneuver.instructionText)
- tbt_board.state = routeModel.get(0).segments[i].maneuver.direction
+// tbt_board.state = routeModel.get(0).segments[i].maneuver.direction
//when goto the last instruction,set the states to "arriveDest"
if(i >= (routeModel.get(0).segments.length-1))
{
total = alldistance;
- tbt_board.state = "arriveDest";
+// tbt_board.state = "arriveDest";
}
var dis = (total - ruler.currentDistance).toFixed(1);
+ console.log("tbtnavi:dis = " + dis)
// Set distance
tbt_board.do_setDistance(dis)
@@ -211,7 +202,7 @@ Item {
tbt_board.do_showTbtboard(false)
}
}
- }
+ }*/ //deleted
}
}
@@ -239,30 +230,91 @@ Item {
Component.onCompleted: {
//request the route info when map load finish
- if (ruler) {
- ruler.initRouteInfo();
- ruler.setCurrentPosition(fileOperation.getStartLatitude(), fileOperation.getStartLongitute());
- }
- }
+ console.log("Component.onCompleted")
+ }
//the functions can be called by outside
//add route signal function
- function do_addRoutePoint(poi_Lat_s, poi_Lon_s, poi_Lat_e, poi_Lon_e) {
- //set the startPoint and endPoint
- startPoint= QtPositioning.coordinate(poi_Lat_s,poi_Lon_s);
- endPoint = QtPositioning.coordinate(poi_Lat_e,poi_Lon_e);
+ function do_addRoutePoint(poi_Lat_s, poi_Lon_s, poi_Lat_e, poi_Lon_e,routes) {
+
+ var latitude = ""
+ var longitute = ""
+ //when current point is null
+ if((poi_Lat_s === "")
+ &&(poi_Lon_s === ""))
+ {
+ latitude = fileOperation.getStartLatitude()
+ longitute = fileOperation.getStartLongitute()
+ }
+ else
+ {
+ latitude = poi_Lat_s
+ longitute = poi_Lon_s
+ }
+
+ startPoint= QtPositioning.coordinate( latitude,longitute);
startMarker.coordinate = startPoint;
- endMarker.coordinate = endPoint;
- //update the route view
- if (map) {
- map.updateRoute();
+
+ if (ruler) {
+ console.log ("latitude:"+latitude+" longitute:"+longitute)
+ ruler.setCurrentCoordinate(latitude,longitute);
+ if((routes !== 0)
+ &&(poi_Lat_e !== "")
+ &&(poi_Lon_e !== ""))
+ {
+ endPoint = QtPositioning.coordinate(poi_Lat_e,poi_Lon_e);
+ endMarker.coordinate = endPoint;
+ //update the route view
+ if (map) {
+ map.updateRoute();
+ }
+ }
+ window.do_subscribe("gps")
+ window.do_subscribe("getdestdir")
+ window.do_subscribe("adddest")
+ window.do_subscribe("setdemopos")
+ window.do_subscribe("stopdemo")
+ window.do_subscribe("arrivedest")
}
}
//set the current position
- function do_setCoordinate(latitude,longitude,direction,distance) {
- ruler.setCurrentPosition(latitude, longitude);
- ruler.setCurrentDistance(distance);
+ function do_setCoordinate(latitude,longitude) {
+ ruler.setCurrentCoordinate(latitude, longitude);
+ }
+
+ function do_setDistance(distance) {
+ ruler.setCurrentDistance(distance);
+ }
+
+ function do_setNextCrossDistance(distance) {
+ var dis = distance;
+ console.log("tbtnavi:dis = " + dis)
+
+ // Set distance
+ tbt_board.do_setDistance(dis)
+
+ // Set board status
+ if((dis < mapWindow.disOffset) && (dis > 2))
+ {
+ //show the tbt board(the big one)
+ tbt_board.do_showTbtboard(false)
+ }
+ else
+ {
+ //disvisible the tbt board(the big one)
+ tbt_board.do_showTbtboard(false)
+ }
+ }
+
+ function do_setDirection(direction) {
+// ruler.setCurrentDistance(direction);
+ }
+
+ function do_setTbtState(tbtstate) {
+ //show the tbt board(it will be always show when demo start)
+ tbt_board.visible = true;
+ tbt_board.state = tbtstate;
}
//stop navidemo signal
@@ -280,4 +332,25 @@ Item {
//disvisible the tbt board
tbt_board.visible = false
}
+
+ //set the current position
+ function do_setdest(allroutes,latitude,longitude) {
+ if((allroutes !== 0)
+ &&(latitude !== "")
+ &&(longitude !== ""))
+ {
+ endPoint = QtPositioning.coordinate(latitude,longitude);
+ endMarker.coordinate = endPoint;
+
+ if (ruler) {
+ if(allroutes !== 0)
+ {
+ //update the route view
+ if (map) {
+ map.updateRoute();
+ }
+ }
+ }
+ }
+ }
}
diff --git a/app/qml/TbtBoard.qml b/app/qml/TbtBoard.qml
index cf6f537..738530d 100644
--- a/app/qml/TbtBoard.qml
+++ b/app/qml/TbtBoard.qml
@@ -93,7 +93,7 @@ Item {
// the cases of direction arrow board
states: [
State {
- name: "arriveDest" //arrive the destination
+ name: "12" //arrive the destination
PropertyChanges { target: turnDirectionBoard; source: "qrc:destination_full.png" }
PropertyChanges { target: turnDirection; source: "qrc:destination.png" }
},
diff --git a/package/config.xml b/package/config.xml
index c1905ec..3b359f3 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -9,9 +9,9 @@
<feature name="urn:AGL:widget:required-api">
<param name="windowmanager" value="ws"/>
<param name="homescreen" value="ws"/>
+ <param name="naviapi" value="ws"/>
</feature>
<feature name="urn:AGL:widget:required-permission">
<param name="urn:AGL:permission::public:no-htdocs" value="required" />
- <param name="http://tizen.org/privilege/internal/dbus" value="required"/>
</feature>
</widget>