22std::pair<std::string, std::string>
parseBlocks(
const std::string& input)
25 const std::string
sendTag =
"+send.portmonitor+";
26 const std::string
recvTag =
"+recv.portmonitor+";
33 if (
posRecv != std::string::npos)
43 middle = input.substr(start, end - start);
45 else if (
posSend != std::string::npos &&
posRecv == std::string::npos)
49 else if (
posSend == std::string::npos &&
posRecv != std::string::npos)
65 if (start != std::string::npos) {
67 for (
size_t i = start; i < (
size_t)input.length(); i++) {
71 }
else if (ch ==
'.') {
93 group = getPeers().add(
portName,
this);
103 options.
put(
"sender_side",
105 options.
put(
"receiver_side",
147 if (!
element.isList()) {
continue; }
150 if (
entry->size() < 2) {
continue; }
152 std::string key =
entry->get(0).asString();
160 auto value =
entry->get(1);
172 for (
auto it=binder.begin();
it!=binder.end(); ++
it)
186 std::string type = options.
check(
"type",
Value(
"")).asString();
187 std::string file = options.
check(
"file",
Value(
"")).asString();
190 if (type.empty() || file.empty())
205 for (
int i = 1; ; ++i)
207 std::string
typeKey =
"type" + std::to_string(i);
208 std::string
fileKey =
"file" + std::to_string(i);
209 std::string
constraintKey =
"constraint" + std::to_string(i);
210 std::string
contextKey =
"context" + std::to_string(i);
220 if (type.empty() || file.empty())
247 binder.push_back(
mon);
254 for (
size_t i=0; i<binder.size(); i++)
289 bReady &= binder[i]->load(
info);
303 for (
size_t i=0; i<binder.size(); i++)
305 binder[i]->setParams(params);
318 for (
size_t i=0; i<binder.size(); i++)
320 binder[i]->getParams(params);
346 for (
size_t i = 0; i < binder.size(); ++i)
349 if(!binder[i]->hasUpdate())
353 current = &binder[i]->updateData(*current);
360 cReader.setParentConnectionReader(&reader);
381 localReader = &reader;
383 if (binder[0]->hasAccept())
389 result &= binder[0]->acceptData(thing);
432 for (
size_t i = 0; i < binder.size(); ++i)
435 if(!binder[i]->hasUpdate())
439 current = &binder[i]->updateData(*current);
458 if (!binder[0]->hasAccept()) {
465 result &= binder[0]->acceptData(thing);
484 for (
size_t i = 0; i < binder.size(); ++i)
487 if(!binder[i]->hasUpdateReply())
491 current = &binder[i]->updateReply(*current);
501std::unique_ptr<ElectionOf<PortMonitorGroup>> PortMonitor::peers =
nullptr;
509 if (peers==
nullptr) {
510 peers = std::make_unique<ElectionOf<PortMonitorGroup>>();
const yarp::os::LogComponent & PORTMONITORCARRIER()
void parseParameters(yarp::os::Property &inputoptions, yarp::os::Property &outputoptions)
std::string separateString(std::string input)
std::pair< std::string, std::string > parseBlocks(const std::string &input)
static MonitorBinding * create(const char *script_type)
factory method
virtual bool canAccept()=0
virtual bool peerTrigged()=0
virtual bool acceptIncomingData(PortMonitor *source)
Allow to monitor and modify port data from Lua script Under development.
MonitorBinding * getBinder()
void getCarrierParams(yarp::os::Property ¶ms) const override
Get carrier configuration and deliver it by port administrative commands.
yarp::os::ConnectionReader & modifyIncomingData(yarp::os::ConnectionReader &reader) override
Modify incoming payload data, if appropriate.
const yarp::os::PortWriter & modifyOutgoingData(const yarp::os::PortWriter &writer) override
Modify outgoing payload data, if appropriate.
yarp::os::PortReader & modifyReply(yarp::os::PortReader &reader) override
Modify reply payload data, if appropriate.
void setCarrierParams(const yarp::os::Property ¶ms) override
Configure carrier from port administrative commands.
bool configureFromProperty(yarp::os::Property &options) override
bool acceptIncomingData(yarp::os::ConnectionReader &reader) override
Determine whether incoming data should be accepted.
bool acceptOutgoingData(const yarp::os::PortWriter &writer) override
Determine whether outgoing data should be accepted.
bool configure(yarp::os::ConnectionState &proto) override
Class PortMonitor.
A simple collection of objects that can be described and transmitted in a portable way.
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
virtual void setParentConnectionReader(ConnectionReader *parentConnectionReader)
Set ConnectionReader to be used for reading the envelope.
The basic state of a connection - route, streams in use, etc.
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
ConnectionReader & getReader(ConnectionWriter *replyWriter=nullptr)
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
void reset()
Reset and clear the current ConnectionWriter.
static void unlock()
Call post() on a global mutual-exclusion semaphore allocated by YARP.
static void lock()
Call wait() on a global mutual-exclusion semaphore allocated by YARP.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
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.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
void clear()
Remove all associations.
Helper class for finding config files and other external resources.
bool setDefaultContext(const std::string &contextName)
Sets the context for the current ResourceFinder object.
bool configure(int argc, char *argv[], bool skipFirstArgument=true)
Sets up the ResourceFinder.
std::string findFile(const std::string &name)
Find the full path to a file.
Base class for generic things.
bool setConnectionReader(yarp::os::ConnectionReader &reader)
set a reference to a ConnectionReader
yarp::os::PortWriter * getPortWriter()
yarp::os::PortReader * getPortReader()
bool write(yarp::os::ConnectionWriter &connection)
void setPortReader(yarp::os::PortReader *reader)
Set the reference to a PortReader object.
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::string asString() const
Get string value.
#define yCError(component,...)
#define yCAssert(component, x)
#define yCTrace(component,...)
An interface to the operating system, including Port based communication.