|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
17 #include <yarp/companion/impl/Companion.h>
34 string nameserver = NetworkBase::getNameServerName();
39 yError() <<
"Cannot write to yarp name server";
43 if(reply.
size() == 0) {
44 yError() <<
"Empty reply from yarp name server";
48 for (
size_t i=1; i<reply.
size(); i++) {
50 if(entry !=
nullptr) {
51 bool shouldTake =
false;
52 std::string portname = entry->
check(
"name",
Value(
"")).asString();
55 shouldTake = portname !=
"";
59 shouldTake = portname !=
"" && portname !=
"fallback" && portname != nameserver;
62 Contact c = Contact::fromConfig(*entry);
64 ports.push_back(*entry);
72 bool NetworkProfiler::getPortDetails(
const string& portName,
PortDetails& info) {
76 ping.
open(
"/yarpviz");
79 if(!NetworkBase::connect(ping.
getName(), portName)) {
80 yWarning()<<
"Cannot connect to"<<portName;
88 if(!ping.
write(cmd, reply)) {
89 yError()<<
"Cannot write (list out) to"<<portName;
93 for(
size_t i=0; i<reply.
size(); i++) {
99 if(!ping.
write(cmd, reply2))
100 yWarning()<<
"Cannot write (list out"<<cnn.
name<<
") to"<<portName;
109 if(!ping.
write(cmd, reply)) {
110 yError()<<
"Cannot write (list in) to"<<portName;
114 for(
size_t i=0; i<reply.
size(); i++) {
118 info.
inputs.push_back(cnn);
124 if(!ping.
write(cmd, reply)) {
125 yError()<<
"Cannot write (prop get"<<portName<<
") to"<<portName;
132 yWarning()<<
"Cannot find 'process' property of port "<<portName;
143 yWarning()<<
"Cannot find 'platform' property of port "<<portName;
157 if(NetworkProfiler::progCallback)
161 unsigned int itr_count = 0;
162 for(itr = details.begin(); itr!=details.end(); itr++) {
181 auto itrVert=graph.
insert(*process);
198 if(NetworkProfiler::progCallback) {
199 NetworkProfiler::progCallback->
onProgress((
unsigned int) (++itr_count/((
float)(details.size()*2)) * 100.0) );
205 for(itr = details.begin(); itr!=details.end(); itr++) {
214 Property edge_prop(
"(type connection)");
215 edge_prop.
put(
"carrier", cnn.carrier);
219 yWarning()<<
"Found a nonexistent port ("<<cnn.name<<
")"<<
"in the output list of"<<(*vi1)->property.find(
"name").asString();
222 if(NetworkProfiler::progCallback) {
223 NetworkProfiler::progCallback->
onProgress((
unsigned int) (++itr_count/((
float)(details.size()*2)) * 100.0) );
226 if(NetworkProfiler::progCallback)
227 NetworkProfiler::progCallback->
onProgress(100);
231 bool NetworkProfiler::yarpClean(
float timeout) {
236 stringstream sstream;
239 argv[0] = (
char*)
"--timeout";
240 argv[1] = (
char*) sstream.str().c_str();
241 yarp::companion::impl::Companion::getInstance().cmdClean(2,argv);
250 for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
260 mv1->property.find(
"hostname").asString());
267 for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
274 pv1->property.find(
"hostname").asString());
280 for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
286 for(eitr = outs.begin(); eitr!=outs.end(); eitr++) {
287 const Edge& e = (*eitr);
292 for(peitr = pouts.begin(); peitr!=pouts.end(); peitr++) {
293 const Vertex& p2 = (*peitr).second();
297 prop.
put(
"label", label);
349 for(itr = vertices.begin(); itr!=vertices.end(); itr++) {
350 const Vertex &v1 = (**itr);
351 for(
const auto& i : v1.
outEdges()) {
387 Contact srcCon = Contact::fromString(portName);
390 yError()<<
"Cannot write to"<<portName;
402 bool NetworkProfiler::detachPortmonitorPlugin(std::string portName) {
407 Contact srcCon = Contact::fromString(portName);
410 yError()<<
"Cannot write to"<<portName;
429 Contact srcCon = Contact::fromString(portName);
432 yError()<<
"Cannot write to"<<portName;
435 if(reply.
size() > 1) {
448 bool NetworkProfiler::getPortmonitorParams(std::string portName,
yarp::os::Bottle& param) {
454 Contact srcCon = Contact::fromString(portName);
457 yError()<<
"Cannot write to"<<portName;
460 if(param.
size() > 1) {
void close() override
Stop port activity.
const pvertex_iterator find(const Vertex &v1)
A simple collection of objects that can be described and transmitted in a portable way.
yarp::os::Property property
std::string toString() const override
Gives a human-readable textual representation of the bottle.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
pvertex_set::const_iterator pvertex_const_iterator
void clear()
Empties the bottle of any objects it contains.
pvertex_iterator insert(const Vertex &vertex)
virtual Property * asDict() const
Get dictionary (hash table) value.
Preferences for the port's Quality of Service.
std::vector< yarp::os::Bottle > ports_name_set
size_type size() const
Gets the number of elements in the bottle.
bool setOwner(yarp::profiler::graph::Vertex *_owner)
static bool getConnectionQos(const std::string &src, const std::string &dest, QosStyle &srcStyle, QosStyle &destStyle, bool quiet=true)
Gets the Qos preferences of a connection.
std::vector< ConnectionInfo > inputs
static bool write(const Contact &contact, PortWriter &cmd, PortReader &reply, bool admin=false, bool quiet=false, double timeout=-1)
Send a single command to a port and await a single response.
int getThreadPriority() const
returns the communication thread priority level
const pvertex_set & vertices()
int getThreadPolicy() const
returns the communication thread scheduling policy
The yarp::profiler::graph::Vertex class.
void setAdminMode(bool adminMode=true)
Turn on/off "admin" mode.
void fromString(const std::string &text)
Initializes bottle from a string.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
The yarp::profiler::graph::Edge class.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
ports_detail_set::iterator ports_detail_iterator
A mini-server for network communication.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
std::vector< PortDetails > ports_detail_set
PacketPriorityLevel getPacketPriorityAsLevel() const
returns the packet TOS value
virtual bool isString() const
Checks if value is a string.
virtual void onProgress(unsigned int percentage)
yarp::os::Property property
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.
std::vector< yarp::profiler::graph::Vertex * > pvertex_set
bool setTimeout(float timeout)
Set a timeout on network operations.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
const edge_set & outEdges() const
virtual std::int32_t asInt32() const
Get 32-bit integer value.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
An interface to the operating system, including Port based communication.
edge_set::const_iterator edge_const_iterator
PacketPriorityLevel
The PacketPriorityLevel defines the packets quality of service (priority) levels.
virtual Bottle * asList() const
Get list value.
The yarp::profiler::graph::Graph class.
std::vector< ConnectionInfo > outputs
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
A single value (typically within a Bottle).
std::vector< yarp::profiler::graph::Edge > edge_set
const yarp::profiler::graph::Vertex & second() const
void insertEdge(const Vertex &v1, const Vertex &v2, const yarp::os::Property &property="")
A class for storing options and configuration information.
pvertex_set::iterator pvertex_iterator
virtual bool isInt32() const
Checks if value is a 32-bit integer.