43int main(
int argc,
char *argv[])
52 std::vector <string> color_map;
53 color_map.push_back (
"cadetblue1");
54 color_map.push_back (
"antiquewhite1");
55 color_map.push_back (
"darkolivegreen2");
56 color_map.push_back (
"gold2");
57 color_map.push_back (
"darkorange2");
58 color_map.push_back (
"cadetblue4");
59 color_map.push_back (
"coral2");
60 color_map.push_back (
"firebrick3");
61 color_map.push_back (
"forestgreen");
62 color_map.push_back (
"cornflowerblue");
66 std::string from_portnumber = p.
check(
"from_portnumber",
yarp::os::Value(std::string(
"*")),
"").asString();
67 std::string to_portnumber = p.
check(
"to_portnumber",
yarp::os::Value(std::string(
"*")),
"").asString();
68 std::string from_portname = p.
check(
"from_portname",
yarp::os::Value(std::string(
"*")),
"").asString();
69 std::string to_portname = p.
check(
"to_portname",
yarp::os::Value(std::string(
"*")),
"").asString();
71 bool display_yarprun_processes =
false;
72 bool display_log_ports =
false;
73 bool display_clock_ports =
false;
74 bool display_unconnected_ports =
false;
77 if (p.
check(
"display_yarprun_processes")) { display_yarprun_processes =
true;}
78 if (p.
check(
"display_log_ports")) { display_log_ports =
true; }
79 if (p.
check(
"display_clock_ports")) { display_clock_ports =
true; }
80 if (p.
check(
"display_unconnnected_ports")) { display_unconnected_ports =
true; }
92 if (from_ip !=
"*" || to_ip !=
"*")
95 conns= conns_filtered;
97 if (from_portnumber !=
"*" || to_portnumber !=
"*")
100 conns = conns_filtered;
102 if (from_portname !=
"*" || to_portname !=
"*")
105 conns = conns_filtered;
108 std::string sss =
"Connections:\n";
109 if (conns.size() !=0)
110 for (
auto it = conns.begin(); it!=conns.end(); it++)
112 sss += it->src.name +
" (" + it->src.ip +
":" + it->src.port_number +
") -> " +
113 it->dst.name +
" (" + it->dst.ip +
":" + it->dst.port_number +
") with carrier: (" +
123 if (to_dotfile !=
"")
127 file.open(to_dotfile.c_str(), std::ios::out);
128 file <<
"digraph G{" <<endl;
129 file <<
"splines=\"compound\"" << endl;
140 file <<
"subgraph cluster_net{" << endl;
141 size_t machine_counter = 0;
142 size_t color_map_index = 0;
143 for (
auto machines_ip_it = ml.begin(); machines_ip_it != ml.end(); machines_ip_it++, machine_counter++)
146 file <<
"subgraph cluster_machine"<<machine_counter <<
" {" << endl;
148 size_t process_counter = 0;
149 for (
auto process_name_it = pl.begin(); process_name_it != pl.end(); process_name_it++, process_counter++)
152 if (display_yarprun_processes ==
false)
154 std::size_t found = process_name_it->find(
"yarprun");
155 if (found != std::string::npos) { process_counter--;
continue;}
158 file <<
"subgraph cluster_process" << process_counter<<
" {" << endl;
159 prof.
filterPortsListByProcess(detailed_ports_filtered_by_ip, detailed_ports_filtered_by_ip_and_process, *process_name_it);
161 for (
auto ports_it = detailed_ports_filtered_by_ip_and_process.begin(); ports_it != detailed_ports_filtered_by_ip_and_process.end(); ports_it++)
164 if (display_log_ports ==
false)
166 std::size_t found = ports_it->info.name.find(
"/log");
167 if (found != std::string::npos) {
continue; }
171 if (display_clock_ports ==
false)
173 std::size_t found = ports_it->info.name.find(
"/clock:i");
174 if (found != std::string::npos) {
continue; }
178 if (display_unconnected_ports ==
false)
180 if (ports_it->inputs.size() == 0 &&
181 ports_it->outputs.size() == 0)
187 file <<
"\"" << ports_it->info.name <<
"\";" << endl;
189 file <<
"label = \""<< *process_name_it <<
"\";" << endl;
192 file <<
"label = \"" << *machines_ip_it <<
"\";" << endl;
193 file <<
"style = filled" << endl;
194 file <<
"color = " << color_map[color_map_index++] << endl;
195 if (color_map_index >=10) color_map_index=0;
200 for (
auto connection_it = conns.begin(); connection_it != conns.end(); connection_it++)
203 if (display_log_ports ==
false)
205 std::size_t founds = connection_it->src.name.find(
"/log");
206 std::size_t foundd = connection_it->dst.name.find(
"/log");
207 if (founds != std::string::npos ||
208 foundd != std::string::npos) {
continue; }
212 if (display_clock_ports ==
false)
214 std::size_t founds = connection_it->src.name.find(
"/clock:i");
215 std::size_t foundd = connection_it->dst.name.find(
"/clock:i");
216 if (founds != std::string::npos ||
217 foundd != std::string::npos) {
222 std::string protocol_name = connection_it->carrier;
223 std::string color_connection =
"black";
224 if (protocol_name ==
"tcp") { color_connection =
"blue";}
225 else if (protocol_name ==
"udp") { color_connection =
"red"; }
226 else if (protocol_name ==
"fast_tcp") { color_connection =
"green"; }
227 else if (protocol_name ==
"mjpeg") { color_connection =
"darkorange2"; }
228 else if (protocol_name ==
"tcpros") { color_connection =
"darkgray"; }
230 file <<
"\"" << connection_it->src.name <<
"\"" <<
" -> "
231 <<
"\"" << connection_it->dst.name <<
"\"" <<
" [label = \""<< protocol_name <<
"\" color = "<< color_connection <<
"]" << endl;
int main(int argc, char *argv[])