Skip to content

Commit

Permalink
CommonAPI-SomeIP-Tools 3.1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
juergengehring committed Feb 28, 2017
1 parent 8d9344e commit c58fc26
Show file tree
Hide file tree
Showing 50 changed files with 984 additions and 49 deletions.
87 changes: 85 additions & 2 deletions CommonAPI-Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ endif()
message("CommonAPI_CONSIDERED_CONFIGS: ${CommonAPI_CONSIDERED_CONFIGS}")
message("COMMONAPI_INCLUDE_DIRS: ${COMMONAPI_INCLUDE_DIRS}")

find_package (CommonAPI-SomeIP 3.1.10 REQUIRED)
find_package (vsomeip 2.5.0 REQUIRED)
find_package (CommonAPI-SomeIP 3.1.11 REQUIRED)
find_package (vsomeip 2.5.3 REQUIRED)

include_directories (
${COMMONAPI_INCLUDE_DIRS}
Expand Down Expand Up @@ -316,3 +316,86 @@ target_link_libraries (
CommonAPI
${DL_LIBRARY}
)

# path A
set(PRJ_SRC_GEN_COMMONAPI_PATH_A src-gen/v1/commonapi/examples/A)
set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_A src-gen/v1/commonapi/examples/A)
# path B
set(PRJ_SRC_GEN_COMMONAPI_PATH_B src-gen/v1/commonapi/examples/B)
set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_B src-gen/v1/commonapi/examples/B)
# path C
set(PRJ_SRC_GEN_COMMONAPI_PATH_C src-gen/v2/commonapi/examples/C)
set(PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_C src-gen/v2/commonapi/examples/C)

# name A
set(PRJ_NAME_CLIENT_A MergedInterfaceClientA)
set(PRJ_NAME_SERVICE_A MergedInterfaceServiceA)
# name B
set(PRJ_NAME_CLIENT_B MergedInterfaceClientB)
set(PRJ_NAME_SERVICE_B MergedInterfaceServiceB)
# name C
set(PRJ_NAME_CLIENT_C MergedInterfaceClientC)
set(PRJ_NAME_SERVICE_C MergedInterfaceServiceC)

