void copyDataflows( ESMoL::ModelsFolder inputModelsFolder, ESMoL::ModelsFolder outputModelsFolder ) {

	getPortList().clear();
	getPortMap().clear();

	DataflowVector dataflowVector = inputModelsFolder.Dataflow_kind_children();
	for( DataflowVector::iterator dfvItr = dataflowVector.begin() ; dfvItr != dataflowVector.end() ; ++dfvItr ) {
		ESMoL::Dataflow inputDataflow = *dfvItr;
		ESMoL::Dataflow outputDataflow = ESMoL::Dataflow::Create( outputModelsFolder );
		outputDataflow.name() = inputDataflow.name();
		copySubsystems_flatten( inputDataflow, outputDataflow );
	}

	for( PortList::iterator ptlItr = getPortList().begin() ; ptlItr != getPortList().end() ; ++ptlItr ) {

		ESMoL::Port inputDstPort = *ptlItr;

		LineSet lineSet = inputDstPort.srcLine();
		if ( lineSet.empty() ) continue;
		ESMoL::Line line = *lineSet.begin();
		ESMoL::Port inputSrcPort = line.srcLine_end();
		lineSet = inputSrcPort.srcLine();
		while( getPortMap().find( inputSrcPort ) == getPortMap().end() && !lineSet.empty() ) {
			line = *lineSet.begin();
			inputSrcPort = line.srcLine_end();
			lineSet = inputSrcPort.srcLine();
		}

		PortMap::iterator ptmItr = getPortMap().find( inputDstPort );
		if ( ptmItr == getPortMap().end() ) {
			std::cerr << "Warning: port not in PortMap" << std::endl;
			continue;
		}
		ESMoL::Port outputDstPort = ptmItr->second;

		ptmItr = getPortMap().find( inputSrcPort );
		if ( ptmItr == getPortMap().end() ) {
			std::cerr << "Warning: port not in PortMap" << std::endl;
			continue;
		}
		ESMoL::Port outputSrcPort = ptmItr->second;

		Udm::Object lineParent = outputSrcPort.GetParent();
		if (  Udm::IsDerivedFrom( outputSrcPort.type(), ESMoL::OutPort::meta )  ) lineParent = lineParent.GetParent();

		ESMoL::Line outputLine = ESMoL::Line::Create( lineParent );
		outputLine.srcLine_end() = outputSrcPort;
		outputLine.dstLine_end() = outputDstPort;
	}
}
Ejemplo n.º 2
0
void ServerWidget::start(){
    textEdit->append("\nSTART");

    for(QLabel* label : labelStatus){
        label->setText("-");
    }

    QStringList adressList = getAdressList();
    QVector<int> portList = getPortList();

    QMetaObject::invokeMethod(server, "setupPlayers", Qt::AutoConnection,
                              Q_ARG(QStringList, adressList),
                              Q_ARG(QVector<int>, portList));
    QMetaObject::invokeMethod(server, "setupClock", Qt::AutoConnection,
                              Q_ARG(int, lineEditStartclock->text().toInt()),
                              Q_ARG(int, lineEditPlayclock->text().toInt()));

//    server->setupPlayers(adressList, portList);
//    server->setupClock(lineEditStartclock->text().toInt(), lineEditPlayclock->text().toInt());

    pingButton->setDisabled(true);
    startButton->setDisabled(true);
    abortButton->setDisabled(false);

    QMetaObject::invokeMethod(server, "start", Qt::AutoConnection);
//    server->start();
}
void copyPorts( ESMoL::Block inputBlock, ESMoL::Block outputBlock ) {

	PortVector portVector = inputBlock.Port_kind_children();
	for( PortVector::iterator ptvItr = portVector.begin() ; ptvItr != portVector.end() ; ++ptvItr ) {
		ESMoL::Port inputPort = *ptvItr;
		ESMoL::Port outputPort = UdmEngine::copy( inputPort, outputBlock  );
		if ( outputPort == Udm::null ) {
			std::cerr << "Warning: could not copy output port" << std::endl;
			return;
		}

		getPortList().push_back( inputPort );
		getPortMap().insert(  std::make_pair( inputPort, outputPort )  );

		ESMoL::TypeBaseRef inputTypeBaseRef = inputPort.TypeBaseRef_child();
		if ( inputTypeBaseRef != Udm::null ) {
			ESMoL::TypeBaseRef outputTypeBaseRef = ESMoL::TypeBaseRef::Create( outputPort );
			ESMoL::TypeBase inputTypeBase = inputTypeBaseRef.ref();
			if ( inputTypeBase != Udm::null ) {
				TypeBaseMap::iterator tbmItr = getTypeBaseMap().find( inputTypeBase );
				if ( tbmItr != getTypeBaseMap().end() ) {
					outputTypeBaseRef.name() = inputTypeBaseRef.name();
					outputTypeBaseRef.ref() = tbmItr->second;
				}
			}
		}

	}	
}
Ejemplo n.º 4
0
  /**
   * @brief  Restart PDelays on all ports
   * @return void
   */
  void restartPDelayAll() {
	  int number_ports, i, j = 0;
	  CommonPort **ports;

	  getPortList( number_ports, ports );

	  for( i = 0; i < number_ports; ++i ) {
		  while( ports[j] == NULL ) ++j;
		  ports[j]->restartPDelay();
	  }
  }
Ejemplo n.º 5
0
  /**
   * @brief  Release all TX locks
   * @return void
   */
  int putTxLockAll() {
	  int number_ports, i, j = 0;
	  CommonPort **ports;

	  getPortList( number_ports, ports );

	  for( i = 0; i < number_ports; ++i ) {
		  while( ports[j] == NULL ) ++j;
		  if( ports[j]->putTxLock() == false ) {
			  return false;
		  }
	  }

	  return true;
  }
Ejemplo n.º 6
0
void ServerWidget::ping(){
    textEdit->append("\nPING");

    QStringList adressList = getAdressList();
    QVector<int> portList = getPortList();

    adressList = adressList.mid(0, nbRoles);
    portList = portList.mid(0, nbRoles);

    QMetaObject::invokeMethod(server, "setupPlayers", Qt::AutoConnection,
                              Q_ARG(QStringList, adressList),
                              Q_ARG(QVector<int>, portList));
    QMetaObject::invokeMethod(server, "ping", Qt::AutoConnection);

    // Direct calls like this would execute the function in the current thread
//    server->setupPlayers(adressList, portList);
//    server->ping();
}