mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-18 10:38:16 +00:00
42
examples/door_demo_example/can_dl_door/CMakeLists.txt
Normal file
42
examples/door_demo_example/can_dl_door/CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
# Enforce CMake version 3.20 or newer needed for path function
|
||||
cmake_minimum_required (VERSION 3.20)
|
||||
|
||||
# Use new policy for project version settings and default warning level
|
||||
cmake_policy(SET CMP0048 NEW) # requires CMake 3.14
|
||||
cmake_policy(SET CMP0092 NEW) # requires CMake 3.15
|
||||
|
||||
# Define project
|
||||
project(can_dl_door VERSION 1.0 LANGUAGES CXX)
|
||||
|
||||
# Use C++17 support
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Library symbols are hidden by default
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
|
||||
# Set the SDV_FRAMEWORK_DEV_INCLUDE if not defined yet
|
||||
if (NOT DEFINED SDV_FRAMEWORK_DEV_INCLUDE)
|
||||
if (NOT DEFINED ENV{SDV_FRAMEWORK_DEV_INCLUDE})
|
||||
message( FATAL_ERROR "The environment variable SDV_FRAMEWORK_DEV_INCLUDE needs to be pointing to the SDV V-API development include files location!")
|
||||
endif()
|
||||
set (SDV_FRAMEWORK_DEV_INCLUDE "$ENV{SDV_FRAMEWORK_DEV_INCLUDE}")
|
||||
endif()
|
||||
|
||||
# Include link to export directory of SDV V-API development include files location
|
||||
include_directories(${SDV_FRAMEWORK_DEV_INCLUDE})
|
||||
|
||||
# Set platform specific compile flags
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
add_compile_options(/W4 /WX /wd4996 /wd4100 /permissive- /Zc:rvalueCast)
|
||||
else()
|
||||
add_compile_options(-Werror -Wall -Wextra -Wshadow -Wpedantic -Wunreachable-code -fno-common)
|
||||
endif()
|
||||
|
||||
# Add the dynamic library
|
||||
add_library(can_dl_door SHARED
|
||||
datalink.cpp
|
||||
datalink.h)
|
||||
|
||||
# Set extension to .sdv
|
||||
set_target_properties(can_dl_door PROPERTIES PREFIX "")
|
||||
set_target_properties(can_dl_door PROPERTIES SUFFIX ".sdv")
|
||||
412
examples/door_demo_example/can_dl_door/datalink.cpp
Normal file
412
examples/door_demo_example/can_dl_door/datalink.cpp
Normal file
@@ -0,0 +1,412 @@
|
||||
/**
|
||||
* @file datalink.cpp
|
||||
* @date 2025-09-06 08:00:37
|
||||
* This file implements the data link object between CAN and the V-API devices.
|
||||
* This file was generated by the DBC utility from:
|
||||
* "", "datalink_4doors_example.dbc"
|
||||
* DBC file version: 1.0.0.1
|
||||
*/
|
||||
#include "datalink.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CDataLink::CDataLink() :
|
||||
m_sRxMsgCAN_Input_L1(m_dispatch),
|
||||
m_sRxMsgCAN_Input_R1(m_dispatch),
|
||||
m_sRxMsgCAN_Input_L2(m_dispatch),
|
||||
m_sRxMsgCAN_Input_R2(m_dispatch),
|
||||
m_sTxMsgCAN_Output(m_dispatch)
|
||||
{}
|
||||
|
||||
CDataLink::~CDataLink()
|
||||
{
|
||||
Shutdown(); // Just in case
|
||||
}
|
||||
|
||||
void CDataLink::Initialize(const sdv::u8string& /*ssObjectConfig*/)
|
||||
{
|
||||
if (m_eStatus != sdv::EObjectStatus::initialization_pending) return;
|
||||
|
||||
// Get the CAN communication object.
|
||||
sdv::TInterfaceAccessPtr ptrCANObject = sdv::core::GetObject("CAN_Communication_Object");
|
||||
if (!ptrCANObject)
|
||||
{
|
||||
SDV_LOG_ERROR("CDataLink::Initialize() failure, 'CAN_Communication_Object' not found");
|
||||
m_eStatus = sdv::EObjectStatus::initialization_failure;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the CAN receiver registration interface.
|
||||
m_pRegister = ptrCANObject.GetInterface<sdv::can::IRegisterReceiver>();
|
||||
if (!m_pRegister)
|
||||
{
|
||||
SDV_LOG_ERROR("CDataLink::Initialize() failure, 'sdv::can::IRegisterReceiver' interface not found");
|
||||
m_eStatus = sdv::EObjectStatus::initialization_failure;
|
||||
return;
|
||||
}
|
||||
m_pRegister->RegisterReceiver(static_cast<sdv::can::IReceive*>(this));
|
||||
|
||||
// Get the CAN transmit interface
|
||||
m_pSend = ptrCANObject.GetInterface<sdv::can::ISend>();
|
||||
if (!m_pSend)
|
||||
{
|
||||
SDV_LOG_ERROR("CDataLink::Initialize() failure, 'sdv::can::ISend' interface not found");
|
||||
m_eStatus = sdv::EObjectStatus::initialization_failure;
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize messages
|
||||
bool bSuccess = true;
|
||||
bSuccess &= m_sRxMsgCAN_Input_L1.Init();
|
||||
bSuccess &= m_sRxMsgCAN_Input_R1.Init();
|
||||
bSuccess &= m_sRxMsgCAN_Input_L2.Init();
|
||||
bSuccess &= m_sRxMsgCAN_Input_R2.Init();
|
||||
bSuccess &= m_sTxMsgCAN_Output.Init(m_pSend);
|
||||
|
||||
m_eStatus = bSuccess ? sdv::EObjectStatus::initialized : sdv::EObjectStatus::initialization_failure;
|
||||
}
|
||||
|
||||
sdv::EObjectStatus CDataLink::GetStatus() const
|
||||
{
|
||||
return m_eStatus;
|
||||
}
|
||||
|
||||
void CDataLink::SetOperationMode(sdv::EOperationMode eMode)
|
||||
{
|
||||
switch (eMode)
|
||||
{
|
||||
case sdv::EOperationMode::configuring:
|
||||
if (m_eStatus == sdv::EObjectStatus::running || m_eStatus == sdv::EObjectStatus::initialized)
|
||||
m_eStatus = sdv::EObjectStatus::configuring;
|
||||
break;
|
||||
case sdv::EOperationMode::running:
|
||||
if (m_eStatus == sdv::EObjectStatus::configuring || m_eStatus == sdv::EObjectStatus::initialized)
|
||||
m_eStatus = sdv::EObjectStatus::running;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CDataLink::Shutdown()
|
||||
{
|
||||
m_eStatus = sdv::EObjectStatus::shutdown_in_progress;
|
||||
|
||||
// Unregister receiver interface.
|
||||
if (m_pRegister) m_pRegister->UnregisterReceiver(static_cast<sdv::can::IReceive*>(this));
|
||||
m_pRegister = nullptr;
|
||||
|
||||
m_pSend = nullptr;
|
||||
|
||||
// Terminate messages
|
||||
m_sRxMsgCAN_Input_L1.Term();
|
||||
m_sRxMsgCAN_Input_R1.Term();
|
||||
m_sRxMsgCAN_Input_L2.Term();
|
||||
m_sRxMsgCAN_Input_R2.Term();
|
||||
m_sTxMsgCAN_Output.Term();
|
||||
|
||||
// Update the status
|
||||
m_eStatus = sdv::EObjectStatus::destruction_pending;
|
||||
}
|
||||
|
||||
void CDataLink::Receive(/*in*/ [[maybe_unused]] const sdv::can::SMessage& sMsg, /*in*/ uint32_t uiIfcIndex)
|
||||
{
|
||||
if (static_cast<size_t>(uiIfcIndex) != m_nIfcIndex) return;
|
||||
|
||||
switch (sMsg.uiID)
|
||||
{
|
||||
case 1: // CAN_Input_L1
|
||||
m_sRxMsgCAN_Input_L1.Process(sMsg.seqData);
|
||||
break;
|
||||
case 2: // CAN_Input_R1
|
||||
m_sRxMsgCAN_Input_R1.Process(sMsg.seqData);
|
||||
break;
|
||||
case 3: // CAN_Input_L2
|
||||
m_sRxMsgCAN_Input_L2.Process(sMsg.seqData);
|
||||
break;
|
||||
case 4: // CAN_Input_R2
|
||||
m_sRxMsgCAN_Input_R2.Process(sMsg.seqData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CDataLink::Error(/*in*/ [[maybe_unused]] const sdv::can::SErrorFrame& sError, /*in*/ uint32_t uiIfcIndex)
|
||||
{
|
||||
if (static_cast<size_t>(uiIfcIndex) != m_nIfcIndex) return;
|
||||
|
||||
// TODO: Currently no error frame handling...
|
||||
}
|
||||
|
||||
|
||||
CDataLink::SRxMsg_CAN_Input_L1::SRxMsg_CAN_Input_L1(sdv::core::CDispatchService& rdispatch) :
|
||||
m_rdispatch(rdispatch)
|
||||
{}
|
||||
|
||||
bool CDataLink::SRxMsg_CAN_Input_L1::Init()
|
||||
{
|
||||
// Register signals
|
||||
[[maybe_unused]] bool bSuccess = true;
|
||||
m_sigDoor01LeftIsOpen = m_rdispatch.RegisterRxSignal("CAN_Input_L1.Door01LeftIsOpen");
|
||||
bSuccess &= m_sigDoor01LeftIsOpen ? true : false;
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_L1::Term()
|
||||
{
|
||||
// Unregister signals
|
||||
m_sigDoor01LeftIsOpen.Reset();
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_L1::Process(const sdv::sequence<uint8_t>& rseqData)
|
||||
{
|
||||
// Check for the correct size.
|
||||
if (rseqData.size() != 1)
|
||||
{
|
||||
// TODO: Error. Delivered data has different size as compared to the specification.
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variable
|
||||
[[maybe_unused]] UValueHelper uValueHelper;
|
||||
|
||||
// Start a transaction
|
||||
sdv::core::CTransaction transaction = m_rdispatch.CreateTransaction();
|
||||
|
||||
// Process CAN_Input_L1.Door01LeftIsOpen
|
||||
uValueHelper.uiUint64Value = rseqData[0] & 3;
|
||||
uValueHelper.uiUint64Value >>= 1;
|
||||
m_sigDoor01LeftIsOpen.Write(std::min(std::max(uValueHelper.s32.u32.uiValue, 0u), 1u), transaction);
|
||||
|
||||
// Finalize the transaction
|
||||
transaction.Finish();
|
||||
}
|
||||
|
||||
CDataLink::SRxMsg_CAN_Input_R1::SRxMsg_CAN_Input_R1(sdv::core::CDispatchService& rdispatch) :
|
||||
m_rdispatch(rdispatch)
|
||||
{}
|
||||
|
||||
bool CDataLink::SRxMsg_CAN_Input_R1::Init()
|
||||
{
|
||||
// Register signals
|
||||
[[maybe_unused]] bool bSuccess = true;
|
||||
m_sigDoor01RightIsOpen = m_rdispatch.RegisterRxSignal("CAN_Input_R1.Door01RightIsOpen");
|
||||
bSuccess &= m_sigDoor01RightIsOpen ? true : false;
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_R1::Term()
|
||||
{
|
||||
// Unregister signals
|
||||
m_sigDoor01RightIsOpen.Reset();
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_R1::Process(const sdv::sequence<uint8_t>& rseqData)
|
||||
{
|
||||
// Check for the correct size.
|
||||
if (rseqData.size() != 1)
|
||||
{
|
||||
// TODO: Error. Delivered data has different size as compared to the specification.
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variable
|
||||
[[maybe_unused]] UValueHelper uValueHelper;
|
||||
|
||||
// Start a transaction
|
||||
sdv::core::CTransaction transaction = m_rdispatch.CreateTransaction();
|
||||
|
||||
// Process CAN_Input_R1.Door01RightIsOpen
|
||||
uValueHelper.uiUint64Value = rseqData[0] & 15;
|
||||
uValueHelper.uiUint64Value >>= 3;
|
||||
m_sigDoor01RightIsOpen.Write(std::min(std::max(uValueHelper.s32.u32.uiValue, 0u), 1u), transaction);
|
||||
|
||||
// Finalize the transaction
|
||||
transaction.Finish();
|
||||
}
|
||||
|
||||
CDataLink::SRxMsg_CAN_Input_L2::SRxMsg_CAN_Input_L2(sdv::core::CDispatchService& rdispatch) :
|
||||
m_rdispatch(rdispatch)
|
||||
{}
|
||||
|
||||
bool CDataLink::SRxMsg_CAN_Input_L2::Init()
|
||||
{
|
||||
// Register signals
|
||||
[[maybe_unused]] bool bSuccess = true;
|
||||
m_sigDoor02LeftIsOpen = m_rdispatch.RegisterRxSignal("CAN_Input_L2.Door02LeftIsOpen");
|
||||
bSuccess &= m_sigDoor02LeftIsOpen ? true : false;
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_L2::Term()
|
||||
{
|
||||
// Unregister signals
|
||||
m_sigDoor02LeftIsOpen.Reset();
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_L2::Process(const sdv::sequence<uint8_t>& rseqData)
|
||||
{
|
||||
// Check for the correct size.
|
||||
if (rseqData.size() != 1)
|
||||
{
|
||||
// TODO: Error. Delivered data has different size as compared to the specification.
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variable
|
||||
[[maybe_unused]] UValueHelper uValueHelper;
|
||||
|
||||
// Start a transaction
|
||||
sdv::core::CTransaction transaction = m_rdispatch.CreateTransaction();
|
||||
|
||||
// Process CAN_Input_L2.Door02LeftIsOpen
|
||||
uValueHelper.uiUint64Value = rseqData[0] & 63;
|
||||
uValueHelper.uiUint64Value >>= 5;
|
||||
m_sigDoor02LeftIsOpen.Write(std::min(std::max(uValueHelper.s32.u32.uiValue, 0u), 1u), transaction);
|
||||
|
||||
// Finalize the transaction
|
||||
transaction.Finish();
|
||||
}
|
||||
|
||||
CDataLink::SRxMsg_CAN_Input_R2::SRxMsg_CAN_Input_R2(sdv::core::CDispatchService& rdispatch) :
|
||||
m_rdispatch(rdispatch)
|
||||
{}
|
||||
|
||||
bool CDataLink::SRxMsg_CAN_Input_R2::Init()
|
||||
{
|
||||
// Register signals
|
||||
[[maybe_unused]] bool bSuccess = true;
|
||||
m_sigDoor02RightIsOpen = m_rdispatch.RegisterRxSignal("CAN_Input_R2.Door02RightIsOpen");
|
||||
bSuccess &= m_sigDoor02RightIsOpen ? true : false;
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_R2::Term()
|
||||
{
|
||||
// Unregister signals
|
||||
m_sigDoor02RightIsOpen.Reset();
|
||||
}
|
||||
|
||||
void CDataLink::SRxMsg_CAN_Input_R2::Process(const sdv::sequence<uint8_t>& rseqData)
|
||||
{
|
||||
// Check for the correct size.
|
||||
if (rseqData.size() != 1)
|
||||
{
|
||||
// TODO: Error. Delivered data has different size as compared to the specification.
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variable
|
||||
[[maybe_unused]] UValueHelper uValueHelper;
|
||||
|
||||
// Start a transaction
|
||||
sdv::core::CTransaction transaction = m_rdispatch.CreateTransaction();
|
||||
|
||||
// Process CAN_Input_R2.Door02RightIsOpen
|
||||
uValueHelper.uiUint64Value = rseqData[0];
|
||||
uValueHelper.uiUint64Value >>= 7;
|
||||
m_sigDoor02RightIsOpen.Write(std::min(std::max(uValueHelper.s32.u32.uiValue, 0u), 1u), transaction);
|
||||
|
||||
// Finalize the transaction
|
||||
transaction.Finish();
|
||||
}
|
||||
|
||||
CDataLink::STxMsg_CAN_Output::STxMsg_CAN_Output(sdv::core::CDispatchService& rdispatch) :
|
||||
m_rdispatch(rdispatch)
|
||||
{}
|
||||
|
||||
bool CDataLink::STxMsg_CAN_Output::Init(sdv::can::ISend* pSend)
|
||||
{
|
||||
if (!pSend) return false;
|
||||
m_pSend = pSend;
|
||||
|
||||
// Register signals
|
||||
bool bSuccess = true;
|
||||
m_sigLockDoor02Right = m_rdispatch.RegisterTxSignal("CAN_Output.LockDoor02Right", sdv::any_t());
|
||||
bSuccess &= m_sigLockDoor02Right ? true : false;
|
||||
m_sigLockDoor02Left = m_rdispatch.RegisterTxSignal("CAN_Output.LockDoor02Left", sdv::any_t());
|
||||
bSuccess &= m_sigLockDoor02Left ? true : false;
|
||||
m_sigLockDoor01Right = m_rdispatch.RegisterTxSignal("CAN_Output.LockDoor01Right", sdv::any_t());
|
||||
bSuccess &= m_sigLockDoor01Right ? true : false;
|
||||
m_sigLockDoor01Left = m_rdispatch.RegisterTxSignal("CAN_Output.LockDoor01Left", sdv::any_t());
|
||||
bSuccess &= m_sigLockDoor01Left ? true : false;
|
||||
|
||||
// Initialize the trigger
|
||||
m_trigger = m_rdispatch.CreateTxTrigger([&] { Transmit(); }, false, 0, 10, false);
|
||||
m_trigger.AddSignal(m_sigLockDoor02Right);
|
||||
m_trigger.AddSignal(m_sigLockDoor02Left);
|
||||
m_trigger.AddSignal(m_sigLockDoor01Right);
|
||||
m_trigger.AddSignal(m_sigLockDoor01Left);
|
||||
bSuccess &= m_trigger;
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
void CDataLink::STxMsg_CAN_Output::Term()
|
||||
{
|
||||
// Reset the trigger
|
||||
m_trigger.Reset();
|
||||
|
||||
// Unregister signals
|
||||
m_sigLockDoor02Right.Reset();
|
||||
m_sigLockDoor02Left.Reset();
|
||||
m_sigLockDoor01Right.Reset();
|
||||
m_sigLockDoor01Left.Reset();
|
||||
}
|
||||
|
||||
void CDataLink::STxMsg_CAN_Output::Transmit()
|
||||
{
|
||||
if (!m_pSend) return;
|
||||
|
||||
// Compose CAN message
|
||||
sdv::can::SMessage msg;
|
||||
msg.uiID = 5;
|
||||
msg.bExtended = false;
|
||||
msg.bCanFd = false; // TODO: Currently not supported
|
||||
msg.seqData.resize(1);
|
||||
std::fill(msg.seqData.begin(), msg.seqData.end(), static_cast<uint8_t>(0));
|
||||
|
||||
// Helper variable
|
||||
[[maybe_unused]] UValueHelper uValueHelper;
|
||||
|
||||
// Start a transaction
|
||||
sdv::core::CTransaction transaction = m_rdispatch.CreateTransaction();
|
||||
|
||||
// Compose CAN_Output.LockDoor02Right
|
||||
uValueHelper.s32.u32.uiValue = static_cast<uint32_t>(std::min(std::max(static_cast<long long int>(m_sigLockDoor02Right.Read(transaction)), 0ll), 1ll));
|
||||
uValueHelper.uiUint64Value <<= 7;
|
||||
msg.seqData[0] |= uValueHelper.uiUint64Value & 0xff;
|
||||
|
||||
// Compose CAN_Output.LockDoor02Left
|
||||
uValueHelper.s32.u32.uiValue = static_cast<uint32_t>(std::min(std::max(static_cast<long long int>(m_sigLockDoor02Left.Read(transaction)), 0ll), 1ll));
|
||||
uValueHelper.uiUint64Value <<= 5;
|
||||
msg.seqData[0] |= uValueHelper.uiUint64Value & 63;
|
||||
|
||||
// Compose CAN_Output.LockDoor01Right
|
||||
uValueHelper.s32.u32.uiValue = static_cast<uint32_t>(std::min(std::max(static_cast<long long int>(m_sigLockDoor01Right.Read(transaction)), 0ll), 1ll));
|
||||
uValueHelper.uiUint64Value <<= 3;
|
||||
msg.seqData[0] |= uValueHelper.uiUint64Value & 15;
|
||||
|
||||
// Compose CAN_Output.LockDoor01Left
|
||||
uValueHelper.s32.u32.uiValue = static_cast<uint32_t>(std::min(std::max(static_cast<long long int>(m_sigLockDoor01Left.Read(transaction)), 0ll), 1ll));
|
||||
uValueHelper.uiUint64Value <<= 1;
|
||||
msg.seqData[0] |= uValueHelper.uiUint64Value & 3;
|
||||
|
||||
// Finalize the transaction
|
||||
transaction.Finish();
|
||||
|
||||
// Transmit the message
|
||||
// TODO: Determine CAN interface index...
|
||||
m_pSend->Send(msg, 0);
|
||||
}
|
||||
|
||||
300
examples/door_demo_example/can_dl_door/datalink.h
Normal file
300
examples/door_demo_example/can_dl_door/datalink.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/**
|
||||
* @file datalink.h
|
||||
* @date 2025-09-06 08:00:37
|
||||
* This file defines the data link object between CAN and the V-API devices.
|
||||
* This file was generated by the DBC utility from:
|
||||
* "", "datalink_4doors_example.dbc"
|
||||
* DBC file version: 1.0.0.1
|
||||
*/
|
||||
#ifndef __DBC_GENERATED__DATALINK_H__20250906_080037_856__
|
||||
#define __DBC_GENERATED__DATALINK_H__20250906_080037_856__
|
||||
|
||||
#include <support/component_impl.h>
|
||||
#include <interfaces/can.h>
|
||||
#include <support/interface_ptr.h>
|
||||
#include <support/signal_support.h>
|
||||
|
||||
/**
|
||||
* @brief Data link class.
|
||||
*/
|
||||
class CDataLink : public sdv::CSdvObject, public sdv::IObjectControl, public sdv::can::IReceive
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*/
|
||||
CDataLink();
|
||||
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
~CDataLink();
|
||||
|
||||
// Interface map
|
||||
BEGIN_SDV_INTERFACE_MAP()
|
||||
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
|
||||
SDV_INTERFACE_ENTRY(sdv::can::IReceive)
|
||||
END_SDV_INTERFACE_MAP()
|
||||
|
||||
// Declarations
|
||||
DECLARE_OBJECT_CLASS_TYPE(sdv::EObjectType::Device)
|
||||
DECLARE_OBJECT_CLASS_NAME("CAN_data_link")
|
||||
DECLARE_DEFAULT_OBJECT_NAME("DataLink")
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Get the current status of the object. Overload of sdv::IObjectControl::GetStatus.
|
||||
* @return Return the current status of the object.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Process a receive a CAN message. Overload of sdv::can::IReceive::Receive.
|
||||
* @param[in] sMsg Message that was received.
|
||||
* @param[in] uiIfcIndex Interface index of the received message.
|
||||
*/
|
||||
virtual void Receive(/*in*/ const sdv::can::SMessage& sMsg, /*in*/ uint32_t uiIfcIndex) override;
|
||||
|
||||
/**
|
||||
* @brief Process an error frame. Overload of sdv::can::IReceive::Error.
|
||||
* @param[in] sError Error frame that was received.
|
||||
* @param[in] uiIfcIndex Interface index of the received message.
|
||||
*/
|
||||
virtual void Error(/*in*/ const sdv::can::SErrorFrame& sError, /*in*/ uint32_t uiIfcIndex) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Union containing all the compound values needed to convert between the DBC defined types.
|
||||
*/
|
||||
union UValueHelper
|
||||
{
|
||||
uint64_t uiUint64Value; ///< The 64-bit unsingned value.
|
||||
int64_t iInt64Value; ///< The 64-bit signed value.
|
||||
|
||||
/**
|
||||
* @brief The structure mapping the 32-bit value types into the 64-bit.
|
||||
*/
|
||||
struct S32
|
||||
{
|
||||
#if (!defined(_MSC_VER) || defined(__clang__)) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
uint32_t uiPadding; ///< Padding for big endian byte ordering (MSB)
|
||||
#endif
|
||||
/**
|
||||
* @brief The 32-bit union containing the possible 32-bit values.
|
||||
*/
|
||||
union U32Value
|
||||
{
|
||||
int32_t iValue; ///< 32-bit signed integer.
|
||||
uint32_t uiValue; ///< 32-bit unsigned integer.
|
||||
float fValue; ///< 32-bit floating point number.
|
||||
} u32; ///< 32-bit union instance.
|
||||
|
||||
#if (defined(_MSC_VER) && !defined(__clang__)) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
uint32_t uiPadding; ///< Padding for little endian byte ordering (MSB)
|
||||
#endif
|
||||
} s32;
|
||||
|
||||
double dValue; ///< 64-bit double precision floating point number.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief RX CAN message definition of: CAN_Input_L1 [id=1]
|
||||
*/
|
||||
struct SRxMsg_CAN_Input_L1
|
||||
{
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] rdispatch Reference to the dispatch service.
|
||||
*/
|
||||
SRxMsg_CAN_Input_L1(sdv::core::CDispatchService& rdispatch);
|
||||
|
||||
/**
|
||||
* @brief Initialize the message by registering all signals.
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* @brief Terminate the message by unregistering all signals.
|
||||
*/
|
||||
void Term();
|
||||
|
||||
/**
|
||||
* @brief Process received data.
|
||||
* @param[in] rseqData Reference to the message data to process.
|
||||
*/
|
||||
void Process(const sdv::sequence<uint8_t>& rseqData);
|
||||
|
||||
sdv::core::CDispatchService& m_rdispatch; ///< Reference to the dispatch service.
|
||||
|
||||
/// Signal Door01LeftIsOpen with unit
|
||||
sdv::core::CSignal m_sigDoor01LeftIsOpen;
|
||||
} m_sRxMsgCAN_Input_L1;
|
||||
|
||||
/**
|
||||
* @brief RX CAN message definition of: CAN_Input_R1 [id=2]
|
||||
*/
|
||||
struct SRxMsg_CAN_Input_R1
|
||||
{
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] rdispatch Reference to the dispatch service.
|
||||
*/
|
||||
SRxMsg_CAN_Input_R1(sdv::core::CDispatchService& rdispatch);
|
||||
|
||||
/**
|
||||
* @brief Initialize the message by registering all signals.
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* @brief Terminate the message by unregistering all signals.
|
||||
*/
|
||||
void Term();
|
||||
|
||||
/**
|
||||
* @brief Process received data.
|
||||
* @param[in] rseqData Reference to the message data to process.
|
||||
*/
|
||||
void Process(const sdv::sequence<uint8_t>& rseqData);
|
||||
|
||||
sdv::core::CDispatchService& m_rdispatch; ///< Reference to the dispatch service.
|
||||
|
||||
/// Signal Door01RightIsOpen with unit
|
||||
sdv::core::CSignal m_sigDoor01RightIsOpen;
|
||||
} m_sRxMsgCAN_Input_R1;
|
||||
|
||||
/**
|
||||
* @brief RX CAN message definition of: CAN_Input_L2 [id=3]
|
||||
*/
|
||||
struct SRxMsg_CAN_Input_L2
|
||||
{
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] rdispatch Reference to the dispatch service.
|
||||
*/
|
||||
SRxMsg_CAN_Input_L2(sdv::core::CDispatchService& rdispatch);
|
||||
|
||||
/**
|
||||
* @brief Initialize the message by registering all signals.
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* @brief Terminate the message by unregistering all signals.
|
||||
*/
|
||||
void Term();
|
||||
|
||||
/**
|
||||
* @brief Process received data.
|
||||
* @param[in] rseqData Reference to the message data to process.
|
||||
*/
|
||||
void Process(const sdv::sequence<uint8_t>& rseqData);
|
||||
|
||||
sdv::core::CDispatchService& m_rdispatch; ///< Reference to the dispatch service.
|
||||
|
||||
/// Signal Door02LeftIsOpen with unit
|
||||
sdv::core::CSignal m_sigDoor02LeftIsOpen;
|
||||
} m_sRxMsgCAN_Input_L2;
|
||||
|
||||
/**
|
||||
* @brief RX CAN message definition of: CAN_Input_R2 [id=4]
|
||||
*/
|
||||
struct SRxMsg_CAN_Input_R2
|
||||
{
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] rdispatch Reference to the dispatch service.
|
||||
*/
|
||||
SRxMsg_CAN_Input_R2(sdv::core::CDispatchService& rdispatch);
|
||||
|
||||
/**
|
||||
* @brief Initialize the message by registering all signals.
|
||||
*/
|
||||
bool Init();
|
||||
|
||||
/**
|
||||
* @brief Terminate the message by unregistering all signals.
|
||||
*/
|
||||
void Term();
|
||||
|
||||
/**
|
||||
* @brief Process received data.
|
||||
* @param[in] rseqData Reference to the message data to process.
|
||||
*/
|
||||
void Process(const sdv::sequence<uint8_t>& rseqData);
|
||||
|
||||
sdv::core::CDispatchService& m_rdispatch; ///< Reference to the dispatch service.
|
||||
|
||||
/// Signal Door02RightIsOpen with unit
|
||||
sdv::core::CSignal m_sigDoor02RightIsOpen;
|
||||
} m_sRxMsgCAN_Input_R2;
|
||||
|
||||
/**
|
||||
* @brief TX CAN message definition of: CAN_Output [id=5]
|
||||
*/
|
||||
struct STxMsg_CAN_Output
|
||||
{
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] rdispatch Reference to the dispatch service.
|
||||
*/
|
||||
STxMsg_CAN_Output(sdv::core::CDispatchService& rdispatch);
|
||||
|
||||
/**
|
||||
* @brief Initialize the message by registering all signals.
|
||||
* @param[in] pSend The send-interface of the CAN.
|
||||
*/
|
||||
bool Init(sdv::can::ISend* pSend);
|
||||
|
||||
/**
|
||||
* @brief Terminate the message by unregistering all signals.
|
||||
*/
|
||||
void Term();
|
||||
|
||||
/**
|
||||
* @brief Transmit data.
|
||||
* @param[in] pCanSend Pointer to the CAN send interface.
|
||||
*/
|
||||
void Transmit();
|
||||
|
||||
sdv::core::CDispatchService& m_rdispatch; ///< Reference to the dispatch service.
|
||||
sdv::core::CTrigger m_trigger; ///< Message trigger being called by the dispatch service.
|
||||
sdv::can::ISend* m_pSend = nullptr; ///< Message sending interface.
|
||||
|
||||
/// Signal LockDoor02Right with unit
|
||||
sdv::core::CSignal m_sigLockDoor02Right;
|
||||
/// Signal LockDoor02Left with unit
|
||||
sdv::core::CSignal m_sigLockDoor02Left;
|
||||
/// Signal LockDoor01Right with unit
|
||||
sdv::core::CSignal m_sigLockDoor01Right;
|
||||
/// Signal LockDoor01Left with unit
|
||||
sdv::core::CSignal m_sigLockDoor01Left;
|
||||
} m_sTxMsgCAN_Output;
|
||||
|
||||
sdv::EObjectStatus m_eStatus = sdv::EObjectStatus::initialization_pending; ///< Keep track of the object status.
|
||||
size_t m_nIfcIndex = 0; ///< CAN Interface index.
|
||||
sdv::can::IRegisterReceiver* m_pRegister = nullptr; ///< CAN receiver registration interface.
|
||||
sdv::can::ISend* m_pSend = nullptr; ///< CAN sender interface.
|
||||
sdv::core::CDispatchService m_dispatch; ///< Dispatch service
|
||||
};
|
||||
|
||||
DEFINE_SDV_OBJECT(CDataLink)
|
||||
|
||||
#endif // !defined __DBC_GENERATED__DATALINK_H__20250906_080037_856__
|
||||
Reference in New Issue
Block a user