diff options
36 files changed, 619 insertions, 4347 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bd545b..b485097 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,64 +1,21 @@ -cmake_minimum_required(VERSION 2.8.11) - -INCLUDE(FindPkgConfig) - -set(PROJECT_NAME "agl-service-navigation") -set(PROJECT_PRETTY_NAME "AFM binding for navigation service") -set(PROJECT_DESCRIPTION "Binding for AGL Navigation API") -set(PROJECT_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/include) -set(PROJECT_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib) -set(PROJECT_API_VERSION 0.1.0) -set(PROJECT_URL "https://wiki.automotivelinux.org/eg-navi") - -# Set a default build type if none was specified -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Release' as none was specified.") - set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) -endif() - -project(navi_binder) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC ") - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -pkg_check_modules(DBUSCXX REQUIRED dbus-c++-1) -pkg_check_modules(JSON REQUIRED json-c) -pkg_check_modules(AFBWSC REQUIRED libafbwsc) - -include_directories( ${PROJECT_SOURCE_DIR}/libnavi/include ${PROJECT_SOURCE_DIR}/include ${DBUSCXX_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${AFBWSC_INCLUDE_DIRS} ) - -add_library( naviapi-agl SHARED libnavi/src/navicore.cpp libnavi/src/navicorelistener.cpp libnavi/src/BinderClient.cpp libnavi/src/JsonRequestGenerator.cpp libnavi/src/JsonResponseAnalyzer.cpp libnavi/src/RequestManage.cpp ) -target_link_libraries( naviapi-agl ${JSON_LIBRARIES} ${AFBWSC_LIBRARIES} ) -set_target_properties(naviapi-agl PROPERTIES VERSION 0.1.0 SOVERSION 0) - -install(TARGETS naviapi-agl LIBRARY DESTINATION ${PROJECT_LIBDIR}) -install(FILES ${PROJECT_SOURCE_DIR}/libnavi/include/libnavicore.hpp DESTINATION ${PROJECT_INCLUDEDIR}) - -add_library( NaviAPIService SHARED src/api.cpp src/analyze_request.cpp src/binder_reply.cpp src/genivi_request.cpp ) - -target_link_libraries( NaviAPIService ${DBUSCXX_LIBRARIES} ${JSON_LIBRARIES} ${AFBWSC_LIBRARIES} ) - -########################################################################## -# AGL binding -configure_file(config.xml.in config.xml) -set(BINARY_NAME "naviapi.wgt") - -add_custom_command( - OUTPUT ${BINARY_NAME} - DEPENDS NaviAPIService - COMMAND rm -rf package - COMMAND mkdir -p package/root - COMMAND mkdir -p package/root/lib - COMMAND mv config.xml package/root/ - COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/navigation.png package/root/icon.png - COMMAND mv libNaviAPIService.so package/root/lib - COMMAND wgtpkg-pack -f -o package/${BINARY_NAME} package/root -) -add_custom_target(widget ALL DEPENDS ${BINARY_NAME}) - -#generate configure file -configure_file(libnaviapi-agl.pc.in libnaviapi-agl.pc @ONLY) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnaviapi-agl.pc - DESTINATION - ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) + +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) @@ -1,25 +1,59 @@ -AGL Navigation API Binder -=============== +# Navigation Service -Copyright 2017 AISIN AW +## Overview -author: Yoshito Momiyama <i25461_momiyama@aisin-aw.co.jp> +Navigation service keeps track of application data that allows other clients to share location, waypoints, +and state between each other. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +## Verbs - http://www.apache.org/licenses/LICENSE-2.0 +| Name | Description | JSON Response | +|---------------------|---------------------------------------------|------------------------------------| +| subscribe | subscribe to an navigation service | *Request:* {"value": "status"} | +| unsubscribe | unsubscribe to an navigation service | *Request:* {"value": "status"} | +| broadcast_status | broadcast status event to other clients | *Request:* {"state": "stop"} | +| broadcast_position | broadcast position event to other clients | See *position Verb* section | +| broadcast_waypoints | broadcast waypoints events to other clients | See *waypoints Verb* section | - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +### broadcast_position Verb -=============== +Populate same data referenced in *position Event* section for the event -This component is a reference implementation of the AGL Navigation API. +### broadcast_waypoints Verb +Populate same data referenced in *waypoints Event* section for the event +## Events + +| Name | Description | +|----------------|-------------------------------------| +| status | status of the navigation engine | +| position | current route or car position event | +| waypoints | waypoints for routing engine | + +### position Event + +<pre> +{ + "points": [ + { + "latitude": 36.12906, + "longitude": -115.17908 + } + ] +} +</pre> + +### waypoints Event + +<pre> +{ + "points": [ + { + "latitude": 36.12906, + "longitude": -115.17908 + } + ] +} +</pre> diff --git a/autobuild/agl/autobuild b/autobuild/agl/autobuild index a086c89..db00c1a 100755 --- a/autobuild/agl/autobuild +++ b/autobuild/agl/autobuild @@ -59,8 +59,8 @@ package: build @mkdir -p ${BUILD_DIR}/$@/htdocs @mkdir -p ${BUILD_DIR}/$@/var @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget - @if [ "${DEST}" != "${BUILD_DIR}/$@" ]; then \ - mkdir -p ${DEST} && cp ${BUILD_DIR}/$@/*.wgt ${DEST}; \ + @if [ "${DEST}" != "${BUILD_DIR}" ]; then \ + mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}; \ fi package-test: build diff --git a/autobuild/linux/autobuild b/autobuild/linux/autobuild index 512adda..db00c1a 100755 --- a/autobuild/linux/autobuild +++ b/autobuild/linux/autobuild @@ -16,7 +16,7 @@ THISFILE := $(lastword $(MAKEFILE_LIST)) BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build) -DESTDIR := ${BUILD_DIR} +DEST := ${BUILD_DIR} .PHONY: all clean distclean configure build package help update @@ -33,8 +33,11 @@ help: @echo "- package: output a widget file '*.wgt'" @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory" @echo "" - @echo "Usage: ./autobuild/linux/autobuild package DESTDIR=${HOME}/opt" - @echo "Don't use your build dir as DESTDIR as wgt file is generated at this location" + @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +update: configure + @cmake --build ${BUILD_DIR} --target autobuild clean: @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} ${CLEAN_ARGS} clean) || echo Nothing to clean @@ -50,9 +53,26 @@ build: configure @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all package: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/var + @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget + @if [ "${DEST}" != "${BUILD_DIR}" ]; then \ + mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}; \ + fi + +package-test: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/var @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget - @if [ "${DESTDIR}" != "${BUILD_DIR}" ]; then \ - mkdir -p ${DESTDIR} && cp ${BUILD_DIR}/*.wgt ${DESTDIR}; \ + @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target test_widget + @if [ "${DEST}" != "${BUILD_DIR}" ]; then \ + mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}; \ fi install: build diff --git a/binding/CMakeLists.txt b/binding/CMakeLists.txt new file mode 100644 index 0000000..9088825 --- /dev/null +++ b/binding/CMakeLists.txt @@ -0,0 +1,35 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@iot.bzh> +# contrib: Romain Forlot <romain.forlot@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Add target to project dependency list +PROJECT_TARGET_ADD(afm-navigation-binding) + + # Define project Targets + add_library(afm-navigation-binding MODULE navigation-api.c) + + # Binder exposes a unique public entry point + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + PREFIX "lib" + LABELS "BINDING" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} + ) + + # Library dependencies (include updates automatically) + TARGET_LINK_LIBRARIES(${TARGET_NAME} ${link_libraries}) diff --git a/binding/navigation-api.c b/binding/navigation-api.c new file mode 100644 index 0000000..d9ea285 --- /dev/null +++ b/binding/navigation-api.c @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2019 Konsulko Group + * Author: Matt Ranostay <matt.ranostay@konsulko.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define _GNU_SOURCE +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> +#include <time.h> + +#include <glib.h> +#include <glib/gstdio.h> +#include <gio/gio.h> +#include <json-c/json.h> + +#define AFB_BINDING_VERSION 3 +#include <afb/afb-binding.h> + +#include "navigation-api.h" + +struct navigation_state *navigation_get_userdata(afb_req_t request) { + afb_api_t api = afb_req_get_api(request); + return afb_api_get_userdata(api); +} + +static afb_event_t get_event_from_value(struct navigation_state *ns, + const char *value) +{ + if (!g_strcmp0(value, "status")) + return ns->status_event; + + if (!g_strcmp0(value, "position")) + return ns->position_event; + + if (!g_strcmp0(value, "waypoints")) + return ns->waypoints_event; + + return NULL; +} + +static json_object **get_storage_from_value(struct navigation_state *ns, + const char *value) +{ + if (!g_strcmp0(value, "status")) + return &ns->status_storage; + + if (!g_strcmp0(value, "position")) + return &ns->position_storage; + + if (!g_strcmp0(value, "waypoints")) + return &ns->waypoints_storage; + + return NULL; +} + +static void navigation_subscribe_unsubscribe(afb_req_t request, + gboolean unsub) +{ + struct navigation_state *ns = navigation_get_userdata(request); + json_object *jresp = json_object_new_object(); + const char *value; + afb_event_t event; + int rc; + + value = afb_req_value(request, "value"); + if (!value) { + afb_req_fail_f(request, "failed", "Missing \"value\" event"); + return; + } + + event = get_event_from_value(ns, value); + if (!event) { + afb_req_fail_f(request, "failed", "Bad \"value\" event \"%s\"", + value); + return; + } + + if (!unsub) { + json_object *storage; + rc = afb_req_subscribe(request, event); + + g_rw_lock_reader_lock(&ns->rw_lock); + storage = *get_storage_from_value(ns, value); + if (storage) { + // increment reference counter, and send out cached value + json_object_get(storage); + afb_event_push(event, storage); + } + g_rw_lock_reader_unlock(&ns->rw_lock); + } else { + rc = afb_req_unsubscribe(request, event); + } + if (rc != 0) { + afb_req_fail_f(request, "failed", + "%s error on \"value\" event \"%s\"", + !unsub ? "subscribe" : "unsubscribe", + value); + return; + } + + afb_req_success_f(request, jresp, "Navigation %s to event \"%s\"", + !unsub ? "subscribed" : "unsubscribed", + value); +} + +static void subscribe(afb_req_t request) +{ + navigation_subscribe_unsubscribe(request, FALSE); +} + +static void unsubscribe(afb_req_t request) +{ + navigation_subscribe_unsubscribe(request, TRUE); +} + +static void broadcast(afb_req_t request, const char *name, gboolean cache) +{ + struct navigation_state *ns = navigation_get_userdata(request); + afb_event_t event = get_event_from_value(ns, name); + json_object *jresp = afb_req_json(request); + + if (cache) { + json_object **storage = get_storage_from_value(ns, name); + + g_rw_lock_writer_lock(&ns->rw_lock); + + if (*storage) + json_object_put(*storage); + + // increment reference for storage + json_object_get(jresp); + *storage = jresp; + + g_rw_lock_writer_unlock(&ns->rw_lock); + } + + // increment reference for event + json_object_get(jresp); + afb_event_push(event, jresp); +} + +static void broadcast_status(afb_req_t request) +{ + broadcast(request, "status", TRUE); + + afb_req_success(request, NULL, "Broadcast status send"); +} + +static void broadcast_position(afb_req_t request) +{ + const char *position = afb_req_value(request, "position"); + gboolean cache = FALSE; + + // only send out a car position event on subscribe + if (position && !g_strcmp0(position, "car")) + cache = TRUE; + + broadcast(request, "position", cache); + + afb_req_success(request, NULL, "Broadcast position send"); +} + +static void broadcast_waypoints(afb_req_t request) +{ + broadcast(request, "waypoints", TRUE); + + afb_req_success(request, NULL, "Broadcast waypoints send"); +} + +static int init(afb_api_t api) +{ + struct navigation_state *ns; + + ns = g_try_malloc0(sizeof(*ns)); + if (!ns) { + AFB_ERROR("out of memory allocating navigation state"); + return -ENOMEM; + } + + ns->status_event = afb_daemon_make_event("status"); + ns->position_event = afb_daemon_make_event("position"); + ns->waypoints_event = afb_daemon_make_event("waypoints"); + + if (!afb_event_is_valid(ns->status_event) || + !afb_event_is_valid(ns->position_event) || + !afb_event_is_valid(ns->waypoints_event)) { + AFB_ERROR("Cannot create events"); + return -EINVAL; + } + + afb_api_set_userdata(api, ns); + + g_rw_lock_init(&ns->rw_lock); + + return 0; +} + +static const afb_verb_t binding_verbs[] = { + { + .verb = "subscribe", + .callback = subscribe, + .info = "Subscribe to event" + }, { + .verb = "unsubscribe", + .callback = unsubscribe, + .info = "Unsubscribe to event" + }, { + .verb = "broadcast_status", + .callback = broadcast_status, + .info = "Allows clients to broadcast status events" + }, { + .verb = "broadcast_position", + .callback = broadcast_position, + .info = "Broadcast out position event" + }, { + .verb = "broadcast_waypoints", + .callback = broadcast_waypoints, + .info = "Broadcast out waypoint event" + }, + {} +}; + +/* + * description of the binding for afb-daemon + */ +const afb_binding_t afbBindingV3 = { + .api = "navigation", + .verbs = binding_verbs, + .init = init, +}; diff --git a/binding/navigation-api.h b/binding/navigation-api.h new file mode 100644 index 0000000..457a87d --- /dev/null +++ b/binding/navigation-api.h @@ -0,0 +1,53 @@ +/* + * Copyright 2019 Konsulko Group + * Author: Matt Ranostay <matt.ranostay@konsulko.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NAVIGATION_API_H +#define NAVIGATION_API_H + +#include <stddef.h> + +#define _GNU_SOURCE +#include <glib.h> +#include <stdlib.h> +#include <gio/gio.h> +#include <glib-object.h> + +#include <json-c/json.h> + +#define AFB_BINDING_VERSION 3 +#include <afb/afb-binding.h> + +#include <json-c/json.h> + +struct call_work; + +struct navigation_state { + // events + afb_event_t status_event; + afb_event_t position_event; + afb_event_t waypoints_event; + + // storage + json_object *status_storage; + json_object *position_storage; + json_object *waypoints_storage; + + // locking + GRWLock rw_lock; +}; + +#endif diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake new file mode 100644 index 0000000..e096705 --- /dev/null +++ b/conf.d/cmake/config.cmake @@ -0,0 +1,167 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll <fulup@iot.bzh> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Project Info +# ------------------ +set(PROJECT_NAME agl-service-navigation) +set(PROJECT_VERSION "1.0") +set(PROJECT_PRETTY_NAME "Navigation service for AGL") +set(PROJECT_DESCRIPTION "Navigation reporting proxy for consumers") +set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/agl-service-navigation") +set(PROJECT_ICON "icon.png") +set(PROJECT_AUTHOR "Matt Ranostay") +set(PROJECT_AUTHOR_MAIL "matt.ranostay@konsulko.com") +set(PROJECT_LICENSE "APL2.0") +set(PROJECT_LANGUAGES,"C") +set(API_NAME "navigation") + +# Where the project configuration files are stored +set(PROJECT_CMAKE_CONF_DIR "conf.d") + +# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain +# but used and must be built and linked. +# set(PROJECT_LIBDIR "libs") + +# Where are stored data for your application. Pictures, static resources must be placed in that folder. +# set(PROJECT_RESOURCES "data") + +# Which directories inspect to find CMakeLists.txt target files +# set(PROJECT_SRC_DIR_PATTERN "*") + +# Compilation Mode (DEBUG, RELEASE) +# ---------------------------------- +set(BUILD_TYPE "RELEASE") + +# Kernel selection if needed. You can choose between a +# mandatory version to impose a minimal version. +# Or check Kernel minimal version and just print a Warning +# about missing features and define a preprocessor variable +# to be used as preprocessor condition in code to disable +# incompatibles features. Preprocessor define is named +# KERNEL_MINIMAL_VERSION_OK. +# +# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and +# Yocto SDK Kernel version. +# ----------------------------------------------- +#set(kernel_mandatory_version 4.8) + +# Compiler selection if needed. Impose a minimal version. +# ----------------------------------------------- +set (gcc_minimal_version 4.9) + +# PKG_CONFIG required packages +# ----------------------------- +set (PKG_REQUIRED_LIST + json-c + libsystemd>=222 + afb-daemon + json-c + glib-2.0 + gio-2.0 + gobject-2.0 + gio-unix-2.0 + zlib +) + +# Static constante definition +# ----------------------------- +add_compile_options(-DPB_FIELD_16BIT) +add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-pthread>) + +# Customize link option +# ----------------------------- +list (APPEND link_libraries -pthread) + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] +# --------------------------------------------------------------------- +set(INSTALL_PREFIX $ENV{HOME}/opt) +set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) + +# Optional location for config.xml.in +# ----------------------------------- +set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) + +# Mandatory widget Mimetype specification of the main unit +# -------------------------------------------------------------------------- +# Choose between : +#- text/html : HTML application, +# content.src designates the home page of the application +# +#- application/vnd.agl.native : AGL compatible native, +# content.src designates the relative path of the binary. +# +# - application/vnd.agl.service: AGL service, content.src is not used. +# +#- ***application/x-executable***: Native application, +# content.src designates the relative path of the binary. +# For such application, only security setup is made. +# +set(WIDGET_TYPE application/vnd.agl.service) + +# Mandatory Widget entry point file of the main unit +# -------------------------------------------------------------- +# This is the file that will be executed, loaded, +# at launch time by the application framework. +# +set(WIDGET_ENTRY_POINT lib/libafm-navigation-binding.so) + +# Print a helper message when every thing is finished +# ---------------------------------------------------- +set(CLOSING_MESSAGE "Test with: afb-daemon --rootdir=\$\$(pwd)/package --binding=\$\$(pwd)/package/${WIDGET_ENTRY_POINT} --port=1234 --tracereq=common --token=\"1\" --verbose") +set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") + + + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS) + +# Optional extra libraries +# ------------------------- +#set(EXTRA_LINK_LIBRARIES) + +# Optional force binding installation +# ------------------------------------ +# set(BINDINGS_INSTALL_PREFIX PrefixPath ) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + +# Optional force package prefix generation, like widget +# ----------------------------------------------------- +# set(PKG_PREFIX DestinationPath) + +# Optional Application Framework security token +# and port use for remote debugging. +#------------------------------------------------------------ +#set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") +#set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") + +# This include is mandatory and MUST happens at the end +# of this file, else you expose you to unexpected behavior +# +# This CMake module could be found at the following url: +# https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module +# ----------------------------------------------------------- +include(CMakeAfbTemplates) diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in new file mode 100644 index 0000000..485407e --- /dev/null +++ b/conf.d/wgt/config.xml.in @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@"> + <name>@PROJECT_NAME@</name> + <icon src="@PROJECT_ICON@"/> + <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/> + <description>@PROJECT_DESCRIPTION@</description> + <author>@PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@></author> + <license>@PROJECT_LICENSE@</license> + + <feature name="urn:AGL:widget:required-permission"> + <param name="urn:AGL:permission::public:hidden" value="required" /> + <param name="urn:AGL:permission::public:no-htdocs" value="required" /> + </feature> + + <feature name="urn:AGL:widget:provided-api"> + <param name="navigation" value="ws" /> + </feature> + + <feature name="urn:AGL:widget:required-api"> + <param name="@WIDGET_ENTRY_POINT@" value="local" /> + </feature> +</widget> diff --git a/config.xml.in b/config.xml.in deleted file mode 100644 index 25b9e53..0000000 --- a/config.xml.in +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<widget xmlns="http://www.w3.org/ns/widgets" id="naviapi-binding-service" version="0.1"> - <name>naviapi-binding-service</name> - <icon src="icon.png"/> - <content src="config.xml" type="application/vnd.agl.service"/> - <description>naviapi binding service</description> - <author>AISIN AW</author> - <license>GPL</license> - <feature name="urn:AGL:widget:required-permission"> - <param name="urn:AGL:permission::public:hidden" value="required" /> - <param name="http://tizen.org/privilege/internal/dbus" value="required" /> - </feature> - <feature name="urn:AGL:widget:provided-api"> - <param name="naviapi" value="ws" /> - </feature> - <feature name="urn:AGL:widget:required-api"> - <param name="lib/libNaviAPIService.so" value="local" /> - </feature> -</widget> diff --git a/include/analyze_request.h b/include/analyze_request.h deleted file mode 100644 index f570a1c..0000000 --- a/include/analyze_request.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <stdbool.h> -#include <stdint.h> -#include <vector> - -#include "genivi_request.h" - -/** - * @brief Analyze requests from BinderClient and create arguments to pass to Genivi API. - */ -class AnalyzeRequest -{ -public: - bool CreateParamsGetPosition( const char* req_json_str, std::vector< int32_t >& Params ); - bool CreateParamsCreateRoute( const char* req_json_str, uint32_t& sessionHdl ); - bool CreateParamsPauseSimulation( const char* req_json_str, uint32_t& sessionHdl ); - bool CreateParamsSetSimulationMode( const char* req_json_str, uint32_t& sessionHdl, bool& simuMode ); - bool CreateParamsCancelRouteCalculation( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl ); - bool CreateParamsSetWaypoints( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl, - bool& currentPos, std::vector<Waypoint>& waypointsList ); - bool CreateParamsCalculateRoute( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl ); - -private: - bool JsonObjectGetSessionHdl( const char* req_json_str, uint32_t& sessionHdl); - bool JsonObjectGetSessionHdlRouteHdl( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl); -}; - diff --git a/include/binder_reply.h b/include/binder_reply.h deleted file mode 100644 index 44e20d0..0000000 --- a/include/binder_reply.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <stdio.h> -#include <stdbool.h> -#include <string> -#include <map> -#include <vector> -#include <json-c/json.h> - -/** - * @brief Response to return to Binder client. - */ -typedef struct APIResponse_ -{ - bool isSuccess; - std::string errMessage; - json_object* json_data; -}APIResponse; - -/** - * @brief Convert information acquired by Genevi API to JSON format. - */ -class BinderReply -{ -public: - APIResponse ReplyNavicoreGetPosition( std::map<int32_t, double>& posList ); - APIResponse ReplyNavicoreGetAllRoutes( std::vector< uint32_t > &allRoutes ); - APIResponse ReplyNavicoreCreateRoute( uint32_t route ); - APIResponse ReplyNavicoreGetAllSessions( std::map<uint32_t, std::string> &allSessions ); -}; - diff --git a/include/genivi/genivi-navicore-constants.h b/include/genivi/genivi-navicore-constants.h deleted file mode 100644 index 4021006..0000000 --- a/include/genivi/genivi-navicore-constants.h +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#ifndef GENIVI_NAVICORE_CONSTANTS_H -#define GENIVI_NAVICORE_CONSTANTS_H - -#define NAVICORE_INVALID 0x0000 -#define NAVICORE_DEFAULT 0xfffe -#define NAVICORE_ALL 0xffff -#define NAVICORE_AVAILABLE 0x0001 -#define NAVICORE_NOT_AVAILABLE 0x0002 -#define NAVICORE_TIME_FORMAT 0x0003 -#define NAVICORE_12H 0x0004 -#define NAVICORE_24H 0x0005 -#define NAVICORE_COORDINATES_FORMAT 0x0006 -#define NAVICORE_DEGREES 0x0007 -#define NAVICORE_MINUTES 0x0008 -#define NAVICORE_SECONDS 0x0009 -#define NAVICORE_TIMESTAMP 0x0010 -#define NAVICORE_TIMEZONE_OFFSET 0x0011 -#define NAVICORE_DAYLIGHT_OFFSET 0x0012 -#define NAVICORE_LOCALE 0x0025 -#define NAVICORE_UNITS_OF_MEASUREMENT 0x0030 -#define NAVICORE_LENGTH 0x0031 -#define NAVICORE_METER 0x0032 -#define NAVICORE_MILE 0x0033 -#define NAVICORE_KM 0x0034 -#define NAVICORE_YARD 0x0035 -#define NAVICORE_FOOT 0x0036 -#define NAVICORE_DISABLED_PROMPT 0x0041 -#define NAVICORE_AUTOMATIC_PROMPT 0x0042 -#define NAVICORE_MANUAL_PROMPT 0x0043 -#define NAVICORE_CRUISE 0x0050 -#define NAVICORE_MANEUVER_APPEARED 0x0051 -#define NAVICORE_PRE_ADVICE 0x0052 -#define NAVICORE_ADVICE 0x0053 -#define NAVICORE_PASSED 0x0054 -#define NAVICORE_ACTIVE 0x0060 -#define NAVICORE_INACTIVE 0x0061 -#define NAVICORE_STRAIGHT_ON 0x0070 -#define NAVICORE_CROSSROAD 0x0071 -#define NAVICORE_ROUNDABOUT 0x0072 -#define NAVICORE_HIGHWAY_ENTER 0x0073 -#define NAVICORE_HIGHWAY_EXIT 0x0074 -#define NAVICORE_FOLLOW_SPECIFIC_LANE 0x0075 -#define NAVICORE_DESTINATION 0x0076 -#define NAVICORE_WAYPOINT 0x0077 -#define NAVICORE_TURN 0x0078 -#define NAVICORE_BIFURCATION 0x0079 -#define NAVICORE_LEFT 0x0080 -#define NAVICORE_SLIGHT_LEFT 0x0081 -#define NAVICORE_HARD_LEFT 0x0082 -#define NAVICORE_RIGHT 0x0083 -#define NAVICORE_SLIGHT_RIGHT 0x0084 -#define NAVICORE_HARD_RIGHT 0x0085 -#define NAVICORE_UTURN_RIGHT 0x0086 -#define NAVICORE_UTURN_LEFT 0x0087 -#define NAVICORE_ALL_MANUAL 0x0090 -#define NAVICORE_ALL_AUTOMATIC 0x0091 -#define NAVICORE_TRAFFIC_MANUAL 0x0092 -#define NAVICORE_OFF_ROUTE_MANUAL 0x0093 -#define NAVICORE_LATITUDE 0x00a0 -#define NAVICORE_LONGITUDE 0x00a1 -#define NAVICORE_ALTITUDE 0x00a2 -#define NAVICORE_HEADING 0x00a3 -#define NAVICORE_SPEED 0x00a4 -#define NAVICORE_CLIMB 0x00a5 -#define NAVICORE_COUNTRY 0x00a6 -#define NAVICORE_STATE 0x00a7 -#define NAVICORE_CITY 0x00a8 -#define NAVICORE_ZIPCODE 0x00a9 -#define NAVICORE_STREET 0x00aa -#define NAVICORE_HOUSENUMBER 0x00ab -#define NAVICORE_CROSSING 0x00ac -#define NAVICORE_DISTRICT 0x00ad -#define NAVICORE_PHONENUMBER 0x00ae -#define NAVICORE_POINAME 0x00af -#define NAVICORE_TOWNCENTER 0x00b0 -#define NAVICORE_LOCATION_INPUT 0x00b1 -#define NAVICORE_FULL_ADDRESS 0x00b2 -#define NAVICORE_COUNTRYCODE 0x00b3 -#define NAVICORE_HOUSENAME 0x00b4 -#define NAVICORE_POSTAL_CODE 0x00b5 -#define NAVICORE_NOT_STARTED 0x0c0 -#define NAVICORE_SEARCHING 0x00c1 -#define NAVICORE_FINISHED 0x00c2 -#define NAVICORE_OK 0x00d0 -#define NAVICORE_UNKNOWN 0x00d1 -#define NAVICORE_AMBIGUOUS 0x00d2 -#define NAVICORE_INCONSISTENT 0x00d3 -#define NAVICORE_GNSS_FIX_STATUS 0x00e0 -#define NAVICORE_DR_STATUS 0x00e1 -#define NAVICORE_MM_STATUS 0x00e2 -#define NAVICORE_SIMULATION_MODE 0x00e3 -#define NAVICORE_MATCH_TYPE 0x00f0 -#define NAVICORE_ON_ROAD 0x00f1 -#define NAVICORE_OFF_ROAD 0x00f2 -#define NAVICORE_ON_FERRY 0x00f3 -#define NAVICORE_IN_TUNNEL 0x00f4 -#define NAVICORE_ON_CARPARK 0x00f5 -#define NAVICORE_NO_FIX 0x0100 -#define NAVICORE_TIME_FIX 0x0101 -#define NAVICORE_2D_FIX 0x0102 -#define NAVICORE_3D_FIX 0x0103 -#define NAVICORE_SEGMENT_ID 0x0110 -#define NAVICORE_DIRECTION_ON_SEGMENT 0x0112 -#define NAVICORE_DISTANCE_ON_SEGMENT 0x0113 -#define NAVICORE_INTERMEDIATE_POINTS 0x0120 -#define NAVICORE_WAYPOINT_TYPE 0x0121 -#define NAVICORE_SOFT_POINT 0x0122 -#define NAVICORE_HARD_POINT 0x0123 -#define NAVICORE_CALCULATION_OK 0x0130 -#define NAVICORE_NO_POSITION 0x0131 -#define NAVICORE_UNMATCHED_POSITION 0x0132 -#define NAVICORE_UNREACHABLE_DESTINATION 0x0133 -#define NAVICORE_UNFULFILLED_PREFERENCE_MODE 0x0134 -#define NAVICORE_LINK_ID 0x0140 -#define NAVICORE_START_LATITUDE 0x0141 -#define NAVICORE_END_LATITUDE 0x0142 -#define NAVICORE_START_LONGITUDE 0x0143 -#define NAVICORE_END_LONGITUDE 0x0144 -#define NAVICORE_START_ALTITUDE 0x0145 -#define NAVICORE_END_ALTITUDE 0x0146 -#define NAVICORE_ROAD_NAME 0x0147 -#define NAVICORE_DISTANCE 0x0148 -#define NAVICORE_TIME 0x0149 -#define NAVICORE_MANEUVER 0x014a -#define NAVICORE_INSTRUCTION 0x014b -#define NAVICORE_BORDER_CROSSING 0x014c -#define NAVICORE_ADDITIONAL_INFORMATION 0x014d -#define NAVICORE_ROAD_NUMBER 0x014e -#define NAVICORE_START_OFFSET 0x014f -#define NAVICORE_FASTEST 0x0160 -#define NAVICORE_SHORTEST 0x0161 -#define NAVICORE_ECOLOGICAL 0x0162 -#define NAVICORE_SCENIC 0x0163 -#define NAVICORE_EASY 0x0164 -#define NAVICORE_BALANCED 0x0166 -#define NAVICORE_CHEAPEST 0x0167 -#define NAVICORE_FERRY 0x0170 -#define NAVICORE_TOLL_ROADS 0x0171 -#define NAVICORE_TUNNELS 0x0172 -#define NAVICORE_HIGHWAYS_MOTORWAYS 0x0173 -#define NAVICORE_VEHICLE_SIZE_LIMIT 0x0174 -#define NAVICORE_CRIME_AREAS 0x0175 -#define NAVICORE_BY_CAR 0x0180 -#define NAVICORE_ON_FOOT 0x0181 -#define NAVICORE_LONG_RANGE_TRAINS 0x0182 -#define NAVICORE_PUBLIC_TRANSPORTATION 0x0183 -#define NAVICORE_BY_BICYCLE 0x0184 -#define NAVICORE_BY_TRUCK 0x0185 -#define NAVICORE_BLOCK_NUMBER 0x0186 -#define NAVICORE_UNIT_NUMBER 0x0187 -#define NAVICORE_BEGIN_STREET 0x0188 -#define NAVICORE_ROAD_INTERSECTION 0x0189 -#define NAVICORE_ARRIVAL_TIME 0x018a -#define NAVICORE_ARRIVAL_DATE 0x018b -#define NAVICORE_DEPARTURE_TIME 0x018c -#define NAVICORE_DEPARTURE_DATE 0x018d -#define NAVICORE_TOTAL_TIME 0x018e -#define NAVICORE_TOTAL_DISTANCE 0x018f -#define NAVICORE_PROHIBIT 0x0190 -#define NAVICORE_AVOID 0x0191 -#define NAVICORE_USE 0x0192 -#define NAVICORE_PREFER 0x0193 -#define NAVICORE_IGNORE 0x0194 -#define NAVICORE_TRAFFIC_REALTIME 0x0200 -#define NAVICORE_TRAFFIC 0x0210 -#define NAVICORE_OFF_ROUTE 0x0211 -#define NAVICORE_MANUAL 0x0212 -#define NAVICORE_SIMULATION_STATUS_NO_SIMULATION 0x0220 -#define NAVICORE_SIMULATION_STATUS_RUNNING 0x0221 -#define NAVICORE_SIMULATION_STATUS_PAUSED 0x0222 -#define NAVICORE_SIMULATION_STATUS_FIXED_POSITION 0x0223 -#define NAVICORE_ROAD_FORM_CHANGE 0x0230 -#define NAVICORE_ROAD_REGULAR 0x0231 -#define NAVICORE_ROAD_HIGHWAY_MOTORWAY 0x0232 -#define NAVICORE_ROAD_FERRY 0x0233 -#define NAVICORE_DIRECTION 0x0240 -#define NAVICORE_EXIT_NUMBER 0x0241 -#define NAVICORE_ROAD_FORM 0x0242 -#define NAVICORE_LANE_INFO 0x0243 -#define NAVICORE_LANE_INFO_BITMASK_STRAIGHT 0x0001 -#define NAVICORE_LANE_INFO_BITMASK_SLIGHTRIGHT 0x0002 -#define NAVICORE_LANE_INFO_BITMASK_RIGHT 0x0004 -#define NAVICORE_LANE_INFO_BITMASK_SHARPRIGHT 0x0008 -#define NAVICORE_LANE_INFO_BITMASK_RIGHTUTURN 0x0010 -#define NAVICORE_LANE_INFO_BITMASK_SLIGHTLEFT 0x0020 -#define NAVICORE_LANE_INFO_BITMASK_LEFT 0x0040 -#define NAVICORE_LANE_INFO_BITMASK_SHARPLEFT 0x0080 -#define NAVICORE_LANE_INFO_BITMASK_LEFTUTURN 0x0100 -#define NAVICORE_DIVIDER_UNDEFINED 0x0250 -#define NAVICORE_DIVIDER_INTERRUPTEDLONG 0x0251 -#define NAVICORE_DIVIDER_INTERRUPTEDSHORT 0x0252 -#define NAVICORE_DIVIDER_SOLIDSINGLE 0x0253 -#define NAVICORE_DIVIDER_SOLIDDOUBLE 0x0254 -#define NAVICORE_DIVIDER_SOLIDINTERRUPTED 0x0255 -#define NAVICORE_DIVIDER_INTERRUPTEDSOLID 0x0256 - -#endif diff --git a/include/genivi/genivi-navigationcore-proxy.h b/include/genivi/genivi-navigationcore-proxy.h deleted file mode 100644 index 2322fa0..0000000 --- a/include/genivi/genivi-navigationcore-proxy.h +++ /dev/null @@ -1,1147 +0,0 @@ - -/* - * This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT! - */ - -#ifndef __dbusxx__genivi_navigationcore_proxy_h__PROXY_MARSHAL_H -#define __dbusxx__genivi_navigationcore_proxy_h__PROXY_MARSHAL_H - -#include <dbus-c++-1/dbus-c++/dbus.h> -#include <cassert> - -namespace org { -namespace genivi { -namespace navigationcore { - -class Session_proxy -: public ::DBus::InterfaceProxy -{ -public: - - Session_proxy() - : ::DBus::InterfaceProxy("org.genivi.navigationcore.Session") - { - connect_signal(Session_proxy, SessionDeleted, _SessionDeleted_stub); - } - -public: - - /* properties exported by this interface */ -public: - - /* methods exported by this interface, - * this functions will invoke the corresponding methods on the remote objects - */ - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > SessionGetVersion() - { - ::DBus::CallMessage call; - call.member("GetVersion"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > argout; - ri >> argout; - return argout; - } - - uint32_t CreateSession(const std::string& client) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << client; - call.member("CreateSession"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - uint32_t argout; - ri >> argout; - return argout; - } - - void DeleteSession(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("DeleteSession"); - ::DBus::Message ret = invoke_method (call); - } - - int32_t GetSessionStatus(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("GetSessionStatus"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - int32_t argout; - ri >> argout; - return argout; - } - - std::vector< ::DBus::Struct< uint32_t, std::string > > GetAllSessions() - { - ::DBus::CallMessage call; - call.member("GetAllSessions"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< ::DBus::Struct< uint32_t, std::string > > argout; - ri >> argout; - return argout; - } - - -public: - - /* signal handlers for this interface - */ - virtual void SessionDeleted(const uint32_t& sessionHandle) = 0; - -private: - - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _SessionDeleted_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t sessionHandle; - ri >> sessionHandle; - SessionDeleted(sessionHandle); - } -}; - -} } } -namespace org { -namespace genivi { -namespace navigationcore { - -class Routing_proxy -: public ::DBus::InterfaceProxy -{ -public: - - Routing_proxy() - : ::DBus::InterfaceProxy("org.genivi.navigationcore.Routing") - { - connect_signal(Routing_proxy, RouteDeleted, _RouteDeleted_stub); - connect_signal(Routing_proxy, RouteCalculationCancelled, _RouteCalculationCancelled_stub); - connect_signal(Routing_proxy, RouteCalculationSuccessful, _RouteCalculationSuccessful_stub); - connect_signal(Routing_proxy, RouteCalculationFailed, _RouteCalculationFailed_stub); - connect_signal(Routing_proxy, RouteCalculationProgressUpdate, _RouteCalculationProgressUpdate_stub); - connect_signal(Routing_proxy, AlternativeRoutesAvailable, _AlternativeRoutesAvailable_stub); - } - -public: - - /* properties exported by this interface */ -public: - - /* methods exported by this interface, - * this functions will invoke the corresponding methods on the remote objects - */ - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > RoutingGetVersion() - { - ::DBus::CallMessage call; - call.member("GetVersion"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > argout; - ri >> argout; - return argout; - } - - uint32_t CreateRoute(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("CreateRoute"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - uint32_t argout; - ri >> argout; - return argout; - } - - void DeleteRoute(const uint32_t& sessionHandle, const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - call.member("DeleteRoute"); - ::DBus::Message ret = invoke_method (call); - } - - void SetCostModel(const uint32_t& sessionHandle, const uint32_t& routeHandle, const int32_t& costModel) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << costModel; - call.member("SetCostModel"); - ::DBus::Message ret = invoke_method (call); - } - - int32_t GetCostModel(const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetCostModel"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - int32_t argout; - ri >> argout; - return argout; - } - - std::vector< int32_t > GetSupportedCostModels() - { - ::DBus::CallMessage call; - call.member("GetSupportedCostModels"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< int32_t > argout; - ri >> argout; - return argout; - } - - void SetRoutePreferences(const uint32_t& sessionHandle, const uint32_t& routeHandle, const std::string& countryCode, const std::vector< ::DBus::Struct< int32_t, int32_t > >& roadPreferenceList, const std::vector< ::DBus::Struct< int32_t, int32_t > >& conditionPreferenceList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << countryCode; - wi << roadPreferenceList; - wi << conditionPreferenceList; - call.member("SetRoutePreferences"); - ::DBus::Message ret = invoke_method (call); - } - - void GetRoutePreferences(const uint32_t& routeHandle, const std::string& countryCode, std::vector< ::DBus::Struct< int32_t, int32_t > >& roadPreferenceList, std::vector< ::DBus::Struct< int32_t, int32_t > >& conditionPreferenceList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - wi << countryCode; - call.member("GetRoutePreferences"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> roadPreferenceList; - ri >> conditionPreferenceList; - } - - void GetSupportedRoutePreferences(std::vector< ::DBus::Struct< int32_t, int32_t > >& routePreferencesList, std::vector< ::DBus::Struct< int32_t, int32_t > >& conditionPreferenceList) - { - ::DBus::CallMessage call; - call.member("GetSupportedRoutePreferences"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> routePreferencesList; - ri >> conditionPreferenceList; - } - - void SetRouteSchedule(const uint32_t& sessionHandle, const uint32_t& routeHandle, const std::map< int32_t, uint32_t >& routeSchedule) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << routeSchedule; - call.member("SetRouteSchedule"); - ::DBus::Message ret = invoke_method (call); - } - - std::map< int32_t, uint32_t > GetRouteSchedule(const uint32_t& routeHandle, const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - wi << valuesToReturn; - call.member("GetRouteSchedule"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, uint32_t > argout; - ri >> argout; - return argout; - } - - void SetTransportationMeans(const uint32_t& sessionHandle, const uint32_t& routeHandle, const std::vector< int32_t >& transportationMeansList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << transportationMeansList; - call.member("SetTransportationMeans"); - ::DBus::Message ret = invoke_method (call); - } - - std::vector< int32_t > GetTransportationMeans(const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetTransportationMeans"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< int32_t > argout; - ri >> argout; - return argout; - } - - std::vector< int32_t > GetSupportedTransportationMeans() - { - ::DBus::CallMessage call; - call.member("GetSupportedTransportationMeans"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< int32_t > argout; - ri >> argout; - return argout; - } - - void SetExcludedAreas(const uint32_t& sessionHandle, const uint32_t& routeHandle, const std::vector< std::vector< ::DBus::Struct< double, double > > >& excludedAreas) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << excludedAreas; - call.member("SetExcludedAreas"); - ::DBus::Message ret = invoke_method (call); - } - - std::vector< std::vector< ::DBus::Struct< double, double > > > GetExcludedAreas(const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetExcludedAreas"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< std::vector< ::DBus::Struct< double, double > > > argout; - ri >> argout; - return argout; - } - - void SetWaypoints(const uint32_t& sessionHandle, const uint32_t& routeHandle, const bool& startFromCurrentPosition, const std::vector< std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > >& waypointsList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << startFromCurrentPosition; - wi << waypointsList; - call.member("SetWaypoints"); - ::DBus::Message ret = invoke_method (call); - } - - void GetWaypoints(const uint32_t& routeHandle, bool& startFromCurrentPosition, std::vector< std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > >& waypointsList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetWaypoints"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> startFromCurrentPosition; - ri >> waypointsList; - } - - void CalculateRoute(const uint32_t& sessionHandle, const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - call.member("CalculateRoute"); - ::DBus::Message ret = invoke_method (call); - } - - void CancelRouteCalculation(const uint32_t& sessionHandle, const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - call.member("CancelRouteCalculation"); - ::DBus::Message ret = invoke_method (call); - } - - std::vector< uint32_t > CalculateRoutes(const uint32_t& sessionHandle, const std::vector< uint32_t >& calculatedRoutesList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << calculatedRoutesList; - call.member("CalculateRoutes"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< uint32_t > argout; - ri >> argout; - return argout; - } - - void GetRouteSegments(const uint32_t& routeHandle, const int16_t& detailLevel, const std::vector< int32_t >& valuesToReturn, const uint32_t& numberOfSegments, const uint32_t& offset, uint32_t& totalNumberOfSegments, std::vector< std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > >& routeSegments) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - wi << detailLevel; - wi << valuesToReturn; - wi << numberOfSegments; - wi << offset; - call.member("GetRouteSegments"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> totalNumberOfSegments; - ri >> routeSegments; - } - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetRouteOverview(const uint32_t& routeHandle, const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - wi << valuesToReturn; - call.member("GetRouteOverview"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > argout; - ri >> argout; - return argout; - } - - ::DBus::Struct< ::DBus::Struct< double, double >, ::DBus::Struct< double, double > > GetRouteBoundingBox(const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetRouteBoundingBox"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ::DBus::Struct< ::DBus::Struct< double, double >, ::DBus::Struct< double, double > > argout; - ri >> argout; - return argout; - } - - std::vector< uint32_t > GetAllRoutes() - { - ::DBus::CallMessage call; - call.member("GetAllRoutes"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< uint32_t > argout; - ri >> argout; - return argout; - } - - void SetBlockedRouteStretches(const uint32_t& sessionHandle, const uint32_t& routeHandle, const std::vector< ::DBus::Struct< uint32_t, uint32_t > >& blockParameters) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - wi << blockParameters; - call.member("SetBlockedRouteStretches"); - ::DBus::Message ret = invoke_method (call); - } - - std::vector< ::DBus::Struct< uint32_t, uint32_t > > GetBlockedRouteStretches(const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << routeHandle; - call.member("GetBlockedRouteStretches"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::vector< ::DBus::Struct< uint32_t, uint32_t > > argout; - ri >> argout; - return argout; - } - - -public: - - /* signal handlers for this interface - */ - virtual void RouteDeleted(const uint32_t& routeHandle) = 0; - virtual void RouteCalculationCancelled(const uint32_t& routeHandle) = 0; - virtual void RouteCalculationSuccessful(const uint32_t& routeHandle, const std::map< int32_t, int32_t >& unfullfilledPreferences) = 0; - virtual void RouteCalculationFailed(const uint32_t& routeHandle, const int32_t& errorCode, const std::map< int32_t, int32_t >& unfullfilledPreferences) = 0; - virtual void RouteCalculationProgressUpdate(const uint32_t& routeHandle, const int32_t& status, const uint8_t& percentage) = 0; - virtual void AlternativeRoutesAvailable(const std::vector< uint32_t >& routeHandlesList) = 0; - -private: - - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _RouteDeleted_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t routeHandle; - ri >> routeHandle; - RouteDeleted(routeHandle); - } - void _RouteCalculationCancelled_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t routeHandle; - ri >> routeHandle; - RouteCalculationCancelled(routeHandle); - } - void _RouteCalculationSuccessful_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t routeHandle; - ri >> routeHandle; - std::map< int32_t, int32_t > unfullfilledPreferences; - ri >> unfullfilledPreferences; - RouteCalculationSuccessful(routeHandle, unfullfilledPreferences); - } - void _RouteCalculationFailed_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t routeHandle; - ri >> routeHandle; - int32_t errorCode; - ri >> errorCode; - std::map< int32_t, int32_t > unfullfilledPreferences; - ri >> unfullfilledPreferences; - RouteCalculationFailed(routeHandle, errorCode, unfullfilledPreferences); - } - void _RouteCalculationProgressUpdate_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t routeHandle; - ri >> routeHandle; - int32_t status; - ri >> status; - uint8_t percentage; - ri >> percentage; - RouteCalculationProgressUpdate(routeHandle, status, percentage); - } - void _AlternativeRoutesAvailable_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::vector< uint32_t > routeHandlesList; - ri >> routeHandlesList; - AlternativeRoutesAvailable(routeHandlesList); - } -}; - -} } } -namespace org { -namespace genivi { -namespace navigationcore { - -class MapMatchedPosition_proxy -: public ::DBus::InterfaceProxy -{ -public: - - MapMatchedPosition_proxy() - : ::DBus::InterfaceProxy("org.genivi.navigationcore.MapMatchedPosition") - { - connect_signal(MapMatchedPosition_proxy, SimulationStatusChanged, _SimulationStatusChanged_stub); - connect_signal(MapMatchedPosition_proxy, SimulationSpeedChanged, _SimulationSpeedChanged_stub); - connect_signal(MapMatchedPosition_proxy, PositionUpdate, _PositionUpdate_stub); - connect_signal(MapMatchedPosition_proxy, AddressUpdate, _AddressUpdate_stub); - connect_signal(MapMatchedPosition_proxy, PositionOnSegmentUpdate, _PositionOnSegmentUpdate_stub); - connect_signal(MapMatchedPosition_proxy, StatusUpdate, _StatusUpdate_stub); - connect_signal(MapMatchedPosition_proxy, OffRoadPositionChanged, _OffRoadPositionChanged_stub); - } - -public: - - /* properties exported by this interface */ -public: - - /* methods exported by this interface, - * this functions will invoke the corresponding methods on the remote objects - */ - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > MapMatchedPositionGetVersion() - { - ::DBus::CallMessage call; - call.member("GetVersion"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > argout; - ri >> argout; - return argout; - } - - void SetSimulationMode(const uint32_t& sessionHandle, const bool& activate) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << activate; - call.member("SetSimulationMode"); - ::DBus::Message ret = invoke_method (call); - } - - int32_t GetSimulationStatus() - { - ::DBus::CallMessage call; - call.member("GetSimulationStatus"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - int32_t argout; - ri >> argout; - return argout; - } - - void AddSimulationStatusListener() - { - ::DBus::CallMessage call; - call.member("AddSimulationStatusListener"); - ::DBus::Message ret = invoke_method (call); - } - - void RemoveSimulationStatusListener() - { - ::DBus::CallMessage call; - call.member("RemoveSimulationStatusListener"); - ::DBus::Message ret = invoke_method (call); - } - - void SetSimulationSpeed(const uint32_t& sessionHandle, const uint8_t& speedFactor) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << speedFactor; - call.member("SetSimulationSpeed"); - ::DBus::Message ret = invoke_method (call); - } - - uint8_t GetSimulationSpeed() - { - ::DBus::CallMessage call; - call.member("GetSimulationSpeed"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - uint8_t argout; - ri >> argout; - return argout; - } - - void AddSimulationSpeedListener() - { - ::DBus::CallMessage call; - call.member("AddSimulationSpeedListener"); - ::DBus::Message ret = invoke_method (call); - } - - void RemoveSimulationSpeedListener() - { - ::DBus::CallMessage call; - call.member("RemoveSimulationSpeedListener"); - ::DBus::Message ret = invoke_method (call); - } - - void StartSimulation(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("StartSimulation"); - ::DBus::Message ret = invoke_method (call); - } - - void PauseSimulation(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("PauseSimulation"); - ::DBus::Message ret = invoke_method (call); - } - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetPosition(const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << valuesToReturn; - call.member("GetPosition"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > argout; - ri >> argout; - return argout; - } - - void SetPosition(const uint32_t& sessionHandle, const std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > >& position) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << position; - call.member("SetPosition"); - ::DBus::Message ret = invoke_method (call); - } - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetAddress(const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << valuesToReturn; - call.member("GetAddress"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > argout; - ri >> argout; - return argout; - } - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetPositionOnSegment(const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << valuesToReturn; - call.member("GetPositionOnSegment"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > argout; - ri >> argout; - return argout; - } - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > GetStatus(const std::vector< int32_t >& valuesToReturn) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << valuesToReturn; - call.member("GetStatus"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > argout; - ri >> argout; - return argout; - } - - -public: - - /* signal handlers for this interface - */ - virtual void SimulationStatusChanged(const int32_t& simulationStatus) = 0; - virtual void SimulationSpeedChanged(const uint8_t& speedFactor) = 0; - virtual void PositionUpdate(const std::vector< int32_t >& changedValues) = 0; - virtual void AddressUpdate(const std::vector< int32_t >& changedValues) = 0; - virtual void PositionOnSegmentUpdate(const std::vector< int32_t >& changedValues) = 0; - virtual void StatusUpdate(const std::vector< int32_t >& changedValues) = 0; - virtual void OffRoadPositionChanged(const uint32_t& distance, const int32_t& direction) = 0; - -private: - - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _SimulationStatusChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - int32_t simulationStatus; - ri >> simulationStatus; - SimulationStatusChanged(simulationStatus); - } - void _SimulationSpeedChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint8_t speedFactor; - ri >> speedFactor; - SimulationSpeedChanged(speedFactor); - } - void _PositionUpdate_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::vector< int32_t > changedValues; - ri >> changedValues; - PositionUpdate(changedValues); - } - void _AddressUpdate_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::vector< int32_t > changedValues; - ri >> changedValues; - AddressUpdate(changedValues); - } - void _PositionOnSegmentUpdate_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::vector< int32_t > changedValues; - ri >> changedValues; - PositionOnSegmentUpdate(changedValues); - } - void _StatusUpdate_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - std::vector< int32_t > changedValues; - ri >> changedValues; - StatusUpdate(changedValues); - } - void _OffRoadPositionChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t distance; - ri >> distance; - int32_t direction; - ri >> direction; - OffRoadPositionChanged(distance, direction); - } -}; - -} } } -namespace org { -namespace genivi { -namespace navigationcore { - -class Guidance_proxy -: public ::DBus::InterfaceProxy -{ -public: - - Guidance_proxy() - : ::DBus::InterfaceProxy("org.genivi.navigationcore.Guidance") - { - connect_signal(Guidance_proxy, VehicleLeftTheRoadNetwork, _VehicleLeftTheRoadNetwork_stub); - connect_signal(Guidance_proxy, GuidanceStatusChanged, _GuidanceStatusChanged_stub); - connect_signal(Guidance_proxy, WaypointReached, _WaypointReached_stub); - connect_signal(Guidance_proxy, ManeuverChanged, _ManeuverChanged_stub); - connect_signal(Guidance_proxy, PositionOnRouteChanged, _PositionOnRouteChanged_stub); - connect_signal(Guidance_proxy, VehicleLeftTheRoute, _VehicleLeftTheRoute_stub); - connect_signal(Guidance_proxy, PositionToRouteChanged, _PositionToRouteChanged_stub); - connect_signal(Guidance_proxy, ActiveRouteChanged, _ActiveRouteChanged_stub); - } - -public: - - /* properties exported by this interface */ -public: - - /* methods exported by this interface, - * this functions will invoke the corresponding methods on the remote objects - */ - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > GuidanceGetVersion() - { - ::DBus::CallMessage call; - call.member("GetVersion"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ::DBus::Struct< uint16_t, uint16_t, uint16_t, std::string > argout; - ri >> argout; - return argout; - } - - void StartGuidance(const uint32_t& sessionHandle, const uint32_t& routeHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeHandle; - call.member("StartGuidance"); - ::DBus::Message ret = invoke_method (call); - } - - void StopGuidance(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("StopGuidance"); - ::DBus::Message ret = invoke_method (call); - } - - void SetVoiceGuidance(const bool& activate, const std::string& voice) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << activate; - wi << voice; - call.member("SetVoiceGuidance"); - ::DBus::Message ret = invoke_method (call); - } - - void GetGuidanceDetails(bool& voiceGuidance, bool& vehicleOnTheRoad, bool& isDestinationReached, int32_t& maneuver) - { - ::DBus::CallMessage call; - call.member("GetGuidanceDetails"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> voiceGuidance; - ri >> vehicleOnTheRoad; - ri >> isDestinationReached; - ri >> maneuver; - } - - void PlayVoiceManeuver() - { - ::DBus::CallMessage call; - call.member("PlayVoiceManeuver"); - ::DBus::Message ret = invoke_method (call); - } - - void GetWaypointInformation(const uint16_t& requestedNumberOfWaypoints, uint16_t& numberOfWaypoints, std::vector< ::DBus::Struct< uint32_t, uint32_t, int32_t, int32_t, int16_t, int16_t, bool, uint16_t > >& waypointsList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << requestedNumberOfWaypoints; - call.member("GetWaypointInformation"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> numberOfWaypoints; - ri >> waypointsList; - } - - void GetDestinationInformation(uint32_t& offset, uint32_t& travelTime, int32_t& direction, int32_t& side, int16_t& timeZone, int16_t& daylightSavingTime) - { - ::DBus::CallMessage call; - call.member("GetDestinationInformation"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> offset; - ri >> travelTime; - ri >> direction; - ri >> side; - ri >> timeZone; - ri >> daylightSavingTime; - } - - void GetManeuversList(const uint16_t& requestedNumberOfManeuvers, const uint32_t& maneuverOffset, uint16_t& numberOfManeuvers, std::vector< ::DBus::Struct< std::string, std::string, uint16_t, int32_t, uint32_t, std::vector< ::DBus::Struct< uint32_t, uint32_t, int32_t, int32_t, std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > > > > >& maneuversList) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << requestedNumberOfManeuvers; - wi << maneuverOffset; - call.member("GetManeuversList"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> numberOfManeuvers; - ri >> maneuversList; - } - - void SetRouteCalculationMode(const uint32_t& sessionHandle, const int32_t& routeCalculationMode) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - wi << routeCalculationMode; - call.member("SetRouteCalculationMode"); - ::DBus::Message ret = invoke_method (call); - } - - void SkipNextManeuver(const uint32_t& sessionHandle) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << sessionHandle; - call.member("SkipNextManeuver"); - ::DBus::Message ret = invoke_method (call); - } - - void GetGuidanceStatus(int32_t& guidanceStatus, uint32_t& routeHandle) - { - ::DBus::CallMessage call; - call.member("GetGuidanceStatus"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - ri >> guidanceStatus; - ri >> routeHandle; - } - - void SetVoiceGuidanceSettings(const int32_t& promptMode) - { - ::DBus::CallMessage call; - ::DBus::MessageIter wi = call.writer(); - - wi << promptMode; - call.member("SetVoiceGuidanceSettings"); - ::DBus::Message ret = invoke_method (call); - } - - int32_t GetVoiceGuidanceSettings() - { - ::DBus::CallMessage call; - call.member("GetVoiceGuidanceSettings"); - ::DBus::Message ret = invoke_method (call); - ::DBus::MessageIter ri = ret.reader(); - - int32_t argout; - ri >> argout; - return argout; - } - - -public: - - /* signal handlers for this interface - */ - virtual void VehicleLeftTheRoadNetwork() = 0; - virtual void GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle) = 0; - virtual void WaypointReached(const bool& isDestination) = 0; - virtual void ManeuverChanged(const int32_t& maneuver) = 0; - virtual void PositionOnRouteChanged(const uint32_t& offsetOnRoute) = 0; - virtual void VehicleLeftTheRoute() = 0; - virtual void PositionToRouteChanged(const uint32_t& distance, const int32_t& direction) = 0; - virtual void ActiveRouteChanged(const int32_t& changeCause) = 0; - -private: - - /* unmarshalers (to unpack the DBus message before calling the actual signal handler) - */ - void _VehicleLeftTheRoadNetwork_stub(const ::DBus::SignalMessage &sig) - { - VehicleLeftTheRoadNetwork(); - } - void _GuidanceStatusChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - int32_t guidanceStatus; - ri >> guidanceStatus; - uint32_t routeHandle; - ri >> routeHandle; - GuidanceStatusChanged(guidanceStatus, routeHandle); - } - void _WaypointReached_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - bool isDestination; - ri >> isDestination; - WaypointReached(isDestination); - } - void _ManeuverChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - int32_t maneuver; - ri >> maneuver; - ManeuverChanged(maneuver); - } - void _PositionOnRouteChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t offsetOnRoute; - ri >> offsetOnRoute; - PositionOnRouteChanged(offsetOnRoute); - } - void _VehicleLeftTheRoute_stub(const ::DBus::SignalMessage &sig) - { - VehicleLeftTheRoute(); - } - void _PositionToRouteChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - uint32_t distance; - ri >> distance; - int32_t direction; - ri >> direction; - PositionToRouteChanged(distance, direction); - } - void _ActiveRouteChanged_stub(const ::DBus::SignalMessage &sig) - { - ::DBus::MessageIter ri = sig.reader(); - - int32_t changeCause; - ri >> changeCause; - ActiveRouteChanged(changeCause); - } -}; - -} } } -#endif //__dbusxx__genivi_navigationcore_proxy_h__PROXY_MARSHAL_H diff --git a/include/genivi/navicore.h b/include/genivi/navicore.h deleted file mode 100644 index a80bc1f..0000000 --- a/include/genivi/navicore.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#ifndef NAVICORE_H -#define NAVICORE_H - -#include <dbus-c++-1/dbus-c++/dbus.h> -#include "genivi-navigationcore-proxy.h" -#include <stdio.h> - -class Navicore : - public org::genivi::navigationcore::Session_proxy, - public org::genivi::navigationcore::Routing_proxy, - public org::genivi::navigationcore::MapMatchedPosition_proxy, - public org::genivi::navigationcore::Guidance_proxy, - public DBus::IntrospectableProxy, - public DBus::ObjectProxy -{ -public: - Navicore(DBus::Connection &connection, const char *path, const char *name) - : DBus::ObjectProxy(connection, path, name) - { - }; - - // Session - void SessionDeleted(const uint32_t& sessionHandle) - { - printf("NavicoreSession - Session %d deleted\n",sessionHandle); - }; - - // Routing - void RouteDeleted(const uint32_t& routeHandle) - { - // TODO - }; - - void RouteCalculationCancelled(const uint32_t& routeHandle) - { - // TODO - }; - - void RouteCalculationSuccessful(const uint32_t& routeHandle, const std::map< int32_t, int32_t >& unfullfilledPreferences) - { - // TODO - }; - - void RouteCalculationFailed(const uint32_t& routeHandle, const int32_t& errorCode, const std::map< int32_t, int32_t >& unfullfilledPreferences) - { - // TODO - }; - - void RouteCalculationProgressUpdate(const uint32_t& routeHandle, const int32_t& status, const uint8_t& percentage) - { - // TODO - }; - - void AlternativeRoutesAvailable(const std::vector< uint32_t >& routeHandlesList) - { - // TODO - }; - - // MapMatchedPosition - void SimulationStatusChanged(const int32_t& simulationStatus) - { - // TODO - }; - - void SimulationSpeedChanged(const uint8_t& speedFactor) - { - // TODO - }; - - void PositionUpdate(const std::vector< int32_t >& changedValues) - { - // TODO - }; - - void AddressUpdate(const std::vector< int32_t >& changedValues) - { - // TODO - }; - - void PositionOnSegmentUpdate(const std::vector< int32_t >& changedValues) - { - // TODO - }; - - void StatusUpdate(const std::vector< int32_t >& changedValues) - { - // TODO - }; - - void OffRoadPositionChanged(const uint32_t& distance, const int32_t& direction) - { - // TODO - }; - - // Guidance - void VehicleLeftTheRoadNetwork() - { - // TODO - }; - - void GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle) - { - // TODO - }; - - void WaypointReached(const bool& isDestination) - { - // TODO - }; - - void ManeuverChanged(const int32_t& maneuver) - { - // TODO - }; - - void PositionOnRouteChanged(const uint32_t& offsetOnRoute) - { - // TODO - }; - - void VehicleLeftTheRoute() - { - // TODO - }; - - void PositionToRouteChanged(const uint32_t& distance, const int32_t& direction) - { - // TODO - }; - - void ActiveRouteChanged(const int32_t& changeCause) - { - // TODO - }; - -}; - -#endif diff --git a/include/genivi_request.h b/include/genivi_request.h deleted file mode 100644 index 75201c7..0000000 --- a/include/genivi_request.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <map> -#include <vector> -#include <stdint.h> - -typedef std::tuple<double, double> Waypoint; - -/** - * @brief Genivi API call. - */ -class GeniviRequest -{ -public: - ~GeniviRequest(); - - std::map< int32_t, double > NavicoreGetPosition( const std::vector< int32_t >& valuesToReturn ); - std::vector< uint32_t > NavicoreGetAllRoutes(); - uint32_t NavicoreCreateRoute( const uint32_t& sessionHandle ); - void NavicorePauseSimulation( const uint32_t& sessionHandle ); - void NavicoreSetSimulationMode( const uint32_t& sessionHandle, const bool& activate ); - void NavicoreCancelRouteCalculation( const uint32_t& sessionHandle, const uint32_t& routeHandle ); - void NavicoreSetWaypoints( const uint32_t& sessionHandle, const uint32_t& routeHandle, - const bool& startFromCurrentPosition, const std::vector<Waypoint>& waypointsList ); - void NavicoreCalculateRoute( const uint32_t& sessionHandle, const uint32_t& routeHandle ); - std::map<uint32_t, std::string> NavicoreGetAllSessions(); - -private: - void* navicore_; - - void CreateDBusSession(); - bool CheckSession(); -}; - diff --git a/libnavi/include/BinderClient.h b/libnavi/include/BinderClient.h deleted file mode 100644 index 70a6558..0000000 --- a/libnavi/include/BinderClient.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <map> -#include <tuple> -#include <vector> -#include <string> - -#include "libnavicore.hpp" - -#include "RequestManageListener.h" -#include "RequestManage.h" - -#define API_NAME "naviapi" - -/** - * @brief API name - */ -#define VERB_GETPOSITION "navicore_getposition" -#define VERB_GETALLROUTES "navicore_getallroutes" -#define VERB_CREATEROUTE "navicore_createroute" -#define VERB_PAUSESIMULATION "navicore_pausesimulation" -#define VERB_SETSIMULATIONMODE "navicore_setsimulationmode" -#define VERB_CANCELROUTECALCULATION "navicore_cancelroutecalculation" -#define VERB_SETWAYPOINTS "navicore_setwaypoints" -#define VERB_CALCULATEROUTE "navicore_calculateroute" -#define VERB_GETALLSESSIONS "navicore_getallsessions" - -/** - * @brief Binder client class - */ -class BinderClient : public RequestManageListener -{ -public: - BinderClient(); - ~BinderClient(); - - bool ConnectServer(std::string url , naviapi::NavicoreListener* listener); - void NavicoreGetPosition(const std::vector< int32_t >& valuesToReturn); - void NavicoreGetAllRoutes(); - void NavicoreCreateRoute(const uint32_t& sessionHandle); - void NavicorePauseSimulation(const uint32_t& sessionHandle); - void NavicoreSetSimulationMode(const uint32_t& sessionHandle, const bool& activate); - void NavicoreCancelRouteCalculation(const uint32_t& sessionHandle, const uint32_t& routeHandle); - void NavicoreSetWaypoints(const uint32_t& sessionHandle, const uint32_t& routeHandle, const bool& startFromCurrentPosition, const std::vector<naviapi::Waypoint>& waypointsList); - void NavicoreCalculateRoute(const uint32_t& sessionHandle, const uint32_t& routeHandle); - void NavicoreGetAllSessions(); - -private: - void OnReply(struct json_object *reply); - -private: - naviapi::NavicoreListener* navicoreListener; - RequestManage* requestMng; -}; - diff --git a/libnavi/include/JsonRequestGenerator.h b/libnavi/include/JsonRequestGenerator.h deleted file mode 100644 index 7cd6979..0000000 --- a/libnavi/include/JsonRequestGenerator.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <stdint.h> -#include <string> -#include <vector> - -#include "libnavicore.hpp" - -/** -* @brief Class for generating Json request -*/ -class JsonRequestGenerator -{ -public: - static std::string CreateRequestGetPosition(const std::vector< int32_t >& valuesToReturn); - static std::string CreateRequestGetAllRoutes(); - static std::string CreateRequestCreateRoute(const uint32_t* sessionHandle); - static std::string CreateRequestPauseSimulation(const uint32_t* sessionHandle); - static std::string CreateRequestSetSimulationMode(const uint32_t* sessionHandle, const bool* activate); - static std::string CreateRequestCancelRouteCalculation(const uint32_t* sessionHandle, const uint32_t* routeHandle); - static std::string CreateRequestSetWaypoints(const uint32_t* sessionHandle, const uint32_t* routeHandle, - const bool* startFromCurrentPosition, const std::vector<naviapi::Waypoint>* waypointsList); - static std::string CreateRequestCalculateroute(const uint32_t* sessionHandle, const uint32_t* routeHandle); - static std::string CreateRequestGetAllSessions(); -}; - diff --git a/libnavi/include/JsonResponseAnalyzer.h b/libnavi/include/JsonResponseAnalyzer.h deleted file mode 100644 index 50b2cd2..0000000 --- a/libnavi/include/JsonResponseAnalyzer.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <json-c/json.h> -#include <stdint.h> -#include <string> -#include <vector> -#include <map> - -#include "libnavicore.hpp" - -/** -* @brief JSON response analysis class -*/ -class JsonResponseAnalyzer -{ -public: - static std::map< int32_t, naviapi::variant > AnalyzeResponseGetPosition( std::string& res_json ); - static std::vector< uint32_t > AnalyzeResponseGetAllRoutes( std::string& res_json ); - static uint32_t AnalyzeResponseCreateRoute( std::string& res_json ); - static std::map<uint32_t, std::string> AnalyzeResponseGetAllSessions( std::string& res_json ); -}; - diff --git a/libnavi/include/RequestManage.h b/libnavi/include/RequestManage.h deleted file mode 100644 index 05ffcdf..0000000 --- a/libnavi/include/RequestManage.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <stdint.h> -#include <string> -#include <pthread.h> - -extern "C" { - #include <afb/afb-wsj1.h> - #include <afb/afb-ws-client.h> -} - -#include "RequestManageListener.h" - -/** -* @brief Class for request -*/ -class RequestManage -{ -public: - pthread_cond_t cond; - pthread_mutex_t mutex; - - struct afb_wsj1* wsj1; - std::string* requestURL; - struct afb_wsj1_itf wsj1_itf; - -private: - RequestManageListener* listener; - int request_cnt; - uint32_t sessionHandle; - uint32_t routeHandle; - - // Function called from thread - static void* BinderThread(void* param); - - // Callback function - void OnReply(struct afb_wsj1_msg *msg); - void OnHangup(struct afb_wsj1 *wsj1); - void OnCallStatic(const char *api, const char *verb, struct afb_wsj1_msg *msg); - void OnEventStatic(const char *event, struct afb_wsj1_msg *msg); - - static void OnReplyStatic(void *closure, struct afb_wsj1_msg *msg); - static void OnHangupStatic(void *closure, struct afb_wsj1 *wsj1); - static void OnCallStatic(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg); - static void OnEventStatic(void *closure, const char *event, struct afb_wsj1_msg *msg); - -// ================================================================================================== -// public -// ================================================================================================== -public: - RequestManage(); - ~RequestManage(); - - bool Connect(const char* api_url, RequestManageListener* listener); - bool IsConnect(); - bool CallBinderAPI(const char *api, const char *verb, const char *object); - void SetSessionHandle(uint32_t session); - uint32_t GetSessionHandle(); - void SetRouteHandle(uint32_t route); - uint32_t GetRouteHandle(); -}; - diff --git a/libnavi/include/RequestManageListener.h b/libnavi/include/RequestManageListener.h deleted file mode 100644 index 3b0c932..0000000 --- a/libnavi/include/RequestManageListener.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <json-c/json.h> - -class RequestManageListener -{ -public: - RequestManageListener() { - } - virtual ~RequestManageListener() { - } - - virtual void OnReply(struct json_object *reply) = 0; -}; - diff --git a/libnavi/include/libnavicore.hpp b/libnavi/include/libnavicore.hpp deleted file mode 100644 index 66200d9..0000000 --- a/libnavi/include/libnavicore.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#pragma once - -#include <map> -#include <string> -#include <tuple> -#include <vector> - -#include <stdint.h> - -namespace naviapi { - -static const uint32_t NAVICORE_TIMESTAMP = 0x0010; -static const uint32_t NAVICORE_LATITUDE = 0x00a0; -static const uint32_t NAVICORE_LONGITUDE = 0x00a1; -static const uint32_t NAVICORE_HEADING = 0x00a3; -static const uint32_t NAVICORE_SPEED = 0x00a4; -static const uint32_t NAVICORE_SIMULATION_MODE = 0x00e3; - -typedef union -{ - bool _bool; - int32_t _int32_t; - uint32_t _uint32_t; - double _double; -} variant; - -typedef std::tuple<double, double> Waypoint; - -class NavicoreListener -{ -public: - NavicoreListener(); - virtual ~NavicoreListener(); - - virtual void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions); - virtual void getPosition_reply(std::map< int32_t, variant > position); - virtual void getAllRoutes_reply(std::vector< uint32_t > allRoutes); - virtual void createRoute_reply(uint32_t routeHandle); -}; // class NavicoreListener - -class Navicore -{ -private: - NavicoreListener* mListener; - -public: - Navicore(); - virtual ~Navicore(); - - bool connect(int argc, char *argv[], NavicoreListener* listener); - void disconnect(); - - void getAllSessions(); - void getPosition(std::vector<int32_t> params); - void getAllRoutes(); - void createRoute(uint32_t session); - - void pauseSimulation(uint32_t session); - void setSimulationMode(uint32_t session, bool activate); - void cancelRouteCalculation(uint32_t session, uint32_t routeHandle); - void setWaypoints(uint32_t session, uint32_t routeHandle, bool flag, std::vector<Waypoint>); - void calculateRoute(uint32_t session, uint32_t routeHandle); - -}; // class Navicore - -}; // namespace naviapi - diff --git a/libnavi/include/traces.h b/libnavi/include/traces.h deleted file mode 100644 index a1f96ec..0000000 --- a/libnavi/include/traces.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#ifndef __TRACE_H__ -#define __TRACE_H__ - -#include <stdio.h> - -#define BLACK "\033[30m" -#define RED "\033[31m" -#define GREEN "\033[32m" -#define YELLOW "\033[33m" -#define BLUE "\033[34m" -#define PURPLE "\033[35m" -#define DGREEN "\033[6m" -#define WHITE "\033[7m" -#define CYAN "\x1b[36m" -#define NONE "\033[0m" - -#ifdef NDEBUG - -#define TRACE_DEBUG_JSON(fmt, args...) -#define TRACE_DEBUG(fmt, args...) -#define TRACE_INFO(fmt, args...) -#define TRACE_WARN(fmt, args...) -#define TRACE_ERROR(fmt, args...) - -#else - -#define TRACE_DEBUG(fmt, args...) do { fprintf(stderr, "[%s:%d] " CYAN "DEBUG" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_INFO(fmt, args...) do { fprintf(stderr, "[%s:%d] " GREEN "INFO" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_WARN(fmt, args...) do { fprintf(stderr, "[%s:%d] " YELLOW "WARN" NONE": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_ERROR(fmt, args...) do { fprintf(stderr, "[%s:%d] " RED "ERROR" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) - -#define TRACE_DEBUG_JSON(fmt, args...) - -#endif - -#endif // __TRACE_H__ diff --git a/libnavi/src/BinderClient.cpp b/libnavi/src/BinderClient.cpp deleted file mode 100644 index 1e1e9e9..0000000 --- a/libnavi/src/BinderClient.cpp +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include <cstring> - -#include "BinderClient.h" -#include "JsonRequestGenerator.h" -#include "JsonResponseAnalyzer.h" - -#include "traces.h" - -/** - * @brief constructor - */ -BinderClient::BinderClient() : navicoreListener(nullptr) -{ - requestMng = new RequestManage(); -} - -/** - * @brief Destructor - */ -BinderClient::~BinderClient() -{ - delete requestMng; -} - -/** - * @brief Connect with the Binder server - */ -bool BinderClient::ConnectServer(std::string url, naviapi::NavicoreListener* listener) -{ - this->navicoreListener = listener; - - if( !requestMng->Connect(url.c_str(), this)) - { - TRACE_ERROR("cannot connect to binding service.\n"); - return false; - } - - return true; -} - -/** - * @brief Call Genivi's GetPosition via Binder and get the result - */ -void BinderClient::NavicoreGetPosition(const std::vector< int32_t >& valuesToReturn) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - std::string req_json = JsonRequestGenerator::CreateRequestGetPosition(valuesToReturn); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_GETPOSITION, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_getposition success.\n"); - } - else - { - TRACE_ERROR("navicore_getposition failed.\n"); - } - } -} - -/** - * @brief Get route handle - */ -void BinderClient::NavicoreGetAllRoutes() -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - std::string req_json = JsonRequestGenerator::CreateRequestGetAllRoutes(); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_GETALLROUTES, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_getallroutes success.\n"); - } - else - { - TRACE_ERROR("navicore_getallroutes failed.\n"); - } - } -} - -/** - * @brief Generate route handle - */ -void BinderClient::NavicoreCreateRoute(const uint32_t& sessionHandle) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestCreateRoute(&session); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_CREATEROUTE, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_createroute success.\n"); - } - else - { - TRACE_ERROR("navicore_createroute failed.\n"); - } - } -} - -/** - * @brief Pause demo - */ -void BinderClient::NavicorePauseSimulation(const uint32_t& sessionHandle) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestPauseSimulation(&session); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_PAUSESIMULATION, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_pausesimulationmode success.\n"); - } - else - { - TRACE_ERROR("navicore_pausesimulationmode failed.\n"); - } - } -} - -/** - * @brief Simulation mode setting - */ -void BinderClient::NavicoreSetSimulationMode(const uint32_t& sessionHandle, const bool& activate) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestSetSimulationMode(&session, &activate); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_SETSIMULATIONMODE, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_setsimulationmode success.\n"); - } - else - { - TRACE_ERROR("navicore_setsimulationmode failed.\n"); - } - } -} - -/** - * @brief Delete route information - */ -void BinderClient::NavicoreCancelRouteCalculation(const uint32_t& sessionHandle, const uint32_t& routeHandle) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestCancelRouteCalculation(&session, &routeHandle); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_CANCELROUTECALCULATION, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_cancelroutecalculation success.\n"); - } - else - { - TRACE_ERROR("navicore_cancelroutecalculation failed.\n"); - } - } -} - -/** - * @brief Destination setting - */ -void BinderClient::NavicoreSetWaypoints(const uint32_t& sessionHandle, const uint32_t& routeHandle, const bool& startFromCurrentPosition, const std::vector<naviapi::Waypoint>& waypointsList) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - uint32_t route = requestMng->GetRouteHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestSetWaypoints(&session, &route, - &startFromCurrentPosition, &waypointsList); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_SETWAYPOINTS, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_setwaypoints success.\n"); - } - else - { - TRACE_ERROR("navicore_setwaypoints failed.\n"); - } - } -} - -/** - * @brief Route calculation processing - */ -void BinderClient::NavicoreCalculateRoute(const uint32_t& sessionHandle, const uint32_t& routeHandle) -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - uint32_t session = requestMng->GetSessionHandle(); - uint32_t route = requestMng->GetRouteHandle(); - std::string req_json = JsonRequestGenerator::CreateRequestCalculateroute(&session, &route); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_CALCULATEROUTE, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_calculateroute success.\n"); - } - else - { - TRACE_ERROR("navicore_calculateroute failed.\n"); - } - } -} - -/** - * @brief Retrieve session information - * @return Map of session information - */ -void BinderClient::NavicoreGetAllSessions() -{ - // Check if it is connected - if( requestMng->IsConnect() ) - { - // JSON request generation - std::string req_json = JsonRequestGenerator::CreateRequestGetAllSessions(); - - // Send request - if( requestMng->CallBinderAPI(API_NAME, VERB_GETALLSESSIONS, req_json.c_str()) ) - { - TRACE_DEBUG("navicore_getallsessions success.\n"); - } - else - { - TRACE_ERROR("navicore_getallsessions failed.\n"); - } - } -} - -void BinderClient::OnReply(struct json_object* reply) -{ - struct json_object* requestObject = nullptr; - json_object_object_get_ex(reply, "request", &requestObject); - - struct json_object* infoObject = nullptr; - json_object_object_get_ex(requestObject, "info", &infoObject); - - const char* info = json_object_get_string(infoObject); - - char tmpVerb[256]; - strcpy(tmpVerb, info); - - // Create a new JSON response - const char* json_str = json_object_to_json_string_ext(reply, JSON_C_TO_STRING_PRETTY); - std::string response_json = std::string( json_str ); - - if (strcmp(VERB_GETALLSESSIONS, tmpVerb) == 0) - { - std::map<uint32_t, std::string> ret = JsonResponseAnalyzer::AnalyzeResponseGetAllSessions(response_json); - - // keep session handle - requestMng->SetSessionHandle( ret.begin()->first ); - - this->navicoreListener->getAllSessions_reply(ret); - } - else if (strcmp(VERB_GETPOSITION, tmpVerb) == 0) - { - std::map< int32_t, naviapi::variant > ret = JsonResponseAnalyzer::AnalyzeResponseGetPosition(response_json); - - this->navicoreListener->getPosition_reply(ret); - } - else if (strcmp(VERB_GETALLROUTES, tmpVerb) == 0) - { - std::vector< uint32_t > ret = JsonResponseAnalyzer::AnalyzeResponseGetAllRoutes(response_json); - - // route handle - if(ret.size() > 0) - { - requestMng->SetRouteHandle(ret[0]); - } - - this->navicoreListener->getAllRoutes_reply(ret); - } - else if (strcmp(VERB_CREATEROUTE, tmpVerb) == 0) - { - uint32_t ret = JsonResponseAnalyzer::AnalyzeResponseCreateRoute(response_json); - - // keep route handle - requestMng->SetRouteHandle(ret); - - this->navicoreListener->createRoute_reply(ret); - } -} - diff --git a/libnavi/src/JsonRequestGenerator.cpp b/libnavi/src/JsonRequestGenerator.cpp deleted file mode 100644 index 09d68c0..0000000 --- a/libnavi/src/JsonRequestGenerator.cpp +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include <json-c/json.h> -#include <traces.h> -#include "JsonRequestGenerator.h" - -/** - * @brief Generate request for navicore_getposition - * @param valuesToReturn Key information you want to obtain - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestGetPosition(const std::vector< int32_t >& valuesToReturn) -{ - std::vector< int32_t >::const_iterator itr; - - struct json_object* request_json = json_object_new_object(); - struct json_object* json_array = json_object_new_array(); - - for (itr = valuesToReturn.begin(); itr != valuesToReturn.end(); itr++) - { - json_object_array_add(json_array, json_object_new_int(*itr)); - } - - json_object_object_add(request_json, "valuesToReturn", json_array); - TRACE_DEBUG("CreateRequestGetPosition request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_getallroutes - * @return json strin - */ -std::string JsonRequestGenerator::CreateRequestGetAllRoutes() -{ - // Request is empty and OK - struct json_object* request_json = json_object_new_object(); - TRACE_DEBUG("CreateRequestGetAllRoutes request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_createroute - * @param sessionHandle session handle - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestCreateRoute(const uint32_t* sessionHandle) -{ - struct json_object* request_json = json_object_new_object(); - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - TRACE_DEBUG("CreateRequestCreateRoute request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_pausesimulation - * @param sessionHandle session handle - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestPauseSimulation(const uint32_t* sessionHandle) -{ - struct json_object* request_json = json_object_new_object(); - // sessionHandle - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - TRACE_DEBUG("CreateRequestPauseSimulation request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_pausesimulation - * @param sessionHandle session handle - * @param active Simulation state - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestSetSimulationMode(const uint32_t* sessionHandle, const bool* activate) -{ - struct json_object* request_json = json_object_new_object(); - - // "sessionHandle" - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - - // "simulationMode" - json_object_object_add(request_json, "simulationMode", json_object_new_boolean(*activate)); - TRACE_DEBUG("CreateRequestSetSimulationMode request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_pausesimulation - * @param sessionHandle session handle - * @param routeHandle route handle - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestCancelRouteCalculation(const uint32_t* sessionHandle, const uint32_t* routeHandle) -{ - struct json_object* request_json = json_object_new_object(); - - // "sessionHandle" - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - - // "route" - json_object_object_add(request_json, "route", json_object_new_int(*routeHandle)); - TRACE_DEBUG("CreateRequestCancelRouteCalculation request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_setwaypoints - * @param sessionHandle session handle - * @param routeHandle route handle - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestSetWaypoints(const uint32_t* sessionHandle, const uint32_t* routeHandle, - const bool* startFromCurrentPosition, const std::vector<naviapi::Waypoint>* waypointsList) -{ - naviapi::Waypoint destWp; - - struct json_object* request_json = json_object_new_object(); - struct json_object* json_array = json_object_new_array(); - - // "sessionHandle" - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - - // "route" - json_object_object_add(request_json, "route", json_object_new_int(*routeHandle)); - - // "startFromCurrentPosition" - json_object_object_add(request_json, "startFromCurrentPosition", json_object_new_boolean(*startFromCurrentPosition)); - - // "latitude", "longitude" - std::vector<naviapi::Waypoint>::const_iterator it; - for (it = waypointsList->begin(); it != waypointsList->end(); ++it) - { - struct json_object* destpoint = json_object_new_object(); - - double latitude = std::get<0>(*it); - json_object_object_add(destpoint, "latitude", json_object_new_double(latitude)); - - double longitude = std::get<1>(*it); - json_object_object_add(destpoint, "longitude", json_object_new_double(longitude)); - - json_object_array_add(json_array, destpoint); - } - - json_object_object_add(request_json, "", json_array); - TRACE_DEBUG("CreateRequestSetWaypoints request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_calculateroute - * @param sessionHandle session handle - * @param routeHandle route handle - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestCalculateroute(const uint32_t* sessionHandle, const uint32_t* routeHandle) -{ - struct json_object* request_json = json_object_new_object(); - // "sessionHandle" - json_object_object_add(request_json, "sessionHandle", json_object_new_int(*sessionHandle)); - - // "route" - json_object_object_add(request_json, "route", json_object_new_int(*routeHandle)); - TRACE_DEBUG("CreateRequestCalculateroute request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - -/** - * @brief Generate request for navicore_getallsessions - * @return json string - */ -std::string JsonRequestGenerator::CreateRequestGetAllSessions() -{ - // Request is empty and OK - struct json_object* request_json = json_object_new_object(); - TRACE_DEBUG("CreateRequestGetAllSessions request_json:\n%s\n", json_object_to_json_string(request_json)); - - return std::string( json_object_to_json_string( request_json ) ); -} - diff --git a/libnavi/src/JsonResponseAnalyzer.cpp b/libnavi/src/JsonResponseAnalyzer.cpp deleted file mode 100644 index b0d943f..0000000 --- a/libnavi/src/JsonResponseAnalyzer.cpp +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include <traces.h> - -#include "JsonResponseAnalyzer.h" - -/** - * @brief Response analysis of navicore_getallroutes - * @param res_json JSON string of response - * @return Map information for the key sent in the request - */ -std::map< int32_t, naviapi::variant > JsonResponseAnalyzer::AnalyzeResponseGetPosition( std::string& res_json ) -{ - std::map< int32_t, naviapi::variant > ret; - - TRACE_DEBUG("AnalyzeResponseGetPosition json_obj:\n%s\n", json_object_to_json_string(json_obj)); - - // convert to Json Object - struct json_object *json_obj = json_tokener_parse( res_json.c_str() ); - - // Check key - struct json_object *json_map_ary = NULL; - if( json_object_object_get_ex(json_obj, "response", &json_map_ary) ) - { - // Check if the response is array information - if( json_object_is_type(json_map_ary, json_type_array) ) - { - for (int i = 0; i < json_object_array_length(json_map_ary); ++i) - { - struct json_object* j_elem = json_object_array_get_idx(json_map_ary, i); - - if( json_object_is_type( j_elem, json_type_object) ) - { - // Check key - struct json_object* key = NULL; - struct json_object* value = NULL; - if( json_object_object_get_ex(j_elem, "key", &key) - && json_object_object_get_ex(j_elem, "value", &value) ) - { - if( json_object_is_type(key, json_type_int) ) - { - uint32_t req_key = (uint32_t)json_object_get_int(key); - - switch( req_key ) - { - case naviapi::NAVICORE_LATITUDE: - ret[req_key]._double = json_object_get_double(value); - break; - - case naviapi::NAVICORE_LONGITUDE: - ret[req_key]._double = json_object_get_double(value); - break; - - case naviapi::NAVICORE_TIMESTAMP: - ret[req_key]._uint32_t = (uint32_t)json_object_get_int(value); - break; - - case naviapi::NAVICORE_HEADING: - ret[req_key]._uint32_t = (uint32_t)json_object_get_int(value); - break; - - case naviapi::NAVICORE_SPEED: - ret[req_key]._int32_t = json_object_get_int(value); - break; - - case naviapi::NAVICORE_SIMULATION_MODE: - ret[req_key]._bool = json_object_get_boolean(value); - break; - - default: - TRACE_WARN("unknown key type.\n"); - break; - } - } - } - } - else - { - TRACE_WARN("element type is not object.\n"); - break; - } - } - } - else - { - TRACE_WARN("response type is not array.\n"); - } - } - - json_object_put(json_obj); - return ret; -} - -/** - * @brief Response analysis of navicore_getallroutes - * @param res_json JSON string of response - * @return Route handle array - */ -std::vector< uint32_t > JsonResponseAnalyzer::AnalyzeResponseGetAllRoutes( std::string& res_json ) -{ - std::vector< uint32_t > routeList; - - TRACE_DEBUG("AnalyzeResponseGetAllRoutes json_obj:\n%s\n", json_object_to_json_string(json_obj)); - - // convert to Json Object - struct json_object *json_obj = json_tokener_parse( res_json.c_str() ); - - // Check key - struct json_object *json_route_ary = NULL; - if( json_object_object_get_ex(json_obj, "response", &json_route_ary) ) - { - // Check if the response is array information - if( json_object_is_type(json_route_ary, json_type_array) ) - { - for (int i = 0; i < json_object_array_length(json_route_ary); ++i) - { - struct json_object* j_elem = json_object_array_get_idx(json_route_ary, i); - - // Check that it is an element - struct json_object *json_route_obj = NULL; - if( json_object_object_get_ex(j_elem, "route", &json_route_obj) ) - { - // Check if it is an int value - if( json_object_is_type(json_route_obj, json_type_int) ) - { - uint32_t routeHandle = (uint32_t)json_object_get_int(json_route_obj); - routeList.push_back( routeHandle ); - } - else - { - TRACE_WARN("route value is not integer.\n"); - break; - } - } - else - { - TRACE_WARN("key route is not found.\n"); - break; - } - } - } - else - { - TRACE_WARN("response type is not array.\n"); - } - } - - json_object_put(json_obj); - return routeList; -} - -/** - * @brief Response analysis of navicore_createroute - * @param res_json JSON string of response - * @return Route handle - */ -uint32_t JsonResponseAnalyzer::AnalyzeResponseCreateRoute( std::string& res_json ) -{ - uint32_t routeHandle = 0; - - TRACE_DEBUG("AnalyzeResponseCreateRoute json_obj:\n%s\n", json_object_to_json_string(json_obj)); - - // convert to Json Object - struct json_object *json_obj = json_tokener_parse( res_json.c_str() ); - - // Check key - struct json_object *json_root_obj = NULL; - struct json_object *json_route_obj = NULL; - if( json_object_object_get_ex(json_obj, "response", &json_root_obj) - && json_object_object_get_ex(json_root_obj, "route", &json_route_obj) ) - { - // Check if the response is array information - if( json_object_is_type(json_route_obj, json_type_int) ) - { - // Get route handle - routeHandle = (uint32_t)json_object_get_int(json_route_obj); - } - else - { - TRACE_WARN("response type is not integer.\n"); - } - } - - json_object_put(json_obj); - return routeHandle; -} - -/** - * @brief Response analysis of navicore_getallsessions - * @param res_json JSON string of response - * @return Map of session information - */ -std::map<uint32_t, std::string> JsonResponseAnalyzer::AnalyzeResponseGetAllSessions( std::string& res_json ) -{ - std::map<uint32_t, std::string> session_map; - - TRACE_DEBUG("AnalyzeResponseGetAllSessions json_obj:\n%s\n", json_object_to_json_string(json_obj)); - - // convert to Json Object - struct json_object *json_obj = json_tokener_parse( res_json.c_str() ); - - // Check key - struct json_object *json_map_ary = NULL; - if( json_object_object_get_ex(json_obj, "response", &json_map_ary) ) - { - // Check if the response is array information - if( json_object_is_type(json_map_ary, json_type_array) ) - { - for (int i = 0; i < json_object_array_length(json_map_ary); ++i) - { - struct json_object* j_elem = json_object_array_get_idx(json_map_ary, i); - - if( json_object_is_type( j_elem, json_type_object) ) - { - // Check key - struct json_object* handle = NULL; - struct json_object* client = NULL; - if( json_object_object_get_ex(j_elem, "sessionHandle", &handle) - && json_object_object_get_ex(j_elem, "client", &client) ) - { - if( json_object_is_type(handle, json_type_int) - && json_object_is_type(client, json_type_string) ) - { - uint32_t sessionHandle = (uint32_t)json_object_get_int(handle); - std::string clientName = std::string( json_object_get_string(client) ); - - // add to map - session_map[sessionHandle] = clientName; - } - else - { - TRACE_WARN("invalid response.\n"); - break; - } - } - } - else - { - TRACE_WARN("element type is not object.\n"); - break; - } - } - } - else - { - TRACE_WARN("response type is not array.\n"); - } - } - - json_object_put(json_obj); - return session_map; -} - diff --git a/libnavi/src/RequestManage.cpp b/libnavi/src/RequestManage.cpp deleted file mode 100644 index 7db34e1..0000000 --- a/libnavi/src/RequestManage.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <time.h> -#include <unistd.h> -#include <systemd/sd-event.h> -#include <json-c/json.h> -#include <traces.h> -#include "RequestManage.h" - -/** - * @brief constructor - */ -RequestManage::RequestManage() : listener(nullptr) -{ - // Callback setting - this->wsj1_itf.on_hangup = RequestManage::OnHangupStatic; - this->wsj1_itf.on_call = RequestManage::OnCallStatic; - this->wsj1_itf.on_event = RequestManage::OnEventStatic; - - pthread_cond_init(&this->cond, nullptr); - pthread_mutex_init(&this->mutex, nullptr); -} - -/** - * @brief Destructor - */ -RequestManage::~RequestManage() -{ -} - -void* RequestManage::BinderThread(void* param) -{ - RequestManage* instance = (RequestManage*) param; - sd_event *loop; - - int rc = sd_event_default(&loop); - if (rc < 0) { - TRACE_ERROR("connection to default event loop failed: %s\n", strerror(-rc)); - return nullptr; - } - - instance->wsj1 = afb_ws_client_connect_wsj1(loop, instance->requestURL->c_str(), &instance->wsj1_itf, nullptr); - if (instance->wsj1 == nullptr) - { - TRACE_ERROR("connection to %s failed: %m\n", api_url); - return nullptr; - } - - // Signal - pthread_mutex_unlock(&instance->mutex); - pthread_cond_signal(&instance->cond); - - while (1) - { - sd_event_run(loop, 1000 * 1000); // 1sec - } - - return nullptr; -} - -/** - * @brief Connect with a service - * @param URL - * @return Success or failure of connection - */ -bool RequestManage::Connect(const char* api_url, RequestManageListener* listener) -{ - this->listener = listener; - this->requestURL = new std::string(api_url); - - pthread_t thread_id; - pthread_create(&thread_id, nullptr, RequestManage::BinderThread, (void*)this); - - // Wait until response comes - pthread_mutex_lock(&this->mutex); - pthread_cond_wait(&this->cond, &this->mutex); - pthread_mutex_unlock(&this->mutex); - - if (this->wsj1 == nullptr) - { - return false; - } - - return true; -} - -/** - * @brief Connection status check with service - * @return Connection status - */ -bool RequestManage::IsConnect(){ - return (this->wsj1 != NULL); -} - -/** - * @brief Call Binder's API - * @param api api - * @param verb method - * @param req_json Json style request - * @return Success or failure of processing - */ -bool RequestManage::CallBinderAPI(const char* api, const char* verb, const char* req_json) -{ - // Send request - int rc = afb_wsj1_call_s(this->wsj1, api, verb, req_json, RequestManage::OnReplyStatic, this); - if (rc < 0) - { - TRACE_ERROR("calling %s/%s(%s) failed: %m\n", api, verb, req_json); - return false; - } - - return true; -} - -/** - * @brief Set session handle - * @param session Session handle - */ -void RequestManage::SetSessionHandle( uint32_t session ) -{ - this->sessionHandle = session; -} - -/** - * @brief Get session handle - * @return Session handle - */ -uint32_t RequestManage::GetSessionHandle() -{ - return this->sessionHandle; -} - -/** - * @brief Set route handle - * @param route Route handle - */ -void RequestManage::SetRouteHandle( uint32_t route ) -{ - this->routeHandle = route; -} - -/** - * @brief Get route handle - * @return Route handle - */ -uint32_t RequestManage::GetRouteHandle() -{ - return this->routeHandle; -} - -void RequestManage::OnReply(struct afb_wsj1_msg *msg) -{ - struct json_object * json = afb_wsj1_msg_object_j(msg); - - this->listener->OnReply(json); -} - -void RequestManage::OnHangup(struct afb_wsj1 *wsj1) -{ -} - -void RequestManage::OnCallStatic(const char *api, const char *verb, struct afb_wsj1_msg *msg) -{ -} - -void RequestManage::OnEventStatic(const char *event, struct afb_wsj1_msg *msg) -{ -} - - -/** - * @brief Answer callback from service - */ -void RequestManage::OnReplyStatic(void *closure, struct afb_wsj1_msg *msg) -{ - RequestManage* instance = (RequestManage *)closure; - instance->OnReply(msg); -} - -/** - * @brief Service hang notification - */ -void RequestManage::OnHangupStatic(void *closure, struct afb_wsj1 *wsj1) -{ - printf("DEBUG:%s:%d (%p,%p)\n", __func__, __LINE__, closure, wsj1); - fflush(stdout); -} - -void RequestManage::OnCallStatic(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg) -{ - printf("DEBUG:%s:%d (%p,%s,%s,%p)\n", __func__, __LINE__, closure, api, verb, msg); - fflush(stdout); -} - -void RequestManage::OnEventStatic(void *closure, const char *event, struct afb_wsj1_msg *msg) -{ - printf("DEBUG:%s:%d (%p,%s,%p)\n", __func__, __LINE__, closure, event, msg); - fflush(stdout); -} - diff --git a/libnavi/src/navicore.cpp b/libnavi/src/navicore.cpp deleted file mode 100644 index 5402aa8..0000000 --- a/libnavi/src/navicore.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#include "libnavicore.hpp" -#include "BinderClient.h" - -static BinderClient mBinderClient; - -naviapi::Navicore::Navicore() -{ -} - -naviapi::Navicore::~Navicore() -{ -} - -bool naviapi::Navicore::connect(int argc, char *argv[], NavicoreListener* listener) -{ - this->mListener = listener; - - if (argc != 3) - { - printf("Error: argc != 3 : argc = %d\n", argc); - return false; - } - - char url[1024]; - sprintf(url, "ws://localhost:%d/api?token=%s", atoi(argv[1]), argv[2]); - - return mBinderClient.ConnectServer(url, this->mListener); -} - -void naviapi::Navicore::disconnect() -{ - // TODO -} - -void naviapi::Navicore::getAllSessions() -{ - mBinderClient.NavicoreGetAllSessions(); -} - -void naviapi::Navicore::getPosition(std::vector<int32_t> params) -{ - mBinderClient.NavicoreGetPosition(params); -} - -void naviapi::Navicore::getAllRoutes() -{ - mBinderClient.NavicoreGetAllRoutes(); -} - -void naviapi::Navicore::createRoute(uint32_t session) -{ - mBinderClient.NavicoreCreateRoute(session); -} - -void naviapi::Navicore::pauseSimulation(uint32_t session) -{ - mBinderClient.NavicorePauseSimulation(session); -} - -void naviapi::Navicore::setSimulationMode(uint32_t session, bool activate) -{ - mBinderClient.NavicoreSetSimulationMode(session, activate); -} - -void naviapi::Navicore::cancelRouteCalculation(uint32_t session, uint32_t routeHandle) -{ - mBinderClient.NavicoreCancelRouteCalculation(session, routeHandle); -} - -void naviapi::Navicore::setWaypoints(uint32_t session, uint32_t routeHandle, bool flag, std::vector<Waypoint> waypoints) -{ - mBinderClient.NavicoreSetWaypoints(session, routeHandle, flag, waypoints); -} - -void naviapi::Navicore::calculateRoute(uint32_t session, uint32_t routeHandle) -{ - mBinderClient.NavicoreCalculateRoute(session, routeHandle); -} - diff --git a/libnavi/src/navicorelistener.cpp b/libnavi/src/navicorelistener.cpp deleted file mode 100644 index 2aa2b5d..0000000 --- a/libnavi/src/navicorelistener.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#include "libnavicore.hpp" - -naviapi::NavicoreListener::NavicoreListener() -{ -} - -naviapi::NavicoreListener::~NavicoreListener() -{ -} - -void naviapi::NavicoreListener::getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions) -{ -} - -void naviapi::NavicoreListener::getPosition_reply(std::map< int32_t, variant > position) -{ -} - -void naviapi::NavicoreListener::getAllRoutes_reply(std::vector< uint32_t > allRoutes) -{ -} - -void naviapi::NavicoreListener::createRoute_reply(uint32_t routeHandle) -{ -} - diff --git a/libnaviapi-agl.pc.in b/libnaviapi-agl.pc.in deleted file mode 100644 index b7dcb60..0000000 --- a/libnaviapi-agl.pc.in +++ /dev/null @@ -1,14 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -includedir=@PROJECT_INCLUDEDIR@ -libdir=@PROJECT_LIBDIR@ -binding_install_dir=@binding_install_dir@ - -Name: @PROJECT_PRETTY_NAME@ -Description: @PROJECT_DESCRIPTION@ -Version: @PROJECT_VERSION@ -URL: @PROJECT_URL@ - -Requires: json-c libafbwsc -Cflags: -I${includedir} -Libs: -L${libdir} -lnaviapi-agl diff --git a/navigation.png b/navigation.png Binary files differdeleted file mode 100644 index e7ad085..0000000 --- a/navigation.png +++ /dev/null diff --git a/src/analyze_request.cpp b/src/analyze_request.cpp deleted file mode 100644 index 593ed42..0000000 --- a/src/analyze_request.cpp +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include "genivi/genivi-navicore-constants.h" -#include "analyze_request.h" -#include <stdio.h> -#include <string.h> -#include <json-c/json.h> -#include <string> - - -/** - * @brief Create arguments to pass to Genivi API GetPosition. - * @param[in] req_json_str JSON request from BinderClient - * @param[out] Params An array of key information you want to obtain - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsGetPosition( const char* req_json_str, std::vector< int32_t >& Params) -{ - struct json_object *req_json = json_tokener_parse(req_json_str); - struct json_object* jValuesToReturn = NULL; - if( json_object_object_get_ex(req_json, "valuesToReturn", &jValuesToReturn) ) - { - if( json_object_is_type(jValuesToReturn, json_type_array) ) - { - for (int i = 0; i < json_object_array_length(jValuesToReturn); ++i) - { - struct json_object* j_elem = json_object_array_get_idx(jValuesToReturn, i); - - // JSON type acquisition - if( json_object_is_type(j_elem, json_type_int ) ) - { - int32_t req_key = json_object_get_int (j_elem); - - // no supported. - if ((NAVICORE_TIMESTAMP == req_key) || (NAVICORE_SPEED == req_key)) - { - continue; - } - Params.push_back(req_key); - } - else - { - fprintf(stdout, "key is not integer type.\n"); - return false; - } - } - } - else - { - fprintf(stdout, "request is not array type.\n"); - return false; - } - } - else - { - fprintf(stdout, "key valuesToReturn not found.\n"); - return false; - } - - return true; -} - - -/** - * @brief Create arguments to pass to Genivi API CreateRoute - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsCreateRoute( const char* req_json_str, uint32_t& sessionHdl ) -{ - // Get sessionHandle information - return JsonObjectGetSessionHdl(req_json_str, sessionHdl); -} - - -/** - * @brief Create arguments to pass to Genivi API PauseSimulation - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsPauseSimulation( const char* req_json_str, uint32_t& sessionHdl ) -{ - // Get sessionHandle information - return JsonObjectGetSessionHdl(req_json_str, sessionHdl); -} - - -/** - * @brief Create arguments to pass to Genivi API CreateRoute - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @param[out] simuMode Simulation mode - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsSetSimulationMode( const char* req_json_str, uint32_t& sessionHdl, bool& simuMode ) -{ - bool ret = false; - struct json_object *sess = NULL; - struct json_object *simu = NULL; - - struct json_object *req_json = json_tokener_parse(req_json_str); - if ((json_object_object_get_ex(req_json, "sessionHandle", &sess)) && - (json_object_object_get_ex(req_json, "simulationMode", &simu))) - { - if (json_object_is_type(sess, json_type_int) && - json_object_is_type(simu, json_type_boolean)) - { - sessionHdl = json_object_get_int(sess); - simuMode = json_object_get_int(simu); - ret = true; - } - else - { - fprintf(stdout, "key is invalid type.\n"); - } - } - else - { - fprintf(stdout, "key sessionHandle or simulationMode not found.\n"); - } - - return ret; -} - - -/** - * @brief Create arguments to pass to Genivi API CancelRouteCalculation - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @param[out] routeHdl Route handle - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsCancelRouteCalculation( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl ) -{ - // Get sessionHandle, RouteHandle - return JsonObjectGetSessionHdlRouteHdl(req_json_str, sessionHdl, routeHdl); -} - - -/** - * @brief Create arguments to pass to Genivi API SetWaypoints - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @param[out] routeHdl Route handle - * @param[out] currentPos Whether or not to draw a route from the position of the vehicle - * @param[out] waypointsList Destination coordinates - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsSetWaypoints( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl, - bool& currentPos, std::vector<Waypoint>& waypointsList ) -{ - bool ret = false; - struct json_object *sess = NULL; - struct json_object *rou = NULL; - struct json_object *current = NULL; - struct json_object *wpl = NULL; - - struct json_object *req_json = json_tokener_parse(req_json_str); - if ((json_object_object_get_ex(req_json, "sessionHandle", &sess)) && - (json_object_object_get_ex(req_json, "route", &rou)) && - (json_object_object_get_ex(req_json, "startFromCurrentPosition", ¤t)) && - (json_object_object_get_ex(req_json, "", &wpl))) - { - if (json_object_is_type(sess, json_type_int) && - json_object_is_type(rou, json_type_int) && - json_object_is_type(current, json_type_boolean) && - json_object_is_type(wpl, json_type_array)) - { - sessionHdl = json_object_get_int(sess); - routeHdl = json_object_get_int(rou); - currentPos = json_object_get_boolean(current); - - // Get latitude, longitude - for (int i = 0; i < json_object_array_length(wpl); ++i) - { - struct json_object *array = json_object_array_get_idx(wpl, i); - struct json_object *lati = NULL; - struct json_object *longi = NULL; - - if (json_object_object_get_ex(array, "latitude", &lati) && - json_object_object_get_ex(array, "longitude", &longi)) { - - double latitude = json_object_get_double(lati); - double longitude = json_object_get_double(longi); - Waypoint destWp(latitude, longitude); - waypointsList.push_back(destWp); - ret = true; - } - else - { - fprintf(stdout, "key latitude or longitude not found.\n"); - } - } - } - else - { - fprintf(stdout, "key is invalid type.\n"); - } - } - else - { - fprintf(stdout, "key valuesToReturn not found.\n"); - } - - return ret; -} - - -/** - * @brief Create arguments to pass to Genivi API CalculateRoute - * @param[in] req_json_str JSON request from BinderClient - * @param[out] sessionHdl Session handle - * @param[out] routeHdl Route handle - * @return Success or failure of processing - */ -bool AnalyzeRequest::CreateParamsCalculateRoute( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl ) -{ - // Get sessionHandle, RouteHandle - return JsonObjectGetSessionHdlRouteHdl(req_json_str, sessionHdl, routeHdl); -} - - -/** - * @brief Get session handle and route handle information from JSON - * @param[in] req_json_str JSON request from BinderClient - * @param[out] Session handle value - * @return Success or failure of processing - */ - -bool AnalyzeRequest::JsonObjectGetSessionHdl( const char* req_json_str, uint32_t& sessionHdl) -{ - bool ret = false; - struct json_object *sess = NULL; - - struct json_object *req_json = json_tokener_parse(req_json_str); - if (json_object_object_get_ex(req_json, "sessionHandle", &sess)) - { - if (json_object_is_type(sess, json_type_int)) - { - sessionHdl = json_object_get_int(sess); - ret = true; - } - else - { - fprintf(stdout, "key is not integer type.\n"); - } - } - else - { - fprintf(stdout, "key sessionHandle not found.\n"); - } - - return ret; -} - - -/** - * @brief Get session handle and route handle information from JSON - * @param[in] req_json_str JSON request from BinderClient - * @param[out] Session handle value - * @param[out] Route handle value - * @return Success or failure of processing - */ - -bool AnalyzeRequest::JsonObjectGetSessionHdlRouteHdl( const char* req_json_str, uint32_t& sessionHdl, uint32_t& routeHdl) -{ - bool ret = false; - struct json_object *sess = NULL; - struct json_object *rou = NULL; - - struct json_object *req_json = json_tokener_parse(req_json_str); - if ((json_object_object_get_ex(req_json, "sessionHandle", &sess)) && - (json_object_object_get_ex(req_json, "route", &rou))) - { - if (json_object_is_type(sess, json_type_int) && - json_object_is_type(rou, json_type_int)) - { - sessionHdl = json_object_get_int(sess); - routeHdl = json_object_get_int(rou); - ret = true; - } - else - { - fprintf(stdout, "key is not integer type.\n"); - } - } - else - { - fprintf(stdout, "key sessionHandle or route not found.\n"); - } - - return ret; -} diff --git a/src/api.cpp b/src/api.cpp deleted file mode 100644 index 8573b47..0000000 --- a/src/api.cpp +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include <string.h> - -#include "binder_reply.h" -#include "genivi_request.h" -#include "analyze_request.h" -#include "genivi/genivi-navicore-constants.h" - -#define AFB_BINDING_VERSION 2 - -extern "C" { - #include <afb/afb-binding.h> -} - -/** - * Variable declaration - */ -GeniviRequest* geniviRequest; // Send request to Genivi -BinderReply* binderReply; // Convert Genivi response result to json format -AnalyzeRequest* analyzeRequest; // Analyze BinderClient's request and create arguments to pass to GeniviAPI - -/** - * @brief navicore_getposition request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreGetPosition(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_getposition"); - - // Request of Json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - std::vector< int32_t > Params; - if( !analyzeRequest->CreateParamsGetPosition( req_json_str, Params )) - { - afb_req_fail(req, "failed", "navicore_getposition Bad Request"); - return; - } - - // GENIVI API call - std::map< int32_t, double > posList = geniviRequest->NavicoreGetPosition( Params ); - - // Convert to json style response - APIResponse response = binderReply->ReplyNavicoreGetPosition( posList ); - - // On success - if(response.isSuccess) - { - AFB_REQ_NOTICE(req, "res_json_str = %s", json_object_to_json_string(response.json_data)); - // Return success to BinderClient - afb_req_success(req, response.json_data, "navicore_getposition"); - } - else - { - AFB_REQ_ERROR(req, "%s - %s:%d", response.errMessage.c_str(), __FILE__, __LINE__); - afb_req_fail(req, "failed", "navicore_getposition Bad Request"); - - // Json object release - json_object_put(response.json_data); - } - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_getallroutes request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreGetAllRoutes(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_getallroutes"); - - // No request information in json format - AFB_REQ_NOTICE(req, "req_json_str = none"); - - // GENEVI API call - std::vector< uint32_t > allRoutes = geniviRequest->NavicoreGetAllRoutes(); - - // Convert to json style response - APIResponse response = binderReply->ReplyNavicoreGetAllRoutes( allRoutes ); - - // On success - if(response.isSuccess) - { - AFB_REQ_NOTICE(req, "res_json_str = %s", json_object_to_json_string(response.json_data)); - // Return success to BinderClient - afb_req_success(req, response.json_data, "navicore_getallroutes"); - } - else - { - AFB_REQ_ERROR(req, "%s - %s:%d", response.errMessage.c_str(), __FILE__, __LINE__); - afb_req_fail(req, "failed", "navicore_getallroutes Bad Request"); - - // json object release - json_object_put(response.json_data); - } - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_createroute request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreCreateRoute(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s ", __func__); - AFB_REQ_DEBUG(req, "request navicore_createroute"); - - // Request of json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - if( !analyzeRequest->CreateParamsCreateRoute( req_json_str, sessionHdl )) - { - afb_req_fail(req, "failed", "navicore_createroute Bad Request"); - return; - } - - // GENEVI API call - uint32_t routeHdl = geniviRequest->NavicoreCreateRoute( sessionHdl ); - - // Convert to json style response - APIResponse response = binderReply->ReplyNavicoreCreateRoute( routeHdl ); - - // On success - if(response.isSuccess) - { - AFB_REQ_NOTICE(req, "res_json_str = %s", json_object_to_json_string(response.json_data)); - // Return success to BinderClient - afb_req_success(req, response.json_data, "navicore_createroute"); - } - else - { - AFB_REQ_ERROR(req, "%s - %s:%d", response.errMessage.c_str(), __FILE__, __LINE__); - afb_req_fail(req, "failed", "navicore_createroute Bad Request"); - - // json object release - json_object_put(response.json_data); - } - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_pausesimulation request callback - * @param[in] req Request from client - */ -void OnRequestNavicorePauseSimulation(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_pausesimulation"); - - // Request of json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - if( !analyzeRequest->CreateParamsPauseSimulation( req_json_str, sessionHdl )) - { - afb_req_fail(req, "failed", "navicore_pausesimulation Bad Request"); - return; - } - - // GENEVI API call - geniviRequest->NavicorePauseSimulation( sessionHdl ); - - // No reply unnecessary API for conversion to json format response is unnecessary - AFB_REQ_NOTICE(req, "res_json_str = none"); - - // Return success to BinderClient - afb_req_success(req, NULL, "navicore_pausesimulation"); - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_setsimulationmode request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreSetSimulationMode(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_setsimulationmode"); - - // Request of json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - bool simuMode = false; - if( !analyzeRequest->CreateParamsSetSimulationMode( req_json_str, sessionHdl, simuMode )) - { - afb_req_fail(req, "failed", "navicore_setsimulationmode Bad Request"); - return; - } - - // GENEVI API call - geniviRequest->NavicoreSetSimulationMode( sessionHdl, simuMode ); - - // No reply unnecessary API for conversion to json format response is unnecessary - AFB_REQ_NOTICE(req, "res_json_str = none"); - - // Return success to BinderClient - afb_req_success(req, NULL, "navicore_setsimulationmode"); - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_cancelroutecalculation request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreCancelRouteCalculation(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_cancelroutecalculation"); - - // Request of Json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - uint32_t routeHdl = 0; - if( !analyzeRequest->CreateParamsCancelRouteCalculation( req_json_str, sessionHdl, routeHdl )) - { - afb_req_fail(req, "failed", "navicore_cancelroutecalculation Bad Request"); - return; - } - - // GENEVI API call - geniviRequest->NavicoreCancelRouteCalculation( sessionHdl, routeHdl ); - - // No reply unnecessary API for conversion to json format response is unnecessary - AFB_REQ_NOTICE(req, "res_json_str = none"); - - // Return success to BinderClient - afb_req_success(req, NULL, "navicore_cancelroutecalculation"); - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_setwaypoints request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreWaypoints(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_setwaypoints"); - - // Request of Json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - uint32_t routeHdl = 0; - bool currentPos = false; - std::vector<Waypoint> waypointsList; - if( !analyzeRequest->CreateParamsSetWaypoints( req_json_str, sessionHdl, routeHdl, currentPos, waypointsList )) - { - afb_req_fail(req, "failed", "navicore_setwaypoints Bad Request"); - return; - } - - // GENEVI API call - geniviRequest->NavicoreSetWaypoints( sessionHdl, routeHdl, currentPos, waypointsList ); - - // No reply unnecessary API for conversion to json format response is unnecessary - AFB_REQ_NOTICE(req, "res_json_str = none"); - - // Return success to BinderClient - afb_req_success(req, NULL, "navicore_setwaypoints"); - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_calculateroute request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreCalculateRoute(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_calculateroute"); - - // Request of Json format request - json_object* req_json = afb_req_json(req); - const char* req_json_str = json_object_to_json_string(req_json); - AFB_REQ_NOTICE(req, "req_json_str = %s", req_json_str); - - // Request analysis and create arguments to pass to Genivi - uint32_t sessionHdl = 0; - uint32_t routeHdl = 0; - if( !analyzeRequest->CreateParamsCalculateRoute( req_json_str, sessionHdl, routeHdl )) - { - afb_req_fail(req, "failed", "navicore_calculateroute Bad Request"); - return; - } - - // GENEVI API call - geniviRequest->NavicoreCalculateRoute( sessionHdl, routeHdl ); - - // No reply unnecessary API for conversion to json format response is unnecessary - AFB_REQ_NOTICE(req, "res_json_str = none"); - - // Return success to BinderClient - afb_req_success(req, NULL, "navicore_calculateroute"); - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief navicore_getallsessions request callback - * @param[in] req Request from client - */ -void OnRequestNavicoreGetAllSessions(afb_req req) -{ - AFB_REQ_NOTICE(req, "--> Start %s()", __func__); - AFB_REQ_DEBUG(req, "request navicore_getallsessions"); - - // No request information in Json format - AFB_REQ_NOTICE(req, "req_json_str = none"); - - // GENEVI API call - std::map<uint32_t, std::string> allSessions = geniviRequest->NavicoreGetAllSessions(); - - // Convert to json style response - APIResponse response = binderReply->ReplyNavicoreGetAllSessions( allSessions ); - - // On success - if(response.isSuccess) - { - AFB_REQ_NOTICE(req, "res_json_str = %s", json_object_to_json_string(response.json_data)); - // Return success to BinderClient - afb_req_success(req, response.json_data, "navicore_getallsessions"); - } - else - { - AFB_REQ_ERROR(req, "%s - %s:%d", response.errMessage.c_str(), __FILE__, __LINE__); - afb_req_fail(req, "failed", "navicore_getallsessions Bad Request"); - - // json object release - json_object_put(response.json_data); - } - - AFB_REQ_NOTICE(req, "<-- End %s()", __func__); -} - - -/** - * @brief Callback called at service startup - */ -int Init() -{ - // Create instance - geniviRequest = new GeniviRequest(); - binderReply = new BinderReply(); - analyzeRequest = new AnalyzeRequest(); - - return 0; -} - -/** - * @brief API definition - */ -const afb_verb_v2 verbs[] = -{ - { verb : "navicore_getposition", callback : OnRequestNavicoreGetPosition }, - { verb : "navicore_getallroutes", callback : OnRequestNavicoreGetAllRoutes }, - { verb : "navicore_createroute", callback : OnRequestNavicoreCreateRoute }, - { verb : "navicore_pausesimulation", callback : OnRequestNavicorePauseSimulation }, - { verb : "navicore_setsimulationmode", callback : OnRequestNavicoreSetSimulationMode }, - { verb : "navicore_cancelroutecalculation", callback : OnRequestNavicoreCancelRouteCalculation }, - { verb : "navicore_setwaypoints", callback : OnRequestNavicoreWaypoints }, - { verb : "navicore_calculateroute", callback : OnRequestNavicoreCalculateRoute }, - { verb : "navicore_getallsessions", callback : OnRequestNavicoreGetAllSessions }, - { verb : NULL } -}; - -/** - * @brief Service definition - */ -const afb_binding_v2 afbBindingV2 = -{ - "naviapi", - "", - "", - verbs, - NULL, - Init -}; - diff --git a/src/binder_reply.cpp b/src/binder_reply.cpp deleted file mode 100644 index 172a22a..0000000 --- a/src/binder_reply.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include "binder_reply.h" -#include "genivi/genivi-navicore-constants.h" - -/** - * @brief GeniviAPI GetPosition call - * @param[in] posList Map information on key and value of information acquired from Genivi - * @return Response information - */ -APIResponse BinderReply::ReplyNavicoreGetPosition( std::map<int32_t, double>& posList ) -{ - APIResponse response = {0}; - - // Json information to return as a response - struct json_object* response_json = json_object_new_array(); - std::map<int32_t, double>::iterator it; - - // If the argument map is empty return - if(posList.empty()) - { - response.isSuccess = false; - response.errMessage = "posList is empty"; - response.json_data = response_json; - return response; - } - - // Make the passed Genivi response json format - for (it = posList.begin(); it != posList.end(); it++) - { - struct json_object* obj = json_object_new_object(); - - switch(it->first) - { - case NAVICORE_LATITUDE: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_LATITUDE)); - json_object_object_add(obj, "value", json_object_new_double(it->second) ); - json_object_array_add(response_json, obj); - break; - - case NAVICORE_LONGITUDE: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_LONGITUDE)); - json_object_object_add(obj, "value", json_object_new_double(it->second)); - json_object_array_add(response_json, obj); - break; - - case NAVICORE_HEADING: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_HEADING)); - json_object_object_add(obj, "value", json_object_new_boolean (it->second)); - json_object_array_add(response_json, obj); - break; -#if 0 - // no support - case NAVICORE_TIMESTAMP: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_TIMESTAMP)); - json_object_object_add(obj, "value", json_object_new_int(it->second)); - json_object_array_add(response_json, obj); - break; - - // no support - case NAVICORE_SPEED: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_SPEED)); - json_object_object_add(obj, "value", json_object_new_int(it->second)); - json_object_array_add(response_json, obj); - break; -#endif - - case NAVICORE_SIMULATION_MODE: - json_object_object_add(obj, "key", json_object_new_int(NAVICORE_SIMULATION_MODE)); - json_object_object_add(obj, "value", json_object_new_boolean (it->second)); - json_object_array_add(response_json, obj); - break; - - default: - fprintf(stderr, "Unknown key."); - json_object_put(obj); - break; - } - } - - response.json_data = response_json; - response.isSuccess = true; - return response; -} - -/** - * @brief GeniviAPI GetAllRoutes call - * @param[in] allRoutes Route handle information - * @return Response information - */ -APIResponse BinderReply::ReplyNavicoreGetAllRoutes( std::vector< uint32_t > &allRoutes ) -{ - APIResponse response = {0}; - - // Json information to return as a response - struct json_object* response_json = json_object_new_array(); - - if (0 < allRoutes.size()) - { - std::vector< uint32_t >::iterator it; - - for (it = allRoutes.begin(); it != allRoutes.end(); it++) - { - struct json_object* obj = json_object_new_object(); - json_object_object_add(obj, "route", json_object_new_int(*it)); - json_object_array_add(response_json, obj); - } - } - - response.json_data = response_json; - response.isSuccess = true; - return response; -} - -/** - * @brief GeniviAPI CreateRoute call - * @param[in] route Route handle - * @return Response information - */ -APIResponse BinderReply::ReplyNavicoreCreateRoute( uint32_t route ) -{ - APIResponse response; - - // Json information to return as a response - struct json_object* response_json = json_object_new_object(); - json_object_object_add(response_json, "route", json_object_new_int(route)); - - response.json_data = response_json; - response.isSuccess = true; - return response; -} - -/** - * @brief GeniviAPI GetAllSessions call - * @param[in] allSessions Map information on key and value of information acquired from Genivi - * @return Response information - */ -APIResponse BinderReply::ReplyNavicoreGetAllSessions( std::map<uint32_t, std::string> &allSessions ) -{ - APIResponse response = {0}; - - // Json information to return as a response - struct json_object* response_json = json_object_new_array(); - std::map<uint32_t, std::string>::iterator it; - - for (it = allSessions.begin(); it != allSessions.end(); it++) - { - struct json_object* obj = json_object_new_object(); - - if (NAVICORE_INVALID != it->first) - { - json_object_object_add(obj, "sessionHandle", json_object_new_int(it->first)); - json_object_object_add(obj, "client", json_object_new_string(it->second.c_str())); - json_object_array_add(response_json, obj); - } - else - { - fprintf(stderr, "invalid key."); - json_object_put(obj); - } - } - - response.json_data = response_json; - response.isSuccess = true; - return response; -} - diff --git a/src/genivi_request.cpp b/src/genivi_request.cpp deleted file mode 100644 index a485667..0000000 --- a/src/genivi_request.cpp +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright 2017 AW SOFTWARE CO.,LTD -// Copyright 2017 AISIN AW CO.,LTD - -#include "genivi/navicore.h" -#include "genivi/genivi-navicore-constants.h" -#include "genivi_request.h" -#include <stdio.h> -#include <exception> -#include <dbus-c++-1/dbus-c++/dbus.h> - -/** - * @brief Destructor - */ -GeniviRequest::~GeniviRequest() -{ - delete (Navicore*)navicore_; - navicore_ = NULL; -} - -/** - * @brief DBus session creation - */ -void GeniviRequest::CreateDBusSession( ) -{ - try - { - static DBus::BusDispatcher dispatcher; - DBus::default_dispatcher = &dispatcher; - DBus::Connection conn = DBus::Connection::SessionBus(); - - navicore_ = new Navicore(conn, "/org/genivi/navicore", "org.agl.naviapi"); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - -/** - * @brief Check connection status - * @return Presence / absence of connection - */ -bool GeniviRequest::CheckSession() -{ - if(this->navicore_ == NULL) - { - this->CreateDBusSession(); - } - - try - { - // Get connection status - DBus::Connection conn = ((Navicore*)navicore_)->conn(); - bool isConnect = conn.connected(); - - // If it is not connected, it issues an error - if(!isConnect) - { - fprintf(stderr, "Service has no session.\n"); - } - - return isConnect; - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - return false; - } -} - -/** - * @brief Call GeniviAPI GetPosition to get information - * @param[in] valuesToReturn Key arrangement of information acquired from Genivi - * @return Map information on key and value of information acquired from Genivi - */ -std::map< int32_t, double > GeniviRequest::NavicoreGetPosition( const std::vector< int32_t >& valuesToReturn ) -{ - std::map< int32_t, double > ret; - - if( !CheckSession() ) - { - return ret; - } - - try - { - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > >::iterator it; - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > PosList = - ((Navicore*)navicore_)->GetPosition(valuesToReturn); - for (it = PosList.begin(); it != PosList.end(); it++) - { - if (it->first == NAVICORE_LATITUDE || it->second._1 == NAVICORE_LATITUDE) - { - ret[it->first] = it->second._2.reader().get_double(); - } - else if (it->first == NAVICORE_LONGITUDE || it->second._1 == NAVICORE_LONGITUDE) - { - ret[it->first] = it->second._2.reader().get_double(); - } - else if (it->first == NAVICORE_HEADING || it->second._1 == NAVICORE_HEADING) - { - ret[it->first] = it->second._2.reader().get_uint32(); - } -#if 0 // no supported - else if (it->first == NAVICORE_TIMESTAMP || it->second._1 == NAVICORE_TIMESTAMP) - { - ret[it->first] = it->second._2.reader().get_uint32(); - } - else if (it->first == NAVICORE_SPEED || it->second._1 == NAVICORE_SPEED) - { - ret[it->first] = it->second._2.reader().get_int32(); - } -#endif - else if (it->first == NAVICORE_SIMULATION_MODE || it->second._1 == NAVICORE_SIMULATION_MODE) - { - ret[it->first] = it->second._2.reader().get_bool(); - } - } - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } - - return ret; -} - -/** - * @brief Call GeniviAPI GetPosition to get information - * @return Route handle acquired from Genivi - */ -std::vector< uint32_t > GeniviRequest::NavicoreGetAllRoutes( void ) -{ - if( !CheckSession() ) - { - std::vector< uint32_t > no_route; - return no_route; - } - - std::vector< uint32_t > allRoutes; - try - { - allRoutes = ((Navicore*)navicore_)->GetAllRoutes(); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } - - return allRoutes; -} - - -/** - * @brief Call GeniviAPI GetPosition to get information - * @param[in] sessionHandle Session handle - * @return Route handle acquired from Genivi - */ -uint32_t GeniviRequest::NavicoreCreateRoute( const uint32_t& sessionHandle ) -{ - if( !CheckSession() ) - { - return 0; - } - - uint32_t routeHandle = 0; - try - { - routeHandle = ((Navicore*)navicore_)->CreateRoute(sessionHandle); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } - - return routeHandle; -} - -/** - * @brief Call GeniviAPI PauseSimulation - * @param[in] sessionHandle Session handle - */ -void GeniviRequest::NavicorePauseSimulation( const uint32_t& sessionHandle ) -{ - if( !CheckSession() ) - { - return; - } - - try - { - ((Navicore*)navicore_)->PauseSimulation(sessionHandle); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - - -/** - * @brief Call GeniviAPI SetSimulationMode - * @param[in] sessionHandle Session handle - * @param[in] activate Simulation mode enabled / disabled - */ -void GeniviRequest::NavicoreSetSimulationMode( const uint32_t& sessionHandle, const bool& activate ) -{ - if( !CheckSession() ) - { - return; - } - - try - { - ((Navicore*)navicore_)->SetSimulationMode(sessionHandle, activate); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - - -/** - * @brief Call GeniviAPI SetSimulationMode - * @param[in] sessionHandle Session handle - * @param[in] routeHandle Route handle - */ -void GeniviRequest::NavicoreCancelRouteCalculation( const uint32_t& sessionHandle, const uint32_t& routeHandle ) -{ - if( !CheckSession() ) - { - return; - } - - try - { - ((Navicore*)navicore_)->CancelRouteCalculation(sessionHandle, routeHandle); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - -/** - * @brief Call GeniviAPI SetWaypoints - * @param[in] sessionHandle Session handle - * @param[in] routeHandle Route handle - * @param[in] startFromCurrentPosition Whether or not to draw a route from the position of the vehicle - * @param[in] waypointsList Destination coordinates - */ -void GeniviRequest::NavicoreSetWaypoints( const uint32_t& sessionHandle, const uint32_t& routeHandle, - const bool& startFromCurrentPosition, const std::vector<Waypoint>& waypointsList ) -{ - if( !CheckSession() ) - { - return; - } - - std::vector<Waypoint>::const_iterator it; - std::vector< std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > > wpl; - - fprintf(stdout, "session: %d, route: %d, startFromCurrentPosition: %d\n", - sessionHandle, routeHandle, startFromCurrentPosition); - - for (it = waypointsList.begin(); it != waypointsList.end(); it++) - { - std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > Point; - ::DBus::Struct< uint8_t, ::DBus::Variant > VarLat, VarLon; - - VarLat._1 = NAVICORE_LATITUDE; - VarLat._2.writer().append_double(std::get<0>(*it)); - fprintf(stdout, "VarLat._1 : %x, VarLat._2 : %lf\n", VarLat._1, VarLat._2.reader().get_double()); - - VarLon._1 = NAVICORE_LONGITUDE; - VarLon._2.writer().append_double(std::get<1>(*it)); - fprintf(stdout, "VarLon._1 : %x, VarLon._2 : %lf\n", VarLon._1, VarLon._2.reader().get_double()); - - Point[NAVICORE_LATITUDE] = VarLat; - Point[NAVICORE_LONGITUDE] = VarLon; - - wpl.push_back(Point); - } - - try - { - ((Navicore*)navicore_)->SetWaypoints(sessionHandle, routeHandle, startFromCurrentPosition, wpl); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - -/** - * @brief Call GeniviAPI CalculateRoute - * @param[in] sessionHandle Session handle - * @param[in] routeHandle Route handle - */ -void GeniviRequest::NavicoreCalculateRoute( const uint32_t& sessionHandle, const uint32_t& routeHandle ) -{ - if( !CheckSession() ) - { - return; - } - - try - { - ((Navicore*)navicore_)->CalculateRoute(sessionHandle, routeHandle); - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } -} - - -/** - * @brief Call GeniviAPI CalculateRoute - * @return Map information on key and value of information acquired from Genivi - */ -std::map<uint32_t, std::string> GeniviRequest::NavicoreGetAllSessions() -{ - std::map<uint32_t, std::string> ret; - - if( !CheckSession() ) - { - return ret; - } - - std::vector< ::DBus::Struct< uint32_t, std::string > > ncAllSessions; - std::vector< ::DBus::Struct< uint32_t, std::string > >::iterator it; - - try - { - ncAllSessions = ((Navicore*)navicore_)->GetAllSessions(); - for (it = ncAllSessions.begin(); it != ncAllSessions.end(); it++) - { - ret[it->_1] = it->_2; - } - } - catch(const std::exception& e) - { - fprintf(stderr, "Error:%s\n", e.what()); - } - - return ret; -} - diff --git a/src/traces.h b/src/traces.h deleted file mode 100644 index a1f96ec..0000000 --- a/src/traces.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 AISIN AW CO.,LTD - -#ifndef __TRACE_H__ -#define __TRACE_H__ - -#include <stdio.h> - -#define BLACK "\033[30m" -#define RED "\033[31m" -#define GREEN "\033[32m" -#define YELLOW "\033[33m" -#define BLUE "\033[34m" -#define PURPLE "\033[35m" -#define DGREEN "\033[6m" -#define WHITE "\033[7m" -#define CYAN "\x1b[36m" -#define NONE "\033[0m" - -#ifdef NDEBUG - -#define TRACE_DEBUG_JSON(fmt, args...) -#define TRACE_DEBUG(fmt, args...) -#define TRACE_INFO(fmt, args...) -#define TRACE_WARN(fmt, args...) -#define TRACE_ERROR(fmt, args...) - -#else - -#define TRACE_DEBUG(fmt, args...) do { fprintf(stderr, "[%s:%d] " CYAN "DEBUG" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_INFO(fmt, args...) do { fprintf(stderr, "[%s:%d] " GREEN "INFO" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_WARN(fmt, args...) do { fprintf(stderr, "[%s:%d] " YELLOW "WARN" NONE": " fmt "\n", __func__, __LINE__, ##args); } while(0) -#define TRACE_ERROR(fmt, args...) do { fprintf(stderr, "[%s:%d] " RED "ERROR" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0) - -#define TRACE_DEBUG_JSON(fmt, args...) - -#endif - -#endif // __TRACE_H__ |