Go to the documentation of this file.
12 #ifndef RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_RECORDINGTHREAD_HPP
13 #define RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_RECORDINGTHREAD_HPP
18 #include <ipcq/reader.hpp>
35 template<
typename Writer,
typename Topic =
typename Writer::TelemetryType,
typename Reader = ipcq::Reader<Topic>>
42 class InvalidStorageURLException :
public ::elt::error::CiiBaseException {
44 using ::elt::error::CiiBaseException::CiiBaseException;
45 explicit InvalidStorageURLException(
const std::string& uri) :
46 CiiBaseException(
"Invalid Telemetry Storage URL: " +uri) {}
51 class InvalidRecordingThreadOperation :
public ::elt::error::CiiBaseException {
53 using ::elt::error::CiiBaseException::CiiBaseException;
54 explicit InvalidRecordingThreadOperation(
const std::string& message) :
55 CiiBaseException(
"Invalid Operation on Recording Thread: " + message) {}
61 class RecordingThreadIPCQError :
public ::elt::error::CiiBaseException {
63 using ::elt::error::CiiBaseException::CiiBaseException;
64 explicit RecordingThreadIPCQError(
const std::string& message) :
65 CiiBaseException(
"Error in IPCQ: " + message) {}
71 class RecordingThreadInvalidStartSample :
public ::elt::error::CiiBaseException {
73 using ::elt::error::CiiBaseException::CiiBaseException;
74 explicit RecordingThreadInvalidStartSample(
const uint64_t sample_id) :
75 CiiBaseException(
"Invalid Start SampleID " + std::to_string(sample_id)) {}
85 RecordingThread(std::unique_ptr<Writer>&& writer,
const std::string& topic);
91 RecordingThread(std::unique_ptr<Writer>&& writer, std::unique_ptr<Reader>&& reader);
128 void SetTopic(
const std::string& topic);
162 void ReadDataWrapper(
const Topic& telemetry_data);
164 std::mutex m_state_lock;
166 std::unique_ptr<Reader> m_reader;
167 std::unique_ptr<Writer> m_writer;
168 std::thread m_thread;
169 uint64_t m_subsample_rate = 0;
170 size_t m_sampling_counter = 0;
171 std::string m_topic_name;
172 std::string m_output_dir;
173 uint64_t m_start_sample = 0;
174 uint64_t m_last_observed_sample_id = 0;
181 #endif //RTCTK_REUSABLECOMPONENT_TELEMETRYRECORDER_RECORDINGTHREAD_HPP
RecordingThread()
Definition: recordingThreadDetail.hpp:25
RecordingThread(const RecordingThread &)=delete
RecordingThread & operator=(RecordingThread &&)=delete
void Open()
Open the reader and writer.
Definition: recordingThreadDetail.hpp:145
void SetTopic(const std::string &topic)
Set the topic for the ipc queue.
Definition: recordingThreadDetail.hpp:192
Business Logic of the Telemetry Recorder.
void Pause()
Pause recording.
Definition: recordingThreadDetail.hpp:77
Recording Thread of the Telemetry Recorder template implementations.
RecordingThread(RecordingThread &&)=delete
@ PAUSED
Definition: recordingThread.hpp:29
The RecordingThread is responsible for reading from the ipc queue and writing to the provided Writer.
Definition: recordingThread.hpp:37
@ RUNNING
Definition: recordingThread.hpp:28
void Stop()
Stop the recording thread and wait for it's termination.
Definition: recordingThreadDetail.hpp:64
void SetSubSampleFactor(uint64_t rate)
Set the Subsample Factor.
Definition: recordingThreadDetail.hpp:178
void SetOutputUri(const ::elt::mal::Uri &storage_uri)
Sets this URI where the output files should be written to.
Definition: recordingThreadDetail.hpp:170
void SetTelemetrySubSet(const std::string &mask)
Set the TelemetrySubset for the Writer.
Definition: recordingThreadDetail.hpp:183
void SetStartSampleId(const uint64_t sample_id)
Set the first sample_id that should be recorded.
Definition: recordingThreadDetail.hpp:197
void Close()
Close the writer file.
Definition: recordingThreadDetail.hpp:161
~RecordingThread()
Definition: recordingThreadDetail.hpp:43
void Unpause()
Unpause the recording or begin recording after having started the recording thread.
Definition: recordingThreadDetail.hpp:85
Definition: businessLogic.hpp:20
void Start()
Start the recording thread.
Definition: recordingThreadDetail.hpp:55
RecordingThread & operator=(const RecordingThread &)=delete
@ STOPPED
Definition: recordingThread.hpp:27
ThreadState
State of the RecordingThread.
Definition: recordingThread.hpp:26