bool checkVectorExistInConfiguration(yarp::os::Bottle & bot, const std::string & name, const int expected_vec_size) { //std::cerr << " checkVectorExistInConfiguration(" << name // << " , " << expected_vec_size << " )" << std::endl; //std::cerr << "bot.check(name) : " << bot.check(name) << std::endl; //std::cerr << "bot.find(name).isList(): " << bot.find(name).isList() << std::endl; //std::cerr << "bot.find(name).asList()->size() : " << bot.find(name).asList()->size()<< std::endl; return (bot.check(name) && bot.find(name).isList() && bot.find(name).asList()->size() == expected_vec_size ); }
bool homeostaticModule::addNewDrive(string driveName, yarp::os::Bottle& grpHomeostatic) { Drive* drv = new Drive(driveName); drv->setHomeostasisMin(grpHomeostatic.check((driveName + "-homeostasisMin"), Value(drv->homeostasisMin)).asDouble()); drv->setHomeostasisMax(grpHomeostatic.check((driveName + "-homeostasisMax"), Value(drv->homeostasisMax)).asDouble()); cout << "H1 " << grpHomeostatic.check((driveName + "-decay"), Value(drv->decay)).asDouble() <<endl; drv->setDecay(grpHomeostatic.check((driveName + "-decay"), Value(drv->decay)).asDouble()); drv->setValue((drv->homeostasisMax + drv->homeostasisMin) / 2.); drv->setGradient(grpHomeostatic.check((driveName + "-gradient"), Value(drv->gradient)).asBool()); cout << "h2 " << drv->decay << endl; //cout << drv->name << " " << drv->homeostasisMin << " " << drv->homeostasisMax << " " << drv->decay << " " <<drv->gradient << endl; //cout << d << endl; //cout << grpHomeostatic.toString()<<endl; manager.addDrive(drv); cout << "h2 " << manager.drives[0]->decay << endl; openPorts(driveName); return true; }
bool NameServiceOnTriples::apply(yarp::os::Bottle& cmd, yarp::os::Bottle& reply, yarp::os::Bottle& event, const yarp::os::Contact& remote) { ConstString key = cmd.get(0).toString(); ConstString prefix = " * "; access.wait(); if (key=="register") { lastRegister = cmd.get(1).asString().c_str(); } else if (key=="set") { if (cmd.get(1).asString()==lastRegister.c_str()) { prefix = " + "; } } else { lastRegister = ""; } if (!silent) { printf("%s%s\n", prefix.c_str(), cmd.toString().c_str()); } access.post(); TripleSource& mem = *db; //mem.begin(); mem.reset(); reply.clear(); NameTripleState act(cmd,reply,event,remote,mem); if (cmd.check("format")) { if (cmd.find("format")=="json") { act.bottleMode = true; } } if (key == "NAME_SERVER") { cmd = cmd.tail(); key = cmd.get(0).asString(); } if (key == "bot") { act.bottleMode = true; cmd = cmd.tail(); key = cmd.get(0).asString(); } if (key=="register") { return cmdRegister(act); } else if (key=="unregister") { return cmdUnregister(act); } else if (key=="query") { return cmdQuery(act); } else if (key=="list") { return cmdList(act); } else if (key=="set") { return cmdSet(act); } else if (key=="get") { return cmdGet(act); } else if (key=="check") { return cmdCheck(act); } else if (key=="route") { return cmdRoute(act); } else if (key=="gc") { return cmdGc(act); } else if (key=="help") { return cmdHelp(act); } else { // not understood act.reply.addString("old"); } //mem.end(); return true; }