#include "demo_thread_trigger_function.h"
ADTF_PLUGIN(
"Demo Thread Trigger Plugin", cAsynchronousDataPrinter);
cAsynchronousDataPrinter::cAsynchronousDataPrinter()
{
m_pReader = CreateInputPin("in", stream_type_plain<float>(), true);
SetDescription("in", "Input value for printing");
CreateRunner("print_data",
std::bind(&cAsynchronousDataPrinter::PrintData, this),
cThreadTriggerHint());
SetDescription("print_data", "Runner to cyclically trigger the function which prints the data");
SetDescription("Use this filter to print asynchronously the received values with a defined Thread Runner.");
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_thread_triggered_filter.html");
}
tResult cAsynchronousDataPrinter::ProcessInput(tNanoSeconds ,
ISampleReader* )
{
m_oSamplesAvailable.notify_all();
}
tResult cAsynchronousDataPrinter::PrintData()
{
object_ptr<const ISample> pSample;
std::unique_lock<std::mutex> oGuard(m_oSamplesAvailableMutex);
{
return IS_OK(m_pReader->GetNextSample(pSample));
}))
{
float fValue = sample_data<float>(pSample);
LOG_INFO(
"value number %ld: %f", ++m_nSampleCounter, fValue);
}
}
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
#define LOG_INFO(...)
Logs an info message.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
std::chrono::milliseconds milliseconds
Compatibility to C++11 std::chrono::milliseconds