44int main(
int argc,
char *argv[])
53 std::vector <string> color_map;
54 color_map.push_back (
"cadetblue1");
55 color_map.push_back (
"antiquewhite1");
56 color_map.push_back (
"darkolivegreen2");
57 color_map.push_back (
"gold2");
58 color_map.push_back (
"darkorange2");
59 color_map.push_back (
"cadetblue4");
60 color_map.push_back (
"coral2");
61 color_map.push_back (
"firebrick3");
62 color_map.push_back (
"forestgreen");
63 color_map.push_back (
"cornflowerblue");
67 std::string from_portnumber = p.
check(
"from_portnumber",
yarp::os::Value(std::string(
"*")),
"").asString();
68 std::string to_portnumber = p.
check(
"to_portnumber",
yarp::os::Value(std::string(
"*")),
"").asString();
69 std::string from_portname = p.
check(
"from_portname",
yarp::os::Value(std::string(
"*")),
"").asString();
70 std::string to_portname = p.
check(
"to_portname",
yarp::os::Value(std::string(
"*")),
"").asString();
72 bool display_yarprun_processes =
false;
73 bool display_log_ports =
false;
74 bool display_stats_ports =
false;
75 bool display_clock_ports =
false;
76 bool display_unconnected_ports =
false;
79 if (p.
check(
"display_yarprun_processes")) { display_yarprun_processes =
true;}
80 if (p.
check(
"display_log_ports")) { display_log_ports =
true; }
81 if (p.
check(
"display_stats_ports")) { display_stats_ports =
true; }
82 if (p.
check(
"display_clock_ports")) { display_clock_ports =
true; }
83 if (p.
check(
"display_unconnnected_ports")) { display_unconnected_ports =
true; }
95 if (from_ip !=
"*" || to_ip !=
"*")
98 conns= conns_filtered;
100 if (from_portnumber !=
"*" || to_portnumber !=
"*")
103 conns = conns_filtered;
105 if (from_portname !=
"*" || to_portname !=
"*")
108 conns = conns_filtered;
111 std::string sss =
"Connections:\n";
112 if (conns.size() !=0)
113 for (
auto it = conns.begin(); it!=conns.end(); it++)
115 sss += it->src.name +
" (" + it->src.ip +
":" + it->src.port_number +
") -> " +
116 it->dst.name +
" (" + it->dst.ip +
":" + it->dst.port_number +
") with carrier: (" +
126 if (to_dotfile !=
"")
130 file.open(to_dotfile.c_str(), std::ios::out);
131 file <<
"digraph G{" <<endl;
132 file <<
"splines=\"compound\"" << endl;
143 file <<
"subgraph cluster_net{" << endl;
144 size_t machine_counter = 0;
145 size_t color_map_index = 0;
146 for (
auto machines_ip_it = ml.begin(); machines_ip_it != ml.end(); machines_ip_it++, machine_counter++)
149 file <<
"subgraph cluster_machine"<<machine_counter <<
" {" << endl;
151 size_t process_counter = 0;
152 for (
auto process_name_it = pl.begin(); process_name_it != pl.end(); process_name_it++, process_counter++)
155 if (display_yarprun_processes ==
false)
157 std::size_t found = process_name_it->find(
"yarprun");
158 if (found != std::string::npos) { process_counter--;
continue;}
161 file <<
"subgraph cluster_process" << process_counter<<
" {" << endl;
162 prof.
filterPortsListByProcess(detailed_ports_filtered_by_ip, detailed_ports_filtered_by_ip_and_process, *process_name_it);
164 for (
auto ports_it = detailed_ports_filtered_by_ip_and_process.begin(); ports_it != detailed_ports_filtered_by_ip_and_process.end(); ports_it++)
167 if (display_log_ports ==
false)
169 std::size_t found = ports_it->info.name.find(
"/log");
170 if (found != std::string::npos) {
continue; }
174 if (display_stats_ports ==
false)
176 std::size_t found = ports_it->info.name.find(
"/stats:o");
177 if (found != std::string::npos) {
continue; }
181 if (display_clock_ports ==
false)
183 std::size_t found = ports_it->info.name.find(
"/clock:i");
184 if (found != std::string::npos) {
continue; }
188 if (display_unconnected_ports ==
false)
190 if (ports_it->inputs.size() == 0 &&
191 ports_it->outputs.size() == 0)
197 file <<
"\"" << ports_it->info.name <<
"\";" << endl;
199 file <<
"label = \""<< *process_name_it <<
"\";" << endl;
202 file <<
"label = \"" << *machines_ip_it <<
"\";" << endl;
203 file <<
"style = filled" << endl;
204 file <<
"color = " << color_map[color_map_index++] << endl;
205 if (color_map_index >=10) color_map_index=0;
210 for (
auto connection_it = conns.begin(); connection_it != conns.end(); connection_it++)
213 if (display_log_ports ==
false)
215 std::size_t founds = connection_it->src.name.find(
"/log");
216 std::size_t foundd = connection_it->dst.name.find(
"/log");
217 if (founds != std::string::npos ||
218 foundd != std::string::npos) {
continue; }
222 if (display_clock_ports ==
false)
224 std::size_t founds = connection_it->src.name.find(
"/clock:i");
225 std::size_t foundd = connection_it->dst.name.find(
"/clock:i");
226 if (founds != std::string::npos ||
227 foundd != std::string::npos) {
232 std::string protocol_name = connection_it->carrier;
233 std::string color_connection =
"black";
234 if (protocol_name ==
"tcp") { color_connection =
"blue";}
235 else if (protocol_name ==
"udp") { color_connection =
"red"; }
236 else if (protocol_name ==
"fast_tcp") { color_connection =
"green"; }
237 else if (protocol_name ==
"mjpeg") { color_connection =
"darkorange2"; }
238 else if (protocol_name ==
"tcpros") { color_connection =
"darkgray"; }
240 file <<
"\"" << connection_it->src.name <<
"\"" <<
" -> "
241 <<
"\"" << connection_it->dst.name <<
"\"" <<
" [label = \""<< protocol_name <<
"\" color = "<< color_connection <<
"]" << endl;
int main(int argc, char *argv[])