#include "stdafx.h"
#include "demo_signal_listener_service.h"
#include <cinttypes>
cDemoSignalListener);
class cSignalDumper: public ISignalListening::ISignalListener
{
public:
cSignalDumper(const char* strSignalName):
m_strSignalName(strSignalName)
{
}
public:
virtual void SignalUpdated(ISignalRegistry::tSignalID , const ISignalRegistry::tSignalValueNs& sValue) override
{
LOG_INFO(
"%s @ %" PRIi64
": %f", m_strSignalName.GetPtr(), sValue.nTimeStamp.nCount, sValue.f64Value);
}
private:
};
cDemoSignalListener::cDemoSignalListener()
{
SetDescription("Use this System Service to print signal updates (e.g. send by 'Demo Signal Provider', see Filters.");
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_signal_listener.html");
}
tResult cDemoSignalListener::ServiceInit()
{
}
tResult cDemoSignalListener::ServiceShutdown()
{
for (auto& oDumper: m_oDumper)
{
m_pSignalListening->CancelSignalUpdates(oDumper.first, *oDumper.second.get());
}
m_pSignalListening.Reset();
}
void cDemoSignalListener::SignalAdded(const ISignalRegistry::tSignalAttributes& sSignalAttributes)
{
std::unique_ptr<cSignalDumper> pDumper(new cSignalDumper(sSignalAttributes.strName));
if (
IS_OK(m_pSignalListening->RequestSignalUpdates(sSignalAttributes.nSignalID, *pDumper.get())))
{
m_oDumper.emplace(sSignalAttributes.nSignalID, std::move(pDumper));
}
}
void cDemoSignalListener::SignalRemoved(const ISignalRegistry::tSignalAttributes& sSignalAttributes)
{
m_oDumper.erase(sSignalAttributes.nSignalID);
}
#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_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define IS_OK(s)
Check if result is OK.
virtual tResult GetObject(iobject_ptr< IObject > &pObject, const char *strNameOID) const =0
Get registered object from object registry.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
@ RL_Session
The session level.
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.