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