diff --git a/include/fastdds_monitor/backend/SyncBackendConnection.h b/include/fastdds_monitor/backend/SyncBackendConnection.h index fceb3dc0..94636b65 100644 --- a/include/fastdds_monitor/backend/SyncBackendConnection.h +++ b/include/fastdds_monitor/backend/SyncBackendConnection.h @@ -116,6 +116,10 @@ class SyncBackendConnection EntityKind get_type( backend::EntityId id); + //! Get entity by GUID in string format + backend::EntityId get_entity_by_guid( + const std::string& guid); + //! Get a summary of important data collected from the backend related with the entity with id \c id EntityInfo get_summary( backend::EntityId id); @@ -211,6 +215,10 @@ class SyncBackendConnection std::string get_deserialized_guid( const backend::GUID_s& data); + //! Convert a given entity guid in string format to GUID_s + backend::GUID_s get_serialize_guid( + const std::string& guid_str); + //! Get info from an entity from the Backend std::vector<EntityId> get_entities( EntityKind entity_type, diff --git a/src/Engine.cpp b/src/Engine.cpp index 134cbdd9..d06a3876 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -1193,8 +1193,23 @@ bool Engine::update_entity_status( backend::policy_documentation_description(policy_id) + std::string("\">here</a></html>"), "", true); + std::string remote_entity; + backend::EntityId remote_entity_id = backend_connection_.get_entity_by_guid(remote_entity_guid); + if (remote_entity_id.is_valid()) + { + EntityInfo entity_info = backend_connection_.get_info(remote_entity_id); + std::string remote_entity_kind = utils::to_string( + backend::entity_kind_to_QString(backend_connection_.get_type(remote_entity_id))); + std::stringstream ss; + ss << std::string(entity_info["alias"]) << " (" << remote_entity_kind << ")"; + remote_entity = ss.str(); + } + else + { + remote_entity = remote_entity_guid; + } auto remote_entity_item = new models::StatusTreeItem(id, kind, - std::string("Remote entity: " + remote_entity_guid), + std::string("Remote entity: " + remote_entity), sample.status, std::string(""), std::string( ""), remote_entity_guid, false); entity_status_model_->addItem(incompatible_qos_item, policy_item); diff --git a/src/backend/SyncBackendConnection.cpp b/src/backend/SyncBackendConnection.cpp index 1d5b32d1..b75ee53f 100644 --- a/src/backend/SyncBackendConnection.cpp +++ b/src/backend/SyncBackendConnection.cpp @@ -555,6 +555,22 @@ EntityKind SyncBackendConnection::get_type( } } +backend::EntityId SyncBackendConnection::get_entity_by_guid( + const std::string& guid) +{ + try + { + return StatisticsBackend::get_entity_by_guid(guid); + } + catch (const Exception& e) + { + qWarning() << "Fail getting entity by guid " << e.what(); + static_cast<void>(e); // In release qWarning does not compile and so e is not used + + return EntityId::invalid(); + } +} + std::vector<EntityId> SyncBackendConnection::get_entities( EntityKind entity_type, EntityId entity_id) @@ -940,6 +956,20 @@ std::string SyncBackendConnection::get_deserialized_guid( return StatisticsBackend::deserialize_guid(data); } +backend::GUID_s SyncBackendConnection::get_serialize_guid( + const std::string& guid_str) +{ + try + { + return StatisticsBackend::serialize_guid(guid_str); + } + catch(const std::exception& e) + { + qWarning() << "Error generating GUID from string " << e.what(); + } + return backend::GUID_s(); +} + bool SyncBackendConnection::build_source_target_entities_vectors( DataKind data_kind, EntityId source_entity_id,