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 }
0 commit comments