本文整理汇总了C++中yarp::os::ConnectionState类的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionState类的具体用法?C++ ConnectionState怎么用?C++ ConnectionState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expectIndex
virtual bool expectIndex(yarp::os::ConnectionState& proto) {
yarp::os::ConstString prefix = "human says ";
yarp::os::ConstString compare = prefix;
yarp::os::Bytes b2((char*)prefix.c_str(),prefix.length());
proto.is().read(b2);
bool ok = proto.is().isOk() && (prefix==compare);
if (!ok) yInfo() << "YOU DID NOT SAY 'human says '";
return ok;
}
示例2: expectAck
virtual bool expectAck(yarp::os::ConnectionState& proto) {
std::string prefix = "computers rule!\r\n";
std::string compare = prefix;
yarp::os::Bytes b2((char*)prefix.c_str(),prefix.length());
proto.is().read(b2);
bool ok = proto.is().isOk() && (prefix==compare);
if (!ok) yInfo() << "YOU DID NOT SAY 'computers rule!'";
return ok;
}
示例3: expectReplyToHeader
virtual bool expectReplyToHeader(yarp::os::ConnectionState& proto) {
// SWITCH TO NEW STREAM TYPE
HumanStream *stream = new HumanStream();
if (stream==NULL) { return false; }
proto.takeStreams(stream);
return true;
}
示例4: configure
// Read connection settings.
bool PortMonitor::configure(yarp::os::ConnectionState& proto)
{
portName = proto.getRoute().getToName();
sourceName = proto.getRoute().getFromName();
group = getPeers().add(portName,this);
if (!group) return false;
Property options;
options.fromString(proto.getSenderSpecifier().c_str());
if(binder) delete binder;
binder = NULL;
ConstString script = options.check("type", Value("lua")).asString();
ConstString filename = options.check("file", Value("modifier")).asString();
ConstString constraint = options.check("constraint", Value("")).asString();
// context is used to find the script files
ConstString context = options.check("context", Value("")).asString();
// check which monitor should be used
if((binder = MonitorBinding::create(script.c_str())) == NULL)
{
yError("Currently only \'lua\' script and \'dll\' object is supported by portmonitor");
return false;
}
// set the acceptance constraint
binder->setAcceptConstraint(constraint.c_str());
ConstString strFile = filename;
if(script != "dll")
{
yarp::os::ResourceFinder rf;
rf.setDefaultContext(context.c_str());
rf.configure(0, NULL);
strFile = rf.findFile(filename.c_str());
if(strFile == "")
strFile = rf.findFile(filename+".lua");
}
// provide some useful information for the monitor object
// which can be accessed in the create() callback.
Property info;
info.clear();
info.put("filename", strFile);
info.put("type", script);
info.put("sender_side",
(proto.getContactable()->getName() == sourceName));
info.put("receiver_side",
(proto.getContactable()->getName() == portName));
info.put("source", sourceName);
info.put("destination", portName);
info.put("carrier", proto.getRoute().getCarrierName());
PortMonitor::lock();
bReady = binder->load(info);
PortMonitor::unlock();
return bReady;
}
示例5: sendHeader
virtual bool sendHeader(yarp::os::ConnectionState& proto) {
// Send the "magic number" for this carrier
yarp::os::ManagedBytes header(8);
getHeader(header.bytes());
proto.os().write(header.bytes());
if (!proto.os().isOk()) return false;
// Now we can do whatever we want, as long as somehow
// we also send the name of the originating port
// let's just send the port name in plain text terminated with a
// carriage-return / line-feed
std::string from = proto.getRoute().getFromName();
yarp::os::Bytes b2((char*)from.c_str(),from.length());
proto.os().write(b2);
proto.os().write('\r');
proto.os().write('\n');
proto.os().flush();
return proto.os().isOk();
}
示例6: configure
// Read connection settings.
bool PortMonitor::configure(yarp::os::ConnectionState& proto)
{
portName = proto.getRoute().getToName();
sourceName = proto.getRoute().getFromName();
group = getPeers().add(portName,this);
if (!group) return false;
Property options;
options.fromString(proto.getSenderSpecifier().c_str());
options.put("source", sourceName);
options.put("destination", portName);
options.put("sender_side",
(proto.getContactable()->getName() == sourceName) ? 1 : 0);
options.put("receiver_side",
(proto.getContactable()->getName() == portName) ? 1 : 0);
options.put("carrier", proto.getRoute().getCarrierName());
return configureFromProperty(options);
}
示例7: configure
// Read connection settings.
bool PriorityCarrier::configure(yarp::os::ConnectionState& proto) {
portName = proto.getRoute().getToName();
sourceName = proto.getRoute().getFromName();
group = getPeers().add(portName,this);
if (!group) return false;
Property options;
options.fromString(proto.getSenderSpecifier().c_str());
timeConstant = fabs(options.check("tc",Value(1.0)).asFloat64());
timeResting = fabs(options.check("tr",Value(0.0)).asFloat64());
stimulation = fabs(options.check("st",Value(STIMUL_THRESHOLD*10)).asFloat64());
// Zero stimulation is undefined and will be interpreted as S=Thresould.
if(stimulation == 0)
stimulation = STIMUL_THRESHOLD*10;
stimulation /= 10.0;
baias = options.check("bs",Value(STIMUL_THRESHOLD*10)).asFloat64();
baias /= 10.0;
excitation = options.findGroup("ex");
isVirtual = options.check("virtual");
#ifdef WITH_PRIORITY_DEBUG
if(options.check("debug"))
{
std::string msg;
char dummy[1024];
safe_printf(dummy, 1024, "\n%s:\n", sourceName.c_str());
msg+= dummy;
safe_printf(dummy, 1024, " stimulation: %.2f\n", stimulation);
msg+= dummy;
safe_printf(dummy, 1024, " bias: %.2f\n", baias);
msg+= dummy;
safe_printf(dummy, 1024, " tc: %.2fs\n", timeConstant);
msg+= dummy;
safe_printf(dummy, 1024, " tr: %.2fs\n", timeResting);
msg+= dummy;
safe_printf(dummy, 1024, " ex: ");
msg+= dummy;
for(size_t i=0; i<excitation.size(); i++)
{
Value v = excitation.get(i);
if(v.isList() && (v.asList()->size()>=2))
{
Bottle* b = v.asList();
safe_printf(dummy, 1024, "(%s, %.2f) ",
b->get(0).asString().c_str(),
b->get(1).asFloat64()/10.0 );
msg+= dummy;
}
}
//safe_printf(dummy, 1024, "\n");
msg+= "\n";
safe_printf(dummy, 1024, " virtual: %s\n",
(isVirtual)?"yes":"no");
msg+= dummy;
double rate = options.check("rate", Value(10)).asInt32() / 1000.0;
safe_printf(dummy, 1024, " db.rate: %fs\n", rate);
msg+= dummy;
yInfo("%s", msg.c_str());
debugger.stop();
debugger.setPeriod(rate);
debugger.start();
}
#endif
return true;
}
示例8: sendAck
virtual bool sendAck(yarp::os::ConnectionState& proto) {
std::string prefix = "computers rule!\r\n";
yarp::os::Bytes b2((char*)prefix.c_str(),prefix.length());
proto.os().write(b2);
return true;
}
示例9: sendIndex
virtual bool sendIndex(yarp::os::ConnectionState& proto) {
std::string prefix = "human says ";
yarp::os::Bytes b2((char*)prefix.c_str(),prefix.length());
proto.os().write(b2);
return true;
}
示例10: write
virtual bool write(yarp::os::ConnectionState& proto, yarp::os::SizedWriter& writer) {
bool ok = sendIndex(proto);
if (!ok) return false;
writer.write(proto.os());
return proto.os().isOk();
}
示例11: expectSenderSpecifier
virtual bool expectSenderSpecifier(yarp::os::ConnectionState& proto) {
// interpret everything that sendHeader wrote
proto.setRoute(proto.getRoute().addFromName(proto.is().readLine()));
return proto.is().isOk();
}