8#ifndef META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_RECORDER_H
9#define META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_RECORDER_H
37namespace Serialization
89 unsigned int referenceCounter_ = 0u;
121 using ExtraDataSample = std::pair<IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample>;
167 using FrameMediumMap = std::unordered_map<const Media::FrameMedium*, FrameMediumData>;
188 bool start(
const std::string& filename);
200 inline bool isRecording()
const;
206 inline bool hasStopped()
const;
386 std::atomic<RecorderState> recorderState_ = RS_IDLE;
389 bool callbackEventDeviceChangedRegistered_ =
false;
435 frameMedium_(frameMedium)
441 measurement_(measurement),
This class is the base class for all devices of any type.
Definition devices/Device.h:28
This class implements the base class for all devices providing measurement samples.
Definition Measurement.h:41
std::unordered_set< ObjectId > ObjectIdSet
Definition of an unordered set holding object ids.
Definition Measurement.h:57
This class combines relevant data from a sample so that it can be queued for recording.
Definition SerializerDeviceRecorder.h:132
Measurement::SampleRef sample_
The sample as received from the sender, may be invalid.
Definition SerializerDeviceRecorder.h:148
DeviceSampleData(const Measurement *measurement, const Measurement::SampleRef &sample)
Creates a new object based on a sample.
Definition SerializerDeviceRecorder.h:440
const Measurement * measurement_
The sender of the sample.
Definition SerializerDeviceRecorder.h:145
This class combines relevant data for a FrameMedium object.
Definition SerializerDeviceRecorder.h:68
Media::FrameMediumRef frameMedium_
The actual medium object.
Definition SerializerDeviceRecorder.h:80
FrameMediumData(const Media::FrameMediumRef &frameMedium)
Creates a new object and initializes the object with an existing FrameMedium object.
Definition SerializerDeviceRecorder.h:434
Timestamp lastTimestamp_
The timestamp of the last image that has been recorded.
Definition SerializerDeviceRecorder.h:95
SharedAnyCamera camera_
The camera model of the medium which has been used to record the last frame(s).
Definition SerializerDeviceRecorder.h:83
This class implements a serialization recorder for devices and media objects.
Definition SerializerDeviceRecorder.h:46
void recordTracker6DOFSample(const Measurement *sender, const Tracker6DOF::Tracker6DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 6DOF tracker sample.
FrameMediumMap frameMediumMap_
The map mapping media pointers to media data objects.
Definition SerializerDeviceRecorder.h:401
void onMeasurementSample(const Measurement *sender, const Measurement::SampleRef &sample)
Event function for new sample events from Measurement objects.
void recordAccelerationSensor3DOFSample(const Measurement *sender, const AccelerationSensor3DOF::Acceleration3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF acceleration sensor sample.
std::unordered_set< const Measurement * > MeasurementSet
Definition of an unordered set holding measurement objects.
Definition SerializerDeviceRecorder.h:116
void onDeviceChanged(Device *device, const bool added)
Event function for new or removed devices.
RecorderState
Definition of different recorder states.
Definition SerializerDeviceRecorder.h:53
@ RS_STOPPING
Stopping recording.
Definition SerializerDeviceRecorder.h:59
@ RS_RECORDING
Currently recording.
Definition SerializerDeviceRecorder.h:57
@ RS_STOPPED
Recording has stopped.
Definition SerializerDeviceRecorder.h:61
void recordSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given sample.
bool stop()
Stops the recording, returns immediately while pending samples are finished to be recorded.
void recordGravityTracker3DOFSample(const Measurement *sender, const GravityTracker3DOF::GravityTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF gravity tracker sample.
void queueUnqueuedSamples()
Moves all not yet queued samples to the queue.
void recordOrientationTracker3DOFSample(const Measurement *sender, const OrientationTracker3DOF::OrientationTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF orientation tracker sample.
SerializerDeviceRecorder(const SerializerDeviceRecorder &)=delete
Disabled copy constructor.
void recordPositionTracker3DOFSample(const Measurement *sender, const PositionTracker3DOF::PositionTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF position tracker sample.
std::unordered_map< const Measurement *, IO::Serialization::DataSerializer::ChannelId > MeasurementChannelMap
Definition of an unordered map mapping measurements to channel ids.
Definition SerializerDeviceRecorder.h:111
MeasurementChannelMap measurementChannelMap_
The map mapping measurements objects to channel ids.
Definition SerializerDeviceRecorder.h:398
bool addExtraDataSample(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Adds a new extra data sample to be recorded on a specific channel.
SampleEventSubscriptionMap sampleEventSubscriptionMap_
The map of event subscriptions for sample events.
Definition SerializerDeviceRecorder.h:392
void recordGyroSensor3DOFSample(const Measurement *sender, const GyroSensor3DOF::Gyro3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF gyro sensor sample.
void release()
Releases this device recorder explicitly before the recorder is disposed.
IO::Serialization::DataSerializer::ChannelId addExtraChannel(const std::string &sampleType, const std::string &channelName, const std::string &contentType)
Adds a new extra channel for custom data recording.
std::atomic< RecorderState > recorderState_
The state of the recorder.
Definition SerializerDeviceRecorder.h:386
void recordTrackerSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given tracker sample.
std::unordered_map< Device *, Measurement::SampleEventSubscription > SampleEventSubscriptionMap
Definition of an unordered map mapping devices to sample event subscription objects.
Definition SerializerDeviceRecorder.h:101
DeviceSampleDatas unqueuedDeviceSampleDatas_
The samples which are not yet pushed into the recording queue.
Definition SerializerDeviceRecorder.h:407
bool start(const std::string &filename)
Starts recording with a given filename for the new serialization file.
bool isRecording() const
Returns whether the recorder is currently recording.
Definition SerializerDeviceRecorder.h:447
Lock frameMediumMapLock_
The lock for the 'frameMediumMap_' object.
Definition SerializerDeviceRecorder.h:404
std::pair< IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample > ExtraDataSample
Definition of a pair combining a channel id with a data sample for extra data.
Definition SerializerDeviceRecorder.h:121
TrackerObjectEventSubscriptionMap trackerObjectEventSubscriptionMap_
The map of event subscriptions for object events.
Definition SerializerDeviceRecorder.h:395
ExtraDataSampleQueue extraDataSampleQueue_
The queue with extra data samples that are waiting to be recorded.
Definition SerializerDeviceRecorder.h:419
Lock unqueuedDeviceSampleDatasLock_
The lock for the 'unqueuedDeviceSampleDatas_' object.
Definition SerializerDeviceRecorder.h:410
~SerializerDeviceRecorder() override
Destructs the recorder, an active recording will be stopped.
void recordGPSTrackerSample(const Measurement *sender, const GPSTracker::GPSTrackerSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given GPS tracker sample.
std::unordered_map< const Media::FrameMedium *, FrameMediumData > FrameMediumMap
Definition of an unordered map mapping medium objects to medium data objects.
Definition SerializerDeviceRecorder.h:167
Lock recorderLock_
The lock for the entire recorder.
Definition SerializerDeviceRecorder.h:425
bool hasStopped() const
Returns whether the recorder has finished recording.
Definition SerializerDeviceRecorder.h:454
DeviceSampleDataQueue deviceSampleDataQueue_
The queue with samples that are waiting to be recorded.
Definition SerializerDeviceRecorder.h:413
SerializerDeviceRecorder & operator=(const SerializerDeviceRecorder &)=delete
Disabled copy operator.
bool addFrameMedium(const Media::FrameMediumRef &frameMedium)
Adds a new frame medium for recording.
void onTrackerObject(const Tracker *sender, const bool found, const Measurement::ObjectIdSet &objectIds, const Timestamp ×tamp)
Event function for lost or found tracker object ids.
SerializerDeviceRecorder()
Creates a new recorder.
Lock deviceSampleDataQueueLock_
The lock for the 'deviceSampleDataQueue_' object.
Definition SerializerDeviceRecorder.h:416
std::vector< DeviceSampleData > DeviceSampleDatas
Definition of a vector holding DeviceSampleData objects.
Definition SerializerDeviceRecorder.h:157
void threadRun() override
The recorder's thread function in which the actual recording is happening.
std::unordered_map< Device *, Tracker::TrackerObjectEventSubscription > TrackerObjectEventSubscriptionMap
Definition of an unordered map mapping devices to tracker object event subscription objects.
Definition SerializerDeviceRecorder.h:106
void recordSensorSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given sensor sample.
std::queue< DeviceSampleDatas > DeviceSampleDataQueue
Definition of a queue holding DeviceSampleDatas objects.
Definition SerializerDeviceRecorder.h:162
bool removeFrameMedium(const Media::FrameMediumRef &frameMedium)
Removes a frame medium from the recording.
std::unique_ptr< IO::Serialization::FileOutputDataSerializer > outputSerializer_
The actual serialization output serializer.
Definition SerializerDeviceRecorder.h:431
bool recordFrame(FrameMediumData &frameMediumData, const Frame &frame, const SharedAnyCamera &camera)
Records a new frame from a frame medium.
Lock extraDataSampleQueueLock_
The lock for the 'extraDataSampleQueue_' object.
Definition SerializerDeviceRecorder.h:422
MeasurementSet invalidMeasurements_
The set of measurement objects which are not valid anymore.
Definition SerializerDeviceRecorder.h:428
std::queue< ExtraDataSample > ExtraDataSampleQueue
Definition of a queue holding extra data samples.
Definition SerializerDeviceRecorder.h:126
This class implements the base class for all tracker devices.
Definition devices/Tracker.h:39
This class implements Ocean's image class.
Definition Frame.h:1879
uint32_t ChannelId
Definition of a channel id.
Definition DataSerializer.h:40
This class implements a recursive lock object.
Definition Lock.h:31
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition SmartObjectRef.h:90
This class implements a thread.
Definition Thread.h:115
This class implements a timestamp.
Definition Timestamp.h:63
std::unique_ptr< DataSample > UniqueDataSample
Definition of a unique pointer holding a DataSample.
Definition DataSample.h:39
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
The namespace covering the entire Ocean framework.
Definition Accessor.h:15