diff options
author | Jürgen Gehring <juergen.gehring@bmw.de> | 2015-06-17 03:35:44 -0700 |
---|---|---|
committer | Jürgen Gehring <juergen.gehring@bmw.de> | 2015-06-17 03:51:23 -0700 |
commit | 9b91fba4b4008007847f32630cbe160287f291fd (patch) | |
tree | c9f7b77ea4255b30ec3b2683fb9c98840bcdbae2 | |
parent | 1d9ae05afdc4341622d1720138d2bc781ee78144 (diff) | |
download | genivi-common-api-runtime-9b91fba4b4008007847f32630cbe160287f291fd.tar.gz |
CommonAPI 3.1.23.1.2
105 files changed, 2147 insertions, 348 deletions
diff --git a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt index b250e4d..9971079 100644 --- a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt +++ b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt @@ -29,11 +29,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -61,8 +61,8 @@ else() endif() # SOME/IP -find_package (CommonAPI-SomeIP 3.1.1 REQUIRED) -find_package (vsomeip 1.1.0 REQUIRED) +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) # Source Files set(PRJ_SRC_PATH src) @@ -119,6 +119,7 @@ link_directories( ${COMMONAPI_DBUS_LIBDIR} ${COMMONAPI_SOMEIP_CMAKE_DIR}/build ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() diff --git a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl index 4872a22..6d43ef0 100644 --- a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl +++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl @@ -11,6 +11,7 @@ define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E method sayHello { SomeIpMethodID = 33000 + SomeIpReliable = true in { name { @@ -27,6 +28,7 @@ define org.genivi.commonapi.someip.deployment for provider Service { SomeIpInstanceID = 22136 SomeIpUnicastAddress = "192.168.0.2" - SomeIpUnicastPort = 30499 + SomeIpReliableUnicastPort = 30499 + SomeIpUneliableUnicastPort = 30499 } }
\ No newline at end of file diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp index f92ae81..2fb7918 100644 --- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp +++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp @@ -22,7 +22,15 @@ int main() { std::string connection = "service-sample"; std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>(); - runtime->registerService(domain, instance, myService, connection); + bool successfullyRegistered = runtime->registerService(domain, instance, myService, connection); + + while (!successfullyRegistered) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myService, connection); + } + + std::cout << "Successfully Registered Service!" << std::endl; while (true) { std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl; diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json new file mode 100644 index 0000000..731852a --- /dev/null +++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json @@ -0,0 +1,26 @@ +{ + "unicast" : "192.168.56.102", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" }, + "dlt" : "true" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json new file mode 100644 index 0000000..2f4c823 --- /dev/null +++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json @@ -0,0 +1,52 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + }, + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json new file mode 100644 index 0000000..371ecf7 --- /dev/null +++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json @@ -0,0 +1,48 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "service-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E02Attributes/CMakeLists.txt b/CommonAPI-Examples/E02Attributes/CMakeLists.txt index 7da893e..fccec2c 100644 --- a/CommonAPI-Examples/E02Attributes/CMakeLists.txt +++ b/CommonAPI-Examples/E02Attributes/CMakeLists.txt @@ -8,7 +8,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E02Attributes) set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -pthread -D_GLIBCXX_USE_NANOSLEEP") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -22,11 +29,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -42,7 +49,7 @@ if (MSVC) #Not beautiful, but it works if (DBus_DIR) if (DBus_BUILD_DIR) - set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") else () message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") endif () @@ -53,46 +60,71 @@ else() pkg_check_modules(DBus REQUIRED dbus-1>=1.4) endif() +# SOME/IP +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) + # Source Files set(PRJ_SRC_PATH src) -set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_PATH src-gen) +set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_0/commonapi/examples) set(PRJ_NAME_CLIENT ${PRJ_NAME}Client) set(PRJ_NAME_SERVICE ${PRJ_NAME}Service) -FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp) -FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp) - +# Application +FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/CommonTypes.cpp) +FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp) set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) -set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS}) + +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + +# DBus library +FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp) + +# SOME/IP library +FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp) # Paths OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON) message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}") include_directories( - src-gen + src-gen/core + src-gen/dbus + src-gen/someip ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_SOMEIP_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} + ${VSOMEIP_INCLUDE_DIRS} ) if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_LIBDIR} + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() -set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES}) +set(LINK_LIBRARIES -Wl,--as-needed CommonAPI) # Build Client add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS}) @@ -101,3 +133,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES}) # Build service add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) + +# Build DBus library +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) + +# Build SOME/IP library +add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) diff --git a/CommonAPI-Examples/E02Attributes/commonapi4someip.ini b/CommonAPI-Examples/E02Attributes/commonapi4someip.ini new file mode 100644 index 0000000..9d2e519 --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/commonapi4someip.ini @@ -0,0 +1,8 @@ +[default] +binding=someip + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl new file mode 100644 index 0000000..9cadf7d --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl @@ -0,0 +1,11 @@ +/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl" +import "E02Attributes.fidl" + +define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E02Attributes { + DBusDefaultAttributeType = freedesktop +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl new file mode 100644 index 0000000..0afbaf0 --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl @@ -0,0 +1,54 @@ +/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl" +import "E02Attributes.fidl" + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E02Attributes { + SomeIpServiceID = 4660 + + attribute x { + SomeIpGetterID = 3000 + SomeIpSetterID = 3001 + SomeIpNotifierID = 33010 + SomeIpEventGroups = { 33010 } + + SomeIpGetterReliable = true + SomeIpSetterReliable = true + SomeIpNotifierReliable = true + } + + attribute a1 { + SomeIpGetterID = 3002 + SomeIpSetterID = 3003 + SomeIpNotifierID = 33011 + SomeIpEventGroups = { 33011 } + + SomeIpGetterReliable = true + SomeIpSetterReliable = true + SomeIpNotifierReliable = true + } +} + +define org.genivi.commonapi.someip.deployment for typeCollection commonapi.examples.CommonTypes { + struct a1Struct { + } + + struct a2Struct { + } + +} + +define org.genivi.commonapi.someip.deployment for provider Service { + instance commonapi.examples.E02Attributes { + InstanceId = "commonapi.examples.Attributes" + + SomeIpInstanceID = 22136 + + SomeIpUnicastAddress = "192.168.0.2" + SomeIpReliableUnicastPort = 30499 + SomeIpUnreliableUnicastPort = 30500 + } +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp index e51eea7..0ecaa7b 100644 --- a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp +++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp @@ -4,7 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <iostream> + +#ifndef WIN32 #include <unistd.h> +#endif #include <CommonAPI/CommonAPI.hpp> #include <v1_0/commonapi/examples/E02AttributesProxy.hpp> @@ -25,14 +28,19 @@ void recv_cb_s(const CommonAPI::CallStatus& callStatus, const CommonTypes::a1Str } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E02C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E02Attributes"); + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); std::string domain = "local"; - std::string instance = "commonapi.examples.Attributes"; + std::string instance = "commonapi.examples.Attributes"; + std::string connection = "client-sample"; std::shared_ptr<CommonAPI::DefaultAttributeProxyHelper<E02AttributesProxy, AttributeCacheExtension>::class_t> myProxy = - runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(domain, instance); + runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttributeCacheExtension>(domain, instance, connection); + std::cout << "Waiting for service to become available." << std::endl; while (!myProxy->isAvailable()) { usleep(10); } diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp index 60c743d..8947414 100644 --- a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp +++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp @@ -10,13 +10,22 @@ #include "E02AttributesStubImpl.hpp" int main() { + CommonAPI::Runtime::setProperty("LogContext", "E02S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E02Attributes"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); std::string domain = "local"; std::string instance = "commonapi.examples.Attributes"; + std::string connection = "service-sample"; std::shared_ptr<E02AttributesStubImpl> myService = std::make_shared<E02AttributesStubImpl>(); - runtime->registerService(domain, instance, myService); + while (!runtime->registerService(domain, instance, myService, connection)) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + std::cout << "Successfully Registered Service!" << std::endl; while (true) { myService->incCounter(); // Change value of attribute, see stub implementation diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-client.json b/CommonAPI-Examples/E02Attributes/vsomeip-client.json new file mode 100644 index 0000000..731852a --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/vsomeip-client.json @@ -0,0 +1,26 @@ +{ + "unicast" : "192.168.56.102", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" }, + "dlt" : "true" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-local.json b/CommonAPI-Examples/E02Attributes/vsomeip-local.json new file mode 100644 index 0000000..2f4c823 --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/vsomeip-local.json @@ -0,0 +1,52 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + }, + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-service.json b/CommonAPI-Examples/E02Attributes/vsomeip-service.json new file mode 100644 index 0000000..03d8979 --- /dev/null +++ b/CommonAPI-Examples/E02Attributes/vsomeip-service.json @@ -0,0 +1,77 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/tmp/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : + { + "minimum" : "10", + "maximum" : 100 + }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "events" : + [ + { + "event" : "0x80F2", + "is_field" : "false", + "is_reliable" : "true", + "update-cycle" : 2000 + }, + { + "event" : "0x80F3", + "is_field" : "true", + "is_reliable" : "true", + "update-cycle" : 0 + } + ], + "eventgroups" : + [ + { + "eventgroup" : "0x80F2", + "events" : [ "0x80F2" ] + }, + { + "eventgroup" : "0x80F3", + "events" : [ "0x80F3" ] + } + ] + } + ] + } + ], + "routing" : "service-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E03Methods/CMakeLists.txt b/CommonAPI-Examples/E03Methods/CMakeLists.txt index 5640fea..30d1eb2 100644 --- a/CommonAPI-Examples/E03Methods/CMakeLists.txt +++ b/CommonAPI-Examples/E03Methods/CMakeLists.txt @@ -1,4 +1,6 @@ # Copyright (C) 2014, 2015 BMW Group +# Author: Manfred Bathelt (manfred.bathelt@bmw.de) +# Author: Juergen Gehring (juergen.gehring@bmw.de) # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. @@ -8,7 +10,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E03Methods) set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -22,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -42,7 +51,7 @@ if (MSVC) #Not beautiful, but it works if (DBus_DIR) if (DBus_BUILD_DIR) - set(DBUS_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") else () message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") endif () @@ -53,20 +62,37 @@ else() pkg_check_modules(DBus REQUIRED dbus-1>=1.4) endif() +# SOME/IP +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) + # Source Files set(PRJ_SRC_PATH src) -set(PRJ_SRC_GEN_PATH src-gen/core/v1_2/commonapi/examples) -set(PRJ_DBUS_SRC_GEN_PATH src-gen/dbus/v1_2/commonapi/examples) +set(PRJ_SRC_GEN_PATH src-gen) +set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_2/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_2/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_2/commonapi/examples) set(PRJ_NAME_CLIENT ${PRJ_NAME}Client) set(PRJ_NAME_SERVICE ${PRJ_NAME}Service) -FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Proxy.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_DBUS_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp) -FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp) - +# Application +FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/E03Methods.cpp) set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) -set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS}) + +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + +# DBus library +FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS}) + +# SOME/IP library +FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp) # Paths OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON) @@ -75,26 +101,32 @@ message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}") include_directories( src-gen/core src-gen/dbus + src-gen/someip ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_SOMEIP_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} + ${VSOMEIP_INCLUDE_DIRS} ) if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_LIBDIR} + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() -set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES}) +set(LINK_LIBRARIES -Wl,--as-needed CommonAPI) # Build Client add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS}) @@ -103,3 +135,12 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES}) # Build service add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) + +# Build DBus library +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) + +# Build SOME/IP library +add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) + diff --git a/CommonAPI-Examples/E03Methods/commonapi4someip.ini b/CommonAPI-Examples/E03Methods/commonapi4someip.ini new file mode 100644 index 0000000..9d2e519 --- /dev/null +++ b/CommonAPI-Examples/E03Methods/commonapi4someip.ini @@ -0,0 +1,8 @@ +[default] +binding=someip + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl new file mode 100644 index 0000000..560f1a9 --- /dev/null +++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl @@ -0,0 +1,8 @@ +import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl" +import "E03Methods.fidl" + +define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E03Methods { + method foo { + Timeout = 1234 + } +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl new file mode 100644 index 0000000..6782105 --- /dev/null +++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl @@ -0,0 +1,54 @@ +/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl" +import "E03Methods.fidl" + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E03Methods { + SomeIpServiceID = 4660 + + method foo { + SomeIpMethodID = 33000 + SomeIpReliable = false + + in { + x2 { + SomeIpStringEncoding = utf16le + } + } + out { + y2 { + SomeIpStringEncoding = utf16le + } + } + } + + broadcast myStatus { + SomeIpEventID = 33010 + SomeIpEventGroups = { 33010 } + + out { + } + } + + enumeration stdErrorTypeEnum { + NO_FAULT { + } + MY_FAULT { + } + } +} + +define org.genivi.commonapi.someip.deployment for provider Service { + instance commonapi.examples.E03Methods { + InstanceId = "commonapi.examples.Methods" + + SomeIpInstanceID = 22136 + + SomeIpUnicastAddress = "192.168.0.2" + SomeIpReliableUnicastPort = 30500 + SomeIpUnreliableUnicastPort = 30501 +} +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl index edf8dc6..f0963cd 100644 --- a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl +++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl @@ -20,9 +20,7 @@ interface E03Methods { Int32 y1 String y2 } - error { - stdErrorTypeEnum - } + error stdErrorTypeEnum } broadcast myStatus { diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp index 0c6bc56..8d58060 100644 --- a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp +++ b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp @@ -17,25 +17,28 @@ using namespace v1_2::commonapi::examples; void recv_cb(const CommonAPI::CallStatus& callStatus, - const E03Methods::fooError& methodError, + const E03Methods::stdErrorTypeEnum& methodError, const int32_t& y1, const std::string& y2) { std::cout << "Result of asynchronous call of foo: " << std::endl; std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS") << std::endl; std::cout << " error: " - << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : + << ((methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT") << std::endl; std::cout << " Output values: y1 = " << y1 << ", y2 = " << y2 << std::endl; } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E03C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E03Methods"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); std::string domain = "local"; std::string instance = "commonapi.examples.Methods"; - std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance); + std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance, "client-sample"); while (!myProxy->isAvailable()) { usleep(10); @@ -50,7 +53,7 @@ int main() { int32_t inX1 = 5; std::string inX2 = "abc"; CommonAPI::CallStatus callStatus; - E03Methods::fooError methodError; + E03Methods::stdErrorTypeEnum methodError; int32_t outY1; std::string outY2; @@ -62,7 +65,7 @@ int main() { std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS") << std::endl; std::cout << " error: " - << ((methodError.stdErrorTypeEnum == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT") + << ((methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT") << std::endl; std::cout << " Input values: x1 = " << inX1 << ", x2 = " << inX2 << std::endl; std::cout << " Output values: y1 = " << outY1 << ", y2 = " << outY2 << std::endl; @@ -72,7 +75,7 @@ int main() { std::function< void(const CommonAPI::CallStatus&, - const E03Methods::fooError&, + const E03Methods::stdErrorTypeEnum&, const int32_t&, const std::string&)> fcb = recv_cb; myProxy->fooAsync(inX1, inX2, recv_cb); diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp index 7c9528c..a57e46b 100644 --- a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp +++ b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp @@ -12,13 +12,20 @@ #include "E03MethodsStubImpl.hpp" int main() { + CommonAPI::Runtime::setProperty("LogContext", "E03S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E03Methods"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); std::string domain = "local"; std::string instance = "commonapi.examples.Methods"; std::shared_ptr<E03MethodsStubImpl> myService = std::make_shared<E03MethodsStubImpl>(); - runtime->registerService(domain, instance, myService); + while (!runtime->registerService(domain, instance, myService, "service-sample")) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + std::cout << "Successfully Registered Service!" << std::endl; while (true) { myService->incCounter(); // Change value of attribute, see stub implementation diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp index d2856d2..b3b0afa 100644 --- a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp +++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp @@ -30,7 +30,7 @@ void E03MethodsStubImpl::foo(const std::shared_ptr<CommonAPI::ClientId> _client, std::cout << "foo called, setting new values." << std::endl; - E03Methods::fooError methodError = (E03Methods::fooError) E03Methods::stdErrorTypeEnum::MY_FAULT; + E03Methods::stdErrorTypeEnum methodError = E03Methods::stdErrorTypeEnum::MY_FAULT; int32_t y1 = 42; std::string y2 = "xyz"; _reply(methodError, y1, y2); diff --git a/CommonAPI-Examples/E03Methods/vsomeip-client.json b/CommonAPI-Examples/E03Methods/vsomeip-client.json new file mode 100644 index 0000000..f6d7414 --- /dev/null +++ b/CommonAPI-Examples/E03Methods/vsomeip-client.json @@ -0,0 +1,26 @@ +{ + "unicast" : "192.168.56.102", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "true", "path" : "/var/log/E03MethodsClient.log" }, + "dlt" : "true" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E03Methods/vsomeip-local.json b/CommonAPI-Examples/E03Methods/vsomeip-local.json new file mode 100644 index 0000000..2f4c823 --- /dev/null +++ b/CommonAPI-Examples/E03Methods/vsomeip-local.json @@ -0,0 +1,52 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + }, + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E03Methods/vsomeip-service.json b/CommonAPI-Examples/E03Methods/vsomeip-service.json new file mode 100644 index 0000000..2ab32df --- /dev/null +++ b/CommonAPI-Examples/E03Methods/vsomeip-service.json @@ -0,0 +1,77 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/E03MethodsService.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : + { + "minimum" : "10", + "maximum" : 100 + }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "unreliable" : "30509", + "events" : + [ + { + "event" : "0x80F2", + "is_field" : "false", + "is_reliable" : "false", + "update-cycle" : 2000 + }, + { + "event" : "0x80F3", + "is_field" : "true", + "is_reliable" : "false", + "update-cycle" : 0 + } + ], + "eventgroups" : + [ + { + "eventgroup" : "0x80F2", + "events" : [ "0x80F2" ] + }, + { + "eventgroup" : "0x80F3", + "events" : [ "0x80F3" ] + } + ] + } + ] + } + ], + "routing" : "service-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt index ed9840a..81cafd7 100644 --- a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt +++ b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt @@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E04PhoneBook) set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -pthread -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -38,48 +45,88 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}") # CommonAPI include(FindPkgConfig) -pkg_check_modules (DBUS "dbus-1 >= 1.4") +############################################################################### +# find DBus by using the 'pkg-config' tool +if (MSVC) + #Not beautiful, but it works + if (DBus_DIR) + if (DBus_BUILD_DIR) + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + else () + message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "DBus_DIR not set! Cannot continue.") + endif () +else() + pkg_check_modules(DBus REQUIRED dbus-1>=1.4) +endif() + +# SOME/IP +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) # Source Files set(PRJ_SRC_PATH src) -set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples) +set(PRJ_SRC_GEN_PATH src-gen) +set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/commonapi/examples) set(PRJ_NAME_CLIENT ${PRJ_NAME}Client) set(PRJ_NAME_SERVICE ${PRJ_NAME}Service) -FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp) -FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp) - +# Application +FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/E04PhoneBook.cpp) set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) -set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS}) + +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + +# DBus library +FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS}) + +# SOME/IP library +FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp) # Paths OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON) message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}") include_directories( - src-gen + src-gen/core + src-gen/dbus + src-gen/someip ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_SOMEIP_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} + ${VSOMEIP_INCLUDE_DIRS} ) if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_LIBDIR} + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() -set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES}) +set(LINK_LIBRARIES -Wl,--as-needed CommonAPI) # Build Client add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS}) @@ -88,3 +135,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES}) # Build service add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) + +# Build DBus library +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) + +# Build SOME/IP library +#add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +#target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) diff --git a/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini b/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini new file mode 100644 index 0000000..ba5224f --- /dev/null +++ b/CommonAPI-Examples/E04PhoneBook/commonapi4dbus.ini @@ -0,0 +1,8 @@ +[default] +binding=dbus + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini b/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini new file mode 100644 index 0000000..9d2e519 --- /dev/null +++ b/CommonAPI-Examples/E04PhoneBook/commonapi4someip.ini @@ -0,0 +1,8 @@ +[default] +binding=someip + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl new file mode 100644 index 0000000..0ad898b --- /dev/null +++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-DBus.fdepl @@ -0,0 +1,6 @@ +import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_deployment_spec.fdepl" +import "E04PhoneBook.fidl" + +define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E04PhoneBook { + DBusDefaultAttributeType = freedesktop +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl new file mode 100644 index 0000000..af57abc --- /dev/null +++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl @@ -0,0 +1,113 @@ +/* Copyright (C) 2014 BMW Group + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl" +import "E04PhoneBook.fidl" + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E04PhoneBook { + SomeIpServiceID = 4660 + SomeIpEventGroups = { 7000, 7001 } + + attribute phoneBook { + SomeIpGetterID = 7000 + } + + method setPhoneBookDataFilter { + SomeIpMethodID = 33000 + } + + broadcast phoneBookDataSet { + SomeIpEventID = 8000 + } + + enumeration phoneNumberEnum { + WORK { + } + HOME { + } + MOBILE1 { + } + MOBILE2 { + } + } + + struct phoneBookStruct { + name { + } + forename { + } + organisation { + } + address { + } + email { + } + phoneNumber { + } + } + + struct elementFilterStruct { + addName { + } + addForename { + } + addOrganisation { + } + addAddress { + } + addEmail { + } + addPhoneNumber { + } + } + + struct contentFilterStruct { + element { + } + expression { + } + } + + enumeration phoneBookDataElementEnum { + NAME { + } + FORENAME { + } + ORGANISATION { + } + ADDRESS { + } + EMAIL { + } + PHONENUMBER { + } + } + + struct phoneBookDataElement { + } + + struct phoneBookDataElementString { + content { + } + } + + struct phoneBookDataElementPhoneNumber { + content { + } + } + +} + +define org.genivi.commonapi.someip.deployment for provider Service { + instance commonapi.examples.E04PhoneBook { + InstanceId = "commonapi.examples.PhoneBook" + + SomeIpInstanceID = 22136 + + SomeIpUnicastAddress = "192.168.0.2" + SomeIpReliableUnicastPort = 30491 + SomeIpUnreliableUnicastPort = 30492 +} +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp index 8250762..d1b9d84 100644 --- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp +++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp @@ -5,7 +5,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef WIN32 #include <unistd.h> +#endif #include <map> #include <iostream> @@ -128,19 +130,22 @@ void printFilterResult(const std::vector<E04PhoneBook::phoneBookDataElementMap>& } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E04C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E04PhoneBook"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); const std::string &domain = "local"; const std::string &instance = "commonapi.examples.PhoneBook"; - std::shared_ptr < E04PhoneBookProxyDefault > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance); + std::shared_ptr < E04PhoneBookProxy<> > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance); while (!myProxyA->isAvailable()) { usleep(10); } const CommonAPI::ConnectionId_t otherConnectionId = "42"; - std::shared_ptr < E04PhoneBookProxyDefault > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId); + std::shared_ptr < E04PhoneBookProxy<> > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId); while (!myProxyB->isAvailable()) { usleep(10); } diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp index 03da5d8..bece39c 100644 --- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp +++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp @@ -12,6 +12,9 @@ #include "E04PhoneBookStubImpl.h" int main() { + CommonAPI::Runtime::setProperty("LogContext", "E04S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E04PhoneBook"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); const std::string &domain = "local"; @@ -19,7 +22,16 @@ int main() { std::shared_ptr<E04PhoneBookStubImpl> myService = std::make_shared<E04PhoneBookStubImpl>(); myService->setPhoneBookAttribute(myService->createTestPhoneBook()); - runtime->registerService(domain, instance, myService); + bool successfullyRegistered = runtime->registerService(domain, instance, myService); + + while (!successfullyRegistered) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myService); + } + + std::cout << "Successfully Registered Service!" << std::endl; + while (true) { std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl; std::this_thread::sleep_for(std::chrono::seconds(2)); diff --git a/CommonAPI-Examples/E05Manager/CMakeLists.txt b/CommonAPI-Examples/E05Manager/CMakeLists.txt index db10047..ba18ba5 100644 --- a/CommonAPI-Examples/E05Manager/CMakeLists.txt +++ b/CommonAPI-Examples/E05Manager/CMakeLists.txt @@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E05Manager) set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -38,44 +45,83 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}") # CommonAPI include(FindPkgConfig) -pkg_check_modules (DBUS "dbus-1 >= 1.4") +############################################################################### +# find DBus by using the 'pkg-config' tool +if (MSVC) + #Not beautiful, but it works + if (DBus_DIR) + if (DBus_BUILD_DIR) + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + else () + message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "DBus_DIR not set! Cannot continue.") + endif () +else() + pkg_check_modules(DBus REQUIRED dbus-1>=1.4) +endif() + +# SOME/IP +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) # Source Files set(PRJ_SRC_PATH src) -set(PRJ_SRC_GEN_PATH src-gen/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_PATH src-gen) +set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1_0/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1_0/commonapi/examples) set(PRJ_NAME_CLIENT ${PRJ_NAME}Client) set(PRJ_NAME_SERVICE ${PRJ_NAME}Service) -FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp) +# Application +FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp) FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp) - set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) -set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS}) + +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + +# DBus library +FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp) + +# SOME/IP library +FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp) # Paths OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON) message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}") include_directories( - src-gen + src-gen/core + src-gen/dbus + src-gen/someip ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_SOMEIP_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} + ${VSOMEIP_INCLUDE_DIRS} ) if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_LIBDIR} + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() @@ -88,3 +134,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES}) # Build service add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) + +# Build DBus library +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) + +# Build SOME/IP library +#add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +#target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) diff --git a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl new file mode 100644 index 0000000..5befa32 --- /dev/null +++ b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl @@ -0,0 +1,50 @@ +/* Copyright (C) 2014 BMW Group + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl" +import "E05Manager.fidl" + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Manager { + SomeIpServiceID = 4660 + SomeIpEventGroups = { 7000, 7001 } + + attribute myDevices { + SomeIpGetterID = 7000 + SomeIpSetterID = 7004 + } + +} + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Device { + SomeIpServiceID = 4661 + SomeIpEventGroups = { 7000, 7001 } + + method doSomething { + SomeIpMethodID = 7001 + } + +} + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05SpecialDevice { + SomeIpServiceID = 4662 + SomeIpEventGroups = { 7000, 7001 } + + method doSomethingSpecial { + SomeIpMethodID = 7002 + } + +} + +define org.genivi.commonapi.someip.deployment for provider Service { + instance commonapi.examples.E04PhoneBook { + InstanceId = "commonapi.examples.PhoneBook" + + SomeIpInstanceID = 22136 + + SomeIpUnicastAddress = "192.168.0.2" + SomeIpReliableUnicastPort = 30500 + SomeIpUnreliableUnicastPort = 30501 +} +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp index d43fb3d..983601c 100644 --- a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp +++ b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp @@ -5,7 +5,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef WIN32 #include <unistd.h> +#endif #include <iostream> @@ -25,11 +27,14 @@ void newDeviceAvailable(const std::string address, const CommonAPI::Availability } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E05C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); const std::string &domain = "local"; const std::string &instance = "commonapi.examples.Manager"; - std::shared_ptr<E05ManagerProxyDefault> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance); + std::shared_ptr<E05ManagerProxy<>> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance); while (!myProxy->isAvailable()) { usleep(10); } diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp index 188d46c..c32faa0 100644 --- a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp +++ b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp @@ -18,13 +18,21 @@ const static unsigned int maxDeviceNumber = 3; const static std::string managerInstanceName = "commonapi.examples.Manager"; int main() { + CommonAPI::Runtime::setProperty("LogContext", "E05S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); std::shared_ptr<E05ManagerStubImpl> myService = std::make_shared < E05ManagerStubImpl > (managerInstanceName); - const bool serviceRegistered = runtime->registerService("local", managerInstanceName, myService); - if (!serviceRegistered) { - std::cout << "Error: Unable to register service." << std::endl; - } + bool successfullyRegistered = runtime->registerService("local", managerInstanceName, myService); + + while (!successfullyRegistered) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService("local", managerInstanceName, myService); + } + + std::cout << "Successfully Registered Service!" << std::endl; while (true) { // Simulate external events diff --git a/CommonAPI-Examples/E06Unions/CMakeLists.txt b/CommonAPI-Examples/E06Unions/CMakeLists.txt index 641fd78..1b342a3 100644 --- a/CommonAPI-Examples/E06Unions/CMakeLists.txt +++ b/CommonAPI-Examples/E06Unions/CMakeLists.txt @@ -10,7 +10,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E06Unions) set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -24,11 +31,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -38,48 +45,88 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}") # CommonAPI include(FindPkgConfig) -pkg_check_modules (DBUS "dbus-1 >= 1.4") +############################################################################### +# find DBus by using the 'pkg-config' tool +if (MSVC) + #Not beautiful, but it works + if (DBus_DIR) + if (DBus_BUILD_DIR) + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + else () + message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "DBus_DIR not set! Cannot continue.") + endif () +else() + pkg_check_modules(DBus REQUIRED dbus-1>=1.4) +endif() + +# SOME/IP +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) # Source Files set(PRJ_SRC_PATH src) -set(PRJ_SRC_GEN_PATH src-gen/commonapi/examples) +set(PRJ_SRC_GEN_PATH src-gen) +set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/commonapi/examples) +set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/commonapi/examples) set(PRJ_NAME_CLIENT ${PRJ_NAME}Client) set(PRJ_NAME_SERVICE ${PRJ_NAME}Service) -FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Proxy.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp) -FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_PATH}/*Stub*.cpp ${PRJ_SRC_GEN_PATH}/${PRJ_NAME}.cpp ${PRJ_SRC_GEN_PATH}/CommonTypes.cpp) -FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_PATH}/*Stub*.cpp) - +# Application +FILE(GLOB PRJ_PROXY_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Proxy.cpp) +FILE(GLOB PRJ_STUB_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp) +FILE(GLOB PRJ_TYPES_GEN_SRCS ${PRJ_SRC_GEN_COMMONAPI_PATH}/CommonTypes.cpp) set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) -set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS} ${PRJ_TYPES_GEN_SRCS}) + +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + +# DBus library +FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS}) + +# SOME/IP library +FILE(GLOB PRJ_SOMEIP_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH}/*cpp ${PRJ_TYPES_GEN_SRCS}) # Paths OPTION(USE_INSTALLED_DBUS "Set to OFF to use the local (patched) version of dbus" ON) message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}") include_directories( - src-gen + src-gen/core + src-gen/dbus + src-gen/someip ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${COMMONAPI_SOMEIP_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} + ${VSOMEIP_INCLUDE_DIRS} ) if ("${USE_INSTALLED_DBUS}" STREQUAL "ON") link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_LIBDIR} + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() -set(LINK_LIBRARIES -Wl,--no-as-needed CommonAPI-DBus -Wl,--as-needed CommonAPI ${DBUS_LIBRARIES}) +set(LINK_LIBRARIES -Wl,--as-needed CommonAPI) # Build Client add_executable(${PRJ_NAME_CLIENT} ${PRJ_CLIENT_SRCS}) @@ -88,3 +135,11 @@ target_link_libraries(${PRJ_NAME_CLIENT} ${LINK_LIBRARIES}) # Build service add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) + +# Build DBus library +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) + +# Build SOME/IP library +add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) diff --git a/CommonAPI-Examples/E06Unions/commonapi4dbus.ini b/CommonAPI-Examples/E06Unions/commonapi4dbus.ini new file mode 100644 index 0000000..ba5224f --- /dev/null +++ b/CommonAPI-Examples/E06Unions/commonapi4dbus.ini @@ -0,0 +1,8 @@ +[default] +binding=dbus + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E06Unions/commonapi4someip.ini b/CommonAPI-Examples/E06Unions/commonapi4someip.ini new file mode 100644 index 0000000..9d2e519 --- /dev/null +++ b/CommonAPI-Examples/E06Unions/commonapi4someip.ini @@ -0,0 +1,8 @@ +[default] +binding=someip + +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl new file mode 100644 index 0000000..67f27ed --- /dev/null +++ b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl @@ -0,0 +1,73 @@ +/* Copyright (C) 2014 BMW Group + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl" +import "E06Unions.fidl" + +define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E06Unions { + SomeIpServiceID = 4660 + SomeIpEventGroups = { 7000, 7001 } + + attribute u { + SomeIpGetterID = 3000 + SomeIpSetterID = 3001 + SomeIpNotifierID = 33010 + SomeIpEventGroups = { 33010 } + } + + attribute x { + SomeIpGetterID = 3002 + SomeIpSetterID = 3003 + SomeIpNotifierID = 33011 + SomeIpEventGroups = { 33011 } + } + +} + +define org.genivi.commonapi.someip.deployment for typeCollection commonapi.examples.CommonTypes { + + union SettingsUnion { + id { + } + status { + } + channel { + } + name { + } + } + + struct SettingsStructMyTypedef { + id { + } + } + + struct SettingsStructMyEnum { + status { + } + } + + struct SettingsStructUInt8 { + channel { + } + } + + struct SettingsStructString { + name { + } + } +} + +define org.genivi.commonapi.someip.deployment for provider Service { + instance commonapi.examples.E06Unions { + InstanceId = "commonapi.examples.Unions" + + SomeIpInstanceID = 22136 + + SomeIpUnicastAddress = "192.168.0.2" + SomeIpReliableUnicastPort = 30490 + SomeIpUnreliableUnicastPort = 30491 +} +}
\ No newline at end of file diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp index 2fa2527..ea6618a 100644 --- a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp +++ b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp @@ -4,15 +4,15 @@ * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - +#ifndef WIN32 #include <unistd.h> - +#endif #include <iostream> #include <CommonAPI/CommonAPI.hpp> -#include "../src-gen/commonapi/examples/CommonTypes.hpp" -#include "../src-gen/commonapi/examples/E06UnionsProxy.hpp" +#include "commonapi/examples/CommonTypes.hpp" +#include "commonapi/examples/E06UnionsProxy.hpp" #include "typeUtils.hpp" using namespace commonapi::examples; @@ -155,11 +155,16 @@ void recv_msg1(std::shared_ptr<CommonTypes::SettingsStruct> x) { int main() { + CommonAPI::Runtime::setProperty("LogContext", "E06C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); const std::string &domain = "local"; - const std::string &instance = "commonapi.examples.Unions"; - std::shared_ptr<E06UnionsProxyDefault> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance); + const std::string &instance = "commonapi.examples.Unions"; + std::string connection = "client-sample"; + + std::shared_ptr<E06UnionsProxy<>> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance, connection); while (!myProxy->isAvailable()) { usleep(10); diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp index 0e1cf02..9fa72b6 100644 --- a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp +++ b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp @@ -12,23 +12,37 @@ #include "E06UnionsStubImpl.h" int main() { + CommonAPI::Runtime::setProperty("LogContext", "E06S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); const std::string &domain = "local"; - const std::string &instance = "commonapi.examples.Unions"; + const std::string &instance = "commonapi.examples.Unions"; + std::string connection = "service-sample"; + std::shared_ptr<E06UnionsStubImpl> myService = std::make_shared<E06UnionsStubImpl>(); - if (runtime->registerService(domain, instance, myService)) { - int n = 0; - while (true) { - std::cout << "Set value " << n << " for union u." << std::endl; - myService->setMyValue(n); - n++; - if (n == 4) { - n = 0; - } - std::this_thread::sleep_for(std::chrono::seconds(2)); + bool successfullyRegistered = runtime->registerService(domain, instance, myService, connection); + + while (!successfullyRegistered) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myService); + } + + std::cout << "Successfully Registered Service!" << std::endl; + + int n = 0; + while (true) { + std::cout << "Set value " << n << " for union u." << std::endl; + myService->setMyValue(n); + n++; + if (n == 4) { + n = 0; } - } + std::this_thread::sleep_for(std::chrono::seconds(2)); + } + return 0; } diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp index 58e9f82..1cee610 100644 --- a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp +++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp @@ -7,7 +7,7 @@ #include "E06UnionsStubImpl.h" -#include "../src-gen/commonapi/examples/CommonTypes.hpp" +#include "commonapi/examples/CommonTypes.hpp" using namespace commonapi::examples; diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h index cc3b0bf..3f7058e 100644 --- a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h +++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.h @@ -10,7 +10,7 @@ #include <CommonAPI/CommonAPI.hpp> -#include "../src-gen/commonapi/examples/E06UnionsStubDefault.hpp" +#include "commonapi/examples/E06UnionsStubDefault.hpp" class E06UnionsStubImpl: public commonapi::examples::E06UnionsStubDefault { diff --git a/CommonAPI-Examples/E06Unions/vsomeip-client.json b/CommonAPI-Examples/E06Unions/vsomeip-client.json new file mode 100644 index 0000000..731852a --- /dev/null +++ b/CommonAPI-Examples/E06Unions/vsomeip-client.json @@ -0,0 +1,26 @@ +{ + "unicast" : "192.168.56.102", + "netmask" : "255.255.255.0", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "true", "path" : "/var/log/vsomeip.log" }, + "dlt" : "true" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E06Unions/vsomeip-local.json b/CommonAPI-Examples/E06Unions/vsomeip-local.json new file mode 100644 index 0000000..2f4c823 --- /dev/null +++ b/CommonAPI-Examples/E06Unions/vsomeip-local.json @@ -0,0 +1,52 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "client-sample", + "id" : "0x1343" + }, + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "client-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E06Unions/vsomeip-service.json b/CommonAPI-Examples/E06Unions/vsomeip-service.json new file mode 100644 index 0000000..371ecf7 --- /dev/null +++ b/CommonAPI-Examples/E06Unions/vsomeip-service.json @@ -0,0 +1,48 @@ +{ + "unicast" : "192.168.56.101", + "logging" : + { + "level" : "debug", + "console" : "true", + "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" }, + "dlt" : "false" + }, + "applications" : + [ + { + "name" : "service-sample", + "id" : "0x1277" + } + ], + "servicegroups" : + [ + { + "name" : "default", + "delays" : + { + "initial" : { "minimum" : "10", "maximum" : "100" }, + "repetition-base" : "200", + "repetition-max" : "3", + "cyclic-offer" : "2000", + "cyclic-request" : "2001" + }, + "services" : + [ + { + "service" : "0x1234", + "instance" : "0x5678", + "reliable" : { "port" : "30509", "enable-magic-cookies" : "false" }, + "unreliable" : "31000" + } + ] + } + ], + "routing" : "service-sample", + "service-discovery" : + { + "enable" : "true", + "multicast" : "224.244.224.245", + "port" : "30490", + "protocol" : "udp" + } +} diff --git a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt index 2642156..0f54006 100644 --- a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt +++ b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt @@ -9,7 +9,14 @@ cmake_minimum_required(VERSION 2.8) set(PRJ_NAME E07Mainloop) set(CMAKE_VERBOSE_MAKEFILE on) + +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS /EHsc /wd\\\"4503\\\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS /wd\\\"4503\\\"") +else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -O0 -std=c++0x -D_GLIBCXX_USE_NANOSLEEP -DLINUX") +endif() message(STATUS "Compiler options: ${CMAKE_CXX_FLAGS}") @@ -23,11 +30,11 @@ OPTION(USE_INSTALLED_COMMONAPI "Set to OFF to use the local (build tree) version message(STATUS "USE_INSTALLED_COMMONAPI is set to value: ${USE_INSTALLED_COMMONAPI}") if ("${USE_INSTALLED_COMMONAPI}" STREQUAL "ON") - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY) else() - FIND_PACKAGE(CommonAPI REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - FIND_PACKAGE(CommonAPI-DBus REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + FIND_PACKAGE(CommonAPI-DBus 3.1.2 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) endif() message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}") @@ -37,21 +44,53 @@ message(STATUS "COMMONAPI_DBUS_INCLUDE_DIRS: ${COMMONAPI_DBUS_INCLUDE_DIRS}") # CommonAPI include(FindPkgConfig) -pkg_check_modules (DBUS "dbus-1 >= 1.4") +############################################################################### +# find DBus by using the 'pkg-config' tool +if (MSVC) + #Not beautiful, but it works + if (DBus_DIR) + if (DBus_BUILD_DIR) + set(DBus_INCLUDE_DIRS "${DBus_DIR};${DBus_BUILD_DIR};") + else () + message (FATAL_ERROR "DBus_BUILD_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "DBus_DIR not set! Cannot continue.") + endif () +else() + pkg_check_modules(DBus REQUIRED dbus-1>=1.4) +endif() # SOME/IP -find_package (CommonAPI-SomeIP 3.1.1 REQUIRED) -find_package (vsomeip 1.1.0 REQUIRED) +find_package (CommonAPI-SomeIP 3.1.2 REQUIRED) +find_package (vsomeip 1.2.0 REQUIRED) # GLib -FIND_PACKAGE(glib-2.0) -if (GLIB_FOUND) - message ( STATUS "Glib found: " ${GLIB_INCLUDE_DIRS} " " ${_GLIB_LIBRARY_DIR} " " ${GLIBCONFIG_INCLUDE_DIR} ) - include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR}) - #link_directories(${_GLIB_LIBRARY_DIR}) -else (GLIB_FOUND) - message ( WARNING "Glib not found.") -endif (GLIB_FOUND) +if (MSVC) + if (GLIB_INCLUDE_DIRS) + if (GLIBCONFIG_INCLUDE_DIR) + if (_GLIB_LIBRARY_DIR) + include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR}) + link_directories(${_GLIB_LIBRARY_DIR}) + else () + message (FATAL_ERROR "_GLIB_LIBRARY_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "GLIBCONFIG_INCLUDE_DIR not set! Cannot continue.") + endif () + else() + message (FATAL_ERROR "GLIB_INCLUDE_DIRS not set! Cannot continue.") + endif () +else() + FIND_PACKAGE(glib-2.0) + if (GLIB_FOUND) + message ( STATUS "Glib found: " ${GLIB_INCLUDE_DIRS} " " ${_GLIB_LIBRARY_DIR} " " ${GLIBCONFIG_INCLUDE_DIR} ) + include_directories(${GLIB_INCLUDE_DIRS} ${GLIBCONFIG_INCLUDE_DIR}) + #link_directories(${_GLIB_LIBRARY_DIR}) + else (GLIB_FOUND) + message ( WARNING "Glib not found.") + endif (GLIB_FOUND) +endif() # Source Files set(PRJ_SRC_PATH src) @@ -70,6 +109,10 @@ FILE(GLOB PRJ_STUB_IMPL_SRCS ${PRJ_SRC_COMMONAPI_PATH}/*Stub*.cpp) set(PRJ_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS}) set(PRJ_SERVICE_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_SERVICE}.cpp ${PRJ_SRC_PATH}/${PRJ_NAME}StubImpl.cpp ${PRJ_STUB_GEN_SRCS} ${PRJ_STUB_IMPL_SRCS}) +# Boost +find_package( Boost 1.54 COMPONENTS system thread log REQUIRED ) +include_directories( ${Boost_INCLUDE_DIR} ) + # DBus library FILE(GLOB PRJ_DBUS_LIB_SRCS ${PRJ_SRC_GEN_COMMONAPI_DBUS_PATH}/*cpp) @@ -87,7 +130,7 @@ include_directories( ${COMMONAPI_INCLUDE_DIRS} ${COMMONAPI_DBUS_INCLUDE_DIRS} ${COMMONAPI_SOMEIP_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} + ${DBus_INCLUDE_DIRS} ${VSOMEIP_INCLUDE_DIRS} ) @@ -96,13 +139,15 @@ link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} ${COMMONAPI_SOMEIP_CMAKE_DIR}/build + ${Boost_LIBRARY_DIR} ) else() link_directories( ${COMMONAPI_LIBDIR} ${COMMONAPI_DBUS_LIBDIR} ${COMMONAPI_SOMEIP_CMAKE_DIR}/build - ${DBUS_INCLUDE_DIRS}/dbus/.libs + ${DBus_INCLUDE_DIRS}/dbus/.libs + ${Boost_LIBRARY_DIR} ) endif() @@ -117,9 +162,9 @@ add_executable(${PRJ_NAME_SERVICE} ${PRJ_SERVICE_SRCS}) target_link_libraries(${PRJ_NAME_SERVICE} ${LINK_LIBRARIES}) # Build DBus library -add_library (${PRJ_NAME}-DBus SHARED ${PRJ_DBUS_LIB_SRCS}) -target_link_libraries(${PRJ_NAME}-DBus CommonAPI-DBus) +add_library (${PRJ_NAME}-dbus SHARED ${PRJ_DBUS_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-dbus CommonAPI-DBus) # Build SOME/IP library -add_library (${PRJ_NAME}-SomeIP SHARED ${PRJ_SOMEIP_LIB_SRCS}) -target_link_libraries(${PRJ_NAME}-SomeIP CommonAPI-SomeIP)
\ No newline at end of file +add_library (${PRJ_NAME}-someip SHARED ${PRJ_SOMEIP_LIB_SRCS}) +target_link_libraries(${PRJ_NAME}-someip CommonAPI-SomeIP) diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini index 39a52b7..ba5224f 100644 --- a/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini +++ b/CommonAPI-Examples/E07Mainloop/commonapi4dbus.ini @@ -1,8 +1,8 @@ [default] binding=dbus -[proxy] -local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so - -[stub] -local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-DBus.so +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini index 0c68943..9d2e519 100644 --- a/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini +++ b/CommonAPI-Examples/E07Mainloop/commonapi4someip.ini @@ -1,8 +1,8 @@ [default] binding=someip -[proxy] -local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so - -[stub] -local:commonapi.examples.E07Mainloop:commonapi.examples.Mainloop=libE07Mainloop-SomeIP.so +[logging] +console = true +file = ./mylog.log +dlt = true +level = verbose diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp index 02954be..304255f 100644 --- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp +++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp @@ -5,10 +5,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <iostream> + +#ifndef WIN32 #include <unistd.h> +#endif + #include <sstream> #include <glib.h> +#include <gio/gio.h> #include <CommonAPI/CommonAPI.hpp> #include <v1_0/commonapi/examples/E07MainloopProxy.hpp> @@ -114,7 +119,12 @@ static GSourceFuncs standardGLibSourceCallbackFuncs = { gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) { CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData); - watch->dispatch(condition); + +#ifdef WIN32 + condition = static_cast<GIOCondition>(7); +#endif + + watch->dispatch(condition); return true; } @@ -124,11 +134,16 @@ gboolean gTimeoutDispatcher ( void* userData ) { } void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) { - const pollfd& fileDesc = watch->getAssociatedFileDescriptor(); - channel = g_io_channel_unix_new(fileDesc.fd); - GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events)); +#ifdef WIN32 + channel = g_io_channel_win32_new_socket(fileDesc.fd); + GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN); +#else + channel = g_io_channel_unix_new(fileDesc.fd); + GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events)); +#endif + g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL); const auto& dependentSources = watch->getDependentDispatchSources(); @@ -141,7 +156,7 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio g_source_add_child_source(gWatch, gDispatchSource); } - g_source_attach(gWatch, NULL); + int source = g_source_attach(gWatch, NULL); } void watchRemovedCallback ( CommonAPI::Watch* watch ) { @@ -155,6 +170,9 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) { } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E07C"); + CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop"); + std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get(); std::string domain = "local"; @@ -167,11 +185,16 @@ int main() { std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback; mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback); - std::shared_ptr<E07MainloopProxyDefault> myProxy = runtime->buildProxy<E07MainloopProxy>(domain, + std::shared_ptr<E07MainloopProxy<>> myProxy = runtime->buildProxy<E07MainloopProxy>(domain, instance, mainloopContext); std::cout << "Checking availability" << std::flush; - static constexpr bool mayBlock = false; + static + #ifndef WIN32 + constexpr + #endif + bool mayBlock = false; + int count = 0; while (!myProxy->isAvailable()) { if (count % 10 == 0) diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp index e57f192..17e7eb7 100644 --- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp +++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp @@ -8,6 +8,7 @@ #include <thread> #include <glib.h> +#include <gio/gio.h> #include <CommonAPI/CommonAPI.hpp> #include "E07MainloopStubImpl.hpp" @@ -69,7 +70,12 @@ static GSourceFuncs standardGLibSourceCallbackFuncs = { gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) { CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData); - watch->dispatch(condition); + +#ifdef WIN32 + condition = static_cast<GIOCondition>(7); +#endif + + watch->dispatch(condition); return true; } @@ -79,11 +85,16 @@ gboolean gTimeoutDispatcher ( void* userData ) { } void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) { - const pollfd& fileDesc = watch->getAssociatedFileDescriptor(); - channel = g_io_channel_unix_new(fileDesc.fd); - GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events)); +#ifdef WIN32 + channel = g_io_channel_win32_new_socket(fileDesc.fd); + GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN); +#else + channel = g_io_channel_unix_new(fileDesc.fd); + GSource* gWatch = g_io_create_watch(channel, static_cast<GIOCondition>(fileDesc.events)); +#endif + g_source_set_callback(gWatch, reinterpret_cast<GSourceFunc>(&gWatchDispatcher), watch, NULL); const auto& dependentSources = watch->getDependentDispatchSources(); @@ -96,7 +107,7 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio g_source_add_child_source(gWatch, gDispatchSource); } - g_source_attach(gWatch, NULL); + int source = g_source_attach(gWatch, NULL); } void watchRemovedCallback ( CommonAPI::Watch* watch ) { @@ -110,6 +121,9 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) { } int main() { + CommonAPI::Runtime::setProperty("LogContext", "E07S"); + CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop"); + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); std::string domain = "local"; @@ -123,7 +137,16 @@ int main() { mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback); std::shared_ptr<E07MainloopStubImpl> myService = std::make_shared<E07MainloopStubImpl>(); - runtime->registerService(domain, instance, myService, mainloopContext); + + bool successfullyRegistered = runtime->registerService(domain, instance, myService, mainloopContext); + + while (!successfullyRegistered) { + std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + successfullyRegistered = runtime->registerService(domain, instance, myService, mainloopContext); + } + + std::cout << "Successfully Registered Service!" << std::endl; GMainLoop* mainloop = NULL; mainloop = g_main_loop_new(NULL, FALSE); @@ -4,3 +4,20 @@ Changes since 2.1.6 - Changes for CommonAPI 3 (see CommonAPI runtime) - Franca 0.9.1 - Extended code generator options + +Changes since 2.1.5 + +- modifying target platform and pom.xml to accomodate incompatible Franca versioning scheme +- Improved description for maven build of update-site and commandline generator. +- adding dbus.validator to category.xml +- extend and restructure documentation with tutorial and specification +- added O0 optimization flag to CMakeLists.txt. +- added generation of code for disambiguation needed for attributes on inherited interfaces +- adding maven xtend plugin for command line build +- genallincl bug in cli fixed +- removing obsolete plugins to shrink down size of generator +- adapted Test "DBusCommunicationTest > RemoteMethodCallSucceeds" to verification test. +- deleted the old validator, added a validator with general restrictions +- new feature to generate proxies and stubs into seperate target directories +- small changes to generate code that can be compiled warning free +- generator now creates windows compatible code diff --git a/org.genivi.commonapi.console.feature/feature.xml b/org.genivi.commonapi.console.feature/feature.xml index 95bd4c3..9cf2768 100644 --- a/org.genivi.commonapi.console.feature/feature.xml +++ b/org.genivi.commonapi.console.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.genivi.commonapi.console.feature" label="Command Line Feature" - version="3.1.1.qualifier" + version="3.1.2.qualifier" provider-name="BMW AG"> <description url="http://www.example.com/description"> @@ -18,7 +18,7 @@ </license> <requires> - <import feature="org.genivi.commonapi.console.franca.feature" version="3.1.1" match="compatible"/> + <import feature="org.genivi.commonapi.console.franca.feature" version="3.1.2" match="compatible"/> </requires> <plugin diff --git a/org.genivi.commonapi.console.feature/pom.xml b/org.genivi.commonapi.console.feature/pom.xml index 6cbb9bd..fcdb371 100644 --- a/org.genivi.commonapi.console.feature/pom.xml +++ b/org.genivi.commonapi.console.feature/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.releng</relativePath> </parent> </project>
\ No newline at end of file diff --git a/org.genivi.commonapi.console.franca.feature/feature.xml b/org.genivi.commonapi.console.franca.feature/feature.xml index cef489a..13bd567 100644 --- a/org.genivi.commonapi.console.franca.feature/feature.xml +++ b/org.genivi.commonapi.console.franca.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.genivi.commonapi.console.franca.feature" label="Franca Core Dependencies Feature" - version="3.1.1.qualifier" + version="3.1.2.qualifier" provider-name="BMW AG"> <description url="http://www.example.com/description"> diff --git a/org.genivi.commonapi.console.franca.feature/pom.xml b/org.genivi.commonapi.console.franca.feature/pom.xml index 450df41..3115c7e 100644 --- a/org.genivi.commonapi.console.franca.feature/pom.xml +++ b/org.genivi.commonapi.console.franca.feature/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.releng</relativePath> </parent> </project>
\ No newline at end of file diff --git a/org.genivi.commonapi.console/META-INF/MANIFEST.MF b/org.genivi.commonapi.console/META-INF/MANIFEST.MF index 358403e..8b163bb 100644 --- a/org.genivi.commonapi.console/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.console/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: CommonAPI Console Bundle-SymbolicName: org.genivi.commonapi.console;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.1.2.qualifier Bundle-Vendor: BMW AG Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)";visibility:=reexport, org.apache.commons.cli;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, diff --git a/org.genivi.commonapi.console/about.mappings b/org.genivi.commonapi.console/about.mappings index 68552a9..da4ab58 100644 --- a/org.genivi.commonapi.console/about.mappings +++ b/org.genivi.commonapi.console/about.mappings @@ -1,3 +1,3 @@ -0=3.1.1 -1=20150529 -2=$sun.arch.data.model$
\ No newline at end of file +0=3.1.2 +1=20150616 +2=$sun.arch.data.model$ diff --git a/org.genivi.commonapi.console/pom.xml b/org.genivi.commonapi.console/pom.xml index d1e1922..d67917d 100644 --- a/org.genivi.commonapi.console/pom.xml +++ b/org.genivi.commonapi.console/pom.xml @@ -8,7 +8,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.releng</relativePath> </parent> diff --git a/org.genivi.commonapi.core.cli.feature/feature.xml b/org.genivi.commonapi.core.cli.feature/feature.xml index 495a14f..c732143 100644 --- a/org.genivi.commonapi.core.cli.feature/feature.xml +++ b/org.genivi.commonapi.core.cli.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.genivi.commonapi.core.cli.feature" label="CommonAPI Generator Feature" - version="3.1.1.qualifier" + version="3.1.2.qualifier" provider-name="BMW AG"> <plugin diff --git a/org.genivi.commonapi.core.cli.feature/pom.xml b/org.genivi.commonapi.core.cli.feature/pom.xml index dcfd4b7..b1804f3 100644 --- a/org.genivi.commonapi.core.cli.feature/pom.xml +++ b/org.genivi.commonapi.core.cli.feature/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.cli.product/category.xml b/org.genivi.commonapi.core.cli.product/category.xml index 4ee4178..43575e9 100644 --- a/org.genivi.commonapi.core.cli.product/category.xml +++ b/org.genivi.commonapi.core.cli.product/category.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/org.genivi.commonapi.console.feature_3.1.1.qualifier.jar" id="org.genivi.commonapi.console.feature" version="3.1.1.qualifier"> + <feature url="features/org.genivi.commonapi.console.feature_3.1.2.qualifier.jar" id="org.genivi.commonapi.console.feature" version="3.1.2.qualifier"> <category name="GENIVI CommonAPI Console"/> </feature> - <feature url="features/org.genivi.commonapi.console.franca.feature_3.1.1.qualifier.jar" id="org.genivi.commonapi.console.franca.feature" version="3.1.1.qualifier"> + <feature url="features/org.genivi.commonapi.console.franca.feature_3.1.2.qualifier.jar" id="org.genivi.commonapi.console.franca.feature" version="3.1.2.qualifier"> <category name="GENIVI CommonAPI Console"/> </feature> <category-def name="GENIVI CommonAPI Console" label="GENIVI CommonAPI Console Generators"> diff --git a/org.genivi.commonapi.core.cli.product/commonapi_console.product b/org.genivi.commonapi.core.cli.product/commonapi_console.product index 1bc020e..baff218 100644 --- a/org.genivi.commonapi.core.cli.product/commonapi_console.product +++ b/org.genivi.commonapi.core.cli.product/commonapi_console.product @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <?pde version="3.5"?> -<product name="CommonAPI Code Generator" uid="org.genivi.commonapi.core.cli.product" id="org.genivi.commonapi.console.product" application="org.genivi.commonapi.console.application" version="3.1.1" useFeatures="true" includeLaunchers="true"> +<product name="CommonAPI Code Generator" uid="org.genivi.commonapi.core.cli.product" id="org.genivi.commonapi.console.product" application="org.genivi.commonapi.console.application" version="3.1.2" useFeatures="true" includeLaunchers="true"> <configIni use="default"> </configIni> diff --git a/org.genivi.commonapi.core.cli.product/pom.xml b/org.genivi.commonapi.core.cli.product/pom.xml index d414692..c9c2152 100644 --- a/org.genivi.commonapi.core.cli.product/pom.xml +++ b/org.genivi.commonapi.core.cli.product/pom.xml @@ -73,6 +73,7 @@ <copy file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator" tofile="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator-linux-x86" /> + <chmod file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator-linux-x86" perm="777" /> <copy file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator.ini" tofile="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator-linux-x86.ini" /> @@ -89,6 +90,7 @@ <copy file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator" tofile="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator-linux-x86_64" /> + <chmod file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator-linux-x86_64" perm="777" /> <copy file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator.ini" tofile="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86_64/commonapi-generator-linux-x86_64.ini" /> @@ -125,7 +127,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project>
\ No newline at end of file diff --git a/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF index 9647524..b3e32c1 100644 --- a/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: commonapi generator Console Interface Bundle-SymbolicName: org.genivi.commonapi.core.cli;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.1.2.qualifier Bundle-Activator: org.genivi.commonapi.core.cli.Activator Require-Bundle: org.eclipse.core.runtime, org.eclipse.xtext;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, org.franca.core.dsl;bundle-version="[0.9.0,0.10.0)";visibility:=reexport, org.franca.deploymodel.dsl;bundle-version="[0.9.0,0.10.0)";visibility:=reexport, - org.genivi.commonapi.core;bundle-version="3.1.1";visibility:=reexport, - org.genivi.commonapi.console;bundle-version="3.1.1" + org.genivi.commonapi.core;bundle-version="3.1.2";visibility:=reexport, + org.genivi.commonapi.console;bundle-version="3.1.2" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-Vendor: BMW AG diff --git a/org.genivi.commonapi.core.cli/pom.xml b/org.genivi.commonapi.core.cli/pom.xml index c19c5b2..7e19acb 100644 --- a/org.genivi.commonapi.core.cli/pom.xml +++ b/org.genivi.commonapi.core.cli/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.feature/feature.xml b/org.genivi.commonapi.core.feature/feature.xml index 64a6a81..f954c13 100644 --- a/org.genivi.commonapi.core.feature/feature.xml +++ b/org.genivi.commonapi.core.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.genivi.commonapi.core.feature" label="%featureName" - version="3.1.1.qualifier" + version="3.1.2.qualifier" provider-name="%providerName"> <copyright> diff --git a/org.genivi.commonapi.core.feature/pom.xml b/org.genivi.commonapi.core.feature/pom.xml index 8649cae..aef7098 100644 --- a/org.genivi.commonapi.core.feature/pom.xml +++ b/org.genivi.commonapi.core.feature/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.releng/pom.xml b/org.genivi.commonapi.core.releng/pom.xml index 183dd5a..0bafea6 100644 --- a/org.genivi.commonapi.core.releng/pom.xml +++ b/org.genivi.commonapi.core.releng/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.target/pom.xml b/org.genivi.commonapi.core.target/pom.xml index 3b59852..6a084ff 100644 --- a/org.genivi.commonapi.core.target/pom.xml +++ b/org.genivi.commonapi.core.target/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project>
\ No newline at end of file diff --git a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF index 5882593..de6d276 100644 --- a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GENIVI Common API UI Bundle-SymbolicName: org.genivi.commonapi.core.ui;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.1.2.qualifier Bundle-Activator: org.genivi.commonapi.core.ui.CommonApiUiPlugin Bundle-Vendor: BMW AG Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.10.0,4.0.0)";visibility:=reexport, @@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.10.0,4.0.0)";visibil org.eclipse.xtext.builder;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, org.eclipse.xtext.generator;bundle-version="[2.7.0,3.0.0)";visibility:=reexport, com.google.inject;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, - org.genivi.commonapi.core;bundle-version="3.1.1";visibility:=reexport, + org.genivi.commonapi.core;bundle-version="3.1.2";visibility:=reexport, org.franca.core.dsl.ui;bundle-version="0.9.1", org.franca.deploymodel.dsl.ui;bundle-version="0.9.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml index 57352fd..3f28f6f 100644 --- a/org.genivi.commonapi.core.ui/plugin.xml +++ b/org.genivi.commonapi.core.ui/plugin.xml @@ -118,4 +118,13 @@ objectClass="org.eclipse.core.resources.IFile"> </page> </extension> + <extension + point="org.eclipse.ui.bindings"> + <key + commandId="org.genivi.commonapi.core.ui.handler.GenerationCommand" + contextId="org.eclipse.ui.contexts.window" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" + sequence="Ctrl+Shift+C"> + </key> + </extension> </plugin> diff --git a/org.genivi.commonapi.core.ui/pom.xml b/org.genivi.commonapi.core.ui/pom.xml index 98884aa..3a9452f 100644 --- a/org.genivi.commonapi.core.ui/pom.xml +++ b/org.genivi.commonapi.core.ui/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.updatesite/category.xml b/org.genivi.commonapi.core.updatesite/category.xml index 33b8400..89b94f1 100644 --- a/org.genivi.commonapi.core.updatesite/category.xml +++ b/org.genivi.commonapi.core.updatesite/category.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/org.genivi.commonapi.core.validator.feature_3.1.1.qualifier.jar" id="org.genivi.commonapi.core.validator.feature" version="3.1.1.qualifier"> + <feature url="features/org.genivi.commonapi.core.validator.feature_3.1.2.qualifier.jar" id="org.genivi.commonapi.core.validator.feature" version="3.1.2.qualifier"> <category name="GENIVI CommonAPI"/> </feature> - <feature url="features/org.genivi.commonapi.core.feature_3.1.1.qualifier.jar" id="org.genivi.commonapi.core.feature" version="3.1.1.qualifier"> + <feature url="features/org.genivi.commonapi.core.feature_3.1.2.qualifier.jar" id="org.genivi.commonapi.core.feature" version="3.1.2.qualifier"> <category name="GENIVI CommonAPI"/> </feature> <category-def name="GENIVI CommonAPI" label="GENIVI CommonAPI Generators"> diff --git a/org.genivi.commonapi.core.updatesite/pom.xml b/org.genivi.commonapi.core.updatesite/pom.xml index 02c1dd5..a263d41 100644 --- a/org.genivi.commonapi.core.updatesite/pom.xml +++ b/org.genivi.commonapi.core.updatesite/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project>
\ No newline at end of file diff --git a/org.genivi.commonapi.core.validator.feature/feature.xml b/org.genivi.commonapi.core.validator.feature/feature.xml index a2fb5fe..364e052 100644 --- a/org.genivi.commonapi.core.validator.feature/feature.xml +++ b/org.genivi.commonapi.core.validator.feature/feature.xml @@ -2,7 +2,7 @@ <feature id="org.genivi.commonapi.core.validator.feature" label="%featureName" - version="3.1.1.qualifier" + version="3.1.2.qualifier" provider-name="%providerName"> <copyright> @@ -14,7 +14,7 @@ </license> <requires> - <import plugin="org.genivi.commonapi.core.ui" version="3.1.1" match="compatible"/> + <import plugin="org.genivi.commonapi.core.ui" version="3.1.2" match="compatible"/> </requires> <plugin diff --git a/org.genivi.commonapi.core.validator.feature/pom.xml b/org.genivi.commonapi.core.validator.feature/pom.xml index bf2da36..60e893d 100644 --- a/org.genivi.commonapi.core.validator.feature/pom.xml +++ b/org.genivi.commonapi.core.validator.feature/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF index 880487c..786a859 100644 --- a/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF @@ -3,15 +3,15 @@ Bundle-ManifestVersion: 2 Bundle-Name: General Bundle-Vendor: BMW AG Bundle-SymbolicName: org.genivi.commonapi.core.validator;singleton:=true -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.1.2.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Require-Bundle: org.eclipse.ui, org.eclipse.core.expressions;bundle-version="3.4.400", org.eclipse.core.resources, org.eclipse.core.runtime, com.google.inject;bundle-version="3.0.0", - org.genivi.commonapi.core;bundle-version="3.1.1", - org.genivi.commonapi.core.ui;bundle-version="3.1.1", + org.genivi.commonapi.core;bundle-version="3.1.2", + org.genivi.commonapi.core.ui;bundle-version="3.1.2", org.franca.core.dsl;bundle-version="[0.9.0,0.10.0)";visibility:=reexport, org.eclipse.xtext;bundle-version="[2.7.0,3.0.0)";visibility:=reexport Export-Package: org.genivi.commonapi.core.validator diff --git a/org.genivi.commonapi.core.validator/pom.xml b/org.genivi.commonapi.core.validator/pom.xml index 431a2ec..643cb84 100644 --- a/org.genivi.commonapi.core.validator/pom.xml +++ b/org.genivi.commonapi.core.validator/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core.verification/CMakeLists.txt b/org.genivi.commonapi.core.verification/CMakeLists.txt index 79bb784..ffdb9f2 100644 --- a/org.genivi.commonapi.core.verification/CMakeLists.txt +++ b/org.genivi.commonapi.core.verification/CMakeLists.txt @@ -152,7 +152,13 @@ endif() ############################################################################## # verification tests build section +if (MSVC) +# Visual C++ is not always sure whether he is really C++ +set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -DCOMMONAPI_INTERNAL_COMPILATION /EHsc") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOMMONAPI_INTERNAL_COMPILATION") +else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wno-reorder -Wno-unused-variable -DCOMMONAPI_INTERNAL_COMPILATION") +endif() set(USE_RT "rt") message("Compiler options: ${CMAKE_CXX_FLAGS}") @@ -169,7 +175,11 @@ enable_testing() set(CMAKE_CTEST_COMMAND ctest -V) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) +if (MSVC) +set(TEST_LINK_LIBRARIES CommonAPI gtest ws2_32) +else() set(TEST_LINK_LIBRARIES CommonAPI gtest) +endif() add_executable(RTLoadingRuntime src/RTLoadingRuntime.cpp) target_link_libraries(RTLoadingRuntime ${TEST_LINK_LIBRARIES}) diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl index eab2007..0db1c70 100644 --- a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl +++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl @@ -67,7 +67,7 @@ interface TestInterface { union tUnionL1 { tEnum enumMember tArray arrayMember - tStruct structMember + //tStruct structMember tUnion unionMember tMap mapMember } diff --git a/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp index b4af088..d7e9c9d 100644 --- a/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp +++ b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 BMW Group +/* Copyright (C) 2014-2015 BMW Group * Author: Juergen Gehring (juergen.gehring@bmw.de) * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -107,6 +107,37 @@ private: std::function<void(const uint8_t&)> callbackTestAttribute_; }; +class SubscribeUnsubscribeHandler { + +public: + + SubscribeUnsubscribeHandler() { + okAttribute_ = 0; + notOkAttribute_ = 0; + } + + void okCallback(const uint8_t& val) { + okAttribute_ = val; + } + + void notOkCallback(const uint8_t& val) { + notOkAttribute_ = val; + } + + uint8_t getSubscribedOkAttribute() { + return okAttribute_; + } + + uint8_t getSubscribedNotOkAttribute() { + return notOkAttribute_; + } + +private: + + uint8_t okAttribute_; + uint8_t notOkAttribute_; +}; + void testSubscription(ProxyPtr pp) { SubscriptionHandler subscriptionHandler(pp); @@ -308,21 +339,19 @@ TEST_F(CMAttributeSubscription, SubscriptionMultithreading) { } /** - * @test Subscription test for cancellable callbacks. + * @test Subscription test : unsibscribe from the subscription callback. * - Register service and check if proxy is available. - * - Proxy subscribes for TestAttribute (uint8_t) with the subscribeCancellableListener method. + * - Proxy subscribes for TestAttribute (uint8_t). * - Change attribute in service by set method. * - Check if callback function in proxy received the right value. - * - Set desired subscription status to CANCEL. - * - Change value again; the callback should be called again but with return value CommonAPI::SubscriptionStatus::CANCEL. + * - Change value to the magic value 99: this triggers the callback to unsubscribe. * - Change value again; the callback should now be called anymore. * - Unregister the test service. */ -/* this test is no longer valid for CommonAPI 3.0. -TEST_F(CMAttributeSubscription, SubscriptionCancellable) { +TEST_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) { - bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_); + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); ASSERT_TRUE(serviceRegistered); for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { @@ -332,16 +361,13 @@ TEST_F(CMAttributeSubscription, SubscriptionCancellable) { SubscriptionHandler subscriptionHandler(testProxy_); - std::function<CommonAPI::SubscriptionStatus (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); - testProxy_->getTestAttributeAttribute().getChangedEvent().subscribeCancellableListener(myCallback); - subscriptionHandler.setSubscriptionStatus(CommonAPI::SubscriptionStatus::RETAIN); + std::function<void (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); + subscriptionHandler.startSubscribe(); testStub_->setTestAttributeAttribute(42); usleep(wt); EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42); - subscriptionHandler.setSubscriptionStatus(CommonAPI::SubscriptionStatus::CANCEL); - testStub_->setTestAttributeAttribute(99); usleep(wt); EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); @@ -352,46 +378,158 @@ TEST_F(CMAttributeSubscription, SubscriptionCancellable) { runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); } -*/ + /** - * @test Subscription test : unsibscribe from the subscription callback. - * - Register service and check if proxy is available. - * - Proxy subscribes for TestAttribute (uint8_t). - * - Change attribute in service by set method. - * - Check if callback function in proxy received the right value. - * - Change value to the magic value 99: this triggers the callback to unsubscribe. - * - Change value again; the callback should now be called anymore. - * - Unregister the test service. + * @test Test of subscribe and unsubscribe with two coexistent callbacks + * - subscribe both callbacks + * - change value + * - check that both callbacks were executed by changing the value + * - unsubscribe both callbacks + * - change value + * - check that both callbacks were not executed by changing the value */ +TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeTwoCallbacksCoexistent) { -TEST_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) { + SubscribeUnsubscribeHandler subUnsubHandler; + + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk; + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk; + + std::function<void (uint8_t)> callbackOk = std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1); + std::function<void (uint8_t)> callbackNotOk = std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1); + + subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk); + subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk); + + testStub_->setTestAttributeAttribute(1); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 0); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 0); bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); - ASSERT_TRUE(serviceRegistered); + ASSERT_TRUE(serviceRegistered); + usleep(wt); + testStub_->setTestAttributeAttribute(2); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 2); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 2); - for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) { - usleep(10000); - } - ASSERT_TRUE(testProxy_->isAvailable()); + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk); + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk); - SubscriptionHandler subscriptionHandler(testProxy_); + testStub_->setTestAttributeAttribute(3); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 2); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 2); - std::function<void (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1); - subscriptionHandler.startSubscribe(); + bool serviceUnregistered = runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(serviceUnregistered); + usleep(wt); +} - testStub_->setTestAttributeAttribute(42); +/** + * @test Test of subscribing and immediately unsubscribing a callback + * - subscribe first callback + * - subscribe second callback + * - unsubscribe second callback + * - change value + * - check that only first callback was executed + */ +TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeImmediatelyUnsubscribing) { + + SubscribeUnsubscribeHandler subUnsubHandler; + + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk; + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk; + + std::function<void (uint8_t)> callbackOk = std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1); + std::function<void (uint8_t)> callbackNotOk = std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1); + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + usleep(wt); + + // subscribe ok callback + subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk); + + testStub_->setTestAttributeAttribute(10); usleep(wt); - EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 10); - testStub_->setTestAttributeAttribute(99); + // subscribe notOk callback + subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk); + + // unsubscribe notOk callback + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk); + + testStub_->setTestAttributeAttribute(12); usleep(wt); - EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 0); - testStub_->setTestAttributeAttribute(250); + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk); + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk); + + bool serviceUnregistered = runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(serviceUnregistered); usleep(wt); - EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99); +} - runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); +/** + * @test Test of subscribing and immediately sequentially + * - subscribe first callback + * - subscribe second callback + * - change value + * - check that both callbacks were executed by changing the value + * - unsubscribe first callback + * - change value + * - check that only second callback was executed + * - unsubscribe second callback + * - change value + * - check that both callbacks were not executed by changing the value + */ +TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeSequentially) { + + SubscribeUnsubscribeHandler subUnsubHandler; + + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk; + CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk; + + std::function<void (uint8_t)> callbackOk = std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1); + std::function<void (uint8_t)> callbackNotOk = std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1); + + bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId); + ASSERT_TRUE(serviceRegistered); + usleep(wt); + + // subscribe ok and notOk callback + subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk); + subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk); + + testStub_->setTestAttributeAttribute(12); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 12); + + // unsubscribe ok callback + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk); + + testStub_->setTestAttributeAttribute(14); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 14); + + // unsubscribe notOk callback + testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk); + + testStub_->setTestAttributeAttribute(16); + usleep(wt); + EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12); + EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 14); + + bool serviceUnregistered = runtime_->unregisterService(domain, v1_0::commonapi::communication::TestInterfaceStubDefault::StubInterface::getInterface(), testAddress); + ASSERT_TRUE(serviceUnregistered); + usleep(wt); } int main(int argc, char** argv) { diff --git a/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp b/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp index 88e7ff4..29ac109 100644 --- a/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp +++ b/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 BMW Group +/* Copyright (C) 2014-2015 BMW Group * Author: Juergen Gehring (juergen.gehring@bmw.de) * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -71,6 +71,75 @@ TEST_F(RTBuildProxiesAndStubs, LoadedRuntimeCanBuildProxiesAndStubs) { ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress)); } +/** +* @test Loads Runtime, creates proxy and stub/service two times. +* - Calls CommonAPI::Runtime::get() and checks if return value is true +* - Create stub and register service +* - Create proxy +* - Do some synchronous calls +* - Unregister the service. +* - Create stub and register service +* - Create proxy +* - Checks whether proxy is available +* - Unregister the service +*/ +TEST_F(RTBuildProxiesAndStubs, BuildProxiesAndStubsTwoTimes) { + + std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get(); + ASSERT_TRUE((bool)runtime); + + // first build sequence for proxy and stub + { + auto testStub = std::make_shared<v1_0::commonapi::runtime::TestInterfaceStubDefault>(); + ASSERT_TRUE((bool)testStub); + ASSERT_TRUE(runtime->registerService(domain,testAddress,testStub, applicationNameService)); + + auto testProxy = runtime->buildProxy<v1_0::commonapi::runtime::TestInterfaceProxy>(domain,testAddress, applicationNameClient); + ASSERT_TRUE((bool)testProxy); + testProxy->isAvailableBlocking(); + + std::cout << "Executing synchronous method calls (for approximately 30 seconds)" << std::endl; + for (int i = 0; i < 30; i++) { + CommonAPI::CallStatus callStatus; + testProxy->testMethod(callStatus); + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + usleep(1 * 1000 * 1000); + } + std::cout << std::endl; + + ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress)); + } + + // second build sequence for proxy and stub + { + auto testStub = std::make_shared<v1_0::commonapi::runtime::TestInterfaceStubDefault>(); + ASSERT_TRUE((bool)testStub); + ASSERT_TRUE(runtime->registerService(domain,testAddress,testStub, applicationNameService)); + + auto testProxy = runtime->buildProxy<v1_0::commonapi::runtime::TestInterfaceProxy>(domain,testAddress, applicationNameClient); + ASSERT_TRUE((bool)testProxy); + + int i = 0; + while( (i < 100) && (!testProxy->isAvailable()) ) { + if (0 == i) { + std::cout << "Wait for proxy available" << std::flush; + } + std::cout << "." << std::flush; + usleep(100 * 1000); + i++; + } + std::cout << std::endl; + + ASSERT_TRUE(testProxy->isAvailable()); + + usleep(5 * 1000 * 1000); + + ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress)); + } +} + + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); ::testing::AddGlobalTestEnvironment(new Environment()); diff --git a/org.genivi.commonapi.core.verification/src/StabilityMP.cpp b/org.genivi.commonapi.core.verification/src/StabilityMP.cpp index 92f61c4..cd19625 100644 --- a/org.genivi.commonapi.core.verification/src/StabilityMP.cpp +++ b/org.genivi.commonapi.core.verification/src/StabilityMP.cpp @@ -10,8 +10,13 @@ #include "v1_0/commonapi/stability/mp/ControlInterfaceProxy.hpp" #include "stub/StabControlStub.h" #include "stub/StabilityMPStub.h" + +#ifdef WIN32 +#include <Windows.h> +#else #include <unistd.h> #include <sys/wait.h> +#endif using namespace v1_0::commonapi::stability::mp; @@ -31,7 +36,13 @@ const int MAX_WAIT = 10000; const int N_TEST_PROXY_PROCESSES = 3; const int N_CHILDREN = 2 + 2 * N_TEST_PROXY_PROCESSES; // needs to be large enough to cover for all created processes + +#ifdef WIN32 +HANDLE childpids[N_CHILDREN]; +#else pid_t childpids[N_CHILDREN]; +#endif + bool idChild; bool controlServiceRegistered = false; std::shared_ptr<CommonAPI::Runtime> runtime_; @@ -134,7 +145,7 @@ public: success_ = true; break; } - usleep(10000); + usleep(20000); } } void pollForUnavailability(void) { @@ -514,7 +525,7 @@ TEST_F(Stability, ProxyCreation_ProxyFirst) { child->state = DEAD; } - + usleep(1 * 1000 * 1000); } TEST_F(Stability, ProxyCreation_ServerFirst) { @@ -601,6 +612,8 @@ TEST_F(Stability, ProxyCreation_ServerFirst) { child->next_cmd = KILL_YOURSELF; child->state = DEAD; } + + usleep(1 * 1000 * 1000); } int main(int argc, char ** argv) @@ -609,7 +622,12 @@ int main(int argc, char ** argv) /* forking is best done before the google test environment is set up */ bool isChild = false; for (int i = 0; i < N_CHILDREN; i++) { +#ifdef WIN32 + // TODO!!! + HANDLE child = 0; +#else pid_t child = fork(); +#endif if (child == 0) { isChild = true; break; diff --git a/org.genivi.commonapi.core.verification/src/StabilitySP.cpp b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp index 34059f8..3a1b42e 100644 --- a/org.genivi.commonapi.core.verification/src/StabilitySP.cpp +++ b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp @@ -22,7 +22,7 @@ const std::string domain = "local"; const std::string testAddress = "commonapi.stability.sp.TestInterface"; const std::string COMMONAPI_CONFIG_SUFFIX = ".conf"; const int MAXSERVERCOUNT = 40; -const int MAXTHREADCOUNT = 40; +const int MAXTHREADCOUNT = 8; const int MAXMETHODCALLS = 80; const int MAXREGLOOPS = 16; const int MAXREGCOUNT = 16; @@ -185,7 +185,7 @@ public: if (previousCount != asyncCounter) { break; } - usleep(10000); + usleep(10 * 1000); } if (previousCount == asyncCounter) { break; @@ -328,7 +328,9 @@ public: std::bind(&ProxyThread::recvValue, this, std::placeholders::_1, std::placeholders::_2); CommonAPI::CallStatus callStatus; - proxy->getTestAttributeAttribute().getValueAsync(myCallback); + CommonAPI::CallInfo* callInfo = new CommonAPI::CallInfo(30 * 1000); + + proxy->getTestAttributeAttribute().getValueAsync(myCallback, callInfo); return true; } bool exerciseSetAttributeAsync(std::shared_ptr<TestInterfaceProxy<>> proxy) { @@ -340,7 +342,9 @@ public: arrayTestValue.push_back((unsigned char)(messageindex & 0xFF)); } - proxy->getTestAttributeAttribute().setValueAsync(arrayTestValue, myCallback); + CommonAPI::CallInfo* callInfo = new CommonAPI::CallInfo(45 * 1000); + + proxy->getTestAttributeAttribute().setValueAsync(arrayTestValue, myCallback, callInfo); return true; } diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp index ae0ff52..db221c5 100644 --- a/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp +++ b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp @@ -21,6 +21,7 @@ const std::string instance7 = "my.test.commonapi.address.seven"; const std::string instance8 = "my.test.commonapi.address.eight"; const std::string mainloopName1 = "client-sample"; const std::string mainloopName2 = "service-sample"; +const std::string thirdPartyServiceId = "mainloop-thirdParty"; class PingPongTestStub : public v1_0::commonapi::threading::TestInterfaceStubDefault { virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, @@ -204,7 +205,7 @@ TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) { x = 1; y = 0; - std::thread mainLoopRunnerProxy([&]() { threadCtx1_.mainLoop_->runVerification(5, true, true); }); + std::thread mainLoopRunnerProxy([&]() { threadCtx1_.mainLoop_->runVerification(5000, true, true); }); mainLoopRunnerProxy.detach(); mainLoopThread1_ = std::thread([&]() { threadCtx1_.proxy_->testMethod(x, callStatus, y); }); @@ -217,7 +218,7 @@ TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) { mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); }); mainLoopThread2_.detach(); - sleep(1); + usleep(1000000); // now the stub mainloop also runs, so the proxy should receive the answer ASSERT_EQ(1, y); @@ -231,10 +232,11 @@ TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) { */ TEST_F(THMainLoopIndependence, ProxyReceivesJustHisOwnAnswers) { + usleep(1000000); + std::shared_ptr<PingPongTestStub> stubThirdParty = std::make_shared<PingPongTestStub>(); auto runtime = CommonAPI::Runtime::get(); - //ASSERT_TRUE(runtime->getServicePublisher()->registerService(stubThirdParty, testAddress6, runtime->createFactory())); - ASSERT_TRUE(runtime->registerService(domain, instance6, stubThirdParty)); + ASSERT_TRUE(runtime->registerService(domain, instance6, stubThirdParty, thirdPartyServiceId)); CommonAPI::CallStatus callStatusProxy1, callStatusProxy2; @@ -266,8 +268,6 @@ TEST_F(THMainLoopIndependence, ProxyReceivesJustHisOwnAnswers) { // now each proxy should have received the answer to his own request ASSERT_EQ(1, y1); ASSERT_EQ(2, y2); - - //sleep(1); } int main(int argc, char** argv) { diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp index 69b6fc0..489060e 100644 --- a/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp +++ b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp @@ -223,7 +223,7 @@ TEST_F(THMainLoopIntegration, VerifySyncCallMessageHandlingOrder) { usleep(10000); } - sleep(2); + usleep(2); if (mainLoopForStub_->isRunning()) { std::future<bool> stubStopped = mainLoopForStub_->stop(); diff --git a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp index f21554b..62a0115 100644 --- a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DTAdvancedStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp index 7d6460b..b5d2ee5 100644 --- a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DTDerivedStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp index c040e9a..f4cde9b 100644 --- a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "DTPrimitiveStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp index 35c390d..b512e70 100644 --- a/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/StabControlStub.cpp @@ -6,7 +6,10 @@ #include <iostream> #include "StabControlStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp index 482acbd..1468e8e 100644 --- a/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/StabilityMPStub.cpp @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "StabilityMPStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp index 59e89b6..472d39a 100644 --- a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp +++ b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp @@ -5,7 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "StabilitySPStub.h" + +#ifndef WIN32 #include <unistd.h> +#endif namespace v1_0 { namespace commonapi { diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h index 2d5b72b..52f7024 100644 --- a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h +++ b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h @@ -17,13 +17,18 @@ #include <vector> #include <set> #include <map> +#include <cassert> +#include <chrono> +#include <future> + +#ifdef WIN32 +#include <WinSock2.h> +#else #include <poll.h> #include <unistd.h> #include <sys/eventfd.h> -#include <cassert> -#include <chrono> #include <sys/time.h> -#include <future> +#endif const long maxTimeout = 10; @@ -39,7 +44,15 @@ class VerificationMainLoop { explicit VerificationMainLoop(std::shared_ptr<MainLoopContext> context) : context_(context), currentMinimalTimeoutInterval_(TIMEOUT_INFINITE), running_(false), breakLoop_(false), dispatchWatchesTooLong(false) { +#ifdef WIN32 + WSAEVENT wsaEvent = WSACreateEvent(); + + if (wsaEvent != WSA_INVALID_EVENT) { + wakeFd_.fd = PtrToInt(wsaEvent); + } +#else wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK); +#endif wakeFd_.events = POLLIN; assert(wakeFd_.fd != -1); @@ -68,7 +81,11 @@ class VerificationMainLoop { context_->unsubscribeForTimeouts(timeoutSourceListenerSubscription_); context_->unsubscribeForWakeupEvents(wakeupListenerSubscription_); +#ifdef WIN32 + WSACloseEvent(IntToPtr(wakeFd_.fd)); +#else close(wakeFd_.fd); +#endif delete stopPromise; } @@ -157,8 +174,10 @@ class VerificationMainLoop { int64_t dispatchTimeout = TIMEOUT_INFINITE; if(dispatchSourceIterator->second->prepare(dispatchTimeout)) { sourcesToDispatch_.insert(*dispatchSourceIterator); - } else if (dispatchTimeout < currentMinimalTimeoutInterval_) { - currentMinimalTimeoutInterval_ = dispatchTimeout; + } else if (dispatchTimeout != -1 || currentMinimalTimeoutInterval_ == TIMEOUT_INFINITE) { + if (dispatchTimeout < currentMinimalTimeoutInterval_) { + currentMinimalTimeoutInterval_ = dispatchTimeout; + } } } @@ -184,7 +203,17 @@ class VerificationMainLoop { (*fileDescriptor).revents = 0; } +#if WIN32 + INT currentMinimalTimeoutIntervalWin32_ = 1; + size_t numReadyFileDescriptors = ::WSAPoll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), currentMinimalTimeoutIntervalWin32_); + + if (numReadyFileDescriptors == SOCKET_ERROR) { + int iError = WSAGetLastError(); + //printf("WSAPoll failed with error: %ld\n", iError); + } +#else size_t numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), currentMinimalTimeoutInterval_); +#endif // If no FileDescriptors are ready, poll returned because of a timeout that has expired. // The only case in which this is not the reason is when the timeout handed in "prepare" @@ -246,8 +275,13 @@ class VerificationMainLoop { bool dispatchWatchesTooLong; void wakeup() { +#ifdef WIN32 + HANDLE h = IntToPtr(wakeFd_.fd); + SetEvent(h); +#else int64_t wake = 1; ::write(wakeFd_.fd, &wake, sizeof(int64_t)); +#endif } void dispatchTimeouts() { @@ -264,7 +298,7 @@ class VerificationMainLoop { watchIterator != watchesToDispatch_.end(); watchIterator++) { Watch* watch = watchIterator->second; - const unsigned int flags = 7; + const unsigned int flags = watch->getAssociatedFileDescriptor().events; watch->dispatch(flags); } } @@ -366,8 +400,13 @@ class VerificationMainLoop { } void acknowledgeWakeup() { +#ifdef WIN32 + HANDLE h = IntToPtr(wakeFd_.fd); + ResetEvent(h); +#else int64_t buffer; while (::read(wakeFd_.fd, &buffer, sizeof(int64_t)) == sizeof(buffer)); +#endif } std::shared_ptr<MainLoopContext> context_; diff --git a/org.genivi.commonapi.core/META-INF/MANIFEST.MF b/org.genivi.commonapi.core/META-INF/MANIFEST.MF index 87908ce..9063bd5 100644 --- a/org.genivi.commonapi.core/META-INF/MANIFEST.MF +++ b/org.genivi.commonapi.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: GENIVI Common API Generator Bundle-Vendor: BMW AG -Bundle-Version: 3.1.1.qualifier +Bundle-Version: 3.1.2.qualifier Bundle-SymbolicName: org.genivi.commonapi.core;singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)";visibility:=reexport, diff --git a/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl b/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl index acc6a62..65e038c 100644 --- a/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl +++ b/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl @@ -1,22 +1,14 @@ /* * Copyright (C) 2015 Bayerische Motoren Werke AG (BMW). - * Author: Manfred Bathelt (manfred.bathelt@bmw.de) - * Author: Juergen Gehring (juergen.gehring@bmw.de) * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Version 1.0 * - * - * CommonAPI C++ SOME/IP deployment for CommonAPI C++ 3.x - * Version: 1.0 - * - * Generic deployment specification for CommonAPI 3.x to be used by - * all CommonAPI code generation tools, e.g. - * CommonAPI-Tools - * CommonAPI-DBus-Tools - * CommonAPI-SOMEIP-Tools - * and all other CommonAPI language bindings compatible to CommonAPI C++ 3.x + * This is the Franca deployment specification to be used for CommonAPI C++ + * Core. */ specification org.genivi.commonapi.core.deployment { @@ -42,15 +34,15 @@ specification org.genivi.commonapi.core.deployment { * To avoid inconsistencies only domain and instance id can be specified during deployment, * while the interface id is fixed by the interface the instance realizes. */ - Domain : String (default: "local"); // the domain part of the CommonAPI address. + Domain : String (default: "local"); // the domain part of the CommonAPI address. InstanceId : String; // the instance id of the CommonAPI address. /* - * Define default timeout for all methods awaiting results of an instance in seconds. - * 0s means no timeout/waiting forever. - * if the timeout elapsed without arrival of a valid result an error will be delivered to the application. + * Define default timeout for all methods/getter/setter awaiting results of an instance in ms. + * -1 means no timeout/waiting forever. + * If the timeout elapsed without arrival of a valid result an error will be delivered to the application. */ - DefaultMethodTimeout : Integer (default:0); + DefaultTimeout : Integer (optional); /* * provide properties to register for instance. use "Name=Value" as format. @@ -61,12 +53,22 @@ specification org.genivi.commonapi.core.deployment { for methods { /* - * timeout for method calls in ns. - * If timeout is defined with value > 0, then a method call will return with a timeout error + * timeout for method calls in ms. + * If timeout is defined with a value > -1, then a method call will return with a timeout error + * in case no result arrived before the timeout elapsed. + * -1 means no timeout. + */ + Timeout : Integer (optional); + } + + for attributes { + /* + * timeout for setter/getter calls in ms. + * If timeout is defined with value > -1, then the call will return with a timeout error * in case no result arrived before the timeout elapsed. - * 0 means no timeout. + * -1 means no timeout. */ - Timeout : Integer (default: 0); + Timeout : Integer (optional); } for enumerations { diff --git a/org.genivi.commonapi.core/pom.xml b/org.genivi.commonapi.core/pom.xml index 9a43f72..380c30d 100644 --- a/org.genivi.commonapi.core/pom.xml +++ b/org.genivi.commonapi.core/pom.xml @@ -7,7 +7,7 @@ <parent> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.core.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <relativePath>../org.genivi.commonapi.core.releng</relativePath> </parent> </project> diff --git a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentInterfacePropertyAccessor.java b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentInterfacePropertyAccessor.java index bfe7c5b..27876b0 100644 --- a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentInterfacePropertyAccessor.java +++ b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentInterfacePropertyAccessor.java @@ -7,6 +7,7 @@ package org.genivi.commonapi.core; import org.franca.core.franca.FInterface; import org.franca.core.franca.FMethod; import org.franca.core.franca.FEnumerationType; +import org.franca.core.franca.FAttribute; import org.franca.deploymodel.core.FDeployedInterface; /** @@ -53,6 +54,10 @@ public class DeploymentInterfacePropertyAccessor return target.getInteger(obj, "Timeout"); } + public Integer getTimeout (FAttribute obj) { + return target.getInteger(obj, "Timeout"); + } + public enum EnumBackingType { UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 } diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend index 664b386..52c5fd3 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend @@ -166,8 +166,8 @@ class FInterfaceProxyGenerator { typedef «fInterface.getRelativeNameReference(fInterface)» InterfaceType; «IF fInterface.base != null» - inline static const char* getInterfaceId() { - return(«fInterface.elementName»::getInterfaceId()); + inline static const char* getInterface() { + return(«fInterface.elementName»::getInterface()); } «ENDIF» diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend index c03b058..7001423 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend @@ -15,11 +15,17 @@ import org.franca.core.franca.FAttribute import org.franca.core.franca.FInterface import org.genivi.commonapi.core.preferences.PreferenceConstants import org.genivi.commonapi.core.preferences.FPreferences +import java.util.HashMap +import org.franca.core.franca.FMethod class FInterfaceStubGenerator { @Inject private extension FTypeGenerator @Inject private extension FrancaGeneratorExtensions + var HashMap<String, Integer> counterMap; + var HashMap<FMethod, String> methodreplyMap; + + def generateStub(FInterface fInterface, IFileSystemAccess fileSystemAccess, IResource modelid) { fileSystemAccess.generateFile(fInterface.stubHeaderPath, PreferenceConstants.P_OUTPUT_STUBS, fInterface.generateStubHeader(modelid)) // should skeleton code be generated ? @@ -164,11 +170,13 @@ class FInterfaceStubGenerator { public virtual «fInterface.base.getTypeCollectionName(fInterface)»Stub«ENDIF» { public: - «FOR method: fInterface.methods» - «IF !method.isFireAndForget» - typedef std::function<void («method.generateStubReplySignature()»)> «method.elementName»Reply_t; - «ENDIF» - «ENDFOR» + «{counterMap = new HashMap<String, Integer>();""}» + «{methodreplyMap = new HashMap<FMethod, String>();""}» + «FOR method: fInterface.methods» + «IF !method.isFireAndForget» + «generateMethodReplyDeclarations(method, fInterface, counterMap, methodreplyMap)» + «ENDIF» + «ENDFOR» virtual ~«fInterface.stubClassName»() {} virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -182,7 +190,7 @@ class FInterfaceStubGenerator { «FOR method: fInterface.methods» «FTypeGenerator::generateComments(method, false)» /// This is the method that will be called on remote calls on the method «method.elementName». - virtual void «method.elementName»(«method.generateStubSignature») = 0; + virtual void «method.elementName»(«generateOverloadedStubSignature(method, methodreplyMap.get(method))») = 0; «ENDFOR» «FOR broadcast : fInterface.broadcasts» «FTypeGenerator::generateComments(broadcast, false)» @@ -223,6 +231,17 @@ class FInterfaceStubGenerator { #endif // «fInterface.defineName»_STUB_HPP_ ''' + def private generateMethodReplyDeclarations(FMethod fMethod, FInterface fInterface, HashMap<String, Integer> counterMap, HashMap<FMethod, String> methodreplyMap) ''' + «IF !(counterMap.containsKey(fMethod.elementName))» + «{counterMap.put(fMethod.elementName, 0); methodreplyMap.put(fMethod, fMethod.elementName);""}» + typedef std::function<void («fMethod.generateStubReplySignature()»)>«fMethod.elementName»Reply_t; + «ELSE» + «{counterMap.put(fMethod.elementName, counterMap.get(fMethod.elementName) + 1); methodreplyMap.put(fMethod, fMethod.elementName + counterMap.get(fMethod.elementName));""}» + typedef std::function<void («fMethod.generateStubReplySignature()»)>«methodreplyMap.get(fMethod)»Reply_t; + «ENDIF» + ''' + + def private generateStubDefaultHeader(FInterface fInterface, IResource modelid) ''' «generateCommonApiLicenseHeader(fInterface, modelid)» «FTypeGenerator::generateComments(fInterface, false)» @@ -271,7 +290,7 @@ class FInterfaceStubGenerator { «FOR method: fInterface.methods» «FTypeGenerator::generateComments(method, false)» - virtual void «method.elementName»(«method.generateStubSignature»); + virtual void «method.elementName»(«generateOverloadedStubSignature(method, methodreplyMap?.get(method))»); «ENDFOR» «FOR broadcast : fInterface.broadcasts» @@ -429,7 +448,7 @@ class FInterfaceStubGenerator { «FOR method : fInterface.methods» «FTypeGenerator::generateComments(method, false)» - void «fInterface.stubDefaultClassName»::«method.elementName»(«method.generateStubSignature») { + void «fInterface.stubDefaultClassName»::«method.elementName»(«generateOverloadedStubSignature(method, methodreplyMap?.get(method))») { «IF !method.isFireAndForget» «method.generateDummyArgumentDefinitions» _reply(«method.generateDummyArgumentList»); diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend index 8a70e41..b86b126 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend @@ -75,7 +75,7 @@ class FTypeGenerator { def private static findNextBreak(String text) { var breakIndex = text.substring(0, CommentLineLength).lastIndexOf(" "); - if (breakIndex > -1) { + if (breakIndex > 0) { return breakIndex; } else { return Math.min(CommentLineLength, text.length); @@ -102,7 +102,7 @@ class FTypeGenerator { } // TODO: Does this code offer additional functionality compared to breaktext ? - def static breaktext_(String text, int annotation) { + def static breaktext_(String text, FAnnotationType annotation) { var ret = "" var temptext = "" @@ -455,15 +455,44 @@ class FTypeGenerator { «val baseTypeName = _enumeration.getBaseType(backingType)» struct «_enumeration.name» : «baseTypeName» { + enum Literal : «backingType» { + «FOR enumerator : _enumeration.enumerators» + «enumPrefix»«enumerator.elementName» = «enumerator.value.enumeratorValue»«IF enumerator != _enumeration.enumerators.last»,«ENDIF» + «ENDFOR» + }; + «_enumeration.name»() = default; - «_enumeration.name»(const «backingType» &_value) - : «baseTypeName»(_value) {} - «FOR enumerator : _enumeration.enumerators» - «generateComments(enumerator, false)» - static const «backingType» «enumPrefix»«enumerator.elementName» = «enumerator.value.enumeratorValue»; - «ENDFOR» + «_enumeration.name»(const Literal &_value) + : «baseTypeName»(static_cast<«IF _enumeration.base == null»«backingType»«ELSE»«baseTypeName»::Literal«ENDIF»>(_value)) {} + «_enumeration.generateBaseTypeAssignmentOperator(_accessor)» + + inline bool operator==(const «_enumeration.name» &_other) const { return (value_ == _other.value_); } + inline bool operator!=(const «_enumeration.name» &_other) const { return (value_ != _other.value_); } + inline bool operator<=(const «_enumeration.name» &_other) const { return (value_ <= _other.value_); } + inline bool operator>=(const «_enumeration.name» &_other) const { return (value_ >= _other.value_); } + inline bool operator<(const «_enumeration.name» &_other) const { return (value_ < _other.value_); } + inline bool operator>(const «_enumeration.name» &_other) const { return (value_ > _other.value_); } + + inline bool operator==(const Literal &_value) const { return (value_ == static_cast<«backingType»>(_value)); } + inline bool operator!=(const Literal &_value) const { return (value_ != static_cast<«backingType»>(_value)); } + inline bool operator<=(const Literal &_value) const { return (value_ <= static_cast<«backingType»>(_value)); } + inline bool operator>=(const Literal &_value) const { return (value_ >= static_cast<«backingType»>(_value)); } + inline bool operator<(const Literal &_value) const { return (value_ < static_cast<«backingType»>(_value)); } + inline bool operator>(const Literal &_value) const { return (value_ > static_cast<«backingType»>(_value)); } }; ''' + + def generateBaseTypeAssignmentOperator(FEnumerationType _enumeration, PropertyAccessor _accessor) ''' + «IF _enumeration.base != null» + «val backingType = _enumeration.getBackingType(_accessor).primitiveTypeName» + «val baseTypeName = _enumeration.getBaseType(backingType)» + «_enumeration.name» &operator=(const «baseTypeName»::Literal &_value) { + value_ = static_cast<«backingType»>(_value); + return (*this); + } + «_enumeration.base.generateBaseTypeAssignmentOperator(_accessor)» + «ENDIF» + ''' def dispatch generateFTypeDeclaration(FUnionType fUnionType, PropertyAccessor deploymentAccessor) ''' «generateComments(fUnionType, false)» @@ -471,14 +500,16 @@ class FTypeGenerator { ''' def private String getElementNames(FUnionType fUnion) { - var names = ""; + var names = "" if (fUnion.base != null) { - names = fUnion.base.getElementNames - } - if (names != "") { - names = ", " + names + names += fUnion.base.getElementNames + if (names != "") { + names += ", " + } } - names = fUnion.elements.map[getTypeName(fUnion, false)].join(", ") + names + + names += fUnion.elements.map[getTypeName(fUnion, false)].join(", ") + return names } @@ -499,15 +530,6 @@ class FTypeGenerator { def dispatch generateFTypeImplementation(FArrayType fArrayType, FModelElement parent, PropertyAccessor _accessor) '''''' def dispatch generateFTypeImplementation(FMapType fMap, FModelElement parent, PropertyAccessor _accessor) '''''' def dispatch generateFTypeImplementation(FEnumerationType _enumeration, FModelElement _parent, PropertyAccessor _accessor) ''' - #ifndef WIN32 - «FOR enumerator : _enumeration.enumerators» - «IF _parent != null && _parent != _enumeration» - const «_enumeration.getBackingType(_accessor).primitiveTypeName» «_parent.elementName»::«_enumeration.name»::«enumPrefix + enumerator.elementName»; - «ELSE» - const «_enumeration.getBackingType(_accessor).primitiveTypeName» «_enumeration.name»::«enumPrefix + enumerator.elementName»; - «ENDIF» - «ENDFOR» - #endif ''' def dispatch generateFTypeImplementation(FStructType fStructType, FModelElement parent, PropertyAccessor _accessor) ''' @@ -696,15 +718,6 @@ class FTypeGenerator { "const " + destination.getTypeName(source, false) + " &_" + destination.elementName } - def private List<FField> getAllElements(FStructType fStructType) { - if (fStructType.base == null) - return new LinkedList(fStructType.elements) - - val elements = fStructType.base.allElements - elements.addAll(fStructType.elements) - return elements - } - //TODO: used? def generateInlineOperatorWithName(FEnumerationType fEnumerationType, String enumerationName, FEnumerationType base, FModelElement parent, String parentName, String operator, PropertyAccessor deploymentAccessor) ''' inline bool operator«operator»(const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& lhs, const «base.getClassNamespaceWithName(base.elementName, base.eContainer as FModelElement, (base.eContainer as FModelElement).elementName)»& rhs) { diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend index 0944894..1f7ccfc 100644 --- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend +++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend @@ -15,6 +15,7 @@ import java.util.ArrayList import java.util.Collection import java.util.HashMap import java.util.HashSet +import java.util.LinkedList import java.util.List import java.util.Map import java.util.Set @@ -30,16 +31,19 @@ import org.franca.core.franca.FArrayType import org.franca.core.franca.FAttribute import org.franca.core.franca.FBasicTypeId import org.franca.core.franca.FBroadcast +import org.franca.core.franca.FConstantDef import org.franca.core.franca.FEnumerationType import org.franca.core.franca.FEnumerator import org.franca.core.franca.FExpression import org.franca.core.franca.FField +import org.franca.core.franca.FInitializerExpression import org.franca.core.franca.FIntegerConstant import org.franca.core.franca.FInterface import org.franca.core.franca.FMapType import org.franca.core.franca.FMethod import org.franca.core.franca.FModel import org.franca.core.franca.FModelElement +import org.franca.core.franca.FQualifiedElementRef import org.franca.core.franca.FStringConstant import org.franca.core.franca.FStructType import org.franca.core.franca.FType @@ -60,9 +64,6 @@ import org.osgi.framework.FrameworkUtil import static com.google.common.base.Preconditions.* import static extension java.lang.Integer.* -import org.franca.core.franca.FConstantDef -import org.franca.core.franca.FQualifiedElementRef -import org.franca.core.franca.FInitializerExpression class FrancaGeneratorExtensions { @@ -413,6 +414,23 @@ class FrancaGeneratorExtensions { return signature } + + def generateOverloadedStubSignature(FMethod fMethod, String methodName) { + var signature = 'const std::shared_ptr<CommonAPI::ClientId> _client' + + if (!fMethod.inArgs.empty) + signature = signature + ', ' + + signature = signature + fMethod.inArgs.map[getTypeName(fMethod, true) + ' _' + elementName].join(', ') + + if (!fMethod.isFireAndForget) { + if (signature != "") + signature = signature + ", "; + signature = signature + methodName + "Reply_t _reply"; + } + + return signature + } def generateStubReplySignature(FMethod fMethod) { var signature = '' @@ -979,7 +997,6 @@ class FrancaGeneratorExtensions { // collect all predefined enum values for (literal : _enumeration.enumerators) { if (literal.value != null) { - System.out.println(literal.value) predefineEnumValues.add(literal.value.enumeratorValue) } } @@ -1064,8 +1081,8 @@ class FrancaGeneratorExtensions { def String generateCases(FStructType fStructType, FModelElement parent, boolean qualified) { var String itsCases = "case "; - if (parent != null) - itsCases = itsCases + parent.elementName + "::" + //if (parent != null) + // itsCases = itsCases + parent.elementName + "::" if (qualified) { itsCases = itsCases @@ -1611,10 +1628,10 @@ class FrancaGeneratorExtensions { var EObject container = _me.eContainer while (container != null && container != _until) { if (container instanceof FModel) { - name = container.name + "::" + name + name = container.containerName + "::" + name } if (container instanceof FModelElement) { - name = container.name + "::" + name + name = container.containerName + "::" + name } container = container.eContainer } @@ -1698,4 +1715,23 @@ class FrancaGeneratorExtensions { def String getEnumPrefix(){ FPreferences::instance.getPreference(PreferenceConstants::P_ENUMPREFIX, "") } + + def List<FField> getAllElements(FStructType _struct) { + if (_struct.base == null) + return new LinkedList(_struct.elements) + + val elements = _struct.base.allElements + elements.addAll(_struct.elements) + return elements + } + + def List<FField> getAllElements(FUnionType _union) { + if (_union.base == null) + return new LinkedList(_union.elements) + + val elements = _union.base.allElements + elements.addAll(_union.elements) + return elements + } + } diff --git a/org.genivi.commonapi.releng/pom.xml b/org.genivi.commonapi.releng/pom.xml index 9c673fb..8a660e6 100644 --- a/org.genivi.commonapi.releng/pom.xml +++ b/org.genivi.commonapi.releng/pom.xml @@ -3,7 +3,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>commonapi</groupId> <artifactId>org.genivi.commonapi.releng</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> <packaging>pom</packaging> <properties> <tycho-version>0.22.0</tycho-version> @@ -46,7 +46,7 @@ <artifact> <groupId>commonapi</groupId> <artifactId>${target.id}</artifactId> - <version>3.1.1-SNAPSHOT</version> + <version>3.1.2-SNAPSHOT</version> </artifact> </target> <filters> |