Skip to content

Commit

Permalink
Print name of the incompatible entity instead of guid
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>
  • Loading branch information
rsanchez15 committed Jan 29, 2025
1 parent df0ce30 commit b30ea7d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/fastdds_monitor/backend/SyncBackendConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 16 additions & 1 deletion src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 30 additions & 0 deletions src/backend/SyncBackendConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b30ea7d

Please sign in to comment.