#include "demo_flexray_encoder.h"
#include <adtf_mediadescription.h>
#include <cstring>
#include <string>
ADTF_PLUGIN_VERSION("Demo FlexRay Encoder",
devicetb,
DEVICETB_VERSION_MAJOR,
DEVICETB_VERSION_MINOR,
DEVICETB_VERSION_PATCH,
cDDL2FlexRayFilter)
cDDL2FlexRayFilter::cDDL2FlexRayFilter()
{
CreateInputPin("input_ddl", mediadescription::description<input_ddl>());
SetDescription("input_ddl", "The incoming FlexRay content to encode.");
SetDescription("output_flexray", "The encoded FlexRay sample stream.");
m_nChannelID.SetDescription("Channel-ID for the desired FlexRay database, made available by FlexRay service");
m_nChannelID.SetValidRange(FLEXRAY_DEVICECHANNEL_MIN, FLEXRAY_DEVICECHANNEL_MIN);
RegisterPropertyVariable("ChannelID", m_nChannelID);
SetDescription("Use this filter to encode FlexRay data for specific signals.");
SetHelpLink("$(ADTF_DEVICE_TOOLBOX_DIR)/doc/adtf_device_toolbox_html/page_example_source_flexray_config_encoder.html");
}
tResult cDDL2FlexRayFilter::Init(filter::cFilter::tInitStage eStage)
{
if (filter::cFilter::tInitStage::StageNormal == eStage)
{
RETURN_IF_FAILED(_runtime->GetObject(m_pFlexRaySupport));
RETURN_IF_FAILED(m_pFlexRaySupport->CreateCoder(m_pFlexRayDatabase, m_pFlexRayCoder));
}
RETURN_NOERROR;
}
tResult cDDL2FlexRayFilter::AcceptType(streaming::ISampleReader* ,
const ucom::iobject_ptr<const streaming::IStreamType>& pType)
{
m_oSampleDataFactory = mediadescription::md_sample_data_factory<input_ddl>(pType);
RETURN_NOERROR;
}
tResult cDDL2FlexRayFilter::ProcessInput(streaming::ISampleReader* ,
const ucom::iobject_ptr<const streaming::ISample>& pSample)
{
auto oSampleData = m_oSampleDataFactory.Make(pSample);
RETURN_IF_FAILED(m_pFlexRayDatabase->GetSignalID("Signal_3", &oSignalId));
oValue.nf64Value = oSampleData.Signal_3();
RETURN_IF_FAILED(m_pFlexRayCoder->SetSignalValue(oSignalId, &oValue));
RETURN_IF_FAILED(m_pFlexRayDatabase->GetSignalID("Signal_4", &oSignalId));
oValue.nf64Value = oSampleData.Signal_4();
RETURN_IF_FAILED(m_pFlexRayCoder->SetSignalValue(oSignalId, &oValue));
RETURN_IF_FAILED(m_pFlexRayDatabase->GetSignalID("Signal_5", &oSignalId));
oValue.nf64Value = oSampleData.Signal_5();
RETURN_IF_FAILED(m_pFlexRayCoder->SetSignalValue(oSignalId, &oValue));
tInt nSampleSize = 0;
RETURN_IF_FAILED(m_pFlexRayCoder->TransmitData(nullptr, &nSampleSize));
ucom::object_ptr<streaming::ISample> pOutputSample;
ucom::object_ptr_locked<streaming::ISampleBuffer> pBuffer;
RETURN_IF_FAILED(alloc_sample(pOutputSample, pSample->GetTime()));
RETURN_IF_FAILED(pOutputSample->WriteLock(pBuffer, nSampleSize));
RETURN_IF_FAILED(m_pFlexRayCoder->TransmitData(pBuffer->GetPtr(), &nSampleSize));
pBuffer->Unlock();
m_pFlexRayCoder->ResetData();
m_pWriter->Write(pOutputSample);
RETURN_NOERROR;
}
Copyright 2024 CARIAD SE.
axle::tChannelID tChannelID
FlexRay Cluster and Channel ID (FLEXRAY_CHANNEL_A, FLEXRAY_CHANNEL_B, FLEXRAY_CHANNEL_AB).
axle::tSignalValue tSignalValue
Signal value structure.
axle::tSignalID tSignalID
FlexRay signal ID.
axle::stream_meta_type_flexray stream_meta_type_flexray
Definition of Stream Meta Type FlexRay Messages.