Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portscope carrier #8

Merged
merged 3 commits into from
Apr 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/doc/yarpscope.dox
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Here is an example of portscope description file in XML format:

\code
<?xml version="1.0" encoding="UTF-8" ?>
<portscope rows="1" columns="2">
<portscope rows="1" columns="2" carrier="mcast">
<plot gridx="0"
gridy="0"
hspan="1"
Expand Down Expand Up @@ -143,12 +143,13 @@ This xml will produce a GUI similar to this:
Details:

\code
<portscope rows="1" columns="2">
<portscope rows="1" columns="2" carrier="mcast">
\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:
Expand Down
2 changes: 1 addition & 1 deletion src/yarpscope/examples/test_portscope.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<portscope rows="1" columns="2">
<portscope rows="1" columns="2" carrier="mcast">
<plot gridx="0"
gridy="0"
hspan="1"
Expand Down
8 changes: 0 additions & 8 deletions src/yarpscope/src/PortReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/yarpscope/src/PortReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 21 additions & 4 deletions src/yarpscope/src/SimpleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
#include <string.h>

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;
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;
}


Expand All @@ -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";
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/yarpscope/src/XmlLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/yarpscope/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ 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 << " --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;
Expand Down