diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp index 3da7d7b5..7b5f0ea3 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/DataStreamer.hpp @@ -17,8 +17,11 @@ #include #include #include +#include -#include +#include + +#include #include #include @@ -39,7 +42,7 @@ class DataStreamer : public TopicRateCalculator using CallbackType = std::function; FASTDDSSPY_PARTICIPANTS_DllAPI @@ -56,7 +59,8 @@ class DataStreamer : public TopicRateCalculator FASTDDSSPY_PARTICIPANTS_DllAPI void add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) override; + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::tuple& type_ids_tuple) override; FASTDDSSPY_PARTICIPANTS_DllAPI void add_data( @@ -80,7 +84,7 @@ class DataStreamer : public TopicRateCalculator ddspipe::core::types::DdsTopic activated_topic_; - std::map types_discovered_; + std::map types_discovered_; mutable std::shared_timed_mutex mutex_; }; diff --git a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp index 185665d3..2cf1dd20 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/model/NetworkDatabase.hpp @@ -14,7 +14,7 @@ #pragma once -#include +#include #include #include diff --git a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp index f7186e20..70d34028 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp @@ -47,18 +47,18 @@ class SpyDdsParticipant : public ddspipe::participants::DynTypesParticipant const ddspipe::core::ITopic& topic) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_participant_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onParticipantDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ParticipantDiscoveryInfo&& info) override; FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_subscriber_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onReaderDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info); FASTDDSSPY_PARTICIPANTS_DllAPI - virtual void on_publisher_discovery( - fastdds::dds::DomainParticipant* participant, + virtual void onWriterDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info); protected: diff --git a/fastddsspy_participants/package.xml b/fastddsspy_participants/package.xml index dc40f5ff..7c296439 100644 --- a/fastddsspy_participants/package.xml +++ b/fastddsspy_participants/package.xml @@ -21,7 +21,7 @@ cpp_utils ddspipe_core ddspipe_participants - fastrtps + fastdds doxygen diff --git a/fastddsspy_participants/project_settings.cmake b/fastddsspy_participants/project_settings.cmake index aaed7e9e..61c9e459 100644 --- a/fastddsspy_participants/project_settings.cmake +++ b/fastddsspy_participants/project_settings.cmake @@ -24,12 +24,12 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants) -set(fastrtps_MINIMUM_VERSION "2.8") +set(fastdds_MINIMUM_VERSION "3.0.0") set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> diff --git a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp index 12d82e16..d0fbbded 100644 --- a/fastddsspy_participants/src/cpp/model/DataStreamer.cpp +++ b/fastddsspy_participants/src/cpp/model/DataStreamer.cpp @@ -14,11 +14,10 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -73,13 +72,16 @@ void DataStreamer::deactivate() } void DataStreamer::add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::tuple& type_ids_tuple) { + static_cast(type_ids_tuple); + std::unique_lock _(mutex_); // Add type to map if not yet // NOTE: it does not matter if it is already in set - types_discovered_[dynamic_type->get_name()] = dynamic_type; + types_discovered_[dynamic_type->get_name().to_string()] = dynamic_type; logInfo(FASTDDSSPY_DATASTREAMER, "\nAdding schema with name " << dynamic_type->get_name() << "."); } @@ -90,7 +92,7 @@ void DataStreamer::add_data( { TopicRateCalculator::add_data(topic, data); - fastrtps::types::DynamicType_ptr dyn_type; + fastdds::dds::DynamicType::_ref_type dyn_type; { std::shared_lock _(mutex_); diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index c9c85f04..0a544ab3 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include +#include #include #include @@ -56,12 +59,14 @@ std::shared_ptr SpyDdsParticipant::create_reader( return ddspipe::participants::DynTypesParticipant::create_reader(topic); } -void SpyDdsParticipant::on_participant_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onParticipantDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ParticipantDiscoveryInfo&& discovery_info) { + fastrtps::rtps::ParticipantProxyData proxy_copy_info(discovery_info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(discovery_info.info.m_guid)) + if (come_from_this_participant_(proxy_copy_info.m_guid)) { return; } @@ -69,18 +74,22 @@ void SpyDdsParticipant::on_participant_discovery( ParticipantInfo info; info.active = (discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DISCOVERED_PARTICIPANT || discovery_info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::CHANGED_QOS_PARTICIPANT); - info.name = std::string(discovery_info.info.m_participantName); - info.guid = discovery_info.info.m_guid; + info.name = std::string(proxy_copy_info.m_participantName); + info.guid = proxy_copy_info.m_guid; + + ddspipe::participants::rtps::CommonParticipant::onParticipantDiscovery(participant, std::move(discovery_info)); internal_notify_participant_discovered_(info); } -void SpyDdsParticipant::on_subscriber_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onReaderDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::ReaderDiscoveryInfo&& info) { + fastrtps::rtps::ReaderProxyData proxy_copy(info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(info.info.guid())) + if (come_from_this_participant_(proxy_copy.guid())) { return; } @@ -90,15 +99,19 @@ void SpyDdsParticipant::on_subscriber_discovery( // If participant left or dropped, this notification arrives as well endpoint_info.active = !(info.status == fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERY_STATUS::REMOVED_READER); + ddspipe::participants::DynTypesParticipant::onReaderDiscovery(participant, std::move(info)); + internal_notify_endpoint_discovered_(endpoint_info); } -void SpyDdsParticipant::on_publisher_discovery( - fastdds::dds::DomainParticipant* participant, +void SpyDdsParticipant::onWriterDiscovery( + fastrtps::rtps::RTPSParticipant* participant, fastrtps::rtps::WriterDiscoveryInfo&& info) { + fastrtps::rtps::WriterProxyData proxy_copy(info.info); + // If comes from this participant is not interesting - if (come_from_this_participant_(info.info.guid())) + if (come_from_this_participant_(proxy_copy.guid())) { return; } @@ -108,6 +121,8 @@ void SpyDdsParticipant::on_publisher_discovery( // If participant left or dropped, this notification arrives as well endpoint_info.active = !(info.status == fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER); + ddspipe::participants::DynTypesParticipant::onWriterDiscovery(participant, std::move(info)); + internal_notify_endpoint_discovered_(endpoint_info); } @@ -140,9 +155,7 @@ void SpyDdsParticipant::internal_notify_endpoint_discovered_( bool SpyDdsParticipant::come_from_this_participant_( const ddspipe::core::types::Guid& guid) const noexcept { - return (guid.guid_prefix() == dds_participant_->guid().guidPrefix - || guid.guid_prefix() == rtps_participant_->getGuid().guidPrefix - ); + return (guid.guid_prefix() == rtps_participant_->getGuid().guidPrefix); } } /* namespace participants */ diff --git a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp index ad7ac427..22edf344 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyParticipant.cpp @@ -75,7 +75,7 @@ utils::ReturnCode SpyParticipant::new_participant_info_( ParticipantInfo info = participant_info.info; ddspipe::core::types::Guid guid = info.guid; model_->participant_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::RETCODE_OK; + return utils::ReturnCode::OK; } utils::ReturnCode SpyParticipant::new_endpoint_info_( @@ -86,7 +86,7 @@ utils::ReturnCode SpyParticipant::new_endpoint_info_( EndpointInfo info = endpoint_info.info; ddspipe::core::types::Guid guid = info.guid; model_->endpoint_database_.add_or_modify(std::move(guid), std::move(info)); - return utils::ReturnCode::RETCODE_OK; + return utils::ReturnCode::OK; } } /* namespace participants */ diff --git a/fastddsspy_tool/project_settings.cmake b/fastddsspy_tool/project_settings.cmake index 89b44db8..40cb75d9 100644 --- a/fastddsspy_tool/project_settings.cmake +++ b/fastddsspy_tool/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/fastddsspy_tool/src/cpp/tool/Controller.cpp b/fastddsspy_tool/src/cpp/tool/Controller.cpp index 3397d743..67c83e0c 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.cpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.cpp @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -111,25 +111,26 @@ void Controller::run_command_( } } -fastrtps::types::DynamicData_ptr Controller::get_dynamic_data_( - const fastrtps::types::DynamicType_ptr& dyn_type, +fastdds::dds::DynamicData::_ref_type Controller::get_dynamic_data_( + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) noexcept { // TODO fast this should not be done, but dyn types API is like it is. auto& data_no_const = const_cast(data); // Create PubSub Type - fastrtps::types::DynamicPubSubType pubsub_type(dyn_type); - fastrtps::types::DynamicData_ptr dyn_data(fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type)); + fastdds::dds::DynamicPubSubType pubsub_type(dyn_type); + fastdds::dds::DynamicData::_ref_type dyn_data(fastdds::dds::DynamicDataFactory::get_instance()->create_data(dyn_type)); - pubsub_type.deserialize(&data_no_const.payload, dyn_data.get()); + // pubsub_type.deserialize(&data_no_const.payload, dyn_data.get()); + pubsub_type.deserialize(&data_no_const.payload, &dyn_data); return dyn_data; } void Controller::data_stream_callback_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) { // Block entrance so prints does not collapse @@ -141,13 +142,16 @@ void Controller::data_stream_callback_( // TODO fast this does not make much sense as dynamictypes::print does not allow to choose target // change in dyn types to be able to print it in view view_.show("---"); - fastrtps::types::DynamicDataHelper::print(dyn_data.get()); + std::stringstream ss; + ss << std::setw(4); + auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; view_.show("---\n"); } void Controller::data_stream_callback_verbose_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) { // Block entrance so prints does not collapse @@ -170,7 +174,10 @@ void Controller::data_stream_callback_verbose_( // Print data view_.show("data:\n---"); - fastrtps::types::DynamicDataHelper::print(dyn_data.get()); + std::stringstream ss; + ss << std::setw(4); + auto ret = fastdds::dds::json_serialize(dyn_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; view_.show("---\n"); } @@ -310,7 +317,7 @@ void Controller::print_command_( std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { @@ -363,7 +370,7 @@ void Controller::print_command_( callback = std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { @@ -375,7 +382,7 @@ void Controller::print_command_( callback = std::make_shared( [this]( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data ) { diff --git a/fastddsspy_tool/src/cpp/tool/Controller.hpp b/fastddsspy_tool/src/cpp/tool/Controller.hpp index 7d722861..c5860092 100644 --- a/fastddsspy_tool/src/cpp/tool/Controller.hpp +++ b/fastddsspy_tool/src/cpp/tool/Controller.hpp @@ -17,7 +17,8 @@ #include #include -#include +#include +#include #include @@ -52,18 +53,18 @@ class Controller //////////////////////////// // DATA STREAM CALLBACKS - static fastrtps::types::DynamicData_ptr get_dynamic_data_( - const fastrtps::types::DynamicType_ptr& dyn_type, + static fastdds::dds::DynamicData::_ref_type get_dynamic_data_( + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data) noexcept; void data_stream_callback_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data); void data_stream_callback_verbose_( const ddspipe::core::types::DdsTopic& topic, - const fastrtps::types::DynamicType_ptr& dyn_type, + const fastdds::dds::DynamicType::_ref_type& dyn_type, const ddspipe::core::types::RtpsPayloadData& data); ///////////////////// diff --git a/fastddsspy_yaml/project_settings.cmake b/fastddsspy_yaml/project_settings.cmake index c8540d1d..3b024885 100644 --- a/fastddsspy_yaml/project_settings.cmake +++ b/fastddsspy_yaml/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants