13#ifndef RTCTK_EXAMPLE_DATATASK_OPTIMISER_BUSINESSLOGIC_HPP
14#define RTCTK_EXAMPLE_DATATASK_OPTIMISER_BUSINESSLOGIC_HPP
24using namespace rtctk::componentFramework;
34 , m_oldb(services.Get<
OldbIf>())
35 , m_dp_slopes(
"/common/static/wfs_1/slopes")
36 , m_dp_nacts(
"/common/static/dm_1/acts")
37 , m_dp_im(
"/" + name +
"/" +
"dynamic/im")
38 , m_dp_cm(
"/" + name +
"/" +
"dynamic/cm")
39 , m_dp_stats_time(
"/" + name +
"/" +
"statistics/computation/time")
42 m_oldb.CreateDataPoint<
double>(m_dp_stats_time);
43 m_oldb.SetDataPoint<
double>(m_dp_stats_time, 0.0);
47 m_computation.SetStaticConfig(m_rtr.GetDataPoint<int32_t>(m_dp_slopes),
48 m_rtr.GetDataPoint<int32_t>(m_dp_nacts));
58 auto result = m_computation.Compute(ParseAlgorithm(arg));
61 m_oldb.SetDataPoint<
double>(m_dp_stats_time, result.stats.elapsed.count());
66 const std::string alg_key =
"algorithm";
68 if (not arg.contains(alg_key)) {
69 std::stringstream err_text;
70 err_text <<
"No algorithm specified: ";
71 for (
auto& [key, value] : arg.items()) {
72 err_text <<
" " << key <<
" : " << value;
77 std::string value = arg[alg_key];
79 if (value ==
"SimpleInversion") {
81 }
else if (value ==
"PythonInversion") {
84 std::stringstream err_text;
85 err_text <<
"Invalid algorithm specified: ";
86 for (
auto& [key, value] : arg.items()) {
87 err_text <<
" " << key <<
" : " << value;
89 CII_THROW(RtctkException, err_text.str());
98 DataPointPath m_dp_slopes;
99 DataPointPath m_dp_nacts;
100 DataPointPath m_dp_im;
101 DataPointPath m_dp_cm;
102 DataPointPath m_dp_stats_time;
104 Computation m_computation;
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:213
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:28
Base interface for all OLDB adapters.
Definition oldbIf.hpp:25
Base interface for all Runtime Configuration Repository adapters.
Definition runtimeRepoIf.hpp:27
Container class that holds services of any type.
Definition serviceContainer.hpp:39
Definition businessLogic.hpp:29
void ActivityOptimising(StopToken st, const JsonPayload &arg) override
Definition businessLogic.hpp:57
void ActivityInitialising(StopToken st) override
Definition businessLogic.hpp:46
LifeCycle ComponentType
Definition businessLogic.hpp:31
void ActivityUpdating(StopToken st, const JsonPayload &arg) override
Definition businessLogic.hpp:53
BusinessLogic(const std::string &name, ServiceContainer &services)
Definition businessLogic.hpp:32
Algorithm
Definition computation.hpp:37
@ SimpleInversion
Definition computation.hpp:37
@ PythonInversion
Definition computation.hpp:37
rad::StopToken StopToken
Definition stopToken.hpp:20
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:25
Definition businessLogic.cpp:27
Runnable< RtcComponent > LifeCycle
Definition businessLogic.hpp:27
Header file for OldbIf, which defines the API for OldbAdapters.
Lifecycle Extension that makes an RTC Component 'Optimisable'.
Computation class of the example data task.
Lifecycle of a basic 'RtcComponent'.
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
Life cycle extension to make RtcComponent Optimisable.
Definition optimisable.hpp:128