RTC Toolkit  1.0.0
businessLogicDetail.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_BUSINESSLOGIC_DETAIL_HPP
13 #define RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_BUSINESSLOGIC_DETAIL_HPP
14 
15 
18 #include <thread>
19 #include <chrono>
20 
22 
24 
25 using namespace rtctk::componentFramework;
26 using namespace std::chrono_literals;
27 
28 using std::this_thread::sleep_for;
29 
30 namespace rtctk::telemetryRecorder {
31 
32 template <typename T>
34  ServiceContainer& services)
35  : m_name(name), m_services(services) {
36  static_assert((std::is_base_of<RecorderIf<typename T::TelemetryType>, T>::value),
37  "template parameter for TelemetryRecorderBusinessLogic needs to be derived from "
38  "RecorderIf");
39 }
40 
41 // activities
42 template<typename T>
44 {
45  return;
46 }
47 
48 template<typename T>
50 {
51  auto& rtr = m_services.Get<RuntimeRepoIf>();
52  m_recorder_thread.SetTopic(rtr.GetDataPoint<std::string>(DataPointPath("/" + m_name + "/static/topic_name")));
53  m_recorder_thread.SetSubSampleFactor(rtr.GetDataPoint<int64_t>(DataPointPath("/" + m_name + "/dynamic/subsample_factor")));
54  m_recorder_thread.SetTelemetrySubSet(rtr.GetDataPoint<std::string>(DataPointPath("/" + m_name + "/dynamic/tel_subset")));
55  m_recorder_thread.SetOutputUri(::elt::mal::Uri(rtr.GetDataPoint<std::string>(DataPointPath("/" + m_name + "/dynamic/output_uri"))));
56  m_recorder_thread.SetStartSampleId(rtr.GetDataPoint<int64_t>(DataPointPath("/" + m_name + "/static/start_with_sample_id")));
57 }
58 
59 template<typename T>
61 {
62  m_recorder_thread.Open();
63  m_recorder_thread.Start();
64 }
65 
66 template<typename T>
68 {
69  m_recorder_thread.Stop();
70  m_recorder_thread.Close();
71 }
72 
73 template<typename T>
75 {
76  m_recorder_thread.Unpause();
77  return;
78 }
79 
80 template<typename T>
82 {
83  m_recorder_thread.Pause();
84 }
85 
86 template<typename T>
88 {
89  while(not st.StopRequested()) {
90  sleep_for(100ms);
91  }
92 }
93 
94 template<typename T>
96 {
97  return;
98 }
99 
100 template<typename T>
102 {
103  auto& rtr = m_services.Get<RuntimeRepoIf>();
104  m_recorder_thread.SetOutputUri(::elt::mal::Uri(rtr.GetDataPoint<std::string>(DataPointPath("/" + m_name + "/dynamic/output_uri"))));
105  m_recorder_thread.SetSubSampleFactor(rtr.GetDataPoint<int64_t>(DataPointPath("/" + m_name + "/dynamic/subsample_factor")));
106  m_recorder_thread.SetTelemetrySubSet(rtr.GetDataPoint<std::string>(DataPointPath("/" + m_name + "/dynamic/tel_subset")));
107 
108  return;
109 }
110 
111 // guards
112 template<typename T>
114 {
115  // Updates are always allowed in states Running and Idle
116  return true;
117 }
118 
119 }
120 
121 #endif // RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_BUSINESSLOGIC_DETAIL_HPP
wscript.name
name
Definition: wscript:15
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityInitialising
void ActivityInitialising(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:49
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityGoingRunning
void ActivityGoingRunning(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:74
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityUpdating
void ActivityUpdating(rtctk::componentFramework::StopToken st, rtctk::componentFramework::Payload args) override
Definition: businessLogicDetail.hpp:101
rtctk::telemetryRecorder::RecorderIf
Definition: recorderIf.hpp:25
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic
Definition: businessLogic.hpp:26
rtctk::componentFramework::StopToken
rad::StopToken StopToken
Definition: stopToken.hpp:19
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityRunning
void ActivityRunning(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:87
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityGoingIdle
void ActivityGoingIdle(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:81
rtctk::componentFramework::Payload
std::string Payload
Definition: payload.hpp:19
rtctk::componentFramework::ServiceContainer
Container class that holds services of any type.
Definition: serviceContainer.hpp:35
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityDisabling
void ActivityDisabling(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:67
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::GuardUpdatingAllowed
bool GuardUpdatingAllowed(rtctk::componentFramework::Payload args) override
Definition: businessLogicDetail.hpp:113
rtctk::telemetryRecorder
Definition: businessLogic.hpp:20
recorderIf.hpp
Recorder Interface of the Telemetry Recorder.
rtctk::componentFramework::RuntimeRepoIf
Definition: runtimeRepoIf.hpp:20
logger.hpp
Logging Support Library based on log4cplus.
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityStarting
void ActivityStarting(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:43
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityEnabling
void ActivityEnabling(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:60
rtctk::telemetryRecorder::TelemetryRecorderBusinessLogic::ActivityRecovering
void ActivityRecovering(rtctk::componentFramework::StopToken st) override
Definition: businessLogicDetail.hpp:95
rtctk::componentFramework::DataPointPath
This class provides a wraper for DataPoint paths which ensures that they only contain valid character...
Definition: dataPointPath.hpp:34
runtimeRepoIf.hpp
Header file for RuntimeRepoIf, which defines the API for RuntimeRepoAdapters.
businessLogic.hpp
Business Logic of the Telemetry Recorder.