mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-07-01 21:25:11 +00:00
Update sdv_packager (#6)
This commit is contained in:
@@ -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(sdv_service_datadispatchservice VERSION 1.0 LANGUAGES CXX)
|
||||
|
||||
|
||||
@@ -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 "dispatchservice.h"
|
||||
|
||||
|
||||
@@ -9,7 +22,7 @@ CDispatchService::CDispatchService()
|
||||
sdv::IInterfaceAccess* CDispatchService::CreateTxTrigger(uint32_t uiCycleTime, uint32_t uiDelayTime, uint32_t uiBehaviorFlags,
|
||||
sdv::IInterfaceAccess* pTriggerCallback)
|
||||
{
|
||||
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
|
||||
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
|
||||
|
||||
// Check for parameter validity
|
||||
if (!uiCycleTime && !(uiBehaviorFlags & static_cast<uint32_t>(sdv::core::ISignalTransmission::ETxTriggerBehavior::spontaneous)))
|
||||
@@ -39,7 +52,7 @@ sdv::IInterfaceAccess* CDispatchService::CreateTxTrigger(uint32_t uiCycleTime, u
|
||||
|
||||
sdv::IInterfaceAccess* CDispatchService::RegisterTxSignal(/*in*/ const sdv::u8string& ssSignalName, /*in*/ sdv::any_t anyDefVal)
|
||||
{
|
||||
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
|
||||
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mtxSignals);
|
||||
|
||||
@@ -49,7 +62,7 @@ sdv::IInterfaceAccess* CDispatchService::RegisterTxSignal(/*in*/ const sdv::u8st
|
||||
|
||||
sdv::IInterfaceAccess* CDispatchService::RegisterRxSignal(/*in*/ const sdv::u8string& ssSignalName)
|
||||
{
|
||||
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
|
||||
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mtxSignals);
|
||||
auto prSignal = m_mapRxSignals.try_emplace(ssSignalName, *this, ssSignalName, sdv::core::ESignalDirection::sigdir_rx);
|
||||
@@ -58,7 +71,7 @@ sdv::IInterfaceAccess* CDispatchService::RegisterRxSignal(/*in*/ const sdv::u8st
|
||||
|
||||
sdv::IInterfaceAccess* CDispatchService::RequestSignalPublisher(/*in*/ const sdv::u8string& ssSignalName)
|
||||
{
|
||||
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
|
||||
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mtxSignals);
|
||||
auto itSignal = m_mapTxSignals.find(ssSignalName);
|
||||
@@ -70,7 +83,7 @@ sdv::IInterfaceAccess* CDispatchService::RequestSignalPublisher(/*in*/ const sdv
|
||||
|
||||
sdv::IInterfaceAccess* CDispatchService::AddSignalSubscription(/*in*/ const sdv::u8string& ssSignalName, /*in*/ IInterfaceAccess* pSubscriber)
|
||||
{
|
||||
if (m_eObjectStatus != sdv::EObjectStatus::configuring) return nullptr;
|
||||
if (GetObjectState() != sdv::EObjectState::configuring) return nullptr;
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mtxSignals);
|
||||
auto itSignal = m_mapRxSignals.find(ssSignalName);
|
||||
@@ -118,42 +131,15 @@ uint64_t CDispatchService::GetDirectTransactionID() const
|
||||
return m_uiDirectTransactionID;
|
||||
}
|
||||
|
||||
void CDispatchService::Initialize(const sdv::u8string& /*ssObjectConfig*/)
|
||||
bool CDispatchService::OnInitialize()
|
||||
{
|
||||
m_eObjectStatus = sdv::EObjectStatus::initializing;
|
||||
m_scheduler.Start();
|
||||
m_eObjectStatus = sdv::EObjectStatus::initialized;
|
||||
return true;
|
||||
}
|
||||
|
||||
sdv::EObjectStatus CDispatchService::GetStatus() const
|
||||
void CDispatchService::OnShutdown()
|
||||
{
|
||||
return m_eObjectStatus;
|
||||
}
|
||||
|
||||
void CDispatchService::SetOperationMode(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 CDispatchService::Shutdown()
|
||||
{
|
||||
m_eObjectStatus = sdv::EObjectStatus::shutdown_in_progress;
|
||||
|
||||
m_scheduler.Stop();
|
||||
|
||||
m_eObjectStatus = sdv::EObjectStatus::initialization_pending;
|
||||
}
|
||||
|
||||
void CDispatchService::UnregisterSignal(/*in*/ const sdv::u8string& ssSignalName, sdv::core::ESignalDirection eDirection)
|
||||
|
||||
@@ -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
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef DISPATCH_SERVICE_H
|
||||
#define DISPATCH_SERVICE_H
|
||||
|
||||
@@ -28,7 +41,7 @@
|
||||
* @brief data dispatch service to read/write and react on signal changes
|
||||
*/
|
||||
class CDispatchService : public sdv::CSdvObject, public sdv::core::ISignalTransmission, public sdv::core::ISignalAccess,
|
||||
public sdv::core::IDispatchTransaction, public sdv::IObjectControl
|
||||
public sdv::core::IDispatchTransaction
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -41,11 +54,10 @@ public:
|
||||
SDV_INTERFACE_ENTRY(sdv::core::ISignalTransmission)
|
||||
SDV_INTERFACE_ENTRY(sdv::core::ISignalAccess)
|
||||
SDV_INTERFACE_ENTRY(sdv::core::IDispatchTransaction)
|
||||
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
|
||||
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("DataDispatchService")
|
||||
DECLARE_OBJECT_SINGLETON()
|
||||
DECLARE_OBJECT_DEPENDENCIES("TaskTimerService")
|
||||
@@ -145,27 +157,15 @@ public:
|
||||
uint64_t GetDirectTransactionID() const;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
void Initialize(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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Unregister a previously registered signal. This will render all subscriptions and provider connections invalid.
|
||||
@@ -205,7 +205,6 @@ private:
|
||||
mutable std::mutex m_mtxSignals; ///< Signal object map protection.
|
||||
std::map<sdv::u8string, CSignal> m_mapRxSignals; ///< Signal object map.
|
||||
std::map<sdv::u8string, CSignal> m_mapTxSignals; ///< Signal object map.
|
||||
sdv::EObjectStatus m_eObjectStatus = sdv::EObjectStatus::initialization_pending; ///< Object status.
|
||||
std::atomic_uint64_t m_uiTransactionCnt = 1ull; ///< Transaction counter.
|
||||
std::mutex m_mtxTransactions; ///< List with transactions access.
|
||||
std::list<CTransaction> m_lstTransactions; ///< List with transactions.
|
||||
|
||||
@@ -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 "dispatchservice.h"
|
||||
#include "signal.h"
|
||||
#include "trigger.h"
|
||||
@@ -159,7 +172,7 @@ void CSignal::RemoveConsumer(CConsumer* pConsumer)
|
||||
|
||||
void CSignal::WriteFromProvider(const sdv::any_t& ranyVal, uint64_t uiTransactionID, std::set<CTrigger*>& rsetTriggers)
|
||||
{
|
||||
if (m_rDispatchSvc.GetStatus() != sdv::EObjectStatus::running) return;
|
||||
if (m_rDispatchSvc.GetObjectState() != sdv::EObjectState::running) return;
|
||||
|
||||
uint64_t uiTransactionIDTemp = uiTransactionID;
|
||||
if (!uiTransactionIDTemp) uiTransactionIDTemp = m_rDispatchSvc.GetDirectTransactionID();
|
||||
@@ -221,7 +234,7 @@ sdv::any_t CSignal::ReadFromConsumer(uint64_t uiTransactionID) const
|
||||
|
||||
void CSignal::DistributeToConsumers(const sdv::any_t& ranyVal)
|
||||
{
|
||||
if (m_rDispatchSvc.GetStatus() != sdv::EObjectStatus::running) return;
|
||||
if (m_rDispatchSvc.GetObjectState() != sdv::EObjectState::running) return;
|
||||
|
||||
std::unique_lock<std::mutex> lock(m_mtxSignalObjects);
|
||||
for (auto& rvtConsumer : m_mapConsumers)
|
||||
|
||||
@@ -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
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef SIGNAL_H
|
||||
#define SIGNAL_H
|
||||
|
||||
|
||||
@@ -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 "dispatchservice.h"
|
||||
#include "transaction.h"
|
||||
#include "trigger.h"
|
||||
|
||||
@@ -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
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef TRANSACTION_H
|
||||
#define TRANSACTION_H
|
||||
|
||||
|
||||
@@ -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 "dispatchservice.h"
|
||||
#include "trigger.h"
|
||||
#include "signal.h"
|
||||
@@ -157,7 +170,7 @@ void CTrigger::RemoveSignal(/*in*/ const sdv::u8string& ssSignalName)
|
||||
|
||||
void CTrigger::Execute(EExecutionFlag eExecFlag /*= EExecutionFlag::spontaneous*/)
|
||||
{
|
||||
if (m_rDispatchSvc.GetStatus() != sdv::EObjectStatus::running) return;
|
||||
if (m_rDispatchSvc.GetObjectState() != sdv::EObjectState::running) return;
|
||||
|
||||
// Check for allowed execution
|
||||
if (eExecFlag == EExecutionFlag::spontaneous &&
|
||||
|
||||
@@ -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
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef TRIGGER_H
|
||||
#define TRIGGER_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user