12#ifndef RTCTK_COMPONENTFRAMEWORK_IPCQRECORDINGUNIT_HPP
13#define RTCTK_COMPONENTFRAMEWORK_IPCQRECORDINGUNIT_HPP
24#include <fmt/format.h>
32template <
typename T,
typename =
int>
37 : std::conditional<std::is_same<uint32_t, decltype(std::declval<T>().sample_id)>::value,
39 std::false_type>::type {};
51template <
typename RecInfoType>
55 "Topic struct must contain member 'sample_id' with type 'uint32_t'!");
68 , m_queue_name(
m_rtr.GetDataPoint<std::string>(
84 "Number of samples successfully written to file"));
85 m_last_observed_sample_id_reg =
88 "Last sample id successfully written to file"));
90 m_freq_estimator = std::make_unique<FrequencyEstimator<>>(
93 m_dur_monitor = std::make_unique<DurationMonitor<>>(
97 std::make_unique<BufferMonitor<>>(
m_metrics,
"SHM read buffer occupancy",
unit_id);
104 if (m_process_thread.joinable()) {
105 m_process_thread.join();
117 void Start()
override;
122 std::vector<std::filesystem::path>
Stop()
override;
136 static typename RecInfoType::Recorder::DisabledFields
147 std::thread m_process_thread;
151 std::atomic<bool> m_start =
false;
152 std::atomic<bool> m_stop =
false;
156 std::string m_queue_name;
160 std::optional<size_t> m_cpu_affinity;
164 typename RecInfoType::Recorder m_output;
176 int64_t m_stop_after_num_samples;
184 perfc::CounterI64 m_samples_written;
185 perfc::ScopedRegistration m_samples_written_reg;
189 perfc::CounterI64 m_last_observed_sample_id;
190 perfc::ScopedRegistration m_last_observed_sample_id_reg;
192 std::unique_ptr<FrequencyEstimator<>> m_freq_estimator;
193 std::unique_ptr<DurationMonitor<>> m_dur_monitor;
194 std::unique_ptr<BufferMonitor<>> m_buffer_monitor;
198 inline static constexpr std::string_view RTR_PATH_QUEUE_NAME =
199 "/{}/static/rec_units/{}/shm_queue_name";
203 inline static constexpr std::string_view RTR_PATH_CPU_AFFINITY =
204 "/{}/static/rec_units/{}/cpu_affinity";
208 inline static constexpr std::string_view RTR_PATH_TELEMETRY_SUBSET =
209 "/{}/dynamic/rec_units/{}/telemetry_subset";
213 inline static constexpr std::string_view RTR_PATH_SUBSAMPLE_FACTOR =
214 "/{}/dynamic/rec_units/{}/subsample_factor";
218 inline static constexpr std::string_view RTR_PATH_START_SAMPLE_ID =
219 "/{}/dynamic/rec_units/{}/start_at_sample_id";
223 inline static constexpr std::string_view RTR_PATH_STOP_AFTER_NUM_SAMPLES =
224 "/{}/dynamic/rec_units/{}/stop_after_num_samples";
228 inline static constexpr std::string_view OLDB_PATH_QUEUE_NAME =
"/{}/rec_units/{}/queue_name";
233 inline static constexpr size_t MAX_SAMPLES_READ = 16;
Header file for Buffer Monitor.
virtual perfc::ScopedRegistration AddCounter(CounterVariant counter, CounterMetricInfo info)=0
Add a counter to be included in component metrics, identified by its address, together with info to t...
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition componentMetricsIf.hpp:46
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
Recording Unit that can record from shared memory queue.
Definition ipcqRecordingUnit.hpp:52
std::vector< std::filesystem::path > Stop() override
Stop the recording thread and wait for it's termination.
Definition ipcqRecordingUnit.ipp:53
void Update() override
Update settings from RuntimeRepo.
Definition ipcqRecordingUnit.ipp:68
virtual ~IpcqRecordingUnit()
Definition ipcqRecordingUnit.hpp:102
void Prepare(const std::filesystem::path &file_path) override
Prepare the recording thread and start recording.
Definition ipcqRecordingUnit.ipp:30
static RecInfoType::Recorder::DisabledFields GetDisabled(RepositoryIf &rtr, const DataPointPath &sub_path)
get disabled fields from a DataPoint in the runtime repo.
Definition ipcqRecordingUnit.ipp:246
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.hpp:64
void Start() override
Start the recording.
Definition ipcqRecordingUnit.ipp:48
Abstract base class for all sources that can be recorded by the MetadataCollector and TelemetryRecord...
Definition recordingUnit.hpp:51
OldbIf & m_oldb
Definition recordingUnit.hpp:173
ComponentMetricsIf & m_metrics
Definition recordingUnit.hpp:174
RuntimeRepoIf & m_rtr
Definition recordingUnit.hpp:172
Abstract interface providing basic read and write facilities to a repository.
Definition repositoryIf.hpp:104
T GetDataPoint(const DataPointPath &path) const
Fetches a datapoint from the repository.
Definition repositoryIf.ipp:1711
void CreateDataPoint(const DataPointPath &path)
Creates a new datapoint in the repository.
Definition repositoryIf.ipp:1696
void SetDataPoint(const DataPointPath &path, const T &value)
Sets a datapoint in the repository.
Definition repositoryIf.ipp:1720
bool DataPointExists(const DataPointPath &path) const
Checks for the existence of a datapoint in the repository.
Definition repositoryIf.cpp:461
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 ddsSub.hpp:151
Definition commandReplier.cpp:22
constexpr bool HAS_MEMBER_SAMPLE_ID_UINT32T
Definition ipcqRecordingUnit.hpp:43
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
FitsRecorder allows to write ColumnData to into fits files in a specified directory.
Abstract base class defining functionality common to all recording units.
Definition ipcqRecordingUnit.hpp:33