diff options
author | asanoaozora <fifitaneki@hotmail.com> | 2016-09-22 11:12:02 +0200 |
---|---|---|
committer | asanoaozora <fifitaneki@hotmail.com> | 2016-09-22 11:12:02 +0200 |
commit | c25f7101bae08776a128fe64a306e45b62dfc56f (patch) | |
tree | d19a348c1be76882bc4da1935d2b9d5f13a48755 /src | |
parent | b083370474dccf501010bef5a0c6fec4d77f0c8d (diff) | |
download | navigation-c25f7101bae08776a128fe64a306e45b62dfc56f.tar.gz |
Refinement to facilitate migration to CommonAPI
Diffstat (limited to 'src')
33 files changed, 2393 insertions, 204 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e016c1..157d036 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 2.8) option(WITH_DEBUG "Enable the debug messages" OFF) option(WITH_PLUGIN_MIGRATION - "Enable navit plugin migration to commonapi" OFF) + "Enable navit plugins and fuel-stop-advisor migration to commonapi" OFF) option(AMB_ON_DBUS_SESSION "Run amb on dbus session" ON) option(WITH_HTML_MIGRATION @@ -32,7 +32,10 @@ message(STATUS "WITH_PLUGIN_MIGRATION = ${WITH_PLUGIN_MIGRATION}") message(STATUS "AMB_ON_DBUS_SESSION = ${AMB_ON_DBUS_SESSION}") message(STATUS "WITH_HTML_MIGRATION = ${WITH_HTML_MIGRATION}") +set(NAVIGATION_API_DIR "${CMAKE_CURRENT_SOURCE_DIR}/navigation/api") +set(POSITIONING_API_DIR "${CMAKE_CURRENT_SOURCE_DIR}/navigation/src/navigation/positioning/enhanced-position-service/dbus/api") set(FUEL_STOP_ADVISOR_API_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fuel-stop-advisor") + set(AUTOMOTIVE_MESSAGE_BROKER "automotive-message-broker") set(AUTOMOTIVE_MESSAGE_BROKER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${AUTOMOTIVE_MESSAGE_BROKER}") set(AUTOMOTIVE_MESSAGE_BROKER_SRC_DIR "${AUTOMOTIVE_MESSAGE_BROKER_DIR}/src/${AUTOMOTIVE_MESSAGE_BROKER}") @@ -41,6 +44,7 @@ set(AUTOMOTIVE_MESSAGE_BROKER_LIB_DIR "${AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR}/lib" set(PATCH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/patches") set(NAVIT_PNG_BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/navigation/navit/navit/xpm") set(TRIPCOMPUTER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tripcomputer") +set(COMMONAPI_GEN_DIR_POSITIONING "${CMAKE_CURRENT_BINARY_DIR}/enhanced-position-service/franca/api") if(NOT EXISTS ${AUTOMOTIVE_MESSAGE_BROKER_DIR}) if(NOT ${AMB_ON_DBUS_SESSION}) @@ -67,8 +71,13 @@ if(NOT EXISTS ${AUTOMOTIVE_MESSAGE_BROKER_DIR}) endif() add_subdirectory(navigation/src/navigation "${CMAKE_CURRENT_BINARY_DIR}/navigation") +set(DBUS_GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/navigation/dbus-include") -add_subdirectory(fuel-stop-advisor) +if (WITH_PLUGIN_MIGRATION) + add_subdirectory(fuel-stop-advisor-capi) +else() + add_subdirectory(fuel-stop-advisor) +endif() add_subdirectory(genivilogreplayer) diff --git a/src/build.sh b/src/build.sh index 9379f65..b8c381e 100755 --- a/src/build.sh +++ b/src/build.sh @@ -1,11 +1,39 @@ #!/bin/bash debug="OFF" -franca="OFF" html="OFF" clean=0 +capi=0 +navit=0 +commonapi_tools_option="" -while getopts cdfh opt +function check_path_for_capi +{ + echo 'check path for CommonAPI' + if [ ! $COMMONAPI_TOOL_DIR ] + then + echo 'Set the dir of the common api tools' + echo 'export COMMONAPI_TOOL_DIR=<path>' + exit 1 + fi + + if [ ! $COMMONAPI_DBUS_TOOL_DIR ] + then + echo 'Set the dir of the common api dbus tools' + echo 'export COMMONAPI_DBUS_TOOL_DIR=<path>' + exit 1 + fi + + if [ ! $DBUS_LIB_PATH ] + then + echo 'Set the dir of the patched dbus' + echo 'export DBUS_LIB_PATH=<path>' + exit 1 + fi + commonapi_tools_option="-DDBUS_LIB_PATH="$DBUS_LIB_PATH" -DCOMMONAPI_DBUS_TOOL_DIR="$COMMONAPI_DBUS_TOOL_DIR" -DCOMMONAPI_TOOL_DIR="$COMMONAPI_TOOL_DIR"" +} + +while getopts cdmhn opt do case $opt in c) @@ -14,24 +42,36 @@ do d) debug="ON" ;; - f) - franca="ON" + m) + capi=1 ;; h) html="ON" ;; + n) + navit=1 + ;; \?) echo "Usage:" - echo "$0 [-cdfh]" + echo "$0 [-cdmhn]" echo "-c: Rebuild with clean" echo "-d: Enable the debug messages" - echo "-f: Build using the Franca interfaces" + echo "-m: Build with commonAPI plugins " echo "-h: Enable migration to the html based hmi" + echo "-n: Build navit" exit 1 esac done set -e +if [ "$capi" = 1 ] +then + check_path_for_capi + cp ./hmi/qml/Core/genivi-capi.js ./hmi/qml/Core/genivi.js +else + cp ./hmi/qml/Core/genivi-origin.js ./hmi/qml/Core/genivi.js +fi + if [ "$clean" = 1 ] then echo 'clean up the build folder and regenerate all the stuff' @@ -50,27 +90,39 @@ cd navigation mkdir -p navit cd navit -echo 'build navit' -if [ "$clean" = 1 ] +if [ "$navit" = 1 ] then - cmake -DDISABLE_QT=1 -DSAMPLE_MAP=0 -Dvehicle/null=1 -Dgraphics/qt_qpainter=0 ../../../navigation/src/navigation/navit/ -fi -make -cd ../ - -echo 'build navigation' -if [ "$clean" = 1 ] -then - cmake -DWITH_DEBUG=$debug ../../navigation/src/navigation + echo 'build navit' + if [ "$clean" = 1 ] + then + cmake -DDISABLE_QT=1 -DSAMPLE_MAP=0 -Dvehicle/null=1 -Dgraphics/qt_qpainter=0 ../../../navigation/src/navigation/navit/ + fi + make +else + if [ "$clean" = 1 ] + then + echo 'build navit' + cmake -DDISABLE_QT=1 -DSAMPLE_MAP=0 -Dvehicle/null=1 -Dgraphics/qt_qpainter=0 ../../../navigation/src/navigation/navit/ + make + fi fi -make -cd .. +cd ../../ echo 'build fsa' if [ "$clean" = 1 ] then - cmake -DWITH_HTML_MIGRATION=$html -DWITH_FRANCA_DBUS_INTERFACE=$franca -DCOMMONAPI_DBUS_TOOL_DIR=$COMMONAPI_DBUS_TOOL_DIR -DCOMMONAPI_TOOL_DIR=$COMMONAPI_TOOL_DIR -DWITH_DEBUG=$debug ../ + if [ "$capi" = 0 ] + then + cmake -DWITH_HTML_MIGRATION=$html -DWITH_PLUGIN_MIGRATION=OFF -DWITH_DEBUG=$debug ../ + else + cmake -DWITH_HTML_MIGRATION=$html -DWITH_PLUGIN_MIGRATION=ON -DWITH_DBUS_INTERFACE=OFF $commonapi_tools_option -DWITH_DEBUG=$debug ../ + echo 'fix a bug in the generation of CommonAPI hpp' + sed -i -e 's/(const TimeStampedEnum::/(const ::v4::org::genivi::navigation::navigationcore::NavigationCoreTypes::TimeStampedEnum::/' ./navigation/franca/src-gen/v4/org/genivi/navigation/navigationcore/LocationInput.hpp + sed -i -e 's/(const TimeStampedEnum::/(const ::v4::org::genivi::navigation::navigationcore::NavigationCoreTypes::TimeStampedEnum::/' ./navigation/franca/src-gen/v4/org/genivi/navigation/navigationcore/MapMatchedPosition.hpp + sed -i -e 's/(const TimeStampedEnum::/(const ::v4::org::genivi::navigation::navigationcore::NavigationCoreTypes::TimeStampedEnum::/' ./poi-service/poi-server-capi/src-gen/v4/org/genivi/navigation/navigationcore/LocationInput.hpp + sed -i -e 's/(const TimeStampedEnum::/(const ::v4::org::genivi::navigation::navigationcore::NavigationCoreTypes::TimeStampedEnum::/' ./poi-service/poi-server-capi/src-gen/v4/org/genivi/navigation/navigationcore/MapMatchedPosition.hpp + fi fi make cd ../ diff --git a/src/clone_and_build.sh b/src/clone_and_build.sh index 0f00f85..e62ff43 100755 --- a/src/clone_and_build.sh +++ b/src/clone_and_build.sh @@ -1,8 +1,9 @@ #!/bin/bash -navigation_version='1cfa51e76ba173166c113eccf6a61a5904ff7e7d' +build_option="" +navigation_version='4c5be944a506f64427a25ada714a4a6f64e5ebf3' positioning_version='f341b4a2cb216d6204136794d33076170ab1bf80' -navit_version='0a8f85666a3b849d70ed450d74bed3cf85466630' +navit_version='c1b0faace0e241f743a1421e8826d84aacb2d153' echo "version of navigation is: $navigation_version" echo "version of positioning is: $positioning_version" @@ -16,6 +17,20 @@ then exit 1 fi +while getopts m opt +do + case $opt in + m) + build_option="-m" + ;; + \?) + echo "Usage:" + echo "$0 [-m]" + echo "-m: build with commonAPI plugins " + exit 1 + esac +done + if [ -d "./build" ] then find ./build ! -name '*.cbp' -type f -exec rm -f {} + @@ -38,7 +53,7 @@ patch -p0 -i ../patches/search_list_get_unique.diff patch -p0 -i ../patches/fsa_issue_padding.diff cd ../../../../ -./build.sh -c +./build.sh -c $build_option diff --git a/src/commonapi-dbus.ini b/src/commonapi-dbus.ini new file mode 100644 index 0000000..8a49d2c --- /dev/null +++ b/src/commonapi-dbus.ini @@ -0,0 +1,61 @@ +[local:org.genivi.navigation.navigationcore.Configuration:Configuration] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/Configuration +interface=org.genivi.navigation.navigationcore.Configuration +[local:org.genivi.navigation.navigationcore.Guidance:Guidance] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/Guidance +interface=org.genivi.navigation.navigationcore.Guidance +[local:org.genivi.navigation.navigationcore.LocationInput:LocationInput] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/LocationInput +interface=org.genivi.navigation.navigationcore.LocationInput +[local:org.genivi.navigation.navigationcore.MapMatchedPosition:MapMatchedPosition] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/MapMatchedPosition +interface=org.genivi.navigation.navigationcore.MapMatchedPosition +[local:org.genivi.navigation.navigationcore.Routing:Routing] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/Routing +interface=org.genivi.navigation.navigationcore.Routing +[local:org.genivi.navigation.navigationcore.Session:Session] +service=org.genivi.navigation.navigationcore +path=/org/genivi/navigation/navigationcore/Session +interface=org.genivi.navigation.navigationcore.Session +[local:org.genivi.navigation.poiservice.POIContentAccessModule:POIContentAccessModuleService] +service=org.genivi.navigation.poiservice +path=/org/genivi/navigation/poiservice/POIContentAccessModule +interface=org.genivi.navigation.poiservice.POIContentAccessModule +[local:org.genivi.navigation.poiservice.POIContentAccess:POIContentAccessService] +service=org.genivi.navigation.poiservice +path=/org/genivi/navigation/poiservice/POIContentAccess +interface=org.genivi.navigation.poiservice.POIContentAccess +[local:org.genivi.navigation.mapviewer.Configuration:Configuration] +service=org.genivi.navigation.mapviewer +path=/org/genivi/navigation/mapviewer/Configuration +interface=org.genivi.navigation.mapviewer.Configuration +[local:org.genivi.navigation.mapviewer.MapViewerControl:MapViewerControl] +service=org.genivi.navigation.mapviewer +path=/org/genivi/navigation/mapviewer/MapViewerControl +interface=org.genivi.navigation.mapviewer.MapViewerControl +[local:org.genivi.navigation.mapviewer.Session:Session] +service=org.genivi.navigation.mapviewer +path=/org/genivi/navigation/mapviewer/Session +interface=org.genivi.navigation.mapviewer.Session +[local:org.genivi.EnhancedPositionService.PositionFeedback:EnhancedPositionService] +service=org.genivi.EnhancedPositionService +path=/org/genivi/EnhancedPositionService/PositionFeedback +interface=org.genivi.EnhancedPositionService.PositionFeedback +[local:org.genivi.EnhancedPositionService.EnhancedPosition:EnhancedPositionService] +service=org.genivi.EnhancedPositionService +path=/org/genivi/EnhancedPositionService/EnhancedPosition +interface=org.genivi.EnhancedPositionService.EnhancedPosition +[local:org.genivi.EnhancedPositionService.Configuration:EnhancedPositionService] +service=org.genivi.EnhancedPositionService +path=/org/genivi/EnhancedPositionService/Configuration +interface=org.genivi.EnhancedPositionService.Configuration +[local:org.genivi.demonstrator.FuelStopAdvisor:FuelStopAdvisor] +service=org.genivi.FuelStopAdvisor +path=/org/genivi/demonstrator/FuelStopAdvisor +interface=org.genivi.demonstrator.FuelStopAdvisor + diff --git a/src/commonapi4dbus.ini b/src/commonapi4dbus.ini new file mode 100644 index 0000000..1e5b30b --- /dev/null +++ b/src/commonapi4dbus.ini @@ -0,0 +1,4 @@ +[default] +binding=dbus + + diff --git a/src/fuel-stop-advisor-capi/CMakeLists.txt b/src/fuel-stop-advisor-capi/CMakeLists.txt new file mode 100644 index 0000000..77e2fc2 --- /dev/null +++ b/src/fuel-stop-advisor-capi/CMakeLists.txt @@ -0,0 +1,138 @@ +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# Component Name: fuel-stop-advisor-capi +# +# 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(fuel-stop-advisor) +cmake_minimum_required(VERSION 2.8) + +message(STATUS ${PROJECT_NAME}) + +set(CMAKE_VERBOSE_MAKEFILE on) +set(CMAKE_CXX_FLAGS "-Wall -std=c++0x") +add_definitions("-std=gnu++11") + +include(FindPkgConfig) + +message(STATUS "generation of DBus files for AMB") + +find_program(DBUSXML2CPP dbusxx-xml2cpp REQUIRED) + +file (GLOB XML_TO_DBUS + ${CMAKE_CURRENT_SOURCE_DIR}/amb.xml +) +foreach (RAW_FILE ${XML_TO_DBUS}) + get_filename_component(FILE ${RAW_FILE} NAME_WE) + execute_process( + COMMAND ${DBUSXML2CPP} ${RAW_FILE} --proxy=${CMAKE_CURRENT_BINARY_DIR}/${FILE}_proxy.h + COMMAND ${DBUSXML2CPP} ${RAW_FILE} --adaptor=${CMAKE_CURRENT_BINARY_DIR}/${FILE}_adaptor.h + ) +endforeach() + + +# DBus Path +if(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) +pkg_search_module(DBUS_CPP dbus-c++-1) + +# generates the CommonAPI templates from the Franca files +set(COMMONAPI_GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/franca/src-gen") + +# for Navigation routing +set(API_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../navigation/api") +add_subdirectory(${API_DIR}/franca/navigation/navigationcore "${CMAKE_CURRENT_BINARY_DIR}/franca") +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 + +# for FSA +set(API_DIR_FSA "${CMAKE_CURRENT_SOURCE_DIR}/../../api") +add_subdirectory(${API_DIR_FSA}/franca "${CMAKE_CURRENT_BINARY_DIR}/franca-fsa") +set(PRJ_SRC_GEN_DEMONSTRATOR_PATH ${COMMONAPI_GEN_DIR}/v1/org/genivi/demonstrator) #files shared by the demonstrator APIs + +# Source Files +set(FRANCA_FILE "FuelStopAdvisor") +FILE(GLOB PRJ_LOCAL_SRCS fuel-stop-advisor.cpp) +FILE(GLOB PRJ_TRIPCOMPUTER_SRCS ${TRIPCOMPUTER_DIR}/ctripcomputer.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS + ${PRJ_SRC_GEN_DEMONSTRATOR_PATH}/${FRANCA_FILE}DBusStub*.cpp ${PRJ_SRC_GEN_DEMONSTRATOR_PATH}/${FRANCA_FILE}Types.cpp ${PRJ_SRC_GEN_DEMONSTRATOR_PATH}/${FRANCA_FILE}DBusDeployment.cpp ${PRJ_SRC_GEN_DEMONSTRATOR_PATH}/${FRANCA_FILE}StubDefault.cpp + ) +FILE(GLOB PRJ_STUB_IMPL_SRCS + ${PRJ_SRC_GEN_DEMONSTRATOR_PATH}/${FRANCA_FILE}Stub*.cpp + ) + +set(FRANCA_FILE_CLIENT "Routing") +FILE(GLOB PRJ_PROXY_GEN_SRCS + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH}/${FRANCA_FILE_CLIENT}*DBusProxy.cpp +) + + +set(PRJ_SRCS ${PRJ_LOCAL_SRCS} ${PRJ_TRIPCOMPUTER_SRCS} ${PRJ_STUB_GEN_SRCS} ${PRJ_PROXY_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) + +include_directories( + ${COMMONAPI_GEN_DIR} + ${PRJ_SRC_GEN_DEMONSTRATOR_PATH} + ${PRJ_SRC_GEN_NAVIGATION_PATH} + ${PRJ_SRC_GEN_NAVIGATIONCORE_PATH} + ${CMAKE_CURRENT_BINARY_DIR} + ${TRIPCOMPUTER_DIR} + ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_INCLUDE_DIRS} + ${COMMONAPI_DBUS_INCLUDE_DIRS} + ${GOBJECT_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} + ${DBUS_CPP_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} +) + +add_executable(fuel-stop-advisor ${PRJ_SRCS}) +target_link_libraries(fuel-stop-advisor ${LIBRARIES}) + diff --git a/src/fuel-stop-advisor-capi/amb.xml b/src/fuel-stop-advisor-capi/amb.xml new file mode 100644 index 0000000..966ec3f --- /dev/null +++ b/src/fuel-stop-advisor-capi/amb.xml @@ -0,0 +1,68 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<!-- GDBus 2.40.0 --> +<node> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="s" name="property_name" direction="in"/> + <arg type="v" name="value" direction="out"/> + </method> + <method name="GetAll"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="a{sv}" name="properties" direction="out"/> + </method> + <method name="Set"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="s" name="property_name" direction="in"/> + <arg type="v" name="value" direction="in"/> + </method> + <signal name="PropertiesChanged"> + <arg type="s" name="interface_name"/> + <arg type="a{sv}" name="changed_properties"/> + <arg type="as" name="invalidated_properties"/> + </signal> + </interface> + <interface name="org.automotive.Manager"> + <method name="FindObject"> + <arg type="s" name="searchstring" direction="in"> + </arg> + <arg type="ao" name="response" direction="out"> + </arg> + </method> + <method name="FindObjectForZone"> + <arg type="s" name="searchstring" direction="in"> + </arg> + <arg type="i" name="zone" direction="in"> + </arg> + <arg type="o" name="response" direction="out"> + </arg> + </method> + <method name="FindObjectForSourceZone"> + <arg type="s" name="searchstring" direction="in"> + </arg> + <arg type="s" name="source" direction="in"> + </arg> + <arg type="i" name="zone" direction="in"> + </arg> + <arg type="o" name="response" direction="out"> + </arg> + </method> + <method name="List"> + <arg type="as" name="response" direction="out"> + </arg> + </method> + <method name="ZonesForObjectName"> + <arg type="s" name="searchstring" direction="in"> + </arg> + <arg type="ai" name="response" direction="out"> + </arg> + </method> + <method name="SourcesForObjectName"> + <arg type="s" name="searchstring" direction="in"> + </arg> + <arg type="as" name="response" direction="out"> + </arg> + </method> + </interface> +</node> diff --git a/src/fuel-stop-advisor-capi/fuel-stop-advisor.cpp b/src/fuel-stop-advisor-capi/fuel-stop-advisor.cpp new file mode 100644 index 0000000..48ce2f4 --- /dev/null +++ b/src/fuel-stop-advisor-capi/fuel-stop-advisor.cpp @@ -0,0 +1,567 @@ +#include <dbus-c++/glib-integration.h> +#include <glib.h> +#include <stdio.h> +#include <unistd.h> + +#include "amb_proxy.h" +#include "ctripcomputer.h" +#include <boost/variant/get.hpp> + +#include <CommonAPI/CommonAPI.hpp> +#include <FuelStopAdvisorStubDefault.hpp> +#include <NavigationTypes.hpp> +#include <NavigationCoreTypes.hpp> +#include <RoutingProxy.hpp> + + +static GMainLoop *loop; + +#define dbgprintf(...) printf(__VA_ARGS__); + +#if (!DEBUG_ENABLED) +#undef dbgprintf +#define dbgprintf(...) ; +#endif + +using namespace v4::org::genivi::navigation::navigationcore; +using namespace v4::org::genivi::navigation; +using namespace v4::org::genivi; +using namespace v1::org::genivi::demonstrator; + +/* vehicle parameter */ +static double fuel_consumption_l_100km=6.3; + +static double fuel_consumption_speed[]={ + 6.0, /* 0-9 km/h */ + 6.0, /* 10-19 km/h */ + 6.0, /* 20-29 km/h */ + 6.0, /* 30-39 km/h */ + 4.5, /* 40-49 km/h */ + 4.5, /* 50-59 km/h */ + 4.5, /* 60-69 km/h */ + 5.5, /* 70-79 km/h */ + 5.5, /* 80-89 km/h */ + 7.0, /* 90-99 km/h */ + 7.0, /* 100-109 km/h */ + 7.0, /* 110-119 km/h */ + 7.0, /* 120-129 km/h */ +}; + + +static DBus::Variant +variant_uint16(uint16_t i) +{ + DBus::Variant variant; + DBus::MessageIter iter=variant.writer(); + iter << i; + return variant; +} + +static DBus::Variant +variant_uint32(uint32_t i) +{ + DBus::Variant variant; + DBus::MessageIter iter=variant.writer(); + iter << i; + return variant; +} + + +class Properties +: public ::DBus::InterfaceProxy, + public ::DBus::ObjectProxy +{ + public: + + Properties(::DBus::Connection &connection, ::DBus::Path path) + : ::DBus::InterfaceProxy("org.freedesktop.DBus.Properties"), + ::DBus::ObjectProxy(connection, path,"org.automotive.message.broker") + { + } + ::DBus::Variant Get(const std::string &iface, const std::string &property) + { + ::DBus::CallMessage call; + ::DBus::MessageIter wi = call.writer(); + + wi << iface; + wi << property; + call.member("Get"); + ::DBus::Message ret = invoke_method (call); + ::DBus::MessageIter ri = ret.reader(); + ::DBus::Variant argout; + ri >> argout; + return argout; + } +}; + + +class AutomotiveMessageBroker +: public org::automotive::Manager_proxy, + public DBus::ObjectProxy +{ + public: + + AutomotiveMessageBroker(DBus::Connection &connection) + : DBus::ObjectProxy(connection, "/","org.automotive.message.broker") + { + } +}; + +static std::shared_ptr < CommonAPI::Runtime > runtime; + +class RoutingClientProxy +{ + public: + + std::shared_ptr<RoutingProxyDefault> myServiceRouting; + + RoutingClientProxy(const std::string & domain, const std::string & instance) + { + myServiceRouting = runtime->buildProxy<RoutingProxy>(domain, instance); +// not working correctly (blocked) so removed for the moment +// while (!myServiceRouting->isAvailable()) { +// usleep(10); +// } + } + + 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) + { + } + + void routeCalculationSuccessful(const NavigationTypes::Handle& RouteHandle, const Routing::UnfullfilledRoutePreference& unfullfilledPreferences) + { + } + +}; + +static DBus::Glib::BusDispatcher amb_dispatcher; +static DBus::Connection *amb_conn; + +class FuelStopAdvisorServerStub +: public FuelStopAdvisorStubDefault +{ +public: + FuelStopAdvisorServerStub() + { + version_t version; + + //connect to amb and create two handlers for fuel and odometer + amb=new AutomotiveMessageBroker(*amb_conn); + + //init the routing client + const std::string domain = "local"; + const std::string instanceRouting = "Routing"; + mp_routingClientProxy = new RoutingClientProxy(domain,instanceRouting); + mp_routingClientProxy->setListeners(); + + fuel = amb->FindObject("Fuel"); + odometer = amb->FindObject("Odometer"); + + fuel_properties=new Properties(*amb_conn,fuel[0]); + odometer_properties=new Properties(*amb_conn,odometer[0]); + + // create an instance of basic trip computer and initialize it + mp_tripComputer = new CTripComputer(); + + mp_tripComputer->Initialize(CTripComputer::INSTANT_FUEL_CONSUMPTION_START_VALUE); + + version = mp_tripComputer->GetVersion(); //Get the version of the basic trip computer + + m_version.setVersionMajor(version.major); + m_version.setVersionMinor(version.minor); + m_version.setVersionMicro(version.micro); + m_version.setDate(version.date); + + + tripComputerInput_t tripComputerInput; + + tripComputerInput.fuelLevel = 0; + tripComputerInput.time = 0; + tripComputerInput.distance = 0; + tripComputerInput.fuelConsumption = 0; + + mp_tripComputer->RefreshTripComputerInput(tripComputerInput); + + for (uint8_t i; i<mp_tripComputer->GetSupportedTripNumbers();i++) + { + mp_tripComputer->ResetTrip(i); + } + + // init fsa settings + advisorMode=false; + distanceThreshold=0; + destinationCantBeReached=false; + routeHandle=0; + initFlag=true; + } + + /** + * 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: setUnits = This method sets the calculation unit for a given value + */ + void setUnits(const std::shared_ptr<CommonAPI::ClientId> _client, FuelStopAdvisor::Units _unit, setUnitsReply_t _reply) { + FuelStopAdvisor::Units::const_iterator iter; + tupleInt32_t data; + for(iter=_unit.begin();iter!=_unit.end();++iter) + { + data[(iter->first)]=(iter->second); + } + mp_tripComputer->SetUnits(data); //Set units of the basic trip computer + _reply(); + } + + /** + * description: getInstantData = This method returns a given set of global (not related to a + * trip number) trip computer data (e.g. odometer, fuel level, tank distance... ) + */ + void getInstantData(const std::shared_ptr<CommonAPI::ClientId> _client, getInstantDataReply_t _reply) { + FuelStopAdvisor::InstantData _data; + tupleVariantTripComputer_t tripComputerData; + tupleVariantTripComputer_t::iterator iter; + variantTripComputer_t value; + uint16_t level; + double remaining; + + tripComputerData= mp_tripComputer->GetInstantData(); + + for(iter = tripComputerData.begin(); iter != tripComputerData.end(); iter++) + { + value = iter->second; + if (iter->first == CTripComputer::TRIPCOMPUTER_INSTANT_FUEL_CONSUMPTION_PER_DISTANCE) + { + _data[FuelStopAdvisor::InstantDataAttribute::INSTANT_FUEL_CONSUMPTION_PER_DISTANCE]= boost::get<uint16_t>(iter->second); + } + else + { + if (iter->first == CTripComputer::TRIPCOMPUTER_TANK_DISTANCE) + { //tank distance is valid, so it means that fuel level is valid too + _data[FuelStopAdvisor::InstantDataAttribute::TANK_DISTANCE]=boost::get<uint16_t>(iter->second); + _data[FuelStopAdvisor::InstantDataAttribute::FUEL_LEVEL]=fuelLevel; + if (this->routeHandle != 0) + { // a route is valid so it makes sense to calculate enhanced tank distance + _data[FuelStopAdvisor::InstantDataAttribute::ENHANCED_TANK_DISTANCE]=(uint16_t)(enhancedDistance(fuelLevel,remaining)+0.5); + } + } + } + } + + _reply(_data); + } + + /** + * description: getTripData = This method returns the data of a given trip number + */ + void getTripData(const std::shared_ptr<CommonAPI::ClientId> _client, FuelStopAdvisor::TripNumber _number, getTripDataReply_t _reply) { + FuelStopAdvisor::TripData _data; + tupleVariantTripComputer_t tripComputerData; + tupleVariantTripComputer_t::iterator iter; + variantTripComputer_t value; + + if (_number >= mp_tripComputer->GetSupportedTripNumbers()) + throw DBus::ErrorInvalidArgs("Invalid trip number"); + + tripComputerData= mp_tripComputer->GetTripData(_number); + for(iter = tripComputerData.begin(); iter != tripComputerData.end(); iter++) + { + value = iter->second; + if (iter->first == CTripComputer::TRIPCOMPUTER_AVERAGE_FUEL_CONSUMPTION_PER_DISTANCE) + { + _data[FuelStopAdvisor::TripDataAttribute::AVERAGE_FUEL_CONSUMPTION_PER_DISTANCE]=boost::get<uint16_t>(iter->second); + } + else + { + if (iter->first == CTripComputer::TRIPCOMPUTER_AVERAGE_SPEED) + { + _data[FuelStopAdvisor::TripDataAttribute::AVERAGE_SPEED]=boost::get<uint16_t>(iter->second); + } + else + { + if (iter->first == CTripComputer::TRIPCOMPUTER_DISTANCE) + { + _data[FuelStopAdvisor::TripDataAttribute::DISTANCE]=boost::get<uint16_t>(iter->second); + } + } + } + } + _reply(_data); + + } + + /** + * description: getSupportedTripNumbers = This method returns the number of supported trips + */ + void getSupportedTripNumbers(const std::shared_ptr<CommonAPI::ClientId> _client, getSupportedTripNumbersReply_t _reply) { + _reply(mp_tripComputer->GetSupportedTripNumbers()); + } + + /** + * description: setFuelAdvisorSettings = This method configures the fuel stop advisor settings + */ + void setFuelAdvisorSettings(const std::shared_ptr<CommonAPI::ClientId> _client, bool _advisorMode, uint8_t _distanceThreshold, setFuelAdvisorSettingsReply_t _reply) { + dbgprintf("SetFuelAdvisorSettings(%d,%d)\n",advisorMode, distanceThreshold); + advisorMode=_advisorMode; + distanceThreshold=_distanceThreshold; + updateEnhancedDistance(); + _reply(); + } + + /** + * description: resetTripData = This method resets the data of a given trip + */ + void resetTripData(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _number, resetTripDataReply_t _reply) { + if (_number >= mp_tripComputer->GetSupportedTripNumbers()) + throw DBus::ErrorInvalidArgs("Invalid trip number"); + mp_tripComputer->ResetTrip(_number); + fireTripDataResettedEvent(_number); + _reply(); + } + + /** + * description: getFuelAdvisorSettings = This method gets the fuel stop advisor settings + */ + void getFuelAdvisorSettings(const std::shared_ptr<CommonAPI::ClientId> _client, getFuelAdvisorSettingsReply_t _reply) { + bool _advisorMode; + uint8_t _distanceThreshold; + bool _destinationCantBeReached; + _advisorMode=advisorMode; + _distanceThreshold=distanceThreshold; + _destinationCantBeReached=destinationCantBeReached; + _reply(_advisorMode,_distanceThreshold,_destinationCantBeReached); + } + + /** + * description: setRouteHandle = This method configures the route handle for the enhanced tank + * distance + */ + void setRouteHandle(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _routeHandle, setRouteHandleReply_t _reply) { + dbgprintf("SetRouteHandle %d\n",_routeHandle); + routeHandle=_routeHandle; + updateEnhancedDistance(); + _reply(); + } + + /** + * description: releaseRouteHandle = This method release the route handle for the enhanced tank + * distance + */ + void releaseRouteHandle(const std::shared_ptr<CommonAPI::ClientId> _client, uint32_t _routeHandle, releaseRouteHandleReply_t _reply) { + dbgprintf("ResetRouteHandle %d\n",_routeHandle); + routeHandle=0; + updateEnhancedDistance(); + _reply(); + } + + + double fuelConsumptionAtSpeed(uint16_t seg_speed) + { + if (seg_speed > 129) + seg_speed=129; + return fuel_consumption_speed[seg_speed/10]; + } + + double enhancedDistance(double level, double &remaining) + { + double distance=0; + dbgprintf("routeHandle %d\n",routeHandle); + if (routeHandle) { + std::vector< Routing::RouteSegment > RouteShape; + std::vector< Routing::RouteSegmentType > valuesToReturn; + uint32_t totalNumberOfSegments; + valuesToReturn.push_back(Routing::RouteSegmentType::DISTANCE); + valuesToReturn.push_back(Routing::RouteSegmentType::SPEED); + CommonAPI::CallStatus _internalCallStatus; + mp_routingClientProxy->myServiceRouting->getRouteSegments(routeHandle, 1, valuesToReturn, 0xffffffff, 0,_internalCallStatus, totalNumberOfSegments, RouteShape); + for (size_t i=0 ; i < RouteShape.size(); i++) { + double seg_distance; + uint16_t seg_speed; + + seg_distance=RouteShape[i][Routing::RouteSegmentType::DISTANCE].get<double>(); + seg_speed=RouteShape[i][Routing::RouteSegmentType::SPEED].get<uint16_t>(); + if (seg_distance && seg_speed) { + double fuel_consumption=fuelConsumptionAtSpeed(seg_speed)*seg_distance/100000; + if (fuel_consumption > level && level > 0) { + seg_distance=seg_distance*level/fuel_consumption; + fuel_consumption=level; + } + if (level > 0) + distance+=seg_distance; + level-=fuel_consumption; + } + } + dbgprintf("%d segments\n",totalNumberOfSegments); + } + remaining=level/fuel_consumption_l_100km*100; + dbgprintf("distance_on_route %f remaining %f\n",distance/1000,remaining); + return distance/1000+(remaining > 0 ? remaining:0); + } + + void update_data() + { + tripComputerInput_t tripComputerInput; + DBus::Variant variant; + DBus::MessageIter it; + uint32_t odometer; + uint16_t level; + uint32_t consumption; + double time; + + + variant=fuel_properties->Get("org.automotive.Fuel","Level"); + it=variant.reader(); + it >> level; + + variant=odometer_properties->Get("org.automotive.Odometer","Time"); + it=variant.reader(); + it >> time; + + //odometer is used for simulating distance + variant=odometer_properties->Get("org.automotive.Odometer","Odometer"); + it=variant.reader(); + it >> odometer; + + if (initFlag) + { + if (time != 0) + { + initFlag = false; + lastTime = time; + lastOdometer = odometer; + } + timeCounter = 0; + distanceCounter = 0; + } + else + { + if ((timeCounter+(time-lastTime)*CTripComputer::CONVERT_SECOND_IN_MILLISECOND) > USHRT_MAX) + { + timeCounter = (time-lastTime)*CTripComputer::CONVERT_SECOND_IN_MILLISECOND - (USHRT_MAX - timeCounter); + } + else + { + timeCounter += (time-lastTime)*CTripComputer::CONVERT_SECOND_IN_MILLISECOND; + } + lastTime = time; + +// if ((distanceCounter+(odometer-lastOdometer)) > USHRT_MAX) + if ((distanceCounter+odometer) > USHRT_MAX) + { +// distanceCounter = (odometer-lastOdometer) - (USHRT_MAX - distanceCounter); + distanceCounter = (distanceCounter+odometer)-USHRT_MAX ; + } + else + { +// distanceCounter += (odometer-lastOdometer); + distanceCounter += odometer; + } +// lastOdometer = odometer; + + } + tripComputerInput.time = timeCounter; + tripComputerInput.distance = distanceCounter; + + variant=fuel_properties->Get("org.automotive.Fuel","InstantConsumption"); + it=variant.reader(); + it >> consumption; + + tripComputerInput.fuelLevel = level*CTripComputer::CONVERT_LITER_IN_DL; + tripComputerInput.fuelConsumption = consumption; + + mp_tripComputer->RefreshTripComputerInput(tripComputerInput); + + fuelLevel = level; //to avoid re-ask it to amb + + fireTripDataUpdatedEvent(0); //arg is for future use + } + + void updateEnhancedDistance() + { + double remaining; + if (advisorMode) { + enhancedDistance(fuelLevel, remaining); + dbgprintf("Advisor %f vs %d\n",remaining, distanceThreshold); + if (remaining < distanceThreshold) { + dbgprintf("Warning %f < %d\n",remaining, distanceThreshold); + destinationCantBeReached = true; + } + else + { + destinationCantBeReached = false; + } + fireFuelStopAdvisorWarningEvent(destinationCantBeReached); + fireTripDataUpdatedEvent(0); //arg is for future use + } + } + + + private: + RoutingClientProxy* mp_routingClientProxy; + FuelStopAdvisor::Version m_version; + AutomotiveMessageBroker *amb; + std::vector< ::DBus::Path > fuel; + std::vector< ::DBus::Path > odometer; + Properties *fuel_properties; + Properties *odometer_properties; + CTripComputer *mp_tripComputer; + bool advisorMode; + uint8_t distanceThreshold; + bool destinationCantBeReached; + uint32_t routeHandle; + bool initFlag; + double lastTime; + uint16_t timeCounter; + uint32_t lastOdometer; + uint16_t distanceCounter; + uint16_t fuelLevel; +}; + +static gboolean +update_data(gpointer user_data) +{ + FuelStopAdvisorServerStub *tc=(FuelStopAdvisorServerStub *)user_data; + tc->update_data(); + return TRUE; +} + +int main(int argc, char **argv) +{ + loop=g_main_loop_new(NULL, false); + + // Init AMB DBus connection + amb_dispatcher.attach(NULL); + DBus::default_dispatcher = &amb_dispatcher; + amb_conn = new DBus::Connection(DBus::Connection::SessionBus()); + amb_conn->setup(&amb_dispatcher); + + // Common API data init + runtime = CommonAPI::Runtime::get(); + + // init the Fuel Stop Advisor server + const std::string domain = "local"; + const std::string instanceFuelStopAdvisor = "FuelStopAdvisor"; + + std::shared_ptr<FuelStopAdvisorServerStub> myServiceFuelStopAdvisor = std::make_shared<FuelStopAdvisorServerStub>(); + + bool successfullyRegistered = runtime->registerService(domain, instanceFuelStopAdvisor, myServiceFuelStopAdvisor); + while (!successfullyRegistered) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instanceFuelStopAdvisor, myServiceFuelStopAdvisor); + } + + g_timeout_add(CTripComputer::SAMPLING_TIME*CTripComputer::CONVERT_SECOND_IN_MILLISECOND, update_data, myServiceFuelStopAdvisor.get()); + g_main_loop_run(loop); +} diff --git a/src/fuel-stop-advisor/CMakeLists.txt b/src/fuel-stop-advisor/CMakeLists.txt index 2148ab6..5f78033 100644 --- a/src/fuel-stop-advisor/CMakeLists.txt +++ b/src/fuel-stop-advisor/CMakeLists.txt @@ -29,7 +29,7 @@ include_directories( ${DBUS_CPP_INCLUDE_DIRS} ${DBUS_CPP_GLIB_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} - ${DBUS_GENERATED_INCLUDE_DIR_PARENT_SCOPE}/navigation-core + ${DBUS_GENERATED_INCLUDE_DIR}/navigation-core ${TRIPCOMPUTER_DIR} ) diff --git a/src/fuel-stop-advisor/fuel-stop-advisor.cpp b/src/fuel-stop-advisor/fuel-stop-advisor.cpp index f458c0b..0a41286 100644 --- a/src/fuel-stop-advisor/fuel-stop-advisor.cpp +++ b/src/fuel-stop-advisor/fuel-stop-advisor.cpp @@ -45,22 +45,26 @@ static double fuel_consumption_speed[]={ }; -static DBus::Variant +static ::DBus::Struct< uint8_t, ::DBus::Variant > variant_uint16(uint16_t i) { DBus::Variant variant; + ::DBus::Struct< uint8_t, ::DBus::Variant > ret; DBus::MessageIter iter=variant.writer(); iter << i; - return variant; + ret._2 = variant; + return ret; } -static DBus::Variant +static ::DBus::Struct< uint8_t, ::DBus::Variant > variant_uint32(uint32_t i) { DBus::Variant variant; - DBus::MessageIter iter=variant.writer(); + ::DBus::Struct< uint8_t, ::DBus::Variant > ret; + DBus::MessageIter iter=variant.writer(); iter << i; - return variant; + ret._2 = variant; + return ret; } @@ -208,15 +212,15 @@ class FuelStopAdvisor } void - SetUnits(const std::map< uint16_t, uint16_t >& data) + SetUnits(const std::map< int32_t, int32_t >& data) { mp_tripComputer->SetUnits(data); //Set units of the basic trip computer } - std::map< uint16_t, ::DBus::Variant > + std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetInstantData() { - std::map< uint16_t, ::DBus::Variant > ret; + std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > ret; tupleVariantTripComputer_t tripComputerData; tupleVariantTripComputer_t::iterator iter; variantTripComputer_t value; @@ -255,10 +259,10 @@ class FuelStopAdvisor return (mp_tripComputer->GetSupportedTripNumbers()); } - std::map< uint16_t, ::DBus::Variant > + std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetTripData(const uint8_t& number) { - std::map< uint16_t, ::DBus::Variant > ret; + std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > ret; tupleVariantTripComputer_t tripComputerData; tupleVariantTripComputer_t::iterator iter; variantTripComputer_t value; diff --git a/src/fuel-stop-advisor/fuel-stop-advisor.xml b/src/fuel-stop-advisor/fuel-stop-advisor.xml index a7cf2ef..c66bfd9 100644 --- a/src/fuel-stop-advisor/fuel-stop-advisor.xml +++ b/src/fuel-stop-advisor/fuel-stop-advisor.xml @@ -31,7 +31,7 @@ <line>SetUnits = This method sets the calculation unit for a given value</line> </doc> - <arg name="data" type="a{qq}" direction="in"> + <arg name="data" type="a{ii}" direction="in"> <doc> <line>data = dictionary[key,value]</line> <line>dictionary = array of tuples (key,value)</line> @@ -48,7 +48,7 @@ <line>GetInstantData = This method returns a given set of global (not related to a trip number) trip computer data (e.g. odometer, fuel level, tank distance... )</line> </doc> - <arg name="data" type="a{qv}" direction="out"> + <arg name="data" type="a{i(yv)}" direction="out"> <doc> <line>data = dictionary[key,value]</line> <line>dictionary = array of tuples (key,value)</line> @@ -85,7 +85,7 @@ </doc> </arg> - <arg name="tripData" type="a{qv}" direction="out"> + <arg name="tripData" type="a{i(yv)}" direction="out"> <doc> <line>data = dictionary[key,value]</line> <line>dictionary = array of tuples (key,value)</line> diff --git a/src/hmi/qml/Core/.gitignore b/src/hmi/qml/Core/.gitignore index 12e875f..99942f1 100644 --- a/src/hmi/qml/Core/.gitignore +++ b/src/hmi/qml/Core/.gitignore @@ -1 +1,2 @@ resource.js +genivi.js diff --git a/src/hmi/qml/Core/genivi-capi.js b/src/hmi/qml/Core/genivi-capi.js new file mode 100644 index 0000000..a5e0de2 --- /dev/null +++ b/src/hmi/qml/Core/genivi-capi.js @@ -0,0 +1,871 @@ +/** +* @licence app begin@ +* SPDX-License-Identifier: MPL-2.0 +* +* \copyright Copyright (C) 2013-2016, PCA Peugeot Citroen +* +* \file genivi-capi.js +* +* \brief This file is part of the navigation hmi. It defines basic functions used by the QML files, for the CommonAPI version of the FSA. +* +* \author Martin Schaller <martin.schaller@it-schaller.de> +* \author Philippe Colliot <philippe.colliot@mpsa.com> +* +* \version 1.1 +* +* 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-05, Philippe Colliot, migration to the new HMI design +* <date>, <name>, <description of change> +* +* @licence end@ +*/ +.pragma library + +Qt.include("resource.js") + +var dbusIf; +var g_nav_session=["uint32",0]; +var g_locationinput_handle=["uint32",0]; +var g_routing_handle=["uint32",0]; +var g_mapviewer_session=["uint32",0]; +var g_mapviewer_handle=["uint32",0]; +var g_mapviewer_handle2=["uint32",0]; +var g_poisearch_handle=["uint32",0]; +var g_lang; + +var data=new Array; + +var poi_data=new Array; +var poi_id; + +var translations=new Array; + +var simulationPanelOnMapview=true;// simulation panel on map view by default + +var guidance_activated=false; //used by the HMI to directly go to map when guidance is on (reroute use case) +var route_calculated=false; //no route (managed by NavigationRoute and NavigationCalculatedRoute) + +var entryback = new Array; +var entrybackheapsize=0; +entryback[entrybackheapsize]=""; +var entrydest; +var entrycriterion; +var entryselectedentry; + +var entrycancel = false; //set to true when back button is pushed without any selection + +var roadPreferenceList=new Object; +roadPreferenceList[NAVIGATIONCORE_FERRY]=NAVIGATIONCORE_AVOID; +roadPreferenceList[NAVIGATIONCORE_TOLL_ROADS]=NAVIGATIONCORE_AVOID; +roadPreferenceList[NAVIGATIONCORE_HIGHWAYS_MOTORWAYS]=NAVIGATIONCORE_AVOID; +var conditionPreferenceList=new Object; +conditionPreferenceList[NAVIGATIONCORE_TRAFFIC_REALTIME]=NAVIGATIONCORE_AVOID; + +var Maneuver = new Object; +Maneuver[NAVIGATIONCORE_INVALID]="INV"; +Maneuver[NAVIGATIONCORE_CRUISE]="CRU"; +Maneuver[NAVIGATIONCORE_MANEUVER_APPEARED]="APP"; +Maneuver[NAVIGATIONCORE_PRE_ADVICE]="PRE"; +Maneuver[NAVIGATIONCORE_ADVICE]="ADV"; +Maneuver[NAVIGATIONCORE_PASSED]="PAS"; + + +var ManeuverType = new Object; +ManeuverType[NAVIGATIONCORE_INVALID]="INVALID"; +ManeuverType[NAVIGATIONCORE_STRAIGHT_ON]="STRAIGHT_ON"; +ManeuverType[NAVIGATIONCORE_CROSSROAD]="CROSSROAD"; +ManeuverType[NAVIGATIONCORE_ROUNDABOUT]="ROUNDABOUT"; +ManeuverType[NAVIGATIONCORE_HIGHWAY_ENTER]="HIGHWAY_ENTER"; +ManeuverType[NAVIGATIONCORE_HIGHWAY_EXIT]="HIGHWAY_EXIT"; +ManeuverType[NAVIGATIONCORE_FOLLOW_SPECIFIC_LANE]="FOLLOW_SPECIFIC_LANE"; +ManeuverType[NAVIGATIONCORE_DESTINATION]="DESTINATION"; +ManeuverType[NAVIGATIONCORE_WAYPOINT]="WAYPOINT"; + +var ManeuverDirection = new Object; +ManeuverDirection[NAVIGATIONCORE_INVALID]="INVALID"; +ManeuverDirection[NAVIGATIONCORE_STRAIGHT_ON]="STRAIGHT_ON"; +ManeuverDirection[NAVIGATIONCORE_LEFT]="LEFT"; +ManeuverDirection[NAVIGATIONCORE_SLIGHT_LEFT]="SLIGHT_LEFT"; +ManeuverDirection[NAVIGATIONCORE_HARD_LEFT]="HARD_LEFT"; +ManeuverDirection[NAVIGATIONCORE_RIGHT]="RIGHT"; +ManeuverDirection[NAVIGATIONCORE_SLIGHT_RIGHT]="SLIGHT_RIGHT"; +ManeuverDirection[NAVIGATIONCORE_HARD_RIGHT]="HARD_RIGHT"; +ManeuverDirection[NAVIGATIONCORE_UTURN_RIGHT]="UTURN_RIGHT"; +ManeuverDirection[NAVIGATIONCORE_UTURN_LEFT]="UTURN_LEFT"; + +var CostModels = new Object; +CostModels[NAVIGATIONCORE_INVALID]="INVALID"; +CostModels[NAVIGATIONCORE_FASTEST]="FASTEST"; +CostModels[NAVIGATIONCORE_SHORTEST]="SHORTEST"; + +var preloadMode=false; //set to true when the address is restored +var address = new Object; //to store the address, in order to make the hmi more friendly :-) +var tripMode; //trip mode to be displayed by the trip computer menu ("TRIP_NUMBER1", "TRIP_NUMBER2" or "TRIP_INSTANT") +var historyOfLastEnteredLocationDepth; +var historyOfLastEnteredLocation = new Array; //to store the last entered locations (for consistency, it'd be nice to "remapmatch" it when the map is upadted) +var historyOfLastEnteredLat = new Array; //dirty but need to know how to do it in qml +var historyOfLastEnteredLon = new Array; //dirty but need to know how to do it in qml +var historyOfLastEnteredLocationIn=0; //next input +var historyOfLastEnteredLocationOut=0; //first ouput +var radius=5000; //radius in m around the vehicle to search for the refill stations +var offset=0; //offset of the start record to get on the list of pois +var maxWindowSize=20; //max size of elements to return as a result +var fuelCategoryId; //unique id of fuel category + +//the default data below will be managed by the persistency component in the future +address[NAVIGATIONCORE_COUNTRY]="Switzerland"; +address[NAVIGATIONCORE_CITY]="Zürich"; +address[NAVIGATIONCORE_STREET]="In Lampitzäckern"; +address[NAVIGATIONCORE_HOUSENUMBER]=""; +historyOfLastEnteredLocationDepth=10; //max number of items into the history is set to historyOfLastEnteredLocationDepth-1 +tripMode="TRIP_NUMBER1"; + +//dump functions for debug +function dump2(prefix,index,args) +{ + for (var i=0 ; i < args.length ; i+=2) { + var i1=index+"["+i+"]"; + var i2=index+"["+(i+1)+"]"; + if (args[i] == "array" || args[i] == "map" || args[i] == "structure") { + console.log(prefix+i1+args[i]+":"); + dump2(prefix,i2,args[i+1]); + } else if (args[i] == "variant" || args[i] == "error") { + dump2(prefix+i1+args[i]+":",i2,args[i+1]); + } else { + console.log(prefix+i1+args[i]+":"+i2+args[i+1]); + } + } +} + +function dump(prefix,args) +{ + dump2(prefix,"",args); +} + +//Manage the historyOfLastEnteredLocation +function updateHistoryOfLastEnteredLocation(enteredLocation,enteredLat,enteredLon) +{ + //"fifo like" management + historyOfLastEnteredLocation[historyOfLastEnteredLocationIn] = enteredLocation; + historyOfLastEnteredLat[historyOfLastEnteredLocationIn] = enteredLat; + historyOfLastEnteredLon[historyOfLastEnteredLocationIn] = enteredLon; + + if ((historyOfLastEnteredLocationIn+1) >= historyOfLastEnteredLocationDepth) + historyOfLastEnteredLocationIn=0; + else + historyOfLastEnteredLocationIn+=1; + + if (historyOfLastEnteredLocationOut == historyOfLastEnteredLocationIn) + { //fifo is full, so remove one entry + if ((historyOfLastEnteredLocationOut+1) >= historyOfLastEnteredLocationDepth) + historyOfLastEnteredLocationOut=0; + else + historyOfLastEnteredLocationOut+=1; + } +} + +// Give the formated distance +function distance(meter) +{ + if (meter >= 10000) { + return Math.round(meter/1000)+"km"; + } else { + return meter+"m"; + } +} + +// Give the formated time +function time(seconds) +{ + if (seconds >= 3600) { + return Math.floor(seconds/3600)+":"+(Math.floor(seconds/60)%60)+":"+(seconds%60); + } else { + return Math.floor(seconds/60)+":"+(seconds%60); + } +} + +// Language and text +function setlang(lang) +{ + g_lang=lang; + translations = new Array; + Qt.include("translations/"+lang+".js"); +} + +function gettext(arg) +{ + if (!translations[arg]) { + if (g_lang) { + console.log("Translation for '" + arg + "' missing for " + g_lang); + } + return arg; + } else { + return translations[arg]; + } +} + +//----------------- Management of the DBus messages ----------------- + +// Send a dbus message to layer manager +function lm_message(par, func, args) +{ + return par.message("org.genivi.layermanagementservice","/org/genivi/layermanagementservice","org.genivi.layermanagementservice", func, args); +} + +// Send a message to navigationcore (basic) +function navigationcore_message(par, iface, func, args) +{ + return par.message("org.genivi.navigation.navigationcore."+iface+"_"+iface,"/"+iface,"org.genivi.navigation.navigationcore."+iface, func, args); +} + +// Send a message to mapviewer (basic) +function mapviewer_message(par, iface, func, args) +{ + return par.message("org.genivi.navigation.mapviewer."+iface+"_"+iface,"/"+iface,"org.genivi.navigation.mapviewer."+iface, func, args); +} + +// Send a message to poiservice (basic) +function poi_message(par, iface, func, args) +{ + return par.message("org.genivi.navigation.poiservice."+iface+"_"+iface,"/"+iface,"org.genivi.navigation.poiservice."+iface, func, args); +} + +// Send a message to demonstrator (basic) +function demonstrator_message(par, iface, func, args) +{ + return par.message("org.genivi.demonstrator."+iface,"/org/genivi/demonstrator"+iface,"org.genivi.demonstrator."+iface, func, args); +} + +//----------------- NavigationCore dbus messages ----------------- + +//----------------- Navigation core Session messages ----------------- + +function navigationcore_session_message(par, func, args) +{ + return navigationcore_message(par, "Session", func, args); +} + +// Create a new session or get the current session +function navigationcore_session(par) { + if (!g_nav_session[1]) + { + var res=navigationcore_session_message(par,"CreateSession", ["string","TestHMI"]); + g_nav_session[1]=res[3]; + } + return g_nav_session; +} + +// Delete the current session if exists +function navigationcore_session_clear(par) +{ + if (g_nav_session[1]) { + var res=navigationcore_session_message(par,"deleteSession", [g_nav_session]); + g_nav_session[1]=0; + } +} + +function navigationcore_session_GetVersion(par) +{ + return navigationcore_session_message(par,"getVersion",[]); +} + + +//----------------- Navigation core Configuration messages ----------------- + +function navigationcore_configuration_message(par, func, args) +{ + return navigationcore_message(par, "Configuration", func,args); +} + +function navigationcore_configuration_GetSupportedLocales(dbusIf) +{ + return navigationcore_configuration_message(dbusIf,"getSupportedLocales",[]); +} + +function navigationcore_configuration_GetLocale(dbusIf) +{ + return navigationcore_configuration_message(dbusIf,"getLocale",[]); +} + +function navigationcore_configuration_SetLocale(dbusIf,language,country,script) +{ + navigationcore_configuration_message(dbusIf,"setLocale",["string",language,"string",country,"string",script]); +} + +function navigationcore_configuration_GetUnitsOfMeasurement(dbusIf) +{ + return navigationcore_configuration_message(dbusIf,"getUnitsOfMeasurement",[]); +} + +function navigationcore_configuration_SetUnitsOfMeasurementLength(dbusIf,unit) +{ + navigationcore_configuration_message(dbusIf,"setUnitsOfMeasurement",["map",["int32",NAVIGATIONCORE_LENGTH,"int32",unit]]); +} + +//----------------- LocationInput messages ----------------- + +// Create a new location handle or get the current handle +function locationinput_handle(par) +{ + if (!g_locationinput_handle[1]) + { + var res=navigationcore_message(par, "LocationInput","createLocationInput", navigationcore_session(par)).slice(0,2); + g_locationinput_handle[1]=res[3]; + } + return g_locationinput_handle; +} + +function locationinput_message(par, func, args) +{ + return navigationcore_message(par, "LocationInput", func, navigationcore_session(par).concat(locationinput_handle(par),args)); +} + +function locationinput_Spell(dbusIf,inputCharacter,maxWindowSize) +{ + locationinput_message(dbusIf,"spell",["string",inputCharacter,"uint16",maxWindowSize]); +} + +function locationinput_RequestListUpdate(dbusIf,offset,maxWindowSize) +{ + locationinput_message(dbusIf,"requestListUpdate",["uint16",offset,"uint16",maxWindowSize]); +} + +function locationinput_SetSelectionCriterion(dbusIf,selectionCriterion) +{ + locationinput_message(dbusIf,"setSelectionCriterion",["int32",selectionCriterion]); +} + +function locationinput_Search(dbusIf,inputString,maxWindowSize) +{ + locationinput_message(dbusIf,"search",["string",inputString,"uint16",maxWindowSize]); +} + +function locationinput_SelectEntry(dbusIf,index) +{ + locationinput_message(dbusIf,"selectEntry",["uint16",index]); +} + +// Delete the location handle if exists +function locationinput_handle_clear(par) +{ + if (g_locationinput_handle[1]) { + var res=locationinput_message(par, "deleteLocationInput", []); + g_locationinput_handle[1]=0; + } +} + +//----------------- Routing messages ----------------- + +// Send a message to routing with session handle +function routing_message(par, func, args) +{ //session handle sent + return navigationcore_message(par, "Routing", func, navigationcore_session(par).concat(routing_handle(par),args)); +} + +// Send a message to routing without session handle +function routing_get(par, func, args) +{ + return navigationcore_message(par, "Routing", func, routing_handle(par).concat(args)); +} + +// Create a new routing handle or get the current handle +function routing_handle(par) { + if (!g_routing_handle[1]) + { + var res=navigationcore_message(par, "Routing","createRoute", navigationcore_session(par)); + g_routing_handle[1]=res[3]; + } + return g_routing_handle; +} + +// Delete the routing handle if exists +function routing_handle_clear(par) +{ + if (g_routing_handle[1]) { + var res=routing_message(par, "deleteRoute", []); + g_routing_handle[1]=0; + } +} + +function routing_GetRouteOverviewTimeAndDistance(dbusIf) +{ + var valuesToReturn=[], pref=[]; + pref=pref.concat("int32",NAVIGATIONCORE_TOTAL_TIME,"int32",NAVIGATIONCORE_TOTAL_DISTANCE); + valuesToReturn = valuesToReturn.concat("array",[pref]); + + return routing_get(dbusIf,"getRouteOverview",valuesToReturn); +} + +function routing_GetCostModel(dbusIf) +{ + return routing_message(dbusIf,"getCostModel",[]); +} + +function routing_SetCostModel(dbusIf,costModel) +{ + var res=routing_message(dbusIf,"setCostModel",["int32",costModel]); +} + +function routing_GetSupportedCostModels(dbusIf) +{ + return routing_message(dbusIf,"getSupportedCostModels",[]); +} + +function routing_GetSupportedRoutePreferences(dbusIf) +{ + return routing_message(dbusIf,"getSupportedRoutePreferences",[]); +} + +function routing_GetRoutePreferences(dbusIf,countryCode) +{ + return routing_get(dbusIf,"getRoutePreferences",["string",countryCode]); +} + +function routing_SetRoutePreferences(dbusIf,countryCode) +{ + var roadMessage=["array",["structure",["int32",roadPreferenceList[NAVIGATIONCORE_FERRY],"int32",NAVIGATIONCORE_FERRY],"structure",["int32",roadPreferenceList[NAVIGATIONCORE_TOLL_ROADS],"int32",NAVIGATIONCORE_TOLL_ROADS],"structure",["int32",roadPreferenceList[NAVIGATIONCORE_HIGHWAYS_MOTORWAYS],"int32",NAVIGATIONCORE_HIGHWAYS_MOTORWAYS]]]; + var conditionMessage=["array",["structure",["int32",conditionPreferenceList[NAVIGATIONCORE_TRAFFIC_REALTIME],"int32",NAVIGATIONCORE_TRAFFIC_REALTIME]]]; + var message=["string",countryCode]; + message=message.concat(roadMessage.concat(conditionMessage)); + var res=routing_message(dbusIf,"setRoutePreferences",message); + dump("setRoutePreferences",res); +} + +function routing_GetRouteSegments(dbusIf,detailLevel,numberOfSegments,offset) +{ + var routeSegmentType=["int32",NAVIGATIONCORE_DISTANCE,"int32",NAVIGATIONCORE_TIME,"int32",NAVIGATIONCORE_ROAD_NAME]; + + return routing_get(dbusIf,"getRouteSegments",["int16",detailLevel,"array",routeSegmentType,"uint32",numberOfSegments,"uint32",offset]); +} + +function latlon_to_map(latlon) +{ + return [ + "int32",NAVIGATIONCORE_LATITUDE,"structure",["uint8",0,"variant",["double",latlon['lat']]], + "int32",NAVIGATIONCORE_LONGITUDE,"structure",["uint8",0,"variant",["double",latlon['lon']]] + ]; +} + +function routing_SetWaypoints(dbusIf,startFromCurrentPosition,position,destination) +{ + var message=[]; + if(startFromCurrentPosition==false) + { + message=message.concat(["boolean",startFromCurrentPosition,"array",["map",position,"map",destination]]); + } + else + { + message=message.concat(["boolean",startFromCurrentPosition,"array",["map",destination]]); + } + var res=routing_message(dbusIf,"setWaypoints",message); +} + +function routing_CalculateRoute(dbusIf) +{ + var res=routing_message(dbusIf,"calculateRoute",[]); +} + +function routing_GetRouteBoundingBox(dbusIf,routeHandle) +{ + var message=[]; + message=message.concat(navigationcore_session(dbusIf)); + return navigationcore_message(dbusIf, "Routing", "getRouteBoundingBox", message.concat(routeHandle)); +} + +//----------------- Guidance messages ----------------- + +// Send a message to guidance with session handle +function guidance_s(par, func, args) +{ + return navigationcore_message(par, "Guidance", func, navigationcore_session(par).concat(args)); +} +// Send a message to guidance without session handle +function guidance_message(par, func, args) +{ + return navigationcore_message(par, "Guidance", func, args); +} + +function guidance_StartGuidance(dbusIf,routeHandle) +{ + guidance_s(dbusIf,"startGuidance",routeHandle); +} + +function guidance_StopGuidance(dbusIf) +{ + guidance_s(dbusIf,"stopGuidance",[]); +} + +function guidance_GetGuidanceStatus(dbusIf) +{ + return guidance_message(dbusIf,"getGuidanceStatus",[]); +} + +function guidance_GetDestinationInformation(dbusIf) +{ + return guidance_message(dbusIf,"getDestinationInformation",[]); +} + +function guidance_GetManeuversList(dbusIf,requestedNumberOfManeuvers,maneuverOffset) +{ + return guidance_message(dbusIf,"getManeuversList",["uint16",requestedNumberOfManeuvers,"uint32",maneuverOffset]); +} + +//---------------- Map matched position messages ---------------- + +// Send a message to mapmatchedposition with session handle +function mapmatchedposition_s(par, func, args) +{ + return navigationcore_message(par, "MapMatchedPosition", func, navigationcore_session(par).concat(args)); +} + +// Send a message to mapmatchedposition without session handle +function mapmatchedposition_message(par, func, args) +{ + return navigationcore_message(par, "MapMatchedPosition", func, args); +} + +function mapmatchedposition_GetCurrentAddress(dbusIf) +{ + var valuesToReturn=["int32",NAVIGATIONCORE_STREET]; + + return mapmatchedposition_message(dbusIf,"getCurrentAddress",["array",valuesToReturn]); +} + +function mapmatchedposition_SetSimulationMode(dbusIf,activate) +{ + mapmatchedposition_s(dbusIf,"setSimulationMode",["boolean",activate]); +} + +function mapmatchedposition_StartSimulation(dbusIf) +{ + mapmatchedposition_s(dbusIf,"startSimulation",[]); +} + +function mapmatchedposition_PauseSimulation(dbusIf) +{ + mapmatchedposition_s(dbusIf,"pauseSimulation",[]); +} + +function mapmatchedposition_GetSimulationStatus(dbusIf) +{ + return mapmatchedposition_message(dbusIf,"getSimulationStatus",[]); +} + +function mapmatchedposition_GetSimulationSpeed(dbusIf) +{ + return mapmatchedposition_message(dbusIf,"getSimulationSpeed",[]); +} + +function mapmatchedposition_SetSimulationSpeed(dbusIf,speedFactor) +{ + mapmatchedposition_s(dbusIf,"setSimulationSpeed",["uint8",speedFactor]); +} + +function mapmatchedposition_GetPosition(dbusIf) +{ + var valuesToReturn=["int32",NAVIGATIONCORE_SPEED,"int32",NAVIGATIONCORE_LATITUDE,"int32",NAVIGATIONCORE_LONGITUDE]; + + return mapmatchedposition_message(dbusIf,"getPosition",["array",valuesToReturn]); +} + +//---------------- MapViewer messages (handle 1) ---------------- + +// Create a new session or get the current session +function mapviewer_session(par) { + if (!g_mapviewer_session[1]) + { + var res=mapviewer_message(par, "Session", "createSession", ["string","TestHMI"]); + g_mapviewer_session[1]=res[3]; + } + return g_mapviewer_session; +} + +// Delete the current session if exists +function mapviewer_session_clear(par) +{ + if (g_mapviewer_session[1]) { + var res=mapviewer_message(par, "Session", "deleteSession", [g_mapviewer_session]); + g_mapviewer_session[1]=0; + } +} + +// Create a new map handle or get the current handle +function mapviewer_handle(par,w,h,type) +{ + if (!g_mapviewer_handle[1]) + { + var res=mapviewer_message(par, "MapViewerControl","createMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])); + g_mapviewer_handle[1]=res[3]; + } + return g_mapviewer_handle; +} + +// Delete the map handle if exists +function mapviewer_handle_clear(par) +{ + if (g_mapviewer_handle[1]) { + var res=mapviewercontrol_message(par, "releaseMapViewInstance", []); + g_mapviewer_handle[1]=0; + } +} + +// Send a message to map viewer control with session handle +function mapviewercontrol_message(par, func, args) +{ + return mapviewer_message(par, "MapViewerControl", func, mapviewer_session(par).concat(g_mapviewer_handle,args)); +} + +function mapviewer_GetMapViewScale(dbusIf) +{ + return mapviewercontrol_message(dbusIf,"getMapViewScale", []); +} + +function mapviewer_GetDisplayedRoutes(dbusIf) +{ + return mapviewercontrol_message(dbusIf,"getDisplayedRoutes", []); +} + +function mapviewer_SetMapViewScaleByDelta(dbusIf,scaleDelta) +{ + mapviewercontrol_message(dbusIf,"setMapViewScaleByDelta", ["int16",scaleDelta]); +} + +function mapviewer_GetMapViewTheme(dbusIf) +{ + return mapviewercontrol_message(dbusIf,"getMapViewTheme", []); +} + +function mapviewer_SetMapViewTheme(dbusIf,mapViewTheme) +{ + mapviewercontrol_message(dbusIf,"setMapViewTheme", ["int32",mapViewTheme]); +} + +function mapviewer_GetMapViewPerspective(dbusIf) +{ + return mapviewercontrol_message(dbusIf,"getMapViewPerspective", []); +} + +function mapviewer_SetMapViewPerspective(dbusIf,perspective) +{ + mapviewercontrol_message(dbusIf,"setMapViewPerspective", ["int32",perspective]); +} + +function mapviewer_SetFollowCarMode(dbusIf,followCarMode) +{ + mapviewercontrol_message(dbusIf,"setFollowCarMode", ["boolean",followCarMode]); +} + +function mapviewer_DisplayRoute(dbusIf,routeHandle,highlighted) +{ + var args=[]; + args=args.concat(routeHandle); + mapviewercontrol_message(dbusIf,"displayRoute", args.concat("boolean",highlighted)); +} + +function mapviewer_SetTargetPoint(dbusIf,latitude,longitude,altitude) +{ + mapviewercontrol_message(dbusIf, "setTargetPoint", ["structure",["double",latitude,"double",longitude,"double",altitude]]); +} + +function mapviewer_SetMapViewBoundingBox(dbusIf,boundingBox) +{ + mapviewercontrol_message(dbusIf,"setMapViewBoundingBox", boundingBox); +} + +function mapviewer_GetTargetPoint(dbusIf) +{ + return mapviewercontrol_message(dbusIf,"getTargetPoint", []); +} + +//---------------- MapViewer messages (handle 2) ---------------- + +// Create a new map handle or get the current handle +function mapviewer_handle2(par,w,h,type) +{ + if (!g_mapviewer_handle2[1]) + { + var res=mapviewer_message(par, "MapViewerControl","createMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])); + g_mapviewer_handle2[1]=res[3]; + } + return g_mapviewer_handle2; +} + +// Delete the map handle if exists +function mapviewer_handle_clear2(par) +{ + if (g_mapviewer_handle2[1]) { + var res=mapviewercontrol_message2(par, "releaseMapViewInstance", []); + g_mapviewer_handle2[1]=0; + } +} + +// Send a message to map viewer control with session handle on handle 2 +function mapviewercontrol_message2(par, func, args) +{ + return mapviewer_message(par, "MapViewerControl", func, mapviewer_session(par).concat(g_mapviewer_handle2,args)); +} + +function mapviewer2_SetMapViewTheme(dbusIf,mapViewTheme) +{ + mapviewercontrol_message2(dbusIf,"setMapViewTheme", ["uint16",mapViewTheme]); +} + +function mapviewer2_SetMapViewBoundingBox(dbusIf,boundingBox) +{ + mapviewercontrol_message2(dbusIf,"setMapViewBoundingBox", boundingBox); +} + +function mapviewer2_DisplayRoute(dbusIf,routeHandle,highlighted) +{ + var args=[]; + args=args.concat(routeHandle); + mapviewercontrol_message2(dbusIf,"displayRoute", args.concat("boolean",highlighted)); +} + +//---------------- Mapviewer Configuration messages ---------------- + +function mapviewer_configuration_message(par, func, args) +{ + return mapviewer_message(par, "Configuration", func,args); +} + +function mapviewer_configuration_GetSupportedLocales(dbusIf) +{ + return mapviewer_configuration_message(dbusIf,"getSupportedLocales",[]); +} + +function mapviewer_configuration_GetLocale(dbusIf) +{ + return mapviewer_configuration_message(dbusIf,"getLocale",[]); +} + +function mapviewer_configuration_SetLocale(dbusIf,language,country,script) +{ + mapviewer_configuration_message(dbusIf,"setLocale",["string",language,"string",country,"string",script]); +} + +function mapviewer_configuration_GetUnitsOfMeasurement(dbusIf) +{ + return mapviewer_configuration_message(dbusIf,"getUnitsOfMeasurement",[]); +} + +function mapviewer_configuration_SetUnitsOfMeasurementLength(dbusIf,unit) +{ + mapviewer_configuration_message(dbusIf,"setUnitsOfMeasurement",["map",["int32",NAVIGATIONCORE_LENGTH,"int32",unit]]); +} + +// -------------------- POISearch dbus messages -------------------- + +// Send a message to poisearch with session handle +function poisearch_message(par, func, args) +{ //session handle sent + return poi_message(par, "POISearch", func, poisearch_handle(par).concat(args)); +} + +// Send a message to poisearch without session handle +function poisearch_message_get(par, func, args) +{ + return poi_message(par, "POISearch", func, args); +} + +// Create a new poisearch handle or get the current handle +function poisearch_handle(par) { + if (!g_poisearch_handle[1]) + { + var res=poisearch_message_get(par, "createPoiSearchHandle", []); + g_poisearch_handle[1]=res[3]; + } + return g_poisearch_handle; +} + +// Delete the poisearch handle if exists +function poisearch_handle_clear(par) +{ + if (g_poisearch_handle[1]) { + poisearch_message(par, "deletePoiSearchHandle", []); + g_poisearch_handle[1]=0; + } +} + +function poisearch_StartPoiSearch(dbusIf,inputString,sortOption) +{ + poisearch_message(dbusIf,"startPoiSearch",["string",inputString,"int32",sortOption]); +} + +function poisearch_SetCenter(dbusIf,latitude,longitude,altitude) +{ + poisearch_message(dbusIf, "setCenter", ["structure",["double",latitude,"double",longitude,"double",altitude]]); +} + +function poisearch_SetCategories(dbusIf,poiCategories) +{ + var value=[]; + for(var i=0;i<poiCategories.length;i+=1) + { + value=value.concat(["structure",["uint32",poiCategories[i][0],"uint32",poiCategories[i][1]]]); + } + + poisearch_message(dbusIf, "setCategories", ["array",value]); +} + +function poisearch_GetAvailableCategories(dbusIf) +{ + return poisearch_message_get(dbusIf,"getAvailableCategories",[]); +} + +function poisearch_RequestResultList(dbusIf,offset,maxWindowSize,attributeList) +{ + var value=[]; + for(var i=0;i<attributeList.length;i+=1) + { + value=value.concat(["uint32",attributeList[i]]); + } + return poisearch_message(dbusIf,"requestResultList",["uint16",offset,"uint16",maxWindowSize,"array",value]); +} + +function poisearch_GetPoiDetails(dbusIf,ids) +{ + var value=[]; + for(var i=0;i<ids.length;i+=1) + { + value=value.concat(["uint32",ids[i]]); + } + return poisearch_message_get(dbusIf,"getPoiDetails",["array",value]); +} + +//----------------- Trip Computer messages ----------------- + +// Send a message to tripcomputer (basic) +function tripcomputer_message(par, func, args) +{ + return demonstrator_message(par, "TripComputer", func, args); +} + +// Send a message to fuel stop advisor (basic) +function fuelstopadvisor_message(par, func, args) +{ + return demonstrator_message(par, "FuelStopAdvisor", func, args); +} + +function fuelstopadvisor_ReleaseRouteHandle(dbusIf,routeHandle) +{ + fuelstopadvisor_message(dbusIf,"releaseRouteHandle",routeHandle); +} + +function fuelstopadvisor_SetRouteHandle(dbusIf,routeHandle) +{ + fuelstopadvisor_message(dbusIf,"setRouteHandle",routeHandle); +} + +function fuelstopadvisor_SetFuelAdvisorSettings(dbusIf,advisorMode,distanceThreshold) +{ + fuelstopadvisor_message(dbusIf,"setFuelAdvisorSettings",["boolean",advisorMode,"uint8",distanceThreshold]); +} + diff --git a/src/hmi/qml/Core/genivi.js b/src/hmi/qml/Core/genivi-origin.js index 564954d..1f79f33 100644 --- a/src/hmi/qml/Core/genivi.js +++ b/src/hmi/qml/Core/genivi-origin.js @@ -4,9 +4,9 @@ * * \copyright Copyright (C) 2013-2016, PCA Peugeot Citroen * -* \file NavigationSearchAddress.qml +* \file genivi-origin.js * -* \brief This file is part of the navigation hmi. +* \brief This file is part of the navigation hmi. It defines basic functions used by the QML files, for the former version of the FSA. * * \author Martin Schaller <martin.schaller@it-schaller.de> * \author Philippe Colliot <philippe.colliot@mpsa.com> @@ -31,13 +31,13 @@ Qt.include("resource.js") var dbusIf; -var g_nav_session; -var g_locationinput_handle; -var g_routing_handle; -var g_mapviewer_session; -var g_mapviewer_handle; -var g_mapviewer_handle2; -var g_poisearch_handle; +var g_nav_session=["uint32",0]; +var g_locationinput_handle=["uint32",0]; +var g_routing_handle=["uint32",0]; +var g_mapviewer_session=["uint32",0]; +var g_mapviewer_handle=["uint32",0]; +var g_mapviewer_handle2=["uint32",0]; +var g_poisearch_handle=["uint32",0]; var g_lang; var data=new Array; @@ -211,7 +211,6 @@ function gettext(arg) } } - //----------------- Management of the DBus messages ----------------- // Send a dbus message to layer manager @@ -220,32 +219,148 @@ function lm_message(par, func, args) return par.message("org.genivi.layermanagementservice","/org/genivi/layermanagementservice","org.genivi.layermanagementservice", func, args); } -//----------------- NavigationCore dbus messages ----------------- - // Send a message to navigationcore (basic) function navigationcore_message(par, iface, func, args) { - return par.message("org.genivi.navigationcore."+iface,"/org/genivi/navigationcore","org.genivi.navigationcore."+iface, func, args); + return par.message("org.genivi.navigationcore."+iface,"/org/genivi/navigationcore","org.genivi.navigationcore."+iface, func, args); } -// Create a new location handle or get the current handle -function locationinput_handle(par) +// Send a message to mapviewer (basic) +function mapviewer_message(par, iface, func, args) { - if (g_locationinput_handle) - return g_locationinput_handle; - g_locationinput_handle=navigationcore_message(par, "LocationInput","CreateLocationInput", navigationcore_session(par)).slice(0,2); - return g_locationinput_handle; + return par.message("org.genivi.mapviewer."+iface,"/org/genivi/mapviewer","org.genivi.mapviewer."+iface, func, args); } -// Delete the location handle if exists -function locationinput_handle_clear(par) +// Send a message to poiservice (basic) +function poi_message(par, iface, func, args) { - if (g_locationinput_handle) { - locationinput_message(par, "DeleteLocationInput", []); - g_locationinput_handle=null; - } + return par.message("org.genivi.poiservice."+iface,"/org/genivi/poiservice/"+iface,"org.genivi.poiservice."+iface, func, args); +} + +// Send a message to demonstrator (basic) +function demonstrator_message(par, iface, func, args) +{ + return par.message("org.genivi.demonstrator."+iface,"/org/genivi/demonstrator"+iface,"org.genivi.demonstrator."+iface, func, args); +} + +//----------------- DBus signals ----------------- +function connect_simulationStatusChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationStatusChanged",menu,"simulationStatusChanged"); +} + +function connect_simulationSpeedChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationSpeedChanged",menu,"simulationSpeedChanged"); +} + +function connect_searchStatusSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); +} + +function connect_searchResultListSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultList"); +} + +function connect_spellResultSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SpellResult",menu,"spellResult"); +} + +function connect_guidanceWaypointReachedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","WaypointReached",menu,"guidanceWaypointReached"); +} + +function connect_guidanceManeuverChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","ManeuverChanged",menu,"guidanceManeuverChanged"); +} + +function connect_guidancePositionOnRouteChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","PositionOnRouteChanged",menu,"guidancePositionOnRouteChanged"); +} + +function connect_simulationStatusChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationStatusChanged",menu,"simulationStatusChanged"); +} + +function connect_simulationSpeedChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationSpeedChanged",menu,"simulationSpeedChanged"); +} + +function connect_mapmatchedpositionPositionUpdateSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","PositionUpdate",menu,"mapmatchedpositionPositionUpdate"); +} + +function connect_mapmatchedpositionAddressUpdateSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","AddressUpdate",menu,"mapmatchedpositionAddressUpdate"); +} + +function connect_fuelStopAdvisorSignal(interface,menu) +{ + return interface.connect("","/org/genivi/demonstrator/FuelStopAdvisor","org.genivi.demonstrator.FuelStopAdvisor","FuelStopAdvisorWarning",menu,"fuelStopAdvisorWarning"); +} + +function connect_routeCalculationSuccessfulSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationSuccessful",menu,"routeCalculationSuccessful"); +} + +function connect_routeCalculationFailedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationFailed",menu,"routeCalculationFailed"); +} + +function connect_routeCalculationProgressUpdateSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationProgressUpdate",menu,"routeCalculationProgressUpdate"); +} + +function connect_mapmatchedpositionPositionUpdateSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","PositionUpdate",menu,"mapmatchedpositionPositionUpdate"); +} + +function connect_currentSelectionCriterionSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","CurrentSelectionCriterion",menu,"currentSelectionCriterion"); +} + +function connect_searchStatusSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); +} + +function connect_searchResultListSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultList"); +} + +function connect_contentUpdatedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","ContentUpdated",menu,"contentUpdated"); } +function connect_configurationChangedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Configuration","ConfigurationChanged",menu,"configurationChanged"); +} + +function connect_tripDataUpdatedSignal(interface,menu) +{ + return interface.connect("","/org/genivi/demonstrator/FuelStopAdvisor","org.genivi.demonstrator.FuelStopAdvisor","TripDataUpdated",menu,"tripDataUpdated"); +} + +//----------------- NavigationCore dbus messages ----------------- + //----------------- Navigation core Session messages ----------------- function navigationcore_session_message(par, func, args) @@ -255,24 +370,26 @@ function navigationcore_session_message(par, func, args) // Create a new session or get the current session function navigationcore_session(par) { - if (g_nav_session) - return g_nav_session; - g_nav_session=navigationcore_message(par,"Session","CreateSession", ["string","TestHMI"]).slice(0,2); + if (!g_nav_session[1]) + { + var res=navigationcore_session_message(par,"CreateSession", ["string","TestHMI"]); + g_nav_session[1]=res[3]; + } return g_nav_session; } // Delete the current session if exists function navigationcore_session_clear(par) { - if (g_nav_session) { - navigationcore_message(par, "Session", "DeleteSession", [g_nav_session]); - g_nav_session=null; + if (g_nav_session[1]) { + var res=navigationcore_session_message(par,"DeleteSession", [g_nav_session]); + g_nav_session[1]=0; } } -function navigationcore_session_GetVersion(dbusIf) +function navigationcore_session_GetVersion(par) { - return navigationcore_session_message(dbusIf,"GetVersion",[]); + return navigationcore_session_message(par,"GetVersion",[]); } //----------------- Navigation core Configuration messages ----------------- @@ -309,6 +426,17 @@ function navigationcore_configuration_SetUnitsOfMeasurementLength(dbusIf,unit) //----------------- LocationInput messages ----------------- +// Create a new location handle or get the current handle +function locationinput_handle(par) +{ + if (!g_locationinput_handle[1]) + { + var res=navigationcore_message(par, "LocationInput","CreateLocationInput", navigationcore_session(par)); + g_locationinput_handle[1]=res[3]; + } + return g_locationinput_handle; +} + function locationinput_message(par, func, args) { return navigationcore_message(par, "LocationInput", func, navigationcore_session(par).concat(locationinput_handle(par),args)); @@ -339,6 +467,14 @@ function locationinput_SelectEntry(dbusIf,index) locationinput_message(dbusIf,"SelectEntry",["uint16",index]); } +function locationinput_handle_clear(par) +{ + if (g_locationinput_handle[1]) { + var res=locationinput_message(par, "DeleteLocationInput", []); + g_locationinput_handle[1]=0; + } +} + //----------------- Routing messages ----------------- // Send a message to routing with session handle @@ -354,20 +490,21 @@ function routing_get(par, func, args) } // Create a new routing handle or get the current handle -// NB: the format of the handle is [0]uint32:[1]value function routing_handle(par) { - if (g_routing_handle) - return g_routing_handle; - g_routing_handle=navigationcore_message(par, "Routing","CreateRoute", navigationcore_session(par)).slice(0,2); + if (!g_routing_handle[1]) + { + var res=navigationcore_message(par, "Routing","CreateRoute", navigationcore_session(par)); + g_routing_handle[1]=res[3]; + } return g_routing_handle; } // Delete the routing handle if exists function routing_handle_clear(par) { - if (g_routing_handle) { - routing_message(par, "DeleteRoute", []); - g_routing_handle=0; + if (g_routing_handle[1]) { + var res=routing_message(par, "DeleteRoute", []); + g_routing_handle[1]=0; } } @@ -387,7 +524,7 @@ function routing_GetCostModel(dbusIf) function routing_SetCostModel(dbusIf,costModel) { - routing_message(dbusIf,"SetCostModel",["int32",costModel]); + var res=routing_message(dbusIf,"SetCostModel",["int32",costModel]); } function routing_GetSupportedCostModels(dbusIf) @@ -411,7 +548,7 @@ function routing_SetRoutePreferences(dbusIf,countryCode) var conditionMessage=["array",["structure",["int32",conditionPreferenceList[NAVIGATIONCORE_TRAFFIC_REALTIME],"int32",NAVIGATIONCORE_TRAFFIC_REALTIME]]]; var message=["string",countryCode]; message=message.concat(roadMessage.concat(conditionMessage)); - routing_message(dbusIf,"SetRoutePreferences",message); + var res=routing_message(dbusIf,"SetRoutePreferences",message); } function routing_GetRouteSegments(dbusIf,detailLevel,numberOfSegments,offset) @@ -440,12 +577,12 @@ function routing_SetWaypoints(dbusIf,startFromCurrentPosition,position,destinati { message=message.concat(["boolean",startFromCurrentPosition,"array",["map",destination]]); } - routing_message(dbusIf,"SetWaypoints",message); + var res=routing_message(dbusIf,"SetWaypoints",message); } function routing_CalculateRoute(dbusIf) { - routing_message(dbusIf,"CalculateRoute",[]); + var res=routing_message(dbusIf,"CalculateRoute",[]); } function routing_GetRouteBoundingBox(dbusIf,routeHandle) @@ -507,11 +644,11 @@ function mapmatchedposition_message(par, func, args) return navigationcore_message(par, "MapMatchedPosition", func, args); } -function mapmatchedposition_GetAddress(dbusIf) +function mapmatchedposition_GetCurrentAddress(dbusIf) { var valuesToReturn=["int32",NAVIGATIONCORE_STREET]; - return mapmatchedposition_message(dbusIf,"GetAddress",["array",valuesToReturn]); + return mapmatchedposition_message(dbusIf,"GetCurrentAddress",["array",valuesToReturn]); } function mapmatchedposition_SetSimulationMode(dbusIf,activate) @@ -553,46 +690,42 @@ function mapmatchedposition_GetPosition(dbusIf) //---------------- MapViewer messages (handle 1) ---------------- -// Send a message to mapviewer (basic) -function mapviewer_message(par, iface, func, args) -{ - return par.message("org.genivi.mapviewer."+iface,"/org/genivi/mapviewer","org.genivi.mapviewer."+iface, func, args); -} - // Create a new session or get the current session -// NB: the format of the handle is [0]uint32:[1]value function mapviewer_session(par) { - if (g_mapviewer_session) - return g_mapviewer_session; - g_mapviewer_session=mapviewer_message(par, "Session", "CreateSession", ["string","TestHMI"]).slice(0,2); + if (!g_mapviewer_session[1]) + { + var res=mapviewer_message(par, "Session", "CreateSession", ["string","TestHMI"]); + g_mapviewer_session[1]=res[3]; + } return g_mapviewer_session; } // Delete the current session if exists function mapviewer_session_clear(par) { - if (g_mapviewer_session) { - mapviewer_message(par, "Session", "DeleteSession", [g_mapviewer_session]); - g_mapviewer_session=null; + if (g_mapviewer_session[1]) { + var res=mapviewer_message(par, "Session", "DeleteSession", [g_mapviewer_session]); + g_mapviewer_session[1]=0; } } // Create a new map handle or get the current handle -// NB: the format of the handle is [0]uint32:[1]value function mapviewer_handle(par,w,h,type) { - if (g_mapviewer_handle) - return g_mapviewer_handle; - g_mapviewer_handle=mapviewer_message(par, "MapViewerControl","CreateMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])).slice(0,2); + if (!g_mapviewer_handle[1]) + { + var res=mapviewer_message(par, "MapViewerControl","CreateMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])); + g_mapviewer_handle[1]=res[3]; + } return g_mapviewer_handle; } // Delete the map handle if exists function mapviewer_handle_clear(par) { - if (g_mapviewer_handle) { - mapviewercontrol_message(par, "ReleaseMapViewInstance", []); - g_mapviewer_handle=null; + if (g_mapviewer_handle[1]) { + var res=mapviewercontrol_message(par, "ReleaseMapViewInstance", []); + g_mapviewer_handle[1]=0; } } @@ -667,21 +800,22 @@ function mapviewer_GetTargetPoint(dbusIf) //---------------- MapViewer messages (handle 2) ---------------- // Create a new map handle or get the current handle -// NB: the format of the handle is [0]uint32:[1]value function mapviewer_handle2(par,w,h,type) { - if (g_mapviewer_handle2) - return g_mapviewer_handle2; - g_mapviewer_handle2=mapviewer_message(par, "MapViewerControl","CreateMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])).slice(0,2); + if (!g_mapviewer_handle2[1]) + { + var res=mapviewer_message(par, "MapViewerControl","CreateMapViewInstance", mapviewer_session(par).concat(["structure",["uint16",w,"uint16",h],"int32",type])); + g_mapviewer_handle2[1]=res[3]; + } return g_mapviewer_handle2; } // Delete the map handle if exists function mapviewer_handle_clear2(par) { - if (g_mapviewer_handle2) { - mapviewercontrol_message2(par, "ReleaseMapViewInstance", []); - g_mapviewer_handle2=null; + if (g_mapviewer_handle2[1]) { + var res=mapviewercontrol_message2(par, "ReleaseMapViewInstance", []); + g_mapviewer_handle2[1]=0; } } @@ -742,12 +876,6 @@ function mapviewer_configuration_SetUnitsOfMeasurementLength(dbusIf,unit) // -------------------- POISearch dbus messages -------------------- -// Send a message to poiservice (basic) -function poi_message(par, iface, func, args) -{ - return par.message("org.genivi.poiservice."+iface,"/org/genivi/poiservice/"+iface,"org.genivi.poiservice."+iface, func, args); -} - // Send a message to poisearch with session handle function poisearch_message(par, func, args) { //session handle sent @@ -761,20 +889,21 @@ function poisearch_message_get(par, func, args) } // Create a new poisearch handle or get the current handle -// NB: the format of the handle is [0]uint32:[1]value function poisearch_handle(par) { - if (g_poisearch_handle) - return g_poisearch_handle; - g_poisearch_handle=poisearch_message_get(par, "CreatePoiSearchHandle", []); + if (!g_poisearch_handle[1]) + { + var res=poisearch_message_get(par, "CreatePoiSearchHandle", []); + g_poisearch_handle[1]=res[3]; + } return g_poisearch_handle; } // Delete the poisearch handle if exists function poisearch_handle_clear(par) { - if (g_poisearch_handle) { + if (g_poisearch_handle[1]) { poisearch_message(par, "DeletePoiSearchHandle", []); - g_poisearch_handle=null; + g_poisearch_handle[1]=0; } } @@ -826,12 +955,6 @@ function poisearch_GetPoiDetails(dbusIf,ids) //----------------- Trip Computer messages ----------------- -// Send a message to demonstrator (basic) -function demonstrator_message(par, iface, func, args) -{ - return par.message("org.genivi.demonstrator."+iface,"/org/genivi/demonstrator/"+iface,"org.genivi.demonstrator."+iface, func, args); -} - // Send a message to tripcomputer (basic) function tripcomputer_message(par, func, args) { diff --git a/src/hmi/qml/Entry.qml b/src/hmi/qml/Entry.qml index 227f4dc..96dfb3c 100644 --- a/src/hmi/qml/Entry.qml +++ b/src/hmi/qml/Entry.qml @@ -98,19 +98,15 @@ HMIMenu { function connectSignals() { - //currentSelectionCriterionSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","CurrentSelectionCriterion",menu,"currentSelectionCriterion"); - searchStatusSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); - searchResultListSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultList"); - //contentUpdatedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","ContentUpdated",menu,"contentUpdated"); - spellResultSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SpellResult",menu,"spellResult"); + searchStatusSignal=Genivi.connect_searchStatusSignal(dbusIf,menu); + searchResultListSignal=Genivi.connect_searchResultListSignal(dbusIf,menu); + spellResultSignal=Genivi.connect_spellResultSignal(dbusIf,menu); } function disconnectSignals() { - //currentSelectionCriterionSignal.destroy(); searchStatusSignal.destroy(); searchResultListSignal.destroy(); - //contentUpdatedSignal.destroy(); spellResultSignal.destroy(); } diff --git a/src/hmi/qml/EntryFreeText.qml b/src/hmi/qml/EntryFreeText.qml index fd37999..22f65d3 100644 --- a/src/hmi/qml/EntryFreeText.qml +++ b/src/hmi/qml/EntryFreeText.qml @@ -89,18 +89,14 @@ HMIMenu { function connectSignals() { - //currentSelectionCriterionSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","CurrentSelectionCriterion",menu,"currentSelectionCriterion"); - searchStatusSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); - searchResultListSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultListAddress"); - //contentUpdatedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","ContentUpdated",menu,"contentUpdated"); - } + searchStatusSignal=Genivi.connect_searchStatusSignal(dbusIf,menu); + searchResultListSignal=Genivi.connect_searchResultListSignal(dbusIf,menu); + } function disconnectSignals() { - //currentSelectionCriterionSignal.destroy(); searchStatusSignal.destroy(); searchResultListSignal.destroy(); - //contentUpdatedSignal.destroy(); } Keys.onPressed: { diff --git a/src/hmi/qml/NavigationBrowseMap.qml b/src/hmi/qml/NavigationBrowseMap.qml index 4fd824f..6ba5e19 100644 --- a/src/hmi/qml/NavigationBrowseMap.qml +++ b/src/hmi/qml/NavigationBrowseMap.qml @@ -85,9 +85,9 @@ HMIMenu { function mapmatchedpositionPositionUpdate(args) { var res=Genivi.mapmatchedposition_GetPosition(dbusIf); - for (var i=0;i<res[1].length;i+=4){ - if (res[1][i+1]== Genivi.NAVIGATIONCORE_SPEED){ - vehicleSpeedValue.text=res[1][i+3][3][1]; + for (var i=0;i<res[3].length;i+=4){ + if (res[3][i+1]== Genivi.NAVIGATIONCORE_SPEED){ + vehicleSpeedValue.text=res[3][i+3][3][1]; } } } @@ -249,9 +249,9 @@ HMIMenu { function updateAddress() { - var res=Genivi.mapmatchedposition_GetAddress(dbusIf); - if (res[1][1] == Genivi.NAVIGATIONCORE_STREET) { - currentroad.text=res[1][3][3][1]; + var res=Genivi.mapmatchedposition_GetCurrentAddress(dbusIf); + if (res[3][1] == Genivi.NAVIGATIONCORE_STREET) { + currentroad.text=res[3][3][3][1]; } else { currentroad.text=""; } @@ -287,14 +287,14 @@ HMIMenu { function connectSignals() { - guidanceWaypointReachedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","WaypointReached",menu,"guidanceWaypointReached"); - guidanceManeuverChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","ManeuverChanged",menu,"guidanceManeuverChanged"); - guidancePositionOnRouteChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Guidance","PositionOnRouteChanged",menu,"guidancePositionOnRouteChanged"); - simulationStatusChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationStatusChanged",menu,"simulationStatusChanged"); - simulationSpeedChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationSpeedChanged",menu,"simulationSpeedChanged"); - mapmatchedpositionPositionUpdateSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","PositionUpdate",menu,"mapmatchedpositionPositionUpdate"); - mapmatchedpositionAddressUpdateSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","AddressUpdate",menu,"mapmatchedpositionAddressUpdate"); - fuelStopAdvisorSignal=dbusIf.connect("","/org/genivi/demonstrator/FuelStopAdvisor","org.genivi.demonstrator.FuelStopAdvisor","FuelStopAdvisorWarning",menu,"fuelStopAdvisorWarning"); + guidanceWaypointReachedSignal=Genivi.connect_guidanceWaypointReachedSignal(dbusIf,menu); + guidanceManeuverChangedSignal=Genivi.connect_guidanceManeuverChangedSignal(dbusIf,menu); + guidancePositionOnRouteChangedSignal=Genivi.connect_guidancePositionOnRouteChangedSignal(dbusIf,menu); + simulationStatusChangedSignal=Genivi.connect_simulationStatusChangedSignal(dbusIf,menu); + simulationSpeedChangedSignal=Genivi.connect_simulationSpeedChangedSignal(dbusIf,menu); + mapmatchedpositionPositionUpdateSignal=Genivi.connect_mapmatchedpositionPositionUpdateSignal(dbusIf,menu); + mapmatchedpositionAddressUpdateSignal=Genivi.connect_mapmatchedpositionAddressUpdateSignal(dbusIf,menu); + fuelStopAdvisorSignal=Genivi.connect_fuelStopAdvisorSignal(dbusIf,menu); } function disconnectSignals() @@ -350,9 +350,9 @@ HMIMenu { } var maneuversList=Genivi.guidance_GetManeuversList(dbusIf,1,0); - var numberOfManeuvers=maneuversList[1]; + var numberOfManeuvers=maneuversList[3]; //only one maneuver is considered - var maneuver=maneuversList[3][1]; + var maneuver=maneuversList[5][1]; var roadNumberAfterManeuver=maneuver[1]; var roadNameAfterManeuver=maneuver[3]; var roadPropertyAfterManeuver=maneuver[5]; @@ -882,7 +882,7 @@ HMIMenu { delete(Genivi.data['show_route_handle']); } if (Genivi.data['zoom_route_handle']) { - var res=Genivi.navigationcore_message(dbusIf, "Routing", "GetRouteBoundingBox", Genivi.navigationcore_session(dbusIf).concat(Genivi.data['zoom_route_handle'])); + var res=Genivi.routing_GetRouteBoundingBox(dbusIf,Genivi.data['zoom_route_handle']); if (res[0] == "structure") { Genivi.mapviewercontrol_message(dbusIf, "SetMapViewBoundingBox", res); } else { diff --git a/src/hmi/qml/NavigationCalculatedRoute.qml b/src/hmi/qml/NavigationCalculatedRoute.qml index 2a7dcb5..3d86da4 100644 --- a/src/hmi/qml/NavigationCalculatedRoute.qml +++ b/src/hmi/qml/NavigationCalculatedRoute.qml @@ -110,9 +110,9 @@ HMIMenu { function connectSignals() { - routeCalculationSuccessfulSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationSuccessful",menu,"routeCalculationSuccessful"); - routeCalculationFailedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationFailed",menu,"routeCalculationFailed"); - routeCalculationProgressUpdateSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Routing","RouteCalculationProgressUpdate",menu,"routeCalculationProgressUpdate"); + routeCalculationSuccessfulSignal=Genivi.connect_routeCalculationSuccessfulSignal(dbusIf,menu); + routeCalculationFailedSignal=Genivi.connect_routeCalculationFailedSignal(dbusIf,menu); + routeCalculationProgressUpdateSignal=Genivi.connect_routeCalculationProgressUpdateSignal(dbusIf,menu); } function disconnectSignals() diff --git a/src/hmi/qml/NavigationManeuversList.qml b/src/hmi/qml/NavigationManeuversList.qml index 12ce48c..4097644 100644 --- a/src/hmi/qml/NavigationManeuversList.qml +++ b/src/hmi/qml/NavigationManeuversList.qml @@ -78,7 +78,7 @@ HMIMenu { Component.onCompleted: { var res=Genivi.guidance_GetManeuversList(dbusIf,0xffff,0); - var maneuversList=res[3]; + var maneuversList=res[5]; var model=view.model; for (var i = 0 ; i < maneuversList.length ; i+=2) { var roadNameAfterManeuver=maneuversList[i+1][3]; diff --git a/src/hmi/qml/NavigationRoute.qml b/src/hmi/qml/NavigationRoute.qml index 7618506..87a4aa9 100644 --- a/src/hmi/qml/NavigationRoute.qml +++ b/src/hmi/qml/NavigationRoute.qml @@ -53,11 +53,11 @@ HMIMenu { var res=Genivi.mapmatchedposition_GetPosition(dbusIf); var oklat=0; var oklong=0; - for (var i=0;i<res[1].length;i+=4){ - if ((res[1][i+1]== Genivi.NAVIGATIONCORE_LATITUDE) && (res[1][i+3][3][1] != 0)){ + for (var i=0;i<res[3].length;i+=4){ + if ((res[3][i+1]== Genivi.NAVIGATIONCORE_LATITUDE) && (res[3][i+3][3][1] != 0)){ oklat=1; } else { - if ((res[1][i+1]== Genivi.NAVIGATIONCORE_LONGITUDE) && (res[1][i+3][3][1] != 0)){ + if ((res[3][i+1]== Genivi.NAVIGATIONCORE_LONGITUDE) && (res[3][i+3][3][1] != 0)){ oklong=1; } } @@ -76,11 +76,12 @@ HMIMenu { function connectSignals() { - mapmatchedpositionPositionUpdateSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","PositionUpdate",menu,"mapmatchedpositionPositionUpdate"); + mapmatchedpositionPositionUpdateSignal=Genivi.connect_mapmatchedpositionPositionUpdateSignal(dbusIf,menu); } function disconnectSignals() { + mapmatchedpositionPositionUpdateSignal.destroy(); } DBusIf { diff --git a/src/hmi/qml/NavigationSearchAddress.qml b/src/hmi/qml/NavigationSearchAddress.qml index d5265ea..fddb82d 100644 --- a/src/hmi/qml/NavigationSearchAddress.qml +++ b/src/hmi/qml/NavigationSearchAddress.qml @@ -149,10 +149,10 @@ HMIMenu { function connectSignals() { - currentSelectionCriterionSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","CurrentSelectionCriterion",menu,"currentSelectionCriterion"); - searchStatusSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); - searchResultListSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultList"); - contentUpdatedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","ContentUpdated",menu,"contentUpdated"); + currentSelectionCriterionSignal=Genivi.connect_currentSelectionCriterionSignal(dbusIf,menu); + searchStatusSignal=Genivi.connect_searchStatusSignal(dbusIf,menu); + searchResultListSignal=Genivi.connect_searchResultListSignal(dbusIf,menu); + contentUpdatedSignal=Genivi.connect_contentUpdatedSignal(dbusIf,menu); } function disconnectSignals() diff --git a/src/hmi/qml/NavigationSearchFreeText.qml b/src/hmi/qml/NavigationSearchFreeText.qml index f90eca3..796a6e1 100644 --- a/src/hmi/qml/NavigationSearchFreeText.qml +++ b/src/hmi/qml/NavigationSearchFreeText.qml @@ -86,10 +86,10 @@ HMIMenu { function connectSignals() { - searchStatusSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchStatus",menu,"searchStatus"); - searchResultListSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","SearchResultList",menu,"searchResultList"); - contentUpdatedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.LocationInput","ContentUpdated",menu,"contentUpdated"); - } + searchStatusSignal=Genivi.connect_searchStatusSignal(dbusIf,menu); + searchResultListSignal=Genivi.connect_searchResultListSignal(dbusIf,menu); + contentUpdatedSignal=Genivi.connect_contentUpdatedSignal(dbusIf,menu); + } function disconnectSignals() { @@ -119,7 +119,7 @@ HMIMenu { Component.onCompleted: { connectSignals(); - var res=Genivi.navigationcore_message(dbusIf,"Session","GetVersion",[]); + var res=Genivi.navigationcore_session_GetVersion(dbusIf); if (res[0] != "error") { res=Genivi.navigationcore_session(dbusIf); res=Genivi.locationinput_handle(dbusIf); diff --git a/src/hmi/qml/NavigationSearchHistory.qml b/src/hmi/qml/NavigationSearchHistory.qml index d8bebd2..76c26c2 100644 --- a/src/hmi/qml/NavigationSearchHistory.qml +++ b/src/hmi/qml/NavigationSearchHistory.qml @@ -85,7 +85,6 @@ HMIMenu { Component.onCompleted: { var model=view.model; var array=Genivi.historyOfLastEnteredLocation; - Genivi.dump("",array.length); // display list of locations (fifo) var i = Genivi.historyOfLastEnteredLocationOut; while (i !== Genivi.historyOfLastEnteredLocationIn) diff --git a/src/hmi/qml/NavigationSettings.qml b/src/hmi/qml/NavigationSettings.qml index 847922b..3c9ae17 100644 --- a/src/hmi/qml/NavigationSettings.qml +++ b/src/hmi/qml/NavigationSettings.qml @@ -111,8 +111,8 @@ HMIMenu { function connectSignals() { - simulationStatusChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationStatusChanged",menu,"simulationStatusChanged"); - simulationSpeedChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.MapMatchedPosition","SimulationSpeedChanged",menu,"simulationSpeedChanged"); + simulationStatusChangedSignal=Genivi.connect_simulationStatusChangedSignal(dbusIf,menu); + simulationSpeedChangedSignal=Genivi.connect_simulationSpeedChangedSignal(dbusIf,menu); } function disconnectSignals() diff --git a/src/hmi/qml/NavigationSettingsLanguageAndUnits.qml b/src/hmi/qml/NavigationSettingsLanguageAndUnits.qml index 8b61d73..9526dd1 100644 --- a/src/hmi/qml/NavigationSettingsLanguageAndUnits.qml +++ b/src/hmi/qml/NavigationSettingsLanguageAndUnits.qml @@ -58,7 +58,7 @@ HMIMenu { function connectSignals() { - configurationChangedSignal=dbusIf.connect("","/org/genivi/navigationcore","org.genivi.navigationcore.Configuration","ConfigurationChanged",menu,"configurationChanged"); + configurationChangedSignal=Genivi.connect_configurationChangedSignal(dbusIf,menu); } function disconnectSignals() diff --git a/src/hmi/qml/POI.qml b/src/hmi/qml/POI.qml index 476ded1..2188bdd 100644 --- a/src/hmi/qml/POI.qml +++ b/src/hmi/qml/POI.qml @@ -113,12 +113,12 @@ HMIMenu { var position=Genivi.mapmatchedposition_GetPosition(dbusIf); var latitude=0; var longitude=0; - for (var i=0;i<position[1].length;i+=4){ - if ((position[1][i+1]== Genivi.NAVIGATIONCORE_LATITUDE) && (position[1][i+3][3][1] != 0)){ - latitude=position[1][i+3][3][1]; + for (var i=0;i<position[3].length;i+=4){ + if ((position[3][i+1]== Genivi.NAVIGATIONCORE_LATITUDE) && (position[3][i+3][3][1] != 0)){ + latitude=position[3][i+3][3][1]; } else { - if ((position[1][i+1]== Genivi.NAVIGATIONCORE_LONGITUDE) && (position[1][i+3][3][1] != 0)){ - longitude=position[1][i+3][3][1]; + if ((position[3][i+1]== Genivi.NAVIGATIONCORE_LONGITUDE) && (position[3][i+3][3][1] != 0)){ + longitude=position[3][i+3][3][1]; } } } @@ -145,6 +145,7 @@ HMIMenu { var attributeList=[]; attributeList[0]=0; var res=Genivi.poisearch_RequestResultList(dbusIf,Genivi.offset,Genivi.maxWindowSize,attributeList); + Genivi.dump("poisearch_RequestResultList",res) var res_win=res[5]; for (i = 0 ; i < res_win.length ; i+=2) { var id=res_win[i+1][1]; @@ -183,9 +184,9 @@ HMIMenu { disabled:true; next:select_display_on_map; prev:select_search_for_refill onClicked: { - var poi_data=Genivi.poi_data[Genivi.poi_id]; - var dest=["uint16",Genivi.NAVIGATIONCORE_LATITUDE,"variant",["double",poi_data.lat],"uint16",Genivi.NAVIGATIONCORE_LONGITUDE,"variant",["double",poi_data.lon]]; - Genivi.routing_message(dbusIf,"SetWaypoints",["boolean",true,"array",["map",dest]]); + var destination=Genivi.latlon_to_map(Genivi.poi_data[Genivi.poi_id]); + var position=""; + Genivi.routing_SetWaypoints(dbusIf,true,position,destination); Genivi.data['calculate_route']=true; Genivi.data['lat']=''; Genivi.data['lon']=''; diff --git a/src/hmi/qml/TripComputer.qml b/src/hmi/qml/TripComputer.qml index d3a8108..a1bb1cf 100644 --- a/src/hmi/qml/TripComputer.qml +++ b/src/hmi/qml/TripComputer.qml @@ -49,7 +49,7 @@ HMIMenu { function connectSignals() { - tripDataUpdatedSignal=dbusIf.connect("","/org/genivi/demonstrator/FuelStopAdvisor","org.genivi.demonstrator.FuelStopAdvisor","TripDataUpdated",menu,"tripDataUpdated"); + tripDataUpdatedSignal=Genivi.connect_tripDataUpdatedSignal(dbusIf,menu); } function disconnectSignals() @@ -183,7 +183,8 @@ HMIMenu { disableAllValue(); // By default set all the values to "--" if (tripnr > 0) { res=Genivi.fuelstopadvisor_message(dbusIf,"GetTripData",["uint8",tripnr-1]); - for (var i = 0 ; i < res[1].length ; i+=4) { + Genivi.dump("update",res); + for (var i = 0 ; i < res[1].length ; i+=4) { if (res[1][i+1] == Genivi.FUELSTOPADVISOR_DISTANCE) { value=res[1][i+3][1]/10; distance_value.text=value.toFixed(1); @@ -394,10 +395,10 @@ HMIMenu { id:reset; text: Genivi.gettext("Reset"); explode:false; disabled:false; next:select_trip1; prev:back; onClicked:{ if (Genivi.tripMode == "TRIP_NUMBER1") { - Genivi.fuelstopadvisor_message(dbusIf,"ResetTripData",["uint8",0]); + Genivi.fuelstopadvisor_message(dbusIf,"ResetTripData",["uint8",0]); } if (Genivi.tripMode == "TRIP_NUMBER2") { - Genivi.fuelstopadvisor_message(dbusIf,"ResetTripData",["uint8",1]); + Genivi.fuelstopadvisor_message(dbusIf,"ResetTripData",["uint8",1]); } updateTripMode(); } diff --git a/src/hmi/qml/hmi-launcher/CMakeLists.txt b/src/hmi/qml/hmi-launcher/CMakeLists.txt index 7c22e2e..5869ce0 100644 --- a/src/hmi/qml/hmi-launcher/CMakeLists.txt +++ b/src/hmi/qml/hmi-launcher/CMakeLists.txt @@ -92,10 +92,10 @@ set(LIBRARIES # generate constants used by the QML files # in order to generate it, navigation-service and positioning have to be being cloned before file (GLOB XML_TO_CONSTANTS - ${API_DIR_PARENT_SCOPE}/map-viewer/genivi-mapviewer-constants.xml - ${API_DIR_PARENT_SCOPE}/navigation-core/genivi-navigationcore-constants.xml - ${API_DIR_PARENT_SCOPE}/poi-service/genivi-poiservice-constants.xml - ${POSITIONING_API_DIR_PARENT_SCOPE}/genivi-positioning-constants.xml + ${NAVIGATION_API_DIR}/map-viewer/genivi-mapviewer-constants.xml + ${NAVIGATION_API_DIR}/navigation-core/genivi-navigationcore-constants.xml + ${NAVIGATION_API_DIR}/poi-service/genivi-poiservice-constants.xml + ${POSITIONING_API_DIR}/genivi-positioning-constants.xml ${FUEL_STOP_ADVISOR_API_DIR}/constants.xml ) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/constants.js) diff --git a/src/hmi/qml/hmi-launcher/dbusif.cpp b/src/hmi/qml/hmi-launcher/dbusif.cpp index dde9383..1ef7526 100644 --- a/src/hmi/qml/hmi-launcher/dbusif.cpp +++ b/src/hmi/qml/hmi-launcher/dbusif.cpp @@ -608,9 +608,10 @@ QVariant dbus_error_free(&error); return QVariant(l); } - //fprintf(stderr,"res=%p\n",rmsg); + //fprintf(stderr,"res=%p\n",rmsg); dbus_error_free(&error); ret=qml_list_from_dbus_message(rmsg); + //qDebug() << ret; dbus_message_unref(rmsg); } else { dbus_message_unref(msg); diff --git a/src/run-capi b/src/run-capi new file mode 100755 index 0000000..a252a95 --- /dev/null +++ b/src/run-capi @@ -0,0 +1,281 @@ +#! /bin/bash +########################################################################### +# @licence app begin@ +# SPDX-License-Identifier: MPL-2.0 +# +# \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen +# +# \file run +# +# \brief This file is part of the Build System. +# +# \author # 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: +# +# 5-8-2014, Philippe Colliot, Refine, add a sleep and improve comments +# 30-9-2014, Philippe Colliot, Make it simpler and add a check for availability of hmi style-sheets +# +# @licence end@ +########################################################################### + +# function to start a process by freezing some of the options +function run +{ + local x=$xterm + local g=$gdb + local l=$log + local title="$1" + shift + if [ "$1" = "-n" ] + then + shift + x=0 + log=0 + fi + if [ "$1" = -"g" ] + then + shift + g=0 + fi + if [ "$x" = 1 ] + then + if [ "$g" = 1 ] + then + set -- gdb -ex run --args "$@" + fi + xterm -T "$title" -sb -sl 5000 -e "$@" & + elif [ "$log" = 1 ] + then + "$@" >"$CUR_DIR/$title.log" 2>&1 & + else + "$@" & + fi + PIDS="$PIDS $!" +} + +# function to catch the ctrl C or exit and to stop cleanly +function terminate +{ + set +e + trap "" EXIT INT + kill $PIDS 2>/dev/null + if [ "$gdb" = 1 ] + then + kill -9 $PIDS 2>/dev/null + fi + if [ -n "$wm" ] + then + sleep 2 + cd + nohup $wm >/dev/null 2>/dev/null & + fi +} + +# default settings +gdb=0 #no debug +xterm=0 #no subprocess into a separate xterm +log=0 #no log file +enhpos=1 #enhanced position server enabled +replayer=1 #replayer enabled +lm=0 #layer manager disabled +wm="" #to store the current window manager (in case of start with the layer manager) +verbose=0 #no debug or log messages displayed +center="4612 N 0608 E" + +CUR_DIR=$PWD +BIN_DIR=$CUR_DIR/build +SRC_DIR=$CUR_DIR + +SCRIPT_DIR=$SRC_DIR/script +HMI_QML_DIR=$SRC_DIR/hmi/qml +app=$HMI_QML_DIR/application.qml # hmi panel launched by default +STYLE_SHEETS_GENERATED_INDICATOR=$HMI_QML_DIR/Core/style-sheets/the-style-sheets-have-been-generated-css.js +REPLAYER_LOG_FILE=none +export REPLAYER_LOG_FILE + +# location of exe, lib and config files +AUTOMOTIVE_MESSAGE_BROKER=automotive-message-broker +AUTOMOTIVE_MESSAGE_BROKER_SRC_DIR=$SRC_DIR/$AUTOMOTIVE_MESSAGE_BROKER +AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR=$AUTOMOTIVE_MESSAGE_BROKER_SRC_DIR/src/$AUTOMOTIVE_MESSAGE_BROKER-build +GENIVI_LOGREPLAYER=genivilogreplayer +GENIVI_LOGREPLAYER_SRC_DIR=$SRC_DIR/$GENIVI_LOGREPLAYER +GENIVI_LOGREPLAYER_BIN_DIR=$BIN_DIR/$GENIVI_LOGREPLAYER + +NAVIGATION=navigation +NAVIGATION_SRC_DIR=$SRC_DIR/$NAVIGATION/src/navigation +NAVIGATION_BIN_DIR=$BIN_DIR/$NAVIGATION + +NAVIT=navit +NAVIT_BIN_DIR=$NAVIGATION_BIN_DIR/navit/navit + +POI_SERVER=poi-server +POI_SERVER_SRC_DIR=$SRC_DIR/$NAVIGATION/src/poi-service/$POI_SERVER +POI_SERVER_BIN_DIR=$SRC_DIR/$NAVIGATION/src/poi-service/poi-server-capi/bin + +LOG_REPLAYER=log-replayer +LOG_REPLAYER_SRC_DIR=$NAVIGATION_SRC_DIR/positioning/$LOG_REPLAYER +LOG_REPLAYER_BIN_DIR=$NAVIGATION_SRC_DIR/bin + +ENHANCED_POSITION_SERVICE=enhanced-position-service +ENHANCED_POSITION_SERVICE_SRC_DIR=$NAVIGATION_SRC_DIR/positioning/$ENHANCED_POSITION_SERVICE +ENHANCED_POSITION_SERVICE_BIN_DIR=$NAVIGATION_SRC_DIR/bin + +FUEL_STOP_ADVISOR=fuel-stop-advisor-capi +FUEL_STOP_ADVISOR_SRC_DIR=$SRC_DIR/$FUEL_STOP_ADVISOR +FUEL_STOP_ADVISOR_BIN_DIR=$BIN_DIR/$FUEL_STOP_ADVISOR + +HMI_LAUNCHER=hmi-launcher +HMI_LAUNCHER_SRC_DIR=$SRC_DIR/hmi/qml/$HMI_LAUNCHER +HMI_LAUNCHER_BIN_DIR=$BIN_DIR/hmi/qml/$HMI_LAUNCHER + + +# options analysis +while getopts a:c:glnorvx opt +do + case $opt in + a) #select another hmi panel + app=$OPTARG + ;; + c) #set the map center + case "$OPTARG" in + paris) + center="2.34 48.86" + ;; + tokyo) + center="139.74 35.70" + ;; + [0-9-]*) + center=$OPTARG + ;; + *) + echo "Unsupported center $OPTARG" >&2 + exit 1 + ;; + esac + ;; + g) #enable the debugger + gdb=1 + ;; + l) #enable the layer manager + lm=1 + ;; + n) #disable the enhanced position server + enhpos=0 + ;; + o) #enable the log file + log=1 + ;; + r) #disable the log replayer + replayer=0 + ;; + v) #enable log messages + verbose=1 + ;; + x) #enable subprocess in a separate xterm + xterm=1 + ;; + \?) + echo "Usage:" + echo "$0 [-a application][-c center][-glnorvx]" + echo "-a: Set application (default application.qml)" + echo "-c: Set center (supported values: paris,tokyo,longitude latitude). Default is geneve" + echo "-g: Run subprocesses within gdb (only with -x)" + echo "-l: Use layermanager" + echo "-n: Don't start enhanced positioning service" + echo "-o: Create log file of subprocess output" + echo "-r: Don't start replayer" + echo "-v: Enable the output of log or debug messages" + echo "-x: Run subprocesses in own xterm to get separated log messages (doesn't make sense with -l)" + exit 1 + esac +done + +# check if style sheets have been generated +if [ ! -f $STYLE_SHEETS_GENERATED_INDICATOR ] +then + echo "Please generate the style sheets before" + $SCRIPT_DIR/prepare.sh -h + exit 1 +fi + +# check and kill remaining ambd process +ambd_process_id=$(pidof ambd) +if [ -n $ambd_process_id ] +then + kill -9 $ambd_process_id +fi + +trap "terminate" EXIT INT +set -e #exit on error now + +echo "the graphic for navit is based on sdl" +export NAVIT_GRAPHICS='sdl' + +# set the language to en_US for navit +export LANGUAGE=en_US + +# start the automotive message broker and wait for dbus service +cd $AUTOMOTIVE_MESSAGE_BROKER_BIN_DIR +if [ "$verbose" = "1" ] +then + run "Automotive Message Broker" ./ambd/ambd --config $GENIVI_LOGREPLAYER_SRC_DIR/logreplayerconfig.in.json +else + run "Automotive Message Broker" ./ambd/ambd > /dev/null 2>&1 --config $GENIVI_LOGREPLAYER_SRC_DIR/logreplayerconfig.in.json +fi + +# start the poi server and wait for dbus service +run "POI service" $POI_SERVER_BIN_DIR/$POI_SERVER -f $SCRIPT_DIR/empty.db + +if [ "$enhpos" = 1 ] +then # start the enhanced position service + run "EnhancedPositionService" $ENHANCED_POSITION_SERVICE_BIN_DIR/EnhancedPositionServiceDBus +fi + +# start the two instances of navit with plugins (one for navigation core and another one for map viewer) +cd $NAVIT_BIN_DIR +>bookmark.txt +echo "$center" >center.txt + +if [ "$verbose" = "1" ] +then + run "MapViewer" ./$NAVIT -d 3 -c navit_genivi_mapviewer.xml +else + run "MapViewer" ./$NAVIT -d 0 -c navit_genivi_mapviewer.xml 2>~/mapviewer.log +fi + +if [ "$verbose" = "1" ] +then + run "NavigationCore" ./$NAVIT -d 3 -c navit_genivi_navigationcore.xml +else + run "NavigationCore" ./$NAVIT -d 0 -c navit_genivi_navigationcore.xml +fi + +if [ "$replayer" = 1 ] +then # start the log replayer (of the fsa) with a sample log file + run "Log Replayer" $LOG_REPLAYER_BIN_DIR/$LOG_REPLAYER $LOG_REPLAYER_SRC_DIR/logs/geneve-cologny.log +fi + +sleep 3 # need a sleep here (to be improved) +# start the fuel stop advisor application +run "Fuel Stop Advisor" $FUEL_STOP_ADVISOR_BIN_DIR/fuel-stop-advisor + +# log trace into a file +if [ "$log" = 1 ] +then + exec >$CUR_DIR/fsa.log + exec 2>&1 +fi + +# start the hmi +$HMI_LAUNCHER_BIN_DIR/$HMI_LAUNCHER $app + diff --git a/src/tripcomputer/ctripcomputer.cpp b/src/tripcomputer/ctripcomputer.cpp index 01db594..f7461f3 100644 --- a/src/tripcomputer/ctripcomputer.cpp +++ b/src/tripcomputer/ctripcomputer.cpp @@ -254,7 +254,7 @@ void CTripComputer::ResetTrip(const uint8_t &number) } } -void CTripComputer::SetUnits(const tupleUint16_t &data) +void CTripComputer::SetUnits(const tupleInt32_t &data) { //to do m_units = data; diff --git a/src/tripcomputer/ctripcomputer.h b/src/tripcomputer/ctripcomputer.h index 4f29566..62747c7 100644 --- a/src/tripcomputer/ctripcomputer.h +++ b/src/tripcomputer/ctripcomputer.h @@ -133,7 +133,7 @@ public: * \param data : dictionary of unit per value * */ - void SetUnits(const tupleUint16_t &data); + void SetUnits(const tupleInt32_t &data); /*! * \brief Get the basic data of a given trip (for testing) @@ -149,7 +149,7 @@ private: version_t m_version; uint8_t m_tripNumbers; vector<trip_t> m_tripData; - tupleUint16_t m_units; + tupleInt32_t m_units; bool m_firstRefresh; tripComputerInput_t m_lastTripComputerInput; }; diff --git a/src/tripcomputer/ctripcomputertypes.h b/src/tripcomputer/ctripcomputertypes.h index ab2436d..4203893 100644 --- a/src/tripcomputer/ctripcomputertypes.h +++ b/src/tripcomputer/ctripcomputertypes.h @@ -51,14 +51,14 @@ typedef boost::variant<uint32_t,uint16_t> variantTripComputer_t; * \brief Dictionary for getting the trip computer output values. * */ -typedef map<uint16_t,variantTripComputer_t > tupleVariantTripComputer_t; +typedef map<int32_t,variantTripComputer_t > tupleVariantTripComputer_t; /** * \union tupleUint16_t * \brief Dictionary for setting the trip computer units. * */ -typedef map<uint16_t,uint16_t> tupleUint16_t; +typedef map<int32_t,int32_t> tupleInt32_t; /** * \struct version_t |