diff options
author | <philippe colliot> | 2016-04-08 18:14:34 +0200 |
---|---|---|
committer | <philippe colliot> | 2016-04-08 18:14:34 +0200 |
commit | 5240ff33da9c821d6b36afb30f0d3e3897b0ad76 (patch) | |
tree | 8e82b8e65f25d189b4813bd0fccb06bd69a9d700 | |
parent | 497fe70ab183c2a968c8e488fde2e3ba143b141e (diff) | |
download | poi-service-5240ff33da9c821d6b36afb30f0d3e3897b0ad76.tar.gz |
improvement of python scripts
-rwxr-xr-x | test/navigation/test-location-input.py | 146 | ||||
-rwxr-xr-x | test/navigation/test-map-viewer-control.py | 8 | ||||
-rwxr-xr-x | test/navigation/test-route-calculation.py | 183 |
3 files changed, 227 insertions, 110 deletions
diff --git a/test/navigation/test-location-input.py b/test/navigation/test-location-input.py index 741c5a1..2c48762 100755 --- a/test/navigation/test-location-input.py +++ b/test/navigation/test-location-input.py @@ -31,6 +31,7 @@ import dbus import gobject import dbus.mainloop.glib +import argparse # constants as defined in the Navigation API LATITUDE = 0x00a0 @@ -59,35 +60,30 @@ HOUSE_NUMBER_STRING = list() COUNTRY_STRING.append('Switzerland') CITY_STRING.append(u'Genève') STREET_STRING.append('Rue de Lausanne') -HOUSE_NUMBER_STRING.append('32') +HOUSE_NUMBER_STRING.append('') # Address #1 COUNTRY_STRING.append('Switzerland') CITY_STRING.append('Bern') STREET_STRING.append('Haslerstrasse') -HOUSE_NUMBER_STRING.append('25') +HOUSE_NUMBER_STRING.append('') # Address #2 COUNTRY_STRING.append('Switzerland') CITY_STRING.append(u'Zürich') STREET_STRING.append('Rainstrasse') -HOUSE_NUMBER_STRING.append('75') -# Address #3 -COUNTRY_STRING.append('Italy') -CITY_STRING.append('Aosta') -STREET_STRING.append('Via Liconi') -HOUSE_NUMBER_STRING.append('44') +HOUSE_NUMBER_STRING.append('') # Default size of the list WINDOW_SIZE = 20 -# Configuration -current_address_index = 0 - # Search mode (0 = Spell, 1 = Full string search) country_search_mode = 1 city_search_mode = 0 -street_search_mode = 0 +street_search_mode = 1 #set to full because of a bug to be fixed in the plug-in house_number_search_mode = 1 +parser = argparse.ArgumentParser(description='Location input test.') +parser.add_argument("-v", "--verbose", help='print the whole log messages') +args = parser.parse_args() print '\n--------------------------\n' + \ 'LocationInput Test' + \ @@ -99,7 +95,10 @@ if __name__ == '__main__': # connect to session bus bus = dbus.SessionBus() - +def vprint(text): + if args.verbose: + print(text) + # Turn selection criteria values to their corresponding string description def selection_criterion_to_string(selection_criterion): return_value = '' @@ -175,8 +174,8 @@ def selection_criteria_array_to_string(selection_criterion_array): def print_current_context(): - print '\tACTIVE CONTEXT: selection criterion = ' + selection_criterion_to_string(current_selection_criterion) + \ - ', search string = \'' + entered_search_string + '\'' + vprint('\tACTIVE CONTEXT: selection criterion = ' + selection_criterion_to_string(current_selection_criterion) + \ + ', search string = \'' + entered_search_string + '\'') def change_selection_criterion(selection_criterion): @@ -191,23 +190,23 @@ def change_selection_criterion(selection_criterion): def spell_search(handle, entered_string, search_string, valid_characters, first=0): global entered_search_string - print '-> SpellSearch - entered \'' + entered_string + '\' target \'' + search_string + '\'' + vprint('-> SpellSearch - entered \'' + entered_string + '\' target \'' + search_string + '\'') if unicode(search_string) != unicode(entered_string): found = unicode(search_string).lower().find(unicode(entered_string).lower()) if found == 0: - spell_character = '' is_valid = -1 if first == 0: spell_character = search_string[len(entered_string)] is_valid = valid_characters.find(spell_character) else: + spell_character='' is_valid = 0 if is_valid != -1: entered_search_string = entered_string + spell_character - print '\nACTION: Spell search, selection criterion = ' + \ + vprint('\nACTION: Spell search, selection criterion = ' + \ selection_criterion_to_string(current_selection_criterion) + ', trying \'' + spell_character + \ - '\'' + '\'') location_input_interface.Spell(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.String(spell_character), dbus.UInt16(20)) else: @@ -227,8 +226,8 @@ def full_string_search(handle, search_string): entered_search_string = search_string found_exact_match = 1 # Force exact match for full string search - print '\nACTION: Full string search, selection criterion = ' + \ - selection_criterion_to_string(current_selection_criterion) + ', trying \'' + search_string + '\'' + vprint('\nACTION: Full string search, selection criterion = ' + \ + selection_criterion_to_string(current_selection_criterion) + ', trying \'' + search_string + '\'') location_input_interface.Search(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.String(search_string), dbus.UInt16(20)) @@ -238,20 +237,20 @@ def evaluate_address(address, guidable): print '\nAddress complete!\nEvaluating...' if COUNTRY_STRING[current_address_index] == '': test_passed = 1 - elif address[COUNTRY] == COUNTRY_STRING[current_address_index]: - print 'Country\t\t\t-> ok (' + address[COUNTRY] + ')' + elif address[COUNTRY][1] == COUNTRY_STRING[current_address_index]: + print 'Country\t\t\t-> ok (' + address[COUNTRY][1] + ')' if CITY_STRING[current_address_index] == '': test_passed = 1 - elif address[CITY] == CITY_STRING[current_address_index]: - print 'City\t\t\t-> ok (' + address[CITY] + ')' + elif address[CITY][1] == CITY_STRING[current_address_index]: + print 'City\t\t\t-> ok (' + address[CITY][1] + ')' if STREET_STRING[current_address_index] == '': test_passed = 1 - elif address[STREET] == STREET_STRING[current_address_index]: - print 'Street\t\t\t-> ok (' + address[STREET] + ')' + elif address[STREET][1] == STREET_STRING[current_address_index]: + print 'Street\t\t\t-> ok (' + address[STREET][1] + ')' if HOUSE_NUMBER_STRING[current_address_index] == '': test_passed = 1 - elif address[HOUSE_NUMBER] == HOUSE_NUMBER_STRING[current_address_index]: - print 'House number\t-> ok (' + address[HOUSE_NUMBER] + ')' + elif address[HOUSE_NUMBER][1] == HOUSE_NUMBER_STRING[current_address_index]: + print 'House number\t-> ok (' + address[HOUSE_NUMBER][1] + ')' test_passed = 1 if guidable == 1: @@ -259,10 +258,16 @@ def evaluate_address(address, guidable): print 'TEST PASSED' else: print 'TEST FAILED (wrong address)' + loop.quit() else: print 'TEST FAILED (non-guidable address)' - - loop.quit() + loop.quit() + address_index = current_address_index + 1 + if address_index < len(COUNTRY_STRING): + startSearch(address_index) + else: + print 'END OF THE TEST' + loop.quit() # Signal receiver @@ -270,7 +275,7 @@ def evaluate_address(address, guidable): # Handler for ContentUpdated callback def search_status_handler(handle,status): - print '\n::Search status ' + str(int(status)) + vprint('\n::Search status ' + str(int(status))) if status == FINISHED: location_input_interface.RequestListUpdate(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(0), @@ -281,11 +286,11 @@ def content_updated_handler(handle, guidable, available_selection_criteria, addr global target_search_string global entered_search_string - print '\n::ContentUpdated for LocationInputHandle ' + str(int(handle)) + vprint('\n::ContentUpdated for LocationInputHandle ' + str(int(handle))) print_current_context() - print '\tGuidable = ' + str(guidable) - print '\tAvailable selection criteria = ' + selection_criteria_array_to_string(available_selection_criteria) - print '\tADDRESS: '+dictionary_to_string(address) + vprint('\tGuidable = ' + str(guidable)) + vprint('\tAvailable selection criteria = ' + selection_criteria_array_to_string(available_selection_criteria)) + vprint('\tADDRESS: '+dictionary_to_string(address)) search_mode = -1 @@ -305,10 +310,11 @@ def content_updated_handler(handle, guidable, available_selection_criteria, addr target_search_string = '' entered_search_string = '' + if target_search_string == '': evaluate_address(address, guidable) elif search_mode == 0: - spell_search(handle, '', target_search_string, '', 1) + spell_search(handle, entered_search_string, target_search_string, '', 1) elif search_mode == 1: full_string_search(handle, target_search_string) else: @@ -322,15 +328,15 @@ def spell_result_handler(handle, unique_string, valid_characters, full_match): global found_exact_match global available_characters - print '\n::SpellResult for LocationInputHandle '+str(int(handle)) + vprint('\n::SpellResult for LocationInputHandle '+str(int(handle))) if unique_string != entered_search_string: - print '\tAUTOCOMPLETE: \'' + entered_search_string + '\' -> \'' + unique_string + '\'' + vprint('\tAUTOCOMPLETE: \'' + entered_search_string + '\' -> \'' + unique_string + '\'') entered_search_string = unique_string available_characters = valid_characters print_current_context() - print '\tUnique string = \''+unique_string+'\'' - print '\tValid Characters = \''+valid_characters+'\'' - print '\tFull Match = '+str(full_match) + vprint('\tUnique string = \''+unique_string+'\'') + vprint('\tValid Characters = \''+valid_characters+'\'') + vprint('\tFull Match = '+str(full_match)) if len(valid_characters) == 1: if unicode(valid_characters[0]) == u'\x08': @@ -349,33 +355,33 @@ def search_result_list_handler(handle, total_size, window_offset, window_size, r global spell_next_character global found_exact_match - print '\n::SearchResultList for LocationInputHandle ' + str(int(handle)) + vprint('\n::SearchResultList for LocationInputHandle ' + str(int(handle))) print_current_context() - print '\tTotal size = ' + str(int(total_size)) + ', Window offset = ' + str(int(window_offset)) + \ - ', Window size = ' + str(int(window_size)) - print '\t' + dictionary_array_to_string(result_list_window, '\n\t', window_offset) + vprint('\tTotal size = ' + str(int(total_size)) + ', Window offset = ' + str(int(window_offset)) + \ + ', Window size = ' + str(int(window_size))) + vprint('\t' + dictionary_array_to_string(result_list_window, '\n\t', window_offset)) if found_exact_match == 1: found_exact_match = 0 i = 0 for address in result_list_window: if unicode(address[current_selection_criterion][1]) == target_search_string: - print '\nACTION: Found exact match, selecting \''+unicode(address[current_selection_criterion][1]) + \ - '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')' + vprint('\nACTION: Found exact match, selecting \''+unicode(address[current_selection_criterion][1]) + \ + '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')') location_input_interface.SelectEntry(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(i)) break i += 1 if i == window_size: - print '\nACTION: Found exact match, searching in next page (Session '+str(int(session_handle)) +\ - ' LocationInputHandle ' + str(int(handle))+')' + vprint('\nACTION: Found exact match, searching in next page (Session '+str(int(session_handle)) +\ + ' LocationInputHandle ' + str(int(handle))+')') location_input_interface.RequestListUpdate(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(window_offset + window_size), dbus.UInt16(window_size)) elif total_size == 1: selection_name = result_list_window[0][current_selection_criterion] if selection_name == target_search_string: - print '\nACTION: Single entry list, selecting \'' + result_list_window[0][current_selection_criterion] + \ - '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')' + vprint('\nACTION: Single entry list, selecting \'' + result_list_window[0][current_selection_criterion] + \ + '\' (Session '+str(int(session_handle)) + ' LocationInputHandle ' + str(int(handle))+')') location_input_interface.SelectEntry(dbus.UInt32(session_handle), dbus.UInt32(handle), dbus.UInt16(0)) else: print '\nTEST FAILED (Unexpected single result list)' @@ -409,7 +415,29 @@ def timeout(): print '\nTEST FAILED\n' loop.quit() - +def startSearch(address_index): + global entered_search_string + global spell_next_character + global found_exact_match + global available_characters + global target_search_string + global country_search_mode + global current_address_index + current_address_index = address_index + entered_search_string = '' + spell_next_character = 0 + found_exact_match = 0 + available_characters = '' + target_search_string = COUNTRY_STRING[current_address_index] + + change_selection_criterion(COUNTRY) + + if country_search_mode == 0: + spell_search(location_input_handle, entered_search_string, target_search_string, available_characters, 1) + elif country_search_mode == 1: + full_string_search(location_input_handle, target_search_string) + + session = bus.get_object('org.genivi.navigationcore.Session', '/org/genivi/navigationcore') session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigationcore.Session') @@ -427,19 +455,15 @@ print 'LocationInput handle = ' + str(location_input_handle) attributes = location_input_interface.GetSupportedAddressAttributes() print 'Initially supported address attributes = ' + selection_criteria_array_to_string(attributes) -# Start by entering country +# Configuration +current_address_index = 0 entered_search_string = '' spell_next_character = 0 found_exact_match = 0 available_characters = '' -target_search_string = COUNTRY_STRING[current_address_index] - -change_selection_criterion(COUNTRY) +target_search_string = '' -if country_search_mode == 0: - spell_search(location_input_handle, '', target_search_string, '', 1) -elif country_search_mode == 1: - full_string_search(location_input_handle, target_search_string) +startSearch(0) # Main loop gobject.timeout_add(10000, timeout) diff --git a/test/navigation/test-map-viewer-control.py b/test/navigation/test-map-viewer-control.py index 78e956b..077e673 100755 --- a/test/navigation/test-map-viewer-control.py +++ b/test/navigation/test-map-viewer-control.py @@ -31,6 +31,8 @@ import dbus import gobject import time +#import pdb; pdb.set_trace() + #constants as defined in the Navigation API LATITUDE = 0x00a0 LONGITUDE = 0x00a1 @@ -56,6 +58,12 @@ session_interface = dbus.Interface(session, dbus_interface='org.genivi.mapviewer sessionhandle = session_interface.CreateSession(dbus.String("test mapviewer")) print 'Session handle: ' + str(sessionhandle) +sessionstatus = session_interface.GetSessionStatus(dbus.UInt32(sessionhandle)); +print 'Session status: ' + str(sessionstatus) + +sessionlist = session_interface.GetAllSessions(); +print 'Active sessions = ' + str(len(sessionlist)) + MapViewerControl_obj = bus.get_object('org.genivi.mapviewer.MapViewerControl','/org/genivi/mapviewer') MapViewerControl_interface = dbus.Interface(MapViewerControl_obj, dbus_interface='org.genivi.mapviewer.MapViewerControl') diff --git a/test/navigation/test-route-calculation.py b/test/navigation/test-route-calculation.py index e8d4e54..3caf704 100755 --- a/test/navigation/test-route-calculation.py +++ b/test/navigation/test-route-calculation.py @@ -31,21 +31,71 @@ import dbus import gobject import dbus.mainloop.glib -from collections import namedtuple +from collections import namedtuple,defaultdict +from _dbus_bindings import Int32 +from PIL.GimpGradientFile import SEGMENTS +#import pdb; pdb.set_trace() #typedef routeOverviewValue = namedtuple('routeOverviewValue', ['y','v']) #constants as defined in the Navigation API -LATITUDE = 0x00a0 -LONGITUDE = 0x00a1 -TOTAL_DISTANCE = 0x018f -TIME_OUT = 10000 +GENIVI_LATITUDE = 0x00a0 +GENIVI_LONGITUDE = 0x00a1 +GENIVI_TOTAL_TIME = 0x018e +GENIVI_TOTAL_DISTANCE = 0x018f +GENIVI_ROAD_NAME = 0x0147 +#constants used into the script +TIME_OUT = 10000 -print '\n--------------------------' +#waypoints used by the script +ZUERICH = 0 +BERN = 1 +GENEVE = 2 +NEUCHATEL = 3 + +LOCATION_LAT_INDEX = 0 +LOCATION_LON_INDEX = 1 +LOCATION_NAME_INDEX = 2 +locations = [] +locations.append([]) +locations[ZUERICH].append(47.3673) +locations[ZUERICH].append(8.5500) +locations[ZUERICH].append('Zuerich') +locations.append([]) +locations[BERN].append(46.9479) +locations[BERN].append(7.4446) +locations[BERN].append('Bern') +locations.append([]) +locations[GENEVE].append(46.2065442) +locations[GENEVE].append(6.1411703) +locations[GENEVE].append('Geneve') +locations.append([]) +locations[NEUCHATEL].append(46.9905681) +locations[NEUCHATEL].append(6.928624) +locations[NEUCHATEL].append('Neuchatel') + + +ROUTE_START_INDEX = 0 +ROUTE_DEST_INDEX = 1 +ROUTE_NAME_INDEX = 2 +ROUTE_HANDLE = 3 +routes = [] +routes.append([]) +routes[0].append(ZUERICH) +routes[0].append(BERN) +routes[0].append('Route number 1') +routes[0].append(0) #by default +routes.append([]) +routes[1].append(GENEVE) +routes[1].append(NEUCHATEL) +routes[1].append('Route number 2') +routes[1].append(0) #by default + +print '--------------------------' print 'Route Calculation Test' -print '--------------------------\n' +print '--------------------------' if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) @@ -53,69 +103,104 @@ if __name__ == '__main__': #connect to session bus bus = dbus.SessionBus() -#signal receiver +#add signal receivers 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.Int32(TOTAL_DISTANCE)])) + overview = g_routing_interface.GetRouteOverview(dbus.UInt32(g_route_handle),dbus.Array([dbus.Int32(GENIVI_TOTAL_DISTANCE),dbus.Int32(GENIVI_TOTAL_TIME)])) #retrieve distance - totalDistance = dbus.Struct(overview[dbus.Int32(TOTAL_DISTANCE)]) - print 'Total Distance: ' + str(totalDistance[1]) + ' m' - #check distance - if totalDistance[1] < 100000 or totalDistance[1] > 150000: - print '\nTest FAILED\n' + totalDistance = dbus.Struct(overview[dbus.Int32(GENIVI_TOTAL_DISTANCE)]) + print 'Total Distance: ' + str(totalDistance[1]/1000) + ' km' + totalTime = dbus.Struct(overview[dbus.Int32(GENIVI_TOTAL_TIME)]) + m, s = divmod(totalTime[1], 60) + h, m = divmod(m, 60) + print "Total Time: %d:%02d:%02d" % (h, m, s) + #get route segments GetRouteSegments(const uint32_t& routeHandle, const int16_t& detailLevel, const std::vector< DBusCommonAPIEnumeration >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< DBusCommonAPIEnumeration, DBusCommonAPIVariant > >& routeSegments) + totalNumberOfSegments = dbus.Int32() + CapiVariant = namedtuple('CapiVariant', ('y','v')) + routeSegments = [{(Int32,CapiVariant)}] + #g_routing_interface.GetRouteSegments(dbus.UInt32(g_route_handle),dbus.Int16(0),dbus.Array([dbus.Int32(GENIVI_TOTAL_DISTANCE),dbus.Int32(GENIVI_TOTAL_TIME),dbus.Int32(GENIVI_ROAD_NAME)]),dbus.UInt32(500),dbus.UInt32(0),totalNumberOfSegments,routeSegments) + route = g_current_route + 1 + if route < len(routes): + launch_route_calculation(route) else: - print '\nTest PASSED\n' - loop.quit() + for i in range(len(routes)): + g_routing_interface.DeleteRoute(dbus.UInt32(g_session_handle),dbus.UInt32(routes[i][ROUTE_HANDLE])) + g_session_interface.DeleteSession(dbus.UInt32(g_session_handle)) + +def catchall_session_signals_handler(sessionHandle): + print('Session handle deleted: '+str(sessionHandle)) + if sessionHandle == g_session_handle: + print 'Test PASSED' + else: + print 'Test FAILED' + loop.quit() + +def catchall_route_deleted_signals_handler(routeHandle): + print('Route handle deleted: '+str(routeHandle)) -#add signal receiver bus.add_signal_receiver(catchall_route_calculation_signals_handler, \ dbus_interface = "org.genivi.navigationcore.Routing", \ signal_name = "RouteCalculationProgressUpdate") +bus.add_signal_receiver(catchall_route_deleted_signals_handler, \ + dbus_interface = "org.genivi.navigationcore.Routing", \ + signal_name = "RouteDeleted") + +bus.add_signal_receiver(catchall_session_signals_handler, \ + dbus_interface = "org.genivi.navigationcore.Session", \ + signal_name = "SessionDeleted") + #timeout def timeout(): print 'Timeout Expired' - print '\nTest FAILED\n' + print '\nTest FAILED' loop.quit() +def launch_route_calculation(route): + global g_current_route + global g_route_handle + global g_routing_interface + global g_session_handle + g_current_route = route + print 'Route name: '+routes[g_current_route][ROUTE_NAME_INDEX] + #get route handle + g_route_handle = g_routing_interface.CreateRoute(dbus.UInt32(g_session_handle)) + routes[g_current_route][ROUTE_HANDLE] = g_route_handle + print 'Route handle: ' + str(g_route_handle) + start = routes[g_current_route][ROUTE_START_INDEX] + dest = routes[g_current_route][ROUTE_DEST_INDEX] + print 'Calculating route from \ +'+locations[start][LOCATION_NAME_INDEX]+'(' + str(locations[start][LOCATION_LAT_INDEX]) + ',' + str(locations[start][LOCATION_LON_INDEX]) + ') to \ +'+locations[dest][LOCATION_NAME_INDEX]+'(' + str(locations[dest][LOCATION_LAT_INDEX]) + ',' + str(locations[dest][LOCATION_LON_INDEX]) + ')' + #set waypoints + g_routing_interface.SetWaypoints(dbus.UInt32(g_session_handle), \ + dbus.UInt32(g_route_handle), \ + dbus.Boolean(0), \ + dbus.Array([ \ + dbus.Dictionary({dbus.UInt16(GENIVI_LATITUDE):dbus.Struct([0,dbus.Double(locations[start][LOCATION_LAT_INDEX])]),dbus.UInt16(GENIVI_LONGITUDE):dbus.Struct([0,dbus.Double(locations[start][LOCATION_LON_INDEX])])}), \ + dbus.Dictionary({dbus.UInt16(GENIVI_LATITUDE):dbus.Struct([0,dbus.Double(locations[dest][LOCATION_LAT_INDEX])]),dbus.UInt16(GENIVI_LONGITUDE):dbus.Struct([0,dbus.Double(locations[dest][LOCATION_LON_INDEX])])}) \ + ]) \ + ) + + #calculate route + g_routing_interface.CalculateRoute(dbus.UInt32(g_session_handle),dbus.UInt32(g_route_handle)) + + session = bus.get_object('org.genivi.navigationcore.Session','/org/genivi/navigationcore') -session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigationcore.Session') +g_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) +g_session_handle = g_session_interface.CreateSession(dbus.String("test route calculation")) +print 'Session handle: ' + str(g_session_handle) 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.Struct([0,dbus.Double(lat1)]),dbus.UInt16(LONGITUDE):dbus.Struct([0,dbus.Double(lon1)])}), \ - dbus.Dictionary({dbus.UInt16(LATITUDE):dbus.Struct([0,dbus.Double(lat2)]),dbus.UInt16(LONGITUDE):dbus.Struct([0,dbus.Double(lon2)])}) \ - ]) \ - ) - -#calculate route -routing_interface.CalculateRoute(dbus.UInt32(sessionhandle),dbus.UInt32(routehandle)) +g_routing_interface = dbus.Interface(routing_obj, dbus_interface='org.genivi.navigationcore.Routing') + +g_current_route = 0 +launch_route_calculation(0) + #main loop gobject.timeout_add(TIME_OUT, timeout) |