Update sdv_packager (#6)

This commit is contained in:
tompzf
2026-03-27 14:12:49 +01:00
committed by GitHub
parent 234be8917f
commit aefefd52f7
717 changed files with 42252 additions and 11334 deletions

View File

@@ -1,3 +1,13 @@
#*******************************************************************************
# 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
#*******************************************************************************
project(AutoHeadlight)
# Use new policy for project version settings and default warning level
@@ -128,7 +138,7 @@ file (COPY ${PROJECT_SOURCE_DIR}/config/autoheadlight_cs.toml DESTINATION ${CMAK
#
# What cannot be created automatically is the method OpenAPILoad(const std::string& resources) in file model.cpp
# The method must load all required components
# Therfore here the file is copied and overwritten the auto generated file
# Therefore here the file is copied and overwritten the auto generated file
#
# The required toml files need to be copied to the folder:
# generated/fmu_DemoExampleFMU/DemoExampleFMU/resources

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#include <iostream>
#include <fstream>
#include <support/app_control.h>

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#include "autoheadlight_console.h"
#ifdef _WIN32

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#ifndef CONSOLE_OUTPUT_H
#define CONSOLE_OUTPUT_H

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#include "autoheadlight_simulate.h"
#ifdef _WIN32

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#include <iostream>
#include <string>
#include <functional>

View File

@@ -1,4 +1,14 @@
/**
/********************************************************************************
* 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 /generated/vss_files/signal_identifier.h
* exists, use the file, otherwise define the namespace

View File

@@ -1,27 +1,31 @@
/********************************************************************************
* 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
********************************************************************************/
#include <iostream>
#include "autoheadlight_cs.h"
CAutoHeadlightService::CAutoHeadlightService()
{
}
{}
CAutoHeadlightService::~CAutoHeadlightService()
{
Shutdown();
}
{}
void CAutoHeadlightService::Initialize(const sdv::u8string& ssObjectConfig)
bool CAutoHeadlightService::OnInitialize()
{
m_eStatus = sdv::EObjectStatus::initializing;
// Request the basic service for the headlight.
m_pHeadlightSvc = sdv::core::GetObject("Vehicle.Body.Light.Front.LowBeam_Service").GetInterface<vss::Vehicle::Body::Light::Front::LowBeamService::IVSS_SetHeadLightLowBeam>();
if (!m_pHeadlightSvc)
{
SDV_LOG_ERROR("Could not get interface 'IVSS_SetHeadlightLowBeam': [CAutoHeadlightService]");
m_eStatus = sdv::EObjectStatus::initialization_failure;
return;
return false;
}
// Request the basic service for the steering wheel.
@@ -29,8 +33,7 @@ void CAutoHeadlightService::Initialize(const sdv::u8string& ssObjectConfig)
if (!pCurrentLatitudeSvc)
{
SDV_LOG_ERROR("Could not get interface 'IVSS_GetCurrentLatitude': [CAutoHeadlightService]");
m_eStatus = sdv::EObjectStatus::initialization_failure;
return;
return false;
}
// Request the basic service for the vehicle speed.
@@ -38,8 +41,7 @@ void CAutoHeadlightService::Initialize(const sdv::u8string& ssObjectConfig)
if (!pCurrentLongitudeSvc)
{
SDV_LOG_ERROR("Could not get interface 'IVSS_GetCurrentLongitude': [CAutoHeadlightService]");
m_eStatus = sdv::EObjectStatus::initialization_failure;
return;
return false;
}
// Register Current Latitude change event handler.
@@ -49,32 +51,17 @@ void CAutoHeadlightService::Initialize(const sdv::u8string& ssObjectConfig)
pCurrentLongitudeSvc->RegisterOnSignalChangeOfFCurrentLongitude(static_cast<vss::Vehicle::Position::CurrentLongitudeService::IVSS_SetCurrentLongitude_Event*> (this));
if(LoadGPSBounds(ssObjectConfig))
{
SDV_LOG_INFO("AutoHeadlightService: GPS bounds loaded Successfully");
m_eStatus = sdv::EObjectStatus::initialized;
}
else
{
SDV_LOG_ERROR("AutoHeadlightService: GPS bounds could not be loaded");
m_eStatus = sdv::EObjectStatus::initialization_failure;
return;
}
// Swap the bounding box the make certain that min is less than max
if (m_SGPSBoundingBox.fTunnelMinLat > m_SGPSBoundingBox.fTunnelMaxLat)
std::swap(m_SGPSBoundingBox.fTunnelMinLat, m_SGPSBoundingBox.fTunnelMaxLat);
if (m_SGPSBoundingBox.fTunnelMinLon > m_SGPSBoundingBox.fTunnelMaxLon)
std::swap(m_SGPSBoundingBox.fTunnelMinLon, m_SGPSBoundingBox.fTunnelMaxLon);
SDV_LOG_INFO("AutoHeadlightService: Initialized Successfully");
return true;
}
sdv::EObjectStatus CAutoHeadlightService::GetStatus() const
{
return m_eStatus;
}
void CAutoHeadlightService::SetOperationMode(sdv::EOperationMode /*eMode*/)
{
// Not applicable
}
void CAutoHeadlightService::Shutdown()
void CAutoHeadlightService::OnShutdown()
{
// Unregister the Current latitude event handler.
auto pCurrentLatitudeSvc = sdv::core::GetObject("Vehicle.Position.CurrentLatitude_Service").GetInterface<vss::Vehicle::Position::CurrentLatitudeService::IVSS_GetCurrentLatitude>();
@@ -139,57 +126,6 @@ void CAutoHeadlightService::ProcessHeadlightBasedOnEgoPosition()
}
}
bool CAutoHeadlightService::LoadGPSBounds(const sdv::u8string& rssObjectConfig)
{
try
{
sdv::toml::CTOMLParser config(rssObjectConfig.c_str());
sdv::toml::CNode fStartLatNode = config.GetDirect("tunnel_start_lat");
float fTunnelStartLat = 0.0; ///< Tunnel Start Latitude
if (fStartLatNode.GetType() == sdv::toml::ENodeType::node_floating_point)
{
fTunnelStartLat = static_cast<float>(fStartLatNode.GetValue());
}
sdv::toml::CNode fStartLonNode = config.GetDirect("tunnel_start_lon");
float fTunnelStartLon = 0.0; ///< Tunnel Start Longitude
if (fStartLonNode.GetType() == sdv::toml::ENodeType::node_floating_point)
{
fTunnelStartLon = static_cast<float>(fStartLonNode.GetValue());
}
sdv::toml::CNode fEndLatNode = config.GetDirect("tunnel_end_lat");
float fTunnelEndLat = 0.0; ///< Tunnel End Latitude
if (fEndLatNode.GetType() == sdv::toml::ENodeType::node_floating_point)
{
fTunnelEndLat = static_cast<float>(fEndLatNode.GetValue());
}
sdv::toml::CNode fEndLonNode = config.GetDirect("tunnel_end_lon");
float fTunnelEndLon = 0.0; ///< Tunnel End Longitude
if (fEndLonNode.GetType() == sdv::toml::ENodeType::node_floating_point)
{
fTunnelEndLon = static_cast<float>(fEndLonNode.GetValue());
}
// Calculate bounding box
m_SGPSBoundingBox.fTunnelMinLat = std::min(fTunnelStartLat, fTunnelEndLat);
m_SGPSBoundingBox.fTunnelMaxLat = std::max(fTunnelStartLat, fTunnelEndLat);
m_SGPSBoundingBox.fTunnelMinLon = std::min(fTunnelStartLon, fTunnelEndLon);
m_SGPSBoundingBox.fTunnelMaxLon = std::max(fTunnelStartLon, fTunnelEndLon);
}
catch (const sdv::toml::XTOMLParseException& e)
{
SDV_LOG_ERROR("Parsing error: ", e.what());
return false;
}
return true;
}
IAutoheadlightService::SGPSBoundBox CAutoHeadlightService::GetGPSBoundBox() const
{
SGPSBoundBox tunnel;

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
#ifndef COMPLEX_SERVICE_EXAMPLE_H
#define COMPLEX_SERVICE_EXAMPLE_H
@@ -35,7 +45,6 @@
*/
class CAutoHeadlightService :
public sdv::CSdvObject,
public sdv::IObjectControl,
public IAutoheadlightService,
public vss::Vehicle::Position::CurrentLatitudeService::IVSS_SetCurrentLatitude_Event,
public vss::Vehicle::Position::CurrentLongitudeService::IVSS_SetCurrentLongitude_Event
@@ -53,39 +62,35 @@ public:
// Interface map
BEGIN_SDV_INTERFACE_MAP()
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
SDV_INTERFACE_ENTRY(vss::Vehicle::Position::CurrentLatitudeService::IVSS_SetCurrentLatitude_Event)
SDV_INTERFACE_ENTRY(vss::Vehicle::Position::CurrentLongitudeService::IVSS_SetCurrentLongitude_Event)
SDV_INTERFACE_ENTRY(IAutoheadlightService)
END_SDV_INTERFACE_MAP()
// Object declarations
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::ComplexService)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::vehicle_function)
DECLARE_OBJECT_CLASS_NAME("Auto Headlight Service")
DECLARE_OBJECT_SINGLETON()
/**
* @brief Initialize the object. Overload of sdv::IObjectControl::Initialize.
* @param[in] ssObjectConfig Optional configuration string.
*/
void Initialize(const sdv::u8string& ssObjectConfig) override;
// Parameter map
BEGIN_SDV_PARAM_MAP()
SDV_PARAM_ENABLE_LOCKING()
SDV_PARAM_ENTRY(m_SGPSBoundingBox.fTunnelMinLat, "tunnel_start_lat", 0.0f, u8"<EFBFBD>", "Tunnel Start Latitude")
SDV_PARAM_ENTRY(m_SGPSBoundingBox.fTunnelMinLon, "tunnel_start_lon", 0.0f, u8"<EFBFBD>", "Tunnel Start Longitude")
SDV_PARAM_ENTRY(m_SGPSBoundingBox.fTunnelMaxLat, "tunnel_end_lat", 0.0f, u8"<EFBFBD>", "Tunnel End Latitude")
SDV_PARAM_ENTRY(m_SGPSBoundingBox.fTunnelMaxLon, "tunnel_end_lon", 0.0f, u8"<EFBFBD>", "Tunnel End Longitude")
END_SDV_PARAM_MAP()
/**
* @brief Get the current status of the object. Overload of sdv::IObjectControl::GetStatus.
* @return Return the current status of the object.
* @brief Initialization event, called after object configuration was loaded. Overload of sdv::CSdvObject::OnInitialize.
* @return Returns 'true' when the initialization was successful, 'false' when not.
*/
sdv::EObjectStatus GetStatus() const override;
virtual bool OnInitialize() override;
/**
* @brief Set the component operation mode. Overload of sdv::IObjectControl::SetOperationMode.
* @param[in] eMode The operation mode, the component should run in.
* @brief Shutdown the object. Overload of sdv::CSdvObject::OnShutdown.
*/
void SetOperationMode(sdv::EOperationMode eMode) override;
/**
* @brief Shutdown called before the object is destroyed. Overload of sdv::IObjectControl::Shutdown.
*/
void Shutdown() override;
virtual void OnShutdown() override;
private:
@@ -129,13 +134,11 @@ private:
*/
bool LoadGPSBounds(const sdv::u8string& rssObjectConfig);
sdv::EObjectStatus m_eStatus = sdv::EObjectStatus::initialization_pending; ///< Current object status
volatile float m_fCurrentLatitude = 0.0; ///< Current Latitude
volatile float m_fCurrentLongitude = 0.0; ///< Current Longitude
volatile bool m_bHeadlight = false; ///< Headlight status
SGPSBoundBox m_SGPSBoundingBox; ///< Tunnel bounding box coordinates
///< Headlight interface.
vss::Vehicle::Body::Light::Front::LowBeamService::IVSS_SetHeadLightLowBeam* m_pHeadlightSvc = nullptr;
};

View File

@@ -1,11 +1,16 @@
/*******************************************************************************
* @file AutoHeadlight.idl
* @details Auto Headlight example service interface definition.
*/
/********************************************************************************
* 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
********************************************************************************/
/**
* @brief AutoHeadlight example service interface. The interface provides functions for the
* @details Auto Headlight example service interface definition.
* Auto Headlight example complex service.
*/
interface IAutoheadlightService

View File

@@ -4,6 +4,7 @@ Version = 100
[[Component]]
Path = "autoheadlight_service.sdv"
Class = "Auto Headlight Service"
[Component.Parameters]
tunnel_start_lat = 47.6500
tunnel_start_lon = 9.4700
tunnel_end_lat = 47.6506

View File

@@ -1,3 +1,13 @@
/********************************************************************************
* 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
********************************************************************************/
/**
* @file model.cpp
* @date 2025-09-12 15:01:57

View File

@@ -4,6 +4,7 @@ Version = 100
[[Component]]
Path = "autoheadlight_service.sdv"
Class = "Auto Headlight Service"
[Component.Parameters]
tunnel_start_lat = 31.300
tunnel_start_lon = 3.756
tunnel_end_lat = 21.168