This tutorial shows how to create a simple filter that requests all signals from the XCP Master Filter for recording. After reading this guide, you will know:
Within the ADTF3 Guides, we have explained you how to generate your own projects, with the help of CMake. For configuring your project, generate and use listed files and follow the mentioned ADTF3 Guide:
After you have succesfully configured and generated your project, you can start to implement the filter.
signal_requester_filter.h
and add the filter definitions:
#pragma once
#include <adtffiltersdk/adtf_filtersdk.h>
#include <vector>
#include <string>
class cSignalRequesterFilter : public adtf::filter::cFilter
{
public:
ADTF_CLASS_ID_NAME(cSignalRequesterFilter, "tutorial_signal_requester.filter.calibtb.cid", "Tutorial Signal Requester Filter");
cSignalRequesterFilter();
private:
tResult HandleStreamType(const adtf::ucom::iobject_ptr<const adtf::streaming::IStreamType>& pType);
adtf::streaming::cExternalQueueSampleReader* m_pReader = nullptr;
std::vector<adtf::ucom::object_ptr<adtf::streaming::IStreamingRequest>> m_oRequests;
adtf::base::property_variable<std::string> m_strDaqEvent;
adtf::base::property_variable<tUInt16> m_ui16DaqPrescaler = 1;
adtf::base::property_variable<tTimeStamp> m_tmPollingInterval = 0;
adtf::base::property_variable<tBool> m_bRequestRawValues = tFalse;
};
signal_requester_filter.cpp
and add the method implementations:
#include "tutorial_signal_requester_filter.h"
#include <xcpsupport/stream_meta_type_xcp.h>
ADTF_PLUGIN_VERSION("Signal Requester Filter",
calibtb,
CALIBTB_VERSION_MAJOR,
CALIBTB_VERSION_MINOR,
CALIBTB_VERSION_PATCH,
cSignalRequesterFilter)
using namespace adtf::util;
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
cSignalRequesterFilter::cSignalRequesterFilter()
{
// set the plugindescription
SetDescription("Use this filter to request all XCP signals from an A2L file. "\
"All signals are requested with a corresponding" \
" * DAQ 'or'" \
" * Polling Interval");
m_strDaqEvent.SetDescription("DAQ Event as String, e.g. '100ms'");
RegisterPropertyVariable("DAQ Event", m_strDaqEvent);
m_ui16DaqPrescaler.SetDescription("DAQ Prescaler as Integer");
RegisterPropertyVariable("DAQ Prescaler", m_ui16DaqPrescaler);
m_tmPollingInterval.SetDescription("Polling Intervall as Integer");
RegisterPropertyVariable("Polling Interval", m_tmPollingInterval);
// cExternalQueueSampleReader without a queue wil simply discard everything
m_pReader = CreateInputPin<cExternalQueueSampleReader>("signals", adtf::streaming::stream_meta_type_substreams());
m_pReader->SetSynchronousTypeUpdateCallback(std::bind(&cSignalRequesterFilter::HandleStreamType, this, std::placeholders::_1));
}
tResult cSignalRequesterFilter::HandleStreamType(const adtf::ucom::iobject_ptr<const adtf::streaming::IStreamType>& pType)
{
// first we clear all ongoing requests
m_oRequests.clear();
cProperties oRequestProperties;
if (!m_strDaqEvent->empty())
{
auto nDaqEventId = adtf::calibtb::stream_meta_type_xcp_signal_values::GetDaqEventId(*pType.Get(), m_strDaqEvent->c_str());
set_property(oRequestProperties, adtf::calibtb::stream_meta_type_xcp_signal_values::DaqEventId, nDaqEventId);
set_property(oRequestProperties, adtf::calibtb::stream_meta_type_xcp_signal_values::DaqPrescaler, *m_ui16DaqPrescaler);
}
else
{
set_property(oRequestProperties, adtf::calibtb::stream_meta_type_xcp_signal_values::PollingInterval, *m_tmPollingInterval);
}
//and then request samples from all substreams
stream_meta_type_substreams::ListSubStreams(*pType.Get(), [&](const tChar* strName, tUInt32 nSubStreamId)
{
if (!m_bRequestRawValues && std::string(strName).find("raw.") == 0)
{
return;
}
object_ptr<IStreamingRequest> pRequest;
THROW_IF_FAILED(m_pReader->RequestSamples(pRequest, nSubStreamId, &oRequestProperties));
// we store the request object for as long as we want those samples.
m_oRequests.push_back(pRequest);
});
RETURN_NOERROR;
}
signal_requester_filter.adtfplugin
signal_requester_filter.plugindescription
. This file contains a XML based description
of all the features our new filter has. The Configuration Editor needs this file to show our new filter in the "Components" view.
We generate the plugin description file by building the project called "INSTALL" with Visual Studio.
tutorial_signal_requester_filter.plugindescription
file.
If the file resides in a folder the Configuration Editor does not know of, tell the Configuration Editor
to look there by extending the settings (Plugin Directories). If the Configuration Editor was already running,
restart the application, so changes can take effect.
Congratulations! You can now 'drag & drop' the 'Signal Requester Filter' into the filter graph.
Purpose of this filter is the recording of all 'MEASUREMENT' signals which are defined within an A2L file. The corresponding A2L file has to be set up within the properties of the XCP Master Filter.
Advantage of this filter:
The calibrationtoolbox.adtfproject
example contains a DEMO Signal Requester Filter
session, which will show the usage of the generated filter.
The Signal Requester Filter
only has to be connected to the xcp_master
"signal_updates" pin of the XCP Master.
Before running the session, you have to decide on which measurment method the XCP signals should requested from the ECU.
This properties can be found in the property browser of the Signal Requester Filter
:
Property | Type | Default | Description |
---|---|---|---|
DAQ Event | String | " " | Defines the DAQ event channel |
DAQ Prescaler | Integer | 1 | Transmission rate prescaler (=>1) |
Polling Interval | Integer | 0 | Defines the polling interval |
After setting up the necessary measurement method, you are able to start the session. The running Signal Requester Filter
will immediately run over all 'MEASUREMENT' signals
and the XCP Master
will request this signals from the ECU. The received 'undecoded' signal will then be recorded by the
ADTFDAT File Recorder.
The complete communication between the XCP Master and the ECU can be played back with the
ADTFDAT File Player.
We recomment not to decode the signal values while recording the XCP communication.