RTC Toolkit 5.1.0
Loading...
Searching...
No Matches
computation.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP
14#define RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP
15
18
21
22#include <chrono>
23#include <mutex>
24#include <optional>
25#include <vector>
26
27namespace rtctk::exampleDataTask {
28
29// the type of the shm supertopic
31
32// type of the user-owned sample buffer
33using BufferType = std::vector<decltype(decltype(TopicType::wfs)::slopes)>;
34
35class Computation : public dataTask::ComputationBase<TopicType> {
36public:
38
39 template <typename T>
41
42 struct Result {
43 std::vector<float> avg_slopes;
44 std::vector<float> avg_modes;
45 };
46
47 struct ResultIf {
48 virtual ~ResultIf() = default;
49 virtual void OnResultAvailable(const Result& result) = 0;
50 };
51
54 const std::string& shm_name,
55 size_t to_read,
56 size_t to_skip,
57 std::chrono::milliseconds sample_timeout,
58 std::optional<numapp::NumaPolicies> thread_policies,
59 size_t n_slopes,
60 size_t n_modes);
61
63
65
66private:
67 void CopyData(size_t sample_idx, const TopicType& sample) noexcept override;
68
69 void Compute() override;
70
71 void Publish() override;
72
73 ResultIf& m_publisher;
74 size_t m_slopes;
75 size_t m_modes;
76 std::mutex m_mutex; // protects m_s2m_matrix from concurrent access
77 MatrixBuffer<float> m_s2m_matrix;
78 BufferType m_sample_buffer;
79 Result m_result;
80};
81
82} // namespace rtctk::exampleDataTask
83
84#endif // RTCTK_EXAMPLEDATATASK_COMPUTATION_HPP
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:28
Container class that holds services of any type.
Definition serviceContainer.hpp:39
void SetSlopesToModesMatrix(MatrixBuffer< float > &&s2m_matrix)
Computation()
Definition computation.hpp:39
Base class for Data Task computations.
Declaration of the MatrixBuffer template class used in APIs.
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Definition businessLogic.cpp:27
rtctk::exampleTopic::ScaoLoopTopic TopicType
Definition computation.hpp:31
std::vector< decltype(decltype(TopicType::wfs)::slopes)> BufferType
Definition computation.hpp:34
A container that can hold any type of service.
virtual void OnResultAvailable(const Result &result)=0
Definition computation.hpp:43
std::vector< float > avg_modes
Definition computation.hpp:45
std::vector< float > avg_slopes
Definition computation.hpp:44
Definition topics.hpp:33
WfsLoopBaseTopic< N_SUBAPS > wfs
Definition topics.hpp:38
Common topic definitions used in various examples.