#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/adtf_html/page_demo_custom_stream_type_filters.html");
}
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),
get_property<double>(*pType.Get(), stream_meta_type_mounted_sensor::SensorMountY),
get_property<double>(*pType.Get(), stream_meta_type_mounted_sensor::SensorMountZ) };
}
}
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",
sample_data<tSensorData>(pSample)->fDistance);
}
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,
sample_data<tSensorData>(pSample)->fDistance);
}
else if (pReader == m_pSensorAReader)
{
LOG_INFO(
"received a distance reading from sensor A: %f",
sample_data<tSensorData>(pSample)->fDistance);
}
else if (pReader == m_pSensorBReader)
{
LOG_INFO(
"received a distance reading from sensor B: %f",
sample_data<tSensorData>(pSample)->fDistance);
}
}
#define LOG_INFO(...)
Logs an info message.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.