14#include <yarp/companion/impl/Companion.h>
25 std::string ip =
it->owner_process.owner_machine.ip;
26 if (std::find(
l.begin(),
l.end(), ip) ==
l.end())
40 std::string pid =
it->owner_process.process_fullname;
41 if (std::find(
l.begin(),
l.end(), pid) ==
l.end())
60 if (!r) {
yError() <<
"getPortDetails of `" <<
it->name <<
"`failed"; }
61 ports.push_back(details);
69 for (
auto it = in.begin();
it != in.end();
it++)
72 if (
it->owner_process.owner_machine.hostname == ip) {
filtered_out.push_back(*
it); }
80 for (
auto it = in.begin();
it != in.end();
it++)
82 if (process_fullname !=
"*") {
83 if (
it->owner_process.process_fullname == process_fullname) {
filtered_out.push_back(*
it); }
91 for (
auto it = in.begin();
it != in.end();
it++)
108 for (
auto it = in.begin();
it != in.end();
it++)
125 for (
auto it = in.begin();
it != in.end();
it++)
143 if (name ==
it->name)
147 p.port_number =
it->port_number;
186 conn.src.port_number=
it->port_number;
187 conn.dst.name =
it2->port_name;
189 conn.dst.port_number =
p.port_number;
194 if (
conn.isValid() &&
195 std::find(connections.begin(), connections.end(),
conn) == connections.end())
197 connections.push_back(
conn);
215 yError() <<
"Cannot write to yarp name server";
219 if(reply.
size() == 0) {
220 yError() <<
"Empty reply from yarp name server";
224 for (
size_t i=1;
i<reply.
size();
i++) {
226 if(
entry !=
nullptr) {
239 if (
c.getCarrier() !=
"mcast")
244 portd.port_number = std::to_string(
entry->find(
"port_number").asInt32());
259 ping.setAdminMode(
true);
260 ping.setTimeout(1.0);
262 yWarning()<<
"Cannot connect to"<<portName;
271 yError()<<
"Cannot write (list out) to"<<portName;
275 for(
size_t i=0;
i<reply.
size();
i++) {
282 yWarning()<<
"Cannot write (list out"<<
cnn.port_name <<
") to"<<portName;
284 cnn.carrier =
reply2.find(
"carrier").asString();
293 yError()<<
"Cannot write (list in) to"<<portName;
297 for(
size_t i=0;
i<reply.
size();
i++) {
309 yError()<<
"Cannot write (prop get"<<portName<<
") to"<<portName;
316 yWarning()<<
"Cannot find 'process' property of port "<<portName;
329 yWarning()<<
"Cannot find 'platform' property of port "<<portName;
350 argv[0] = (
char*)
"--timeout";
351 argv[1] = (
char*)
sstream.str().c_str();
352 yarp::companion::impl::Companion::getInstance().cmdClean(2,argv);
358 std::ostringstream str;
359 str <<
"port name: " <<
info.
name << std::endl;
360 str <<
"port ip: " <<
info.
ip << std::endl;
362 str <<
"outputs:" << std::endl;
363 std::vector<ConnectedPortInfo>::const_iterator itr;
365 str <<
" + " << (*itr).port_name <<
" (" << (*itr).carrier <<
")" << std::endl;
367 str <<
"inputs:" << std::endl;
368 for (itr =
inputs.begin(); itr !=
inputs.end(); itr++) {
369 str <<
" + " << (*itr).port_name <<
" (" << (*itr).carrier <<
")" << std::endl;
371 str <<
"owner:" << std::endl;
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
static std::string getNameServerName()
Get the name of the port associated with the nameserver (usually "/root", but this can be overwritten...
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
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.
A mini-server for network communication.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Return a standard text representation of the content of the object.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
virtual Property * asDict() const
Get dictionary (hash table) value.
virtual std::string asString() const
Get string value.
std::vector< ConnectionDetails > connections_set
static bool getProcessesList(const ports_detail_set &ports, processes_list &l)
static void filterConnectionListByName(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static bool getPortsList(ports_name_set &ports, bool complete=false)
static void filterConnectionListByPortNumber(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static void filterPortsListByProcess(const ports_detail_set &in, ports_detail_set &filtered_out, std::string fullprocess="*")
std::vector< PortDetails > ports_detail_set
std::vector< std::string > processes_list
static bool getPortDetails(const std::string &portName, PortDetails &info)
static bool yarpClean(float timeout=0.1)
static void filterConnectionListByIp(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static bool getConnectionsList(connections_set &connections)
static bool getMachinesList(const ports_detail_set &ports, machines_list &l)
static void filterPortsListByIp(const ports_detail_set &in, ports_detail_set &filtered_out, std::string ip="*")
std::vector< PortInfo > ports_name_set
static bool getPortsDetailedList(ports_detail_set &ports, bool complete=false)
static bool getPortInfo(const std::string &name, const ports_name_set &ports, PortInfo &p)
std::vector< std::string > machines_list
An interface to the operating system, including Port based communication.
std::vector< ConnectedPortInfo > outputs
std::vector< ConnectedPortInfo > inputs
ProcessInfo owner_process
std::string toString() const
MachineInfo owner_machine
std::string process_fullname