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,16 @@
#*******************************************************************************
# 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
#
# Contributors:
# Erik Verhoeven - initial API and implementation
#*******************************************************************************
# Define project
project(task_timer VERSION 1.0 LANGUAGES CXX)

View File

@@ -1,3 +1,16 @@
/********************************************************************************
* 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
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#include "simulationtasktimer.h"
#include <fstream>
#include <functional>
@@ -44,7 +57,7 @@ void CSimulationTimer::SimulationStep(uint64_t uiSimulationStep)
//#ifdef _WIN32
//void CSimulationTimer::ExecuteCallback()
//{
// if (m_rtimersvc.GetStatus() != sdv::EObjectStatus::running) return;
// if (m_rtimersvc.GetObjectState() != sdv::EObjectState::running) return;
// if (!m_pExecute) return;
// if (!m_bPrioritySet)
// SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
@@ -62,52 +75,27 @@ CSimulationTaskTimerService::~CSimulationTaskTimerService()
{
}
void CSimulationTaskTimerService::Initialize(/*in*/ const sdv::u8string& /*ssObjectConfig*/)
bool CSimulationTaskTimerService::OnInitialize()
{
#ifdef _WIN32
m_eObjectStatus = sdv::EObjectStatus::initializing;
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// set up time resolution and maybe some other things
timeBeginPeriod(1);
#endif
m_eObjectStatus = sdv::EObjectStatus::initialized;
return true;
}
sdv::EObjectStatus CSimulationTaskTimerService::GetStatus() const
{
return m_eObjectStatus;
}
void CSimulationTaskTimerService::SetOperationMode(/*in*/ sdv::EOperationMode eMode)
{
switch (eMode)
{
case sdv::EOperationMode::configuring:
if (m_eObjectStatus == sdv::EObjectStatus::running || m_eObjectStatus == sdv::EObjectStatus::initialized)
m_eObjectStatus = sdv::EObjectStatus::configuring;
break;
case sdv::EOperationMode::running:
if (m_eObjectStatus == sdv::EObjectStatus::configuring || m_eObjectStatus == sdv::EObjectStatus::initialized)
m_eObjectStatus = sdv::EObjectStatus::running;
break;
default:
break;
}
}
void CSimulationTaskTimerService::Shutdown()
void CSimulationTaskTimerService::OnShutdown()
{
#ifdef _WIN32
m_eObjectStatus = sdv::EObjectStatus::shutdown_in_progress;
timeEndPeriod(1);
#endif
m_eObjectStatus = sdv::EObjectStatus::destruction_pending;
}
sdv::IInterfaceAccess* CSimulationTaskTimerService::CreateTimer(uint32_t uiPeriod, sdv::IInterfaceAccess* pTask)
{
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
if (!uiPeriod) return nullptr;
if (!pTask) return nullptr;
sdv::core::ITaskExecute* pExecute = pTask->GetInterface<sdv::core::ITaskExecute>();

View File

@@ -1,13 +1,15 @@
/**
* @file simulationtasktimer.h
* @author Sudipta Babu Durjoy FRD DISS21 (mailto:sudipta.durjoy@zf.com)
* @brief
* @version 1.0
* @date 2023-05-24
*
* @copyright Copyright ZF Friedrichshafen AG (c) 2023
*
*/
/********************************************************************************
* 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
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#ifndef SIMULATION_TASK_TIMER_H
#define SIMULATION_TASK_TIMER_H
@@ -108,8 +110,7 @@ private:
/**
* @brief Task timer class to execute task periodically
*/
class CSimulationTaskTimerService : public sdv::CSdvObject, public sdv::IObjectControl, public sdv::core::ITaskTimer,
public sdv::core::ITimerSimulationStep
class CSimulationTaskTimerService : public sdv::CSdvObject, public sdv::core::ITaskTimer, public sdv::core::ITimerSimulationStep
{
public:
/**
@@ -124,42 +125,25 @@ public:
// Interface map
BEGIN_SDV_INTERFACE_MAP()
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
SDV_INTERFACE_ENTRY(sdv::core::ITaskTimer)
SDV_INTERFACE_ENTRY(sdv::core::ITimerSimulationStep)
END_SDV_INTERFACE_MAP()
// Object declarations
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::SystemObject)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::system_object)
DECLARE_OBJECT_CLASS_NAME("SimulationTaskTimerService")
DECLARE_OBJECT_SINGLETON()
/**
* @brief Initialize the object. Overload of sdv::IObjectControl::Initialize.
* @param[in] ssObjectConfig Optional configuration string.
* @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.
*/
virtual void Initialize(/*in*/ const sdv::u8string& ssObjectConfig) override;
virtual bool OnInitialize() override;
/**
* @brief Get the current status of the object. Overload of sdv::IObjectControl::GetStatus.
* @return Return the current status of the object.
* @brief Shutdown the object. Overload of sdv::CSdvObject::OnShutdown.
*/
virtual sdv::EObjectStatus GetStatus() const override;
/**
* @brief Set the component operation mode. Overload of sdv::IObjectControl::SetOperationMode.
* @param[in] eMode The operation mode, the component should run in.
*/
virtual void SetOperationMode(/*in*/ sdv::EOperationMode eMode) override;
/**
* @brief Shutdown called before the object is destroyed. Overload of sdv::IObjectControl::Shutdown.
* @attention Implement calls to other SDV objects here as this is no longer considered safe during the destructor of the object!
* After a call to shutdown any threads/callbacks/etc that could call other SDV objects need to have been stopped.
* The SDV object itself is to remain in a state where it can respond to calls to its interfaces as other objects may still call it during the shutdown sequence!
* Any subsequent call to GetStatus should return EObjectStatus::destruction_pending
*/
virtual void Shutdown() override;
virtual void OnShutdown() override;
/**
* @brief Method to execute the user-defined task periodically until ShutdownTask is called.
@@ -170,7 +154,6 @@ public:
*/
virtual sdv::IInterfaceAccess* CreateTimer(uint32_t uiPeriod, sdv::IInterfaceAccess* pTask) override;
/**
* @brief Method to set the time which has past from the last simulation step.
* @param[in] uiSimulationStep the time in microseconds which has past from the last simulation step.
@@ -184,9 +167,8 @@ public:
void RemoveTimer(CSimulationTimer* pTimer);
private:
sdv::EObjectStatus m_eObjectStatus = sdv::EObjectStatus::initialization_pending; ///< Object operation status
std::mutex m_mtxTasks; ///< Mutex for tasks
std::map<CSimulationTimer*, std::unique_ptr<CSimulationTimer>> m_mapTasks; ///< Set to get the active tasks
std::mutex m_mtxTasks; ///< Mutex for tasks
std::map<CSimulationTimer*, std::unique_ptr<CSimulationTimer>> m_mapTasks; ///< Set to get the active tasks
};
DEFINE_SDV_OBJECT(CSimulationTaskTimerService)

View File

@@ -1,3 +1,16 @@
/********************************************************************************
* 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
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#include "tasktimer.h"
#include <fstream>
#include <functional>
@@ -96,7 +109,7 @@ CTimer::operator bool() const
#ifdef _WIN32
void CTimer::ExecuteCallback()
{
if (m_rtimersvc.GetStatus() != sdv::EObjectStatus::running) return;
if (m_rtimersvc.GetObjectState() != sdv::EObjectState::running) return;
if (!m_pExecute) return;
if (!m_bPrioritySet)
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
@@ -113,53 +126,28 @@ CTaskTimerService::~CTaskTimerService()
{
}
void CTaskTimerService::Initialize(/*in*/ const sdv::u8string& /*ssObjectConfig*/)
bool CTaskTimerService::OnInitialize()
{
#ifdef _WIN32
m_eObjectStatus = sdv::EObjectStatus::initializing;
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// set up time resolution and maybe some other things
timeBeginPeriod(1);
#endif
m_eObjectStatus = sdv::EObjectStatus::initialized;
return true;
}
sdv::EObjectStatus CTaskTimerService::GetStatus() const
{
return m_eObjectStatus;
}
void CTaskTimerService::SetOperationMode(/*in*/ sdv::EOperationMode eMode)
{
switch (eMode)
{
case sdv::EOperationMode::configuring:
if (m_eObjectStatus == sdv::EObjectStatus::running || m_eObjectStatus == sdv::EObjectStatus::initialized)
m_eObjectStatus = sdv::EObjectStatus::configuring;
break;
case sdv::EOperationMode::running:
if (m_eObjectStatus == sdv::EObjectStatus::configuring || m_eObjectStatus == sdv::EObjectStatus::initialized)
m_eObjectStatus = sdv::EObjectStatus::running;
break;
default:
break;
}
}
void CTaskTimerService::Shutdown()
void CTaskTimerService::OnShutdown()
{
#ifdef _WIN32
m_eObjectStatus = sdv::EObjectStatus::shutdown_in_progress;
timeEndPeriod(1);
#endif
m_eObjectStatus = sdv::EObjectStatus::destruction_pending;
}
sdv::IInterfaceAccess* CTaskTimerService::CreateTimer(uint32_t uiPeriod, sdv::IInterfaceAccess* pTask)
{
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
if (!uiPeriod) return nullptr;
if (!pTask) return nullptr;

View File

@@ -1,13 +1,15 @@
/**
* @file tasktimer.h
* @author Sudipta Babu Durjoy FRD DISS21 (mailto:sudipta.durjoy@zf.com)
* @brief
* @version 1.0
* @date 2023-05-24
*
* @copyright Copyright ZF Friedrichshafen AG (c) 2023
*
*/
/********************************************************************************
* 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
*
* Contributors:
* Erik Verhoeven - initial API and implementation
********************************************************************************/
#ifndef TASK_TIMER_H
#define TASK_TIMER_H
@@ -19,6 +21,7 @@
#include <map>
#include <set>
#include <fstream>
#include <atomic>
#ifdef _WIN32
// Resolve conflict
@@ -93,10 +96,10 @@ private:
sdv::core::ITaskExecute* m_pExecute = nullptr; ///< Pointer to the execution callback interface.
#ifdef _WIN32
UINT m_uiTimerID = 0ul; ///< Timer ID
bool m_bPrioritySet = false; ///< When set, the priority of the task was increased.
std::atomic_bool m_bPrioritySet = false; ///< When set, the priority of the task was increased.
#elif defined __unix__
timer_t m_timerid = 0; ///< Timer ID.
bool m_bRunning = false; ///< When set, the timer is running.
std::atomic_bool m_bRunning = false; ///< When set, the timer is running.
std::mutex m_mtxExecution; ///< Prevent killing the timer when in execution.
#endif
};
@@ -104,7 +107,7 @@ private:
/**
* @brief Task timer class to execute task periodically
*/
class CTaskTimerService : public sdv::CSdvObject, public sdv::IObjectControl, public sdv::core::ITaskTimer
class CTaskTimerService : public sdv::CSdvObject, public sdv::core::ITaskTimer
{
public:
/**
@@ -119,41 +122,24 @@ public:
// Interface map
BEGIN_SDV_INTERFACE_MAP()
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
SDV_INTERFACE_ENTRY(sdv::core::ITaskTimer)
END_SDV_INTERFACE_MAP()
// Object declarations
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::SystemObject)
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::system_object)
DECLARE_OBJECT_CLASS_NAME("TaskTimerService")
DECLARE_OBJECT_SINGLETON()
/**
* @brief Initialize the object. Overload of sdv::IObjectControl::Initialize.
* @param[in] ssObjectConfig Optional configuration string.
* @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.
*/
virtual void Initialize(/*in*/ const sdv::u8string& ssObjectConfig) override;
virtual bool OnInitialize() override;
/**
* @brief Get the current status of the object. Overload of sdv::IObjectControl::GetStatus.
* @return Return the current status of the object.
* @brief Shutdown the object. Overload of sdv::CSdvObject::OnShutdown.
*/
virtual sdv::EObjectStatus GetStatus() const override;
/**
* @brief Set the component operation mode. Overload of sdv::IObjectControl::SetOperationMode.
* @param[in] eMode The operation mode, the component should run in.
*/
virtual void SetOperationMode(/*in*/ sdv::EOperationMode eMode) override;
/**
* @brief Shutdown called before the object is destroyed. Overload of sdv::IObjectControl::Shutdown.
* @attention Implement calls to other SDV objects here as this is no longer considered safe during the destructor of the object!
* After a call to shutdown any threads/callbacks/etc that could call other SDV objects need to have been stopped.
* The SDV object itself is to remain in a state where it can respond to calls to its interfaces as other objects may still call it during the shutdown sequence!
* Any subsequent call to GetStatus should return EObjectStatus::destruction_pending
*/
virtual void Shutdown() override;
virtual void OnShutdown() override;
/**
* @brief Method to execute the user-defined task periodically until ShutdownTask is called.
@@ -171,9 +157,8 @@ public:
void RemoveTimer(CTimer* pTimer);
private:
sdv::EObjectStatus m_eObjectStatus = sdv::EObjectStatus::initialization_pending; ///< Object operation status
std::mutex m_mtxTasks; ///< Mutex for tasks
std::map<CTimer*, std::unique_ptr<CTimer>> m_mapTasks; ///< Set to get the active tasks
std::mutex m_mtxTasks; ///< Mutex for tasks
std::map<CTimer*, std::unique_ptr<CTimer>> m_mapTasks; ///< Set to get the active tasks
};
DEFINE_SDV_OBJECT(CTaskTimerService)