Description
Shows how to create own stream meta types.
Prebuilt Binaries
Source Code
./examples/demo_adtfplugins/demo_custom_stream_type/
Common
sensor_data.h
#pragma once
struct tSensorData
{
double fDistance;
};
{
Add("fDistance", &tSensorData::fDistance);
}
Stream Types
stream_type_custom_sensor.h
#pragma once
#include "sensor_data.h"
struct stream_meta_type_custom_sensor
{
static constexpr const tChar* const MetaTypeName = "demo/custom_sensor";
static constexpr const tChar* const SensorType = "sensor_type";
{
}
{
if (strSourceSensorType != strDestSensorType)
{
"The required destination sensor type '%s' differs from the source sensor type '%s'",
strSourceSensorType.GetPtr(),
strDestSensorType.GetPtr());
}
}
};
{
stream_type_custom_sensor() = default;
stream_type_custom_sensor(const char* strSensorType)
{
stream_meta_type_custom_sensor::SensorType,
strSensorType);
}
};
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
Definition result.h:44
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Defines access methods for the interface of a Stream Type.
Definition streamtype_intf.h:96
Definition streamtype.h:368
virtual T * Get() const =0
Get raw pointer to shared object.
tResult set_property(IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oValue)
Set the property.
Definition configuration.h:327
VALUETYPE get_property(const IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oDefaultValue)
Definition streamtype_intf.h:287
tResult set_property(IStreamType &oStreamType, const char *strNameOfValue, VALUETYPE oValue)
Definition streamtype_intf.h:257
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
stream_type_mounted_sensor.h
#pragma once
#include "sensor_data.h"
struct stream_meta_type_mounted_sensor
{
static constexpr const tChar* const MetaTypeName = "demo/mounted_sensor";
static constexpr const tChar* const SensorMountX = "sensor_mount_x";
static constexpr const tChar* const SensorMountY = "sensor_mount_y";
static constexpr const tChar* const SensorMountZ = "sensor_mount_z";
{
}
};
{
stream_type_mounted_sensor() = default;
stream_type_mounted_sensor(double fMountX,
double fMountY,
double fMountZ)
{
}
};
stream_type_raw.h
#pragma once
struct stream_meta_type_raw_data_that_only_i_understand
{
static constexpr const tChar* const MetaTypeName = "demo/raw_data_that_only_i_understand";
};
stream_type_raw_with_properties.h
#pragma once
struct stream_meta_type_raw_data_with_properties
{
static constexpr const tChar* const MetaTypeName = "demo/raw_data_with_properties";
static constexpr const tChar* const MyProperty = "my_property";
{
}
};
{
stream_type_raw_data_with_properties() = default;
stream_type_raw_data_with_properties(int nMyProperty)
{
}
};
Access
demo_custom_stream_type_access_filter.h
#pragma once
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_custom_stream_types_access.filter" ADTF_EXAMPLES_CID,
"Demo Custom Stream Types Data Access");
cCustomStreamTypesDataAccess();
~cCustomStreamTypesDataAccess() override;
private:
int32_t m_nCurrentMyPropertyValue = 0;
struct tSensorMountPosition
{
double fX;
double fY;
double fZ;
};
tSensorMountPosition m_sSensorMountPosition;
};
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
virtual tResult ProcessInput(base::flash::tNanoSeconds tmTrigger, streaming::flash::ISampleReader *pReader)
virtual tResult AcceptType(streaming::flash::ISampleReader *pReader, const ucom::ant::iobject_ptr< const streaming::ant::IStreamType > &pType)
Definition samplestreamer_intf.h:188
demo_custom_stream_type_access_filter.cpp
#include "demo_custom_stream_type_access_filter.h"
#include "stream_type_raw.h"
#include "stream_type_raw_with_properties.h"
#include "stream_type_mounted_sensor.h"
#include "stream_type_custom_sensor.h"
#include "sensor_data.h"
cCustomStreamTypesDataAccess::cCustomStreamTypesDataAccess()
{
m_pRawDataReader = CreateInputPin("raw", stream_meta_type_raw_data_that_only_i_understand());
SetDescription("raw", "Input data based on raw stream type");
m_pRawDataWithPropertyReader = CreateInputPin("raw_with_property", stream_type_raw_data_with_properties());
SetDescription("raw_with_property", "Input data based on a raw stream type with setted property");
m_pUnspecifiedSensorReader = CreateInputPin("unspecified_sensor", get_sensor_data_type_definition());
SetDescription("unspecified_sensor", "Input data for an unspecified sensor");
m_pMountedSensorReader = CreateInputPin("mounted_sensor", stream_type_mounted_sensor());
SetDescription("mounted_sensor", "Input data compatible with a specified mounted_sensor");
m_pSensorAReader = CreateInputPin("sensor_a", stream_type_custom_sensor("SensorA"));
SetDescription("sensor_a", "Input data compatible with a specified Sensor A");
m_pSensorBReader = CreateInputPin("sensor_b", stream_type_custom_sensor("SensorB"));
SetDescription("sensor_b", "Input data compatible with a specified Sensor B");
SetDescription("Use this filter to print received streaming data based on several custom stream types.");
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_custom_stream_types_data_access.html");
}
cCustomStreamTypesDataAccess::~cCustomStreamTypesDataAccess() = default;
tResult cCustomStreamTypesDataAccess::AcceptType(
ISampleReader* pReader,
const iobject_ptr<const IStreamType>& pType)
{
if (pReader == m_pRawDataWithPropertyReader)
{
m_nCurrentMyPropertyValue =
get_property<int>(*pType.Get(), stream_meta_type_raw_data_with_properties::MyProperty);
}
else if (pReader == m_pMountedSensorReader)
{
m_sSensorMountPosition = {
get_property<double>(*pType.Get(), stream_meta_type_mounted_sensor::SensorMountX),
}
}
tResult cCustomStreamTypesDataAccess::ProcessInput(
ISampleReader* pReader,
const iobject_ptr<const ISample>& pSample)
{
if (pReader == m_pRawDataReader)
{
}
else if (pReader == m_pRawDataWithPropertyReader)
{
LOG_INFO(
"received a raw sample, my_property is currently %d", m_nCurrentMyPropertyValue);
}
else if (pReader == m_pUnspecifiedSensorReader)
{
LOG_INFO(
"received a distance reading from unspecified sensor: %f",
}
else if (pReader == m_pMountedSensorReader)
{
LOG_INFO(
"received a distance reading from sensor mounted at (%f, %f, %f): %f",
m_sSensorMountPosition.fX,
m_sSensorMountPosition.fY,
m_sSensorMountPosition.fZ,
}
else if (pReader == m_pSensorAReader)
{
LOG_INFO(
"received a distance reading from sensor A: %f",
}
else if (pReader == m_pSensorBReader)
{
LOG_INFO(
"received a distance reading from sensor B: %f",
}
}
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
Definition sample_data.h:429
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
VALUETYPE get_property(const IConfiguration &oConfiguration, const char *strNameOfValue, VALUETYPE oDefaultValue)
Get the property content converted to the VALUETYPE.
Definition configuration.h:291
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Generator
demo_custom_stream_type_generator_filter.h
#pragma once
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_custom_stream_types_generator.filter" ADTF_EXAMPLES_CID,
"Demo Custom Stream Types Data Generator");
cCustomStreamTypesDataGenerator();
~cCustomStreamTypesDataGenerator() override;
private:
};
virtual tResult Process(base::flash::tNanoSeconds tmTrigger, streaming::ant::IRunner *pRunner)
Definition runner_intf.h:24
Definition samplestreamer_intf.h:234
A timestamp with nanosecond precision.
Definition chrono.h:23
demo_custom_stream_type_generator_filter.cpp
#include "demo_custom_stream_type_generator_filter.h"
#include "stream_type_raw.h"
#include "stream_type_raw_with_properties.h"
#include "stream_type_mounted_sensor.h"
#include "stream_type_custom_sensor.h"
cCustomStreamTypesDataGenerator::cCustomStreamTypesDataGenerator()
{
m_pRawDataWriter = CreateOutputPin("raw", stream_meta_type_raw_data_that_only_i_understand());
SetDescription("raw", "Provides data compatible with raw stream type");
m_pRawDataWithPropertyWriter = CreateOutputPin("raw_with_property", stream_type_raw_data_with_properties(42));
SetDescription("raw_with_property", "Provides data compatible with raw stream type with setted property");
m_pMountedSensorWriter = CreateOutputPin("mounted_sensor", stream_type_mounted_sensor(1.0, 2.0, 3.0));
SetDescription("mounted_sensor", "Provides data compatible with mounted_sensor");
m_pSensorAWriter = CreateOutputPin("sensor_a", stream_type_custom_sensor("SensorA"));
SetDescription("sensor_a", "Provides data compatible with Sensor A");
m_pSensorBWriter = CreateOutputPin("sensor_b", stream_type_custom_sensor("SensorB"));
SetDescription("sensor_b", "Provides data compatible with Sensor B");
CreateRunner("generate_data", cTimerTriggerHint(std::chrono::seconds{1}));
SetDescription("generate_data", "Runner to periodically trigger the function which generates the output samples");
SetDescription("Use this filter to generate data based on several custom stream types.");
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_custom_stream_types_data_generator.html");
}
cCustomStreamTypesDataGenerator::~cCustomStreamTypesDataGenerator() = default;
{
m_pRawDataWriter->Write(oRawData.Release());
m_pRawDataWithPropertyWriter->Write(oRawDataWithProperty.Release());
m_pMountedSensorWriter->Write(oMountedSensorData.Release());
m_pSensorAWriter->Write(oSensorAData.Release());
m_pSensorBWriter->Write(oSensorBData.Release());
}
Plugin
plugin.cpp
#include "demo_string_sending_filter.h"
#include "demo_string_receiving_filter.h"
cDemoStringSending,
cDemoStringReceiving);
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29