Skip to content

Commit

Permalink
Refs #19563: Fix Durability QoS setup in configuration example
Browse files Browse the repository at this point in the history
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
  • Loading branch information
JesusPoderoso committed Jun 26, 2024
1 parent ff688c2 commit 88eaf73
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
10 changes: 5 additions & 5 deletions examples/cpp/configuration/CLIParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class CLIParser
int32_t max_samples = 5000;
int32_t max_instances = 10;
int32_t max_samples_per_instance = 400;
uint32_t deadline = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t lifespan = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t liveliness_lease = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t liveliness_assert = fastdds::Duration_t::INFINITE_SECONDS - 1;
uint32_t deadline = 0;
uint32_t lifespan = 0;
uint32_t liveliness_lease = 0;
uint32_t liveliness_assert = 0;
std::string partitions = "";
std::string profile_participant = "";
std::string topic_name = "configuration_topic";
Expand Down Expand Up @@ -76,7 +76,7 @@ class CLIParser
struct publisher_config : public entity_config
{
uint16_t wait = 0;
uint32_t ack_keep_duration = fastdds::Duration_t::INFINITE_SECONDS;
uint32_t ack_keep_duration = 0;
uint32_t interval = 100;
uint32_t msg_size = 10;
uint32_t ownership_strength = 0;
Expand Down
30 changes: 22 additions & 8 deletions examples/cpp/configuration/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,30 @@ PublisherApp::PublisherApp(
"DataWriter initialization failed: ownership strength is only valid with exclusive ownership");
}
writer_qos.ownership_strength().value = config.ownership_strength;
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
if (config.deadline > 0)
{
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
}
writer_qos.reliable_writer_qos().disable_positive_acks.enabled = config.disable_positive_ack;
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
config.ack_keep_duration * 1e-3);
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
if (config.ack_keep_duration > 0)
{
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
config.ack_keep_duration * 1e-3);
}
if (config.lifespan > 0)
{
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
}
writer_qos.liveliness().kind = config.liveliness;
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
config.liveliness_lease * 1e-3);
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
if (config.liveliness_lease > 0)
{
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
}
if (config.liveliness_assert > 0)
{
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
}
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
}
else
Expand Down
23 changes: 17 additions & 6 deletions examples/cpp/configuration/SubscriberApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,25 @@ SubscriberApp::SubscriberApp(
reader_qos.resource_limits().max_instances = config.max_instances;
reader_qos.resource_limits().max_samples_per_instance = config.max_samples_per_instance;
reader_qos.ownership().kind = config.ownership;
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
if (config.deadline > 0)
{
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
}
reader_qos.reliable_reader_qos().disable_positive_acks.enabled = config.disable_positive_ack;
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
if (config.lifespan > 0)
{
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
}
reader_qos.liveliness().kind = config.liveliness;
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
config.liveliness_lease * 1e-3);
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
if (config.liveliness_lease > 0)
{
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
}
if (config.liveliness_assert > 0)
{
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
config.liveliness_assert * 1e-3);
}
reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all());
}
else
Expand Down

0 comments on commit 88eaf73

Please sign in to comment.