From 3d9f1eed3df79c19b5b1ed0dc14697575be945fa Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Thu, 8 Jun 2017 13:58:58 +0200 Subject: extend test for mapviewer and add a signal for debugging --- .../genivi-mapviewer-mapviewercontrol.xml | 11 ++ src/navigation/build.sh | 4 + .../mapviewercontrol-plugin/CMakeLists.txt | 2 +- .../genivi_mapviewer_mapviewercontrol.cxx | 64 +++++-- .../genivi_mapviewer_mapviewercontrol.cxx | 64 ++++--- src/navigation/navigation-common/log.h | 154 ++++++++++++++++ .../script-capi/test-map-viewer-control-capi.py | 3 +- test/navigation/script/test-map-viewer-control.py | 203 +++++++++++++++------ 8 files changed, 405 insertions(+), 100 deletions(-) create mode 100644 src/navigation/navigation-common/log.h diff --git a/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml b/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml index db6eb63..cee04ca 100644 --- a/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml +++ b/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml @@ -2002,5 +2002,16 @@ cover with other windows or user interface elements + + + MapViewRotated = This signal is emitted when the rotation is achieved + This signal is meant for debugging purposes + + + + mapViewInstanceHandle = Map instance handle. Range[0x0:0x7fffffff]. 0x0 is reserved as an invalid handle value + + + diff --git a/src/navigation/build.sh b/src/navigation/build.sh index 23d5ec5..d5d3873 100755 --- a/src/navigation/build.sh +++ b/src/navigation/build.sh @@ -103,6 +103,10 @@ else fi cd ../ echo 'build navigation' +if [ "$capi" = 1 ] +then + echo 'delete option because DBus does not manage it' +fi if [ "$clean" = 1 ] then cmake $dlt_option $commonapi_tools_option ../ diff --git a/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt b/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt index 2b83ce0..9165e80 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/CMakeLists.txt @@ -51,4 +51,4 @@ set(genivi_mapviewer_mapviewercontrol_LIBRARY_DIRS ${PLUGIN_LIBRARIES}) module_add_library(genivi_mapviewer_mapviewercontrol genivi_mapviewer_mapviewercontrol.cxx ${DBUS_GENERATED_INCLUDE_DIR}/map-viewer/genivi-mapviewer-mapviewercontrol_adaptor.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-routing_proxy.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-session_proxy.h ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-mapmatchedposition_proxy.h) add_dependencies(genivi_mapviewer_mapviewercontrol ${API_DIR}/map-viewer) - +target_link_libraries(genivi_mapviewer_mapviewercontrol ${LIBRARIES}) 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 6093567..cd73751 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -66,6 +66,10 @@ #include "navigation-common-dbus.h" +#include "log.h" + +DLT_DECLARE_CONTEXT(gCtx); + #if (!DEBUG_ENABLED) #undef dbg #define dbg(level,...) ; @@ -138,8 +142,8 @@ class MapViewerControlObj void MoveMap(void); void SetFollowCarMode(uint32_t SessionHandle, bool active); void GetFollowCarMode(bool& active); - void SetCameraHeadingAngle(uint32_t sessionHandle, double angle); - void GetCameraHeadingAngle(double &angle); + void SetCameraHeadingAngle(uint32_t sessionHandle, int32_t angle); + void GetCameraHeading(DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target); void SetCameraTiltAngle(uint32_t sessionHandle, double angle); void GetCameraTiltAngle(double &angle); void SetCameraRollAngle(uint32_t sessionHandle, double angle); @@ -189,7 +193,8 @@ class Routing : DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.Routing") { m_mapviewerobj=obj; - } + LOG_INFO_MSG(gCtx,"routing client"); + } void RouteDeleted(const uint32_t& routeHandle) @@ -243,7 +248,8 @@ class NavigationCoreSession NavigationCoreSession(DBus::Connection &connection) : DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.Session") { - } + LOG_INFO_MSG(gCtx,"session client"); + } void SessionDeleted(const uint32_t& sessionHandle) { } @@ -262,7 +268,8 @@ class MapMatchedPosition : DBus::ObjectProxy(connection, "/org/genivi/navigationcore","org.genivi.navigation.navigationcore.MapMatchedPosition") { cb=callback_new_2(callback_cast(position_update), this, v); - } + LOG_INFO_MSG(gCtx,"map matched position client"); + } void PositionUpdate(const std::vector< DBusCommonAPIEnumeration >& changedValues) { @@ -344,7 +351,8 @@ class MapViewerControl MapViewerControl(DBus::Connection &connection) : DBus::ObjectAdaptor(connection, "/org/genivi/mapviewer") { - } + LOG_INFO_MSG(gCtx,"map viewer control server"); + } void CreateMapViewInstance(const uint32_t& sessionHandle, const ::DBus::Struct< uint16_t, uint16_t >& mapViewSize, const DBusCommonAPIEnumeration& mapViewType, int32_t& error, uint32_t& mapViewInstanceHandle) @@ -386,9 +394,12 @@ class MapViewerControl SetMapViewPerspective(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const DBusCommonAPIEnumeration& perspective) { MapViewerControlObj *obj=handles[mapViewInstanceHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetMapViewPerspective(sessionHandle, perspective); + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + else{ + obj->SetMapViewPerspective(sessionHandle, perspective); + MapViewPerspectiveChanged(mapViewInstanceHandle,perspective); + } } DBusCommonAPIEnumeration @@ -417,8 +428,10 @@ class MapViewerControl throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); else { obj->SetMapViewScale(SessionHandle, ScaleID); - //todo: manage the isminmax indicator - MapViewScaleChanged(MapViewInstanceHandle,ScaleID,GENIVI_MAPVIEWER_INVALID); + uint8_t current_scale; + DBusCommonAPIEnumeration is_min_max; + obj->GetMapViewScale(current_scale,is_min_max); + MapViewScaleChanged(MapViewInstanceHandle,current_scale,is_min_max); } } @@ -723,7 +736,10 @@ class MapViewerControl MapViewerControlObj *obj=handles[mapViewInstanceHandle]; if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetMapViewRotation(sessionHandle, rotationAngle, rotationAnglePerSecond); + else { + obj->SetMapViewRotation(sessionHandle, rotationAngle, rotationAnglePerSecond); + MapViewRotated(mapViewInstanceHandle); + } } void @@ -848,7 +864,7 @@ class MapViewerControl MapViewerControlObj *obj=handles[mapViewInstanceHandle]; if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); - else obj->SetCameraHeadingTrackUp(sessionHandle); + else obj->SetCameraHeadingTrackUp(sessionHandle); } void @@ -866,8 +882,11 @@ class MapViewerControl void GetCameraHeading(const uint32_t& mapViewInstanceHandle, DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target) { - throw DBus::ErrorNotSupported("Not yet supported"); - } + MapViewerControlObj *obj=handles[mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + else obj->GetCameraHeading(headingType,headingAngle,target); + } std::vector< uint32_t > DisplayCustomElements(const uint32_t& sessionHandle, const uint32_t& mapViewInstanceHandle, const std::vector< ::DBus::Struct< std::string, std::string, ::DBus::Struct< double, double >, ::DBus::Struct< int16_t, int16_t > > >& customElements) @@ -1217,7 +1236,7 @@ MapViewerControlObj::GetFollowCarMode(bool& active) } void -MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, double angle) +MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, int32_t angle) { struct attr orientation={attr_orientation}; orientation.u.num=angle; @@ -1226,10 +1245,13 @@ MapViewerControlObj::SetCameraHeadingAngle(uint32_t sessionHandle, double angle) } void -MapViewerControlObj::GetCameraHeadingAngle(double &angle) +MapViewerControlObj::GetCameraHeading(DBusCommonAPIEnumeration& headingType, int32_t& headingAngle, ::DBus::Struct< double, double >& target) { struct transformation *trans=navit_get_trans(m_navit.u.navit); - angle=transform_get_yaw(trans); + headingAngle=transform_get_yaw(trans); + headingType=GENIVI_MAPVIEWER_INVALID; + target._1=0; + target._2=0; } void @@ -1426,7 +1448,6 @@ MapViewerControlObj::SetMapViewRotation(uint32_t sessionHandle, double rotationA m_rotationanglepersecond=rotationAnglePerSecond; SetFollowCarMode(sessionHandle, false); MoveMap(); - } void @@ -1894,7 +1915,10 @@ static class MapViewerControl *server; void plugin_init(void) { - event_request_system("glib","genivi_mapviewercontrol"); + DLT_REGISTER_APP("MPVS","MAP VIEWER CONTROL SERVER"); + DLT_REGISTER_CONTEXT(gCtx,"MPVS","Global Context"); + + event_request_system("glib","genivi_mapviewercontrol"); int i; for (i = 0 ; i < CONNECTION_AMOUNT ; i++) { // init the dispatcher 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 bbacb2d..dd03d80 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 @@ -64,7 +64,6 @@ #include #include #include - #include "log.h" DLT_DECLARE_CONTEXT(gCtx); @@ -120,7 +119,7 @@ class MapViewerControlObj struct mapset *m_mapset; uint32_t m_handle; double m_scrolldirection, m_scrollspeed; - double m_rotationangle, m_rotationanglepersecond; + double m_rotationangle, m_rotationanglepersecond; struct callback *m_postdraw_callback; struct callback *m_move_callback; @@ -134,7 +133,9 @@ class MapViewerControlObj uint16_t m_width; uint16_t m_height; - void MoveMap(void); + MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize); + ~MapViewerControlObj(); + void MoveMap(void); void SetFollowCarMode(NavigationTypes::Handle SessionHandle, bool active); void GetFollowCarMode(bool& active); void SetCameraHeadingAngle(NavigationTypes::Handle SessionHandle, double angle); @@ -151,7 +152,7 @@ class MapViewerControlObj void SetMapViewPerspective(NavigationTypes::Handle SessionHandle, MapViewerControl::MapPerspective MapViewPerspectiveMode); void GetMapViewPerspective(MapViewerControl::MapPerspective &MapViewPerspectiveMode); void GetScaleList(std::vector< MapViewerControl::MapScale >& ScalesList); - void SetMapViewScale(NavigationTypes::Handle SessionHandle, uint32_t ScaleID); + void SetMapViewScale(NavigationTypes::Handle SessionHandle, uint8_t ScaleID); void SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta); void GetMapViewScale(uint8_t& ScaleID, MapViewerControl::MapScaleType &IsMinMax); void GetMapViewType(MapViewerControl::MapViewType &MapViewType); @@ -170,8 +171,6 @@ class MapViewerControlObj void HideRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle); void ConvertPixelCoordsToGeoCoords(NavigationTypes::Handle SessionHandle, const std::vector &pixelCoordinates, std::vector &GeoCoordinates); void ConvertGeoCoordsToPixelCoords(NavigationTypes::Handle SessionHandle, const std::vector &geoCoordinates, std::vector &pixelCoordinates); - MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize); - ~MapViewerControlObj(); }; static std::map mp_handles; @@ -323,6 +322,19 @@ class NavigationCoreSessionClientProxy } }; +class ClientStub : public CommonAPI::ClientId +{ +public: + ~ClientStub(){} + bool operator==(ClientId& clientIdToCompare) { + return true; + } + + std::size_t hashCode() { + return 0; + } +}; + class MapViewerControlServerStub : public MapViewerControlStubDefault { public: @@ -336,7 +348,6 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault m_version.setVersionMinor(0); m_version.setVersionMicro(0); m_version.setDate("21-01-2014"); - } /** @@ -447,6 +458,7 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); else obj->SetFollowCarMode(_sessionHandle, _followCarMode); + fireFollowCarModeChangedEvent(_mapViewInstanceHandle,_followCarMode); _reply(); } @@ -709,17 +721,17 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault /** * description: setMapViewScale = This method sets the map scale by specifying a ScaleID */ - void setMapViewScale(const std::shared_ptr _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint16_t _scaleID, setMapViewScaleReply_t _reply){ - dbg(lvl_debug,"enter\n"); + void setMapViewScale(const std::shared_ptr _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint8_t _scaleID, setMapViewScaleReply_t _reply){ + MapViewerControl::MapScaleType is_min_max=MapViewerControl::MapScaleType::INVALID; MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); else { - obj->SetMapViewScale(_sessionHandle, _scaleID); - uint8_t current_scale; - MapViewerControl::MapScaleType is_min_max; - obj->GetMapViewScale(current_scale,is_min_max); - fireMapViewScaleChangedSelective(_mapViewInstanceHandle,current_scale,is_min_max); +// obj->SetMapViewScale(_sessionHandle, _scaleID); +// obj->GetMapViewScale(_scaleID,is_min_max); + fireMapViewScaleChangedSelective(_mapViewInstanceHandle,_scaleID,is_min_max); + fireFollowCarModeChangedEvent(_mapViewInstanceHandle,false); + } _reply(); } @@ -1069,7 +1081,6 @@ class MapViewerControlServerStub : public MapViewerControlStubDefault throw DBus::ErrorNotSupported("Not yet supported"); } - private: CommonTypes::Version m_version; @@ -1188,18 +1199,17 @@ MapViewerControlObj::GetScaleList(std::vector &Scale } void -MapViewerControlObj::SetMapViewScale(NavigationTypes::Handle SessionHandle, uint32_t ScaleID) +MapViewerControlObj::SetMapViewScale(NavigationTypes::Handle SessionHandle, uint8_t ScaleID) { long scale=1 << ScaleID; struct transformation *trans=navit_get_trans(m_navit.u.navit); transform_set_scale(trans, scale); - navit_draw(m_navit.u.navit); + navit_draw(m_navit.u.navit); } void MapViewerControlObj::SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta) { - LOG_INFO(gCtx,"Delta=%d",ScaleDelta); if (ScaleDelta < 0) navit_zoom_in(m_navit.u.navit,1 << (-ScaleDelta),NULL); else if (ScaleDelta > 0) @@ -1983,34 +1993,34 @@ plugin_init(void) // init the map viewer control server const std::string domain = "local"; - const std::string instanceMapViewerControl = "MapViewerControl"; + const std::string instanceMapViewerControlServer = "MapViewerControl"; std::shared_ptr myServiceMapViewerControl = std::make_shared(); - bool successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl); + bool successfullyRegistered = runtime->registerService(domain, instanceMapViewerControlServer, myServiceMapViewerControl); while (!successfullyRegistered) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl); + successfullyRegistered = runtime->registerService(domain, instanceMapViewerControlServer, myServiceMapViewerControl); } LOG_INFO_MSG(gCtx,"map viewer control server"); //init the session client - const std::string instanceNavigationCoreSession = "Session"; - mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSession); + const std::string instanceNavigationCoreSessionClient = "Session"; + mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSessionClient); LOG_INFO_MSG(gCtx,"session client"); //init the routing client - const std::string instanceRouting = "Routing"; - mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting); + const std::string instanceRoutingClient = "Routing"; + mp_routingClientProxy = new RoutingClientProxy(domain,instanceRoutingClient); mp_routingClientProxy->setListeners(); LOG_INFO_MSG(gCtx,"routing client"); // init the map matched position client - const std::string instanceMapMatchedPosition = "MapMatchedPosition"; - mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPosition); + const std::string instanceMapMatchedPositionClient = "MapMatchedPosition"; + mp_mapMatchedPositionClientProxy = new MapMatchedPositionClientProxy(domain,instanceMapMatchedPositionClient); mp_mapMatchedPositionClientProxy->setListeners(); LOG_INFO_MSG(gCtx,"map matched position client"); diff --git a/src/navigation/navigation-common/log.h b/src/navigation/navigation-common/log.h new file mode 100644 index 0000000..4d946fb --- /dev/null +++ b/src/navigation/navigation-common/log.h @@ -0,0 +1,154 @@ +/************************************************************************** +* @licence app begin@ +* +* SPDX-License-Identifier: MPL-2.0 +* +* \ingroup GNSSService +* +* \copyright Copyright (C) BMW Car IT GmbH 2011 +* Copyright (C) 2013, XS Embedded GmbH +* +* \license +* 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/. +* +* @licence end@ +**************************************************************************/ + +#ifndef INCLUDE_LOG +#define INCLUDE_LOG + +// turn-on via cmake define: +// $ cmake -DWITH_DLT=1 -DDEBUG_ENABLED=1 .. + +#if (!DLT_ENABLED) +/*****************************************************************************/ +// use printf +#include + +// some type-name used instead of DLT context +typedef const char* NoDltContext; + +#define DLT_DECLARE_CONTEXT(CONTEXT) \ + NoDltContext CONTEXT; + +#define DLT_IMPORT_CONTEXT(CONTEXT) \ + extern NoDltContext CONTEXT; + +#define DLT_REGISTER_CONTEXT(CONTEXT, CONTEXT_ID, DESC) \ + CONTEXT = CONTEXT_ID; + +#define DLT_REGISTER_APP(CONTEXT, DESC) ; + +#define DLT_UNREGISTER_CONTEXT(CONTEXT) ; +#define DLT_UNREGISTER_APP() ; +#define dlt_free() ; + +// log calls +#if (!DEBUG_ENABLED) + +#define LOG_VERBOSE_MSG(context, msg) ; +#define LOG_VERBOSE(context, fmt, ...) ; + +#define LOG_DEBUG_MSG(context, msg) ; +#define LOG_DEBUG(context, fmt, ...) ; + +#define LOG_INFO_MSG(context, msg) ; +#define LOG_INFO(context, fmt, ...) ; + +#define LOG_WARNING_MSG(context, msg) ; +#define LOG_WARNING(context, fmt, ...) ; + +#else + +#define LOG_VERBOSE_MSG(context, msg) \ + fprintf(stderr, "[VERBO][%4s] " msg "\n", context) +#define LOG_VERBOSE(context, fmt, ...) \ + fprintf(stderr, "[VERBO][%4s] " fmt "\n", context, __VA_ARGS__) + +#define LOG_DEBUG_MSG(context, msg) \ + fprintf(stderr, "[DEBUG][%4s] " msg "\n", context) +#define LOG_DEBUG(context, fmt, ...) \ + fprintf(stderr, "[DEBUG][%4s] " fmt "\n", context, __VA_ARGS__) + +#define LOG_INFO_MSG(context, msg) \ + fprintf(stderr, "[INFO ][%4s] " msg "\n", context) +#define LOG_INFO(context, fmt, ...) \ + fprintf(stderr, "[INFO ][%4s] " fmt "\n", context, __VA_ARGS__) + +#define LOG_WARNING_MSG(context, msg) \ + fprintf(stderr, "[WARN ][%4s] " msg "\n", context) +#define LOG_WARNING(context, fmt, ...) \ + fprintf(stderr, "[WARN ][%4s] " fmt "\n", context, __VA_ARGS__) +#endif + +#define LOG_ERROR_MSG(context, msg) \ + fprintf(stderr, "[ERROR][%4s] " msg "\n", context) +#define LOG_ERROR(context, fmt, ...) \ + fprintf(stderr, "[ERROR][%4s] " fmt "\n", context, __VA_ARGS__) + +#define LOG_FATAL_MSG(context, msg) \ + fprintf(stderr, "[FATAL][%4s] " msg "\n", context) +#define LOG_FATAL(context, fmt, ...) \ + fprintf(stderr, "[FATAL][%4s] " fmt "\n", context, __VA_ARGS__) + +#else /* DLT_ENABLED */ +/*****************************************************************************/ +// use DLT +#include "dlt.h" + +typedef const char* Context; + +#define LOG_VERBOSE_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_VERBOSE, DLT_STRING(msg)); +#define LOG_VERBOSE(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_VERBOSE, DLT_STRING(logBuffer)); \ + } +#define LOG_DEBUG_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_DEBUG, DLT_STRING(msg)); +#define LOG_DEBUG(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_DEBUG, DLT_STRING(logBuffer)); \ + } +#define LOG_INFO_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_INFO, DLT_STRING(msg)); +#define LOG_INFO(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_INFO, DLT_STRING(logBuffer)); \ + } +#define LOG_WARNING_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_WARN, DLT_STRING(msg)); +#define LOG_WARNING(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_WARN, DLT_STRING(logBuffer)); \ + } +#define LOG_ERROR_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_ERROR, DLT_STRING(msg)); +#define LOG_ERROR(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_ERROR, DLT_STRING(logBuffer)); \ + } +#define LOG_FATAL_MSG(context, msg) \ + DLT_LOG(context, DLT_LOG_FATAL, DLT_STRING(msg)); +#define LOG_FATAL(context, fmt, ...) \ + { \ + char logBuffer[256]; \ + sprintf(logBuffer, fmt, __VA_ARGS__); \ + DLT_LOG(context, DLT_LOG_FATAL, DLT_STRING(logBuffer)); \ + } + +#endif /* DLT_ENABLED */ + +#endif /* INCLUDE_LOG */ diff --git a/test/navigation/script-capi/test-map-viewer-control-capi.py b/test/navigation/script-capi/test-map-viewer-control-capi.py index 4f70ca8..730172d 100755 --- a/test/navigation/script-capi/test-map-viewer-control-capi.py +++ b/test/navigation/script-capi/test-map-viewer-control-capi.py @@ -174,6 +174,7 @@ if __name__ == '__main__': #connect to session bus bus = dbus.SessionBus() +result = bus.request_name("org.genivi.navigation.mapviewer.MapViewerClient", dbus.UInt32(0)) bus.add_signal_receiver(mapviewer_mapViewScaleChanged_handler, \ dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl.v4_0", \ @@ -252,7 +253,7 @@ print('Scale: '+str(int(ret[0]))) print('Is min max: '+str(int(ret[1]))) g_scale=int(ret[0]) - +time.sleep(2) step=TEST_STEP_START next_step() diff --git a/test/navigation/script/test-map-viewer-control.py b/test/navigation/script/test-map-viewer-control.py index 5cc5515..0c278d4 100755 --- a/test/navigation/script/test-map-viewer-control.py +++ b/test/navigation/script/test-map-viewer-control.py @@ -6,6 +6,7 @@ * SPDX-License-Identifier: MPL-2.0 * * \copyright Copyright (C) 2015, Mentor Graphics +* \copyright Copyright (C) 2017, PSA GROUP * * \file test-map-viewer-control.py * @@ -47,18 +48,27 @@ LATITUDE = 0x00a0 LONGITUDE = 0x00a1 MAPVIEWER_MAX = 0x0041 MAPVIEWER_MIN = 0x0040 - +PERSPECTIVE_TWO_D = 0x0020 +PERSPECTIVE_THREE_D = 0x0021 MAIN_MAP = 0x0010 SPLIT_SCREEN = 0x0011 #constants used by the script HORIZONTAL_SIZE = 800 VERTICAL_SIZE = 480 -TIME_OUT = 20000 -INIT_SCALE=2 +TIME_OUT = 1000000 +INIT_SCALE=8 +SCALE_FOR_ROTATE=4 +SCALE_FOR_THREE_D=4 TEST_STEP_START=0 TEST_STEP_SCALE=1 TEST_STEP_ROTATE=2 +TEST_STEP_THREE_D=3 +SCALE_DELTA_DECREASE=-1 +SCALE_DELTA_INCREASE=1 +ROTATE_INCREMENT=5 +ROTATE_MAX=360 +ROTATE_SPEED=30 # List of coordinates LATITUDE = list() @@ -69,34 +79,111 @@ CITY_STRING = list() STREET_STRING = list() HOUSE_NUMBER_STRING = list() -def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle,scale,isMinMax): +def init_test_rotate(): + print ('Test rotate') + MapViewerControl_interface.SetMapViewScale( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.UInt16(SCALE_FOR_ROTATE)) + +def test_rotate(): + global g_angle + if g_angle < (ROTATE_MAX-ROTATE_INCREMENT): + g_angle += ROTATE_INCREMENT + MapViewerControl_interface.SetMapViewRotation( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.Int16(g_angle), \ + dbus.Int16(ROTATE_SPEED)) + return True + else: + print('Test rotate PASSED') + return False + +def init_test_scale(): + print ('Test scale') + MapViewerControl_interface.SetMapViewScale( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.UInt16(INIT_SCALE)) + +def test_scale(scale,isMinMax): global g_scale - global step - new_scale=int(scale) - print("Scale: "+str(new_scale)) - print('Is min max: '+str(int(isMinMax))) - if step ==TEST_STEP_SCALE: - time.sleep(0.25) - if g_scale > new_scale and isMinMax !=MAPVIEWER_MIN: + global g_scale_delta + global g_heading_angle + print("Scale: "+str(scale)) + print('Is min max: '+str(isMinMax)) + g_scale=scale + if g_scale_delta==SCALE_DELTA_DECREASE: + if isMinMax !=MAPVIEWER_MIN: print("Zoom in") - g_scale=new_scale MapViewerControl_interface.SetMapViewScaleByDelta( \ dbus.UInt32(sessionhandle), \ dbus.UInt32(mapviewerhandle), \ - dbus.Int16(-1)) + dbus.Int16(g_scale_delta)) + return True else: - if isMinMax !=MAPVIEWER_MAX: - print("Zoom out") - g_scale=new_scale - MapViewerControl_interface.SetMapViewScaleByDelta( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.Int16(1)) - else: - print('Test scale PASSED') - next_step() + print("Zoom out") + g_scale_delta=SCALE_DELTA_INCREASE + MapViewerControl_interface.SetMapViewScaleByDelta( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.Int16(g_scale_delta)) + return True + else: + if isMinMax !=MAPVIEWER_MAX: + print("Zoom out") + MapViewerControl_interface.SetMapViewScaleByDelta( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.Int16(g_scale_delta)) + return True + else: + print('Test scale PASSED') + return False + -#timeout +def init_test_three_d(): + print('Test 3D') + MapViewerControl_interface.SetMapViewScale( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.UInt16(SCALE_FOR_THREE_D)) + +def test_three_d(): + MapViewerControl_interface.SetMapViewPerspective(\ + dbus.UInt32(sessionhandle),\ + dbus.UInt32(mapviewerhandle), \ + PERSPECTIVE_THREE_D) + return False + +def mapviewer_mapViewRotated_handler(mapViewInstanceHandle): + if step ==TEST_STEP_ROTATE: + if test_rotate()==False: + next_step() + +def mapviewer_mapViewScaleChanged_handler(mapViewInstanceHandle,scale,isMinMax): + global step + if step ==TEST_STEP_SCALE: + if test_scale(int(scale),int(isMinMax))==False: + next_step() + else: + if step == TEST_STEP_ROTATE: + test_rotate() + else: + if step == TEST_STEP_THREE_D: + test_three_d() + + +def mapviewer_mapViewPerspectiveChanged_handler(mapViewInstanceHandle, perspective): + print("Perspective: "+str(perspective)) + if step==TEST_STEP_THREE_D: + if int(perspective)==PERSPECTIVE_THREE_D: + print('Test 3D PASSED') + else: + print('Test 3D failed') + exit() + def timeout(): print('Timeout Expired') print ('\nTest FAILED') @@ -115,22 +202,16 @@ def next_step(): global step if step == TEST_STEP_START: step=TEST_STEP_SCALE - print ('Test scale') - MapViewerControl_interface.SetMapViewScale( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.UInt16(INIT_SCALE)) + init_test_scale() else: if step ==TEST_STEP_SCALE: step=TEST_STEP_ROTATE - print ('Test rotate') - MapViewerControl_interface.SetMapViewScale( \ - dbus.UInt32(sessionhandle), \ - dbus.UInt32(mapviewerhandle), \ - dbus.UInt16(INIT_SCALE)) - exit() + init_test_rotate() else: if step ==TEST_STEP_ROTATE: + step=TEST_STEP_THREE_D + init_test_three_d() + else: exit() print('\n--------------------------') @@ -178,7 +259,14 @@ bus.add_signal_receiver(mapviewer_mapViewScaleChanged_handler, \ dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl", \ signal_name = "MapViewScaleChanged") +bus.add_signal_receiver(mapviewer_mapViewRotated_handler, \ + dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl", \ + signal_name = "MapViewRotated") +bus.add_signal_receiver(mapviewer_mapViewPerspectiveChanged_handler, \ + dbus_interface = "org.genivi.navigation.mapviewer.MapViewerControl", \ + signal_name = "MapViewPerspectiveChanged") + startTrigger(test_name) session = bus.get_object('org.genivi.navigation.mapviewer.Session','/org/genivi/mapviewer') @@ -207,12 +295,6 @@ mapviewerhandle=ret[1] print('MapView handle: ' + str(mapviewerhandle)) -index=0 - -lat1 = LATITUDE[index] -lon1 = LONGITUDE[index] -alt1 = ALTITUDE[index] - time.sleep(2) print ('Stop following the car position') @@ -221,42 +303,61 @@ MapViewerControl_interface.SetFollowCarMode( \ dbus.UInt32(mapviewerhandle), \ dbus.Boolean(False)) +#init the target (it's the first location in the input file by default) and test +index=0 +lat1 = LATITUDE[index] +lon1 = LONGITUDE[index] +alt1 = ALTITUDE[index] print('Set center in '+ CITY_STRING[index]+ ' (' + str(lat1) + ',' + str(lon1) + ')') MapViewerControl_interface.SetTargetPoint( \ dbus.UInt32(sessionhandle), \ dbus.UInt32(mapviewerhandle), \ dbus.Struct((dbus.Double(lat1),dbus.Double(lon1),dbus.Double(alt1)))) - -# Get current position targetPoint = MapViewerControl_interface.GetTargetPoint( \ dbus.UInt32(mapviewerhandle) ) - lat2 = targetPoint[0] lon2 = targetPoint[1] alt2 = targetPoint[2] - -print ('Get center -> (' + str(lat2) + ',' + str(lon2) + ')' ) - if round(float(lat1),4) != round(float(lat2),4) : print ('\nTest Failed:' + str(round(float(lat1),4)) + '!=' + str(round(float(lat2),4)) + '\n' ) - + exit() if round(float(lon1),4) != round(float(lon2),4) : print('\nTest Failed:' + str(round(float(lon1),4)) + '!=' + str(round(float(lon2),4)) + '\n' ) - + exit() if round(float(alt1),4) != round(float(alt2),4) : print('\nTest Failed:' + str(round(float(alt1),4)) + '!=' + str(round(float(alt2),4)) + '\n') + exit() +#init the scale +#get the default ret=MapViewerControl_interface.GetMapViewScale(dbus.UInt32(mapviewerhandle)) print('Scale: '+str(int(ret[0]))) print('Is min max: '+str(int(ret[1]))) +#and set it to init value +g_scale=INIT_SCALE +g_scale_delta=SCALE_DELTA_DECREASE +MapViewerControl_interface.SetMapViewScale( \ + dbus.UInt32(sessionhandle), \ + dbus.UInt32(mapviewerhandle), \ + dbus.UInt16(g_scale)) + +#wait for map refresh +time.sleep(0.25) -g_scale=int(ret[0]) +#init the perspective to 2D +MapViewerControl_interface.SetMapViewPerspective(dbus.UInt32(sessionhandle),dbus.UInt32(mapviewerhandle), PERSPECTIVE_TWO_D) + +#init the heading angle +MapViewerControl_interface.SetCameraHeadingAngle(dbus.UInt32(sessionhandle),dbus.UInt32(mapviewerhandle), dbus.Int32(0)) +ret=MapViewerControl_interface.GetCameraHeading(dbus.UInt32(mapviewerhandle)) +print('Heading: '+str(int(ret[1]))) +g_angle=int(ret[0]) step=TEST_STEP_START next_step() #main loop -gobject.timeout_add(TIME_OUT, timeout) +g_timer_timeout=gobject.timeout_add(TIME_OUT, timeout) loop = gobject.MainLoop() loop.run() -- cgit v1.2.1