diff options
author | asanoaozora <fifitaneki@hotmail.com> | 2016-06-24 05:12:31 +0200 |
---|---|---|
committer | asanoaozora <fifitaneki@hotmail.com> | 2016-06-24 05:12:31 +0200 |
commit | 79fa3754af2abc3c9ea51c7f889a6ac8ffc72a0a (patch) | |
tree | 8213d7ddb94bc6bf1364a2cd71cb57535c0ba160 /src | |
parent | 9bbc028781d58dbfd29bb77cf6e1892307964d35 (diff) | |
download | poi-service-79fa3754af2abc3c9ea51c7f889a6ac8ffc72a0a.tar.gz |
CommonAPI: navigationcore configuration plugin OK
Diffstat (limited to 'src')
-rw-r--r-- | src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt | 59 | ||||
-rw-r--r-- | src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx | 98 |
2 files changed, 93 insertions, 64 deletions
diff --git a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt index b059f06..508da73 100644 --- a/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt +++ b/src/navigation/navigation-core/configuration-server-plugin/CMakeLists.txt @@ -16,21 +16,18 @@ # @licence end@ ########################################################################### project(configuration-server-plugin) -message(STATUS ${PROJECT_NAME}) +cmake_minimum_required(VERSION 2.8) -option(DBUS_LIB_PATH - "Path to the patched DBus library") +message(STATUS ${PROJECT_NAME}) set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") -set(PARENT_API navigationcore) -set(ROOT_API navigation) -set(API_VERSION_MAJOR 0) -set(API_VERSION "v${API_VERSION_MAJOR}") -set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/src-gen") -set(PRJ_SRC_GEN_PATH ${COMMONAPI_GEN_DIR}/${API_VERSION}/org/genivi/${ROOT_API}/${PARENT_API}) -set(PRJ_SRC_GEN_NAVIGATION_TYPES_PATH ${COMMONAPI_GEN_DIR}/org/genivi/${ROOT_API}) + + +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) @@ -39,33 +36,54 @@ if(DBUS_LIB_PATH) 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 -D DBUS_LIB_PATH=yourPath") + message(FATAL_ERROR "Please specify the path to your patched DBus library using -DDBUS_LIB_PATH=yourPath") endif() # Packages -find_package(PkgConfig REQUIRED) 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) -# Source Files -FILE(GLOB PRJ_LOCAL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cxx) +# 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") -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp) -FILE(GLOB PRJ_STUB_GEN_TYPES ${PRJ_SRC_GEN_NAVIGATION_TYPES_PATH}/*Types*.cpp) -set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_GEN_TYPES}) +# 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_NAVIGATIONCORE_PATH ${PRJ_SRC_GEN_NAVIGATION_PATH}/navigationcore) #files shared by the navigationcore 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_NAVIGATIONCORE_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_NAVIGATIONCORE_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_NAVIGATIONCORE_PATH}/${FRANCA_FILE}Stub*.cpp + ) + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) include_directories( - ${PRJ_SRC_GEN_PATH} - ${DBUS_INCLUDE_DIRS} ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_ROOT_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH} + ${DBUS_INCLUDE_DIRS} ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS} @@ -89,5 +107,6 @@ set(LIBRARIES ) # Build service -module_add_library(genivi_navigationcore_configuration_server genivi_navigationcore_configuration.cxx ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core/genivi-navigationcore-configuration_adaptor.h) +module_add_library(genivi_navigationcore_configuration_server ${PRJ_SRCS}) +target_link_libraries(genivi_navigationcore_configuration_server ${LIBRARIES}) diff --git a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx index 85752e0..b16a418 100644 --- a/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx +++ b/src/navigation/navigation-core/configuration-server-plugin/genivi_navigationcore_configuration.cxx @@ -44,16 +44,20 @@ #include "event.h" #include <CommonAPI/CommonAPI.hpp> -#include <org/genivi/CommonTypes.hpp> -#include <org/genivi/navigation/NavigationTypes.hpp> -#include <org/genivi/navigation/navigationcore/NavigationCoreTypes.hpp> -#include <v0/org/genivi/navigation/navigationcore/ConfigurationStubDefault.hpp> +#include <CommonTypes.hpp> +#include <NavigationTypes.hpp> +#include <NavigationCoreTypes.hpp> +#include <ConfigurationStubDefault.hpp> #if (!DEBUG_ENABLED) #undef dbg #define dbg(level,...) ; #endif +using namespace v4::org::genivi::navigation::navigationcore; +using namespace v4::org::genivi::navigation; +using namespace v4::org::genivi; + typedef struct { const char *c3; const char *c2; @@ -118,21 +122,6 @@ country_2_to_3(const char *in) return map_2_to_3(country_map, sizeof(country_map)/sizeof(country_map[0]), in); } -using namespace std; -using namespace v0::org::genivi::navigation::navigationcore; -using namespace org::genivi::navigation; -using namespace org::genivi; - -Configuration::UnitsOfMeasurementValue value; -Configuration::UnitsOfMeasurement unit = {{Configuration::UnitsOfMeasurementAttribute::LENGTH, value }}; -static std::vector<Configuration::UnitsOfMeasurement> unitsOfMeasurementList; - -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" }; -static std::vector< NavigationTypes::Locale> localeList; - class NavigationCoreConfigurationServerStub: public ConfigurationStubDefault { public: @@ -142,7 +131,7 @@ public: 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, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_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); @@ -155,30 +144,53 @@ public: 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; }; NavigationCoreConfigurationServerStub::NavigationCoreConfigurationServerStub() { + Configuration::UnitsOfMeasurementListValue valueList; + m_version.setVersionMajor(3); m_version.setVersionMinor(0); m_version.setVersionMicro(0); m_version.setDate("21-01-2014"); - localeList.push_back(en_US); - localeList.push_back(fr_FR); - localeList.push_back(de_DE); - localeList.push_back(jp_JP); + 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" }; - unitsOfMeasurementList.push_back(unit); + 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 = localeList.at(0).getLanguageCode(); - m_countryCode = localeList.at(0).getCountryCode(); - m_scriptCode = localeList.at(0).getScriptCode(); + 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::KM; + m_unitsOfMeasurement[Configuration::UnitsOfMeasurementAttribute::LENGTH] = Configuration::UnitsOfMeasurementValue::METER; + m_timeFormat = m_SupportedTimeFormats.at(0); } NavigationCoreConfigurationServerStub::~NavigationCoreConfigurationServerStub() @@ -211,52 +223,52 @@ void NavigationCoreConfigurationServerStub::getLocale(const std::shared_ptr<Comm void NavigationCoreConfigurationServerStub::getSupportedLocales(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedLocalesReply_t _reply) { - + _reply(m_SupportedLocales); } -void NavigationCoreConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, ::org::genivi::navigation::NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply) +void NavigationCoreConfigurationServerStub::setTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, NavigationTypes::TimeFormat _format, setTimeFormatReply_t _reply) { - + m_timeFormat = _format; } void NavigationCoreConfigurationServerStub::getTimeFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getTimeFormatReply_t _reply) { - + _reply(m_timeFormat); } void NavigationCoreConfigurationServerStub::getSupportedTimeFormats(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTimeFormatsReply_t _reply) { - + _reply(m_SupportedTimeFormats); } void NavigationCoreConfigurationServerStub::setCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::CoordinatesFormat _coordinatesFormat, setCoordinatesFormatReply_t _reply) { - + m_coordinatesFormat = _coordinatesFormat; } void NavigationCoreConfigurationServerStub::getCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getCoordinatesFormatReply_t _reply) { - + _reply(m_coordinatesFormat); } void NavigationCoreConfigurationServerStub::getSupportedCoordinatesFormat(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedCoordinatesFormatReply_t _reply) { - + _reply(m_SupportedCoordinatesFormats); } void NavigationCoreConfigurationServerStub::setUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, Configuration::UnitsOfMeasurement _unitsOfMeasurementList, setUnitsOfMeasurementReply_t _reply) { - + m_unitsOfMeasurement = _unitsOfMeasurementList; } void NavigationCoreConfigurationServerStub::getUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getUnitsOfMeasurementReply_t _reply) { - + _reply(m_unitsOfMeasurement); } void NavigationCoreConfigurationServerStub::getSupportedUnitsOfMeasurement(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedUnitsOfMeasurementReply_t _reply) { - + _reply(m_SupportedUnitsOfMeasurement); } void @@ -270,14 +282,12 @@ plugin_init(void) const std::string &domain = "local"; const std::string &instance = "Configuration"; - std::string connection = "Configuration"; - std::shared_ptr<NavigationCoreConfigurationServerStub> myServiceConfiguration = std::make_shared<NavigationCoreConfigurationServerStub>(); - bool successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); + bool successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration); while (!successfullyRegistered) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration, connection); + successfullyRegistered = runtime->registerService(domain, instance, myServiceConfiguration); } } |