├── .clang-format ├── .clang-tidy ├── .conan └── profiles │ ├── linux-aarch64 │ └── linux-x86_64 ├── .devcontainer ├── Dockerfile ├── devcontainer.json └── scripts │ ├── configure-codespaces.sh │ ├── configure-proxies.sh │ ├── container-set.sh │ ├── onCreateCommand.sh │ ├── postStartCommand.sh │ ├── reinstall-cmake.sh │ ├── setup-dependencies.sh │ ├── setup-git.sh │ └── upgrade-cli.sh ├── .dockerignore ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── feature-request.yml │ └── question.yml ├── PULL_REQUEST_TEMPLATE.md ├── scripts │ ├── deploy_image_from_artifact.sh │ └── junit.tpl └── workflows │ ├── check-licenses.yml │ ├── check-updates.yml │ ├── ci.yml │ └── ensure-lifecycle.yml ├── .gitignore ├── .licensechecker.yml ├── .pre-commit-config.yaml ├── .scripts ├── common.sh └── test_package.sh ├── .velocitas-lock.json ├── .velocitas.json ├── .vscode ├── c_cpp_properties.json ├── launch.json └── tasks.json ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CPPLINT.cfg ├── LICENSE ├── NOTICE-3RD-PARTY-CONTENT.md ├── NOTICE.md ├── README.md ├── SECURITY.md ├── build.sh ├── conanfile.py ├── examples ├── CMakeLists.txt ├── example_model │ ├── CMakeLists.txt │ └── vehicle │ │ ├── Cabin │ │ ├── Cabin.h │ │ └── Seat │ │ │ └── Seat.h │ │ └── Vehicle.h ├── grpc_client │ ├── AppManifest.json │ ├── CMakeLists.txt │ ├── README.md │ └── src │ │ ├── CMakeLists.txt │ │ └── Launcher.cpp ├── grpc_server │ ├── AppManifest.json │ ├── CMakeLists.txt │ ├── README.md │ └── src │ │ ├── CMakeLists.txt │ │ ├── Launcher.cpp │ │ ├── SeatsServiceImpl.cpp │ │ └── SeatsServiceImpl.h ├── performance-subscribe │ ├── AppManifest.json │ ├── CMakeLists.txt │ ├── README.md │ ├── src │ │ ├── Launcher.cpp │ │ ├── PerformanceTestApp.cpp │ │ └── PerformanceTestApp.h │ └── subscription_signals.json ├── seat-adjuster │ ├── AppManifest.json │ ├── CMakeLists.txt │ └── src │ │ ├── SeatAdjusterApp.cpp │ │ └── SeatAdjusterApp.h └── set-data-points │ ├── AppManifest.json │ ├── CMakeLists.txt │ └── src │ └── SetDataPointsApp.cpp ├── gcovr.cfg ├── install_dependencies.sh ├── license_header.txt ├── requirements.txt ├── sdk ├── CMakeLists.txt ├── include │ └── sdk │ │ ├── AsyncResult.h │ │ ├── DataPoint.h │ │ ├── DataPointBatch.h │ │ ├── DataPointReply.h │ │ ├── DataPointValue.h │ │ ├── Exceptions.h │ │ ├── IPubSubClient.h │ │ ├── Job.h │ │ ├── Logger.h │ │ ├── Model.h │ │ ├── Node.h │ │ ├── QueryBuilder.h │ │ ├── Status.h │ │ ├── ThreadPool.h │ │ ├── Utils.h │ │ ├── VehicleApp.h │ │ ├── VehicleModelContext.h │ │ ├── grpc │ │ ├── AsyncGrpcFacade.h │ │ ├── GrpcCall.h │ │ └── GrpcClient.h │ │ ├── middleware │ │ └── Middleware.h │ │ └── vdb │ │ └── IVehicleDataBrokerClient.h ├── proto │ ├── CMakeLists.txt │ ├── kuksa │ │ └── val │ │ │ └── v2 │ │ │ ├── types.proto │ │ │ └── val.proto │ └── sdv │ │ └── databroker │ │ └── v1 │ │ ├── broker.proto │ │ ├── collector.proto │ │ └── types.proto ├── src │ ├── CMakeLists.txt │ └── sdk │ │ ├── DataPoint.cpp │ │ ├── DataPointValue.cpp │ │ ├── Job.cpp │ │ ├── Logger.cpp │ │ ├── Model.cpp │ │ ├── Node.cpp │ │ ├── QueryBuilder.cpp │ │ ├── ThreadPool.cpp │ │ ├── Utils.cpp │ │ ├── VehicleApp.cpp │ │ ├── grpc │ │ ├── AsyncGrpcFacade.cpp │ │ └── GrpcClient.cpp │ │ ├── middleware │ │ ├── Middleware.cpp │ │ ├── NativeMiddleware.cpp │ │ └── NativeMiddleware.h │ │ ├── pubsub │ │ └── MqttPubSubClient.cpp │ │ └── vdb │ │ ├── DataPointBatch.cpp │ │ ├── IVehicleDataBrokerClient.cpp │ │ └── grpc │ │ ├── common │ │ ├── ChannelConfiguration.cpp │ │ ├── ChannelConfiguration.h │ │ ├── TypeConversions.cpp │ │ └── TypeConversions.h │ │ ├── kuksa_val_v2 │ │ ├── BrokerAsyncGrpcFacade.cpp │ │ ├── BrokerAsyncGrpcFacade.h │ │ ├── BrokerClient.cpp │ │ ├── BrokerClient.h │ │ ├── Metadata.cpp │ │ ├── Metadata.h │ │ ├── TypeConversions.cpp │ │ └── TypeConversions.h │ │ └── sdv_databroker_v1 │ │ ├── BrokerAsyncGrpcFacade.cpp │ │ ├── BrokerAsyncGrpcFacade.h │ │ ├── BrokerClient.cpp │ │ ├── BrokerClient.h │ │ ├── GrpcDataPointValueProvider.cpp │ │ ├── GrpcDataPointValueProvider.h │ │ └── IDataPointValueProvider.h └── tests │ ├── CMakeLists.txt │ ├── mocks │ └── VehicleDataBrokerClientMock.h │ ├── model │ └── Vehicle.h │ └── unit │ ├── AsyncResult_tests.cpp │ ├── AsyncSubscription_tests.cpp │ ├── CMakeLists.txt │ ├── DataPointBatch_tests.cpp │ ├── DataPointValue_tests.cpp │ ├── DataPoint_tests.cpp │ ├── Job_tests.cpp │ ├── Logger_tests.cpp │ ├── Middleware_tests.cpp │ ├── NativeMiddleware_tests.cpp │ ├── Node_tests.cpp │ ├── PubSub_tests.cpp │ ├── QueryBuilder_tests.cpp │ ├── ScopedBoolInverter_tests.cpp │ ├── TestBaseUsingEnvVars.cpp │ ├── TestBaseUsingEnvVars.h │ ├── ThreadPool_tests.cpp │ ├── Utils_tests.cpp │ ├── grpc │ └── GrpcClient_tests.cpp │ ├── testmain.cpp │ └── vdb │ └── grpc │ ├── kuksa_val_v2 │ └── TypeConversions_tests.cpp │ └── sdv_databroker_v1 │ └── BrokerClient_tests.cpp ├── test_package ├── CMakeLists.txt ├── conanfile.py └── main.cpp └── whitelisted-licenses.txt /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | Checks: 'clang-analyzer-*, 3 | cppcoreguidelines-*, 4 | modernize-*, 5 | readability-*, 6 | -google-readability-todo, 7 | -readability-convert-member-functions-to-static, 8 | -bugprone-branch-clone, 9 | -cppcoreguidelines-avoid-non-const-global-variables, 10 | -modernize-use-equals-default, 11 | -modernize-use-trailing-return-type, 12 | -readability-make-member-function-const' 13 | HeaderFilterRegex: 'include' 14 | WarningsAsErrors: 'clang-analyzer-*, 15 | modernize-*, 16 | cppcoreguidelines-*, 17 | readability-*, 18 | -google-readability-todo, 19 | -readability-convert-member-functions-to-static, 20 | -bugprone-branch-clone, 21 | -cppcoreguidelines-avoid-non-const-global-variables, 22 | -modernize-use-equals-default, 23 | -modernize-use-trailing-return-type, 24 | -readability-make-member-function-const' 25 | AnalyzeTemporaryDtors: false 26 | FormatStyle: file 27 | CheckOptions: 28 | - key: cert-dcl16-c.NewSuffixes 29 | value: 'L;LL;LU;LLU' 30 | - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField 31 | value: '0' 32 | - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors 33 | value: '1' 34 | - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic 35 | value: '1' 36 | - key: google-readability-braces-around-statements.ShortStatementLines 37 | value: '1' 38 | - key: google-readability-function-size.StatementThreshold 39 | value: '800' 40 | - key: google-readability-namespace-comments.ShortNamespaceLines 41 | value: '10' 42 | - key: google-readability-namespace-comments.SpacesBeforeComments 43 | value: '2' 44 | - key: modernize-loop-convert.MaxCopySize 45 | value: '16' 46 | - key: modernize-loop-convert.MinConfidence 47 | value: reasonable 48 | - key: modernize-loop-convert.NamingStyle 49 | value: CamelCase 50 | - key: modernize-pass-by-value.IncludeStyle 51 | value: llvm 52 | - key: modernize-replace-auto-ptr.IncludeStyle 53 | value: llvm 54 | - key: modernize-use-nullptr.NullMacros 55 | value: 'NULL' 56 | ... 57 | -------------------------------------------------------------------------------- /.conan/profiles/linux-aarch64: -------------------------------------------------------------------------------- 1 | [settings] 2 | os=Linux 3 | arch=armv8 4 | compiler=gcc 5 | compiler.version=11 6 | compiler.cppstd=17 7 | compiler.libcxx=libstdc++11 8 | 9 | [buildenv] 10 | CC=aarch64-linux-gnu-gcc-11 11 | CXX=aarch64-linux-gnu-g++-11 12 | LD=aarch64-linux-gnu-ld 13 | -------------------------------------------------------------------------------- /.conan/profiles/linux-x86_64: -------------------------------------------------------------------------------- 1 | [settings] 2 | os=Linux 3 | arch=x86_64 4 | compiler=gcc 5 | compiler.version=11 6 | compiler.cppstd=17 7 | compiler.libcxx=libstdc++11 8 | 9 | [buildenv] 10 | CC=x86_64-linux-gnu-gcc-11 11 | CXX=x86_64-linux-gnu-g++-11 12 | LD=x86_64-linux-gnu-ld 13 | -------------------------------------------------------------------------------- /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/cpp:v0.4 17 | 18 | ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE 19 | ENV REINSTALL_CMAKE_VERSION_FROM_SOURCE="${REINSTALL_CMAKE_VERSION_FROM_SOURCE:-none}" 20 | 21 | COPY scripts/*.sh /tmp/scripts/ 22 | RUN find /tmp/scripts/ -type f -iname "*.sh" -exec chmod +x {} \; 23 | RUN /bin/bash /tmp/scripts/configure-proxies.sh 24 | -------------------------------------------------------------------------------- /.devcontainer/scripts/configure-codespaces.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | if [ "${CODESPACES}" = "true" ]; then 18 | echo "#######################################################" 19 | echo "### Setup Access to Codespaces ###" 20 | echo "#######################################################" 21 | 22 | # restart Docker connection if in Codespaces 23 | # Workaround according to https://github.com/devcontainers/features/issues/671#issuecomment-1701754897 24 | sudo pkill dockerd && sudo pkill containerd 25 | /usr/local/share/docker-init.sh 26 | 27 | # Remove the default credential helper 28 | sudo sed -i -E 's/helper =.*//' /etc/gitconfig 29 | 30 | # Add one that just uses secrets available in the Codespace 31 | git config --global credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${MY_GH_TOKEN}"; }; f' 32 | fi 33 | -------------------------------------------------------------------------------- /.devcontainer/scripts/container-set.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | echo "#######################################################" 18 | echo "### Checking container creation ###" 19 | echo "#######################################################" 20 | useradd vscode --password vscode -m 21 | usermod -aG sudo vscode 22 | -------------------------------------------------------------------------------- /.devcontainer/scripts/onCreateCommand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | sudo chmod +x .devcontainer/scripts/*.sh 18 | 19 | .devcontainer/scripts/setup-git.sh 20 | 21 | if [[ -z "${VELOCITAS_OFFLINE}" ]]; then 22 | .devcontainer/scripts/configure-codespaces.sh 23 | .devcontainer/scripts/upgrade-cli.sh 24 | fi 25 | 26 | # Call user initialization hook if present 27 | ON_CREATE_USER_HOOK_PATH=.devcontainer/scripts/onCreateUserHook.sh 28 | if [[ -x $ON_CREATE_USER_HOOK_PATH ]]; then 29 | $ON_CREATE_USER_HOOK_PATH 30 | fi 31 | 32 | echo "#######################################################" 33 | echo "### Run VADF Lifecycle Management ###" 34 | echo "#######################################################" 35 | velocitas init 36 | velocitas sync 37 | 38 | # Some setup might be required even in offline mode 39 | .devcontainer/scripts/setup-dependencies.sh 40 | 41 | echo "#######################################################" 42 | echo "### VADF package status ###" 43 | echo "#######################################################" 44 | velocitas upgrade --dry-run --ignore-bounds 45 | 46 | # Don't let container creation fail if lifecycle management fails 47 | echo "Done!" 48 | -------------------------------------------------------------------------------- /.devcontainer/scripts/postStartCommand.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | if [[ -z "${VELOCITAS_OFFLINE}" ]]; then 18 | .devcontainer/scripts/upgrade-cli.sh 19 | fi 20 | 21 | # Call user initialization hook if present 22 | POST_START_USER_HOOK_PATH=.devcontainer/scripts/onPostStartUserHook.sh 23 | if [[ -x $POST_START_USER_HOOK_PATH ]]; then 24 | $POST_START_USER_HOOK_PATH 25 | fi 26 | -------------------------------------------------------------------------------- /.devcontainer/scripts/reinstall-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | #------------------------------------------------------------------------------------------------------------- 18 | # Copyright (c) Microsoft Corporation. All rights reserved. 19 | # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. 20 | #------------------------------------------------------------------------------------------------------------- 21 | # 22 | set -e 23 | 24 | CMAKE_VERSION=${1:-"none"} 25 | 26 | if [ "${CMAKE_VERSION}" = "none" ]; then 27 | echo "No CMake version specified, skipping CMake reinstallation" 28 | exit 0 29 | fi 30 | 31 | # Cleanup temporary directory and associated files when exiting the script. 32 | cleanup() { 33 | EXIT_CODE=$? 34 | set +e 35 | if [[ -n "${TMP_DIR}" ]]; then 36 | echo "Executing cleanup of tmp files" 37 | rm -Rf "${TMP_DIR}" 38 | fi 39 | exit $EXIT_CODE 40 | } 41 | trap cleanup EXIT 42 | 43 | 44 | echo "Installing CMake..." 45 | apt-get -y purge --auto-remove cmake 46 | mkdir -p /opt/cmake 47 | 48 | architecture=$(dpkg --print-architecture) 49 | case "${architecture}" in 50 | arm64) 51 | ARCH=aarch64 ;; 52 | amd64) 53 | ARCH=x86_64 ;; 54 | *) 55 | echo "Unsupported architecture ${architecture}." 56 | exit 1 57 | ;; 58 | esac 59 | 60 | CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" 61 | CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" 62 | TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) 63 | 64 | echo "${TMP_DIR}" 65 | cd "${TMP_DIR}" 66 | 67 | curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O 68 | curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O 69 | 70 | sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" 71 | sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license 72 | 73 | ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake 74 | -------------------------------------------------------------------------------- /.devcontainer/scripts/setup-dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | echo "#######################################################" 18 | echo "### Install Prerequisites and Tools ###" 19 | echo "#######################################################" 20 | 21 | if [[ -z "${VELOCITAS_OFFLINE}" ]]; then 22 | # Optionally install the cmake for vcpkg 23 | .devcontainer/scripts/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE} 24 | 25 | # Install python, conan and ccache 26 | sudo apt-get update 27 | sudo apt-get install -y python3 28 | sudo apt-get install -y python3-distutils 29 | curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python3 30 | sudo apt-get -y install --no-install-recommends ccache 31 | 32 | build_arch=$(arch) 33 | 34 | # ensure we can always build for an arm target 35 | if [ "${build_arch}" != "aarch64" ]; then 36 | sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu 37 | fi 38 | 39 | pip3 install -r ./requirements.txt 40 | 41 | # Install static analyzer tools 42 | sudo apt-get install -y cppcheck clang-format-14 clang-tidy-14 43 | sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100 44 | sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 100 45 | fi 46 | 47 | echo "#######################################################" 48 | echo "### Install Dependencies ###" 49 | echo "#######################################################" 50 | ./install_dependencies.sh 2>&1 | tee -a $HOME/install_dependencies.log 51 | -------------------------------------------------------------------------------- /.devcontainer/scripts/setup-git.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | echo "#######################################################" 18 | echo "### Setup Git ###" 19 | echo "#######################################################" 20 | # Add git name and email from env variables 21 | if [[ -n "${GIT_CONFIG_NAME}" && -n "${GIT_CONFIG_EMAIL}" ]]; then 22 | git config --global user.name $GIT_CONFIG_NAME 23 | git config --global user.email $GIT_CONFIG_EMAIL 24 | fi 25 | 26 | git config --global --add safe.directory "*" 27 | -------------------------------------------------------------------------------- /.devcontainer/scripts/upgrade-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 3 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Apache License, Version 2.0 which is available at 7 | # https://www.apache.org/licenses/LICENSE-2.0. 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | # SPDX-License-Identifier: Apache-2.0 16 | 17 | echo "#######################################################" 18 | echo "### Auto-upgrade CLI ###" 19 | echo "#######################################################" 20 | 21 | ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." ) 22 | DESIRED_VERSION=$(cat $ROOT_DIRECTORY/.velocitas.json | jq .cliVersion | tr -d '"') 23 | 24 | # Get installed CLI version 25 | INSTALLED_VERSION=v$(velocitas --version | sed -E 's/velocitas-cli\/(\w+.\w+.\w+).*/\1/') 26 | 27 | if [ "$DESIRED_VERSION" = "$INSTALLED_VERSION" ]; then 28 | echo "> Already up to date!" 29 | exit 0 30 | else 31 | echo "> Checking upgrade to $DESIRED_VERSION" 32 | fi 33 | 34 | AUTHORIZATION_HEADER="" 35 | if [ "${GITHUB_API_TOKEN}" != "" ]; then 36 | AUTHORIZATION_HEADER="-H \"Authorization: Bearer ${GITHUB_API_TOKEN}\"" 37 | fi 38 | 39 | if [ "$DESIRED_VERSION" = "latest" ]; then 40 | CLI_RELEASES_URL=https://api.github.com/repos/eclipse-velocitas/cli/releases/latest 41 | else 42 | CLI_RELEASES_URL=https://api.github.com/repos/eclipse-velocitas/cli/releases/tags/${DESIRED_VERSION} 43 | fi 44 | 45 | CLI_RELEASES=$(curl -s -L \ 46 | -H "Accept: application/vnd.github+json" \ 47 | -H "X-GitHub-Api-Version: 2022-11-28" \ 48 | ${AUTHORIZATION_HEADER} \ 49 | ${CLI_RELEASES_URL}) 50 | 51 | res=$? 52 | if test "$res" != "0"; then 53 | echo "the curl command failed with exit code: $res" 54 | exit 0 55 | fi 56 | 57 | DESIRED_VERSION_TAG=$(echo ${CLI_RELEASES} | jq -r .name) 58 | 59 | if [ "$DESIRED_VERSION_TAG" = "null" ] || [ "$DESIRED_VERSION_TAG" = "" ]; then 60 | echo "> Can't find desired Velocitas CLI version: $DESIRED_VERSION. Skipping Auto-Upgrade." 61 | exit 0 62 | fi 63 | 64 | if [ "$DESIRED_VERSION_TAG" != "$INSTALLED_VERSION" ]; then 65 | echo "> Upgrading CLI..." 66 | if [[ $(arch) == "aarch64" ]]; then 67 | CLI_ASSET_NAME=velocitas-linux-arm64 68 | else 69 | CLI_ASSET_NAME=velocitas-linux-x64 70 | fi 71 | CLI_INSTALL_PATH=/usr/bin/velocitas 72 | CLI_DOWNLOAD_URL="https://github.com/eclipse-velocitas/cli/releases/download/${DESIRED_VERSION_TAG}/${CLI_ASSET_NAME}" 73 | 74 | echo "> Downloading Velocitas CLI from ${CLI_DOWNLOAD_URL}" 75 | sudo curl -s -L ${CLI_DOWNLOAD_URL} -o "${CLI_INSTALL_PATH}" 76 | sudo chmod +x "${CLI_INSTALL_PATH}" 77 | else 78 | echo "> Up to date!" 79 | fi 80 | 81 | echo "> Using CLI: $(velocitas --version)" 82 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .conan_home 2 | .devcontainer 3 | .github 4 | .vscode 5 | **/build 6 | **/deploy 7 | **/docs 8 | **/licenses 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Automatically normalize line endings for all text-based files 2 | # http://git-scm.com/docs/gitattributes#_end_of_line_conversion 3 | * text=auto 4 | 5 | # For the following file types, normalize line endings to LF on 6 | # checkin and prevent conversion to CRLF when they are checked out 7 | # (this is required in order to prevent newline related issues like, 8 | # for example, after the build script is run) 9 | .* text eol=lf 10 | *.css text eol=lf 11 | *.html text eol=lf 12 | *.js text eol=lf 13 | *.json text eol=lf 14 | *.md text eol=lf 15 | *.sh text eol=lf 16 | *.txt text eol=lf 17 | *.xml text eol=lf 18 | 19 | # Source files 20 | # ============ 21 | *.pxd text diff=python 22 | *.py text diff=python 23 | *.py3 text diff=python 24 | *.pyw text diff=python 25 | *.pyx text diff=python 26 | *.pyz text diff=python 27 | *.pyi text diff=python 28 | *.c text 29 | *.h text 30 | *.cpp text 31 | *.hpp text 32 | 33 | # Binary files 34 | # ============ 35 | *.db binary 36 | *.p binary 37 | *.pkl binary 38 | *.pickle binary 39 | *.pyc binary export-ignore 40 | *.pyo binary export-ignore 41 | *.pyd binary 42 | 43 | # Jupyter notebook 44 | *.ipynb text 45 | 46 | # Note: .db, .p, and .pkl files are associated 47 | # with the python modules ``pickle``, ``dbm.*``, 48 | # ``shelve``, ``marshal``, ``anydbm``, & ``bsddb`` 49 | # (among others). 50 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2023-2024 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | name: 🐞 Bug Report 17 | description: Provide a general summary of the bug in the title below. 18 | title: "[Bug]: " 19 | labels: 20 | - bug 21 | body: 22 | - type: markdown 23 | attributes: 24 | value: | 25 | **Thank you :heart: for taking the time to fill out this bug report!** 26 | - type: dropdown 27 | id: severity 28 | validations: 29 | required: true 30 | attributes: 31 | label: Severity 32 | description: How severe is the bug in your opinion? 33 | multiple: false 34 | options: 35 | - "Trivial" 36 | - "Medium" 37 | - "High" 38 | - "Critical" 39 | - "Blocker" 40 | - type: input 41 | id: version 42 | validations: 43 | required: true 44 | attributes: 45 | label: What release version, tag or commit-hash did you use? 46 | description: Please include a link if possible. 47 | placeholder: v0.1.0 or 06f432a00e4c66804202c91bdfb9c9b12823928b 48 | - type: textarea 49 | id: current-behavior 50 | validations: 51 | required: true 52 | attributes: 53 | label: Current Behavior 54 | description: Tell us what happened instead of the expected behavior. 55 | placeholder: Error message appeared when I cloned a repository... 56 | - type: textarea 57 | id: steps-to-reproduce 58 | validations: 59 | required: true 60 | attributes: 61 | label: Steps to Reproduce 62 | description: Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant 63 | placeholder: | 64 | 1. ... 65 | 2. ... 66 | 3. ... 67 | - type: textarea 68 | id: expected-behavior 69 | validations: 70 | required: true 71 | attributes: 72 | label: Expected Behavior 73 | description: Tell us what should happen 74 | placeholder: Clone of repository shall be prune of errors. 75 | - type: textarea 76 | id: possible-solution 77 | validations: 78 | required: false 79 | attributes: 80 | label: Possible Solution 81 | description: Fix/reason of the bug suggestion 82 | placeholder: A possible solution or fix is... 83 | - type: textarea 84 | id: additional-information 85 | validations: 86 | required: false 87 | attributes: 88 | label: Additional Information 89 | description: Provide an additional detailed description / screenshots / evidences of the bug 90 | placeholder: I would like to add... 91 | - type: checkboxes 92 | id: code-of-conduct 93 | attributes: 94 | label: Code of Conduct 95 | description: By submitting this issue, you agree to follow our "Code of Conduct". 96 | options: 97 | - label: I agree to follow this project's "Code of Conduct". 98 | required: true 99 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2023-2024 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | name: 🛠️ Feature Request 17 | description: Suggest an idea to help us improve our product. 18 | title: "[Feature]: " 19 | labels: 20 | - "enhancement" 21 | body: 22 | - type: markdown 23 | attributes: 24 | value: | 25 | **Thank you :heart: for taking the time to fill out this feature request report!** 26 | We kindly ask you to search if an issue already exists for your requested feature. 27 | 28 | We are happy about contributions from all users. 29 | - type: textarea 30 | attributes: 31 | label: Description 32 | description: | 33 | A clear and concise description of the feature you're interested in. 34 | validations: 35 | required: true 36 | 37 | - type: textarea 38 | attributes: 39 | label: Suggested Solution 40 | description: | 41 | Describe the solution you'd like to be implemented. Provide a clear and concise description of what you want to happen. 42 | validations: 43 | required: false 44 | 45 | - type: textarea 46 | attributes: 47 | label: Alternatives 48 | description: | 49 | Describe alternatives you've considered. 50 | A clear and concise description of alternative solutions or features you've considered. 51 | validations: 52 | required: false 53 | 54 | - type: textarea 55 | attributes: 56 | label: Additional Context 57 | description: | 58 | Add any other context about the problem here. 59 | validations: 60 | required: false 61 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2023-2024 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | name: ❓ Question or general issue 17 | description: Approach us with a question 18 | title: "[Q]: " 19 | labels: 20 | - question 21 | body: 22 | - type: markdown 23 | attributes: 24 | value: | 25 | **We are happy that you have a question to ask!** 26 | - type: textarea 27 | validations: 28 | required: true 29 | attributes: 30 | label: Question 31 | description: Feel free to ask us if you need assistance 32 | placeholder: How can I create a repository based on your template? 33 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ## Describe your changes 3 | 4 | 7 | 8 | ## Issue ticket number and link 9 | 10 | 13 | 14 | ## Checklist - Manual tasks 15 | 16 | 19 | 20 | * [ ] Examples are executing successfully 21 | * [ ] Created/updated unit tests. Code Coverage percentage on new code shall be >= 80%. 22 | * [ ] Created/updated integration tests. 23 | 24 | * [ ] Devcontainer can be opened successfully 25 | * [ ] Devcontainer can be opened successfully behind a corporate proxy 26 | * [ ] Devcontainer can be re-built successfully 27 | 28 | * [ ] Extended the documentation (e.g. README.md, CONTRIBUTING.md, Velocitas Docs) 29 | -------------------------------------------------------------------------------- /.github/scripts/deploy_image_from_artifact.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | set -e 17 | 18 | ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." ) 19 | APP_ARTIFACT_NAME=$(cat $ROOT_DIRECTORY/${{ appManifestPath }} | jq -r .name | tr -d '"') 20 | APP_NAME_LOWERCASE=$(echo $APP_ARTIFACT_NAME | tr '[:upper:]' '[:lower:]') 21 | APP_REGISTRY="localhost:12345" 22 | 23 | local_tag="$APP_REGISTRY/$APP_NAME_LOWERCASE:local" 24 | echo "Local URL: $local_tag" 25 | 26 | docker load -i "$APP_ARTIFACT_NAME.tar" | sed -n 's/^Loaded image: \([0-9a-f]*\).*/\1/p' | xargs -i docker tag {} $local_tag 27 | docker push $local_tag 28 | 29 | cd $ROOT_DIRECTORY 30 | velocitas exec deployment-kanto deploy-vehicleapp 31 | -------------------------------------------------------------------------------- /.github/scripts/junit.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{- range . -}} 4 | {{- $failures := len .Vulnerabilities }} 5 | 6 | {{- if not (eq .Type "") }} 7 | 8 | 9 | 10 | {{- end -}} 11 | {{ range .Vulnerabilities }} 12 | 13 | {{ escapeXML .Description }} 14 | 15 | {{- end }} 16 | 17 | {{- end }} 18 | 19 | -------------------------------------------------------------------------------- /.github/workflows/check-licenses.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | # _Summary_ 17 | # 18 | # Scans the repository for all 3rd party dependencies 19 | # and generates a notice file containing all used software within 20 | # the project. 21 | 22 | name: Check licenses 23 | 24 | on: 25 | workflow_dispatch: 26 | pull_request: 27 | branches: 28 | - main 29 | schedule: 30 | - cron: "0 4 * * *" 31 | 32 | jobs: 33 | check-licenses: 34 | runs-on: ubuntu-22.04 35 | name: Check Software Licenses 36 | 37 | steps: 38 | - name: Checkout repository 39 | uses: actions/checkout@v4 40 | 41 | - name: Clone License Check Repo 42 | uses: actions/checkout@v4 43 | with: 44 | repository: eclipse-velocitas/license-check 45 | ref: v1.3 46 | path: .github/actions/license-check 47 | 48 | - name: Run License Checker 49 | uses: ./.github/actions/license-check 50 | with: 51 | config-file-path: ./.licensechecker.yml 52 | fail-on-violation: false 53 | notice-file-name: "NOTICE-3RD-PARTY-CONTENT" 54 | generate-dash: true 55 | 56 | - name: Setup Java JDK 57 | uses: actions/setup-java@v4 58 | with: 59 | distribution: "temurin" 60 | java-version: 11.0.19 61 | 62 | - name: Run dash 63 | shell: bash 64 | run: | 65 | wget -O dash.jar "https://repo.eclipse.org/content/repositories/dash-licenses/org/eclipse/dash/org.eclipse.dash.licenses/1.0.2/org.eclipse.dash.licenses-1.0.2.jar" 66 | java -jar dash.jar clearlydefined.input -summary DEPENDENCIES > dash.out 2>&1 || true 67 | echo -e "Dash output: \n\`\`\` " >> $GITHUB_STEP_SUMMARY 68 | cat dash.out >> $GITHUB_STEP_SUMMARY 69 | echo -e "\n\`\`\`" 70 | 71 | - name: Upload dash input/output as artifacts 72 | uses: actions/upload-artifact@v4 73 | if: always() 74 | with: 75 | name: "dash-artifacts" 76 | path: | 77 | clearlydefined.input 78 | DEPENDENCIES 79 | dash.out 80 | -------------------------------------------------------------------------------- /.github/workflows/check-updates.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | name: Automatic Package Update Check 17 | 18 | on: 19 | workflow_dispatch: 20 | schedule: 21 | - cron: "0 4 * * *" 22 | 23 | jobs: 24 | package_update_check: 25 | if: github.repository_owner == 'eclipse-velocitas' 26 | runs-on: ubuntu-22.04 27 | 28 | steps: 29 | - name: Checkout Repository 30 | uses: actions/checkout@v4 31 | with: 32 | token: ${{ secrets.VELOCITAS_PROJECT_TOKEN }} 33 | 34 | - name: Use devcontainer for upgrade and PR creation 35 | uses: devcontainers/ci@v0.3 36 | with: 37 | runCmd: | 38 | sudo apt-get update && sudo apt-get install -y gh 39 | 40 | echo "${{ secrets.VELOCITAS_PROJECT_TOKEN }}" | gh auth login --with-token 41 | 42 | velocitas upgrade --ignore-bounds && velocitas init && velocitas sync 43 | 44 | git config --global user.name "${{ github.actor }}" 45 | git config --global user.email "${{ github.actor }}@users.noreply.github.com" 46 | 47 | if [ -n "$(git status --porcelain)" ]; then 48 | PR_TITLE="Automated Package Update" 49 | PR_BODY="This pull request was created automatically by GitHub Actions to update package versions." 50 | 51 | # Check if a PR with the same title already exists 52 | PR_EXISTING=$(gh pr list --state open --search "$PR_TITLE" --json number | jq -r '.[0].number // empty') 53 | 54 | if [ -n "$PR_EXISTING" ]; then 55 | echo "Existing PR found (#${PR_EXISTING}). Editing..." 56 | git checkout . 57 | gh pr checkout "$PR_EXISTING" 58 | velocitas upgrade --ignore-bounds && velocitas init && velocitas sync 59 | git add . 60 | git commit -m "Update velocitas package versions" 61 | if [ $? -eq 0 ]; then 62 | git push 63 | gh pr comment "$PR_EXISTING" --body "Updated PR with latest package updates" 64 | fi 65 | else 66 | git add . 67 | git commit -m "Update velocitas package versions" 68 | BRANCH_NAME="automated-update-${{ github.sha }}" 69 | git push origin HEAD:$BRANCH_NAME 70 | echo "Creating new PR..." 71 | gh pr create --title "$PR_TITLE" --body "$PR_BODY" --head $BRANCH_NAME --base main 72 | fi 73 | else 74 | echo "No changes detected. Skip creating Pull Request." 75 | fi 76 | -------------------------------------------------------------------------------- /.github/workflows/ensure-lifecycle.yml: -------------------------------------------------------------------------------- 1 | # This file is maintained by velocitas CLI, do not modify manually. Change settings in .velocitas.json 2 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | name: Ensure lifecycle management 17 | concurrency: 18 | group: ${{ github.ref }}-ensure-lifecycle 19 | cancel-in-progress: true 20 | 21 | on: 22 | workflow_dispatch: 23 | pull_request: 24 | branches: 25 | - main 26 | schedule: 27 | - cron: "0 4 * * *" 28 | 29 | jobs: 30 | check-sync: 31 | runs-on: ubuntu-22.04 32 | container: ghcr.io/eclipse-velocitas/devcontainer-base-images/cpp:v0.4 33 | name: Are files in sync? 34 | 35 | steps: 36 | - name: Checkout repository 37 | uses: actions/checkout@v4 38 | 39 | - name: Run CLI 40 | run: | 41 | velocitas init 42 | velocitas sync 43 | 44 | - name: Fix dubious ownership 45 | run: | 46 | git config --global --add safe.directory $( pwd ) 47 | 48 | - name: Has Changes 49 | id: changes 50 | run: | 51 | if [[ -z "$(git status --porcelain .)" ]]; 52 | then 53 | echo "changed=0" >> $GITHUB_OUTPUT 54 | else 55 | echo "changed=1" >> $GITHUB_OUTPUT 56 | 57 | echo -e "## Summary of detected changes\n" >> $GITHUB_STEP_SUMMARY 58 | echo -e "\`\`\`bash" >> $GITHUB_STEP_SUMMARY 59 | git status --porcelain >> $GITHUB_STEP_SUMMARY 60 | echo -e "\`\`\`" >> $GITHUB_STEP_SUMMARY 61 | echo -e "## Diff Details\n" >> $GITHUB_STEP_SUMMARY 62 | echo -e "\`\`\`bash" >> $GITHUB_STEP_SUMMARY 63 | git diff >> $GITHUB_STEP_SUMMARY 64 | echo -e "\`\`\`" >> $GITHUB_STEP_SUMMARY 65 | fi 66 | shell: bash 67 | 68 | - name: Fail if there are changes 69 | if: steps.changes.outputs.changed == 1 70 | run: exit 1 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | # Prerequisites 16 | *.d 17 | 18 | # Compiled Object files 19 | *.slo 20 | *.lo 21 | *.o 22 | *.obj 23 | 24 | # Precompiled Headers 25 | *.gch 26 | *.pch 27 | 28 | # Compiled Dynamic libraries 29 | *.so 30 | *.dylib 31 | *.dll 32 | 33 | # Fortran module files 34 | *.mod 35 | *.smod 36 | 37 | # Compiled Static libraries 38 | *.lai 39 | *.la 40 | *.a 41 | *.lib 42 | 43 | # Executables 44 | *.exe 45 | *.out 46 | *.app 47 | 48 | # Python pre-compiled files 49 | *.pyc 50 | 51 | # CMake 52 | build* 53 | CMakeUserPresets.json 54 | 55 | # Mac files 56 | .DS_Store 57 | 58 | # conan licenses 59 | licenses 60 | conan_imports_manifest.txt 61 | 62 | # conan home 63 | .conan_home 64 | 65 | # auto-generated SDK version 66 | version.txt 67 | logs 68 | 69 | # Velocitas home 70 | .velocitas 71 | -------------------------------------------------------------------------------- /.licensechecker.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | whitelist-file-path: ./whitelisted-licenses.txt 16 | scan-dirs: 17 | - path: . 18 | cpp-conan-included-profile-files: 19 | - "./.conan/profiles/linux-x86_64" 20 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | fail_fast: false 16 | repos: 17 | - repo: https://github.com/pocc/pre-commit-hooks 18 | rev: v1.3.5 19 | hooks: 20 | - id: clang-format 21 | args: ["--style=file", "--version=14"] 22 | - id: clang-tidy 23 | args: 24 | [ 25 | "--version=14", 26 | "--checks=-*", 27 | "--config-file=.clang-tidy", 28 | "--format-style=file", 29 | ] 30 | - id: cpplint 31 | args: ["--recursive"] 32 | - id: cppcheck 33 | args: [ 34 | "--project=build/compile_commands.json", 35 | "--language=c++", 36 | "--std=c++17", 37 | "--error-exitcode=1", 38 | "--enable=all", 39 | "--inline-suppr", 40 | "--suppress=noExplicitConstructor", 41 | "--suppress=missingInclude", 42 | "--suppress=unusedFunction", 43 | "--suppress=uninitMemberVar", 44 | "--suppress=unmatchedSuppression", 45 | # suppress all warnings for generated code 46 | "--suppress=*:build*/*", 47 | "--suppress=*:app/vehicle_model/*", 48 | "--suppress=*:examples/vehicle_model/*", 49 | ] 50 | - repo: https://github.com/Lucas-C/pre-commit-hooks 51 | rev: v1.5.4 52 | hooks: 53 | - id: insert-license 54 | files: '.*\.(py|pyi|yaml|yml|sh)$' 55 | exclude: "reinstall-cmake.sh" 56 | args: 57 | - --license-filepath 58 | - license_header.txt 59 | - --comment-style 60 | - "#" 61 | - --use-current-year 62 | - --allow-past-years 63 | - --skip-license-insertion-comment=This file is maintained by velocitas CLI, do not modify manually. 64 | - id: insert-license 65 | files: '.*\.(cpp|c|cc|h)$' 66 | exclude: '.*\.(pb.cpp|pb.c|pb.cc|pb.h)$' 67 | args: 68 | - --license-filepath 69 | - license_header.txt 70 | - --comment-style 71 | - /**| *| */ 72 | - --use-current-year 73 | - --allow-past-years 74 | - --skip-license-insertion-comment=This file is maintained by velocitas CLI, do not modify manually. 75 | - id: insert-license 76 | files: "Dockerfile.*|CMakeLists.txt" 77 | args: 78 | - --license-filepath 79 | - license_header.txt 80 | - --comment-style 81 | - "#" 82 | - --use-current-year 83 | - --allow-past-years 84 | - --skip-license-insertion-comment=This file is maintained by velocitas CLI, do not modify manually. 85 | -------------------------------------------------------------------------------- /.scripts/common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | function get_valid_cross_compile_architecture() { 17 | if [[ "$1" == "aarch64" || "$1" == "arm64" || "$1" == "armv8" ]]; then 18 | HOST_ARCH="aarch64" 19 | elif [[ "$1" == "x86_64" || "$1" == "amd64" ]]; then 20 | HOST_ARCH="x86_64" 21 | else 22 | return 1 23 | fi 24 | 25 | echo $HOST_ARCH 26 | return 0 27 | } 28 | -------------------------------------------------------------------------------- /.scripts/test_package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Apache License, Version 2.0 which is available at 6 | # https://www.apache.org/licenses/LICENSE-2.0. 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | # License for the specific language governing permissions and limitations 12 | # under the License. 13 | # 14 | # SPDX-License-Identifier: Apache-2.0 15 | 16 | HOST_PROFILE=$1 17 | if [ "${HOST_PROFILE}" == "" ]; then 18 | HOST_PROFILE="linux-$(arch)" 19 | echo "Missing host profile argument - using default: ${HOST_PROFILE}" 20 | fi 21 | 22 | conan create --build=missing -pr:b ./.conan/profiles/linux-$(arch) -pr:h ./.conan/profiles/${HOST_PROFILE} -s:a="build_type=Release" . --user ci --channel testing -------------------------------------------------------------------------------- /.velocitas-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": { 3 | "devenv-runtimes": "v4.1.0", 4 | "devenv-devcontainer-setup": "v3.0.0", 5 | "devenv-github-templates": "v1.0.5", 6 | "devenv-github-workflows": "v7.0.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.velocitas.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": { 3 | "devenv-runtimes": "v4.1.0", 4 | "devenv-devcontainer-setup": "v3.0.0", 5 | "devenv-github-templates": "v1.0.5", 6 | "devenv-github-workflows": "v7.0.0" 7 | }, 8 | "components": [ 9 | "devcontainer-setup", 10 | "vehicle-signal-interface", 11 | "runtime-local", 12 | "github-templates", 13 | "github-workflows" 14 | ], 15 | "variables": { 16 | "language": "cpp", 17 | "repoType": "sdk", 18 | "githubRepoId": "eclipse-velocitas/vehicle-app-cpp-sdk", 19 | "appManifestPath": "examples/seat-adjuster/AppManifest.json" 20 | }, 21 | "cliVersion": "v0.13.2" 22 | } 23 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/sdk/include", 7 | "${workspaceFolder}/sdk/src" 8 | ], 9 | "defines": [ ], 10 | "compilerPath": "/usr/bin/gcc", 11 | "cStandard": "c17", 12 | "cppStandard": "c++11", 13 | "configurationProvider": "ms-vscode.cmake-tools" 14 | } 15 | ], 16 | "version": 4 17 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "Local Runtime - Up", 6 | "detail": "Starts up the local runtime", 7 | "type": "shell", 8 | "command": "velocitas exec runtime-local up", 9 | "group": "none", 10 | "presentation": { 11 | "panel": "dedicated", 12 | "clear": true, 13 | }, 14 | "problemMatcher": [ ] 15 | }, 16 | { 17 | "label": "Local Runtime - Down", 18 | "detail": "Stops the local runtime", 19 | "type": "shell", 20 | "command": "velocitas exec runtime-local down", 21 | "group": "none", 22 | "presentation": { 23 | "panel": "dedicated", 24 | "clear": true, 25 | }, 26 | "problemMatcher": [ ] 27 | }, 28 | { 29 | "label": "Local Runtime - Run SeatAdjuster", 30 | "detail": "Starts the SeatAdjuster under development", 31 | "type": "shell", 32 | "command": [ 33 | "velocitas exec runtime-local run-vehicle-app ${workspaceFolder}/build/bin/example-seatadjusterapp" 34 | ], 35 | "presentation": { 36 | "panel": "dedicated", 37 | "close": false, 38 | "reveal": "always" 39 | }, 40 | "problemMatcher": [ ] 41 | }, 42 | { 43 | "label": "Local Runtime - VehicleDataBroker CLI", 44 | "detail": "Starts the VehicleDataBroker CLI", 45 | "type": "shell", 46 | "command": "velocitas exec runtime-local run-vehicledatabroker-cli", 47 | "presentation": { 48 | "panel": "dedicated", 49 | "clear": true, 50 | }, 51 | "group": "none", 52 | "problemMatcher": [ ] 53 | }, 54 | // CPP specific tasks 55 | { 56 | "label": "CPP - Calculate code coverage", 57 | "detail": "Calculates code coverage of the c++ SDK", 58 | "type": "shell", 59 | // 'build' folder is a symlink. Assigning pwd to ROOT_DIR makes this independent 60 | // of the number of dirs covered by the symlink 61 | "command": "ROOT_DIR=$(pwd) && cd build && gcovr -r $ROOT_DIR", 62 | "group": "none", 63 | "dependsOn": [ 64 | "CMake: Run Tests" 65 | ], 66 | "presentation": { 67 | "close": false, 68 | "panel": "dedicated" 69 | }, 70 | "problemMatcher": [ ] 71 | } 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | cmake_minimum_required(VERSION 3.16) 16 | 17 | set(SDK_BUILD_TESTS ON CACHE BOOL "Build the SDK tests.") 18 | set(SDK_BUILD_EXAMPLES ON CACHE BOOL "Build the SDK examples.") 19 | set(STATIC_BUILD OFF CACHE BOOL "Build all targets with external dependencies linked in statically.") 20 | 21 | set(CMAKE_CXX_STANDARD 17) 22 | 23 | project(VehicleAppCppSdk CXX) 24 | 25 | find_package(fmt REQUIRED CONFIG) 26 | find_package(gRPC REQUIRED CONFIG) 27 | find_package(nlohmann_json REQUIRED CONFIG) 28 | find_package(PahoMqttCpp REQUIRED CONFIG) 29 | find_package(eclipse-paho-mqtt-c REQUIRED CONFIG) 30 | find_package(protobuf REQUIRED CONFIG) 31 | find_package(absl REQUIRED CONFIG) 32 | 33 | # Induce to put executables into the bin folder of the current build folder 34 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) 35 | 36 | if(STATIC_BUILD) 37 | set(BUILD_SHARED_LIBS OFF) 38 | set(CMAKE_EXE_LINKER_FLAGS "-static") 39 | endif() 40 | 41 | find_program(CCACHE_FOUND ccache) 42 | if(CCACHE_FOUND) 43 | message("Found ccache installation") 44 | set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) 45 | endif() 46 | 47 | if(SDK_BUILD_TESTS) 48 | enable_testing() 49 | endif() 50 | 51 | add_subdirectory(sdk) 52 | 53 | if(SDK_BUILD_EXAMPLES) 54 | add_subdirectory(examples) 55 | endif() 56 | -------------------------------------------------------------------------------- /CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | 3 | # When using Velocitas gRPC service generation the header file will include the *ServiceImpl.cpp file 4 | # this gives by default an error so lets ignore that 5 | filter=-build/include 6 | 7 | filter=-build/include_order 8 | filter=-build/header_guard 9 | filter=-whitespace/indent 10 | filter=-whitespace/comments 11 | filter=-build/c++11 12 | filter=-build/namespaces 13 | filter=-readability/todo 14 | filter=-readability/braces 15 | filter=-build/include_what_you_use 16 | filter=-runtime/references 17 | linelength=120 18 | -------------------------------------------------------------------------------- /NOTICE-3RD-PARTY-CONTENT.md: -------------------------------------------------------------------------------- 1 | # Licenses Notice 2 | *Note*: This file is auto-generated. Do not modify it manually. 3 | ## Python 4 | | Dependency | Version | License | 5 | |:-----------|:-------:|--------:| 6 | |certifi|2025.4.26|Mozilla Public License 2.0| 7 | |cfgv|3.4.0|MIT| 8 | |charset-normalizer|3.4.2|MIT| 9 | |colorama|0.4.6|BSD| 10 | |conan|2.15.1|MIT| 11 | |cpplint|1.6.1|New BSD| 12 | |distlib|0.3.9|Python Software Foundation License| 13 | |distro|1.8.0|Apache 2.0| 14 | |fasteners|0.19|Apache 2.0| 15 | |filelock|3.18.0|The Unlicense (Unlicense)| 16 | |gcovr|5.2|BSD| 17 | |identify|2.6.10|MIT| 18 | |idna|3.10|BSD| 19 | |jinja2|3.1.6|BSD| 20 | |lxml|5.4.0|New BSD| 21 | |MarkupSafe|3.0.2|BSD| 22 | |nodeenv|1.9.1|BSD| 23 | |patch-ng|1.18.1|MIT| 24 | |platformdirs|4.3.8|MIT| 25 | |pre-commit|3.5.0|MIT| 26 | |pygments|2.19.1|Simplified BSD| 27 | |python-dateutil|2.9.0.post0|Apache 2.0
BSD| 28 | |PyYAML|6.0.2|MIT| 29 | |requests|2.32.3|Apache 2.0| 30 | |six|1.17.0|MIT| 31 | |urllib3|2.0.7|MIT| 32 | |virtualenv|20.31.2|MIT| 33 | ## Workflows 34 | | Dependency | Version | License | 35 | |:-----------|:-------:|--------:| 36 | |actions/checkout|v4|MIT License| 37 | |actions/setup-java|v4|MIT License| 38 | |actions/upload-artifact|v4|MIT License| 39 | |devcontainers/ci|v0.3|MIT License| 40 | |irongut/CodeCoverageSummary|v1.3.0|MIT License| 41 | |pre-commit/action|v3.0.1|MIT License| 42 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | _ISO 27005 defines vulnerability as: 3 | "A weakness of an asset or group of assets that can be exploited by one or more threats."_ 4 | 5 | ## The Eclipse Security Team 6 | 7 | The Eclipse Security Team provides help and advice to Eclipse projects 8 | on vulnerability issues and is the first point of contact 9 | for handling security vulnerabilities. 10 | Members of the Security Team are committers on Eclipse Projects 11 | and members of the Eclipse Architecture Council. 12 | 13 | Contact the [Eclipse Security Team](mailto:security@eclipse.org). 14 | 15 | **Note that, as a matter of policy, the security team does not open attachments.** 16 | 17 | ## Reporting a Security Vulnerability 18 | 19 | Vulnerabilities can be reported either via email to the Eclipse Security Team 20 | or directly with a project via the Eclipse Foundation's Bugzilla instance. 21 | 22 | The general security mailing list address is security@eclipse.org. 23 | Members of the Eclipse Security Team will receive messages sent to this address. 24 | This address should be used only for reporting undisclosed vulnerabilities; 25 | regular issue reports and questions unrelated to vulnerabilities in Eclipse software 26 | will be ignored. 27 | Note that this email address is not encrypted. 28 | 29 | The community is also encouraged to report vulnerabilities using the 30 | [Eclipse Foundation's Bugzilla instance](https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Community&component=Vulnerability%20Reports&keywords=security&groups=Security_Advisories). 31 | Note that you will require an Eclipse Foundation account to create an issue report, 32 | but by doing so you will be able to participate directly in the resolution of the issue. 33 | 34 | Issue reports related to vulnerabilities must be marked as "committers-only", 35 | either automatically by clicking the provided link, by the reporter, 36 | or by a committer during the triage process. 37 | Note that issues marked "committers-only" are visible to all Eclipse committers. 38 | By default, a "committers-only" issue is also accessible to the reporter 39 | and individuals explicitly indicated in the "cc" list. 40 | 41 | ## Disclosure 42 | 43 | Disclosure is initially limited to the reporter and all Eclipse Committers, 44 | but is expanded to include other individuals, and the general public. 45 | The timing and manner of disclosure is governed by the 46 | [Eclipse Security Policy](https://www.eclipse.org/security/policy.php). 47 | 48 | Publicly disclosed issues are listed on the 49 | [Disclosed Vulnerabilities Page](https://www.eclipse.org/security/known.php). 50 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | add_subdirectory(example_model) 16 | 17 | # Currently only adding examples that can be tested without additional velocitas code generation 18 | 19 | add_subdirectory(performance-subscribe) 20 | add_subdirectory(seat-adjuster) 21 | add_subdirectory(set-data-points) 22 | -------------------------------------------------------------------------------- /examples/example_model/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "example_model") 16 | 17 | add_library(${TARGET_NAME} INTERFACE) 18 | 19 | target_include_directories(${TARGET_NAME} INTERFACE .) 20 | -------------------------------------------------------------------------------- /examples/example_model/vehicle/Cabin/Cabin.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VMDL_EXAMPLE_VEHICLE_CABIN_H 18 | #define VMDL_EXAMPLE_VEHICLE_CABIN_H 19 | 20 | #include "sdk/DataPoint.h" 21 | #include "sdk/Model.h" 22 | 23 | #include "vehicle/Cabin/Seat/Seat.h" 24 | 25 | #include 26 | 27 | namespace velocitas::vehicle { 28 | 29 | using ParentClass = Model; 30 | 31 | /** Cabin model. */ 32 | class Cabin : public ParentClass { 33 | public: 34 | class SeatCollection : public ParentClass { 35 | public: 36 | class RowType : public ParentClass { 37 | public: 38 | RowType(const std::string& name, ParentClass* parent) 39 | : ParentClass(name, parent) 40 | , DriverSide("DriverSide", this) 41 | , Middle("Middle", this) 42 | , PassengerSide("PassengerSide", this) {} 43 | 44 | vehicle::cabin::Seat DriverSide; 45 | vehicle::cabin::Seat Middle; 46 | vehicle::cabin::Seat PassengerSide; 47 | }; 48 | 49 | explicit SeatCollection(ParentClass* parent) 50 | : ParentClass("Seat", parent) 51 | , Row1("Row1", this) 52 | , Row2("Row2", this) {} 53 | 54 | RowType& Row(int index) { 55 | if (index == 1) { 56 | return Row1; 57 | } 58 | if (index == 2) { 59 | return Row2; 60 | } 61 | throw std::runtime_error("Given value is outside of allowed range [1;2]!"); 62 | } 63 | 64 | RowType Row1; 65 | RowType Row2; 66 | }; 67 | 68 | Cabin(const std::string& name, ParentClass* parent) 69 | : ParentClass(name, parent) 70 | , Seat(this) {} 71 | 72 | /** 73 | * Seat: branch 74 | * All seats. 75 | * 76 | **/ 77 | SeatCollection Seat; 78 | }; 79 | 80 | } // namespace velocitas::vehicle 81 | 82 | #endif // VMDL_EXAMPLE_VEHICLE_CABIN_H 83 | -------------------------------------------------------------------------------- /examples/example_model/vehicle/Cabin/Seat/Seat.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VMDL_EXAMPLE_VEHICLE_CABIN_SEAT_H 18 | #define VMDL_EXAMPLE_VEHICLE_CABIN_SEAT_H 19 | 20 | #include "sdk/DataPoint.h" 21 | #include "sdk/Model.h" 22 | 23 | namespace velocitas::vehicle::cabin { 24 | 25 | using ParentClass = Model; 26 | 27 | /** Seat model. */ 28 | class Seat : public ParentClass { 29 | public: 30 | Seat(const std::string& name, ParentClass* parent) 31 | : ParentClass(name, parent) 32 | , Position("Position", this) {} 33 | 34 | /** 35 | * Position: actuator 36 | * Seat position on vehicle x-axis. Position is relative to the frontmost position supported by 37 | *the seat. 0 = Frontmost position supported. 38 | * 39 | * Value range: [0, ] 40 | * Unit: mm 41 | **/ 42 | DataPointUint32 Position; 43 | }; 44 | 45 | } // namespace velocitas::vehicle::cabin 46 | 47 | #endif // VMDL_EXAMPLE_VEHICLE_CABIN_SEAT_H 48 | -------------------------------------------------------------------------------- /examples/example_model/vehicle/Vehicle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VMDL_EXAMPLE_VEHICLE_H 18 | #define VMDL_EXAMPLE_VEHICLE_H 19 | 20 | #include "sdk/DataPoint.h" 21 | #include "sdk/Model.h" 22 | 23 | #include "vehicle/Cabin/Cabin.h" 24 | 25 | namespace velocitas { 26 | 27 | using ParentClass = Model; 28 | 29 | /** Vehicle model. */ 30 | class Vehicle : public ParentClass { 31 | public: 32 | Vehicle() 33 | : ParentClass("Vehicle") 34 | , Speed("Speed", this) 35 | , Cabin("Cabin", this) {} 36 | 37 | /** 38 | * Speed: sensor 39 | * Vehicle speed. 40 | * 41 | * Unit: km/h 42 | */ 43 | DataPointFloat Speed; 44 | 45 | /** 46 | * Cabin: branch 47 | * All in-cabin components, including doors. 48 | * 49 | */ 50 | vehicle::Cabin Cabin; 51 | }; 52 | 53 | } // namespace velocitas 54 | 55 | #endif // VMDL_EXAMPLE_VEHICLE_H 56 | -------------------------------------------------------------------------------- /examples/grpc_client/AppManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifestVersion": "v3", 3 | "name": "SampleApp", 4 | "interfaces": [ 5 | { 6 | "type": "grpc-interface", 7 | "config": { 8 | "src": "https://raw.githubusercontent.com/eclipse-kuksa/kuksa-incubation/0.4.0/seat_service/proto/sdv/edge/comfort/seats/v1/seats.proto", 9 | "required": { 10 | "methods": [ 11 | "Move", "CurrentPosition" 12 | ] 13 | } 14 | } 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /examples/grpc_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | include_directories( 16 | ${CMAKE_BINARY_DIR}/gens 17 | ${CONAN_INCLUDE_DIRS} 18 | ) 19 | 20 | link_directories( 21 | ${CONAN_LIB_DIRS} 22 | ) 23 | 24 | add_subdirectory(src) 25 | -------------------------------------------------------------------------------- /examples/grpc_client/README.md: -------------------------------------------------------------------------------- 1 | # GRPC Client Example 2 | 3 | Used for the [Client](https://eclipse.dev/velocitas/docs/tutorials/grpc_service_generation/create_client/) example. 4 | -------------------------------------------------------------------------------- /examples/grpc_client/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "grpc_client") 16 | 17 | add_executable(${TARGET_NAME} 18 | Launcher.cpp 19 | ) 20 | 21 | target_link_libraries(${TARGET_NAME} 22 | ${CONAN_LIBS} 23 | ) 24 | -------------------------------------------------------------------------------- /examples/grpc_client/src/Launcher.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | using namespace velocitas; 24 | 25 | int main(int argc, char** argv) { 26 | // The default Velocitas Middleware class performs service discovery by 27 | // environment variables. 28 | // For this client it expects SDV_SEATS_ADDRESS to be defined 29 | // for example: 30 | // export SDV_SEATS_ADDRESS=grpc://127.0.0.1:5556 31 | 32 | std::cout << "Starting " << std::endl; 33 | auto serviceClient = SeatsServiceClientFactory::create(Middleware::getInstance()); 34 | 35 | ::grpc::ClientContext context; 36 | ::sdv::edge::comfort::seats::v1::MoveRequest request; 37 | ::sdv::edge::comfort::seats::v1::MoveReply response; 38 | 39 | ::sdv::edge::comfort::seats::v1::Seat seat; 40 | 41 | ::sdv::edge::comfort::seats::v1::SeatLocation seat_location; 42 | seat_location.set_row(1); 43 | seat_location.set_index(1); 44 | 45 | ::sdv::edge::comfort::seats::v1::Position seat_position; 46 | 47 | seat_position.set_base(75.0); 48 | 49 | seat.set_allocated_location(&seat_location); 50 | seat.set_allocated_position(&seat_position); 51 | 52 | request.set_allocated_seat(&seat); 53 | 54 | auto status = serviceClient->Move(&context, request, &response); 55 | 56 | std::cout << "gRPC Server returned code: " << status.error_code() << std::endl; 57 | std::cout << "gRPC error message: " << status.error_message().c_str() << std::endl; 58 | 59 | if (status.error_code() != ::grpc::StatusCode::OK) { 60 | // Some error 61 | return 1; 62 | } else { 63 | ::grpc::ClientContext context; 64 | ::sdv::edge::comfort::seats::v1::CurrentPositionRequest request; 65 | ::sdv::edge::comfort::seats::v1::CurrentPositionReply response; 66 | 67 | request.set_row(1); 68 | request.set_index(1); 69 | 70 | auto status_curr_pos = serviceClient->CurrentPosition(&context, request, &response); 71 | std::cout << "gRPC Server returned code: " << status_curr_pos.error_code() << std::endl; 72 | std::cout << "gRPC error message: " << status_curr_pos.error_message().c_str() << std::endl; 73 | if (status_curr_pos.ok()) 74 | std::cout << "current Position:" << response.seat().position().base() << std::endl; 75 | return 0; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /examples/grpc_server/AppManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifestVersion": "v3", 3 | "name": "SampleApp", 4 | "interfaces": [ 5 | { 6 | "type": "grpc-interface", 7 | "config": { 8 | "src": "https://raw.githubusercontent.com/eclipse-kuksa/kuksa-incubation/0.4.0/seat_service/proto/sdv/edge/comfort/seats/v1/seats.proto", 9 | "provided": { } 10 | } 11 | }, 12 | { 13 | "type": "vehicle-signal-interface", 14 | "config": { 15 | "src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json", 16 | "datapoints": { 17 | "required": [ 18 | { 19 | "path": "Vehicle.Cabin.Seat.Row1.DriverSide.Position", 20 | "access": "write" 21 | } 22 | ] 23 | } 24 | } 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /examples/grpc_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | include_directories( 16 | ${CMAKE_BINARY_DIR}/gens 17 | ${CONAN_INCLUDE_DIRS} 18 | ) 19 | 20 | link_directories( 21 | ${CONAN_LIB_DIRS} 22 | ) 23 | 24 | add_subdirectory(src) 25 | -------------------------------------------------------------------------------- /examples/grpc_server/README.md: -------------------------------------------------------------------------------- 1 | # GRPC Server Example 2 | 3 | Used for the [Server](https://eclipse.dev/velocitas/docs/tutorials/grpc_service_generation/create_server/) example. 4 | -------------------------------------------------------------------------------- /examples/grpc_server/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "grpc_server") 16 | 17 | add_executable(${TARGET_NAME} 18 | # SeatsServiceImpl.cpp - No need to include as included from header file 19 | Launcher.cpp 20 | ) 21 | 22 | target_link_libraries(${TARGET_NAME} 23 | ${CONAN_LIBS} 24 | ) 25 | -------------------------------------------------------------------------------- /examples/grpc_server/src/Launcher.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "SeatsServiceImpl.h" 18 | #include 19 | #include 20 | 21 | #include "vehicle/Vehicle.hpp" 22 | 23 | #include 24 | 25 | using namespace velocitas; 26 | 27 | int main(int argc, char** argv) { 28 | auto seatsImpl = std::make_shared(); 29 | 30 | velocitas::VehicleModelContext::getInstance().setVdbc( 31 | velocitas::IVehicleDataBrokerClient::createInstance("vehicledatabroker")); 32 | 33 | auto seatServer = SeatsServiceServerFactory::create(Middleware::getInstance(), seatsImpl); 34 | 35 | seatServer->Wait(); 36 | 37 | std::cout << "Waiting!" << std::endl; 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /examples/grpc_server/src/SeatsServiceImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VELOCITAS_SERVICE_IMPL_Seats_H 18 | #define VELOCITAS_SERVICE_IMPL_Seats_H 19 | 20 | #include "vehicle/Vehicle.hpp" 21 | #include 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | class SeatsService final : public sdv::edge::comfort::seats::v1::Seats::Service { 27 | public: 28 | SeatsService(){}; 29 | virtual ~SeatsService(){}; 30 | 31 | // 32 | ::grpc::Status Move(::grpc::ServerContext* context, 33 | const ::sdv::edge::comfort::seats::v1::MoveRequest* request, 34 | ::sdv::edge::comfort::seats::v1::MoveReply* response) override; 35 | ::grpc::Status 36 | MoveComponent(::grpc::ServerContext* context, 37 | const ::sdv::edge::comfort::seats::v1::MoveComponentRequest* request, 38 | ::sdv::edge::comfort::seats::v1::MoveComponentReply* response) override; 39 | ::grpc::Status 40 | CurrentPosition(::grpc::ServerContext* context, 41 | const ::sdv::edge::comfort::seats::v1::CurrentPositionRequest* request, 42 | ::sdv::edge::comfort::seats::v1::CurrentPositionReply* response) override; 43 | // 44 | 45 | private: 46 | vehicle::Vehicle vehicle; 47 | }; 48 | 49 | } // namespace velocitas 50 | 51 | #include "SeatsServiceImpl.cpp" 52 | 53 | #endif // VELOCITAS_SERVICE_IMPL_Seats_H 54 | -------------------------------------------------------------------------------- /examples/performance-subscribe/AppManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifestVersion": "v3", 3 | "name": "performance-subscribe", 4 | "interfaces": [ 5 | { 6 | "type": "vehicle-signal-interface", 7 | "config": { 8 | "src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json", 9 | "datapoints": { 10 | "required": [ 11 | ] 12 | } 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /examples/performance-subscribe/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "example-performance-subscribe") 16 | 17 | add_executable(${TARGET_NAME} 18 | src/Launcher.cpp 19 | src/PerformanceTestApp.cpp 20 | ) 21 | 22 | target_include_directories(${TARGET_NAME} 23 | PRIVATE 24 | ${CMAKE_CURRENT_SOURCE_DIR}/src 25 | ) 26 | 27 | target_link_libraries(${TARGET_NAME} 28 | vehicle-app-sdk 29 | example_model 30 | nlohmann_json::nlohmann_json 31 | ) 32 | -------------------------------------------------------------------------------- /examples/performance-subscribe/README.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | 1) Create a .json file named: "subscription_signals.json" 4 | 2) Place it in the same folder as the binary 5 | 3) Exeucute the binary e.g. "./example-performance-subscribe"
6 | Alternatively, you can specify the path of the signal list explicitly: "./example-performance-subscribe \" 7 | 4) Check the console output for the timestamps: "\ - \ - \" 8 | 9 | ## .json format 10 | 11 | The following format is mandatory for the input file: 12 | 13 | ``` 14 | { 15 | "signals": [ 16 | { 17 | "path": "Vehicle.LowVoltageBattery.CurrentVoltage" 18 | }, 19 | { 20 | "path": "Vehicle.LowVoltageBattery.CurrentCurrent" 21 | }, 22 | { 23 | "path": "Vehicle.Speed" 24 | }, 25 | ... 26 | ] 27 | } 28 | ``` 29 | 30 | Signals which are not available will be printed in the console as a warning. 31 | -------------------------------------------------------------------------------- /examples/performance-subscribe/src/Launcher.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "PerformanceTestApp.h" 18 | #include "sdk/Logger.h" 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace { 30 | 31 | std::unique_ptr myApp; 32 | 33 | void signal_handler(int sig) { 34 | velocitas::logger().info("App terminating signal received: {}", sig); 35 | myApp->stop(); 36 | } 37 | 38 | const char DEFAULT_CONFIG_FILENAME[] = "subscription_signals.json"; 39 | 40 | std::string getDefaultConfigFilePath(const char* appBinaryPath) { 41 | std::filesystem::path path = appBinaryPath; 42 | path.replace_filename(DEFAULT_CONFIG_FILENAME); 43 | return std::string{path}; 44 | } 45 | 46 | std::vector readSignalNameFromFiles(const std::string& configFile) { 47 | velocitas::logger().info("Reading signal list from file {}.", configFile); 48 | const auto config = nlohmann::json::parse(std::ifstream(configFile)); 49 | const auto& signalList = config["signals"]; 50 | 51 | std::vector signalNames; 52 | signalNames.reserve(signalList.size()); 53 | for (const auto& signal : signalList) { 54 | const std::string& signalName = signal["path"]; 55 | if (!signalName.empty()) { 56 | velocitas::logger().debug("{}", signalName); 57 | signalNames.push_back(signalName); 58 | } else { 59 | velocitas::logger().warn("Signal entry without 'path' found!"); 60 | } 61 | } 62 | return signalNames; 63 | } 64 | 65 | } // anonymous namespace 66 | 67 | int main(int argc, char** argv) { 68 | signal(SIGINT, signal_handler); 69 | 70 | const auto configFile = 71 | (argc > 1) ? std::filesystem::path(argv[1]).string() : getDefaultConfigFilePath(argv[0]); 72 | auto signalList = readSignalNameFromFiles(configFile); 73 | 74 | myApp = std::make_unique(std::move(signalList)); 75 | myApp->run(); 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /examples/performance-subscribe/src/PerformanceTestApp.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "PerformanceTestApp.h" 18 | #include "sdk/IPubSubClient.h" 19 | #include "sdk/Logger.h" 20 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace example { 29 | 30 | namespace { 31 | std::string getValueRepresentation(const velocitas::DataPointValue& value) { 32 | if (!value.isValid()) { 33 | return toString(value.getFailure()); 34 | } 35 | return value.getValueAsString(); 36 | } 37 | 38 | template TTimeBase getTimestamp() { 39 | const auto timestamp = std::chrono::high_resolution_clock::now(); 40 | const auto timeSinceEpoch = timestamp.time_since_epoch(); 41 | return std::chrono::duration_cast(timeSinceEpoch); 42 | } 43 | 44 | } // anonymous namespace 45 | 46 | PerformanceTestApp::PerformanceTestApp(std::vector signalList) 47 | : VehicleApp(velocitas::IVehicleDataBrokerClient::createInstance("vehicledatabroker")) 48 | , m_signalList{std::move(signalList)} {} 49 | 50 | void PerformanceTestApp::onStart() { 51 | velocitas::logger().info("Subscribing to signals ..."); 52 | for (auto path : m_signalList) { 53 | subscribeDataPoints("SELECT " + path) 54 | ->onItem([path](const velocitas::DataPointReply& reply) { 55 | const auto value = getValueRepresentation(*reply.getUntyped(path)); 56 | const auto timestamp = getTimestamp(); 57 | fmt::print("{:%T} - {} - {}\n", timestamp, path, value); 58 | }) 59 | ->onError([path](const velocitas::Status& status) { 60 | velocitas::logger().error("Error on subscription for data point {}: {}", path, 61 | status.errorMessage()); 62 | }); 63 | } 64 | } 65 | 66 | } // namespace example 67 | -------------------------------------------------------------------------------- /examples/performance-subscribe/src/PerformanceTestApp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_PERFORMANCETESTAPP_H 18 | #define VEHICLE_APP_SDK_PERFORMANCETESTAPP_H 19 | 20 | #include "sdk/VehicleApp.h" 21 | 22 | #include 23 | #include 24 | 25 | namespace example { 26 | 27 | /** 28 | * @brief 29 | */ 30 | class PerformanceTestApp : public velocitas::VehicleApp { 31 | public: 32 | explicit PerformanceTestApp(std::vector signalList); 33 | 34 | void onStart() override; 35 | 36 | private: 37 | std::vector m_signalList; 38 | }; 39 | 40 | } // namespace example 41 | 42 | #endif // VEHICLE_APP_SDK_PERFORMANCETESTAPP_H 43 | -------------------------------------------------------------------------------- /examples/seat-adjuster/AppManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifestVersion": "v3", 3 | "name": "seatadjuster", 4 | "interfaces": [ 5 | { 6 | "type": "vehicle-signal-interface", 7 | "config": { 8 | "src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json", 9 | "datapoints": { 10 | "required": [ 11 | { 12 | "path": "Vehicle.Cabin.Seat.Row1.DriverSide.Position", 13 | "access": "write" 14 | }, 15 | { 16 | "path": "Vehicle.Speed", 17 | "access": "read" 18 | } 19 | ] 20 | } 21 | } 22 | }, 23 | { 24 | "type": "pubsub", 25 | "config": { 26 | "reads": [ "seatadjuster/setPosition/request" ], 27 | "writes": [ 28 | "seatadjuster/setPosition/response", 29 | "seatadjuster/currentPosition" 30 | ] 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /examples/seat-adjuster/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "example-seatadjusterapp") 16 | 17 | add_executable(${TARGET_NAME} 18 | src/SeatAdjusterApp.cpp 19 | ) 20 | 21 | target_include_directories(${TARGET_NAME} 22 | PRIVATE 23 | ${CMAKE_CURRENT_SOURCE_DIR}/src 24 | ) 25 | 26 | target_link_libraries(${TARGET_NAME} 27 | vehicle-app-sdk 28 | example_model 29 | nlohmann_json::nlohmann_json 30 | ) 31 | -------------------------------------------------------------------------------- /examples/seat-adjuster/src/SeatAdjusterApp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_SEATADJUSTER_EXAMPLE_H 18 | #define VEHICLE_APP_SDK_SEATADJUSTER_EXAMPLE_H 19 | 20 | #include "sdk/Status.h" 21 | #include "sdk/VehicleApp.h" 22 | #include "vehicle/Vehicle.h" 23 | 24 | #include 25 | #include 26 | 27 | namespace example { 28 | 29 | /** 30 | * @brief A sample SeatAdjusterApp. 31 | * The SeatAdjusterApp subscribes at the VehicleDataBroker for updates for 32 | * the Vehicle.Speed signal. It also subscribes at a MQTT topic to listen for 33 | * incoming requests to change the seat position and forwards the requested position 34 | * to the respective data point at the data broker, but only if Vehicle.Speed equals 0. 35 | */ 36 | class SeatAdjusterApp : public velocitas::VehicleApp { 37 | public: 38 | SeatAdjusterApp(); 39 | 40 | void onStart() override; 41 | 42 | /** 43 | * @brief Handle successful seat movement requests. 44 | * 45 | * @param requestId The ID of the request requested the movement. 46 | * @param requestedPosition The seat position of the request. 47 | */ 48 | void onSeatMovementRequested(const velocitas::VoidResult&, int requestId, 49 | float requestedPosition); 50 | 51 | /** 52 | * @brief Handle set position request from PubSub topic 53 | * 54 | * @param data The JSON string received from PubSub topic. 55 | */ 56 | void onSetPositionRequestReceived(const std::string& data); 57 | 58 | /** 59 | * @brief Handle seat movement events from the VDB. 60 | * 61 | * @param dataPoints The affected data points. 62 | */ 63 | void onSeatPositionChanged(const velocitas::DataPointReply& dataPoints); 64 | 65 | /** 66 | * @brief Handle errors which occurred during async invocation. 67 | * 68 | * @param status The status which contains the error. 69 | */ 70 | void onError(const velocitas::Status& status); 71 | void onErrorDatapoint(const velocitas::Status& status); 72 | void onErrorTopic(const velocitas::Status& status); 73 | 74 | private: 75 | std::shared_ptr m_vehicleModel; 76 | }; 77 | 78 | } // namespace example 79 | 80 | #endif // VEHICLE_APP_SDK_SEATADJUSTER_EXAMPLE_H 81 | -------------------------------------------------------------------------------- /examples/set-data-points/AppManifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifestVersion": "v3", 3 | "name": "set-data-points", 4 | "interfaces": [ 5 | { 6 | "type": "vehicle-signal-interface", 7 | "config": { 8 | "src": "https://github.com/COVESA/vehicle_signal_specification/releases/download/v4.0/vss_rel_4.0.json", 9 | "datapoints": { 10 | "required": [ 11 | { 12 | "path": "Vehicle.Cabin.Seat.Row1.DriverSide.Position", 13 | "access": "write" 14 | }, 15 | { 16 | "path": "Vehicle.Cabin.Seat.Row1.PassengerSide.Position", 17 | "access": "write" 18 | }, 19 | { 20 | "path": "Vehicle.Speed", 21 | "access": "write" 22 | } 23 | ] 24 | } 25 | } 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /examples/set-data-points/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "example-set-data-points") 16 | 17 | add_executable(${TARGET_NAME} 18 | src/SetDataPointsApp.cpp 19 | ) 20 | 21 | target_include_directories(${TARGET_NAME} 22 | PRIVATE 23 | ${CMAKE_CURRENT_SOURCE_DIR}/src 24 | ) 25 | 26 | target_link_libraries(${TARGET_NAME} 27 | vehicle-app-sdk 28 | example_model 29 | nlohmann_json::nlohmann_json 30 | ) 31 | -------------------------------------------------------------------------------- /examples/set-data-points/src/SetDataPointsApp.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/DataPointBatch.h" 18 | #include "sdk/IPubSubClient.h" 19 | #include "sdk/Logger.h" 20 | #include "sdk/QueryBuilder.h" 21 | #include "sdk/VehicleApp.h" 22 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 23 | #include "vehicle/Vehicle.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace example { 30 | 31 | class SetDataPointsApp : public velocitas::VehicleApp { 32 | public: 33 | SetDataPointsApp() 34 | : VehicleApp(velocitas::IVehicleDataBrokerClient::createInstance("vehicledatabroker")) {} 35 | 36 | void onStart() override { 37 | // set a single data point 38 | try { 39 | velocitas::logger().info("Setting single data point ..."); 40 | 41 | Vehicle.Speed.set(100.0F)->await(); 42 | 43 | velocitas::logger().info("Setting single data point successfully done."); 44 | } catch (velocitas::AsyncException& e) { 45 | velocitas::logger().error("Error on setting single data point: {}", e.what()); 46 | } 47 | 48 | // set multiple data points at the same time 49 | try { 50 | velocitas::logger().info("Setting batch of data points ..."); 51 | 52 | auto result = Vehicle.setMany() 53 | .add(Vehicle.Cabin.Seat.Row1.DriverSide.Position, 1000) 54 | .add(Vehicle.Cabin.Seat.Row1.PassengerSide.Position, 1000) 55 | .apply() 56 | ->await(); 57 | 58 | if (result.empty()) { 59 | velocitas::logger().info("Setting batch of data points successfully done."); 60 | } else { 61 | velocitas::logger().error("Some data points of batch could not be set:"); 62 | for (auto datapointError : result) { 63 | velocitas::logger().error(" '{}' -> {}", datapointError.first, 64 | datapointError.second); 65 | } 66 | } 67 | } catch (velocitas::AsyncException& e) { 68 | velocitas::logger().error("Error on setting batch of data points: {}", e.what()); 69 | } 70 | 71 | velocitas::logger().info("Done. (Press Ctrl+C to terminate the app.)"); 72 | } 73 | 74 | private: 75 | velocitas::Vehicle Vehicle; 76 | }; 77 | 78 | } // namespace example 79 | 80 | std::unique_ptr myApp; 81 | 82 | void signal_handler(int sig) { 83 | velocitas::logger().info("App terminating signal received: {}", sig); 84 | myApp->stop(); 85 | } 86 | 87 | int main(int argc, char** argv) { 88 | signal(SIGINT, signal_handler); 89 | 90 | myApp = std::make_unique(); 91 | myApp->run(); 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /gcovr.cfg: -------------------------------------------------------------------------------- 1 | filter = examples 2 | filter = sdk 3 | exclude = .*/vehicle_model/ 4 | exclude = .*/tests/ 5 | 6 | cobertura = build/coverage.cobertura.xml 7 | html = build/coverage.html 8 | -------------------------------------------------------------------------------- /license_header.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2025 Contributors to the Eclipse Foundation 2 | 3 | This program and the accompanying materials are made available under the 4 | terms of the Apache License, Version 2.0 which is available at 5 | https://www.apache.org/licenses/LICENSE-2.0. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | License for the specific language governing permissions and limitations 11 | under the License. 12 | 13 | SPDX-License-Identifier: Apache-2.0 14 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | gcovr==5.2 2 | conan==2.15.1 3 | 4 | pre-commit==3.5.0 5 | cpplint==1.6.1 6 | -------------------------------------------------------------------------------- /sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | add_subdirectory(proto) 16 | add_subdirectory(src) 17 | 18 | if(SDK_BUILD_TESTS) 19 | add_subdirectory(tests) 20 | endif(SDK_BUILD_TESTS) 21 | -------------------------------------------------------------------------------- /sdk/include/sdk/DataPointBatch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_DATAPOINTBATCH_H 18 | #define VEHICLE_APP_SDK_DATAPOINTBATCH_H 19 | 20 | #include "sdk/AsyncResult.h" 21 | #include "sdk/DataPointValue.h" 22 | 23 | #include 24 | #include 25 | 26 | namespace velocitas { 27 | 28 | /** 29 | * @brief Batch implementation for setting multiple data points 30 | * atomically inside the VDB. 31 | * 32 | */ 33 | class DataPointBatch final { 34 | public: 35 | using SetErrorMap_t = std::map; 36 | 37 | DataPointBatch() = default; 38 | 39 | /** 40 | * @brief Add a data point and its new value to the batch. 41 | * It does **not** set the value yet! 42 | * 43 | * @tparam TDataPoint The type of the data point. 44 | * @param dataPoint The reference to the data point to set. 45 | * @param value The new value to set. 46 | * @return DataPointBatch& A reference to the batch for method chaining. 47 | */ 48 | template 49 | DataPointBatch& add(const TDataPoint& dataPoint, typename TDataPoint::value_type value) { 50 | m_dataPoints.emplace_back( 51 | std::make_unique>( 52 | dataPoint.getPath(), value, Timestamp{})); 53 | 54 | return *this; 55 | } 56 | 57 | /** 58 | * @brief Applies all data points and their values by invoking an atomic set 59 | * operation. 60 | * 61 | * @pre At least one point was added via @ref DataPointBatch:add 62 | * 63 | * @return AsyncResultPtr_t The async result of the 64 | * operation. Contains a map of [dataPointPath, error] if any of the added data points 65 | * caused an error during set. 66 | */ 67 | AsyncResultPtr_t apply(); 68 | 69 | private: 70 | std::vector> m_dataPoints; 71 | }; 72 | 73 | } // namespace velocitas 74 | 75 | #endif // VEHICLE_APP_SDK_DATAPOINTBATCH_H 76 | -------------------------------------------------------------------------------- /sdk/include/sdk/DataPointReply.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_DATAPOINTREPLY_H 18 | #define VEHICLE_APP_SDK_DATAPOINTREPLY_H 19 | 20 | #include "sdk/DataPointValue.h" 21 | #include "sdk/Exceptions.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace velocitas { 30 | 31 | using DataPointMap_t = std::map>; 32 | 33 | class DataPoint; 34 | 35 | /** 36 | * @brief Result of an operation which returns multiple data points. 37 | * Provides typed access to obtained data points. 38 | * 39 | */ 40 | class DataPointReply final { 41 | public: 42 | DataPointReply() = default; 43 | 44 | DataPointReply(DataPointMap_t&& dataPointsMap) 45 | : m_dataPointsMap(std::move(dataPointsMap)) {} 46 | 47 | /** 48 | * @brief Get the desired data point from the reply as an untyped DataPointValue. 49 | * 50 | * @param path The path ("name") of the data point to query from the reply. 51 | * @return std::shared_ptr The genric data point value contained in the reply. 52 | */ 53 | [[nodiscard]] std::shared_ptr getUntyped(const std::string& path) const { 54 | auto mapEntry = m_dataPointsMap.find(path); 55 | if (mapEntry == m_dataPointsMap.end()) { 56 | throw InvalidValueException(path + " is not contained in reply!"); 57 | } 58 | return mapEntry->second; 59 | } 60 | 61 | /** 62 | * @brief Get the desired data point from the reply. 63 | * 64 | * @tparam TDataPointType The type of the data point to return. 65 | * @param dataPoint The data point to query from the reply. 66 | * @return std::shared_ptr The data point value contained in the reply. 67 | */ 68 | template 69 | [[nodiscard]] std::shared_ptr> 70 | get(const TDataPointType& dataPoint) const { 71 | static_assert(std::is_base_of_v); 72 | 73 | auto value = getUntyped(dataPoint.getPath()); 74 | if (value->isValid()) { 75 | return std::dynamic_pointer_cast< 76 | TypedDataPointValue>(value); 77 | } 78 | 79 | return std::make_shared>( 80 | value->getPath(), value->getFailure(), value->getTimestamp()); 81 | } 82 | 83 | /** 84 | * @brief Check if the reply is empty. 85 | * 86 | * @return true Reply is empty. 87 | * @return false Reply is not empty. 88 | */ 89 | [[nodiscard]] bool empty() const { return m_dataPointsMap.empty(); } 90 | 91 | private: 92 | DataPointMap_t m_dataPointsMap; 93 | }; 94 | 95 | } // namespace velocitas 96 | 97 | #endif // VEHICLE_APP_SDK_DATAPOINTREPLY_H 98 | -------------------------------------------------------------------------------- /sdk/include/sdk/Exceptions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_EXCEPTIONS_H 18 | #define VEHICLE_APP_SDK_EXCEPTIONS_H 19 | 20 | #include 21 | 22 | namespace velocitas { 23 | 24 | /** 25 | * @brief Base exception when there is an issue during remote procedure calls. 26 | * 27 | */ 28 | class RpcException : public std::runtime_error { 29 | public: 30 | using std::runtime_error::runtime_error; 31 | }; 32 | 33 | /** 34 | * @brief Base exception when a type cannot be converted. 35 | * 36 | */ 37 | class InvalidTypeException : public std::runtime_error { 38 | public: 39 | using std::runtime_error::runtime_error; 40 | }; 41 | 42 | /** 43 | * @brief Base exception when an invalid value is received. 44 | * 45 | */ 46 | class InvalidValueException : public std::runtime_error { 47 | public: 48 | using std::runtime_error::runtime_error; 49 | }; 50 | 51 | /** 52 | * @brief Any issue which occurred during async invocation. 53 | * 54 | */ 55 | class AsyncException : public std::runtime_error { 56 | public: 57 | using std::runtime_error::runtime_error; 58 | }; 59 | 60 | } // namespace velocitas 61 | 62 | #endif // VEHICLE_APP_SDK_EXCEPTIONS_H 63 | -------------------------------------------------------------------------------- /sdk/include/sdk/Model.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_MODEL_H 18 | #define VEHICLE_APP_SDK_MODEL_H 19 | 20 | #include "sdk/DataPointBatch.h" 21 | #include "sdk/Node.h" 22 | #include "sdk/middleware/Middleware.h" 23 | 24 | #include 25 | 26 | namespace velocitas { 27 | 28 | /** 29 | * @brief The Model class represents a branch of the model tree, including root. 30 | * Leafs are typcially one of the typed DataPoint* classes. 31 | * But also a Model class can be a leaf, if it does not contain data Points, just methods. 32 | */ 33 | class Model : public Node { 34 | public: 35 | using Node::Node; 36 | 37 | [[nodiscard]] DataPointBatch setMany() const { return DataPointBatch{}; } 38 | }; 39 | 40 | /** 41 | * @brief Base class for services within the model tree. 42 | * 43 | */ 44 | class Service : public Node { 45 | public: 46 | using Node::Node; 47 | 48 | [[nodiscard]] std::string getLocation() const; 49 | [[nodiscard]] Middleware::Metadata getMiddlewareMetadata() const; 50 | }; 51 | 52 | } // namespace velocitas 53 | 54 | #endif // VEHICLE_APP_SDK_MODEL_H 55 | -------------------------------------------------------------------------------- /sdk/include/sdk/Node.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_NODE_H 18 | #define VEHICLE_APP_SDK_NODE_H 19 | 20 | #include 21 | 22 | namespace velocitas { 23 | 24 | /** 25 | * @brief A tree node. 26 | * 27 | */ 28 | class Node { 29 | public: 30 | enum class Type { 31 | BRANCH, 32 | UNKNOWN_LEAF_TYPE, // Added for backward compatibility with older model generators 33 | ATTRIBUTE, 34 | SENSOR, 35 | ACTUATOR, 36 | }; 37 | 38 | /** 39 | * @brief Construct a new Node object 40 | * 41 | * @param name Name of the node. 42 | * @param parent Parent of the node. 43 | */ 44 | explicit Node(std::string name, Node* parent = nullptr); 45 | 46 | virtual ~Node() = default; 47 | 48 | /** 49 | * @brief Get the parent node of this Node 50 | * 51 | * @return const Node* Pointer to the parent or nullptr if this node represents the root of the 52 | * model 53 | */ 54 | [[nodiscard]] const Node* getParent() const; 55 | 56 | /** 57 | * @brief Get the name of this node 58 | * 59 | * @return const std::string& being the name (not the path) of this node 60 | */ 61 | [[nodiscard]] const std::string& getName() const; 62 | 63 | /** 64 | * @brief Return the fully qualified path of the node down from the root of the tree. 65 | * 66 | * @return std::string Fully qualified path of the node within the tree. 67 | */ 68 | [[nodiscard]] std::string getPath() const; 69 | 70 | /** 71 | * @brief Get the type of the node 72 | * Possibly, needs being overridden by sub-classes 73 | * 74 | * @return Type::BRANCH as the Node base class always represents a branch of the model 75 | */ 76 | [[nodiscard]] virtual Type getType() const { return Type::BRANCH; } 77 | 78 | Node(const Node&) = delete; 79 | Node(Node&&) = delete; 80 | Node& operator=(const Node&) = delete; 81 | Node& operator=(Node&&) = delete; 82 | 83 | private: 84 | // TODO: Use std::weak_ptr ? 85 | Node* const m_parent; 86 | const std::string m_name; 87 | }; 88 | 89 | } // namespace velocitas 90 | 91 | #endif // VEHICLE_APP_SDK_NODE_H 92 | -------------------------------------------------------------------------------- /sdk/include/sdk/Status.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_STATUS_H 18 | #define VEHICLE_APP_SDK_STATUS_H 19 | 20 | #include 21 | #include 22 | 23 | namespace velocitas { 24 | 25 | /** 26 | * @brief Status of an asynchronous request. 27 | * 28 | */ 29 | class Status final { 30 | public: 31 | /** 32 | * @brief Construct a new Status object without any errors. 33 | * 34 | */ 35 | Status(){}; 36 | 37 | /** 38 | * @brief Construct a new error status. 39 | * 40 | * @param errorMsg 41 | */ 42 | Status(std::string errorMsg) 43 | : m_isOk(false) 44 | , m_errorMsg(std::move(errorMsg)) {} 45 | 46 | /** 47 | * @brief Returns whether the reported status is OK or not. 48 | * 49 | * @return true Status is OK 50 | * @return false Status is not OK 51 | */ 52 | [[nodiscard]] bool ok() const { return m_isOk; } 53 | 54 | /** 55 | * @brief Return the error message stored within the status. 56 | * 57 | * @return const std::string& Error message. May be empty if status is ok. 58 | */ 59 | [[nodiscard]] const std::string& errorMessage() const { return m_errorMsg; } 60 | 61 | private: 62 | bool m_isOk{true}; 63 | std::string m_errorMsg; 64 | }; 65 | 66 | } // namespace velocitas 67 | 68 | #endif // VEHICLE_APP_SDK_STATUS_H 69 | -------------------------------------------------------------------------------- /sdk/include/sdk/ThreadPool.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_THREADPOOL_H 18 | #define VEHICLE_APP_SDK_THREADPOOL_H 19 | 20 | #include "sdk/Job.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace velocitas { 32 | 33 | /** 34 | * @brief Manages a pool of threads which are capable of executing jobs asynchronously. 35 | * 36 | */ 37 | class ThreadPool final { 38 | public: 39 | ThreadPool(); 40 | explicit ThreadPool(size_t numWorkerThreads); 41 | 42 | ~ThreadPool(); 43 | 44 | /** 45 | * @brief Get the Instance object. 46 | * 47 | * @return std::shared_ptr 48 | */ 49 | static std::shared_ptr getInstance(); 50 | 51 | [[nodiscard]] size_t getNumWorkerThreads() const; 52 | 53 | /** 54 | * @brief Enqueue the given job to be executed asynchronously by one of the worker threads. 55 | * 56 | * @param job The job to execute. 57 | */ 58 | void enqueue(JobPtr_t job); 59 | 60 | ThreadPool(const ThreadPool&) = delete; 61 | ThreadPool(ThreadPool&&) = delete; 62 | ThreadPool& operator=(const ThreadPool&) = delete; 63 | ThreadPool& operator=(ThreadPool&&) = delete; 64 | 65 | private: 66 | JobPtr_t getNextExecutableJob(); 67 | void waitForPotentiallyExecutableJob() const; 68 | void threadLoop(); 69 | 70 | using QueueType = 71 | std::priority_queue, decltype(lowerJobPriority)*>; 72 | 73 | mutable std::mutex m_queueMutex; 74 | mutable std::condition_variable m_cv; 75 | QueueType m_jobs; 76 | std::vector m_workerThreads; 77 | std::atomic_bool m_isRunning{true}; 78 | }; 79 | 80 | } // namespace velocitas 81 | 82 | #endif // VEHICLE_APP_SDK_THREADPOOL_H 83 | -------------------------------------------------------------------------------- /sdk/include/sdk/VehicleModelContext.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VEHICLEMODELCONTEXT_H 18 | #define VEHICLE_APP_SDK_VEHICLEMODELCONTEXT_H 19 | 20 | #include "sdk/AsyncResult.h" 21 | #include "sdk/DataPoint.h" 22 | 23 | #include 24 | 25 | namespace velocitas { 26 | 27 | class IVehicleDataBrokerClient; 28 | 29 | /** 30 | * @brief Abstraction layer for vehicle models which provides access 31 | * to the actual implementation that drives the fluent queries (get/set/subscribe) 32 | * 33 | */ 34 | class VehicleModelContext final { 35 | public: 36 | /** 37 | * @brief Provide the instance of the context. 38 | * 39 | * @return VehicleModelContext& The context instance. 40 | */ 41 | static VehicleModelContext& getInstance() { 42 | static VehicleModelContext context{}; 43 | return context; 44 | } 45 | 46 | /** 47 | * @brief Set the VehicleDataBrokerClient implementation. 48 | * 49 | * @param vdbc Pointer to the VehicleDataBrokerClient 50 | */ 51 | void setVdbc(std::shared_ptr vdbc) { m_vdbc = vdbc; } 52 | 53 | /** 54 | * @brief Get the VehicleDataBrokerClient implementation. 55 | * 56 | * @return std::shared_ptr Pointer to the VehicleDataBrokerClient 57 | * implementation. 58 | */ 59 | std::shared_ptr getVdbc() { return m_vdbc; } 60 | 61 | private: 62 | VehicleModelContext() = default; 63 | 64 | std::shared_ptr m_vdbc; 65 | }; 66 | 67 | } // namespace velocitas 68 | 69 | #endif // VEHICLE_APP_SDK_VEHICLEMODELCONTEXT_H 70 | -------------------------------------------------------------------------------- /sdk/include/sdk/grpc/AsyncGrpcFacade.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_ASYNCGRPCFACADE_H 18 | #define VEHICLE_APP_SDK_ASYNCGRPCFACADE_H 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | class GrpcCall; 27 | 28 | class AsyncGrpcFacade { 29 | public: 30 | using ContextModifierFunction = std::function; 31 | 32 | void setContextModifier(ContextModifierFunction function); 33 | 34 | protected: 35 | void applyContextModifier(GrpcCall& call); // NOLINT 36 | 37 | private: 38 | ContextModifierFunction m_contextModifierFunction; 39 | }; 40 | 41 | } // namespace velocitas 42 | 43 | #endif // VEHICLE_APP_SDK_ASYNCGRPCFACADE_H 44 | -------------------------------------------------------------------------------- /sdk/include/sdk/grpc/GrpcClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_GRPCCLIENT_H 18 | #define VEHICLE_APP_SDK_GRPCCLIENT_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | class GrpcCall; 27 | 28 | class GrpcClient { 29 | public: 30 | GrpcClient() = default; 31 | virtual ~GrpcClient() = default; 32 | 33 | GrpcClient(const GrpcClient&) = delete; 34 | GrpcClient(GrpcClient&&) = delete; 35 | GrpcClient& operator=(const GrpcClient&) = delete; 36 | GrpcClient& operator=(GrpcClient&&) = delete; 37 | 38 | void addActiveCall(std::shared_ptr call); 39 | [[nodiscard]] size_t getNumActiveCalls() const { return m_activeCalls.size(); } 40 | 41 | private: 42 | void pruneCompletedRequests(); 43 | 44 | std::vector> m_activeCalls; 45 | std::mutex m_mutex; 46 | }; 47 | 48 | } // namespace velocitas 49 | 50 | #endif // VEHICLE_APP_SDK_GRPCCLIENT_H 51 | -------------------------------------------------------------------------------- /sdk/include/sdk/vdb/IVehicleDataBrokerClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_IVEHICLEDATABROKERCLIENT_H 18 | #define VEHICLE_APP_SDK_IVEHICLEDATABROKERCLIENT_H 19 | 20 | #include "sdk/AsyncResult.h" 21 | #include "sdk/DataPointReply.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace velocitas { 29 | 30 | class DataPointReply; 31 | class DataPointValue; 32 | 33 | /** 34 | * @brief Interface for implementing VehicleDataBroker clients. 35 | * 36 | */ 37 | class IVehicleDataBrokerClient { 38 | public: 39 | using SetErrorMap_t = std::map; 40 | 41 | virtual ~IVehicleDataBrokerClient() = default; 42 | 43 | IVehicleDataBrokerClient(const IVehicleDataBrokerClient&) = delete; 44 | IVehicleDataBrokerClient(IVehicleDataBrokerClient&&) = delete; 45 | IVehicleDataBrokerClient& operator=(const IVehicleDataBrokerClient&) = delete; 46 | IVehicleDataBrokerClient& operator=(IVehicleDataBrokerClient&&) = delete; 47 | 48 | /** 49 | * @brief Returns data points for a list of data point paths from the VDB. 50 | * 51 | * @param datapoints The list of data point paths to query. 52 | * 53 | * @return The AsyncResult containing the values of all requested data points 54 | */ 55 | virtual AsyncResultPtr_t 56 | getDatapoints(const std::vector& datapoints) = 0; 57 | 58 | /** 59 | * @brief Set datapoint values in the VDB. 60 | * 61 | * @return AsyncResultPtr_t A map which contains [key, error] entries 62 | * if a data point could not be set. 63 | */ 64 | virtual AsyncResultPtr_t 65 | setDatapoints(const std::vector>& datapoints) = 0; 66 | 67 | /** 68 | * @brief Subscribe to updates for the given query. 69 | * 70 | * @param query The query to subscribe to. 71 | * 72 | * @return The subscription to the data points. 73 | */ 74 | virtual AsyncSubscriptionPtr_t subscribe(const std::string& query) = 0; 75 | 76 | /** 77 | * @brief Create an instance of the IVehicleDataBrokerClient. 78 | * 79 | * @param serviceName The name of the VDB. 80 | * 81 | * @return std::shared_ptr 82 | */ 83 | static std::shared_ptr createInstance(const std::string& serviceName); 84 | 85 | protected: 86 | IVehicleDataBrokerClient() = default; 87 | }; 88 | 89 | } // namespace velocitas 90 | 91 | #endif // VEHICLE_APP_SDK_IVEHICLEDATABROKERCLIENT_H 92 | -------------------------------------------------------------------------------- /sdk/proto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "vehicle-app-sdk-generated-grpc") 16 | 17 | add_library(${TARGET_NAME} STATIC 18 | kuksa/val/v2/types.proto 19 | kuksa/val/v2/val.proto 20 | sdv/databroker/v1/types.proto 21 | sdv/databroker/v1/collector.proto 22 | sdv/databroker/v1/broker.proto 23 | ) 24 | 25 | target_include_directories(${TARGET_NAME} 26 | PUBLIC 27 | ${absl_INCLUDE_DIRS} 28 | ${protobuf_INCLUDE_DIRS} 29 | ${gRPC_INCLUDE_DIRS} 30 | ${CMAKE_CURRENT_BINARY_DIR} 31 | ) 32 | 33 | target_link_libraries(${TARGET_NAME} 34 | gRPC::grpc++ 35 | ) 36 | 37 | protobuf_generate(TARGET ${TARGET_NAME}) 38 | protobuf_generate( 39 | TARGET ${TARGET_NAME} 40 | LANGUAGE grpc 41 | PLUGIN protoc-gen-grpc=$ 42 | PLUGIN_OPTIONS generate_mock_code=true 43 | GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc) 44 | -------------------------------------------------------------------------------- /sdk/proto/sdv/databroker/v1/broker.proto: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * Copyright (c) 2022 Contributors to the Eclipse Foundation 3 | * 4 | * See the NOTICE file(s) distributed with this work for additional 5 | * information regarding copyright ownership. 6 | * 7 | * This program and the accompanying materials are made available under the 8 | * terms of the Apache License 2.0 which is available at 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | ********************************************************************************/ 13 | 14 | syntax = "proto3"; 15 | 16 | package sdv.databroker.v1; 17 | 18 | import "sdv/databroker/v1/types.proto"; 19 | 20 | service Broker { 21 | // Request a set of datapoints (values) 22 | // 23 | // Returns a list of requested data points. 24 | // 25 | // InvalidArgument is returned if the request is malformed. 26 | rpc GetDatapoints(GetDatapointsRequest) returns (GetDatapointsReply); 27 | 28 | // Set a datapoint (values) 29 | rpc SetDatapoints(SetDatapointsRequest) returns (SetDatapointsReply); 30 | 31 | // Subscribe to a set of data points or conditional expressions 32 | // using the Data Broker Query Syntax (described in QUERY.md) 33 | // 34 | // Returns a stream of replies. 35 | // 36 | // InvalidArgument is returned if the request is malformed. 37 | rpc Subscribe(SubscribeRequest) returns (stream SubscribeReply); 38 | 39 | // Request the metadata of a set of datapoints 40 | // 41 | // Returns metadata of the requested data points that exist. 42 | rpc GetMetadata(GetMetadataRequest) returns (GetMetadataReply); 43 | } 44 | 45 | message GetDatapointsRequest { 46 | // A list of requested data points. 47 | repeated string datapoints = 1; 48 | } 49 | 50 | message GetDatapointsReply { 51 | // Contains the values of the requested data points. 52 | // If a requested data point is not available, the corresponding Datapoint 53 | // will have the respective failure value set. 54 | map datapoints = 1; 55 | } 56 | 57 | message SetDatapointsRequest { 58 | // A map of data points to set 59 | map datapoints = 1; 60 | } 61 | 62 | message SetDatapointsReply { 63 | // A map of errors (if any) 64 | map errors = 1; 65 | } 66 | 67 | message SubscribeRequest { 68 | // Subscribe to a set of data points (or expressions) described 69 | // by the provided query. 70 | // The query syntax is a subset of SQL and is described in more 71 | // detail in the QUERY.md file. 72 | string query = 2; 73 | } 74 | 75 | message SubscribeReply { 76 | // Contains the fields specified by the query. 77 | // If a requested data point value is not available, the corresponding 78 | // Datapoint will have it's respective failure value set. 79 | map fields = 1; 80 | } 81 | 82 | message GetMetadataRequest { 83 | // Request metadata for a list of data points referenced by their names. 84 | // e.g. "Vehicle.Cabin.Seat.Row1.Pos1.Position" or "Vehicle.Speed". 85 | // 86 | // If no names are provided, metadata for all known data points will be 87 | // returned. 88 | repeated string names = 1; 89 | } 90 | 91 | message GetMetadataReply { 92 | // Contains metadata of the requested data points. If a data point 93 | // doesn't exist (i.e. not known to the Data Broker) the corresponding 94 | // Metadata isn't part of the returned list. 95 | repeated Metadata list = 1; 96 | } 97 | -------------------------------------------------------------------------------- /sdk/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "vehicle-app-sdk") 16 | 17 | add_library(${TARGET_NAME} 18 | sdk/VehicleApp.cpp 19 | sdk/Model.cpp 20 | sdk/Node.cpp 21 | sdk/QueryBuilder.cpp 22 | sdk/DataPoint.cpp 23 | sdk/DataPointValue.cpp 24 | sdk/ThreadPool.cpp 25 | sdk/Job.cpp 26 | sdk/Utils.cpp 27 | sdk/Logger.cpp 28 | 29 | sdk/grpc/GrpcClient.cpp 30 | sdk/grpc/AsyncGrpcFacade.cpp 31 | 32 | sdk/middleware/Middleware.cpp 33 | sdk/middleware/NativeMiddleware.cpp 34 | 35 | sdk/pubsub/MqttPubSubClient.cpp 36 | sdk/vdb/DataPointBatch.cpp 37 | sdk/vdb/IVehicleDataBrokerClient.cpp 38 | sdk/vdb/grpc/common/ChannelConfiguration.cpp 39 | sdk/vdb/grpc/common/TypeConversions.cpp 40 | sdk/vdb/grpc/kuksa_val_v2/BrokerAsyncGrpcFacade.cpp 41 | sdk/vdb/grpc/kuksa_val_v2/BrokerClient.cpp 42 | sdk/vdb/grpc/kuksa_val_v2/Metadata.cpp 43 | sdk/vdb/grpc/kuksa_val_v2/TypeConversions.cpp 44 | sdk/vdb/grpc/sdv_databroker_v1/BrokerAsyncGrpcFacade.cpp 45 | sdk/vdb/grpc/sdv_databroker_v1/BrokerClient.cpp 46 | sdk/vdb/grpc/sdv_databroker_v1/GrpcDataPointValueProvider.cpp 47 | ) 48 | 49 | target_include_directories(${TARGET_NAME} 50 | PUBLIC 51 | ${fmt_INCLUDE_DIRS} 52 | ${absl_INCLUDE_DIRS} 53 | ${gRPC_INCLUDE_DIRS} 54 | ../include 55 | PRIVATE 56 | . 57 | ) 58 | 59 | target_link_libraries(${TARGET_NAME} 60 | gRPC::grpc++ 61 | fmt::fmt 62 | PahoMqttCpp::paho-mqttpp3-static 63 | nlohmann_json::nlohmann_json 64 | vehicle-app-sdk-generated-grpc 65 | ) 66 | -------------------------------------------------------------------------------- /sdk/src/sdk/DataPointValue.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/DataPointValue.h" 18 | 19 | #include "sdk/Logger.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace velocitas { 27 | 28 | std::string toString(const DataPointValue::Failure failure) { 29 | switch (failure) { 30 | case DataPointValue::Failure::NONE: 31 | return "DataPointValue::Failure::NONE"; 32 | case DataPointValue::Failure::INVALID_VALUE: 33 | return "DataPointValue::Failure::INVALID_VALUE"; 34 | case DataPointValue::Failure::NOT_AVAILABLE: 35 | return "DataPointValue::Failure::NOT_AVAILABLE"; 36 | case DataPointValue::Failure::UNKNOWN_DATAPOINT: 37 | return "DataPointValue::Failure::UNKNOWN_DATAPOINT"; 38 | case DataPointValue::Failure::ACCESS_DENIED: 39 | return "DataPointValue::Failure::ACCESS_DENIED"; 40 | case DataPointValue::Failure::INTERNAL_ERROR: 41 | return "DataPointValue::Failure::INTERNAL_ERROR"; 42 | default: 43 | logger().error("velocitas::toString(DataPointValue::Failure): Unknown " 44 | "DataPointValue::Failure enum value {}", 45 | static_cast(failure)); 46 | assert(false); 47 | return fmt::format("DataPointValue::Failure::", 48 | static_cast(failure)); 49 | } 50 | } 51 | 52 | } // namespace velocitas 53 | -------------------------------------------------------------------------------- /sdk/src/sdk/Job.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Job.h" 18 | 19 | namespace velocitas { 20 | 21 | bool lowerJobPriority(const JobPtr_t& left, const JobPtr_t& right) { 22 | return left->getTimepointToExecute() > right->getTimepointToExecute(); 23 | } 24 | 25 | Job::Job(std::function fun, std::chrono::milliseconds delay) 26 | : m_fun(std::move(fun)) { 27 | if (delay > std::chrono::milliseconds::zero()) { 28 | m_timepointToExecute = Clock::now() + delay; 29 | } 30 | } 31 | 32 | void Job::waitForTermination() const { std::lock_guard lock(m_terminationMutex); } 33 | 34 | void Job::execute() { 35 | std::lock_guard lock(m_terminationMutex); 36 | m_fun(); 37 | } 38 | 39 | void RecurringJob::execute() { 40 | if (!m_isCancelled) { 41 | Job::execute(); 42 | } 43 | } 44 | 45 | } // namespace velocitas 46 | -------------------------------------------------------------------------------- /sdk/src/sdk/Logger.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Logger.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | /** 27 | * @brief Logger implementation for logging to the console. 28 | * 29 | */ 30 | class ConsoleLogger : public ILogger { 31 | public: 32 | void info(const std::string& msg) override { log("INFO ", fmt::color::white, msg); } 33 | 34 | void warn(const std::string& msg) override { log("WARN ", fmt::color::yellow, msg); } 35 | 36 | void error(const std::string& msg) override { log("ERROR", fmt::color::red, msg); } 37 | 38 | void debug(const std::string& msg) override { log("DEBUG", fmt::color::brown, msg); } 39 | 40 | private: 41 | void log(const std::string& level, fmt::color color, const std::string& msg) { 42 | fmt::print(fmt::fg(color), "{}, {} : {}\n", std::chrono::system_clock::now(), level, msg); 43 | std::fflush(stdout); 44 | } 45 | }; 46 | 47 | Logger::Logger() 48 | : m_impl(std::make_unique()) {} 49 | 50 | } // namespace velocitas 51 | -------------------------------------------------------------------------------- /sdk/src/sdk/Model.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Model.h" 18 | #include "sdk/middleware/Middleware.h" 19 | 20 | namespace velocitas { 21 | 22 | std::string Service::getLocation() const { 23 | return Middleware::getInstance().getServiceLocation(getName()); 24 | } 25 | 26 | Middleware::Metadata Service::getMiddlewareMetadata() const { 27 | return Middleware::getInstance().getMetadata(getName()); 28 | } 29 | 30 | } // namespace velocitas 31 | -------------------------------------------------------------------------------- /sdk/src/sdk/Node.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Node.h" 18 | #include "sdk/Utils.h" 19 | 20 | #include 21 | 22 | namespace velocitas { 23 | 24 | Node::Node(std::string name, Node* parent) 25 | : m_name(std::move(name)) 26 | , m_parent(parent) {} 27 | 28 | const Node* Node::getParent() const { return m_parent; } 29 | 30 | const std::string& Node::getName() const { return m_name; } 31 | 32 | std::string Node::getPath() const { 33 | std::vector path; 34 | path.push_back(m_name); 35 | auto* node = m_parent; 36 | while (node != nullptr) { 37 | path.insert(path.begin(), node->m_name); 38 | node = node->m_parent; 39 | } 40 | 41 | return StringUtils::join(path, "."); 42 | } 43 | 44 | } // namespace velocitas 45 | -------------------------------------------------------------------------------- /sdk/src/sdk/QueryBuilder.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/QueryBuilder.h" 18 | #include "sdk/Utils.h" 19 | 20 | #include 21 | 22 | namespace velocitas { 23 | 24 | QueryBuilder QueryBuilder::select(const DataPoint& dataPoint) { 25 | QueryBuilder builder; 26 | builder.m_queryContext.emplace_back("SELECT"); 27 | builder.m_queryContext.push_back(dataPoint.getPath()); 28 | return builder; 29 | } 30 | 31 | QueryBuilder 32 | QueryBuilder::select(const std::vector>& dataPoints) { 33 | QueryBuilder builder; 34 | builder.m_queryContext.emplace_back("SELECT"); 35 | 36 | std::vector paths; 37 | paths.reserve(dataPoints.size()); 38 | std::transform(dataPoints.begin(), dataPoints.end(), std::back_inserter(paths), 39 | [](const auto& dataPoint) { return dataPoint.get().getPath(); }); 40 | 41 | builder.m_queryContext.emplace_back(StringUtils::join(paths, ", ")); 42 | return builder; 43 | } 44 | 45 | std::string QueryBuilder::build() const { return StringUtils::join(m_queryContext, " "); } 46 | 47 | } // namespace velocitas 48 | -------------------------------------------------------------------------------- /sdk/src/sdk/Utils.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Utils.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | std::string getEnvVar(const std::string& varName, const std::string& defaultValue) { 27 | auto* const value = ::getenv(varName.c_str()); 28 | if (value != nullptr) { 29 | return std::string(value); 30 | } 31 | return defaultValue; 32 | } 33 | 34 | std::string StringUtils::toLower(const std::string& str) { 35 | std::string result{str}; 36 | std::transform(result.begin(), result.end(), result.begin(), ::tolower); 37 | return result; 38 | } 39 | 40 | std::string StringUtils::toUpper(const std::string& str) { 41 | std::string result{str}; 42 | std::transform(result.begin(), result.end(), result.begin(), ::toupper); 43 | return result; 44 | } 45 | 46 | std::string StringUtils::join(const std::vector& stringVector, 47 | const std::string& separator) { 48 | std::ostringstream oss; 49 | if (!stringVector.empty()) { 50 | oss << stringVector.front(); 51 | std::for_each(stringVector.begin() + 1, stringVector.end(), 52 | [&oss, &separator](const std::string& elem) { oss << separator << elem; }); 53 | } 54 | return oss.str(); 55 | } 56 | 57 | namespace { 58 | constexpr std::string_view SCHEME_PART_START = "//"; 59 | constexpr std::string_view SIMPLIFIED_SCHEME_SEPARATOR = "://"; 60 | } // namespace 61 | 62 | SimpleUrlParse::SimpleUrlParse(const std::string& url) { 63 | auto schemeLen = url.find(SIMPLIFIED_SCHEME_SEPARATOR); 64 | if (schemeLen != std::string::npos) { 65 | m_scheme = StringUtils::toLower(url.substr(0, schemeLen)); 66 | } else { 67 | schemeLen = 0; 68 | } 69 | 70 | // return the full URL if using Unix domain socket 71 | if (m_scheme == "unix") { 72 | m_netLocation = url; 73 | return; 74 | } 75 | 76 | auto startOfSchemePart = url.find(SCHEME_PART_START, schemeLen); 77 | if (startOfSchemePart != std::string::npos) { 78 | startOfSchemePart += SCHEME_PART_START.length(); 79 | } else { 80 | startOfSchemePart = 0; 81 | } 82 | 83 | auto netLocationLen = url.find("/", startOfSchemePart); 84 | if (netLocationLen != std::string::npos) { 85 | netLocationLen -= startOfSchemePart; 86 | } 87 | m_netLocation = url.substr(startOfSchemePart, netLocationLen); 88 | } 89 | 90 | } // namespace velocitas 91 | -------------------------------------------------------------------------------- /sdk/src/sdk/grpc/AsyncGrpcFacade.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/grpc/AsyncGrpcFacade.h" 18 | #include "sdk/grpc/GrpcCall.h" 19 | 20 | namespace velocitas { 21 | 22 | void AsyncGrpcFacade::setContextModifier(ContextModifierFunction function) { 23 | m_contextModifierFunction = function; 24 | } 25 | 26 | void AsyncGrpcFacade::applyContextModifier(GrpcCall& call) { 27 | if (m_contextModifierFunction) { 28 | m_contextModifierFunction(call.m_context); 29 | } 30 | } 31 | 32 | } // namespace velocitas 33 | -------------------------------------------------------------------------------- /sdk/src/sdk/grpc/GrpcClient.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/grpc/GrpcClient.h" 18 | #include "sdk/grpc/GrpcCall.h" 19 | 20 | namespace velocitas { 21 | 22 | void GrpcClient::addActiveCall(std::shared_ptr call) { 23 | pruneCompletedRequests(); 24 | { 25 | std::scoped_lock lock(m_mutex); 26 | m_activeCalls.emplace_back(call); 27 | } 28 | } 29 | 30 | void GrpcClient::pruneCompletedRequests() { 31 | static auto isComplete = [](const auto& activeCall) { return activeCall->m_isComplete; }; 32 | 33 | { 34 | std::scoped_lock lock(m_mutex); 35 | m_activeCalls.erase(std::remove_if(m_activeCalls.begin(), m_activeCalls.end(), isComplete), 36 | m_activeCalls.end()); 37 | } 38 | } 39 | 40 | } // namespace velocitas 41 | -------------------------------------------------------------------------------- /sdk/src/sdk/middleware/Middleware.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/middleware/Middleware.h" 18 | 19 | #include "NativeMiddleware.h" 20 | 21 | #include "sdk/Utils.h" 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace velocitas { 29 | 30 | std::unique_ptr Middleware::instantiate() { 31 | const std::string middlewareType = StringUtils::toLower(getEnvVar(TYPE_DEFINING_ENV_VAR_NAME)); 32 | if (middlewareType.empty()) { 33 | return std::make_unique(); 34 | } else if (middlewareType == NativeMiddleware::TYPE_ID) { 35 | return std::make_unique(); 36 | } else { 37 | throw std::runtime_error(fmt::format("Unknown middleware type '{}'", middlewareType)); 38 | } 39 | } 40 | 41 | } // namespace velocitas 42 | -------------------------------------------------------------------------------- /sdk/src/sdk/middleware/NativeMiddleware.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "NativeMiddleware.h" 18 | 19 | #include "sdk/IPubSubClient.h" 20 | #include "sdk/Logger.h" 21 | #include "sdk/Utils.h" 22 | 23 | #include "fmt/core.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace velocitas { 30 | 31 | static const std::unordered_map DEFAULT_LOCATIONS = { 32 | {"mqtt", "localhost:1883"}, 33 | {"vehicledatabroker", "localhost:55555"}, 34 | }; 35 | 36 | static std::string getDefaultLocation(const std::string& serviceName) { 37 | std::string defaultLocation; 38 | auto iter = DEFAULT_LOCATIONS.find(StringUtils::toLower(serviceName)); 39 | if (iter != DEFAULT_LOCATIONS.end()) { 40 | defaultLocation = SimpleUrlParse(iter->second).getNetLocation(); 41 | } 42 | return defaultLocation; 43 | }; 44 | 45 | static std::string getServiceEnvVarName(const std::string& serviceName) { 46 | return "SDV_" + StringUtils::toUpper(serviceName) + "_ADDRESS"; 47 | } 48 | 49 | std::string NativeMiddleware::getServiceLocation(const std::string& serviceName) const { 50 | auto envVarName = getServiceEnvVarName(serviceName); 51 | auto serviceAddress = SimpleUrlParse(getEnvVar(envVarName)).getNetLocation(); 52 | if (!serviceAddress.empty()) { 53 | return serviceAddress; 54 | } 55 | 56 | serviceAddress = getDefaultLocation(serviceName); 57 | if (!serviceAddress.empty()) { 58 | logger().warn("Env variable '{}' defining location of service '{}' not properly set. " 59 | "Taking default: '{}'", 60 | envVarName, serviceName, serviceAddress); 61 | return serviceAddress; 62 | } 63 | 64 | const std::string errorMsg{ 65 | fmt::format("Env variable '{}' defining location of service '{}' not set. Please define!", 66 | envVarName, serviceName)}; 67 | logger().error(errorMsg); 68 | throw std::runtime_error(errorMsg); 69 | } 70 | 71 | std::shared_ptr 72 | NativeMiddleware::createPubSubClient(const std::string& clientId) const { 73 | std::string brokerLocation = getServiceLocation("mqtt"); 74 | return IPubSubClient::createInstance(brokerLocation, clientId); 75 | } 76 | 77 | } // namespace velocitas 78 | -------------------------------------------------------------------------------- /sdk/src/sdk/middleware/NativeMiddleware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_MIDDLEWARE_NATIVEMIDDLEWARE_H 18 | #define VEHICLE_APP_SDK_MIDDLEWARE_NATIVEMIDDLEWARE_H 19 | 20 | #include "sdk/middleware/Middleware.h" 21 | 22 | namespace velocitas { 23 | 24 | class NativeMiddleware : public Middleware { 25 | public: 26 | static constexpr char const* TYPE_ID = "native"; 27 | 28 | NativeMiddleware() 29 | : Middleware(TYPE_ID) {} 30 | 31 | std::string getServiceLocation(const std::string& serviceName) const override; 32 | std::shared_ptr createPubSubClient(const std::string& clientId) const override; 33 | }; 34 | 35 | } // namespace velocitas 36 | 37 | #endif // VEHICLE_APP_SDK_MIDDLEWARE_NATIVEMIDDLEWARE_H 38 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/DataPointBatch.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/DataPointBatch.h" 18 | #include "sdk/VehicleModelContext.h" 19 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 20 | 21 | #include "sdk/Exceptions.h" 22 | 23 | namespace velocitas { 24 | 25 | AsyncResultPtr_t DataPointBatch::apply() { 26 | if (m_dataPoints.empty()) { 27 | throw InvalidValueException("Called DataPointBatch::apply() without any data points!"); 28 | } 29 | 30 | return VehicleModelContext::getInstance().getVdbc()->setDatapoints(std::move(m_dataPoints)); 31 | } 32 | 33 | } // namespace velocitas 34 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/IVehicleDataBrokerClient.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 18 | 19 | #include "sdk/Logger.h" 20 | #include "sdk/Utils.h" 21 | #include "sdk/vdb/grpc/kuksa_val_v2/BrokerClient.h" 22 | #include "sdk/vdb/grpc/sdv_databroker_v1/BrokerClient.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace velocitas { 29 | 30 | static const std::string API_DEFINING_ENV_VAR = "KUKSA_DATABROKER_API"; // NOLINT(runtime/string) 31 | static const std::string SDV_V1_API = "sdv.databroker.v1"; // NOLINT(runtime/string) 32 | static const std::string KUKSA_V2_API = "kuksa.val.v2"; // NOLINT(runtime/string) 33 | static const auto& DEFAULT_API = SDV_V1_API; 34 | 35 | std::shared_ptr 36 | IVehicleDataBrokerClient::createInstance(const std::string& vdbServiceName) { 37 | const auto apiVariant = getEnvVar(API_DEFINING_ENV_VAR, DEFAULT_API); 38 | 39 | if (apiVariant == SDV_V1_API) { 40 | logger().info("Using Kuksa Databroker {} API", apiVariant); 41 | return std::make_shared(vdbServiceName); 42 | } 43 | 44 | if (apiVariant == KUKSA_V2_API) { 45 | logger().info("Using Kuksa Databroker {} API", apiVariant); 46 | return std::make_shared(vdbServiceName); 47 | } 48 | 49 | logger().error("Unsupported Kuksa Databroker {} API", apiVariant); 50 | throw std::runtime_error("Unsupported API specified"); 51 | } 52 | 53 | } // namespace velocitas 54 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/common/ChannelConfiguration.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "ChannelConfiguration.h" 18 | 19 | #include "sdk/Logger.h" 20 | #include "sdk/Utils.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | extern char** environ; 27 | 28 | namespace velocitas { 29 | 30 | namespace { 31 | constexpr char const* ENV_VAR_CHANNEL_CONFIG = "SDV_VDB_CHANNEL_CONFIG_PATH"; 32 | 33 | constexpr char const* JSON_CHANNEL_ARGS_KEY = "channelArguments"; 34 | } // namespace 35 | 36 | grpc::ChannelArguments getChannelArguments() { 37 | grpc::ChannelArguments chArgs; 38 | 39 | std::string chConfigFilepath = getEnvVar(ENV_VAR_CHANNEL_CONFIG); 40 | if (!chConfigFilepath.empty()) { 41 | auto ifs = std::ifstream(chConfigFilepath); 42 | if (ifs.is_open()) { 43 | try { 44 | velocitas::logger().info("Reading channel configuration from file {}.", 45 | chConfigFilepath); 46 | const auto config = nlohmann::json::parse(ifs); 47 | const auto& channelArgs = config[JSON_CHANNEL_ARGS_KEY]; 48 | for (const auto& channelArg : channelArgs.items()) { 49 | if (channelArg.value().is_number_integer()) { 50 | chArgs.SetInt(channelArg.key(), channelArg.value()); 51 | } else if (channelArg.value().is_string()) { 52 | chArgs.SetString(channelArg.key(), channelArg.value()); 53 | } else { 54 | velocitas::logger().warn("Ignoring channel argument {} - unknown type.", 55 | channelArg.key()); 56 | } 57 | } 58 | } catch (const nlohmann::json::exception& ex) { 59 | velocitas::logger().warn("Error reading channel configuration file {}.", 60 | chConfigFilepath); 61 | } 62 | } else { 63 | velocitas::logger().warn("Cannot open channel configuration file {}.", 64 | chConfigFilepath); 65 | } 66 | } 67 | 68 | return chArgs; 69 | } 70 | 71 | } // namespace velocitas 72 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/common/ChannelConfiguration.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VDB_GRPC_COMMON_CHANNELCONFIGURATION_H 18 | #define VEHICLE_APP_SDK_VDB_GRPC_COMMON_CHANNELCONFIGURATION_H 19 | 20 | namespace grpc { 21 | class ChannelArguments; 22 | } 23 | 24 | namespace velocitas { 25 | 26 | grpc::ChannelArguments getChannelArguments(); 27 | 28 | } // namespace velocitas 29 | 30 | #endif // VEHICLE_APP_SDK_VDB_GRPC_COMMON_CHANNELCONFIGURATION_H 31 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/common/TypeConversions.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "TypeConversions.h" 18 | 19 | #include "sdk/DataPointValue.h" 20 | 21 | #include 22 | 23 | namespace velocitas { 24 | 25 | Timestamp convertFromGrpcTimestamp(const google::protobuf::Timestamp& grpcTimestamp) noexcept { 26 | return {grpcTimestamp.seconds(), grpcTimestamp.nanos()}; 27 | } 28 | 29 | } // namespace velocitas 30 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/common/TypeConversions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VDB_GRPC_COMMON_TYPECONVERSIONS_H 18 | #define VEHICLE_APP_SDK_VDB_GRPC_COMMON_TYPECONVERSIONS_H 19 | 20 | namespace google::protobuf { 21 | class Timestamp; 22 | } 23 | 24 | namespace velocitas { 25 | 26 | class Timestamp; 27 | 28 | Timestamp convertFromGrpcTimestamp(const google::protobuf::Timestamp& grpcTimestamp) noexcept; 29 | 30 | } // namespace velocitas 31 | 32 | #endif // VEHICLE_APP_SDK_VDB_GRPC_COMMON_TYPECONVERSIONS_H 33 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/kuksa_val_v2/BrokerAsyncGrpcFacade.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERASYNCGRPCFACADE_H 18 | #define VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERASYNCGRPCFACADE_H 19 | 20 | #include "sdk/grpc/AsyncGrpcFacade.h" 21 | #include "sdk/grpc/GrpcCall.h" 22 | 23 | #include "kuksa/val/v2/val.grpc.pb.h" 24 | 25 | #include 26 | #include 27 | 28 | namespace grpc { 29 | class Channel; 30 | class Status; 31 | } // namespace grpc 32 | 33 | namespace velocitas::kuksa_val_v2 { 34 | 35 | class BrokerAsyncGrpcFacade : public AsyncGrpcFacade { 36 | public: 37 | explicit BrokerAsyncGrpcFacade(const std::shared_ptr& channel); 38 | 39 | void GetValues(kuksa::val::v2::GetValuesRequest request, 40 | std::function replyHandler, 41 | std::function errorHandler); 42 | 43 | std::shared_ptr SubscribeById( 44 | kuksa::val::v2::SubscribeByIdRequest request, 45 | std::function updateHandler, 46 | std::function errorHandler); 47 | 48 | void BatchActuate( 49 | kuksa::val::v2::BatchActuateRequest request, 50 | std::function replyHandler, 51 | std::function errorHandler); 52 | 53 | void ListMetadata( 54 | kuksa::val::v2::ListMetadataRequest request, 55 | std::function replyHandler, 56 | std::function errorHandler); 57 | 58 | private: 59 | std::unique_ptr m_stub; 60 | }; 61 | 62 | } // namespace velocitas::kuksa_val_v2 63 | 64 | #endif // VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERASYNCGRPCFACADE_H 65 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/kuksa_val_v2/BrokerClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERCLIENT_H 18 | #define VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERCLIENT_H 19 | 20 | #include "BrokerAsyncGrpcFacade.h" 21 | #include "Metadata.h" 22 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 23 | 24 | #include 25 | #include 26 | 27 | namespace velocitas { 28 | 29 | class GrpcClient; 30 | 31 | namespace kuksa_val_v2 { 32 | 33 | /** 34 | * Provides the Graph API to access vehicle signals via the kuksa.val.v2 API 35 | */ 36 | class BrokerClient : public IVehicleDataBrokerClient { 37 | public: 38 | BrokerClient(const std::string& vdbAddress, const std::string& vdbServiceName); 39 | explicit BrokerClient(const std::string& vdbserviceName); 40 | 41 | ~BrokerClient() override; 42 | 43 | BrokerClient(const BrokerClient&) = delete; 44 | BrokerClient(BrokerClient&&) = delete; 45 | BrokerClient& operator=(const BrokerClient&) = delete; 46 | BrokerClient& operator=(BrokerClient&&) = delete; 47 | 48 | AsyncResultPtr_t 49 | getDatapoints(const std::vector& datapoints) override; 50 | 51 | AsyncResultPtr_t 52 | setDatapoints(const std::vector>& datapoints) override; 53 | 54 | AsyncSubscriptionPtr_t subscribe(const std::string& query) override; 55 | 56 | private: 57 | void onGetValuesResponse(const kuksa::val::v2::GetValuesResponse& response, 58 | const MetadataList_t& metadataList, size_t numRequestedSignals, 59 | const AsyncResultPtr_t& result); 60 | void onGetValuesError(const grpc::Status& status, const MetadataList_t& metadataList, 61 | const AsyncResultPtr_t& result); 62 | 63 | std::shared_ptr m_asyncBrokerFacade; 64 | std::shared_ptr m_metadataAgent; 65 | std::unique_ptr m_activeCalls; 66 | }; 67 | 68 | } // namespace kuksa_val_v2 69 | } // namespace velocitas 70 | 71 | #endif // VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_BROKERCLIENT_H 72 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/kuksa_val_v2/TypeConversions.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_TYPECONVERSIONS_H 18 | #define VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_TYPECONVERSIONS_H 19 | 20 | #include "kuksa/val/v2/val.grpc.pb.h" 21 | 22 | #include "sdk/DataPointValue.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace velocitas::kuksa_val_v2 { 29 | 30 | kuksa::val::v2::Value convertToGrpcValue(const DataPointValue& dataPoint); 31 | 32 | std::shared_ptr convertFromGrpcValue(const std::string& path, 33 | const kuksa::val::v2::Value& value, 34 | const Timestamp& timestamp); 35 | 36 | std::shared_ptr 37 | convertFromGrpcDataPoint(const std::string& path, const kuksa::val::v2::Datapoint& grpcDataPoint); 38 | 39 | std::vector parseQuery(const std::string& query); 40 | 41 | } // namespace velocitas::kuksa_val_v2 42 | 43 | #endif // VEHICLE_APP_SDK_VDB_GRPC_KUKSA_VAL_V2_TYPECONVERSIONS_H 44 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/sdv_databroker_v1/BrokerAsyncGrpcFacade.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_BROKERASYNCGRPCFACADE_H 18 | #define VEHICLE_APP_SDK_BROKERASYNCGRPCFACADE_H 19 | 20 | #include "sdk/grpc/AsyncGrpcFacade.h" 21 | #include "sdk/grpc/GrpcClient.h" 22 | 23 | #include "sdv/databroker/v1/broker.grpc.pb.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace grpc { 32 | class Channel; 33 | class Status; 34 | } // namespace grpc 35 | 36 | namespace velocitas::sdv_databroker_v1 { 37 | 38 | class BrokerAsyncGrpcFacade : public AsyncGrpcFacade, GrpcClient { 39 | public: 40 | explicit BrokerAsyncGrpcFacade(const std::shared_ptr& channel); 41 | 42 | void GetDatapoints( 43 | const std::vector& datapoints, 44 | std::function replyHandler, 45 | std::function errorHandler); 46 | 47 | void SetDatapoints( 48 | const std::map& datapoints, 49 | std::function replyHandler, 50 | std::function errorHandler); 51 | 52 | void 53 | Subscribe(const std::string& query, 54 | std::function itemHandler, 55 | std::function errorHandler); 56 | 57 | private: 58 | std::unique_ptr m_stub; 59 | }; 60 | 61 | } // namespace velocitas::sdv_databroker_v1 62 | 63 | #endif // VEHICLE_APP_SDK_BROKERASYNCGRPCFACADE_H 64 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/sdv_databroker_v1/BrokerClient.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_BROKERCLIENT_H 18 | #define VEHICLE_APP_SDK_BROKERCLIENT_H 19 | 20 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace velocitas::sdv_databroker_v1 { 27 | 28 | class BrokerAsyncGrpcFacade; 29 | 30 | /** 31 | * VehicleDataBrokerClient provides the Graph API to access vehicle services 32 | * and vehicle signals. 33 | */ 34 | class BrokerClient : public IVehicleDataBrokerClient { 35 | public: 36 | explicit BrokerClient(const std::string& vdbAddress, const std::string& vdbServiceName); 37 | explicit BrokerClient(const std::string& vdbserviceName); 38 | 39 | ~BrokerClient() override; 40 | 41 | BrokerClient(const BrokerClient&) = delete; 42 | BrokerClient(BrokerClient&&) = delete; 43 | BrokerClient& operator=(const BrokerClient&) = delete; 44 | BrokerClient& operator=(BrokerClient&&) = delete; 45 | 46 | AsyncResultPtr_t 47 | getDatapoints(const std::vector& datapoints) override; 48 | 49 | AsyncResultPtr_t 50 | setDatapoints(const std::vector>& datapoints) override; 51 | 52 | AsyncSubscriptionPtr_t subscribe(const std::string& query) override; 53 | 54 | private: 55 | std::shared_ptr m_asyncBrokerFacade; 56 | }; 57 | 58 | } // namespace velocitas::sdv_databroker_v1 59 | 60 | #endif // VEHICLE_APP_SDK_BROKERCLIENT_H 61 | -------------------------------------------------------------------------------- /sdk/src/sdk/vdb/grpc/sdv_databroker_v1/GrpcDataPointValueProvider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "IDataPointValueProvider.h" 18 | #include "sdv/databroker/v1/types.grpc.pb.h" 19 | 20 | namespace velocitas::sdv_databroker_v1 { 21 | 22 | /** 23 | * @brief Value provider implementation for gRPC provided DataPoints 24 | * 25 | */ 26 | class GrpcDataPointValueProvider : public IDataPointValueProvider { 27 | public: 28 | explicit GrpcDataPointValueProvider(sdv::databroker::v1::Datapoint datapoint); 29 | 30 | DataPointValue::Failure getFailure() const override; 31 | bool getBoolValue() const override; 32 | std::vector getBoolArrayValue() const override; 33 | float getFloatValue() const override; 34 | std::vector getFloatArrayValue() const override; 35 | double getDoubleValue() const override; 36 | std::vector getDoubleArrayValue() const override; 37 | int8_t getInt8Value() const override; 38 | std::vector getInt8ArrayValue() const override; 39 | int16_t getInt16Value() const override; 40 | std::vector getInt16ArrayValue() const override; 41 | int32_t getInt32Value() const override; 42 | std::vector getInt32ArrayValue() const override; 43 | int64_t getInt64Value() const override; 44 | std::vector getInt64ArrayValue() const override; 45 | uint8_t getUint8Value() const override; 46 | std::vector getUint8ArrayValue() const override; 47 | uint16_t getUint16Value() const override; 48 | std::vector getUint16ArrayValue() const override; 49 | uint32_t getUint32Value() const override; 50 | std::vector getUint32ArrayValue() const override; 51 | uint64_t getUint64Value() const override; 52 | std::vector getUint64ArrayValue() const override; 53 | std::string getStringValue() const override; 54 | std::vector getStringArrayValue() const override; 55 | Timestamp getTimestamp() const; 56 | 57 | protected: 58 | const sdv::databroker::v1::Datapoint& getDataPoint() const; 59 | 60 | private: 61 | sdv::databroker::v1::Datapoint m_datapoint; 62 | }; 63 | 64 | } // namespace velocitas::sdv_databroker_v1 65 | -------------------------------------------------------------------------------- /sdk/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | include(FetchContent) 16 | FetchContent_Declare( 17 | googletest 18 | URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip 19 | ) 20 | 21 | set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 22 | FetchContent_GetProperties(googletest) 23 | FetchContent_MakeAvailable(googletest) 24 | 25 | add_subdirectory(unit) 26 | -------------------------------------------------------------------------------- /sdk/tests/mocks/VehicleDataBrokerClientMock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_VEHICLEDATABROKERCLIENTMOCK_H 18 | #define VEHICLE_APP_SDK_VEHICLEDATABROKERCLIENTMOCK_H 19 | 20 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 21 | 22 | #include 23 | 24 | namespace velocitas { 25 | 26 | class VehicleDataBrokerClientMock : public IVehicleDataBrokerClient { 27 | public: 28 | MOCK_METHOD(AsyncResultPtr_t, getDatapoints, 29 | (const std::vector& datapoints)); 30 | 31 | MOCK_METHOD(AsyncResultPtr_t, setDatapoints, 32 | (const std::vector>& datapoints)); 33 | 34 | MOCK_METHOD(AsyncSubscriptionPtr_t, subscribe, (const std::string& query)); 35 | }; 36 | 37 | } // namespace velocitas 38 | 39 | #endif // VEHICLE_APP_SDK_VEHICLEDATABROKERCLIENTMOCK_H 40 | -------------------------------------------------------------------------------- /sdk/tests/model/Vehicle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef TEST_MODEL_VEHICLE_H 18 | #define TEST_MODEL_VEHICLE_H 19 | 20 | #include "sdk/DataPoint.h" 21 | #include "sdk/Model.h" 22 | 23 | namespace velocitas { 24 | 25 | using ParentClass = Model; 26 | 27 | namespace vehicle { 28 | namespace cabin { 29 | 30 | class Seat : public ParentClass { 31 | public: 32 | Seat(const std::string& name, ParentClass* parent) 33 | : ParentClass(name, parent) 34 | , Position("Position", Node::Type::ACTUATOR, this) {} 35 | DataPointUint32 Position; 36 | }; 37 | 38 | } // namespace cabin 39 | 40 | class Cabin : public ParentClass { 41 | public: 42 | class SeatCollection : public ParentClass { 43 | public: 44 | class RowType : public ParentClass { 45 | public: 46 | RowType(const std::string& name, ParentClass* parent) 47 | : ParentClass(name, parent) 48 | , DriverSide("DriverSide", this) 49 | , Middle("Middle", this) 50 | , PassengerSide("PassengerSide", this) {} 51 | 52 | vehicle::cabin::Seat DriverSide; 53 | vehicle::cabin::Seat Middle; 54 | vehicle::cabin::Seat PassengerSide; 55 | }; 56 | 57 | explicit SeatCollection(ParentClass* parent) 58 | : ParentClass("Seat", parent) 59 | , Row1("Row1", this) 60 | , Row2("Row2", this) {} 61 | 62 | RowType& Row(int index) { 63 | if (index == 1) { 64 | return Row1; 65 | } 66 | if (index == 2) { 67 | return Row2; 68 | } 69 | throw std::runtime_error("Given value is outside of allowed range [1;2]!"); 70 | } 71 | 72 | RowType Row1; 73 | RowType Row2; 74 | }; 75 | 76 | Cabin(const std::string& name, ParentClass* parent) 77 | : ParentClass(name, parent) 78 | , Seat(this) {} 79 | SeatCollection Seat; 80 | }; 81 | 82 | } // namespace vehicle 83 | 84 | class Vehicle : public ParentClass { 85 | public: 86 | Vehicle() 87 | : ParentClass("Vehicle") 88 | , Speed("Speed", Node::Type::SENSOR, this) 89 | , Cabin("Cabin", this) {} 90 | DataPointFloat Speed; 91 | vehicle::Cabin Cabin; 92 | }; 93 | 94 | } // namespace velocitas 95 | 96 | #endif // TEST_MODEL_VEHICLE_H 97 | -------------------------------------------------------------------------------- /sdk/tests/unit/AsyncResult_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/AsyncResult.h" 18 | 19 | #include 20 | 21 | using namespace velocitas; 22 | 23 | TEST(Test_AsyncResult, await_withBufferedValue_returnsValueImmediately) { 24 | AsyncResult asyncResult; 25 | asyncResult.insertResult(5); 26 | EXPECT_EQ(5, asyncResult.await()); 27 | } 28 | 29 | TEST(Test_AsyncResult, await_withoutHandler_blocksCallerUntilResultIsAvailable) { 30 | constexpr auto INT_RESULT{999}; 31 | 32 | AsyncResult asyncResult; 33 | std::thread thread([&asyncResult, INT_RESULT]() { 34 | int temp = INT_RESULT; 35 | asyncResult.insertResult(std::move(temp)); 36 | }); 37 | 38 | auto result = asyncResult.await(); 39 | EXPECT_EQ(INT_RESULT, result); 40 | 41 | thread.join(); 42 | } 43 | 44 | TEST(Test_AsyncResult, await_withHandler_throws) { 45 | AsyncResult asyncResult; 46 | asyncResult.onResult([](int result) {}); 47 | EXPECT_THROW(asyncResult.await(), std::runtime_error); 48 | } 49 | 50 | TEST(Test_AsyncResult, onResult_withRegisteredHandler_handlerCalledWithValue) { 51 | int receivedResult{-1}; 52 | AsyncResult asyncResult; 53 | asyncResult.onResult([&receivedResult](int result) { receivedResult = result; }); 54 | asyncResult.insertResult(10); 55 | 56 | EXPECT_EQ(receivedResult, 10); 57 | } 58 | 59 | TEST(Test_AsyncResult, onResult_whileAwaiting_throws) { 60 | AsyncResult asyncResult; 61 | std::thread thread([&asyncResult]() { asyncResult.await(); }); 62 | while (!asyncResult.isInAwaitingState()) { 63 | std::this_thread::sleep_for(std::chrono::milliseconds{1}); 64 | } 65 | EXPECT_THROW(asyncResult.onResult([](int result) {}), std::runtime_error); 66 | asyncResult.insertResult(4); 67 | thread.join(); 68 | } 69 | -------------------------------------------------------------------------------- /sdk/tests/unit/AsyncSubscription_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/AsyncResult.h" 18 | 19 | #include 20 | 21 | using namespace velocitas; 22 | 23 | TEST(Test_AsyncSubcription, next_withBufferedItems_returnsItemsInOrder) { 24 | AsyncSubscription asyncSubscription; 25 | asyncSubscription.insertNewItem(1); 26 | asyncSubscription.insertNewItem(2); 27 | asyncSubscription.insertNewItem(3); 28 | 29 | EXPECT_EQ(asyncSubscription.next(), 1); 30 | EXPECT_EQ(asyncSubscription.next(), 2); 31 | EXPECT_EQ(asyncSubscription.next(), 3); 32 | } 33 | 34 | TEST(Test_AsyncSubcription, next_noBufferedItems_blocksUntilItemsInserted) { 35 | constexpr auto INT_RESULT{999}; 36 | AsyncSubscription asyncSubscription; 37 | std::thread thread([&asyncSubscription, INT_RESULT]() { 38 | int temp = INT_RESULT; 39 | asyncSubscription.insertNewItem(std::move(temp)); 40 | }); 41 | 42 | EXPECT_EQ(asyncSubscription.next(), INT_RESULT); 43 | thread.join(); 44 | } 45 | -------------------------------------------------------------------------------- /sdk/tests/unit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | set(TARGET_NAME "sdk_utests") 16 | 17 | add_executable(${TARGET_NAME} 18 | testmain.cpp 19 | AsyncResult_tests.cpp 20 | AsyncSubscription_tests.cpp 21 | DataPoint_tests.cpp 22 | DataPointBatch_tests.cpp 23 | DataPointValue_tests.cpp 24 | Job_tests.cpp 25 | Logger_tests.cpp 26 | Middleware_tests.cpp 27 | NativeMiddleware_tests.cpp 28 | Node_tests.cpp 29 | ScopedBoolInverter_tests.cpp 30 | ThreadPool_tests.cpp 31 | Utils_tests.cpp 32 | QueryBuilder_tests.cpp 33 | #PubSub_tests.cpp 34 | TestBaseUsingEnvVars.cpp 35 | grpc/GrpcClient_tests.cpp 36 | vdb/grpc/kuksa_val_v2/TypeConversions_tests.cpp 37 | vdb/grpc/sdv_databroker_v1/BrokerClient_tests.cpp 38 | ) 39 | 40 | target_link_libraries(${TARGET_NAME} 41 | vehicle-app-sdk 42 | gmock 43 | ) 44 | 45 | include(GoogleTest) 46 | 47 | target_include_directories(${TARGET_NAME} 48 | PRIVATE 49 | ${CMAKE_CURRENT_SOURCE_DIR}/../mocks 50 | ${CMAKE_CURRENT_SOURCE_DIR}/../model 51 | ${CMAKE_CURRENT_SOURCE_DIR}/../../src 52 | ) 53 | 54 | if(NOT CMAKE_TOOLCHAIN_FILE) 55 | gtest_discover_tests(${TARGET_NAME}) 56 | endif() 57 | -------------------------------------------------------------------------------- /sdk/tests/unit/Middleware_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "TestBaseUsingEnvVars.h" 18 | #include 19 | 20 | #define private public 21 | #include "sdk/middleware/Middleware.h" 22 | #include "sdk/middleware/NativeMiddleware.h" 23 | 24 | using namespace velocitas; 25 | 26 | class Test_Middleware : public TestUsingEnvVars {}; 27 | 28 | TEST_F(Test_Middleware, getInstance_envVarGloballySetToNative_typeIdIsNative) { 29 | const Middleware& middleware = Middleware::getInstance(); 30 | EXPECT_EQ(NativeMiddleware::TYPE_ID, middleware.getTypeId()); 31 | } 32 | 33 | TEST_F(Test_Middleware, instantiate_envVarNotSet_typeIdDefaultsToNative) { 34 | unsetEnvVar(Middleware::TYPE_DEFINING_ENV_VAR_NAME); 35 | auto middleware = Middleware::instantiate(); 36 | EXPECT_EQ(NativeMiddleware::TYPE_ID, middleware->getTypeId()); 37 | } 38 | 39 | TEST_F(Test_Middleware, instantiate_envVarSetToNative_typeIdIsNative) { 40 | setEnvVar(Middleware::TYPE_DEFINING_ENV_VAR_NAME, NativeMiddleware::TYPE_ID); 41 | EXPECT_EQ(NativeMiddleware::TYPE_ID, Middleware::instantiate()->getTypeId()); 42 | } 43 | 44 | TEST_F(Test_Middleware, instantiate_envVarSetToUndefined_throwRuntimeError) { 45 | setEnvVar(Middleware::TYPE_DEFINING_ENV_VAR_NAME, "something undefined"); 46 | EXPECT_THROW(Middleware::instantiate(), std::runtime_error); 47 | } 48 | -------------------------------------------------------------------------------- /sdk/tests/unit/NativeMiddleware_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/middleware/NativeMiddleware.h" 18 | 19 | #include "TestBaseUsingEnvVars.h" 20 | #include 21 | 22 | using namespace velocitas; 23 | 24 | class Test_NativeMiddleware : public TestUsingEnvVars { 25 | protected: 26 | Middleware& getCut() { return m_cut; } 27 | 28 | private: 29 | NativeMiddleware m_cut; 30 | }; 31 | 32 | TEST_F(Test_NativeMiddleware, getTypeId__typeIdIsNative) { 33 | ::std::string typeId = getCut().getTypeId(); 34 | EXPECT_EQ(NativeMiddleware::TYPE_ID, typeId); 35 | } 36 | 37 | TEST_F(Test_NativeMiddleware, createPubSubClient__validPointer) { 38 | std::shared_ptr pubSubClient; 39 | EXPECT_NO_THROW(pubSubClient = getCut().createPubSubClient("My Test Id")); 40 | EXPECT_NE(nullptr, pubSubClient.get()); 41 | } 42 | 43 | TEST_F(Test_NativeMiddleware, getServiceLocation_envVarNotSet_throwsRuntimeError) { 44 | EXPECT_THROW(getCut().getServiceLocation("UnknownService"), std::runtime_error); 45 | } 46 | 47 | TEST_F(Test_NativeMiddleware, getServiceLocation_envVarNotSetButDefaultKnown_default) { 48 | auto serviceLocation = getCut().getServiceLocation("mqtt"); 49 | EXPECT_EQ("localhost:1883", serviceLocation); 50 | } 51 | 52 | TEST_F(Test_NativeMiddleware, getServiceLocation_envVarSetWithPureAddress_contentOfEnvVar) { 53 | setEnvVar("SDV_SOMESERVICE_ADDRESS", "some-service-address"); 54 | auto serviceLocation = getCut().getServiceLocation("SomeService"); 55 | EXPECT_EQ("some-service-address", serviceLocation); 56 | } 57 | 58 | TEST_F(Test_NativeMiddleware, getServiceLocation_envVarSetWithUrl_contentOfUrlsNetLocation) { 59 | setEnvVar("SDV_SOMESERVICE_ADDRESS", "scheme://some-host:port/path"); 60 | auto serviceLocation = getCut().getServiceLocation("SomeService"); 61 | EXPECT_EQ("some-host:port", serviceLocation); 62 | } 63 | 64 | TEST_F(Test_NativeMiddleware, getMetadata__emptyMap) { 65 | Middleware::Metadata metadata = getCut().getMetadata("don't care"); 66 | EXPECT_TRUE(metadata.empty()); 67 | } 68 | -------------------------------------------------------------------------------- /sdk/tests/unit/Node_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/Node.h" 18 | #include 19 | 20 | using namespace velocitas; 21 | 22 | TEST(Test_Node, constructor_withoutParent_isRootNoParent) { 23 | Node node{"foo"}; 24 | 25 | EXPECT_EQ(node.getName(), "foo"); 26 | EXPECT_EQ(node.getParent(), nullptr); 27 | EXPECT_EQ(node.getPath(), "foo"); 28 | } 29 | 30 | TEST(Test_Node, constructor_withParent_isLeaf) { 31 | Node nodeRoot{"root"}; 32 | Node node{"foo", &nodeRoot}; 33 | 34 | EXPECT_EQ(node.getName(), "foo"); 35 | EXPECT_EQ(node.getParent(), &nodeRoot); 36 | EXPECT_EQ(node.getPath(), "root.foo"); 37 | } 38 | -------------------------------------------------------------------------------- /sdk/tests/unit/PubSub_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/DataPoint.h" 18 | #include "sdk/IPubSubClient.h" 19 | 20 | #include 21 | #include 22 | 23 | class PubSubTest : public ::testing::Test { 24 | protected: 25 | void SetUp() override { 26 | client = velocitas::IPubSubClient::createInstance("localhost:1883", "TestClient"); 27 | client->connect(); 28 | } 29 | 30 | void TearDown() override { client->disconnect(); } 31 | void receivedMessage(const std::string& data) { 32 | messageReceived = true; 33 | receivedData = data; 34 | } 35 | 36 | void waitForMessage() { 37 | while (!messageReceived) { 38 | std::this_thread::sleep_for(std::chrono::seconds{1}); 39 | } 40 | messageReceived = false; 41 | } 42 | std::shared_ptr client; 43 | std::string receivedData = ""; 44 | bool messageReceived = false; 45 | }; 46 | 47 | TEST_F(PubSubTest, subscribeTopic_publishOnTopic_sameTopic) { 48 | auto subAbc = client->subscribeTopic("a/b/c"); 49 | subAbc->onItem([this](auto&& item) { receivedMessage(std::forward(item)); }); 50 | std::string message = "testMessage"; 51 | 52 | client->publishOnTopic("a/b/c", message); 53 | waitForMessage(); 54 | EXPECT_EQ(receivedData, message); 55 | } 56 | -------------------------------------------------------------------------------- /sdk/tests/unit/QueryBuilder_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/QueryBuilder.h" 18 | 19 | #include 20 | 21 | using namespace velocitas; 22 | 23 | TEST(Test_QueryBuilder, select_singleDataPoint) { 24 | DataPointFloat foo{"foo", nullptr}; 25 | const auto query = QueryBuilder::select(foo).build(); 26 | ASSERT_EQ(query, "SELECT foo"); 27 | } 28 | 29 | TEST(Test_QueryBuilder, select_multipleDataPoints) { 30 | DataPointFloat foo{"foo", nullptr}; 31 | DataPointFloat bar{"bar", nullptr}; 32 | const auto query = QueryBuilder::select({foo, bar}).build(); 33 | ASSERT_EQ(query, "SELECT foo, bar"); 34 | } 35 | 36 | TEST(Test_QueryBuilder, whereCondition_gt) { 37 | DataPointFloat foo{"foo", nullptr}; 38 | const auto query = QueryBuilder::select(foo).where(foo).gt(10.0F).build(); 39 | ASSERT_EQ(query, "SELECT foo WHERE foo > 10.000000"); 40 | } 41 | 42 | TEST(Test_QueryBuilder, whereCondition_lt) { 43 | DataPointInt32 foo{"foo", nullptr}; 44 | const auto query = QueryBuilder::select(foo).where(foo).lt(100).build(); 45 | ASSERT_EQ(query, "SELECT foo WHERE foo < 100"); 46 | } 47 | 48 | TEST(Test_QueryBuilder, whereCondition_eq) { 49 | DataPointBoolean foo{"foo", nullptr}; 50 | const auto query = QueryBuilder::select(foo).where(foo).eq(true).build(); 51 | ASSERT_EQ(query, "SELECT foo WHERE foo = 1"); 52 | } 53 | -------------------------------------------------------------------------------- /sdk/tests/unit/ScopedBoolInverter_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/AsyncResult.h" 18 | 19 | #include 20 | 21 | using namespace velocitas; 22 | 23 | TEST(Test_ScopedBoolInverter, create_boolIsFalse_boolIsTrue) { 24 | bool testBool = false; 25 | ScopedBoolInverter cut{testBool}; 26 | EXPECT_TRUE(testBool); 27 | } 28 | 29 | TEST(Test_ScopedBoolInverter, create_boolIsTrue_boolIsFalse) { 30 | bool testBool = true; 31 | ScopedBoolInverter cut{testBool}; 32 | EXPECT_FALSE(testBool); 33 | } 34 | 35 | TEST(Test_ScopedBoolInverter, destroy_boolSetToFalseAfterConstruction_boolIsTrue) { 36 | bool testBool = false; 37 | { 38 | ScopedBoolInverter cut{testBool}; 39 | testBool = false; 40 | } 41 | EXPECT_TRUE(testBool); 42 | } 43 | 44 | TEST(Test_ScopedBoolInverter, destroy_boolSetToTrueAfterConstruction_boolIsFalse) { 45 | bool testBool = false; 46 | { 47 | ScopedBoolInverter cut{testBool}; 48 | testBool = true; 49 | } 50 | EXPECT_FALSE(testBool); 51 | } 52 | -------------------------------------------------------------------------------- /sdk/tests/unit/TestBaseUsingEnvVars.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "TestBaseUsingEnvVars.h" 18 | 19 | #include 20 | #include 21 | 22 | namespace velocitas { 23 | 24 | void TestUsingEnvVars::preserveEnvVarState(const std::string& varName) { 25 | if (m_envVarsToRestore.count(varName) > 0 || m_envVarsToUnset.count(varName) > 0) { 26 | return; 27 | } 28 | 29 | const char* content = ::getenv(varName.c_str()); 30 | if (content) { 31 | m_envVarsToRestore[varName] = *content; 32 | } else { 33 | m_envVarsToUnset.insert(varName); 34 | } 35 | } 36 | 37 | void TestUsingEnvVars::setEnvVar(const std::string& varName, const std::string& content) { 38 | preserveEnvVarState(varName); 39 | ::setenv(varName.c_str(), content.c_str(), /*replace=*/true); 40 | } 41 | 42 | void TestUsingEnvVars::unsetEnvVar(const std::string& varName) { 43 | preserveEnvVarState(varName); 44 | ::unsetenv(varName.c_str()); 45 | } 46 | 47 | void TestUsingEnvVars::TearDown() { 48 | for (auto varToUnset : m_envVarsToUnset) { 49 | ::unsetenv(varToUnset.c_str()); 50 | } 51 | for (auto varToRestore : m_envVarsToRestore) { 52 | ::setenv(varToRestore.first.c_str(), varToRestore.second.c_str(), /*replace=*/true); 53 | } 54 | } 55 | 56 | } // namespace velocitas 57 | -------------------------------------------------------------------------------- /sdk/tests/unit/TestBaseUsingEnvVars.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #ifndef VEHICLE_APP_SDK_TESTUSINGENVVARS_H 18 | #define VEHICLE_APP_SDK_TESTUSINGENVVARS_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | namespace velocitas { 27 | 28 | /** 29 | * @brief Base class for test cases where you need to set or unset environment variables 30 | * 31 | * It provides a setEnvVar and a unsetEnvVar function to be used for this by your test case. 32 | * After the test case is finished the original state of the changed variables is restored. * 33 | */ 34 | class TestUsingEnvVars : public ::testing::Test { 35 | public: 36 | ~TestUsingEnvVars() = default; 37 | 38 | protected: 39 | TestUsingEnvVars() = default; 40 | 41 | /** 42 | * @brief Restores the state of the set and unset variables as it was before executing the test 43 | * case 44 | */ 45 | void TearDown() override; 46 | 47 | /** 48 | * @brief Set the an environment variable to the specified value 49 | * 50 | * @param varName Name of the variable to be set 51 | * @param content Value to be set 52 | */ 53 | void setEnvVar(const std::string& varName, const std::string& content); 54 | 55 | /** 56 | * @brief Unset a possibly existing environment variable 57 | * 58 | * @param varName Name of the variable to be unset 59 | */ 60 | void unsetEnvVar(const std::string& varName); 61 | 62 | private: 63 | void preserveEnvVarState(const std::string& varName); 64 | 65 | std::unordered_map m_envVarsToRestore; 66 | std::unordered_set m_envVarsToUnset; 67 | }; 68 | 69 | } // namespace velocitas 70 | 71 | #endif // VEHICLE_APP_SDK_TESTUSINGENVVARS_H 72 | -------------------------------------------------------------------------------- /sdk/tests/unit/grpc/GrpcClient_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/grpc/GrpcCall.h" 18 | #include "sdk/grpc/GrpcClient.h" 19 | 20 | #include 21 | 22 | using namespace velocitas; 23 | 24 | TEST(Test_GrpcClient, addActiveCall_newlyCreatedGrpcClient_oneActiveCall) { 25 | // preparation 26 | GrpcClient cut; 27 | 28 | // test 29 | cut.addActiveCall(std::make_shared()); 30 | EXPECT_EQ(1, cut.getNumActiveCalls()); 31 | } 32 | 33 | TEST(Test_GrpcClient, addActiveCall_oneActiveCallPresent_twoActiveCalls) { 34 | // preparation 35 | GrpcClient cut; 36 | cut.addActiveCall(std::make_shared()); 37 | 38 | // test 39 | cut.addActiveCall(std::make_shared()); 40 | EXPECT_EQ(2, cut.getNumActiveCalls()); 41 | } 42 | 43 | TEST(Test_GrpcClient, addActiveCall_oneFinishedCallPresent_oneActiveCall) { 44 | // preparation 45 | GrpcClient cut; 46 | auto finishedCall = std::make_shared(); 47 | cut.addActiveCall(finishedCall); 48 | finishedCall->m_isComplete = true; 49 | 50 | // test 51 | cut.addActiveCall(std::make_shared()); 52 | EXPECT_EQ(1, cut.getNumActiveCalls()); 53 | } 54 | 55 | TEST(Test_GrpcClient, addActiveCall_oneFinishedAndOneActiveCallPresent_finishedCallRemoved) { 56 | // preparation 57 | GrpcClient cut; 58 | auto finishedCall = std::make_shared(); 59 | cut.addActiveCall(finishedCall); 60 | auto activeCall = std::make_shared(); 61 | cut.addActiveCall(activeCall); 62 | finishedCall->m_isComplete = true; 63 | 64 | // test 65 | auto anotherActiveCall = std::make_shared(); 66 | cut.addActiveCall(anotherActiveCall); 67 | EXPECT_EQ(2, cut.getNumActiveCalls()); 68 | EXPECT_EQ(1, finishedCall.use_count()); // no other reference held to this pointer 69 | EXPECT_EQ(2, activeCall.use_count()); 70 | EXPECT_EQ(2, anotherActiveCall.use_count()); 71 | } 72 | -------------------------------------------------------------------------------- /sdk/tests/unit/testmain.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/middleware/Middleware.h" 18 | #include "sdk/middleware/NativeMiddleware.h" 19 | 20 | #include 21 | #include 22 | 23 | using namespace velocitas; 24 | 25 | class SetupMiddlewareSingleton : public ::testing::Environment { 26 | public: 27 | void SetUp() override { 28 | ::setenv(Middleware::TYPE_DEFINING_ENV_VAR_NAME, NativeMiddleware::TYPE_ID, 29 | /*overwrite=*/true); 30 | std::ignore = Middleware::getInstance(); 31 | } 32 | }; 33 | 34 | int main(int argc, char** argv) { 35 | ::testing::InitGoogleTest(&argc, argv); 36 | std::ignore = testing::AddGlobalTestEnvironment(new SetupMiddlewareSingleton); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /sdk/tests/unit/vdb/grpc/sdv_databroker_v1/BrokerClient_tests.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2022-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/vdb/grpc/sdv_databroker_v1/BrokerClient.h" 18 | 19 | #include 20 | 21 | using namespace velocitas; 22 | 23 | TEST(Test_sdv_databroker_v1_BrokerClient, getDatapoints_noConnection_throwsAsyncException) { 24 | auto client = sdv_databroker_v1::BrokerClient("vehicledatabroker"); 25 | EXPECT_THROW(client.getDatapoints({})->await(), AsyncException); 26 | } 27 | -------------------------------------------------------------------------------- /test_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | cmake_minimum_required(VERSION 3.16) 16 | 17 | project(test_package) 18 | 19 | find_package(vehicle-app-sdk CONFIG REQUIRED) 20 | 21 | if(NOT vehicle-app-sdk_FOUND) 22 | message(FATAL_ERROR "This project can only be built with a 'conan create' command in the parent directory!") 23 | endif() 24 | 25 | add_executable(${PROJECT_NAME} main.cpp) 26 | target_link_libraries(${PROJECT_NAME} 27 | vehicle-app-sdk::vehicle-app-sdk 28 | ) 29 | -------------------------------------------------------------------------------- /test_package/conanfile.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Apache License, Version 2.0 which is available at 5 | # https://www.apache.org/licenses/LICENSE-2.0. 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | # License for the specific language governing permissions and limitations 11 | # under the License. 12 | # 13 | # SPDX-License-Identifier: Apache-2.0 14 | 15 | import os 16 | 17 | from conan import ConanFile 18 | from conan.tools.build import can_run 19 | from conan.tools.cmake import CMake, cmake_layout 20 | 21 | 22 | class VehicleAppSdkTest(ConanFile): 23 | test_type = "explicit" 24 | name = "vehicle_app_sdk_test" 25 | license = "Apache-2.0" 26 | url = "https://github.com/eclipse-velocitas/vehicle-app-cpp-sdk" 27 | 28 | settings = "os", "compiler", "build_type", "arch" 29 | 30 | generators = "CMakeDeps", "CMakeToolchain" 31 | 32 | def requirements(self): 33 | self.requires(self.tested_reference_str) 34 | 35 | def build(self): 36 | cmake = CMake(self) 37 | cmake.configure() 38 | cmake.build() 39 | 40 | def layout(self): 41 | cmake_layout(self) 42 | 43 | def test(self): 44 | if can_run(self): 45 | cmd = os.path.join(self.cpp.build.bindir, "test_package") 46 | self.run(f"SDV_MIDDLEWARE_TYPE=native {cmd}", env="conanrun") 47 | -------------------------------------------------------------------------------- /test_package/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2024-2025 Contributors to the Eclipse Foundation 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Apache License, Version 2.0 which is available at 6 | * https://www.apache.org/licenses/LICENSE-2.0. 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 | * License for the specific language governing permissions and limitations 12 | * under the License. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | */ 16 | 17 | #include "sdk/IPubSubClient.h" 18 | #include "sdk/VehicleApp.h" 19 | #include "sdk/vdb/IVehicleDataBrokerClient.h" 20 | 21 | #include 22 | 23 | int main() { 24 | const auto vehicleApp = std::make_unique( 25 | velocitas::IVehicleDataBrokerClient::createInstance("vehicledatabroker"), 26 | velocitas::IPubSubClient::createInstance("SetDataPointsApp")); 27 | vehicleApp->onStart(); 28 | vehicleApp->onStop(); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /whitelisted-licenses.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/d4031dcd35a04466a90fdc44d0aa9313f58c7536/whitelisted-licenses.txt --------------------------------------------------------------------------------