# Application A
FILE(GLOB PRJ_PROXY_GEN_SRCS_A ${PRJ_SRC_GEN_COMMONAPI_PATH_A}/*Proxy.cpp)
FILE(GLOB PRJ_STUB_GEN_SRCS_A ${PRJ_SRC_GEN_COMMONAPI_PATH_A}/*Stub*.cpp)
FILE(GLOB PRJ_STUB_IMPL_SRCS_A ${PRJ_SRC_COMMONAPI_PATH_A}/*Stub*.cpp)
# Application B
FILE(GLOB PRJ_PROXY_GEN_SRCS_B ${PRJ_SRC_GEN_COMMONAPI_PATH_B}/*Proxy.cpp)
FILE(GLOB PRJ_STUB_GEN_SRCS_B ${PRJ_SRC_GEN_COMMONAPI_PATH_B}/*Stub*.cpp)
FILE(GLOB PRJ_STUB_IMPL_SRCS_B ${PRJ_SRC_COMMONAPI_PATH_B}/*Stub*.cpp)
# Application C
FILE(GLOB PRJ_PROXY_GEN_SRCS_C ${PRJ_SRC_GEN_COMMONAPI_PATH_C}/*Proxy.cpp)
FILE(GLOB PRJ_STUB_GEN_SRCS_C ${PRJ_SRC_GEN_COMMONAPI_PATH_C}/*Stub*.cpp)
FILE(GLOB PRJ_STUB_IMPL_SRCS_C ${PRJ_SRC_COMMONAPI_PATH_C}/*Stub*.cpp)

# sources A
set(PRJ_CLIENT_SRCS_A src/A/${PRJ_NAME_CLIENT_A}.cpp ${PRJ_PROXY_GEN_SRCS_A})
set(PRJ_SERVICE_SRCS_A src/A/${PRJ_NAME_SERVICE_A}.cpp src/A/MergedInterfaceStubImplA.cpp ${PRJ_STUB_GEN_SRCS_A} ${PRJ_STUB_IMPL_SRCS_A})
#sources B
set(PRJ_CLIENT_SRCS_B src/B/${PRJ_NAME_CLIENT_B}.cpp ${PRJ_PROXY_GEN_SRCS_B})
set(PRJ_SERVICE_SRCS_B src/B/${PRJ_NAME_SERVICE_B}.cpp src/B/MergedInterfaceStubImplB.cpp ${PRJ_STUB_GEN_SRCS_B} ${PRJ_STUB_IMPL_SRCS_B})
# sources C
set(PRJ_CLIENT_SRCS_C src/C/${PRJ_NAME_CLIENT_C}.cpp ${PRJ_PROXY_GEN_SRCS_C})
set(PRJ_SERVICE_SRCS_C src/C/${PRJ_NAME_SERVICE_C}.cpp src/C/MergedInterfaceStubImplC.cpp ${PRJ_STUB_GEN_SRCS_C} ${PRJ_STUB_IMPL_SRCS_C})

# SOME/IP library A
FILE(GLOB PRJ_SOMEIP_LIB_SRCS_A ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_A}/*cpp)
# SOME/IP library B
FILE(GLOB PRJ_SOMEIP_LIB_SRCS_B ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_B}/*cpp)
# SOME/IP library C
FILE(GLOB PRJ_SOMEIP_LIB_SRCS_C ${PRJ_SRC_GEN_COMMONAPI_SOMEIP_PATH_C}/*cpp)

set(LINK_LIBRARIES -Wl,--as-needed CommonAPI CommonAPI-SomeIP)

# Build Client A
add_executable(${PRJ_NAME_CLIENT_A} ${PRJ_CLIENT_SRCS_A})
target_link_libraries(${PRJ_NAME_CLIENT_A} ${LINK_LIBRARIES})
# Build Client B
add_executable(${PRJ_NAME_CLIENT_B} ${PRJ_CLIENT_SRCS_B})
target_link_libraries(${PRJ_NAME_CLIENT_B} ${LINK_LIBRARIES})
# Build Client C
add_executable(${PRJ_NAME_CLIENT_C} ${PRJ_CLIENT_SRCS_C})
target_link_libraries(${PRJ_NAME_CLIENT_C} ${LINK_LIBRARIES})

# Build service A
add_executable(${PRJ_NAME_SERVICE_A} ${PRJ_SERVICE_SRCS_A})
target_link_libraries(${PRJ_NAME_SERVICE_A} ${LINK_LIBRARIES})
# Build service B
add_executable(${PRJ_NAME_SERVICE_B} ${PRJ_SERVICE_SRCS_B})
target_link_libraries(${PRJ_NAME_SERVICE_B} ${LINK_LIBRARIES})
# Build service C
add_executable(${PRJ_NAME_SERVICE_C} ${PRJ_SERVICE_SRCS_C})
target_link_libraries(${PRJ_NAME_SERVICE_C} ${LINK_LIBRARIES})

# Build SOME/IP library A
add_library (MergedInterface-A-someip SHARED ${PRJ_SOMEIP_LIB_SRCS_A})
target_link_libraries(MergedInterface-A-someip CommonAPI-SomeIP)
# Build SOME/IP library B
add_library (MergedInterface-B-someip SHARED ${PRJ_SOMEIP_LIB_SRCS_B})
target_link_libraries(MergedInterface-B-someip CommonAPI-SomeIP)
# Build SOME/IP library C
add_library (MergedInterface-C-someip SHARED ${PRJ_SOMEIP_LIB_SRCS_C})
target_link_libraries(MergedInterface-C-someip CommonAPI-SomeIP)

13 changes: 13 additions & 0 deletions CommonAPI-Examples/commonapi-someip-aliases.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[aliases]
service:0x1234:0x5678:0x01:0x00=0x1236:0x5678:0x02:0x01
service:0x1235:0x5678:0x01:0x00=0x1236:0x5678:0x02:0x01
method:0x1234:0x5678:0x01:0x00:0x3E8=0x1236:0x5678:0x02:0x01:0x1388
method:0x1234:0x5678:0x01:0x00:0x3E9=0x1236:0x5678:0x02:0x01:0x1389
event:0x1234:0x5678:0x01:0x00:0x2B02=0x1236:0x5678:0x02:0x01:0xD6E2
eventgroup:0x1234:0x5678:0x01:0x00:0x2B02=0x1236:0x5678:0x02:0x01:0xD6E2
method:0x1235:0x5678:0x01:0x00:0xBB8=0x1236:0x5678:0x02:0x01:0x2BC
method:0x1235:0x5678:0x01:0x00:0xBB9=0x1236:0x5678:0x02:0x01:0x2BD
event:0x1235:0x5678:0x01:0x00:0x80F2=0x1236:0x5678:0x02:0x01:0x1E1E
eventgroup:0x1235:0x5678:0x01:0x00:0x80F2=0x1236:0x5678:0x02:0x01:0x1E1E


44 changes: 44 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceA.fdepl
Original file line number Diff line number Diff line change
@@ -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/. */

import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "MergedInterfaceA.fidl"

define org.genivi.commonapi.someip.deployment for interface commonapi.examples.A.MergedInterfaceA {
SomeIpServiceID = 4660

attribute x1 {
SomeIpGetterID = 1000
SomeIpSetterID = 1001
SomeIpNotifierID = 11010
SomeIpEventGroups = { 11010 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}

attribute x2 {
SomeIpGetterID = 2000
SomeIpSetterID = 2001
SomeIpNotifierID = 22010
SomeIpEventGroups = { 22010 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}
}


define org.genivi.commonapi.someip.deployment for provider Service {
instance commonapi.examples.A.MergedInterfaceA {
InstanceId = "commonapi.examples.A.MergedInterfaceA"
SomeIpInstanceID = 22136
SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30499
SomeIpUnreliableUnicastPort = 30500
}
}
14 changes: 14 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceA.fidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* 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/. */

package commonapi.examples.A

interface MergedInterfaceA {
version { major 1 minor 0 }

attribute Int32 x1
attribute Int32 x2
}

44 changes: 44 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceB.fdepl
Original file line number Diff line number Diff line change
@@ -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/. */

import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "MergedInterfaceB.fidl"

define org.genivi.commonapi.someip.deployment for interface commonapi.examples.B.MergedInterfaceB {
SomeIpServiceID = 4661

attribute x3 {
SomeIpGetterID = 3000
SomeIpSetterID = 3001
SomeIpNotifierID = 33010
SomeIpEventGroups = { 33010 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}

attribute x4 {
SomeIpGetterID = 4000
SomeIpSetterID = 4001
SomeIpNotifierID = 44010
SomeIpEventGroups = { 44010 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}
}


define org.genivi.commonapi.someip.deployment for provider Service {
instance commonapi.examples.B.MergedInterfaceB {
InstanceId = "commonapi.examples.B.MergedInterfaceB"
SomeIpInstanceID = 22136
SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30499
SomeIpUnreliableUnicastPort = 30500
}
}
14 changes: 14 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceB.fidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* 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/. */

package commonapi.examples.B

interface MergedInterfaceB {
version { major 1 minor 0 }

attribute Int32 x3
attribute Int32 x4
}

66 changes: 66 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceC.fdepl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import "platform:/plugin/org.genivi.commonapi.someip/deployment/CommonAPI-SOMEIP_deployment_spec.fdepl"
import "MergedInterfaceC.fidl"

define org.genivi.commonapi.someip.deployment for interface commonapi.examples.C.MergedInterfaceC {
SomeIpServiceID = 4662

attribute x1 {
SomeIpGetterID = 5000
SomeIpSetterID = 5001
SomeIpNotifierID = 55010
SomeIpEventGroups = { 55010 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}

attribute x2 {
SomeIpGetterID = 600
SomeIpSetterID = 601
SomeIpNotifierID = 6610
SomeIpEventGroups = { 6610 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}

attribute x3 {
SomeIpGetterID = 700
SomeIpSetterID = 701
SomeIpNotifierID = 7710
SomeIpEventGroups = { 7710 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}

attribute x4 {
SomeIpGetterID = 800
SomeIpSetterID = 801
SomeIpNotifierID = 8810
SomeIpEventGroups = { 8810 }

SomeIpGetterReliable = true
SomeIpSetterReliable = true
SomeIpNotifierReliable = true
}
}


define org.genivi.commonapi.someip.deployment for provider Service {
instance commonapi.examples.C.MergedInterfaceC {
InstanceId = "commonapi.examples.C.MergedInterfaceC"
SomeIpInstanceID = 22136
SomeIpUnicastAddress = "192.168.0.2"
SomeIpReliableUnicastPort = 30499
SomeIpUnreliableUnicastPort = 30500
}
}
16 changes: 16 additions & 0 deletions CommonAPI-Examples/fidl/MergedInterfaceC.fidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* 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/. */

package commonapi.examples.C

interface MergedInterfaceC {
version { major 2 minor 1 }

attribute Int32 x1
attribute Int32 x2
attribute Int32 x3
attribute Int32 x4
}

78 changes: 78 additions & 0 deletions CommonAPI-Examples/src/A/MergedInterfaceClientA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* 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>

#ifndef _WIN32
#include <unistd.h>
#endif

#include <CommonAPI/CommonAPI.hpp>
#include <CommonAPI/Extensions/AttributeCacheExtension.hpp>
#include <v1/commonapi/examples/A/MergedInterfaceAProxy.hpp>

using namespace v1::commonapi::examples::A;

void recv_cb(const CommonAPI::CallStatus& callStatus, const int32_t& val) {
std::cout << "Receive callback: " << val << std::endl;
}

int main() {
CommonAPI::Runtime::setProperty("LogContext", "E02CA");
CommonAPI::Runtime::setProperty("LogApplication", "E02CA");
CommonAPI::Runtime::setProperty("LibraryBase", "MergedInterface-A");

std::shared_ptr < CommonAPI::Runtime > runtime = CommonAPI::Runtime::get();

std::string domain = "local";
std::string instance = "commonapi.examples.A.MergedInterfaceA";
std::string connection = "client-sample";

auto myProxy = runtime->buildProxyWithDefaultAttributeExtension<MergedInterfaceAProxy, CommonAPI::Extensions::AttributeCacheExtension>(domain, instance, connection);

std::cout << "Waiting for service to become available." << std::endl;
while (!myProxy->isAvailable()) {
std::this_thread::sleep_for(std::chrono::microseconds(10));
}

CommonAPI::CallStatus callStatus;

int32_t value = 0;

CommonAPI::CallInfo info(1000);
info.sender_ = 5678;

// Get actual attribute value from service
std::cout << "Proxy A getting attribute X1 value: " << value << std::endl;
myProxy->getX1Attribute().getValue(callStatus, value, &info);
if (callStatus != CommonAPI::CallStatus::SUCCESS) {
std::cerr << "Remote call A failed!\n";
return -1;
}
std::cout << "Proxy A got attribute X1 value: " << value << std::endl;

// Subscribe for receiving values
myProxy->getX1Attribute().getChangedEvent().subscribe([&](const int32_t& val) {
std::cout << "Proxy A received attribute X1 change message: " << val << std::endl;
});

value = 100;

// Asynchronous call to set attribute of service
std::function<void(const CommonAPI::CallStatus&, int32_t)> fcb = recv_cb;
myProxy->getX1Attribute().setValueAsync(value, fcb, &info);


while (true) {
int32_t errorValue = -1;
int32_t valueCached = *myProxy->getX1AttributeExtension().getCachedValue(errorValue);
if (valueCached != errorValue) {
std::cout << "Proxy A ot cached attribute X1 value[" << (int)valueCached << "]: " << valueCached << std::endl;
} else {
std::cout << "Proxy A got cached attribute X1 error value[" << (int)valueCached << "]: " << valueCached << std::endl;
}
std::this_thread::sleep_for(std::chrono::microseconds(1000000));
}
}

0 comments on commit c58fc26

Please sign in to comment.