Go to the documentation of this file. 1 #ifndef RTCTK_EXAMPLEDATATASK_BUSINESSLOGIC_GPU_HPP
2 #define RTCTK_EXAMPLEDATATASK_BUSINESSLOGIC_GPU_HPP
11 #include <ipcq/reader.hpp>
20 using namespace std::chrono_literals;
25 template <
class ComputationType,
class TopicType>
28 using ReaderType = ipcq::Reader<TopicType>;
36 LOG4CPLUS_DEBUG(
GetLogger(),
"ExampleDataTask c'tor");
41 LOG4CPLUS_INFO(
GetLogger(),
"ExampleDataTask d'tor");
48 m_computation.reset();
58 m_computation = std::make_unique<ComputationType>(m_rtr, m_oldb, m_name);
59 m_reader = std::make_unique<ReaderThread<TopicType,ReaderType>>();
62 m_reader->RegisterOnDataCallback( [
this] (
const TopicType& sample) {m_computation->OnDataAvailable(sample);});
63 m_reader->RegisterInitThreadCallback([
this](){m_computation->ThreadInit();});
66 m_reader->SetQueueName(GetParam<std::string>(
"/common/static/loop_1/queue_name"));
67 m_reader->SetCpuAffinity(GetParam<int32_t>(
"/" + m_name +
"/static/reader_thread/cpu_affinity"));
68 m_reader->SetLoopFrequency(GetParam<int32_t>(
"/common/static/loop_1/frequency"));
71 m_reader->SetSamplesToRead(GetParam<int32_t>(
"/" + m_name +
"/static/common/samples_to_read"));
72 m_reader->SetSamplesToSkip(GetParam<int32_t>(
"/" + m_name +
"/dynamic/reader_thread/samples_to_skip"));
87 m_computation->Reset();
101 if(st.StopRequested()){
break;}
103 m_reader->WaitUntilComputationAllowed();
105 if(st.StopRequested()){
break;}
107 m_computation->Compute();
109 m_reader->SignalComputationDone();
112 m_reader->SignalComputationDone();
117 m_reader->SetSamplesToSkip(GetParam<int32_t>(
"/" + m_name +
"/dynamic/reader_thread/samples_to_skip"));
118 m_computation->DynamicLoad();
124 if(m_computation->isComputing())
140 auto value = m_rtr.GetDataPoint<T>(dp_uri);
148 std::unique_ptr<ReaderThread<TopicType,ReaderType>>
m_reader;
A container that can hold any type of service.
Empty implementation for the RunnableStateMachineLogicIf.
std::unique_ptr< ComputationType > m_computation
Definition: businessLogicGpu.hpp:147
BusinessLogicGpu(const std::string &name, rtctk::componentFramework::ServiceContainer &services)
Definition: businessLogicGpu.hpp:31
Definition: businessLogicGpu.hpp:27
virtual ~BusinessLogicGpu()
Definition: businessLogicGpu.hpp:39
RuntimeRepoApiIf & m_rtr
Definition: businessLogicGpu.hpp:144
void Initialising(StopToken st) override
Definition: businessLogicGpu.hpp:55
Definition: rtcComponent.hpp:17
Header file for OldbApiIf, which defines the API for OldbAdapters.
string path
Definition: rtctkExampleDataTaskRobotTest.py:228
bool IsUpdatingAllowed(Payload args) override
Definition: businessLogicGpu.hpp:122
rad::StopToken StopToken
Definition: stopToken.hpp:16
void Disabling(StopToken st) override
Definition: businessLogicGpu.hpp:80
void Starting(StopToken st) override
Definition: businessLogicGpu.hpp:45
log4cplus::Logger & GetLogger(const std::string &name="")
Definition: oldbApiIf.hpp:18
std::string Payload
Definition: runnableStateMachineLogicIf.hpp:17
Definition: serviceContainer.hpp:31
Definition: businessLogic.hpp:22
void Recovering(StopToken st) override
Definition: businessLogicGpu.hpp:51
Definition: runtimeRepoApiIf.hpp:59
void GoingRunning(StopToken st) override
Definition: businessLogicGpu.hpp:85
OldbApiIf & m_oldb
Definition: businessLogicGpu.hpp:145
Definition: messageQueue.hpp:17
Header file for RuntimeRepoApiIf, which defines the API for RuntimeRepoAdapters.
Logging Support Library based on log4cplus.
void GoingIdle(StopToken st) override
Definition: businessLogicGpu.hpp:91
Definition: runnableStateMachineLogic.hpp:28
Definition: dataPointPath.hpp:30
void Enabling(StopToken st) override
Definition: businessLogicGpu.hpp:75
void Running(StopToken st) override
Definition: businessLogicGpu.hpp:96
T GetParam(std::string const &path)
Definition: businessLogicGpu.hpp:137
void Updating(StopToken st, Payload args) override
Definition: businessLogicGpu.hpp:115
std::unique_ptr< ReaderThread< TopicType, ReaderType > > m_reader
Definition: businessLogicGpu.hpp:148