Skip to content

Commit

Permalink
Move TimeSeries creation
Browse files Browse the repository at this point in the history
If this commit is applied then TimeSeries creation post topic selection
will be moved to a new auxiliar method.
So that I can perform some changes in it to manage keyed topics.

Issue: [#eProsima#56]
Signed-off-by: Manuel Valch <manuelValch@proton.me>
  • Loading branch information
manuelValch committed May 28, 2024
1 parent 265a22e commit b358cde
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 37 deletions.
79 changes: 42 additions & 37 deletions plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,44 +79,9 @@ bool FastDdsDataStreamer::start(
// Store as default configuration
configuration_.save_default_settings(CONFIGURATION_SETTINGS_PREFIX_);

// Topics selected
const auto& topics = configuration_.topics_selected; // Decorator variable to avoid calling internal member

if (topics.empty())
{
DEBUG("No topics selected, exiting");
throw InitializationException("No topics selected.");
}

for (const auto& topic : topics)
{
// Create a subscription
fastdds_handler_.create_subscription(
utils::QString_to_string(topic),
configuration_.data_type_configuration);
}

// Get all series from topics and create them
// NUMERIC
std::vector<types::DatumLabel> numeric_series = fastdds_handler_.numeric_data_series_names();
for (const auto& series : numeric_series)
{
// Create a series
DEBUG("Creating numeric series: " << series);
dataMap().addNumeric(series);
}
running_ = onTopicSelection();

// STRING
std::vector<types::DatumLabel> string_series = fastdds_handler_.string_data_series_names();
for (const auto& series : string_series)
{
// Create a series
DEBUG("Creating string series: " << series);
dataMap().addStringSeries(series);
}

running_ = true;
return true;
return running_;
}

void FastDdsDataStreamer::shutdown()
Expand Down Expand Up @@ -255,6 +220,46 @@ void FastDdsDataStreamer::connect_to_domain_(
select_topics_dialog_.connect_to_domain(domain_id);
}

bool FastDdsDataStreamer::onTopicSelection()
{
// Topics selected
const auto& topics = configuration_.topics_selected; // Decorator variable to avoid calling internal member

if (topics.empty())
{
DEBUG("No topics selected, exiting");
throw InitializationException("No topics selected.");
}

for (const auto& topic : topics)
{
// Create a subscription
fastdds_handler_.create_subscription(
utils::QString_to_string(topic),
configuration_.data_type_configuration);
}

// Get all series from topics and create them
// NUMERIC
std::vector<types::DatumLabel> numeric_series = fastdds_handler_.numeric_data_series_names();
for (const auto& series : numeric_series)
{
// Create a series
DEBUG("Creating numeric series: " << series);
dataMap().addNumeric(series);
}

// STRING
std::vector<types::DatumLabel> string_series = fastdds_handler_.string_data_series_names();
for (const auto& series : string_series)
{
// Create a series
DEBUG("Creating string series: " << series);
dataMap().addStringSeries(series);
}
return true;
}

} /* namespace datastreamer */
} /* namespace plotjuggler */
} /* namespace eprosima */
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class FastDdsDataStreamer :
unsigned int domain_id);


bool onTopicSelection();

////////////////////////////////////////////////////
// INTERNAL VALUES
////////////////////////////////////////////////////
Expand Down

0 comments on commit b358cde

Please sign in to comment.