RTC Toolkit 6.0.0-pre2
Loading...
Searching...
No Matches
ipcqRecordingUnit.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_COMPONENTFRAMEWORK_IPCQRECORDINGUNIT_HPP
13#define RTCTK_COMPONENTFRAMEWORK_IPCQRECORDINGUNIT_HPP
14
23
24#include <fmt/format.h>
25
26#include <cstdint>
27#include <string>
28#include <filesystem>
29#include <thread>
30#include <type_traits>
31#include <atomic>
32#include <optional>
33
35
36template <typename T, typename = int>
37struct HasSampleIdWithCorrectType : std::false_type {};
38
39template <typename T>
40struct HasSampleIdWithCorrectType<T, decltype(std::declval<T>().sample_id, 0)>
41 : std::conditional_t<std::is_same_v<uint32_t, decltype(std::declval<T>().sample_id)>,
42 std::true_type,
43 std::false_type> {};
44// first check if the member exists. If yes, then check if it has the right type
45
46template <typename T>
48
55template <typename RecInfoType>
57public:
59 "Topic struct must contain member 'sample_id' with type 'uint32_t'!");
60
68 IpcqRecordingUnit(const std::string& comp_id,
69 const std::string& unit_id,
70 ServiceContainer& services);
71
75 ~IpcqRecordingUnit() override;
76
81 void Prepare(const std::filesystem::path& file_path) override;
85 void Start() override;
90 std::vector<std::filesystem::path> Stop() override;
94 void Update() override;
95
96protected:
104 static typename RecInfoType::Recorder::DisabledFields
105 GetDisabled(RepositoryIf& rtr, const DataPointPath& sub_path);
106
107private:
111 void LoadDynamicConfig();
115 void Process();
119 std::thread m_process_thread;
123 std::atomic<bool> m_start = false;
124 std::atomic<bool> m_stop = false;
128 std::string m_queue_name;
132 std::optional<size_t> m_cpu_affinity;
136 typename RecInfoType::Recorder m_output;
140 int64_t m_subsample_factor;
144 int64_t m_start_sample_id;
148 int64_t m_stop_after_num_samples;
152 uint64_t m_sampling_counter;
156 perfc::CounterI64 m_samples_written;
157 perfc::ScopedRegistration m_samples_written_reg;
161 perfc::CounterI64 m_last_observed_sample_id;
162 perfc::ScopedRegistration m_last_observed_sample_id_reg;
163
164 std::unique_ptr<FrequencyEstimator<>> m_freq_estimator;
165 std::unique_ptr<DurationMonitor<>> m_dur_monitor;
166 std::unique_ptr<BufferMonitor<>> m_buffer_monitor;
170 inline static constexpr std::string_view RTR_PATH_QUEUE_NAME =
171 "/{}/static/rec_units/{}/shm_queue_name";
175 inline static constexpr std::string_view RTR_PATH_CPU_AFFINITY =
176 "/{}/static/rec_units/{}/cpu_affinity";
180 inline static constexpr std::string_view RTR_PATH_TELEMETRY_SUBSET =
181 "/{}/dynamic/rec_units/{}/telemetry_subset";
185 inline static constexpr std::string_view RTR_PATH_SUBSAMPLE_FACTOR =
186 "/{}/dynamic/rec_units/{}/subsample_factor";
190 inline static constexpr std::string_view RTR_PATH_START_SAMPLE_ID =
191 "/{}/dynamic/rec_units/{}/start_at_sample_id";
195 inline static constexpr std::string_view RTR_PATH_STOP_AFTER_NUM_SAMPLES =
196 "/{}/dynamic/rec_units/{}/stop_after_num_samples";
200 inline static constexpr std::string_view OLDB_PATH_QUEUE_NAME = "/{}/rec_units/{}/queue_name";
201
205 inline static constexpr size_t MAX_SAMPLES_READ = 16;
206};
207
208} // namespace rtctk::componentFramework
209
211
212#endif // RTCTK_COMPONENTFRAMEWORK_IPCQRECORDINGUNIT_HPP
Header file for Buffer Monitor.
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:77
std::vector< std::filesystem::path > Stop() override
Stop the recording thread and wait for it's termination.
Definition ipcqRecordingUnit.ipp:113
void Update() override
Update settings from RuntimeRepo.
Definition ipcqRecordingUnit.ipp:128
void Prepare(const std::filesystem::path &file_path) override
Prepare the recording thread and start recording.
Definition ipcqRecordingUnit.ipp:86
static RecInfoType::Recorder::DisabledFields GetDisabled(RepositoryIf &rtr, const DataPointPath &sub_path)
get disabled fields from a DataPoint in the runtime repo.
Definition ipcqRecordingUnit.ipp:313
IpcqRecordingUnit(const std::string &comp_id, const std::string &unit_id, ServiceContainer &services)
Create a new Ipcq Recorder reading from a given queue and outputting to the given output stage.
Definition ipcqRecordingUnit.ipp:33
void Start() override
Start the recording.
Definition ipcqRecordingUnit.ipp:108
~IpcqRecordingUnit() override
Destructor.
Definition ipcqRecordingUnit.ipp:78
RecordingUnit(const std::string &comp_id, const std::string &unit_id, const std::string &unit_type, ServiceContainer &services)
Create a new RecordingIngestion.
Definition recordingUnit.cpp:19
Abstract interface providing basic read and write facilities to a repository.
Definition repositoryIf.hpp:51
Container class that holds services of any type.
Definition serviceContainer.hpp:39
Header file for ComponentMetricsIf.
Provides an abstract DataRecorder class as the output stage for a recording unit.
Header file for Duration Monitor.
Provides macros and utilities for exception handling.
Header file for Frequency Estimator.
Recording Unit that can record from shared memory queue.
Definition commandReplier.cpp:22
constexpr bool HAS_MEMBER_SAMPLE_ID_UINT32T
Definition ipcqRecordingUnit.hpp:47
Definition ddsSub.hpp:156
FitsRecorder allows to write ColumnData to into fits files in a specified directory.
Abstract base class defining functionality common to all recording units.