Shows how to implement a filter which is triggered by a Thread Runner.
#pragma once
#include <condition_variable>
#include <mutex>
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
{
public:
"demo_thread_trigger.filter" ADTF_EXAMPLES_CID,
"Demo Thread Trigger");
public:
cAsynchronousDataPrinter();
~cAsynchronousDataPrinter() override;
private:
private:
std::mutex m_oSamplesAvailableMutex;
std::condition_variable m_oSamplesAvailable;
size_t m_nSampleCounter = 0;
};
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Definition class_id.h:33
virtual tResult ProcessInput(base::flash::tNanoSeconds tmTrigger, streaming::flash::ISampleReader *pReader)
Definition samplestreamer_intf.h:188
A timestamp with nanosecond precision.
Definition chrono.h:23
#include "demo_thread_trigger_function.h"
using namespace adtf::util;
ADTF_PLUGIN(
"Demo Thread Trigger Plugin", cAsynchronousDataPrinter);
cAsynchronousDataPrinter::cAsynchronousDataPrinter()
{
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_trigger.html");
}
cAsynchronousDataPrinter::~cAsynchronousDataPrinter() = default;
{
m_oSamplesAvailable.notify_all();
}
tResult cAsynchronousDataPrinter::PrintData()
{
std::unique_lock<std::mutex> oGuard(m_oSamplesAvailableMutex);
if (m_oSamplesAvailable.wait_for(oGuard, std::chrono::milliseconds(10), [&]
{
return IS_OK(m_pReader->GetNextSample(pSample));
}))
{
LOG_INFO(
"value number %" PRIuPTR
": %f", ++m_nSampleCounter, fValue);
}
}
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition sample_data.h:429
Generator template to create an instance of a ant::IStreamType class for penguin::stream_meta_type_pl...
Definition streammetatypeplain.h:315
Definition object_ptr.h:384
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
definition of the ddl namespace
Definition codec.h:21