summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author <philippe colliot>2014-06-18 14:57:42 +0200
committer <philippe colliot>2014-06-18 14:57:42 +0200
commit83af236086378785cbec01e1d70863a5d2382fbc (patch)
tree7b147473dd62b1bfe2f504d94ea7e465712c6bac
parent13e7dfd151202598a3d700c2f6e113ce31885122 (diff)
downloadpoi-service-83af236086378785cbec01e1d70863a5d2382fbc.tar.gz
add an option to makefiles, add a test file for navigation
-rw-r--r--src/navigation/script/Makefile6
-rw-r--r--src/poi-service/script/Makefile7
-rw-r--r--test/navigation/test-route-calculation.py118
-rw-r--r--test/poi-service/script/Makefile7
4 files changed, 135 insertions, 3 deletions
diff --git a/src/navigation/script/Makefile b/src/navigation/script/Makefile
index bb0bb4a..d010ce1 100644
--- a/src/navigation/script/Makefile
+++ b/src/navigation/script/Makefile
@@ -22,6 +22,7 @@
# List of changes:
#
# 4/6/2014, Philippe Colliot, complete src-clean option
+# 18/6/2014, Philippe Colliot, APT_GET option for Fedora
#
# @licence end@
SRC_DIR=$(CURDIR)/../../navigation
@@ -32,7 +33,9 @@ MAP_DIR=$(CURDIR)/../../map
CONSTANTS_BIN=$(BIN_DIR)/constants
QMAKE=qmake
-APT_GET=apt-get
+ifndef $(APT_GET)
+ APT_GET=apt-get
+endif
default: help
@@ -42,6 +45,7 @@ help::
@echo "all2: Install all necessary dependencies and build all"
@echo "clean: Clean up build dir"
@echo "src-clean: Clean up all checked out sources"
+ @echo "make APT_GET=yum for Fedora, by default APT_GET is set to apt-get"
include *.mk
diff --git a/src/poi-service/script/Makefile b/src/poi-service/script/Makefile
index 1a0b041..8e91761 100644
--- a/src/poi-service/script/Makefile
+++ b/src/poi-service/script/Makefile
@@ -21,6 +21,7 @@
# List of changes:
#
# 4/6/2014, Philippe Colliot, complete src-clean option
+# 18/6/2014, Philippe Colliot, APT_GET option for Fedora
#
# @licence end@
@@ -34,7 +35,10 @@ CXX=g++
CXXFLAGS=-pipe -O2 -Wall
CHK_DIR_EXISTS=test -d
MKDIR=mkdir -p
-APT_GET=apt-get
+
+ifndef $(APT_GET)
+ APT_GET=apt-get
+endif
default: help
@@ -44,6 +48,7 @@ help::
@echo "clean: Clean up build dir"
@echo "src-clean: Clean up all checked out sources"
@echo "all2: Get $(DEPS) and build $(ALL)"
+ @echo "make APT_GET=yum for Fedora, by default APT_GET is set to apt-get"
#Clone the positioning repository for getting the API, generate the proxies and adaptors for the DBus APIs firstly
include get-positioning.mk
diff --git a/test/navigation/test-route-calculation.py b/test/navigation/test-route-calculation.py
new file mode 100644
index 0000000..f26c31c
--- /dev/null
+++ b/test/navigation/test-route-calculation.py
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+
+"""
+**************************************************************************
+* @licence app begin@
+* SPDX-License-Identifier: MPL-2.0
+*
+* \copyright Copyright (C) 2014, XS Embedded GmbH
+*
+* \file simulation-dashboard.py
+*
+* \brief This simple test shows how the route calculation
+* could be easily tested using a python script
+*
+* \author Marco Residori <marco.residori@xse.de>
+*
+* \version 1.0
+*
+* This Source Code Form is subject to the terms of the
+* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+* List of changes:
+* <date>, <name>, <description of change>
+*
+* @licence end@
+**************************************************************************
+"""
+
+
+import dbus
+import gobject
+import dbus.mainloop.glib
+
+#constants as defined in the Navigation API
+LATITUDE = 0x00a0
+LONGITUDE = 0x00a1
+TOTAL_DISTANCE = 0x018f
+
+print '\n--------------------------'
+print 'Route Calculation Test'
+print '--------------------------\n'
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+#connect to session bus
+bus = dbus.SessionBus()
+
+#signal receiver
+def catchall_route_calculation_signals_handler(routeHandle, status, percentage):
+ print 'Route Calculation: ' + str(int(percentage)) + ' %'
+ if int(percentage) == 100:
+ #get route overview
+ overview = routing_interface.GetRouteOverview(dbus.UInt32(routehandle),dbus.Array([dbus.UInt16(399)]))
+ #retrieve distance
+ totalDistance = int(overview[dbus.UInt16(TOTAL_DISTANCE)])
+ print 'Total Distance: ' + str(totalDistance) + ' m'
+ #check distance
+ if totalDistance < 100000 or totalDistance > 150000:
+ print '\nTest FAILED\n'
+ else:
+ print '\nTest PASSED\n'
+ loop.quit()
+
+#add signal receiver
+bus.add_signal_receiver(catchall_route_calculation_signals_handler, \
+ dbus_interface = "org.genivi.navigationcore.Routing", \
+ signal_name = "RouteCalculationProgressUpdate")
+
+#timeout
+def timeout():
+ print 'Timeout Expired'
+ print '\nTest FAILED\n'
+ loop.quit()
+
+session = bus.get_object('org.genivi.navigationcore.Session','/org/genivi/navigationcore')
+session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigationcore.Session')
+
+#get session handle
+sessionhandle = session_interface.CreateSession(dbus.String("test route calculation"))
+print 'Session handle: ' + str(sessionhandle)
+
+routing_obj = bus.get_object('org.genivi.navigationcore.Routing','/org/genivi/navigationcore')
+routing_interface = dbus.Interface(routing_obj, dbus_interface='org.genivi.navigationcore.Routing')
+
+#get route handle
+routehandle = routing_interface.CreateRoute(dbus.UInt32(sessionhandle))
+print 'Route handle: ' + str(routehandle)
+
+#route Zuerich->Bern (125Km)
+lat1 = 47.3673
+lon1 = 8.5500
+lat2 = 46.9479
+lon2 = 7.4446
+
+print 'Calculating route from \
+A(' + str(lat1) + ',' + str(lon1) + ') to \
+B(' + str(lat2) + ',' + str(lon2) + ')'
+
+#set waypoints
+routing_interface.SetWaypoints(dbus.UInt32(sessionhandle), \
+ dbus.UInt32(routehandle), \
+ dbus.Boolean(0), \
+ dbus.Array([ \
+ dbus.Dictionary({dbus.UInt16(LATITUDE):dbus.Double(lat1),dbus.UInt16(LONGITUDE):dbus.Double(lon1)}), \
+ dbus.Dictionary({dbus.UInt16(LATITUDE):dbus.Double(lat2),dbus.UInt16(LONGITUDE):dbus.Double(lon2)}) \
+ ]) \
+ )
+
+#calculate route
+routing_interface.CalculateRoute(dbus.UInt32(sessionhandle),dbus.UInt32(routehandle))
+
+#main loop
+gobject.timeout_add(5000, timeout)
+loop = gobject.MainLoop()
+loop.run()
+
+
diff --git a/test/poi-service/script/Makefile b/test/poi-service/script/Makefile
index 8818aa4..0abc30c 100644
--- a/test/poi-service/script/Makefile
+++ b/test/poi-service/script/Makefile
@@ -21,6 +21,7 @@
# List of changes:
#
# 4/6/2014, Philippe Colliot, complete src-clean option
+# 18/6/2014, Philippe Colliot, APT_GET option for Fedora
#
# @licence end@
@@ -35,7 +36,10 @@ CXX=g++
CXXFLAGS=-pipe -O2 -Wall
CHK_DIR_EXISTS=test -d
MKDIR=mkdir -p
-APT_GET=apt-get
+
+ifndef $(APT_GET)
+ APT_GET=apt-get
+endif
default: help
@@ -45,6 +49,7 @@ help::
@echo "clean: Clean up build dir"
@echo "src-clean: Clean up all checked out sources"
@echo "all2: Get $(DEPS) and build $(ALL)"
+ @echo "make APT_GET=yum for Fedora, by default APT_GET is set to apt-get"
#Clone the positioning repository for getting the API, generate the proxies and adaptors for the DBus APIs firstly
include get-positioning.mk