diff options
author | asanoaozora <fifitaneki@hotmail.com> | 2016-10-14 17:43:53 +0200 |
---|---|---|
committer | asanoaozora <fifitaneki@hotmail.com> | 2016-10-14 17:43:53 +0200 |
commit | 86145b863cc8add76bc98085eddd51309659f76f (patch) | |
tree | a1de6ead4b858d70220afa61192d79ca8f8da0aa | |
parent | 275b7621fd06d3a6e8157b97e4a898a04af78f9a (diff) | |
download | poi-service-86145b863cc8add76bc98085eddd51309659f76f.tar.gz |
fix lock in poi capi and mapviewer control
7 files changed, 160 insertions, 132 deletions
diff --git a/api/franca/navigation/navigationcore/Routing.fidl b/api/franca/navigation/navigationcore/Routing.fidl index ddca1ff..d2951bd 100644 --- a/api/franca/navigation/navigationcore/Routing.fidl +++ b/api/franca/navigation/navigationcore/Routing.fidl @@ -21,7 +21,7 @@ interface Routing { minor 0
}
- enumeration CalculationStatus extends BasicEnum { //Base 0x0130
+ enumeration CalculationStatus extends BasicEnum {
CALCULATION_OK = 304
NO_POSITION = 305
}
@@ -32,7 +32,7 @@ interface Routing { UNFULFILLED_PREFERENCE_MODE = 308
}
- enumeration CostModel extends BasicEnum { //Base 0x0160
+ enumeration CostModel extends BasicEnum {
FASTEST = 352
SHORTEST = 353
ECOLOGICAL = 354
@@ -43,7 +43,7 @@ interface Routing { CHEAPEST = 359
}
- enumeration RoutePreferenceSource extends BasicEnum { //Base 0x0170
+ enumeration RoutePreferenceSource extends BasicEnum {
FERRY = 368
TOLL_ROADS = 369
TUNNELS = 370
@@ -52,7 +52,7 @@ interface Routing { CRIME_AREAS = 373
}
- enumeration TransportationMeans extends BasicEnum { //Base 0x0180
+ enumeration TransportationMeans extends BasicEnum {
BY_CAR = 384
ON_FOOT = 385
LONG_RANGE_TRAINS = 386
@@ -62,13 +62,13 @@ interface Routing { }
enumeration Schedule extends BasicEnum {
- ARRIVAL_TIME = 394
- ARRIVAL_DATE = 395
- DEPARTURE_TIME = 396
- DEPARTURE_DATE = 397
+ ARRIVAL_TIME = 394 //value of type UInt32, that represents the arrival time expressed in seconds since mid-night (UTC)
+ ARRIVAL_DATE = 395 //value of type UInt32, that represents the arrival date expressed either as calendar date (the number of days since 1 Jan 2000) or as weekday. The weekday is expressed with values from 0 to 6 (0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday)
+ DEPARTURE_TIME = 396 //value of type UInt32, that represents the departure time expressed in seconds since mid-night (UTC)
+ DEPARTURE_DATE = 397 //value of type UInt32, that represents the departure date expressed either as calendar date (the number of days since 1 Jan 2000) or as weekday. The weekday is expressed with values from 0 to 6 (0 = Saturday, 1 = Sunday, 2 = Monday, ..., 6 = Friday)
}
- enumeration PreferenceMode extends BasicEnum { //Base 0x0190
+ enumeration PreferenceMode extends BasicEnum {
PROHIBIT = 400
AVOID = 401
USE = 402
@@ -76,7 +76,7 @@ interface Routing { IGNORE = 404
}
- enumeration ConditionPreferenceSource extends BasicEnum { //Base 0x0200
+ enumeration ConditionPreferenceSource extends BasicEnum {
TRAFFIC_REALTIME = 512
}
@@ -119,10 +119,10 @@ interface Routing { }
enumeration RouteOverviewType extends Schedule {
- TOTAL_TIME = 398
- TOTAL_DISTANCE = 399
+ TOTAL_TIME = 398 //value of type UInt32, that represents the total time in seconds
+ TOTAL_DISTANCE = 399 //value of type UInt32, that represents the total distance in m
}
-
+
union RouteOverviewItem {
UInt32 uValue
}
@@ -154,27 +154,29 @@ interface Routing { START_LATITUDE = 321 //value of type Double, that expresses the latitude of the starting point in format %3.6f. Range [-90:+90]. Example: 48.053250
END_LATITUDE = 322 //value idem of START_LATITUDE, it can be omitted, if it coincides with the latitude of the start point of the next segment
START_LONGITUDE = 323 //value of type Double, that expresses the longitude of the starting point in format %3.6f. Range [-180:+180]. Example: 8.321000
- END_LONGITUDE = 324 //
- START_ALTITUDE = 325 //
- END_ALTITUDE = 326 //
- ROAD_NAME = 327 //
- DISTANCE = 328 //
- TIME = 329 //
- MANEUVER = 330 //
- INSTRUCTION = 331 //
- BORDER_CROSSING = 332 //
- ADDITIONAL_INFORMATION = 333 //
- ROAD_NUMBER = 334 //
- START_OFFSET = 335 //
- INTERMEDIATE_POINTS = 288 //
- HIGHWAY_EXIT = 116 //
- SPEED = 164 //
+ END_LONGITUDE = 324 //value of type Double, that expresses the longitude of the ending point in format %3.6f. Range [-180:+180]. Example: 8.321000
+ START_ALTITUDE = 325 //value of type Int32, that expresses the altitude relative to the ground of the starting point in meters
+ END_ALTITUDE = 326 //value of type Int32, can be omitted, if it coincides with the altitude of the start point of the next segment
+ ROAD_NAME = 327 //value of type String, that expresses the road name
+ DISTANCE = 328 //value of type Double, that identifies distance to the next segment in meters
+ TIME = 329 //value of type UInt16, that identifies time to travel to the next segment in seconds
+ MANEUVER = 330 //value of type 'a(qqaq)', that identifies a pictogram that describes the next maneuver (OPTIONAL)
+ INSTRUCTION = 331 //value of type String, that identifies the instruction to the user
+ BORDER_CROSSING = 332 //value of type String, that contains information about border crossings
+ ADDITIONAL_INFORMATION = 333 //value of type String, that contains additional information to the user (toll cost, ... )
+ ROAD_NUMBER = 334 //value of type String, that expresses the road number
+ START_OFFSET = 335 //value of type UInt32, that indicates the offset of the starting point in meters from the beginning of the route
+ INTERMEDIATE_POINTS = 288 //value of type IntermediatePoint[], that expresses an array of intermediate points
+ HIGHWAY_EXIT = 116 //value of type String, that in case the road segment ends with a highway exit, it expresses the highway exit number
+ SPEED = 164 //value of type UInt16, that identifies speed limit on the current segment
+ TIME_ZONE //value of type 'n', that indicates the time zone of the current segment. It is expressed as the time difference from the UTC in minutes
+ DAYLIGHT_SAVING_TIME //value of type 'n', that indicates the daylight saving time of the current segment. It is expressed as the time difference from the UTC in minutes
}
//TODO: Incomplete
union RouteSegmentItem {
Double doubleValue // LATITUDE, LONGITUDE, ALTITUDE
- IntermediatePoint[] intermediatePoints
+ IntermediatePoint[] intermediatePoints //Note: an intermediate point is expressed as a struct(type,latitude,longitude,altitude), where type = enum(INVALID,HARD_POINT,SOFT_POINT, ... )
String stringValue // ROAD_NUMBER
UInt8[] linkId
Int32 int32Value
diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx index ae407e2..96b1fe5 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -393,24 +393,30 @@ class MapViewerControl throw DBus::ErrorNotSupported("Not yet supported"); } - void + void SetMapViewScale(const uint32_t& SessionHandle, const uint32_t& MapViewInstanceHandle, const uint16_t& ScaleID) - { + { dbg(lvl_debug,"enter\n"); - MapViewerControlObj *obj=handles[MapViewInstanceHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - obj->SetMapViewScale(SessionHandle, ScaleID); - } + MapViewerControlObj *obj=handles[MapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewScale(SessionHandle, ScaleID); + //todo: manage the isminmax indicator + MapViewScaleChanged(MapViewInstanceHandle,ScaleID,GENIVI_MAPVIEWER_INVALID); + } - void + void SetMapViewScaleByDelta(const uint32_t& SessionHandle, const uint32_t& MapViewInstanceHandle, const int16_t& ScaleDelta) - { - MapViewerControlObj *obj=handles[MapViewInstanceHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - obj->SetMapViewScaleByDelta(SessionHandle, ScaleDelta); - } + { + MapViewerControlObj *obj=handles[MapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewScaleByDelta(SessionHandle, ScaleDelta); + uint8_t current_scale; + DBusCommonAPIEnumeration is_min_max; + obj->GetMapViewScale(current_scale,is_min_max); + MapViewScaleChanged(MapViewInstanceHandle,current_scale,is_min_max); + } void GetMapViewScale(const uint32_t& MapViewInstanceHandle, uint8_t& ScaleID, DBusCommonAPIEnumeration& IsMinMax) diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx index d63a924..38c2856 100644 --- a/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -75,11 +75,16 @@ using namespace v4::org::genivi::navigation::navigationcore; using namespace v4::org::genivi::navigation; using namespace v4::org::genivi; -static NavigationTypes::Handle m_navigationcore_session; - class MapViewerControlServerStub; class MapMatchedPositionClientProxy; class RoutingClientProxy; +class NavigationCoreSessionClientProxy; + +static std::shared_ptr < CommonAPI::Runtime > runtime; +static NavigationTypes::Handle m_navigationcore_session; +static MapMatchedPositionClientProxy *mp_mapMatchedPositionClientProxy; +static RoutingClientProxy* mp_routingClientProxy; +static NavigationCoreSessionClientProxy* mp_navigationCoreSessionClientProxy; class DisplayedRoute { @@ -117,8 +122,6 @@ class MapViewerControlObj bool m_follow_car; MapViewerControlServerStub *mp_mapviewercontrol; std::vector<DisplayedRoute *> m_displayed_routes; - MapMatchedPositionClientProxy *mp_mapMatchedPositionClientProxy; - RoutingClientProxy* mp_routingClientProxy; struct point m_pan; int m_pan_action; @@ -164,9 +167,8 @@ class MapViewerControlObj static std::map<uint32_t, MapViewerControlObj *> mp_handles; -static std::shared_ptr < CommonAPI::Runtime > runtime; - static void positionVehicleNavitUpdate(std::shared_ptr<MapMatchedPositionProxyDefault> pos, struct vehicle *v); + class MapMatchedPositionClientProxy { public: @@ -189,10 +191,9 @@ class MapMatchedPositionClientProxy { myServiceMapMatchedPosition = runtime->buildProxy<MapMatchedPositionProxy>(domain, instance); -// not working correctly (blocked) so removed for the moment -// while (!myServiceRouting->isAvailable()) { -// usleep(10); -// } + while (!myServiceMapMatchedPosition->isAvailable()) { + usleep(10); + } } void setListeners() @@ -254,10 +255,9 @@ class RoutingClientProxy RoutingClientProxy(const std::string & domain, const std::string & instance) { myServiceRouting = runtime->buildProxy<RoutingProxy>(domain, instance); -// not working correctly (blocked) so removed for the moment -// while (!myServiceRouting->isAvailable()) { -// usleep(10); -// } + while (!myServiceRouting->isAvailable()) { + usleep(10); + } } void connectToMapViewer(MapViewerControlObj *obj) @@ -287,7 +287,6 @@ class RoutingClientProxy void routeCalculationSuccessful(const NavigationTypes::Handle& RouteHandle, const Routing::UnfullfilledRoutePreference& unfullfilledPreferences) { std::vector<DisplayedRoute *>::iterator it; - for (it=m_mapviewerobj->m_displayed_routes.begin() ; it < m_mapviewerobj->m_displayed_routes.end(); it++ ) { if (*it && (*it)->m_handle == RouteHandle) { (*it)->Hide(); @@ -309,15 +308,12 @@ class NavigationCoreSessionClientProxy { myServiceNavigationCoreSession = runtime->buildProxy<SessionProxy>(domain, instance); -// not working correctly (blocked) so removed for the moment -// while (!myServiceRouting->isAvailable()) { -// usleep(10); -// } + while (!myServiceNavigationCoreSession->isAvailable()) { + usleep(10); + } } }; -static NavigationCoreSessionClientProxy* mp_navigationCoreSessionClientProxy; - class MapViewerControlServerStub : public MapViewerControlStubDefault { public: @@ -721,6 +717,8 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); obj->SetMapViewScale(_sessionHandle, _scaleID); + //todo: manage the isminmax indicator + fireMapViewScaleChangedEvent(_mapViewInstanceHandle,_scaleID,MapViewerControl::MapScaleType::INVALID); _reply(); } @@ -733,6 +731,10 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); obj->SetMapViewScaleByDelta(_sessionHandle, _scaleDelta); + uint8_t current_scale; + MapViewerControl::MapScaleType is_min_max; + obj->GetMapViewScale(current_scale,is_min_max); + fireMapViewScaleChangedEvent(_mapViewInstanceHandle,current_scale,is_min_max); _reply(); } @@ -1448,15 +1450,14 @@ MapViewerControlObj::SetMapViewBoundingBox(NavigationTypes::Handle SessionHandle struct coord_rect r; struct coord_geo g; SetFollowCarMode(SessionHandle, false); - dbg(lvl_debug,"%f,%f-%f,%f\n",boundingBox._1._1,boundingBox._1._2,boundingBox._2._1,boundingBox._2._2); g.lat=boundingBox.getTopLeft().getLatitude(); g.lng=boundingBox.getTopLeft().getLongitude(); - transform_from_geo(projection_mg, &g, &r.lu); + transform_from_geo(projection_mg, &g, &r.lu); g.lat=boundingBox.getBottomRight().getLatitude(); - g.lng=boundingBox.getBottomRight().getLatitude(); - transform_from_geo(projection_mg, &g, &r.rl); + g.lng=boundingBox.getBottomRight().getLongitude(); + transform_from_geo(projection_mg, &g, &r.rl); dbg(lvl_debug,"0x%x,0x%x-0x%x,0x%x\n",r.lu.x,r.lu.y,r.rl.x,r.rl.y); - navit_zoom_to_rect(m_navit.u.navit, &r); + navit_zoom_to_rect(m_navit.u.navit, &r); } void @@ -1628,13 +1629,8 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco m_force_draw=false; m_perspective=MapViewerControl::MapPerspective::PERSPECTIVE_2D; m_follow_car=true; - m_navigationcore_session = NavigationTypes::BasicEnum::INVALID; - //init the routing client - const std::string domain = "local"; - const std::string instanceRouting = "Routing"; - mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting); - mp_routingClientProxy->setListeners(); + //connect the routing client to map viewer mp_routingClientProxy->connectToMapViewer(this); struct attr navit_template; struct attr navit_flags={attr_flags};navit_flags.u.num=2; @@ -1646,7 +1642,7 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco m_navit.u.navit=navit_new(NULL,navit_attrs); if (!m_navit.u.navit) { dbg(lvl_debug,"failed to create new navit instance\n"); - return; + return; } const char *graphics=getenv("NAVIT_GRAPHICS"); if (!graphics) @@ -1692,12 +1688,9 @@ MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewerco m_vehicle.u.vehicle=vehicle_new(&m_navit,vehicle_attrs); navit_add_attr(m_navit.u.navit, &m_vehicle); navit_set_attr(m_navit.u.navit, &m_vehicle); - - // init the map matched position client - const std::string instanceMapMatchedPosition = "MapMatchedPosition"; - mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPosition); - mp_mapMatchedPositionClientProxy->setListeners(); + //connect the map matched position client to map viewer mp_mapMatchedPositionClientProxy->connectToMapViewer(this); + // and connect it to the vehicle mp_mapMatchedPositionClientProxy->connectToVehicle(m_vehicle.u.vehicle); navit_init(m_navit.u.navit); graphics_get_data(m_graphics.u.graphics,"window"); @@ -1845,7 +1838,7 @@ void DisplayedRoute::WriteSegment(FILE *out) { if (m_coordinates.size()) { - int i; + size_t i; uint32_t header[3]={2+2*m_coordinates.size(),type_street_route,2*m_coordinates.size()}; fwrite(header, sizeof(header), 1, out); for (i = 0 ; i < m_coordinates.size() ; i++) @@ -1871,8 +1864,8 @@ DisplayedRoute::DisplayedRoute(class MapViewerControlObj *mapviewer, uint8_t Rou m_shown=false; uint32_t totalNumberOfSegments; CommonAPI::CallStatus status; - mapviewer->mp_routingClientProxy->myServiceRouting->getRouteSegments(RouteHandle, 1, valuesToReturn, 0xffffffff, 0, status,totalNumberOfSegments, RouteShape); - m_filename=g_strdup_printf("/tmp/genivi_route_map_%d_%d.bin",mapviewer->m_handle,RouteHandle); + mp_routingClientProxy->myServiceRouting->getRouteSegments(RouteHandle, 1, valuesToReturn, 0xffffffff, 0, status,totalNumberOfSegments, RouteShape); + m_filename=g_strdup_printf("/tmp/genivi_route_map_%d_%d.bin",mapviewer->m_handle,RouteHandle); FILE *f=fopen(m_filename,"w"); int count=RouteShape.size(); bool complete=true; @@ -1935,6 +1928,16 @@ plugin_init(void) const std::string instanceNavigationCoreSession = "Session"; mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSession); + //init the routing client + const std::string instanceRouting = "Routing"; + mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting); + mp_routingClientProxy->setListeners(); + + // init the map matched position client + const std::string instanceMapMatchedPosition = "MapMatchedPosition"; + mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPosition); + mp_mapMatchedPositionClientProxy->setListeners(); + #if LM if (ilm_init() != ILM_SUCCESS) { dbg(lvl_error,"error on ilm_init\n"); diff --git a/src/navigation/navigation-core/poicam-server-plugin/genivi_poiservice_cam_navit.cxx b/src/navigation/navigation-core/poicam-server-plugin/genivi_poiservice_cam_navit.cxx index 98d4dca..0f98611 100644 --- a/src/navigation/navigation-core/poicam-server-plugin/genivi_poiservice_cam_navit.cxx +++ b/src/navigation/navigation-core/poicam-server-plugin/genivi_poiservice_cam_navit.cxx @@ -444,9 +444,13 @@ plugin_init(void) const std::string instancePOIContentAccess = "POIContentAccess"; myServicePOIContentAccess = runtime->buildProxy<POIContentAccessProxy>(domain, instancePOIContentAccess); - while (!myServicePOIContentAccess->isAvailable()) { + uint8_t counter=0; + while (!myServicePOIContentAccess->isAvailable() && ++counter<100) { usleep(10); } - myServicePOIContentAccessModule->register_cam(); + if (counter<100) + myServicePOIContentAccessModule->register_cam(); + else + printf("NB: POIContentAccessModule not available\n"); } diff --git a/src/navigation/navigation-core/routing-server-plugin/genivi_navigationcore_routing.cxx b/src/navigation/navigation-core/routing-server-plugin/genivi_navigationcore_routing.cxx index 5f1426d..bef3b16 100644 --- a/src/navigation/navigation-core/routing-server-plugin/genivi_navigationcore_routing.cxx +++ b/src/navigation/navigation-core/routing-server-plugin/genivi_navigationcore_routing.cxx @@ -738,10 +738,10 @@ get_map(struct coord *c, struct item *item, int is_end, const std::vector< Routi map[Routing::RouteSegmentType::DISTANCE]=(double)length.u.num; } if (item_attr_get(item, attr_time, &time) && vector_contains(valuesToReturn, Routing::RouteSegmentType::TIME)) { - map[Routing::RouteSegmentType::TIME]=(uint32_t)((time.u.num+5)/10); + map[Routing::RouteSegmentType::TIME]=(uint16_t)((time.u.num+5)/10); } if (item_attr_get(item, attr_speed, &speed) && vector_contains(valuesToReturn, Routing::RouteSegmentType::SPEED)) { - map[Routing::RouteSegmentType::SPEED]=(uint32_t)speed.u.num; + map[Routing::RouteSegmentType::SPEED]=(uint16_t)speed.u.num; } } if (item && vector_contains(valuesToReturn, Routing::RouteSegmentType::ROAD_NAME)) { diff --git a/test/navigation/test-map-viewer-control-capi.py b/test/navigation/test-map-viewer-control-capi.py index ecdf6f8..534ce62 100755 --- a/test/navigation/test-map-viewer-control-capi.py +++ b/test/navigation/test-map-viewer-control-capi.py @@ -29,9 +29,11 @@ import dbus import gobject +import dbus.mainloop.glib import time -#import pdb; pdb.set_trace() +#import pdb; +#pdb.set_trace() #constants as defined in the Navigation API LATITUDE = 0x00a0 @@ -43,14 +45,57 @@ SPLIT_SCREEN = 0x0011 #constants used by the script HORIZONTAL_SIZE = 800 VERTICAL_SIZE = 480 +TIME_OUT = 10000 +MIN_SCALE = 0 +MAX_SCALE = 16 + +def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle,scale,isMinMax): + global g_scale + new_scale=int(scale) + print("Scale: "+str(new_scale)) + if g_scale > new_scale and new_scale !=MIN_SCALE: + print("Zoom in") + g_scale=new_scale + MapViewerControl_interface.setMapViewScaleByDelta( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.Int16(1)) + else: + if new_scale < MAX_SCALE: + print("Zoom out") + g_scale=new_scale + MapViewerControl_interface.setMapViewScaleByDelta( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.Int16(-1)) + else: + print 'Test PASSED' + MapViewerControl_interface.releaseMapViewInstance( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle)) + session_interface.deleteSession(sessionhandle) + loop.quit() + +#timeout +def timeout(): + print 'Timeout Expired' + print '\nTest FAILED' + loop.quit() print '\n--------------------------' print 'MapViewerControl Test' print '--------------------------\n' +if __name__ == '__main__': + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + #connect to session bus bus = dbus.SessionBus() +bus.add_signal_receiver(mapviewer_mapViewScaleChanged_handler, \ + dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl", \ + signal_name = "mapViewScaleChanged") + session = bus.get_object('org.genivi.navigation.mapviewer.Session_Session','/Session') session_interface = dbus.Interface(session, dbus_interface='org.genivi.navigation.mapviewer.Session') @@ -118,49 +163,19 @@ ret=MapViewerControl_interface.getMapViewScale(dbus.UInt32(mapviewerhandle)) print('Scale ID: '+str(int(ret[0]))) print('MapScaleType: '+str(int(ret[1]))) -time.sleep(3) - -print 'Zoom in' -MapViewerControl_interface.setMapViewScaleByDelta( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.Int16(1)) +g_scale=int(ret[0]) time.sleep(3) print 'Zoom in' -MapViewerControl_interface.setMapViewScaleByDelta( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.Int16(1)) - -time.sleep(3) - -print 'Zoom out' -MapViewerControl_interface.setMapViewScaleByDelta( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.Int16(-1)) - -time.sleep(3) - -print 'Zoom out' -MapViewerControl_interface.setMapViewScaleByDelta( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.Int16(-1)) - -time.sleep(3) - -MapViewerControl_interface.releaseMapViewInstance( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle)) - -session_interface.deleteSession(sessionhandle) - +MapViewerControl_interface.setMapViewScaleByDelta(dbus.UInt32(sessionhandle), dbus.UInt32(mapviewerhandle), dbus.Int16(1)) -print '\nTest Finished\n' +time.sleep(1) +#main loop +gobject.timeout_add(TIME_OUT, timeout) +loop = gobject.MainLoop() +loop.run() diff --git a/test/navigation/test-map-viewer-control.py b/test/navigation/test-map-viewer-control.py index 75fc9be..1588f5d 100755 --- a/test/navigation/test-map-viewer-control.py +++ b/test/navigation/test-map-viewer-control.py @@ -121,7 +121,7 @@ MapViewerControl_interface.SetMapViewScaleByDelta( \ dbus.UInt32(mapviewerhandle), \ dbus.Int16(1)) -time.sleep(1) +time.sleep(3) print 'Zoom in' MapViewerControl_interface.SetMapViewScaleByDelta( \ @@ -129,7 +129,7 @@ MapViewerControl_interface.SetMapViewScaleByDelta( \ dbus.UInt32(mapviewerhandle), \ dbus.Int16(1)) -time.sleep(1) +time.sleep(3) print 'Zoom out' MapViewerControl_interface.SetMapViewScaleByDelta( \ @@ -137,7 +137,7 @@ MapViewerControl_interface.SetMapViewScaleByDelta( \ dbus.UInt32(mapviewerhandle), \ dbus.Int16(-1)) -time.sleep(1) +time.sleep(3) print 'Zoom out' MapViewerControl_interface.SetMapViewScaleByDelta( \ @@ -145,15 +145,13 @@ MapViewerControl_interface.SetMapViewScaleByDelta( \ dbus.UInt32(mapviewerhandle), \ dbus.Int16(-1)) -time.sleep(1) +time.sleep(3) MapViewerControl_interface.ReleaseMapViewInstance( \ dbus.UInt32(sessionhandle), \ dbus.UInt32(mapviewerhandle)) session_interface.DeleteSession(sessionhandle) - -time.sleep(1) print '\nTest Finished\n' |