YARP
Yet Another Robot Platform
NetworkProfiler.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_PROFILER_NETWORK_PROFILER_H
7 #define YARP_PROFILER_NETWORK_PROFILER_H
8 
9 #include <string>
10 #include <sstream>
11 #include <iostream>
12 #include <vector>
13 
14 #include <yarp/profiler/Graph.h>
15 #include <yarp/os/Network.h>
16 #include <yarp/os/LogStream.h>
17 #include <yarp/os/Bottle.h>
18 
19 
20 namespace yarp {
21  namespace profiler {
22 
24 {
25 
26 public:
27 
29  {
30  public:
31  virtual ~ProgressCallback() { }
32  virtual void onProgress(unsigned int percentage) { }
33  };
34 
36  {
37  std::string name;
38  std::string carrier;
39  };
40 
41  struct MachineInfo
42  {
43  std::string os;
44  std::string hostname;
45 
46  };
47 
48  struct ProcessInfo
49  {
50  std::string name;
51  std::string arguments;
52  std::string os;
53  std::string hostname;
55  int pid;
56  int priority;
57  int policy;
58  ProcessInfo() { pid = priority = policy = -1; }
59  };
60 
61  struct PortDetails
62  {
63  std::string name;
64  std::vector<ConnectionInfo> outputs;
65  std::vector<ConnectionInfo> inputs;
67  std::string toString() const {
68  std::ostringstream str;
69  str<<"port name: "<<name<<std::endl;
70  str<<"outputs:"<<std::endl;
71  std::vector<ConnectionInfo>::const_iterator itr;
72  for (itr = outputs.begin(); itr != outputs.end(); itr++) {
73  str << " + " << (*itr).name << " (" << (*itr).carrier << ")" << std::endl;
74  }
75  str<<"inputs:"<<std::endl;
76  for (itr = inputs.begin(); itr != inputs.end(); itr++) {
77  str << " + " << (*itr).name << " (" << (*itr).carrier << ")" << std::endl;
78  }
79  str<<"owner:"<<std::endl;
80  str<<" + name: "<<owner.name<<std::endl;
81  str<<" + arguments: "<<owner.arguments<<std::endl;
82  str<<" + hostname: "<<owner.hostname<<std::endl;
83  str<<" + priority: "<<owner.priority<<std::endl;
84  str<<" + policy: "<<owner.policy<<std::endl;
85  str<<" + os: "<<owner.os<<std::endl;
86  str<<" + pid: "<<owner.pid<<std::endl;
87  return str.str();
88  }
89  };
90 
91  typedef std::vector<yarp::os::Bottle> ports_name_set;
92  typedef ports_name_set::iterator ports_name_iterator;
93 
94  typedef std::vector<PortDetails> ports_detail_set;
95  typedef ports_detail_set::iterator ports_detail_iterator;
96 
97 public:
104  static bool getPortDetails(const std::string& portName, PortDetails& info);
105 
111  static bool yarpNameList(ports_name_set& ports, bool complete=false);
112 
120 
122 
128  static bool yarpClean(float timeout=0.1);
129 
130  static void setProgressCallback(ProgressCallback* callback) {
131  progCallback = callback;
132  }
133 
135 
138 
139  static bool attachPortmonitorPlugin(std::string portName, yarp::os::Property pluginProp);
140  static bool detachPortmonitorPlugin(std::string portName);
141  static bool setPortmonitorParams(std::string portName, yarp::os::Property& param);
142  static bool getPortmonitorParams(std::string portName, yarp::os::Bottle &param);
143 
144 private:
145  static ProgressCallback* progCallback;
146 
147 };
148 
149  }
150 }
151 
152 
153 #endif //YARP_PROFILER_NETWORK_PROFILER_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
A class for storing options and configuration information.
Definition: Property.h:34
PacketPriorityLevel
The PacketPriorityLevel defines the packets quality of service (priority) levels.
Definition: QosStyle.h:31
virtual void onProgress(unsigned int percentage)
static bool getPortmonitorParams(std::string portName, yarp::os::Bottle &param)
static std::string packetPrioToString(yarp::os::QosStyle::PacketPriorityLevel level)
static bool attachPortmonitorPlugin(std::string portName, yarp::os::Property pluginProp)
static bool yarpNameList(ports_name_set &ports, bool complete=false)
yarpNameList
static bool updateConnectionQosStatus(yarp::profiler::graph::Graph &graph)
static bool yarpClean(float timeout=0.1)
NetworkProfiler::yarpClean.
static bool setPortmonitorParams(std::string portName, yarp::os::Property &param)
static yarp::os::QosStyle::PacketPriorityLevel packetStringToPrio(std::string level)
static bool creatNetworkGraph(ports_detail_set details, yarp::profiler::graph::Graph &graph)
creatNetworkGraph
static bool getPortDetails(const std::string &portName, PortDetails &info)
getPortDetails
static bool creatSimpleModuleGraph(yarp::profiler::graph::Graph &graph, yarp::profiler::graph::Graph &subgraph)
std::vector< yarp::os::Bottle > ports_name_set
ports_detail_set::iterator ports_detail_iterator
static bool detachPortmonitorPlugin(std::string portName)
ports_name_set::iterator ports_name_iterator
static void setProgressCallback(ProgressCallback *callback)
std::vector< PortDetails > ports_detail_set
The yarp::profiler::graph::Graph class.
Definition: Graph.h:108
The main, catch-all namespace for YARP.
Definition: dirs.h:16
std::vector< ConnectionInfo > inputs
std::vector< ConnectionInfo > outputs