diff options
33 files changed, 3225 insertions, 65 deletions
diff --git a/api/franca/CMakeLists.txt b/api/franca/CMakeLists.txt index 95c72fc..ee3c795 100644 --- a/api/franca/CMakeLists.txt +++ b/api/franca/CMakeLists.txt @@ -29,7 +29,13 @@ option(COMMONAPI_TOOL_DIR option(COMMONAPI_DBUS_TOOL_DIR "Absolute path to CommonAPI-DBus tool" "") -set(COMMONAPI_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}) +get_directory_property(hasParent PARENT_DIRECTORY) + +if(hasParent) + set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen" PARENT_SCOPE) +else() + set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") +endif() if (COMMONAPI_TOOL_DIR) message(STATUS "COMMONAPI_TOOL_DIR ${COMMONAPI_TOOL_DIR}") diff --git a/api/franca/navigation/mapviewer/MapViewerControl.fidl b/api/franca/navigation/mapviewer/MapViewerControl.fidl index 1346045..5b0595c 100755 --- a/api/franca/navigation/mapviewer/MapViewerControl.fidl +++ b/api/franca/navigation/mapviewer/MapViewerControl.fidl @@ -1330,6 +1330,8 @@ interface MapViewerControl { @description : valueToReturn = enum(PAN_START,PAN_TO,PAN_END) **> PanAction valueToReturn + } + out { Pixel [] pixelCoordinates } diff --git a/api/franca/navigation/navigationcore/MapMatchedPosition.fidl b/api/franca/navigation/navigationcore/MapMatchedPosition.fidl index 0658eab..437dfca 100644 --- a/api/franca/navigation/navigationcore/MapMatchedPosition.fidl +++ b/api/franca/navigation/navigationcore/MapMatchedPosition.fidl @@ -278,7 +278,7 @@ interface MapMatchedPosition { <**
@description : getAddress = This method returns the current address
**>
- method getAddress {
+ method getCurrentAddress {
in {
AddressItemKey[] valuesToReturn
}
diff --git a/api/franca/navigation/navigationcore/Routing.fidl b/api/franca/navigation/navigationcore/Routing.fidl index 6e741a5..c05477a 100644 --- a/api/franca/navigation/navigationcore/Routing.fidl +++ b/api/franca/navigation/navigationcore/Routing.fidl @@ -161,7 +161,7 @@ interface Routing { //TODO: Incomplete
union RouteSegmentItem {
Double doubleValue // LATITUDE, LONGITUDE, ALTITUDE
- IntermediatePoint intermediatePoints
+ IntermediatePoint[] intermediatePoints
String stringValue // ROAD_NUMBER
ByteBuffer linkId
Int32 int32Value
diff --git a/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml b/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml index e400238..5335bfb 100644 --- a/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml +++ b/api/map-viewer/genivi-mapviewer-mapviewercontrol.xml @@ -1067,7 +1067,7 @@ cover with other windows or user interface elements</line> <line>valueToReturn = enum(PAN_START,PAN_TO,PAN_END)</line> </doc> </arg> - <arg name="pixelCoordinates" type="a(qq)" direction="in"> + <arg name="pixelCoordinates" type="a(qq)" direction="out"> <doc> <line>pixelCoordinates = array[struct(x,y)]</line> <line>x = x-coordinate (x=0 indicates the first left pixel of the map view)</line> diff --git a/src/navigation/CMakeLists.txt b/src/navigation/CMakeLists.txt index d45974f..bb599cc 100644 --- a/src/navigation/CMakeLists.txt +++ b/src/navigation/CMakeLists.txt @@ -103,6 +103,7 @@ endif() # For the moment, there's still an issue there #add_subdirectory(navit/navit) +# so cmake for navit has to be invoked manually add_subdirectory(map) @@ -118,6 +119,27 @@ endif() include(${NAVIT_CMAKE_DIR}/navit_macros.cmake) +if (WITH_PLUGIN_MIGRATION) + # generates the CommonAPI templates from the Franca files + set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/franca/src-gen") + # for hmi and navigation + set(FRANCA_DIR "${API_DIR}/franca") + add_subdirectory(${FRANCA_DIR} "${CMAKE_CURRENT_BINARY_DIR}/franca") + # for enhanced position service + set(FRANCA_POSITIONING_DIR "${CMAKE_CURRENT_SOURCE_DIR}/positioning/enhanced-position-service/franca/api") + execute_process(COMMAND uname -i OUTPUT_VARIABLE OS_VERSION) + if("${OS_VERSION}" MATCHES "i686") + set(OS_VERSION "x86") + else() + set(OS_VERSION "x86_64") + endif() + set(COMMONAPI_TOOL_GENERATOR "${COMMONAPI_TOOL_DIR}/org.genivi.commonapi.core.cli.product/target/products/org.genivi.commonapi.core.cli.product/linux/gtk/${OS_VERSION}/commonapi-generator-linux-${OS_VERSION}") + set(COMMONAPI_DBUS_TOOL_GENERATOR "${COMMONAPI_DBUS_TOOL_DIR}/org.genivi.commonapi.dbus.cli.product/target/products/org.genivi.commonapi.dbus.cli.product/linux/gtk/${OS_VERSION}/commonapi-dbus-generator-linux-${OS_VERSION}") + set(WITH_FRANCA_DBUS_INTERFACE "ON") + set(COMMONAPI_GEN_DIR_POSITIONING "${CMAKE_CURRENT_BINARY_DIR}/enhanced-position-service/franca/api") + add_subdirectory(${FRANCA_POSITIONING_DIR} "${CMAKE_CURRENT_BINARY_DIR}/franca-positioning") +endif() + add_subdirectory(navigation-core) add_subdirectory(map-viewer) diff --git a/src/navigation/map-viewer/CMakeLists.txt b/src/navigation/map-viewer/CMakeLists.txt index 538f3d1..ad8194d 100644 --- a/src/navigation/map-viewer/CMakeLists.txt +++ b/src/navigation/map-viewer/CMakeLists.txt @@ -45,15 +45,29 @@ find_program(XSLTPROC xsltproc REQUIRED) # Generate the config file for navit/mapviewer if(NOT ${YOCTO_CONFIG}) - execute_process( - OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_mapviewer.xml - COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml - ) + if (WITH_PLUGIN_MIGRATION) + execute_process( + OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_mapviewer.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer_capi.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml + ) + else() + execute_process( + OUTPUT_FILE ${NAVIT_BIN_DIR}/navit_genivi_mapviewer.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer.xsl ${navit_SOURCE_DIR}/navit/navit_shipped.xml + ) + endif() else() - execute_process( - OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_mapviewer.xml - COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml - ) + if (WITH_PLUGIN_MIGRATION) + execute_process( + OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_mapviewer.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer_capi.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml + ) + else() + execute_process( + OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/navit_genivi_mapviewer.xml + COMMAND ${XSLTPROC} ${CMAKE_CURRENT_SOURCE_DIR}/navit_genivi_mapviewer.xsl ${NAVIT_CMAKE_DIR}/../navit/navit_shipped.xml + ) + endif() endif() add_definitions(-DPLUGIN=1) @@ -75,8 +89,13 @@ if(${YOCTO_CONFIG}) include_directories(${STAGING_INCDIR}/navit) endif() -add_subdirectory(configuration-plugin) - -add_subdirectory(mapviewercontrol-plugin) - -add_subdirectory(session-plugin) +if (WITH_PLUGIN_MIGRATION) + set(FRANCA_DIR "${API_DIR}/franca") + add_subdirectory(configuration-server-plugin) + add_subdirectory(mapviewercontrol-server-plugin) + add_subdirectory(session-server-plugin) +else() + add_subdirectory(configuration-plugin) + add_subdirectory(mapviewercontrol-plugin) + add_subdirectory(session-plugin) +endif() diff --git a/src/navigation/map-viewer/configuration-server-plugin/.gitignore b/src/navigation/map-viewer/configuration-server-plugin/.gitignore new file mode 100644 index 0000000..96372cd --- /dev/null +++ b/src/navigation/map-viewer/configuration-server-plugin/.gitignore @@ -0,0 +1,9 @@ +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +compat_includes +compat_libs +*_adaptor.h +Makefile +.svn +.libs diff --git a/src/navigation/map-viewer/configuration-server-plugin/CMakeLists.txt b/src/navigation/map-viewer/configuration-server-plugin/CMakeLists.txt new file mode 100644 index 0000000..37d7e24 --- /dev/null +++ b/src/navigation/map-viewer/configuration-server-plugin/CMakeLists.txt @@ -0,0 +1,106 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: configuration-server-plugin +# +# Author: Philippe Colliot +# +# Copyright (C) 2015, PCA Peugeot Citroën +# +# 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@ +########################################################################### +project(configuration-server-plugin) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") + + + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) + + +# DBus Path +if(DBUS_LIB_PATH) + message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH}) + set(DBUS_INCLUDE_DIRS ${DBUS_LIB_PATH}/include/dbus-1.0 ${DBUS_LIB_PATH}/lib/dbus-1.0/include) + set(DBUS_LIBDIR ${DBUS_LIB_PATH}/lib) + set(DBUS_LIBRARIES ${DBUS_LIB_PATH}/lib/libdbus-1.so) +else() + message(FATAL_ERROR "Please specify the path to your patched DBus library using -DDBUS_LIB_PATH=yourPath") +endif() + +# Packages +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) + +#pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1.5") +pkg_check_modules(GOBJECT gobject-2.0) +pkg_check_modules(GLIB REQUIRED glib-2.0) + +# Path to the generated files +set(API_VERSION_MAJOR 4) +set(API_VERSION "v${API_VERSION_MAJOR}") +set(PRJ_SRC_GEN_ROOT_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi) #files shared by all the APIs +set(PRJ_SRC_GEN_NAVIGATION_PATH ${PRJ_SRC_GEN_ROOT_PATH}/navigation) #files shared by the navigation APIs +set(PRJ_SRC_GEN_MAPVIEWER_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/mapviewer) #files shared by the mapviewer APIs + +# Source Files +set(FRANCA_FILE "Configuration") +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +FILE(GLOB PRJ_STUB_GEN_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*Types.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Types.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}StubDefault.cpp + ) +FILE(GLOB PRJ_STUB_IMPL_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Stub*.cpp + ) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_ROOT_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_MAPVIEWER_PATH} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} +) + +link_directories( + ${DBUS_LIBDIR} + ${COMMONAPI_LIBDIR} + ${COMMONAPI_DBUS_LIBDIR} + ${GOBJECT_LIBRARY_DIRS} + ${GLIB_LIBRARY_DIRS} +) + +set(LIBRARIES + ${DBUS_LIBRARIES} + ${COMMONAPI_LIBRARIES} + ${COMMONAPI_DBUS_LIBRARIES} + ${GOBJECT_LIBRARIES} + ${GLIB_LIBRARIES} +) + +# Build service +module_add_library(genivi_mapviewer_configuration_server ${PRJ_SRCS}) +target_link_libraries(genivi_mapviewer_configuration_server ${LIBRARIES}) + diff --git a/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx b/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx new file mode 100644 index 0000000..7e34b39 --- /dev/null +++ b/src/navigation/map-viewer/configuration-server-plugin/genivi_mapviewer_configuration.cxx @@ -0,0 +1,240 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* +* \file genivi_mapviewer_configuration.cxx +* +* \brief This file is part of the Navit POC. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), 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/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* +* 2014-03-18, Philippe Colliot, Add JPN language to locale +* +* @licence end@ +*/ +#include <locale.h> +#include <stdlib.h> +#include "config.h" +#define USE_PLUGINS 1 +#include "debug.h" +#include "plugin.h" +#include "event.h" + +#include <CommonAPI/CommonAPI.hpp> +#include <CommonTypes.hpp> +#include <NavigationTypes.hpp> +#include <ConfigurationStubDefault.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +using namespace v4::org::genivi::navigation::mapviewer; +using namespace v4::org::genivi::navigation; +using namespace v4::org::genivi; + +typedef struct { + const char *c3; + const char *c2; +} map32_t; + +static const map32_t language_map[] = { + {"deu","de"}, + {"eng","en"}, + {"fra","fr"}, + {"jpn","jp"}, +}; + +static const map32_t country_map[] = { + {"CHE","CH"}, + {"DEU","DE"}, + {"FRA","FR"}, + {"USA","US"}, + {"JPN","JP"}, +}; + +class MapViewerConfigurationServerStub: public ConfigurationStubDefault +{ + +public: + MapViewerConfigurationServerStub(); + ~MapViewerConfigurationServerStub(); + void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply); + void setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply); + void getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply); + void getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply); + void setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply); + void getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply); + void getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply); + void setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply); + void getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply); + void getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply); + void setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply); + void getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply); + void getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply); + +private: + CommonTypes::Version m_version; + Configuration::UnitsOfMeasurement m_unitsOfMeasurement; + Configuration::UnitsOfMeasurementList m_SupportedUnitsOfMeasurement; + std::vector< NavigationTypes::Locale> m_SupportedLocales; + std::string m_languageCode, m_countryCode, m_scriptCode; + NavigationTypes::TimeFormat m_timeFormat; + std::vector<NavigationTypes::TimeFormat> m_SupportedTimeFormats; + Configuration::CoordinatesFormat m_coordinatesFormat; + std::vector<Configuration::CoordinatesFormat> m_SupportedCoordinatesFormats; +}; + +MapViewerConfigurationServerStub::MapViewerConfigurationServerStub() +{ + Configuration::UnitsOfMeasurementListValue valueList; + + m_version.setVersionMajor(3); + m_version.setVersionMinor(0); + m_version.setVersionMicro(0); + m_version.setDate("21-01-2014"); + + NavigationTypes::Locale en_US { "eng","USA", "Latn" }; + NavigationTypes::Locale fr_FR { "fra","FRA", "Latn" }; + NavigationTypes::Locale de_DE { "deu","DEU", "Latn" }; + NavigationTypes::Locale jp_JP { "jpn","JPN", "Hrkt" }; + + m_SupportedLocales.push_back(en_US); + m_SupportedLocales.push_back(fr_FR); + m_SupportedLocales.push_back(de_DE); + m_SupportedLocales.push_back(jp_JP); + + valueList.push_back(Configuration::UnitsOfMeasurementValue::MILE); + valueList.push_back(Configuration::UnitsOfMeasurementValue::METER); + + m_SupportedUnitsOfMeasurement[Configuration::UnitsOfMeasurementAttribute::LENGTH]=valueList; + + m_SupportedTimeFormats.push_back(NavigationTypes::TimeFormat::TWELVEH); + m_SupportedTimeFormats.push_back(NavigationTypes::TimeFormat::TWENTYFOURH); + + m_SupportedCoordinatesFormats.push_back(Configuration::CoordinatesFormat::DEGREES); + + //default init + m_languageCode = m_SupportedLocales.at(0).getLanguageCode(); + m_countryCode = m_SupportedLocales.at(0).getCountryCode(); + m_scriptCode = m_SupportedLocales.at(0).getScriptCode(); + m_coordinatesFormat = m_SupportedCoordinatesFormats.at(0); + + m_unitsOfMeasurement[Configuration::UnitsOfMeasurementAttribute::LENGTH] = Configuration::UnitsOfMeasurementValue::METER; + + m_timeFormat = m_SupportedTimeFormats.at(0); +} + +MapViewerConfigurationServerStub::~MapViewerConfigurationServerStub() +{ + +} + +void MapViewerConfigurationServerStub::getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply) +{ + _reply(m_version); +} + +void MapViewerConfigurationServerStub::setLocale(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _languageCode, std::string _countryCode, std::string _scriptCode, setLocaleReply_t _reply) +{ + std::vector<Configuration::Settings> changedSettings; + + m_languageCode = _languageCode; + m_countryCode = _countryCode; + m_scriptCode = _scriptCode; + + changedSettings.push_back(Configuration::Settings::LOCALE); + + fireConfigurationChangedEvent(changedSettings); +} + +void MapViewerConfigurationServerStub::getLocale(const std::shared_ptr<CommonAPI::ClientId> _client, getLocaleReply_t _reply) +{ + _reply(m_languageCode,m_countryCode,m_scriptCode); +} + +void MapViewerConfigurationServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply) +{ + _reply(m_SupportedLocales); +} + +void MapViewerConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply) +{ + m_timeFormat = _format; +} + +void MapViewerConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply) +{ + _reply(m_timeFormat); +} + +void MapViewerConfigurationServerStub::getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply) +{ + _reply(m_SupportedTimeFormats); +} + +void MapViewerConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply) +{ + m_coordinatesFormat = _coordinatesFormat; +} + +void MapViewerConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply) +{ + _reply(m_coordinatesFormat); +} + +void MapViewerConfigurationServerStub::getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply) +{ + _reply(m_SupportedCoordinatesFormats); +} + +void MapViewerConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply) +{ + m_unitsOfMeasurement = _unitsOfMeasurementList; +} + +void MapViewerConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply) +{ + _reply(m_unitsOfMeasurement); +} + +void MapViewerConfigurationServerStub::getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply) +{ + _reply(m_SupportedUnitsOfMeasurement); +} + +void +plugin_init(void) +{ + event_request_system("glib","genivi_mapviewerconfiguration"); + + // Common API data init + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); + + const std::string &domain = "local"; + const std::string &instance = "Configuration"; + + std::shared_ptr<MapViewerConfigurationServerStub> myServiceConfiguration = std::make_shared<MapViewerConfigurationServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration); + } +} + 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 fb10f39..58a2967 100644 --- a/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx +++ b/src/navigation/map-viewer/mapviewercontrol-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -432,17 +432,16 @@ class MapViewerControl } } - void - GetMapViewPan(const uint32_t& mapViewInstanceHandle, const DBusCommonAPIEnumeration& valueToReturn, const std::vector< ::DBus::Struct< uint16_t, uint16_t > >& pixelCoordinates) + std::vector< ::DBus::Struct< uint16_t, uint16_t > > + GetMapViewPan(const uint32_t& mapViewInstanceHandle, const int32_t& valueToReturn) { + std::vector< ::DBus::Struct< uint16_t, uint16_t > > pixelCoordinates; ::DBus::Struct< uint16_t, uint16_t > pixel; MapViewerControlObj *obj=handles[mapViewInstanceHandle]; if (!obj) throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); obj->GetMapViewPan(valueToReturn, pixel); //limited to one pixel coordinate -#if 0 /* FIXME */ pixelCoordinates.push_back(pixel); -#endif } void diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/.gitignore b/src/navigation/map-viewer/mapviewercontrol-server-plugin/.gitignore new file mode 100644 index 0000000..93e9f1e --- /dev/null +++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/.gitignore @@ -0,0 +1,10 @@ +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +compat_includes +compat_libs +*_adaptor.h +*_proxy.h +Makefile +.svn +.libs diff --git a/src/navigation/map-viewer/mapviewercontrol-server-plugin/CMakeLists.txt b/src/navigation/map-viewer/mapviewercontrol-server-plugin/CMakeLists.txt new file mode 100644 index 0000000..b8c39e2 --- /dev/null +++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/CMakeLists.txt @@ -0,0 +1,120 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: control-server-plugin +# +# Author: Philippe Colliot +# +# Copyright (C) 2015, PCA Peugeot Citroën +# +# 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@ +########################################################################### +project(mapviewer-control-server-plugin) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") + + + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) + + +# DBus Path +if(DBUS_LIB_PATH) + message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH}) + set(DBUS_INCLUDE_DIRS ${DBUS_LIB_PATH}/include/dbus-1.0 ${DBUS_LIB_PATH}/lib/dbus-1.0/include) + set(DBUS_LIBDIR ${DBUS_LIB_PATH}/lib) + set(DBUS_LIBRARIES ${DBUS_LIB_PATH}/lib/libdbus-1.so) +else() + message(FATAL_ERROR "Please specify the path to your patched DBus library using -DDBUS_LIB_PATH=yourPath") +endif() + +# Packages +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) + + +#pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1.5") +pkg_check_modules(GOBJECT gobject-2.0) +pkg_check_modules(GLIB REQUIRED glib-2.0) +pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) + + +# Path to the generated files +set(API_VERSION_MAJOR 4) +set(API_VERSION "v${API_VERSION_MAJOR}") +set(PRJ_SRC_GEN_ROOT_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi) #files shared by all the APIs +set(PRJ_SRC_GEN_NAVIGATION_PATH ${PRJ_SRC_GEN_ROOT_PATH}/navigation) #files shared by the navigation APIs +set(PRJ_SRC_GEN_MAPVIEWER_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/mapviewer) #files shared by the mapviewer APIs +set(PRJ_SRC_GEN_NAVIGATIONCORE_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/navigationcore) #files shared by the navigationcore APIs + +# Source Files +set(FRANCA_FILE "MapViewerControl") +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +FILE(GLOB PRJ_STUB_GEN_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*Types.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Types.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}StubDefault.cpp + ) +FILE(GLOB PRJ_STUB_IMPL_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Stub*.cpp + ) +# here the source files for the proxies +FILE(GLOB PRJ_PROXY_GEN_SRCS + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/RoutingDBusProxy.cpp + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/MapMatchedPositionDBusProxy.cpp + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/SessionDBusProxy.cpp +) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_PROXY_GEN_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_ROOT_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_MAPVIEWER_PATH} + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${DBUS_CPP_GLIB_INCLUDE_DIRS} +) + +link_directories( + ${DBUS_LIBDIR} + ${COMMONAPI_LIBDIR} + ${COMMONAPI_DBUS_LIBDIR} + ${GOBJECT_LIBRARY_DIRS} + ${GLIB_LIBRARY_DIRS} + ${DBUS_CPP_GLIB_DIRS} +) + +set(LIBRARIES + ${DBUS_LIBRARIES} + ${COMMONAPI_LIBRARIES} + ${COMMONAPI_DBUS_LIBRARIES} + ${GOBJECT_LIBRARIES} + ${GLIB_LIBRARIES} + ${DBUS_CPP_GLIB_LIBRARIES} +) + +# Build service +module_add_library(genivi_mapviewer_mapviewercontrol_server ${PRJ_SRCS}) +target_link_libraries(genivi_mapviewer_mapviewercontrol_server ${LIBRARIES}) + 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 new file mode 100644 index 0000000..24f6534 --- /dev/null +++ b/src/navigation/map-viewer/mapviewercontrol-server-plugin/genivi_mapviewer_mapviewercontrol.cxx @@ -0,0 +1,1928 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* +* \file genivi_mapviewer_mapviewercontrol.cxx +* +* \brief This file is part of the Navit POC. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* \author Tanibata, Nobuhiko <NOBUHIKO_TANIBATA@denso.co.jp> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), 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/. +* +* For further information see http://www.genivi.org/. +* +* @licence end@ +*/ +#include <dbus-c++/glib-integration.h> +#include <math.h> +#include <unistd.h> +#include <stdlib.h> +#if LM +#include <ilm/ilm_client.h> +#include <ilm/ilm_client.h> +#include <ilm/ilm_control.h> +#ifndef FSA_LAYER +#define FSA_LAYER 600 +#define HMI_LAYER 700 +#endif +#endif + +#include "config.h" +#define USE_PLUGINS 1 +#include "debug.h" +#include "plugin.h" +#include "item.h" +#include "config_.h" +#include "navit.h" +#include "event.h" +#include "point.h" +#include "graphics.h" +#include "coord.h" +#include "transform.h" +#include "map.h" +#include "mapset.h" +#include "callback.h" +#include "vehicle.h" +#include "attr.h" +#include "xmlconfig.h" +#include "layout.h" + +#include <CommonAPI/CommonAPI.hpp> +#include <CommonTypes.hpp> +#include <NavigationTypes.hpp> +#include <MapViewerControlStubDefault.hpp> +#include <MapMatchedPositionProxy.hpp> +#include <RoutingProxy.hpp> +#include <navigationcore/SessionProxy.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +using namespace v4::org::genivi::navigation::mapviewer; +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 DisplayedRoute +{ + char *m_filename; + std::vector <struct coord> m_coordinates; + struct mapset *m_mapset; + bool m_shown; + + void AddGeoCoordinateD(double lat, double lon); + bool AddSegment(Routing::RouteSegment map); + void WriteSegment(FILE *out); + public: + uint32_t m_handle; + struct attr m_map; + NavigationTypes::Handle RouteHandle(); + void Show(); + void Hide(); + DisplayedRoute(class MapViewerControlObj *mapviewer, uint8_t RouteSession, NavigationTypes::Handle RouteHandle, struct mapset *mapset); + ~DisplayedRoute(); +}; + +class MapViewerControlObj +{ + public: + struct attr m_navit,m_vehicle,m_graphics; + struct mapset *m_mapset; + uint32_t m_handle; + double m_scrolldirection, m_scrollspeed; + double m_rotationangle, m_rotationangleperframe; + + struct callback *m_postdraw_callback; + struct callback *m_move_callback; + bool m_force_draw; + MapViewerControl::MapPerspective m_perspective; + bool m_follow_car; + MapViewerControlServerStub *m_mapviewercontrol; + std::vector<DisplayedRoute *> m_displayed_routes; + MapMatchedPositionClientProxy *m_mapmatchedposition; + RoutingClientProxy *m_routing; + struct point m_pan; + int m_pan_action; + void MoveMap(void); + void SetFollowCarMode(NavigationTypes::Handle SessionHandle, bool active); + void GetFollowCarMode(bool& active); + void SetCameraHeadingAngle(NavigationTypes::Handle SessionHandle, double angle); + void GetCameraHeadingAngle(double &angle); + void SetCameraTiltAngle(NavigationTypes::Handle SessionHandle, double angle); + void GetCameraTiltAngle(int32_t &angle); + void SetCameraRollAngle(NavigationTypes::Handle SessionHandle, double angle); + void GetCameraRollAngle(int32_t &angle); + void SetCameraDistanceFromTargetPoint(NavigationTypes::Handle SessionHandle, double distance); + void GetCameraDistanceFromTargetPoint(uint32_t &distance); + void SetCameraHeight(NavigationTypes::Handle SessionHandle, double height); + void GetCameraHeight(uint32_t &height); + void SetCameraHeadingTrackUp(NavigationTypes::Handle SessionHandle); + 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 SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta); + void GetMapViewScale(uint8_t& ScaleID, MapViewerControl::MapScaleType &IsMinMax); + void GetMapViewType(MapViewerControl::MapViewType &MapViewType); + void SetMapViewTheme(NavigationTypes::Handle SessionHandle, MapViewerControl::MapTheme mapViewTheme); + void GetMapViewTheme(MapViewerControl::MapTheme &mapViewTheme); + void SetTargetPoint(NavigationTypes::Handle SessionHandle, NavigationTypes::Coordinate3D target); + void GetTargetPoint(NavigationTypes::Coordinate3D &target); + void SetMapViewPan(NavigationTypes::Handle SessionHandle, MapViewerControl::PanAction panningAction, MapViewerControl::Pixel p); + void GetMapViewPan(const int32_t &panningAction, MapViewerControl::Pixel &p); + void SetMapViewRotation(NavigationTypes::Handle SessionHandle, double rotationAngle, double rotationAnglePerFrame); + void GetMapViewRotation(int32_t& rotationAngle, int32_t& rotationAnglePerFrame); + void SetMapViewBoundingBox(NavigationTypes::Handle SessionHandle, const NavigationTypes::Rectangle& boundingBox); + void GetMapViewBoundingBox(NavigationTypes::Rectangle& boundingBox); + void GetDisplayedRoutes(std::vector<MapViewerControl::DisplayedRoute> &displayedRoutes); + void DisplayRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle, bool highlighted); + void HideRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle); + void ConvertPixelCoordsToGeoCoords(NavigationTypes::Handle SessionHandle, const std::vector<MapViewerControl::Pixel> &pixelCoordinates, std::vector<NavigationTypes::Coordinate2D> &GeoCoordinates); + void ConvertGeoCoordsToPixelCoords(NavigationTypes::Handle SessionHandle, const std::vector<NavigationTypes::Coordinate2D> &geoCoordinates, std::vector<MapViewerControl::Pixel> &pixelCoordinates); + MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize); + ~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: + + struct callback *mp_callback; + MapViewerControlObj *m_mapviewerobj; + std::shared_ptr<MapMatchedPositionProxyDefault> myServiceMapMatchedPosition; + + void connectToMapViewer(MapViewerControlObj *obj) + { + m_mapviewerobj=obj; + } + + void connectToVehicle(struct vehicle *v) + { + mp_callback=callback_new_2(callback_cast(positionVehicleNavitUpdate), myServiceMapMatchedPosition, v); + } + + MapMatchedPositionClientProxy(const std::string domain, const std::string instance) + { + myServiceMapMatchedPosition = runtime->buildProxy<MapMatchedPositionProxy>(domain, instance); + + while (!myServiceMapMatchedPosition->isAvailable()) { + usleep(10); + } + } + + void setListeners() + { + myServiceMapMatchedPosition->getPositionUpdateEvent().subscribe([&](const std::vector<MapMatchedPosition::PositionItemKey>& changedValues) { + positionUpdate(changedValues);}); + } + + void positionUpdate(const std::vector<MapMatchedPosition::PositionItemKey>& changedValues) + { + event_add_timeout(0, 0, mp_callback); + } +}; +static void positionVehicleNavitUpdate(std::shared_ptr<MapMatchedPositionProxyDefault> pos, struct vehicle *v) +{ + std::vector< MapMatchedPosition::PositionItemKey > valuesToReturn; + CommonAPI::CallStatus status; + MapMatchedPosition::PositionItemDict _position; + valuesToReturn.push_back(MapMatchedPosition::PositionItemKey::LATITUDE); + valuesToReturn.push_back(MapMatchedPosition::PositionItemKey::LONGITUDE); + valuesToReturn.push_back(MapMatchedPosition::PositionItemKey::SPEED); + valuesToReturn.push_back(MapMatchedPosition::PositionItemKey::HEADING); + + pos->getPosition(valuesToReturn,status,_position); + if (_position.find(MapMatchedPosition::PositionItemKey::SPEED) != _position.end()) { + struct attr position_speed={attr_position_speed}; + double speed; + position_speed.u.numd=&speed; + speed=_position[MapMatchedPosition::PositionItemKey::SPEED].get<double>(); + vehicle_set_attr(v, &position_speed); + } + if (_position.find(MapMatchedPosition::PositionItemKey::HEADING) != _position.end()) { + struct attr position_direction={attr_position_direction}; + double direction; + position_direction.u.numd=&direction; + direction=_position[MapMatchedPosition::PositionItemKey::HEADING].get<double>(); + vehicle_set_attr(v, &position_direction); + } + if (_position.find(MapMatchedPosition::PositionItemKey::LATITUDE) != _position.end() && _position.find(MapMatchedPosition::PositionItemKey::LONGITUDE) != _position.end()) { + struct attr position_coord_geo={attr_position_coord_geo}; + struct coord_geo g; + position_coord_geo.u.coord_geo=&g; + g.lat=_position[MapMatchedPosition::PositionItemKey::LATITUDE].get<double>(); + g.lng=_position[MapMatchedPosition::PositionItemKey::LONGITUDE].get<double>(); + dbg(lvl_debug,"update %f %f\n",g.lat,g.lng); + vehicle_set_attr(v, &position_coord_geo); + } +} + +class RoutingClientProxy +{ + public: + + MapViewerControlObj *m_mapviewerobj; + std::shared_ptr<RoutingProxyDefault> myServiceRouting; + + RoutingClientProxy(const std::string & domain, const std::string & instance) + { + myServiceRouting = runtime->buildProxy<RoutingProxy>(domain, instance); + + while (!myServiceRouting->isAvailable()) { + usleep(10); + } + } + + void connectToMapViewer(MapViewerControlObj *obj) + { + m_mapviewerobj=obj; + } + + void setListeners() + { + myServiceRouting->getRouteCalculationFailedEvent().subscribe([&](const NavigationTypes::Handle& routeHandle, const Routing::CalculationError& errorCode, const Routing::UnfullfilledRoutePreference& unfullfilledPreferences) { + routeCalculationFailed(routeHandle,errorCode,unfullfilledPreferences);}); + myServiceRouting->getRouteCalculationSuccessfulEvent().subscribe([&](const NavigationTypes::Handle& routeHandle, const Routing::UnfullfilledRoutePreference& unfullfilledPreferences) { + routeCalculationSuccessful(routeHandle,unfullfilledPreferences);}); + } + + void routeCalculationFailed(const NavigationTypes::Handle& routeHandle, const Routing::CalculationError& errorCode, 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(); + } + } + } + + 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(); + delete(*it); + *it=new DisplayedRoute(m_mapviewerobj,1,RouteHandle,m_mapviewerobj->m_mapset); + (*it)->Show(); + } + } + } + +}; + +class NavigationCoreSessionClientProxy +{ + public: + std::shared_ptr<SessionProxyDefault> myServiceNavigationCoreSession; + + NavigationCoreSessionClientProxy(const std::string domain, const std::string instance) + { + myServiceNavigationCoreSession = runtime->buildProxy<SessionProxy>(domain, instance); + + while (!myServiceNavigationCoreSession->isAvailable()) { + usleep(10); + } + } +}; + +static MapMatchedPositionClientProxy* mp_mapMatchedPositionClientProxy; +static RoutingClientProxy* mp_routingClientProxy; +static NavigationCoreSessionClientProxy* mp_navigationCoreSessionClientProxy; + +class MapViewerControlServerStub : public MapViewerControlStubDefault +{ + public: +#define MAX_SESSION_HANDLE 256 + + MapViewerControlServerStub() + { + m_version.setVersionMajor(3); + m_version.setVersionMinor(0); + m_version.setVersionMicro(0); + m_version.setDate("21-01-2014"); + } + + /** + * description: getVersion = This method returns the API version implemented by the server + * application + */ + void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply){ + _reply(m_version); + } + + /** + * description: createMapViewInstance = This method creates a new map instance + */ + void createMapViewInstance(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, MapViewerControl::Dimension _mapViewSize, MapViewerControl::MapViewType _mapViewType, createMapViewInstanceReply_t _reply) + { + dbg(lvl_debug,"enter\n"); + if (_mapViewType != MapViewerControl::MapViewType::MAIN_MAP) + throw DBus::ErrorInvalidArgs("Unsupported mapViewType"); + NavigationTypes::Handle _mapViewInstanceHandle=1; + while (mp_handles[_mapViewInstanceHandle]) { + _mapViewInstanceHandle++; + if (_mapViewInstanceHandle == MAX_SESSION_HANDLE) + throw DBus::ErrorLimitsExceeded("Out of mapviewinstance handles"); + } + mp_handles[_mapViewInstanceHandle]=new MapViewerControlObj(this, _mapViewInstanceHandle, _mapViewSize); + _reply(_mapViewInstanceHandle); + } + + /** + * description: releaseMapViewInstance = This method releases (i.e. destroys) a given map + * instance. Only invisible map instances can be released + */ + void releaseMapViewInstance(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, releaseMapViewInstanceReply_t _reply) + { + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + delete(obj); + mp_handles[_mapViewInstanceHandle]=NULL; + _reply(); + } + + /** + * description: getMapViewType = This method returns the map type of a map instance as it was + * set using CreateMapViewInstance + */ + void getMapViewType(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewTypeReply_t _reply){ + MapViewerControl::MapViewType _mapViewType; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewType(_mapViewType); + _reply(_mapViewType); + + } + + /** + * description: getSupportedMapViewTypes = This method retrieves the supported map view types + */ + void getSupportedMapViewTypes(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedMapViewTypesReply_t _reply){ + std::vector<MapViewerControl::MapViewType> _mapViewTypeList; + _mapViewTypeList.push_back(MapViewerControl::MapViewType::MAIN_MAP); + _reply(_mapViewTypeList); + } + + /** + * description: setTargetPoint = This method sets the position of the point the camera is + * always aimed at + */ + void setTargetPoint(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Coordinate3D _targetPoint, setTargetPointReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetTargetPoint(_sessionHandle, _targetPoint); + _reply(); + } + + /** + * description: getTargetPoint = This method retrieves the target point position + */ + void getTargetPoint(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getTargetPointReply_t _reply){ + NavigationTypes::Coordinate3D _targetPoint; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetTargetPoint(_targetPoint); + _reply(_targetPoint); + + } + + /** + * description: setFollowCarMode = This method sets the FollowCar mode + */ + void setFollowCarMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, bool _followCarMode, setFollowCarModeReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetFollowCarMode(_sessionHandle, _followCarMode); + _reply(); + } + + /** + * description: getFollowCarMode = This method returns the current FollowCar-mode + */ + void getFollowCarMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getFollowCarModeReply_t _reply){ + bool _followCarMode; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetFollowCarMode(_followCarMode); + _reply(_followCarMode); + + } + + /** + * description: setCameraPosition = This method sets the coordinates of the point at which the + * camera must be positioned + Note: the camera heading will be automatically set + * in such a way, that the camera is aimed at the view point + */ + void setCameraPosition(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Coordinate3D _position, setCameraPositionReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getCameraPosition = This method returns the coordinates of the point at which + * the camera is positioned + */ + void getCameraPosition(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraPositionReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setCameraHeadingAngle = This method sets the map view heading angle + Note: the + * camera position will be automatically set in such a way, that it looks at the + * currently selected target point + */ + void setCameraHeadingAngle(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, int32_t _heading, setCameraHeadingAngleReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraHeadingAngle(_sessionHandle, _heading); + _reply(); + } + + /** + * description: setCameraHeadingToTarget = This method sets the camera heading in such a way, + * that the camera always looks at a given target + */ + void setCameraHeadingToTarget(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Coordinate2D _target, setCameraHeadingToTargetReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setCameraHeadingTrackUp = This method sets the camera heading in such a way, + * that the camera always looks in the direction in which the car is moving + */ + void setCameraHeadingTrackUp(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, setCameraHeadingTrackUpReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraHeadingTrackUp(_sessionHandle); + _reply(); + } + + /** + * description: getCameraHeading = This method returns the current camera heading + */ + void getCameraHeading(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraHeadingReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setCameraTiltAngle = This method sets the camera tilt angle + */ + void setCameraTiltAngle(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, int32_t _tilt, setCameraTiltAngleReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraTiltAngle(_sessionHandle, _tilt); + _reply(); + } + + /** + * description: getCameraTiltAngle = This method returns the camera tilt angle + */ + void getCameraTiltAngle(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraTiltAngleReply_t _reply){ + int32_t _tilt; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetCameraTiltAngle(_tilt); + _reply(_tilt); + + } + + /** + * description: setCameraRollAngle = This method sets the camera roll angle + */ + void setCameraRollAngle(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, int32_t _roll, setCameraRollAngleReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraRollAngle(_sessionHandle, _roll); + _reply(); + } + + /** + * description: getCameraRollAngle = This method returns the camera roll angle + */ + void getCameraRollAngle(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraRollAngleReply_t _reply){ + int32_t _roll; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetCameraRollAngle(_roll); + _reply(_roll); + + } + + /** + * description: setCameraDistanceFromTargetPoint = This method sets the mode and the camera + * distance from the target point + */ + void setCameraDistanceFromTargetPoint(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint32_t _distance, setCameraDistanceFromTargetPointReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraDistanceFromTargetPoint(_sessionHandle, _distance); + _reply(); + } + + /** + * description: getCameraDistanceFromTargetPoint = This method gets the mode and the camera + * distance from the target point + */ + void getCameraDistanceFromTargetPoint(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraDistanceFromTargetPointReply_t _reply){ + uint32_t _distance; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetCameraDistanceFromTargetPoint(_distance); + _reply(_distance); + } + + /** + * description: setMapViewScaleMode = This method sets the scaling mode. + */ + void setMapViewScaleMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::MapScaleMode _scaleMode, setMapViewScaleModeReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewScaleMode = This method gets the scaling mode. + */ + void getMapViewScaleMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewScaleModeReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getSupportedMapViewScaleModes = This method gets the supported scaling modes. + */ + void getSupportedMapViewScaleModes(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getSupportedMapViewScaleModesReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: addMapViewScaleChangedListener = This method adds a listener which is notified + * when map view scale changes. + */ + void addMapViewScaleChangedListener(const std::shared_ptr<CommonAPI::ClientId> _client, addMapViewScaleChangedListenerReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: removeMapViewScaleChangedListener = This method removes a listener which is + * notified when map view scale changes. + */ + void removeMapViewScaleChangedListener(const std::shared_ptr<CommonAPI::ClientId> _client, removeMapViewScaleChangedListenerReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setCameraHeight = This method sets the camera height + */ + void setCameraHeight(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, uint32_t _height, setCameraHeightReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetCameraHeight(_sessionHandle, _height); + _reply(); + } + + /** + * description: getCameraHeight = This method gets the camera height + */ + void getCameraHeight(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getCameraHeightReply_t _reply){ + uint32_t _height; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetCameraHeight(_height); + _reply(_height); + } + + /** + * description: setMapViewPerspective = This method sets the map perspective + */ + void setMapViewPerspective(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::MapPerspective _perspective, setMapViewPerspectiveReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewPerspective(_sessionHandle, _perspective); + _reply(); + } + + /** + * description: getMapViewPerspective = This method returns the current map perspective + */ + void getMapViewPerspective(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewPerspectiveReply_t _reply){ + MapViewerControl::MapPerspective _perspective; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewPerspective(_perspective); + _reply(_perspective); + } + + /** + * description: getSupportedMapViewPerspectives = This method retrieves the supported mapview + * perspectives + */ + void getSupportedMapViewPerspectives(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedMapViewPerspectivesReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setMapViewObjectVisibility = This method specifies the type of objects to show + * on the map. + */ + void setMapViewObjectVisibility(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::MapObjectVisibility _objectVisibilityList, setMapViewObjectVisibilityReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewObjectVisibility = This method gets the type of objects shown on the + * map. + */ + void getMapViewObjectVisibility(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewObjectVisibilityReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getSupportedMapViewObjectVisibilities = This method gets the supported object + * visibilities. + */ + void getSupportedMapViewObjectVisibilities(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getSupportedMapViewObjectVisibilitiesReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getScaleList = This method returns a list of supported map scales + */ + void getScaleList(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getScaleListReply_t _reply){ + std::vector<MapViewerControl::MapScale> _scaleList; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetScaleList(_scaleList); + _reply(_scaleList); + } + + /** + * description: setMapViewScale = This method sets the map scale by specifying a ScaleID + */ + void setMapViewScale(const std::shared_ptr<CommonAPI::ClientId> _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"); + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewScale(_sessionHandle, _scaleID); + _reply(); + } + + /** + * description: setMapViewScaleByDelta = This method sets the map scale by specifying a delta + * value with respect to the currently set ScaleID + */ + void setMapViewScaleByDelta(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, int16_t _scaleDelta, setMapViewScaleByDeltaReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewScaleByDelta(_sessionHandle, _scaleDelta); + _reply(); + } + + /** + * description: setMapViewScaleByMetersPerPixel = This method sets the map scale by specifying + * the number of meters that a pixel represents + */ + void setMapViewScaleByMetersPerPixel(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, double _metersPerPixel, setMapViewScaleByMetersPerPixelReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewScale = This method returns the currently used map scale + */ + void getMapViewScale(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewScaleReply_t _reply){ + uint8_t _scaleID; + MapViewerControl::MapScaleType _isMinMax; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewScale(_scaleID, _isMinMax); + _reply(_scaleID,_isMinMax); + } + + /** + * description: setMapViewBoundingBox = This method sets the map bounding box + */ + void setMapViewBoundingBox(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Rectangle _boundingBox, setMapViewBoundingBoxReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewBoundingBox(_sessionHandle, _boundingBox); + _reply(); + } + + /** + * description: getMapViewBoundingBox = This method returns the bounding box of a given map + * instance + */ + void getMapViewBoundingBox(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewBoundingBoxReply_t _reply){ + NavigationTypes::Rectangle _boundingBox; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewBoundingBox(_boundingBox); + _reply(_boundingBox); + } + + /** + * description: setMapViewSaveArea = This methods defines the area that the HMI guarantees not + * to cover with other windows or user interface elements + */ + void setMapViewSaveArea(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::MapViewArea _saveArea, setMapViewSaveAreaReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewSaveArea = This methods defines the area that the HMI guarantees not + * to cover with other windows or user interface elements + */ + void getMapViewSaveArea(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewSaveAreaReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setMapViewPan = This method pans a given map instance + */ + void setMapViewPan(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::PanAction _panningAction, std::vector<MapViewerControl::Pixel> _pixelCoordinates, setMapViewPanReply_t _reply){ + MapViewerControl::Pixel pixel; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + if (_pixelCoordinates.size()) + { + pixel = _pixelCoordinates.at(0); + obj->SetMapViewPan(_sessionHandle, _panningAction, pixel); + } + _reply(); + } + + /** + * description: getMapViewPan + */ + void getMapViewPan(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::PanAction _valueToReturn, getMapViewPanReply_t _reply){ + MapViewerControl::Pixel pixel; + std::vector<MapViewerControl::Pixel> _pixelCoordinates; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewPan(_valueToReturn, pixel); //limited to one pixel coordinate + _pixelCoordinates.push_back(pixel); + _reply(_pixelCoordinates); + } + + /** + * description: setMapViewRotation = This method rotates the map + */ + void setMapViewRotation(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, int32_t _rotationAngle, int32_t _rotationAnglePerSecond, setMapViewRotationReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewRotation(_sessionHandle, _rotationAngle, _rotationAnglePerSecond); + _reply(); + } + + /** + * description: getMapViewRotation = This method is particularly interesting for debugging + * purposes + */ + void getMapViewRotation(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewRotationReply_t _reply){ + int32_t _rotationAngle; + int32_t _rotationAnglePerFrame; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewRotation(_rotationAngle, _rotationAnglePerFrame); + _reply(_rotationAngle,_rotationAnglePerFrame); + } + + /** + * description: setMapViewVisibilityMode = This method sets the current visibility mode + */ + void setMapViewVisibilityMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::Visibility _visibilityMode, setMapViewVisibilityModeReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewVisibilityMode = This method returns the current visibility mode + */ + void getMapViewVisibilityMode(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewVisibilityModeReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getSupportedMapViewVisibilityModes = This method retrieves the supported + * mapview visibility modes + */ + void getSupportedMapViewVisibilityModes(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedMapViewVisibilityModesReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setMapViewPerformanceLevel = This method sets the perfomance level of a given + * map instance + */ + void setMapViewPerformanceLevel(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::Level _performanceLevel, setMapViewPerformanceLevelReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getMapViewPerformanceLevel = This method returns the perfomance level of a + * given map instance + */ + void getMapViewPerformanceLevel(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewPerformanceLevelReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getSupportedMapViewPerformanceLevels = This method retrieves the supported + * perfomance levels + */ + void getSupportedMapViewPerformanceLevels(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedMapViewPerformanceLevelsReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: displayRoute = This method visualizes one of the calculated routes + */ + void displayRoute(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _routeHandle, bool _highlighted, displayRouteReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->DisplayRoute(_sessionHandle, _routeHandle, _highlighted); + _reply(); + } + + /** + * description: hideRoute = This method hides one of the visible routes + */ + void hideRoute(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _routeHandle, hideRouteReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->HideRoute(_sessionHandle, _routeHandle); + _reply(); + } + + /** + * description: getDisplayedRoutes = This method returns a list of displayed routes + */ + void getDisplayedRoutes(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getDisplayedRoutesReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + std::vector<MapViewerControl::DisplayedRoute> _displayedRoutes; + obj->GetDisplayedRoutes(_displayedRoutes); + _reply(_displayedRoutes); + } + + /** + * description: getPoiCategoriesVisible = Get the set of POI categories displayed on the map. + */ + void getPoiCategoriesVisible(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getPoiCategoriesVisibleReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setPoiCategoriesVisible = Add POI categories to the set of POI categories + * displayed on the map. + Any specified category that until now + * was displayed with scale limits is now displayed without limits. + */ + void setPoiCategoriesVisible(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector< ::v4::org::genivi::CommonTypes::CategoryID> _poiCategoryIds, setPoiCategoriesVisibleReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setPoiCategoriesVisible = Add POI categories to the set of POI categories + * displayed on the map, where the POI's are only displayed in a specific range + * of scales. + Any specified category that until now was + * displayed without scale limits is now displayed with limits. + */ + void setPoiCategoriesVisibleWithinLimits(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector< ::v4::org::genivi::CommonTypes::CategoryID> _poiCategoryIds, uint8_t _minScaleID, uint8_t _maxScaleID, setPoiCategoriesVisibleWithinLimitsReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setPoiCategoriesNotVisible = Remove POI categories from the set of POI + * categories displayed on the map. + */ + void setPoiCategoriesNotVisible(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector< ::v4::org::genivi::CommonTypes::CategoryID> _poiCategoryIds, setPoiCategoriesNotVisibleReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setTrafficIncidentsVisibility = Set the visibility of Traffic Incidents on the + * map. + */ + void setTrafficIncidentsVisibility(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, bool _visible, setTrafficIncidentsVisibilityReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: setMapViewTheme = This method configures the theme of a given map view instance + */ + void setMapViewTheme(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::MapTheme _mapViewTheme, setMapViewThemeReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->SetMapViewTheme(_sessionHandle, _mapViewTheme); + _reply(); + } + + /** + * description: getMapViewTheme = This method returns the current theme of a given map view + * instance + */ + void getMapViewTheme(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getMapViewThemeReply_t _reply){ + MapViewerControl::MapTheme _mapViewTheme; + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + obj->GetMapViewTheme(_mapViewTheme); + _reply(_mapViewTheme); + + } + + /** + * description: getSupportedMapViewThemes = This method retrieves the supported mapview themes + */ + void getSupportedMapViewThemes(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedMapViewThemesReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: convertPixelCoordsToGeoCoords = This method converts pixel coordinates to + * geographical coordinates + */ + void convertPixelCoordsToGeoCoords(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector<MapViewerControl::Pixel> _pixelCoordinates, convertPixelCoordsToGeoCoordsReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + std::vector< ::v4::org::genivi::navigation::NavigationTypes::Coordinate2D> _geoCoordinates; + obj->ConvertPixelCoordsToGeoCoords(_sessionHandle, _pixelCoordinates, _geoCoordinates); + _reply(_geoCoordinates); + } + + /** + * description: convertGeoCoordsToPixelCoords = This method converts geographical coordinates + * into pixel coordinates + */ + void convertGeoCoordsToPixelCoords(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector< ::v4::org::genivi::navigation::NavigationTypes::Coordinate2D> _geoCoordinates, convertGeoCoordsToPixelCoordsReply_t _reply){ + MapViewerControlObj *obj=mp_handles[_mapViewInstanceHandle]; + if (!obj) + throw DBus::ErrorInvalidArgs("Invalid mapviewinstance handle"); + std::vector<MapViewerControl::Pixel> _pixelCoordinates; + obj->ConvertGeoCoordsToPixelCoords(_sessionHandle, _geoCoordinates, _pixelCoordinates); + _reply(_pixelCoordinates); + } + + /** + * description: displayCustomElements = This method visualizes a set of custom elements on the + * map + */ + void displayCustomElements(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector<MapViewerControl::CustomElement> _customElements, displayCustomElementsReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: hideCustomElements = This method hides a set of custom elements which were + * visualized by DisplayCustomElements + */ + void hideCustomElements(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, std::vector< ::v4::org::genivi::navigation::NavigationTypes::Handle> _customElementhandles, hideCustomElementsReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: getDisplayedCustomElements = This method retrieves the visualized custom + * elements on the map + */ + void getDisplayedCustomElements(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, getDisplayedCustomElementsReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + /** + * description: selectElementsOnMap = This method selects elements on the map view which are at + * the position specified by user input + */ + void selectElementsOnMap(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _mapViewInstanceHandle, MapViewerControl::Pixel _pixelCoordinate, std::vector<MapViewerControl::SelectableMapType> _selectableTypes, uint16_t _maxNumberOfSelectedElements, selectElementsOnMapReply_t _reply){ + throw DBus::ErrorNotSupported("Not yet supported"); + } + + +private: + CommonTypes::Version m_version; + +}; + +void +MapViewerControlObj::SetMapViewPerspective(NavigationTypes::Handle SessionHandle, MapViewerControl::MapPerspective MapViewPerspectiveMode) +{ + if (m_perspective != MapViewPerspectiveMode) { + m_perspective=MapViewPerspectiveMode; + struct transformation *trans=navit_get_trans(m_navit.u.navit); + switch (m_perspective) { + case MapViewerControl::MapPerspective::PERSPECTIVE_2D: + transform_set_pitch(trans, 0); + break; + case MapViewerControl::MapPerspective::PERSPECTIVE_3D: + transform_set_pitch(trans, 40); + break; + } + navit_draw_async(m_navit.u.navit, 1); + } +} + +void +MapViewerControlObj::GetMapViewPerspective(MapViewerControl::MapPerspective& MapViewPerspectiveMode) +{ + MapViewPerspectiveMode=m_perspective; +} + +void +MapViewerControlObj::GetScaleList(std::vector<MapViewerControl::MapScale> &ScalesList) +{ + throw DBus::ErrorNotSupported("Not yet supported"); +} + +void +MapViewerControlObj::SetMapViewScale(NavigationTypes::Handle SessionHandle, uint32_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); +} + +void +MapViewerControlObj::SetMapViewScaleByDelta(NavigationTypes::Handle SessionHandle, int16_t ScaleDelta) +{ + if (!ScaleDelta) + throw DBus::ErrorInvalidArgs("ScaleDelta must not be 0"); + if (ScaleDelta < 0) + navit_zoom_out(m_navit.u.navit,1 << (-ScaleDelta),NULL); + else if (ScaleDelta > 0) + navit_zoom_in(m_navit.u.navit,1 << ScaleDelta,NULL); +} + +void +MapViewerControlObj::GetMapViewScale(uint8_t& ScaleID, MapViewerControl::MapScaleType &IsMinMax) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + long scale=transform_get_scale(trans); + if (scale >= 2097152) + IsMinMax=MapViewerControl::MapScaleType::MAX; + else { + if (scale <= 1) { + IsMinMax=MapViewerControl::MapScaleType::MIN; + } else { + IsMinMax=MapViewerControl::MapScaleType::MID; + ScaleID=0; + while (scale > 1) { //strange code here, to be investigated ? + scale >>=1; + ScaleID++; + } + } + } + +} + +void +MapViewerControlObj::GetMapViewType(MapViewerControl::MapViewType& MapViewType) +{ + MapViewType=MapViewerControl::MapViewType::MAIN_MAP; +} + +void +MapViewerControlObj::SetMapViewTheme(NavigationTypes::Handle SessionHandle, MapViewerControl::MapTheme mapViewTheme) +{ + struct attr layout,name; + struct attr_iter *iter; + const char *layout_name=NULL; + dbg(lvl_debug,"Theme %d\n",mapViewTheme); + switch (mapViewTheme) { + case MapViewerControl::MapTheme::THEME_1: + layout_name="Car"; + break; + case MapViewerControl::MapTheme::THEME_2: + layout_name="Car-dark"; + break; + default: + dbg(lvl_debug,"Invalid mapViewTheme\n"); + throw DBus::ErrorInvalidArgs("Invalid mapViewTheme"); + } + iter=navit_attr_iter_new(); + while (navit_get_attr(m_navit.u.navit, attr_layout, &layout, iter)) { + dbg(lvl_debug,"layout\n"); + if (!layout_get_attr(layout.u.layout, attr_name, &name, NULL)) { + navit_attr_iter_destroy(iter); + throw DBus::ErrorFailed("Internal error: Failed to get layout name"); + } + dbg(lvl_debug,"%s vs %s\n",name.u.str,layout_name); + if (!strcmp(name.u.str,layout_name)) { + navit_set_attr(m_navit.u.navit, &layout); + navit_attr_iter_destroy(iter); + return; + } + } + navit_attr_iter_destroy(iter); + throw DBus::ErrorFailed("Internal error: Failed to get map layout"); +} + +void +MapViewerControlObj::GetMapViewTheme(MapViewerControl::MapTheme& mapViewTheme) +{ + struct attr layout,name; + if (!navit_get_attr(m_navit.u.navit, attr_layout, &layout, NULL)) + throw DBus::ErrorFailed("Internal error: Failed to get map layout"); + if (!layout_get_attr(layout.u.layout, attr_name, &name, NULL)) + throw DBus::ErrorFailed("Internal error: Failed to get layout name"); + dbg(lvl_debug,"name %s\n",name.u.str); + if (!strcmp(name.u.str,"Car-dark")) + mapViewTheme=MapViewerControl::MapTheme::THEME_2; + else + mapViewTheme=MapViewerControl::MapTheme::THEME_1; +} + +void +MapViewerControlObj::SetFollowCarMode(NavigationTypes::Handle SessionHandle, bool active) +{ + struct attr follow={attr_follow}; + m_follow_car=active; + if (active) + follow.u.num=1; + else + follow.u.num=100000; + dbg(lvl_debug,"setting follow to %d\n",(int) follow.u.num); + navit_set_attr(m_navit.u.navit,&follow); + vehicle_set_attr(m_vehicle.u.vehicle,&follow); + follow.type=attr_timeout; + navit_set_attr(m_navit.u.navit,&follow); +} + +void +MapViewerControlObj::GetFollowCarMode(bool& active) +{ + active=m_follow_car; +} + +void +MapViewerControlObj::SetCameraHeadingAngle(NavigationTypes::Handle SessionHandle, double angle) +{ + struct attr orientation={attr_orientation}; + orientation.u.num=angle; + navit_set_attr(m_navit.u.navit, &orientation); + navit_draw_async(m_navit.u.navit, 1); +} + +void +MapViewerControlObj::GetCameraHeadingAngle(double &angle) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + angle=transform_get_yaw(trans); +} + +void +MapViewerControlObj::SetCameraTiltAngle(NavigationTypes::Handle SessionHandle, double angle) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + transform_set_pitch(trans, angle); + navit_draw(m_navit.u.navit); + +} + +void +MapViewerControlObj::GetCameraTiltAngle(int32_t &angle) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + angle=transform_get_pitch(trans); +} + +void +MapViewerControlObj::SetCameraRollAngle(NavigationTypes::Handle SessionHandle, double angle) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + transform_set_roll(trans, angle); + navit_draw(m_navit.u.navit); +} + +void +MapViewerControlObj::GetCameraRollAngle(int32_t &angle) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + angle=transform_get_roll(trans); +} + +void +MapViewerControlObj::SetCameraDistanceFromTargetPoint(NavigationTypes::Handle SessionHandle, double distance) +{ + struct transformation *t=navit_get_trans(m_navit.u.navit); + transform_set_distance(t, distance); + dbg(lvl_debug,"distance %f\n",distance); + transform_set_scales(t, 100, 100, 100 << 8); + navit_draw(m_navit.u.navit); +} + +void +MapViewerControlObj::GetCameraDistanceFromTargetPoint(uint32_t &distance) +{ + struct transformation *t=navit_get_trans(m_navit.u.navit); + distance=transform_get_distance(t); +} + +void +MapViewerControlObj::SetCameraHeight(NavigationTypes::Handle SessionHandle, double height) +{ + struct transformation *t=navit_get_trans(m_navit.u.navit); + double distance=transform_get_distance(t); + if (height > distance || height < -distance) + throw DBus::ErrorInvalidArgs("Height > Distance"); + double angle=acos(height/distance)*180.0/M_PI; + transform_set_pitch(t, angle); + dbg(lvl_debug,"distance %f angle %f height %f\n",distance,angle,height); + navit_draw(m_navit.u.navit); +} + +void +MapViewerControlObj::GetCameraHeight(uint32_t &height) +{ + struct transformation *t=navit_get_trans(m_navit.u.navit); + double distance=transform_get_distance(t); + double angle=transform_get_pitch(t); + height=cos(angle*M_PI/180)*distance; + dbg(lvl_debug,"distance %f angle %f height %f\n",distance,angle,height); +} + +void +MapViewerControlObj::SetCameraHeadingTrackUp(NavigationTypes::Handle SessionHandle) +{ + struct attr orientation={attr_orientation}; + orientation.u.num=-1; + navit_set_attr(m_navit.u.navit, &orientation); + navit_draw_async(m_navit.u.navit, 1); +} + +void +MapViewerControlObj::SetTargetPoint(NavigationTypes::Handle SessionHandle, NavigationTypes::Coordinate3D target) +{ + struct coord_geo g; + struct attr center={attr_center}; + center.u.coord_geo=&g; + g.lat=target.getLatitude(); + g.lng=target.getLongitude(); + navit_set_attr(m_navit.u.navit, ¢er); + navit_draw_async(m_navit.u.navit, 1); +} + +void +MapViewerControlObj::GetTargetPoint(NavigationTypes::Coordinate3D&target) +{ + struct attr center; + if (!navit_get_attr(m_navit.u.navit, attr_center, ¢er, NULL) || !center.u.coord_geo) + throw DBus::ErrorFailed("Internal error: Failed to get center attribute"); + target.setLatitude(center.u.coord_geo->lat); + target.setLongitude(center.u.coord_geo->lng); + target.setAltitude(0); +} + +void +MapViewerControlObj::MoveMap(void) +{ + if (m_scrollspeed || m_rotationangleperframe || m_force_draw) { + int w,h; + double refresh_time=0.3; // Time needed to redraw map + double r=m_scrollspeed*refresh_time; + struct point p; + struct transformation *t=navit_get_trans(m_navit.u.navit); + if (m_rotationangleperframe) { + int yaw=transform_get_yaw(t); + int delta=((int)(m_rotationangle+0.5)-yaw)%360; + if (delta > 180) + delta-=180; + if (delta < -180) + delta+=180; + if (delta < 0 && delta < -m_rotationangleperframe) + delta=-m_rotationangleperframe; + if (delta > 0 && delta > m_rotationangleperframe) + delta=m_rotationangleperframe; + if (delta) + transform_set_yaw(t, yaw+delta); + else + m_rotationangleperframe=0; + } + transform_get_size(t, &w, &h); + p.x=w/2+sin(m_scrolldirection*M_PI/180)*r; + p.y=h/2-cos(m_scrolldirection*M_PI/180)*r; + navit_set_center_screen(m_navit.u.navit, &p, 1); + m_force_draw=false; + } +} + +static void +MapViewerControlObj_MoveMap(class MapViewerControlObj *obj) +{ + obj->MoveMap(); +} + +static void +MapViewerControlObj_PostDraw(class MapViewerControlObj *obj) +{ + event_add_timeout(0, 0, obj->m_move_callback); +} + +void +MapViewerControlObj::SetMapViewPan(NavigationTypes::Handle SessionHandle, MapViewerControl::PanAction panningAction, MapViewerControl::Pixel p) +{ + struct transformation *tr; + struct coord co,cn,c,*cp; + struct point pan; + SetFollowCarMode(SessionHandle, false); + dbg(lvl_debug,"enter %d\n",panningAction); + switch(panningAction) { + case MapViewerControl::PanAction::PAN_START: + break; + case MapViewerControl::PanAction::PAN_END: + tr=navit_get_trans(m_navit.u.navit); + transform_reverse(tr, &m_pan, &co); + pan.x=p.getX(); + pan.y=p.getY(); + transform_reverse(tr, &pan, &cn); + dbg(lvl_debug,"%d,%d - %d,%d\n",m_pan.x,m_pan.y,pan.x,pan.y); + cp=transform_get_center(tr); + c.x=cp->x+co.x-cn.x; + c.y=cp->y+co.y-cn.y; + transform_set_center(tr, &c); + navit_draw(m_navit.u.navit); + default: + return; + } + m_pan_action=panningAction; + m_pan.x=p.getX(); + m_pan.y=p.getY(); +} + +void +MapViewerControlObj::GetMapViewPan(const int32_t& panningAction, MapViewerControl::Pixel& p) +{ + p.setX(m_pan.x); + p.setY(m_pan.y); +} + +void +MapViewerControlObj::SetMapViewRotation(NavigationTypes::Handle SessionHandle, double rotationAngle, double rotationAnglePerFrame) +{ + m_rotationangle=rotationAngle; + m_rotationangleperframe=rotationAnglePerFrame; + SetFollowCarMode(SessionHandle, false); + MoveMap(); + +} + +void +MapViewerControlObj::GetMapViewRotation(int32_t& rotationAngle, int32_t& rotationAnglePerFrame) +{ + rotationAngle=m_rotationangle; + rotationAnglePerFrame=m_rotationangleperframe; +} + +void +MapViewerControlObj::SetMapViewBoundingBox(NavigationTypes::Handle SessionHandle, const NavigationTypes::Rectangle& boundingBox) +{ + 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); + g.lat=boundingBox.getBottomRight().getLatitude(); + g.lng=boundingBox.getBottomRight().getLatitude(); + 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); +} + +void +MapViewerControlObj::GetMapViewBoundingBox(NavigationTypes::Rectangle& boundingBox) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + struct point p; + struct coord c; + struct coord_geo g; + int w,h; + NavigationTypes::Coordinate2D coordinate; + + transform_get_size(trans, &w, &h); + p.x=0; + p.y=0; + transform_reverse(trans, &p, &c); + transform_to_geo(projection_mg, &c, &g); + coordinate.setLatitude(g.lat); + coordinate.setLongitude(g.lng); + boundingBox.setTopLeft(coordinate); + p.x=w; + p.y=h; + transform_reverse(trans, &p, &c); + transform_to_geo(projection_mg, &c, &g); + coordinate.setLatitude(g.lat); + coordinate.setLongitude(g.lng); + boundingBox.setBottomRight(coordinate); +} + +void +MapViewerControlObj::GetDisplayedRoutes(std::vector<MapViewerControl::DisplayedRoute>& displayedRoutes) +{ + int i; + for (i = 0 ; i < m_displayed_routes.size(); i++) { + MapViewerControl::DisplayedRoute route; + route.setRouteHandle(m_displayed_routes[i]->RouteHandle()); + route.setHighlighted(false); + displayedRoutes.push_back(route); + } +} + +void +MapViewerControlObj::DisplayRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle, bool highlighted) +{ + HideRoute(SessionHandle, RouteHandle); + DisplayedRoute *route=new DisplayedRoute(this,m_navigationcore_session,RouteHandle,m_mapset); + route->Show(); + m_displayed_routes.push_back(route); + m_force_draw=true; + event_add_timeout(0, 0, m_move_callback); +} + +void +MapViewerControlObj::HideRoute(NavigationTypes::Handle SessionHandle, NavigationTypes::Handle RouteHandle) +{ + std::vector<DisplayedRoute *>::iterator it; + + for (it=m_displayed_routes.begin() ; it < m_displayed_routes.end(); it++ ) { + if (*it && (*it)->m_handle == RouteHandle) { + (*it)->Hide(); + m_displayed_routes.erase(it); + delete(*it); + m_force_draw=true; + event_add_timeout(0, 0, m_move_callback); + } + } + dbg(lvl_debug,"Route not displayed\n"); +} + +void +MapViewerControlObj::ConvertPixelCoordsToGeoCoords(NavigationTypes::Handle SessionHandle, const std::vector< MapViewerControl::Pixel >& pixelCoordinates, std::vector< NavigationTypes::Coordinate2D >& geoCoordinates) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + struct coord c; + struct point p; + struct coord_geo g; + std::vector< MapViewerControl::Pixel >::const_iterator it; + for (it=pixelCoordinates.begin(); it < pixelCoordinates.end(); it++) { + NavigationTypes::Coordinate2D geoCoordinate; + p.x=it->getX(); + p.y=it->getY(); + transform_reverse(trans, &p, &c); + transform_to_geo(projection_mg, &c, &g); + geoCoordinate.setLatitude(g.lat); + geoCoordinate.setLongitude(g.lng); + geoCoordinates.push_back(geoCoordinate); + } + +} + +void +MapViewerControlObj::ConvertGeoCoordsToPixelCoords(NavigationTypes::Handle SessionHandle, const std::vector< NavigationTypes::Coordinate2D >& geoCoordinates, std::vector< MapViewerControl::Pixel >& pixelCoordinates) +{ + struct transformation *trans=navit_get_trans(m_navit.u.navit); + struct coord c; + struct point p; + struct coord_geo g; + std::vector< NavigationTypes::Coordinate2D >::const_iterator it; + for (it=geoCoordinates.begin(); it < geoCoordinates.end(); it++) { + MapViewerControl::Pixel pixelCoordinate; + g.lat=it->getLatitude(); + g.lng=it->getLongitude(); + transform_from_geo(projection_mg, &g, &c); + transform(trans, projection_mg, &c, &p, 1, 0, 0, NULL); + pixelCoordinate.setX(p.x); + pixelCoordinate.setY(p.y); + pixelCoordinates.push_back(pixelCoordinate); + } +} + +#if LM +static void callbackFunction(ilmObjectType object, t_ilm_uint surfaceId, t_ilm_bool created, void *user_data) +{ + (void)user_data; + struct ilmSurfaceProperties sp; + + if (object == ILM_SURFACE) { + if (created) { + //m_handle not propageted here but it is m_handle=1. + if (surfaceId == FSA_LAYER+1) { + //Configure map surface + if (ilm_getPropertiesOfSurface(surfaceId, &sp) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_getPropertiesOfSurface\n"); + } + + if (ilm_layerAddSurface(FSA_LAYER, surfaceId) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerAddSurface\n"); + } + + if (ilm_surfaceSetSourceRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_surfaceSetSourceRectangle\n"); + } + + if (ilm_surfaceSetDestinationRectangle(surfaceId, 0, 0, sp.origSourceWidth, sp.origSourceHeight) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_surfaceSetDestinationRectangle\n"); + } + + if (ilm_surfaceSetVisibility(surfaceId, ILM_TRUE) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_surfaceSetVisibility\n"); + } + + if (ilm_commitChanges() != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_commitChanges\n"); + } + } + } + } +} +#endif + +class MapMatchedPositionClientProxy; +class RoutingClientProxy; + +MapViewerControlObj::MapViewerControlObj(MapViewerControlServerStub *mapviewercontrol, NavigationTypes::Handle handle, const MapViewerControl::Dimension &MapViewSize) +{ + m_mapviewercontrol=mapviewercontrol; + m_handle=handle; + m_navit.type=attr_navit; + m_scrollspeed=0; + m_scrolldirection=0; + m_force_draw=false; + m_perspective=MapViewerControl::MapPerspective::PERSPECTIVE_2D; + m_follow_car=true; + + //init the routing client + const std::string domain = "local"; + const std::string instanceRouting = "Routing"; + mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting); + mp_routingClientProxy->setListeners(); + mp_routingClientProxy->connectToMapViewer(this); + + struct attr navit_template; + struct attr navit_flags={attr_flags};navit_flags.u.num=2; + struct attr *navit_attrs[]={&navit_flags,NULL}; + if (!config_get_attr(config, attr_navit, &navit_template, NULL)) { + dbg(lvl_debug,"failed to get navit template from config\n"); + return; + } + 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; + } + const char *graphics=getenv("NAVIT_GRAPHICS"); + if (!graphics) + graphics="gtk_drawing_area"; + struct attr graphics_type={attr_type};graphics_type.u.str=(char *)graphics; + struct attr graphics_w={attr_w};graphics_w.u.num=MapViewSize.getHorizontalSize(); + struct attr graphics_h={attr_h};graphics_h.u.num=MapViewSize.getVerticalSize(); + struct attr graphics_window_title={attr_window_title};graphics_window_title.u.str=g_strdup_printf("Navit-%d",handle); + struct attr *graphics_attrs[]={&graphics_type,&graphics_w,&graphics_h,&graphics_window_title,NULL}; + m_graphics.type=attr_graphics; + m_graphics.u.graphics=graphics_new(&m_navit,graphics_attrs); + g_free(graphics_window_title.u.str); + + if (!m_graphics.u.graphics) { + dbg(lvl_debug,"failed to create new graphics\n"); + return; + } + m_postdraw_callback=callback_new_attr_1(reinterpret_cast<void (*)(void)>(MapViewerControlObj_PostDraw), attr_postdraw, this); + m_move_callback=callback_new_1(reinterpret_cast<void (*)(void)>(MapViewerControlObj_MoveMap), this); + graphics_add_callback(m_graphics.u.graphics, m_postdraw_callback); + navit_add_attr(m_navit.u.navit, &m_graphics); + + struct attr mapset; + if (!navit_get_attr(navit_template.u.navit, attr_mapset, &mapset, NULL)) { + dbg(lvl_debug,"failed to get mapset\n"); + return; + } + mapset.u.mapset=mapset_dup(mapset.u.mapset); + m_mapset=mapset.u.mapset; + navit_add_attr(m_navit.u.navit, &mapset); + + struct attr_iter *iter=navit_attr_iter_new(); + struct attr layout; + while (navit_get_attr(navit_template.u.navit, attr_layout, &layout, iter)) { + navit_add_attr(m_navit.u.navit, &layout); + } + navit_attr_iter_destroy(iter); + + struct attr vehicle_source={attr_source};vehicle_source.u.str=(char *)"null:"; + struct attr vehicle_follow={attr_follow};vehicle_follow.u.num=1; + struct attr *vehicle_attrs[]={&vehicle_source,&vehicle_follow,NULL}; + m_vehicle.type=attr_vehicle; + 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(); + mp_mapMatchedPositionClientProxy->connectToMapViewer(this); + mp_mapMatchedPositionClientProxy->connectToVehicle(m_vehicle.u.vehicle); + + navit_init(m_navit.u.navit); + graphics_get_data(m_graphics.u.graphics,"window"); + struct transformation *trans=navit_get_trans(m_navit.u.navit); + struct map_selection sel; + memset(&sel, 0, sizeof(sel)); + sel.u.p_rect.rl.x=MapViewSize.getHorizontalSize(); + sel.u.p_rect.rl.y=MapViewSize.getVerticalSize(); + transform_set_screen_selection(trans, &sel); + +#if LM + t_ilm_nativedisplay display = (t_ilm_nativedisplay)graphics_get_data(m_graphics.u.graphics, "display"); + + if (ilmClient_init(display) != ILM_SUCCESS) { + dbg(lvl_error, "error on ilm_initWidthNativeDisplay\n"); + } + + t_ilm_nativehandle nativehandle=(t_ilm_nativehandle)graphics_get_data(m_graphics.u.graphics,"xwindow_id"); + t_ilm_surface surfaceId=FSA_LAYER+m_handle; + t_ilm_layer layerId=FSA_LAYER; + + //Configure Screen for FSA + t_ilm_layer renderOrder[1]; + renderOrder[0] = FSA_LAYER; + renderOrder[1] = HMI_LAYER; + if (ilm_displaySetRenderOrder(0,renderOrder,2) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_displaySetRenderOrder\n"); + } + + //Configure the FSA layer dimensions & visibility + if (ilm_layerSetSourceRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerSetSourceRectangle\n"); + } + + if (ilm_layerSetDestinationRectangle(layerId, 0, 0, MapViewSize._1, MapViewSize._2) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerSetDestinationRectangle\n"); + } + + if (ilm_layerSetVisibility(layerId, ILM_TRUE) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerSetVisibility\n"); + } + + //Register Notification + if (ilm_registerNotification(callbackFunction, NULL) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_registerNotification\n"); + } + + //Create surface for the map and add notification when created + if (ilm_surfaceCreate(nativehandle, MapViewSize._1, MapViewSize._2, ILM_PIXELFORMAT_RGBA_8888, &surfaceId) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_surfaceCreate\n"); + } + + //Commit all changes + if (ilm_commitChanges() != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_commitChanges\n"); + } +#endif + +} + +MapViewerControlObj::~MapViewerControlObj() +{ +#if LM + t_ilm_surface surfaceId=FSA_LAYER+m_handle; + t_ilm_layer layerId=FSA_LAYER; + if (ilm_surfaceRemove(surfaceId) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_surfaceRemove\n"); + } + if (ilm_layerRemoveSurface(layerId, surfaceId) != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_layerAddSurface\n"); + } + if (ilm_commitChanges() != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_commitChanges\n"); + } +#endif + + graphics_remove_callback(m_graphics.u.graphics, m_postdraw_callback); +#if 0 + graphics_free(m_graphics.u.graphics); + vehicle_destroy(m_vehicle.u.vehicle); +#endif + navit_destroy(m_navit.u.navit); + delete(m_routing); + delete(m_mapmatchedposition); +} + +uint32_t +DisplayedRoute::RouteHandle() +{ + return m_handle; +} + +void +DisplayedRoute::Show() +{ + if (!m_shown) { + if (m_map.u.map) + mapset_add_attr(m_mapset, &m_map); + m_shown=true; + } +} + +void +DisplayedRoute::Hide() +{ + if (m_shown) { + if (m_map.u.map) + mapset_remove_attr(m_mapset, &m_map); + m_shown=false; + } +} + +void +DisplayedRoute::AddGeoCoordinateD(double lat, double lon) +{ + struct coord_geo g; + struct coord c; + g.lat=lat; + g.lng=lon; + transform_from_geo(projection_mg, &g, &c); + m_coordinates.push_back(c); +} + +bool +DisplayedRoute::AddSegment(Routing::RouteSegment map) +{ + if (map.find(Routing::RouteSegmentType::START_LATITUDE) != map.end() && map.find(Routing::RouteSegmentType::START_LONGITUDE) != map.end()) + AddGeoCoordinateD(map[Routing::RouteSegmentType::START_LATITUDE].get<double>(),map[Routing::RouteSegmentType::START_LONGITUDE].get<double>()); + if (map.find(Routing::RouteSegmentType::INTERMEDIATE_POINTS) != map.end()) { + std::vector<Routing::IntermediatePoint> intermediate_points=map[Routing::RouteSegmentType::INTERMEDIATE_POINTS].get<std::vector<Routing::IntermediatePoint>>(); + Routing::IntermediatePoint intermediate_point; + for (size_t i = 0 ; i < intermediate_points.size(); i++) { + intermediate_point = intermediate_points[i]; + AddGeoCoordinateD(intermediate_point.getLatitude(), intermediate_point.getLongitude()); + } + } + if (map.find(Routing::RouteSegmentType::END_LATITUDE) != map.end() && map.find(Routing::RouteSegmentType::END_LONGITUDE) != map.end()) { + AddGeoCoordinateD(map[Routing::RouteSegmentType::END_LATITUDE].get<double>(),map[Routing::RouteSegmentType::END_LONGITUDE].get<double>()); + return true; + } + return false; +} + +void +DisplayedRoute::WriteSegment(FILE *out) +{ + if (m_coordinates.size()) { + int 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++) + fwrite(&m_coordinates[i], sizeof(struct coord), 1, out); + } +} + +DisplayedRoute::DisplayedRoute(class MapViewerControlObj *mapviewer, uint8_t RouteSession, NavigationTypes::Handle RouteHandle, struct mapset *mapset) +{ + dbg(lvl_debug,"enter\n"); + std::vector<Routing::RouteSegment> RouteShape; + std::vector<Routing::RouteSegmentType> valuesToReturn; + valuesToReturn.push_back(Routing::RouteSegmentType::START_LATITUDE); + valuesToReturn.push_back(Routing::RouteSegmentType::START_LONGITUDE); + valuesToReturn.push_back(Routing::RouteSegmentType::END_LATITUDE); + valuesToReturn.push_back(Routing::RouteSegmentType::END_LONGITUDE); + valuesToReturn.push_back(Routing::RouteSegmentType::INTERMEDIATE_POINTS); + m_handle=RouteHandle; + m_map.type=attr_map; + m_map.u.map=NULL; + m_filename=NULL; + m_mapset=mapset; + m_shown=false; + uint32_t totalNumberOfSegments; + CommonAPI::CallStatus status; + mapviewer->m_routing->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; + for (int i = 0 ; i < count ; i++) { + Routing::RouteSegment map = RouteShape[i]; + if (!complete) { + if (map.find(Routing::RouteSegmentType::START_LATITUDE) != map.end() && map.find(Routing::RouteSegmentType::START_LONGITUDE) != map.end()) + AddGeoCoordinateD(map[Routing::RouteSegmentType::START_LATITUDE].get<double>(),map[Routing::RouteSegmentType::START_LONGITUDE].get<double>()); + else + dbg(lvl_debug,"previous segment is missing end, but current segment is missing start also"); + WriteSegment(f); + } + complete=AddSegment(map); + } + if (!complete) + dbg(lvl_debug,"last segment is missing end"); + WriteSegment(f); + fclose(f); + struct attr map_attr_type={attr_type}; + map_attr_type.u.str=(char *)"binfile"; + struct attr map_attr_data={attr_data}; + map_attr_data.u.str=m_filename; + struct attr *map_attrs[]={&map_attr_type, &map_attr_data, NULL}; + m_map.u.map=map_new(NULL,map_attrs); +} + +DisplayedRoute::~DisplayedRoute() +{ + dbg(lvl_debug,"enter\n"); + if (m_map.u.map) + map_destroy(m_map.u.map); + if (m_filename) { + unlink(m_filename); + g_free(m_filename); + } +} + +void +plugin_init(void) +{ + dbg(lvl_debug,"enter\n"); + event_request_system("glib","genivi_mapviewercontrol"); + + // Common API data init + runtime = CommonAPI::Runtime::get(); + + // init the map viewer control server + const std::string domain = "local"; + const std::string instanceMapViewerControl = "MapViewerControl"; + + std::shared_ptr<MapViewerControlServerStub> myServiceMapViewerControl = std::make_shared<MapViewerControlServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instanceMapViewerControl, myServiceMapViewerControl); + } + + //init the session client + const std::string instanceNavigationCoreSession = "NavigationCoreSession"; + mp_navigationCoreSessionClientProxy = new NavigationCoreSessionClientProxy(domain,instanceNavigationCoreSession); + + CommonAPI::CallStatus status; + mp_navigationCoreSessionClientProxy->myServiceNavigationCoreSession->createSession(std::string("MapViewerControl"),status,m_navigationcore_session); + +#if LM + if (ilm_init() != ILM_SUCCESS) { + dbg(lvl_error,"error on ilm_init\n"); + } +#endif + +} + diff --git a/src/navigation/map-viewer/navit_genivi_mapviewer_capi.xsl b/src/navigation/map-viewer/navit_genivi_mapviewer_capi.xsl new file mode 100644 index 0000000..32a50ff --- /dev/null +++ b/src/navigation/map-viewer/navit_genivi_mapviewer_capi.xsl @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- ************************************************************************ +* Component Name: Navit POC +* Author: Martin Schaller <martin.schaller@it-schaller.de> +* +* Copyright (C) 2012, GENIVI Alliance, Inc. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +************************************************************************ --> +<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2001/XInclude"> + <xsl:template match="/config/plugins/plugin[1]" priority="1" > + <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> + <xsl:text>
 </xsl:text> + <plugin path="../../map-viewer/configuration-server-plugin/.libs/libgenivi_mapviewer_configuration_server.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../map-viewer/session-server-plugin/.libs/libgenivi_mapviewer_session_server.so" ondemand="no"/> + <xsl:text>
 </xsl:text> + <plugin path="../../map-viewer/mapviewercontrol-server-plugin/.libs/libgenivi_mapviewer_mapviewercontrol_server.so" ondemand="no"/> + </xsl:template> + <xsl:template match="/config/plugins/plugin"> + <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit"> + <xsl:copy><xsl:attribute name="flags">7</xsl:attribute><xsl:attribute name="tracking">0</xsl:attribute><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/graphics"> + <xsl:copy><xsl:attribute name="enabled">no</xsl:attribute><xsl:apply-templates select="@*|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/gui"> + <xsl:copy><xsl:attribute name="enabled">no</xsl:attribute><xsl:apply-templates select="@*[not(name()='enabled')]|node()"/></xsl:copy> + </xsl:template> + <xsl:template match="/config/navit/vehicle[@name='Local GPS']"> + <xsl:copy><xsl:attribute name="source">null:</xsl:attribute><xsl:attribute name="follow">null:</xsl:attribute></xsl:copy> + </xsl:template> + <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy></xsl:template> +</xsl:transform> diff --git a/src/navigation/map-viewer/session-server-plugin/.gitignore b/src/navigation/map-viewer/session-server-plugin/.gitignore new file mode 100644 index 0000000..96372cd --- /dev/null +++ b/src/navigation/map-viewer/session-server-plugin/.gitignore @@ -0,0 +1,9 @@ +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +compat_includes +compat_libs +*_adaptor.h +Makefile +.svn +.libs diff --git a/src/navigation/map-viewer/session-server-plugin/CMakeLists.txt b/src/navigation/map-viewer/session-server-plugin/CMakeLists.txt new file mode 100644 index 0000000..bde8c8a --- /dev/null +++ b/src/navigation/map-viewer/session-server-plugin/CMakeLists.txt @@ -0,0 +1,111 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: session-server-plugin +# +# Author: Philippe Colliot +# +# Copyright (C) 2015, PCA Peugeot Citroën +# +# 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@ +########################################################################### +project(session-server-plugin) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") + + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) + + +# DBus Path +if(DBUS_LIB_PATH) + message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH}) + set(DBUS_INCLUDE_DIRS ${DBUS_LIB_PATH}/include/dbus-1.0 ${DBUS_LIB_PATH}/lib/dbus-1.0/include) + set(DBUS_LIBDIR ${DBUS_LIB_PATH}/lib) + set(DBUS_LIBRARIES ${DBUS_LIB_PATH}/lib/libdbus-1.so) +else() + message(FATAL_ERROR "Please specify the path to your patched DBus library using -DDBUS_LIB_PATH=yourPath") +endif() + +# Packages +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) + + +#pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1.5") +pkg_check_modules(GOBJECT gobject-2.0) +pkg_check_modules(GLIB REQUIRED glib-2.0) +pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) + + +# Path to the generated files +set(API_VERSION_MAJOR 4) +set(API_VERSION "v${API_VERSION_MAJOR}") +set(PRJ_SRC_GEN_ROOT_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi) #files shared by all the APIs +set(PRJ_SRC_GEN_NAVIGATION_PATH ${PRJ_SRC_GEN_ROOT_PATH}/navigation) #files shared by the navigation APIs +set(PRJ_SRC_GEN_MAPVIEWER_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/mapviewer) #files shared by the navigationcore APIs + +# Source Files +set(FRANCA_FILE "Session") +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +FILE(GLOB PRJ_STUB_GEN_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*Types.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_ROOT_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Types.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATION_PATH}/*StubDefault.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}StubDefault.cpp + ) +FILE(GLOB PRJ_STUB_IMPL_SRCS + ${PRJ_SRC_GEN_ROOT_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_NAVIGATION_PATH}/*Stub*.cpp + ${PRJ_SRC_GEN_MAPVIEWER_PATH}/${FRANCA_FILE}Stub*.cpp + ) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_ROOT_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_MAPVIEWER_PATH} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${DBUS_CPP_GLIB_INCLUDE_DIRS} +) + +link_directories( + ${DBUS_LIBDIR} + ${COMMONAPI_LIBDIR} + ${COMMONAPI_DBUS_LIBDIR} + ${GOBJECT_LIBRARY_DIRS} + ${GLIB_LIBRARY_DIRS} + ${DBUS_CPP_GLIB_DIRS} +) + +set(LIBRARIES + ${DBUS_LIBRARIES} + ${COMMONAPI_LIBRARIES} + ${COMMONAPI_DBUS_LIBRARIES} + ${GOBJECT_LIBRARIES} + ${GLIB_LIBRARIES} + ${DBUS_CPP_GLIB_LIBRARIES} +) + +# Build service +module_add_library(genivi_mapviewer_session_server ${PRJ_SRCS}) +target_link_libraries(genivi_mapviewer_session_server ${LIBRARIES}) + diff --git a/src/navigation/map-viewer/session-server-plugin/genivi_mapviewer_session.cxx b/src/navigation/map-viewer/session-server-plugin/genivi_mapviewer_session.cxx new file mode 100644 index 0000000..141b9b0 --- /dev/null +++ b/src/navigation/map-viewer/session-server-plugin/genivi_mapviewer_session.cxx @@ -0,0 +1,152 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* +* \file genivi_mapviewer_session.cxx +* +* \brief This file is part of the Navit POC. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), 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/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* +* <date>, <name>, <description of change> +* +* @licence end@ +*/ +#include <dbus-c++/glib-integration.h> +#include "config.h" +#define USE_PLUGINS 1 +#include "debug.h" +#include "plugin.h" +#include "event.h" + +#include <CommonAPI/CommonAPI.hpp> +#include <CommonTypes.hpp> +#include <NavigationTypes.hpp> +#include <SessionStubDefault.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +using namespace v4::org::genivi::navigation::mapviewer; +using namespace v4::org::genivi::navigation; +using namespace v4::org::genivi; + +class SessionServerStub : public SessionStubDefault +{ + public: + +#define MAX_SESSION_HANDLES 256 + + SessionServerStub() + { + m_version.setVersionMajor(3); + m_version.setVersionMinor(0); + m_version.setVersionMicro(0); + m_version.setDate("21-01-2014"); + } + + ~SessionServerStub(){} + + /** + * description: getVersion = This method returns the API version implemented by the server + * application + */ + void getVersion(const std::shared_ptr<CommonAPI::ClientId> _client, getVersionReply_t _reply) { + _reply(m_version); + } + + /** + * description: createSession = This method creates a new session and retrieves a handle . + */ + void createSession(const std::shared_ptr<CommonAPI::ClientId> _client, std::string _clientApp, createSessionReply_t _reply){ + dbg(lvl_debug,"enter\n"); + NavigationTypes::Handle _sessionHandle=1; + while (mp_handles[_sessionHandle]) { + _sessionHandle++; + if (_sessionHandle == MAX_SESSION_HANDLES) + throw DBus::Error("org.genivi.navigationcore.Session.Error.NoMoreSessionHandles","Out of session handles"); + } + mp_handles[_sessionHandle]=new std::string(_clientApp); + _reply(_sessionHandle); + } + + /** + * description: deleteSession = This method deletes a session and its associated resources . + */ + void deleteSession(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, deleteSessionReply_t _reply){ + dbg(lvl_debug,"enter\n"); + if (!mp_handles[_sessionHandle]) + throw DBus::Error("org.genivi.navigationcore.Session.Error.NotAvailableSessionHandle","Session handle invalid"); + delete(mp_handles[_sessionHandle]); + mp_handles[_sessionHandle]=NULL; + fireSessionDeletedEvent(_sessionHandle); + _reply(); + } + + /** + * description: This method returns whether a given session handle is available or not (for + * example because it was deleted) . + */ + void getSessionStatus(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, getSessionStatusReply_t _reply){ + if (mp_handles[_sessionHandle]) + _reply(NavigationTypes::SessionStatus::AVAILABLE); + else + _reply(NavigationTypes::SessionStatus::NOT_AVAILABLE); + } + + /** + * description: This method returns a list of all available sessions . + */ + void getAllSessions(const std::shared_ptr<CommonAPI::ClientId> _client, getAllSessionsReply_t _reply){ + std::vector< NavigationTypes::Session > _sessionsList; + std::map<NavigationTypes::Handle, std::string *>::const_iterator it; + for(it = mp_handles.begin(); it != mp_handles.end(); it++) { + NavigationTypes::Session session; + if (it->second) { + session.setSessionHandle(it->first); + session.setClientApp(*it->second); + _sessionsList.push_back(session); + } + + } + _reply(_sessionsList); + } + +private: + CommonTypes::Version m_version; + std::map<NavigationTypes::Handle, std::string *> mp_handles; + +}; + +void +plugin_init(void) +{ + // Common API data init + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); + + const std::string &domain = "local"; + const std::string &instance = "Session"; + + std::shared_ptr<SessionServerStub> myServiceSession = std::make_shared<SessionServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instance, myServiceSession); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myServiceSession); + } +} diff --git a/src/navigation/navigation-core/CMakeLists.txt b/src/navigation/navigation-core/CMakeLists.txt index 986d61d..8723405 100644 --- a/src/navigation/navigation-core/CMakeLists.txt +++ b/src/navigation/navigation-core/CMakeLists.txt @@ -90,8 +90,6 @@ if(${YOCTO_CONFIG}) endif() -add_subdirectory(enhancedposition-plugin) - if (WITH_PLUGIN_MIGRATION) set(FRANCA_DIR "${API_DIR}/franca") add_subdirectory(configuration-server-plugin) @@ -101,6 +99,7 @@ if (WITH_PLUGIN_MIGRATION) add_subdirectory(routing-server-plugin) add_subdirectory(session-server-plugin) add_subdirectory(poicam-server-plugin) + add_subdirectory(enhancedposition-client-plugin) else() add_subdirectory(configuration-plugin) add_subdirectory(locationinput-plugin) @@ -108,5 +107,6 @@ else() add_subdirectory(mapmatchedposition-plugin) add_subdirectory(routing-plugin) add_subdirectory(session-plugin) + add_subdirectory(enhancedposition-plugin) endif() diff --git a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt index 508da73..26b3376 100644 --- a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt @@ -51,10 +51,6 @@ pkg_check_modules(GOBJECT gobject-2.0) pkg_check_modules(GLIB REQUIRED glib-2.0) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/enhancedposition-client-plugin/CMakeLists.txt b/src/navigation/navigation-core/enhancedposition-client-plugin/CMakeLists.txt new file mode 100644 index 0000000..83a9142 --- /dev/null +++ b/src/navigation/navigation-core/enhancedposition-client-plugin/CMakeLists.txt @@ -0,0 +1,99 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: enhancedposition-client-plugin +# +# Author: Philippe Colliot +# +# Copyright (C) 2015, PCA Peugeot Citroën +# +# 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@ +########################################################################### +project(positioning-enhancedposition-client-plugin) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") + + + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) + + +# DBus Path +if(DBUS_LIB_PATH) + message(STATUS "DBUS_LIB_PATH = " ${DBUS_LIB_PATH}) + set(DBUS_INCLUDE_DIRS ${DBUS_LIB_PATH}/include/dbus-1.0 ${DBUS_LIB_PATH}/lib/dbus-1.0/include) + set(DBUS_LIBDIR ${DBUS_LIB_PATH}/lib) + set(DBUS_LIBRARIES ${DBUS_LIB_PATH}/lib/libdbus-1.so) +else() + message(FATAL_ERROR "Please specify the path to your patched DBus library using -DDBUS_LIB_PATH=yourPath") +endif() + +# Packages +find_package(CommonAPI 3.1.5 REQUIRED) +find_package(CommonAPI-DBus 3.1.5 REQUIRED) + + +#pkg_check_modules(DBUS "dbus-1 >= 1.8.4") // #to be fixed, it doesn't work so the paths are set manually (see above) +pkg_check_modules(COMMONAPI "CommonAPI >= 3.1.5") +pkg_check_modules(COMMONAPI_DBUS "CommonAPI-DBus >= 3.1.5") +pkg_check_modules(GOBJECT gobject-2.0) +pkg_check_modules(GLIB REQUIRED glib-2.0) +pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) + + +# Path to the generated files +set(PRJ_SRC_GEN_ENHANCEDPOSITIONSERVICE_PATH "${COMMONAPI_GEN_DIR_POSITIONING}/org/genivi/EnhancedPositionService") #files shared by the enhanced position service APIs + +# Source Files +FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +FILE(GLOB PRJ_PROXY_GEN_SRCS + ${PRJ_SRC_GEN_ENHANCEDPOSITIONSERVICE_PATH}/EnhancedPositionDBusProxy.cpp +) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_PROXY_GEN_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${COMMONAPI_GEN_DIR_POSITIONING} + ${PRJ_SRC_GEN_ENHANCEDPOSITIONSERVICE_PATH} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${DBUS_CPP_GLIB_INCLUDE_DIRS} +) + +link_directories( + ${DBUS_LIBDIR} + ${COMMONAPI_LIBDIR} + ${COMMONAPI_DBUS_LIBDIR} + ${GOBJECT_LIBRARY_DIRS} + ${GLIB_LIBRARY_DIRS} + ${DBUS_CPP_GLIB_DIRS} +) + +set(LIBRARIES + ${DBUS_LIBRARIES} + ${COMMONAPI_LIBRARIES} + ${COMMONAPI_DBUS_LIBRARIES} + ${GOBJECT_LIBRARIES} + ${GLIB_LIBRARIES} + ${DBUS_CPP_GLIB_LIBRARIES} +) + +# Build service +module_add_library(genivi_positioning_enhancedposition_client ${PRJ_SRCS}) +target_link_libraries(genivi_positioning_enhancedposition_client ${LIBRARIES}) + diff --git a/src/navigation/navigation-core/enhancedposition-client-plugin/genivi_positioning_enhancedposition.cxx b/src/navigation/navigation-core/enhancedposition-client-plugin/genivi_positioning_enhancedposition.cxx new file mode 100644 index 0000000..d7c592d --- /dev/null +++ b/src/navigation/navigation-core/enhancedposition-client-plugin/genivi_positioning_enhancedposition.cxx @@ -0,0 +1,300 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +* +* \file genivi_positioning_enhancedposition.cxx +* +* \brief This file is part of the Navit POC. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* +* \version 1.0 +* +* This Source Code Form is subject to the terms of the +* Mozilla Public License (MPL), 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/. +* +* For further information see http://www.genivi.org/. +* +* List of changes: +* +* <date>, <name>, <description of change> +* +* @licence end@ +*/ + +#include <dbus-c++/glib-integration.h> +#include <glib.h> +#include <string.h> +#include <stdbool.h> +#include <assert.h> +#include <math.h> +#define USE_PLUGINS 1 +#include "debug.h" +#include "item.h" +#include "navit.h" +#include "map.h" +#include "callback.h" +#include "transform.h" +#include "plugin.h" +#include "event.h" +#include "vehicle.h" +#include "time.h" +#include <unistd.h> + +#include <CommonAPI/CommonAPI.hpp> +#include <EnhancedPositionProxy.hpp> +#include <EnhancedPositionServiceTypes.hpp> + +#if (!DEBUG_ENABLED) +#undef dbg +#define dbg(level,...) ; +#endif + +using namespace org::genivi::EnhancedPositionService; + +static std::shared_ptr < CommonAPI::Runtime > runtime; + +class EnhancedPositionClientProxy; + +struct vehicle_priv { + class EnhancedPositionClientProxy *enhanced_position; + struct callback_list *cbl; + struct callback *cb; + int cb_pending; + struct coord_geo geo; + double speed; + double direction; + double height; + int fix_type; + time_t fix_time; + char fixiso8601[128]; + double hdop; + int sats; + int sats_signal; + int sats_used; +}; + +class EnhancedPositionClientProxy +{ + public: + + struct vehicle_priv *mp_priv; + std::shared_ptr<EnhancedPositionProxyDefault> myServiceEnhancedPosition; + + EnhancedPositionClientProxy(const std::string domain, const std::string instance) + { + myServiceEnhancedPosition = runtime->buildProxy<EnhancedPositionProxy>(domain, instance); + + while (!myServiceEnhancedPosition->isAvailable()) { + usleep(10); + } + } + + void connectToVehicle(struct vehicle_priv *priv) + { + mp_priv=priv; + } + + void setListeners() + { + myServiceEnhancedPosition->getPositionUpdateEvent().subscribe([&](const uint64_t& changedValues) { + positionUpdate(changedValues);}); + } + + void + positionUpdate(const uint64_t& changedValues) + { + dbg(lvl_debug,"enter\n"); + bool position_found=false; + if ((changedValues & (EnhancedPositionServiceTypes::PositionInfoKey::LATITUDE | EnhancedPositionServiceTypes::PositionInfoKey::LONGITUDE)) == (EnhancedPositionServiceTypes::PositionInfoKey::LATITUDE | EnhancedPositionServiceTypes::PositionInfoKey::LONGITUDE)) + { + position_found=true; + } + if (position_found && !mp_priv->cb_pending) { + event_add_timeout(0, 0, mp_priv->cb); + mp_priv->cb_pending=1; + } + } +}; + +/** + * @see vehicle_enhancedposition_methods + */ +static void vehicle_enhancedposition_destroy(struct vehicle_priv *priv) +{ + dbg(lvl_debug,"enter\n"); + delete(priv->enhanced_position); + callback_destroy(priv->cb); + g_free(priv); +} + +/** + * This function is used to really fetch the changed attribute, e.g. Position, + * into navit core. + * + * @see vehicle_enhancedposition_methods + */ +static int vehicle_enhancedposition_position_attr_get(struct vehicle_priv *priv, enum attr_type type, struct attr *attr) +{ + dbg(lvl_debug, "enter\n"); + + switch (type) { + case attr_position_fix_type: + // printf("fix_type\n"); + attr->u.num = priv->fix_type; + break; + case attr_position_height: + // printf("height\n"); + attr->u.numd = &priv->height; + break; + case attr_position_speed: + // printf("speed\n"); + attr->u.numd = &priv->speed; + break; + case attr_position_direction: + // printf("direction\n"); + attr->u.numd = &priv->direction; + break; +#if 0 + case attr_position_hdop: + // printf("hdop\n"); + attr->u.numd = &priv->hdop; + break; + case attr_position_qual: + // printf("qual\n"); + attr->u.num = priv->sats; + break; + case attr_position_sats_signal: + // printf("sats signal\n"); + attr->u.num = priv->sats_signal; + break; + case attr_position_sats_used: + // printf("sats used\n"); + attr->u.num = priv->sats_used; + break; +#endif + case attr_position_coord_geo: + attr->u.coord_geo = &priv->geo; + break; + case attr_position_time_iso8601: { + struct tm tm; + if (!priv->fix_time) { + dbg(lvl_debug,"no fix time\n"); + return 0; + } + if (gmtime_r(&priv->fix_time, &tm)) { + strftime(priv->fixiso8601, sizeof(priv->fixiso8601), "%Y-%m-%dT%TZ", &tm); + attr->u.str = priv->fixiso8601; + } else + return 0; + break; + } + default: + // printf("other attribute\n"); + return 0; + } + return 1; +} + +static int vehicle_enhancedposition_set_attr(struct vehicle_priv *priv, struct attr *attr) +{ + dbg(lvl_debug, "enter\n"); +} + +// navit plugin callbacks +struct vehicle_methods vehicle_enhancedposition_methods = { + vehicle_enhancedposition_destroy, + vehicle_enhancedposition_position_attr_get, + vehicle_enhancedposition_set_attr, +}; + +static double +double_variant(DBus::Variant variant) +{ + double d; + DBus::MessageIter iter=variant.reader(); + iter >> d; + return d; +} + + +static void +vehicle_process_map(struct vehicle_priv *priv, EnhancedPositionServiceTypes::PositionInfo& map) +{ + EnhancedPositionServiceTypes::PositionInfo::const_iterator itr; + for(itr = map.begin(); itr != map.end(); ++itr) { + switch ((*itr).first) { + case EnhancedPositionServiceTypes::PositionInfoKey::LATITUDE: + priv->geo.lat=(*itr).second.get<double>(); + break; + case EnhancedPositionServiceTypes::PositionInfoKey::LONGITUDE: + priv->geo.lng=(*itr).second.get<double>(); + break; + case EnhancedPositionServiceTypes::PositionInfoKey::ALTITUDE: +// priv->height=(*itr).second.get<double>(); + break; + case EnhancedPositionServiceTypes::PositionInfoKey::HEADING: +// priv->direction=(*itr).second.get<double>(); + break; + case EnhancedPositionServiceTypes::PositionInfoKey::SPEED: + priv->speed=floor((*itr).second.get<double>()*360+0.5)/100; + break; + } + } +} + +static void +vehicle_enhancedposition_callback(struct vehicle_priv *priv) +{ + EnhancedPositionServiceTypes::Bitmask valuesToReturn = (EnhancedPositionServiceTypes::PositionInfoKey::LATITUDE | EnhancedPositionServiceTypes::PositionInfoKey::LONGITUDE | EnhancedPositionServiceTypes::PositionInfoKey::SPEED); + EnhancedPositionServiceTypes::PositionInfo position; + EnhancedPositionServiceTypes::Timestamp timestamp; + CommonAPI::CallStatus status; + priv->enhanced_position->myServiceEnhancedPosition->GetPositionInfo(valuesToReturn,status,timestamp,position); + dbg(lvl_debug,"enter GetPositionInfo\n"); + vehicle_process_map(priv, position); + time(&priv->fix_time); /* FIXME: Use actual value */ + priv->fix_type=2; /* 3d, FIXME: Use actual value */ + callback_list_call_attr_0(priv->cbl, attr_position_coord_geo); + priv->cb_pending=0; +} + +/** + * vehicle_enhancedposition Constructor. + * + * @see plugin_init + */ +static struct vehicle_priv * +vehicle_enhancedposition_new(struct vehicle_methods *meth, + struct callback_list *cbl, struct attr **attrs) +{ + struct vehicle_priv *ret; + + dbg(lvl_debug, "enter\n"); + + *meth=vehicle_enhancedposition_methods; + ret = g_new0(struct vehicle_priv, 1); + + //init the enhanced position service client + const std::string domain = "local"; + const std::string instanceEnhancedposition = "Enhancedposition"; + ret->enhanced_position = new EnhancedPositionClientProxy(domain,instanceEnhancedposition); + ret->enhanced_position->setListeners(); + ret->enhanced_position->connectToVehicle(ret); + + ret->cb=callback_new_1(callback_cast(vehicle_enhancedposition_callback), ret); + ret->cbl=cbl; + + return ret; +} + +void plugin_init(void) +{ + event_request_system("glib","genivi_navigationcore_enhpos"); + + plugin_register_vehicle_type("enhancedposition", vehicle_enhancedposition_new); +} diff --git a/src/navigation/navigation-core/guidance-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/guidance-server-plugin/CMakeLists.txt index 78773ac..026e166 100644 --- a/src/navigation/navigation-core/guidance-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/guidance-server-plugin/CMakeLists.txt @@ -52,10 +52,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt index 8600ed9..c910984 100644 --- a/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/locationinput-server-plugin/CMakeLists.txt @@ -52,10 +52,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx b/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx index e42a3c9..2a987ed 100644 --- a/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx +++ b/src/navigation/navigation-core/locationinput-server-plugin/genivi_navigationcore_locationinput.cxx @@ -91,7 +91,12 @@ class LocationInputObj class LocationInputServerStub : public LocationInputStubDefault { public: + +#define MAX_LOCATION_HANDLES 256 +#define FIRST_LOCATION_HANDLE 1 + LocationInputServerStub(){ + mp_handles[FIRST_LOCATION_HANDLE]=NULL; m_version.setVersionMajor(3); m_version.setVersionMinor(0); m_version.setVersionMicro(0); @@ -115,10 +120,10 @@ public: void createLocationInput(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, createLocationInputReply_t _reply){ uint32_t LocationInputHandle; dbg(lvl_debug,"enter\n"); - LocationInputHandle=1; - while (mp_handles[LocationInputHandle]) { + LocationInputHandle=FIRST_LOCATION_HANDLE; + while (mp_handles.count(LocationInputHandle)>0 ) { LocationInputHandle++; - if (LocationInputHandle == 256) + if (LocationInputHandle == MAX_LOCATION_HANDLES) throw DBus::ErrorLimitsExceeded("Out of location handles"); } mp_handles[LocationInputHandle]=new LocationInputObj(this, LocationInputHandle); @@ -131,11 +136,14 @@ public: */ void deleteLocationInput(const std::shared_ptr<CommonAPI::ClientId> _client, ::v4::org::genivi::navigation::NavigationTypes::Handle _sessionHandle, ::v4::org::genivi::navigation::NavigationTypes::LocationHandle _locationInputHandle, deleteLocationInputReply_t _reply){ dbg(lvl_debug,"enter\n"); - LocationInputObj *obj=mp_handles[_locationInputHandle]; - if (!obj) - throw DBus::ErrorInvalidArgs("location handle invalid"); - delete(obj); - mp_handles[_locationInputHandle]=NULL; + if (mp_handles.find(_locationInputHandle) != mp_handles.end()) + { + LocationInputObj *obj=mp_handles[_locationInputHandle]; + delete(obj); + } + else { + throw DBus::ErrorInvalidArgs("location handle invalid"); + } _reply(); } diff --git a/src/navigation/navigation-core/mapmatchedposition-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/mapmatchedposition-server-plugin/CMakeLists.txt index 43df6dd..3526409 100644 --- a/src/navigation/navigation-core/mapmatchedposition-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/mapmatchedposition-server-plugin/CMakeLists.txt @@ -52,10 +52,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/mapmatchedposition-server-plugin/genivi_navigationcore_mapmatchedposition.cxx b/src/navigation/navigation-core/mapmatchedposition-server-plugin/genivi_navigationcore_mapmatchedposition.cxx index 40b6984..5c752a3 100644 --- a/src/navigation/navigation-core/mapmatchedposition-server-plugin/genivi_navigationcore_mapmatchedposition.cxx +++ b/src/navigation/navigation-core/mapmatchedposition-server-plugin/genivi_navigationcore_mapmatchedposition.cxx @@ -269,7 +269,7 @@ class MapMatchedPositionServerStub : public MapMatchedPositionStubDefault /** * description: getAddress = This method returns the current address */ - void getAddress(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector<MapMatchedPosition::AddressItemKey> _valuesToReturn, getAddressReply_t _reply){ + void getCurrentAddress(const std::shared_ptr<CommonAPI::ClientId> _client, std::vector<MapMatchedPosition::AddressItemKey> _valuesToReturn, getCurrentAddressReply_t _reply){ MapMatchedPosition::AddressItemDict ret; std::vector< MapMatchedPosition::AddressItemKey >::const_iterator it; for (it = _valuesToReturn.begin(); it < _valuesToReturn.end(); it++) { diff --git a/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl b/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl index d2dde47..94b92c9 100644 --- a/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl +++ b/src/navigation/navigation-core/navit_genivi_navigationcore_capi.xsl @@ -35,7 +35,7 @@ <xsl:text>
 </xsl:text> <plugin path="../../navigation-core/mapmatchedposition-server-plugin/.libs/libgenivi_navigationcore_mapmatchedposition_server.so" ondemand="no"/> <xsl:text>
 </xsl:text> - <plugin path="../../navigation-core/enhancedposition-plugin/.libs/libgenivi_positioning_enhancedposition.so" ondemand="no"/> + <plugin path="../../navigation-core/enhancedposition-client-plugin/.libs/libgenivi_positioning_enhancedposition_client.so" ondemand="no"/> <xsl:text>
 </xsl:text> <plugin path="../../navigation-core/poicam-server-plugin/.libs/libgenivi_poiservice_cam_server.so" ondemand="no"/> </xsl:template> diff --git a/src/navigation/navigation-core/poicam-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/poicam-server-plugin/CMakeLists.txt index 64af8bc..5ac8680 100644 --- a/src/navigation/navigation-core/poicam-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/poicam-server-plugin/CMakeLists.txt @@ -52,10 +52,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/poiservice "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") @@ -79,7 +75,7 @@ FILE(GLOB PRJ_STUB_IMPL_SRCS ) set(FRANCA_FILE_CLIENT "POIContentAccess") FILE(GLOB PRJ_PROXY_GEN_SRCS - ${PRJ_SRC_GEN_POISERVICE_PATH}/${FRANCA_FILE_CLIENT}DBusClient*.cpp + ${PRJ_SRC_GEN_POISERVICE_PATH}/${FRANCA_FILE_CLIENT}*DBusProxy.cpp ) set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_PROXY_GEN_SRCS}) 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 fcf49ed..13b43d8 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 @@ -439,12 +439,12 @@ plugin_init(void) const std::string instancePOIContentAccess = "POIContentAccess"; -/* myServicePOIContentAccess = runtime->buildProxy<POIContentAccessProxy>(domain, instancePOIContentAccess); + myServicePOIContentAccess = runtime->buildProxy<POIContentAccessProxy>(domain, instancePOIContentAccess); while (!myServicePOIContentAccess->isAvailable()) { usleep(10); } myServicePOIContentAccessModule->register_cam(); -*/ + } diff --git a/src/navigation/navigation-core/routing-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/routing-server-plugin/CMakeLists.txt index de78caf..ecbdb8b 100644 --- a/src/navigation/navigation-core/routing-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/routing-server-plugin/CMakeLists.txt @@ -52,10 +52,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/session-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/session-server-plugin/CMakeLists.txt index ff085fd..5c3652b 100644 --- a/src/navigation/navigation-core/session-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/session-server-plugin/CMakeLists.txt @@ -51,10 +51,6 @@ pkg_check_modules(GLIB REQUIRED glib-2.0) pkg_check_modules(DBUS_CPP_GLIB dbus-c++-glib-1) -# Add the Franca files (that will generate the CommonAPI stuff) -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -add_subdirectory(${FRANCA_DIR}/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") - # Path to the generated files set(API_VERSION_MAJOR 4) set(API_VERSION "v${API_VERSION_MAJOR}") diff --git a/src/navigation/navigation-core/session-server-plugin/genivi_navigationcore_session.cxx b/src/navigation/navigation-core/session-server-plugin/genivi_navigationcore_session.cxx index 880b030..5c9e58d 100644 --- a/src/navigation/navigation-core/session-server-plugin/genivi_navigationcore_session.cxx +++ b/src/navigation/navigation-core/session-server-plugin/genivi_navigationcore_session.cxx @@ -107,7 +107,7 @@ class SessionServerStub : public SessionStubDefault if (mp_handles[_sessionHandle]) _reply(NavigationTypes::SessionStatus::AVAILABLE); else - _reply(NavigationTypes::SessionStatus::AVAILABLE); + _reply(NavigationTypes::SessionStatus::NOT_AVAILABLE); } /** |