Skip to content

Commit

Permalink
eCAL core: provide TopicInformation (encoding, type, descriptor) inst…
Browse files Browse the repository at this point in the history
…ead of 2 strings (type, schema). (#1126)

* eCAL core: provide TopicInformation (encoding, type, descriptor) instead of 2 strings (type, schema).
This commit contains various API changes, however made in a semver compliant way.
- Adds various API functions and deprecates old ones
- Adds field to topic.proto file
- For communication compatibility, descriptor information is send out on old and new fields in proto message

Occurrences of deprecated functions fixed in eCAL Code (Samples, Apps, Tests)
  • Loading branch information
KerstinKeller committed Jun 16, 2023
1 parent 2cd7db4 commit 7011931
Show file tree
Hide file tree
Showing 65 changed files with 1,260 additions and 646 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
shell: bash

- name: Build Release
run: cmake --build . --config Release
run: cmake --build . --config Release -- -k 0
working-directory: ${{ runner.workspace }}/_build

# Create Python Wheels
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
shell: bash

- name: Build Release
run: cmake --build . --config Release
run: cmake --build . --config Release -- -k 0
working-directory: ${{ runner.workspace }}/_build

# Create Python Wheels
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ if(BUILD_ECAL_TESTS)
add_subdirectory(testing/ecal/pubsub_proto_test)
add_subdirectory(testing/ecal/pubsub_test)
add_subdirectory(testing/ecal/topic2mcast_test)
add_subdirectory(testing/ecal/util_test)

# ------------------------------------------------------
# test apps
Expand Down
5 changes: 3 additions & 2 deletions app/mon/mon_cli/src/ecal_mon_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,9 @@ void ProcProto(const std::string& topic_name, int msg_count)
std::this_thread::sleep_for(std::chrono::milliseconds(1000));

// get topic type
std::string topic_type = eCAL::Util::GetTopicTypeName(topic_name);
if(topic_type.empty())
eCAL::STopicInformation topic_info;
eCAL::Util::GetTopicInformation(topic_name, topic_info);
if(topic_info.type.empty())
{
std::cout << "could not get type for topic " << topic_name << std::endl;
return;
Expand Down
30 changes: 23 additions & 7 deletions app/mon/mon_gui/src/widgets/ecalmon_tree_widget/topic_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ TopicWidget::TopicWidget(QWidget *parent)
(int)TopicTreeModel::Columns::HOST_NAME,
(int)TopicTreeModel::Columns::PROCESS_NAME,
(int)TopicTreeModel::Columns::UNIT_NAME,
(int)TopicTreeModel::Columns::TOPIC_ENCODING,
(int)TopicTreeModel::Columns::MESSAGE_TYPE,
(int)TopicTreeModel::Columns::QOS,
(int)TopicTreeModel::Columns::TRANSPORT_LAYER,
Expand All @@ -94,6 +95,7 @@ TopicWidget::TopicWidget(QWidget *parent)
(int)TopicTreeModel::Columns::UNIT_NAME,
(int)TopicTreeModel::Columns::HOST_NAME,
(int)TopicTreeModel::Columns::PROCESS_NAME,
(int)TopicTreeModel::Columns::TOPIC_ENCODING,
(int)TopicTreeModel::Columns::MESSAGE_TYPE,
(int)TopicTreeModel::Columns::QOS,
(int)TopicTreeModel::Columns::TRANSPORT_LAYER,
Expand All @@ -119,6 +121,12 @@ TopicWidget::TopicWidget(QWidget *parent)
topic.name = "Topic";
preconfigured_group_by_settings.push_back(topic);

EcalmonTreeWidget::GroupSetting encoding;
encoding.group_by_columns = { (int)TopicTreeModel::Columns::TOPIC_ENCODING, (int)TopicTreeModel::Columns::TOPIC_NAME };
encoding.auto_expand = -1;
encoding.name = "Encoding";
preconfigured_group_by_settings.push_back(encoding);

EcalmonTreeWidget::GroupSetting type;
type.group_by_columns = { (int)TopicTreeModel::Columns::MESSAGE_TYPE, (int)TopicTreeModel::Columns::TOPIC_NAME };
type.auto_expand = -1;
Expand All @@ -142,6 +150,7 @@ TopicWidget::TopicWidget(QWidget *parent)
(int)TopicTreeModel::Columns::UNIT_NAME,
(int)TopicTreeModel::Columns::HOST_NAME,
(int)TopicTreeModel::Columns::PID,
(int)TopicTreeModel::Columns::TOPIC_ENCODING,
(int)TopicTreeModel::Columns::MESSAGE_TYPE,
(int)TopicTreeModel::Columns::TOPIC_SIZE,
(int)TopicTreeModel::Columns::MESSAGE_DROPS,
Expand Down Expand Up @@ -249,6 +258,7 @@ void TopicWidget::autoSizeColumns()
(int)TopicTreeModel::Columns::UNIT_NAME,
(int)TopicTreeModel::Columns::HOST_NAME,
(int)TopicTreeModel::Columns::PID,
(int)TopicTreeModel::Columns::TOPIC_ENCODING,
(int)TopicTreeModel::Columns::MESSAGE_TYPE,
(int)TopicTreeModel::Columns::HEARTBEAT,
(int)TopicTreeModel::Columns::QOS,
Expand Down Expand Up @@ -298,10 +308,13 @@ void TopicWidget::openReflectionWindowForSelection()
}
else
{
QString topic_encoding = topic_item->data(TopicTreeItem::Columns::TENCODING, (Qt::ItemDataRole)ItemDataRoles::RawDataRole).toString(); //-V1016
QString topic_type = topic_item->data(TopicTreeItem::Columns::TTYPE, (Qt::ItemDataRole)ItemDataRoles::RawDataRole).toString(); //-V1016


QString combined_topic_encoding_type{ QString::fromStdString(eCAL::Util::CombinedTopicEncodingAndType(topic_encoding.toStdString(), topic_type.toStdString())) };

// Create a new Reflection Window
VisualisationWindow* visualisation_window = new VisualisationWindow(topic_name, topic_type);
VisualisationWindow* visualisation_window = new VisualisationWindow(topic_name, combined_topic_encoding_type);
visualisation_window->setAttribute(Qt::WA_DeleteOnClose, true);
visualisation_window->setParseTimeEnabled(parse_time_);
visualisation_windows_[topic_name] = visualisation_window;
Expand Down Expand Up @@ -331,21 +344,24 @@ void TopicWidget::fillContextMenu(QMenu& menu, const QList<QAbstractTreeItem*>&

if (item)
{
QString topic_name = item->data((int)TopicTreeItem::Columns::TNAME).toString();
QString topic_type = item->data((int)TopicTreeItem::Columns::TTYPE).toString();
QString topic_name = item->data((int)TopicTreeItem::Columns::TNAME).toString();
QString topic_encoding = item->data((int)TopicTreeItem::Columns::TENCODING).toString();
QString topic_type = item->data((int)TopicTreeItem::Columns::TTYPE).toString();

QString combined_topic_encoding_type{ QString::fromStdString(eCAL::Util::CombinedTopicEncodingAndType(topic_encoding.toStdString(), topic_type.toStdString()))};

QAction* reflection_action = new QAction(tr("Inspect topic \"") + topic_name + "\"", &menu);
connect(reflection_action, &QAction::triggered, this, &TopicWidget::openReflectionWindowForSelection);
menu.addSeparator();
menu.addAction(reflection_action);

auto reflection_with_menu = menu.addMenu(tr("Inspect topic \"") + topic_name + "\" with");
for (const auto& matching_plugin_data : PluginManager::getInstance()->getMatchingPluginData(topic_name, topic_type))
for (const auto& matching_plugin_data : PluginManager::getInstance()->getMatchingPluginData(topic_name, combined_topic_encoding_type))
{
auto reflection_with_action = reflection_with_menu->addAction(matching_plugin_data.meta_data.name);
const auto iid = matching_plugin_data.iid;
connect(reflection_with_action, &QAction::triggered, this, [this, iid, topic_name, topic_type]() {
emit requestVisualisationDockWidget(topic_name, topic_type, iid);
connect(reflection_with_action, &QAction::triggered, this, [this, iid, topic_name, combined_topic_encoding_type]() {
emit requestVisualisationDockWidget(topic_name, combined_topic_encoding_type, iid);
});
}
}
Expand Down
33 changes: 29 additions & 4 deletions app/mon/mon_gui/src/widgets/models/topic_tree_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,31 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
{
return topic_.direction().c_str();
}
else if (column == Columns::TENCODING)
{
// When the monitor didn't tell us the topic encoding, we ask eCAL::Util instead
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_encoding = topic_.tinfo().encoding();
if (!monitor_topic_encoding.empty())
{
return monitor_topic_encoding.c_str();
}
else
{
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
eCAL::STopicInformation topic_info;
eCAL::Util::GetTopicInformation(monitor_topic_name, topic_info);
return topic_info.encoding.c_str();
}
}
}
else if (column == Columns::TTYPE)
{
// When the monitor didn't tell us the topic type, we ask eCAL::Util instead
const std::string monitor_topic_type = topic_.ttype();
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_type = topic_.tinfo().type();
if (!monitor_topic_type.empty())
{
return monitor_topic_type.c_str();
Expand All @@ -89,14 +110,15 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
return eCAL::Util::GetTopicTypeName(monitor_topic_name).c_str();
eCAL::STopicInformation topic_info;
eCAL::Util::GetTopicInformation(monitor_topic_name, topic_info);
return topic_info.type.c_str();
}
}
return "";
}
else if (column == Columns::TDESC)
{
return topic_.tdesc().c_str();
return topic_.tinfo().desc().c_str();
}
else if (column == Columns::TQOS)
{
Expand Down Expand Up @@ -175,6 +197,7 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
|| (column == Columns::UNAME)
|| (column == Columns::TNAME)
|| (column == Columns::DIRECTION)
|| (column == Columns::TENCODING)
|| (column == Columns::TTYPE))
{
const QString raw_data = data(column, (Qt::ItemDataRole)ItemDataRoles::RawDataRole).toString(); //-V1016
Expand Down Expand Up @@ -269,6 +292,7 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
|| (column == Columns::UNAME)
|| (column == Columns::TNAME)
|| (column == Columns::DIRECTION)
|| (column == Columns::TENCODING)
|| (column == Columns::TTYPE))
{
auto raw_data = data(column, (Qt::ItemDataRole)ItemDataRoles::RawDataRole); //-V1016
Expand Down Expand Up @@ -332,6 +356,7 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
|| (column == Columns::UNAME)
|| (column == Columns::TNAME)
|| (column == Columns::DIRECTION)
|| (column == Columns::TENCODING)
|| (column == Columns::TTYPE))
{
const QString raw_data = data(column, (Qt::ItemDataRole)ItemDataRoles::RawDataRole).toString(); //-V1016
Expand Down
1 change: 1 addition & 0 deletions app/mon/mon_gui/src/widgets/models/topic_tree_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TopicTreeItem :
TID,
TNAME,
DIRECTION,
TENCODING,
TTYPE,
TDESC,
TQOS,
Expand Down
3 changes: 3 additions & 0 deletions app/mon/mon_gui/src/widgets/models/topic_tree_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class TopicTreeModel : public GroupTreeModel
PROCESS_NAME,
MESSAGE_TYPE,
HEARTBEAT,
TOPIC_ENCODING,
TOPIC_DESCRIPTOR,
QOS,
TRANSPORT_LAYER,
Expand Down Expand Up @@ -95,6 +96,7 @@ class TopicTreeModel : public GroupTreeModel
{ Columns::TOPIC_ID, "Topic ID" },
{ Columns::TOPIC_NAME, "Topic" },
{ Columns::DIRECTION, "Direction" },
{ Columns::TOPIC_ENCODING, "Encoding" },
{ Columns::MESSAGE_TYPE, "Message Type" },
{ Columns::TOPIC_DESCRIPTOR, "Descriptor" },
{ Columns::QOS, "QoS" },
Expand All @@ -118,6 +120,7 @@ class TopicTreeModel : public GroupTreeModel
{ Columns::TOPIC_ID, (int)TopicTreeItem::Columns::TID },
{ Columns::TOPIC_NAME, (int)TopicTreeItem::Columns::TNAME },
{ Columns::DIRECTION, (int)TopicTreeItem::Columns::DIRECTION },
{ Columns::TOPIC_ENCODING, (int)TopicTreeItem::Columns::TENCODING },
{ Columns::MESSAGE_TYPE, (int)TopicTreeItem::Columns::TTYPE },
{ Columns::TOPIC_DESCRIPTOR, (int)TopicTreeItem::Columns::TDESC },
{ Columns::QOS, (int)TopicTreeItem::Columns::TQOS },
Expand Down
2 changes: 2 additions & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ set(ecal_cmn_header_src
src/ecal_log_impl.h
src/ecal_registration_provider.h
src/ecal_registration_receiver.h
src/ecal_sample_to_topicinfo.h
src/ecal_thread.h
src/ecal_timegate.h
src/getenvvar.h
Expand Down Expand Up @@ -343,6 +344,7 @@ set(ecal_header_cmn
include/ecal/ecal_util.h
include/ecal/ecalc.h
include/ecal/ecalc_types.h
include/ecal/types/topic_information.h
)

set(ecal_header_cimpl
Expand Down
11 changes: 9 additions & 2 deletions ecal/core/include/ecal/ecal_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#pragma once

#include <ecal/cimpl/ecal_callback_cimpl.h>
#include <ecal/types/topic_information.h>

#include <functional>
#include <string>
Expand Down Expand Up @@ -66,8 +67,11 @@ namespace eCAL
long long time; //!< publisher event time in µs
long long clock; //!< publisher event clock
std::string tid; //!< topic id of the of the connected subscriber (for pub_event_update_connection only)
std::string ttype; //!< topic type information of the connected subscriber (for pub_event_update_connection only)
std::string tdesc; //!< topic descriptor information of the connected subscriber (for pub_event_update_connection only)
[[deprecated("Use the separate infos encoding and type in member tinfo instead of ttype.")]]
std::string ttype; //!< topic type information of the connected publisher (for sub_event_update_connection only)
[[deprecated("Use the tinfo.descriptor instead of tdesc.")]]
std::string tdesc; //!< topic descriptor information of the connected publisher (for sub_event_update_connection only)
STopicInformation tinfo; //!< topic information of the connected subscriber (for pub_event_update_connection only)
};

/**
Expand All @@ -85,8 +89,11 @@ namespace eCAL
long long time; //!< subscriber event time in µs
long long clock; //!< subscriber event clock
std::string tid; //!< topic id of the of the connected publisher (for sub_event_update_connection only)
[[deprecated("Use the separate infos encoding and type in member tinfo instead of ttype.")]]
std::string ttype; //!< topic type information of the connected publisher (for sub_event_update_connection only)
[[deprecated("Use the tinfo.descriptor instead of tdesc.")]]
std::string tdesc; //!< topic descriptor information of the connected publisher (for sub_event_update_connection only)
STopicInformation tinfo; //!< topic information of the connected subscriber (for pub_event_update_connection only)
};

/**
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/include/ecal/ecal_monitoring_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <ecal/ecal_os.h>
#include <ecal/ecal_monitoring_entity.h>
#include <ecal/types/topic_information.h>

#include <map>
#include <string>
Expand Down Expand Up @@ -64,8 +65,7 @@ namespace eCAL
std::string tid; //!< topic id
std::string tname; //!< topic name
std::string direction; //!< direction (publisher, subscriber)
std::string ttype; //!< topic type (protocol)
std::string tdesc; //!< topic description (protocol descriptor)
STopicInformation tinfo; //!< topic information (encoding, type, descriptor)
int tsize; //!< topic size

bool tlayer_ecal_udp_mc; //!< transport layer udp active
Expand Down
Loading

0 comments on commit 7011931

Please sign in to comment.