From c72289b6a9b82723f38d991629de8677a260f9fd Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Mon, 12 Jun 2017 17:36:33 +0200 Subject: test poi OK --- .../poi-cam/genivi_poiservice_cam_navit.cxx | 137 +++++++++++++++------ src/poi-service/poi-server/main.cpp | 3 +- test/navigation/README.md | 8 +- test/navigation/script/test-address-input.py | 13 +- test/navigation/script/test-all | 10 +- test/navigation/script/test-guidance.py | 16 ++- test/navigation/script/test-location-input.py | 15 ++- test/navigation/script/test-map-viewer-control.py | 13 +- test/navigation/script/test-poi.py | 60 +++++---- test/navigation/script/test-route-calculation.py | 13 +- 10 files changed, 196 insertions(+), 92 deletions(-) diff --git a/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx b/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx index 59d916e..f5ab752 100644 --- a/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx +++ b/src/navigation/poi-cam/genivi_poiservice_cam_navit.cxx @@ -103,10 +103,18 @@ class ContentAccessModule item_type formerId; int32_t givenId; }; + struct poiCategoryIdRadius{ + item_type formerId; + uint32_t givenId; + uint32_t radius; + }; std::vector m_poiEquivalenceList; + item_type m_bottom_poi_type; std::vector< uint32_t > m_poiCategoriesId; + std::vector m_poiCategoriesIdRadius; std::vector< ::DBus::Struct< uint32_t, std::string, uint32_t, ::DBus::Struct< double, double, double >, uint16_t, std::vector< ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > > > > m_resultList; + std::string m_inputString; int m_max_radius; bool (*m_sort_func)(::DBus::Struct< uint32_t, std::string, uint32_t, ::DBus::Struct< double, double, double >, uint16_t, std::vector< ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > > > a, ::DBus::Struct< uint32_t, std::string, uint32_t, ::DBus::Struct< double, double, double >, uint16_t, std::vector< ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > > > b); struct coord m_center; @@ -140,6 +148,8 @@ class ContentAccessModule size_t i; poiEquivalence poi_equivalence; + //The m_poiEquivalenceList is populated 'by hand' and the formerId have to be ordered from min to max ! + m_bottom_poi_type=type_poi_land_feature; //the minimum used for init poi_equivalence.name="fuel"; poi_equivalence.formerId=type_poi_fuel; m_poiEquivalenceList.push_back(poi_equivalence); @@ -189,45 +199,52 @@ class ContentAccessModule m_map_rect=NULL; } - void - add_poi(struct item *item) + bool + add_poi(struct item *item, uint32_t category, std::string inputString) { struct attr label; struct coord c; dbg(lvl_debug,"adding poi\n"); ::DBus::Struct< uint32_t, std::string, uint32_t, ::DBus::Struct< double, double, double >, uint16_t, std::vector< ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > > > result; ::DBus::Struct< uint32_t, int32_t, DBusCommonAPIVariant > attribute; + bool stringMatched=false; - result._1=m_resultList.size(); /* source_id */ - if (item_attr_get(item, attr_label, &label)) + if (item_attr_get(item, attr_label, &label)){ result._2=std::string(label.u.str); /* name */ - else - result._2=std::string(""); /* name */ - result._3=m_poiCategoriesId[0]; /* category */ - if (item_coord_get(item, &c, 1)) { - struct coord_geo g; - transform_to_geo(projection_mg, &c, &g); - result._4._1=g.lat; /* lat */ - result._4._2=g.lng; /* lon */ - double distance=transform_distance(projection_mg, &m_center, &c)/m_scale; -#if 0 - if (distance > m_max_radius) - return; -#endif - result._5=distance; /* distance */ - } else { - result._4._1=0; /* lat */ - result._4._2=0; /* lon */ - result._5=0; /* distance */ + std::size_t found = result._2.find(inputString); + if (found!=std::string::npos) + stringMatched=true; + } + + if(stringMatched){ + result._1=m_resultList.size(); /* source_id */ + result._3=category; /* category */ + if (item_coord_get(item, &c, 1)) { + struct coord_geo g; + transform_to_geo(projection_mg, &c, &g); + result._4._1=g.lat; /* lat */ + result._4._2=g.lng; /* lon */ + double distance=transform_distance(projection_mg, &m_center, &c)/m_scale; + #if 0 + if (distance > m_max_radius) + return; + #endif + result._5=distance; /* distance */ + } else { + result._4._1=0; /* lat */ + result._4._2=0; /* lon */ + result._5=0; /* distance */ + } + result._4._3=0; /* altitude */ + /* result._6 attributes */ + attribute._1 = 0; + attribute._2 = 0; + attribute._3._1 = 0; + attribute._3._2 = variant_string(std::string("")); /* value */ + result._6.push_back(attribute); + m_resultList.push_back(result); } - result._4._3=0; /* altitude */ - /* result._6 attributes */ - attribute._1 = 0; - attribute._2 = 0; - attribute._3._1 = 0; - attribute._3._2 = variant_string(std::string("")); /* value */ - result._6.push_back(attribute); - m_resultList.push_back(result); + return stringMatched; } ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > @@ -324,8 +341,14 @@ class ContentAccessModule dbg(lvl_debug,"enter handle=%d size=%d location=%f,%f,%d string='%s' sortOption=%d\n",poiSearchHandle, maxSize, location._1,location._2,location._3, inputString.c_str(), sortOption); m_resultList.resize(0); m_max_radius=0; + m_inputString=inputString; + poiCategoryIdRadius categoryIdRadius; + m_poiCategoriesIdRadius.clear(); for (int i = 0 ; i < poiCategories.size(); i++) { dbg(lvl_debug,"category %d %d\n",poiCategories[i]._1,poiCategories[i]._2); + categoryIdRadius.givenId=poiCategories[i]._1; + categoryIdRadius.radius=poiCategories[i]._2; + m_poiCategoriesIdRadius.push_back(categoryIdRadius); if (m_max_radius < poiCategories[i]._2) m_max_radius=poiCategories[i]._2; } @@ -355,14 +378,37 @@ class ContentAccessModule m_selection.u.c_rect.lu.x-=d; m_selection.u.c_rect.lu.y+=d; m_selection.order=18; - //for the time being only search for the first id (because I don't know how to manage it for several ones) + + //set the range of categories to search + m_selection.range.min=m_bottom_poi_type; + m_selection.range.max=m_bottom_poi_type; + bool isFound; + size_t index; for(size_t i=0;im_selection.range.max){ + m_selection.range.max=m_poiEquivalenceList[i].formerId; + } + } + } + isFound=true; + } + index++; + }while((isFound==false)&&(indextype == m_selection.range.min) - add_poi(item); + isFound=false; + index=0; + do{ + if (item->type == (m_poiCategoriesIdRadius.at(index)).formerId) + { + isFound=add_poi(item,(m_poiCategoriesIdRadius.at(index)).givenId,m_inputString); + } + index++; + }while((isFound==false)&&(indexPoiDetailsRequested(poiList); + if(resultListSize>0) + m_poiDetailsTable = mp_contentAccessModule->PoiDetailsRequested(poiList); } return(resultListSize); diff --git a/test/navigation/README.md b/test/navigation/README.md index d32bfe4..1cc1225 100644 --- a/test/navigation/README.md +++ b/test/navigation/README.md @@ -3,6 +3,7 @@ These folders contain several files that allow to test the navigation. The folder ./script contains the ones for the GlibDBus version: +test-poi.py test-location-input.py test-address-input.py test-map-viewer-control.py @@ -17,7 +18,7 @@ The folder ./resource contains the resource files (e.g. the address) used as inp The folder ./log contains the generated sequence charts (see below) -There's a mechanism to trig with DLT, so it's necessary to build some stuff before. +There's a optional mechanism to trig with DLT, please build the stuff in dlt-triggers before: ##How to build the trigger Under ./dlt-triggers @@ -31,13 +32,14 @@ make install ##Tested targets Desktop: Tested under Ubuntu 16.04 LTS 64 bits ##How-to test -First, open a new terminal and launch the navigation by entering: +First, open a new terminal and launch the navigation and the poi server by entering: ``` -./run -r +./run -r -p ``` Unitary tests: (under ./script folder) ``` +./test-poi.py -l ../resource/location.xml ./test-location-input.py -l locations.xml ./test-route-calculation.py -r routes.xml ./test-address-input.py -l location.xml diff --git a/test/navigation/script/test-address-input.py b/test/navigation/script/test-address-input.py index 4ba732f..ff273f0 100755 --- a/test/navigation/script/test-address-input.py +++ b/test/navigation/script/test-address-input.py @@ -37,7 +37,12 @@ import argparse import sys import errno import genivi -from dltTrigger import * +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False #import pdb;pdb.set_trace() #name of the test @@ -337,7 +342,8 @@ def exit(): print('Delete location input: '+str(int(error))) error=session_interface.DeleteSession(dbus.UInt32(session_handle)) print('Delete session: '+str(int(error))) - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() @@ -356,7 +362,8 @@ def startSearch(address_index): change_selection_criterion(genivi.COUNTRY) full_string_search(location_input_handle, target_search_string) -startTrigger(test_name) +if dltTrigger==True: + startTrigger(test_name) session = bus.get_object('org.genivi.navigation.navigationcore.Session', '/org/genivi/navigationcore') session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigation.navigationcore.Session') diff --git a/test/navigation/script/test-all b/test/navigation/script/test-all index f2c8dfa..0f54f73 100755 --- a/test/navigation/script/test-all +++ b/test/navigation/script/test-all @@ -1,11 +1,13 @@ #!/bin/bash +./test-poi.py -l ../resource/location.xml +sleep 1 ./test-location-input.py -l ../resource/locations.xml -sleep 2 +sleep 1 ./test-route-calculation.py -r ../resource/routes.xml -sleep 2 +sleep 1 ./test-address-input.py -l ../resource/location.xml -sleep 2 +sleep 1 ./test-guidance.py -r ../resource/route.xml -sleep 2 +sleep 1 ./test-map-viewer-control.py -l ../resource/location.xml diff --git a/test/navigation/script/test-guidance.py b/test/navigation/script/test-guidance.py index 74be6ac..8f91a77 100755 --- a/test/navigation/script/test-guidance.py +++ b/test/navigation/script/test-guidance.py @@ -36,9 +36,13 @@ import sys import errno import time import genivi -from dltTrigger import * -#import pdb -#pdb.set_trace() +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False +#import pdb;pdb.set_trace() #name of the test test_name = "guidance" @@ -135,7 +139,8 @@ def timeout(): exit() def exit(): - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() def display_route(route): @@ -302,7 +307,8 @@ bus.add_signal_receiver(mapmatchedposition_simulationStatusChanged_handler, \ dbus_interface = "org.genivi.navigation.navigationcore.MapMatchedPosition", \ signal_name = "SimulationStatusChanged") -startTrigger(test_name) +if dltTrigger==True: + startTrigger(test_name) navigationcore_session_obj = bus.get_object('org.genivi.navigation.navigationcore.Session','/org/genivi/navigationcore') g_navigationcore_session_interface = dbus.Interface(navigationcore_session_obj, dbus_interface='org.genivi.navigation.navigationcore.Session') diff --git a/test/navigation/script/test-location-input.py b/test/navigation/script/test-location-input.py index c16388e..d7c5adc 100755 --- a/test/navigation/script/test-location-input.py +++ b/test/navigation/script/test-location-input.py @@ -37,7 +37,12 @@ import argparse import sys import errno import genivi -from dltTrigger import * +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False #import pdb;pdb.set_trace() #name of the test @@ -421,7 +426,8 @@ def exit(): print('Delete location input: '+str(int(error))) error=session_interface.DeleteSession(dbus.UInt32(session_handle)) print('Delete session: '+str(int(error))) - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() def startSearch(address_index): @@ -445,8 +451,9 @@ def startSearch(address_index): elif country_search_mode == 1: full_string_search(location_input_handle, target_search_string) -startTrigger(test_name) - +if dltTrigger==True: + startTrigger(test_name) + session = bus.get_object('org.genivi.navigation.navigationcore.Session', '/org/genivi/navigationcore') session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigation.navigationcore.Session') diff --git a/test/navigation/script/test-map-viewer-control.py b/test/navigation/script/test-map-viewer-control.py index 51ec581..03bb5ff 100755 --- a/test/navigation/script/test-map-viewer-control.py +++ b/test/navigation/script/test-map-viewer-control.py @@ -32,12 +32,17 @@ import dbus import gobject import dbus.mainloop.glib import time -from dltTrigger import * import xml.dom.minidom import argparse import sys import errno import genivi +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False #import pdb; pdb.set_trace() #name of the test @@ -185,7 +190,8 @@ def exit(): dbus.UInt32(sessionhandle), \ dbus.UInt32(mapviewerhandle)) session_interface.DeleteSession(sessionhandle) - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() def next_step(): @@ -256,7 +262,8 @@ bus.add_signal_receiver(mapviewer_mapViewPerspectiveChanged_handler, \ dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl", \ signal_name = "MapViewPerspectiveChanged") -startTrigger(test_name) +if dltTrigger==True: + startTrigger(test_name) session = bus.get_object('org.genivi.navigation.mapviewer.Session','/org/genivi/mapviewer') session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigation.mapviewer.Session') diff --git a/test/navigation/script/test-poi.py b/test/navigation/script/test-poi.py index 56628d3..6610a48 100755 --- a/test/navigation/script/test-poi.py +++ b/test/navigation/script/test-poi.py @@ -28,12 +28,17 @@ import dbus import gobject import dbus.mainloop.glib -from dltTrigger import * import xml.dom.minidom import argparse import sys import errno import genivi +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False #import pdb; pdb.set_trace() #name of the test @@ -49,8 +54,8 @@ ID_RESTAURANT = 260 ATTRIBUTE_SOURCE = 0 ATTRIBUTE_PHONE = 2 RADIUS_HOTEL = 100 #in tenth of meter ! -RADIUS_FUEL = 500 -STRING_TO_SEARCH = "Alpes" +RADIUS_RESTAURANT = 500 +STRING_TO_SEARCH = "hof" MAX_WINDOW_SIZE = 100 OFFSET = 0 @@ -82,19 +87,22 @@ def catch_poi_poiStatus_signal_handler(poiSearchHandle,statusValue): def catch_poi_resultListChanged_signal_handler(poiSearchHandle,resultListSize): poiList=[] - if poiSearchHandle == g_searchHandle and resultListSize != 0: - ret=g_poiSearch_interface.RequestResultList(dbus.UInt32(poiSearchHandle),dbus.UInt16(OFFSET),dbus.UInt16(MAX_WINDOW_SIZE),[ATTRIBUTE_SOURCE,ATTRIBUTE_PHONE]) - if ret[0] == genivi.SEARCH_FINISHED and ret[1] >= 0: - print("Results: "+str(int(ret[1]))) - for result in ret[2]: - poiList.append(result[0]) - ret=g_poiSearch_interface.GetPoiDetails(poiList) - for resultDetail in ret: - if resultDetail[1][0] == ID_HOTEL: - print("Hotel: " +resultDetail[0][1]) - elif resultDetail[1][0] == ID_FUEL: - print("Fuel: " +resultDetail[0][1]) - g_poiSearch_interface.CancelPoiSearch(dbus.UInt32(poiSearchHandle)) + if poiSearchHandle == g_searchHandle: + if resultListSize != 0: + ret=g_poiSearch_interface.RequestResultList(dbus.UInt32(poiSearchHandle),dbus.UInt16(OFFSET),dbus.UInt16(MAX_WINDOW_SIZE),[ATTRIBUTE_SOURCE,ATTRIBUTE_PHONE]) + if ret[0] == genivi.SEARCH_FINISHED and ret[1] >= 0: + print("Results: "+str(int(ret[1]))) + for result in ret[2]: + poiList.append(result[0]) + ret=g_poiSearch_interface.GetPoiDetails(poiList) + for resultDetail in ret: + if resultDetail[1][0] == ID_HOTEL: + print("Hotel: " +resultDetail[0][1]) + elif resultDetail[1][0] == ID_RESTAURANT: + print("Restaurant: " +resultDetail[0][1]) + g_poiSearch_interface.CancelPoiSearch(dbus.UInt32(poiSearchHandle)) + else: + g_poiSearch_interface.CancelPoiSearch(dbus.UInt32(poiSearchHandle)) def timeout(): print ('Timeout Expired') @@ -102,7 +110,8 @@ def timeout(): exit() def exit(): - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() @@ -143,7 +152,7 @@ for location in location_set.getElementsByTagName("location"): if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) -print("Search for hotel and fuel with keyword: "+ STRING_TO_SEARCH) +print("Search for hotel and restaurant with keyword: "+ STRING_TO_SEARCH) #connect to session bus bus = dbus.SessionBus() @@ -160,7 +169,8 @@ bus.add_signal_receiver(catch_poi_resultListChanged_signal_handler, \ dbus_interface = "org.genivi.navigation.poiservice.POISearch", \ signal_name = "ResultListChanged") -startTrigger(test_name) +if dltTrigger==True: + startTrigger(test_name) poiConfiguration = bus.get_object('org.genivi.navigation.poiservice.POIConfiguration','/org/genivi/poiservice/POIConfiguration') g_poiConfiguration_interface = dbus.Interface(poiConfiguration, dbus_interface='org.genivi.navigation.poiservice.POIConfiguration') @@ -176,13 +186,13 @@ g_poiConfiguration_interface.SetLocale(dbus.String("fra"),dbus.String("FRA"),dbu categories=[] ret=g_poiSearch_interface.GetAvailableCategories() for categoryAndName in ret: - if categoryAndName[0] == ID_HOTEL or categoryAndName[0] == ID_FUEL: + if categoryAndName[0] == ID_HOTEL or categoryAndName[0] == ID_RESTAURANT: print("Category ID: " + str(int(categoryAndName[0]))) categories.append(categoryAndName[0]) print("Name: " + categoryAndName[1]) attributes_hotel=[] -attributes_fuel=[] +attributes_restaurant=[] attributesDetails=[] ret=g_poiSearch_interface.GetCategoriesDetails(categories) for results in ret: @@ -190,10 +200,10 @@ for results in ret: for attribute in results[1]: attributes_hotel.append(attribute[0]) attributesDetails.append(dbus.Struct([dbus.UInt32(attribute[0]),dbus.UInt32(ID_HOTEL),dbus.Int32(1280),dbus.Struct([dbus.Byte(2),dbus.String("")]),dbus.Int32(1314),dbus.Boolean(False)])) - elif results[0][0] == ID_FUEL: + elif results[0][0] == ID_RESTAURANT: for attribute in results[1]: - attributes_fuel.append(attribute[0]) - attributesDetails.append(dbus.Struct([dbus.UInt32(attribute[0]),dbus.UInt32(ID_FUEL),dbus.Int32(1280),dbus.Struct([dbus.Byte(2),dbus.String("")]),dbus.Int32(1314),dbus.Boolean(False)])) + attributes_restaurant.append(attribute[0]) + attributesDetails.append(dbus.Struct([dbus.UInt32(attribute[0]),dbus.UInt32(ID_RESTAURANT),dbus.Int32(1280),dbus.Struct([dbus.Byte(2),dbus.String("")]),dbus.Int32(1314),dbus.Boolean(False)])) ret=g_poiSearch_interface.GetRootCategory() @@ -208,7 +218,7 @@ alt = ALTITUDE[index] g_poiSearch_interface.SetCenter(g_searchHandle,dbus.Struct([dbus.Double(lat),dbus.Double(lon),dbus.Double(alt)])) -g_poiSearch_interface.SetCategories(g_searchHandle,[dbus.Struct([dbus.UInt32(ID_HOTEL),dbus.UInt32(RADIUS_HOTEL)]),dbus.Struct([dbus.UInt32(ID_FUEL),dbus.UInt32(RADIUS_FUEL)])]) +g_poiSearch_interface.SetCategories(g_searchHandle,[dbus.Struct([dbus.UInt32(ID_HOTEL),dbus.UInt32(RADIUS_HOTEL)]),dbus.Struct([dbus.UInt32(ID_RESTAURANT),dbus.UInt32(RADIUS_RESTAURANT)])]) g_poiSearch_interface.SetAttributes(g_searchHandle,attributesDetails) diff --git a/test/navigation/script/test-route-calculation.py b/test/navigation/script/test-route-calculation.py index 29dcfd5..0a34429 100755 --- a/test/navigation/script/test-route-calculation.py +++ b/test/navigation/script/test-route-calculation.py @@ -36,8 +36,13 @@ import argparse import sys import errno import genivi +try: + from dltTrigger import * + dltTrigger=True + print('DLT signal sent') +except dltTriggerNotBuilt: + dltTrigger=False #import pdb;pdb.set_trace() -from dltTrigger import * #name of the test test_name = "route calculation" @@ -146,7 +151,8 @@ def timeout(): exit() def exit(): - stopTrigger(test_name) + if dltTrigger==True: + stopTrigger(test_name) loop.quit() def launch_route_calculation(route): @@ -178,7 +184,8 @@ def launch_route_calculation(route): #calculate route g_routing_interface.CalculateRoute(dbus.UInt32(g_session_handle),dbus.UInt32(g_route_handle)) -startTrigger(test_name) +if dltTrigger==True: + startTrigger(test_name) session = bus.get_object('org.genivi.navigation.navigationcore.Session','/org/genivi/navigationcore') g_session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigation.navigationcore.Session') -- cgit v1.2.1