当前位置: 首页>>代码示例>>C++>>正文


C++ os::ConnectionState类代码示例

本文整理汇总了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;
 }
开发者ID:apaikan,项目名称:yarp,代码行数:9,代码来源:carrier_human.cpp

示例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;
 }
开发者ID:robotology,项目名称:yarp,代码行数:9,代码来源:carrier_human.cpp

示例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;
 }
开发者ID:robotology,项目名称:yarp,代码行数:7,代码来源:carrier_human.cpp

示例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;
}
开发者ID:BRKMYR,项目名称:yarp,代码行数:61,代码来源:PortMonitor.cpp

示例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();
    }
开发者ID:robotology,项目名称:yarp,代码行数:20,代码来源:carrier_human.cpp

示例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);
}
开发者ID:silasxue,项目名称:yarp,代码行数:19,代码来源:PortMonitor.cpp

示例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;
}
开发者ID:claudiofantacci,项目名称:yarp,代码行数:69,代码来源:PriorityCarrier.cpp

示例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;
 }
开发者ID:robotology,项目名称:yarp,代码行数:6,代码来源:carrier_human.cpp

示例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;
 }
开发者ID:robotology,项目名称:yarp,代码行数:6,代码来源:carrier_human.cpp

示例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();
 }
开发者ID:robotology,项目名称:yarp,代码行数:6,代码来源:carrier_human.cpp

示例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();
 }
开发者ID:robotology,项目名称:yarp,代码行数:5,代码来源:carrier_human.cpp


注:本文中的yarp::os::ConnectionState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。