tunnel component & update vehicle abstraction example (#8)

This commit is contained in:
tompzf
2026-04-02 17:37:00 +02:00
committed by GitHub
parent 6ed5fdb951
commit 07cf4f654b
94 changed files with 9268 additions and 830 deletions

View File

@@ -30,7 +30,7 @@ include_directories(${SDV_FRAMEWORK_DEV_INCLUDE})
# services are generated during the configuration phase of CMake. This is necessary, since CMakeFiles.txt files are generated and
# they have to be available during the configuration phase of CMake to be taken into the build process. Requisite for the code
# generation during the configuration time of CMake is the availability of the tools to do the generation. Hence the tools cannot be
# created during the build process, which is executed after the configuraiton process.
# created during the build process, which is executed after the configuration process.
# Execute sdv_vss_util to create IDL files for devices and basic services.
message("Create interface code for devices and basic services of open trunk example.")
@@ -46,7 +46,7 @@ execute_process(COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/v
# We need proxies and stubs for basic services to give access to the interfaces for complex services ans applications: --ps_lib_namedemo_proxystub
# We need proxies and stubs for basic services to give access to the interfaces for complex services and applications: --ps_lib_namedemo_proxystub
message("Compiling vss_vehiclebodytrunk_bs_tx.idl")
execute_process(COMMAND "${SDV_IDL_COMPILER}" "${PROJECT_SOURCE_DIR}/generated/vss_files/vss_vehiclebodytrunk_bs_tx.idl" "-O${PROJECT_SOURCE_DIR}/generated/vss_files/" "-I${SDV_FRAMEWORK_DEV_INCLUDE}" -Igenerated/vss_files/ --ps_lib_nametrunk_proxystub)
message("Compiling vss_vehiclespeed_bs_rx.idl")
@@ -78,7 +78,7 @@ add_subdirectory(generated/can_dl)
# REMARK: Proxy/stub and vehicle device and basic service code was generated during the configuration phase of CMake. Following
# below are the build steps to build the components that were generated.
message("Include: trunk proxy/stub for vehicle devices and basic services")
message("Include: trunk proxy/stub for basic services")
include_directories(${CMAKE_CURRENT_LIST_DIR}/generated/vss_files)
add_subdirectory(generated/vss_files/ps)
@@ -116,7 +116,6 @@ add_executable(open_trunk_example
open_trunk_app/trunk_application.h
open_trunk_app/console.cpp
open_trunk_app/console.h
open_trunk_app/signal_names.h
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

View File

@@ -34,8 +34,8 @@ const CConsole::SConsolePos g_sComment3{ 24, 1 };
const CConsole::SConsolePos g_sComment4{ 25, 1 };
const CConsole::SConsolePos g_sComment5{ 26, 1 };
const CConsole::SConsolePos g_sSeparator5{ 28, 1 };
const CConsole::SConsolePos g_sComplexServcie1{ 30, 1 };
const CConsole::SConsolePos g_sComplexServcie2{ 31, 1 };
const CConsole::SConsolePos g_sComplexService1{ 30, 1 };
const CConsole::SConsolePos g_sComplexService2{ 31, 1 };
const CConsole::SConsolePos g_sSeparator6{ 33, 1 };
const CConsole::SConsolePos g_sControlDescription{ 35, 1 };
const CConsole::SConsolePos g_sCursor{ 36, 1 };
@@ -111,12 +111,12 @@ void CConsole::PrintHeader(uint32_t uiInstance)
PrintText(g_sSeparator4, "============================================================================");
PrintText(g_sComment1, "The complex service which checks the speed of the vehicle can be seen");
PrintText(g_sComment2, "as an ASIL A/B component and will block the call from QM.");
PrintText(g_sComment3, "The extern apllication can be seen as a QM function.");
PrintText(g_sComment3, "The extern application can be seen as a QM function.");
PrintText(g_sComment4, "If this example would run in a mixed critical environment the connection");
PrintText(g_sComment5, "from QM to basic service interface would be forbidden.");
PrintText(g_sSeparator5, "============================================================================");
PrintText(g_sComplexServcie1, "Basic Service Interface not available.");
PrintText(g_sComplexServcie2, "Complex Service Interface not available.");
PrintText(g_sComplexService1, "Basic Service Interface not available.");
PrintText(g_sComplexService2, "Complex Service Interface not available.");
PrintText(g_sSeparator6, "----------------------------------------------------------------------------");
PrintText(g_sControlDescription, "Press 'X' to quit; 'C' to clear screen, '1' or '2' to open trunk ");
}
@@ -130,7 +130,7 @@ bool CConsole::PrepareDataConsumers()
PrintValue(g_sDataLinkSpeed, "Vehicle Speed RX", m_SpeedDL, "m/s");
// Registrate for the vehicle device & basic service of the speed.
auto vehicleDevice = sdv::core::GetObject("Vehicle.Speed_Device").GetInterface<vss::Vehicle::SpeedDevice::IVSS_Speed>();
auto vehicleDevice = sdv::core::GetObject("Vehicle.Speed_Device").GetInterface<vss::Vehicle::SpeedDevice::IVSS_ReadSpeed>();
if (vehicleDevice)
{
PrintValue(g_sVehicleDeviceSpeed, "Vehicle Speed RX", m_SpeedVD, "m/s");
@@ -147,15 +147,15 @@ bool CConsole::PrepareDataConsumers()
// Request the basic service for opening the trunk.
m_pTrunkSvc = sdv::core::GetObject("Vehicle.Body.Trunk_Service").GetInterface<vss::Vehicle::Body::TrunkService::IVSS_SetOpen>();
if (m_pTrunkSvc)
PrintText(g_sComplexServcie1, "Basic Service available");
PrintText(g_sComplexService1, "Basic Service available");
else
PrintText(g_sComplexServcie1, "Basic Service NOT available");
PrintText(g_sComplexService1, "Basic Service NOT available");
m_pTrunkComplexService = sdv::core::GetObject("Open Trunk Service").GetInterface<ITrunkKitService>();
if (m_pTrunkComplexService)
PrintText(g_sComplexServcie2, "Complex Service available");
PrintText(g_sComplexService2, "Complex Service available");
else
PrintText(g_sComplexServcie2, "Complex Service NOT available");
PrintText(g_sComplexService2, "Complex Service NOT available");
return true;
}
@@ -165,7 +165,7 @@ void CConsole::ResetSignals()
// Set the cursor position at the end
SetCursorPos(g_sCursor);
auto vehicleDevice = sdv::core::GetObject("Vehicle.Speed_Device").GetInterface<vss::Vehicle::SpeedDevice::IVSS_Speed>();
auto vehicleDevice = sdv::core::GetObject("Vehicle.Speed_Device").GetInterface<vss::Vehicle::SpeedDevice::IVSS_ReadSpeed>();
if (vehicleDevice)
vehicleDevice->UnregisterSpeedEvent(dynamic_cast<vss::Vehicle::SpeedDevice::IVSS_WriteSpeed_Event*> (this));
@@ -173,7 +173,7 @@ void CConsole::ResetSignals()
if (basicService)
basicService->UnregisterOnSignalChangeOfVehicleSpeed(dynamic_cast<vss::Vehicle::SpeedService::IVSS_SetSpeed_Event*> (this));
// Unregister the data link signalss
// Unregister the data link signals
if (m_SignalSpeed)
m_SignalSpeed.Reset();
}
@@ -291,25 +291,25 @@ void CConsole::RunUntilBreak()
{
case 'c':
case 'C':
PrintText(g_sComplexServcie1, " ");
PrintText(g_sComplexServcie2, " ");
PrintText(g_sComplexService1, " ");
PrintText(g_sComplexService2, " ");
break;
case '1':
if (m_pTrunkSvc)
{
if (m_pTrunkSvc->SetOpen(true))
PrintText(g_sComplexServcie1, "Open trunk via basic service - will not be available in Mixed-Critical mode!");
PrintText(g_sComplexService1, "Open trunk via basic service - will not be available in Mixed-Critical mode!");
else
PrintText(g_sComplexServcie1, "Open trunk via basic service failed.");
PrintText(g_sComplexService1, "Open trunk via basic service failed.");
}
break;
case '2':
if (m_pTrunkComplexService)
{
if (m_pTrunkComplexService->PopTrunk())
PrintText(g_sComplexServcie2, "Safety open trunk via complex service.");
PrintText(g_sComplexService2, "Safety open trunk via complex service.");
else
PrintText(g_sComplexServcie2, "Safety open trunk via complex service failed, car is moving");
PrintText(g_sComplexService2, "Safety open trunk via complex service failed, car is moving");
}
break;
case 'x':

View File

@@ -18,7 +18,8 @@
#include <support/app_control.h>
#include <support/component_impl.h>
#include <support/timer.h>
#include "signal_names.h"
#include "../generated/vss_files/signal_identifier.h"
#include <fcntl.h>
#include "../generated/vss_files/vss_vehiclebodytrunk_bs_tx.h"
#include "../generated/vss_files/vss_vehiclespeed_bs_rx.h"
@@ -139,7 +140,7 @@ private:
* @param[in] sPos The location to print the value at.
* @param[in] rssName Reference to the value.
* @param[in] tValue The value.
* @param[in] rssStatus Status, becuse we have signals of type bool
* @param[in] rssStatus Status, because we have signals of type bool
*/
template <typename TValue>
void PrintValue(SConsolePos sPos, const std::string& rssName, TValue tValue, const std::string& rssStatus);
@@ -154,7 +155,6 @@ private:
mutable std::mutex m_mtxPrintToConsole; ///< Mutex to print complete message
bool m_bRunning = false; ///< When set, the application is running.
mutable std::mutex m_mPrintToConsole; ///< Mutex to print complete message
sdv::core::CSignal m_SignalSpeed; ///< Speed
float m_SpeedDL = 0.0; ///< Speed Data Link
@@ -186,7 +186,7 @@ inline void CConsole::PrintValue(SConsolePos sPos, const std::string& rssName, T
std::string(nValueNameLen - std::min(rssName.size(), static_cast<size_t>(nValueNameLen - 1)) - 1, '.') <<
" " << std::fixed << std::setprecision(2) << tValue << " " << rssUnits << " ";
std::lock_guard<std::mutex> lock(m_mPrintToConsole);
std::lock_guard<std::mutex> lock(m_mtxPrintToConsole);
SetCursorPos(sPos);
std::cout << sstreamValueText.str();
}

View File

@@ -1,35 +0,0 @@
/********************************************************************************
* Copyright (c) 2025-2026 ZF Friedrichshafen AG
*
* This program and the accompanying materials are made available under the
* terms of the Apache License Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
/**
* namespace for the signal names
* in case /interfaces/signal_identifier.h
* exists, use the file, otherwise define the namespace
*/
#ifndef SIGNAL_NAMES_H
#define SIGNAL_NAMES_H
#ifdef __has_include
#if __has_include("../interfaces/signal_identifier.h")
#include "../interfaces/signal_identifier.h"
#else
namespace trunk
{
// Data Dispatch Service signal names to dbc variable names C-type RX/TX vss name space
static std::string dsVehicleSpeed = "CAN_Input.Speed"; ///< bool RX Vehicle.Speed
static std::string dsTrunk = "CAN_Output.OpenTrunk"; ///< bool TX Vehicle.Body.Trunk
} // trunk
#endif
#endif
#endif // SIGNAL_NAMES_H

View File

@@ -9,7 +9,7 @@
********************************************************************************/
#include "trunk_application.h"
#include "signal_names.h"
#include "../generated/vss_files/signal_identifier.h"
#ifdef _WIN32
#include <conio.h> // Needed for _kbhit

View File

@@ -11,7 +11,6 @@
#include <string>
#include <support/app_control.h>
#include <support/signal_support.h>
#include "vss_vehiclespeed_bs_rx.h"
/**
@@ -47,7 +46,7 @@ private:
bool IsSDVFrameworkEnvironmentSet();
/**
* @brief Loac config file and register vehicle device and basic service.
* @brief Load config file and register vehicle device and basic service.
* @param[in] inputMsg message string to be printed on console in case of success and failure
* @param[in] configFileName config toml file name
* @return Return true on success otherwise false