void CorbaMQueueIPCTest::setUp() { // setup DataPorts: we write into mw1, the server roundtrips it to mr1 mr1 = new InputPort<double>("mr"); mw1 = new OutputPort<double>("mw"); tc = new TaskContext( "root" ); tc->ports()->addEventPort( *mr1, boost::bind(&CorbaMQueueIPCTest::new_data_listener, this, _1) ); tc->ports()->addPort( *mw1 ); tc->start(); ts2 = ts = 0; tp2 = tp = 0; }
bool Logger::unreportComponent( const std::string& component ) { TaskContext* comp = this->getPeer(component); if (!comp) { log(Error) << "no such component " << component << endlog(); return false; } Ports ports = comp->ports()->getPorts(); for (Ports::iterator it = ports.begin(); it != ports.end() ; ++it) { this->unreportPort(component, (*it)->getName()); } return true; }
bool Logger::reportComponent( const std::string& component ) { // Users may add own data sources, so avoid duplicates //std::vector<std::string> sources = comp->data()->getNames(); TaskContext* comp = this->getPeer(component); if ( !comp ) { log(Error) << "no such component " << component << endlog(); return false; } Ports ports = comp->ports()->getPorts(); for (Ports::iterator it = ports.begin(); it != ports.end() ; ++it) this->reportPort( component, (*it)->getName() ); return true; }
void CorbaTest::setUp() { // connect DataPorts mi = new InputPort<double>("mi"); mo = new OutputPort<double>("mo"); tc = new TaskContext( "root" ); tc->ports()->addPort( *mi ); tc->ports()->addPort( *mo ); t2 = 0; ts2 = ts = 0; tp2 = tp = 0; wait = cbcount = 0; is_calling = false, is_sending = false; addOperation("callBackPeer", &CorbaTest::callBackPeer, this,ClientThread); addOperation("callBackPeerOwn", &CorbaTest::callBackPeer, this,OwnThread); }
// Exactly the same as th reportPort from the Reporter component bool ImageDisplayComponent::addDisplayPort(std::string& component, std::string& port) { Logger::In in("ImageDisplayComponent"); TaskContext* comp = this->getPeer(component); if ( !comp ) { log(Error) << "Could not display Component " << component <<" : no such peer."<<endlog(); return false; } PortInterface* porti = comp->ports()->getPort(port); if ( !porti ) { log(Error) << "Could not display Port " << port <<" : no such port on Component "<<component<<"."<<endlog(); return false; } if ( porti->connected() ) { this->addDisplaySource( component + "." + port, "Port", porti->connection()->getDataSource() ); log(Info) << "Reporting port " << port <<" : ok."<<endlog(); } else { // create new port temporarily // this port is only created with the purpose of // creating a connection object. PortInterface* ourport = porti->antiClone(); assert(ourport); ConnectionInterface::shared_ptr ci = porti->createConnection( ourport ); if ( !ci ) ci = ourport->createConnection( porti ); if ( !ci ) return false; ci->connect(); delete ourport; this->addDisplaySource( component + "." + porti->getName(), "Port", ci->getDataSource() ); log(Info) << "Created connection for port " << porti->getName()<<" : ok."<<endlog(); } return true; }
// report a specific connection. bool Logger::reportPort(const std::string& component, const std::string& port ) { TaskContext* comp = this->getPeer(component); if ( !comp ) { log(Error) << "no such component " << component << endlog(); return false; } RTT::base::OutputPortInterface* writer = dynamic_cast<RTT::base::OutputPortInterface*>(comp->ports()->getPort(port)); if ( !writer ) { log(Error) << "component " << component << " does not have a port named " << port << ", or it is a read port" << endlog(); return false; } std::string portname(component + "." + port); RTT::base::PortInterface *pi = ports()->getPort(portname); if(pi) // we are already reporting this port { log(Info) << "port " << port << " of component " << component << " is already logged" << endlog(); return true; } // Create the corresponding read port RTT::base::InputPortInterface* reader = static_cast<RTT::base::InputPortInterface*>(writer->antiClone()); reader->setName(portname); writer->createBufferConnection(*reader, 25); return addLoggingPort(reader, portname); }