From 5374859f12adeeccb96f51695d1aea665b5bae99 Mon Sep 17 00:00:00 2001 From: Manuel Valch Date: Wed, 28 Aug 2024 21:55:08 +0200 Subject: [PATCH] Add plotjuggler group creation and data reading With recent version of fastDDS we can now read wml file with key, so read this value and create group. Plotjuggler groups are now created in FastDdsDataStreamer so that it can latter handle them. Issue: [https://github.com/eProsima/fastdds-visualizer-plugin/issues/56] Signed-off-by: Manuel Valch --- .../datastreamer/FastDdsDataStreamer.cpp | 53 ++++++++++++++++++- .../datastreamer/FastDdsDataStreamer.hpp | 4 +- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp index a3194f1..f8fb6ea 100644 --- a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp +++ b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.cpp @@ -96,7 +96,7 @@ bool FastDdsDataStreamer::start( configuration_.data_type_configuration); } - running_ = timeSeriesCreation(); + running_ = pjGroupCreation(); return running_; } @@ -139,6 +139,55 @@ bool FastDdsDataStreamer::xmlLoadState( return configuration_.xmlLoadState(parent_element); } + +void FastDdsDataStreamer::onNewInstance(const std::string& topic_name, const std::string& instance_name) +{ + // NUMERIC + + + // First we need to now which series belong to the instance and then register them + // this will all be name based, i.e on topic name + std::vector numeric_series = fastdds_handler_.numeric_data_series_names(); + std::vector string_series = fastdds_handler_.string_data_series_names(); + + // get Pj group serie belong to + + for (const auto& series : numeric_series) + { + std::size_t char_id = series.find_first_of("/"); + std::string topic_name = series.substr(0U, char_id); + std::string series_name = series.substr(char_id); + + if (plot_groups_.end() == plot_groups_.find(topic_name)) + { + // Create plotjuggler group + DEBUG("Creating plotjuggler group: " << topic_name); + plot_groups_.insert({topic_name, std::make_shared(topic_name)}); + } + // Create a series + DEBUG("Creating numeric series: " << series_name); + dataMap().addNumeric(series_name, plot_groups_.at(topic_name)); + } + + // STRING + for (const auto& series : string_series) + { + std::size_t char_id = series.find_first_of("/"); + std::string topic_name = series.substr(0U, char_id); + std::string series_name = series.substr(char_id); + + if (plot_groups_.end() == plot_groups_.find(topic_name)) + { + // Create plotjuggler group + DEBUG("Creating plotjuggler group: " << topic_name); + plot_groups_.insert({topic_name, std::make_shared(topic_name)}); + } + // Create a series + DEBUG("Creating string series: " << series_name); + dataMap().addStringSeries(series_name, plot_groups_.at(topic_name)); + } +} + //////////////////////////////////////////////////// // FASTDDS LISTENER METHODS //////////////////////////////////////////////////// @@ -237,7 +286,7 @@ void FastDdsDataStreamer::connect_to_domain_( select_topics_dialog_.connect_to_domain(domain_id); } -bool FastDdsDataStreamer::timeSeriesCreation() +bool FastDdsDataStreamer::pjGroupCreation() { // Get all series from topics and create them diff --git a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp index 8b8b791..6effa02 100644 --- a/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp +++ b/plugins/datastreamer_plugin/datastreamer/FastDdsDataStreamer.hpp @@ -88,6 +88,8 @@ class FastDdsDataStreamer : bool xmlLoadState( const QDomElement& parent_element) override; + void onNewInstance(const std::string& topic_name, const std::string& instance_name); + //////////////////////////////////////////////////// // FASTDDS LISTENER METHODS //////////////////////////////////////////////////// @@ -133,7 +135,7 @@ class FastDdsDataStreamer : unsigned int domain_id); - bool timeSeriesCreation(); + bool pjGroupCreation(); //////////////////////////////////////////////////// // INTERNAL VALUES