ddt 1.2.1
|
#include <ddtDataConsumer.hpp>
Public Types | |
enum | SubscriberType { LOCAL , REMOTE } |
![]() | |
enum | NotificationType { NEW_DATA , PUB_REG , PUB_UNREG , SHM_DEL } |
Public Attributes | |
signal_n | notification_signal |
Protected Attributes | |
DdtMemoryAccessor * | memory_accessor |
std::string | data_stream_identifier |
int32_t | number_of_samples |
int32_t | notification_port |
std::string | publishing_uri |
std::chrono::system_clock::time_point | last_received |
uint64_t | total_samples = 0 |
uint64_t | total_bytes = 0 |
uint64_t | total_latency = 0 |
![]() | |
int32_t | min_port |
int32_t | max_port |
DdtLogger * | logger |
const int | MIN_PORT_DEFAULT = 5100 |
const int | MAX_PORT_DEFAULT = 5500 |
const int | MIN_RANGE = 3 |
const int | LINE_LENGTH = 256 |
DdtDataConsumer (const std::string &data_stream_identifier, const int32_t latency, const int32_t deadline, DdtLogger *ddt_logger) | |
DdtDataConsumer (const std::string &data_stream_identifier, const std::string &subscription_uri, const int32_t latency, const int32_t deadline, DdtLogger *ddt_logger) | |
~DdtDataConsumer () override | |
void | StartSubscription () |
void | StopSubscription () |
void | AddUuid (std::string uuid, SubscriberType type) |
void | RemoveUuid (const std::string uuid) |
void | Notify (const NotificationType type) override |
int32_t | get_number_of_subscribers () |
int32_t | get_number_of_remote_subscribers () |
std::map< std::string, SubscriberType > | get_subscribers () |
std::string | get_remote_broker_uri () const |
int32_t | get_notification_port () const |
DdtStatistics | get_statistics () |
void | ResetStatistics () |
std::string | get_publishing_uri () const |
void | set_remote_broker_uri (const std::string &remote_uri) |
void | set_number_of_samples (const int32_t num_samples) |
void | set_memory_accessor (DdtMemoryAccessor *mem_accessor) |
void | set_notification_port (const int32_t noti_port) |
void | set_publishing_uri (const std::string pub_uri) |
void | set_originating_broker (const std::string orig_broker) |
void | Init (const std::string &ds_id, DdtLogger *ddt_logger) |
Additional Inherited Members | |
![]() | |
DdtProducerConsumerBase (DdtLogger *ddt_logger) | |
virtual | ~DdtProducerConsumerBase () |
![]() | |
void | Init (DdtLogger *ddt_logger) |
void | LoadDefaults () |
void | ReadIni () |
void | PrintConfigValues () |
int32_t | GetFreePort () const |
This class provides the functionality to subscribe to a data stream, to write the received data into shared memory and to notify DdtDataSubscribers that new data is available. There will be one data consumer object per data stream identifier and thus several DdtDataSubscribers may share one consumer object.
DdtDataConsumer::DdtDataConsumer | ( | const std::string & | data_stream_identifier, |
const int32_t | latency, | ||
const int32_t | deadline, | ||
DdtLogger * | ddt_logger ) |
Constructor
data_stream_identifier | The data stream identifier. |
latency | A MAL QoS parameter. Shall be the maximum time a sample may remain in-transit between the publisher and subscriber in [ms]. |
deadline | A MAL QoS parameter. Shall be the maximum age of a sample in [s]. |
ddt_logger | A DDT logger object (no transfer of ownership). |
DdtDataConsumer::DdtDataConsumer | ( | const std::string & | data_stream_identifier, |
const std::string & | subscription_uri, | ||
const int32_t | latency, | ||
const int32_t | deadline, | ||
DdtLogger * | ddt_logger ) |
Constructor
data_stream_identifier | The data stream identifier. |
subscription_uri | URI for the subscription. |
latency | A MAL QoS parameter. Shall be the maximum time a sample may remain in-transit between the publisher and subscriber in [ms]. |
deadline | A MAL QoS parameter. Shall be the maximum age of a sample in [s]. |
ddt_logger | A DDT logger object (no transfer of ownership). |
|
overridedefault |
Destructor
void DdtDataConsumer::AddUuid | ( | std::string | uuid, |
SubscriberType | type ) |
Adds the UUID of a DdtDataSubscriber to the subscriber_map.
uuid | UUID of the subscriber. |
type | Type of the subscriber. |
int32_t DdtDataConsumer::get_notification_port | ( | ) | const |
Returns notification_port.
int32_t DdtDataConsumer::get_number_of_remote_subscribers | ( | ) |
Returns the number of remote DdtDataSubscribers attached to a consumer object.
iterate over the subscriber map count all subscribers of type REMOTE
int32_t DdtDataConsumer::get_number_of_subscribers | ( | ) |
Returns the number of all DdtDataSubscribers attached to a consumer object.
std::string DdtDataConsumer::get_publishing_uri | ( | ) | const |
Returns publishing_uri.
std::string DdtDataConsumer::get_remote_broker_uri | ( | ) | const |
Returns remote_broker_uri.
DdtStatistics DdtDataConsumer::get_statistics | ( | ) |
Returns the statistics.
std::map< std::string, DdtDataConsumer::SubscriberType > DdtDataConsumer::get_subscribers | ( | ) |
Returns the map with the uuids of DdtDataSubscribers attached to a consumer object.
|
protected |
Initializes some member variables.
ds_id | The data stream identifier. |
ddt_logger | A DDT logger object (no transfer of ownership). |
|
overridevirtual |
Sends a notification to local subscribers.
type | Type of the subscriber. |
Implements ddt::DdtProducerConsumerBase.
void DdtDataConsumer::RemoveUuid | ( | const std::string | uuid | ) |
Removes the UUID of a DdtDataSubscriber from the subscriber_map.
uuid | UUID of the subscriber. |
void DdtDataConsumer::ResetStatistics | ( | ) |
Resets the statistics to zero in case the shared memory was deleted.
void DdtDataConsumer::set_memory_accessor | ( | DdtMemoryAccessor * | mem_accessor | ) |
Sets memory_accessor.
mem_accessor | A DDT memory accessor object (no transfer of ownership). |
void DdtDataConsumer::set_notification_port | ( | const int32_t | noti_port | ) |
Sets notification_port.
noti_port | The port used for notifications. |
void DdtDataConsumer::set_number_of_samples | ( | const int32_t | num_samples | ) |
Sets number_of_samples.
num_samples | Number of samples stored in the SHM ring buffer. |
void DdtDataConsumer::set_originating_broker | ( | const std::string | orig_broker | ) |
Sets the originating broker_uri.
orig_broker | The originating broker URI. |
void DdtDataConsumer::set_publishing_uri | ( | const std::string | pub_uri | ) |
Sets the publishing_uri.
pub_uri | The publishing URI. |
void DdtDataConsumer::set_remote_broker_uri | ( | const std::string & | remote_uri | ) |
Sets remote_broker_uri.
remote_uri | THe URI of the remote broker. |
void DdtDataConsumer::StartSubscription | ( | ) |
Starts MAL subscription as a separate thread.
void DdtDataConsumer::StopSubscription | ( | ) |
Stops MAL subscription.
|
protected |
The data stream identifier.
|
protected |
Last time when a data sample was received.
|
protected |
The DDT memory accessor object.
|
protected |
The port used for notifications.
signal_n ddt::DdtDataConsumer::notification_signal |
Boost signal to send the notification type received via MALps.
|
protected |
The Number of samples stored in the SHM ring buffer.
|
protected |
The publishing URI.
|
protected |
Total number of bytes received in the data stream.
|
protected |
Aggregated latency in [ms].
|
protected |
Total number of complete data samples received.