Skip to content

Commit 47c77d3

Browse files
committed
Adapt to newer monitoring.
1 parent 73c37cc commit 47c77d3

5 files changed

Lines changed: 59 additions & 65 deletions

File tree

app/rec/rec_client_core/src/monitoring_thread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace eCAL
4242
{
4343
TopicInfoMap topic_info_snapshot;
4444
std::set<STopicId> publisher_ids;
45-
auto got_publisher_ids = eCAL::Registration::GetPublisherIDs(publisher_ids);
45+
std::ignore = eCAL::Registration::GetPublisherIDs(publisher_ids);
4646

4747
for (const auto& publisher_id : publisher_ids)
4848
{

app/rec/rec_gui/src/widgets/topic_widget/topic_list_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void TopicListModel::reset(const std::map<std::string, eCAL::rec_server::TopicIn
265265
{
266266
Topic topic_info;
267267
topic_info.name_ = topic.first.c_str();
268-
topic_info.type_ = topic.second.type_.c_str();
268+
topic_info.type_ = topic.second.type_.begin()->name.c_str(); // TODO this will print the first, maybe we need more here?
269269
topic_info.publishers_ = topic.second.publishers_;
270270
topic_info.listed_ = (listed_topics.find(topic.first) != listed_topics.end());
271271
topic_info.in_topic_info_map_ = true;

app/rec/rec_server_core/include/rec_server_core/rec_server_types.h

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,32 @@ namespace eCAL
3636
{
3737
namespace rec_server
3838
{
39+
using TopicName_T = std::string;
40+
using Hostname_T = std::string;
41+
using UnitName_T = std::string;
42+
using DataFrequency_T = double;
43+
using ProcessID_T = int32_t;
44+
using IsEcalRecClientRunning_T = bool;
45+
3946
struct TopicInfo
4047
{
41-
TopicInfo(const std::string& type)
42-
: type_(type)
43-
{}
48+
TopicInfo()
49+
{
50+
}
4451

45-
std::string type_; ///< Type of the topic (e.g. the protobuf-type)
46-
std::map<std::string, std::set<std::string>> publishers_; ///< {hostname: [publisher_names]}
47-
std::map<std::pair<std::string, int32_t>, double> rec_subscribers_; ///< {(hostname, process_id): data_frequency}
48-
};
52+
void AddTypeInfo(const eCAL::SDataTypeInformation& data_type_info)
53+
{
54+
type_.insert(data_type_info);
55+
}
4956

50-
typedef std::map<std::string, eCAL::rec_server::TopicInfo> TopicInfoMap_T;
51-
typedef std::map<std::string, bool> HostsRunningEcalRec_T;
52-
typedef std::function<void(const TopicInfoMap_T&, const HostsRunningEcalRec_T&)> PostUpdateCallback_T;
57+
std::set<SDataTypeInformation> type_;
58+
std::map<Hostname_T, std::set<UnitName_T>> publishers_;
59+
std::map<std::pair<Hostname_T, ProcessID_T>, DataFrequency_T> rec_subscribers_;
60+
};
5361

54-
typedef std::map<std::string, std::pair<eCAL::rec::RecorderStatus, eCAL::Time::ecal_clock::time_point>> RecorderStatusMap_T;
62+
using TopicInfoMap_T = std::map<TopicName_T, eCAL::rec_server::TopicInfo>;
63+
using HostsRunningEcalRec_T = std::map<Hostname_T, IsEcalRecClientRunning_T>;
64+
using PostUpdateCallback_T = std::function<void(const TopicInfoMap_T&, const HostsRunningEcalRec_T&)>;
65+
using RecorderStatusMap_T = std::map<std::string, std::pair<eCAL::rec::RecorderStatus, eCAL::Time::ecal_clock::time_point>>;
5566
}
5667
}

app/rec/rec_server_core/src/monitoring_thread.cpp

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323

2424
#include <ecal_utils/ecal_utils.h>
2525

26-
#ifdef _MSC_VER
27-
#pragma warning(push)
28-
#pragma warning(disable: 4100 4127 4146 4505 4800 4189 4592) // disable proto warnings
29-
#endif
30-
#include <ecal/core/pb/monitoring.pb.h>
31-
#include <ecal/core/pb/process.pb.h>
32-
#ifdef _MSC_VER
33-
#pragma warning(pop)
34-
#endif
35-
3626
#include <rec_client_core/ecal_rec_logger.h>
3727

3828
#include <iostream>
@@ -82,14 +72,10 @@ namespace eCAL
8272

8373
void MonitoringThread::Loop()
8474
{
85-
std::string monitoring_string;
86-
eCAL::pb::Monitoring monitoring_pb;
75+
eCAL::Monitoring::SMonitoring monitoring;
8776

88-
if (eCAL::Monitoring::GetMonitoring(monitoring_string))
77+
if (eCAL::Monitoring::GetMonitoring(monitoring))
8978
{
90-
monitoring_pb.Clear();
91-
monitoring_pb.ParseFromString(monitoring_string);
92-
9379
auto running_enabled_rec_clients = get_running_enabled_rec_clients_function_();
9480

9581
{
@@ -104,9 +90,9 @@ namespace eCAL
10490
topic_info_map_.clear();
10591

10692
// Re-create host list
107-
for (const auto& process : monitoring_pb.processes())
93+
for (const auto& process : monitoring.processes)
10894
{
109-
std::string host_name = process.host_name();
95+
std::string host_name = process.host_name;
11096
auto existing_host_it = hosts_running_ecal_rec_.find(host_name);
11197

11298
// Add host if it didn't exist already
@@ -116,57 +102,54 @@ namespace eCAL
116102
}
117103

118104
// set whether this host has an eCAL Rec client
119-
if (process.unit_name() == "eCALRecClient")
105+
if (process.unit_name == "eCALRecClient")
120106
{
121107
existing_host_it->second = true;
122108
}
123109
}
124110

111+
auto add_type_info = [this](auto topic) -> auto
112+
{
113+
auto topic_info_map_it = topic_info_map_.find(topic.topic_name);
114+
if (topic_info_map_it == topic_info_map_.end())
115+
{
116+
// Create a new topic entry
117+
auto emplace_result = topic_info_map_.emplace(topic.topic_name, eCAL::rec_server::TopicInfo());
118+
topic_info_map_it = emplace_result.first;
119+
}
120+
topic_info_map_it->second.AddTypeInfo(topic.datatype_information);
121+
return topic_info_map_it;
122+
};
123+
125124
// Update topic list
126-
for (const auto& topic : monitoring_pb.topics())
125+
for (const auto& publisher : monitoring.publishers)
127126
{
128-
// Create combined encoding:type type (to be fully compatible to old behavior)
129-
std::string combined_enc_type = eCAL::Util::CombinedTopicEncodingAndType(topic.datatype_information().encoding(), topic.datatype_information().name());
127+
auto topic_info_map_it = add_type_info(publisher);
130128

131-
auto topic_info_map_it = topic_info_map_.find(topic.topic_name());
132-
if (topic_info_map_it != topic_info_map_.end())
129+
// Set the topic publisher
130+
auto existing_publisher_it = topic_info_map_it->second.publishers_.find(publisher.host_name);
131+
if (existing_publisher_it != topic_info_map_it->second.publishers_.end())
133132
{
134-
// Only update the values if there are information available
135-
if (!combined_enc_type.empty() || !topic.datatype_information().name().empty())
136-
{
137-
topic_info_map_it->second.type_ = combined_enc_type;
138-
}
133+
existing_publisher_it->second.emplace(publisher.unit_name);
139134
}
140135
else
141136
{
142-
// Create a new topic entry
143-
topic_info_map_.emplace(topic.topic_name(), eCAL::rec_server::TopicInfo(combined_enc_type));
144-
topic_info_map_it = topic_info_map_.find(topic.topic_name());
137+
topic_info_map_it->second.publishers_.emplace(publisher.host_name, std::set<std::string>{publisher.unit_name});
145138
}
139+
}
146140

147-
// Set the topic publisher
148-
if (EcalUtils::String::Icompare(topic.direction(), "publisher"))
149-
{
150-
auto existing_publisher_it = topic_info_map_it->second.publishers_.find(topic.host_name());
151-
if (existing_publisher_it != topic_info_map_it->second.publishers_.end())
152-
{
153-
existing_publisher_it->second.emplace(topic.unit_name());
154-
}
155-
else
156-
{
157-
topic_info_map_it->second.publishers_.emplace(topic.host_name(), std::set<std::string>{topic.unit_name()});
158-
}
159-
}
141+
for (const auto& subscriber : monitoring.subscribers)
142+
{
143+
auto topic_info_map_it = add_type_info(subscriber);
160144

161145
// Set the subscribing eCAL Rec instances
162-
if (((topic.unit_name() == "eCALRecClient") || (topic.unit_name() == "eCALRecGUI"))
163-
&& EcalUtils::String::Icompare(topic.direction(), "subscriber"))
146+
if ((subscriber.unit_name == "eCALRecClient") || (subscriber.unit_name == "eCALRecGUI"))
164147
{
165-
auto running_enabled_rec_client_it = running_enabled_rec_clients.find(topic.host_name());
148+
auto running_enabled_rec_client_it = running_enabled_rec_clients.find(subscriber.host_name);
166149
if ((running_enabled_rec_client_it != running_enabled_rec_clients.end()
167-
&& (running_enabled_rec_client_it->second == topic.process_id())))
150+
&& (running_enabled_rec_client_it->second == subscriber.process_id)))
168151
{
169-
topic_info_map_it->second.rec_subscribers_[{topic.host_name(), topic.process_id()}] = (static_cast<double>(topic.data_frequency()) / 1000.0);
152+
topic_info_map_it->second.rec_subscribers_[{subscriber.host_name, subscriber.process_id}] = (static_cast<double>(subscriber.data_frequency) / 1000.0);
170153
}
171154
}
172155
}

app/rec/rec_server_core/src/monitoring_thread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ namespace eCAL
4848
public:
4949
void SetPostUpdateCallbacks(const std::vector<PostUpdateCallback_T>& post_update_callbacks);
5050

51-
std::map<std::string, eCAL::rec_server::TopicInfo> GetTopicInfoMap() const;
52-
std::map<std::string, bool> GetHostsRunningEcalRec() const;
51+
TopicInfoMap_T GetTopicInfoMap() const;
52+
HostsRunningEcalRec_T GetHostsRunningEcalRec() const;
5353

5454
/////////////////////////////////////////
5555
// Interruptible Thread overrides

0 commit comments

Comments
 (0)