summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Huss <dirk_huss@mentor.com>2015-11-25 14:48:42 +0100
committerDirk Huss <dirk_huss@mentor.com>2015-11-25 14:49:50 +0100
commitee0a7727239fb3087fb0a25b41f55d907b935a2c (patch)
tree87bba07a8679ef219fd646c6532c80aeca6765df
parent9fbd805bbec9fa719251bf509034f1601001a514 (diff)
downloadgenivi-common-api-runtime-ee0a7727239fb3087fb0a25b41f55d907b935a2c.tar.gz
CommonAPI-Tools 3.1.43.1.4
-rw-r--r--CommonAPI-Examples/E01HelloWorld/CMakeLists.txt44
-rw-r--r--CommonAPI-Examples/E01HelloWorld/README2
-rw-r--r--CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl40
-rw-r--r--CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl18
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp32
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp22
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp6
-rw-r--r--CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp2
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-local.json100
-rw-r--r--CommonAPI-Examples/E01HelloWorld/vsomeip-service.json92
-rw-r--r--CommonAPI-Examples/E02Attributes/CMakeLists.txt46
-rw-r--r--CommonAPI-Examples/E02Attributes/README91
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl2
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl68
-rw-r--r--CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl28
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp37
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp14
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp8
-rw-r--r--CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp2
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-local.json152
-rw-r--r--CommonAPI-Examples/E02Attributes/vsomeip-service.json150
-rw-r--r--CommonAPI-Examples/E03Methods/CMakeLists.txt46
-rw-r--r--CommonAPI-Examples/E03Methods/README103
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl6
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl72
-rw-r--r--CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl42
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp4
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp10
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp6
-rw-r--r--CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp8
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-local.json132
-rw-r--r--CommonAPI-Examples/E03Methods/vsomeip-service.json130
-rw-r--r--CommonAPI-Examples/E04PhoneBook/CMakeLists.txt40
-rw-r--r--CommonAPI-Examples/E04PhoneBook/README85
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl198
-rw-r--r--CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl162
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp8
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp14
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp6
-rw-r--r--CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h6
-rw-r--r--CommonAPI-Examples/E04PhoneBook/vsomeip-client.json56
-rw-r--r--CommonAPI-Examples/E04PhoneBook/vsomeip-local.json110
-rw-r--r--CommonAPI-Examples/E04PhoneBook/vsomeip-service.json98
-rw-r--r--CommonAPI-Examples/E05Manager/CMakeLists.txt20
-rw-r--r--CommonAPI-Examples/E05Manager/README31
-rw-r--r--CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl94
-rw-r--r--CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl16
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp5
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h5
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp6
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp14
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h2
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp5
-rw-r--r--CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h5
-rw-r--r--CommonAPI-Examples/E05Manager/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E05Manager/vsomeip-local.json162
-rw-r--r--CommonAPI-Examples/E05Manager/vsomeip-service.json154
-rw-r--r--CommonAPI-Examples/E05Manager/vsomeip.json83
-rw-r--r--CommonAPI-Examples/E06Unions/CMakeLists.txt40
-rw-r--r--CommonAPI-Examples/E06Unions/README20
-rw-r--r--CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl84
-rw-r--r--CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl44
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp156
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp40
-rw-r--r--CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp8
-rw-r--r--CommonAPI-Examples/E06Unions/src/typeUtils.hpp4
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-local.json152
-rw-r--r--CommonAPI-Examples/E06Unions/vsomeip-service.json144
-rw-r--r--CommonAPI-Examples/E07Mainloop/CMakeLists.txt92
-rw-r--r--CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl52
-rw-r--r--CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl22
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp120
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp86
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp16
-rw-r--r--CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp2
-rw-r--r--CommonAPI-Examples/E07Mainloop/vsomeip-client.json48
-rw-r--r--CommonAPI-Examples/E07Mainloop/vsomeip-local.json90
-rw-r--r--CommonAPI-Examples/E07Mainloop/vsomeip-service.json92
-rw-r--r--CommonAPI-Examples/README2
-rw-r--r--docx/CommonAPICppUserGuide133
-rw-r--r--org.genivi.commonapi.console.feature/feature.xml4
-rw-r--r--org.genivi.commonapi.console.feature/pom.xml2
-rw-r--r--org.genivi.commonapi.console.franca.feature/feature.xml2
-rw-r--r--org.genivi.commonapi.console.franca.feature/pom.xml2
-rw-r--r--org.genivi.commonapi.console/META-INF/MANIFEST.MF2
-rw-r--r--org.genivi.commonapi.console/about.mappings4
-rw-r--r--org.genivi.commonapi.console/pom.xml2
-rw-r--r--org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandExecuter.java7
-rw-r--r--org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandlineTool.java233
-rw-r--r--org.genivi.commonapi.core.cli.feature/feature.xml2
-rw-r--r--org.genivi.commonapi.core.cli.feature/pom.xml2
-rw-r--r--org.genivi.commonapi.core.cli.product/category.xml4
-rw-r--r--org.genivi.commonapi.core.cli.product/commonapi_console.product2
-rw-r--r--org.genivi.commonapi.core.cli.product/pom.xml12
-rw-r--r--org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF6
-rw-r--r--org.genivi.commonapi.core.cli/plugin.xml64
-rw-r--r--org.genivi.commonapi.core.cli/pom.xml2
-rw-r--r--org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandLineHandler.java47
-rw-r--r--org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java462
-rw-r--r--org.genivi.commonapi.core.feature/feature.xml2
-rw-r--r--org.genivi.commonapi.core.feature/pom.xml2
-rw-r--r--org.genivi.commonapi.core.releng/pom.xml2
-rw-r--r--org.genivi.commonapi.core.target/pom.xml2
-rw-r--r--org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF8
-rw-r--r--org.genivi.commonapi.core.ui/plugin.xml32
-rw-r--r--org.genivi.commonapi.core.ui/pom.xml2
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java362
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java38
-rwxr-xr-xorg.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java129
-rwxr-xr-xorg.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties3
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineStringFieldEditor.java140
-rw-r--r--org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java11
-rw-r--r--org.genivi.commonapi.core.updatesite/category.xml4
-rw-r--r--org.genivi.commonapi.core.updatesite/pom.xml2
-rw-r--r--org.genivi.commonapi.core.validator.feature/feature.xml4
-rw-r--r--org.genivi.commonapi.core.validator.feature/pom.xml2
-rw-r--r--org.genivi.commonapi.core.validator/META-INF/MANIFEST.MF6
-rw-r--r--org.genivi.commonapi.core.validator/pom.xml2
-rw-r--r--org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ValidatorCoreUi.java20
-rw-r--r--org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/preferencepage/ValidatorCorePreferencesPage.java9
-rw-r--r--org.genivi.commonapi.core.verification/CMakeLists.txt444
-rw-r--r--org.genivi.commonapi.core.verification/README5
-rwxr-xr-xorg.genivi.commonapi.core.verification/build.sh17
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_advanced_bselective.fidl23
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_advanced_managed.fidl29
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_advanced_polymorph.fidl98
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_communication.fidl42
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl4
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl4
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl5
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl6
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl38
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl22
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl6
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl2
-rw-r--r--org.genivi.commonapi.core.verification/fidl/ti_threading.fidl24
-rw-r--r--org.genivi.commonapi.core.verification/src/AFManaged.cpp1255
-rw-r--r--org.genivi.commonapi.core.verification/src/AFPolymorph.cpp317
-rw-r--r--org.genivi.commonapi.core.verification/src/AFSelective.cpp442
-rw-r--r--org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp799
-rw-r--r--org.genivi.commonapi.core.verification/src/CMAttributes.cpp23
-rw-r--r--org.genivi.commonapi.core.verification/src/CMBroadcasts.cpp244
-rw-r--r--org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp36
-rw-r--r--org.genivi.commonapi.core.verification/src/DTAdvanced.cpp137
-rw-r--r--org.genivi.commonapi.core.verification/src/DTCombined.cpp11
-rw-r--r--org.genivi.commonapi.core.verification/src/DTDerived.cpp22
-rw-r--r--org.genivi.commonapi.core.verification/src/DTPrimitive.cpp44
-rw-r--r--org.genivi.commonapi.core.verification/src/PFComplex.cpp258
-rw-r--r--org.genivi.commonapi.core.verification/src/PFPrimitive.cpp187
-rw-r--r--org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp70
-rw-r--r--org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp4
-rw-r--r--org.genivi.commonapi.core.verification/src/StabilitySP.cpp533
-rw-r--r--org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp87
-rw-r--r--org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp74
-rw-r--r--org.genivi.commonapi.core.verification/src/THMainLoopTwoThreads.cpp144
-rw-r--r--org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in13
-rw-r--r--org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in13
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFManagedStub.cpp84
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFManagedStub.h44
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.cpp41
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.h32
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.cpp58
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.h35
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp4
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h6
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.cpp58
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.h32
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp10
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h6
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp5
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp7
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp15
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h7
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.cpp22
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.h21
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp16
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp18
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.cpp23
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.h22
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp13
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h8
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp12
-rw-r--r--org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h6
-rw-r--r--org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp22
-rw-r--r--org.genivi.commonapi.core.verification/src/utils/StopWatch.h54
-rw-r--r--org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h202
-rw-r--r--org.genivi.commonapi.core.verification/src/utils/VerificationMainLoopWithQueue.h322
-rw-r--r--org.genivi.commonapi.core/META-INF/MANIFEST.MF2
-rwxr-xr-x[-rw-r--r--]org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl16
-rw-r--r--org.genivi.commonapi.core/pom.xml2
-rw-r--r--org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentInterfacePropertyAccessor.java20
-rw-r--r--org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentProviderPropertyAccessor.java9
-rw-r--r--org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentTypeCollectionPropertyAccessor.java20
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/PropertyAccessor.java31
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java19
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend55
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceProxyGenerator.xtend56
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceStubGenerator.xtend169
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend24
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeGenerator.xtend260
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend352
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGeneratorExtensions.xtend316
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/GeneratorFileSystemAccess.java66
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/FPreferences.java26
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java34
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CommandlineValidator.java297
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CppKeywords.java2
-rw-r--r--org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/ValidatorCore.java23
-rw-r--r--org.genivi.commonapi.releng/pom.xml4
219 files changed, 10061 insertions, 4707 deletions
diff --git a/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt b/CommonAPI-Examples/E01HelloWorld/CMakeLists.txt
index 52e436a..1b2ef2b 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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -46,30 +46,30 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
set(PRJ_SRC_GEN_PATH src-gen)
-set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v0_1/commonapi/examples)
-set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v0_1/commonapi/examples)
-set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v0_1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v0/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v0/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
@@ -111,7 +111,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -119,7 +119,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E01HelloWorld/README b/CommonAPI-Examples/E01HelloWorld/README
index b48e6f2..f1ecf48 100644
--- a/CommonAPI-Examples/E01HelloWorld/README
+++ b/CommonAPI-Examples/E01HelloWorld/README
@@ -49,7 +49,7 @@ Here, you will need two includes in order to access the Common API client functi
#include <unistd.h>
#include <CommonAPI/CommonAPI.hpp>
-#include <v0_1/commonapi/examples/E01HelloWorldProxy.hpp>
+#include <v0/commonapi/examples/E01HelloWorldProxy.hpp>
----
Please note that you always have to include +CommonAPI.hpp+ for accessing the runtime part of CommonAPI and the generated proxy. If your defined interface has a version number then you will find the version in the namespace of your interface class and in the directory structure.
diff --git a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
index 0310e23..2475d8a 100644
--- a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
+++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fdepl
@@ -7,28 +7,28 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E01HelloWorld.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E01HelloWorld {
- SomeIpServiceID = 4660
+ SomeIpServiceID = 4660
- method sayHello {
- SomeIpMethodID = 33000
- SomeIpReliable = true
-
- in {
- name {
- SomeIpStringEncoding = utf16le
- }
- }
- }
+ method sayHello {
+ SomeIpMethodID = 33000
+ SomeIpReliable = true
+
+ in {
+ name {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E01HelloWorld {
- InstanceId = "commonapi.examples.HelloWorld"
-
- SomeIpInstanceID = 22136
-
- SomeIpUnicastAddress = "192.168.0.2"
- SomeIpReliableUnicastPort = 30499
- SomeIpUnreliableUnicastPort = 30499
- }
+ instance commonapi.examples.E01HelloWorld {
+ InstanceId = "commonapi.examples.HelloWorld"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30499
+ SomeIpUnreliableUnicastPort = 30499
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl
index d1360ba..fdb1231 100644
--- a/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl
+++ b/CommonAPI-Examples/E01HelloWorld/fidl/E01HelloWorld.fidl
@@ -6,14 +6,14 @@
package commonapi.examples
interface E01HelloWorld {
- version { major 0 minor 1 }
+ version { major 0 minor 1 }
- method sayHello {
- in {
- String name
- }
- out {
- String message
- }
- }
+ method sayHello {
+ in {
+ String name
+ }
+ out {
+ String message
+ }
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp
index 111fd5f..0b4622b 100644
--- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldClient.cpp
@@ -11,13 +11,13 @@
#endif
#include <CommonAPI/CommonAPI.hpp>
-#include <v0_1/commonapi/examples/E01HelloWorldProxy.hpp>
+#include <v0/commonapi/examples/E01HelloWorldProxy.hpp>
-using namespace v0_1::commonapi::examples;
+using namespace v0::commonapi::examples;
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E01C");
- CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
+ CommonAPI::Runtime::setProperty("LogContext", "E01C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
@@ -25,12 +25,12 @@ int main() {
std::string instance = "commonapi.examples.HelloWorld";
std::string connection = "client-sample";
- std::shared_ptr<E01HelloWorldProxy<>> myProxy = runtime->buildProxy<E01HelloWorldProxy>(domain,
- instance, connection);
+ std::shared_ptr<E01HelloWorldProxy<>> myProxy = runtime->buildProxy<E01HelloWorldProxy>(domain,
+ instance, connection);
std::cout << "Checking availability!" << std::endl;
while (!myProxy->isAvailable())
- usleep(10);
+ usleep(10);
std::cout << "Available..." << std::endl;
const std::string name = "World";
@@ -41,15 +41,15 @@ int main() {
info.sender_ = 1234;
while (true) {
- myProxy->sayHello(name, callStatus, returnMessage, &info);
- if (callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote call failed!\n";
- return -1;
- }
- info.timeout_ = info.timeout_ + 1000;
-
- std::cout << "Got message: '" << returnMessage << "'\n";
- std::this_thread::sleep_for(std::chrono::seconds(1));
+ myProxy->sayHello(name, callStatus, returnMessage, &info);
+ if (callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call failed!\n";
+ return -1;
+ }
+ info.timeout_ = info.timeout_ + 1000;
+
+ std::cout << "Got message: '" << returnMessage << "'\n";
+ std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
index 2fb7918..bf6c94d 100644
--- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldService.cpp
@@ -12,25 +12,25 @@
using namespace std;
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E01S");
- CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
+ CommonAPI::Runtime::setProperty("LogContext", "E01S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E01HelloWorld");
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.HelloWorld";
- std::string connection = "service-sample";
+ std::string instance = "commonapi.examples.HelloWorld";
+ std::string connection = "service-sample";
- std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
+ std::shared_ptr<E01HelloWorldStubImpl> myService = std::make_shared<E01HelloWorldStubImpl>();
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);
- }
+ 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;
+ 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/src/E01HelloWorldStubImpl.cpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp
index df13c01..7f02818 100644
--- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.cpp
@@ -12,10 +12,10 @@ E01HelloWorldStubImpl::~E01HelloWorldStubImpl() {
}
void E01HelloWorldStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client,
- std::string _name,
- sayHelloReply_t _reply) {
+ std::string _name,
+ sayHelloReply_t _reply) {
- std::stringstream messageStream;
+ std::stringstream messageStream;
messageStream << "Hello " << _name << "!";
std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
diff --git a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp
index 83a4112..da5ee1f 100644
--- a/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp
+++ b/CommonAPI-Examples/E01HelloWorld/src/E01HelloWorldStubImpl.hpp
@@ -7,7 +7,7 @@
#define E01HELLOWORLDSTUBIMPL_H_
#include <CommonAPI/CommonAPI.hpp>
-#include <v0_1/commonapi/examples/E01HelloWorldStubDefault.hpp>
+#include <v0/commonapi/examples/E01HelloWorldStubDefault.hpp>
class E01HelloWorldStubImpl: public v0_1::commonapi::examples::E01HelloWorldStubDefault {
diff --git a/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json
index 731852a..584fdb1 100644
--- a/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-client.json
@@ -1,26 +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"
- }
+ "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
index 2f4c823..07cd2f3 100644
--- a/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json
@@ -1,52 +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"
- }
+ "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
index 371ecf7..7d2aba9 100644
--- a/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json
+++ b/CommonAPI-Examples/E01HelloWorld/vsomeip-service.json
@@ -1,48 +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"
- }
+ "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 63eec7b..a3cd270 100644
--- a/CommonAPI-Examples/E02Attributes/CMakeLists.txt
+++ b/CommonAPI-Examples/E02Attributes/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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -46,30 +46,30 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
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_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
@@ -79,7 +79,7 @@ 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_CLIENT_SRCS ${PRJ_SRC_PATH}/${PRJ_NAME_CLIENT}.cpp ${PRJ_PROXY_GEN_SRCS} ${PRJ_TYPES_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} ${PRJ_TYPES_GEN_SRCS})
# Boost
@@ -112,7 +112,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -120,7 +120,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E02Attributes/README b/CommonAPI-Examples/E02Attributes/README
index 25c13ce..50f2ba0 100644
--- a/CommonAPI-Examples/E02Attributes/README
+++ b/CommonAPI-Examples/E02Attributes/README
@@ -67,49 +67,99 @@ Now see the implementation of the client. The simplest case is to get the curren
[source,{cppstr}]
----
-#include <iostream>
-#include <unistd.h>
-
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E02AttributesProxy.hpp>
+#include <CommonAPI/Extensions/AttributeCacheExtension.hpp>
+#include <v1/commonapi/examples/E02AttributesProxy.hpp>
+using namespace v1::commonapi::examples;
-#include "AttributeCacheExtension.hpp"
+template<typename _AttributeType>
+class AttrExt : public CommonAPI::Extensions::AttributeCacheExtension<_AttributeType>
+{
+public:
+ AttrExt(_AttributeType& baseAttribute) :
+ CommonAPI::Extensions::AttributeCacheExtension<_AttributeType>(baseAttribute) {
+ };
+};
+
+void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
+ std::cout << "Receive callback: " << val << std::endl;
+}
-using namespace v1_0::commonapi::examples;
+void recv_cb_s(const CommonAPI::CallStatus& callStatus, const CommonTypes::a1Struct& valStruct) {
+ std::cout << "Receive callback for structure: a1.s = " << valStruct.getS()
+ << ", valStruct.a2.b = " << (valStruct.getA2().getB() ? "TRUE" : "FALSE")
+ << ", valStruct.a2.d = " << valStruct.getA2().getD()
+ << std::endl;
+}
int main() {
-
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
- std::string domain = "local";
- std::string instance = "commonapi.examples.Attributes";
- std::shared_ptr<CommonAPI::DefaultAttributeProxyHelper<E02AttributesProxy,
- AttributeCacheExtension>::class_t> myProxy =
- runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy,
- AttributeCacheExtension>(domain, instance);
+ std::string domain = "local";
+ std::string instance = "commonapi.examples.Attributes";
+ std::string connection = "client-sample";
+ auto myProxy = runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttrExt>(domain, instance, connection);
+ std::cout << "Waiting for service to become available." << std::endl;
while (!myProxy->isAvailable()) {
usleep(10);
}
-
CommonAPI::CallStatus callStatus;
int32_t value = 0;
- myProxy->getXAttribute().getValue(callStatus, value);
+
+ CommonAPI::CallInfo info(1000);
+ info.sender_ = 5678;
+
+ // Get actual attribute value from service
+ std::cout << "Getting attribute value: " << value << std::endl;
+ myProxy->getXAttribute().getValue(callStatus, value, &info);
+ if (callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call A failed!\n";
+ return -1;
+ }
std::cout << "Got attribute value: " << value << std::endl;
+ // Subscribe for receiving values
myProxy->getXAttribute().getChangedEvent().subscribe([&](const int32_t& val) {
std::cout << "Received change message: " << val << std::endl;
});
+ myProxy->getA1Attribute().getChangedEvent().subscribe([&](const CommonTypes::a1Struct& val) {
+ std::cout << "Received change message for A1" << std::endl;
+ });
+
value = 100;
- std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
- myProxy->getXAttribute().setValueAsync(value, fcb);
- while (true) { usleep(1000000); }
+ // Asynchronous call to set attribute of service
+ std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
+ myProxy->getXAttribute().setValueAsync(value, fcb, &info);
+
+ // Asynchronous call to set attribute of type structure in service
+ CommonTypes::a1Struct valueStruct;
+
+ valueStruct.setS("abc");
+ CommonTypes::a2Struct a2Struct = valueStruct.getA2();
+ a2Struct.setA(123);
+ a2Struct.setB(true);
+ a2Struct.setD(1234);
+ valueStruct.setA2(a2Struct);
+
+ std::function<void(const CommonAPI::CallStatus&, CommonTypes::a1Struct)> fcb_s = recv_cb_s;
+ myProxy->getA1Attribute().setValueAsync(valueStruct, fcb_s, &info);
+
+ while (true) {
+ int32_t errorValue = -1;
+ int32_t valueCached = *myProxy->getXAttributeExtension().getCachedValue(errorValue);
+ if (valueCached != errorValue) {
+ std::cout << "Got cached attribute value[" << (int)valueCached << "]: " << valueCached << std::endl;
+ } else {
+ std::cout << "Got cached attribute error value[" << (int)valueCached << "]: " << valueCached << std::endl;
+ }
+ usleep(1000000);
+ }
}
----
-
The +getXAttribute+ method will deliver the type +XAttribute+ which has to be used for the access to +x+. Every access returns a flag named callStatus (please see the CommonAPI specification). Subscription requires in general the definition of a callback function which is called in case of an attribute change. The subscribe method of CommonAPI requires a function object; for a compact notation this function object can be defined as lambda function.
Of course it is also possible to define a separate callback function with an user-defined name (here recv_cb) as can be seen at the asynchronous set call for the attribute +x+:
@@ -123,8 +173,9 @@ void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
.... // main method
value = 100;
+// Asynchronous call to set attribute of service
std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
-myProxy->getXAttribute().setValueAsync(value, fcb);
+myProxy->getXAttribute().setValueAsync(value, fcb, &info);
----
This example uses a special feature of CommonAPI which is called _Attribute Extension_. This feature is described separately. At this point we do not want to go into more detail. Please see the source code of the example for a deeper insight.
diff --git a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl
index 9cadf7d..8026593 100644
--- a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-DBus.fdepl
@@ -7,5 +7,5 @@ import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_dep
import "E02Attributes.fidl"
define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E02Attributes {
- DBusDefaultAttributeType = freedesktop
+ 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
index 0afbaf0..4cf165c 100644
--- a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes-SomeIP.fdepl
@@ -7,48 +7,48 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
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 }
+ 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 {
- }
-
+ 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
- }
+ 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/fidl/E02Attributes.fidl b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl
index dd47949..e848a81 100644
--- a/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl
+++ b/CommonAPI-Examples/E02Attributes/fidl/E02Attributes.fidl
@@ -6,23 +6,23 @@
package commonapi.examples
interface E02Attributes {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- attribute Int32 x
- attribute CommonTypes.a1Struct a1
+ attribute Int32 x
+ attribute CommonTypes.a1Struct a1
}
typeCollection CommonTypes {
- version { major 1 minor 0 }
-
- struct a1Struct {
- String s
- a2Struct a2
- }
+ version { major 1 minor 0 }
+
+ struct a1Struct {
+ String s
+ a2Struct a2
+ }
- struct a2Struct {
- Int32 a
- Boolean b
- Double d
- }
+ struct a2Struct {
+ Int32 a
+ Boolean b
+ Double d
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
index 0ecaa7b..dbecb96 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesClient.cpp
@@ -10,11 +10,19 @@
#endif
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E02AttributesProxy.hpp>
+#include <CommonAPI/Extensions/AttributeCacheExtension.hpp>
+#include <v1/commonapi/examples/E02AttributesProxy.hpp>
-#include "AttributeCacheExtension.hpp"
+using namespace v1::commonapi::examples;
-using namespace v1_0::commonapi::examples;
+template<typename _AttributeType>
+class AttrExt : public CommonAPI::Extensions::AttributeCacheExtension<_AttributeType>
+{
+public:
+ AttrExt(_AttributeType& baseAttribute) :
+ CommonAPI::Extensions::AttributeCacheExtension<_AttributeType>(baseAttribute) {
+ };
+};
void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
std::cout << "Receive callback: " << val << std::endl;
@@ -22,8 +30,8 @@ void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
void recv_cb_s(const CommonAPI::CallStatus& callStatus, const CommonTypes::a1Struct& valStruct) {
std::cout << "Receive callback for structure: a1.s = " << valStruct.getS()
- << ", valStruct.a2.b = " << (valStruct.getA2().getB() ? "TRUE" : "FALSE")
- << ", valStruct.a2.d = " << valStruct.getA2().getD()
+ << ", valStruct.a2.b = " << (valStruct.getA2().getB() ? "TRUE" : "FALSE")
+ << ", valStruct.a2.d = " << valStruct.getA2().getD()
<< std::endl;
}
@@ -34,11 +42,10 @@ int main() {
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.Attributes";
- std::string connection = "client-sample";
+ 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, connection);
+ auto myProxy = runtime->buildProxyWithDefaultAttributeExtension<E02AttributesProxy, AttrExt>(domain, instance, connection);
std::cout << "Waiting for service to become available." << std::endl;
while (!myProxy->isAvailable()) {
@@ -90,9 +97,13 @@ int main() {
myProxy->getA1Attribute().setValueAsync(valueStruct, fcb_s, &info);
while (true) {
- int32_t valueCached = 0;
- bool r = myProxy->getXAttributeExtension().getCachedValue(valueCached);
- std::cout << "Got cached attribute value[" << (int)r << "]: " << valueCached << std::endl;
- usleep(1000000);
+ int32_t errorValue = -1;
+ int32_t valueCached = *myProxy->getXAttributeExtension().getCachedValue(errorValue);
+ if (valueCached != errorValue) {
+ std::cout << "Got cached attribute value[" << (int)valueCached << "]: " << valueCached << std::endl;
+ } else {
+ std::cout << "Got cached attribute error value[" << (int)valueCached << "]: " << valueCached << std::endl;
+ }
+ usleep(1000000);
}
}
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
index 8947414..584611a 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesService.cpp
@@ -16,16 +16,16 @@ int main() {
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::string instance = "commonapi.examples.Attributes";
+ std::string connection = "service-sample";
std::shared_ptr<E02AttributesStubImpl> myService = std::make_shared<E02AttributesStubImpl>();
- 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));
- }
+ 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;
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
myService->incCounter(); // Change value of attribute, see stub implementation
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp
index 2eb226c..5bed931 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.cpp
@@ -6,14 +6,14 @@
#include "E02AttributesStubImpl.hpp"
E02AttributesStubImpl::E02AttributesStubImpl() {
- cnt = 0;
+ cnt = 0;
}
E02AttributesStubImpl::~E02AttributesStubImpl() {
}
void E02AttributesStubImpl::incCounter() {
- cnt++;
- setXAttribute((int32_t)cnt);
- std::cout << "New counter value = " << cnt << "!" << std::endl;
+ cnt++;
+ setXAttribute((int32_t)cnt);
+ std::cout << "New counter value = " << cnt << "!" << std::endl;
}
diff --git a/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp
index 655a094..abb2959 100644
--- a/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp
+++ b/CommonAPI-Examples/E02Attributes/src/E02AttributesStubImpl.hpp
@@ -7,7 +7,7 @@
#define E02ATTRIBUTESSTUBIMPL_H_
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E02AttributesStubDefault.hpp>
+#include <v1/commonapi/examples/E02AttributesStubDefault.hpp>
class E02AttributesStubImpl: public v1_0::commonapi::examples::E02AttributesStubDefault {
diff --git a/CommonAPI-Examples/E02Attributes/vsomeip-client.json b/CommonAPI-Examples/E02Attributes/vsomeip-client.json
index 731852a..584fdb1 100644
--- a/CommonAPI-Examples/E02Attributes/vsomeip-client.json
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-client.json
@@ -1,26 +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"
- }
+ "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
index ac274e1..b96c1f6 100644
--- a/CommonAPI-Examples/E02Attributes/vsomeip-local.json
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-local.json
@@ -1,78 +1,78 @@
{
- "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",
- "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"
- }
+ "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",
+ "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/E02Attributes/vsomeip-service.json b/CommonAPI-Examples/E02Attributes/vsomeip-service.json
index 03d8979..199e954 100644
--- a/CommonAPI-Examples/E02Attributes/vsomeip-service.json
+++ b/CommonAPI-Examples/E02Attributes/vsomeip-service.json
@@ -1,77 +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"
- }
+ "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 98b8589..8d9c5bd 100644
--- a/CommonAPI-Examples/E03Methods/CMakeLists.txt
+++ b/CommonAPI-Examples/E03Methods/CMakeLists.txt
@@ -31,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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -48,30 +48,30 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
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_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
@@ -100,7 +100,7 @@ message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
src-gen/core
- src-gen/dbus
+ src-gen/dbus
src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
@@ -114,7 +114,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -122,7 +122,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E03Methods/README b/CommonAPI-Examples/E03Methods/README
index 70488d3..94130de 100644
--- a/CommonAPI-Examples/E03Methods/README
+++ b/CommonAPI-Examples/E03Methods/README
@@ -71,6 +71,7 @@ In the example there is another function incCounter implemented which sends the
void E03MethodsStubImpl::incCounter() {
cnt++;
fireMyStatusEvent((int32_t) cnt);
+ std::cout << "New counter value = " << cnt << "!" << std::endl;
}
----
@@ -82,60 +83,78 @@ The subscription to the broadcast is nearly identical to the subscription to the
#include <unistd.h>
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_2/commonapi/examples/E03MethodsProxy.hpp>
+#include <v1/commonapi/examples/E03MethodsProxy.hpp>
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 << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
+ << std::endl;
std::cout << " error: "
- << ((methodError.stdErrorTypeEnum ==
- E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" : "MY_FAULT")
- << std::endl;
-
+ << ((methodError == E03Methods::stdErrorTypeEnum::NO_FAULT) ? "NO_FAULT" :
+ "MY_FAULT") << std::endl;
std::cout << " Output values: y1 = " << y1 << ", y2 = " << y2 << std::endl;
}
int main() {
-
- // Subscribe to broadcast
- myProxy->getMyStatusEvent().subscribe([&](const int32_t& val) {
- std::cout << "Received status event: " << val << std::endl;
- });
-
- while(true) {
-
- int32_t inX1 = 5;
- std::string inX2 = "abc";
- CommonAPI::CallStatus callStatus;
- E03Methods::fooError methodError;
- int32_t outY1;
- std::string outY2;
-
- // Synchronous call
- std::cout << "Call foo with synchronous semantics ..." << std::endl ;
- myProxy->foo(inX1, inX2, callStatus, methodError, outY1, outY2);
-
- // Asynchronous call
- std::cout << "Call foo with asynchronous semantics ..." << std::endl;
-
- std::function<void (const CommonAPI::CallStatus&,
- const E03Methods::fooError&, const int32_t&, const std::string&)> fcb = recv_cb;
-
- myProxy->fooAsync(inX1, inX2, recv_cb);
-
- std::this_thread::sleep_for(std::chrono::seconds(5));
- }
- return 0;
+ 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, "client-sample");
+
+ while (!myProxy->isAvailable()) {
+ usleep(10);
+ }
+
+ // Subscribe to broadcast
+ myProxy->getMyStatusEvent().subscribe([&](const int32_t& val) {
+ std::cout << "Received status event: " << val << std::endl;
+ });
+
+ while (true) {
+ int32_t inX1 = 5;
+ std::string inX2 = "abc";
+ CommonAPI::CallStatus callStatus;
+ E03Methods::stdErrorTypeEnum methodError;
+ int32_t outY1;
+ std::string outY2;
+
+ // Synchronous call
+ std::cout << "Call foo with synchronous semantics ..." << std::endl;
+ myProxy->foo(inX1, inX2, callStatus, methodError, outY1, outY2);
+
+ std::cout << "Result of synchronous call of foo: " << std::endl;
+ std::cout << " callStatus: " << ((callStatus == CommonAPI::CallStatus::SUCCESS) ? "SUCCESS" : "NO_SUCCESS")
+ << std::endl;
+ std::cout << " error: "
+ << ((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;
+
+ // Asynchronous call
+ std::cout << "Call foo with asynchronous semantics ..." << std::endl;
+
+ std::function<
+ void(const CommonAPI::CallStatus&,
+ const E03Methods::stdErrorTypeEnum&,
+ const int32_t&,
+ const std::string&)> fcb = recv_cb;
+ myProxy->fooAsync(inX1, inX2, recv_cb);
+
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ }
+
+ return 0;
}
----
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl
index 560f1a9..2729fea 100644
--- a/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-DBus.fdepl
@@ -2,7 +2,7 @@ import "platform:/plugin/org.genivi.commonapi.dbus/deployment/CommonAPI-DBus_dep
import "E03Methods.fidl"
define org.genivi.commonapi.dbus.deployment for interface commonapi.examples.E03Methods {
- method foo {
- Timeout = 1234
- }
+ 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
index 6782105..2620684 100644
--- a/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods-SomeIP.fdepl
@@ -7,47 +7,47 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E03Methods.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E03Methods {
- SomeIpServiceID = 4660
+ SomeIpServiceID = 4660
- method foo {
- SomeIpMethodID = 33000
- SomeIpReliable = false
-
- in {
- x2 {
- SomeIpStringEncoding = utf16le
- }
- }
- out {
- y2 {
- SomeIpStringEncoding = utf16le
- }
- }
- }
-
- broadcast myStatus {
- SomeIpEventID = 33010
- SomeIpEventGroups = { 33010 }
+ 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 {
- }
- }
+ 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"
+ instance commonapi.examples.E03Methods {
+ InstanceId = "commonapi.examples.Methods"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30500
SomeIpUnreliableUnicastPort = 30501
}
diff --git a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
index f0963cd..1cb49d3 100644
--- a/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
+++ b/CommonAPI-Examples/E03Methods/fidl/E03Methods.fidl
@@ -9,28 +9,28 @@ package commonapi.examples
interface E03Methods {
- version { major 1 minor 2 }
+ version { major 1 minor 2 }
- method foo {
- in {
- Int32 x1
- String x2
- }
- out {
- Int32 y1
- String y2
- }
- error stdErrorTypeEnum
- }
+ method foo {
+ in {
+ Int32 x1
+ String x2
+ }
+ out {
+ Int32 y1
+ String y2
+ }
+ error stdErrorTypeEnum
+ }
- broadcast myStatus {
- out {
- Int32 myCurrentValue
- }
- }
+ broadcast myStatus {
+ out {
+ Int32 myCurrentValue
+ }
+ }
- enumeration stdErrorTypeEnum {
- NO_FAULT
- MY_FAULT
- }
+ enumeration stdErrorTypeEnum {
+ NO_FAULT
+ MY_FAULT
+ }
}
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
index 8d58060..0c9b558 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsClient.cpp
@@ -12,7 +12,7 @@
#endif
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_2/commonapi/examples/E03MethodsProxy.hpp>
+#include <v1/commonapi/examples/E03MethodsProxy.hpp>
using namespace v1_2::commonapi::examples;
@@ -36,7 +36,7 @@ int main() {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.Methods";
+ std::string instance = "commonapi.examples.Methods";
std::shared_ptr<E03MethodsProxy<>> myProxy = runtime->buildProxy < E03MethodsProxy > (domain, instance, "client-sample");
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
index a57e46b..f4be7e1 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsService.cpp
@@ -18,14 +18,14 @@ int main() {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.Methods";
+ std::string instance = "commonapi.examples.Methods";
std::shared_ptr<E03MethodsStubImpl> myService = std::make_shared<E03MethodsStubImpl>();
- while (!runtime->registerService(domain, instance, myService, "service-sample")) {
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
+ while (!runtime->registerService(domain, instance, myService, "service-sample")) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
- std::cout << "Successfully Registered Service!" << std::endl;
+ 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 b3b0afa..1d0607d 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.cpp
@@ -24,9 +24,9 @@ void E03MethodsStubImpl::incCounter() {
;
void E03MethodsStubImpl::foo(const std::shared_ptr<CommonAPI::ClientId> _client,
- int32_t _x1,
- std::string _x2,
- fooReply_t _reply) {
+ int32_t _x1,
+ std::string _x2,
+ fooReply_t _reply) {
std::cout << "foo called, setting new values." << std::endl;
diff --git a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp
index 3afdbe8..eba07fa 100644
--- a/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp
+++ b/CommonAPI-Examples/E03Methods/src/E03MethodsStubImpl.hpp
@@ -9,7 +9,7 @@
#define E03METHODSSTUBIMPL_H_
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_2/commonapi/examples/E03MethodsStubDefault.hpp>
+#include <v1/commonapi/examples/E03MethodsStubDefault.hpp>
class E03MethodsStubImpl: public v1_2::commonapi::examples::E03MethodsStubDefault {
@@ -18,9 +18,9 @@ public:
virtual ~E03MethodsStubImpl();
virtual void incCounter();
virtual void foo(const std::shared_ptr<CommonAPI::ClientId> _client,
- int32_t _x1,
- std::string _x2,
- fooReply_t _reply);
+ int32_t _x1,
+ std::string _x2,
+ fooReply_t _reply);
private:
int cnt;
diff --git a/CommonAPI-Examples/E03Methods/vsomeip-client.json b/CommonAPI-Examples/E03Methods/vsomeip-client.json
index f6d7414..bd77149 100644
--- a/CommonAPI-Examples/E03Methods/vsomeip-client.json
+++ b/CommonAPI-Examples/E03Methods/vsomeip-client.json
@@ -1,26 +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"
- }
+ "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
index bda9e87..fbc1194 100644
--- a/CommonAPI-Examples/E03Methods/vsomeip-local.json
+++ b/CommonAPI-Examples/E03Methods/vsomeip-local.json
@@ -1,68 +1,68 @@
{
- "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",
- "events" :
- [
- {
- "event" : "0x80F2",
- "is_field" : "false",
- "is_reliable" : "false",
- "update-cycle" : 2000
- }
- ],
- "eventgroups" :
- [
- {
- "eventgroup" : "0x80F2",
- "events" : [ "0x80F2" ]
- }
- ]
- }
- ]
- }
- ],
- "routing" : "service-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "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",
+ "events" :
+ [
+ {
+ "event" : "0x80F2",
+ "is_field" : "false",
+ "is_reliable" : "false",
+ "update-cycle" : 2000
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x80F2",
+ "events" : [ "0x80F2" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "routing" : "service-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
index 1418e71..0f4996a 100644
--- a/CommonAPI-Examples/E03Methods/vsomeip-service.json
+++ b/CommonAPI-Examples/E03Methods/vsomeip-service.json
@@ -1,67 +1,67 @@
{
- "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
- }
- ],
- "eventgroups" :
- [
- {
- "eventgroup" : "0x80F2",
- "events" : [ "0x80F2" ]
- }
- ]
- }
- ]
- }
- ],
- "routing" : "service-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "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
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x80F2",
+ "events" : [ "0x80F2" ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "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 78758de..750dec7 100644
--- a/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
+++ b/CommonAPI-Examples/E04PhoneBook/CMakeLists.txt
@@ -31,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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -48,23 +48,23 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
@@ -100,7 +100,7 @@ message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
src-gen/core
- src-gen/dbus
+ src-gen/dbus
src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
@@ -114,7 +114,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -122,7 +122,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E04PhoneBook/README b/CommonAPI-Examples/E04PhoneBook/README
index 431351a..497af83 100644
--- a/CommonAPI-Examples/E04PhoneBook/README
+++ b/CommonAPI-Examples/E04PhoneBook/README
@@ -169,50 +169,83 @@ On client side we create two proxies which shall set different filters and get d
[source,{cppstr}]
----
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";
+ const std::string &connection = "client-sample";
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyA =
- runtime->buildProxy < E04PhoneBookProxy > (domain, instance);
-
- while (!myProxyA->isAvailable()) { usleep(10); }
+ std::shared_ptr < E04PhoneBookProxy<> > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, connection);
+ while (!myProxyA->isAvailable()) {
+ usleep(10);
+ }
+ std::cout << "Service for Proxy A is available!" << std::endl;
- const CommonAPI::ConnectionId_t otherConnectionId = "42";
+ const CommonAPI::ConnectionId_t otherConnection = "other-client-sample";
+ std::shared_ptr < E04PhoneBookProxy<> > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnection);
+ while (!myProxyB->isAvailable()) {
+ usleep(10);
+ }
+ std::cout << "Service for Proxy B is available!" << std::endl;
- std::shared_ptr < E04PhoneBookProxyDefault > myProxyB =
- runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId);
-
- while (!myProxyB->isAvailable()) { usleep(10); }
+ // Subscribe A to broadcast
+ myProxyA->getPhoneBookDataSetSelectiveEvent().subscribe(
+ [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
+ std::cout << "-- A --" << std::endl;
+ printFilterResult(phoneBookDataSet, "A");
+ std::cout << "-------" << std::endl;
+ });
- myProxyA->getPhoneBookDataSetSelectiveEvent().subscribe([&](
- const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
- printFilterResult(phoneBookDataSet, "A");});
+ std::cout << "Subscribed A" << std::endl;
- myProxyB->getPhoneBookDataSetSelectiveEvent().subscribe([&](
- const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
- printFilterResult(phoneBookDataSet, "B");});
+ // Subscribe B to broadcast
+ myProxyB->getPhoneBookDataSetSelectiveEvent().subscribe(
+ [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) {
+ std::cout << "-- B --" << std::endl;
+ printFilterResult(phoneBookDataSet, "B");
+ std::cout << "-------" << std::endl;
+ });
+ std::cout << "Subscribed B" << std::endl;
+
+ // Get actual phoneBook from service
CommonAPI::CallStatus myCallStatus;
std::vector<E04PhoneBook::phoneBookStruct> myValue;
myProxyA->getPhoneBookAttribute().getValue(myCallStatus, myValue);
- printPhoneBook (myValue);
+ if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
+ std::cerr << "Remote call getPhoneBookAttribute failed!\n";
+ else
+ printPhoneBook (myValue);
+
+ // Synchronous call setPhoneBookDataFilter
+ std::cout << "Call setPhoneBookDataFilter A ..." << std::endl;
+ E04PhoneBook::elementFilterStruct lElementFilterA = {true, true, false, false, false, false};
+ std::vector<E04PhoneBook::contentFilterStruct> lContentFilterA = { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
- E04PhoneBook::elementFilterStruct lElementFilterA =
- {true, true, false, false, false, false};
- std::vector<E04PhoneBook::contentFilterStruct> lContentFilterA =
- { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
myProxyA->setPhoneBookDataFilter(lElementFilterA, lContentFilterA, myCallStatus);
+ if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
+ std::cerr << "Remote call setPhoneBookDataFilter A failed: " << (int) myCallStatus << std::endl;
+ else
+ std::cout << "Remote call setPhoneBookDataFilter A succeeded." << std::endl;
- E04PhoneBook::elementFilterStruct lElementFilterB =
- {true, false, false, false, false, true};
- std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB =
- { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
- myProxyB->setPhoneBookDataFilter(lElementFilterB, lContentFilterB, myCallStatus);
+ std::cout << "Call setPhoneBookDataFilter B ..." << std::endl;
+ E04PhoneBook::elementFilterStruct lElementFilterB = {true, false, false, false, false, true};
+ std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB = { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
- while (true) { std::this_thread::sleep_for(std::chrono::seconds(5)); }
+ myProxyB->setPhoneBookDataFilter(lElementFilterB, lContentFilterB, myCallStatus);
+ if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
+ std::cerr << "Remote call setPhoneBookDataFilter B failed: " << (int) myCallStatus << std::endl;
+ else
+ std::cout << "Remote call setPhoneBookDataFilter B succeeded." << std::endl;
+
+ while (true) {
+ std::cout << "Now I am going to sleep for 5 seconds..." << std::endl;
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ }
return 0;
}
----
diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl
index 1ca64c2..472b585 100644
--- a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook-SomeIP.fdepl
@@ -7,110 +7,110 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E04PhoneBook.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E04PhoneBook {
- SomeIpServiceID = 4660
- SomeIpEventGroups = { 7000, 7001 }
-
- attribute phoneBook {
- SomeIpGetterID = 33000
- SomeIpSetterID = 33001
- SomeIpNotifierID = 8000
- SomeIpEventGroups = { 7000 }
- }
-
- method setPhoneBookDataFilter {
- SomeIpMethodID = 33002
- }
-
- broadcast phoneBookDataSet {
- SomeIpEventID = 8001
- SomeIpEventGroups = { 7001 }
- }
-
- 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 {
- }
- }
+ SomeIpServiceID = 4660
+ SomeIpEventGroups = { 7000, 7001 }
+
+ attribute phoneBook {
+ SomeIpGetterID = 33000
+ SomeIpSetterID = 33001
+ SomeIpNotifierID = 8000
+ SomeIpEventGroups = { 7000 }
+ }
+
+ method setPhoneBookDataFilter {
+ SomeIpMethodID = 33002
+ }
+
+ broadcast phoneBookDataSet {
+ SomeIpEventID = 8001
+ SomeIpEventGroups = { 7001 }
+ }
+
+ 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"
+ instance commonapi.examples.E04PhoneBook {
+ InstanceId = "commonapi.examples.PhoneBook"
- SomeIpInstanceID = 22136
-
- SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30491
SomeIpUnreliableUnicastPort = 30492
}
diff --git a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl
index c22fd77..06c57d0 100644
--- a/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl
+++ b/CommonAPI-Examples/E04PhoneBook/fidl/E04PhoneBook.fidl
@@ -8,85 +8,85 @@
package commonapi.examples
interface E04PhoneBook {
- version { major 0 minor 0 }
-
- <** @description : the phone book itself **>
- attribute phoneBookStruct [] phoneBook readonly
-
- <** @description : filter operations **>
- method setPhoneBookDataFilter {
- in {
- elementFilterStruct elementFilter
- contentFilterStruct [] contentFilter
- }
- }
-
- <** @description : filter result **>
- broadcast phoneBookDataSet selective {
- out {
- phoneBookDataElementMap [] phoneBookDataSet
- }
- }
-
- <** @description : Data types of the phone book itself **>
- enumeration phoneNumberEnum {
- WORK
- HOME
- MOBILE1
- MOBILE2
- }
-
- map phoneNumberMap {
- phoneNumberEnum to String
- }
-
- struct phoneBookStruct {
- String name
- String forename
- String organisation
- String address
- String email
- phoneNumberMap phoneNumber
- }
-
- <** @description : Data types for the filter operations **>
-
- struct elementFilterStruct {
- Boolean addName
- Boolean addForename
- Boolean addOrganisation
- Boolean addAddress
- Boolean addEmail
- Boolean addPhoneNumber
- }
-
- struct contentFilterStruct {
- phoneBookDataElementEnum element
- String expression
- }
-
- <** @description : Data types for the result of the phone book filter **>
- enumeration phoneBookDataElementEnum {
- NAME
- FORENAME
- ORGANISATION
- ADDRESS
- EMAIL
- PHONENUMBER
- }
-
- struct phoneBookDataElement polymorphic {
- }
-
- struct phoneBookDataElementString extends phoneBookDataElement {
- String content
- }
-
- struct phoneBookDataElementPhoneNumber extends phoneBookDataElement {
- phoneNumberMap content
- }
-
- map phoneBookDataElementMap {
- phoneBookDataElementEnum to phoneBookDataElement
- }
+ version { major 0 minor 0 }
+
+ <** @description : the phone book itself **>
+ attribute phoneBookStruct [] phoneBook readonly
+
+ <** @description : filter operations **>
+ method setPhoneBookDataFilter {
+ in {
+ elementFilterStruct elementFilter
+ contentFilterStruct [] contentFilter
+ }
+ }
+
+ <** @description : filter result **>
+ broadcast phoneBookDataSet selective {
+ out {
+ phoneBookDataElementMap [] phoneBookDataSet
+ }
+ }
+
+ <** @description : Data types of the phone book itself **>
+ enumeration phoneNumberEnum {
+ WORK
+ HOME
+ MOBILE1
+ MOBILE2
+ }
+
+ map phoneNumberMap {
+ phoneNumberEnum to String
+ }
+
+ struct phoneBookStruct {
+ String name
+ String forename
+ String organisation
+ String address
+ String email
+ phoneNumberMap phoneNumber
+ }
+
+ <** @description : Data types for the filter operations **>
+
+ struct elementFilterStruct {
+ Boolean addName
+ Boolean addForename
+ Boolean addOrganisation
+ Boolean addAddress
+ Boolean addEmail
+ Boolean addPhoneNumber
+ }
+
+ struct contentFilterStruct {
+ phoneBookDataElementEnum element
+ String expression
+ }
+
+ <** @description : Data types for the result of the phone book filter **>
+ enumeration phoneBookDataElementEnum {
+ NAME
+ FORENAME
+ ORGANISATION
+ ADDRESS
+ EMAIL
+ PHONENUMBER
+ }
+
+ struct phoneBookDataElement polymorphic {
+ }
+
+ struct phoneBookDataElementString extends phoneBookDataElement {
+ String content
+ }
+
+ struct phoneBookDataElementPhoneNumber extends phoneBookDataElement {
+ phoneNumberMap content
+ }
+
+ map phoneBookDataElementMap {
+ phoneBookDataElementEnum to phoneBookDataElement
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
index 7db3313..0a56ee5 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp
@@ -191,9 +191,9 @@ int main() {
if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
std::cerr << "Remote call setPhoneBookDataFilter A failed: " << (int) myCallStatus << std::endl;
else
- std::cout << "Remote call setPhoneBookDataFilter A succeeded." << std::endl;
+ std::cout << "Remote call setPhoneBookDataFilter A succeeded." << std::endl;
- std::cout << "Call setPhoneBookDataFilter B ..." << std::endl;
+ std::cout << "Call setPhoneBookDataFilter B ..." << std::endl;
E04PhoneBook::elementFilterStruct lElementFilterB = {true, false, false, false, false, true};
std::vector<E04PhoneBook::contentFilterStruct> lContentFilterB = { {E04PhoneBook::phoneBookDataElementEnum::NAME, "*"}};
@@ -201,10 +201,10 @@ int main() {
if (myCallStatus != CommonAPI::CallStatus::SUCCESS)
std::cerr << "Remote call setPhoneBookDataFilter B failed: " << (int) myCallStatus << std::endl;
else
- std::cout << "Remote call setPhoneBookDataFilter B succeeded." << std::endl;
+ std::cout << "Remote call setPhoneBookDataFilter B succeeded." << std::endl;
while (true) {
- std::cout << "Now I am going to sleep for 5 seconds..." << std::endl;
+ std::cout << "Now I am going to sleep for 5 seconds..." << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5));
}
return 0;
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
index 020209b..7decc7c 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp
@@ -24,15 +24,15 @@ int main() {
std::shared_ptr<E04PhoneBookStubImpl> myService = std::make_shared<E04PhoneBookStubImpl>();
myService->setPhoneBookAttribute(myService->createTestPhoneBook());
- bool successfullyRegistered = 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);
- }
+ 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;
+ 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/E04PhoneBook/src/E04PhoneBookStubImpl.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp
index bfd06bb..f4f11f3 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.cpp
@@ -40,9 +40,9 @@ void E04PhoneBookStubImpl::onPhoneBookDataSetSelectiveSubscriptionChanged(const
}
void E04PhoneBookStubImpl::setPhoneBookDataFilter(const std::shared_ptr<CommonAPI::ClientId> _client,
- E04PhoneBook::elementFilterStruct _elementFilter,
- std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
- setPhoneBookDataFilterReply_t _reply) {
+ E04PhoneBook::elementFilterStruct _elementFilter,
+ std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
+ setPhoneBookDataFilterReply_t _reply) {
std::shared_ptr < CommonAPI::ClientIdList > clientList = getSubscribersForPhoneBookDataSetSelective();
std::cout << "setPhoneBookDataFilter called from client " << _client->hashCode() << " of ("
<< clientList->size() << ")" << std::endl;
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h
index 38fce08..a7259aa 100644
--- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h
+++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookStubImpl.h
@@ -26,9 +26,9 @@ public:
const CommonAPI::SelectiveBroadcastSubscriptionEvent);
void setPhoneBookDataFilter(const std::shared_ptr<CommonAPI::ClientId> _client,
- E04PhoneBook::elementFilterStruct _elementFilter,
- std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
- setPhoneBookDataFilterReply_t _reply);
+ E04PhoneBook::elementFilterStruct _elementFilter,
+ std::vector<E04PhoneBook::contentFilterStruct> _contentFilter,
+ setPhoneBookDataFilterReply_t _reply);
private:
std::unordered_map<std::shared_ptr<CommonAPI::ClientId>, std::vector<E04PhoneBook::phoneBookDataElementMap>> phoneBookClientData;
diff --git a/CommonAPI-Examples/E04PhoneBook/vsomeip-client.json b/CommonAPI-Examples/E04PhoneBook/vsomeip-client.json
index f3f9cd8..6ad0351 100644
--- a/CommonAPI-Examples/E04PhoneBook/vsomeip-client.json
+++ b/CommonAPI-Examples/E04PhoneBook/vsomeip-client.json
@@ -1,30 +1,30 @@
{
- "unicast" : "10.10.46.59",
- "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"
- },
- {
- "name" : "other-client-sample",
- "id" : "0x1344"
- }
- ],
- "routing" : "client-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "unicast" : "10.10.46.59",
+ "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"
+ },
+ {
+ "name" : "other-client-sample",
+ "id" : "0x1344"
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E04PhoneBook/vsomeip-local.json b/CommonAPI-Examples/E04PhoneBook/vsomeip-local.json
index d03051d..f7a08d2 100644
--- a/CommonAPI-Examples/E04PhoneBook/vsomeip-local.json
+++ b/CommonAPI-Examples/E04PhoneBook/vsomeip-local.json
@@ -1,47 +1,47 @@
{
- "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" : "other-client-sample",
- "id" : "0x1482"
- },
- {
- "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",
- "events" :
+ "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" : "other-client-sample",
+ "id" : "0x1482"
+ },
+ {
+ "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",
+ "events" :
[
{
"event" : "0x1F40",
@@ -65,16 +65,16 @@
"events" : [ "0x1F41" ]
}
]
- }
- ]
- }
- ],
- "routing" : "client-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E04PhoneBook/vsomeip-service.json b/CommonAPI-Examples/E04PhoneBook/vsomeip-service.json
index 3d05bb9..2cb2ef1 100644
--- a/CommonAPI-Examples/E04PhoneBook/vsomeip-service.json
+++ b/CommonAPI-Examples/E04PhoneBook/vsomeip-service.json
@@ -1,50 +1,50 @@
{
- "unicast" : "10.10.46.59",
- "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",
- "events" :
+ "unicast" : "10.10.46.59",
+ "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",
+ "events" :
[
{
"event" : "0x1F40",
"is_field" : "true",
- "is_reliable" : "true",
+ "is_reliable" : "true",
"update-cycle" : "0"
},
{
"event" : "0x1F41",
"is_field" : "false",
- "is_reliable" : "true",
+ "is_reliable" : "true",
"update-cycle" : "0"
}
],
@@ -59,16 +59,16 @@
"events" : [ "0x1F41" ]
}
]
- }
- ]
- }
- ],
- "routing" : "service-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E05Manager/CMakeLists.txt b/CommonAPI-Examples/E05Manager/CMakeLists.txt
index c3d2a88..1bad474 100644
--- a/CommonAPI-Examples/E05Manager/CMakeLists.txt
+++ b/CommonAPI-Examples/E05Manager/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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -61,15 +61,15 @@ else()
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
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_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
@@ -119,7 +119,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E05Manager/README b/CommonAPI-Examples/E05Manager/README
index 66bd9a0..9e96299 100644
--- a/CommonAPI-Examples/E05Manager/README
+++ b/CommonAPI-Examples/E05Manager/README
@@ -80,7 +80,7 @@ The functions for the special device has been omitted for clarity.The implementa
#include <iostream>
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E05ManagerProxy.hpp>
+#include <v1/commonapi/examples/E05ManagerProxy.hpp>
using namespace v1_0::commonapi::examples;
@@ -97,28 +97,35 @@ void newDeviceAvailable(const std::string address,
}
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);
-
- while (!myProxy->isAvailable()) { usleep(10); }
+ const std::string connectionIdClient = "client-sample";
+
+ std::shared_ptr<E05ManagerProxy<>> myProxy = runtime->buildProxy<E05ManagerProxy>(domain, instance, connectionIdClient);
+ while (!myProxy->isAvailable()) {
+ usleep(10);
+ }
+
+ std::cout << "Proxy available." << std::endl;
CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& deviceEvent =
- myProxy->getProxyManagerE05Device().getInstanceAvailabilityStatusChangedEvent();
-
- /* special device analogously */
+ myProxy->getProxyManagerE05Device().getInstanceAvailabilityStatusChangedEvent();
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& specialDeviceEvent =
+ myProxy->getProxyManagerE05SpecialDevice().getInstanceAvailabilityStatusChangedEvent();
- std::function<void(const std::string, const CommonAPI::AvailabilityStatus)>
- newDeviceAvailableFunc = newDeviceAvailable;
+ std::function<void(const std::string, const CommonAPI::AvailabilityStatus)> newDeviceAvailableFunc = newDeviceAvailable;
deviceEvent.subscribe(newDeviceAvailableFunc);
specialDeviceEvent.subscribe(newDeviceAvailableFunc);
- while (true) { std::this_thread::sleep_for(std::chrono::seconds(5)); }
+ while (true) {
+ std::this_thread::sleep_for(std::chrono::seconds(5));
+ }
return 0;
}
----
diff --git a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl
index 628f18a..92cc8f0 100644
--- a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl
+++ b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fdepl
@@ -7,73 +7,73 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E05Manager.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Manager {
- SomeIpServiceID = 4660
+ SomeIpServiceID = 4660
- attribute myDevices {
- SomeIpGetterID = 3000
- SomeIpSetterID = 3001
- SomeIpNotifierID = 33000
- SomeIpEventGroups = { 17749 }
- }
+ attribute myDevices {
+ SomeIpGetterID = 3000
+ SomeIpSetterID = 3001
+ SomeIpNotifierID = 33000
+ SomeIpEventGroups = { 17749 }
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E05Manager {
- InstanceId = "commonapi.examples.Manager"
-
- SomeIpInstanceID = 1000
-
- SomeIpUnicastAddress = "127.0.0.1"
- SomeIpReliableUnicastPort = 30499
- }
+ instance commonapi.examples.E05Manager {
+ InstanceId = "commonapi.examples.Manager"
+
+ SomeIpInstanceID = 1000
+
+ SomeIpUnicastAddress = "127.0.0.1"
+ SomeIpReliableUnicastPort = 30499
+ }
}
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05Device {
- SomeIpServiceID = 4661
+ SomeIpServiceID = 4661
- method doSomething {
- SomeIpMethodID = 33001
- }
+ method doSomething {
+ SomeIpMethodID = 33001
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E05Device {
- InstanceId = "commonapi.examples.Manager.device01"
-
- SomeIpInstanceID = 2000
-
- SomeIpUnicastAddress = "127.0.0.1"
- SomeIpUnreliableUnicastPort = 30500
- }
+ instance commonapi.examples.E05Device {
+ InstanceId = "commonapi.examples.Manager.device01"
+
+ SomeIpInstanceID = 2000
+
+ SomeIpUnicastAddress = "127.0.0.1"
+ SomeIpUnreliableUnicastPort = 30500
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E05Device {
- InstanceId = "commonapi.examples.Manager.device02"
-
- SomeIpInstanceID = 2001
-
- SomeIpUnicastAddress = "127.0.0.1"
- SomeIpUnreliableUnicastPort = 30501
- }
+ instance commonapi.examples.E05Device {
+ InstanceId = "commonapi.examples.Manager.device02"
+
+ SomeIpInstanceID = 2001
+
+ SomeIpUnicastAddress = "127.0.0.1"
+ SomeIpUnreliableUnicastPort = 30501
+ }
}
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E05SpecialDevice {
- SomeIpServiceID = 4662
+ SomeIpServiceID = 4662
- method doSomethingSpecial {
- SomeIpMethodID = 33002
- }
+ method doSomethingSpecial {
+ SomeIpMethodID = 33002
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E05SpecialDevice {
- InstanceId = "commonapi.examples.Manager.specialDevice00"
-
- SomeIpInstanceID = 3000
-
- SomeIpUnicastAddress = "127.0.0.1"
- SomeIpUnreliableUnicastPort = 30600
- }
+ instance commonapi.examples.E05SpecialDevice {
+ InstanceId = "commonapi.examples.Manager.specialDevice00"
+
+ SomeIpInstanceID = 3000
+
+ SomeIpUnicastAddress = "127.0.0.1"
+ SomeIpUnreliableUnicastPort = 30600
+ }
}
diff --git a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl
index ff020b0..5e4fc43 100644
--- a/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl
+++ b/CommonAPI-Examples/E05Manager/fidl/E05Manager.fidl
@@ -8,22 +8,22 @@
package commonapi.examples
interface E05Manager manages E05Device, E05SpecialDevice {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- attribute String [] myDevices
+ attribute String [] myDevices
}
interface E05Device {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- method doSomething {
- }
+ method doSomething {
+ }
}
interface E05SpecialDevice extends E05Device {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- method doSomethingSpecial {
- }
+ method doSomethingSpecial {
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp
index 80bc2be..7100a1a 100644
--- a/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.cpp
@@ -15,6 +15,9 @@ E05DeviceStubImpl::E05DeviceStubImpl() {
E05DeviceStubImpl::~E05DeviceStubImpl() {
}
-void E05DeviceStubImpl::doSomething() {
+void E05DeviceStubImpl::doSomething(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingReply_t _reply) {
std::cout << "E05DeviceStubImpl::doSomething() called." << std::endl;
+ _reply();
}
diff --git a/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h
index 7b1932f..da44f27 100644
--- a/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05DeviceStubImpl.h
@@ -8,7 +8,7 @@
#ifndef E05DEVICESTUBIMPL_H_
#define E05DEVICESTUBIMPL_H_
-#include <v1_0/commonapi/examples/E05DeviceStubDefault.hpp>
+#include <v1/commonapi/examples/E05DeviceStubDefault.hpp>
using namespace v1_0::commonapi::examples;
@@ -16,7 +16,8 @@ class E05DeviceStubImpl: public E05DeviceStubDefault {
public:
E05DeviceStubImpl();
virtual ~E05DeviceStubImpl();
- void doSomething();
+ void doSomething(const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingReply_t _reply);
};
#endif /* E05DEVICESTUBIMPL_H_ */
diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
index 51c7d57..1266a6f 100644
--- a/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerClient.cpp
@@ -12,7 +12,7 @@
#include <iostream>
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E05ManagerProxy.hpp>
+#include <v1/commonapi/examples/E05ManagerProxy.hpp>
using namespace v1_0::commonapi::examples;
@@ -27,8 +27,8 @@ void newDeviceAvailable(const std::string address, const CommonAPI::Availability
}
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E05C");
- CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager");
+ CommonAPI::Runtime::setProperty("LogContext", "E05C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E05Manager");
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
index a1626c3..e9720c3 100644
--- a/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerService.cpp
@@ -24,15 +24,15 @@ int main() {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::shared_ptr<E05ManagerStubImpl> myService = std::make_shared < E05ManagerStubImpl > (managerInstanceName);
- bool successfullyRegistered = runtime->registerService("local", managerInstanceName, myService, connectionIdService);
+ bool successfullyRegistered = runtime->registerService("local", managerInstanceName, myService, connectionIdService);
- 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, connectionIdService);
- }
+ 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, connectionIdService);
+ }
- std::cout << "Successfully Registered Service!" << std::endl;
+ std::cout << "Successfully Registered Service!" << std::endl;
while (true) {
// Simulate external events
diff --git a/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h
index 94be54d..fd0605a 100644
--- a/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05ManagerStubImpl.h
@@ -11,7 +11,7 @@
#include <map>
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E05ManagerStubDefault.hpp>
+#include <v1/commonapi/examples/E05ManagerStubDefault.hpp>
#include "E05DeviceStubImpl.h"
#include "E05SpecialDeviceStubImpl.h"
diff --git a/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp
index f31710c..34a62a0 100644
--- a/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp
+++ b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.cpp
@@ -15,6 +15,9 @@ E05SpecialDeviceStubImpl::E05SpecialDeviceStubImpl() {
E05SpecialDeviceStubImpl::~E05SpecialDeviceStubImpl() {
}
-void E05SpecialDeviceStubImpl::doSomethingSpecial() {
+void E05SpecialDeviceStubImpl::doSomethingSpecial(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingSpecialReply_t _reply) {
std::cout << "E05SpecialDeviceStubImpl::doSomethingSpecial() called." << std::endl;
+ _reply();
}
diff --git a/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h
index 0649ac5..3d89eaa 100644
--- a/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h
+++ b/CommonAPI-Examples/E05Manager/src/E05SpecialDeviceStubImpl.h
@@ -8,7 +8,7 @@
#ifndef E05SPECIALDEVICESTUBIMPL_H_
#define E05SPECIALDEVICESTUBIMPL_H_
-#include <v1_0/commonapi/examples/E05SpecialDeviceStubDefault.hpp>
+#include <v1/commonapi/examples/E05SpecialDeviceStubDefault.hpp>
using namespace v1_0::commonapi::examples;
@@ -17,7 +17,8 @@ public:
E05SpecialDeviceStubImpl();
virtual ~E05SpecialDeviceStubImpl();
- void doSomethingSpecial();
+ void doSomethingSpecial(const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingSpecialReply_t _reply);
};
#endif /* E05SPECIALDEVICESTUBIMPL_H_ */
diff --git a/CommonAPI-Examples/E05Manager/vsomeip-client.json b/CommonAPI-Examples/E05Manager/vsomeip-client.json
index 628509d..83a2b82 100644
--- a/CommonAPI-Examples/E05Manager/vsomeip-client.json
+++ b/CommonAPI-Examples/E05Manager/vsomeip-client.json
@@ -1,26 +1,26 @@
{
- "unicast" : "10.10.46.59",
- "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"
- }
+ "unicast" : "10.10.46.59",
+ "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/E05Manager/vsomeip-local.json b/CommonAPI-Examples/E05Manager/vsomeip-local.json
index 9e94d50..1d3c80b 100644
--- a/CommonAPI-Examples/E05Manager/vsomeip-local.json
+++ b/CommonAPI-Examples/E05Manager/vsomeip-local.json
@@ -1,83 +1,83 @@
{
- "unicast" : "127.0.0.1",
- "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" : "0x03e8",
- "unreliable" : "30499",
- "events" :
- [
- {
- "event" : "0x80e8",
- "is_field" : "true"
- }
- ],
- "eventgroups" :
- [
- {
- "eventgroup" : "0x4555",
- "events" :
- [
- "0x80e8"
- ]
- }
- ]
- },
- {
- "service" : "0x1235",
- "instance" : "0x07d0",
- "unreliable" : "30500"
- },
- {
- "service" : "0x1235",
- "instance" : "0x07d1",
- "unreliable" : "30501"
- },
- {
- "service" : "0x1236",
- "instance" : "0x0bb8",
- "unreliable" : "30600"
- }
- ]
- }
- ],
- "routing" : "client-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "unicast" : "127.0.0.1",
+ "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" : "0x03e8",
+ "unreliable" : "30499",
+ "events" :
+ [
+ {
+ "event" : "0x80e8",
+ "is_field" : "true"
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4555",
+ "events" :
+ [
+ "0x80e8"
+ ]
+ }
+ ]
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d0",
+ "unreliable" : "30500"
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d1",
+ "unreliable" : "30501"
+ },
+ {
+ "service" : "0x1236",
+ "instance" : "0x0bb8",
+ "unreliable" : "30600"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E05Manager/vsomeip-service.json b/CommonAPI-Examples/E05Manager/vsomeip-service.json
index 5e1a4b0..3cdfae8 100644
--- a/CommonAPI-Examples/E05Manager/vsomeip-service.json
+++ b/CommonAPI-Examples/E05Manager/vsomeip-service.json
@@ -1,79 +1,79 @@
{
- "unicast" : "10.10.46.59",
- "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" : "0x03e8",
- "unreliable" : "30499",
- "events" :
- [
- {
- "event" : "0x80e8",
- "is_field" : "true"
- }
- ],
- "eventgroups" :
- [
- {
- "eventgroup" : "0x4555",
- "events" :
- [
- "0x80e8"
- ]
- }
- ]
- },
- {
- "service" : "0x1235",
- "instance" : "0x07d0",
- "unreliable" : "30500"
- },
- {
- "service" : "0x1235",
- "instance" : "0x07d1",
- "unreliable" : "30501"
- },
- {
- "service" : "0x1236",
- "instance" : "0x0bb8",
- "unreliable" : "30600"
- }
- ]
- }
- ],
- "routing" : "service-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "unicast" : "10.10.46.59",
+ "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" : "0x03e8",
+ "unreliable" : "30499",
+ "events" :
+ [
+ {
+ "event" : "0x80e8",
+ "is_field" : "true"
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4555",
+ "events" :
+ [
+ "0x80e8"
+ ]
+ }
+ ]
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d0",
+ "unreliable" : "30500"
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d1",
+ "unreliable" : "30501"
+ },
+ {
+ "service" : "0x1236",
+ "instance" : "0x0bb8",
+ "unreliable" : "30600"
+ }
+ ]
+ }
+ ],
+ "routing" : "service-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E05Manager/vsomeip.json b/CommonAPI-Examples/E05Manager/vsomeip.json
new file mode 100644
index 0000000..1d3c80b
--- /dev/null
+++ b/CommonAPI-Examples/E05Manager/vsomeip.json
@@ -0,0 +1,83 @@
+{
+ "unicast" : "127.0.0.1",
+ "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" : "0x03e8",
+ "unreliable" : "30499",
+ "events" :
+ [
+ {
+ "event" : "0x80e8",
+ "is_field" : "true"
+ }
+ ],
+ "eventgroups" :
+ [
+ {
+ "eventgroup" : "0x4555",
+ "events" :
+ [
+ "0x80e8"
+ ]
+ }
+ ]
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d0",
+ "unreliable" : "30500"
+ },
+ {
+ "service" : "0x1235",
+ "instance" : "0x07d1",
+ "unreliable" : "30501"
+ },
+ {
+ "service" : "0x1236",
+ "instance" : "0x0bb8",
+ "unreliable" : "30600"
+ }
+ ]
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
+}
diff --git a/CommonAPI-Examples/E06Unions/CMakeLists.txt b/CommonAPI-Examples/E06Unions/CMakeLists.txt
index 6f3f207..193f805 100644
--- a/CommonAPI-Examples/E06Unions/CMakeLists.txt
+++ b/CommonAPI-Examples/E06Unions/CMakeLists.txt
@@ -31,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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -48,23 +48,23 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# Source Files
set(PRJ_SRC_PATH src)
@@ -100,7 +100,7 @@ message(STATUS "USE_INSTALLED_DBUS is set to value: ${USE_INSTALLED_DBUS}")
include_directories(
src-gen/core
- src-gen/dbus
+ src-gen/dbus
src-gen/someip
${COMMONAPI_INCLUDE_DIRS}
${COMMONAPI_DBUS_INCLUDE_DIRS}
@@ -114,7 +114,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -122,7 +122,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E06Unions/README b/CommonAPI-Examples/E06Unions/README
index c4f1884..5ea025c 100644
--- a/CommonAPI-Examples/E06Unions/README
+++ b/CommonAPI-Examples/E06Unions/README
@@ -141,15 +141,23 @@ int main() {
const std::string &domain = "local";
const std::string &instance = "commonapi.examples.Unions";
- std::shared_ptr<E06UnionsProxyDefault> myProxy =
- runtime->buildProxy<E06UnionsProxy>(domain, instance);
+ std::string connection = "client-sample";
- while (!myProxy->isAvailable()) { usleep(10); }
+ std::shared_ptr<E06UnionsProxy<>> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance, connection);
- std::function<void (CommonTypes::SettingsUnion)> f = recv_msg;
- myProxy->getUAttribute().getChangedEvent().subscribe(f);
+ while (!myProxy->isAvailable()) {
+ usleep(10);
+ }
+
+ std::function<void (CommonTypes::SettingsUnion)> f = recv_msg;
+ myProxy->getUAttribute().getChangedEvent().subscribe(f);
- while (true) { usleep(10); }
+ std::function<void (std::shared_ptr<CommonTypes::SettingsStruct>)> f1 = recv_msg1;
+ myProxy->getXAttribute().getChangedEvent().subscribe(f1);
+
+ while (true) {
+ usleep(10);
+ }
return 0;
}
diff --git a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl
index 67f27ed..f434ee7 100644
--- a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl
+++ b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fdepl
@@ -7,67 +7,67 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E06Unions.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E06Unions {
- SomeIpServiceID = 4660
- SomeIpEventGroups = { 7000, 7001 }
+ 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 }
- }
+ 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 {
- }
+
+ union SettingsUnion {
+ id {
+ }
+ status {
+ }
+ channel {
+ }
+ name {
+ }
+ }
+
+ struct SettingsStructMyTypedef {
+ id {
+ }
}
struct SettingsStructMyEnum {
- status {
- }
+ status {
+ }
}
struct SettingsStructUInt8 {
- channel {
- }
+ channel {
+ }
}
struct SettingsStructString {
- name {
- }
+ name {
+ }
}
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E06Unions {
- InstanceId = "commonapi.examples.Unions"
+ instance commonapi.examples.E06Unions {
+ InstanceId = "commonapi.examples.Unions"
- SomeIpInstanceID = 22136
-
- SomeIpUnicastAddress = "192.168.0.2"
- SomeIpReliableUnicastPort = 30490
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30490
SomeIpUnreliableUnicastPort = 30491
}
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl
index 60dae9d..262d5eb 100644
--- a/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl
+++ b/CommonAPI-Examples/E06Unions/fidl/E06Unions.fidl
@@ -8,46 +8,46 @@
package commonapi.examples
interface E06Unions {
- version { major 0 minor 0 }
+ version { major 0 minor 0 }
- attribute CommonTypes.SettingsUnion u
- attribute CommonTypes.SettingsStruct x
+ attribute CommonTypes.SettingsUnion u
+ attribute CommonTypes.SettingsStruct x
}
typeCollection CommonTypes {
- version { major 0 minor 0 }
+ version { major 0 minor 0 }
- typedef MyTypedef is Int32
+ typedef MyTypedef is Int32
- enumeration MyEnum {
- DEFAULT
- ON
- OFF
- }
+ enumeration MyEnum {
+ DEFAULT
+ ON
+ OFF
+ }
- union SettingsUnion {
- MyTypedef id
- MyEnum status
- UInt8 channel
- String name
- }
-
- struct SettingsStruct polymorphic {
+ union SettingsUnion {
+ MyTypedef id
+ MyEnum status
+ UInt8 channel
+ String name
+ }
+
+ struct SettingsStruct polymorphic {
}
struct SettingsStructMyTypedef extends SettingsStruct {
- MyTypedef id
+ MyTypedef id
}
struct SettingsStructMyEnum extends SettingsStruct {
- MyEnum status
+ MyEnum status
}
struct SettingsStructUInt8 extends SettingsStruct {
- UInt8 channel
+ UInt8 channel
}
struct SettingsStructString extends SettingsStruct {
- String name
+ String name
}
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
index ea6618a..8998ac8 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsClient.cpp
@@ -19,162 +19,162 @@ using namespace commonapi::examples;
struct MyVisitor {
- explicit inline MyVisitor() {
- }
+ explicit inline MyVisitor() {
+ }
- template<typename... T>
- inline void eval(const CommonAPI::Variant<T...>& v) {
- CommonAPI::ApplyVoidVisitor<MyVisitor, CommonAPI::Variant<T...>, T...>::visit(*this, v);
- }
+ template<typename... T>
+ inline void eval(const CommonAPI::Variant<T...>& v) {
+ CommonAPI::ApplyVoidVisitor<MyVisitor, CommonAPI::Variant<T...>, T...>::visit(*this, v);
+ }
- void operator()(CommonTypes::MyTypedef val) {
+ void operator()(CommonTypes::MyTypedef val) {
- std::cout << "Received (C) MyTypedef with value " << (int)val << std::endl;
- }
+ std::cout << "Received (C) MyTypedef with value " << (int)val << std::endl;
+ }
- void operator()(CommonTypes::MyEnum val) {
+ void operator()(CommonTypes::MyEnum val) {
- std::cout << "Received (C) MyEnum with value " << (int)val << std::endl;
- }
+ std::cout << "Received (C) MyEnum with value " << (int)val << std::endl;
+ }
- void operator()(uint8_t val) {
+ void operator()(uint8_t val) {
- std::cout << "Received (C) uint8_t with value " << (int)val << std::endl;
- }
+ std::cout << "Received (C) uint8_t with value " << (int)val << std::endl;
+ }
- void operator()(std::string val) {
+ void operator()(std::string val) {
- std::cout << "Received (C) string " << val << std::endl;
- }
+ std::cout << "Received (C) string " << val << std::endl;
+ }
- template<typename T>
- void operator()(const T&) {
+ template<typename T>
+ void operator()(const T&) {
- std::cout << "Received (C) change message with unknown type." << std::endl;
- }
+ std::cout << "Received (C) change message with unknown type." << std::endl;
+ }
- void operator()() {
+ void operator()() {
- std::cout << "NOOP." << std::endl;
- }
+ std::cout << "NOOP." << std::endl;
+ }
};
void evalA (const CommonTypes::SettingsUnion& v) {
- if ( v.isType<CommonTypes::MyTypedef>() ) {
+ if ( v.isType<CommonTypes::MyTypedef>() ) {
- std::cout << "Received (A) MyTypedef with value " << v.get<CommonTypes::MyTypedef>() << " at index " << (int)v.getValueType() << std::endl;
+ std::cout << "Received (A) MyTypedef with value " << v.get<CommonTypes::MyTypedef>() << " at index " << (int)v.getValueType() << std::endl;
- } else if ( v.isType<CommonTypes::MyEnum>() ) {
+ } else if ( v.isType<CommonTypes::MyEnum>() ) {
- std::cout << "Received (A) MyEnum with value " << (int) (v.get<CommonTypes::MyEnum>()) << " at index " << (int)v.getValueType() << std::endl;
+ std::cout << "Received (A) MyEnum with value " << (int) (v.get<CommonTypes::MyEnum>()) << " at index " << (int)v.getValueType() << std::endl;
- } else if ( v.isType<uint8_t>() ) {
+ } else if ( v.isType<uint8_t>() ) {
- std::cout << "Received (A) uint8_t with value " << (int) (v.get<uint8_t>()) << " at index " << (int)v.getValueType() << std::endl;
+ std::cout << "Received (A) uint8_t with value " << (int) (v.get<uint8_t>()) << " at index " << (int)v.getValueType() << std::endl;
- } else if ( v.isType<std::string>() ) {
+ } else if ( v.isType<std::string>() ) {
- std::cout << "Received (A) string " << v.get<std::string>() << " at index " << (int)v.getValueType() << std::endl;
+ std::cout << "Received (A) string " << v.get<std::string>() << " at index " << (int)v.getValueType() << std::endl;
- } else {
+ } else {
- std::cout << "Received (A) change message with unknown type." << std::endl;
- }
+ std::cout << "Received (A) change message with unknown type." << std::endl;
+ }
}
template <typename T1, typename... T>
void evalB (const CommonAPI::Variant<T1, T...>& v) {
- switch (v.getValueType()) {
+ switch (v.getValueType()) {
- case typeIdOf<CommonTypes::MyTypedef, T1, T...>::value:
+ case typeIdOf<CommonTypes::MyTypedef, T1, T...>::value:
- std::cout << "Received (B) MyTypedef with value " << (int)(v.template get<CommonTypes::MyTypedef>()) << " at index " << (int)v.getValueType() << std::endl;
- break;
+ std::cout << "Received (B) MyTypedef with value " << (int)(v.template get<CommonTypes::MyTypedef>()) << " at index " << (int)v.getValueType() << std::endl;
+ break;
- case typeIdOf<CommonTypes::MyEnum, T1, T...>::value:
+ case typeIdOf<CommonTypes::MyEnum, T1, T...>::value:
- std::cout << "Received (B) MyEnum with value " << (int)(v.template get<CommonTypes::MyEnum>()) << " at index " << (int)v.getValueType() << std::endl;
- break;
+ std::cout << "Received (B) MyEnum with value " << (int)(v.template get<CommonTypes::MyEnum>()) << " at index " << (int)v.getValueType() << std::endl;
+ break;
- case typeIdOf<uint8_t, T1, T...>::value:
+ case typeIdOf<uint8_t, T1, T...>::value:
- std::cout << "Received (B) uint8_t with value " << (int)(v.template get<uint8_t>()) << " at index " << (int)v.getValueType() << std::endl;
- break;
+ std::cout << "Received (B) uint8_t with value " << (int)(v.template get<uint8_t>()) << " at index " << (int)v.getValueType() << std::endl;
+ break;
- case typeIdOf<std::string, T1, T...>::value:
+ case typeIdOf<std::string, T1, T...>::value:
- std::cout << "Received (B) string " << v.template get<std::string>() << " at index " << (int)v.getValueType() << std::endl;
- break;
+ std::cout << "Received (B) string " << v.template get<std::string>() << " at index " << (int)v.getValueType() << std::endl;
+ break;
- default:
+ default:
- std::cout << "Received (B) change message with unknown type." << std::endl;
- break;
- }
+ std::cout << "Received (B) change message with unknown type." << std::endl;
+ break;
+ }
}
void evalC(const CommonTypes::SettingsUnion& v) {
- MyVisitor visitor;
- visitor.eval(v);
+ MyVisitor visitor;
+ visitor.eval(v);
}
void recv_msg(const CommonTypes::SettingsUnion& v) {
- evalA(v);
- evalB(v);
- evalC(v);
+ evalA(v);
+ evalB(v);
+ evalC(v);
}
void recv_msg1(std::shared_ptr<CommonTypes::SettingsStruct> x) {
- if ( std::shared_ptr<CommonTypes::SettingsStructMyTypedef> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyTypedef>(x) ) {
+ if ( std::shared_ptr<CommonTypes::SettingsStructMyTypedef> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyTypedef>(x) ) {
- std::cout << "Received (D) MyTypedef with value " << (int)sp->getId() << std::endl;
+ std::cout << "Received (D) MyTypedef with value " << (int)sp->getId() << std::endl;
- } else if ( std::shared_ptr<CommonTypes::SettingsStructMyEnum> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyEnum>(x) ) {
+ } else if ( std::shared_ptr<CommonTypes::SettingsStructMyEnum> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructMyEnum>(x) ) {
- std::cout << "Received (D) MyEnum with value " << (int)sp->getStatus() << std::endl;
+ std::cout << "Received (D) MyEnum with value " << (int)sp->getStatus() << std::endl;
- } else if ( std::shared_ptr<CommonTypes::SettingsStructUInt8> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructUInt8>(x) ) {
+ } else if ( std::shared_ptr<CommonTypes::SettingsStructUInt8> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructUInt8>(x) ) {
- std::cout << "Received (D) uint8_t with value " << (int)sp->getChannel() << std::endl;
+ std::cout << "Received (D) uint8_t with value " << (int)sp->getChannel() << std::endl;
- } else if ( std::shared_ptr<CommonTypes::SettingsStructString> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructString>(x) ) {
+ } else if ( std::shared_ptr<CommonTypes::SettingsStructString> sp = std::dynamic_pointer_cast<CommonTypes::SettingsStructString>(x) ) {
- std::cout << "Received (D) string " << sp->getName() << std::endl;
+ std::cout << "Received (D) string " << sp->getName() << std::endl;
- } else {
+ } else {
- std::cout << "Received (D) change message with unknown type." << std::endl;
- }
+ std::cout << "Received (D) change message with unknown type." << std::endl;
+ }
}
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E06C");
- CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions");
+ 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::string connection = "client-sample";
+ const std::string &instance = "commonapi.examples.Unions";
+ std::string connection = "client-sample";
- std::shared_ptr<E06UnionsProxy<>> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance, connection);
+ std::shared_ptr<E06UnionsProxy<>> myProxy = runtime->buildProxy<E06UnionsProxy>(domain, instance, connection);
while (!myProxy->isAvailable()) {
usleep(10);
}
- std::function<void (CommonTypes::SettingsUnion)> f = recv_msg;
- myProxy->getUAttribute().getChangedEvent().subscribe(f);
+ std::function<void (CommonTypes::SettingsUnion)> f = recv_msg;
+ myProxy->getUAttribute().getChangedEvent().subscribe(f);
- std::function<void (std::shared_ptr<CommonTypes::SettingsStruct>)> f1 = recv_msg1;
- myProxy->getXAttribute().getChangedEvent().subscribe(f1);
+ std::function<void (std::shared_ptr<CommonTypes::SettingsStruct>)> f1 = recv_msg1;
+ myProxy->getXAttribute().getChangedEvent().subscribe(f1);
while (true) {
usleep(10);
diff --git a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
index 9fa72b6..906269d 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsService.cpp
@@ -12,37 +12,37 @@
#include "E06UnionsStubImpl.h"
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E06S");
- CommonAPI::Runtime::setProperty("LibraryBase", "E06Unions");
+ 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";
- std::string connection = "service-sample";
+ const std::string &instance = "commonapi.examples.Unions";
+ std::string connection = "service-sample";
std::shared_ptr<E06UnionsStubImpl> myService = std::make_shared<E06UnionsStubImpl>();
- bool successfullyRegistered = 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);
- }
+ 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;
+ 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));
- }
+ 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 1cee610..5b28046 100644
--- a/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
+++ b/CommonAPI-Examples/E06Unions/src/E06UnionsStubImpl.cpp
@@ -29,19 +29,19 @@ void E06UnionsStubImpl::setMyValue(int n) {
if (n == 0) {
CommonTypes::SettingsUnion v(t0);
setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructMyTypedef>(t0));
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructMyTypedef>(t0));
} else if (n == 1) {
CommonTypes::SettingsUnion v(t1);
setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructMyEnum>(t1));
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructMyEnum>(t1));
} else if (n == 2) {
CommonTypes::SettingsUnion v(t2);
setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructUInt8>(t2));
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructUInt8>(t2));
} else if (n == 3) {
CommonTypes::SettingsUnion v(t3);
setUAttribute(v);
- setXAttribute(std::make_shared<CommonTypes::SettingsStructString>(t3));
+ setXAttribute(std::make_shared<CommonTypes::SettingsStructString>(t3));
}
} else {
diff --git a/CommonAPI-Examples/E06Unions/src/typeUtils.hpp b/CommonAPI-Examples/E06Unions/src/typeUtils.hpp
index 0dfb0f2..a56f2b6 100644
--- a/CommonAPI-Examples/E06Unions/src/typeUtils.hpp
+++ b/CommonAPI-Examples/E06Unions/src/typeUtils.hpp
@@ -16,12 +16,12 @@ struct typeIdOf;
template <typename SearchT, typename T>
struct typeIdOf<SearchT, T> {
- static const int value = std::is_same<SearchT, T>::value ? 1 : -1;
+ static const int value = std::is_same<SearchT, T>::value ? 1 : -1;
};
template <typename SearchT, typename T1, typename... T>
struct typeIdOf<SearchT, T1, T...> {
- static const int value = std::is_same<SearchT, T1>::value ? sizeof...(T)+1 : typeIdOf<SearchT, T...>::value;
+ static const int value = std::is_same<SearchT, T1>::value ? sizeof...(T)+1 : typeIdOf<SearchT, T...>::value;
};
#endif // DE_BMW_EXAMPLES_TYPE_UTILS_H_
diff --git a/CommonAPI-Examples/E06Unions/vsomeip-client.json b/CommonAPI-Examples/E06Unions/vsomeip-client.json
index 731852a..584fdb1 100644
--- a/CommonAPI-Examples/E06Unions/vsomeip-client.json
+++ b/CommonAPI-Examples/E06Unions/vsomeip-client.json
@@ -1,26 +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"
- }
+ "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
index d26710c..6c30f65 100644
--- a/CommonAPI-Examples/E06Unions/vsomeip-local.json
+++ b/CommonAPI-Examples/E06Unions/vsomeip-local.json
@@ -1,78 +1,78 @@
{
- "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",
- "events" :
- [
- {
- "event" : "0x80F2",
- "is_field" : "false",
- "is_reliable" : "false",
- "update-cycle" : 0
- },
- {
- "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"
- }
+ "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",
+ "events" :
+ [
+ {
+ "event" : "0x80F2",
+ "is_field" : "false",
+ "is_reliable" : "false",
+ "update-cycle" : 0
+ },
+ {
+ "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/E06Unions/vsomeip-service.json b/CommonAPI-Examples/E06Unions/vsomeip-service.json
index 683f59f..e5d9018 100644
--- a/CommonAPI-Examples/E06Unions/vsomeip-service.json
+++ b/CommonAPI-Examples/E06Unions/vsomeip-service.json
@@ -1,74 +1,74 @@
{
- "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",
- "events" :
- [
- {
- "event" : "0x80F2",
- "is_field" : "false",
- "is_reliable" : "false",
- "update-cycle" : 0
- },
- {
- "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"
- }
+ "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",
+ "events" :
+ [
+ {
+ "event" : "0x80F2",
+ "is_field" : "false",
+ "is_reliable" : "false",
+ "update-cycle" : 0
+ },
+ {
+ "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/E07Mainloop/CMakeLists.txt b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
index 3249b0b..2cb7923 100644
--- a/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
+++ b/CommonAPI-Examples/E07Mainloop/CMakeLists.txt
@@ -30,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 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_CMAKE_PACKAGE_REGISTRY)
else()
- FIND_PACKAGE(CommonAPI 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
- FIND_PACKAGE(CommonAPI-DBus 3.1.3 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+ FIND_PACKAGE(CommonAPI-DBus 3.1.4 REQUIRED CONFIG NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
endif()
message(STATUS "CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
@@ -47,57 +47,61 @@ include(FindPkgConfig)
###############################################################################
# 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 ()
+ #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)
+ pkg_check_modules(DBus REQUIRED dbus-1>=1.4)
endif()
# SOME/IP
-find_package (CommonAPI-SomeIP 3.1.3 REQUIRED)
-find_package (vsomeip 1.3.0 REQUIRED)
+find_package (CommonAPI-SomeIP 3.1.4 REQUIRED)
+find_package (vsomeip 2.0.0 REQUIRED)
# GLib
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 ()
+ 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)
+ FIND_PACKAGE(glib-2.0)
+ if (NOT GLIB_FOUND)
+ message ("glib not found via cmake trying via pkg-config")
+ pkg_check_modules(GLIB REQUIRED glib-2.0)
+ endif()
+ 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)
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_SRC_GEN_COMMONAPI_PATH ${PRJ_SRC_GEN_PATH}/core/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_DBUS_PATH ${PRJ_SRC_GEN_PATH}/dbus/v1/commonapi/examples)
+set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH ${PRJ_SRC_GEN_PATH}/someip/v1/commonapi/examples)
set(PRJ_NAME_CLIENT ${PRJ_NAME}Client)
set(PRJ_NAME_SERVICE ${PRJ_NAME}Service)
@@ -139,7 +143,7 @@ link_directories(
${COMMONAPI_LIBDIR}
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
else()
link_directories(
@@ -147,7 +151,7 @@ link_directories(
${COMMONAPI_DBUS_LIBDIR}
${COMMONAPI_SOMEIP_CMAKE_DIR}/build
${DBus_INCLUDE_DIRS}/dbus/.libs
- ${Boost_LIBRARY_DIR}
+ ${Boost_LIBRARY_DIR}
)
endif()
diff --git a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl
index d409861..d25e2b6 100644
--- a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl
+++ b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fdepl
@@ -7,35 +7,35 @@ import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP
import "E07Mainloop.fidl"
define org.genivi.commonapi.someip.deployment for interface commonapi.examples.E07Mainloop {
- SomeIpServiceID = 4660
+ SomeIpServiceID = 4660
- attribute x {
- SomeIpGetterID = 3000
- SomeIpSetterID = 3001
- SomeIpNotifierID = 33010
- SomeIpEventGroups = { 33010 }
- }
-
- method sayHello {
- SomeIpMethodID = 33000
-
- in {
- name {
- SomeIpStringEncoding = utf16le
- }
- }
- }
+ attribute x {
+ SomeIpGetterID = 3000
+ SomeIpSetterID = 3001
+ SomeIpNotifierID = 33010
+ SomeIpEventGroups = { 33010 }
+ }
+
+ method sayHello {
+ SomeIpMethodID = 33000
+
+ in {
+ name {
+ SomeIpStringEncoding = utf16le
+ }
+ }
+ }
}
define org.genivi.commonapi.someip.deployment for provider Service {
- instance commonapi.examples.E07Mainloop {
- InstanceId = "commonapi.examples.Mainloop"
-
- SomeIpInstanceID = 22136
-
- SomeIpUnicastAddress = "192.168.0.2"
- SomeIpReliableUnicastPort = 30499
- SomeIpUnreliableUnicastPort = 30499
- }
+ instance commonapi.examples.E07Mainloop {
+ InstanceId = "commonapi.examples.Mainloop"
+
+ SomeIpInstanceID = 22136
+
+ SomeIpUnicastAddress = "192.168.0.2"
+ SomeIpReliableUnicastPort = 30499
+ SomeIpUnreliableUnicastPort = 30499
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl
index c835cd9..1892911 100644
--- a/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl
+++ b/CommonAPI-Examples/E07Mainloop/fidl/E07Mainloop.fidl
@@ -7,16 +7,16 @@
package commonapi.examples
interface E07Mainloop {
- version { major 1 minor 0 }
-
- attribute Int32 x
+ version { major 1 minor 0 }
+
+ attribute Int32 x
- method sayHello {
- in {
- String name
- }
- out {
- String message
- }
- }
+ method sayHello {
+ in {
+ String name
+ }
+ out {
+ String message
+ }
+ }
} \ No newline at end of file
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
index 70873a8..8d2db12 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopClient.cpp
@@ -16,7 +16,7 @@
#include <gio/gio.h>
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E07MainloopProxy.hpp>
+#include <v1/commonapi/examples/E07MainloopProxy.hpp>
using namespace v1_0::commonapi::examples;
@@ -34,48 +34,48 @@ void myAttrXCallback(const CommonAPI::CallStatus& callStatus, const int32_t& val
void mySayHelloCallback(const CommonAPI::CallStatus& _callStatus, const std::string& _returnMessage) {
- if (_callStatus != CommonAPI::CallStatus::SUCCESS) {
- std::cerr << "Remote call failed!\n";
- return;
- }
- std::cout << "Got message: '" << _returnMessage << "'\n";
+ if (_callStatus != CommonAPI::CallStatus::SUCCESS) {
+ std::cerr << "Remote call failed!\n";
+ return;
+ }
+ std::cout << "Got message: '" << _returnMessage << "'\n";
}
gboolean callSetAttrX(void* proxy) {
- std::cout << "callSetAttrX called ..." << std::endl;
+ std::cout << "callSetAttrX called ..." << std::endl;
- E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
- myProxy->getXAttribute().setValueAsync(gValueForX , myAttrXCallback);
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ myProxy->getXAttribute().setValueAsync(gValueForX , myAttrXCallback);
- return false;
+ return false;
}
gboolean callGetAttrX(void* proxy) {
- std::cout << "callGetAttrX called ..." << std::endl;
+ std::cout << "callGetAttrX called ..." << std::endl;
- E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
- myProxy->getXAttribute().getValueAsync(myAttrXCallback);
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ myProxy->getXAttribute().getValueAsync(myAttrXCallback);
- return false;
+ return false;
}
gboolean callSayHello(void* proxy) {
- std::cout << "callSayHello called ..." << std::endl;
+ std::cout << "callSayHello called ..." << std::endl;
- static int number = 1;
+ static int number = 1;
- std::stringstream stream;
- stream << "World (" << number << ")";
+ std::stringstream stream;
+ stream << "World (" << number << ")";
const std::string name = stream.str();
- E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
- gFutureCallStatus = myProxy->sayHelloAsync(name, mySayHelloCallback);
+ E07MainloopProxy<>* myProxy = static_cast<E07MainloopProxy<>*>(proxy);
+ gFutureCallStatus = myProxy->sayHelloAsync(name, mySayHelloCallback);
- number++;
+ number++;
return true;
}
@@ -88,60 +88,60 @@ class GDispatchWrapper: public GSource {
gboolean dispatchPrepare ( GSource* source, gint* timeout ) {
- bool result = false;
- int64_t eventTimeout;
+ bool result = false;
+ int64_t eventTimeout;
- result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
+ result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
- *timeout = eventTimeout;
+ *timeout = eventTimeout;
return result;
}
gboolean dispatchCheck ( GSource* source ) {
- return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
+ return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
}
gboolean dispatchExecute ( GSource* source, GSourceFunc callback, gpointer userData ) {
- static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
+ static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
return true;
}
static GSourceFuncs standardGLibSourceCallbackFuncs = {
- dispatchPrepare,
- dispatchCheck,
- dispatchExecute,
- NULL
+ dispatchPrepare,
+ dispatchCheck,
+ dispatchExecute,
+ NULL
};
gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
- CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
+ CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
#ifdef WIN32
- condition = static_cast<GIOCondition>(POLLIN);
+ condition = static_cast<GIOCondition>(POLLIN);
#endif
- watch->dispatch(condition);
+ watch->dispatch(condition);
return true;
}
gboolean gTimeoutDispatcher ( void* userData ) {
- return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
+ return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
}
void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
- const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
+ const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
#ifdef WIN32
- channel = g_io_channel_win32_new_socket(fileDesc.fd);
- GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN);
+ 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));
+ 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);
@@ -161,7 +161,7 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio
void watchRemovedCallback ( CommonAPI::Watch* watch ) {
- g_source_remove_by_user_data(watch);
+ g_source_remove_by_user_data(watch);
if(channel) {
g_io_channel_unref(channel);
@@ -170,8 +170,8 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) {
}
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E07C");
- CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
+ CommonAPI::Runtime::setProperty("LogContext", "E07C");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();
@@ -181,36 +181,36 @@ int main() {
std::shared_ptr<CommonAPI::MainLoopContext> mainloopContext = std::make_shared<CommonAPI::MainLoopContext>(connection);
- std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
- std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
- mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
+ std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
+ std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
+ mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
std::shared_ptr<E07MainloopProxy<>> myProxy = runtime->buildProxy<E07MainloopProxy>(domain,
- instance, mainloopContext);
+ instance, mainloopContext);
std::cout << "Checking availability" << std::flush;
static
- #ifndef WIN32
- constexpr
- #endif
- bool mayBlock = false;
-
+ #ifndef WIN32
+ constexpr
+ #endif
+ bool mayBlock = false;
+
int count = 0;
while (!myProxy->isAvailable()) {
- if (count % 10 == 0)
- std::cout << "." << std::flush;
- g_main_context_iteration(NULL, mayBlock);
- usleep(50000);
+ if (count % 10 == 0)
+ std::cout << "." << std::flush;
+ g_main_context_iteration(NULL, mayBlock);
+ usleep(50000);
}
std::cout << "done." << std::endl;
GMainLoop* mainloop = NULL;
mainloop = g_main_loop_new(NULL, FALSE);
- void *proxyPtr = (void*)myProxy.get();
- g_timeout_add(100, callSayHello, proxyPtr);
- g_timeout_add(5000, callGetAttrX, proxyPtr);
- g_timeout_add(9000, callSetAttrX, proxyPtr);
+ void *proxyPtr = (void*)myProxy.get();
+ g_timeout_add(100, callSayHello, proxyPtr);
+ g_timeout_add(5000, callGetAttrX, proxyPtr);
+ g_timeout_add(9000, callSetAttrX, proxyPtr);
g_main_loop_run (mainloop);
g_main_loop_unref (mainloop);
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
index 86be1aa..72126c5 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopService.cpp
@@ -19,16 +19,16 @@ GIOChannel* channel;
gboolean callIncCounter(void* service) {
- E07MainloopStubImpl* myService = static_cast<E07MainloopStubImpl*>(service);
- myService->incAttrX();
+ E07MainloopStubImpl* myService = static_cast<E07MainloopStubImpl*>(service);
+ myService->incAttrX();
- return true;
+ return true;
}
gboolean callWaitingInfo(void* service) {
- std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
+ std::cout << "Waiting for calls... (Abort with CTRL+C)" << std::endl;
- return true;
+ return true;
}
class GDispatchWrapper: public GSource {
@@ -39,60 +39,60 @@ class GDispatchWrapper: public GSource {
gboolean dispatchPrepare ( GSource* source, gint* timeout ) {
- bool result = false;
- int64_t eventTimeout;
+ bool result = false;
+ int64_t eventTimeout;
- result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
+ result = static_cast<GDispatchWrapper*>(source)->dispatchSource_->prepare(eventTimeout);
- *timeout = eventTimeout;
+ *timeout = eventTimeout;
return result;
}
gboolean dispatchCheck ( GSource* source ) {
- return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
+ return static_cast<GDispatchWrapper*>(source)->dispatchSource_->check();
}
gboolean dispatchExecute ( GSource* source, GSourceFunc callback, gpointer userData ) {
- static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
+ static_cast<GDispatchWrapper*>(source)->dispatchSource_->dispatch();
return true;
}
static GSourceFuncs standardGLibSourceCallbackFuncs = {
- dispatchPrepare,
- dispatchCheck,
- dispatchExecute,
- NULL
+ dispatchPrepare,
+ dispatchCheck,
+ dispatchExecute,
+ NULL
};
gboolean gWatchDispatcher ( GIOChannel *source, GIOCondition condition, gpointer userData ) {
- CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
+ CommonAPI::Watch* watch = static_cast<CommonAPI::Watch*>(userData);
#ifdef WIN32
- condition = static_cast<GIOCondition>(POLLIN);
+ condition = static_cast<GIOCondition>(POLLIN);
#endif
- watch->dispatch(condition);
+ watch->dispatch(condition);
return true;
}
gboolean gTimeoutDispatcher ( void* userData ) {
- return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
+ return static_cast<CommonAPI::DispatchSource*>(userData)->dispatch();
}
void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority ) {
- const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
+ const pollfd& fileDesc = watch->getAssociatedFileDescriptor();
#ifdef WIN32
- channel = g_io_channel_win32_new_socket(fileDesc.fd);
- GSource* gWatch = g_io_create_watch(channel, GIOCondition::G_IO_IN);
+ 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));
+ 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);
@@ -107,12 +107,12 @@ void watchAddedCallback ( CommonAPI::Watch* watch, const CommonAPI::DispatchPrio
g_source_add_child_source(gWatch, gDispatchSource);
}
- int source = g_source_attach(gWatch, NULL);
+ int source = g_source_attach(gWatch, NULL);
}
void watchRemovedCallback ( CommonAPI::Watch* watch ) {
- g_source_remove_by_user_data(watch);
+ g_source_remove_by_user_data(watch);
if(channel) {
g_io_channel_unref(channel);
@@ -121,40 +121,40 @@ void watchRemovedCallback ( CommonAPI::Watch* watch ) {
}
int main() {
- CommonAPI::Runtime::setProperty("LogContext", "E07S");
- CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
+ CommonAPI::Runtime::setProperty("LogContext", "E07S");
+ CommonAPI::Runtime::setProperty("LibraryBase", "E07Mainloop");
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
std::string domain = "local";
- std::string instance = "commonapi.examples.Mainloop";
- std::string connection = "service-sample";
+ std::string instance = "commonapi.examples.Mainloop";
+ std::string connection = "service-sample";
std::shared_ptr<CommonAPI::MainLoopContext> mainloopContext = std::make_shared<CommonAPI::MainLoopContext>(connection);
- std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
- std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
- mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
+ std::function<void(CommonAPI::Watch*, const CommonAPI::DispatchPriority)> f_watchAddedCallback = watchAddedCallback;
+ std::function<void(CommonAPI::Watch*)> f_watchRemovedCallback = watchRemovedCallback;
+ mainloopContext->subscribeForWatches(f_watchAddedCallback, f_watchRemovedCallback);
- std::shared_ptr<E07MainloopStubImpl> myService = std::make_shared<E07MainloopStubImpl>();
+ std::shared_ptr<E07MainloopStubImpl> myService = std::make_shared<E07MainloopStubImpl>();
- bool successfullyRegistered = 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);
- }
+ 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;
+ std::cout << "Successfully Registered Service!" << std::endl;
GMainLoop* mainloop = NULL;
mainloop = g_main_loop_new(NULL, FALSE);
void *servicePtr = (void*)myService.get();
- g_timeout_add_seconds(10, callWaitingInfo, servicePtr);
+ g_timeout_add_seconds(10, callWaitingInfo, servicePtr);
- g_timeout_add(2500, callIncCounter, servicePtr);
+ g_timeout_add(2500, callIncCounter, servicePtr);
g_main_loop_run (mainloop);
g_main_loop_unref (mainloop);
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp
index 53a2cd0..af000ff 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.cpp
@@ -7,17 +7,17 @@
#include "E07MainloopStubImpl.hpp"
E07MainloopStubImpl::E07MainloopStubImpl() {
- setXAttribute(0);
+ setXAttribute(0);
}
E07MainloopStubImpl::~E07MainloopStubImpl() {
}
void E07MainloopStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _client,
- std::string _name,
- sayHelloReply_t _reply) {
+ std::string _name,
+ sayHelloReply_t _reply) {
- std::stringstream messageStream;
+ std::stringstream messageStream;
messageStream << "Hello " << _name << "!";
std::cout << "sayHello('" << _name << "'): '" << messageStream.str() << "'\n";
@@ -26,8 +26,8 @@ void E07MainloopStubImpl::sayHello(const std::shared_ptr<CommonAPI::ClientId> _c
}
void E07MainloopStubImpl::incAttrX() {
- int32_t xValue = getXAttribute();
- xValue++;
- setXAttribute((int32_t)xValue);
- std::cout << "New counter value = " << xValue << "!" << std::endl;
+ int32_t xValue = getXAttribute();
+ xValue++;
+ setXAttribute((int32_t)xValue);
+ std::cout << "New counter value = " << xValue << "!" << std::endl;
}
diff --git a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp
index 1cd82b1..1427b31 100644
--- a/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp
+++ b/CommonAPI-Examples/E07Mainloop/src/E07MainloopStubImpl.hpp
@@ -8,7 +8,7 @@
#define E07MAINLOOPSTUBIMPL_H_
#include <CommonAPI/CommonAPI.hpp>
-#include <v1_0/commonapi/examples/E07MainloopStubDefault.hpp>
+#include <v1/commonapi/examples/E07MainloopStubDefault.hpp>
class E07MainloopStubImpl: public v1_0::commonapi::examples::E07MainloopStubDefault {
diff --git a/CommonAPI-Examples/E07Mainloop/vsomeip-client.json b/CommonAPI-Examples/E07Mainloop/vsomeip-client.json
index 731852a..584fdb1 100644
--- a/CommonAPI-Examples/E07Mainloop/vsomeip-client.json
+++ b/CommonAPI-Examples/E07Mainloop/vsomeip-client.json
@@ -1,26 +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"
- }
+ "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/E07Mainloop/vsomeip-local.json b/CommonAPI-Examples/E07Mainloop/vsomeip-local.json
index 641f13b..5701078 100644
--- a/CommonAPI-Examples/E07Mainloop/vsomeip-local.json
+++ b/CommonAPI-Examples/E07Mainloop/vsomeip-local.json
@@ -1,47 +1,47 @@
{
- "unicast" : "192.168.0.235",
- "logging" :
- {
- "level" : "info",
- "console" : "true",
- "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
- "dlt" : "false"
- },
- "applications" :
- [
- {
- "name" : "client-sample",
- "id" : "0x1343"
- },
- {
- "name" : "other-client-sample",
- "id" : "0x1344"
- },
- {
- "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"
- }
- }
- ],
- "routing" : "client-sample",
- "service-discovery" :
- {
- "enable" : "true",
- "multicast" : "224.244.224.245",
- "port" : "30490",
- "protocol" : "udp"
- }
+ "unicast" : "192.168.0.235",
+ "logging" :
+ {
+ "level" : "info",
+ "console" : "true",
+ "file" : { "enable" : "false", "path" : "/var/log/vsomeip.log" },
+ "dlt" : "false"
+ },
+ "applications" :
+ [
+ {
+ "name" : "client-sample",
+ "id" : "0x1343"
+ },
+ {
+ "name" : "other-client-sample",
+ "id" : "0x1344"
+ },
+ {
+ "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"
+ }
+ }
+ ],
+ "routing" : "client-sample",
+ "service-discovery" :
+ {
+ "enable" : "true",
+ "multicast" : "224.244.224.245",
+ "port" : "30490",
+ "protocol" : "udp"
+ }
}
diff --git a/CommonAPI-Examples/E07Mainloop/vsomeip-service.json b/CommonAPI-Examples/E07Mainloop/vsomeip-service.json
index bd135f6..3cec46d 100644
--- a/CommonAPI-Examples/E07Mainloop/vsomeip-service.json
+++ b/CommonAPI-Examples/E07Mainloop/vsomeip-service.json
@@ -1,48 +1,48 @@
{
- "unicast" : "10.10.46.59",
- "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"
- }
+ "unicast" : "10.10.46.59",
+ "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/README b/CommonAPI-Examples/README
index 56f9b64..cbcf38e 100644
--- a/CommonAPI-Examples/README
+++ b/CommonAPI-Examples/README
@@ -28,7 +28,7 @@ If do not specify any configuration file it is assumed that you want to use the
* +LD_LIBRARY_PATH+ should contain the path to the _libdbus_ if you use the D-Bus binding with an uninstalled _libdbus_ and should contain the path to your gluecode libraries, e.g. +LD_LIBRARY_PATH=<path to libdbus>/dbus-1.8.20/dbus/.libs:<path to CommonAPI-Tools>/CommonAPI-Examples/E01HelloWorld/build+
-* +VSOMEIP_CONFIGURATION_FILE+ should contain the path to your vsomeip configuration file if you are using the SOME/IP binding, e.g. +VSOMEIP_CONFIGURATION_FILE=<path to CommonAPI-Tools>/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json+
+* +VSOMEIP_CONFIGURATION+ should contain the path to your vsomeip configuration file if you are using the SOME/IP binding, e.g. +VSOMEIP_CONFIGURATION=<path to CommonAPI-Tools>/CommonAPI-Examples/E01HelloWorld/vsomeip-local.json+
Here are some hints if you want to configure your eclipse project for the CMake build:
diff --git a/docx/CommonAPICppUserGuide b/docx/CommonAPICppUserGuide
index 624628a..25dec3c 100644
--- a/docx/CommonAPICppUserGuide
+++ b/docx/CommonAPICppUserGuide
@@ -192,7 +192,8 @@ You can build all code generators by calling maven from the command-line. Open a
mvn -Dtarget.id=org.genivi.commonapi.core.target clean verify
----
-After the successful build you will find the commond-line generators archived in org.genivi.commonapi.core.cli.product/target/products/commonapi-generator.zip and the update-sites in org.genivi.commonapi.core.updatesite/target.
+After the successful build you will find the commond-line generators archived in
+_org.genivi.commonapi.core.cli.product/target/products/commonapi-generator.zip_ and the update-sites in org.genivi.commonapi.core.updatesite/target.
==== Eclipse
@@ -545,58 +546,85 @@ The parameters of the code generator are now significantly extended. The usage o
commonapi-generator-linux-x86 <options> <fidl files>
----
-[cols="6,10", options="header"]
+[cols="8,10", options="header"]
|=========================================================
|Options|
Description
|+-h, --help+|
-Print out options of the code generator
+display help of available console commands
-|+-d, --dest+ _<arg>_|
+|+-p,--plugins+ |
+print plug-in versions
+
+|+-v,--version+ |
+print code generator version
+
+|+-d,--dest+ _<arg>_ |
The default output directory
-|+-dc, --dest-common+ _<arg>_|
-The directory for the common code (relevant for proxy and stub, e.g. type definitions)
+|+-dc,--dest-common+ _<arg>_ |
+The directory for the common code
-|+-dp, --dest-proxy+ _<arg>_|
+|+-dp,--dest-proxy+ _<arg>_ |
The directory for proxy code
-|+-ds, --dest-stub+ _<arg>_|
+|+-ds,--dest-stub+ _<arg>_ |
The directory for stub code
-|+-dsk, --dest-skel+ _<arg>_|
+|+-dsk,--dest-skel+ _<arg>_ |
The directory for the skeleton code
-|+-l, --license+ _<arg>_|
+|+-l,--license+ _<arg>_ |
The file path to the license text that will be added to each generated file
-|+-ll, --loglevel+ _<arg>_|
+|+-ll,--loglevel+ _<arg>_ |
The log level (quiet or verbose)
-|+-np, --no-proxy+ _<arg>_|
+|+-nc,--no-common+ |
+Switch off generation of common code
+
+|+-ng,--no-gen+ |
+Switch off code generation completely
+
+|+-np,--no-proxy+ |
Switch off generation of proxy code
-|+-ns, --no-stub+ _<arg>_|
+|+-ns,--no-stub+ |
Switch off generation of stub code
-|+-pre, --prefix-enum-literal+ _<arg>_|
+|+-nsc,--no-sync-calls+ |
+Switch off code generation of synchronous methods
+
+|+-nv,--no-val+ |
+Switch off validation of the fidl file
+
+|+-pf,--printfiles+ |
+Print out generated files
+
+|+-pre,--prefix-enum-literal+ _<arg>_ |
The prefix added to all generated enumeration literals
-|+-sk, --skel+ _<arg>_|
- Generate skeleton code. The optional argument specifies the postfix. Without argument, the postfix is 'default'
+|+-sk,--skel+ _<arg>_ |
+Generate skeleton code. The optional argument specifies the postfix. Without argument, the postfix is 'default'
+
+|+-sp,--searchpath+ _<arg>_ |
+The search path to contain fidl/fdepl files
+
+|+-wod,--without-dependencies+ |
+Switch off code generation of dependencies
|=========================================================
Please note:
-- It is now possible to define different destination directories for proxy and stub code and to switch off the generation of proxy or stub code.
+- It is now possible to define different destination directories for proxy, stub and common code and to switch off the generation of proxy, stub or common code.
- The CommonAPI 2.x code generator always generated default implementations for the stubs (skeleton). This is not the default behavior anymore. Call the code generator with the option +-sk+ without an argument to get the same result as before.
- It is possible to influence the literals of enumerations by setting the option +-pre+. With this option you can add a custom prefix to all generated enumeration literals.
==== Version In Namespace
-Since CommonAPI version 3, the version of the Franca interface becomes part of the C++ namespace. The version is added at the beginning of the namespace path, e.g. for an interface with version 1.0 the modified namespace begins with +v1_0+. Please refer to chapter _Namespaces_ for further information.
+Since CommonAPI version 3, the version of the Franca interface becomes part of the C++ namespace. The version is added at the beginning of the namespace path, e.g. for an interface with version 1.0 the modified namespace begins with +v1+. Please refer to chapter _Namespaces_ for further information.
==== New Runtime Loading Concept
@@ -693,36 +721,45 @@ See the example +E01HelloWorld+:
----
package commonapi.examples
-
interface E01HelloWorld {
- version { major 1 minor 0 }
+ version { major 0 minor 1 }
// Interface definition here
+
}
----
The generated code looks as follows:
[source,{cppstr}]
----
-namespace v1_0 {
+namespace v0 {
namespace commonapi {
namespace examples {
class E01HelloWorld {
public:
-
-// Code here
+ virtual ~E01HelloWorld() { }
+
+ static inline const char* getInterface();
+ static inline CommonAPI::Version getInterfaceVersion();
+};
+
+const char* E01HelloWorld::getInterface() {
+ return ("commonapi.examples.E01HelloWorld");
+}
CommonAPI::Version E01HelloWorld::getInterfaceVersion() {
- return CommonAPI::Version(1, 0);
+ return CommonAPI::Version(0, 1);
}
+
} // namespace examples
} // namespace commonapi
-} // namespace v1_0
+} // namespace v0
+
----
-The generated code will be generated into the directory +src-gen/v1_0/commonapi/examples+.
+The generated code will be generated into the directory +src-gen/v0/commonapi/examples+.
The main reason for adding the version at the beginning of the namespace is that we consider the name of the interfaces together with the package path (fully qualified name) as a unit, as it is specified in the Franca file. This name should not be destroyed by an intervening add on.
@@ -831,41 +868,51 @@ The verification tests are implemented by using _googletest_ (http://code.google
The first step is to create the glue code library. The term "glue code" refers to a binary that contains the binding specific generated code from the provided Franca files which you can find in _org.genivi.commonapi.core.verification/fidl_. The glue code library must contain the generated binding specific proxy and stub files. Please follow the instructions in your binding code for creating the glue code library.
-Now create a _build_ directory in the verification project and start CMake. Call CMake with the following parameters:
+Now create a _build_ directory in the verification project and start CMake.
+The Following parameters can be applied:
-[width="80%",cols="5,5"]
+[width="100%",cols="8,12"]
|=========================================================
|+-DUSE_INSTALLED_COMMONAPI+ |
OFF/ON
-|+-DBINDING_NAME+ |
-DBus/SomeIP/...
+|+-DTESTS_BAT+ |
+Set to ON to build a subset of tests covering basic functionality which
+also have little execution time to serve as build acceptance tests
+
+|+-DTESTS_EXTRA+ |
+Set to ON to build extra tests for stability and performance testing
-|+-DCMAKE_BINDING_NAME+ |
-CommonAPI-DBus/CommonAPI-SomeIP/...
+|+-DCOMMONAPI_CMAKE_INSTALL_PATH+ |
+Path to the CommonAPI library
-|+-DCMAKE_BINDING_PATH+ |
-Path to the binding library
+|+-DCMAKE_GLUECODE_SOMEIP_NAME+ |
+Name of the someIP gluecode library (e.g. "SomeIPGlue" for "libSomeIPGlue.so")
-|+-DCMAKE_GLUECODE_NAME+ |
-Name of the glue code library
+|+-DCMAKE_GLUECODE_DBUS_NAME+ |
+Name of the dbus gluecode library (e.g. "DBusGlue" for "libDBusGlue.so")
-|+DCMAKE_GLUECODE_PATH+ |
-Path to the glue code library
+|+-DSomeIPGlue_DIR+ |
+Path to the someIP gluecode library
+(e.g. TOOLS_DIR/org.genivi.commonapi.someip.verification/build)
-|+-DBINDING_EXTRA+ |
-Path to additional libraries which are needed by the linker (e.g. _libdbus_)
+|+-DDBusGlue_DIR+ |
+Path to the dbus gluecode library
+(e.g. DBUS_TOOLS_DIR/org.genivi.commonapi.dbus.verification/build)
|+-DCOMMONAPI_CMAKE_INSTALL_PATH+ |
Path to the CommonAPI library
-|+-DCOMMONAPI_DBUS_TOOL_GENERATOR+ |
-Code generator executable with path
+|+-DCommonAPI_DIR+ |
+Path to CommonAPI
+
+|+-DCOMMONAPI_TOOL_GENERATOR+ |
+Path to the CommonAPI core generator executable
|=========================================================
-After that start _make check_ to build and run the verification tests.
+After that start _make -j4_ and _ctest_ to build and run the verification tests.
=== Formatting Code
diff --git a/org.genivi.commonapi.console.feature/feature.xml b/org.genivi.commonapi.console.feature/feature.xml
index beb64a2..8d891f3 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.3.qualifier"
+ version="3.1.4.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.3" match="compatible"/>
+ <import feature="org.genivi.commonapi.console.franca.feature" version="3.1.4" match="compatible"/>
</requires>
<plugin
diff --git a/org.genivi.commonapi.console.feature/pom.xml b/org.genivi.commonapi.console.feature/pom.xml
index d2d6b00..7604571 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 440c4e0..4717d56 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.3.qualifier"
+ version="3.1.4.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 5fb1d01..1abc70e 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 67cb66a..2a85533 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.3.qualifier
+Bundle-Version: 3.1.4.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 61b0c0c..87f1e7d 100644
--- a/org.genivi.commonapi.console/about.mappings
+++ b/org.genivi.commonapi.console/about.mappings
@@ -1,3 +1,3 @@
-0=3.1.3-p5
-1=20151030
+0=3.1.4
+1=20151109
2=$sun.arch.data.model$
diff --git a/org.genivi.commonapi.console/pom.xml b/org.genivi.commonapi.console/pom.xml
index 7c5535d..0446e11 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.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
<relativePath>../org.genivi.commonapi.releng</relativePath>
</parent>
diff --git a/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandExecuter.java b/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandExecuter.java
index c88ec44..00c67c0 100644
--- a/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandExecuter.java
+++ b/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandExecuter.java
@@ -80,13 +80,11 @@ public enum CommandExecuter
private final String EXTENSION_POINT_PARSING_ERROR_MESSAGE = "An error occured while parsing console command \"%s\"!";
private final String OPTION_ID_NOT_FOUND_MESSAGE = "The option ID \"%s\" could not be found!";
private final String OPTION_GROUP_ID_NOT_FOUND_MESSAGE = "The option group ID \"%s\" could not be found!";
- private final String NO_REQUIRED_OPTION_MESSAGE = "This console command needs to specify at least one required option!";
private final String HELP_NO_COMMANDS_TEXT_MESSAGE = "No registered console commands available!";
private final String HELP_NAME_TEXT_MESSAGE = "Command: %s";
private final String HELP_ID_TEXT_MESSAGE = "%s: %s";
private final String HELP_WRONG_ID_MESSAGE = HELP_ID_TEXT_MESSAGE + "%nID does not match: %s";
private final String HELP_SEVERAL_COMMANDS_MESSAGE = "Several console commands are compatible to this set of parameters. Add ID option to select the desired one.%n";
- private final String EXECUTE_COMMAND_MESSAGE = "Executing %s...%n" ;
private final String LAUNCHER_NAME;
private final Option ID_OPTION;
@@ -220,11 +218,6 @@ public enum CommandExecuter
{
ConsoleConfiguration configuration = perfectMatchingConfigurations.get(0);
- if (configurations.size() > 1)
- {
- println(EXECUTE_COMMAND_MESSAGE, configuration.name);
- }
-
Object executable = configuration.commandConfiguration.createExecutableExtension(COMMAND_HANDLER_ATTRIBUTE_NAME);
ICommandLineHandler handler = (ICommandLineHandler) executable;
diff --git a/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandlineTool.java b/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandlineTool.java
new file mode 100644
index 0000000..15cbad3
--- /dev/null
+++ b/org.genivi.commonapi.console/src/org/genivi/commonapi/console/CommandlineTool.java
@@ -0,0 +1,233 @@
+package org.genivi.commonapi.console;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+
+
+public class CommandlineTool {
+
+ public static final String FILESEPARATOR = System.getProperty("file.separator");
+ protected boolean isCodeGeneration = true;
+ protected static final int ERROR_STATE = 1;
+ protected static final int NO_ERROR_STATE = 0;
+ protected boolean dumpGeneratedFiles;
+ protected List<String> files = new ArrayList<String>();
+ protected boolean hasValidationError;
+ protected boolean isValidation = true;
+ protected static final String FDEPL_EXTENSION = ".fdepl";
+ protected static final String FIDL_EXTENSION = ".fidl";
+
+ /**
+ * Get the text from a file which will be inserted as a comment in each generated file (for example your license)
+ *
+ * @param fileWithText
+ * @return
+ */
+ public String getLicenseText(String fileWithText) {
+ String licenseText = "";
+ if (fileWithText != null && !fileWithText.isEmpty())
+ {
+ File file = new File(createAbsolutPath(fileWithText));
+ if (!file.exists() || file.isDirectory())
+ {
+ ConsoleLogger.printErrorLog("Please specify a path to an existing file after option -l");
+ }
+ BufferedReader inReader = null;
+
+ try
+ {
+ inReader = new BufferedReader(new FileReader(file));
+ String thisLine;
+ while ((thisLine = inReader.readLine()) != null)
+ {
+ licenseText = licenseText + thisLine + "\n";
+ }
+ }
+ catch (IOException e)
+ {
+ ConsoleLogger.printLog("Failed to get the text from the given file: " + e.getLocalizedMessage());
+ }
+ finally
+ {
+ try
+ {
+ if(inReader != null) {
+ inReader.close();
+ }
+ }
+ catch (Exception e)
+ {
+ ;
+ }
+ }
+ }
+ else
+ {
+ ConsoleLogger.printErrorLog("Please write a path to an existing file after -l");
+ }
+ return licenseText;
+ }
+
+ /**
+ * creates a absolute path from a relative path which starts on the current
+ * user directory
+ *
+ * @param path
+ * the relative path which start on the current user-directory
+ * @return the created absolute path
+ */
+ public String createAbsolutPath(String path)
+ {
+ return createAbsolutPath(path, System.getProperty("user.dir") + FILESEPARATOR);
+ }
+
+ /**
+ * Here we create an absolute path from a relativ path and a rootpath from
+ * which the relative path begins
+ *
+ * @param path
+ * the relative path which begins on rootpath
+ * @param rootpath
+ * an absolute path to a folder
+ * @return the merded absolute path without points
+ */
+ private String createAbsolutPath(String path, String rootpath)
+ {
+ if (System.getProperty("os.name").contains("Windows"))
+ {
+ if (path.startsWith(":", 1))
+ return path;
+ }
+ else
+ {
+ if (path.startsWith(FILESEPARATOR))
+ return path;
+ }
+
+ String ret = (rootpath.endsWith(FILESEPARATOR) ? rootpath : (rootpath + FILESEPARATOR)) + path;
+ while (ret.contains(FILESEPARATOR + "." + FILESEPARATOR) || ret.contains(FILESEPARATOR + ".." + FILESEPARATOR))
+ {
+ if (ret.contains(FILESEPARATOR + ".." + FILESEPARATOR))
+ {
+ String temp = ret.substring(0, ret.indexOf(FILESEPARATOR + ".."));
+ temp = temp.substring(0, temp.lastIndexOf(FILESEPARATOR));
+ ret = temp + ret.substring(ret.indexOf(FILESEPARATOR + "..") + 3);
+ }
+ else
+ {
+ ret = replaceAll(ret, FILESEPARATOR + "." + FILESEPARATOR, FILESEPARATOR);
+ }
+ }
+ return ret;
+ }
+
+
+ /**
+ * a relaceAll Method which doesn't interprets the toreplace String as a
+ * regex and so you can also replace \ and such special things
+ *
+ * @param text
+ * the text who has to be modified
+ * @param toreplace
+ * the text which has to be replaced
+ * @param replacement
+ * the text which has to be inserted instead of toreplace
+ * @return the modified text with all toreplace parts replaced with
+ * replacement
+ */
+ public String replaceAll(String text, String toreplace, String replacement)
+ {
+ String ret = "";
+ while (text.contains(toreplace))
+ {
+ ret += text.substring(0, text.indexOf(toreplace)) + replacement;
+ text = text.substring(text.indexOf(toreplace) + toreplace.length());
+ }
+ ret += text;
+ return ret;
+ }
+
+ public String getFrancaVersion()
+ {
+ return Platform.getBundle("org.franca.core").getVersion().toString();
+ }
+
+ protected static FilenameFilter fidlFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if(name.endsWith(FIDL_EXTENSION)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ protected static FilenameFilter fdeplFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(FDEPL_EXTENSION)) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ private static FilenameFilter fidlFdeplFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if((name.endsWith(FIDL_EXTENSION) || name.endsWith(FDEPL_EXTENSION))) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+
+ public List<String> searchFidlFiles(String searchPath) {
+ return searchFiles(searchPath, fidlFilter);
+ }
+
+ public List<String> searchFdeplFiles(String searchPath) {
+ return searchFiles(searchPath, fdeplFilter);
+ }
+
+ public List<String> searchFidlandFdeplFiles(String searchPath) {
+ return searchFiles(searchPath, fidlFdeplFilter);
+ }
+
+ /**
+ * Search files with the given filter in the given path. the directories in a linux path are
+ * separated by ":".
+ *
+ * @param searchPath
+ * @return the list of fdepl files.
+ */
+ private List<String> searchFiles(String searchPath, FilenameFilter filter) {
+ List<String> fileList = new ArrayList<String>();
+ String[] searchDirs;
+ // if the search path contains several directories...
+ if (System.getProperty("os.name").contains("Windows")) {
+ searchDirs = searchPath.split(",");
+ }
+ else {
+ searchDirs = searchPath.split(":");
+ }
+ for (String dir : searchDirs) {
+ try {
+ File searchDir = new File(dir);
+ if (searchDir.isDirectory()) {
+ for (File file : searchDir.listFiles(filter)) {
+ fileList.add(file.getPath());
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ return fileList;
+ }
+
+}
diff --git a/org.genivi.commonapi.core.cli.feature/feature.xml b/org.genivi.commonapi.core.cli.feature/feature.xml
index 525d852..fa14b71 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.3.qualifier"
+ version="3.1.4.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 755fdb5..e9fe1b2 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 7d5a057..d015774 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.3.qualifier.jar" id="org.genivi.commonapi.console.feature" version="3.1.3.qualifier">
+ <feature url="features/org.genivi.commonapi.console.feature_3.1.4.qualifier.jar" id="org.genivi.commonapi.console.feature" version="3.1.4.qualifier">
<category name="GENIVI CommonAPI Console"/>
</feature>
- <feature url="features/org.genivi.commonapi.console.franca.feature_3.1.3.qualifier.jar" id="org.genivi.commonapi.console.franca.feature" version="3.1.3.qualifier">
+ <feature url="features/org.genivi.commonapi.console.franca.feature_3.1.4.qualifier.jar" id="org.genivi.commonapi.console.franca.feature" version="3.1.4.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 969744b..870d24c 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.3" 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.4" 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 0568d1b..f52b7e1 100644
--- a/org.genivi.commonapi.core.cli.product/pom.xml
+++ b/org.genivi.commonapi.core.cli.product/pom.xml
@@ -112,8 +112,14 @@
<configuration>
<target>
<zip excludesfile="zip.excludes"
+ excludes="commonapi-generator-linux-x86,commonapi-generator-linux-x86_64,commonapi-generator-windows-x86.exe,commonapi-generator-windows-x86_64.exe"
destfile="${project.build.directory}/products/commonapi-generator.zip"
- basedir="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all" />
+ basedir="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all">
+ <zipfileset file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all/commonapi-generator-linux-x86" filemode="777"/>
+ <zipfileset file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all/commonapi-generator-linux-x86_64" filemode="777"/>
+ <zipfileset file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all/commonapi-generator-windows-x86.exe" filemode="777"/>
+ <zipfileset file="${project.build.directory}/products/org.genivi.commonapi.core.cli.product/all/commonapi-generator-windows-x86_64.exe" filemode="777"/>
+ </zip>
</target>
</configuration>
<goals>
@@ -127,7 +133,7 @@
<parent>
<groupId>commonapi</groupId>
<artifactId>org.genivi.commonapi.core.releng</artifactId>
- <version>3.1.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
<relativePath>../org.genivi.commonapi.core.releng</relativePath>
</parent>
-</project> \ No newline at end of file
+</project>
diff --git a/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF b/org.genivi.commonapi.core.cli/META-INF/MANIFEST.MF
index 55e499a..f58939d 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.3.qualifier
+Bundle-Version: 3.1.4.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.3";visibility:=reexport,
- org.genivi.commonapi.console;bundle-version="3.1.3"
+ org.genivi.commonapi.core;bundle-version="3.1.4";visibility:=reexport,
+ org.genivi.commonapi.console;bundle-version="3.1.4"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-Vendor: BMW AG
diff --git a/org.genivi.commonapi.core.cli/plugin.xml b/org.genivi.commonapi.core.cli/plugin.xml
index 44db8ad..a117de6 100644
--- a/org.genivi.commonapi.core.cli/plugin.xml
+++ b/org.genivi.commonapi.core.cli/plugin.xml
@@ -23,6 +23,15 @@
<options>
<option
argCount="0"
+ description="Switch off generation of common code"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.noproxy"
+ longName="no-common"
+ required="false"
+ shortName="nc">
+ </option>
+ <option
+ argCount="0"
description="Switch off generation of proxy code"
hasOptionalArg="false"
id="org.genivi.commonapi.core.cli.option.noproxy"
@@ -85,13 +94,13 @@
shortName="dsk">
</option>
<option
- argCount="1"
- description="Switch on/off validation of the fidl file"
+ argCount="0"
+ description="Switch off validation of the fidl file"
hasOptionalArg="false"
id="org.genivi.commonapi.core.cli.option.validation"
- longName="validation"
+ longName="no-val"
required="false"
- shortName="val">
+ shortName="nv">
</option>
<option
argCount="1"
@@ -129,7 +138,52 @@
required="false"
shortName="sk">
</option>
- </options>
+ <option
+ argCount="0"
+ description="Print out generated files"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.printFiles"
+ longName="printfiles"
+ required="false"
+ shortName="pf">
+ </option>
+ <option
+ argCount="1"
+ description="The search path to contain fidl/fdepl files"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.searchpath"
+ longName="searchpath"
+ required="false"
+ shortName="sp">
+ </option>
+ <option
+ argCount="0"
+ description="Switch off code generation completely"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.nogeneration"
+ longName="no-gen"
+ required="false"
+ shortName="ng">
+ </option>
+ <option
+ argCount="0"
+ description="Switch off code generation of dependencies"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.nodependencies"
+ longName="without-dependencies"
+ required="false"
+ shortName="wod">
+ </option>
+ <option
+ argCount="0"
+ description="Switch off code generation of synchronous methods"
+ hasOptionalArg="false"
+ id="org.genivi.commonapi.core.cli.option.nosynccalls"
+ longName="no-sync-calls"
+ required="false"
+ shortName="nsc">
+ </option>
+ </options>
</command>
</extension>
</plugin>
diff --git a/org.genivi.commonapi.core.cli/pom.xml b/org.genivi.commonapi.core.cli/pom.xml
index 9395a3b..0f871c3 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.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
<relativePath>../org.genivi.commonapi.core.releng</relativePath>
</parent>
</project>
diff --git a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandLineHandler.java b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandLineHandler.java
index b17e75f..fbc1fe2 100644
--- a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandLineHandler.java
+++ b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandLineHandler.java
@@ -1,9 +1,17 @@
+/*
+ * Copyright (C) 2013 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/.
+ */
package org.genivi.commonapi.core.cli;
import java.util.List;
import org.apache.commons.cli.CommandLine;
import org.genivi.commonapi.console.AbstractCommandLineHandler;
+import org.genivi.commonapi.console.ConsoleLogger;
import org.genivi.commonapi.console.ICommandLineHandler;
@@ -33,6 +41,7 @@ public class CommandLineHandler extends AbstractCommandLineHandler implements
if(parsedArguments.hasOption("ll")) {
cliTool.setLogLevel(parsedArguments.getOptionValue("ll"));
}
+ ConsoleLogger.printLog("Executing CommonAPI Core Code Generation...\n");
if(parsedArguments.hasOption("sk")) {
// Switch on generation of skeletons (if this option has a parameter,
@@ -53,12 +62,24 @@ public class CommandLineHandler extends AbstractCommandLineHandler implements
cliTool.setSkeletonPostfix(skArgument);
}
}
+ // a search path may be specified, collect all fidl/fdepl files
+ if(parsedArguments.hasOption("sp")) {
+ String searchPath = parsedArguments.getOptionValue("sp");
+ files.addAll(cliTool.searchFidlandFdeplFiles(searchPath));
+ }
+
// we expect at least the fidel/fdepl file as command line argument
if(files.size() > 0 && files.get(0) != null) {
String file = files.get(0);
if(file.endsWith(FILE_EXTENSION_FDEPL) || file.endsWith(FILE_EXTENSION_FIDL)) {
// handle command line options
+ // Switch off generation of common code
+ // -nc --no-common do not generate common code
+ if(parsedArguments.hasOption("nc")) {
+ cliTool.setNoCommonCode();
+ }
+
// Switch off generation of proxy code
// -np --no-proxy do not generate proxy code
if(parsedArguments.hasOption("np")) {
@@ -88,7 +109,7 @@ public class CommandLineHandler extends AbstractCommandLineHandler implements
// destination: -ds --dest-stub overwrite target directory for stub code
if(parsedArguments.hasOption("ds")) {
- cliTool.setStubtDirectory(parsedArguments.getOptionValue("ds"));
+ cliTool.setStubDirectory(parsedArguments.getOptionValue("ds"));
}
// destination: -dsk --dest-skel overwrite target directory for skeleton code
@@ -107,12 +128,26 @@ public class CommandLineHandler extends AbstractCommandLineHandler implements
if(parsedArguments.hasOption("pre")) {
cliTool.setEnumPrefix(parsedArguments.getOptionValue("pre"));
}
-
- // Switch on/off validation
- if(parsedArguments.hasOption("val")) {
- cliTool.enableValidation(parsedArguments.getOptionValue("val"));
+ // Switch off validation
+ if(parsedArguments.hasOption("nv")) {
+ cliTool.disableValidation();
+ }
+ // Switch off code generation
+ if(parsedArguments.hasOption("ng")) {
+ cliTool.disableCodeGeneration();
+ }
+ // Don't generate code for included types and interfaces
+ if(parsedArguments.hasOption("wod")) {
+ cliTool.noCodeforDependencies();
+ }
+ // Don't generate synchronous calls
+ if(parsedArguments.hasOption("nsc")) {
+ cliTool.disableSyncCalls();
+ }
+ // print out generated files
+ if(parsedArguments.hasOption("pf")) {
+ cliTool.listGeneratedFiles();
}
-
// finally invoke the generator.
// the remaining arguments are assumed to be files !
cliTool.generateCore(files);
diff --git a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java
index 0d2c49d..c7be6ab 100644
--- a/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java
+++ b/org.genivi.commonapi.core.cli/src/org/genivi/commonapi/core/cli/CommandlineToolMain.java
@@ -8,158 +8,95 @@
package org.genivi.commonapi.core.cli;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Set;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.generator.IGenerator;
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.validation.AbstractValidationMessageAcceptor;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
import org.franca.core.dsl.FrancaIDLRuntimeModule;
import org.franca.core.franca.FModel;
+import org.franca.deploymodel.dsl.fDeploy.FDModel;
+import org.genivi.commonapi.console.CommandlineTool;
import org.genivi.commonapi.console.ConsoleLogger;
import org.genivi.commonapi.core.generator.FrancaGenerator;
import org.genivi.commonapi.core.generator.FrancaGeneratorExtensions;
+import org.genivi.commonapi.core.generator.GeneratorFileSystemAccess;
import org.genivi.commonapi.core.preferences.FPreferences;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
+import org.genivi.commonapi.core.verification.CommandlineValidator;
import org.genivi.commonapi.core.verification.ValidatorCore;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
- * Receive command line arguments and set them as preference values for the code generation.
+ * Receive command line arguments and set them as preference values for the code
+ * generation.
*/
-public class CommandlineToolMain
-{
-
- public static final String FILESEPARATOR = System.getProperty("file.separator");
-
- public static List<String> files = new ArrayList<String>();
- // All given files were saved in this list with an absolute path
- protected static Set<String> filelist = new LinkedHashSet<String>();
- // true if for all interfaces have to be generated the stubs
- protected static boolean allstubs = false;
-
- protected JavaIoFileSystemAccess fsa;
- private FPreferences pref;
- protected Injector injector;
- private List<String> tempfilelist;
-
- protected IGenerator francaGenerator;
-
- protected ValidatorCore validator;
- private int validationErrorCount;
- protected String SCOPE = "Core validation: ";
- private boolean isValidation = true;
- public static final int ERROR_STATE = 1;
- public static final int NO_ERROR_STATE = 0;
-
+public class CommandlineToolMain extends CommandlineTool {
+
+ protected GeneratorFileSystemAccess fsa;
+ private FPreferences pref;
+ protected Injector injector;
+ protected IGenerator francaGenerator;
+ protected String scope = "Core validation: ";
+
private ValidationMessageAcceptor cliMessageAcceptor = new AbstractValidationMessageAcceptor() {
@Override
- public void acceptInfo(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
- ConsoleLogger.printLog(SCOPE + message);
+ public void acceptInfo(String message, EObject object,
+ EStructuralFeature feature, int index, String code,
+ String... issueData) {
+ ConsoleLogger.printLog(scope + message);
}
@Override
- public void acceptWarning(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
- ConsoleLogger.printLog("Warning: " + SCOPE + message);
+ public void acceptWarning(String message, EObject object,
+ EStructuralFeature feature, int index, String code,
+ String... issueData) {
+ ConsoleLogger.printLog("Warning: " + scope + message);
}
@Override
- public void acceptError(String message, EObject object, EStructuralFeature feature, int index, String code, String... issueData) {
- validationErrorCount++;
- ConsoleLogger.printLog("Error: " + SCOPE + message);
+ public void acceptError(String message, EObject object,
+ EStructuralFeature feature, int index, String code,
+ String... issueData) {
+ hasValidationError = true;
+ ConsoleLogger.printErrorLog("Error: " + scope + message);
}
};
/**
* The constructor registers the needed bindings to use the generator
*/
- public CommandlineToolMain()
- {
+ public CommandlineToolMain() {
+
injector = Guice.createInjector(new FrancaIDLRuntimeModule());
- fsa = injector.getInstance(JavaIoFileSystemAccess.class);
+ fsa = injector.getInstance(GeneratorFileSystemAccess.class);
pref = FPreferences.getInstance();
- validator = new ValidatorCore();
-
- }
-
- /**
- * Set the text from a file which will be inserted as a comment in each generated file (for example your license)
- *
- * @param fileWithText
- * @return
- */
- public void setLicenseText(String fileWithText) {
- if (fileWithText != null && !fileWithText.isEmpty())
- {
- File file = new File(createAbsolutPath(fileWithText));
- if (!file.exists() || file.isDirectory())
- {
- ConsoleLogger.printErrorLog("Please specify a path to an existing file after option -l");
- }
- BufferedReader inReader = null;
- String licenseText = "";
- try
- {
- inReader = new BufferedReader(new FileReader(file));
- String thisLine;
- while ((thisLine = inReader.readLine()) != null)
- {
- licenseText = licenseText + thisLine + "\n";
- }
- if (licenseText != null && !licenseText.isEmpty())
- {
- pref.setPreference(PreferenceConstants.P_LICENSE, licenseText);
- }
- }
- catch (IOException e)
- {
- ConsoleLogger.printLog("Failed to set the text from the given file: " + e.getLocalizedMessage());
- }
- finally
- {
- try
- {
- inReader.close();
- }
- catch (Exception e)
- {
- ;
- }
- }
- ConsoleLogger.printLog("The following text was set as header: \n" + licenseText);
- }
- else
- {
- ConsoleLogger.printErrorLog("Please write a path to an existing file after -p");
- }
}
- public void generateCore(List<String> fileList)
- {
+ public void generateCore(List<String> fileList) {
francaGenerator = injector.getInstance(FrancaGenerator.class);
doGenerate(fileList);
}
+
+ protected String normalize(String _path) {
+ File itsFile = new File(_path);
+ return itsFile.getAbsolutePath();
+ }
+
/**
* Call the franca generator for the specified list of files.
@@ -167,226 +104,132 @@ public class CommandlineToolMain
* @param fileList
* the list of files to generate code from
*/
- protected void doGenerate(List<String> fileList)
- {
- fsa.setOutputConfigurations(FPreferences.getInstance().getOutputpathConfiguration());
-
- XtextResourceSet rsset = injector.getProvider(XtextResourceSet.class).get();
-
- tempfilelist = new ArrayList<String>();
-
- /*
- * Reading the options and the files given in the arguments and they
- * will be saved in the predefined attributes
- */
- String francaversion = getFrancaVersion();
- String coreversion = FrancaGeneratorExtensions.getCoreVersion();
- for (String element : fileList)
- {
- File file = new File(createAbsolutPath(element));
- if (!file.exists() || file.isDirectory())
- {
- ConsoleLogger.printErrorLog("The following path won't be generated because it doesn't exists:\n" + element + "\n");
- }
- else
- tempfilelist.add(createAbsolutPath(element));
- }
- if (tempfilelist.size() == 0)
- {
- ConsoleLogger.printErrorLog("There are no valid files to generate !");
- return;
- }
- ConsoleLogger.printLog("Using Franca Version " + francaversion);
- ConsoleLogger.printLog("and CommonAPI Version " + coreversion);
+ protected void doGenerate(List<String> _fileList) {
+ fsa.setOutputConfigurations(FPreferences.getInstance()
+ .getOutputpathConfiguration());
+
+ XtextResourceSet rsset = injector.getProvider(XtextResourceSet.class)
+ .get();
+ ConsoleLogger.printLog("Using Franca Version " + getFrancaVersion());
+ ConsoleLogger.printLog("and CommonAPI Version "
+ + FrancaGeneratorExtensions.getCoreVersion());
int error_state = NO_ERROR_STATE;
- for (String file : tempfilelist)
- {
+
+ // Create absolute paths
+ List<String> fileList = new ArrayList<String>();
+ for (String path : _fileList) {
+ String absolutePath = normalize(path);
+ fileList.add(absolutePath);
+ }
+
+ for (String file : fileList) {
URI uri = URI.createFileURI(file);
Resource resource = null;
try {
resource = rsset.createResource(uri);
} catch (IllegalStateException ise) {
- // In case we have a search path with several fidl and fdepl files that have includes to each other:
- // This resource may have been already registered. Don't worry, continue.
+ ConsoleLogger.printErrorLog("Failed to create a resource from "
+ + file + "\n" + ise.getMessage());
+ error_state = ERROR_STATE;
continue;
}
- validationErrorCount = 0;
- if(isValidation) {
- validate(resource);
- }
- if(validationErrorCount == 0) {
+ hasValidationError = false;
+ if (isValidation) {
+ validateCore(resource);
+ }
+ if (hasValidationError) {
+ ConsoleLogger.printErrorLog(file
+ + " contains validation errors !");
+ error_state = ERROR_STATE;
+ } else if (isCodeGeneration) {
ConsoleLogger.printLog("Generating code for " + file);
try {
francaGenerator.doGenerate(resource, fsa);
- }
- catch (Exception e) {
- System.err.println("Failed to generate code for " + file + " due to " + e.getMessage());
+ } catch (Exception e) {
+ System.err.println("Failed to generate code for " + file
+ + " due to " + e.getMessage());
error_state = ERROR_STATE;
- }
+ }
}
- else {
- ConsoleLogger.printErrorLog(file + " contains validation errors !");
- error_state = ERROR_STATE;
+ if (resource != null) {
+ // Clear each resource from the resource set in order to let
+ // other fidl files import it.
+ // Otherwise an IllegalStateException will be thrown for a
+ // resource that was already created.
+ resource.unload();
+ rsset.getResources().clear();
}
}
- System.exit(error_state);
- }
-
- private void validate(Resource resource) {
- EObject model = null;
-
- if(resource != null && resource.getURI().isFile()) {
-
- try {
- resource.load(Collections.EMPTY_MAP);
- model = resource.getContents().get(0);
- } catch (IOException e) {
- e.printStackTrace();
- }
- ConsoleLogger.printLog("validating...");
-
- // check for (internal )resource validation errors
- for(org.eclipse.emf.ecore.resource.Resource.Diagnostic error : resource.getErrors()) {
- ConsoleLogger.printErrorLog("ERROR at line: " + error.getLine() + " : " + error.getMessage());
- validationErrorCount++;
- }
-
- // check for external validation errors if no errors have been detected so far
- if(validationErrorCount == 0 ) {
- if( model instanceof FModel) {
- FModel fmodel = (FModel)model;
- try {
- validator.validateModel(fmodel, cliMessageAcceptor);
- } catch (Exception e) {
- ConsoleLogger.printErrorLog(e.getMessage());
- validationErrorCount++;
- }
- }
- }
+ if (dumpGeneratedFiles) {
+ fsa.dumpGeneratedFiles();
}
+ fsa.clearFileList();
+ dumpGeneratedFiles = false;
+ System.exit(error_state);
}
/**
- * creates a absolute path from a relative path which starts on the current
- * user directory
- *
- * @param path
- * the relative path which start on the current user-directory
- * @return the created absolute path
- */
- public String createAbsolutPath(String path)
- {
- return createAbsolutPath(path, System.getProperty("user.dir") + FILESEPARATOR);
- }
-
- /**
- * Here we create an absolute path from a relativ path and a rootpath from
- * which the relative path begins
+ * Validate the fidl/fdepl file resource
*
- * @param path
- * the relative path which begins on rootpath
- * @param rootpath
- * an absolute path to a folder
- * @return the merded absolute path without points
+ * @param resource
*/
- private String createAbsolutPath(String path, String rootpath)
- {
- if (System.getProperty("os.name").contains("Windows"))
- {
- if (path.startsWith(":", 1))
- return path;
- }
- else
- {
- if (path.startsWith(FILESEPARATOR))
- return path;
- }
+ private void validateCore(Resource resource) {
+ EObject model = null;
+ CommandlineValidator cliValidator = new CommandlineValidator(
+ cliMessageAcceptor);
- String ret = (rootpath.endsWith(FILESEPARATOR) ? rootpath : (rootpath + FILESEPARATOR)) + path;
- while (ret.contains(FILESEPARATOR + "." + FILESEPARATOR) || ret.contains(FILESEPARATOR + ".." + FILESEPARATOR))
- {
- if (ret.contains(FILESEPARATOR + ".." + FILESEPARATOR))
- {
- String temp = ret.substring(0, ret.indexOf(FILESEPARATOR + ".."));
- temp = temp.substring(0, temp.lastIndexOf(FILESEPARATOR));
- ret = temp + ret.substring(ret.indexOf(FILESEPARATOR + "..") + 3);
- }
- else
- {
- ret = replaceAll(ret, FILESEPARATOR + "." + FILESEPARATOR, FILESEPARATOR);
- }
- }
- return ret;
- }
+ //ConsoleLogger.printLog("validating " + resource.getURI().lastSegment());
+ model = cliValidator.loadResource(resource);
- /**
- * a relaceAll Method which doesn't interprets the toreplace String as a
- * regex and so you can also replace \ and such special things
- *
- * @param text
- * the text who has to be modified
- * @param toreplace
- * the text which has to be replaced
- * @param replacement
- * the text which has to be inserted instead of toreplace
- * @return the modified text with all toreplace parts replaced with
- * replacement
- */
- public String replaceAll(String text, String toreplace, String replacement)
- {
- String ret = "";
- while (text.contains(toreplace))
- {
- ret += text.substring(0, text.indexOf(toreplace)) + replacement;
- text = text.substring(text.indexOf(toreplace) + toreplace.length());
- }
- ret += text;
- return ret;
- }
+ if (model != null) {
+ // check existence of imported fidl/fdepl files
+ if (model instanceof FModel) {
+ cliValidator.validateImports((FModel) model, resource.getURI());
- /**
- * removes recursively all files on the path and his folders and at the end
- * himself
- *
- * @param path
- * the path to the folder which has to be deleted
- */
- public void deleteTempFiles(File path)
- {
- if (path != null && path.isDirectory())
- {
- for (File file : path.listFiles())
- {
- if (file.isDirectory())
- deleteTempFiles(file);
- file.delete();
+ // validate against GENIVI rules
+ ValidatorCore validator = new ValidatorCore();
+ try {
+ validator.validateModel((FModel) model, cliMessageAcceptor);
+ } catch (Exception e) {
+ ConsoleLogger.printErrorLog(e.getMessage());
+ hasValidationError = true;
+ return;
+ }
+ }
+ if (model instanceof FDModel) {
+ // don't validate fdepl files at the moment
+ return;
+ // cliValidator.validateImports((FDModel) model, resource.getURI());
}
+ // XText validation
+ cliValidator.validateResourceWithImports(resource);
+ } else {
+ // model is null, no resource factory was registered !
+ hasValidationError = true;
}
- if (path != null)
- path.delete();
}
- public String getFrancaVersion()
- {
- return Platform.getBundle("org.franca.core").getVersion().toString();
+ public void setNoCommonCode() {
+ pref.setPreference(PreferenceConstants.P_GENERATE_COMMON, "false");
+ ConsoleLogger.printLog("No common code will be generated");
}
-
+
public void setNoProxyCode() {
- pref.setPreference(PreferenceConstants.P_GENERATEPROXY, "false");
+ pref.setPreference(PreferenceConstants.P_GENERATE_PROXY, "false");
ConsoleLogger.printLog("No proxy code will be generated");
}
public void setNoStubCode() {
- pref.setPreference(PreferenceConstants.P_GENERATESTUB, "false");
+ pref.setPreference(PreferenceConstants.P_GENERATE_STUB, "false");
ConsoleLogger.printLog("No stub code will be generated");
}
public void setDefaultDirectory(String optionValue) {
ConsoleLogger.printLog("Default output directory: " + optionValue);
pref.setPreference(PreferenceConstants.P_OUTPUT_DEFAULT, optionValue);
- // In the case where no other output directories are set,
+ // In the case where no other output directories are set,
// this default directory will be used for them
pref.setPreference(PreferenceConstants.P_OUTPUT_COMMON, optionValue);
pref.setPreference(PreferenceConstants.P_OUTPUT_PROXIES, optionValue);
@@ -404,7 +247,7 @@ public class CommandlineToolMain
pref.setPreference(PreferenceConstants.P_OUTPUT_PROXIES, optionValue);
}
- public void setStubtDirectory(String optionValue) {
+ public void setStubDirectory(String optionValue) {
ConsoleLogger.printLog("Stub output directory: " + optionValue);
pref.setPreference(PreferenceConstants.P_OUTPUT_STUBS, optionValue);
}
@@ -415,25 +258,25 @@ public class CommandlineToolMain
}
public void setLogLevel(String optionValue) {
- if(PreferenceConstants.LOGLEVEL_QUIET.equals(optionValue)) {
+ if (PreferenceConstants.LOGLEVEL_QUIET.equals(optionValue)) {
pref.setPreference(PreferenceConstants.P_LOGOUTPUT, "false");
ConsoleLogger.enableLogging(false);
ConsoleLogger.enableErrorLogging(false);
}
- if(PreferenceConstants.LOGLEVEL_VERBOSE.equals(optionValue)) {
+ if (PreferenceConstants.LOGLEVEL_VERBOSE.equals(optionValue)) {
pref.setPreference(PreferenceConstants.P_LOGOUTPUT, "true");
ConsoleLogger.enableErrorLogging(true);
ConsoleLogger.enableLogging(true);
}
}
- public void setEnumPrefix(String optionValue) {
+ public void setEnumPrefix(String optionValue) {
pref.setPreference(PreferenceConstants.P_ENUMPREFIX, optionValue);
ConsoleLogger.printLog("Enum prefix: " + optionValue);
}
public void setCreateSkeletonCode() {
- pref.setPreference(PreferenceConstants.P_GENERATESKELETON, "true");
+ pref.setPreference(PreferenceConstants.P_GENERATE_SKELETON, "true");
ConsoleLogger.printLog("Skeleton code will be created");
}
@@ -442,11 +285,52 @@ public class CommandlineToolMain
pref.setPreference(PreferenceConstants.P_SKELETONPOSTFIX, postfix);
ConsoleLogger.printLog("Skeleton postfix: " + postfix);
}
-
- public void enableValidation(String optionValue) {
- if(optionValue.equals("no") || optionValue.equals("off")) {
- ConsoleLogger.printLog("Validation is off");
- isValidation = false;
+
+ public void disableValidation() {
+ ConsoleLogger.printLog("Validation is off");
+ isValidation = false;
+ }
+
+ /**
+ * Set the text from a file which will be inserted as a comment in each
+ * generated file (for example your license)
+ *
+ * @param fileWithText
+ * @return
+ */
+ public void setLicenseText(String fileWithText) {
+
+ String licenseText = getLicenseText(fileWithText);
+
+ if (licenseText != null && !licenseText.isEmpty()) {
+ pref.setPreference(PreferenceConstants.P_LICENSE, licenseText);
}
- }
+ }
+
+ /**
+ * set a preference value to disable code generation
+ */
+ public void disableCodeGeneration() {
+ ConsoleLogger.printLog("Code generation is off");
+ pref.setPreference(PreferenceConstants.P_GENERATE_CODE, "false");
+ }
+
+ /**
+ * Set a preference value to disable code generation for included types and
+ * interfaces
+ */
+ public void noCodeforDependencies() {
+ ConsoleLogger.printLog("Code generation for dependencies is switched off");
+ pref.setPreference(PreferenceConstants.P_GENERATE_DEPENDENCIES, "false");
+ }
+
+ public void listGeneratedFiles() {
+ dumpGeneratedFiles = true;
+ }
+
+ public void disableSyncCalls() {
+ ConsoleLogger.printLog("Code generation for synchronous calls is off");
+ pref.setPreference(PreferenceConstants.P_GENERATE_SYNC_CALLS, "false");
+ }
+
}
diff --git a/org.genivi.commonapi.core.feature/feature.xml b/org.genivi.commonapi.core.feature/feature.xml
index b1fd26a..53c2e15 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.3.qualifier"
+ version="3.1.4.qualifier"
provider-name="%providerName">
<copyright>
diff --git a/org.genivi.commonapi.core.feature/pom.xml b/org.genivi.commonapi.core.feature/pom.xml
index 738f630..fcfc7fa 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 57b2a0b..a84574f 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 bc18d62..5331992 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 6026889..2b81942 100644
--- a/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF
+++ b/org.genivi.commonapi.core.ui/META-INF/MANIFEST.MF
@@ -2,22 +2,22 @@ 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.3.qualifier
+Bundle-Version: 3.1.4.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,
org.eclipse.core.resources;bundle-version="[3.9.0,4.0.0)";visibility:=reexport,
org.eclipse.core.expressions;bundle-version="[3.4.400,4.0.0)";visibility:=reexport,
org.eclipse.ui,
- org.eclipse.cdt.ui;bundle-version="[5.5.0,6.0.0)";visibility:=reexport,
org.eclipse.xtext.ui;bundle-version="[2.7.0,3.0.0)";visibility:=reexport,
org.eclipse.xtext.ui.ecore;bundle-version="[2.7.0,3.0.0)";visibility:=reexport,
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.3";visibility:=reexport,
+ org.genivi.commonapi.core;bundle-version="3.1.4";visibility:=reexport,
org.franca.core.dsl.ui;bundle-version="0.9.1",
- org.franca.deploymodel.dsl.ui;bundle-version="0.9.1"
+ org.franca.deploymodel.dsl.ui;bundle-version="0.9.1",
+ org.eclipse.ui.console;bundle-version="[3.5.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.genivi.commonapi.core.ui,
diff --git a/org.genivi.commonapi.core.ui/plugin.xml b/org.genivi.commonapi.core.ui/plugin.xml
index 3f28f6f..58c503e 100644
--- a/org.genivi.commonapi.core.ui/plugin.xml
+++ b/org.genivi.commonapi.core.ui/plugin.xml
@@ -82,7 +82,7 @@
</adapt>
</iterate>
</or>
- </definition>
+ </definition>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
@@ -93,7 +93,7 @@
</page>
</extension> <extension
point="org.eclipse.core.runtime.preferences">
- <initializer
+ <initializer
class="org.genivi.commonapi.core.ui.preferences.PreferenceInitializer">
</initializer>
</extension>
@@ -102,20 +102,20 @@
<page
class="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage"
id="org.genivi.commonapi.core.ui.preferences.property.CommonAPIPreferencePage"
- name="CommonAPI"
- objectClass="org.eclipse.core.resources.IProject">
- </page>
- <page
- class="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage"
- id="org.genivi.commonapi.core.ui.preferences.property.CommonAPIPreferencePage"
- name="CommonAPI"
- objectClass="org.eclipse.core.resources.IFolder">
- </page>
- <page
- class="org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage"
- id="org.genivi.commonapi.core.ui.preferences.property.CommonAPIPreferencePage"
- name="CommonAPI"
- objectClass="org.eclipse.core.resources.IFile">
+ name="CommonAPI">
+ <enabledWhen>
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IFolder">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ </or>
+ </enabledWhen>
</page>
</extension>
<extension
diff --git a/org.genivi.commonapi.core.ui/pom.xml b/org.genivi.commonapi.core.ui/pom.xml
index 7022959..f74ba1a 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.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
<relativePath>../org.genivi.commonapi.core.releng</relativePath>
</parent>
</project>
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
index a842602..2b0af48 100644
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/handler/GenerationCommand.java
@@ -8,7 +8,10 @@
package org.genivi.commonapi.core.ui.handler;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import javax.inject.Inject;
@@ -26,7 +29,9 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -35,17 +40,33 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.console.MessageConsoleStream;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
+import org.eclipse.xtext.diagnostics.Severity;
import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
+import org.eclipse.xtext.util.IAcceptor;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
+import org.eclipse.xtext.validation.CheckMode;
+import org.eclipse.xtext.validation.DiagnosticConverterImpl;
+import org.eclipse.xtext.validation.IResourceValidator;
+import org.eclipse.xtext.validation.Issue;
+import org.franca.core.dsl.FrancaIDLRuntimeModule;
+import org.franca.core.dsl.FrancaImportsProvider;
+import org.franca.core.dsl.ui.util.SpecificConsole;
+import org.franca.core.utils.ModelPersistenceHandler;
+import org.franca.deploymodel.dsl.FDeployImportsProvider;
+import org.franca.deploymodel.dsl.fDeploy.FDModel;
import org.genivi.commonapi.core.preferences.FPreferences;
import org.genivi.commonapi.core.preferences.PreferenceConstants;
import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
import com.google.inject.Provider;
public class GenerationCommand extends AbstractHandler {
@@ -78,6 +99,8 @@ public class GenerationCommand extends AbstractHandler {
private void executeGeneratorForSelection(
final IStructuredSelection structuredSelection) {
IProject project = null;
+ final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
+
for (Iterator<?> iterator = structuredSelection.iterator(); iterator
.hasNext();) {
final Object selectiobObject = iterator.next();
@@ -89,11 +112,16 @@ public class GenerationCommand extends AbstractHandler {
.getProject());
final Resource r = rs.getResource(uri, true);
- project = file.getProject();
+ project = file.getProject();
+
+ setupPreferences(file);
- setupPreferences(file);
+ // Clear any already existing output from a previous command execution (e.g. errors) from the Franca console
+ // by creating a new one or initializing an already existing one.
+ //
+ final SpecificConsole francaConsole = new SpecificConsole("Franca");
+ francaConsole.getOut().println("Loading " + file.getFullPath().toPortableString());
- final EclipseResourceFileSystemAccess2 fileSystemAccess = createFileSystemAccess();
fileSystemAccess.setProject(project);
Job job = new Job("validation and generation") {
@@ -114,34 +142,195 @@ public class GenerationCommand extends AbstractHandler {
} catch (CoreException ce) {
}
+
+ // Validation of FIDL and FDEPL and all imported FIDL/FDEPL files.
+ try {
+ if (!validate(uri, francaConsole)) {
+ validatorErrorPopUp(file);
+ outputCancelResult(francaConsole);
+ return Status.CANCEL_STATUS;
+ }
+ }
+ catch (Exception ex) {
+ validatorExceptionPopUp(ex, file);
+ outputCancelResult(francaConsole);
+ return Status.CANCEL_STATUS;
+ }
+
if (r.getErrors().size() == 0 && i == 0) {
monitor.subTask("Generate");
try {
francaGenerator.doGenerate(r, fileSystemAccess);
} catch (Exception e) {
exceptionPopUp(e, file);
+ outputCancelResult(francaConsole);
return Status.CANCEL_STATUS;
} catch (Error e) {
errorPopUp(e, file);
+ outputCancelResult(francaConsole);
return Status.CANCEL_STATUS;
}
+ outputSuccessResult(francaConsole);
return Status.OK_STATUS;
- } else {
- markerPopUp(file);
- return Status.CANCEL_STATUS;
}
-
+ markerPopUp(file, r);
+ outputCancelResult(francaConsole);
+ return Status.CANCEL_STATUS;
}
};
job.schedule();
+ // wait for this job to end
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ exceptionPopUp(e, file);
+ }
}
}
}
- /**
+ protected boolean validate(URI resourcePathUri, SpecificConsole francaConsole)
+ {
+ // Load the FIDL and all imported FIDL files, or the FDEPL and all imported FDEPL/FIDL files.
+ //
+ ModelPersistenceHandler.registerFileExtensionHandler("fidl", new FrancaImportsProvider());
+ ModelPersistenceHandler.registerFileExtensionHandler("fdepl", new FDeployImportsProvider());
+ Injector injector = Guice.createInjector(new FrancaIDLRuntimeModule());
+ ModelPersistenceHandler modelPersistenceHandler = new ModelPersistenceHandler(injector.getInstance(ResourceSet.class));
+ URI rootPathUri = URI.createPlatformResourceURI("/", true);
+ modelPersistenceHandler.loadModel(resourcePathUri, rootPathUri);
+
+ if ("fdepl".equals(resourcePathUri.fileExtension()))
+ {
+ if (!validateDeployment(modelPersistenceHandler.getResourceSet(), francaConsole))
+ return false;
+ }
+
+ // Validate all loaded FDEPL and FIDL files.
+ francaConsole.getOut().println("Validating " + getDisplayPath(resourcePathUri));
+ return validate(modelPersistenceHandler.getResourceSet(), francaConsole);
+ }
+
+ protected boolean validate(ResourceSet resourceSet, SpecificConsole francaConsole)
+ {
+ boolean hasValidationError = false;
+ for (Resource resource : resourceSet.getResources())
+ {
+ //francaConsole.getOut().println("Validating " + getDisplayPath(resource.getURI()));
+ if (!validate(resource, francaConsole))
+ hasValidationError = true;
+ }
+ return !hasValidationError;
+ }
+
+ protected boolean validate(Resource resource, SpecificConsole francaConsole)
+ {
+ boolean hasValidationError = false;
+ IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI());
+ if (resourceServiceProvider != null)
+ {
+ IResourceValidator resourceValidator = resourceServiceProvider.getResourceValidator();
+ Collection<Issue> issues = resourceValidator.validate(resource, CheckMode.ALL, null);
+ if (!outputIssues(issues, francaConsole))
+ hasValidationError = true;
+ }
+ return !hasValidationError;
+ }
+
+ private boolean outputIssues(Collection<Issue> issues, SpecificConsole francaConsole)
+ {
+ boolean hasValidationError = false;
+ for (Issue issue : issues)
+ {
+ if (issue.getSeverity() == Severity.ERROR) {
+ hasValidationError = true;
+ francaConsole.getErr().println(issue.toString());
+ }
+ else if (issue.getSeverity() == Severity.WARNING)
+ francaConsole.getOut().println(issue.toString());
+ }
+ return !hasValidationError;
+ }
+
+ String getDisplayPath(URI uri)
+ {
+ String displayPath = null;
+ if (uri.isPlatformResource())
+ displayPath = uri.toPlatformString(true);
+ if (displayPath == null)
+ displayPath = uri.toFileString();
+ if (displayPath == null)
+ displayPath = uri.toString();
+ return displayPath;
+ }
+
+ private void outputSuccessResult(SpecificConsole console)
+ {
+ console.getOut().println("Code generation finished successfully.");
+ }
+
+ private void outputCancelResult(SpecificConsole console)
+ {
+ console.getOut().println("Code generation aborted.");
+ }
+
+ protected boolean validateDeployment(ResourceSet resourceSet, SpecificConsole francaConsole)
+ {
+ boolean hasValidationError = false;
+
+ List<FDModel> fdeplModels = new ArrayList<FDModel>();
+ for (Resource resource : resourceSet.getResources())
+ {
+ for (EObject eObject : resource.getContents())
+ {
+ if (eObject instanceof FDModel)
+ {
+ fdeplModels.add((FDModel)eObject);
+ }
+ }
+ }
+
+ //francaConsole.getOut().println("Validating deployment");
+
+ List<Diagnostic> diags = validateDeployment(fdeplModels);
+ if (diags != null)
+ {
+ int numErrors = 0, numWarnings = 0;
+ final List<Issue> issues = new ArrayList<Issue>();
+ IAcceptor<Issue> acceptor = new IAcceptor<Issue>()
+ {
+ @Override
+ public void accept(Issue issue)
+ {
+ issues.add(issue);
+ }
+ };
+ DiagnosticConverterImpl converter = new DiagnosticConverterImpl();
+ for (Diagnostic diag : diags)
+ {
+ converter.convertValidatorDiagnostic(diag, acceptor);
+ if (diag.getSeverity() == Diagnostic.ERROR)
+ numErrors++;
+ else if (diag.getSeverity() == Diagnostic.WARNING)
+ numWarnings++;
+ }
+ if (!outputIssues(issues, francaConsole))
+ hasValidationError = true;
+ francaConsole.getOut().println("Validaton of deployment finished with: " + numErrors + " errors, " + numWarnings + " warnings.");
+ }
+
+ return !hasValidationError;
+ }
+
+ protected List<Diagnostic> validateDeployment(List<FDModel> fdepls)
+ {
+ return null;
+ }
+
+ /**
* Init core preferences
- * @param file
+ * @param file
* @param page
* @param project
*/
@@ -221,7 +410,8 @@ public class GenerationCommand extends AbstractHandler {
final Exception ex = e;
final IFile file = f;
Display.getDefault().asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
ex.printStackTrace();
MessageDialog.openError(
null,
@@ -234,22 +424,43 @@ public class GenerationCommand extends AbstractHandler {
}
private void markerPopUp(IFile f) {
- final IFile file = f;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- MessageDialog.openError(
- null,
- "Error in file " + file.getName(),
- "Couldn't generate file. File still holds errors!\n\nSee Problems view for details.");
- }
- });
+ markerPopUp(f, null);
}
+ private void markerPopUp(final IFile file, final Resource resource)
+ {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (resource != null && resource.getErrors().size() > 0)
+ {
+ SpecificConsole francaConsole = new SpecificConsole("Franca");
+ MessageConsoleStream out = francaConsole.getOut();
+ for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diag : resource.getErrors())
+ {
+ StringBuffer msg = new StringBuffer();
+ msg.append(diag.getLocation() != null ? diag.getLocation() : file.getFullPath());
+ msg.append(":");
+ msg.append(diag.getLine());
+ msg.append(" ");
+ msg.append(diag.getMessage());
+ out.println(msg.toString());
+ }
+ }
+ MessageDialog.openError(
+ null,
+ "Error in file " + file.getName(),
+ "Couldn't generate file. File still holds errors!\n\nSee Problems view for details.");
+ }
+ });
+ }
+
private void errorPopUp(Error e, IFile f) {
final Error er = e;
final IFile file = f;
Display.getDefault().asyncExec(new Runnable() {
- public void run() {
+ @Override
+ public void run() {
er.printStackTrace();
MessageDialog.openError(
null,
@@ -261,6 +472,44 @@ public class GenerationCommand extends AbstractHandler {
});
}
+ private void validatorErrorPopUp(final IFile file)
+ {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(
+ null,
+ "Error by validating file " + file.getName(),
+ "Couldn't validate file.\n\nSee console view for details.");
+ }
+ });
+ }
+
+ private void validatorExceptionPopUp(final Exception ex, final IFile file) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ex.printStackTrace();
+ String exMessage = null;
+ if (ex.getCause() != null)
+ exMessage = ex.getCause().getMessage();
+ if (exMessage == null)
+ exMessage = ex.getMessage();
+
+ SpecificConsole francaConsole = new SpecificConsole("Franca");
+ MessageConsoleStream out = francaConsole.getOut();
+ out.println("ERROR: " + exMessage);
+
+ MessageDialog.openError(
+ null,
+ "Error by validating file " + file.getName(),
+ "Couldn't validate file. Exception occured:\n"
+ + exMessage
+ + "\n\nSee console view for details.");
+ }
+ });
+ }
+
protected EclipseResourceFileSystemAccess2 createFileSystemAccess() {
final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
@@ -275,23 +524,26 @@ public class GenerationCommand extends AbstractHandler {
/**
* Set the properties for the code generation from the resource properties (set with the property page, via the context menu).
* Take default values from the eclipse preference page.
- * @param file
+ * @param file
* @param store - the eclipse preference store
*/
private void initPreferences(IFile file, IPreferenceStore store) {
FPreferences instance = FPreferences.getInstance();
-
+
String outputFolderCommon = null;
String outputFolderProxies = null;
String outputFolderStubs = null;
String outputFolderSkeleton = null;
String licenseHeader = null;
+ String generateCommon = null;
String generateProxy = null;
- String generatStub = null;
- String generatSkeleton = null;
+ String generateStub = null;
+ String generateSkeleton = null;
+ String generateDependencies = null;
String skeletonPostfix = null;
String enumPrefix = null;
-
+ String generateSyncCalls = null;
+
IProject project = file.getProject();
IResource resource = file;
@@ -301,64 +553,78 @@ public class GenerationCommand extends AbstractHandler {
String useProject2 = file.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_USEPROJECTSETTINGS));
if("true".equals(useProject1) || "true".equals(useProject2)) {
resource = project;
- }
+ }
outputFolderCommon = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_COMMON));
outputFolderSkeleton = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_SKELETON));
outputFolderProxies = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_PROXIES));
outputFolderStubs = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_OUTPUT_STUBS));
licenseHeader = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_LICENSE));
- generateProxy = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATEPROXY));
- generatStub = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATESTUB));
- generatSkeleton = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATESKELETON));
+ generateCommon = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_COMMON));
+ generateProxy = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_PROXY));
+ generateStub = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_STUB));
+ generateSkeleton = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_SKELETON));
+ generateDependencies = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_DEPENDENCIES));
+ generateSyncCalls = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_GENERATE_SYNC_CALLS));
skeletonPostfix = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_SKELETONPOSTFIX));
enumPrefix = resource.getPersistentProperty(new QualifiedName(PreferenceConstants.PROJECT_PAGEID, PreferenceConstants.P_ENUMPREFIX));
} catch (CoreException ce) {
System.err.println("Failed to get property for " + resource.getName());
- }
-
+ }
+
// Set defaults from the preference store in the case, where the value was not specified in the properties.
if(outputFolderCommon == null) {
- outputFolderCommon = store.getString(PreferenceConstants.P_OUTPUT_COMMON);
+ outputFolderCommon = store.getString(PreferenceConstants.P_OUTPUT_COMMON);
}
if(outputFolderProxies == null) {
- outputFolderProxies = store.getString(PreferenceConstants.P_OUTPUT_PROXIES);
+ outputFolderProxies = store.getString(PreferenceConstants.P_OUTPUT_PROXIES);
}
if(outputFolderStubs == null) {
- outputFolderStubs = store.getString(PreferenceConstants.P_OUTPUT_STUBS);
+ outputFolderStubs = store.getString(PreferenceConstants.P_OUTPUT_STUBS);
}
if(outputFolderSkeleton == null) {
- outputFolderSkeleton = store.getString(PreferenceConstants.P_OUTPUT_SKELETON);
+ outputFolderSkeleton = store.getString(PreferenceConstants.P_OUTPUT_SKELETON);
}
if(skeletonPostfix == null) {
- skeletonPostfix = store.getString(PreferenceConstants.P_SKELETONPOSTFIX);
+ skeletonPostfix = store.getString(PreferenceConstants.P_SKELETONPOSTFIX);
}
if(enumPrefix == null) {
- enumPrefix = store.getString(PreferenceConstants.P_ENUMPREFIX);
+ enumPrefix = store.getString(PreferenceConstants.P_ENUMPREFIX);
}
if(licenseHeader == null) {
- licenseHeader = store.getString(PreferenceConstants.P_LICENSE);
+ licenseHeader = store.getString(PreferenceConstants.P_LICENSE);
+ }
+ if (generateCommon == null) {
+ generateCommon = store.getString(PreferenceConstants.P_GENERATE_COMMON);
}
if(generateProxy == null) {
- generateProxy = store.getString(PreferenceConstants.P_GENERATEPROXY);
+ generateProxy = store.getString(PreferenceConstants.P_GENERATE_PROXY);
}
- if(generatStub == null) {
- generatStub = store.getString(PreferenceConstants.P_GENERATESTUB);
+ if(generateStub == null) {
+ generateStub = store.getString(PreferenceConstants.P_GENERATE_STUB);
}
- if(generatSkeleton == null) {
- generatSkeleton = store.getString(PreferenceConstants.P_GENERATESKELETON);
+ if(generateSkeleton == null) {
+ generateSkeleton = store.getString(PreferenceConstants.P_GENERATE_SKELETON);
+ }
+ if(generateDependencies == null) {
+ generateDependencies = store.getString(PreferenceConstants.P_GENERATE_DEPENDENCIES);
+ }
+ if(generateSyncCalls == null) {
+ generateSyncCalls = store.getString(PreferenceConstants.P_GENERATE_SYNC_CALLS);
}
-
// finally, store the properties for the code generator
instance.setPreference(PreferenceConstants.P_OUTPUT_COMMON, outputFolderCommon);
instance.setPreference(PreferenceConstants.P_OUTPUT_PROXIES, outputFolderProxies);
instance.setPreference(PreferenceConstants.P_OUTPUT_STUBS, outputFolderStubs);
instance.setPreference(PreferenceConstants.P_OUTPUT_SKELETON, outputFolderSkeleton);
instance.setPreference(PreferenceConstants.P_LICENSE, licenseHeader);
- instance.setPreference(PreferenceConstants.P_GENERATEPROXY, generateProxy);
- instance.setPreference(PreferenceConstants.P_GENERATESTUB, generatStub);
- instance.setPreference(PreferenceConstants.P_GENERATESKELETON, generatSkeleton);
+ instance.setPreference(PreferenceConstants.P_GENERATE_COMMON, generateCommon);
+ instance.setPreference(PreferenceConstants.P_GENERATE_PROXY, generateProxy);
+ instance.setPreference(PreferenceConstants.P_GENERATE_STUB, generateStub);
+ instance.setPreference(PreferenceConstants.P_GENERATE_SKELETON, generateSkeleton);
instance.setPreference(PreferenceConstants.P_SKELETONPOSTFIX, skeletonPostfix);
instance.setPreference(PreferenceConstants.P_ENUMPREFIX, enumPrefix);
- }
+ instance.setPreference(PreferenceConstants.P_GENERATE_DEPENDENCIES, generateDependencies);
+ instance.setPreference(PreferenceConstants.P_GENERATE_SYNC_CALLS, generateSyncCalls);
+ }
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java
index e825c86..21eba9a 100644
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/CommonAPIPreferencePage.java
@@ -8,7 +8,6 @@
package org.genivi.commonapi.core.ui.preferences;
-import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
@@ -27,14 +26,14 @@ import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
* This class represents a preference page that is contributed to the
* Preferences dialog. By subclassing <samp>FieldEditorOverlayPage</samp>.
* <p>
- * This page is used to modify preferences. They are stored in the preference store that
- * belongs to the main plug-in class.
+ * This page is used to modify preferences. They are stored in the preference store that
+ * belongs to the main plug-in class.
*/
public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements IWorkbenchPreferencePage
{
- private MultiLineTextFieldEditor license = null;
+ private MultiLineStringFieldEditor license = null;
private FieldEditor proxyOutput = null;
private FieldEditor stubOutput = null;
private FieldEditor commonOutput = null;
@@ -42,7 +41,7 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
private StringFieldEditor postFix = null;
private BooleanFieldEditor generatSkeleton = null;
private StringFieldEditor enumPrefix = null;
-
+
public CommonAPIPreferencePage()
{
super(GRID);
@@ -53,16 +52,17 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
* GUI blocks needed to manipulate various types of preferences. Each field
* editor knows how to save and restore itself.
*/
+ @Override
public void createFieldEditors()
{
- generatSkeleton = new BooleanFieldEditor(PreferenceConstants.P_GENERATESKELETON, "Generate skeleton code", getFieldEditorParent());
+ generatSkeleton = new BooleanFieldEditor(PreferenceConstants.P_GENERATE_SKELETON, "Generate skeleton code", getFieldEditorParent());
addField(generatSkeleton);
- license = new MultiLineTextFieldEditor(PreferenceConstants.P_LICENSE, "The license header to be inserted in all generated files", 30,
+ license = new MultiLineStringFieldEditor(PreferenceConstants.P_LICENSE, "The license header to be inserted in all generated files", 30,
getFieldEditorParent());
license.setLabelText(""); // need to set this parameter (seems to be a bug)
addField(license);
-
+
// output directory definitions
commonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_COMMON, "Output directory for the common code", 30,
getFieldEditorParent());
@@ -72,10 +72,10 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
addField(proxyOutput);
stubOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_STUBS, "Output directory for stub code", 30,
getFieldEditorParent());
- addField(stubOutput);
+ addField(stubOutput);
skeletonOutput = new StringFieldEditor(PreferenceConstants.P_OUTPUT_SKELETON, "Output directory for the skeleton code", 30,
getFieldEditorParent());
- addField(skeletonOutput);
+ addField(skeletonOutput);
postFix = new StringFieldEditor(PreferenceConstants.P_SKELETONPOSTFIX, "Postfix for skeleton filenames", 30, getFieldEditorParent());
addField(postFix);
@@ -88,12 +88,13 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
@Override
protected void performDefaults()
{
- DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, "true");
- DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, "true");
- DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESKELETON, "false");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_COMMON, "true");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_PROXY, "true");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_STUB, "true");
+ DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_SKELETON, "false");
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_SKELETONPOSTFIX, "Default");
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_ENUMPREFIX, "");
-
+
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_OUTPUT_PROXIES,
PreferenceConstants.DEFAULT_OUTPUT);
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE)
@@ -102,10 +103,11 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
.put(PreferenceConstants.P_OUTPUT_COMMON, PreferenceConstants.DEFAULT_OUTPUT);
DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE)
.put(PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants.DEFAULT_OUTPUT);
-
+
super.performDefaults();
}
+ @Override
public void init(IWorkbench workbench)
{
if (!isPropertyPage())
@@ -141,7 +143,7 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
IResource resource = (IResource) getElement();
try
{
- resource.setPersistentProperty(new QualifiedName(getPageId(), PreferenceConstants.P_GENERATESKELETON), "false");
+ resource.setPersistentProperty(new QualifiedName(getPageId(), PreferenceConstants.P_GENERATE_SKELETON), "false");
}
catch (CoreException e)
{
@@ -150,6 +152,6 @@ public class CommonAPIPreferencePage extends FieldEditorOverlayPage implements I
}
// will be disposed from FieldEditorPreferencePage !
}
-
-
+
+
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
index 7a859df..4504cf6 100755
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/FieldEditorOverlayPage.java
@@ -50,10 +50,13 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
private List<Button> buttons = new ArrayList<Button>();
+ private Button checkboxcommon = null;
private Button checkboxproxy = null;
private Button checkboxstub = null;
private Button checkboxProject = null;
-
+ private Button checkboxIncludes = null;
+ private Button checkboxSyncCalls = null;
+
// Stores owning element of properties
private IAdaptable element;
@@ -226,36 +229,57 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
checkboxProject = new Button(settingsGroup, SWT.CHECK);
checkboxProject.setText("Enable project specific settings");
+ checkboxcommon = new Button(radioGroup, SWT.CHECK);
+ checkboxcommon.setText(Messages.getString("OverlayPage.Generate_Common"));
checkboxproxy = new Button(radioGroup, SWT.CHECK);
checkboxproxy.setText(Messages.getString("OverlayPage.Generate_Proxy"));
checkboxstub = new Button(radioGroup, SWT.CHECK);
checkboxstub.setText(Messages.getString("OverlayPage.Generate_Stub"));
+ checkboxIncludes = new Button(radioGroup, SWT.CHECK);
+ checkboxIncludes.setText(Messages.getString("OverlayPage.Generate_Includes"));
+ checkboxSyncCalls = new Button(radioGroup, SWT.CHECK);
+ checkboxSyncCalls.setText(Messages.getString("OverlayPage.Generate_SyncCalls"));
+ buttons.add(checkboxcommon);
buttons.add(checkboxproxy);
- buttons.add(checkboxproxy);
+ buttons.add(checkboxstub);
buttons.add(checkboxProject);
+ buttons.add(checkboxIncludes);
+ buttons.add(checkboxSyncCalls);
+ String genCommon = TRUE;
String genProxy = TRUE;
String genStub = TRUE;
String project = FALSE;
+ String dependencies = TRUE;
+ String syncCalls = TRUE;
if (isPropertyPage())
{
// get values from the persistent properties of theses resources and set the button states
try
{
+ genCommon = ((IResource) getElement())
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_COMMON));
genProxy = ((IResource) getElement())
- .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATEPROXY));
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_PROXY));
genStub = ((IResource) getElement())
- .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB));
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_STUB));
project = ((IResource) getElement())
.getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_USEPROJECTSETTINGS));
+ dependencies = ((IResource) getElement())
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_DEPENDENCIES));
+ syncCalls = ((IResource) getElement())
+ .getPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_SYNC_CALLS));
}
catch (CoreException e)
{
// failed to access this resource...
}
// Not all properties are set for this resource
+ if (genCommon == null) {
+ genCommon = TRUE;
+ }
if(genProxy == null) {
genProxy = TRUE;
}
@@ -265,22 +289,40 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
if(project == null) {
project = FALSE;
}
+ if(dependencies == null) {
+ dependencies = TRUE;
+ }
+ if(syncCalls == null) {
+ syncCalls = TRUE;
+ }
}
else // is a preference page
{
- genProxy = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, "");
- genProxy = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATEPROXY, genProxy);
+ genCommon = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_COMMON, TRUE);
+ genCommon = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_COMMON, genCommon);
- genStub = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, "");
- genStub = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATESTUB, genStub);
+ genProxy = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_PROXY, TRUE);
+ genProxy = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_PROXY, genProxy);
- project = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_USEPROJECTSETTINGS, "");
+ genStub = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_STUB, TRUE);
+ genStub = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_STUB, genStub);
+
+ project = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_USEPROJECTSETTINGS, FALSE);
project = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_USEPROJECTSETTINGS, project);
+
+ dependencies = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_DEPENDENCIES, TRUE);
+ dependencies = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_DEPENDENCIES, dependencies);
+
+ syncCalls = DefaultScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_SYNC_CALLS, TRUE);
+ syncCalls = InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).get(PreferenceConstants.P_GENERATE_SYNC_CALLS, syncCalls);
}
// set the selection state of the buttons
+ checkboxcommon.setSelection(TRUE.equals(genCommon));
checkboxproxy.setSelection(TRUE.equals(genProxy));
checkboxstub.setSelection(TRUE.equals(genStub));
checkboxProject.setSelection(TRUE.equals(project));
+ checkboxIncludes.setSelection(TRUE.equals(dependencies));
+ checkboxSyncCalls.setSelection(TRUE.equals(syncCalls));
}
/**
@@ -324,31 +366,39 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
*/
public boolean performOk()
{
- boolean result = super.performOk();
- String genProxy = (checkboxproxy.getSelection()) ? TRUE : FALSE;
- String genStub = (checkboxstub.getSelection()) ? TRUE : FALSE;
- String project = (checkboxProject.getSelection()) ? TRUE : FALSE;
-
- if (result && isPropertyPage())
- {
- IResource resource = (IResource) getElement();
- try
- {
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_USEPROJECTSETTINGS), project);
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATEPROXY), genProxy);
- resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATESTUB), genStub);
- }
- catch (CoreException e)
- {
- result = false;
- }
- }
- else if (result)
- {
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, genProxy);
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, genStub);
- }
- return result;
+ boolean result = super.performOk();
+ String genCommon = (checkboxcommon.getSelection()) ? TRUE : FALSE;
+ String genProxy = (checkboxproxy.getSelection()) ? TRUE : FALSE;
+ String genStub = (checkboxstub.getSelection()) ? TRUE : FALSE;
+ String project = (checkboxProject.getSelection()) ? TRUE : FALSE;
+ String dependencies = (checkboxIncludes.getSelection()) ? TRUE : FALSE;
+ String syncCalls = (checkboxSyncCalls.getSelection()) ? TRUE : FALSE;
+
+ if (result) {
+ if(isPropertyPage()) {
+ IResource resource = (IResource) getElement();
+ try
+ {
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_USEPROJECTSETTINGS), project);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_COMMON), genCommon);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_PROXY), genProxy);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_STUB), genStub);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_DEPENDENCIES), dependencies);
+ resource.setPersistentProperty(new QualifiedName(pageId, PreferenceConstants.P_GENERATE_SYNC_CALLS), syncCalls);
+ }
+ catch (CoreException e)
+ {
+ result = false;
+ }
+ } else { // preference page
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_COMMON, genCommon);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_PROXY, genProxy);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_STUB, genStub);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_DEPENDENCIES, dependencies);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_SYNC_CALLS, syncCalls);
+ }
+ }
+ return result;
}
/**
@@ -357,12 +407,17 @@ public abstract class FieldEditorOverlayPage extends FieldEditorPreferencePage i
protected void performDefaults()
{
enableControls();
+ checkboxcommon.setSelection(true);
checkboxproxy.setSelection(true);
checkboxstub.setSelection(true);
checkboxProject.setSelection(false);
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATEPROXY, "true");
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATESTUB, "true");
- InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_USEPROJECTSETTINGS, "false");
+ checkboxIncludes.setSelection(true);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_COMMON, TRUE);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_PROXY, TRUE);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_STUB, TRUE);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_USEPROJECTSETTINGS, FALSE);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_DEPENDENCIES, TRUE);
+ InstanceScope.INSTANCE.getNode(PreferenceConstants.SCOPE).put(PreferenceConstants.P_GENERATE_SYNC_CALLS, TRUE);
super.performDefaults();
}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
index 081c072..714b1d6 100755
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/Messages.properties
@@ -4,6 +4,9 @@
PropertyStore.Cannot_write_resource_property=Cannot write resource property
PropertyStore.Cannot_read_resource_property=Cannot read resource property
+OverlayPage.Generate_Common=Generate common code
OverlayPage.Generate_Proxy=Generate proxy code
OverlayPage.Generate_Stub=Generate stub code
+OverlayPage.Generate_Includes=Generate code for dependencies
+OverlayPage.Generate_SyncCalls=Generate code for synchronous calls
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineStringFieldEditor.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineStringFieldEditor.java
new file mode 100644
index 0000000..16fcbe7
--- /dev/null
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/MultiLineStringFieldEditor.java
@@ -0,0 +1,140 @@
+package org.genivi.commonapi.core.ui.preferences;
+
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class MultiLineStringFieldEditor extends FieldEditor
+{
+ private Text textControl;
+ private String oldTextValue;
+
+ public MultiLineStringFieldEditor(String name, String labelText, int width, Composite parent)
+ {
+ init(name, labelText);
+ createControl(parent);
+ }
+
+ @Override
+ protected void adjustForNumColumns(int numColumns)
+ {
+ GridData gdLabel = (GridData) getLabelControl().getLayoutData();
+ gdLabel.horizontalSpan = numColumns;
+
+ GridData gdText = (GridData) textControl.getLayoutData();
+ gdText.horizontalSpan = numColumns;
+ }
+
+ @Override
+ public int getNumberOfControls()
+ {
+ return 1;
+ }
+
+ @Override
+ protected void doFillIntoGrid(Composite parent, int numColumns)
+ {
+ GridData gdParent = new GridData(GridData.FILL_HORIZONTAL);
+ parent.setLayoutData(gdParent);
+
+ Label labelControl = getLabelControl(parent);
+ GridData gdLabel = new GridData();
+ labelControl.setLayoutData(gdLabel);
+
+ textControl = getTextControl(parent);
+ GridData gdText = new GridData(GridData.FILL_HORIZONTAL);
+ gdText.widthHint = 100;
+ gdText.heightHint = 60;
+ textControl.setLayoutData(gdText);
+ }
+
+ protected Text getTextControl(Composite parent)
+ {
+ if (textControl == null)
+ {
+ textControl = new Text(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
+ textControl.setFont(parent.getFont());
+ textControl.addKeyListener(new KeyAdapter()
+ {
+ @Override
+ public void keyPressed(KeyEvent e)
+ {
+ valueChanged();
+ }
+ });
+
+ textControl.addDisposeListener(new DisposeListener()
+ {
+ @Override
+ public void widgetDisposed(DisposeEvent event)
+ {
+ textControl = null;
+ }
+ });
+ }
+ else
+ checkParent(textControl, parent);
+
+ return textControl;
+ }
+
+ @Override
+ protected void doLoad()
+ {
+ if (textControl != null)
+ {
+ String value = getPreferenceStore().getString(getPreferenceName());
+ textControl.setText(value);
+ oldTextValue = value;
+ }
+ }
+
+ @Override
+ protected void doLoadDefault()
+ {
+ if (textControl != null)
+ {
+ String value = getPreferenceStore().getDefaultString(getPreferenceName());
+ textControl.setText(value);
+ }
+ valueChanged();
+ }
+
+ @Override
+ protected void doStore()
+ {
+ getPreferenceStore().setValue(getPreferenceName(), textControl.getText());
+ }
+
+ @Override
+ public void setFocus()
+ {
+ if (textControl != null)
+ textControl.setFocus();
+ }
+
+ protected void valueChanged()
+ {
+ setPresentsDefaultValue(false);
+
+ String newValue = textControl.getText();
+ if (!newValue.equals(oldTextValue))
+ {
+ fireValueChanged(VALUE, oldTextValue, newValue);
+ oldTextValue = newValue;
+ }
+ }
+
+ @Override
+ public void setEnabled(boolean enabled, Composite parent)
+ {
+ getTextControl(parent).setEnabled(enabled);
+ }
+}
diff --git a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java
index 0d33ecd..b991712 100644
--- a/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java
+++ b/org.genivi.commonapi.core.ui/src/org/genivi/commonapi/core/ui/preferences/PreferenceInitializer.java
@@ -24,6 +24,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
* initializeDefaultPreferences()
*/
+ @Override
public void initializeDefaultPreferences() {
IPreferenceStore store = CommonApiUiPlugin.getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.P_LICENSE, PreferenceConstants.DEFAULT_LICENSE);
@@ -31,11 +32,15 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(PreferenceConstants.P_OUTPUT_STUBS, PreferenceConstants.DEFAULT_OUTPUT);
store.setDefault(PreferenceConstants.P_OUTPUT_COMMON, PreferenceConstants.DEFAULT_OUTPUT);
store.setDefault(PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants.DEFAULT_OUTPUT);
- store.setDefault(PreferenceConstants.P_GENERATEPROXY, true);
- store.setDefault(PreferenceConstants.P_GENERATESTUB, true);
- store.setDefault(PreferenceConstants.P_GENERATESKELETON, false);
+ store.setDefault(PreferenceConstants.P_GENERATE_COMMON, true);
+ store.setDefault(PreferenceConstants.P_GENERATE_PROXY, true);
+ store.setDefault(PreferenceConstants.P_GENERATE_STUB, true);
+ store.setDefault(PreferenceConstants.P_GENERATE_SKELETON, false);
store.setDefault(PreferenceConstants.P_SKELETONPOSTFIX, PreferenceConstants.DEFAULT_SKELETONPOSTFIX);
store.setDefault(PreferenceConstants.P_USEPROJECTSETTINGS, false);
+ store.setDefault(PreferenceConstants.P_GENERATE_DEPENDENCIES, true);
+ store.setDefault(PreferenceConstants.P_ENABLE_CORE_VALIDATOR, true);
+ store.setDefault(PreferenceConstants.P_GENERATE_SYNC_CALLS, true);
}
}
diff --git a/org.genivi.commonapi.core.updatesite/category.xml b/org.genivi.commonapi.core.updatesite/category.xml
index 50f10cf..a02e9be 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.3.qualifier.jar" id="org.genivi.commonapi.core.validator.feature" version="3.1.3.qualifier">
+ <feature url="features/org.genivi.commonapi.core.validator.feature_3.1.4.qualifier.jar" id="org.genivi.commonapi.core.validator.feature" version="3.1.4.qualifier">
<category name="GENIVI CommonAPI"/>
</feature>
- <feature url="features/org.genivi.commonapi.core.feature_3.1.3.qualifier.jar" id="org.genivi.commonapi.core.feature" version="3.1.3.qualifier">
+ <feature url="features/org.genivi.commonapi.core.feature_3.1.4.qualifier.jar" id="org.genivi.commonapi.core.feature" version="3.1.4.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 67763ba..049d5bc 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 ae39e49..372bd13 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.3.qualifier"
+ version="3.1.4.qualifier"
provider-name="%providerName">
<copyright>
@@ -14,7 +14,7 @@
</license>
<requires>
- <import plugin="org.genivi.commonapi.core.ui" version="3.1.3" match="compatible"/>
+ <import plugin="org.genivi.commonapi.core.ui" version="3.1.4" 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 caa05a6..e5bcdac 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 6a97d70..6a58373 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.3.qualifier
+Bundle-Version: 3.1.4.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.3",
- org.genivi.commonapi.core.ui;bundle-version="3.1.3",
+ org.genivi.commonapi.core;bundle-version="3.1.4",
+ org.genivi.commonapi.core.ui;bundle-version="3.1.4",
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 b0f9dc4..ea128fb 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.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
<relativePath>../org.genivi.commonapi.core.releng</relativePath>
</parent>
</project>
diff --git a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ValidatorCoreUi.java b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ValidatorCoreUi.java
index 4c288ed..858135e 100644
--- a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ValidatorCoreUi.java
+++ b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/ValidatorCoreUi.java
@@ -24,8 +24,8 @@ import org.franca.core.franca.FModel;
import org.franca.core.franca.FrancaPackage;
import org.franca.core.franca.Import;
import org.genivi.commonapi.core.verification.ValidatorCore;
+import org.genivi.commonapi.core.preferences.PreferenceConstants;
import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
-import org.genivi.commonapi.core.validator.preferencepage.ValidatorCorePreferencesPage;
/**
* This validator is automatically triggered from the XText editor.
@@ -44,7 +44,7 @@ public class ValidatorCoreUi extends ValidatorCore {
}
// call the super validation method
super.validateModel(model, messageAcceptor);
-
+
Resource res = model.eResource();
final Path platformPath = new Path(res.getURI().toPlatformString(true));
final IFile file = ResourcesPlugin.getWorkspace().getRoot()
@@ -110,7 +110,7 @@ public class ValidatorCoreUi extends ValidatorCore {
}
start.clear();
}
-
+
private HashMap<String, HashSet<String>> buildImportList(
HashMap<String, HashSet<String>> rekImportList) {
HashMap<String, HashSet<String>> helpMap = new HashMap<String, HashSet<String>>();
@@ -157,9 +157,9 @@ public class ValidatorCoreUi extends ValidatorCore {
} else {
return rekImportList;
}
- }
-
-
+ }
+
+
protected void findCyclicImports(String filePath, String prevFilePath,
ArrayList<String> cyclicList, Import imp,
ValidationMessageAcceptor messageAcceptor) {
@@ -191,17 +191,17 @@ public class ValidatorCoreUi extends ValidatorCore {
}
cyclicList.remove(cyclicList.size() - 1);
}
- }
-
+ }
+
/**
* Check whether the validation is enabled in the eclipse preferences
* @return
*/
public boolean isValidatorEnabled() {
-
+
IPreferenceStore prefs = CommonApiUiPlugin.getValidatorPreferences();
- return prefs != null && prefs.getBoolean(ValidatorCorePreferencesPage.ENABLED_CORE_VALIDATOR);
+ return prefs != null && prefs.getBoolean(PreferenceConstants.P_ENABLE_CORE_VALIDATOR);
}
}
diff --git a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/preferencepage/ValidatorCorePreferencesPage.java b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/preferencepage/ValidatorCorePreferencesPage.java
index 8c2c749..c37561a 100644
--- a/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/preferencepage/ValidatorCorePreferencesPage.java
+++ b/org.genivi.commonapi.core.validator/src/org/genivi/commonapi/core/validator/preferencepage/ValidatorCorePreferencesPage.java
@@ -12,12 +12,12 @@ import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.genivi.commonapi.core.preferences.PreferenceConstants;
import org.genivi.commonapi.core.ui.CommonApiUiPlugin;
public class ValidatorCorePreferencesPage extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
- public final static String ENABLED_CORE_VALIDATOR = "ENABLED_CORE_VALIDATOR";
@Override
public void checkState() {
@@ -26,17 +26,14 @@ public class ValidatorCorePreferencesPage extends FieldEditorPreferencePage
@Override
public void createFieldEditors() {
- addField(new BooleanFieldEditor(ENABLED_CORE_VALIDATOR,
+ addField(new BooleanFieldEditor(PreferenceConstants.P_ENABLE_CORE_VALIDATOR,
"validator enabled", getFieldEditorParent()));
}
@Override
public void init(IWorkbench workbench) {
- IPreferenceStore prefStore = CommonApiUiPlugin.getDefault()
- .getPreferenceStore();
+ IPreferenceStore prefStore = CommonApiUiPlugin.getValidatorPreferences();
setPreferenceStore(prefStore);
setDescription("Disable or enable the core validator!");
- prefStore.setDefault(
- ValidatorCorePreferencesPage.ENABLED_CORE_VALIDATOR, true);
}
}
diff --git a/org.genivi.commonapi.core.verification/CMakeLists.txt b/org.genivi.commonapi.core.verification/CMakeLists.txt
index 4005ac0..1b02928 100644
--- a/org.genivi.commonapi.core.verification/CMakeLists.txt
+++ b/org.genivi.commonapi.core.verification/CMakeLists.txt
@@ -90,38 +90,38 @@ message("UPPER_CMAKE_BUILD_TYPE: ${UPPER_CMAKE_BUILD_TYPE}")
if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na")
get_property(GLUECODE_LIB_PATH_NAME_DBUS TARGET ${CMAKE_GLUECODE_DBUS_NAME} PROPERTY IMPORTED_LOCATION_${UPPER_CMAKE_BUILD_TYPE})
message("GLUECODE_LIB_PATH_NAME_DBUS value: ${GLUECODE_LIB_PATH_NAME_DBUS}")
- if (MSVC)
- SET(GLUECODE_SO_DBUS ${GLUECODE_LIB_PATH_NAME_DBUS})
- else()
- # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so
- string(LENGTH ${GLUECODE_LIB_PATH_NAME_DBUS} GLUECODE_LIB_PATH_NAME_DBUS_LENGTH)
- math(EXPR GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH}-6')
- string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_DBUS}
- 0 ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED}
- GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN
- )
- # GLUECODE_SO_DBUS is used in commonapi4dbus.ini.in file
- SET(GLUECODE_SO_DBUS ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN})
- endif()
+ if (MSVC)
+ SET(GLUECODE_SO_DBUS ${GLUECODE_LIB_PATH_NAME_DBUS})
+ else()
+ # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so
+ string(LENGTH ${GLUECODE_LIB_PATH_NAME_DBUS} GLUECODE_LIB_PATH_NAME_DBUS_LENGTH)
+ math(EXPR GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH}-6')
+ string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_DBUS}
+ 0 ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_ADJUSTED}
+ GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN
+ )
+ # GLUECODE_SO_DBUS is used in commonapi4dbus.ini.in file
+ SET(GLUECODE_SO_DBUS ${GLUECODE_LIB_PATH_NAME_DBUS_LENGTH_CLEAN})
+ endif()
endif()
# libSomeIPGlue
if(NOT "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na")
get_property(GLUECODE_LIB_PATH_NAME_SOMEIP TARGET ${CMAKE_GLUECODE_SOMEIP_NAME} PROPERTY IMPORTED_LOCATION_${UPPER_CMAKE_BUILD_TYPE})
message("GLUECODE_LIB_PATH_NAME_SOMEIP value: ${GLUECODE_LIB_PATH_NAME_SOMEIP}")
- if (MSVC)
- SET(GLUECODE_SO_SOMEIP ${GLUECODE_LIB_PATH_NAME_SOMEIP})
- else()
- # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so
- string(LENGTH ${GLUECODE_LIB_PATH_NAME_SOMEIP} GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH)
- math(EXPR GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH}-6')
- string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_SOMEIP}
- 0 ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED}
- GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN
- )
- # GLUECODE_SO_SOMEIP is used in commonapi4dbus.ini.in file
- SET(GLUECODE_SO_SOMEIP ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN})
- endif()
+ if (MSVC)
+ SET(GLUECODE_SO_SOMEIP ${GLUECODE_LIB_PATH_NAME_SOMEIP})
+ else()
+ # Strip the trailing .0.0.0 from the path as otherwise libCommonAPI won't load the .so
+ string(LENGTH ${GLUECODE_LIB_PATH_NAME_SOMEIP} GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH)
+ math(EXPR GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED '${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH}-6')
+ string(SUBSTRING ${GLUECODE_LIB_PATH_NAME_SOMEIP}
+ 0 ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_ADJUSTED}
+ GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN
+ )
+ # GLUECODE_SO_SOMEIP is used in commonapi4dbus.ini.in file
+ SET(GLUECODE_SO_SOMEIP ${GLUECODE_LIB_PATH_NAME_SOMEIP_LENGTH_CLEAN})
+ endif()
endif()
##############################################################################
@@ -154,7 +154,7 @@ endif()
# ...but visual studio needs a shared CRT for gtest, otherwise the linker won't work correctly with the testcases.
if (MSVC)
- set(gtest_force_shared_crt ON)
+ set( gtest_force_shared_crt ON CACHE BOOL "Always use msvcrt.dll" )
endif()
add_subdirectory($ENV{GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL)
@@ -172,7 +172,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOMMONAPI_INTERNAL_COMPILATION /EHsc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOMMONAPI_INTERNAL_COMPILATION")
set(USE_RT "")
else()
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wno-reorder -Wno-unused-variable -DCOMMONAPI_INTERNAL_COMPILATION")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector -fasynchronous-unwind-tables -fno-omit-frame-pointer -D_GLIBCXX_USE_NANOSLEEP")
set(USE_RT "rt")
endif()
@@ -190,133 +190,195 @@ enable_testing()
set(CMAKE_CTEST_COMMAND ctest -V)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
+SET(TESTS_BAT "OFF" CACHE BOOL
+ "Controls whether only tests for build acceptance should be build and run via 'make check'")
+
+SET(TESTS_EXTRA "OFF" CACHE BOOL
+ "Controls whether extra tests should be build or not")
+
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})
+if (NOT ${TESTS_BAT})
+ add_executable(RTLoadingRuntime src/RTLoadingRuntime.cpp)
+ target_link_libraries(RTLoadingRuntime ${TEST_LINK_LIBRARIES})
-add_executable(RTBuildProxiesAndStubs
- src/RTBuildProxiesAndStubs.cpp
- src-gen/v1_0/commonapi/runtime/TestInterfaceStubDefault.cpp)
-target_link_libraries(RTBuildProxiesAndStubs ${TEST_LINK_LIBRARIES})
+ add_executable(RTBuildProxiesAndStubs
+ src/RTBuildProxiesAndStubs.cpp
+ src-gen/v1/commonapi/runtime/TestInterfaceStubDefault.cpp)
+ target_link_libraries(RTBuildProxiesAndStubs ${TEST_LINK_LIBRARIES})
+endif()
add_executable(CMMethodCalls
src/CMMethodCalls.cpp
src/stub/CMMethodCallsStub.cpp
- src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp)
+ src-gen/v1/commonapi/communication/TestInterfaceStubDefault.cpp)
target_link_libraries(CMMethodCalls ${TEST_LINK_LIBRARIES})
add_executable(CMAttributes
src/CMAttributes.cpp
src/stub/CMAttributesStub.cpp
- src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp)
+ src-gen/v1/commonapi/communication/TestInterfaceStubDefault.cpp)
target_link_libraries(CMAttributes ${TEST_LINK_LIBRARIES})
add_executable(CMAttributeSubscription
src/CMAttributeSubscription.cpp
- src-gen/v1_0/commonapi/communication/TestInterfaceStubDefault.cpp
- src-gen/v1_0/commonapi/communication/DaemonStubDefault.cpp)
+ src-gen/v1/commonapi/communication/TestInterfaceStubDefault.cpp
+ src-gen/v1/commonapi/communication/DaemonStubDefault.cpp)
target_link_libraries(CMAttributeSubscription ${TEST_LINK_LIBRARIES})
-add_executable(DTPrimitive
- src/DTPrimitive.cpp
- src/stub/DTPrimitiveStub.cpp
- src-gen/v1_0/commonapi/datatypes/primitive/TestInterfaceStubDefault.cpp)
-target_link_libraries(DTPrimitive ${TEST_LINK_LIBRARIES})
-
-add_executable(DTAdvanced
- src/DTAdvanced.cpp
- src/stub/DTAdvancedStub.cpp
- src-gen/v1_0/commonapi/datatypes/advanced/TestInterfaceStubDefault.cpp
- src-gen/v1_0/commonapi/datatypes/advanced/TestInterface.cpp)
-target_link_libraries(DTAdvanced ${TEST_LINK_LIBRARIES})
-
-add_executable(DTDerived
- src/DTDerived.cpp
- src/stub/DTDerivedStub.cpp
- src-gen/v1_0/commonapi/datatypes/derived/TestInterfaceStubDefault.cpp
- src-gen/v1_0/commonapi/datatypes/derived/TestInterface.cpp)
-target_link_libraries(DTDerived ${TEST_LINK_LIBRARIES})
-
-add_executable(DTCombined
- src/DTCombined.cpp
- src/stub/DTCombinedStub.cpp
- src-gen/v1_0/commonapi/datatypes/combined/TestInterface.cpp
- src-gen/v1_0/commonapi/datatypes/combined/TestInterfaceStubDefault.cpp)
-target_link_libraries(DTCombined ${TEST_LINK_LIBRARIES})
-
-add_executable(THMainLoopIntegration
- src/THMainLoopIntegration.cpp
- src/stub/THMainLoopIntegrationStub.cpp
- src-gen/v1_0/commonapi/threading/TestInterfaceStubDefault.cpp)
-target_link_libraries(THMainLoopIntegration ${TEST_LINK_LIBRARIES})
-
-add_executable(THMainLoopIndependence
- src/THMainLoopIndependence.cpp
- src-gen/v1_0/commonapi/threading/TestInterfaceStubDefault.cpp)
-target_link_libraries(THMainLoopIndependence ${TEST_LINK_LIBRARIES})
-
-add_executable(THMainLoopTwoThreads
- src/THMainLoopTwoThreads.cpp
- src-gen/v1_0/commonapi/threading/TestInterfaceStubDefault.cpp)
-target_link_libraries(THMainLoopTwoThreads ${TEST_LINK_LIBRARIES})
-
-add_executable(PFPrimitive
- src/PFPrimitive.cpp
- src/stub/PFPrimitiveStub.cpp
- src/utils/StopWatch.cpp
- src-gen/v1_0/commonapi/performance/primitive/TestInterfaceStubDefault.cpp)
-target_link_libraries(PFPrimitive ${TEST_LINK_LIBRARIES} ${USE_RT})
-
-add_executable(PFComplex
- src/PFComplex.cpp
- src/stub/PFComplexStub.cpp
- src/utils/StopWatch.cpp
- src-gen/v1_0/commonapi/performance/complex/TestInterface.cpp
- src-gen/v1_0/commonapi/performance/complex/TestInterfaceStubDefault.cpp)
-target_link_libraries(PFComplex ${TEST_LINK_LIBRARIES} ${USE_RT})
-
-add_executable(StabilitySP
- src/StabilitySP.cpp
- src/stub/StabilitySPStub.cpp
- src-gen/v1_0/commonapi/stability/sp/TestInterfaceStubDefault.cpp)
-target_link_libraries(StabilitySP ${TEST_LINK_LIBRARIES})
-
-add_dependencies(RTLoadingRuntime gtest)
-add_dependencies(RTBuildProxiesAndStubs gtest)
+add_executable(CMBroadcasts
+ src/CMBroadcasts.cpp
+ src/stub/CMBroadcastsStub.cpp
+ src-gen/v1/commonapi/communication/TestInterfaceStubDefault.cpp
+ src-gen/v1/commonapi/communication/DaemonStubDefault.cpp)
+target_link_libraries(CMBroadcasts ${TEST_LINK_LIBRARIES})
+
+if (NOT ${TESTS_BAT})
+ add_executable(AFSelective
+ src/AFSelective.cpp
+ src/stub/AFSelectiveStub.cpp
+ src-gen/v1/commonapi/advanced/bselective/TestInterfaceStubDefault.cpp)
+ target_link_libraries(AFSelective ${TEST_LINK_LIBRARIES})
+
+ add_executable(AFManaged
+ src/AFManaged.cpp
+ src/stub/AFManagedStub.cpp
+ src/stub/DeviceStubImpl.cpp
+ src/stub/SpecialDeviceStubImpl.cpp
+ src-gen/v1/commonapi/advanced/managed/DeviceStubDefault.cpp
+ src-gen/v1/commonapi/advanced/managed/SpecialDeviceStubDefault.cpp
+ src-gen/v1/commonapi/advanced/managed/ManagerStubDefault.cpp)
+ target_link_libraries(AFManaged ${TEST_LINK_LIBRARIES})
+
+ add_executable(AFPolymorph
+ src/AFPolymorph.cpp
+ src/stub/AFPolymorphStub.cpp
+ src-gen/v1/commonapi/advanced/polymorph/TestInterfaceStubDefault.cpp
+ src-gen/v1/commonapi/advanced/polymorph/TestInterface.cpp)
+ target_link_libraries(AFPolymorph ${TEST_LINK_LIBRARIES})
+
+ add_executable(DTPrimitive
+ src/DTPrimitive.cpp
+ src/stub/DTPrimitiveStub.cpp
+ src-gen/v1/commonapi/datatypes/primitive/TestInterfaceStubDefault.cpp)
+ target_link_libraries(DTPrimitive ${TEST_LINK_LIBRARIES})
+
+ add_executable(DTAdvanced
+ src/DTAdvanced.cpp
+ src/stub/DTAdvancedStub.cpp
+ src-gen/v1/commonapi/datatypes/advanced/TestInterfaceStubDefault.cpp
+ src-gen/v1/commonapi/datatypes/advanced/TestInterface.cpp)
+ target_link_libraries(DTAdvanced ${TEST_LINK_LIBRARIES})
+
+ add_executable(DTDerived
+ src/DTDerived.cpp
+ src/stub/DTDerivedStub.cpp
+ src-gen/v1/commonapi/datatypes/derived/TestInterfaceStubDefault.cpp
+ src-gen/v1/commonapi/datatypes/derived/TestInterface.cpp)
+ target_link_libraries(DTDerived ${TEST_LINK_LIBRARIES})
+
+ add_executable(DTCombined
+ src/DTCombined.cpp
+ src/stub/DTCombinedStub.cpp
+ src-gen/v1/commonapi/datatypes/combined/TestInterface.cpp
+ src-gen/v1/commonapi/datatypes/combined/TestInterfaceStubDefault.cpp)
+ target_link_libraries(DTCombined ${TEST_LINK_LIBRARIES})
+
+ add_executable(THMainLoopIntegration
+ src/THMainLoopIntegration.cpp
+ src/stub/THMainLoopIntegrationStub.cpp
+ src-gen/v1/commonapi/threading/TestInterfaceStubDefault.cpp)
+ target_link_libraries(THMainLoopIntegration ${TEST_LINK_LIBRARIES})
+
+ add_executable(THMainLoopIndependence
+ src/THMainLoopIndependence.cpp
+ src-gen/v1/commonapi/threading/TestInterfaceStubDefault.cpp)
+ target_link_libraries(THMainLoopIndependence ${TEST_LINK_LIBRARIES})
+
+ add_executable(THMainLoopTwoThreads
+ src/THMainLoopTwoThreads.cpp
+ src-gen/v1/commonapi/threading/TestInterfaceStubDefault.cpp)
+ target_link_libraries(THMainLoopTwoThreads ${TEST_LINK_LIBRARIES})
+
+ if(${TESTS_EXTRA})
+ add_executable(PFPrimitive
+ src/PFPrimitive.cpp
+ src/stub/PFPrimitiveStub.cpp
+ src/utils/StopWatch.cpp
+ src-gen/v1/commonapi/performance/primitive/TestInterfaceStubDefault.cpp)
+ target_link_libraries(PFPrimitive ${TEST_LINK_LIBRARIES} ${USE_RT})
+
+ add_executable(PFComplex
+ src/PFComplex.cpp
+ src/stub/PFComplexStub.cpp
+ src/utils/StopWatch.cpp
+ src-gen/v1/commonapi/performance/complex/TestInterface.cpp
+ src-gen/v1/commonapi/performance/complex/TestInterfaceStubDefault.cpp)
+ target_link_libraries(PFComplex ${TEST_LINK_LIBRARIES} ${USE_RT})
+
+ add_executable(StabilitySP
+ src/StabilitySP.cpp
+ src/stub/StabilitySPStub.cpp
+ src-gen/v1/commonapi/stability/sp/TestInterfaceStubDefault.cpp)
+ target_link_libraries(StabilitySP ${TEST_LINK_LIBRARIES})
+ endif()
+endif()
+
+if (NOT ${TESTS_BAT})
+ add_dependencies(RTLoadingRuntime gtest)
+ add_dependencies(RTBuildProxiesAndStubs gtest)
+endif()
add_dependencies(CMMethodCalls gtest)
add_dependencies(CMAttributes gtest)
add_dependencies(CMAttributeSubscription gtest)
-add_dependencies(DTPrimitive gtest)
-add_dependencies(DTAdvanced gtest)
-add_dependencies(DTDerived gtest)
-add_dependencies(DTCombined gtest)
-add_dependencies(THMainLoopIntegration gtest)
-add_dependencies(THMainLoopIndependence gtest)
-add_dependencies(THMainLoopTwoThreads gtest)
-add_dependencies(PFPrimitive gtest)
-add_dependencies(PFComplex gtest)
-add_dependencies(StabilitySP gtest)
-
-add_dependencies(check RTLoadingRuntime)
-add_dependencies(check RTBuildProxiesAndStubs)
+add_dependencies(CMBroadcasts gtest)
+if (NOT ${TESTS_BAT})
+ add_dependencies(AFSelective gtest)
+ add_dependencies(AFManaged gtest)
+ add_dependencies(AFPolymorph gtest)
+ add_dependencies(DTPrimitive gtest)
+ add_dependencies(DTAdvanced gtest)
+ add_dependencies(DTDerived gtest)
+ add_dependencies(DTCombined gtest)
+ add_dependencies(THMainLoopIntegration gtest)
+ add_dependencies(THMainLoopIndependence gtest)
+ add_dependencies(THMainLoopTwoThreads gtest)
+ if(${TESTS_EXTRA})
+ add_dependencies(PFPrimitive gtest)
+ add_dependencies(PFComplex gtest)
+ add_dependencies(StabilitySP gtest)
+ endif()
+endif()
+
+if (NOT ${TESTS_BAT})
+ add_dependencies(check RTLoadingRuntime)
+ add_dependencies(check RTBuildProxiesAndStubs)
+endif()
add_dependencies(check CMMethodCalls)
add_dependencies(check CMAttributes)
add_dependencies(check CMAttributeSubscription)
-add_dependencies(check DTPrimitive)
-add_dependencies(check DTAdvanced)
-add_dependencies(check DTDerived)
-add_dependencies(check DTCombined)
-add_dependencies(check THMainLoopIntegration)
-add_dependencies(check THMainLoopIndependence)
-add_dependencies(check THMainLoopTwoThreads)
-add_dependencies(check PFPrimitive)
-add_dependencies(check PFComplex)
-add_dependencies(check StabilitySP)
+add_dependencies(check CMBroadcasts)
+if (NOT ${TESTS_BAT})
+ add_dependencies(check AFSelective)
+ add_dependencies(check AFManaged)
+ add_dependencies(check AFPolymorph)
+ add_dependencies(check DTPrimitive)
+ add_dependencies(check DTAdvanced)
+ add_dependencies(check DTDerived)
+ add_dependencies(check DTCombined)
+ add_dependencies(check THMainLoopIntegration)
+ add_dependencies(check THMainLoopIndependence)
+ add_dependencies(check THMainLoopTwoThreads)
+ if(${TESTS_EXTRA})
+ add_dependencies(check PFPrimitive)
+ add_dependencies(check PFComplex)
+ add_dependencies(check StabilitySP)
+ endif()
+endif()
# Tests for DBus
if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na")
@@ -326,78 +388,108 @@ if(NOT "${CMAKE_GLUECODE_DBUS_NAME}" STREQUAL "na")
${DBUS_COMMONAPI_CONFIG}
)
- add_test(NAME RTLoadingRuntimeDBus COMMAND RTLoadingRuntime)
- set_property(TEST RTLoadingRuntimeDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME RTBuildProxiesAndStubsDBus COMMAND RTBuildProxiesAndStubs)
- set_property(TEST RTBuildProxiesAndStubsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ if (NOT ${TESTS_BAT})
+ add_test(NAME RTLoadingRuntimeDBus COMMAND RTLoadingRuntime)
+ set_property(TEST RTLoadingRuntimeDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME RTBuildProxiesAndStubsDBus COMMAND RTBuildProxiesAndStubs)
+ set_property(TEST RTBuildProxiesAndStubsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ endif()
add_test(NAME CMMethodCallsDBus COMMAND CMMethodCalls)
set_property(TEST CMMethodCallsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
add_test(NAME CMAttributesDBus COMMAND CMAttributes)
set_property(TEST CMAttributesDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
add_test(NAME CMAttributeSubscriptionDBus COMMAND CMAttributeSubscription)
set_property(TEST CMAttributeSubscriptionDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME DTPrimitiveDBus COMMAND DTPrimitive)
- set_property(TEST DTPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME DTAdvancedDBus COMMAND DTAdvanced)
- set_property(TEST DTAdvancedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME DTDerivedDBus COMMAND DTDerived)
- set_property(TEST DTDerivedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME DTCombinedDBus COMMAND DTCombined)
- set_property(TEST DTCombinedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopIntegrationDBus COMMAND THMainLoopIntegration)
- set_property(TEST THMainLoopIntegrationDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopIndependenceDBus COMMAND THMainLoopIndependence)
- set_property(TEST THMainLoopIndependenceDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopTwoThreadsDBus COMMAND THMainLoopTwoThreads)
- set_property(TEST THMainLoopTwoThreadsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME PFPrimitiveDBus COMMAND PFPrimitive)
- set_property(TEST PFPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME PFComplexDBus COMMAND PFComplex)
- set_property(TEST PFComplexDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
- add_test(NAME StabilitySPDBus COMMAND StabilitySP)
- set_property(TEST StabilitySPDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME CMBroadcastsDBus COMMAND CMBroadcasts)
+ set_property(TEST CMBroadcastsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ if (NOT ${TESTS_BAT})
+ add_test(NAME AFSelectiveDBus COMMAND AFSelective)
+ set_property(TEST AFSelectiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME AFManagedDBus COMMAND AFManaged)
+ set_property(TEST AFManagedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME AFPolymorphDBus COMMAND AFPolymorph)
+ set_property(TEST AFPolymorphDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME DTPrimitiveDBus COMMAND DTPrimitive)
+ set_property(TEST DTPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME DTAdvancedDBus COMMAND DTAdvanced)
+ set_property(TEST DTAdvancedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME DTDerivedDBus COMMAND DTDerived)
+ set_property(TEST DTDerivedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME DTCombinedDBus COMMAND DTCombined)
+ set_property(TEST DTCombinedDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopIntegrationDBus COMMAND THMainLoopIntegration)
+ set_property(TEST THMainLoopIntegrationDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopIndependenceDBus COMMAND THMainLoopIndependence)
+ set_property(TEST THMainLoopIndependenceDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopTwoThreadsDBus COMMAND THMainLoopTwoThreads)
+ set_property(TEST THMainLoopTwoThreadsDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ if(${TESTS_EXTRA})
+ add_test(NAME PFPrimitiveDBus COMMAND PFPrimitive)
+ set_property(TEST PFPrimitiveDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME PFComplexDBus COMMAND PFComplex)
+ set_property(TEST PFComplexDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ add_test(NAME StabilitySPDBus COMMAND StabilitySP)
+ set_property(TEST StabilitySPDBus APPEND PROPERTY ENVIRONMENT ${DBUS_TEST_ENVIRONMENT})
+ endif()
+ endif()
endif()
# Tests for SomeIP
if(NOT "${CMAKE_GLUECODE_SOMEIP_NAME}" STREQUAL "na")
# Construct the environment for the tests
set(SOMEIP_COMMONAPI_CONFIG "COMMONAPI_CONFIG=commonapi4someip.ini")
- set(SOMEIP_VSOMEIP_JSON_FILE "VSOMEIP_CONFIGURATION_FILE=../../../ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification/vsomeip.json")
+ if ("${SOMEIP_VSOMEIP_JSON_FILE}" STREQUAL "")
+ set(SOMEIP_VSOMEIP_JSON_FILE "VSOMEIP_CONFIGURATION=../../../ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification/vsomeip.json")
+ endif()
set(SOMEIP_TEST_ENVIRONMENT
${SOMEIP_COMMONAPI_CONFIG}
${SOMEIP_VSOMEIP_JSON_FILE}
)
- add_test(NAME RTLoadingRuntimeSomeIP COMMAND RTLoadingRuntime)
- set_property(TEST RTLoadingRuntimeSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME RTBuildProxiesAndStubsSomeIP COMMAND RTBuildProxiesAndStubs)
- set_property(TEST RTBuildProxiesAndStubsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ if (NOT ${TESTS_BAT})
+ add_test(NAME RTLoadingRuntimeSomeIP COMMAND RTLoadingRuntime)
+ set_property(TEST RTLoadingRuntimeSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME RTBuildProxiesAndStubsSomeIP COMMAND RTBuildProxiesAndStubs)
+ set_property(TEST RTBuildProxiesAndStubsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ endif()
add_test(NAME CMMethodCallsSomeIP COMMAND CMMethodCalls)
set_property(TEST CMMethodCallsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
add_test(NAME CMAttributesSomeIP COMMAND CMAttributes)
set_property(TEST CMAttributesSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
add_test(NAME CMAttributeSubscriptionSomeIP COMMAND CMAttributeSubscription)
set_property(TEST CMAttributeSubscriptionSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME DTPrimitiveSomeIP COMMAND DTPrimitive)
- set_property(TEST DTPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME DTAdvancedSomeIP COMMAND DTAdvanced)
- set_property(TEST DTAdvancedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME DTDerivedSomeIP COMMAND DTDerived)
- set_property(TEST DTDerivedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME DTCombinedSomeIP COMMAND DTCombined)
- set_property(TEST DTCombinedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopIntegrationSomeIP COMMAND THMainLoopIntegration)
- set_property(TEST THMainLoopIntegrationSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopIndependenceSomeIP COMMAND THMainLoopIndependence)
- set_property(TEST THMainLoopIndependenceSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME THMainLoopTwoThreadsSomeIP COMMAND THMainLoopTwoThreads)
- set_property(TEST THMainLoopTwoThreadsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME PFPrimitiveSomeIP COMMAND PFPrimitive)
- set_property(TEST PFPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME PFComplexSomeIP COMMAND PFComplex)
- set_property(TEST PFComplexSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
- add_test(NAME StabilitySPSomeIP COMMAND StabilitySP)
- set_property(TEST StabilitySPSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME CMBroadcastsSomeIP COMMAND CMBroadcasts)
+ set_property(TEST CMBroadcastsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ if (NOT ${TESTS_BAT})
+ add_test(NAME AFSelectiveSomeIP COMMAND AFSelective)
+ set_property(TEST AFSelectiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME AFManagedSomeIP COMMAND AFManaged)
+ set_property(TEST AFManagedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME AFPolymorphSomeIP COMMAND AFPolymorph)
+ set_property(TEST AFPolymorphSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME DTPrimitiveSomeIP COMMAND DTPrimitive)
+ set_property(TEST DTPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME DTAdvancedSomeIP COMMAND DTAdvanced)
+ set_property(TEST DTAdvancedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME DTDerivedSomeIP COMMAND DTDerived)
+ set_property(TEST DTDerivedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME DTCombinedSomeIP COMMAND DTCombined)
+ set_property(TEST DTCombinedSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopIntegrationSomeIP COMMAND THMainLoopIntegration)
+ set_property(TEST THMainLoopIntegrationSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopIndependenceSomeIP COMMAND THMainLoopIndependence)
+ set_property(TEST THMainLoopIndependenceSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME THMainLoopTwoThreadsSomeIP COMMAND THMainLoopTwoThreads)
+ set_property(TEST THMainLoopTwoThreadsSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ if(${TESTS_EXTRA})
+ add_test(NAME PFPrimitiveSomeIP COMMAND PFPrimitive)
+ set_property(TEST PFPrimitiveSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME PFComplexSomeIP COMMAND PFComplex)
+ set_property(TEST PFComplexSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ add_test(NAME StabilitySPSomeIP COMMAND StabilitySP)
+ set_property(TEST StabilitySPSomeIP APPEND PROPERTY ENVIRONMENT ${SOMEIP_TEST_ENVIRONMENT})
+ endif()
+ endif()
endif()
##############################################################################
diff --git a/org.genivi.commonapi.core.verification/README b/org.genivi.commonapi.core.verification/README
index 78d03d9..9107965 100644
--- a/org.genivi.commonapi.core.verification/README
+++ b/org.genivi.commonapi.core.verification/README
@@ -41,6 +41,11 @@ There are some cmake options that allow you to define the binding that should be
This will enable the verification test for SomeIP in ctest
* -DCMAKE_GLUECODE_DBUS_NAME=DBusGlue and -DDBusGlue_DIR :
This will enable the verifcation tests for DBus in ctest
+* -DTESTS_BAT:
+ Set to ON to build a subset of tests covering basic functionality which
+ also have little execution time to serve as build acceptance tests
+* -DTESTS_EXTRA:
+ Set to ON to build extra tests for stability and performance testing
If the gluecode for both middlewarebindings is defined, there will be two
testcases available for one verification tests. One with postfix `DBus` and one
diff --git a/org.genivi.commonapi.core.verification/build.sh b/org.genivi.commonapi.core.verification/build.sh
new file mode 100755
index 0000000..f7de4d1
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/build.sh
@@ -0,0 +1,17 @@
+export GTEST_ROOT=$HOME/Projects/commonapi/helper/gtest-1.7.0/
+
+rm -rf build
+rm -rf src-gen
+mkdir build
+cd build
+
+cmake \
+-DCommonAPI_DIR=$(readlink -f ../../../ascgit017.CommonAPI/build) \
+-DCOMMONAPI_TOOL_GENERATOR=$(readlink -f ../../../ascgit017.CommonAPI-Tools/org.genivi.commonapi.core.cli.product/target/products/org.genivi.commonapi.core.cli.product/linux/gtk/x86/commonapi-generator-linux-x86) \
+-DCMAKE_GLUECODE_SOMEIP_NAME=SomeIPGlue \
+-DSomeIPGlue_DIR=$(readlink -f ../../../ascgit017.CommonAPI-SomeIP-Tools/org.genivi.commonapi.someip.verification/build) \
+-DCMAKE_GLUECODE_DBUS_NAME=DBusGlue \
+-DDBusGlue_DIR=$(readlink -f ../../../ascgit017.CommonAPI-D-Bus-Tools/org.genivi.commonapi.dbus.verification/build) \
+..
+
+make \ No newline at end of file
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_advanced_bselective.fidl b/org.genivi.commonapi.core.verification/fidl/ti_advanced_bselective.fidl
new file mode 100644
index 0000000..605bb27
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/fidl/ti_advanced_bselective.fidl
@@ -0,0 +1,23 @@
+/* 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/. */
+package commonapi.advanced.bselective
+
+interface TestInterface {
+ version { major 1 minor 0 }
+
+ method testMethod {
+ in {
+ UInt8 x
+ }
+ out {
+ UInt8 y
+ }
+ }
+
+ broadcast bTestSelective selective {
+ out {
+ UInt8 ux
+ }
+ }
+} \ No newline at end of file
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_advanced_managed.fidl b/org.genivi.commonapi.core.verification/fidl/ti_advanced_managed.fidl
new file mode 100644
index 0000000..4fce43f
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/fidl/ti_advanced_managed.fidl
@@ -0,0 +1,29 @@
+/* Copyright (C) 2014 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/. */
+
+package commonapi.advanced.managed
+
+interface Manager manages Device, SpecialDevice {
+ version { major 1 minor 0 }
+
+ attribute String [] myDevices
+
+}
+
+interface Device {
+ version { major 1 minor 0 }
+
+ method doSomething {
+ }
+}
+
+interface SpecialDevice extends Device {
+ version { major 1 minor 0 }
+
+ method doSomethingSpecial {
+ }
+}
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_advanced_polymorph.fidl b/org.genivi.commonapi.core.verification/fidl/ti_advanced_polymorph.fidl
new file mode 100644
index 0000000..db01ac5
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/fidl/ti_advanced_polymorph.fidl
@@ -0,0 +1,98 @@
+/* Copyright (C) 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package commonapi.advanced.polymorph
+
+interface TestInterface {
+ version { major 1 minor 0 }
+
+ attribute PStructBase a1
+
+ method testMethod {
+ in {
+ PStructBase x1
+ }
+ out {
+ PStructBase y1
+ }
+ }
+
+ broadcast bTest {
+ out {
+ PStructBase ux
+ }
+ }
+
+ typedef MyTypedef is Int32
+
+ enumeration MyEnum {
+ DEFAULT
+ ON
+ OFF
+ }
+
+ union MyUnion {
+ MyTypedef id
+ MyEnum status
+ UInt8 channel
+ String name
+ }
+
+ struct PStructBase polymorphic {
+ }
+
+ /* This does not generate code that would compile.
+ struct PStructBaseInt polymorphic {
+ UInt8 x1
+ }
+ */
+
+ struct BStruct {
+ UInt8 a1
+ UInt8 a2
+ String s1
+ }
+
+ struct PStructMyTypedef extends PStructBase {
+ MyTypedef id
+ }
+
+ struct PStructMyEnum extends PStructBase {
+ MyEnum status
+ }
+
+ struct PStructUInt8 extends PStructBase {
+ UInt8 channel
+ }
+
+ struct PStructString extends PStructBase {
+ String name
+ }
+
+ /* unions inside polymorphic structures produce compilation errors
+ struct PStructUnion extends PStructBase {
+ MyUnion coll
+ }
+ */
+
+ struct PStructStruct extends PStructBase {
+ BStruct s
+ }
+
+ /* using non-empty polymorphic structures do not currently work.
+ struct PStructStruct2 extends PStructBaseInt {
+ BStruct s
+ }
+
+ struct PStructPStruct extends PStructBase {
+ PStructBaseInt s2
+ }
+
+ struct PStructPStruct2 extends PStructBase {
+ PStructStruct2 s2
+ }
+*/
+}
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl b/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl
index 0740b6f..2d284f8 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_communication.fidl
@@ -4,22 +4,34 @@
package commonapi.communication
interface TestInterface {
- version { major 1 minor 0 }
-
- attribute UInt8 testAttribute
-
- attribute UInt8 testA readonly
- attribute UInt8 testB noSubscriptions
- attribute UInt8 testC readonly noSubscriptions
+ version { major 1 minor 0 }
+
+ attribute UInt8 testAttribute
+
+ attribute UInt8 testA readonly
+ attribute UInt8 testB noSubscriptions
+ attribute UInt8 testC readonly noSubscriptions
- method testMethod {
- in {
- UInt8 x
- }
- out {
- UInt8 y
- }
- }
+ method testMethod {
+ in {
+ UInt8 x
+ }
+ out {
+ UInt8 y
+ }
+ }
+
+ broadcast bTestSelective selective {
+ out {
+ UInt8 ux
+ }
+ }
+ broadcast bTest {
+ out {
+ UInt8 ux
+ }
+ }
+
}
interface Daemon {
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl
index 65b44a9..84c11a0 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_advanced.fidl
@@ -46,8 +46,8 @@ interface TestInterface {
array tArray of String
enumeration tEnumeration {
- VALUE1= "0"
- VALUE2= "123"
+ VALUE1= 1
+ VALUE2= 123
}
struct tStruct {
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..ef2420f 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_combined.fidl
@@ -24,8 +24,8 @@ interface TestInterface {
// Level 0
enumeration tEnum {
- VALUE1= "0"
- VALUE2= "123"
+ VALUE1= 0
+ VALUE2= 123
}
array tArray of String
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl
index d7eede7..7d5d4a6 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_derived.fidl
@@ -44,11 +44,12 @@ interface TestInterface {
}
enumeration tEnum {
- VALUE1= "0"
+ VALUE1= 0
}
enumeration tEnumExt extends tEnum {
- VALUE2= "1"
+ VALUE2= 1
+ VALUE3= 2
}
union tUnion {
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl
index 57e8be2..0766bf2 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_datatypes_primitive.fidl
@@ -53,6 +53,9 @@ interface TestInterface {
}
}
+ method fTestEmptyBroadcast {
+ }
+
broadcast bTest {
out {
UInt8 uint8Out
@@ -70,4 +73,7 @@ interface TestInterface {
//ByteBuffer byteBufferOut
}
}
+
+ broadcast bTestEmpty {
+ }
}
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl b/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl
index eb80e40..cf2dca3 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_performance_complex.fidl
@@ -4,24 +4,24 @@
package commonapi.performance.complex
interface TestInterface {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- method testMethod {
- in {
- tArray x
- }
- out {
- tArray y
- }
- }
-
- struct tStruct {
- innerStruct iStruct
- innerUnion iUnion
- }
-
- struct innerStruct {
- UInt32 uint32Member
+ method testMethod {
+ in {
+ tArray x
+ }
+ out {
+ tArray y
+ }
+ }
+
+ struct tStruct {
+ innerStruct iStruct
+ innerUnion iUnion
+ }
+
+ struct innerStruct {
+ UInt32 uint32Member
Boolean booleanMember
UInt8 uint8Member
String stringMember
@@ -33,6 +33,6 @@ interface TestInterface {
UInt8 uint8Member
String stringMember
}
-
- array tArray of tStruct
+
+ array tArray of tStruct
} \ No newline at end of file
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl b/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl
index 6d30d29..14a0fde 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_performance_primitive.fidl
@@ -4,16 +4,16 @@
package commonapi.performance.primitive
interface TestInterface {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- method testMethod {
- in {
- TestArray x
- }
- out {
- TestArray y
- }
- }
-
- array TestArray of UInt8
+ method testMethod {
+ in {
+ TestArray x
+ }
+ out {
+ TestArray y
+ }
+ }
+
+ array TestArray of UInt8
} \ No newline at end of file
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl b/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl
index 100f086..a0992b3 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_runtime.fidl
@@ -4,8 +4,8 @@
package commonapi.runtime
interface TestInterface {
- version { major 1 minor 0 }
+ version { major 1 minor 0 }
- method testMethod {
- }
+ method testMethod {
+ }
} \ No newline at end of file
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl b/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl
index 144186a..f4ef07a 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_stability_sp.fidl
@@ -16,7 +16,7 @@ interface TestInterface {
tArray y
}
}
-
+
broadcast testBroadcast {
out {
tArray y
diff --git a/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl b/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl
index 2e829a4..7a756ad 100644
--- a/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl
+++ b/org.genivi.commonapi.core.verification/fidl/ti_threading.fidl
@@ -4,18 +4,18 @@
package commonapi.threading
interface TestInterface {
- version { major 1 minor 0 }
-
- method testMethod {
- in {
- UInt8 x
- }
- out {
- UInt8 y
- }
- }
-
- broadcast testBroadcast {
+ version { major 1 minor 0 }
+
+ method testMethod {
+ in {
+ UInt8 x
+ }
+ out {
+ UInt8 y
+ }
+ }
+
+ broadcast testBroadcast {
out {
UInt8 y
}
diff --git a/org.genivi.commonapi.core.verification/src/AFManaged.cpp b/org.genivi.commonapi.core.verification/src/AFManaged.cpp
new file mode 100644
index 0000000..2e37318
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/AFManaged.cpp
@@ -0,0 +1,1255 @@
+// 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/.
+
+#include <thread>
+#include <iostream>
+#include <mutex>
+#include <set>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include "stub/AFManagedStub.h"
+#include "stub/DeviceStubImpl.h"
+#include "stub/SpecialDeviceStubImpl.h"
+
+#include <v1/commonapi/advanced/managed/ManagerProxy.hpp>
+#include <v1/commonapi/advanced/managed/DeviceProxy.hpp>
+#include <v1/commonapi/advanced/managed/SpecialDeviceProxy.hpp>
+
+#include <gtest/gtest.h>
+
+using namespace v1_0::commonapi::advanced::managed;
+
+const std::string &domain = "local";
+const static std::string managerInstanceName = "commonapi.advanced.managed.Manager";
+const static std::string connectionIdService = "service-sample";
+const static std::string connectionIdClient = "client-sample";
+
+const static std::string interfaceDevice = "commonapi.advanced.managed.Device";
+const static std::string addressDevice1 = "local:" + interfaceDevice + ":commonapi.advanced.managed.Manager.device01";
+const static std::string addressDevice2 = "local:" + interfaceDevice + ":commonapi.advanced.managed.Manager.device02";
+const static std::string interfaceSpecialDevice = "commonapi.advanced.managed.SpecialDevice";
+const static std::string addressSpecialDevice1 = "local:" + interfaceSpecialDevice + ":commonapi.advanced.managed.Manager.specialDevice00";
+
+const static int sleepMilli = 1000;
+
+class AFManaged: public ::testing::Test {
+
+public:
+AFManaged() :
+ received_(false),
+ serviceRegistered_(false),
+ subscriptionIdSpecialDevice_(0),
+ subscriptionIdDevice_(0),
+ deviceAvailableCount_(0),
+ specialDeviceAvailableCount_(0),
+ specialDeviceAvailableDesiredValue_(0),
+ deviceAvailableDesiredValue_(0),
+ instanceAvailabilityStatusCallbackCalled_(false) {}
+
+protected:
+ void SetUp() {
+ // CommonAPI::Runtime::setProperty("LibraryBase", "AFManaged");
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
+ std::mutex availabilityMutex;
+ std::unique_lock<std::mutex> lock(availabilityMutex);
+ std::condition_variable cv;
+ bool proxyAvailable = false;
+
+ std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() {
+ std::lock_guard<std::mutex> lock(availabilityMutex);
+
+ testProxy_ = runtime_->buildProxy<ManagerProxy>(domain, managerInstanceName, connectionIdClient);
+ ASSERT_TRUE((bool)testProxy_);
+ testProxy_->isAvailableBlocking();
+ proxyAvailable = true;
+ cv.notify_one();
+ });
+
+ testStub_ = std::make_shared<AFManagedStub>(managerInstanceName);
+ serviceRegistered_ = runtime_->registerService(domain, managerInstanceName, testStub_, connectionIdService);
+ ASSERT_TRUE(serviceRegistered_);
+
+ while(!proxyAvailable) {
+ cv.wait(lock);
+ }
+ t1.join();
+ ASSERT_TRUE(testProxy_->isAvailable());
+
+ // Get the events
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& deviceEvent =
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusChangedEvent();
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& specialDeviceEvent =
+ testProxy_->getProxyManagerSpecialDevice().getInstanceAvailabilityStatusChangedEvent();
+
+ // bind callbacks to member functions
+ newDeviceAvailableCallbackFunc_ = std::bind(
+ &AFManaged::newDeviceAvailableCallback, this,
+ std::placeholders::_1, std::placeholders::_2);
+ newSpecialDeviceAvailableCallbackFunc_ = std::bind(
+ &AFManaged::newSpecialDeviceAvailableCallback, this,
+ std::placeholders::_1, std::placeholders::_2);
+
+ // register callbacks
+ subscriptionIdSpecialDevice_ = specialDeviceEvent.subscribe(
+ newSpecialDeviceAvailableCallbackFunc_);
+ ASSERT_EQ(subscriptionIdSpecialDevice_,
+ static_cast<CommonAPI::Event<>::Subscription>(0));
+
+ subscriptionIdDevice_ = deviceEvent.subscribe(
+ newDeviceAvailableCallbackFunc_);
+ ASSERT_EQ(subscriptionIdDevice_,
+ static_cast<CommonAPI::Event<>::Subscription>(0));
+
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ }
+
+ void TearDown() {
+ // Unregister callbacks
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& deviceEvent =
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusChangedEvent();
+ CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& specialDeviceEvent =
+ testProxy_->getProxyManagerSpecialDevice().getInstanceAvailabilityStatusChangedEvent();
+ specialDeviceEvent.unsubscribe(subscriptionIdSpecialDevice_);
+ deviceEvent.unsubscribe(subscriptionIdDevice_);
+ runtime_->unregisterService(domain, AFManagedStub::StubInterface::getInterface(), managerInstanceName);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
+ }
+
+ void newDeviceAvailableCallback(const std::string _address,
+ const CommonAPI::AvailabilityStatus _status) {
+ ASSERT_TRUE(_address == addressDevice1 || _address == addressDevice2);
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ if(_status == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ std::cout << "New device available: " << _address << std::endl;
+ deviceAvailableCount_++;
+ devicesAvailable_.insert(CommonAPI::Address(_address));
+ }
+
+ if(_status == CommonAPI::AvailabilityStatus::NOT_AVAILABLE) {
+ std::cout << "Device removed: " << _address << std::endl;
+ deviceAvailableCount_--;
+ devicesAvailable_.erase(CommonAPI::Address(_address));
+ }
+ }
+
+ void newSpecialDeviceAvailableCallback(
+ const std::string _address,
+ const CommonAPI::AvailabilityStatus _status) {
+ ASSERT_TRUE(_address == addressSpecialDevice1);
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ if(_status == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ std::cout << "New device available: " << _address << std::endl;
+ specialDeviceAvailableCount_++;
+ specialDevicesAvailable_.insert(CommonAPI::Address(_address));
+ }
+
+ if(_status == CommonAPI::AvailabilityStatus::NOT_AVAILABLE) {
+ std::cout << "Device removed: " << _address << std::endl;
+ specialDeviceAvailableCount_--;
+ specialDevicesAvailable_.erase(CommonAPI::Address(_address));
+ }
+ }
+
+ bool checkInstanceAvailabilityStatus(
+ CommonAPI::ProxyManager* _proxyMananger,
+ const CommonAPI::Address& _instanceAddress) {
+ CommonAPI::CallStatus callStatus(CommonAPI::CallStatus::UNKNOWN);
+ CommonAPI::AvailabilityStatus availabilityStatus(
+ CommonAPI::AvailabilityStatus::UNKNOWN);
+ _proxyMananger->getInstanceAvailabilityStatus(_instanceAddress.getInstance(),
+ callStatus, availabilityStatus);
+ if (callStatus == CommonAPI::CallStatus::SUCCESS &&
+ availabilityStatus == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ void getAvailableInstancesAsyncSpecialDeviceCallback(
+ const CommonAPI::CallStatus &_callStatus,
+ const std::vector<std::string> &_availableSpecialDevices) {
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, _callStatus);
+ ASSERT_EQ(_availableSpecialDevices.size(), specialDeviceAvailableDesiredValue_);
+ bool allDetectedAreAvailable = false;
+ for(auto &i : _availableSpecialDevices) {
+ for(auto &j : specialDevicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+ }
+
+ void getAvailableInstancesAsyncDeviceCallback(
+ const CommonAPI::CallStatus &_callStatus,
+ const std::vector<std::string> &_availableDevices) {
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, _callStatus);
+ ASSERT_EQ(_availableDevices.size(), deviceAvailableDesiredValue_);
+ bool allDetectedAreAvailable = false;
+ for(auto &i : _availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+ }
+
+ void getInstanceAvailabilityStatusAsyncCallbackAvailable(
+ const CommonAPI::CallStatus &_callStatus,
+ const CommonAPI::AvailabilityStatus &_availabilityStatus) {
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, _callStatus);
+ ASSERT_EQ(CommonAPI::AvailabilityStatus::AVAILABLE, _availabilityStatus);
+ instanceAvailabilityStatusCallbackCalled_ = true;
+ }
+
+ void getInstanceAvailabilityStatusAsyncCallbackNotAvailable(
+ const CommonAPI::CallStatus &_callStatus,
+ const CommonAPI::AvailabilityStatus &_availabilityStatus) {
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, _callStatus);
+ ASSERT_EQ(CommonAPI::AvailabilityStatus::NOT_AVAILABLE, _availabilityStatus);
+ instanceAvailabilityStatusCallbackCalled_ = true;
+ }
+
+ bool received_;
+ bool serviceRegistered_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+ std::shared_ptr<ManagerProxy<>> testProxy_;
+ std::shared_ptr<AFManagedStub> testStub_;
+
+ std::function<void(const std::string, const CommonAPI::AvailabilityStatus)> newDeviceAvailableCallbackFunc_;
+ std::function<void(const std::string, const CommonAPI::AvailabilityStatus)> newSpecialDeviceAvailableCallbackFunc_;
+ CommonAPI::Event<>::Subscription subscriptionIdSpecialDevice_;
+ CommonAPI::Event<>::Subscription subscriptionIdDevice_;
+
+ int deviceAvailableCount_;
+ int specialDeviceAvailableCount_;
+
+ std::mutex deviceAvailableCountMutex_;
+ std::mutex specialDeviceAvailableCountMutex_;
+
+ std::set<CommonAPI::Address> devicesAvailable_;
+ std::set<CommonAPI::Address> specialDevicesAvailable_;
+
+ int specialDeviceAvailableDesiredValue_;
+ int deviceAvailableDesiredValue_;
+
+ bool instanceAvailabilityStatusCallbackCalled_;
+};
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Remove the managed interface from the manager
+ * - Check that the client is notified about the removed interface
+ */
+TEST_F(AFManaged, AddRemoveManagedInterfaceSingle) {
+ // Add
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+
+ // Remove
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Add a second instance of the same managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, AddRemoveManagedInterfaceMultiple) {
+ // Add
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+
+ // Remove
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Add a different managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, AddRemoveMultipleManagedInterfacesSingle) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+}
+
+/**
+ * @test
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Add a different managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Add a second instance of the same managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, AddRemoveMultipleManagedInterfacesMultiple) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Build a proxy through the manager to the managed device
+ * - Call a method on the managed device and check call status
+ * - Explicitly deregister managed interface through its instance name
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallSingleDeregistrationExplicit) {
+ // Add
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ const std::string deviceInstance(managerInstanceName + ".device01");
+ if(testProxy_->isAvailable()) {
+ std::shared_ptr<DeviceProxy<>> deviceProxy =
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance);
+ while (!deviceProxy->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ deviceProxy->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ // Remove
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Build a proxy through the manager to the managed device
+ * - Call a method on the managed device and check call status
+ * - Deregister all managed interfaces through manager's stub adapter
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallSingleDeregistrationExplicitAll) {
+ // Add
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ const std::string deviceInstance(managerInstanceName + ".device01");
+ if(testProxy_->isAvailable()) {
+ std::shared_ptr<DeviceProxy<>> deviceProxy =
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance);
+ while (!deviceProxy->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ deviceProxy->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+ testStub_->getStubAdapter()->deactivateManagedInstances();
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Build a proxy through the manager to the managed device
+ * - Call a method on the managed device and check call status
+ * - Don't deregister managed interfaces. This is done in dtor of manager's
+ * StubAdapterInternal when manager service is unregistered in
+ * TearDown() method.
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallSingleDeregistrationImplicit) {
+ // Add
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ const std::string deviceInstance(managerInstanceName + ".device01");
+ if(testProxy_->isAvailable()) {
+ std::shared_ptr<DeviceProxy<>> deviceProxy =
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance);
+ while (!deviceProxy->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ deviceProxy->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add managed interfaces to the manager
+ * - Check that the client is notified about the newly added interfaces
+ * - Build proxies through the manager to the managed interfaces
+ * - Call a method on the managed interfaces and check call status
+ * - Explicitly deregister managed interfaces through their instance name
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallMultipleDeregistrationExplicit) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+
+ const std::string specialDeviceInstance(managerInstanceName + ".specialDevice00");
+ const std::string deviceInstance01(managerInstanceName + ".device01");
+ const std::string deviceInstance02(managerInstanceName + ".device02");
+ std::vector<std::shared_ptr<DeviceProxy<>>> deviceProxies;
+ std::vector<std::shared_ptr<SpecialDeviceProxy<>>> specialDeviceProxies;
+
+ if(testProxy_->isAvailable()) {
+ for (int var = 0; var < 20; ++var) {
+ specialDeviceProxies.push_back(
+ testProxy_->getProxyManagerSpecialDevice().buildProxy<
+ SpecialDeviceProxy>(specialDeviceInstance));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance01));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance02));
+ }
+ }
+
+ for(const auto &dp : deviceProxies) {
+ while (!dp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ dp->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ for(const auto &sdp : specialDeviceProxies) {
+ while (!sdp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ sdp->doSomethingSpecial(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ testStub_->deviceRemoved(1);
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add managed interfaces to the manager
+ * - Check that the client is notified about the newly added interfaces
+ * - Build proxies through the manager to the managed interfaces
+ * - Call a method on the managed interfaces and check call status
+ * - Deregister all managed interfaces through manager's stub adapter
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallMultipleDeregistrationExplicitAll) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+
+ const std::string specialDeviceInstance(managerInstanceName + ".specialDevice00");
+ const std::string deviceInstance01(managerInstanceName + ".device01");
+ const std::string deviceInstance02(managerInstanceName + ".device02");
+ std::vector<std::shared_ptr<DeviceProxy<>>> deviceProxies;
+ std::vector<std::shared_ptr<SpecialDeviceProxy<>>> specialDeviceProxies;
+
+ if(testProxy_->isAvailable()) {
+ for (int var = 0; var < 20; ++var) {
+ specialDeviceProxies.push_back(
+ testProxy_->getProxyManagerSpecialDevice().buildProxy<
+ SpecialDeviceProxy>(specialDeviceInstance));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance01));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance02));
+ }
+ }
+
+ for(const auto &dp : deviceProxies) {
+ while (!dp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ dp->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ for(const auto &sdp : specialDeviceProxies) {
+ while (!sdp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ sdp->doSomethingSpecial(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ // Remove all
+ testStub_->getStubAdapter()->deactivateManagedInstances();
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+}
+
+/**
+ * @test
+ * - Subscribe on the events about availability status changes at the manager
+ * - Add managed interfaces to the manager
+ * - Check that the client is notified about the newly added interfaces
+ * - Build proxies through the manager to the managed interfaces
+ * - Call a method on the managed interfaces and check call status
+ * - Don't deregister managed interfaces. This is done in dtor of manager's
+ * StubAdapterInternal when manager service is unregistered in
+ * TearDown() method.
+ */
+TEST_F(AFManaged, BuildProxyThroughManagerAndMethodCallMultipleDeregistrationImplicit) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+
+ const std::string specialDeviceInstance(managerInstanceName + ".specialDevice00");
+ const std::string deviceInstance01(managerInstanceName + ".device01");
+ const std::string deviceInstance02(managerInstanceName + ".device02");
+ std::vector<std::shared_ptr<DeviceProxy<>>> deviceProxies;
+ std::vector<std::shared_ptr<SpecialDeviceProxy<>>> specialDeviceProxies;
+
+ if(testProxy_->isAvailable()) {
+ for (int var = 0; var < 20; ++var) {
+ specialDeviceProxies.push_back(
+ testProxy_->getProxyManagerSpecialDevice().buildProxy<
+ SpecialDeviceProxy>(specialDeviceInstance));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance01));
+ deviceProxies.push_back(
+ testProxy_->getProxyManagerDevice().buildProxy<DeviceProxy>(
+ deviceInstance02));
+ }
+ }
+
+ for(const auto &dp : deviceProxies) {
+ while (!dp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ dp->doSomething(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+
+ for(const auto &sdp : specialDeviceProxies) {
+ while (!sdp->isAvailable()) {
+ usleep(100);
+ }
+ CommonAPI::CallStatus call(CommonAPI::CallStatus::UNKNOWN);
+ sdp->doSomethingSpecial(call);
+ ASSERT_EQ(call, CommonAPI::CallStatus::SUCCESS);
+ }
+}
+
+/**
+ * @test
+ * - Test the getConnectionId, getDomain and getInteface methods
+ * available via the ProxyManager of the respective managed interfaces
+ * of the manager
+ */
+TEST_F(AFManaged, ProxyManagerTestPrimitiveMethods) {
+ // Commented out because fails under D-Bus binding.
+ // ASSERT_EQ(testProxy_->getProxyManagerDevice().getConnectionId(), connectionIdClient);
+ // ASSERT_EQ(testProxy_->getProxyManagerSpecialDevice().getConnectionId(), connectionIdClient);
+
+ ASSERT_EQ(testProxy_->getProxyManagerDevice().getDomain(), domain);
+ ASSERT_EQ(testProxy_->getProxyManagerSpecialDevice().getDomain(), domain);
+
+ ASSERT_EQ(testProxy_->getProxyManagerDevice().getInterface(), interfaceDevice);
+ ASSERT_EQ(testProxy_->getProxyManagerSpecialDevice().getInterface(), interfaceSpecialDevice);
+}
+
+/**
+ * @test
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatus method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Add a different managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatus method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Add a second instance of the same managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatus method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, ProxyManagerTestNonPrimitiveMethodsSync) {
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 1);
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::UNKNOWN;
+ std::vector<std::string> availableSpecialDevices;
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstances(callStatus,
+ availableSpecialDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableSpecialDevices.size(), 1);
+ bool allDetectedAreAvailable = false;
+ for(auto &i : availableSpecialDevices) {
+ for(auto &j : specialDevicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ ASSERT_TRUE(checkInstanceAvailabilityStatus(&testProxy_->getProxyManagerSpecialDevice(), j));
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 1);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ std::vector<std::string> availableDevices;
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 1);
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ ASSERT_TRUE(checkInstanceAvailabilityStatus(&testProxy_->getProxyManagerDevice(), j));
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 2);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 2);
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ ASSERT_TRUE(checkInstanceAvailabilityStatus(&testProxy_->getProxyManagerDevice(), j));
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 0);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableSpecialDevices.clear();
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstances(callStatus,
+ availableSpecialDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableSpecialDevices.size(), 0);
+
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+ ASSERT_LE(devicesAvailable_.size(), 1);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 1);
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ ASSERT_TRUE(checkInstanceAvailabilityStatus(&testProxy_->getProxyManagerDevice(), j));
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 0);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 0);
+}
+
+/**
+ * @test
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstancesAsync method to check that all
+ * registered instances are returned
+ * - Add a different managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstancesAsync method to check that all
+ * registered instances are returned
+ * - Add a second instance of the same managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstancesAsync method to check that all
+ * registered instances are returned
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, ProxyManagerTestNonPrimitiveMethodsAsync) {
+ std::function<
+ void(const CommonAPI::CallStatus &,
+ const std::vector<std::string> &)> getAvailableInstancesAsyncSpecialDeviceCallbackFunc =
+ std::bind(
+ &AFManaged_ProxyManagerTestNonPrimitiveMethodsAsync_Test::getAvailableInstancesAsyncSpecialDeviceCallback,
+ this, std::placeholders::_1, std::placeholders::_2);
+
+ std::function<
+ void(const CommonAPI::CallStatus &,
+ const std::vector<std::string> &)> getAvailableInstancesAsyncDeviceCallbackFunc =
+ std::bind(
+ &AFManaged_ProxyManagerTestNonPrimitiveMethodsAsync_Test::getAvailableInstancesAsyncDeviceCallback,
+ this, std::placeholders::_1, std::placeholders::_2);
+
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 1);
+ specialDeviceAvailableDesiredValue_ = 1;
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstancesAsync(getAvailableInstancesAsyncSpecialDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 1);
+ deviceAvailableDesiredValue_ = 1;
+ testProxy_->getProxyManagerDevice().getAvailableInstancesAsync(
+ getAvailableInstancesAsyncDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 2);
+ deviceAvailableDesiredValue_ = 2;
+ testProxy_->getProxyManagerDevice().getAvailableInstancesAsync(
+ getAvailableInstancesAsyncDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 0);
+ specialDeviceAvailableDesiredValue_ = 0;
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstancesAsync(getAvailableInstancesAsyncSpecialDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+ ASSERT_LE(devicesAvailable_.size(), 1);
+ deviceAvailableDesiredValue_ = 1;
+ testProxy_->getProxyManagerDevice().getAvailableInstancesAsync(getAvailableInstancesAsyncDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+ ASSERT_LE(devicesAvailable_.size(), 0);
+ deviceAvailableDesiredValue_ = 0;
+ testProxy_->getProxyManagerDevice().getAvailableInstancesAsync(getAvailableInstancesAsyncDeviceCallbackFunc);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+}
+
+/**
+ * @test
+ * - Add a managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatusAsync method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Add a different managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatusAsync method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Add a second instance of the same managed interface to the manager
+ * - Check that the client is notified about the newly added interface
+ * - Use the ProxyManager's getAvailableInstances method to check that all
+ * registered instances are returned
+ * - Use the ProxyManager's checkInstanceAvailabilityStatusAsync method to check that all
+ * returned instances by getAvailableInstances are available
+ * - Remove all the managed interfaces from the manager
+ * - Check that the client is notified about the removed interfaces
+ */
+TEST_F(AFManaged, DISABLED_ProxyManagerTestGetInstanceAvailabilityStatusAsync) {
+ std::function<
+ void(const CommonAPI::CallStatus &,
+ const CommonAPI::AvailabilityStatus &)> getInstanceAvailabilityStatusAsyncCallbackAvailableFunc =
+ std::bind(
+ &AFManaged_DISABLED_ProxyManagerTestGetInstanceAvailabilityStatusAsync_Test::getInstanceAvailabilityStatusAsyncCallbackAvailable,
+ this, std::placeholders::_1, std::placeholders::_2);
+
+ std::function<
+ void(const CommonAPI::CallStatus &,
+ const CommonAPI::AvailabilityStatus &)> getInstanceAvailabilityStatusAsyncCallbackNotAvailableFunc =
+ std::bind(
+ &AFManaged_DISABLED_ProxyManagerTestGetInstanceAvailabilityStatusAsync_Test::getInstanceAvailabilityStatusAsyncCallbackNotAvailable,
+ this, std::placeholders::_1, std::placeholders::_2);
+
+ // Add
+ testStub_->specialDeviceDetected(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(specialDeviceAvailableCountMutex_);
+ ASSERT_EQ(specialDeviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 1);
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::UNKNOWN;
+ std::vector<std::string> availableSpecialDevices;
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstances(callStatus,
+ availableSpecialDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableSpecialDevices.size(), 1);
+ bool allDetectedAreAvailable = false;
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ for(auto &i : availableSpecialDevices) {
+ for(auto &j : specialDevicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ testProxy_->getProxyManagerSpecialDevice().getInstanceAvailabilityStatusAsync(
+ j.getInstance(),
+ getInstanceAvailabilityStatusAsyncCallbackAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ testStub_->deviceDetected(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 1);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 1);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ std::vector<std::string> availableDevices;
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 1);
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusAsync(
+ j.getInstance(),
+ getInstanceAvailabilityStatusAsyncCallbackAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ testStub_->deviceDetected(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_EQ(deviceAvailableCount_, 2);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 2);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 2);
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusAsync(
+ j.getInstance(),
+ getInstanceAvailabilityStatusAsyncCallbackAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+ // Remove
+ testStub_->specialDeviceRemoved(0);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(specialDeviceAvailableCount_, 0);
+ }
+ ASSERT_EQ(specialDevicesAvailable_.size(), 0);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableSpecialDevices.clear();
+ testProxy_->getProxyManagerSpecialDevice().getAvailableInstances(callStatus,
+ availableSpecialDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableSpecialDevices.size(), 0);
+ testProxy_->getProxyManagerSpecialDevice().getInstanceAvailabilityStatusAsync(
+ "local:managed.SpecialDevice:managed-test.Manager.specialDevice00",
+ getInstanceAvailabilityStatusAsyncCallbackNotAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+
+ testStub_->deviceRemoved(1);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 1);
+ }
+ ASSERT_LE(devicesAvailable_.size(), 1);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 1);
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusAsync(
+ "local:managed.Device:commonapi.advanced.managed.Manager.device01",
+ getInstanceAvailabilityStatusAsyncCallbackNotAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ allDetectedAreAvailable = false;
+ for(auto &i : availableDevices) {
+ for(auto &j : devicesAvailable_) {
+ if(i == j.getInstance()) {
+ allDetectedAreAvailable = true;
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusAsync(
+ j.getInstance(),
+ getInstanceAvailabilityStatusAsyncCallbackAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+ instanceAvailabilityStatusCallbackCalled_ = false;
+ break;
+ }
+ }
+ ASSERT_TRUE(allDetectedAreAvailable);
+ }
+
+
+ testStub_->deviceRemoved(2);
+ std::this_thread::sleep_for(std::chrono::milliseconds(sleepMilli));
+ {
+ std::lock_guard<std::mutex> lock(deviceAvailableCountMutex_);
+ ASSERT_LE(deviceAvailableCount_, 0);
+ }
+ ASSERT_EQ(devicesAvailable_.size(), 0);
+ callStatus = CommonAPI::CallStatus::UNKNOWN;
+ availableDevices.clear();
+ testProxy_->getProxyManagerDevice().getAvailableInstances(callStatus,
+ availableDevices);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(availableDevices.size(), 0);
+ testProxy_->getProxyManagerDevice().getInstanceAvailabilityStatusAsync(
+ "local:managed.Device:commonapi.advanced.managed.Manager.device02",
+ getInstanceAvailabilityStatusAsyncCallbackNotAvailableFunc);
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(sleepMilli));
+ ASSERT_TRUE(instanceAvailabilityStatusCallbackCalled_);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new ::testing::Environment());
+ return RUN_ALL_TESTS();
+}
diff --git a/org.genivi.commonapi.core.verification/src/AFPolymorph.cpp b/org.genivi.commonapi.core.verification/src/AFPolymorph.cpp
new file mode 100644
index 0000000..79fb886
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/AFPolymorph.cpp
@@ -0,0 +1,317 @@
+// 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/.
+
+/**
+* @file AFPolymorph.cpp
+*/
+
+#include <functional>
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <fstream>
+#include <gtest/gtest.h>
+#include "CommonAPI/CommonAPI.hpp"
+
+#include "v1/commonapi/advanced/polymorph/TestInterfaceProxy.hpp"
+#include "stub/AFPolymorphStub.h"
+
+const std::string domain = "local";
+const std::string testAddress = "commonapi.advanced.polymorph.TestInterface";
+const std::string connectionId_client = "client-sample";
+const std::string connectionId_service = "service-sample";
+
+class Environment: public ::testing::Environment {
+public:
+ virtual ~Environment() {
+ }
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+using namespace v1_0::commonapi::advanced::polymorph;
+
+class AFPolymorph: public ::testing::Test {
+
+protected:
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
+ std::mutex availabilityMutex;
+ std::unique_lock<std::mutex> lock(availabilityMutex);
+ std::condition_variable cv;
+ bool proxyAvailable = false;
+
+ std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() {
+ std::lock_guard<std::mutex> lock(availabilityMutex);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, connectionId_client);
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE((bool)testProxy_);
+ proxyAvailable = true;
+ cv.notify_one();
+ });
+
+ testStub_ = std::make_shared<AFPolymorphStub>();
+ serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, connectionId_service);
+ ASSERT_TRUE(serviceRegistered_);
+
+ while(!proxyAvailable) {
+ cv.wait(lock);
+ }
+ t1.join();
+ ASSERT_TRUE(testProxy_->isAvailable());
+ }
+
+ void TearDown() {
+ runtime_->unregisterService(domain, AFPolymorphStub::StubInterface::getInterface(), testAddress);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
+ }
+
+ bool received_;
+ bool serviceRegistered_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+
+ std::shared_ptr<TestInterfaceProxy<>> testProxy_;
+ std::shared_ptr<AFPolymorphStub> testStub_;
+
+};
+/**
+ * @test
+ * - Set and get a typedef-type attribute through a polymorphic structure
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, SetAndGetAttributeTypedef) {
+
+ CommonAPI::CallStatus callStatus;
+
+ auto a1 = std::make_shared<TestInterface::PStructMyTypedef>(-5);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->getA1Attribute().setValue(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ testProxy_->getA1Attribute().getValue(callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructMyTypedef> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructMyTypedef>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ((int)sp->getId(), -5);
+
+}
+
+/**
+ * @test
+ * - Set and get a enum-type attribute through a polymorphic structure
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, SetAndGetAttributeEnum) {
+
+ CommonAPI::CallStatus callStatus;
+
+ auto a1 = std::make_shared<TestInterface::PStructMyEnum>(TestInterface::MyEnum::Literal::OFF);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->getA1Attribute().setValue(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ testProxy_->getA1Attribute().getValue(callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructMyEnum> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructMyEnum>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ((int)sp->getStatus(), TestInterface::MyEnum::Literal::OFF);
+
+}
+
+/**
+ * @test
+ * - Set and get a uint-type attribute through a polymorphic structure
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, SetAndGetAttributeUInt) {
+
+ CommonAPI::CallStatus callStatus;
+
+ auto a1 = std::make_shared<TestInterface::PStructUInt8>(123);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->getA1Attribute().setValue(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ testProxy_->getA1Attribute().getValue(callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructUInt8> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructUInt8>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ((int)sp->getChannel(), 123);
+
+}
+
+/**
+ * @test
+ * - Set and get a string-type attribute through a polymorphic structure
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, SetAndGetAttributeString) {
+
+ CommonAPI::CallStatus callStatus;
+
+ auto a1 = std::make_shared<TestInterface::PStructString>("123");
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->getA1Attribute().setValue(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ testProxy_->getA1Attribute().getValue(callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructString> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructString>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ(sp->getName(), "123");
+
+}
+
+/**
+ * @test
+ * - Set and get a struct-type attribute through a polymorphic structure
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, SetAndGetAttributeStruct) {
+
+ CommonAPI::CallStatus callStatus;
+ TestInterface::BStruct b;
+ b.setA1(17);
+ b.setA2(19);
+ b.setS1("ABQZ");
+
+
+ auto a1 = std::make_shared<TestInterface::PStructStruct>(b);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->getA1Attribute().setValue(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ testProxy_->getA1Attribute().getValue(callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructStruct> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructStruct>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ(sp->getS().getA1(), 17);
+ EXPECT_EQ(sp->getS().getA2(), 19);
+ EXPECT_EQ(sp->getS().getS1(), "ABQZ");
+}
+
+/**
+ * @test
+ * - Call a method whose input and output parameters are polymorphic structures
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, MethodCall) {
+
+ CommonAPI::CallStatus callStatus;
+
+ auto a1 = std::make_shared<TestInterface::PStructMyTypedef>(-5);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->testMethod(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructMyTypedef> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructMyTypedef>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ((int)sp->getId(), -5);
+
+}
+
+/**
+ * @test
+ * - Call a method with a special value that tells the stub to send a broadcast signal
+ * - verify that the received data matches the transmitted data
+ */
+TEST_F(AFPolymorph, Broadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ int result;
+ // subscribe to broadcast
+ testProxy_->getBTestEvent().subscribe([&](
+ const std::shared_ptr<TestInterface::PStructBase> &y
+ ) {
+ std::shared_ptr<TestInterface::PStructMyTypedef> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructMyTypedef>(y);
+
+ ASSERT_TRUE(sp != nullptr);
+ result = (int)sp->getId();
+ });
+
+ // send '1' through method - this tells the stub to send the broadcast
+ auto a1 = std::make_shared<TestInterface::PStructMyTypedef>(1);
+ std::shared_ptr<TestInterface::PStructBase> a2 = std::make_shared<TestInterface::PStructBase>();
+ std::shared_ptr<TestInterface::PStructBase> a3 = std::make_shared<TestInterface::PStructBase>();
+
+ a2 = static_cast<std::shared_ptr<TestInterface::PStructBase>>(a1);
+
+ testProxy_->testMethod(a2, callStatus, a3);
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ std::shared_ptr<TestInterface::PStructMyTypedef> sp =
+ std::dynamic_pointer_cast<TestInterface::PStructMyTypedef>(a3);
+
+ ASSERT_TRUE(sp != nullptr);
+ EXPECT_EQ((int)sp->getId(), 1);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result == 1) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(result, 1);
+
+}
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new Environment());
+ return RUN_ALL_TESTS();
+}
diff --git a/org.genivi.commonapi.core.verification/src/AFSelective.cpp b/org.genivi.commonapi.core.verification/src/AFSelective.cpp
new file mode 100644
index 0000000..dc192db
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/AFSelective.cpp
@@ -0,0 +1,442 @@
+// 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/.
+
+/**
+* @file advanced/selective
+*/
+
+#include <functional>
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <fstream>
+#include <gtest/gtest.h>
+#include "CommonAPI/CommonAPI.hpp"
+#include "v1/commonapi/advanced/bselective/TestInterfaceProxy.hpp"
+#include "stub/AFSelectiveStub.h"
+
+const std::string serviceId = "service-sample";
+const std::string clientId = "client-sample";
+const std::string otherclientId = "other-client-sample";
+
+const std::string domain = "local";
+const std::string testAddress = "commonapi.advanced.bselective.TestInterface";
+const int tasync = 100000;
+
+using namespace v1_0::commonapi::advanced::bselective;
+
+class Environment: public ::testing::Environment {
+public:
+ virtual ~Environment() {
+ }
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+class AFSelective: public ::testing::Test {
+
+public:
+
+ void recvSubscribedValue(uint8_t y) {
+ value_ = y;
+ }
+
+protected:
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
+ std::mutex availabilityMutex;
+ std::mutex availabilityMutex2;
+ std::unique_lock<std::mutex> lock(availabilityMutex);
+ std::unique_lock<std::mutex> lock2(availabilityMutex2);
+ std::condition_variable cv;
+ std::condition_variable cv2;
+ bool proxyAvailable = false;
+ bool proxy2Available = false;
+
+ std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() {
+ std::lock_guard<std::mutex> lock(availabilityMutex);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE((bool)testProxy_);
+ proxyAvailable = true;
+ cv.notify_one();
+ });
+
+ std::thread t2([this, &proxy2Available, &cv2, &availabilityMutex2]() {
+ std::lock_guard<std::mutex> lock2(availabilityMutex2);
+ testProxy2_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, otherclientId);
+ testProxy2_->isAvailableBlocking();
+ ASSERT_TRUE((bool)testProxy2_);
+ proxy2Available = true;
+ cv2.notify_one();
+ });
+
+ testStub_ = std::make_shared<AFSelectiveStub>();
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
+
+ while(!proxyAvailable) {
+ cv.wait(lock);
+ }
+ t1.join();
+ ASSERT_TRUE(testProxy_->isAvailable());
+
+ while(!proxy2Available) {
+ cv2.wait(lock2);
+ }
+ t2.join();
+ ASSERT_TRUE(testProxy2_->isAvailable());
+ }
+
+ void TearDown() {
+ bool serviceUnregistered =
+ runtime_->unregisterService(domain, AFSelectiveStub::StubInterface::getInterface(),
+ testAddress);
+
+ ASSERT_TRUE(serviceUnregistered);
+
+ // wait that proxies are not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ counter++;
+ }
+ ASSERT_FALSE(testProxy_->isAvailable());
+
+ counter = 0; // counter for avoiding endless loop
+ while ( testProxy2_->isAvailable() && counter < 10 ) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ counter++;
+ }
+ ASSERT_FALSE(testProxy2_->isAvailable());
+ }
+
+ uint8_t value_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+ std::shared_ptr<AFSelectiveStub> testStub_;
+ std::shared_ptr<TestInterfaceProxy<>> testProxy_;
+ std::shared_ptr<TestInterfaceProxy<>> testProxy2_;
+};
+
+
+/**
+* @test Test selective broadcasts.
+* - inform stub to stop accepting subscriptions
+* - try to subscribe to the selective broadcast
+* - check that an error was received
+* - inform stub to send a broadcast
+* - check that nothing was received in a reasonable time
+*/
+TEST_F(AFSelective, SelectiveBroadcastRejected) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '2' via a method call - this tells stub to stop accepting subs
+ in_ = 2;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that subscription failed correctly
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ // EXPECT_EQ(subStatus, CommonAPI::CallStatus::SUBSCRIPTION_REFUSED); // Not supported by SOME/IP yet.
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that no value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ uint8_t expected = 0;
+ EXPECT_EQ(expected, result);
+
+}
+
+/**
+* @test Test selective broadcasts.
+* - inform stub to start accepting subscriptions
+* - subscribe to the selective broadcast
+* - check that no error was received (in a reasonable time)
+* - inform stub to send a broadcast
+* - check that a correct value is received
+*/
+TEST_F(AFSelective, SelectiveBroadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '4' via a method call - this tells stub to start accepting subs
+ in_ = 4;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(CommonAPI::CallStatus::UNKNOWN, subStatus);
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ uint8_t expected = 1;
+ EXPECT_EQ(expected, result);
+}
+
+/**
+* @test Test multiple selective broadcasts.
+* - inform stub to start accepting subscriptions
+* - subscribe to the selective broadcast
+* - check that no error was received (in a reasonable time)
+* - inform stub to send a broadcast
+* - check that a correct value is received
+*/
+TEST_F(AFSelective, SelectiveMultiBroadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t result2 = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '4' via a method call - this tells stub to start accepting subs
+ in_ = 4;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(CommonAPI::CallStatus::UNKNOWN, subStatus);
+
+ // subscribe from another proxy
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy2_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result2 = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(CommonAPI::CallStatus::UNKNOWN, subStatus);
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ uint8_t expected = 1;
+ EXPECT_EQ(expected, result);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result2 != 0) break;
+ usleep(10000);
+ }
+ uint8_t expected2 = 1;
+ EXPECT_EQ(expected2, result2);
+}
+
+/**
+* @test Test multiple selective broadcasts, with rejection.
+* - subscribe to stub three times:
+* once from proxy2,
+* once from proxy1 (accepted)
+* once from proxy2 (rejected)
+* - This should result with two subscription callbacks being called from broadcast.
+*/
+
+/*
+ * This test currently fails because a single proxy can only subscribe once.
+ * When proxy subscribes the second time, the stub is not notified.
+ * Therefore, whatever the stub did with the first subscription (rejected / accepted)
+ * will also hold for the second subscription.
+ */
+
+TEST_F(AFSelective, DISABLED_SelectiveRejectedMultiBroadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t result2 = 0;
+ uint8_t result3 = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '4' via a method call - this tells stub to start accepting subs
+ in_ = 4;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(CommonAPI::CallStatus::UNKNOWN, subStatus);
+
+ // subscribe from another proxy
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy2_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result3 = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(CommonAPI::CallStatus::UNKNOWN, subStatus);
+
+ // send value '2' via a method call - this tells stub to stop accepting subs
+ in_ = 2;
+ testProxy2_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy2_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result2 = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that subscription failed correctly
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ // EXPECT_EQ(subStatus, CommonAPI::CallStatus::SUBSCRIPTION_REFUSED); // Not supported by SOME/IP yet.
+
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ uint8_t expected = 1;
+ EXPECT_EQ(expected, result);
+ uint8_t expected2 = 0;
+ EXPECT_EQ(expected2, result2);
+ uint8_t expected3 = 1;
+ EXPECT_EQ(expected3, result3);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new Environment());
+ return RUN_ALL_TESTS();
+}
diff --git a/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp
index 4a0c01c..554b90d 100644
--- a/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp
+++ b/org.genivi.commonapi.core.verification/src/CMAttributeSubscription.cpp
@@ -16,9 +16,9 @@
#include <thread>
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp"
-#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp"
-#include "v1_0/commonapi/communication/DaemonStubDefault.hpp"
+#include "v1/commonapi/communication/TestInterfaceProxy.hpp"
+#include "v1/commonapi/communication/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/communication/DaemonStubDefault.hpp"
#include "stub/CMAttributesStub.h"
const std::string daemonId = "service-sample";
@@ -72,16 +72,16 @@ public:
/* for test purposes, magic value 99 unsubscribes the attribute. */
if (val == 99) {
- // We can't call cancleSubscribe() within the async handler
- // because it lead to a dead lock with the SomeIP-binding.
- // Therefore we unsubscribe within the main thread of the test case!
- //
- // The reason for the dead lock is because within the async handler
- // the connection thread is holding the Connection::sendReceiveMutex_
- // which will locked again when calling Connection::removeEventHandler
- // which is implicitly called when unsubscribing!
+ // We can't call cancleSubscribe() within the async handler
+ // because it lead to a dead lock with the SomeIP-binding.
+ // Therefore we unsubscribe within the main thread of the test case!
+ //
+ // The reason for the dead lock is because within the async handler
+ // the connection thread is holding the Connection::sendReceiveMutex_
+ // which will locked again when calling Connection::removeEventHandler
+ // which is implicitly called when unsubscribing!
- // cancelSubscribe();
+ // cancelSubscribe();
}
}
@@ -110,7 +110,19 @@ public:
}
void resetSubcriptedTestAttribute() {
- testAttribute_ = 0;
+ testAttribute_ = 0;
+ }
+
+ bool wait_Attribute(uint8_t expected) {
+ uint8_t count = 0;
+ while (count++ < 50) {
+ if (testAttribute_ == expected) {
+ usleep(wt); // Wait a while to ensure its not (unwanted) changed
+ return true;
+ }
+ usleep(100000);
+ }
+ return false;
}
std::deque<uint8_t> myQueue_;
@@ -131,9 +143,9 @@ class SubscribeUnsubscribeHandler {
public:
- SubscribeUnsubscribeHandler() {
- okAttribute_ = 0;
- notOkAttribute_ = 0;
+ SubscribeUnsubscribeHandler() {
+ okAttribute_ = 0;
+ notOkAttribute_ = 0;
}
void okCallback(const uint8_t& val) {
@@ -141,7 +153,7 @@ public:
}
void notOkCallback(const uint8_t& val) {
- notOkAttribute_ = val;
+ notOkAttribute_ = val;
}
uint8_t getSubscribedOkAttribute() {
@@ -149,9 +161,32 @@ public:
}
uint8_t getSubscribedNotOkAttribute() {
- return notOkAttribute_;
- }
+ return notOkAttribute_;
+ }
+
+ bool wait_OkAttribute(uint8_t expected) {
+ uint8_t count = 0;
+ while (count++ < 50) {
+ if (okAttribute_ == expected) {
+ usleep(wt); // Wait a while to ensure its not (unwanted) changed
+ return true;
+ }
+ usleep(100000);
+ }
+ return false;
+ }
+ bool wait_NotOkAttribute(uint8_t expected) {
+ uint8_t count = 0;
+ while (count++ < 50) {
+ if (notOkAttribute_ == expected) {
+ usleep(wt); // Wait a while to ensure its not (unwanted) changed
+ return true;
+ }
+ usleep(100000);
+ }
+ return false;
+ }
private:
uint8_t okAttribute_;
@@ -160,70 +195,82 @@ private:
class ThreeCallbackHandler {
public:
- ThreeCallbackHandler() :
- callbackCounter_1_(0),
- callbackCounter_2_(0),
- callbackCounter_3_(0),
- callbackValue_1_(0),
- callbackValue_2_(0),
- callbackValue_3_(0) {
-
- }
-
- void callback_1(const uint8_t& val) {
- callbackCounter_1_++;
- callbackValue_1_ = val;
- }
-
- void callback_2(const uint8_t& val) {
- callbackCounter_2_++;
- callbackValue_2_ = val;
- }
-
- void callback_3(const uint8_t& val) {
- callbackCounter_3_++;
- callbackValue_3_ = val;
- }
-
- uint8_t getCallbackCounter_1() {
- return callbackCounter_1_;
- }
-
- uint8_t getCallbackCounter_2() {
- return callbackCounter_2_;
- }
-
- uint8_t getCallbackCounter_3() {
- return callbackCounter_3_;
- }
-
- uint8_t getCallbackValue_1() {
- return callbackValue_1_;
- }
-
- uint8_t getCallbackValue_2() {
- return callbackValue_2_;
- }
-
- uint8_t getCallbackValue_3() {
- return callbackValue_3_;
- }
+ ThreeCallbackHandler() :
+ callbackCounter_1_(0),
+ callbackCounter_2_(0),
+ callbackCounter_3_(0),
+ callbackValue_1_(0),
+ callbackValue_2_(0),
+ callbackValue_3_(0) {
+
+ }
+
+ void callback_1(const uint8_t& val) {
+ callbackCounter_1_++;
+ callbackValue_1_ = val;
+ }
+
+ void callback_2(const uint8_t& val) {
+ callbackCounter_2_++;
+ callbackValue_2_ = val;
+ }
+
+ void callback_3(const uint8_t& val) {
+ callbackCounter_3_++;
+ callbackValue_3_ = val;
+ }
+
+ uint8_t getCallbackCounter_1() {
+ return callbackCounter_1_;
+ }
+
+ uint8_t getCallbackCounter_2() {
+ return callbackCounter_2_;
+ }
+
+ uint8_t getCallbackCounter_3() {
+ return callbackCounter_3_;
+ }
+
+ uint8_t getCallbackValue_1() {
+ return callbackValue_1_;
+ }
+
+ uint8_t getCallbackValue_2() {
+ return callbackValue_2_;
+ }
+
+ uint8_t getCallbackValue_3() {
+ return callbackValue_3_;
+ }
+
+ bool waitCallbacks() {
+ uint8_t count = 0;
+ while (count++ < 50) {
+ if (callbackCounter_1_ > 0 && callbackCounter_2_ > 0 && callbackCounter_3_ > 0) {
+ usleep(wt); // Sleep to ensure that it not called again in the meanwhile
+ return true;
+ }
+ usleep(100000);
+ }
+ return false;
+ }
private:
- uint8_t callbackCounter_1_;
- uint8_t callbackCounter_2_;
- uint8_t callbackCounter_3_;
+ uint8_t callbackCounter_1_;
+ uint8_t callbackCounter_2_;
+ uint8_t callbackCounter_3_;
- uint8_t callbackValue_1_;
- uint8_t callbackValue_2_;
- uint8_t callbackValue_3_;
+ uint8_t callbackValue_1_;
+ uint8_t callbackValue_2_;
+ uint8_t callbackValue_3_;
};
void testSubscription(ProxyPtr pp) {
SubscriptionHandler subscriptionHandler(pp);
- std::function<void(CommonAPI::AvailabilityStatus)> callbackAvailabilityStatus =
+ std::function<void(const CommonAPI::AvailabilityStatus&)> callbackAvailabilityStatus =
std::bind(&SubscriptionHandler::receiveServiceAvailable, &subscriptionHandler, std::placeholders::_1);
pp->getProxyStatusEvent().subscribe(callbackAvailabilityStatus);
@@ -259,12 +306,21 @@ protected:
}
void TearDown() {
- // secure, that service is deregistered by finishing the test
- if (deregisterService_) {
- bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
- ASSERT_TRUE(isUnregistered);
- }
+ // secure, that service is deregistered by finishing the test
+ if (deregisterService_) {
+ bool isUnregistered = runtime_->unregisterService(domain,
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ ASSERT_TRUE(isUnregistered);
+ }
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
std::shared_ptr<CommonAPI::Runtime> runtime_;
@@ -282,13 +338,13 @@ public:
}
virtual void SetUp() {
- stubDaemon_ = std::make_shared<DaemonStubDefault>();
- CommonAPI::Runtime::get()->registerService(domain, daemonAddress, stubDaemon_, daemonId);
+ stubDaemon_ = std::make_shared<DaemonStubDefault>();
+ CommonAPI::Runtime::get()->registerService(domain, daemonAddress, stubDaemon_, daemonId);
}
virtual void TearDown() {
- CommonAPI::Runtime::get()->unregisterService(domain, DaemonStubDefault::StubInterface::getInterface(),
- daemonAddress);
+ CommonAPI::Runtime::get()->unregisterService(domain, DaemonStubDefault::StubInterface::getInterface(),
+ daemonAddress);
}
private:
@@ -297,21 +353,21 @@ private:
/**
* @test Subscription standard test.
- * - Register service and check if proxy is available.
- * - Proxy subscribes for TestAttribute (uint8_t).
- * - Change attribute in service several times by set method.
- * - Callback function in proxy writes the received values in a queue.
- * - Check if values in the queue are the same as the values that were set in the service.
- * - Unregister test service.
+ * - Register service and check if proxy is available.
+ * - Proxy subscribes for TestAttribute (uint8_t).
+ * - Change attribute in service several times by set method.
+ * - Callback function in proxy writes the received values in a queue.
+ * - Check if values in the queue are the same as the values that were set in the service.
+ * - Unregister test service.
*/
TEST_F(CMAttributeSubscription, SubscriptionStandard) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t defaultValue = 33;
+ uint8_t defaultValue = 33;
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(defaultValue);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(defaultValue);
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
ASSERT_TRUE(serviceRegistered);
@@ -321,15 +377,15 @@ TEST_F(CMAttributeSubscription, SubscriptionStandard) {
SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
CommonAPI::Event<uint8_t>::Subscription subscribedListener =
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
const uint8_t testNumber = 10;
for (uint8_t i=1; i<testNumber+1; i++) {
- usleep(100000);
- testStub_->setTestAttributeAttribute(i);
+ usleep(100000);
+ testStub_->setTestAttributeAttribute(i);
}
usleep(wt);
@@ -337,19 +393,19 @@ TEST_F(CMAttributeSubscription, SubscriptionStandard) {
uint8_t t = 0;
for(std::deque<uint8_t>::iterator it = subscriptionHandler.myQueue_.begin(); it != subscriptionHandler.myQueue_.end(); ++it) {
- if (t == 0) {
- EXPECT_EQ(*it, defaultValue);
- t++;
- } else {
- EXPECT_EQ(*it, t);
- t++;
- }
+ if (t == 0) {
+ EXPECT_EQ(defaultValue, *it);
+ t++;
+ } else {
+ EXPECT_EQ(t, *it);
+ t++;
+ }
}
testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener);
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
usleep(wt);
@@ -360,36 +416,37 @@ TEST_F(CMAttributeSubscription, SubscriptionStandard) {
/**
* @test Subscription test with subscription on available-event.
- * - Subscribe for available-event.
- * - Available-callback subscribes for TestPredefinedTypeAttribute if service is available for proxy and
- * unsubscribes if service is not available for proxy.
- * - Change attribute in service by set method; the new attribute value should be received by the proxy because the service is not registered.
- * - Register service and change value again; the value should now be received.
- * - Unregister and change value again.
+ * - Subscribe for available-event.
+ * - Available-callback subscribes for TestPredefinedTypeAttribute if service is available for proxy and
+ * unsubscribes if service is not available for proxy.
+ * - Change attribute in service by set method; the new attribute value should be received by the proxy because the service is not registered.
+ * - Register service and change value again; the value should now be received.
+ * - Unregister and change value again.
*/
TEST_F(CMAttributeSubscription, SubscriptionOnAvailable) {
SubscriptionHandler subscriptionHandler(testProxy_);
- std::function<void (CommonAPI::AvailabilityStatus)> callbackAvailabilityStatus =
- std::bind(&SubscriptionHandler::receiveServiceAvailable, &subscriptionHandler, std::placeholders::_1);
+ std::function<void (const CommonAPI::AvailabilityStatus&)> callbackAvailabilityStatus =
+ std::bind(&SubscriptionHandler::receiveServiceAvailable, &subscriptionHandler, std::placeholders::_1);
testProxy_->getProxyStatusEvent().subscribe(callbackAvailabilityStatus);
testStub_->setTestAttributeAttribute(1);
usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 0);
+ EXPECT_EQ(0, subscriptionHandler.getSubscriptedTestAttribute());
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
ASSERT_TRUE(serviceRegistered);
- usleep(wt);
+
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
+
testStub_->setTestAttributeAttribute(2);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(2);
ASSERT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 2);
bool serviceUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(serviceUnregistered);
usleep(wt);
ASSERT_EQ(subscriptionHandler.getAvailabilityStatus(), CommonAPI::AvailabilityStatus::NOT_AVAILABLE);
@@ -401,16 +458,15 @@ TEST_F(CMAttributeSubscription, SubscriptionOnAvailable) {
/**
* @test Subscription test with several threads.
- * - Start several threads.
- * - The threads subscribe for the availability status.
- * - The available-callback subscribes for TestAttribute if service is available for proxy and
- * - unsubscribes if service is not available for proxy.
- * - Change attribute in service by set method; the new attribute value should be received by all the threads.
- * - The new value is written into a queue.
- * - Check if the values of each thread are written into the queue.
+ * - Start several threads.
+ * - The threads subscribe for the availability status.
+ * - The available-callback subscribes for TestAttribute if service is available for proxy and
+ * - unsubscribes if service is not available for proxy.
+ * - Change attribute in service by set method; the new attribute value should be received by all the threads.
+ * - The new value is written into a queue.
+ * - Check if the values of each thread are written into the queue.
*/
TEST_F(CMAttributeSubscription, SubscriptionMultithreading) {
-
std::thread t0(testSubscription, testProxy_);
std::thread t1(testSubscription, testProxy_);
std::thread t2(testSubscription, testProxy_);
@@ -431,7 +487,7 @@ TEST_F(CMAttributeSubscription, SubscriptionMultithreading) {
usleep(wt);
bool serviceUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(serviceUnregistered);
uint32_t data = 0;
@@ -446,7 +502,7 @@ TEST_F(CMAttributeSubscription, SubscriptionMultithreading) {
data_queue.pop_front();
}
lk.unlock();
- EXPECT_EQ(static_cast<int32_t>(data), 1);
+ EXPECT_EQ(1, static_cast<int32_t>(data));
cnt++;
}
@@ -464,13 +520,13 @@ TEST_F(CMAttributeSubscription, SubscriptionMultithreading) {
/**
* @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.
+ * - 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_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) {
@@ -484,26 +540,26 @@ TEST_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) {
SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback = std::bind(&SubscriptionHandler::myCallback,
- &subscriptionHandler, std::placeholders::_1);
+ &subscriptionHandler, std::placeholders::_1);
subscriptionHandler.startSubscribe();
testStub_->setTestAttributeAttribute(42);
- usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42);
+ subscriptionHandler.wait_Attribute(42);
+ EXPECT_EQ(42, subscriptionHandler.getSubscriptedTestAttribute());
testStub_->setTestAttributeAttribute(99);
- usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99);
+ subscriptionHandler.wait_Attribute(99);
+ EXPECT_EQ(99, subscriptionHandler.getSubscriptedTestAttribute());
subscriptionHandler.cancelSubscribe();
usleep(wt);
testStub_->setTestAttributeAttribute(250);
usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 99);
+ EXPECT_EQ(99, subscriptionHandler.getSubscriptedTestAttribute());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
}
@@ -518,42 +574,43 @@ TEST_F(CMAttributeSubscription, SubscriptionUnsubscribeFromCallback) {
*/
TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeTwoCallbacksCoexistent) {
- SubscribeUnsubscribeHandler subUnsubHandler;
+ SubscribeUnsubscribeHandler subUnsubHandler;
- CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk;
- CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk;
+ 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);
+ std::function<void (const uint8_t&)> callbackOk =
+ std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1);
+ std::function<void (const uint8_t&)> callbackNotOk =
+ std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1);
- subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk);
- subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk);
+ 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);
+ EXPECT_EQ(0, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(0, subUnsubHandler.getSubscribedNotOkAttribute());
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ ASSERT_TRUE(serviceRegistered);
- testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE(testProxy_->isAvailable());
- testStub_->setTestAttributeAttribute(2);
- usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 2);
- EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 2);
+ testStub_->setTestAttributeAttribute(2);
+ subUnsubHandler.wait_OkAttribute(2);
+ subUnsubHandler.wait_NotOkAttribute(2);
+ EXPECT_EQ(2, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(2, subUnsubHandler.getSubscribedNotOkAttribute());
testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk);
testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
testStub_->setTestAttributeAttribute(3);
usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 2);
- EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 2);
+ EXPECT_EQ(2, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(2, subUnsubHandler.getSubscribedNotOkAttribute());
bool serviceUnregistered = runtime_->unregisterService(domain, TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(serviceUnregistered);
@@ -568,49 +625,62 @@ TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeTwoCallbacksCoexistent) {
* - 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);
-
- testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
-
- // subscribe ok callback
- subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk);
-
- testStub_->setTestAttributeAttribute(10);
- usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 10);
-
- // subscribe notOk callback
- subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk);
-
- // unsubscribe notOk callback
- testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
-
- testStub_->setTestAttributeAttribute(12);
- usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12);
- EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 0);
-
- testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
- testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk);
-
- bool serviceUnregistered = runtime_->unregisterService(domain, TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
- ASSERT_TRUE(serviceUnregistered);
- usleep(wt);
-}
+/*
+ * COMMENTED OUT because test case fails (rarely).
+ * The reason for that is a different implementation as in test description:
+ * 1. subscribe first callback
+ * 2. change value
+ * 3. subscribe second callback
+ * 4. unsubscribe second callback
+ *
+ * Between 3. and 4. (before unsubscription) the initial callback can be triggered.
+ * This leads to a failing 'EXPECT_EQ(0, subUnsubHandler.getSubscribedNotOkAttribute())'
+ * command (Expected is '0' Actual is '10').
+ *
+ */
+//TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeImmediatelyUnsubscribing) {
+//
+// SubscribeUnsubscribeHandler subUnsubHandler;
+//
+// CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk;
+// CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk;
+//
+// std::function<void (const uint8_t&)> callbackOk =
+// std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1);
+// std::function<void (const uint8_t&)> callbackNotOk =
+// std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1);
+//
+// bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+// ASSERT_TRUE(serviceRegistered);
+//
+// testProxy_->isAvailableBlocking();
+// ASSERT_TRUE(testProxy_->isAvailable());
+//
+// // subscribe ok callback
+// subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk);
+//
+// testStub_->setTestAttributeAttribute(10);
+// subUnsubHandler.wait_OkAttribute(10);
+// EXPECT_EQ(10, subUnsubHandler.getSubscribedOkAttribute());
+//
+// // subscribe notOk callback
+// subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk);
+//
+// // unsubscribe notOk callback
+// testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
+//
+// testStub_->setTestAttributeAttribute(12);
+// subUnsubHandler.wait_OkAttribute(12);
+// EXPECT_EQ(12, subUnsubHandler.getSubscribedOkAttribute());
+// EXPECT_EQ(0, subUnsubHandler.getSubscribedNotOkAttribute());
+//
+// testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
+// testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk);
+//
+// bool serviceUnregistered = runtime_->unregisterService(domain, TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+// ASSERT_TRUE(serviceUnregistered);
+// usleep(wt);
+//}
/**
* @test Test of subscribing and immediately sequentially
@@ -627,46 +697,47 @@ TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeImmediatelyUnsubscribing)
*/
TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeSequentially) {
- SubscribeUnsubscribeHandler subUnsubHandler;
+ SubscribeUnsubscribeHandler subUnsubHandler;
- CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallOk;
- CommonAPI::Event<uint8_t>::Subscription subscribedListenerCallNotOk;
+ 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);
+ std::function<void (const uint8_t&)> callbackOk =
+ std::bind(&SubscribeUnsubscribeHandler::okCallback, &subUnsubHandler, std::placeholders::_1);
+ std::function<void (const uint8_t&)> callbackNotOk =
+ std::bind(&SubscribeUnsubscribeHandler::notOkCallback, &subUnsubHandler, std::placeholders::_1);
- bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
- testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE(testProxy_->isAvailable());
// subscribe ok and notOk callback
- subscribedListenerCallOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackOk);
- subscribedListenerCallNotOk = testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(callbackNotOk);
+ 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);
+ testStub_->setTestAttributeAttribute(12);
+ subUnsubHandler.wait_OkAttribute(12);
+ subUnsubHandler.wait_NotOkAttribute(12);
+ EXPECT_EQ(12, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(12, subUnsubHandler.getSubscribedNotOkAttribute());
// unsubscribe ok callback
testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallOk);
testStub_->setTestAttributeAttribute(14);
- usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12);
- EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 14);
+ subUnsubHandler.wait_NotOkAttribute(14);
+ EXPECT_EQ(12, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(14, subUnsubHandler.getSubscribedNotOkAttribute());
- // unsubscribe notOk callback
+ // unsubscribe notOk callback
testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListenerCallNotOk);
testStub_->setTestAttributeAttribute(16);
- usleep(wt);
- EXPECT_EQ(subUnsubHandler.getSubscribedOkAttribute(), 12);
- EXPECT_EQ(subUnsubHandler.getSubscribedNotOkAttribute(), 14);
+ usleep(wt);
+ EXPECT_EQ(12, subUnsubHandler.getSubscribedOkAttribute());
+ EXPECT_EQ(14, subUnsubHandler.getSubscribedNotOkAttribute());
bool serviceUnregistered = runtime_->unregisterService(domain, TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(serviceUnregistered);
@@ -692,47 +763,47 @@ TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeSequentially) {
*/
TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeUnsubscribe) {
- testStub_->setTestAttributeAttribute(42);
+ testStub_->setTestAttributeAttribute(42);
- bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- SubscriptionHandler subscriptionHandler(testProxy_);
+ SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
CommonAPI::Event<uint8_t>::Subscription subscribedListener =
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(42);
- // check for initial value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 42);
+ // check for initial value
+ EXPECT_EQ(42, subscriptionHandler.getSubscriptedTestAttribute());
- testStub_->setTestAttributeAttribute(12);
- usleep(wt);
+ testStub_->setTestAttributeAttribute(12);
+ subscriptionHandler.wait_Attribute(12);
- // check for changed value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 12);
+ // check for changed value
+ EXPECT_EQ(12, subscriptionHandler.getSubscriptedTestAttribute());
- testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener);
- testStub_->setTestAttributeAttribute(24);
- usleep(wt);
+ testStub_->setTestAttributeAttribute(24);
+ usleep(wt);
- // value must not be changed
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 12);
+ // value must not be changed
+ EXPECT_EQ(12, subscriptionHandler.getSubscriptedTestAttribute());
- testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().unsubscribe(subscribedListener);
- testStub_->setTestAttributeAttribute(26);
- usleep(wt);
+ testStub_->setTestAttributeAttribute(26);
+ usleep(wt);
- // value must not be changed
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 12);
+ // value must not be changed
+ EXPECT_EQ(12, subscriptionHandler.getSubscriptedTestAttribute());
bool serviceUnregistered = runtime_->unregisterService(domain, TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(serviceUnregistered);
@@ -752,22 +823,22 @@ TEST_F(CMAttributeSubscription, SubscribeAndUnsubscribeUnsubscribe) {
*/
TEST_F(CMAttributeSubscription, SubscribeServiceNotAvailable) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t defaultValue = 33;
+ uint8_t defaultValue = 33;
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(defaultValue);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(defaultValue);
- // subscribe for attribute change by the proxy
+ // subscribe for attribute change by the proxy
SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 0);
+ EXPECT_EQ(0, subscriptionHandler.getSubscriptedTestAttribute());
// register service
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
@@ -776,20 +847,20 @@ TEST_F(CMAttributeSubscription, SubscribeServiceNotAvailable) {
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- usleep(wt);
+ subscriptionHandler.wait_Attribute(defaultValue);
// check received attribute value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), defaultValue);
+ EXPECT_EQ(defaultValue, subscriptionHandler.getSubscriptedTestAttribute());
int8_t newValue = 123;
testStub_->setTestAttributeAttribute(newValue);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(newValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), newValue);
+ EXPECT_EQ(newValue, subscriptionHandler.getSubscriptedTestAttribute());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
@@ -812,11 +883,11 @@ TEST_F(CMAttributeSubscription, SubscribeServiceNotAvailable) {
* - unregister service
*/
TEST_F(CMAttributeSubscription, SubscribeUnregisterSetValueRegisterService) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t firstValue = 35;
- uint8_t secondValue = 43;
- uint8_t thirdValue = 198;
+ uint8_t firstValue = 35;
+ uint8_t secondValue = 43;
+ uint8_t thirdValue = 198;
// register service
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
@@ -825,45 +896,45 @@ TEST_F(CMAttributeSubscription, SubscribeUnregisterSetValueRegisterService) {
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- // subscribe for attribute change by the proxy
+ // subscribe for attribute change by the proxy
SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(firstValue);
- usleep(wt);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(firstValue);
+ subscriptionHandler.wait_Attribute(firstValue);
// check received attribute value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), firstValue);
+ EXPECT_EQ(firstValue, subscriptionHandler.getSubscriptedTestAttribute());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
testStub_->setTestAttributeAttribute(secondValue);
usleep(wt);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), firstValue);
+ EXPECT_EQ(firstValue, subscriptionHandler.getSubscriptedTestAttribute());
// register service
serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
ASSERT_TRUE(serviceRegistered);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(secondValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), secondValue);
+ EXPECT_EQ(secondValue, subscriptionHandler.getSubscriptedTestAttribute());
testStub_->setTestAttributeAttribute(thirdValue);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(thirdValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), thirdValue);
+ EXPECT_EQ(thirdValue, subscriptionHandler.getSubscriptedTestAttribute());
isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
@@ -885,10 +956,10 @@ TEST_F(CMAttributeSubscription, SubscribeUnregisterSetValueRegisterService) {
*/
TEST_F(CMAttributeSubscription, SubscribeUnregisterNoValueSetRegisterService) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t firstValue = 35;
- uint8_t secondValue = 43;
+ uint8_t firstValue = 35;
+ uint8_t secondValue = 43;
// register service
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
@@ -897,42 +968,44 @@ TEST_F(CMAttributeSubscription, SubscribeUnregisterNoValueSetRegisterService) {
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- // subscribe for attribute change by the proxy
+ // subscribe for attribute change by the proxy
SubscriptionHandler subscriptionHandler(testProxy_);
std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(firstValue);
- usleep(wt);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(firstValue);
+ subscriptionHandler.wait_Attribute(firstValue);
// check received attribute value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), firstValue);
+ EXPECT_EQ(firstValue, subscriptionHandler.getSubscriptedTestAttribute());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
+ usleep(wt);
subscriptionHandler.resetSubcriptedTestAttribute();
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), 0);
+ EXPECT_EQ(0, subscriptionHandler.getSubscriptedTestAttribute());
+ usleep(wt);
// register service
serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
ASSERT_TRUE(serviceRegistered);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(firstValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), firstValue);
+ EXPECT_EQ(firstValue, subscriptionHandler.getSubscriptedTestAttribute());
testStub_->setTestAttributeAttribute(secondValue);
- usleep(wt);
+ subscriptionHandler.wait_Attribute(secondValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), secondValue);
+ EXPECT_EQ(secondValue, subscriptionHandler.getSubscriptedTestAttribute());
isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
@@ -952,60 +1025,62 @@ TEST_F(CMAttributeSubscription, SubscribeUnregisterNoValueSetRegisterService) {
*/
TEST_F(CMAttributeSubscription, SubscribeSecondProxyLater) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t defaultValue = 33;
+ uint8_t defaultValue = 33;
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(defaultValue);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(defaultValue);
- // subscribe for attribute change by the proxy
- SubscriptionHandler subscriptionHandler(testProxy_);
- std::function<void (const uint8_t&)> myCallback =
- std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
+ // subscribe for attribute change by the proxy
+ SubscriptionHandler subscriptionHandler(testProxy_);
+ std::function<void (const uint8_t&)> myCallback =
+ std::bind(&SubscriptionHandler::myCallback, &subscriptionHandler, std::placeholders::_1);
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback);
- // register service
- bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ // register service
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
- testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE(testProxy_->isAvailable());
- usleep(wt);
+ subscriptionHandler.wait_Attribute(defaultValue);
- // check received attribute value
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), defaultValue);
+ // check received attribute value
+ EXPECT_EQ(defaultValue, subscriptionHandler.getSubscriptedTestAttribute());
- // create second proxy
- std::shared_ptr<TestInterfaceProxy<>> secondTestProxy =
- runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
- ASSERT_TRUE((bool)secondTestProxy);
+ // create second proxy
+ std::shared_ptr<TestInterfaceProxy<>> secondTestProxy =
+ runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
+ ASSERT_TRUE((bool)secondTestProxy);
- SubscriptionHandler secondSubscriptionHandler(secondTestProxy);
- std::function<void (const uint8_t&)> secondMyCallback =
- std::bind(&SubscriptionHandler::myCallback, &secondSubscriptionHandler, std::placeholders::_1);
+ SubscriptionHandler secondSubscriptionHandler(secondTestProxy);
+ std::function<void (const uint8_t&)> secondMyCallback =
+ std::bind(&SubscriptionHandler::myCallback, &secondSubscriptionHandler, std::placeholders::_1);
- secondTestProxy->getTestAttributeAttribute().getChangedEvent().subscribe(secondMyCallback);
+ secondTestProxy->getTestAttributeAttribute().getChangedEvent().subscribe(secondMyCallback);
- usleep(wt);
+ secondSubscriptionHandler.wait_Attribute(defaultValue);
- EXPECT_EQ(secondSubscriptionHandler.getSubscriptedTestAttribute(), defaultValue);
+ EXPECT_EQ(defaultValue, secondSubscriptionHandler.getSubscriptedTestAttribute());
- int8_t newValue = 123;
+ int8_t newValue = 123;
- testStub_->setTestAttributeAttribute(newValue);
- usleep(wt);
+ testStub_->setTestAttributeAttribute(newValue);
- EXPECT_EQ(subscriptionHandler.getSubscriptedTestAttribute(), newValue);
- EXPECT_EQ(secondSubscriptionHandler.getSubscriptedTestAttribute(), newValue);
+ subscriptionHandler.wait_Attribute(newValue);
+ secondSubscriptionHandler.wait_Attribute(newValue);
- bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
- ASSERT_TRUE(isUnregistered);
+ EXPECT_EQ(newValue, subscriptionHandler.getSubscriptedTestAttribute());
+ EXPECT_EQ(newValue, secondSubscriptionHandler.getSubscriptedTestAttribute());
- deregisterService_ = !isUnregistered;
+ bool isUnregistered = runtime_->unregisterService(domain,
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ ASSERT_TRUE(isUnregistered);
+
+ deregisterService_ = !isUnregistered;
}
/**
@@ -1016,27 +1091,27 @@ TEST_F(CMAttributeSubscription, SubscribeSecondProxyLater) {
*/
TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceNotAvailable) {
- deregisterService_ = true;
+ deregisterService_ = true;
- ThreeCallbackHandler threeCallbackHandler;
+ ThreeCallbackHandler threeCallbackHandler;
- uint8_t defaultValue = 33;
+ uint8_t defaultValue = 33;
- // initialize test stub with default value
- testStub_->setTestAttributeAttribute(defaultValue);
+ // initialize test stub with default value
+ testStub_->setTestAttributeAttribute(defaultValue);
- std::function<void (const uint8_t&)> myCallback1 =
- std::bind(&ThreeCallbackHandler::callback_1, &threeCallbackHandler, std::placeholders::_1);
+ std::function<void (const uint8_t&)> myCallback1 =
+ std::bind(&ThreeCallbackHandler::callback_1, &threeCallbackHandler, std::placeholders::_1);
std::function<void (const uint8_t&)> myCallback2 =
- std::bind(&ThreeCallbackHandler::callback_2, &threeCallbackHandler, std::placeholders::_1);
+ std::bind(&ThreeCallbackHandler::callback_2, &threeCallbackHandler, std::placeholders::_1);
std::function<void (const uint8_t&)> myCallback3 =
- std::bind(&ThreeCallbackHandler::callback_3, &threeCallbackHandler, std::placeholders::_1);
+ std::bind(&ThreeCallbackHandler::callback_3, &threeCallbackHandler, std::placeholders::_1);
testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback1);
+ usleep(wt);
testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback2);
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback3);
-
usleep(wt);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback3);
// register service
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
@@ -1045,7 +1120,7 @@ TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceNotAvailable) {
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- usleep(100000);
+ threeCallbackHandler.waitCallbacks();
EXPECT_EQ(1, threeCallbackHandler.getCallbackCounter_1());
EXPECT_EQ(1, threeCallbackHandler.getCallbackCounter_2());
@@ -1056,7 +1131,7 @@ TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceNotAvailable) {
EXPECT_EQ(defaultValue, threeCallbackHandler.getCallbackValue_3());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
@@ -1069,14 +1144,14 @@ TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceNotAvailable) {
* - initial value must be communicated to every callback
*/
TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceAvailable) {
- deregisterService_ = true;
+ deregisterService_ = true;
- uint8_t defaultValue = 35;
+ uint8_t defaultValue = 35;
- ThreeCallbackHandler threeCallbackHandler;
+ ThreeCallbackHandler threeCallbackHandler;
- testStub_->setTestAttributeAttribute(defaultValue);
- usleep(wt);
+ testStub_->setTestAttributeAttribute(defaultValue);
+ usleep(wt);
// register service
bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
@@ -1086,17 +1161,19 @@ TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceAvailable) {
ASSERT_TRUE(testProxy_->isAvailable());
std::function<void (const uint8_t&)> myCallback1 =
- std::bind(&ThreeCallbackHandler::callback_1, &threeCallbackHandler, std::placeholders::_1);
- std::function<void (const uint8_t&)> myCallback2 =
- std::bind(&ThreeCallbackHandler::callback_2, &threeCallbackHandler, std::placeholders::_1);
- std::function<void (const uint8_t&)> myCallback3 =
- std::bind(&ThreeCallbackHandler::callback_3, &threeCallbackHandler, std::placeholders::_1);
+ std::bind(&ThreeCallbackHandler::callback_1, &threeCallbackHandler, std::placeholders::_1);
+ std::function<void (const uint8_t&)> myCallback2 =
+ std::bind(&ThreeCallbackHandler::callback_2, &threeCallbackHandler, std::placeholders::_1);
+ std::function<void (const uint8_t&)> myCallback3 =
+ std::bind(&ThreeCallbackHandler::callback_3, &threeCallbackHandler, std::placeholders::_1);
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback1);
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback2);
- testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback3);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback1);
+ usleep(wt);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback2);
+ usleep(wt);
+ testProxy_->getTestAttributeAttribute().getChangedEvent().subscribe(myCallback3);
- usleep(100000);
+ threeCallbackHandler.waitCallbacks();
EXPECT_EQ(1, threeCallbackHandler.getCallbackCounter_1());
EXPECT_EQ(1, threeCallbackHandler.getCallbackCounter_2());
@@ -1107,7 +1184,7 @@ TEST_F(CMAttributeSubscription, SubscribeThreeCallbacksServiceAvailable) {
EXPECT_EQ(defaultValue, threeCallbackHandler.getCallbackValue_3());
bool isUnregistered = runtime_->unregisterService(domain,
- TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
+ TestInterfaceStubDefault::StubInterface::getInterface(), testAddress);
ASSERT_TRUE(isUnregistered);
deregisterService_ = !isUnregistered;
diff --git a/org.genivi.commonapi.core.verification/src/CMAttributes.cpp b/org.genivi.commonapi.core.verification/src/CMAttributes.cpp
index 9556ae4..1f52412 100644
--- a/org.genivi.commonapi.core.verification/src/CMAttributes.cpp
+++ b/org.genivi.commonapi.core.verification/src/CMAttributes.cpp
@@ -15,7 +15,7 @@
#include <fstream>
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp"
+#include "v1/commonapi/communication/TestInterfaceProxy.hpp"
#include "stub/CMAttributesStub.h"
const std::string serviceId = "service-sample";
@@ -84,7 +84,16 @@ protected:
runtime_->unregisterService(domain, CMAttributesStub::StubInterface::getInterface(),
testAddress);
- ASSERT_TRUE(serviceUnregistered);
+ ASSERT_TRUE(serviceUnregistered);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
uint8_t value_;
@@ -97,10 +106,10 @@ protected:
* @test Test synchronous getValue API function for attributes with combinations of
* additional properties readonly and noSubscriptions (testAttribute,
* testA readonly, testB noSubscriptions, testC readonly noSubscriptions).
-* - Set attribute to certain value on stub side.
-* - Call getValue.
-* - Check if returned call status is CommonAPI::CallStatus::SUCCESS.
-* - Check if value of is equal to expected value.
+* - Set attribute to certain value on stub side.
+* - Call getValue.
+* - Check if returned call status is CommonAPI::CallStatus::SUCCESS.
+* - Check if value of is equal to expected value.
*/
TEST_F(CMAttributes, AttributeGetSynchronous) {
@@ -147,7 +156,6 @@ TEST_F(CMAttributes, AttributeGetSynchronous) {
*/
TEST_F(CMAttributes, AttributeGetAsynchronous) {
- CommonAPI::CallStatus callStatus;
std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback =
std::bind(&CMAttributes::recvValue, this, std::placeholders::_1, std::placeholders::_2);
@@ -213,7 +221,6 @@ TEST_F(CMAttributes, AttributeSetSynchronous) {
*/
TEST_F(CMAttributes, AttributeSetAsynchronous) {
- CommonAPI::CallStatus callStatus;
std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback =
std::bind(&CMAttributes::recvValue, this, std::placeholders::_1, std::placeholders::_2);
diff --git a/org.genivi.commonapi.core.verification/src/CMBroadcasts.cpp b/org.genivi.commonapi.core.verification/src/CMBroadcasts.cpp
new file mode 100644
index 0000000..8e99b1d
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/CMBroadcasts.cpp
@@ -0,0 +1,244 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+* @file Communication
+*/
+
+#include <functional>
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <fstream>
+#include <gtest/gtest.h>
+#include "CommonAPI/CommonAPI.hpp"
+#include "v1/commonapi/communication/TestInterfaceProxy.hpp"
+#include "stub/CMBroadcastsStub.h"
+
+const std::string serviceId = "service-sample";
+const std::string clientId = "client-sample";
+
+const std::string domain = "local";
+const std::string testAddress = "commonapi.communication.TestInterface";
+const int tasync = 100000;
+
+using namespace v1_0::commonapi::communication;
+
+class Environment: public ::testing::Environment {
+public:
+ virtual ~Environment() {
+ }
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+class CMBroadcasts: public ::testing::Test {
+
+public:
+
+ void recvSubscribedValue(uint8_t y) {
+ value_ = y;
+ }
+
+protected:
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
+ std::mutex availabilityMutex;
+ std::unique_lock<std::mutex> lock(availabilityMutex);
+ std::condition_variable cv;
+ bool proxyAvailable = false;
+
+ std::thread t1([this, &proxyAvailable, &cv, &availabilityMutex]() {
+ std::lock_guard<std::mutex> lock(availabilityMutex);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE((bool)testProxy_);
+ proxyAvailable = true;
+ cv.notify_one();
+ });
+ testStub_ = std::make_shared<CMBroadcastsStub>();
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
+
+ while(!proxyAvailable) {
+ cv.wait(lock);
+ }
+ t1.join();
+ ASSERT_TRUE(testProxy_->isAvailable());
+ }
+
+ void TearDown() {
+ bool serviceUnregistered =
+ runtime_->unregisterService(domain, CMBroadcastsStub::StubInterface::getInterface(),
+ testAddress);
+
+ ASSERT_TRUE(serviceUnregistered);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
+ }
+
+ uint8_t value_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+ std::shared_ptr<CMBroadcastsStub> testStub_;
+ std::shared_ptr<TestInterfaceProxy<>> testProxy_;
+};
+
+/**
+* @test Test broadcasts. Subscribe to a broadcast, and see that the value
+* is correctly received.
+*/
+TEST_F(CMBroadcasts, NormalBroadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ uint8_t result = 0;
+
+ // subscribe to broadcast
+ testProxy_->getBTestEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ });
+
+ // send value '1' via a method call - this tells stub to broadcast
+ uint8_t in_ = 1;
+ uint8_t out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result == 1) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(result, 1);
+}
+
+/**
+* @test Test selective broadcasts.
+* - inform stub to stop accepting subscriptions
+* - try to subscribe to the selective broadcast
+* - check that an error was received
+* - inform stub to send a broadcast
+* - check that nothing was received in a reasonable time
+*/
+TEST_F(CMBroadcasts, SelectiveBroadcastRejected) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '2' via a method call - this tells stub to stop accepting subs
+ in_ = 2;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that subscription failed correctly
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ // The following does not happen in SOME/IP, so it's commented out.
+ //EXPECT_EQ(subStatus, CommonAPI::CallStatus::SUBSCRIPTION_REFUSED);
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that no value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(result, 0);
+
+}
+
+/**
+* @test Test selective broadcasts.
+* - inform stub to start accepting subscriptions
+* - subscribe to the selective broadcast
+* - check that no error was received (in a reasonable time)
+* - inform stub to send a broadcast
+* - check that a correct value is received
+*/
+TEST_F(CMBroadcasts, SelectiveBroadcast) {
+
+ CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus subStatus;
+ uint8_t result = 0;
+ uint8_t in_ = 0;
+ uint8_t out_ = 0;
+
+ // send value '4' via a method call - this tells stub to start accepting subs
+ in_ = 4;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // subscribe
+ subStatus = CommonAPI::CallStatus::UNKNOWN;
+ testProxy_->getBTestSelectiveSelectiveEvent().subscribe([&](
+ const uint8_t &y
+ ) {
+ result = y;
+ },
+ [&](
+ const CommonAPI::CallStatus &status
+ ) {
+ subStatus = status;
+ });
+
+ // check that no error was received
+ for (int i = 0; i < 100; i++) {
+ if (subStatus != CommonAPI::CallStatus::UNKNOWN) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(subStatus, CommonAPI::CallStatus::UNKNOWN);
+
+ // send value '3' via a method call - this tells stub to broadcast through the selective bc
+ result = 0;
+ in_ = 3;
+ out_ = 0;
+ testProxy_->testMethod(in_, callStatus, out_);
+
+ // check that value was correctly received
+ for (int i = 0; i < 100; i++) {
+ if (result != 0) break;
+ usleep(10000);
+ }
+ EXPECT_EQ(result, 1);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new Environment());
+ return RUN_ALL_TESTS();
+}
diff --git a/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp b/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp
index e3ac255..aefcea3 100644
--- a/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp
+++ b/org.genivi.commonapi.core.verification/src/CMMethodCalls.cpp
@@ -12,7 +12,7 @@
#include <fstream>
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/communication/TestInterfaceProxy.hpp"
+#include "v1/commonapi/communication/TestInterfaceProxy.hpp"
#include "stub/CMMethodCallsStub.h"
const std::string serviceId = "service-sample";
@@ -49,19 +49,28 @@ protected:
runtime_ = CommonAPI::Runtime::get();
ASSERT_TRUE((bool)runtime_);
- testStub_ = std::make_shared<CMMethodCallsStub>();
- bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ testStub_ = std::make_shared<CMMethodCallsStub>();
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
- testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
- ASSERT_TRUE((bool)testProxy_);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
+ ASSERT_TRUE((bool)testProxy_);
- testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
+ testProxy_->isAvailableBlocking();
+ ASSERT_TRUE(testProxy_->isAvailable());
}
void TearDown() {
runtime_->unregisterService(domain, CMMethodCallsStub::StubInterface::getInterface(), testAddress);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
uint8_t value_;
@@ -72,10 +81,10 @@ protected:
/**
* @test Call test method synchronous and check call status.
-* - Test stub sets in-value of test method equal out-value of test method.
-* - Make synchronous call of test method.
-* - Check if returned call status is CommonAPI::CallStatus::SUCCESS.
-* - Check if out value of test method is equal to in value.
+* - Test stub sets in-value of test method equal out-value of test method.
+* - Make synchronous call of test method.
+* - Check if returned call status is CommonAPI::CallStatus::SUCCESS.
+* - Check if out value of test method is equal to in value.
*/
TEST_F(CMMethodCalls, SynchronousMethodCall) {
@@ -98,8 +107,7 @@ TEST_F(CMMethodCalls, SynchronousMethodCall) {
TEST_F(CMMethodCalls, AsynchronousMethodCall) {
uint8_t x = 5;
- uint8_t y = 0;
- CommonAPI::CallStatus callStatus;
+ //uint8_t y = 0;
std::function<void (const CommonAPI::CallStatus&, uint8_t)> myCallback =
std::bind(&CMMethodCalls::recvValue, this, std::placeholders::_1, std::placeholders::_2);
diff --git a/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp b/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp
index acd47d9..24c15f3 100644
--- a/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp
+++ b/org.genivi.commonapi.core.verification/src/DTAdvanced.cpp
@@ -16,7 +16,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/datatypes/advanced/TestInterfaceProxy.hpp"
+#include "v1/commonapi/datatypes/advanced/TestInterfaceProxy.hpp"
#include "stub/DTAdvancedStub.h"
const std::string domain = "local";
@@ -38,6 +38,19 @@ public:
class DTAdvanced: public ::testing::Test {
+public:
+ void recvEnumValue(const CommonAPI::CallStatus& callStatus,
+ ::v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration responseValue) {
+ (void)responseValue;
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ }
+ void recvInvalidEnumValue(const CommonAPI::CallStatus& callStatus,
+ ::v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration responseValue) {
+ (void)responseValue;
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::INVALID_VALUE);
+ }
+
+
protected:
void SetUp() {
runtime_ = CommonAPI::Runtime::get();
@@ -69,6 +82,15 @@ protected:
void TearDown() {
ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::advanced::DTAdvancedStub::StubInterface::getInterface(), testAddress));
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
bool received_;
@@ -147,6 +169,111 @@ TEST_F(DTAdvanced, SendAndReceive) {
EXPECT_EQ(typedefTestValue, typedefResultValue);
}
+/*
+* @test Test function call with an invalid type
+* Try to pass an invalid value. Check that it failed.
+*/
+TEST_F(DTAdvanced, SendAndReceiveInvalid) {
+
+ CommonAPI::CallStatus callStatus;
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayTestValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structTestValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionTestValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapTestValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefTestValue;
+
+ arrayTestValue.push_back("Test1");
+ arrayTestValue.push_back("Test2");
+ arrayTestValue.push_back("Test3");
+
+ // put a deliberately invalid value to the enum data value
+ enumerationTestValue = static_cast<const v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::Literal>(1234);
+
+ structTestValue.setBooleanMember(true);
+ structTestValue.setUint8Member(42);
+ structTestValue.setStringMember("Hello World");
+
+ uint8_t u = 53;
+ unionTestValue = u;
+
+ mapTestValue[1] = "Hello";
+ mapTestValue[2] = "World";
+
+ typedefTestValue = 64;
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tArray arrayResultValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tStruct structResultValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tUnion unionResultValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tMap mapResultValue;
+ v1_0::commonapi::datatypes::advanced::TestInterface::tTypedef typedefResultValue;
+
+ testProxy_->fTest(
+ arrayTestValue,
+ enumerationTestValue,
+ structTestValue,
+ unionTestValue,
+ mapTestValue,
+ typedefTestValue,
+ callStatus,
+ arrayResultValue,
+ enumerationResultValue,
+ structResultValue,
+ unionResultValue,
+ mapResultValue,
+ typedefResultValue
+ );
+
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::INVALID_VALUE);
+}
+
+
+/**
+* @test Test attribute functions with invalid values
+* - Call set function of attributes with invalid types
+* - Check that the attribute's value has not changed
+*/
+TEST_F(DTAdvanced, AttributeSetInvalid) {
+
+ CommonAPI::CallStatus callStatus;
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue;
+
+ // put a deliberately invalid value to the enum data value
+ enumerationTestValue = static_cast<const v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::Literal>(1234);
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue;
+
+ testProxy_->getAEnumerationAttribute().setValue(enumerationTestValue, callStatus, enumerationResultValue);
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::INVALID_VALUE);
+}
+
+/**
+* @test Test attribute asynchronous functions with invalid values
+* - Call set asynch function of attributes with invalid types
+* - Callback should be called with error status
+* - Check that attribute value has not changed
+*/
+TEST_F(DTAdvanced, AttributeSetAsyncInvalid) {
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationTestValue;
+
+ std::function<void (const CommonAPI::CallStatus&,
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration)> myCallback =
+ std::bind(&DTAdvanced::recvInvalidEnumValue, this, std::placeholders::_1, std::placeholders::_2);
+
+ // put a deliberately invalid value to the enum data value
+ enumerationTestValue = static_cast<const v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::Literal>(1234);
+
+ v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration enumerationResultValue;
+
+ testProxy_->getAEnumerationAttribute().setValueAsync(enumerationTestValue, myCallback);
+ usleep(100000);
+}
+
+
/**
* @test Test attribute functions with advanced types
* - Call set function of attributes with advanced types
@@ -192,6 +319,14 @@ TEST_F(DTAdvanced, AttributeSet) {
ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
EXPECT_EQ(arrayTestValue, arrayResultValue);
+ // check initial value of enumeration attribute
+ enumerationTestValue = v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::VALUE1; // this is the expected default value
+ EXPECT_EQ(enumerationTestValue, enumerationResultValue); // the uninitialized enumerationResultValue should have the default value
+ enumerationResultValue = v1_0::commonapi::datatypes::advanced::TestInterface::tEnumeration::VALUE2; // set to some other value
+ testProxy_->getAEnumerationAttribute().getValue(callStatus, enumerationResultValue); // get value of attribute
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ EXPECT_EQ(enumerationTestValue, enumerationResultValue); // attribute value should default to the initial default value
+
testProxy_->getAEnumerationAttribute().setValue(enumerationTestValue, callStatus, enumerationResultValue);
ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
EXPECT_EQ(enumerationTestValue, enumerationResultValue);
diff --git a/org.genivi.commonapi.core.verification/src/DTCombined.cpp b/org.genivi.commonapi.core.verification/src/DTCombined.cpp
index 8780c01..e402f8b 100644
--- a/org.genivi.commonapi.core.verification/src/DTCombined.cpp
+++ b/org.genivi.commonapi.core.verification/src/DTCombined.cpp
@@ -16,7 +16,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/datatypes/combined/TestInterfaceProxy.hpp"
+#include "v1/commonapi/datatypes/combined/TestInterfaceProxy.hpp"
#include "stub/DTCombinedStub.h"
const std::string domain = "local";
@@ -72,6 +72,15 @@ protected:
void TearDown() {
ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::combined::TestInterfaceStub::StubInterface::getInterface(), testAddress));
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
bool serviceRegistered_;
diff --git a/org.genivi.commonapi.core.verification/src/DTDerived.cpp b/org.genivi.commonapi.core.verification/src/DTDerived.cpp
index e63159d..b69d2b2 100644
--- a/org.genivi.commonapi.core.verification/src/DTDerived.cpp
+++ b/org.genivi.commonapi.core.verification/src/DTDerived.cpp
@@ -16,7 +16,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/datatypes/derived/TestInterfaceProxy.hpp"
+#include "v1/commonapi/datatypes/derived/TestInterfaceProxy.hpp"
#include "stub/DTDerivedStub.h"
const std::string domain = "local";
@@ -68,7 +68,16 @@ protected:
}
void TearDown() {
- runtime_->unregisterService(domain, v1_0::commonapi::datatypes::derived::DTDerivedStub::StubInterface::getInterface(), testAddress);
+ runtime_->unregisterService(domain, v1_0::commonapi::datatypes::derived::DTDerivedStub::StubInterface::getInterface(), testAddress);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
bool received_;
@@ -170,6 +179,15 @@ TEST_F(DTDerived, AttributeSet) {
ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
EXPECT_EQ(structExtTestValue, structExtResultValue);
+ // check initial value of enumeration attribute
+ enumExtTestValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE2; // this is the expected default value
+ EXPECT_EQ(enumExtTestValue, enumExtResultValue); // the uninitialized enumExtResultValue should have the default value
+ enumExtResultValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE3; // set to some other value
+ testProxy_->getAEnumExtAttribute().getValue(callStatus, enumExtResultValue); // get value of attribute
+ ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ EXPECT_EQ(enumExtTestValue, enumExtResultValue); // attribute value should default to the initial default value
+
+ enumExtTestValue = v1_0::commonapi::datatypes::derived::TestInterface::tEnumExt::VALUE3;
testProxy_->getAEnumExtAttribute().setValue(enumExtTestValue, callStatus, enumExtResultValue);
ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
EXPECT_EQ(enumExtTestValue, enumExtResultValue);
diff --git a/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp b/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp
index b60f851..eb38760 100644
--- a/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp
+++ b/org.genivi.commonapi.core.verification/src/DTPrimitive.cpp
@@ -16,7 +16,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/datatypes/primitive/TestInterfaceProxy.hpp"
+#include "v1/commonapi/datatypes/primitive/TestInterfaceProxy.hpp"
#include "stub/DTPrimitiveStub.h"
const std::string domain = "local";
@@ -69,6 +69,15 @@ protected:
void TearDown() {
ASSERT_TRUE(runtime_->unregisterService(domain, v1_0::commonapi::datatypes::primitive::DTPrimitiveStub::StubInterface::getInterface(), testAddress));
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
bool received_;
@@ -99,7 +108,7 @@ TEST_F(DTPrimitive, SendAndReceive) {
uint64_t uint64TestValue = +4000000000000000004;
int64_t int64TestValue = -5000000005;
bool booleanTestValue = true;
- float floatTestValue = 1.01;
+ float floatTestValue = 1.01f;
double doubleTestValue = 12345.12345;
std::string stringTestValue = "∃y ∀x ¬(x ≺ y)";
//ByteBuffer byteBufferTestValue
@@ -180,7 +189,7 @@ TEST_F(DTPrimitive, AttributeSet) {
uint64_t uint64TestValue = +4000000000000000004;
int64_t int64TestValue = -5000000005;
bool booleanTestValue = true;
- float floatTestValue = 1.01;
+ float floatTestValue = 1.01f;
double doubleTestValue = 12345.12345;
std::string stringTestValue = "∃y ∀x ¬(x ≺ y)";
//ByteBuffer byteBufferTestValue
@@ -267,7 +276,7 @@ TEST_F(DTPrimitive, BroadcastReceive) {
uint64_t uint64TestValue = +4000000000000000004;
int64_t int64TestValue = -5000000005;
bool booleanTestValue = true;
- float floatTestValue = 1.01;
+ float floatTestValue = 1.01f;
double doubleTestValue = 12345.12345;
std::string stringTestValue = "∃y ∀x ¬(x ≺ y)";
//ByteBuffer byteBufferTestValue
@@ -348,6 +357,33 @@ TEST_F(DTPrimitive, BroadcastReceive) {
ASSERT_TRUE(received_);
}
+/**
+* @test Test broadcast with empty broadcast
+* - Subscribe to broadcast which does not contain any datatypes
+* - Call function twice to cause the stub to fire a broadcast event
+* - Check if the callback function was called twice
+*/
+TEST_F(DTPrimitive, EmptyBroadcastReceive) {
+
+ CommonAPI::CallStatus callStatus;
+ std::uint32_t callbackCalled = 0;
+ int numberFunctionCalls = 2;
+
+ received_ = false;
+ testProxy_->getBTestEmptyEvent().subscribe([&]() {
+ received_ = true;
+ callbackCalled++;
+ });
+
+ for (int var = 0; var < numberFunctionCalls; ++var) {
+ testProxy_->fTestEmptyBroadcast(callStatus);
+ usleep(100000);
+ }
+
+ ASSERT_TRUE(received_);
+ ASSERT_EQ(numberFunctionCalls, callbackCalled);
+}
+
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
::testing::AddGlobalTestEnvironment(new Environment());
diff --git a/org.genivi.commonapi.core.verification/src/PFComplex.cpp b/org.genivi.commonapi.core.verification/src/PFComplex.cpp
index 1393213..d4c63fb 100644
--- a/org.genivi.commonapi.core.verification/src/PFComplex.cpp
+++ b/org.genivi.commonapi.core.verification/src/PFComplex.cpp
@@ -11,7 +11,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/performance/complex/TestInterfaceProxy.hpp"
+#include "v1/commonapi/performance/complex/TestInterfaceProxy.hpp"
#include "stub/PFComplexStub.h"
#include "utils/StopWatch.h"
@@ -46,48 +46,61 @@ public:
class PFComplex: public ::testing::Test {
public:
- void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::tArray y) {
- // Stop the time & verify call status
- watch_.stop();
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
-
- std::unique_lock<std::mutex> uniqueLock(synchLock_);
- condVar_.notify_one();
- }
+ void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::tArray y) {
+ (void)y;
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ callCount_++;
+ if (callCount_ == loopCountPerPaylod) {
+ callCount_ = 0;
+ std::unique_lock<std::mutex> uniqueLock(synchLock_);
+ condVar_.notify_one();
+ }
+ }
protected:
- void SetUp() {
- runtime_ = CommonAPI::Runtime::get();
- ASSERT_TRUE((bool)runtime_);
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
- testStub_ = std::make_shared<PFComplexStub>();
- serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, "service-sample");
- ASSERT_TRUE(serviceRegistered_);
+ testStub_ = std::make_shared<PFComplexStub>();
+ serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, "service-sample");
+ ASSERT_TRUE(serviceRegistered_);
- testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, "client-sample");
- ASSERT_TRUE((bool)testProxy_);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, "client-sample");
+ ASSERT_TRUE((bool)testProxy_);
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- }
- void TearDown() {
+ callCount_ = 0;
+ }
+
+ void TearDown() {
runtime_->unregisterService(domain, PFComplexStub::StubInterface::getInterface(), testAddress);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
void printTestValues(size_t payloadSize, size_t objectSize) {
- // Get elapsed time, calculate mean time and print out!
- StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds();
- StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod);
- StopWatch::usec_t perByteTime = meanTime / objectSize;
- uint32_t callsPerSeconds = usecPerSecond / (methodCallTime / loopCountPerPaylod);
-
- std::cout << "[MEASURING ] Payload-Size=" << std::setw(7) << std::setfill('.') << payloadSize
- << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime
- << "us, per-Byte(payload)=" << std::setw(7) << std::setfill('.')
- << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us"
- << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds
- << std::endl;
+ // Get elapsed time, calculate mean time and print out!
+ StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds();
+ StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod);
+ StopWatch::usec_t perByteTime = static_cast<StopWatch::usec_t>(meanTime / objectSize);
+ uint32_t callsPerSeconds = static_cast<uint32_t>(usecPerSecond / (methodCallTime / loopCountPerPaylod));
+
+ std::cout << "[MEASURING ] Payload-Size=" << std::setw(7) << std::setfill('.') << payloadSize
+ << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime
+ << "us, per-Byte(payload)=" << std::setw(7) << std::setfill('.')
+ << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us"
+ << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds
+ << std::endl;
}
std::string configFileName_;
@@ -107,68 +120,68 @@ protected:
/**
* @test Test synchronous ping pong function call
* - complex array is array of a struct containing an union and another struc with primitive datatypes
-* - The stub just set the in array to the out array
-* - CallStatus and array content will be used to verify the sync call has succeeded
-* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
-* - Doing primitiveLoopSize loops to build the mean time
+* - The stub just set the in array to the out array
+* - CallStatus and array content will be used to verify the sync call has succeeded
+* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
+* - Doing primitiveLoopSize loops to build the mean time
*/
TEST_F(PFComplex, Ping_Pong_Complex_Synchronous) {
- CommonAPI::CallStatus callStatus;
-
- watch_.reset();
-
- // Loop until maxPrimitiveArraySize
- while (arraySize_ <= maxArraySize) {
-
- // Create in-array with actual arraySize
- TestInterface::tArray in;
- TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35);
- std::string unionMember = std::string("Hello World");
- TestInterface::innerUnion innerTestUnion = unionMember;
- TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion);
- for (uint32_t i = 0; i < arraySize_; ++i) {
- in.push_back(testStruct);
- }
-
- // Sum up payload size of primitive memebers
- size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member())
- + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member())
- + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember);
+ CommonAPI::CallStatus callStatus;
- // Call commonAPI method loopCountPerPaylod times to calculate mean time
- for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
-
- // Create an empty out-array for every commonAPI function call
- TestInterface::tArray out;
-
- // Call commonAPI function and measure time
- watch_.start();
- testProxy_->testMethod(in, callStatus, out);
- watch_.stop();
-
- // Check the call was successful & out array has same elements than in array
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(in, out);
- }
-
- // Printing results
- printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct));
-
- // Increase array size for next iteration
- arraySize_ *= 2;
+ watch_.reset();
- // Reset StopWatch for next iteration
- watch_.reset();
- }
+ // Loop until maxPrimitiveArraySize
+ while (arraySize_ <= maxArraySize) {
+
+ // Create in-array with actual arraySize
+ TestInterface::tArray in;
+ TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35);
+ std::string unionMember = std::string("Hello World");
+ TestInterface::innerUnion innerTestUnion = unionMember;
+ TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion);
+ for (uint32_t i = 0; i < arraySize_; ++i) {
+ in.push_back(testStruct);
+ }
+
+ // Sum up payload size of primitive memebers
+ size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member())
+ + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member())
+ + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember);
+
+ // Call commonAPI method loopCountPerPaylod times to calculate mean time
+ for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
+
+ // Create an empty out-array for every commonAPI function call
+ TestInterface::tArray out;
+
+ // Call commonAPI function and measure time
+ watch_.start();
+ testProxy_->testMethod(in, callStatus, out);
+ watch_.stop();
+
+ // Check the call was successful & out array has same elements than in array
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ EXPECT_EQ(in, out);
+ }
+
+ // Printing results
+ printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct));
+
+ // Increase array size for next iteration
+ arraySize_ *= 2;
+
+ // Reset StopWatch for next iteration
+ watch_.reset();
+ }
}
/**
* @test Test asynchronous ping pong function call
* - complex array is array of a struct containing an union and another struc with primitive datatypes
-* - The stub just set (copies) the in array to the out array
-* - Only the CallStatus will be used to verify the async call has succeeded
-* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
-* - Doing loopCountPerPaylod loops to calc the mean time
+* - The stub just set (copies) the in array to the out array
+* - Only the CallStatus will be used to verify the async call has succeeded
+* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
+* - Doing loopCountPerPaylod loops to calc the mean time
*/
TEST_F(PFComplex, Ping_Pong_Complex_Asynchronous) {
myCallback_ = std::bind(&PFComplex::recvArray, this, std::placeholders::_1, std::placeholders::_2);
@@ -178,40 +191,49 @@ TEST_F(PFComplex, Ping_Pong_Complex_Asynchronous) {
watch_.reset();
// Loop until maxPrimitiveArraySize
- while (arraySize_ <= maxArraySize) {
-
- // Create in-array with actual arraySize
- TestInterface::tArray in;
- TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35);
- std::string unionMember = std::string("Hello World");
- TestInterface::innerUnion innerTestUnion = unionMember;
- TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion);
- for (uint32_t i = 0; i < arraySize_; ++i) {
- in.push_back(testStruct);
- }
-
- // Sum up payload size of primitive memebers
- size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member())
- + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member())
- + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember);
-
- // Call commonAPI method loopCountPerPaylod times to calculate mean time
- for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
- TestInterface::tArray out;
- watch_.start();
- testProxy_->testMethodAsync(in, myCallback_);
- condVar_.wait(uniqueLock);
- }
-
- // Printing results
- printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct));
-
- // Increase array size for next iteration
- arraySize_ *= 2;
-
- // Reset StopWatch for next iteration
- watch_.reset();
- }
+ while (arraySize_ <= maxArraySize) {
+
+ // Create in-array with actual arraySize
+ TestInterface::tArray in;
+ TestInterface::innerStruct innerTestStruct(123, true, 4, "test", 35);
+ std::string unionMember = std::string("Hello World");
+ TestInterface::innerUnion innerTestUnion = unionMember;
+ TestInterface::tStruct testStruct(innerTestStruct, innerTestUnion);
+ for (uint32_t i = 0; i < arraySize_; ++i) {
+ in.push_back(testStruct);
+ }
+
+ // Sum up payload size of primitive memebers
+ size_t payloadSize = sizeof(innerTestStruct.getBooleanMember()) + sizeof(innerTestStruct.getUint8Member())
+ + sizeof(innerTestStruct.getUint16Member()) + sizeof(innerTestStruct.getUint32Member())
+ + sizeof(innerTestStruct.getStringMember()) + sizeof(unionMember);
+
+ watch_.reset();
+
+#ifdef WIN32
+ // DBus under Windows is way to slow at the moment (about 10 times slower than linux), so without an increase in timeout, this test never succeeds.
+ // Only raising for WIN32, since linux should run with the default timeout without problems.
+ CommonAPI::CallInfo callInfo(60000);
+#endif
+
+ watch_.start();
+ // Call commonAPI method loopCountPerPaylod times to calculate mean time
+ for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
+#ifdef WIN32
+ testProxy_->testMethodAsync(in, myCallback_, &callInfo);
+#else
+ testProxy_->testMethodAsync(in, myCallback_);
+#endif
+ }
+ condVar_.wait(uniqueLock);
+ watch_.stop();
+
+ // Printing results
+ printTestValues(arraySize_ * payloadSize, arraySize_ * sizeof(testStruct));
+
+ // Increase array size for next iteration
+ arraySize_ *= 2;
+ }
}
int main(int argc, char** argv) {
diff --git a/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp b/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp
index bc0c6a7..b2f6849 100644
--- a/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp
+++ b/org.genivi.commonapi.core.verification/src/PFPrimitive.cpp
@@ -11,7 +11,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/performance/primitive/TestInterfaceProxy.hpp"
+#include "v1/commonapi/performance/primitive/TestInterfaceProxy.hpp"
#include "stub/PFPrimitiveStub.h"
#include "utils/StopWatch.h"
@@ -46,49 +46,62 @@ public:
class PFPrimitive: public ::testing::Test {
public:
- void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::TestArray y) {
- // Stop the time & verify call status
- watch_.stop();
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
-
- std::unique_lock<std::mutex> uniqueLock(synchLock_);
- condVar_.notify_one();
- }
+ void recvArray(const CommonAPI::CallStatus& callStatus, TestInterface::TestArray y) {
+ (void)y;
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ callCount_++;
+ if (callCount_ == loopCountPerPaylod) {
+ callCount_ = 0;
+ std::unique_lock<std::mutex> uniqueLock(synchLock_);
+ condVar_.notify_one();
+ }
+ }
protected:
- void SetUp() {
- runtime_ = CommonAPI::Runtime::get();
- ASSERT_TRUE((bool)runtime_);
+ void SetUp() {
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
- testStub_ = std::make_shared<PFPrimitiveStub>();
- bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered);
+ testStub_ = std::make_shared<PFPrimitiveStub>();
+ bool serviceRegistered = runtime_->registerService(domain, testAddress, testStub_, serviceId);
+ ASSERT_TRUE(serviceRegistered);
- testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
- ASSERT_TRUE((bool)testProxy_);
+ testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
+ ASSERT_TRUE((bool)testProxy_);
testProxy_->isAvailableBlocking();
ASSERT_TRUE(testProxy_->isAvailable());
- }
- void TearDown() {
- bool unregistered = runtime_->unregisterService(domain, PFPrimitiveStub::StubInterface::getInterface(), testAddress);
- ASSERT_TRUE(unregistered);
+ callCount_ = 0;
+ }
+
+ void TearDown() {
+ bool unregistered = runtime_->unregisterService(domain, PFPrimitiveStub::StubInterface::getInterface(), testAddress);
+ ASSERT_TRUE(unregistered);
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
void printTestValues() {
- // Get elapsed time, calculate mean time and print out!
- StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds();
- StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod);
- StopWatch::usec_t perByteTime = meanTime / arraySize_;
- uint32_t callsPerSeconds = usecPerSecond / (methodCallTime / loopCountPerPaylod);
-
- std::cout << "[MEASURING ] Size=" << std::setw(7) << std::setfill('.') << arraySize_
- << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime << "us"
- << ", per-Byte=" << std::setw(7) << std::setfill('.')
- << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us"
- << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds
- << std::endl;
+ // Get elapsed time, calculate mean time and print out!
+ StopWatch::usec_t methodCallTime = watch_.getTotalElapsedMicroseconds();
+ StopWatch::usec_t meanTime = (methodCallTime / loopCountPerPaylod);
+ StopWatch::usec_t perByteTime = StopWatch::usec_t(meanTime / arraySize_);
+ uint32_t callsPerSeconds = uint32_t(usecPerSecond / (methodCallTime / loopCountPerPaylod));
+
+ std::cout << "[MEASURING ] Size=" << std::setw(7) << std::setfill('.') << arraySize_
+ << ", Mean-Time=" << std::setw(7) << std::setfill('.') << meanTime << "us"
+ << ", per-Byte=" << std::setw(7) << std::setfill('.')
+ << (perByteTime <= 0 ? ".....<1" : std::to_string(perByteTime)) << "us"
+ << ", calls/s=" << std::setw(7) << std::setfill('.') << callsPerSeconds
+ << std::endl;
}
std::string configFileName_;
@@ -107,83 +120,93 @@ protected:
/**
* @test Test synchronous ping pong function call
* - primitive array is array of UInt_8
-* - The stub just set the in array to the out array
-* - CallStatus and array content will be used to verify the sync call has succeeded
-* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
-* - Doing primitiveLoopSize loops to build the mean time
+* - The stub just set the in array to the out array
+* - CallStatus and array content will be used to verify the sync call has succeeded
+* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
+* - Doing primitiveLoopSize loops to build the mean time
*/
TEST_F(PFPrimitive, Ping_Pong_Primitive_Synchronous) {
- CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus callStatus;
- watch_.reset();
+ watch_.reset();
- // Loop until maxPrimitiveArraySize
- while (arraySize_ <= maxPrimitiveArraySize) {
+ // Loop until maxPrimitiveArraySize
+ while (arraySize_ <= maxPrimitiveArraySize) {
- // Create in-array with actual arraySize
- TestInterface::TestArray in(arraySize_);
+ // Create in-array with actual arraySize
+ TestInterface::TestArray in(arraySize_);
- // Call commonAPI method loopCountPerPaylod times to calculate mean time
- for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
+ // Call commonAPI method loopCountPerPaylod times to calculate mean time
+ for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
- // Create an empty out-array for every commonAPI function call
- TestInterface::TestArray out;
+ // Create an empty out-array for every commonAPI function call
+ TestInterface::TestArray out;
- // Call commonAPI function and measure time
- watch_.start();
- testProxy_->testMethod(in, callStatus, out);
- watch_.stop();
+ // Call commonAPI function and measure time
+ watch_.start();
+ testProxy_->testMethod(in, callStatus, out);
+ watch_.stop();
- // Check the call was successful & out array has same elements than in array
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(in, out);
- }
+ // Check the call was successful & out array has same elements than in array
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ EXPECT_EQ(in, out);
+ }
- // Printing results
- printTestValues();
+ // Printing results
+ printTestValues();
- // Increase array size for next iteration
- arraySize_ *= 2;
+ // Increase array size for next iteration
+ arraySize_ *= 2;
- // Reset StopWatch for next iteration
- watch_.reset();
- }
+ // Reset StopWatch for next iteration
+ watch_.reset();
+ }
}
/**
* @test Test asynchronous ping pong function call
* - primitive array is array of UInt_8
-* - The stub just set (copies) the in array to the out array
-* - Only the CallStatus will be used to verify the async call has succeeded
-* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
-* - Doing primitiveLoopSize loops to build the mean time
+* - The stub just set (copies) the in array to the out array
+* - Only the CallStatus will be used to verify the async call has succeeded
+* - Using double payload every cycle, starting with 1 end with maxPrimitiveArraySize
+* - Doing primitiveLoopSize loops to build the mean time
*/
TEST_F(PFPrimitive, Ping_Pong_Primitive_Asynchronous) {
myCallback_ = std::bind(&PFPrimitive::recvArray, this, std::placeholders::_1, std::placeholders::_2);
std::unique_lock<std::mutex> uniqueLock(synchLock_);
- // Loop until maxPrimitiveArraySize
- while (arraySize_ <= maxPrimitiveArraySize) {
+ // Loop until maxPrimitiveArraySize
+ while (arraySize_ <= maxPrimitiveArraySize) {
- watch_.reset();
+ watch_.reset();
- // Initialize testData, call count stop watch for next iteration!
- TestInterface::TestArray in(arraySize_);
+ // Initialize testData, call count stop watch for next iteration!
+ TestInterface::TestArray in(arraySize_);
- for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
- TestInterface::TestArray out;
- watch_.start();
- testProxy_->testMethodAsync(in, myCallback_);
- condVar_.wait(uniqueLock);
- }
+#ifdef WIN32
+ // DBus under Windows is way to slow at the moment (about 10 times slower than linux), so without an increase in timeout, this test never succeeds.
+ // Only raising for WIN32, since linux should run with the default timeout without problems.
+ CommonAPI::CallInfo callInfo(60000);
+#endif
- // Printing results
- printTestValues();
+ watch_.start();
+ for (uint32_t i = 0; i < loopCountPerPaylod; ++i) {
+#ifdef WIN32
+ testProxy_->testMethodAsync(in, myCallback_, &callInfo);
+#else
+ testProxy_->testMethodAsync(in, myCallback_);
+#endif
+ }
+ condVar_.wait(uniqueLock);
+ watch_.stop();
- // Increase array size for next iteration
- arraySize_ *= 2;
- }
+ // Printing results
+ printTestValues();
+
+ // Increase array size for next iteration
+ arraySize_ *= 2;
+ }
}
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 29ac109..4e66d6b 100644
--- a/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp
+++ b/org.genivi.commonapi.core.verification/src/RTBuildProxiesAndStubs.cpp
@@ -13,8 +13,8 @@
#include <thread>
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/runtime/TestInterfaceProxy.hpp"
-#include "v1_0/commonapi/runtime/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/runtime/TestInterfaceProxy.hpp"
+#include "v1/commonapi/runtime/TestInterfaceStubDefault.hpp"
const std::string domain = "local";
const std::string testAddress = "commonapi.runtime.TestInterface";
@@ -90,52 +90,52 @@ TEST_F(RTBuildProxiesAndStubs, BuildProxiesAndStubsTwoTimes) {
// 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 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();
+ 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);
+ 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;
+ usleep(1 * 1000 * 1000);
+ }
+ std::cout << std::endl;
- ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress));
+ 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 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);
+ 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;
+ 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());
+ ASSERT_TRUE(testProxy->isAvailable());
- usleep(5 * 1000 * 1000);
+ usleep(5 * 1000 * 1000);
- ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress));
+ ASSERT_TRUE(runtime->unregisterService(domain,v1_0::commonapi::runtime::TestInterfaceStub::StubInterface::getInterface(), testAddress));
}
}
diff --git a/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp b/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp
index 5321418..916a9dd 100644
--- a/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp
+++ b/org.genivi.commonapi.core.verification/src/RTLoadingRuntime.cpp
@@ -37,8 +37,8 @@ protected:
/**
* @test Loads Default Runtime.
-* - Calls CommonAPI::Runtime::get().
-* - Success if return value is true.
+* - Calls CommonAPI::Runtime::get().
+* - Success if return value is true.
*/
TEST_F(RTLoadingRuntime, LoadsDefaultRuntime) {
std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::get();
diff --git a/org.genivi.commonapi.core.verification/src/StabilitySP.cpp b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp
index d98d5b6..356e67a 100644
--- a/org.genivi.commonapi.core.verification/src/StabilitySP.cpp
+++ b/org.genivi.commonapi.core.verification/src/StabilitySP.cpp
@@ -11,7 +11,7 @@
#include <fstream>
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
-#include "v1_0/commonapi/stability/sp/TestInterfaceProxy.hpp"
+#include "v1/commonapi/stability/sp/TestInterfaceProxy.hpp"
#include "stub/StabilitySPStub.h"
const std::string serviceId = "service-sample";
@@ -28,6 +28,10 @@ const int MAXREGCOUNT = 16;
const int MESSAGESIZE = 80;
const int MAXSUBSCRIPTIONSETS = 10;
+#ifdef WIN32
+std::mutex gtestMutex;
+#endif
+
using namespace v1_0::commonapi::stability::sp;
class Environment: public ::testing::Environment {
@@ -46,26 +50,66 @@ class StabilitySP: public ::testing::Test {
protected:
void SetUp() {
runtime_ = CommonAPI::Runtime::get();
- ASSERT_TRUE((bool)runtime_);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE((bool)runtime_);
+ }
testStub_ = std::make_shared<StabilitySPStub>();
serviceRegistered_ = runtime_->registerService(domain, testAddress, testStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
testProxy_ = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress, clientId);
- ASSERT_TRUE((bool)testProxy_);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE((bool)testProxy_);
+ }
testProxy_->isAvailableBlocking();
- ASSERT_TRUE(testProxy_->isAvailable());
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(testProxy_->isAvailable());
+ }
}
void TearDown() {
bool unregistered = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress);
- ASSERT_TRUE(unregistered);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(unregistered);
+ }
+
+ // wait that proxy is not available
+ int counter = 0; // counter for avoiding endless loop
+ while ( testProxy_->isAvailable() && counter < 10 ) {
+ usleep(100000);
+ counter++;
+ }
+
+ ASSERT_FALSE(testProxy_->isAvailable());
}
uint8_t value_;
bool serviceRegistered_;
+ bool serviceUnregistered_;
std::shared_ptr<CommonAPI::Runtime> runtime_;
std::shared_ptr<TestInterfaceProxy<>> testProxy_;
@@ -73,11 +117,11 @@ protected:
};
/**
* @test Register and unregister services in a loop.
-* - do MAXREGLOOPS times:
-* - register MAXREGCOUNT addresses as services
-* - unregister the addresses that were just registered
-* - check the return code of each register/unregister call
-* - test fails if any of the return codes are false
+* - do MAXREGLOOPS times:
+* - register MAXREGCOUNT addresses as services
+* - unregister the addresses that were just registered
+* - check the return code of each register/unregister call
+* - test fails if any of the return codes are false
**/
TEST_F(StabilitySP, RepeatedRegistrations) {
@@ -87,12 +131,24 @@ TEST_F(StabilitySP, RepeatedRegistrations) {
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int loopcount = 0; loopcount < MAXREGLOOPS; loopcount++) {
for (unsigned int regcount = 0; regcount < MAXREGCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
for (unsigned int regcount = 0; regcount < MAXREGCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
}
}
}
@@ -105,7 +161,13 @@ public:
// callback for asynchronous attribute functions.
void recvValue(const CommonAPI::CallStatus& callStatus, TestInterface::tArray arrayResultValue) {
std::lock_guard<std::mutex> lock(recvValue_mutex_);
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
+ }
asyncCounter++;
TestInterface::tArray arrayTestValue;
@@ -116,11 +178,29 @@ public:
}
arrayTestValue.shrink_to_fit();
- EXPECT_EQ(arrayTestValue, arrayResultValue);
- ASSERT_EQ(arrayTestValue.size(), arrayResultValue.size()) << "Vectors arrayTestValue and arrayResultValue are of unequal length";
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_EQ(arrayTestValue.size(), arrayResultValue.size()) << "Vectors arrayTestValue and arrayResultValue are of unequal length";
+ }
+
if(arrayTestValue.size() == arrayResultValue.size()) {
for (std::uint32_t i = 0; i < arrayTestValue.size(); ++i) {
- EXPECT_EQ(arrayTestValue[i], arrayResultValue[i]) << "Vectors arrayTestValue and arrayResultValue differ at index " << i;
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue[i], arrayResultValue[i]) << "Vectors arrayTestValue and arrayResultValue differ at index " << i;
+ }
}
}
}
@@ -146,11 +226,28 @@ public:
arrayTestValue.shrink_to_fit();
- EXPECT_EQ(arrayTestValue, arrayResultValue);
- ASSERT_EQ(arrayTestValue.size(), arrayResultValue.size()) << "Vectors arrayTestValue and arrayResultValue are of unequal length";
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_EQ(arrayTestValue.size(), arrayResultValue.size()) << "Vectors arrayTestValue and arrayResultValue are of unequal length";
+ }
+
if(arrayTestValue.size() == arrayResultValue.size()) {
for (std::uint32_t i = 0; i < arrayTestValue.size(); ++i) {
- EXPECT_EQ(arrayTestValue[i], arrayResultValue[i]) << "Vectors arrayTestValue and arrayResultValue differ at index " << i;
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue[i], arrayResultValue[i]) << "Vectors arrayTestValue and arrayResultValue differ at index " << i;
+ }
}
}
}
@@ -164,7 +261,14 @@ public:
for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) {
proxy_[proxycount] = runtime_->buildProxy<TestInterfaceProxy>(domain, testAddress + std::to_string(proxycount), clientId);
success_ = success_ && (bool)proxy_[proxycount];
- ASSERT_TRUE(success_);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_TRUE(success_);
+ }
+
for (unsigned int wait = 0; !proxy_[proxycount]->isAvailable() && wait < 100; ++wait) {
usleep(10000);
}
@@ -172,7 +276,12 @@ public:
if (!proxy_[proxycount]->isAvailable())
std::cout << testAddress + std::to_string(proxycount) << std::endl;
- ASSERT_TRUE(proxy_[proxycount]->isAvailable());
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_TRUE(proxy_[proxycount]->isAvailable());
+ }
}
}
@@ -218,19 +327,25 @@ public:
}
previousCount = asyncCounter;
}
- EXPECT_EQ(expected, asyncCounter);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(expected, asyncCounter);
+ }
}
void runSetSubscribedAttributes(unsigned int id) {
- unsigned char message1 = id;
- unsigned char message2 = message1 + MAXTHREADCOUNT;
+ unsigned char message1 = (unsigned char)(id);
+ unsigned char message2 = static_cast<unsigned char>(message1 + MAXTHREADCOUNT);
unsigned char message = message1;
for (unsigned int loopcount = 0; loopcount < MAXSUBSCRIPTIONSETS; loopcount++) {
for (unsigned int proxycount = 0; proxycount < MAXSERVERCOUNT; proxycount++) {
exerciseSetSubscribedAttribute(proxy_[proxycount], message);
// toggle between two different messages
- message = message1 + message2 - message;
+ message = static_cast<unsigned char>(message1 + message2 - message);
}
}
@@ -296,8 +411,23 @@ public:
CommonAPI::CallStatus callStatus;
proxy->testMethod(arrayTestValue, callStatus, arrayResultValue);
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(arrayTestValue, arrayResultValue);
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ bool status = callStatus == CommonAPI::CallStatus::SUCCESS;
+ EXPECT_TRUE(status);
+ if (!status) {
+ return false;
+ }
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
return true;
}
@@ -311,8 +441,24 @@ public:
CommonAPI::CallStatus callStatus;
proxy->getTestAttributeAttribute().setValue(arrayTestValue, callStatus, arrayResultValue);
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(arrayTestValue, arrayResultValue);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ bool status = callStatus == CommonAPI::CallStatus::SUCCESS;
+ EXPECT_TRUE(status);
+ if (!status) {
+ return false;
+ }
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
return true;
}
@@ -328,8 +474,24 @@ public:
CommonAPI::CallStatus callStatus;
proxy->getTestAttributeAttribute().setValue(arrayTestValue, callStatus, arrayResultValue);
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(arrayTestValue, arrayResultValue);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ bool status = callStatus == CommonAPI::CallStatus::SUCCESS;
+ EXPECT_TRUE(status);
+ if (!status) {
+ return false;
+ }
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
return true;
}
@@ -344,8 +506,24 @@ public:
CommonAPI::CallStatus callStatus;
proxy->getTestAttributeAttribute().getValue(callStatus, arrayResultValue);
- EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS);
- EXPECT_EQ(arrayTestValue, arrayResultValue);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ bool status = callStatus == CommonAPI::CallStatus::SUCCESS;
+ EXPECT_TRUE(status);
+ if (!status) {
+ return false;
+ }
+ }
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ EXPECT_EQ(arrayTestValue, arrayResultValue);
+ }
return true;
}
@@ -353,7 +531,6 @@ public:
std::function<void (const CommonAPI::CallStatus&, TestInterface::tArray)> myCallback =
std::bind(&ProxyThread::recvValue, this, std::placeholders::_1, std::placeholders::_2);
- CommonAPI::CallStatus callStatus;
CommonAPI::CallInfo* callInfo = new CommonAPI::CallInfo(50 * 1000);
proxy->getTestAttributeAttribute().getValueAsync(myCallback, callInfo);
@@ -381,22 +558,28 @@ public:
};
/**
* @test Create a number of services and proxies and send messages through them.
-* - Register MAXSERVERCOUNT addresses as services
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then sends MAXMETHODCALLS messages to each.
-* - Each message is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the return message from the server is not correct
+* - Register MAXSERVERCOUNT addresses as services
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then sends MAXMETHODCALLS messages to each.
+* - Each message is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the return message from the server is not correct
**/
TEST_F(StabilitySP, MultipleMethodCalls) {
std::shared_ptr<TestInterfaceStubDefault> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
ProxyThread * proxyrunners[MAXTHREADCOUNT];
@@ -413,28 +596,51 @@ TEST_F(StabilitySP, MultipleMethodCalls) {
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
/**
* @test Create a number of services and proxies and set attributes through them.
-* - Register MAXSERVERCOUNT addresses as services
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then sets attributes MAXMETHODCALLS times to each.
-* - Each attribute is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the return attribute from the server is not correct
+* - Register MAXSERVERCOUNT addresses as services
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then sets attributes MAXMETHODCALLS times to each.
+* - Each attribute is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the return attribute from the server is not correct
**/
TEST_F(StabilitySP, MultipleAttributeSets) {
std::shared_ptr<TestInterfaceStubDefault> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
ProxyThread * proxyrunners[MAXTHREADCOUNT];
for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
@@ -448,30 +654,53 @@ TEST_F(StabilitySP, MultipleAttributeSets) {
proxyrunners[threadcount]->setThread(0);
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
/**
* @test Create a number of services and proxies and get attributes through them.
-* - Register MAXSERVERCOUNT addresses as services
+* - Register MAXSERVERCOUNT addresses as services
* - Set the attribute for service, at the stub side.
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then gets attributes MAXMETHODCALLS times for each.
-* - Each attribute is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the returned attribute from the server is not correct
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then gets attributes MAXMETHODCALLS times for each.
+* - Each attribute is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the returned attribute from the server is not correct
**/
TEST_F(StabilitySP, MultipleAttributeGets) {
std::shared_ptr<StabilitySPStub> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
TestInterface::tArray arrayTestValue;
@@ -493,30 +722,53 @@ TEST_F(StabilitySP, MultipleAttributeGets) {
proxyrunners[threadcount]->setThread(0);
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
/**
* @test Create a number of services and proxies and get attributes through them.
-* - Register MAXSERVERCOUNT addresses as services
+* - Register MAXSERVERCOUNT addresses as services
* - Set the attribute for service, at the stub side.
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then gets attributes MAXMETHODCALLS times for each asynchronously
-* - Each attribute is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the callbacks are not called correct number of times
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then gets attributes MAXMETHODCALLS times for each asynchronously
+* - Each attribute is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the callbacks are not called correct number of times
**/
TEST_F(StabilitySP, MultipleAttributeGetAsyncs) {
std::shared_ptr<StabilitySPStub> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
TestInterface::tArray arrayTestValue;
@@ -537,30 +789,53 @@ TEST_F(StabilitySP, MultipleAttributeGetAsyncs) {
proxyrunners[threadcount]->setThread(0);
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
/**
* @test Create a number of services and proxies and set attributes through them.
-* - Register MAXSERVERCOUNT addresses as services
+* - Register MAXSERVERCOUNT addresses as services
* - Set the attribute for service, at the stub side.
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then sets attributes MAXMETHODCALLS times for each asynchronously
-* - Each attribute is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the callbacks are not called correct number of times
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then sets attributes MAXMETHODCALLS times for each asynchronously
+* - Each attribute is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the callbacks are not called correct number of times
**/
TEST_F(StabilitySP, MultipleAttributeSetAsyncs) {
std::shared_ptr<StabilitySPStub> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
TestInterface::tArray arrayTestValue;
@@ -581,30 +856,53 @@ TEST_F(StabilitySP, MultipleAttributeSetAsyncs) {
proxyrunners[threadcount]->setThread(0);
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
/**
* @test Create a number of services and proxies and set attributes through them.
-* - Register MAXSERVERCOUNT addresses as services
+* - Register MAXSERVERCOUNT addresses as services
* - Set the attribute for service, at the stub side.
-* - Create MAXTHREADCOUNT threads, each of which
-* creates a proxy for each service address and
-* then sets attributes MAXMETHODCALLS times for each asynchronously
-* - Each attribute is MESSAGESIZE bytes long.
-* - Test fails if any of the services fail to get registered
-* or if any of the proxies won't get available
-* or if the callbacks are not called correct number of times
+* - Create MAXTHREADCOUNT threads, each of which
+* creates a proxy for each service address and
+* then sets attributes MAXMETHODCALLS times for each asynchronously
+* - Each attribute is MESSAGESIZE bytes long.
+* - Test fails if any of the services fail to get registered
+* or if any of the proxies won't get available
+* or if the callbacks are not called correct number of times
**/
TEST_F(StabilitySP, MultipleAttributeSubscriptions) {
std::shared_ptr<StabilitySPStub> testMultiRegisterStub_;
testMultiRegisterStub_ = std::make_shared<StabilitySPStub>();
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string( regcount ), testMultiRegisterStub_, serviceId);
- ASSERT_TRUE(serviceRegistered_);
+ serviceRegistered_ = runtime_->registerService(domain, testAddress + std::to_string(regcount), testMultiRegisterStub_, serviceId);
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceRegistered_);
+ }
}
TestInterface::tArray arrayTestValue;
arrayTestValue.push_back(0);
@@ -644,8 +942,25 @@ TEST_F(StabilitySP, MultipleAttributeSubscriptions) {
proxyrunners[threadcount]->setThread(0);
}
for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
- serviceRegistered_ = runtime_->unregisterService( domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string( regcount ));
- ASSERT_TRUE(serviceRegistered_);
+ serviceUnregistered_ = runtime_->unregisterService(domain, StabilitySPStub::StubInterface::getInterface(), testAddress + std::to_string(regcount));
+
+ {
+#ifdef WIN32
+ std::lock_guard<std::mutex> gtestLock(gtestMutex);
+#endif
+ ASSERT_TRUE(serviceUnregistered_);
+ }
+ }
+
+ for (unsigned int threadcount = 0; threadcount < MAXTHREADCOUNT; threadcount++) {
+ for (unsigned int regcount = 0; regcount < MAXSERVERCOUNT; regcount++) {
+ while (proxyrunners[threadcount]->proxy_[regcount]->isAvailable()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
+ }
+ }
+
+ delete proxyrunners[threadcount];
+ proxyrunners[threadcount] = nullptr;
}
}
diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp
index 8e9c167..cad4012 100644
--- a/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp
+++ b/org.genivi.commonapi.core.verification/src/THMainLoopIndependence.cpp
@@ -11,8 +11,8 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
#include "utils/VerificationMainLoop.h"
-#include "v1_0/commonapi/threading/TestInterfaceProxy.hpp"
-#include "v1_0/commonapi/threading/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/threading/TestInterfaceProxy.hpp"
+#include "v1/commonapi/threading/TestInterfaceStubDefault.hpp"
#include "utils/VerificationMainLoop.h"
const std::string domain = "local";
@@ -24,11 +24,11 @@ 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,
- uint8_t _x,
- testMethodReply_t _reply) {
-
- _reply(_x);
+ virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
+ uint8_t _x,
+ testMethodReply_t _reply) {
+ (void)_client;
+ _reply(_x);
}
};
@@ -40,7 +40,7 @@ public:
}
void setupMainLoopContext(std::promise<bool>& p, std::string mainloopName) {
- mainLoopContext_ = std::make_shared<CommonAPI::MainLoopContext>(mainloopName);
+ mainLoopContext_ = std::make_shared<CommonAPI::MainLoopContext>(mainloopName);
mainLoop_ = new CommonAPI::VerificationMainLoop(mainLoopContext_);
p.set_value(true);
}
@@ -143,42 +143,48 @@ protected:
mainLoopThread1_ = std::thread([&]() { threadCtx1_.mainLoop_->run(); });
mainLoopThread2_ = std::thread([&]() { threadCtx2_.mainLoop_->run(); });
- for (unsigned int i = 0; !threadCtx1_.proxy_->isAvailable() && i < 100; ++i) {
- usleep(10000);
- }
+ for (unsigned int i = 0; !threadCtx1_.proxy_->isAvailable() && i < 100; ++i) {
+ usleep(10000);
+ }
- for (unsigned int i = 0; !threadCtx2_.proxy_->isAvailable() && i < 100; ++i) {
- usleep(10000);
- }
+ for (unsigned int i = 0; !threadCtx2_.proxy_->isAvailable() && i < 100; ++i) {
+ usleep(10000);
+ }
- ASSERT_TRUE(threadCtx1_.proxy_->isAvailable());
+ ASSERT_TRUE(threadCtx1_.proxy_->isAvailable());
ASSERT_TRUE(threadCtx2_.proxy_->isAvailable());
- if (threadCtx1_.mainLoop_->isRunning()) {
- std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop();
- threadCtx1MainStopped.get();
- }
- if (threadCtx2_.mainLoop_->isRunning()) {
- std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop();
- threadCtx2MainStopped.get();
+ // wait until threads are running
+ while (!threadCtx1_.mainLoop_->isRunning() || !threadCtx2_.mainLoop_->isRunning()) {
+ usleep(100);
}
- mainLoopThread1_.join();
- mainLoopThread2_.join();
+ std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop();
+ threadCtx1MainStopped.get();
+
+ std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop();
+ threadCtx2MainStopped.get();
+
+ if(mainLoopThread1_.joinable()) {
+ mainLoopThread1_.join();
+ }
+ if(mainLoopThread2_.joinable()) {
+ mainLoopThread2_.join();
+ }
}
void TearDown() {
- threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance6);
- threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance7);
- threadCtx2_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance8);
+ threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance6);
+ threadCtx1_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance7);
+ threadCtx2_.runtime_->unregisterService(domain, PingPongTestStub::StubInterface::getInterface(), instance8);
if (threadCtx1_.mainLoop_->isRunning()) {
- std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop();
- //threadCtx1MainStopped.get();
+ std::future<bool> threadCtx1MainStopped = threadCtx1_.mainLoop_->stop();
+ //threadCtx1MainStopped.get();
}
if (threadCtx2_.mainLoop_->isRunning()) {
- std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop();
- //threadCtx2MainStopped.get();
+ std::future<bool> threadCtx2MainStopped = threadCtx2_.mainLoop_->stop();
+ //threadCtx2MainStopped.get();
}
if(mainLoopThread1_.joinable()) {
@@ -197,10 +203,10 @@ protected:
/**
* @test Proxy Receives Answer Only If Stub MainLoop Runs.
-* - start proxy in thread 1 and call testPredefinedTypeMethod
-* - proxy should not receive answer, if the stub mainloop does not run
-* - run mainloop of stub
-* - now the stub mainloop also runs, so the proxy should receive the answer
+* - start proxy in thread 1 and call testPredefinedTypeMethod
+* - proxy should not receive answer, if the stub mainloop does not run
+* - run mainloop of stub
+* - now the stub mainloop also runs, so the proxy should receive the answer
*/
TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) {
@@ -231,9 +237,9 @@ TEST_F(THMainLoopIndependence, ProxyReceivesAnswerOnlyIfStubMainLoopRuns) {
/**
* @test Proxy Receives Just His Own Answers.
-* - start 2 proxies in own threads
-* - call test method in each proxy
-* - now each proxy should have received the answer to his own request
+* - start 2 proxies in own threads
+* - call test method in each proxy
+* - now each proxy should have received the answer to his own request
*/
TEST_F(THMainLoopIndependence, ProxyReceivesJustHisOwnAnswers) {
std::shared_ptr<PingPongTestStub> stubThirdParty = std::make_shared<PingPongTestStub>();
@@ -252,11 +258,6 @@ TEST_F(THMainLoopIndependence, ProxyReceivesJustHisOwnAnswers) {
mainLoopRunnerProxy1.detach();
mainLoopRunnerProxy2.detach();
- // wait until threads are running
- while (!threadCtx1_.mainLoop_->isRunning() || !threadCtx2_.mainLoop_->isRunning()) {
- usleep(100);
- }
-
while(!(threadCtx1_.proxyThirdParty_->isAvailable() && threadCtx2_.proxyThirdParty_->isAvailable())) {
usleep(10000);
}
diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp
index 489060e..b20740c 100644
--- a/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp
+++ b/org.genivi.commonapi.core.verification/src/THMainLoopIntegration.cpp
@@ -11,7 +11,7 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
#include "utils/VerificationMainLoop.h"
-#include "v1_0/commonapi/threading/TestInterfaceProxy.hpp"
+#include "v1/commonapi/threading/TestInterfaceProxy.hpp"
#include "utils/VerificationMainLoop.h"
#include "stub/THMainLoopIntegrationStub.h"
@@ -51,17 +51,17 @@ protected:
}
void TearDown() {
- runtime_->unregisterService(domain, v1_0::commonapi::threading::THMainLoopIntegrationStub::StubInterface::getInterface(), instance);
+ runtime_->unregisterService(domain, v1_0::commonapi::threading::THMainLoopIntegrationStub::StubInterface::getInterface(), instance);
if (mainLoopForProxy_->isRunning()) {
- std::future<bool> proxyStopped = mainLoopForProxy_->stop();
- // synchronisation with stopped mainloop
- proxyStopped.get();
+ std::future<bool> proxyStopped = mainLoopForProxy_->stop();
+ // synchronisation with stopped mainloop
+ proxyStopped.get();
}
if (mainLoopForStub_->isRunning()) {
- std::future<bool> stubStopped = mainLoopForStub_->stop();
- // synchronisation with stopped mainloop
- stubStopped.get();
+ std::future<bool> stubStopped = mainLoopForStub_->stop();
+ // synchronisation with stopped mainloop
+ stubStopped.get();
}
usleep(200);
@@ -117,7 +117,7 @@ TEST_F(THMainLoopIntegration, VerifyCommunicationWithMainLoop) {
// wait until threads are running
while (!mainLoopForProxy_->isRunning() || !mainLoopForStub_->isRunning()) {
- usleep(100);
+ usleep(100);
}
for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) {
@@ -136,12 +136,12 @@ TEST_F(THMainLoopIntegration, VerifyCommunicationWithMainLoop) {
/**
* @test Verifies Transport Reading When Dispatching Watches.
-* - get proxy with available flag = true
-* - generate big test data
-* - send asynchronous test message
-* - dispatch dispatchSource: the message must not be arrived
-* - dispatch watches (reads transport).
-* - dispatch dispatchSources again: now the message must be arrived.
+* - get proxy with available flag = true
+* - generate big test data
+* - send asynchronous test message
+* - dispatch dispatchSource: the message must not be arrived
+* - dispatch watches (reads transport).
+* - dispatch dispatchSources again: now the message must be arrived.
*/
TEST_F(THMainLoopIntegration, VerifyTransportReading) {
@@ -151,7 +151,7 @@ TEST_F(THMainLoopIntegration, VerifyTransportReading) {
// wait until threads are running
while (!mainLoopForProxy_->isRunning() || !mainLoopForStub_->isRunning()) {
- usleep(100);
+ usleep(100);
}
for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) {
@@ -160,19 +160,21 @@ TEST_F(THMainLoopIntegration, VerifyTransportReading) {
ASSERT_TRUE(testProxy_->isAvailable());
if (mainLoopForStub_->isRunning()) {
- std::future<bool> stubStopped = mainLoopForStub_->stop();
- // synchronisation with stopped mainloop
- stubStopped.get();
- }
- if (stubThread.joinable()) {
- stubThread.join();
- }
+ std::future<bool> stubStopped = mainLoopForStub_->stop();
+ // synchronisation with stopped mainloop
+ stubStopped.get();
+ }
+ if (stubThread.joinable()) {
+ stubThread.join();
+ }
uint8_t x = 5;
- uint8_t y = 0;
+ //uint8_t y = 0;
std::future<CommonAPI::CallStatus> futureStatus = testProxy_->testMethodAsync(x,
[&] (const CommonAPI::CallStatus& status, uint8_t y) {
+ (void)status;
+ (void)y;
callbackCalled_++;
}
);
@@ -189,10 +191,10 @@ TEST_F(THMainLoopIntegration, VerifyTransportReading) {
/**
* @test Verifies Synchronous Call Message Handling Order.
-* - get proxy with available flag = true
-* - subscribe for broadcast event
-* - generate 5 test broadcasts
-* - 5 broadcasts should arrive in the right order
+* - get proxy with available flag = true
+* - subscribe for broadcast event
+* - generate 5 test broadcasts
+* - 5 broadcasts should arrive in the right order
*/
TEST_F(THMainLoopIntegration, VerifySyncCallMessageHandlingOrder) {
@@ -200,7 +202,7 @@ TEST_F(THMainLoopIntegration, VerifySyncCallMessageHandlingOrder) {
// wait until thread is running
while (!mainLoopForStub_->isRunning()) {
- usleep(100);
+ usleep(100);
}
for(unsigned int i = 0; !testProxy_->isAvailable() && i < 100; ++i) {
@@ -226,13 +228,13 @@ TEST_F(THMainLoopIntegration, VerifySyncCallMessageHandlingOrder) {
usleep(2);
if (mainLoopForStub_->isRunning()) {
- std::future<bool> stubStopped = mainLoopForStub_->stop();
- // synchronisation with stopped mainloop
- stubStopped.get();
- }
- if (stubThread.joinable()) {
- stubThread.join();
- }
+ std::future<bool> stubStopped = mainLoopForStub_->stop();
+ // synchronisation with stopped mainloop
+ stubStopped.get();
+ }
+ if (stubThread.joinable()) {
+ stubThread.join();
+ }
// in total 5 broadcasts should have been arrived
ASSERT_EQ(lastBroadcastNumber_, 5);
diff --git a/org.genivi.commonapi.core.verification/src/THMainLoopTwoThreads.cpp b/org.genivi.commonapi.core.verification/src/THMainLoopTwoThreads.cpp
index e7158bd..0ac5acc 100644
--- a/org.genivi.commonapi.core.verification/src/THMainLoopTwoThreads.cpp
+++ b/org.genivi.commonapi.core.verification/src/THMainLoopTwoThreads.cpp
@@ -11,121 +11,121 @@
#include <gtest/gtest.h>
#include "CommonAPI/CommonAPI.hpp"
#include "utils/VerificationMainLoopWithQueue.h"
-#include "v1_0/commonapi/threading/TestInterfaceProxy.hpp"
-#include "v1_0/commonapi/threading/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/threading/TestInterfaceProxy.hpp"
+#include "v1/commonapi/threading/TestInterfaceStubDefault.hpp"
const std::string domain = "local";
const std::string instance = "my.test.commonapi.address";
class PingPongTestStub : public v1_0::commonapi::threading::TestInterfaceStubDefault {
- virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
- uint8_t _x,
- testMethodReply_t _reply) {
-
- _reply(_x);
+ virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
+ uint8_t _x,
+ testMethodReply_t _reply) {
+ (void)_client;
+ _reply(_x);
}
};
class THMainLoopTwoThreads: public ::testing::Test {
protected:
void SetUp() {
- runtime_ = CommonAPI::Runtime::get();
- ASSERT_TRUE((bool)runtime_);
+ runtime_ = CommonAPI::Runtime::get();
+ ASSERT_TRUE((bool)runtime_);
- context_ = std::make_shared<CommonAPI::MainLoopContext>("client-sample");
- ASSERT_TRUE((bool)context_);
+ context_ = std::make_shared<CommonAPI::MainLoopContext>("client-sample");
+ ASSERT_TRUE((bool)context_);
- eventQueue_ = std::make_shared<CommonAPI::VerificationMainLoopEventQueue>();
- mainLoop_ = new CommonAPI::VerificationMainLoop(context_, eventQueue_);
+ eventQueue_ = std::make_shared<CommonAPI::VerificationMainLoopEventQueue>();
+ mainLoop_ = new CommonAPI::VerificationMainLoop(context_, eventQueue_);
- stub_ = std::make_shared<PingPongTestStub>();
+ stub_ = std::make_shared<PingPongTestStub>();
- bool stubRegistered = runtime_->registerService(domain, instance, stub_, "service-sample");
- ASSERT_TRUE((bool)stubRegistered);
+ bool stubRegistered = runtime_->registerService(domain, instance, stub_, "service-sample");
+ ASSERT_TRUE((bool)stubRegistered);
- proxy_ = runtime_->buildProxy<v1_0::commonapi::threading::TestInterfaceProxy>(domain, instance, context_);
- ASSERT_TRUE((bool)proxy_);
+ proxy_ = runtime_->buildProxy<v1_0::commonapi::threading::TestInterfaceProxy>(domain, instance, context_);
+ ASSERT_TRUE((bool)proxy_);
- eventQueueThread_ = new std::thread([&]() { eventQueue_->run(); });
- mainLoopThread_ = new std::thread([&]() { mainLoop_->run(); });
+ eventQueueThread_ = new std::thread([&]() { eventQueue_->run(); });
+ mainLoopThread_ = new std::thread([&]() { mainLoop_->run(); });
}
void TearDown() {
- runtime_->unregisterService(domain, stub_->getStubAdapter()->getInterface(), instance);
- mainLoop_->stop();
- //mainLoopThread_->join();
+ runtime_->unregisterService(domain, stub_->getStubAdapter()->getInterface(), instance);
+ mainLoop_->stop();
+ //mainLoopThread_->join();
- usleep(1000000);
+ usleep(1000000);
}
- std::shared_ptr<CommonAPI::Runtime> runtime_;
- std::shared_ptr<CommonAPI::MainLoopContext> context_;
- std::shared_ptr<CommonAPI::VerificationMainLoopEventQueue> eventQueue_;
+ std::shared_ptr<CommonAPI::Runtime> runtime_;
+ std::shared_ptr<CommonAPI::MainLoopContext> context_;
+ std::shared_ptr<CommonAPI::VerificationMainLoopEventQueue> eventQueue_;
- std::shared_ptr<PingPongTestStub> stub_;
- std::shared_ptr<v1_0::commonapi::threading::TestInterfaceProxy<>> proxy_;
+ std::shared_ptr<PingPongTestStub> stub_;
+ std::shared_ptr<v1_0::commonapi::threading::TestInterfaceProxy<>> proxy_;
- CommonAPI::VerificationMainLoop* mainLoop_;
+ CommonAPI::VerificationMainLoop* mainLoop_;
- std::thread* eventQueueThread_;
- std::thread* mainLoopThread_;
+ std::thread* eventQueueThread_;
+ std::thread* mainLoopThread_;
};
/**
* @test Proxy Receives Available when MainLoop Dispatched sourced out to other thread.
*/
TEST_F(THMainLoopTwoThreads, ProxyGetsAvailableStatus) {
- std::condition_variable available;
- std::mutex m;
- bool isAvailable(false);
-
- proxy_->getProxyStatusEvent().subscribe([&](const CommonAPI::AvailabilityStatus& val) {
- if (val == CommonAPI::AvailabilityStatus::AVAILABLE) {
- isAvailable = true;
- available.notify_one();
- }
- });
-
- if (!isAvailable) {
- std::unique_lock<std::mutex> uniqueLock(m);
- available.wait_for(uniqueLock, std::chrono::seconds(10));
- }
-
- ASSERT_TRUE(proxy_->isAvailable());
+ std::condition_variable available;
+ std::mutex m;
+ bool isAvailable(false);
+
+ proxy_->getProxyStatusEvent().subscribe([&](const CommonAPI::AvailabilityStatus& val) {
+ if (val == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ isAvailable = true;
+ available.notify_one();
+ }
+ });
+
+ if (!isAvailable) {
+ std::unique_lock<std::mutex> uniqueLock(m);
+ available.wait_for(uniqueLock, std::chrono::seconds(10));
+ }
+
+ ASSERT_TRUE(proxy_->isAvailable());
}
/**
* @test Proxy gets function response when MainLoop Dispatched sourced out to other thread.
*/
TEST_F(THMainLoopTwoThreads, ProxyGetsFunctionResponse) {
- std::condition_variable available;
- std::mutex m;
- bool isAvailable(false);
-
- proxy_->getProxyStatusEvent().subscribe([&](const CommonAPI::AvailabilityStatus& val) {
- if (val == CommonAPI::AvailabilityStatus::AVAILABLE) {
- isAvailable = true;
- available.notify_one();
- }
- });
-
- if (!isAvailable) {
- std::unique_lock<std::mutex> uniqueLock(m);
- available.wait_for(uniqueLock, std::chrono::seconds(10));
- }
+ std::condition_variable available;
+ std::mutex m;
+ bool isAvailable(false);
+
+ proxy_->getProxyStatusEvent().subscribe([&](const CommonAPI::AvailabilityStatus& val) {
+ if (val == CommonAPI::AvailabilityStatus::AVAILABLE) {
+ isAvailable = true;
+ available.notify_one();
+ }
+ });
+
+ if (!isAvailable) {
+ std::unique_lock<std::mutex> uniqueLock(m);
+ available.wait_for(uniqueLock, std::chrono::seconds(10));
+ }
- ASSERT_TRUE(proxy_->isAvailable());
+ ASSERT_TRUE(proxy_->isAvailable());
- CommonAPI::CallStatus callStatus;
+ CommonAPI::CallStatus callStatus;
- uint8_t x, y;
- x = 1;
- y = 0;
+ uint8_t x, y;
+ x = 1;
+ y = 0;
- proxy_->testMethod(x, callStatus, y);
+ proxy_->testMethod(x, callStatus, y);
- ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus);
- ASSERT_EQ(1, y);
+ ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus);
+ ASSERT_EQ(1, y);
}
int main(int argc, char** argv) {
diff --git a/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in b/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in
index f03d53f..147f5aa 100644
--- a/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in
+++ b/org.genivi.commonapi.core.verification/src/conf/commonapi4dbus.ini.in
@@ -8,6 +8,14 @@ level = warning
[proxy]
local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.bselective.TestInterface:commonapi.advanced.bselective.TestInterface=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Manager:commonapi.advanced.managed.Manager=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Device=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Manager.device01=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Manager.device02=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.SpecialDevice=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.Manager.specialDevice00=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.polymorph.TestInterface:commonapi.advanced.polymorph.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_DBUS@
@@ -169,6 +177,11 @@ local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInte
[stub]
local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.bselective.TestInterface:commonapi.advanced.bselective.TestInterface=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Manager:commonapi.advanced.managed.Manager=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Device=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.SpecialDevice=@GLUECODE_SO_DBUS@
+local:commonapi.advanced.polymorph.TestInterface:commonapi.advanced.polymorph.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_DBUS@
local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_DBUS@
diff --git a/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in b/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in
index 554e1f8..158997f 100644
--- a/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in
+++ b/org.genivi.commonapi.core.verification/src/conf/commonapi4someip.ini.in
@@ -4,6 +4,14 @@ binding=someip
[proxy]
local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.bselective.TestInterface:commonapi.advanced.bselective.TestInterface=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Manager:commonapi.advanced.managed.Manager=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Device=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Manager.device01=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Manager.device02=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.SpecialDevice=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.Manager.specialDevice00=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.polymorph.TestInterface:commonapi.advanced.polymorph.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_SOMEIP@
@@ -166,6 +174,11 @@ local:commonapi.stability.mp.ControlInterface:commonapi.stability.mp.ControlInte
local:commonapi.runtime.TestInterface:commonapi.runtime.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.communication.TestInterface:commonapi.communication.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.communication.Daemon:commonapi.communication.Daemon=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.bselective.TestInterface:commonapi.advanced.bselective.TestInterface=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Manager:commonapi.advanced.managed.Manager=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.Device:commonapi.advanced.managed.Device=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.managed.SpecialDevice:commonapi.advanced.managed.SpecialDevice=@GLUECODE_SO_SOMEIP@
+local:commonapi.advanced.polymorph.TestInterface:commonapi.advanced.polymorph.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.primitive.TestInterface:commonapi.datatypes.primitive.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.advanced.TestInterface:commonapi.datatypes.advanced.TestInterface=@GLUECODE_SO_SOMEIP@
local:commonapi.datatypes.derived.TestInterface:commonapi.datatypes.derived.TestInterface=@GLUECODE_SO_SOMEIP@
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.cpp
new file mode 100644
index 0000000..f9918f0
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.cpp
@@ -0,0 +1,84 @@
+// 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/.
+
+#include <sstream>
+#include <iomanip>
+
+#include "AFManagedStub.h"
+
+using namespace v1_0::commonapi::advanced::managed;
+
+AFManagedStub::AFManagedStub() {
+}
+
+AFManagedStub::AFManagedStub(const std::string instanceName) {
+ managerInstanceName = instanceName;
+}
+
+AFManagedStub::~AFManagedStub() {
+}
+
+void AFManagedStub::deviceDetected(unsigned int n) {
+ std::cout << "Device " << n << " detected!" << std::endl;
+
+ std::string deviceInstanceName = getDeviceName(n);
+ myDevices[deviceInstanceName] = DevicePtr(new DeviceStubImpl);
+ const bool deviceRegistered = this->registerManagedStubDevice(myDevices[deviceInstanceName], deviceInstanceName);
+
+ if (!deviceRegistered) {
+ std::cout << "Error: Unable to register device: " << deviceInstanceName << std::endl;
+ }
+}
+
+void AFManagedStub::specialDeviceDetected(unsigned int n) {
+ std::cout << "Special device " << n << " detected!" << std::endl;
+
+ std::string specialDeviceInstanceName = getSpecialDeviceName(n);
+ mySpecialDevices[specialDeviceInstanceName] = SpecialDevicePtr(new SpecialDeviceStubImpl);
+ const bool specialDeviceRegistered = this->registerManagedStubSpecialDevice(mySpecialDevices[specialDeviceInstanceName],
+ specialDeviceInstanceName);
+
+ if (!specialDeviceRegistered) {
+ std::cout << "Error: Unable to register special device: " << specialDeviceInstanceName << std::endl;
+ }
+}
+
+void AFManagedStub::deviceRemoved(unsigned int n) {
+ std::cout << "Device " << n << " removed!" << std::endl;
+
+ std::string deviceInstanceName = getDeviceName(n);
+ const bool deviceDeregistered = this->deregisterManagedStubDevice(deviceInstanceName);
+
+ if (!deviceDeregistered) {
+ std::cout << "Error: Unable to deregister device: " << deviceInstanceName << std::endl;
+ } else {
+ myDevices.erase(deviceInstanceName);
+ }
+}
+
+void AFManagedStub::specialDeviceRemoved(unsigned int n) {
+ std::cout << "Special device " << n << " removed!" << std::endl;
+
+ std::string specialDeviceInstanceName = getSpecialDeviceName(n);
+ const bool specialDeviceDeregistered = this->deregisterManagedStubSpecialDevice(specialDeviceInstanceName);
+
+ if (!specialDeviceDeregistered) {
+ std::cout << "Error: Unable to deregister special device: " << specialDeviceInstanceName << std::endl;
+ } else {
+ mySpecialDevices.erase(specialDeviceInstanceName);
+ }
+}
+
+std::string AFManagedStub::getDeviceName(unsigned int n) {
+ std::stringstream ss;
+ ss << managerInstanceName << ".device" << std::setw(2) << std::hex << std::setfill('0') << n;
+ return ss.str();
+}
+
+std::string AFManagedStub::getSpecialDeviceName(unsigned int n) {
+ std::stringstream ss;
+ ss << managerInstanceName << ".specialDevice" << std::setw(2) << std::hex << std::setfill('0') << n;
+ return ss.str();
+}
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.h b/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.h
new file mode 100644
index 0000000..c9eae37
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFManagedStub.h
@@ -0,0 +1,44 @@
+// 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/.
+
+#ifndef AFMANAGEDSTUB_H_
+#define AFMANAGEDSTUB_H_
+
+#include <map>
+
+#include <CommonAPI/CommonAPI.hpp>
+#include <v1/commonapi/advanced/managed/ManagerStubDefault.hpp>
+
+#include "DeviceStubImpl.h"
+#include "SpecialDeviceStubImpl.h"
+
+using namespace v1_0::commonapi::advanced::managed;
+
+class AFManagedStub: public ManagerStubDefault {
+
+public:
+ AFManagedStub();
+ AFManagedStub(const std::string);
+ virtual ~AFManagedStub();
+
+ void deviceDetected(unsigned int);
+ void specialDeviceDetected(unsigned int);
+
+ void deviceRemoved(unsigned int);
+ void specialDeviceRemoved(unsigned int);
+private:
+ std::string managerInstanceName;
+
+ typedef std::shared_ptr<DeviceStubImpl> DevicePtr;
+ typedef std::shared_ptr<SpecialDeviceStubImpl> SpecialDevicePtr;
+
+ std::map<std::string, DevicePtr> myDevices;
+ std::map<std::string, SpecialDevicePtr> mySpecialDevices;
+
+ std::string getDeviceName(unsigned int);
+ std::string getSpecialDeviceName(unsigned int);
+};
+
+#endif /* AFMANAGEDSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.cpp b/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.cpp
new file mode 100644
index 0000000..e96bae3
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.cpp
@@ -0,0 +1,41 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include "AFPolymorphStub.h"
+
+namespace v1 {
+namespace commonapi {
+namespace advanced {
+namespace polymorph {
+
+AFPolymorphStub::AFPolymorphStub() {
+}
+
+AFPolymorphStub::~AFPolymorphStub() {
+}
+
+void AFPolymorphStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, std::shared_ptr<TestInterface::PStructBase> _x1, testMethodReply_t _reply) {
+ (void)_client;
+ std::shared_ptr<v1::commonapi::advanced::polymorph::TestInterface::PStructMyTypedef> sp =
+ std::dynamic_pointer_cast<v1::commonapi::advanced::polymorph::TestInterface::PStructMyTypedef>(_x1);
+
+ if (sp != nullptr) {
+ if ((int)sp->getId() == 1) {
+ // send the broadcast
+ fireBTestEvent(_x1);
+ }
+ }
+
+ std::shared_ptr<TestInterface::PStructBase> y1 = _x1;
+ _reply(y1);
+}
+
+} /* namespace polymorph */
+} /* namespace advanced */
+} /* namespace commonapi */
+} /* namespace v1 */
+
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.h b/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.h
new file mode 100644
index 0000000..9ef078d
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFPolymorphStub.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef AFPOLYMORPHSTUB_H_
+#define AFPOLYMORPHSTUB_H_
+
+#include "v1/commonapi/advanced/polymorph/TestInterfaceStubDefault.hpp"
+
+namespace v1 {
+namespace commonapi {
+namespace advanced {
+namespace polymorph {
+
+class AFPolymorphStub : public v1_0::commonapi::advanced::polymorph::TestInterfaceStubDefault {
+public:
+ AFPolymorphStub();
+ virtual ~AFPolymorphStub();
+ virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
+ std::shared_ptr<TestInterface::PStructBase> _x1,
+ testMethodReply_t _reply);
+};
+
+
+} /* namespace polymorph */
+} /* namespace advanced */
+} /* namespace commonapi */
+} /* namespace v1 */
+
+#endif /* AFPOLYMORPHSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.cpp
new file mode 100644
index 0000000..782fef4
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.cpp
@@ -0,0 +1,58 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include "AFSelectiveStub.h"
+
+namespace v1 {
+namespace commonapi {
+namespace advanced {
+namespace bselective {
+
+AFSelectiveStub::AFSelectiveStub() {
+ acceptSubscriptions = true;
+}
+
+AFSelectiveStub::~AFSelectiveStub() {
+}
+
+bool AFSelectiveStub::onBTestSelectiveSelectiveSubscriptionRequested(const std::shared_ptr<CommonAPI::ClientId> _client) {
+ (void)_client;
+ return acceptSubscriptions;
+}
+
+
+void AFSelectiveStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _x,
+ testMethodReply_t _reply) {
+ (void)_client;
+
+
+ uint8_t y;
+
+ switch (_x) {
+
+ case 2: // stop accepting subscriptions
+ acceptSubscriptions = false;
+ break;
+ case 3: // send data (= 1) through selective broadcast
+ fireBTestSelectiveSelective(1);
+ break;
+ case 4: // start accepting subscriptions
+ acceptSubscriptions = true;
+ break;
+ default:
+ break;
+ }
+
+ y = _x;
+ _reply(y);
+}
+
+} /* namespace bselective */
+} /* namespace advanced */
+} /* namespace commonapi */
+} /* namespace v1 */
+
diff --git a/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.h b/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.h
new file mode 100644
index 0000000..64d01a8
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/AFSelectiveStub.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef AFSELECTIVESTUB_H_
+#define AFSELECTIVESTUB_H_
+
+#include "v1/commonapi/advanced/bselective/TestInterfaceStubDefault.hpp"
+
+namespace v1 {
+namespace commonapi {
+namespace advanced {
+namespace bselective {
+
+class AFSelectiveStub : public v1_0::commonapi::advanced::bselective::TestInterfaceStubDefault {
+public:
+ AFSelectiveStub();
+ virtual ~AFSelectiveStub();
+ void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x,
+ testMethodReply_t _reply);
+ virtual bool onBTestSelectiveSelectiveSubscriptionRequested(const std::shared_ptr<CommonAPI::ClientId> _client);
+
+private:
+ bool acceptSubscriptions;
+};
+
+
+} /* namespace bselective */
+} /* namespace advanced */
+} /* namespace commonapi */
+} /* namespace v1 */
+
+#endif /* AFSELECTIVESTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp
index 97eb137..37a79f9 100644
--- a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.cpp
@@ -7,7 +7,7 @@
#include <iostream>
#include "CMAttributesStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace communication {
@@ -25,7 +25,7 @@ void CMAttributesStub::setTestValues(uint8_t x) {
setTestCAttribute(x);
}
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace communication */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h
index 3de45f0..2a12d56 100644
--- a/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/CMAttributesStub.h
@@ -7,9 +7,9 @@
#ifndef CMATTRIBUTESSTUB_H_
#define CMATTRIBUTESSTUB_H_
-#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/communication/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace communication {
@@ -20,7 +20,7 @@ public:
virtual void setTestValues(uint8_t);
};
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace communication */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.cpp b/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.cpp
new file mode 100644
index 0000000..3f26b37
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.cpp
@@ -0,0 +1,58 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include "CMBroadcastsStub.h"
+
+namespace v1 {
+namespace commonapi {
+namespace communication {
+
+CMBroadcastsStub::CMBroadcastsStub() {
+ acceptSubscriptions = true;
+}
+
+CMBroadcastsStub::~CMBroadcastsStub() {
+}
+
+bool CMBroadcastsStub::onBTestSelectiveSelectiveSubscriptionRequested(const std::shared_ptr<CommonAPI::ClientId> _client) {
+ (void)_client;
+ return acceptSubscriptions;
+}
+
+
+void CMBroadcastsStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _x,
+ testMethodReply_t _reply) {
+ (void)_client;
+
+ uint8_t y;
+
+ switch (_x) {
+ case 1: // send data (= 1) through non-selective broadcast
+ fireBTestEvent(1);
+ break;
+ case 2: // stop accepting subscriptions
+ acceptSubscriptions = false;
+ break;
+ case 3: // send data (= 1) through selective broadcast
+ fireBTestSelectiveSelective(1);
+ break;
+ case 4: // start accepting subscriptions
+ acceptSubscriptions = true;
+ break;
+ default:
+ break;
+ }
+
+ y = _x;
+ _reply(y);
+}
+
+
+} /* namespace v1 */
+} /* namespace communication */
+} /* namespace commonapi */
+
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.h b/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.h
new file mode 100644
index 0000000..c6b1eb9
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/CMBroadcastsStub.h
@@ -0,0 +1,32 @@
+/* Copyright (C) 2014 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
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef CMBROADCASTSSTUB_H_
+#define CMBROADCASTSSTUB_H_
+
+#include "v1/commonapi/communication/TestInterfaceStubDefault.hpp"
+
+namespace v1 {
+namespace commonapi {
+namespace communication {
+
+class CMBroadcastsStub : public v1_0::commonapi::communication::TestInterfaceStubDefault {
+public:
+ CMBroadcastsStub();
+ virtual ~CMBroadcastsStub();
+ void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x,
+ testMethodReply_t _reply);
+ virtual bool onBTestSelectiveSelectiveSubscriptionRequested(const std::shared_ptr<CommonAPI::ClientId> _client);
+
+private:
+ bool acceptSubscriptions;
+};
+
+} /* namespace v1 */
+} /* namespace communication */
+} /* namespace commonapi */
+
+#endif /* CMBROADCASTSSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp
index 533f458..d5b4fe1 100644
--- a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.cpp
@@ -7,7 +7,7 @@
#include <iostream>
#include "CMMethodCallsStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace communication {
@@ -17,16 +17,18 @@ CMMethodCallsStub::CMMethodCallsStub() {
CMMethodCallsStub::~CMMethodCallsStub() {
}
-void CMMethodCallsStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x,
+void CMMethodCallsStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _x,
testMethodReply_t _reply) {
+ (void)_client;
+
uint8_t y;
std::cout << "testMethod called." << std::endl;
- y = x;
+ y = _x;
_reply(y);
}
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace communication */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h
index d26d71c..2003d0e 100644
--- a/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/CMMethodCallsStub.h
@@ -7,9 +7,9 @@
#ifndef CMMETHODCALLSSTUB_H_
#define CMMETHODCALLSSTUB_H_
-#include "v1_0/commonapi/communication/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/communication/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace communication {
@@ -22,7 +22,7 @@ public:
testMethodReply_t _reply);
};
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace communication */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp
index 62a0115..715cd89 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.cpp
@@ -10,7 +10,7 @@
#include <unistd.h>
#endif
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace advanced {
@@ -31,7 +31,7 @@ void DTAdvancedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId,
TestInterface::tMap tMapIn,
TestInterface::tTypedef tTypedefIn,
fTestReply_t _reply) {
-
+ (void)clientId;
TestInterface::tArray tArrayOut = tArrayIn;
TestInterface::tEnumeration tEnumerationOut = tEnumerationIn;
@@ -40,7 +40,7 @@ void DTAdvancedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId,
TestInterface::tMap tMapOut = tMapIn;
TestInterface::tTypedef tTypedefOut = tTypedefIn;
- _reply(tArrayOut, tEnumerationOut, tStructOut, tUnionOut, tMapOut, tTypedefOut);
+ _reply(tArrayOut, tEnumerationOut, tStructOut, tUnionOut, tMapOut, tTypedefOut);
fireBTestEvent(
tArrayOut,
@@ -55,4 +55,4 @@ void DTAdvancedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId,
} /* namespace advanced */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h
index e7e1eb9..052740f 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/DTAdvancedStub.h
@@ -7,10 +7,10 @@
#ifndef DTADVANCEDSTUB_H_
#define DTADVANCEDSTUB_H_
-#include "v1_0/commonapi/datatypes/advanced/TestInterfaceStubDefault.hpp"
-#include "v1_0/commonapi/datatypes/advanced/TestInterface.hpp"
+#include "v1/commonapi/datatypes/advanced/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/datatypes/advanced/TestInterface.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace advanced {
@@ -35,5 +35,5 @@ public:
} /* namespace advanced */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* DTADVANCEDSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp
index f347026..a4d58c0 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.cpp
@@ -6,7 +6,7 @@
#include "DTCombinedStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace combined {
@@ -22,10 +22,11 @@ DTCombinedStub::~DTCombinedStub(){
void DTCombinedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> _client,
TestInterface::tStructL3 _tStructL3In, fTestReply_t _reply)
{
+ (void)_client;
_reply(_tStructL3In);
}
} /* namespace combined */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h
index 6d94c39..b096e00 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/DTCombinedStub.h
@@ -7,10 +7,10 @@
#ifndef DTCOMBINEDSTUB_H_
#define DTCOMBINEDSTUB_H_
-#include "v1_0/commonapi/datatypes/combined/TestInterfaceStubDefault.hpp"
-#include "v1_0/commonapi/datatypes/combined/TestInterface.hpp"
+#include "v1/commonapi/datatypes/combined/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/datatypes/combined/TestInterface.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace combined {
@@ -31,5 +31,5 @@ public:
} /* namespace combined */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* DTCOMBINEDSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp
index b5d2ee5..69804ce 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.cpp
@@ -10,7 +10,7 @@
#include <unistd.h>
#endif
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace derived {
@@ -29,13 +29,14 @@ void DTDerivedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId,
TestInterface::tUnionExt tUnionExtIn,
std::shared_ptr<TestInterface::tBaseStruct> tBaseStructIn,
fTestReply_t _reply) {
+ (void)clientId;
TestInterface::tStructExt tStructExtOut = tStructExtIn;
TestInterface::tEnumExt tEnumExtOut = tEnumExtIn;
TestInterface::tUnionExt tUnionExtOut = tUnionExtIn;
std::shared_ptr<TestInterface::tBaseStruct> tBaseStructOut = tBaseStructIn;
- _reply(tStructExtOut, tEnumExtOut, tUnionExtOut, tBaseStructOut);
+ _reply(tStructExtOut, tEnumExtOut, tUnionExtOut, tBaseStructOut);
fireBTestEvent(
tStructExtOut,
@@ -48,4 +49,4 @@ void DTDerivedStub::fTest(const std::shared_ptr<CommonAPI::ClientId> clientId,
} /* namespace derived */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h
index cadd627..ebbe15b 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/DTDerivedStub.h
@@ -7,10 +7,10 @@
#ifndef DTDERIVEDSTUB_H_
#define DTDERIVEDSTUB_H_
-#include "v1_0/commonapi/datatypes/derived/TestInterfaceStubDefault.hpp"
-#include "v1_0/commonapi/datatypes/derived/TestInterface.hpp"
+#include "v1/commonapi/datatypes/derived/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/datatypes/derived/TestInterface.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace derived {
@@ -34,5 +34,5 @@ public:
} /* namespace derived */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* DTDERIVEDSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp
index f4cde9b..7ef9dcf 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.cpp
@@ -10,7 +10,7 @@
#include <unistd.h>
#endif
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace primitive {
@@ -35,6 +35,8 @@ void DTPrimitiveStub::fTest(const std::shared_ptr<CommonAPI::ClientId> _client,
double _doubleIn,
std::string _stringIn,
fTestReply_t _reply) {
+ (void)_client;
+
_reply(_uint8In,
_int8In,
_uint16In,
@@ -64,7 +66,16 @@ void DTPrimitiveStub::fTest(const std::shared_ptr<CommonAPI::ClientId> _client,
);
}
+void DTPrimitiveStub::fTestEmptyBroadcast(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ fTestEmptyBroadcastReply_t _reply) {
+ (void)_client;
+ _reply();
+ fireBTestEmptyEvent();
+}
+
+
} /* namespace primitive */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h
index ddc6b86..aeed539 100644
--- a/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/DTPrimitiveStub.h
@@ -7,9 +7,9 @@
#ifndef DTPRIMITIVESTUB_H_
#define DTPRIMITIVESTUB_H_
-#include "v1_0/commonapi/datatypes/primitive/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/datatypes/primitive/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace datatypes {
namespace primitive {
@@ -20,10 +20,11 @@ public:
virtual ~DTPrimitiveStub();
virtual void fTest(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _uint8In, int8_t _int8In, uint16_t _uint16In, int16_t _int16In, uint32_t _uint32In, int32_t _int32In, uint64_t _uint64In, int64_t _int64In, bool _booleanIn, float _floatIn, double _doubleIn, std::string _stringIn, fTestReply_t _reply);
+ virtual void fTestEmptyBroadcast(const std::shared_ptr<CommonAPI::ClientId> _client, fTestEmptyBroadcastReply_t _reply);
};
} /* namespace primitive */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* DTPRIMITIVESTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.cpp b/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.cpp
new file mode 100644
index 0000000..ead2abf
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.cpp
@@ -0,0 +1,22 @@
+// 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/.
+
+#include <iostream>
+
+#include "DeviceStubImpl.h"
+
+DeviceStubImpl::DeviceStubImpl() {
+}
+
+DeviceStubImpl::~DeviceStubImpl() {
+}
+
+void DeviceStubImpl::doSomething(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingReply_t _reply) {
+ (void)_client;
+ std::cout << "DeviceStubImpl::doSomething() called." << std::endl;
+ _reply();
+}
diff --git a/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.h b/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.h
new file mode 100644
index 0000000..afea72b
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/DeviceStubImpl.h
@@ -0,0 +1,21 @@
+// 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/.
+
+#ifndef DEVICESTUBIMPL_H_
+#define DEVICESTUBIMPL_H_
+
+#include <v1/commonapi/advanced/managed/DeviceStubDefault.hpp>
+
+using namespace v1_0::commonapi::advanced::managed;
+
+class DeviceStubImpl: public DeviceStubDefault {
+public:
+ DeviceStubImpl();
+ virtual ~DeviceStubImpl();
+ void doSomething(const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingReply_t _reply);
+};
+
+#endif /* DEVICESTUBIMPL_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp
index fa70170..f9744f7 100644
--- a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.cpp
@@ -7,7 +7,7 @@
#include "PFComplexStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace performance {
namespace complex {
@@ -21,16 +21,16 @@ PFComplexStub::~PFComplexStub() {
}
-void PFComplexStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::tArray x, testMethodReply_t _reply) {
+void PFComplexStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, TestInterface::tArray _x, testMethodReply_t _reply) {
+ (void)_client;
+ TestInterface::tArray y;
- TestInterface::tArray y;
-
- // Copy array!
- y = x;
- _reply(y);
+ // Copy array!
+ y = _x;
+ _reply(y);
}
} /* namespace complex */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h
index 626b975..0573359 100644
--- a/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/PFComplexStub.h
@@ -6,16 +6,16 @@
#ifndef PFCOMPLEXSTUB_H_
#define PFCOMPLEXSTUB_H_
-#include "v1_0/commonapi/performance/complex/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/performance/complex/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace performance {
namespace complex {
class PFComplexStub : public TestInterfaceStubDefault {
public:
- PFComplexStub();
+ PFComplexStub();
virtual ~PFComplexStub();
virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::tArray x, testMethodReply_t _reply);
@@ -24,6 +24,6 @@ public:
} /* namespace complex */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* PFCOMPLEXSTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp
index 1769ed5..7346c1e 100644
--- a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.cpp
@@ -7,7 +7,7 @@
#include "PFPrimitiveStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace performance {
namespace primitive {
@@ -21,18 +21,18 @@ PFPrimitiveStub::~PFPrimitiveStub() {
}
-void PFPrimitiveStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId,
- TestInterface::TestArray x, testMethodReply_t _reply) {
+void PFPrimitiveStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
+ TestInterface::TestArray _x, testMethodReply_t _reply) {
+ (void)_client;
+ TestInterface::TestArray y;
- TestInterface::TestArray y;
-
- // Copy array!
- y = x;
- _reply(y);
+ // Copy array!
+ y = _x;
+ _reply(y);
}
} /* namespace primitive */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h
index aa934d4..9b7e7e5 100644
--- a/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/PFPrimitiveStub.h
@@ -6,16 +6,16 @@
#ifndef PFPRIMITIVESTUB_H_
#define PFPRIMITIVESTUB_H_
-#include "v1_0/commonapi/performance/primitive/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/performance/primitive/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace performance {
namespace primitive {
class PFPrimitiveStub : public TestInterfaceStubDefault {
public:
- PFPrimitiveStub();
+ PFPrimitiveStub();
virtual ~PFPrimitiveStub();
virtual void testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, TestInterface::TestArray x, testMethodReply_t _reply);
@@ -24,6 +24,6 @@ public:
} /* namespace primitive */
} /* namespace datatypes */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* PFPRIMITIVESTUB_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.cpp b/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.cpp
new file mode 100644
index 0000000..f5ea466
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.cpp
@@ -0,0 +1,23 @@
+// 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/.
+
+#include <iostream>
+
+#include "SpecialDeviceStubImpl.h"
+
+SpecialDeviceStubImpl::SpecialDeviceStubImpl() {
+}
+
+SpecialDeviceStubImpl::~SpecialDeviceStubImpl() {
+}
+
+void SpecialDeviceStubImpl::doSomethingSpecial(
+ const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingSpecialReply_t _reply) {
+ (void)_client;
+ std::cout << "SpecialDeviceStubImpl::doSomethingSpecial() called."
+ << std::endl;
+ _reply();
+}
diff --git a/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.h b/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.h
new file mode 100644
index 0000000..4f29a36
--- /dev/null
+++ b/org.genivi.commonapi.core.verification/src/stub/SpecialDeviceStubImpl.h
@@ -0,0 +1,22 @@
+// 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/.
+
+#ifndef SPECIALDEVICESTUBIMPL_H_
+#define SPECIALDEVICESTUBIMPL_H_
+
+#include <v1/commonapi/advanced/managed/SpecialDeviceStubDefault.hpp>
+
+using namespace v1_0::commonapi::advanced::managed;
+
+class SpecialDeviceStubImpl: public SpecialDeviceStubDefault {
+public:
+ SpecialDeviceStubImpl();
+ virtual ~SpecialDeviceStubImpl();
+
+ void doSomethingSpecial(const std::shared_ptr<CommonAPI::ClientId> _client,
+ doSomethingReply_t _reply);
+};
+
+#endif /* SPECIALDEVICESTUBIMPL_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp
index 373636e..7bf459d 100644
--- a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.cpp
@@ -9,7 +9,7 @@
#include <unistd.h>
#endif
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace stability {
namespace sp {
@@ -22,16 +22,17 @@ StabilitySPStub::StabilitySPStub() {
StabilitySPStub::~StabilitySPStub() {
}
-void StabilitySPStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId,
- TestInterface::tArray tArrayIn,
+void StabilitySPStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client,
+ TestInterface::tArray _tArrayIn,
testMethodReply_t _reply) {
+ (void)_client;
TestInterface::tArray tArrayOut;
- tArrayOut = tArrayIn;
+ tArrayOut = _tArrayIn;
fireTestBroadcastEvent(
- tArrayIn
+ _tArrayIn
);
_reply(tArrayOut);
@@ -43,7 +44,7 @@ void StabilitySPStub::setTestValues(TestInterface::tArray x) {
setTestAttributeAttribute(x);
}
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace sp */
} /* namespace stability */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h
index d9a4071..32ab593 100644
--- a/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/StabilitySPStub.h
@@ -6,10 +6,10 @@
#ifndef STABILITYSPSTUB_H_
#define STABILITYSPSTUB_H_
-#include "v1_0/commonapi/stability/sp/TestInterfaceStubDefault.hpp"
-#include "v1_0/commonapi/stability/sp/TestInterface.hpp"
+#include "v1/commonapi/stability/sp/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/stability/sp/TestInterface.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace stability {
namespace sp {
@@ -26,7 +26,7 @@ public:
virtual void setTestValues(TestInterface::tArray x);
};
-} /* namespace v1_0 */
+} /* namespace v1 */
} /* namespace sp */
} /* namespace stability */
} /* namespace commonapi */
diff --git a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp
index 794f6ab..0b29bb2 100644
--- a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp
+++ b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.cpp
@@ -7,7 +7,7 @@
#include <iostream>
#include "THMainLoopIntegrationStub.h"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace threading {
@@ -18,10 +18,10 @@ THMainLoopIntegrationStub::THMainLoopIntegrationStub() {
THMainLoopIntegrationStub::~THMainLoopIntegrationStub() {
}
-void THMainLoopIntegrationStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, uint8_t x, testMethodReply_t _reply) {
-
- uint8_t y = x;
- x_ = x;
+void THMainLoopIntegrationStub::testMethod(const std::shared_ptr<CommonAPI::ClientId> _client, uint8_t _x, testMethodReply_t _reply) {
+ (void)_client;
+ uint8_t y = _x;
+ x_ = _x;
uint8_t broadcastNumber = 0;
broadcastNumber++;
@@ -40,4 +40,4 @@ void THMainLoopIntegrationStub::testMethod(const std::shared_ptr<CommonAPI::Clie
} /* namespace threading */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
diff --git a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h
index 1747af2..7ba0f89 100644
--- a/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h
+++ b/org.genivi.commonapi.core.verification/src/stub/THMainLoopIntegrationStub.h
@@ -7,9 +7,9 @@
#ifndef THMAINLOOPINTEGRATION_H_
#define THMAINLOOPINTEGRATION_H_
-#include "v1_0/commonapi/threading/TestInterfaceStubDefault.hpp"
+#include "v1/commonapi/threading/TestInterfaceStubDefault.hpp"
-namespace v1_0 {
+namespace v1 {
namespace commonapi {
namespace threading {
@@ -25,6 +25,6 @@ public:
} /* namespace threading */
} /* namespace commonapi */
-} /* namespace v1_0 */
+} /* namespace v1 */
#endif /* THMAINLOOPINTEGRATION_H_ */
diff --git a/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
index 49fd14f..112d110 100644
--- a/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
+++ b/org.genivi.commonapi.core.verification/src/utils/StopWatch.cpp
@@ -10,7 +10,7 @@
#include <ctime>
#ifdef WIN32
- #include <chrono>
+ #include <chrono>
#endif
#define USEC_PER_SEC 1000000ULL
@@ -18,27 +18,29 @@
StopWatch::usec_t StopWatch::getTotalElapsedMicroseconds() const {
- usec_t elapsed = totalElapsed_;
+ usec_t elapsed = totalElapsed_;
- if (started_)
- elapsed += getElapsed();
+ if (started_)
+ elapsed += getElapsed();
- return elapsed;
+ return elapsed;
}
StopWatch::usec_t StopWatch::getTotalElapsedSeconds() const {
- return getTotalElapsedMicroseconds() / USEC_PER_SEC;
+ return getTotalElapsedMicroseconds() / USEC_PER_SEC;
}
StopWatch::usec_t StopWatch::now() {
#ifdef WIN32
- return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
+ return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
#else
- struct timespec ts;
+ struct timespec ts;
- assert(!clock_gettime(CLOCK_MONOTONIC, &ts));
+ const int ret = clock_gettime(CLOCK_MONOTONIC, &ts);
+ assert(!ret);
+ (void)ret;
- return (usec_t) ts.tv_sec * USEC_PER_SEC + (usec_t) ts.tv_nsec / NSEC_PER_USEC;
+ return (usec_t) ts.tv_sec * USEC_PER_SEC + (usec_t) ts.tv_nsec / NSEC_PER_USEC;
#endif
}
diff --git a/org.genivi.commonapi.core.verification/src/utils/StopWatch.h b/org.genivi.commonapi.core.verification/src/utils/StopWatch.h
index be54b9f..22433be 100644
--- a/org.genivi.commonapi.core.verification/src/utils/StopWatch.h
+++ b/org.genivi.commonapi.core.verification/src/utils/StopWatch.h
@@ -12,42 +12,42 @@
class StopWatch {
public:
- typedef uint64_t usec_t;
+ typedef uint64_t usec_t;
- StopWatch():
- started_(false),
- totalElapsed_(0),
- startTimePoint_(0) {
- }
+ StopWatch():
+ started_(false),
+ totalElapsed_(0),
+ startTimePoint_(0) {
+ }
- inline void reset() {
- started_ = false;
- totalElapsed_ = 0;
- }
+ inline void reset() {
+ started_ = false;
+ totalElapsed_ = 0;
+ }
- inline void start() {
- startTimePoint_ = now();
- started_ = true;
- }
+ inline void start() {
+ startTimePoint_ = now();
+ started_ = true;
+ }
- inline void stop() {
- totalElapsed_ += getElapsed();
- started_ = false;
- }
+ inline void stop() {
+ totalElapsed_ += getElapsed();
+ started_ = false;
+ }
- usec_t getTotalElapsedMicroseconds() const;
- usec_t getTotalElapsedSeconds() const;
+ usec_t getTotalElapsedMicroseconds() const;
+ usec_t getTotalElapsedSeconds() const;
private:
- inline usec_t getElapsed() const {
- return now() - startTimePoint_;
- }
+ inline usec_t getElapsed() const {
+ return now() - startTimePoint_;
+ }
- static usec_t now();
+ static usec_t now();
- bool started_;
- usec_t startTimePoint_;
- usec_t totalElapsed_;
+ bool started_;
+ usec_t totalElapsed_;
+ usec_t startTimePoint_;
};
#endif // STOP_WATCH_H_
diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h
index beac7a6..6cef43d 100644
--- a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h
+++ b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoop.h
@@ -20,6 +20,8 @@
#include <cassert>
#include <chrono>
#include <future>
+#include <mutex>
+#include <cstdio>
#ifdef WIN32
#include <WinSock2.h>
@@ -43,18 +45,18 @@ class VerificationMainLoop {
VerificationMainLoop& operator=(VerificationMainLoop&&) = delete;
explicit VerificationMainLoop(std::shared_ptr<MainLoopContext> context) :
- context_(context), currentMinimalTimeoutInterval_(TIMEOUT_INFINITE), running_(false), breakLoop_(false), dispatchWatchesTooLong(false) {
+ dispatchWatchesTooLong(false), context_(context), currentMinimalTimeoutInterval_(TIMEOUT_INFINITE), breakLoop_(false), running_(false) {
#ifdef WIN32
- wsaEvents_.push_back(WSACreateEvent());
+ wsaEvents_.push_back(WSACreateEvent());
- if (wsaEvents_[0] == WSA_INVALID_EVENT) {
- printf("Invalid Event Created!");
- }
+ if (wsaEvents_[0] == WSA_INVALID_EVENT) {
+ printf("Invalid Event Created!");
+ }
#else
- wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK);
- wakeFd_.events = POLLIN;
- assert(wakeFd_.fd != -1);
- registerFileDescriptor(wakeFd_);
+ wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK);
+ wakeFd_.events = POLLIN;
+ assert(wakeFd_.fd != -1);
+ registerFileDescriptor(wakeFd_);
#endif
@@ -75,7 +77,7 @@ class VerificationMainLoop {
~VerificationMainLoop() {
#ifndef WIN32
- deregisterFileDescriptor(wakeFd_);
+ deregisterFileDescriptor(wakeFd_);
#endif
context_->unsubscribeForDispatchSources(dispatchSourceListenerSubscription_);
context_->unsubscribeForWatches(watchListenerSubscription_);
@@ -83,7 +85,7 @@ class VerificationMainLoop {
context_->unsubscribeForWakeupEvents(wakeupListenerSubscription_);
#ifdef WIN32
- WSACloseEvent(wsaEvents_[0]);
+ WSACloseEvent(wsaEvents_[0]);
#else
close(wakeFd_.fd);
#endif
@@ -104,7 +106,7 @@ class VerificationMainLoop {
}
if (stopPromise) {
- stopPromise->set_value(true);
+ stopPromise->set_value(true);
}
}
@@ -123,9 +125,9 @@ class VerificationMainLoop {
}
std::future<bool> stop() {
- // delete old promise to secure, that always a new future object is returned
- delete stopPromise;
- stopPromise = new std::promise<bool>;
+ // delete old promise to secure, that always a new future object is returned
+ delete stopPromise;
+ stopPromise = new std::promise<bool>;
running_ = false;
wakeup();
@@ -134,8 +136,8 @@ class VerificationMainLoop {
}
bool isRunning() {
- return running_;
- }
+ return running_;
+ }
/**
* \brief Executes a single cycle of the mainloop.
@@ -168,6 +170,7 @@ class VerificationMainLoop {
void prepare(const int64_t& timeout = TIMEOUT_INFINITE) {
currentMinimalTimeoutInterval_ = timeout;
+ registeredDispatchSourcesMutex_.lock();
for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
@@ -176,14 +179,16 @@ class VerificationMainLoop {
if(dispatchSourceIterator->second->prepare(dispatchTimeout)) {
sourcesToDispatch_.insert(*dispatchSourceIterator);
} else if (dispatchTimeout != -1 || currentMinimalTimeoutInterval_ == TIMEOUT_INFINITE) {
- if (dispatchTimeout < currentMinimalTimeoutInterval_) {
- currentMinimalTimeoutInterval_ = dispatchTimeout;
- }
+ if (dispatchTimeout < currentMinimalTimeoutInterval_) {
+ currentMinimalTimeoutInterval_ = dispatchTimeout;
+ }
}
}
+ registeredDispatchSourcesMutex_.unlock();
int64_t currentContextTime = getCurrentTimeInMs();
+ registeredTimeoutsMutex_.lock();
for (auto timeoutPriorityRange = registeredTimeouts_.begin();
timeoutPriorityRange != registeredTimeouts_.end();
timeoutPriorityRange++) {
@@ -197,40 +202,41 @@ class VerificationMainLoop {
currentMinimalTimeoutInterval_ = intervalToReady;
}
}
+ registeredTimeoutsMutex_.unlock();
}
void poll() {
#ifdef WIN32
- int managedFileDescriptorOffset = 0;
+ int managedFileDescriptorOffset = 0;
#else
- int managedFileDescriptorOffset = 1;
+ int managedFileDescriptorOffset = 1;
#endif
- for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
- (*fileDescriptor).revents = 0;
- }
+ for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
+ (*fileDescriptor).revents = 0;
+ }
#if WIN32
- size_t numReadyFileDescriptors = 0;
-
- int errorCode = WSAWaitForMultipleEvents(wsaEvents_.size(), wsaEvents_.data(), FALSE, currentMinimalTimeoutInterval_, FALSE);
-
- if (errorCode == WSA_WAIT_IO_COMPLETION) {
- printf("WSAWaitForMultipleEvents failed with error: WSA_WAIT_IO_COMPLETION");
- }
- else if (errorCode == WSA_WAIT_FAILED) {
- printf("WSAWaitForMultipleEvents failed with error: %ld\n", WSAGetLastError());
- }
- else {
- for (uint32_t i = 0; i < managedFileDescriptors_.size(); i++) {
- if (WaitForSingleObjectEx(wsaEvents_[i + 1], 0, true) != WAIT_TIMEOUT) {
- numReadyFileDescriptors++;
- managedFileDescriptors_[i].revents = POLLIN;
- }
- }
- }
+ size_t numReadyFileDescriptors = 0;
+
+ int errorCode = WSAWaitForMultipleEvents(wsaEvents_.size(), wsaEvents_.data(), FALSE, currentMinimalTimeoutInterval_, FALSE);
+
+ if (errorCode == WSA_WAIT_IO_COMPLETION) {
+ printf("WSAWaitForMultipleEvents failed with error: WSA_WAIT_IO_COMPLETION");
+ }
+ else if (errorCode == WSA_WAIT_FAILED) {
+ printf("WSAWaitForMultipleEvents failed with error: %ld\n", WSAGetLastError());
+ }
+ else {
+ for (uint32_t i = 0; i < managedFileDescriptors_.size(); i++) {
+ if (WaitForSingleObjectEx(wsaEvents_[i + 1], 0, true) != WAIT_TIMEOUT) {
+ numReadyFileDescriptors++;
+ managedFileDescriptors_[i].revents = POLLIN;
+ }
+ }
+ }
#else
- size_t numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), currentMinimalTimeoutInterval_);
+ size_t numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), int(currentMinimalTimeoutInterval_));
#endif
// If no FileDescriptors are ready, poll returned because of a timeout that has expired.
@@ -239,6 +245,7 @@ class VerificationMainLoop {
if(!numReadyFileDescriptors) {
int64_t currentContextTime = getCurrentTimeInMs();
+ registeredTimeoutsMutex_.lock();
for (auto timeoutPriorityRange = registeredTimeouts_.begin();
timeoutPriorityRange != registeredTimeouts_.end();
timeoutPriorityRange++) {
@@ -249,25 +256,27 @@ class VerificationMainLoop {
timeoutsToDispatch_.insert(*timeoutPriorityRange);
}
}
+ registeredTimeoutsMutex_.unlock();
}
#ifdef WIN32
- acknowledgeWakeup();
+ acknowledgeWakeup();
#else
- if (managedFileDescriptors_[0].revents) {
- acknowledgeWakeup();
- }
+ if (managedFileDescriptors_[0].revents) {
+ acknowledgeWakeup();
+ }
#endif
}
bool check() {
- //The first file descriptor always is the loop's wakeup-descriptor (but not for windows anymore). All others need to be linked to a watch.
+ //The first file descriptor always is the loop's wakeup-descriptor (but not for windows anymore). All others need to be linked to a watch.
#ifdef WIN32
- int managedFileDescriptorOffset = 0;
+ int managedFileDescriptorOffset = 0;
#else
- int managedFileDescriptorOffset = 1;
+ int managedFileDescriptorOffset = 1;
#endif
- for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
+ for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
+ registeredWatchesMutex_.lock();
for (auto registeredWatchIterator = registeredWatches_.begin();
registeredWatchIterator != registeredWatches_.end();
registeredWatchIterator++) {
@@ -278,13 +287,16 @@ class VerificationMainLoop {
watchesToDispatch_.insert( { correspondingWatchPriority, {std::get<1>(correspondingWatchPair)} } );
}
}
+ registeredWatchesMutex_.unlock();
}
+ registeredDispatchSourcesMutex_.lock();
for(auto dispatchSourceIterator = registeredDispatchSources_.begin(); dispatchSourceIterator != registeredDispatchSources_.end(); ++dispatchSourceIterator) {
if((std::get<1>(*dispatchSourceIterator))->check()) {
sourcesToDispatch_.insert( {std::get<0>(*dispatchSourceIterator), std::get<1>(*dispatchSourceIterator)});
}
}
+ registeredDispatchSourcesMutex_.unlock();
return !timeoutsToDispatch_.empty() || !watchesToDispatch_.empty() || !sourcesToDispatch_.empty();
}
@@ -303,14 +315,16 @@ class VerificationMainLoop {
void wakeup() {
#ifdef WIN32
- if (!WSASetEvent(wsaEvents_[0]))
- {
- printf("SetEvent failed (%d)\n", GetLastError());
- return;
- }
+ if (!WSASetEvent(wsaEvents_[0]))
+ {
+ printf("SetEvent failed (%d)\n", GetLastError());
+ return;
+ }
#else
int64_t wake = 1;
- ::write(managedFileDescriptors_[0].fd, &wake, sizeof(int64_t));
+ if(::write(managedFileDescriptors_[0].fd, &wake, sizeof(int64_t)) == -1) {
+ std::perror("VerificationMainLoop::wakeup");
+ }
#endif
}
@@ -381,28 +395,31 @@ class VerificationMainLoop {
}
#ifdef WIN32
- void registerEvent(
- const HANDLE& wsaEvent) {
- wsaEvents_.push_back(wsaEvent);
- }
-
- void unregisterEvent(
- const HANDLE& wsaEvent) {
- for (auto it = wsaEvents_.begin();
- it != wsaEvents_.end(); it++) {
- if ((*it) == wsaEvent) {
- wsaEvents_.erase(it);
- break;
- }
- }
- }
+ void registerEvent(
+ const HANDLE& wsaEvent) {
+ wsaEvents_.push_back(wsaEvent);
+ }
+
+ void unregisterEvent(
+ const HANDLE& wsaEvent) {
+ for (auto it = wsaEvents_.begin();
+ it != wsaEvents_.end(); it++) {
+ if ((*it) == wsaEvent) {
+ wsaEvents_.erase(it);
+ break;
+ }
+ }
+ }
#endif
void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority) {
+ registeredDispatchSourcesMutex_.lock();
registeredDispatchSources_.insert( {dispatchPriority, dispatchSource} );
+ registeredDispatchSourcesMutex_.unlock();
}
void deregisterDispatchSource(DispatchSource* dispatchSource) {
+ registeredDispatchSourcesMutex_.lock();
for(auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
@@ -412,6 +429,7 @@ class VerificationMainLoop {
break;
}
}
+ registeredDispatchSourcesMutex_.unlock();
breakLoop_ = true;
}
@@ -419,33 +437,40 @@ class VerificationMainLoop {
registerFileDescriptor(watch->getAssociatedFileDescriptor());
#ifdef WIN32
- registerEvent(watch->getAssociatedEvent());
+ registerEvent(watch->getAssociatedEvent());
#endif
-
+
+ registeredWatchesMutex_.lock();
registeredWatches_.insert( { dispatchPriority, {watch->getAssociatedFileDescriptor().fd, watch} } );
+ registeredWatchesMutex_.unlock();
}
void deregisterWatch(Watch* watch) {
#ifdef WIN32
- unregisterEvent(watch->getAssociatedEvent());
+ unregisterEvent(watch->getAssociatedEvent());
#endif
+ registeredWatchesMutex_.lock();
for(auto watchIterator = registeredWatches_.begin();
watchIterator != registeredWatches_.end();
watchIterator++) {
if(watchIterator->second.second == watch) {
registeredWatches_.erase(watchIterator);
- break;
+ break;
}
}
+ registeredWatchesMutex_.unlock();
}
void registerTimeout(Timeout* timeout, const DispatchPriority dispatchPriority) {
+ registeredTimeoutsMutex_.lock();
registeredTimeouts_.insert( {dispatchPriority, timeout} );
+ registeredTimeoutsMutex_.unlock();
}
void deregisterTimeout(Timeout* timeout) {
+ registeredTimeoutsMutex_.lock();
for(auto timeoutIterator = registeredTimeouts_.begin();
timeoutIterator != registeredTimeouts_.end();
timeoutIterator++) {
@@ -455,17 +480,18 @@ class VerificationMainLoop {
break;
}
}
+ registeredTimeoutsMutex_.unlock();
}
void acknowledgeWakeup() {
#ifdef WIN32
- for (unsigned int i = 0; i < wsaEvents_.size(); i++) {
- if (!WSAResetEvent(wsaEvents_[i]))
- {
- printf("ResetEvent failed (%d)\n", GetLastError());
- return;
- }
- }
+ for (unsigned int i = 0; i < wsaEvents_.size(); i++) {
+ if (!WSAResetEvent(wsaEvents_[i]))
+ {
+ printf("ResetEvent failed (%d)\n", GetLastError());
+ return;
+ }
+ }
#else
int64_t buffer;
while (::read(managedFileDescriptors_[0].fd, &buffer, sizeof(int64_t)) == sizeof(buffer));
@@ -493,10 +519,14 @@ class VerificationMainLoop {
bool breakLoop_;
bool running_;
+ std::mutex registeredDispatchSourcesMutex_;
+ std::mutex registeredWatchesMutex_;
+ std::mutex registeredTimeoutsMutex_;
+
#ifdef WIN32
- std::vector<HANDLE> wsaEvents_;
+ std::vector<HANDLE> wsaEvents_;
#else
- pollfd wakeFd_;
+ pollfd wakeFd_;
#endif
std::promise<bool>* stopPromise;
diff --git a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoopWithQueue.h b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoopWithQueue.h
index 5bf3af4..9de1469 100644
--- a/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoopWithQueue.h
+++ b/org.genivi.commonapi.core.verification/src/utils/VerificationMainLoopWithQueue.h
@@ -13,6 +13,7 @@
#include <map>
#include <memory>
#include <condition_variable>
+#include <cstdio>
#ifdef WIN32
#include <WinSock2.h>
#else
@@ -22,6 +23,7 @@
#endif
#include <cassert>
+#include <mutex>
namespace CommonAPI {
@@ -29,81 +31,82 @@ typedef pollfd DemoMainLoopPollFd;
class VerificationMainLoopEventQueue {
public:
- void run(const int64_t& timeoutInterval = TIMEOUT_INFINITE) {
- running_ = true;
- while (running_) {
- std::unique_lock<std::mutex> queueUniqueLock(queueLock_);
- queueCondition_.wait(queueUniqueLock);
-
- for (unsigned int i = 0; i < queue_.size(); i++) {
- queue_.at(i)();
- }
-
- queueUniqueLock.unlock();
- queueCondition_.notify_one();
- }
- }
-
- void stop() {
- running_ = false;
- }
-
- void pushToQueue(std::function<void()> func) {
- std::lock_guard<std::mutex> queueUniqueLock(queueLock_);
- queue_.push_back(func);
- queueCondition_.notify_one();
- }
+ void run(const int64_t& timeoutInterval = TIMEOUT_INFINITE) {
+ (void)timeoutInterval;
+ running_ = true;
+ while (running_) {
+ std::unique_lock<std::mutex> queueUniqueLock(queueLock_);
+ queueCondition_.wait(queueUniqueLock);
+
+ for (unsigned int i = 0; i < queue_.size(); i++) {
+ queue_.at(i)();
+ }
+
+ queueUniqueLock.unlock();
+ queueCondition_.notify_one();
+ }
+ }
+
+ void stop() {
+ running_ = false;
+ }
+
+ void pushToQueue(std::function<void()> func) {
+ std::lock_guard<std::mutex> queueUniqueLock(queueLock_);
+ queue_.push_back(func);
+ queueCondition_.notify_one();
+ }
private:
- bool running_;
- std::vector<std::function<void()>> queue_;
- std::condition_variable queueCondition_;
- std::mutex queueLock_;
+ bool running_;
+ std::vector<std::function<void()>> queue_;
+ std::condition_variable queueCondition_;
+ std::mutex queueLock_;
};
class VerificationMainLoop {
public:
- VerificationMainLoop() = delete;
- VerificationMainLoop(const VerificationMainLoop&) = delete;
- VerificationMainLoop& operator=(const VerificationMainLoop&) = delete;
- VerificationMainLoop(VerificationMainLoop&&) = delete;
- VerificationMainLoop& operator=(VerificationMainLoop&&) = delete;
-
- explicit VerificationMainLoop(std::shared_ptr<MainLoopContext> context, std::shared_ptr<VerificationMainLoopEventQueue> eventQueue) :
- context_(context),
- eventQueue_(eventQueue),
- currentMinimalTimeoutInterval_(TIMEOUT_INFINITE),
- breakLoop_(false),
- running_(false),
- m_bNeedWakeup(false)
+ VerificationMainLoop() = delete;
+ VerificationMainLoop(const VerificationMainLoop&) = delete;
+ VerificationMainLoop& operator=(const VerificationMainLoop&) = delete;
+ VerificationMainLoop(VerificationMainLoop&&) = delete;
+ VerificationMainLoop& operator=(VerificationMainLoop&&) = delete;
+
+ explicit VerificationMainLoop(std::shared_ptr<MainLoopContext> context, std::shared_ptr<VerificationMainLoopEventQueue> eventQueue) :
+ m_bNeedWakeup(false),
+ context_(context),
+ currentMinimalTimeoutInterval_(TIMEOUT_INFINITE),
+ breakLoop_(false),
+ running_(false),
+ eventQueue_(eventQueue)
{
#ifdef WIN32
- wsaEvents_.push_back(WSACreateEvent());
+ wsaEvents_.push_back(WSACreateEvent());
- if (wsaEvents_[0] == WSA_INVALID_EVENT) {
- printf("Invalid Event Created!");
- }
+ if (wsaEvents_[0] == WSA_INVALID_EVENT) {
+ printf("Invalid Event Created!");
+ }
#else
- wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK);
- wakeFd_.events = POLLIN;
- assert(wakeFd_.fd != -1);
- registerFileDescriptor(wakeFd_);
+ wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK);
+ wakeFd_.events = POLLIN;
+ assert(wakeFd_.fd != -1);
+ registerFileDescriptor(wakeFd_);
#endif
dispatchSourceListenerSubscription_ = context_->subscribeForDispatchSources(
- std::bind(&VerificationMainLoop::registerDispatchSource, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&VerificationMainLoop::deregisterDispatchSource, this, std::placeholders::_1));
+ std::bind(&VerificationMainLoop::registerDispatchSource, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&VerificationMainLoop::deregisterDispatchSource, this, std::placeholders::_1));
watchListenerSubscription_ = context_->subscribeForWatches(
- std::bind(&VerificationMainLoop::registerWatch, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&VerificationMainLoop::deregisterWatch, this, std::placeholders::_1));
+ std::bind(&VerificationMainLoop::registerWatch, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&VerificationMainLoop::deregisterWatch, this, std::placeholders::_1));
timeoutSourceListenerSubscription_ = context_->subscribeForTimeouts(
- std::bind(&VerificationMainLoop::registerTimeout, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&VerificationMainLoop::deregisterTimeout, this, std::placeholders::_1));
+ std::bind(&VerificationMainLoop::registerTimeout, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&VerificationMainLoop::deregisterTimeout, this, std::placeholders::_1));
wakeupListenerSubscription_ = context_->subscribeForWakeupEvents(
- std::bind(&VerificationMainLoop::wakeup, this));
+ std::bind(&VerificationMainLoop::wakeup, this));
}
- ~VerificationMainLoop() {
+ ~VerificationMainLoop() {
#ifndef WIN32
deregisterFileDescriptor(wakeFd_);
#endif
@@ -113,7 +116,7 @@ class VerificationMainLoop {
context_->unsubscribeForWakeupEvents(wakeupListenerSubscription_);
#ifdef WIN32
- WSACloseEvent(wsaEvents_[0]);
+ WSACloseEvent(wsaEvents_[0]);
#else
close(wakeFd_.fd);
#endif
@@ -156,8 +159,8 @@ class VerificationMainLoop {
prepare(timeout);
poll();
if(check()) {
- dispatch();
- //dispatchCondition_.notify_one();
+ dispatch();
+ //dispatchCondition_.notify_one();
}
}
@@ -169,6 +172,7 @@ class VerificationMainLoop {
void prepare(const int64_t& timeout = TIMEOUT_INFINITE) {
currentMinimalTimeoutInterval_ = timeout;
+ registeredDispatchSourcesMutex_.lock();
for (auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
@@ -180,9 +184,11 @@ class VerificationMainLoop {
currentMinimalTimeoutInterval_ = dispatchTimeout;
}
}
+ registeredDispatchSourcesMutex_.unlock();
int64_t currentContextTime = getCurrentTimeInMs();
+ registeredTimeoutsMutex_.lock();
for (auto timeoutPriorityRange = registeredTimeouts_.begin();
timeoutPriorityRange != registeredTimeouts_.end();
timeoutPriorityRange++) {
@@ -196,99 +202,106 @@ class VerificationMainLoop {
currentMinimalTimeoutInterval_ = intervalToReady;
}
}
+ registeredTimeoutsMutex_.unlock();
}
- void poll() {
+ void poll() {
#ifdef WIN32
- int managedFileDescriptorOffset = 0;
+ int managedFileDescriptorOffset = 0;
#else
- int managedFileDescriptorOffset = 1;
+ int managedFileDescriptorOffset = 1;
#endif
- for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
- (*fileDescriptor).revents = 0;
- }
+ for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
+ (*fileDescriptor).revents = 0;
+ }
#ifdef WIN32
- size_t numReadyFileDescriptors = 0;
-
- int errorCode = WSAWaitForMultipleEvents(wsaEvents_.size(), wsaEvents_.data(), FALSE, currentMinimalTimeoutInterval_, FALSE);
-
- if (errorCode == WSA_WAIT_IO_COMPLETION) {
- printf("WSAWaitForMultipleEvents failed with error: WSA_WAIT_IO_COMPLETION");
- }
- else if (errorCode == WSA_WAIT_FAILED) {
- printf("WSAWaitForMultipleEvents failed with error: %ld\n", WSAGetLastError());
- }
- else {
- for (uint32_t i = 0; i < managedFileDescriptors_.size(); i++) {
- if (WaitForSingleObjectEx(wsaEvents_[i + 1], 0, true) != WAIT_TIMEOUT) {
- numReadyFileDescriptors++;
- managedFileDescriptors_[i].revents = POLLIN;
- }
- }
- }
-#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"
- // expired before any other timeouts.
- if (!numReadyFileDescriptors) {
- int64_t currentContextTime = getCurrentTimeInMs();
+ size_t numReadyFileDescriptors = 0;
- for (auto timeoutPriorityRange = registeredTimeouts_.begin();
- timeoutPriorityRange != registeredTimeouts_.end();
- timeoutPriorityRange++) {
+ int errorCode = WSAWaitForMultipleEvents(wsaEvents_.size(), wsaEvents_.data(), FALSE, currentMinimalTimeoutInterval_, FALSE);
- int64_t intervalToReady = timeoutPriorityRange->second->getReadyTime() - currentContextTime;
-
- if (intervalToReady <= 0) {
- timeoutsToDispatch_.insert(*timeoutPriorityRange);
- }
- }
- }
+ if (errorCode == WSA_WAIT_IO_COMPLETION) {
+ printf("WSAWaitForMultipleEvents failed with error: WSA_WAIT_IO_COMPLETION");
+ }
+ else if (errorCode == WSA_WAIT_FAILED) {
+ printf("WSAWaitForMultipleEvents failed with error: %ld\n", WSAGetLastError());
+ }
+ else {
+ for (uint32_t i = 0; i < managedFileDescriptors_.size(); i++) {
+ if (WaitForSingleObjectEx(wsaEvents_[i + 1], 0, true) != WAIT_TIMEOUT) {
+ numReadyFileDescriptors++;
+ managedFileDescriptors_[i].revents = POLLIN;
+ }
+ }
+ }
+#else
+ size_t numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), int(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"
+ // expired before any other timeouts.
+ if (!numReadyFileDescriptors) {
+ int64_t currentContextTime = getCurrentTimeInMs();
+
+ registeredTimeoutsMutex_.lock();
+ for (auto timeoutPriorityRange = registeredTimeouts_.begin();
+ timeoutPriorityRange != registeredTimeouts_.end();
+ timeoutPriorityRange++) {
+
+ int64_t intervalToReady = timeoutPriorityRange->second->getReadyTime() - currentContextTime;
+
+ if (intervalToReady <= 0) {
+ timeoutsToDispatch_.insert(*timeoutPriorityRange);
+ }
+ }
+ registeredTimeoutsMutex_.unlock();
+ }
#ifdef WIN32
- acknowledgeWakeup();
+ acknowledgeWakeup();
#else
- if (wakeFd_.revents) {
- acknowledgeWakeup();
- }
+ if (wakeFd_.revents) {
+ acknowledgeWakeup();
+ }
#endif
}
bool check() {
//The first file descriptor always is the loop's wakeup-descriptor (but not for windows anymore). All others need to be linked to a watch.
#ifdef WIN32
- int managedFileDescriptorOffset = 0;
+ int managedFileDescriptorOffset = 0;
#else
- int managedFileDescriptorOffset = 1;
+ int managedFileDescriptorOffset = 1;
#endif
- for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
+ registeredWatchesMutex_.lock();
+ for (auto fileDescriptor = managedFileDescriptors_.begin() + managedFileDescriptorOffset; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) {
for (auto registeredWatchIterator = registeredWatches_.begin();
registeredWatchIterator != registeredWatches_.end();
registeredWatchIterator++) {
const auto& correspondingWatchPriority = registeredWatchIterator->first;
const auto& correspondingWatchPair = registeredWatchIterator->second;
- if (std::get<0>(correspondingWatchPair) == fileDescriptor->fd && fileDescriptor->revents) {
- watchesToDispatch_.insert({ correspondingWatchPriority, { std::get<1>(correspondingWatchPair) } });
- }
+ if (std::get<0>(correspondingWatchPair) == fileDescriptor->fd && fileDescriptor->revents) {
+ watchesToDispatch_.insert({ correspondingWatchPriority, { std::get<1>(correspondingWatchPair) } });
+ }
}
}
+ registeredWatchesMutex_.unlock();
+ registeredDispatchSourcesMutex_.lock();
for(auto dispatchSourceIterator = registeredDispatchSources_.begin(); dispatchSourceIterator != registeredDispatchSources_.end(); ++dispatchSourceIterator) {
if((std::get<1>(*dispatchSourceIterator))->check()) {
sourcesToDispatch_.insert( {std::get<0>(*dispatchSourceIterator), std::get<1>(*dispatchSourceIterator)});
}
}
+ registeredDispatchSourcesMutex_.unlock();
return !timeoutsToDispatch_.empty() || !watchesToDispatch_.empty() || !sourcesToDispatch_.empty();
}
void dispatch() {
- eventQueue_->pushToQueue(std::bind(&VerificationMainLoop::doExternalIteration, this));
+ eventQueue_->pushToQueue(std::bind(&VerificationMainLoop::doExternalIteration, this));
}
void doExternalIteration()
@@ -322,14 +335,16 @@ class VerificationMainLoop {
void wakeup() {
#ifdef WIN32
- if (!WSASetEvent(wsaEvents_[0]))
- {
- printf("SetEvent failed (%d)\n", GetLastError());
- return;
- }
+ if (!WSASetEvent(wsaEvents_[0]))
+ {
+ printf("SetEvent failed (%d)\n", GetLastError());
+ return;
+ }
#else
int64_t wake = 1;
- ::write(wakeFd_.fd, &wake, sizeof(int64_t));
+ if(::write(wakeFd_.fd, &wake, sizeof(int64_t)) == -1) {
+ std::perror("VerificationMainLoop::wakeup");
+ }
#endif
}
@@ -348,28 +363,31 @@ class VerificationMainLoop {
}
#ifdef WIN32
- void registerEvent(
- const HANDLE& wsaEvent) {
- wsaEvents_.push_back(wsaEvent);
- }
-
- void unregisterEvent(
- const HANDLE& wsaEvent) {
- for (auto it = wsaEvents_.begin();
- it != wsaEvents_.end(); it++) {
- if ((*it) == wsaEvent) {
- wsaEvents_.erase(it);
- break;
- }
- }
- }
+ void registerEvent(
+ const HANDLE& wsaEvent) {
+ wsaEvents_.push_back(wsaEvent);
+ }
+
+ void unregisterEvent(
+ const HANDLE& wsaEvent) {
+ for (auto it = wsaEvents_.begin();
+ it != wsaEvents_.end(); it++) {
+ if ((*it) == wsaEvent) {
+ wsaEvents_.erase(it);
+ break;
+ }
+ }
+ }
#endif
void registerDispatchSource(DispatchSource* dispatchSource, const DispatchPriority dispatchPriority) {
+ registeredDispatchSourcesMutex_.lock();
registeredDispatchSources_.insert( {dispatchPriority, dispatchSource} );
+ registeredDispatchSourcesMutex_.unlock();
}
void deregisterDispatchSource(DispatchSource* dispatchSource) {
+ registeredDispatchSourcesMutex_.lock();
for(auto dispatchSourceIterator = registeredDispatchSources_.begin();
dispatchSourceIterator != registeredDispatchSources_.end();
dispatchSourceIterator++) {
@@ -379,6 +397,7 @@ class VerificationMainLoop {
break;
}
}
+ registeredDispatchSourcesMutex_.unlock();
breakLoop_ = true;
}
@@ -387,19 +406,21 @@ class VerificationMainLoop {
registerFileDescriptor(fdToRegister);
#ifdef WIN32
- registerEvent(watch->getAssociatedEvent());
+ registerEvent(watch->getAssociatedEvent());
#endif
-
+ registeredWatchesMutex_.lock();
registeredWatches_.insert( {dispatchPriority, {watch->getAssociatedFileDescriptor().fd, watch}});
+ registeredWatchesMutex_.unlock();
}
void deregisterWatch(Watch* watch) {
deregisterFileDescriptor(watch->getAssociatedFileDescriptor());
#ifdef WIN32
- unregisterEvent(watch->getAssociatedEvent());
+ unregisterEvent(watch->getAssociatedEvent());
#endif
+ registeredWatchesMutex_.lock();
for(auto watchIterator = registeredWatches_.begin();
watchIterator != registeredWatches_.end();
watchIterator++) {
@@ -409,13 +430,17 @@ class VerificationMainLoop {
break;
}
}
+ registeredWatchesMutex_.unlock();
}
void registerTimeout(Timeout* timeout, const DispatchPriority dispatchPriority) {
+ registeredTimeoutsMutex_.lock();
registeredTimeouts_.insert( {dispatchPriority, timeout} );
+ registeredTimeoutsMutex_.unlock();
}
void deregisterTimeout(Timeout* timeout) {
+ registeredTimeoutsMutex_.lock();
for(auto timeoutIterator = registeredTimeouts_.begin();
timeoutIterator != registeredTimeouts_.end();
timeoutIterator++) {
@@ -425,17 +450,18 @@ class VerificationMainLoop {
break;
}
}
+ registeredTimeoutsMutex_.unlock();
}
void acknowledgeWakeup() {
#ifdef WIN32
- for (unsigned int i = 0; i < wsaEvents_.size(); i++) {
- if (!WSAResetEvent(wsaEvents_[i]))
- {
- printf("ResetEvent failed (%d)\n", GetLastError());
- return;
- }
- }
+ for (unsigned int i = 0; i < wsaEvents_.size(); i++) {
+ if (!WSAResetEvent(wsaEvents_[i]))
+ {
+ printf("ResetEvent failed (%d)\n", GetLastError());
+ return;
+ }
+ }
#else
int64_t buffer;
while (::read(wakeFd_.fd, &buffer, sizeof(int64_t)) == sizeof(buffer))
@@ -465,13 +491,17 @@ class VerificationMainLoop {
bool breakLoop_;
bool running_;
+ std::mutex registeredDispatchSourcesMutex_;
+ std::mutex registeredWatchesMutex_;
+ std::mutex registeredTimeoutsMutex_;
+
#ifdef WIN32
- std::vector<HANDLE> wsaEvents_;
+ std::vector<HANDLE> wsaEvents_;
#else
DemoMainLoopPollFd wakeFd_;
#endif
- std::shared_ptr<VerificationMainLoopEventQueue> eventQueue_;
+ std::shared_ptr<VerificationMainLoopEventQueue> eventQueue_;
};
diff --git a/org.genivi.commonapi.core/META-INF/MANIFEST.MF b/org.genivi.commonapi.core/META-INF/MANIFEST.MF
index 8516801..367178f 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.3.qualifier
+Bundle-Version: 3.1.4.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 65e038c..454bdc0 100644..100755
--- a/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl
+++ b/org.genivi.commonapi.core/deployment/CommonAPI_deployment_spec.fdepl
@@ -17,7 +17,7 @@ specification org.genivi.commonapi.core.deployment {
/*
* define the enumeration backing type on CommonAPI C++ level for whole interface.
*/
- DefaultEnumBackingType : {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (default: UInt32);
+ DefaultEnumBackingType : {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (default: Int32);
}
for providers {
@@ -25,6 +25,12 @@ specification org.genivi.commonapi.core.deployment {
* Enumerate all service instances this provider depends on (if any).
*/
ClientInstanceReferences : Instance[] (optional);
+
+ /*
+ * Define the project name where this provider is located.
+ * This setting is used to determine which artifacts need to be generated by a code generator for a specific development project.
+ */
+ Project : String (optional);
}
for instances {
@@ -77,5 +83,13 @@ specification org.genivi.commonapi.core.deployment {
* If not specified use "ApiDefaultEnumBackingType".
*/
EnumBackingType : {UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64} (optional);
+
+ /*
+ * Enumerations may be used as error parameters in Franca / CommonAPI.
+ * In this case ErrorType may be used to specify the severity of each enumerator for use in
+ * trace analysis or viewer tools, e.g. to use different colors to highlight traces.
+ */
+ ErrorType : { Error, Warning, Info, NoError } (default:Error);
}
+
} \ No newline at end of file
diff --git a/org.genivi.commonapi.core/pom.xml b/org.genivi.commonapi.core/pom.xml
index 0ee58d6..2a7b647 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.3-SNAPSHOT</version>
+ <version>3.1.4-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 27876b0..30c8306 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
@@ -86,5 +86,25 @@ public class DeploymentInterfacePropertyAccessor
return null;
}
+ public enum ErrorType {
+ Error, Warning, Info, NoError
+ }
+ public ErrorType getErrorType (FEnumerationType obj) {
+ String e = target.getEnum(obj, "ErrorType");
+ if (e==null) return null;
+ return convertErrorType(e);
+ }
+ private ErrorType convertErrorType (String val) {
+ if (val.equals("Error"))
+ return ErrorType.Error; else
+ if (val.equals("Warning"))
+ return ErrorType.Warning; else
+ if (val.equals("Info"))
+ return ErrorType.Info; else
+ if (val.equals("NoError"))
+ return ErrorType.NoError;
+ return null;
+ }
+
}
diff --git a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentProviderPropertyAccessor.java b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentProviderPropertyAccessor.java
index bb88250..44e1270 100644
--- a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentProviderPropertyAccessor.java
+++ b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentProviderPropertyAccessor.java
@@ -5,10 +5,11 @@
package org.genivi.commonapi.core;
import java.util.List;
+
import org.franca.core.franca.FInterface;
-import org.franca.deploymodel.dsl.fDeploy.FDProvider;
-import org.franca.deploymodel.dsl.fDeploy.FDInterfaceInstance;
import org.franca.deploymodel.core.FDeployedProvider;
+import org.franca.deploymodel.dsl.fDeploy.FDInterfaceInstance;
+import org.franca.deploymodel.dsl.fDeploy.FDProvider;
/**
* Accessor for deployment properties for 'org.genivi.commonapi.core.deployment' specification
@@ -26,6 +27,10 @@ public class DeploymentProviderPropertyAccessor
return target.getInterfaceArray(obj, "ClientInstanceReferences");
}
+ public String getProject (FDProvider obj) {
+ return target.getString(obj, "Project");
+ }
+
public String getDomain (FDInterfaceInstance obj) {
return target.getString(obj, "Domain");
}
diff --git a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentTypeCollectionPropertyAccessor.java b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentTypeCollectionPropertyAccessor.java
index c61328f..4fccdc3 100644
--- a/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentTypeCollectionPropertyAccessor.java
+++ b/org.genivi.commonapi.core/src-gen/org/genivi/commonapi/core/DeploymentTypeCollectionPropertyAccessor.java
@@ -76,5 +76,25 @@ public class DeploymentTypeCollectionPropertyAccessor
return null;
}
+ public enum ErrorType {
+ Error, Warning, Info, NoError
+ }
+ public ErrorType getErrorType (FEnumerationType obj) {
+ String e = target.getEnum(obj, "ErrorType");
+ if (e==null) return null;
+ return convertErrorType(e);
+ }
+ private ErrorType convertErrorType (String val) {
+ if (val.equals("Error"))
+ return ErrorType.Error; else
+ if (val.equals("Warning"))
+ return ErrorType.Warning; else
+ if (val.equals("Info"))
+ return ErrorType.Info; else
+ if (val.equals("NoError"))
+ return ErrorType.NoError;
+ return null;
+ }
+
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/PropertyAccessor.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/PropertyAccessor.java
index 734292b..be17c01 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/PropertyAccessor.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/deployment/PropertyAccessor.java
@@ -14,7 +14,10 @@ import org.franca.deploymodel.core.FDeployedInterface;
import org.franca.deploymodel.core.FDeployedProvider;
import org.franca.deploymodel.core.FDeployedTypeCollection;
import org.franca.deploymodel.dsl.fDeploy.FDInterfaceInstance;
+import org.franca.deploymodel.dsl.fDeploy.FDProperty;
import org.franca.deploymodel.dsl.fDeploy.FDProvider;
+import org.franca.deploymodel.dsl.fDeploy.FDString;
+import org.franca.deploymodel.dsl.fDeploy.FDValue;
import org.genivi.commonapi.core.DeploymentInterfacePropertyAccessor;
import org.genivi.commonapi.core.DeploymentProviderPropertyAccessor;
import org.genivi.commonapi.core.DeploymentTypeCollectionPropertyAccessor;
@@ -94,7 +97,7 @@ public class PropertyAccessor {
case PROVIDER:
case NONE:
default:
- return EnumBackingType.Int32;
+ return EnumBackingType.UseDefault;
}
}
catch (java.lang.NullPointerException e) {}
@@ -134,6 +137,16 @@ public class PropertyAccessor {
return provider_.getInstanceId(obj);
}
catch (java.lang.NullPointerException e) {}
+ // Access the model directly, without accessor
+ for(FDProperty property : obj.getProperties()) {
+ if(property.eContainer() instanceof FDInterfaceInstance) {
+ FDValue fdVal = property.getValue().getSingle();
+ if(fdVal instanceof FDString) {
+ String value = ((FDString) fdVal).getValue();
+ return value;
+ }
+ }
+ }
return null;
}
@@ -162,9 +175,9 @@ public class PropertyAccessor {
case UInt16:
return DefaultEnumBackingType.UInt16;
case UInt32:
- return DefaultEnumBackingType.UInt8;
+ return DefaultEnumBackingType.UInt32;
case UInt64:
- return DefaultEnumBackingType.UInt8;
+ return DefaultEnumBackingType.UInt64;
case Int8:
return DefaultEnumBackingType.Int8;
case Int16:
@@ -185,9 +198,9 @@ public class PropertyAccessor {
case UInt16:
return EnumBackingType.UInt16;
case UInt32:
- return EnumBackingType.UInt8;
+ return EnumBackingType.UInt32;
case UInt64:
- return EnumBackingType.UInt8;
+ return EnumBackingType.UInt64;
case Int8:
return EnumBackingType.Int8;
case Int16:
@@ -209,9 +222,9 @@ public class PropertyAccessor {
case UInt16:
return DefaultEnumBackingType.UInt16;
case UInt32:
- return DefaultEnumBackingType.UInt8;
+ return DefaultEnumBackingType.UInt32;
case UInt64:
- return DefaultEnumBackingType.UInt8;
+ return DefaultEnumBackingType.UInt64;
case Int8:
return DefaultEnumBackingType.Int8;
case Int16:
@@ -235,9 +248,9 @@ public class PropertyAccessor {
case UInt16:
return EnumBackingType.UInt16;
case UInt32:
- return EnumBackingType.UInt8;
+ return EnumBackingType.UInt32;
case UInt64:
- return EnumBackingType.UInt8;
+ return EnumBackingType.UInt64;
case Int8:
return EnumBackingType.Int8;
case Int16:
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java
index 4d18675..91417f5 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FDeployManager.java
@@ -61,24 +61,20 @@ public class FDeployManager {
* @return the root model or null in case of an error.
*/
public EObject loadModel(URI uri, URI root) {
-
// Check if this file is already loaded
- if(deploymentModels.keySet().contains(uri.toString())) {
- //System.out.println("aborting: " + uri.toString() + " root: " + root.toString());
- return null;
- }
- if(fidlModels.keySet().contains(uri.toString())) {
- //System.out.println("aborting: " + uri.toString() + " root: " + root.toString());
+ if(deploymentModels.keySet().contains(uri.toString())
+ || fidlModels.keySet().contains(uri.toString())) {
return null;
}
- // resolve the input uri, in case it is a relative path
URI absURI = uri.resolve(root);
+
if (!uri.equals(absURI)) {
// add this pair to URI converter so that others can get the URI by
// its relative path
resourceSet.getURIConverter().getURIMap().put(uri, absURI);
}
+
// load root model
Resource resource = null;
try {
@@ -87,13 +83,13 @@ public class FDeployManager {
// fdepl/fidl files
resource.unload();
resource.load(Collections.EMPTY_MAP);
- //System.out.println("loaded: " + resource.toString() + " root: " + root.toString());
} catch (Exception e) {
// Don't show an error message here, because code may be generated
// from an included fidl file.
- //System.err.println("Failed to load model from : " + absURI);
+ // System.err.println("Failed to load model from : " + absURI + "(" + e.getMessage() +")");
return null;
}
+
EObject model = resource.getContents().get(0);
// load all its imports recursively
@@ -108,7 +104,6 @@ public class FDeployManager {
resourceSet.getURIConverter().getURIMap()
.put(importURI, resolvedURI);
String uriName = resolvedURI.toString();
- //System.out.println("Load model from import " + uriName);
EObject importModel = loadModel(resolvedURI, root);
if (importModel != null) {
if(importModel instanceof FDModel && !(uriName.contains("_spec"))) {
@@ -159,7 +154,7 @@ public class FDeployManager {
}
return null;
}
-
+
public Map<String, FDModel> getDeploymentModels() {
return deploymentModels;
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
index a0b301c..7fa63a7 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FInterfaceGenerator.xtend
@@ -15,6 +15,9 @@ import org.franca.core.franca.FInterface
import org.franca.core.franca.FMethod
import org.franca.core.franca.FVersion
import org.genivi.commonapi.core.deployment.PropertyAccessor
+import org.genivi.commonapi.core.preferences.FPreferences
+import org.genivi.commonapi.core.preferences.PreferenceConstants
+import java.util.List
class FInterfaceGenerator {
@Inject private extension FTypeGenerator
@@ -22,14 +25,54 @@ class FInterfaceGenerator {
@Inject private extension FrancaGeneratorExtensions
def generateInterface(FInterface fInterface, IFileSystemAccess fileSystemAccess, PropertyAccessor deploymentAccessor, IResource modelid) {
- fileSystemAccess.generateFile(fInterface.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, fInterface.generateHeader(modelid, deploymentAccessor))
+
+ if(FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_CODE, "true").equals("true")) {
+ fileSystemAccess.generateFile(fInterface.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, fInterface.generateHeader(modelid, deploymentAccessor))
+ if (fInterface.hasSourceFile)
+ fileSystemAccess.generateFile(fInterface.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, fInterface.generateSource(modelid, deploymentAccessor))
+ }
+ else {
+ // feature: suppress code generation
+ fileSystemAccess.generateFile(fInterface.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, PreferenceConstants::NO_CODE)
+ if (fInterface.hasSourceFile)
+ fileSystemAccess.generateFile(fInterface.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, PreferenceConstants::NO_CODE)
+ }
+ }
- if (fInterface.hasSourceFile)
- fileSystemAccess.generateFile(fInterface.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, fInterface.generateSource(modelid, deploymentAccessor))
+ def generateInstanceIds(FInterface fInterface, IFileSystemAccess fileSystemAccess, List<String> deployedInstances) {
+ if(FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_CODE, "true").equals("true")) {
+ fileSystemAccess.generateFile(fInterface.instanceHeaderPath, IFileSystemAccess.DEFAULT_OUTPUT, fInterface.generateInstanceHeader(deployedInstances))
+ }
}
+ def generateInstanceHeader(FInterface fInterface, List<String> deployedInstances) '''
+ «generateCommonApiLicenseHeader()»
+ «FTypeGenerator::generateComments(fInterface, false)»
+ #ifndef «fInterface.defineName.toUpperCase»_INSTANCE_HPP_
+ #define «fInterface.defineName.toUpperCase»_INSTANCE_HPP_
+
+ «fInterface.generateVersionNamespaceBegin»
+ «fInterface.model.generateNamespaceBeginDeclaration»
+
+ «FOR instanceId : deployedInstances»
+ const std::string «fInterface.elementName»_«instanceId» = "«instanceId»";
+ «ENDFOR»
+
+ const std::string «fInterface.elementName»_INSTANCES[] = {
+ «FOR instanceId : deployedInstances»
+ «fInterface.elementName»_«instanceId»«IF instanceId != deployedInstances.last»,«ENDIF»
+ «ENDFOR»
+ };
+
+ «fInterface.model.generateNamespaceEndDeclaration»
+ «fInterface.generateVersionNamespaceEnd»
+ «fInterface.generateMajorVersionNamespace»
+
+ #endif // «fInterface.defineName.toUpperCase»_INSTANCE_HPP_
+ '''
+
def private generateHeader(FInterface fInterface, IResource modelid, PropertyAccessor deploymentAccessor) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#ifndef «fInterface.defineName.toUpperCase»_HPP_
#define «fInterface.defineName.toUpperCase»_HPP_
@@ -94,13 +137,15 @@ class FInterfaceGenerator {
«fInterface.generateVariantComparators»
}
+ «fInterface.generateMajorVersionNamespace»
+
#endif // «fInterface.defineName.toUpperCase»_HPP_
'''
def private generateSource(FInterface fInterface, IResource modelid, PropertyAccessor _accessor) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#include "«fInterface.headerFile»"
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 b34b061..397522d 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
@@ -16,18 +16,30 @@ import org.franca.core.franca.FInterface
import org.franca.core.franca.FMethod
import org.genivi.commonapi.core.deployment.PropertyAccessor
import org.genivi.commonapi.core.preferences.PreferenceConstants
+import org.genivi.commonapi.core.preferences.FPreferences
class FInterfaceProxyGenerator {
@Inject private extension FTypeGenerator
@Inject private extension FrancaGeneratorExtensions
+ var boolean generateSyncCalls = true
+
def generateProxy(FInterface fInterface, IFileSystemAccess fileSystemAccess, PropertyAccessor deploymentAccessor, IResource modelid) {
- fileSystemAccess.generateFile(fInterface.proxyBaseHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, fInterface.generateProxyBaseHeader(deploymentAccessor, modelid))
- fileSystemAccess.generateFile(fInterface.proxyHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, fInterface.generateProxyHeader(modelid))
+ val String generateCode = FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_CODE, "true")
+ if(generateCode.equals("true")) {
+ generateSyncCalls = FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_SYNC_CALLS, "true").equals("true")
+ fileSystemAccess.generateFile(fInterface.proxyBaseHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, fInterface.generateProxyBaseHeader(deploymentAccessor, modelid))
+ fileSystemAccess.generateFile(fInterface.proxyHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, fInterface.generateProxyHeader(modelid))
+ }
+ else {
+ // feature: suppress code generation
+ fileSystemAccess.generateFile(fInterface.proxyBaseHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, PreferenceConstants::NO_CODE)
+ fileSystemAccess.generateFile(fInterface.proxyHeaderPath, PreferenceConstants.P_OUTPUT_PROXIES, PreferenceConstants::NO_CODE)
+ }
}
def private generateProxyBaseHeader(FInterface fInterface, PropertyAccessor deploymentAccessor, IResource modelid) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#ifndef «fInterface.defineName»_PROXY_BASE_HPP_
#define «fInterface.defineName»_PROXY_BASE_HPP_
@@ -106,12 +118,14 @@ class FInterfaceProxyGenerator {
«FOR method : fInterface.methods»
«FTypeGenerator::generateComments(method, false)»
+ «IF generateSyncCalls»
«IF method.isFireAndForget»
/**
* @invariant Fire And Forget
*/
«ENDIF»
virtual «method.generateDefinition(true)» = 0;
+ «ENDIF»
«IF !method.isFireAndForget»
virtual «method.generateAsyncDefinition(true)» = 0;
«ENDIF»
@@ -124,11 +138,13 @@ class FInterfaceProxyGenerator {
«fInterface.model.generateNamespaceEndDeclaration»
«fInterface.generateVersionNamespaceEnd»
+ «fInterface.generateMajorVersionNamespace»
+
#endif // «fInterface.defineName»_PROXY_BASE_HPP_
'''
def private generateProxyHeader(FInterface fInterface, IResource modelid) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#ifndef «fInterface.defineName»_PROXY_HPP_
#define «fInterface.defineName»_PROXY_HPP_
@@ -192,6 +208,7 @@ class FInterfaceProxyGenerator {
«ENDFOR»
«FOR method : fInterface.methods»
+ «IF generateSyncCalls»
/**
«FTypeGenerator::generateComments(method, true)»
* Calls «method.elementName» with «IF method.isFireAndForget»Fire&Forget«ELSE»synchronous«ENDIF» semantics.
@@ -203,6 +220,7 @@ class FInterfaceProxyGenerator {
* will be set.
*/
virtual «method.generateDefinition(true)»;
+ «ENDIF»
«IF !method.isFireAndForget»
/**
* Calls «method.elementName» with asynchronous semantics.
@@ -282,14 +300,36 @@ class FInterfaceProxyGenerator {
«FOR method : fInterface.methods»
«FTypeGenerator::generateComments(method, false)»
+ «IF generateSyncCalls»
template <typename ... _AttributeExtensions>
«method.generateDefinitionWithin(fInterface.proxyClassName + '<_AttributeExtensions...>', false)» {
+ «FOR arg : method.inArgs»
+ «IF arg.getType.supportsValidation»
+ if (!_«arg.elementName».validate()) {
+ _internalCallStatus = CommonAPI::CallStatus::INVALID_VALUE;
+ return;
+ }
+ «ENDIF»
+ «ENDFOR»
delegate_->«method.elementName»(«method.generateSyncVariableList»);
}
+ «ENDIF»
«IF !method.isFireAndForget»
template <typename ... _AttributeExtensions>
«method.generateAsyncDefinitionWithin(fInterface.proxyClassName + '<_AttributeExtensions...>', false)» {
+ «FOR arg : method.inArgs»
+ «IF arg.getType.supportsValidation»
+ if (!_«arg.elementName».validate()) {
+ «method.generateDummyArgumentDefinitions»
+ «val callbackArguments = method.generateDummyArgumentList»
+ _callback(CommonAPI::CallStatus::INVALID_VALUE«IF callbackArguments != ""», «callbackArguments»«ENDIF»);
+ std::promise<CommonAPI::CallStatus> promise;
+ promise.set_value(CommonAPI::CallStatus::INVALID_VALUE);
+ return promise.get_future();
+ }
+ «ENDIF»
+ «ENDFOR»
return delegate_->«method.elementName»Async(«method.generateASyncVariableList»);
}
«ENDIF»
@@ -342,6 +382,8 @@ class FInterfaceProxyGenerator {
}
«ENDIF»
+ «fInterface.generateMajorVersionNamespace»
+
#endif // «fInterface.defineName»_PROXY_HPP_
'''
@@ -439,6 +481,10 @@ class FInterfaceProxyGenerator {
def private generateASyncVariableList(FMethod fMethod) {
var asyncVariableList = new ArrayList(fMethod.inArgs.map['_' + elementName])
asyncVariableList.add('_callback')
- return asyncVariableList.join(', ') + ", _info"
+ if (fMethod.isFireAndForget) {
+ return asyncVariableList.join(', ')
+ } else {
+ return asyncVariableList.join(', ') + ", _info"
+ }
}
}
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 7bf06ed..14e414a 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
@@ -17,6 +17,7 @@ import org.genivi.commonapi.core.preferences.PreferenceConstants
import org.genivi.commonapi.core.preferences.FPreferences
import java.util.HashMap
import org.franca.core.franca.FMethod
+import org.franca.core.franca.FEnumerationType
class FInterfaceStubGenerator {
@Inject private extension FTypeGenerator
@@ -27,17 +28,30 @@ class FInterfaceStubGenerator {
def generateStub(FInterface fInterface, IFileSystemAccess fileSystemAccess, IResource modelid) {
- fileSystemAccess.generateFile(fInterface.stubHeaderPath, PreferenceConstants.P_OUTPUT_STUBS, fInterface.generateStubHeader(modelid))
- // should skeleton code be generated ?
- if(FPreferences::instance.getPreference(PreferenceConstants::P_GENERATESKELETON, "false").equals("true"))
- {
- fileSystemAccess.generateFile(fInterface.stubDefaultHeaderPath, PreferenceConstants.P_OUTPUT_SKELETON, fInterface.generateStubDefaultHeader(modelid))
- fileSystemAccess.generateFile(fInterface.stubDefaultSourcePath, PreferenceConstants.P_OUTPUT_SKELETON, fInterface.generateStubDefaultSource(modelid))
- }
+
+ if(FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_CODE, "true").equals("true")) {
+ fileSystemAccess.generateFile(fInterface.stubHeaderPath, PreferenceConstants.P_OUTPUT_STUBS, fInterface.generateStubHeader(modelid))
+ // should skeleton code be generated ?
+ if(FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_SKELETON, "false").equals("true"))
+ {
+ fileSystemAccess.generateFile(fInterface.stubDefaultHeaderPath, PreferenceConstants.P_OUTPUT_SKELETON, fInterface.generateStubDefaultHeader(modelid))
+ fileSystemAccess.generateFile(fInterface.stubDefaultSourcePath, PreferenceConstants.P_OUTPUT_SKELETON, fInterface.generateStubDefaultSource(modelid))
+ }
+ }
+ else {
+ // feature: suppress code generation
+ fileSystemAccess.generateFile(fInterface.stubHeaderPath, PreferenceConstants.P_OUTPUT_STUBS, PreferenceConstants::NO_CODE)
+ // should skeleton code be generated ?
+ if(FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_SKELETON, "false").equals("true"))
+ {
+ fileSystemAccess.generateFile(fInterface.stubDefaultHeaderPath, PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants::NO_CODE)
+ fileSystemAccess.generateFile(fInterface.stubDefaultSourcePath, PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants::NO_CODE)
+ }
+ }
}
def private generateStubHeader(FInterface fInterface, IResource modelid) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#ifndef «fInterface.defineName»_STUB_HPP_
#define «fInterface.defineName»_STUB_HPP_
@@ -79,8 +93,8 @@ class FInterfaceStubGenerator {
* An application developer should not need to bother with this class.
*/
class «fInterface.stubAdapterClassName»
- : virtual public CommonAPI::StubAdapter,
- public «fInterface.elementName»«IF fInterface.base != null»,
+ : public virtual CommonAPI::StubAdapter,
+ public virtual «fInterface.elementName»«IF fInterface.base != null»,
public virtual «fInterface.base.getTypeCollectionName(fInterface)»StubAdapter«ENDIF» {
public:
«FOR attribute : fInterface.attributes»
@@ -152,7 +166,7 @@ class FInterfaceStubGenerator {
«FOR attribute : fInterface.attributes»
«IF !attribute.readonly»
/// Verification callback for remote set requests on the attribute «attribute.elementName»
- virtual bool «attribute.stubRemoteEventClassSetMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client, «attribute.getTypeName(fInterface, true)» «attribute.elementName») = 0;
+ virtual bool «attribute.stubRemoteEventClassSetMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client, «attribute.getTypeName(fInterface, true)» _value) = 0;
/// Action callback for remote set requests on the attribute «attribute.elementName»
virtual void «attribute.stubRemoteEventClassChangedMethodName»() = 0;
«ENDIF»
@@ -228,6 +242,8 @@ class FInterfaceStubGenerator {
«fInterface.model.generateNamespaceEndDeclaration»
«fInterface.generateVersionNamespaceEnd»
+ «fInterface.generateMajorVersionNamespace»
+
#endif // «fInterface.defineName»_STUB_HPP_
'''
@@ -243,7 +259,7 @@ class FInterfaceStubGenerator {
def private generateStubDefaultHeader(FInterface fInterface, IResource modelid) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fInterface, false)»
#ifndef «getHeaderDefineName(fInterface)»_HPP_
#define «getHeaderDefineName(fInterface)»_HPP_
@@ -350,7 +366,7 @@ class FInterfaceStubGenerator {
«FOR attribute : fInterface.attributes»
«FTypeGenerator::generateComments(attribute, false)»
- «attribute.getTypeName(fInterface, true)» «attribute.stubDefaultClassVariableName»;
+ «attribute.getTypeName(fInterface, true)» «attribute.stubDefaultClassVariableName» {};
«ENDFOR»
CommonAPI::Version interfaceVersion_;
@@ -359,11 +375,13 @@ class FInterfaceStubGenerator {
«fInterface.model.generateNamespaceEndDeclaration»
«fInterface.generateVersionNamespaceEnd»
+ «fInterface.generateMajorVersionNamespace»
+
#endif // «getHeaderDefineName(fInterface)»
'''
def private generateStubDefaultSource(FInterface fInterface, IResource modelid) '''
- «generateCommonApiLicenseHeader(fInterface, modelid)»
+ «generateCommonApiLicenseHeader()»
#include <«fInterface.stubDefaultHeaderPath»>
#include <assert.h>
@@ -375,10 +393,16 @@ class FInterfaceStubGenerator {
«IF !fInterface.managedInterfaces.empty»
autoInstanceCounter_(0),
«ENDIF»
+ «FOR attribute : fInterface.attributes»
+ «IF attribute.supportsInitialValue»
+ «attribute.stubDefaultClassVariableName»(«attribute.initialValue(fInterface)»),
+ «ENDIF»
+ «ENDFOR»
interfaceVersion_(«fInterface.elementName»::getInterfaceVersion()) {
}
const CommonAPI::Version& «fInterface.stubDefaultClassName»::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> _client) {
+ (void)_client;
return interfaceVersion_;
}
@@ -395,15 +419,18 @@ class FInterfaceStubGenerator {
}
const «typeName»& «fInterface.stubDefaultClassName»::«attribute.stubClassGetMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client) {
+ (void)_client;
return «attribute.stubClassGetMethodName»();
}
void «fInterface.stubDefaultClassName»::«attribute.stubDefaultClassSetMethodName»(«typeName» _value) {
«IF attribute.isObservable»const bool valueChanged = «ENDIF»«attribute.stubDefaultClassTrySetMethodName»(std::move(_value));
«IF attribute.isObservable»
- if (valueChanged && «fInterface.stubCommonAPIClassName»::stubAdapter_ != NULL) {
- «fInterface.stubCommonAPIClassName»::stubAdapter_->«attribute.stubAdapterClassFireChangedMethodName»(«attribute.stubDefaultClassVariableName»);
- }
+ if (valueChanged) {
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ stubAdapter->«attribute.stubAdapterClassFireChangedMethodName»(«attribute.stubDefaultClassVariableName»);
+ }
«ENDIF»
}
@@ -417,11 +444,17 @@ class FInterfaceStubGenerator {
}
bool «fInterface.stubDefaultClassName»::«attribute.stubDefaultClassValidateMethodName»(const «typeName» &_value) {
- return true;
+ (void)_value;
+ «IF attribute.supportsTypeValidation»
+ return «attribute.validateType(fInterface)»;
+ «ELSE»
+ return true;
+ «ENDIF»
}
«IF !attribute.readonly»
void «fInterface.stubDefaultClassName»::«attribute.stubDefaultClassSetMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client, «typeName» _value) {
+ (void)_client;
«attribute.stubDefaultClassSetMethodName»(_value);
}
@@ -440,6 +473,7 @@ class FInterfaceStubGenerator {
}
bool «fInterface.stubDefaultClassName»::RemoteEventHandler::«attribute.stubRemoteEventClassSetMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client, «typeName» _value) {
+ (void)_client;
return «attribute.stubRemoteEventClassSetMethodName»(_value);
}
«ENDIF»
@@ -449,8 +483,19 @@ class FInterfaceStubGenerator {
«FOR method : fInterface.methods»
«FTypeGenerator::generateComments(method, false)»
void «fInterface.stubDefaultClassName»::«method.elementName»(«generateOverloadedStubSignature(method, methodreplyMap?.get(method))») {
+ (void)_client;
+ «IF !method.inArgs.empty»
+ «method.inArgs.map['(void) _' + it.name].join(";\n")»;
+ «ENDIF»
«IF !method.isFireAndForget»
«method.generateDummyArgumentDefinitions»
+ «FOR arg : method.outArgs»
+ «IF arg.getType.supportsValidation»
+ if (!«arg.elementName».validate()) {
+ return;
+ }
+ «ENDIF»
+ «ENDFOR»
_reply(«method.generateDummyArgumentList»);
«ENDIF»
}
@@ -461,25 +506,50 @@ class FInterfaceStubGenerator {
«FTypeGenerator::generateComments(broadcast, false)»
«IF broadcast.selective»
void «fInterface.stubDefaultClassName»::«broadcast.stubAdapterClassFireSelectiveMethodName»(«generateSendSelectiveSignatur(broadcast, fInterface, false)») {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- «fInterface.stubCommonAPIClassName»::stubAdapter_->«broadcast.stubAdapterClassSendSelectiveMethodName»(«broadcast.outArgs.map["_" + elementName].join(', ')»«IF(!broadcast.outArgs.empty)», «ENDIF»_receivers);
+ «FOR arg : broadcast.outArgs»
+ «IF arg.getType.supportsValidation»
+ if (!_«arg.elementName».validate()) {
+ return;
+ }
+ «ENDIF»
+ «ENDFOR»
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ stubAdapter->«broadcast.stubAdapterClassSendSelectiveMethodName»(«broadcast.outArgs.map["_" + elementName].join(', ')»«IF(!broadcast.outArgs.empty)», «ENDIF»_receivers);
}
void «fInterface.stubDefaultClassName»::«broadcast.subscriptionChangedMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client, const CommonAPI::SelectiveBroadcastSubscriptionEvent _event) {
+ (void)_client;
+ (void)_event;
// No operation in default
}
bool «fInterface.stubDefaultClassName»::«broadcast.subscriptionRequestedMethodName»(const std::shared_ptr<CommonAPI::ClientId> _client) {
+ (void)_client;
// Accept in default
return true;
}
std::shared_ptr<CommonAPI::ClientIdList> const «fInterface.stubDefaultClassName»::«broadcast.stubAdapterClassSubscribersMethodName»() {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- return(«fInterface.stubCommonAPIClassName»::stubAdapter_->«broadcast.stubAdapterClassSubscribersMethodName»());
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ return(stubAdapter->«broadcast.stubAdapterClassSubscribersMethodName»());
+ else
+ return NULL;
}
«ELSE»
void «fInterface.stubDefaultClassName»::«broadcast.stubAdapterClassFireEventMethodName»(«broadcast.outArgs.map['const ' + getTypeName(fInterface, true) + ' &_' + elementName].join(', ')») {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- «fInterface.stubCommonAPIClassName»::stubAdapter_->«broadcast.stubAdapterClassFireEventMethodName»(«broadcast.outArgs.map["_" + elementName].join(', ')»);
+ «FOR arg : broadcast.outArgs»
+ «IF arg.getType.supportsValidation»
+ if (!_«arg.elementName».validate()) {
+ return;
+ }
+ «ENDIF»
+ «ENDFOR»
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ stubAdapter->«broadcast.stubAdapterClassFireEventMethodName»(«broadcast.outArgs.map["_" + elementName].join(', ')»);
}
«ENDIF»
«ENDFOR»
@@ -488,22 +558,41 @@ class FInterfaceStubGenerator {
bool «fInterface.stubDefaultClassName»::«managed.stubRegisterManagedAutoName»(std::shared_ptr<«managed.stubFullClassName»> _stub) {
autoInstanceCounter_++;
std::stringstream ss;
- ss << «fInterface.stubCommonAPIClassName»::stubAdapter_->getAddress().getInstance() << ".i" << autoInstanceCounter_;
- std::string instance = ss.str();
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- return «fInterface.stubCommonAPIClassName»::stubAdapter_->«managed.stubRegisterManagedName»(_stub, instance);
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter) {
+ ss << stubAdapter->getAddress().getInstance() << ".i" << autoInstanceCounter_;
+ std::string instance = ss.str();
+ return stubAdapter->«managed.stubRegisterManagedName»(_stub, instance);
+ } else {
+ return false;
+ }
}
bool «fInterface.stubDefaultClassName»::«managed.stubRegisterManagedMethodImpl» {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- return «fInterface.stubCommonAPIClassName»::stubAdapter_->«managed.stubRegisterManagedName»(_stub, _instance);
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ return stubAdapter->«managed.stubRegisterManagedName»(_stub, _instance);
+ else
+ return false;
}
bool «fInterface.stubDefaultClassName»::«managed.stubDeregisterManagedName»(const std::string &_instance) {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- return «fInterface.stubCommonAPIClassName»::stubAdapter_->«managed.stubDeregisterManagedName»(_instance);
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter)
+ return stubAdapter->«managed.stubDeregisterManagedName»(_instance);
+ else
+ return false;
}
std::set<std::string>& «fInterface.stubDefaultClassName»::«managed.stubManagedSetGetterName»() {
- assert((«fInterface.stubCommonAPIClassName»::stubAdapter_) !=NULL);
- return «fInterface.stubCommonAPIClassName»::stubAdapter_->«managed.stubManagedSetGetterName»();
+ assert((«fInterface.stubCommonAPIClassName»::stubAdapter_.lock()) !=NULL);
+ auto stubAdapter = «fInterface.stubCommonAPIClassName»::stubAdapter_.lock();
+ if (stubAdapter) {
+ return stubAdapter->«managed.stubManagedSetGetterName»();
+ } else {
+ static std::set<std::string> emptySet = std::set<std::string>();
+ return emptySet;
+ }
}
«ENDFOR»
@@ -531,4 +620,16 @@ class FInterfaceStubGenerator {
def private getStubDefaultClassVariableName(FAttribute fAttribute) {
fAttribute.elementName.toFirstLower + 'AttributeValue_'
}
+
+ def private supportsInitialValue(FAttribute fAttribute) {
+ fAttribute.type.derived instanceof FEnumerationType && !fAttribute.array
+ }
+ def private initialValue(FAttribute fAttribute, FInterface fInterface) {
+ if (fAttribute.type.derived instanceof FEnumerationType) {
+ val FEnumerationType _enumeration = fAttribute.type.derived as FEnumerationType;
+ fAttribute.getTypeName(fInterface, true) + '::Literal::' + _enumeration.enumerators.get(0).elementName;
+ }
+ else "0"
+ }
+
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend
index a0ac91d..34d99e2 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FTypeCollectionGenerator.xtend
@@ -14,6 +14,8 @@ import org.eclipse.xtext.generator.IFileSystemAccess
import org.franca.core.franca.FStructType
import org.franca.core.franca.FTypeCollection
import org.genivi.commonapi.core.deployment.PropertyAccessor
+import org.genivi.commonapi.core.preferences.FPreferences
+import org.genivi.commonapi.core.preferences.PreferenceConstants
class FTypeCollectionGenerator {
@Inject private extension FTypeGenerator
@@ -25,15 +27,25 @@ class FTypeCollectionGenerator {
PropertyAccessor deploymentAccessor,
IResource modelid) {
- fileSystemAccess.generateFile(fTypeCollection.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, fTypeCollection.generateHeader(modelid, deploymentAccessor))
+ if(FPreferences::getInstance.getPreference(PreferenceConstants::P_GENERATE_CODE, "true").equals("true")) {
+ fileSystemAccess.generateFile(fTypeCollection.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, fTypeCollection.generateHeader(modelid, deploymentAccessor))
- if (fTypeCollection.hasSourceFile) {
- fileSystemAccess.generateFile(fTypeCollection.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, fTypeCollection.generateSource(modelid, deploymentAccessor))
+ if (fTypeCollection.hasSourceFile) {
+ fileSystemAccess.generateFile(fTypeCollection.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, fTypeCollection.generateSource(modelid, deploymentAccessor))
+ }
+ }
+ else {
+ // feature: suppress code generation
+ fileSystemAccess.generateFile(fTypeCollection.headerPath, IFileSystemAccess.DEFAULT_OUTPUT, PreferenceConstants::NO_CODE)
+
+ if (fTypeCollection.hasSourceFile) {
+ fileSystemAccess.generateFile(fTypeCollection.sourcePath, IFileSystemAccess.DEFAULT_OUTPUT, PreferenceConstants::NO_CODE)
+ }
}
}
def private generateHeader(FTypeCollection fTypeCollection, IResource modelid, PropertyAccessor deploymentAccessor) '''
- «generateCommonApiLicenseHeader(fTypeCollection, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fTypeCollection, false)»
#ifndef «fTypeCollection.defineName»_HPP_
#define «fTypeCollection.defineName»_HPP_
@@ -92,11 +104,13 @@ class FTypeCollectionGenerator {
«fTypeCollection.generateHashers(deploymentAccessor)»
}
+ «fTypeCollection.generateMajorVersionNamespace»
+
#endif // «fTypeCollection.defineName»_HPP_
'''
def private generateSource(FTypeCollection fTypeCollection, IResource modelid, PropertyAccessor _accessor) '''
- «generateCommonApiLicenseHeader(fTypeCollection, modelid)»
+ «generateCommonApiLicenseHeader()»
«FTypeGenerator::generateComments(fTypeCollection, false)»
#include "«fTypeCollection.headerFile»"
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 2139344..94397f5 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
@@ -6,19 +6,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.genivi.commonapi.core.generator
-import java.util.ArrayList
import java.util.Collection
import java.util.LinkedList
import java.util.List
import javax.inject.Inject
import org.eclipse.emf.common.util.EList
-import org.franca.core.franca.FAnnotation
import org.franca.core.franca.FAnnotationBlock
import org.franca.core.franca.FAnnotationType
import org.franca.core.franca.FArrayType
import org.franca.core.franca.FBasicTypeId
import org.franca.core.franca.FEnumerationType
-import org.franca.core.franca.FEnumerator
import org.franca.core.franca.FField
import org.franca.core.franca.FInterface
import org.franca.core.franca.FMapType
@@ -33,7 +30,6 @@ import org.franca.core.franca.FUnionType
import org.genivi.commonapi.core.deployment.PropertyAccessor
import static com.google.common.base.Preconditions.*
-
import static extension org.genivi.commonapi.core.generator.FrancaGeneratorExtensions.*
class FTypeGenerator {
@@ -49,29 +45,6 @@ class FTypeGenerator {
}
return false
}
-
- // TODO: is this code needed ?
- def static sortAnnotations(FAnnotationBlock annots) {
- var ArrayList<ArrayList<FAnnotation>> ret = new ArrayList<ArrayList<FAnnotation>>(4)
- ret.add(new ArrayList<FAnnotation>())
- ret.add(new ArrayList<FAnnotation>())
- ret.add(new ArrayList<FAnnotation>())
- ret.add(new ArrayList<FAnnotation>())
- for(anno : annots.elements) {
- if(anno == null){
- }else {
- if(anno.type.value.equals(FAnnotationType::DESCRIPTION_VALUE))
- ret.get(0).add(anno)
- if(anno.type.value.equals(FAnnotationType::PARAM_VALUE))
- ret.get(1).add(anno)
- if(anno.type.value.equals(FAnnotationType::DEPRECATED_VALUE))
- ret.get(2).add(anno)
- if(anno.type.value.equals(FAnnotationType::AUTHOR_VALUE))
- ret.get(3).add(anno)
- }
- }
- return ret
- }
def private static findNextBreak(String text) {
var breakIndex = text.substring(0, CommentLineLength).lastIndexOf(" ");
@@ -101,50 +74,6 @@ class FTypeGenerator {
return commentBody;
}
- // TODO: Does this code offer additional functionality compared to breaktext ?
- def static breaktext_(String text, FAnnotationType annotation) {
- var ret = ""
- var temptext = ""
-
- if(annotation == FAnnotationType::DESCRIPTION_VALUE && text.length > CommentLineLength) {
- ret = " * " + text.substring(0, findNextBreak(text)) + "\n";
- temptext = text.substring(findNextBreak(text));
- }else if(annotation != FAnnotationType::DESCRIPTION_VALUE && text.length > CommentLineLength) {
- if(annotation == FAnnotationType::AUTHOR_VALUE) {
- ret = " * @author "
- }if(annotation == FAnnotationType::DEPRECATED_VALUE){
- ret = " * @deprecated "
- }if(annotation == FAnnotationType::PARAM_VALUE){
- ret = " * @param "
- }
- ret = ret + text.substring(0, findNextBreak(text)) + "\n";
- temptext = text.substring(findNextBreak(text));
- }else {
- if(annotation == FAnnotationType::AUTHOR_VALUE)
- ret = " * @author "
- if(annotation == FAnnotationType::DEPRECATED_VALUE)
- ret = " * @deprecated "
- if(annotation == FAnnotationType::PARAM_VALUE)
- ret = " * @param "
- if(annotation == FAnnotationType::DESCRIPTION_VALUE)
- ret = " * "
- ret = ret + text + "\n";
- }
- while(temptext.length > CommentLineLength) {
- try {
- ret = ret + " * " + temptext.substring(0, findNextBreak(temptext)) + "\n";
- temptext = temptext.substring(findNextBreak(temptext));
- }
- catch (StringIndexOutOfBoundsException sie) {
- System.out.println("Comment problem in text " + text);
- sie.printStackTrace();
- }
- }
- if(temptext.length > 0)
- ret = ret + " * " + temptext + "\n"
- return ret;
- }
-
def static generateComments(FModelElement model, boolean inline) {
var intro = ""
var tail = ""
@@ -164,32 +93,6 @@ class FTypeGenerator {
return ""
}
- // TODO: Does this code offer additional functionality compared to generateComments ?
- def static generateComments_(FModelElement model, boolean inline) {
- var typ = getTyp(model)
- var ret = ""
- var commexists = false
- if( model != null && model.comment != null){
- for (list : sortAnnotations(model.comment)){
- for (comment : list){
- if(comment.type.value.equals(FAnnotationType::DESCRIPTION_VALUE) ||
- (comment.type.value.equals(FAnnotationType::AUTHOR_VALUE) && typ == ModelTyp::INTERFACE) ||
- (comment.type.value.equals(FAnnotationType::DEPRECATED_VALUE) && (typ == ModelTyp::METHOD || typ==ModelTyp::ENUM)) ||
- (comment.type.value.equals(FAnnotationType::PARAM_VALUE) && typ == ModelTyp::METHOD)){
- if(!inline && !commexists)
- ret = "/**\n"
- commexists = true
- ret = ret + breaktext(comment.comment, comment.type)
- }
- }
- }
- if(!inline && commexists)
- ret = ret + " */"
- if(inline && commexists)
- ret = ret + " * "
- }
- return ret
- }
def static getTyp(FModelElement element) {
if(element instanceof FInterface || element instanceof FTypeCollection)
@@ -203,7 +106,6 @@ class FTypeGenerator {
def generateFTypeDeclarations(FTypeCollection fTypeCollection, PropertyAccessor deploymentAccessor) '''
«FOR type: fTypeCollection.types.sortTypes(fTypeCollection)»
- «generateComments(type, false)»
«type.generateFTypeDeclaration(deploymentAccessor)»
«ENDFOR»
«IF fTypeCollection instanceof FInterface»
@@ -250,9 +152,9 @@ class FTypeGenerator {
def dispatch generateFTypeDeclaration(FArrayType fArrayType, PropertyAccessor deploymentAccessor) '''
«generateComments(fArrayType, false)»
«IF fArrayType.elementType.derived != null && fArrayType.elementType.derived instanceof FStructType && (fArrayType.elementType.derived as FStructType).polymorphic»
- typedef std::vector<std::shared_ptr<«fArrayType.elementType.getElementType(null, true)»>> «fArrayType.elementName»;
+ typedef std::vector<std::shared_ptr<«fArrayType.elementType.getElementType(fArrayType, true)»>> «fArrayType.elementName»;
«ELSE»
- typedef std::vector<«fArrayType.elementType.getElementType(null, true)»> «fArrayType.elementName»;
+ typedef std::vector<«fArrayType.elementType.getElementType(fArrayType, true)»> «fArrayType.elementName»;
«ENDIF»
'''
@@ -277,10 +179,10 @@ class FTypeGenerator {
struct «fStructType.elementName» : CommonAPI::Struct<«fStructType.allElements.map[getTypeName(fStructType, false)].join(", ")»> {
«ENDIF»
«IF fStructType.hasPolymorphicBase()»
- «IF fStructType.hasDerivedTypes() »
+ «IF fStructType.polymorphic || (fStructType.hasPolymorphicBase() && fStructType.hasDerivedTypes())»
static std::shared_ptr<«fStructType.elementName»> create(CommonAPI::Serial _serial);
«ENDIF»
- const CommonAPI::Serial getSerial() const { return «fStructType.elementName.toUpperCase»_SERIAL; }
+ CommonAPI::Serial getSerial() const { return «fStructType.elementName.toUpperCase»_SERIAL; }
«ENDIF»
«fStructType.elementName»() {
@@ -316,6 +218,9 @@ class FTypeGenerator {
«IF fStructType.hasPolymorphicBase()»
template<class _Input>
void readValue(CommonAPI::InputStream<_Input> &_input, const CommonAPI::EmptyDeployment *_depl) {
+ «IF fStructType.derivedFStructTypes.empty»
+ (void) _depl;
+ «ENDIF»
«var i = -1»
«FOR element : fStructType.elements»
_input.template readValue<CommonAPI::EmptyDeployment>(std::get<«i = i+1»>(values_));
@@ -352,18 +257,36 @@ class FTypeGenerator {
}
«ENDIF»
}
-
template<class _Output>
- void writeType(CommonAPI::TypeOutputStream<_Output> &_output) {
+ void writeType(CommonAPI::TypeOutputStream<_Output> &_output, const CommonAPI::EmptyDeployment *_depl) {
«var l = -1»
«FOR element : fStructType.elements»
- _output.writeType(std::get<«l = l+1»>(values_));
+ _output.writeType(std::get<«l = l+1»>(values_), _depl);
+ «ENDFOR»
+ «IF fStructType.hasDerivedTypes()»
+ switch (getSerial()) {
+ «FOR derived : fStructType.derivedFStructTypes»
+ «derived.generateCases(null, false)»
+ static_cast<«derived.elementName» *>(this)->template writeType<_Output>(_output, _depl);
+ break;
+ «ENDFOR»
+ default:
+ break;
+ }
+ «ENDIF»
+ }
+ template<class _Output, class _Deployment>
+ void writeType(CommonAPI::TypeOutputStream<_Output> &_output, const _Deployment *_depl) {
+ «var l1 = -1»
+ «var l2 = fStructType.allElements.size - fStructType.elements.size - 1»
+ «FOR element : fStructType.elements»
+ _output.writeType(std::get<«l1 = l1+1»>(values_), std::get<«l2 = l2+1»>(_depl->values_));
«ENDFOR»
«IF fStructType.hasDerivedTypes()»
switch (getSerial()) {
«FOR derived : fStructType.derivedFStructTypes»
«derived.generateCases(null, false)»
- static_cast<«derived.elementName» *>(this)->template writeType<_Output>(_output);
+ static_cast<«derived.elementName» *>(this)->template writeType<_Output, _Deployment>(_output, _depl);
break;
«ENDFOR»
default:
@@ -374,6 +297,9 @@ class FTypeGenerator {
template<class _Output>
void writeValue(CommonAPI::OutputStream<_Output> &_output, const CommonAPI::EmptyDeployment *_depl) {
+ «IF fStructType.derivedFStructTypes.empty»
+ (void) _depl;
+ «ENDIF»
«var m = -1»
«FOR element : fStructType.elements»
_output.template writeValue<CommonAPI::EmptyDeployment>(std::get<«m = m+1»>(values_));
@@ -396,7 +322,7 @@ class FTypeGenerator {
«var n = -1»
«var o = fStructType.allElements.size - fStructType.elements.size - 1»
«FOR element : fStructType.elements»
- _output.template writeValue<>(std::get<«n = n+1»>(values_), _depl, std::get<«o = o + 1»>(_depl->values_));
+ _output.template writeValue<>(std::get<«n = n+1»>(values_), std::get<«o = o + 1»>(_depl->values_));
«ENDFOR»
«IF fStructType.hasDerivedTypes()»
switch (getSerial()) {
@@ -461,11 +387,22 @@ class FTypeGenerator {
«ENDFOR»
};
- «_enumeration.name»() = default;
- «_enumeration.name»(const Literal &_value)
- : «baseTypeName»(static_cast<«IF _enumeration.base == null»«backingType»«ELSE»«baseTypeName»::Literal«ENDIF»>(_value)) {}
+ «_enumeration.name»()
+ : «baseTypeName»(static_cast<«IF _enumeration.base == null»«backingType»«ELSE»«baseTypeName»::Literal«ENDIF»>(Literal::«_enumeration.enumerators.get(0).elementName»)) {}
+ «generateEnumBaseTypeConstructor(_enumeration, _enumeration.name, baseTypeName, backingType)»
«_enumeration.generateBaseTypeAssignmentOperator(_accessor)»
+ inline bool validate() const {
+ switch (value_) {
+ «FOR enumerator : _enumeration.enumerators»
+ case static_cast<«backingType»>(Literal::«enumPrefix»«enumerator.elementName»):
+ «ENDFOR»
+ return true;
+ default:
+ return «IF _enumeration.base == null»false;«ELSE»«baseTypeName»::validate();«ENDIF»
+ }
+ }
+
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_); }
@@ -482,7 +419,20 @@ class FTypeGenerator {
};
'''
- def generateBaseTypeAssignmentOperator(FEnumerationType _enumeration, PropertyAccessor _accessor) '''
+ def CharSequence generateEnumBaseTypeConstructor(FEnumerationType _enumeration, String _name, String _baseName, String _backingType) '''
+ «IF _enumeration.base != null»
+ «generateEnumBaseTypeConstructor(_enumeration.base, _name, _baseName, _backingType)»
+ «_name»(const «_enumeration.getBaseType(_backingType)»::Literal &_value)
+ : «_baseName»(_value) {}
+ «ELSE»
+ «_name»(const Literal &_value)
+ : «_baseName»(static_cast<«_backingType»>(_value)) {}
+ «_name»(const «_backingType» &_value)
+ : «_baseName»(_value) {}
+ «ENDIF»
+ '''
+
+ def CharSequence generateBaseTypeAssignmentOperator(FEnumerationType _enumeration, PropertyAccessor _accessor) '''
«IF _enumeration.base != null»
«val backingType = _enumeration.getBackingType(_accessor).primitiveTypeName»
«val baseTypeName = _enumeration.getBaseType(backingType)»
@@ -513,7 +463,6 @@ class FTypeGenerator {
return names
}
-
def dispatch generateFTypeInlineImplementation(FTypeDef fTypeDef, FModelElement parent, PropertyAccessor deploymentAccessor) ''''''
def dispatch generateFTypeInlineImplementation(FArrayType fArrayType, FModelElement parent, PropertyAccessor deploymentAccessor) ''''''
def dispatch generateFTypeInlineImplementation(FMapType fMap, FModelElement parent, PropertyAccessor deploymentAccessor) ''''''
@@ -557,7 +506,8 @@ class FTypeGenerator {
«IF fStructType.allElements.size > 0»
«FOR element : fStructType.allElements BEFORE 'return (' SEPARATOR ' && ' AFTER ');'»get«element.elementName.toFirstUpper»() == _other.get«element.elementName.toFirstUpper»()«ENDFOR»
«ELSE»
- return true;
+ (void) _other;
+ return true;
«ENDIF»
}
@@ -672,15 +622,6 @@ class FTypeGenerator {
return reference
}
- // TODO: check whether this is used anywhere....
- def String generateBaseConstructorCall(FStructType parent, FStructType source) {
- var call = parent.getRelativeNameReference(source)
- call = call + "(" + parent.allElements.map[elementName + "Value"].join(", ") + ")"
- if (!source.elements.empty)
- call = call + ","
- return call
- }
-
def private generateHasher(FMapType fMap) {
if (fMap.keyType.derived instanceof FEnumerationType) {
return ''', CommonAPI::EnumHasher<«fMap.keyType.derived.getFullName»>'''
@@ -710,82 +651,7 @@ class FTypeGenerator {
}
}
- // TODO: Check whether this is used somewhere
- def getBaseStructName(FStructType fStructType) {
- if (fStructType.hasPolymorphicBase)
- return "CommonAPI::PolymorphicStruct"
-
- return "CommonAPI::Struct"
- }
-
def private getConstReferenceVariable(FField destination, FModelElement source) {
"const " + destination.getTypeName(source, false) + " &_" + destination.elementName
}
-
- //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) {
- return static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(lhs) «operator» static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(rhs);
- }
- inline bool operator«operator»(const «base.getClassNamespaceWithName(base.elementName, base.eContainer as FModelElement, (base.eContainer as FModelElement).elementName)»& lhs, const «fEnumerationType.getClassNamespaceWithName(enumerationName, parent, parentName)»& rhs) {
- return static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(lhs) «operator» static_cast<«fEnumerationType.getBackingType(deploymentAccessor).primitiveTypeName»>(rhs);
- }
- '''
-
- //TODO: used?
- def getBaseList(FEnumerationType fEnumerationType) {
- val baseList = new LinkedList<FEnumerationType>
- var currentBase = fEnumerationType.base
-
- while (currentBase != null) {
- baseList.add(0, currentBase)
- currentBase = currentBase.base
- }
-
- return baseList
- }
-
- //TODO: used?
- def generateValue(FEnumerator fEnumerator) {
- val parsedValue = tryParseInteger(fEnumerator.value.enumeratorValue)
- if (parsedValue != null)
- return ' = ' + parsedValue
- return ''
- }
-
- def private tryParseInteger(String string) {
- if (!string.nullOrEmpty) {
- if (string.startsWith("0x") || string.startsWith("0X")) {
- try {
- return "0x" + Integer::toHexString((Integer::parseInt(string.substring(2), 16)))
- } catch (NumberFormatException e) {
- return null
- }
- } else if (string.startsWith("0b") || string.startsWith("0B")) {
- try {
- return "0x" + Integer::toHexString((Integer::parseInt(string.substring(2), 2)))
- } catch (NumberFormatException e) {
- return null
- }
- } else if (string.startsWith("0")) {
- try {
- Integer::parseInt(string, 8)
- return string
- } catch (NumberFormatException e) {
- return null
- }
- } else {
- try {
- return Integer::parseInt(string, 10)
- } catch (NumberFormatException e) {
- try {
- return "0x" + Integer::toHexString((Integer::parseInt(string, 16)))
- } catch (NumberFormatException e2) {
- return null
- }
- }
- }
- }
- return null
- }
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend
index 346f5a5..c371b19 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/FrancaGenerator.xtend
@@ -6,29 +6,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.genivi.commonapi.core.generator
-import java.util.Collection
+import java.io.File
+import java.util.ArrayList
import java.util.HashSet
-import java.util.LinkedList
import java.util.List
+import java.util.Map
+import java.util.Set
import javax.inject.Inject
import org.eclipse.core.resources.IResource
-import org.eclipse.core.resources.ResourcesPlugin
-import org.eclipse.core.runtime.Path
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.generator.IGenerator
import org.franca.core.dsl.FrancaPersistenceManager
-import org.franca.core.franca.FArrayType
-import org.franca.core.franca.FEnumerationType
import org.franca.core.franca.FInterface
-import org.franca.core.franca.FMapType
import org.franca.core.franca.FModel
-import org.franca.core.franca.FStructType
-import org.franca.core.franca.FType
-import org.franca.core.franca.FTypeCollection
-import org.franca.core.franca.FTypeDef
-import org.franca.core.franca.FTypeRef
-import org.franca.core.franca.FUnionType
import org.franca.deploymodel.core.FDeployedInterface
import org.franca.deploymodel.core.FDeployedTypeCollection
import org.franca.deploymodel.dsl.fDeploy.FDInterface
@@ -38,8 +29,7 @@ import org.franca.deploymodel.dsl.fDeploy.FDTypes
import org.genivi.commonapi.core.deployment.PropertyAccessor
import org.genivi.commonapi.core.preferences.FPreferences
import org.genivi.commonapi.core.preferences.PreferenceConstants
-
-import static com.google.common.base.Preconditions.*
+import org.franca.deploymodel.core.FDeployedProvider
class FrancaGenerator implements IGenerator {
@Inject private extension FTypeCollectionGenerator
@@ -47,72 +37,150 @@ class FrancaGenerator implements IGenerator {
@Inject private extension FInterfaceProxyGenerator
@Inject private extension FInterfaceStubGenerator
@Inject private extension FrancaGeneratorExtensions
-
+
@Inject private FrancaPersistenceManager francaPersistenceManager
@Inject private FDeployManager fDeployManager
+ val String CORE_SPECIFICATION_TYPE = "core.deployment"
+
override doGenerate(Resource input, IFileSystemAccess fileSystemAccess) {
- var List<FDInterface> deployedInterfaces = new LinkedList<FDInterface>()
- var List<FDTypes> deployedTypeCollections = new LinkedList<FDTypes>()
- var List<FDProvider> deployedProviders = new LinkedList<FDProvider>()
+ if (!input.URI.fileExtension.equals(francaPersistenceManager.fileExtension) &&
+ !input.URI.fileExtension.equals(FDeployManager.fileExtension)) {
+ return
+ }
+
+ var List<FDInterface> deployedInterfaces = new ArrayList<FDInterface>()
+ var List<FDTypes> deployedTypeCollections = new ArrayList<FDTypes>()
+ var List<FDProvider> deployedProviders = new ArrayList<FDProvider>()
var IResource res = null
- val String CORE_SPECIFICATION_TYPE = "core.deployment"
- // generate code from the fidl or fdepl file
- if (input.URI.fileExtension.equals(francaPersistenceManager.fileExtension) ||
- input.URI.fileExtension.equals(FDeployManager.fileExtension)) {
+ var rootModel = fDeployManager.loadModel(input.URI, input.URI);
+
+ generatedFiles_ = new HashSet<String>()
+
+ withDependencies_ = FPreferences::instance.getPreference(
+ PreferenceConstants::P_GENERATE_DEPENDENCIES, "true"
+ ).equals("true")
- var model = fDeployManager.loadModel(input.URI, input.URI);
-
- // fModels is the map of all models from imported fidl files
- var fModels = fDeployManager.fidlModels
-
- if (model instanceof FDModel) {
- // read deployment information
- deployedInterfaces = getFDInterfaces(model, CORE_SPECIFICATION_TYPE)
- deployedTypeCollections = getFDTypesList(model, CORE_SPECIFICATION_TYPE)
- deployedProviders = getFDProviders(model, CORE_SPECIFICATION_TYPE)
- }
- // add the model from the given fidl file
- else if(model instanceof FModel) {
- fModels.put(input.URI.lastSegment, model);
- }
+ // models holds the map of all models from imported .fidl files
+ var models = fDeployManager.fidlModels
+ // deployments holds the map of all models from imported .fdepl files
+ var deployments = fDeployManager.deploymentModels
- for (fModelEntry : fModels.entrySet) {
- //System.out.println("Generation code for: " + fModelEntry.key)
- var fModel = fModelEntry.value
+ if (rootModel instanceof FDModel) {
+ deployments.put(input.URI.toString, rootModel)
+ } else if (rootModel instanceof FModel) {
+ models.put(input.URI.toString, rootModel)
+ }
- if (fModel != null) {
+ // Categorize deployment information. Store for each deployment whether (or not)
+ // it contains an interface or type collection deployment
+ for (itsEntry : deployments.entrySet) {
+ var FDModel itsDeployment = itsEntry.value
+
+ val List<FDInterface> itsInterfaces = getFDInterfaces(itsDeployment, CORE_SPECIFICATION_TYPE)
+ val List<FDTypes> itsTypeCollections = getFDTypesList(itsDeployment, CORE_SPECIFICATION_TYPE)
+ val List<FDProvider> itsProviders = getAllFDProviders(itsDeployment)
+
+ deployedInterfaces.addAll(itsInterfaces)
+ deployedTypeCollections.addAll(itsTypeCollections)
+ deployedProviders.addAll(itsProviders)
+ }
+
+ if (rootModel instanceof FDModel) {
+ doGenerateDeployment(rootModel, deployments, models,
+ deployedInterfaces, deployedTypeCollections, deployedProviders,
+ fileSystemAccess, res)
+ } else if (rootModel instanceof FModel) {
+ doGenerateModel(rootModel, deployments, models,
+ deployedInterfaces, deployedTypeCollections, deployedProviders,
+ fileSystemAccess, res)
+ }
+
+ fDeployManager.clearFidlModels
+ fDeployManager.clearDeploymentModels
+ }
+
+ def private void doGenerateDeployment(FDModel _deployment,
+ Map<String, FDModel> _deployments,
+ Map<String, FModel> _models,
+ List<FDInterface> _interfaces,
+ List<FDTypes> _typeCollections,
+ List<FDProvider> _providers,
+ IFileSystemAccess _access,
+ IResource _res) {
+ val String deploymentName
+ = _deployments.entrySet.filter[it.value == _deployment].head.key
+
+ var String basePath = deploymentName.substring(
+ 0, deploymentName.lastIndexOf(File.separatorChar))
+
+ var Set<String> itsImports = new HashSet<String>()
+ for (anImport : _deployment.imports) {
+ val String canonical = getCanonical(basePath, anImport.importURI)
+ itsImports.add(canonical)
+ }
+
+ if (withDependencies_) {
+ for (itsEntry : _deployments.entrySet) {
+ if (itsImports.contains(itsEntry.key)) {
+ doGenerateDeployment(itsEntry.value, _deployments, _models,
+ _interfaces, _typeCollections, _providers,
+ _access, _res)
+ }
+ }
+ }
+
+ for (itsEntry : _models.entrySet) {
+ if (itsImports.contains(itsEntry.key)) {
+ doGenerateModel(itsEntry.value, _deployments, _models,
+ _interfaces, _typeCollections, _providers,
+ _access, _res)
+ }
+ }
+ }
+
+ def private void doGenerateModel(FModel _model,
+ Map<String, FDModel> _deployments,
+ Map<String, FModel> _models,
+ List<FDInterface> _interfaces,
+ List<FDTypes> _typeCollections,
+ List<FDProvider> _providers,
+ IFileSystemAccess _access,
+ IResource _res) {
+
+ val String modelName
+ = _models.entrySet.filter[it.value == _model].head.key
+
+ if (generatedFiles_.contains(modelName)) {
+ return
+ }
- // actually generate code
- doGenerateComponents(fModel, deployedInterfaces, deployedTypeCollections, deployedProviders,
- fileSystemAccess, res)
+ generatedFiles_.add(modelName);
+
+ doGenerateComponents(_model,
+ _interfaces, _typeCollections, _providers,
+ _access, _res)
+
+ if (withDependencies_) {
+ for (itsEntry : _models.entrySet) {
+ var FModel itsModel = itsEntry.value
+ if (itsModel != null) {
+ doGenerateComponents(itsModel,
+ _interfaces, _typeCollections, _providers,
+ _access, _res)
}
}
- fDeployManager.clearFidlModels
- } else {
- // input has not *.fidl or *.fdepl
- checkArgument(false, "Unknown input: " + input)
}
}
- def private doGenerateComponents(FModel fModel, List<FDInterface> deployedInterfaces,
+ def private void doGenerateComponents(FModel fModel, List<FDInterface> deployedInterfaces,
List<FDTypes> deployedTypeCollections, List<FDProvider> deployedProviders,
IFileSystemAccess fileSystemAccess, IResource res) {
-
- val allReferencedFTypes = fModel.allReferencedFTypes
- val allFTypeTypeCollections = allReferencedFTypes.filter[eContainer instanceof FTypeCollection].map[
- eContainer as FTypeCollection]
- val allFTypeFInterfaces = allReferencedFTypes.filter[eContainer instanceof FInterface].map[
- eContainer as FInterface]
-
- val generateTypeCollections = fModel.typeCollections.toSet
- generateTypeCollections.addAll(allFTypeTypeCollections)
-
- val interfacesToGenerate = fModel.allReferencedFInterfaces.toSet
- interfacesToGenerate.addAll(allFTypeFInterfaces)
-
- val defaultDeploymentAccessor = new PropertyAccessor()
+ var typeCollectionsToGenerate = fModel.typeCollections.toSet
+ var interfacesToGenerate = fModel.interfaces.toSet
+
+ val defaultDeploymentAccessor = new PropertyAccessor()
interfacesToGenerate.forEach [
val currentInterface = it
var PropertyAccessor deploymentAccessor
@@ -122,10 +190,13 @@ class FrancaGenerator implements IGenerator {
} else {
deploymentAccessor = defaultDeploymentAccessor
}
- generateInterface(it, fileSystemAccess, deploymentAccessor, res)
+ if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_COMMON, "true").equals("true")) {
+ generateInterface(it, fileSystemAccess, deploymentAccessor, res)
+ }
]
-
- generateTypeCollections.forEach [
+
+ // for all type collections
+ typeCollectionsToGenerate.forEach [
val currentTypeCollection = it
if (!(currentTypeCollection instanceof FInterface)) {
var PropertyAccessor deploymentAccessor
@@ -137,10 +208,13 @@ class FrancaGenerator implements IGenerator {
} else {
deploymentAccessor = defaultDeploymentAccessor
}
- generate(it, fileSystemAccess, deploymentAccessor, res)
+ if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_COMMON, "true").equals("true")) {
+ generate(it, fileSystemAccess, deploymentAccessor, res)
+ }
}
]
+ // for all interfaces
fModel.interfaces.forEach [
val currentInterface = it
var PropertyAccessor deploymentAccessor
@@ -150,136 +224,32 @@ class FrancaGenerator implements IGenerator {
} else {
deploymentAccessor = defaultDeploymentAccessor
}
- if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATEPROXY, "true").equals("true")) {
+ if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_PROXY, "true").equals("true")) {
it.generateProxy(fileSystemAccess, deploymentAccessor, res)
}
- if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATESTUB, "true").equals("true")) {
+ if (FPreferences::instance.getPreference(PreferenceConstants::P_GENERATE_STUB, "true").equals("true")) {
it.generateStub(fileSystemAccess, res)
}
]
-
- return;
- }
-
- private var String filePrefix = "file://"
-
- def getFilePathUrl(Resource resource)
- {
- val filePath = resource.filePath
- return filePrefix + filePath
- }
-
- def private getFilePath(Resource resource)
- {
- if(resource.URI.file)
- {
- return resource.URI.toFileString
- }
-
- val platformPath = new Path(resource.URI.toPlatformString(true))
- val file = ResourcesPlugin::getWorkspace().getRoot().getFile(platformPath);
-
- return file.location.toString
- }
-
- def private getAllReferencedFInterfaces(FModel fModel)
- {
- val referencedFInterfaces = fModel.interfaces.toSet
- fModel.interfaces.forEach[base?.addFInterfaceTree(referencedFInterfaces)]
- fModel.interfaces.forEach[managedInterfaces.forEach[addFInterfaceTree(referencedFInterfaces)]]
- return referencedFInterfaces
- }
-
- def private void addFInterfaceTree(FInterface fInterface, Collection<FInterface> fInterfaceReferences)
- {
- if(!fInterfaceReferences.contains(fInterface))
- {
- fInterfaceReferences.add(fInterface)
- fInterface.base?.addFInterfaceTree(fInterfaceReferences)
- }
- }
-
- def private getAllReferencedFTypes(FModel fModel)
- {
- val referencedFTypes = new HashSet<FType>
-
- fModel.typeCollections.forEach[types.forEach[addFTypeDerivedTree(referencedFTypes)]]
-
+ // generate interface instance header
fModel.interfaces.forEach [
- attributes.forEach[type.addDerivedFTypeTree(referencedFTypes)]
- types.forEach[addFTypeDerivedTree(referencedFTypes)]
- methods.forEach [
- inArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)]
- outArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)]
- ]
- broadcasts.forEach [
- outArgs.forEach[type.addDerivedFTypeTree(referencedFTypes)]
+ val currentInterface = it
+ val List<String> deployedInstances = new ArrayList<String>()
+ deployedProviders.forEach [
+ val deploymentAccessor = new PropertyAccessor(new FDeployedProvider(it))
+ it.instances.filter[currentInterface == target].forEach [
+ var instanceId = deploymentAccessor.getInstanceId(it)
+ if (instanceId != null) {
+ deployedInstances.add(instanceId)
+ }
+ ]
]
+ if (!deployedInstances.isEmpty) {
+ currentInterface.generateInstanceIds(fileSystemAccess, deployedInstances)
+ }
]
-
- return referencedFTypes
- }
-
- def private void addDerivedFTypeTree(FTypeRef fTypeRef, Collection<FType> fTypeReferences)
- {
- fTypeRef.derived?.addFTypeDerivedTree(fTypeReferences)
}
-
- def private dispatch void addFTypeDerivedTree(FTypeDef fTypeDef, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fTypeDef))
- {
- fTypeReferences.add(fTypeDef)
- fTypeDef.actualType.addDerivedFTypeTree(fTypeReferences)
- }
- }
-
- def private dispatch void addFTypeDerivedTree(FArrayType fArrayType, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fArrayType))
- {
- fTypeReferences.add(fArrayType)
- fArrayType.elementType.addDerivedFTypeTree(fTypeReferences)
- }
- }
-
- def private dispatch void addFTypeDerivedTree(FMapType fMapType, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fMapType))
- {
- fTypeReferences.add(fMapType)
- fMapType.keyType.addDerivedFTypeTree(fTypeReferences)
- fMapType.valueType.addDerivedFTypeTree(fTypeReferences)
- }
- }
-
- def private dispatch void addFTypeDerivedTree(FStructType fStructType, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fStructType))
- {
- fTypeReferences.add(fStructType)
- fStructType.base?.addFTypeDerivedTree(fTypeReferences)
- fStructType.elements.forEach[type.addDerivedFTypeTree(fTypeReferences)]
- }
- }
-
- def private dispatch void addFTypeDerivedTree(FEnumerationType fEnumerationType, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fEnumerationType))
- {
- fTypeReferences.add(fEnumerationType)
- fEnumerationType.base?.addFTypeDerivedTree(fTypeReferences)
- }
- }
-
- def private dispatch void addFTypeDerivedTree(FUnionType fUnionType, Collection<FType> fTypeReferences)
- {
- if(!fTypeReferences.contains(fUnionType))
- {
- fTypeReferences.add(fUnionType)
- fUnionType.base?.addFTypeDerivedTree(fTypeReferences)
- fUnionType.elements.forEach[type.addDerivedFTypeTree(fTypeReferences)]
- }
- }
-
+
+ private boolean withDependencies_ = false
+ private Set<String> generatedFiles_;
}
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 e567e39..8773d58 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
@@ -10,6 +10,8 @@ import com.google.common.base.Charsets
import com.google.common.hash.Hasher
import com.google.common.hash.Hashing
import com.google.common.primitives.Ints
+import java.io.File
+import java.io.IOException
import java.math.BigInteger
import java.util.ArrayList
import java.util.Collection
@@ -19,6 +21,7 @@ import java.util.LinkedList
import java.util.List
import java.util.Map
import java.util.Set
+import java.util.jar.Manifest
import org.eclipse.core.resources.IResource
import org.eclipse.core.resources.ResourcesPlugin
import org.eclipse.core.runtime.Path
@@ -27,10 +30,12 @@ import org.eclipse.core.runtime.preferences.InstanceScope
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.util.EcoreUtil
+import org.franca.core.franca.FArgument
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.FCompoundType
import org.franca.core.franca.FConstantDef
import org.franca.core.franca.FEnumerationType
import org.franca.core.franca.FEnumerator
@@ -38,6 +43,7 @@ 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.FIntegerInterval
import org.franca.core.franca.FInterface
import org.franca.core.franca.FMapType
import org.franca.core.franca.FMethod
@@ -56,8 +62,8 @@ import org.franca.core.franca.FVersion
import org.franca.core.franca.FrancaFactory
import org.franca.deploymodel.dsl.fDeploy.FDInterface
import org.franca.deploymodel.dsl.fDeploy.FDModel
-import org.franca.deploymodel.dsl.fDeploy.FDTypes
import org.franca.deploymodel.dsl.fDeploy.FDProvider
+import org.franca.deploymodel.dsl.fDeploy.FDTypes
import org.genivi.commonapi.core.deployment.PropertyAccessor
import org.genivi.commonapi.core.deployment.PropertyAccessor.DefaultEnumBackingType
import org.genivi.commonapi.core.deployment.PropertyAccessor.EnumBackingType
@@ -69,7 +75,6 @@ import static com.google.common.base.Preconditions.*
import static extension java.lang.Integer.*
-
class FrancaGeneratorExtensions {
def boolean isComplex(String _typeName) {
@@ -114,16 +119,17 @@ class FrancaGeneratorExtensions {
def String getFullyQualifiedCppName(FModelElement fModelElement) {
if (fModelElement.eContainer instanceof FModel) {
- var name = (fModelElement.eContainer as FModel).name
+ val containerName = (fModelElement.eContainer as FModel).name
+ var prefix = "::"
if (fModelElement instanceof FTypeCollection) {
val FVersion itsVersion = fModelElement.version
if (itsVersion != null) {
- name = fModelElement.versionPrefix + name
+ prefix = fModelElement.versionPrefix
}
}
- return "::" + (name + "::" + fModelElement.elementName).replace(".", "::")
+ return (prefix + containerName + "::" + fModelElement.elementName).replace(".", "::")
}
- return "::" + ((fModelElement.eContainer as FModelElement).fullyQualifiedName + "::" + fModelElement.elementName).replace(".", "::")
+ return ((fModelElement.eContainer as FModelElement).fullyQualifiedCppName + "::" + fModelElement.elementName).replace(".", "::")
}
def splitCamelCase(String string) {
@@ -227,10 +233,18 @@ class FrancaGeneratorExtensions {
fTypeCollection.elementName + ".hpp"
}
+ def getInstanceHeaderFile(FTypeCollection fTypeCollection) {
+ fTypeCollection.elementName + "InstanceIds.hpp"
+ }
+
def getHeaderPath(FTypeCollection fTypeCollection) {
fTypeCollection.versionPathPrefix + fTypeCollection.model.directoryPath + '/' + fTypeCollection.headerFile
}
+ def getInstanceHeaderPath(FTypeCollection fTypeCollection) {
+ fTypeCollection.versionPathPrefix + fTypeCollection.model.directoryPath + '/' + fTypeCollection.instanceHeaderFile
+ }
+
def getSourceFile(FTypeCollection fTypeCollection) {
fTypeCollection.elementName + ".cpp"
}
@@ -459,35 +473,62 @@ class FrancaGeneratorExtensions {
var String retval = ""
for(list_element : fMethod.outArgs) {
retval += getTypeName(list_element, fMethod, true) + ' ' + list_element.elementName
- if (((list_element.type.derived instanceof FStructType
- && (list_element.type.derived as FStructType).hasPolymorphicBase))
- || list_element.array){
- retval += " = {}"
- } else if(list_element.type.predefined != null) {
- // primitive types
- switch list_element.type.predefined {
- case FBasicTypeId::BOOLEAN: retval+= " = false"
- case FBasicTypeId::INT8: retval += " = 0"
- case FBasicTypeId::UINT8: retval += " = 0"
- case FBasicTypeId::INT16: retval += " = 0"
- case FBasicTypeId::UINT16: retval += " = 0"
- case FBasicTypeId::INT32: retval += " = 0"
- case FBasicTypeId::UINT32: retval += " = 0"
- case FBasicTypeId::INT64: retval += " = 0"
- case FBasicTypeId::UINT64: retval += " = 0"
- case FBasicTypeId::FLOAT: retval += " = 0.0f"
- case FBasicTypeId::DOUBLE: retval += " = 0.0"
- case FBasicTypeId::STRING: retval += " = \"\""
- case FBasicTypeId::BYTE_BUFFER: retval += " = {}"
- default: {}//System.out.println("No initialization generated for" +
- //" non-basic type: " + list_element.getName)
- }
- }
+ retval += list_element.type.generateDummyArgumentInitialization(list_element, fMethod)
retval += ";\n"
}
return retval
}
-
+
+ private def String generateDummyArgumentInitialization(FTypeRef typeRef, FArgument list_element, FMethod fMethod) {
+ if (list_element.array) {
+ " = {}"
+ } else if (typeRef.derived != null) {
+ typeRef.derived.generateDummyArgumentInitialization(list_element, fMethod)
+ } else if (typeRef.predefined != null) {
+ typeRef.predefined.generateDummyArgumentInitialization
+ } else {
+ ""
+ }
+ }
+
+ private def generateDummyArgumentInitialization(FType type, FArgument list_element, FMethod fMethod) {
+ if ((type instanceof FArrayType) || (type instanceof FCompoundType)) {
+ " = {}"
+ } else if (type instanceof FEnumerationType) {
+ val enumType = type as FEnumerationType
+ if (enumType.enumerators.empty) {
+ " = " + getTypeName(list_element, fMethod, true) + "(0u)"
+ } else {
+ " = " + getTypeName(list_element, fMethod, true) + "::" + enumPrefix + enumType.enumerators.get(0).elementName
+ }
+ } else if (type instanceof FIntegerInterval) {
+ " = " + (type as FIntegerInterval).lowerBound
+ } else if (type instanceof FTypeDef) {
+ (type as FTypeDef).actualType.generateDummyArgumentInitialization(list_element, fMethod)
+ } else {
+ ""
+ }
+ }
+
+ private def generateDummyArgumentInitialization(FBasicTypeId basicType) {
+ switch basicType {
+ case FBasicTypeId::BOOLEAN: " = false"
+ case FBasicTypeId::INT8: " = 0"
+ case FBasicTypeId::UINT8: " = 0u"
+ case FBasicTypeId::INT16: " = 0"
+ case FBasicTypeId::UINT16: " = 0u"
+ case FBasicTypeId::INT32: " = 0"
+ case FBasicTypeId::UINT32: " = 0ul"
+ case FBasicTypeId::INT64: " = 0"
+ case FBasicTypeId::UINT64: " = 0ull"
+ case FBasicTypeId::FLOAT: " = 0.0f"
+ case FBasicTypeId::DOUBLE: " = 0.0"
+ case FBasicTypeId::STRING: " = \"\""
+ case FBasicTypeId::BYTE_BUFFER: " = {}"
+ default: ""
+ }
+ }
+
def generateDummyArgumentDefinitions(FMethod fMethod) {
var definition = ''
if (fMethod.hasError)
@@ -610,6 +651,8 @@ class FrancaGeneratorExtensions {
}
signature += fMethod.asyncCallbackClassName + ' _callback'
+ if (_isDefault)
+ signature += " = nullptr"
signature += ", const CommonAPI::CallInfo *_info"
if (_isDefault)
signature += " = nullptr"
@@ -1288,17 +1331,22 @@ class FrancaGeneratorExtensions {
hasher.putString(fTypeRef.predefined.getName, Charsets::UTF_8);
}
- def boolean hasDerivedFStructTypes(FStructType fStructType) {
- return EcoreUtil.UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).exists [
- EObject instanceof FStructType && (EObject as FStructType).base == fStructType
- ]
- }
def getDerivedFStructTypes(FStructType fStructType) {
return EcoreUtil.UsageCrossReferencer::find(fStructType, fStructType.model.eResource.resourceSet).map[EObject].
filter[it instanceof FStructType].map[it as FStructType].filter[base == fStructType]
}
+ def boolean isStructEmpty(FStructType fStructType) {
+ if(!fStructType.elements.empty) {
+ return false
+ }
+ if(fStructType.base != null) {
+ return isStructEmpty(fStructType.base)
+ }
+ return true
+ }
+
def generateCppNamespace(FModel fModel) '''
«fModel.namespaceAsList.map[toString].join("::")»::'''
@@ -1314,17 +1362,26 @@ class FrancaGeneratorExtensions {
«ENDFOR»
'''
+ def generateMajorVersionNamespace(FTypeCollection _tc) '''
+
+ «var FVersion itsVersion = _tc.version»
+ «IF itsVersion != null && (itsVersion.major != 0 || itsVersion.minor != 0)»
+ // Compatibility
+ namespace v«itsVersion.major.toString»_«itsVersion.minor.toString» = v«itsVersion.major.toString»;
+ «ENDIF»
+ '''
+
def generateVersionNamespaceBegin(FTypeCollection _tc) '''
«var FVersion itsVersion = _tc.version»
«IF itsVersion != null && (itsVersion.major != 0 || itsVersion.minor != 0)»
- namespace v«itsVersion.major.toString»_«itsVersion.minor.toString» {
+ namespace v«itsVersion.major.toString» {
«ENDIF»
'''
def generateVersionNamespaceEnd(FTypeCollection _tc) '''
«var FVersion itsVersion = _tc.version»
«IF itsVersion != null && (itsVersion.major != 0 || itsVersion.minor != 0)»
- } // namespace v«itsVersion.major.toString»_«itsVersion.minor.toString»
+ } // namespace v«itsVersion.major.toString»
«ENDIF»
'''
@@ -1340,7 +1397,7 @@ class FrancaGeneratorExtensions {
var String prefix = "::"
var FVersion itsVersion = _tc.version
if (itsVersion != null && (itsVersion.major != 0 || itsVersion.minor != 0)) {
- prefix += "v" + itsVersion.major.toString + "_" + itsVersion.minor.toString + "::"
+ prefix += "v" + itsVersion.major.toString + "::"
}
return prefix
}
@@ -1349,16 +1406,11 @@ class FrancaGeneratorExtensions {
var String prefix = ""
var FVersion itsVersion = _tc.version
if (itsVersion != null && (itsVersion.major != 0 || itsVersion.minor != 0)) {
- prefix = "v" + itsVersion.major.toString + "_" + itsVersion.minor.toString + "/"
+ prefix = "v" + itsVersion.major.toString + "/"
}
return prefix
}
- // TODO: Remove the following method
- def isFireAndForget(FMethod fMethod) {
- return fMethod.fireAndForget
- }
-
def getFilePath(Resource resource) {
if (resource.URI.file)
return resource.URI.toFileString
@@ -1369,43 +1421,60 @@ class FrancaGeneratorExtensions {
return file.location.toString
}
- def getHeader(FModel model, IResource res) {
- if (FrameworkUtil::getBundle(this.getClass()) != null) {
- var returnValue = DefaultScope::INSTANCE.getNode(PreferenceConstants::SCOPE).get(PreferenceConstants::P_LICENSE, "")
- returnValue = InstanceScope::INSTANCE.getNode(PreferenceConstants::SCOPE).get(PreferenceConstants::P_LICENSE, returnValue)
- returnValue = FPreferences::instance.getPreference(PreferenceConstants::P_LICENSE, returnValue)
- return returnValue
- }
- return ""
+ def getLicenseHeader() {
+ return FPreferences::instance.getPreference(PreferenceConstants::P_LICENSE, PreferenceConstants.DEFAULT_LICENSE)
}
- def getFrancaVersion() {
- val bundle = FrameworkUtil::getBundle(FrancaGeneratorExtensions)
- val bundleContext = bundle.getBundleContext();
- for (b : bundleContext.bundles) {
- if (b.symbolicName.equals("org.franca.core")) {
- return b.version.toString
- }
- }
+ static def getFrancaVersion() {
+ val bundleName = "org.franca.core"
+ getBundleVersion(bundleName)
}
- def static getCoreVersion() {
+ static def getCoreVersion() {
+ val bundleName = "org.genivi.commonapi.core"
+ getBundleVersion(bundleName)
+ }
+
+ static def getBundleVersion(String bundleName) {
val bundle = FrameworkUtil::getBundle(FrancaGeneratorExtensions)
- val bundleContext = bundle.getBundleContext();
- for (b : bundleContext.bundles) {
- if (b.symbolicName.equals("org.genivi.commonapi.core")) {
- return b.version.toString
+ if (bundle != null) {
+
+ //OSGI framework running
+ val bundleContext = bundle.getBundleContext();
+ for (b : bundleContext.bundles) {
+ if (b.symbolicName.equals(bundleName)) {
+ return b.version.toString
+ }
}
+ } else {
+
+ //pure java runtime
+ try {
+ val manifestsEnum = typeof(FrancaGeneratorExtensions).classLoader.getResources("META-INF/MANIFEST.MF")
+ val bundleRegex = "^" + bundleName.replace(".", "\\.") + "(;singleton:=true)?$"
+ while (manifestsEnum.hasMoreElements) {
+ val manifestURL = manifestsEnum.nextElement
+ val manifest = new Manifest(manifestURL.openStream)
+ val name = manifest.mainAttributes.getValue("Bundle-SymbolicName")
+ if (name != null && name.matches(bundleRegex)) {
+ val version = manifest.mainAttributes.getValue("Bundle-Version")
+ return version
+ }
+ }
+ } catch (IOException exc) {
+ System.out.println("Failed to get the bundle version: " + exc.getMessage())
+ }
+ return ""
}
}
- def generateCommonApiLicenseHeader(FModelElement model, IResource modelid) '''
+ def generateCommonApiLicenseHeader() '''
/*
* This file was generated by the CommonAPI Generators.
- * Used org.genivi.commonapi.core «FrancaGeneratorExtensions::getCoreVersion()».
+ * Used org.genivi.commonapi.core «getCoreVersion()».
* Used org.franca.core «getFrancaVersion()».
*
- «getCommentedString(getHeader(model.model, modelid))»
+ «getCommentedString(getLicenseHeader())»
*/
'''
@@ -1764,7 +1833,7 @@ class FrancaGeneratorExtensions {
if (depl instanceof FDInterface) {
var specname = depl.spec.name
if(specname != null && specname.contains(selector)) {
- fdinterfaces.add(depl);
+ fdinterfaces.add(depl);
}
}
}
@@ -1783,7 +1852,7 @@ class FrancaGeneratorExtensions {
if (depl instanceof FDTypes) {
var specname = depl.spec?.name
if(specname != null && specname.contains(selector)) {
- fdTypes.add(depl);
+ fdTypes.add(depl);
}
}
}
@@ -1802,39 +1871,52 @@ class FrancaGeneratorExtensions {
if (depl instanceof FDProvider) {
var specname = depl.spec?.name
if(specname != null && specname.contains(selector)) {
- fdProviders.add(depl);
+ fdProviders.add(depl);
}
}
}
return fdProviders;
}
-
+ def List<FDProvider> getAllFDProviders(FDModel fdmodel) {
+ var List<FDProvider> fdProviders = new ArrayList<FDProvider>()
+
+ for(depl : fdmodel.getDeployments()) {
+ if (depl instanceof FDProvider) {
+ fdProviders.add(depl);
+ }
+ }
+ return fdProviders;
+ }
/**
* Copy deployment attributes into the destination deployment
*/
- def mergeDeployments(FDInterface source, FDInterface destination) {
+ def mergeDeployments(FDInterface _source, FDInterface _destination) {
- if(source.target.equals(destination.target)) {
- if(source.attributes.size > 0) {
- if( destination.attributes.size == 0) {
- // e.g: attribute timeout
- destination.attributes.addAll(source.attributes)
+ if (_source.target.equals(_destination.target)) {
+ if (_source.attributes.size > 0) {
+ if(_destination.attributes.size == 0) {
+ _destination.attributes.addAll(_source.attributes)
}
}
- if(source.methods.size > 0) {
- destination.methods.addAll(source.methods)
+ if (_source.methods.size > 0) {
+ _destination.methods.addAll(_source.methods)
}
- // e.g: EnumBackingType
- if(source.types.size > 0) {
- destination.types.addAll(source.types)
- }
// Not used so far:
// if(source.broadcasts != null) {
// destination.broadcasts.addAll(source.broadcasts)
// }
- } else {
- throw new IllegalArgumentException("Cannot merge deployments for different interfaces \n(" + source.target + " != " + destination.target + ")!");
+ if (_source.types.size > 0) {
+ _destination.types.addAll(_source.types)
+ }
}
+ }
+
+ def mergeDeployments(FDTypes _source, FDTypes _destination) {
+ if (_source.target.equals(_destination.target)) {
+ if (!_source.types.empty) {
+ _destination.types.addAll(_source.types)
+ }
+ }
}
def public getAllReferencedFInterfaces(FModel fModel)
@@ -1936,4 +2018,64 @@ class FrancaGeneratorExtensions {
fUnionType.elements.forEach[type.addDerivedFTypeTree(fTypeReferences)]
}
}
+ def public supportsTypeValidation(FAttribute fAttribute) {
+ fAttribute.type.derived instanceof FEnumerationType
+ }
+ def public validateType(FAttribute fAttribute, FInterface fInterface) {
+ if (fAttribute.type.derived instanceof FEnumerationType && !fAttribute.array) {
+ "_value.validate()"
+ }
+ else "true"
+ }
+ def public supportsValidation(FTypeRef fTtypeRef) {
+ fTtypeRef.derived instanceof FEnumerationType
+ }
+
+ def public String getCanonical(String _basePath, String _uri) {
+ if (_uri.startsWith("platform:") || _uri.startsWith("file:"))
+ return _uri
+
+ if (_uri.startsWith(File.separatorChar.toString))
+ return "file:" + _uri
+
+ var char separatorCharacter = File.separatorChar;
+ if (_basePath.startsWith("platform:") || _basePath.startsWith("file:")) {
+ separatorCharacter = '/'
+ }
+
+ val String itsCompleteName = _basePath + separatorCharacter + _uri
+ val String[] itsSegments = itsCompleteName.split(separatorCharacter.toString)
+
+ var int ignore = 0
+ var int i = itsSegments.length - 1
+ var List<String> itsCanonicalName = new ArrayList<String>()
+
+ /*
+ * Run from the last segment to the first. Identity segments (.) are ignored,
+ * while backward segments (..) let us ignore the next segment that is neither
+ * identify nor backward. Thus, if several backward segments follow on each other
+ * we increase the number of non-identity/non-backward segments we need to ignore.
+ * Whenever we find a "normal" segment and the "ignore counter" is zero, it is
+ * added to the result, otherwise the "ignore counter" is decreased.
+ */
+ while (i >= 0) {
+ var String itsCurrentSegment = itsSegments.get(i)
+ if (itsCurrentSegment == "..") {
+ ignore = ignore + 1
+ } else if (itsCurrentSegment != ".") {
+ if (ignore == 0) {
+ itsCanonicalName.add(itsCurrentSegment)
+ } else {
+ ignore = ignore - 1
+ }
+ }
+ i = i - 1
+ }
+
+ /*
+ * As we ran from back to front and added segments, we need to reverse,
+ * before joining the segments
+ */
+ return itsCanonicalName.reverse.join(separatorCharacter.toString)
+ }
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/GeneratorFileSystemAccess.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/GeneratorFileSystemAccess.java
new file mode 100644
index 0000000..205a635
--- /dev/null
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/generator/GeneratorFileSystemAccess.java
@@ -0,0 +1,66 @@
+package org.genivi.commonapi.core.generator;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
+
+
+/**
+ * This class adds the feature to printout the generated files to the JavaIoFileSystemAccess implementation.
+ */
+public class GeneratorFileSystemAccess extends JavaIoFileSystemAccess {
+
+ private Set<String> fileList = new HashSet<String>();
+
+ public GeneratorFileSystemAccess() {
+ super();
+ }
+
+ public void clearFileList() {
+ fileList.clear();
+ }
+
+ /**
+ * Call the base class method and store the filename in the list
+ * @param fileName using '/' as file separator
+ * @param contents the to-be-written contents.
+ */
+ public void generateFile(String fileName, CharSequence contents) {
+ // do not generate a file if the contents is empty (feature: suppress code generation)
+ if(contents.length() > 0) {
+ super.generateFile(fileName, contents);
+ }
+ addFilePath(fileName, "");
+ }
+
+ /**
+ * Call the base class method and store the filename in the list
+ * @param fileName using '/' as file separator
+ * @param outputConfigurationName the name of the output configuration
+ * @param contents the to-be-written contents.
+ */
+ public void generateFile(String fileName, String outputConfigurationName, CharSequence contents) {
+ if(contents.length() > 0) {
+ super.generateFile(fileName, outputConfigurationName, contents);
+ }
+ addFilePath(fileName, outputConfigurationName);
+ }
+
+ public void dumpGeneratedFiles() {
+ for(String name : fileList) {
+ System.out.println(name);
+ }
+ }
+
+ public void addFilePath(String fileName, String outputConfigurationName) {
+ String dirName = "";
+ if(!outputConfigurationName.isEmpty()) {
+ dirName = super.getOutputConfig(outputConfigurationName).getOutputDirectory();
+ }
+ if(!dirName.endsWith("/")) {
+ dirName += "/";
+ }
+ fileList.add(dirName + fileName);
+ }
+}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/FPreferences.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/FPreferences.java
index 5a78630..8c27667 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/FPreferences.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/FPreferences.java
@@ -62,21 +62,23 @@ public class FPreferences {
if (!preferences.containsKey(PreferenceConstants.P_OUTPUT_SKELETON)) {
preferences.put(PreferenceConstants.P_OUTPUT_SKELETON, PreferenceConstants.DEFAULT_OUTPUT);
}
-
if (!preferences.containsKey(PreferenceConstants.P_LICENSE)) {
preferences.put(PreferenceConstants.P_LICENSE, PreferenceConstants.DEFAULT_LICENSE);
}
- if (!preferences.containsKey(PreferenceConstants.P_GENERATESTUB)) {
- preferences.put(PreferenceConstants.P_GENERATESTUB, "true");
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_COMMON)) {
+ preferences.put(PreferenceConstants.P_GENERATE_COMMON, "true");
+ }
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_STUB)) {
+ preferences.put(PreferenceConstants.P_GENERATE_STUB, "true");
}
- if (!preferences.containsKey(PreferenceConstants.P_GENERATEPROXY)) {
- preferences.put(PreferenceConstants.P_GENERATEPROXY, "true");
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_PROXY)) {
+ preferences.put(PreferenceConstants.P_GENERATE_PROXY, "true");
}
if (!preferences.containsKey(PreferenceConstants.P_SKELETONPOSTFIX)) {
preferences.put(PreferenceConstants.P_SKELETONPOSTFIX, "Default");
}
- if (!preferences.containsKey(PreferenceConstants.P_GENERATESKELETON)) {
- preferences.put(PreferenceConstants.P_GENERATESKELETON, "false");
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_SKELETON)) {
+ preferences.put(PreferenceConstants.P_GENERATE_SKELETON, "false");
}
if (!preferences.containsKey(PreferenceConstants.P_LOGOUTPUT)) {
preferences.put(PreferenceConstants.P_LOGOUTPUT, "true");
@@ -84,7 +86,15 @@ public class FPreferences {
if (!preferences.containsKey(PreferenceConstants.P_ENUMPREFIX)) {
preferences.put(PreferenceConstants.P_ENUMPREFIX, "");
}
-
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_CODE)) {
+ preferences.put(PreferenceConstants.P_GENERATE_CODE, "true");
+ }
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_DEPENDENCIES)) {
+ preferences.put(PreferenceConstants.P_GENERATE_DEPENDENCIES, "true");
+ }
+ if (!preferences.containsKey(PreferenceConstants.P_GENERATE_SYNC_CALLS)) {
+ preferences.put(PreferenceConstants.P_GENERATE_SYNC_CALLS, "true");
+ }
}
public String getPreference(String preferencename, String defaultValue) {
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java
index 74dc942..9f522da 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/preferences/PreferenceConstants.java
@@ -17,20 +17,25 @@ public interface PreferenceConstants
public static final String PROJECT_PAGEID = "org.genivi.commonapi.core.ui.preferences.CommonAPIPreferencePage";
// preference keys
- public static final String P_LICENSE = "licenseHeader";
- public static final String P_OUTPUT_PROXIES = "outputDirProxies";
- public static final String P_OUTPUT_STUBS = "outputDirStubs";
- public static final String P_OUTPUT_COMMON = "outputDirCommon";
- public static final String P_OUTPUT_SKELETON = "outputDirSkeleton";
- public static final String P_OUTPUT_DEFAULT = "outputDirDefault";
- public static final String P_GENERATEPROXY = "generateproxy";
- public static final String P_GENERATESTUB = "generatestub";
- public static final String P_GENERATESKELETON = "generateskeleton";
- public static final String P_LOGOUTPUT = "logoutput";
- public static final String P_ENUMPREFIX = "enumprefix";
- public static final String P_SKELETONPOSTFIX = "skeletonpostfix";
- public static final String P_USEPROJECTSETTINGS = "useProjectSettings";
-
+ public static final String P_LICENSE = "licenseHeader";
+ public static final String P_OUTPUT_PROXIES = "outputDirProxies";
+ public static final String P_OUTPUT_STUBS = "outputDirStubs";
+ public static final String P_OUTPUT_COMMON = "outputDirCommon";
+ public static final String P_OUTPUT_SKELETON = "outputDirSkeleton";
+ public static final String P_OUTPUT_DEFAULT = "outputDirDefault";
+ public static final String P_GENERATE_COMMON = "generatecommon";
+ public static final String P_GENERATE_PROXY = "generateproxy";
+ public static final String P_GENERATE_STUB = "generatestub";
+ public static final String P_GENERATE_SKELETON = "generateskeleton";
+ public static final String P_LOGOUTPUT = "logoutput";
+ public static final String P_ENUMPREFIX = "enumprefix";
+ public static final String P_SKELETONPOSTFIX = "skeletonpostfix";
+ public static final String P_USEPROJECTSETTINGS = "useProjectSettings";
+ public static final String P_GENERATE_CODE = "generateCode";
+ public static final String P_GENERATE_DEPENDENCIES = "generateDependencies";
+ public static final String P_GENERATE_SYNC_CALLS = "generateSyncCalls";
+ public static final String P_ENABLE_CORE_VALIDATOR = "enableCoreValidator";
+
// preference values
public static final String DEFAULT_OUTPUT = "./src-gen/";
public static final String LOGLEVEL_QUIET = "quiet";
@@ -39,4 +44,5 @@ public interface PreferenceConstants
+ "If a copy of the MPL was not distributed with this file, You can obtain one at\n"
+ "http://mozilla.org/MPL/2.0/.";
public static final String DEFAULT_SKELETONPOSTFIX = "Default";
+ public static final String NO_CODE = "";
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CommandlineValidator.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CommandlineValidator.java
new file mode 100644
index 0000000..d0eb1d4
--- /dev/null
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CommandlineValidator.java
@@ -0,0 +1,297 @@
+package org.genivi.commonapi.core.verification;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.xtext.diagnostics.Severity;
+import org.eclipse.xtext.resource.IResourceServiceProvider;
+import org.eclipse.xtext.util.IAcceptor;
+import org.eclipse.xtext.validation.CheckMode;
+import org.eclipse.xtext.validation.DiagnosticConverterImpl;
+import org.eclipse.xtext.validation.IResourceValidator;
+import org.eclipse.xtext.validation.Issue;
+import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+import org.franca.core.dsl.FrancaIDLRuntimeModule;
+import org.franca.core.dsl.FrancaImportsProvider;
+import org.franca.core.franca.FModel;
+import org.franca.core.franca.Import;
+import org.franca.core.utils.ModelPersistenceHandler;
+import org.franca.deploymodel.dsl.FDeployImportsProvider;
+import org.franca.deploymodel.dsl.fDeploy.FDModel;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class CommandlineValidator {
+
+ private ValidationMessageAcceptor cliMessageAcceptor;
+ private List<String> ignoreList;
+ protected static final String DEPLOYMENT_SPEC = "deployment_spec.fdepl";
+ protected static final String UNKNOWN_DEPLOYMENT_SPEC = "Couldn't resolve reference to FDSpecification";
+ private ResourceSet resourceSet;
+ private boolean hasError = false;
+
+ public CommandlineValidator(ValidationMessageAcceptor cliMessageAcceptor) {
+ this.cliMessageAcceptor = cliMessageAcceptor;
+ resourceSet = new ResourceSetImpl();
+ ignoreList = new ArrayList<String>();
+ }
+
+ private void showError(String message) {
+ hasError = true;
+ cliMessageAcceptor.acceptError(message, null, null, 0, null, (String[])null);
+ }
+
+ private void showWarning(String message) {
+ cliMessageAcceptor.acceptWarning(message, null, null, 0, null, (String[])null);
+ }
+
+ private void showInfo(String message) {
+ cliMessageAcceptor.acceptInfo(message, null, null, 0, null, (String[])null);
+ }
+
+ public void addIgnoreString(String ingnoreText) {
+ ignoreList.add(ingnoreText);
+ }
+
+ public EObject loadResource(Resource resource) {
+ EObject model = null;
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ model = resource.getContents().get(0);
+ } catch (IOException e) {
+ showError("Could not load resource: " + resource.getURI().toFileString());
+ return null;
+ }
+ // check for resource errors, that have been detected during load
+ for (org.eclipse.emf.ecore.resource.Resource.Diagnostic error : resource.getErrors()) {
+ showError(error.getMessage() + " in " + resource.getURI().lastSegment() + " line: " + error.getLine());
+ }
+ return model;
+ }
+
+ public void validateImports(FModel model, URI fidlUri) {
+ for (Import inport : model.getImports()) {
+ // check existence of imported fidl files
+ if (inport.getImportURI().endsWith("fidl")) {
+ URI importUri = URI.createURI(inport.getImportURI());
+ URI fullImportUri = importUri.resolve(fidlUri);
+ File file = new File(fullImportUri.toFileString());
+ if (!file.exists()) {
+ showError("Imported file does not exist: " + inport.getImportURI());
+ }
+ }
+ }
+ }
+
+ public void validateImports(FDModel model, URI fdeplUri) {
+
+ for (org.franca.deploymodel.dsl.fDeploy.Import inport : model
+ .getImports()) {
+ URI importUri = URI.createURI(inport.getImportURI());
+ URI fullImportUri = importUri.resolve(fdeplUri);
+ try {
+ new File(fullImportUri.toFileString());
+ } catch (Exception e) {
+ // - tolerate "import ..../xxx_deployment_spec.fdepl"
+ if (inport.getImportURI().endsWith(DEPLOYMENT_SPEC)) {
+ // dont log an error, if the deployment spec could not be found
+ } else {
+ showError("Imported file does not exist: " + inport.getImportURI());
+ }
+ }
+ }
+ }
+
+ /**
+ * validate the contents of the fidl/fdepl file
+ * @param resource
+ */
+ public void validateResource(Resource resource) {
+ IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE
+ .getResourceServiceProvider(resource.getURI());
+ if (resourceServiceProvider != null) {
+ IResourceValidator resourceValidator = resourceServiceProvider
+ .getResourceValidator();
+ Collection<Issue> issues = resourceValidator.validate(resource,
+ CheckMode.ALL, null);
+ if (!issues.isEmpty()) {
+ for (Issue issue : issues) {
+ if (issue.getSeverity() == Severity.ERROR) {
+ // ignore certain errors due to unknown deployment specs (SomeIP/DBus)
+ if(isErrorToIgnore(issue)) {
+ continue;
+ }
+ showError(issue.toString());
+ } else {
+ showWarning(issue.toString());
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * validate the contents of the fidl/fdepl file and all its imports
+ * @param resource
+ */
+ public void validateResourceWithImports(Resource resource) {
+
+ validateResource(resource);
+
+ EObject model = loadResource(resource);
+
+ if (model != null) {
+ if (model instanceof FModel) {
+ FModel fmodel = (FModel) model;
+
+ validateImports(fmodel, resource.getURI());
+
+ if (!hasError) {
+ for (Import fimport : fmodel.getImports()) {
+ String uriString = fimport.getImportURI();
+ URI importUri = URI.createURI(uriString);
+ //System.out.println("Validating import " + importUri.lastSegment());
+ URI resolvedUri = importUri.resolve(resource.getURI());
+ Resource importedResource = resourceSet.getResource(
+ resolvedUri, true);
+ validateResourceWithImports(importedResource);
+ }
+ }
+ }
+ }
+ }
+
+
+ private boolean isErrorToIgnore(Issue issue) {
+ for(String ignoreString : ignoreList) {
+ if(issue.toString().contains(ignoreString)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Validate the deployment on a global scope by loading all referenced FDEPL and FIDL files and by performing deployment
+ * specific validations which need to run at such a scope (e.g. checking interface dependencies between FDEPL and FIDL files)
+ *
+ * @param resourcePathUri URI to the FDEPL file
+ * @return
+ */
+ public boolean validateDeployment(URI resourcePathUri)
+ {
+ if ("fdepl".equals(resourcePathUri.fileExtension()))
+ {
+ // Load the FIDL and all imported FIDL files, or the FDEPL and all imported FDEPL/FIDL files.
+ //
+ ModelPersistenceHandler.registerFileExtensionHandler("fidl", new FrancaImportsProvider());
+ ModelPersistenceHandler.registerFileExtensionHandler("fdepl", new FDeployImportsProvider());
+ Injector injector = Guice.createInjector(new FrancaIDLRuntimeModule());
+ ModelPersistenceHandler modelPersistenceHandler = new ModelPersistenceHandler(injector.getInstance(ResourceSet.class));
+ URI rootPathUri = URI.createPlatformResourceURI("/", true);
+ modelPersistenceHandler.loadModel(resourcePathUri, rootPathUri);
+
+ if (!validateDeployment(modelPersistenceHandler.getResourceSet()))
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean validateDeployment(ResourceSet resourceSet)
+ {
+ boolean hasValidationError = false;
+
+ List<FDModel> fdeplModels = new ArrayList<FDModel>();
+ for (Resource resource : resourceSet.getResources())
+ {
+ for (EObject eObject : resource.getContents())
+ {
+ if (eObject instanceof FDModel)
+ {
+ fdeplModels.add((FDModel)eObject);
+ }
+ }
+ }
+
+ List<Diagnostic> diags = validateDeployment(fdeplModels);
+ if (diags != null)
+ {
+ int numErrors = 0, numWarnings = 0;
+ final List<Issue> issues = new ArrayList<Issue>();
+ IAcceptor<Issue> acceptor = new IAcceptor<Issue>()
+ {
+ @Override
+ public void accept(Issue issue)
+ {
+ issues.add(issue);
+ }
+ };
+ DiagnosticConverterImpl converter = new DiagnosticConverterImpl();
+ for (Diagnostic diag : diags)
+ {
+ converter.convertValidatorDiagnostic(diag, acceptor);
+ if (diag.getSeverity() == Diagnostic.ERROR) {
+ numErrors++;
+ hasValidationError = true;
+ }
+ else if (diag.getSeverity() == Diagnostic.WARNING)
+ numWarnings++;
+ }
+ if (!outputIssues(issues))
+ hasValidationError = true;
+ showInfo("Validaton of deployment finished with: " + numErrors + " errors, " + numWarnings + " warnings.");
+ }
+
+ return !hasValidationError;
+ }
+
+ private boolean outputIssues(Collection<Issue> issues)
+ {
+ boolean hasValidationError = false;
+ for (Issue issue : issues)
+ {
+ // 'Issue' messages already add their own message type prefix, but our issue acceptors will add another one.
+ //
+ String msg = issue.toString();
+ if (issue.getSeverity() == Severity.ERROR) {
+ hasValidationError = true;
+ showError(stripMessageType(msg, "ERROR:"));
+ }
+ else if (issue.getSeverity() == Severity.WARNING)
+ showWarning(stripMessageType(msg, "WARNING:"));
+ else
+ showInfo(msg = stripMessageType(msg, "INFO:"));
+ }
+ return !hasValidationError;
+ }
+
+ private String stripMessageType(String msg, String type)
+ {
+ if (msg.startsWith(type))
+ msg = msg.substring(type.length()).trim();
+ return msg;
+ }
+
+ /**
+ * Perform deployment specific validation.
+ *
+ * @param fdepls List of FDEPL files. This list contains already all resolved FDEPL imported files.
+ * @return List of {@link org.eclipse.emf.common.util.Diagnostic}. 'null' if function is not implemented.
+ */
+ protected List<Diagnostic> validateDeployment(List<FDModel> fdepls)
+ {
+ return null;
+ }
+}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CppKeywords.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CppKeywords.java
index de5c0a2..203dfa9 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CppKeywords.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/CppKeywords.java
@@ -102,6 +102,8 @@ public class CppKeywords {
keyWords.add("xor_eq");
keyWords.add("AnonymousTypeCollection");
+ keyWords.add("instance");
+ keyWords.add("attributes");
}
}
diff --git a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/ValidatorCore.java b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/ValidatorCore.java
index 0f4eb4c..c7bb7e9 100644
--- a/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/ValidatorCore.java
+++ b/org.genivi.commonapi.core/src/org/genivi/commonapi/core/verification/ValidatorCore.java
@@ -38,7 +38,7 @@ import org.franca.core.franca.FStructType;
import org.franca.core.franca.FType;
import org.franca.core.franca.FTypeCollection;
import org.franca.core.franca.FrancaPackage;
-import org.osgi.framework.BundleReference;
+import org.genivi.commonapi.core.generator.FrancaGeneratorExtensions;
import org.osgi.framework.Version;
/**
@@ -57,7 +57,8 @@ public class ValidatorCore implements IFrancaExternalValidator {
public void validateModel(FModel model,
ValidationMessageAcceptor messageAcceptor) {
- acceptInfo("model " + model.getName(), messageAcceptor);
+ // don't log the good case
+ //acceptInfo("model " + model.getName(), messageAcceptor);
List<String> interfaceTypecollectionNames = new ArrayList<String>();
for (FTypeCollection fTypeCollection : model.getTypeCollections()) {
@@ -93,11 +94,13 @@ public class ValidatorCore implements IFrancaExternalValidator {
startI.add(fInterface);
ArrayList<FInterface> managedList = new ArrayList<FInterface>();
for (FInterface managedInterface : fInterface.getManagedInterfaces()) {
+ // check that the interface name is not null
if(managedInterface.getName() == null) {
acceptError("unknown managed interface: " + managedInterface.getName(), fInterface,
FrancaPackage.Literals.FINTERFACE__MANAGED_INTERFACES, index, messageAcceptor);
} else {
- acceptInfo("managed interface: " + managedInterface.getName(), messageAcceptor);
+ // don't log the good case
+ //acceptInfo("managed interface: " + managedInterface.getName(), messageAcceptor);
}
findCyclicManagedInterfaces(managedInterface, startI, fInterface,
messageAcceptor, index, false);
@@ -112,6 +115,10 @@ public class ValidatorCore implements IFrancaExternalValidator {
}
}
+ /**
+ * Find interfaces that manage itself
+ *
+ */
private void findCyclicManagedInterfaces(FInterface rekInterface,
ArrayList<FInterface> interfaceList, FInterface fInterface,
ValidationMessageAcceptor messageAcceptor, int index,
@@ -247,8 +254,8 @@ public class ValidatorCore implements IFrancaExternalValidator {
ValidationMessageAcceptor messageAcceptor,
List<String> interfaceTypecollectionNames,
FTypeCollection fTypeCollection) {
-
- acceptInfo("type collection: " + fTypeCollection.getName(), messageAcceptor);
+ // don't log the good case
+ //acceptInfo("type collection: " + fTypeCollection.getName(), messageAcceptor);
validateName(messageAcceptor,
fTypeCollection);
@@ -286,7 +293,8 @@ public class ValidatorCore implements IFrancaExternalValidator {
protected void validateFInterfaceElements(
ValidationMessageAcceptor messageAcceptor, FInterface fInterface) {
- acceptInfo("interface elements: " + fInterface.getName(), messageAcceptor);
+ // don't log the good case
+ //acceptInfo("interface elements: " + fInterface.getName(), messageAcceptor);
if (fInterface.getVersion() == null)
acceptError("Missing version! Add: version(major int minor int)",
fInterface, FrancaPackage.Literals.FMODEL_ELEMENT__NAME,
@@ -325,8 +333,7 @@ public class ValidatorCore implements IFrancaExternalValidator {
}
private boolean isFrancaVersionGreaterThan(int major, int minor, int micro) {
- Version francaVersion = ((BundleReference) FArgument.class
- .getClassLoader()).getBundle().getVersion();
+ Version francaVersion = Version.parseVersion(FrancaGeneratorExtensions.getFrancaVersion());
if (francaVersion.getMajor() > major) {
return true;
}
diff --git a/org.genivi.commonapi.releng/pom.xml b/org.genivi.commonapi.releng/pom.xml
index 3e1be03..21cb8c2 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.3-SNAPSHOT</version>
+ <version>3.1.4-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.3-SNAPSHOT</version>
+ <version>3.1.4-SNAPSHOT</version>
</artifact>
</target>
<filters>