Service* DataFlowInterface::createPortObject(const std::string& name) { PortInterface* p = this->getPort(name); if ( !p ) return 0; Service* to = p->createPortObject(); if (to) { std::string d = this->getPortDescription(name); if ( !d.empty() ) to->doc( d ); else to->doc("No description set for this Port. Use .doc() to document it."); } return to; }
bool InputPortInterface::connectTo(PortInterface& other, ConnPolicy const& policy) { OutputPortInterface* output = dynamic_cast<OutputPortInterface*>(&other); if (! output) { log(Error) << "InputPort "<< getName() <<" could not connect to "<< other.getName() << ": not an Output port." <<endlog(); return false; } return output->createConnection(*this, policy); }
int main() { cout << "starting test" << endl; PortInterface myPort; // Set up port vars: portData myData; myData.port = "/dev/ttyS1"; myData.baud = 9600; myPort.configure(myData); cout << "opening port" << endl; if(myPort.openPort() != 0) { cout << "could not open port" << endl; } cout << "write to port" << endl; string str = "Some data to write BABY!\n"; myPort.writePort(str); //writes data to serial port cout << "write 1" << endl; myPort.writePort((char *)str.c_str()); cout << "write 2" << endl; myPort.writePort((char *)str.c_str(), str.length()); cout << "write 3" << endl; cout << "Reading... waiting for buffer to fill" << endl; char temp[1]; for(;;) { while(myPort.readPort(temp) > 0) { cout << temp[0]; } usleep(10000); } cout << "closing port" << endl; myPort.flushPorts(); myPort.closePort(); return 0; }
bool TaskContext::connectPorts( TaskContext* peer ) { bool failure = false; const std::string& location = this->getName(); Logger::In in( location.c_str() ); DataFlowInterface::Ports myports = this->ports()->getPorts(); for (DataFlowInterface::Ports::iterator it = myports.begin(); it != myports.end(); ++it) { // Then try to get the peer port's connection PortInterface* peerport = peer->ports()->getPort( (*it)->getName() ); if ( !peerport ) { log(Debug)<< "Peer Task "<<peer->getName() <<" has no Port " << (*it)->getName() << endlog(); continue; } // Skip if they have the same type if((dynamic_cast<OutputPortInterface*>(*it) && dynamic_cast<OutputPortInterface*>(peerport)) || (dynamic_cast<InputPortInterface*>(*it) && dynamic_cast<InputPortInterface*>(peerport))) { log(Debug)<< (*it)->getName() << " and " << peerport->getName() << " have the same type" << endlog(); continue; } // Try to find a way to connect them if ( !(*it)->connectTo( peerport ) ) { log(Debug)<< "Data flow incompatible between ports " << getName() << "." << (*it)->getName() << " and " << peer->getName() << "." << (*it)->getName() << endlog(); failure = true; } } return !failure; }
// 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; }
void SDRAM::seeCLKChange(const Signal &value, ticks_t time) { if (value.getValue(time)) { // Rising edge. Command newCommand = getCommand(time); switch (newCommand) { case Command::ACTIVE: currentRow = A.getSignal().getValue(time) & ((1 << config.rowBits) - 1); break; case Command::AUTO_REFRESH: case Command::NOP: case Command::PRECHARGE: break; case Command::LOAD_MODE_REGISTER: modeReg.set(A.getSignal().getValue(time)); break; case Command::READ: currentColumn = A.getSignal().getValue(time) & ((1 << config.columnBits) - 1); currentBank = BA.getSignal().getValue(time) & ((1 << config.bankBits) - 1); counter = 0; break; case Command::WRITE: currentColumn = A.getSignal().getValue(time) & ((1 << config.columnBits) - 1); currentBank = BA.getSignal().getValue(time) & ((1 << config.bankBits) - 1); counter = 0; break; case Command::BURST_TERMINATE: break; } if (newCommand != Command::NOP) { currentCommand = newCommand; } switch (currentCommand) { default: break; case Command::READ: { uint16_t mask = getReadWriteMask(time); unsigned burstLength = modeReg.getReadBurstLength(); uint16_t data = mem[getMemoryIndex(burstLength)] & mask; uint8_t readEdge = edgeNumber + modeReg.getCASLatency(); pendingReads.push(std::make_pair(data, readEdge)); ++counter; if (burstLength != 0 && counter == burstLength) currentCommand = Command::NOP; } break; case Command::WRITE: { unsigned burstLength = modeReg.getReadBurstLength(); if (WE.getSignal().getValue(time)) { uint16_t mask = getReadWriteMask(time); uint32_t index = getMemoryIndex(burstLength); uint16_t old = mem[index]; uint16_t data = DQ.getSignal().getValue(time); mem[index] ^= (old ^ data) & mask; } ++counter; if (burstLength != 0 && counter == burstLength) currentCommand = Command::NOP; } break; } ++edgeNumber; } else { // Falling edge. if (!pendingReads.empty() && pendingReads.front().second == edgeNumber) { DQPort->seePinsChange(Signal(pendingReads.front().first), time); pendingReads.pop(); } } }