#include <ddtMemoryAccessor.hpp>
| DdtMemoryAccessor () |
|
| DdtMemoryAccessor (const std::string &shm_id, const std::string &data_stream_identifier, DdtLogger *logger, const uint64_t time_window=0, const int32_t reading_interval=10) |
|
virtual | ~DdtMemoryAccessor () |
|
const uint32_t | ComputeChecksum (DataSampleShared *const data_sample_shared) |
|
const uint32_t | ComputeChecksum (DataSample *const data_sample) |
|
int32_t | OpenSharedMemory () |
|
void | CloseSharedMemory () |
|
void | WriteData (const int32_t writer_index, const int32_t topic_id, const int32_t sample_id, const uint8_t *datavec, const int32_t datavec_size, const uint8_t *metadata_vec, const int32_t metadatavec_size, const uint64_t timestamp) |
|
void | StartReading () |
|
void | StopReading () |
|
void | SetSizeConstraints (const int32_t max_sample_size, const int32_t space) |
|
void | Reattach () |
|
void | NewData () |
|
void | get_data_packet (std::string *stream_identifier, uint32_t *checksum, int32_t *sample_length, int64_t *writer_idx, uint64_t *timestamp, DataSample **sample) |
|
bool | get_data_available () |
|
int32_t | get_number_of_unread_elements () |
|
SignalT * | DataAvailableSignal () |
|
void | Reset () |
|
void | set_pub_unreg (const bool STATE) |
|
void | set_compute_checksum (const bool compute_crc) |
|
bool | get_compute_checksum () const |
|
bool | get_is_initialized () const |
|
This class provides the functionalities to access created shared memories.
◆ DdtMemoryAccessor() [1/2]
DdtMemoryAccessor::DdtMemoryAccessor |
( |
| ) |
|
◆ DdtMemoryAccessor() [2/2]
DdtMemoryAccessor::DdtMemoryAccessor |
( |
const std::string & | shm_id, |
|
|
const std::string & | data_stream_identifier, |
|
|
DdtLogger * | logger, |
|
|
const uint64_t | time_window = 0, |
|
|
const int32_t | reading_interval = 10 ) |
|
explicit |
Constructor
- Parameters
-
shm_id | The shared memory identifier. |
data_stream_identifier | The data stream identifier. |
logger | A DDT logger object (no transfer of ownership). |
time_window | Specifies when data samples are dropped in [ms]. |
reading_interval | The reading interval in [ms]. |
◆ ~DdtMemoryAccessor()
DdtMemoryAccessor::~DdtMemoryAccessor |
( |
| ) |
|
|
virtual |
◆ CloseSharedMemory()
void DdtMemoryAccessor::CloseSharedMemory |
( |
| ) |
|
Close shared memory specified by the stream identifier.
◆ ComputeChecksum() [1/2]
const uint32_t DdtMemoryAccessor::ComputeChecksum |
( |
DataSample *const | data_sample | ) |
|
Computes a crc32 checksum based on the Slicing-by-16 algorithm.
- Parameters
-
data_sample | The data sample. |
- Returns
- The computed checksum.
◆ ComputeChecksum() [2/2]
const uint32_t DdtMemoryAccessor::ComputeChecksum |
( |
DataSampleShared *const | data_sample_shared | ) |
|
Computes a crc32 checksum based on the Slicing-by-16 algorithm.
- Parameters
-
data_sample_shared | The data sample. |
- Returns
- The computed checksum.
◆ DataAvailableSignal()
SignalT * DdtMemoryAccessor::DataAvailableSignal |
( |
| ) |
|
Method for the connection to the data available signal.
- Returns
- Boost signal used for the event handling.
◆ get_compute_checksum()
bool DdtMemoryAccessor::get_compute_checksum |
( |
| ) |
const |
Get compute_checksum.
- Returns
- Flag indicating if the checksum computation is switched on / off.
◆ get_data_available()
bool DdtMemoryAccessor::get_data_available |
( |
| ) |
|
Returns true if size of the packets list is > 0.
- Returns
- True if size of the packets list is > 0.
◆ get_data_packet()
void DdtMemoryAccessor::get_data_packet |
( |
std::string * | stream_identifier, |
|
|
uint32_t * | checksum, |
|
|
int32_t * | sample_length, |
|
|
int64_t * | writer_idx, |
|
|
uint64_t * | timestamp, |
|
|
DataSample ** | sample ) |
The oldest DataPacket from the list is obtained by calling this function.
- Parameters
-
stream_identifier | The data stream identifier. |
checksum | The computed checksum. |
sample_length | The length of the data sample. |
writer_idx | The writer index. |
timestamp | The timestamp of the data packet. |
sample | The data sample. |
The checksum computation is switched off per default. If the checksum is zero the writer did not compute it. In that case there is no need for the reader to perform the computation.
◆ get_is_initialized()
bool DdtMemoryAccessor::get_is_initialized |
( |
| ) |
const |
Get is_initialized.
- Returns
- Flag indicating if initialization was successful.
◆ get_number_of_unread_elements()
int32_t DdtMemoryAccessor::get_number_of_unread_elements |
( |
| ) |
|
Returns the number of unread elements.
- Returns
- The number of unread elements.
◆ NewData()
void DdtMemoryAccessor::NewData |
( |
| ) |
|
This function is called from DdtDataSubscribers or from the data broker when new data was written into shared memory. It increases the number of unread elements.
◆ OpenSharedMemory()
int32_t DdtMemoryAccessor::OpenSharedMemory |
( |
| ) |
|
Opens an already created shared memory specified by the stream identifier.
- Returns
- 1 if SHM was opened successfully, -1 otherwise.
◆ Reattach()
void DdtMemoryAccessor::Reattach |
( |
| ) |
|
Reattaches to shared memory by closing and opening it again.
◆ Reset()
void DdtMemoryAccessor::Reset |
( |
| ) |
|
Resets the reader index and the number of unread elements after a publisher was restarted.
◆ set_compute_checksum()
void DdtMemoryAccessor::set_compute_checksum |
( |
const bool | compute_crc | ) |
|
Sets compute_checksum.
- Parameters
-
compute_crc | Specifies if the checksum computation is switched on / off. |
◆ set_pub_unreg()
void DdtMemoryAccessor::set_pub_unreg |
( |
const bool | STATE | ) |
|
Sets the pub_unreg flag.
- Parameters
-
STATE | Specifies if a publisher was unregistered. |
◆ SetSizeConstraints()
void DdtMemoryAccessor::SetSizeConstraints |
( |
const int32_t | max_sample_size, |
|
|
const int32_t | space ) |
Sets the maximum sample size and the additional space for the meta.
- Parameters
-
max_sample_size | Maximum sample size. |
space | Additional space required for the meta data. |
◆ StartReading()
void DdtMemoryAccessor::StartReading |
( |
| ) |
|
Creates a thread for reading data from the shared memory.
◆ StopReading()
void DdtMemoryAccessor::StopReading |
( |
| ) |
|
Stops the reading thread.
◆ WriteData()
void DdtMemoryAccessor::WriteData |
( |
const int32_t | writer_index, |
|
|
const int32_t | topic_id, |
|
|
const int32_t | sample_id, |
|
|
const uint8_t * | datavec, |
|
|
const int32_t | datavec_size, |
|
|
const uint8_t * | metadata_vec, |
|
|
const int32_t | metadatavec_size, |
|
|
const uint64_t | timestamp ) |
Writes the data into shared memory.
- Parameters
-
writer_index | |
topic_id | The topic ID. |
sample_id | The sample ID. |
datavec | A vector containing the data. |
datavec_size | The size of the data vector. |
metadata_vec | A vector containing the meta data. |
metadatavec_size | The size of the meta data vector. |
timestamp | The timestamp when the data was written into SHM. |
The writer index of a DataPacket is set to -1 per default. If WriteData() is called from a publisher application the current writer index needs to be attached to the data packet. If WriteData() is called from a broker the received DataPacket contains the source writer index. Note: If the publisher stops publishing and get restarted, the reader index is not reset!
The checksum computation is switched off per default and will only be computed if a publisher is started with the checksum commandline parameter set to true
The documentation for this class was generated from the following files: