From c6a47e2321a50281a0da3a8221bfbb564e3c22b7 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 26 Apr 2013 17:52:19 +0200 Subject: [PATCH 1/3] [portScope] Allow choosing carrier in xml mode --- src/yarpscope/src/XmlLoader.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/yarpscope/src/XmlLoader.cpp b/src/yarpscope/src/XmlLoader.cpp index 3fface2d0a..9f3753bf4b 100644 --- a/src/yarpscope/src/XmlLoader.cpp +++ b/src/yarpscope/src/XmlLoader.cpp @@ -62,6 +62,18 @@ YarpScope::XmlLoader::XmlLoader(const Glib::ustring& filename) fatal() << "Syntax error while loading" << filename << ". Root element should be \"portscope\", found" << rootElem->Value(); } + Glib::ustring connection_carrier; + bool connection_persistent; + + if (const char *t = rootElem->Attribute("carrier")) { + connection_carrier = t; + } else { + connection_carrier = default_connection_carrier; + } + + // TODO read from command line whether connections should be persistent or not + connection_persistent = default_connection_persistent; + for (TiXmlElement *plotElem = rootElem->FirstChildElement(); plotElem != 0; plotElem = plotElem->NextSiblingElement()) { if (Glib::ustring(plotElem->Value()).compare("plot") != 0) { fatal() << "Syntax error while loading" << filename << ". Expected \"plot\", found" << plotElem->Value(); @@ -146,10 +158,6 @@ YarpScope::XmlLoader::XmlLoader(const Glib::ustring& filename) graph_size = default_graph_size; } - //TODO Allow to specify carrier and persistent - Glib::ustring connection_carrier = default_connection_carrier; - bool connection_persistent = default_connection_persistent; - portReader.acquireData(graph_remote, graph_index, "", connection_carrier, connection_persistent); plotManager.addGraph(plotIndex, graph_remote, graph_index, graph_title, graph_color, graph_type, graph_size); } From 89b6260ee35418ff68fd869bbda1a72dce36847a Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 26 Apr 2013 17:51:57 +0200 Subject: [PATCH 2/3] [portScope] Allow choosing carrier in simple mode Remove no longer used method --- src/yarpscope/src/PortReader.cpp | 8 -------- src/yarpscope/src/PortReader.h | 4 ---- src/yarpscope/src/SimpleLoader.cpp | 23 ++++++++++++++++++++--- src/yarpscope/src/main.cpp | 1 + 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/yarpscope/src/PortReader.cpp b/src/yarpscope/src/PortReader.cpp index 637cadf8f9..8cde25eb51 100644 --- a/src/yarpscope/src/PortReader.cpp +++ b/src/yarpscope/src/PortReader.cpp @@ -437,14 +437,6 @@ void YarpScope::PortReader::clearData() mPriv->clearData(); } - -void YarpScope::PortReader::acquireData(const Glib::ustring &remotePortName, - int index, - const Glib::ustring &localPortName) -{ - mPriv->acquireData(remotePortName, index, localPortName, NULL); -} - void YarpScope::PortReader::acquireData(const Glib::ustring &remotePortName, int index, const Glib::ustring &localPortName, diff --git a/src/yarpscope/src/PortReader.h b/src/yarpscope/src/PortReader.h index 152a2a247a..902732e699 100644 --- a/src/yarpscope/src/PortReader.h +++ b/src/yarpscope/src/PortReader.h @@ -35,10 +35,6 @@ class PortReader void clearData(); - void acquireData(const Glib::ustring &remotePortName, - int index, - const Glib::ustring &localPortName); - void acquireData(const Glib::ustring &remotePortName, int index, const Glib::ustring &localPortName, diff --git a/src/yarpscope/src/SimpleLoader.cpp b/src/yarpscope/src/SimpleLoader.cpp index 66aa01dff7..08787d198f 100644 --- a/src/yarpscope/src/SimpleLoader.cpp +++ b/src/yarpscope/src/SimpleLoader.cpp @@ -21,6 +21,8 @@ namespace { static const int default_plot_size = 201; static const int default_graph_size = 1; static const Glib::ustring default_graph_type = "lines"; + static const Glib::ustring default_connection_carrier = "mcast"; + static bool default_connection_persistent = true; } @@ -29,11 +31,26 @@ YarpScope::SimpleLoader::SimpleLoader(/* FIXME const */ yarp::os::Property &opti YarpScope::PortReader &portReader = YarpScope::PortReader::instance(); YarpScope::PlotManager &plotManager = YarpScope::PlotManager::instance(); + Glib::ustring graph_remote, local_port, connection_carrier; + bool connection_persistent; + if (!options.check("remote")) { debug() << "Missing \"remote\" argument. Will wait for external connection"; + } else { + graph_remote = options.find("remote").toString().c_str(); } - const Glib::ustring graph_remote = options.find("remote").toString().c_str(); + local_port = default_local_port; + + if (options.check("carrier")) { + connection_carrier = options.find("carrier").asString().c_str(); + } else { + connection_carrier = default_connection_carrier; + } + + // TODO read from command line whether connections should be persistent or not + connection_persistent = default_connection_persistent; + if (!options.check("index")) { warning() << "Missing \"index\" argument. Will use index = 0"; @@ -133,7 +150,7 @@ YarpScope::SimpleLoader::SimpleLoader(/* FIXME const */ yarp::os::Property &opti graph_size = default_graph_size; } - portReader.acquireData(graph_remote, graph_index, default_local_port); + portReader.acquireData(graph_remote, graph_index, local_port, connection_carrier, connection_persistent); plotManager.addGraph(plotIndex, graph_remote, graph_index, graph_title, graph_color, graph_type, graph_size); } else { @@ -232,7 +249,7 @@ YarpScope::SimpleLoader::SimpleLoader(/* FIXME const */ yarp::os::Property &opti graph_size = default_graph_size; } - portReader.acquireData(graph_remote, graph_index, default_local_port); + portReader.acquireData(graph_remote, graph_index, local_port, connection_carrier, connection_persistent); plotManager.addGraph(plotIndex, graph_remote, graph_index, graph_title, graph_color, graph_type, graph_size); } } diff --git a/src/yarpscope/src/main.cpp b/src/yarpscope/src/main.cpp index e0feb38d8f..b554e008a6 100644 --- a/src/yarpscope/src/main.cpp +++ b/src/yarpscope/src/main.cpp @@ -48,6 +48,7 @@ void usage() { std::cout << std::endl; std::cout << "SIMPLE MODE (single remote):" << std::endl; std::cout << " --remote [string] Remote port to connect to." << std::endl; + std::cout << " --carrier [string] YARP Carrier used for connections (default \"mcast\")" << std::endl; std::cout << " --index [...] Index(es) of the vector to plot." << std::endl; std::cout << " It can be an [uint] or an array of [uint]s" << std::endl; std::cout << " --plot_title [string] Plot title (default = remote)" << std::endl; From 62b83d15acce961d58ea02f82d61e5b00aaf0c0f Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Fri, 26 Apr 2013 17:53:18 +0200 Subject: [PATCH 3/3] [portScope] Update example and docs --- src/doc/yarpscope.dox | 5 +++-- src/yarpscope/examples/test_portscope.xml | 2 +- src/yarpscope/src/SimpleLoader.cpp | 2 +- src/yarpscope/src/main.cpp | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doc/yarpscope.dox b/src/doc/yarpscope.dox index 18b9c9fda6..a980dc101c 100644 --- a/src/doc/yarpscope.dox +++ b/src/doc/yarpscope.dox @@ -30,7 +30,7 @@ Here is an example of portscope description file in XML format: \code - + + \endcode - \a rows and \a columns is the size of the main table. (Note: rows * columns does not necessarily correspond to the number of plots, since for each plot you can set \a hspan and \a vspan) [optional] +- \a "carrier" is the carrier that will be used for connections (default = mcast) [optional] Now declare a plot: diff --git a/src/yarpscope/examples/test_portscope.xml b/src/yarpscope/examples/test_portscope.xml index d0969bbdfd..8e93f33f7b 100644 --- a/src/yarpscope/examples/test_portscope.xml +++ b/src/yarpscope/examples/test_portscope.xml @@ -1,5 +1,5 @@ - + namespace { - static const Glib::ustring default_local_port = "/yarpscope"; + static const Glib::ustring default_local_port = "/yarpscope"; // FIXME Use "..." static const float default_plot_minval = -100.; static const float default_plot_maxval = 100.; static const int default_plot_size = 201; diff --git a/src/yarpscope/src/main.cpp b/src/yarpscope/src/main.cpp index b554e008a6..be15afab79 100644 --- a/src/yarpscope/src/main.cpp +++ b/src/yarpscope/src/main.cpp @@ -49,6 +49,7 @@ void usage() { std::cout << "SIMPLE MODE (single remote):" << std::endl; std::cout << " --remote [string] Remote port to connect to." << std::endl; std::cout << " --carrier [string] YARP Carrier used for connections (default \"mcast\")" << std::endl; +// std::cout << " --no-persistent Do not make persistent connections" << std::endl; std::cout << " --index [...] Index(es) of the vector to plot." << std::endl; std::cout << " It can be an [uint] or an array of [uint]s" << std::endl; std::cout << " --plot_title [string] Plot title (default = remote)" << std::endl;