Beispiel #1
0
void UAPN::createBlockSchedulingOnSQ(std::string startPlace, std::string beginPlace, std::string queueName, std::string blockName) {
    // create the waiting slots for this version of the block, and the transition allowing the advancement in the queue
    
    // creation of the transition symbolizing the start of the execution of the instance
    std::string waitingSlotPlace = getBlockWaitingSlotPlace(queueName, blockName, 0);
    addPlace(waitingSlotPlace, 0);
    Transition * trans = new Transition();
    trans->guards.push_back(waitingSlotPlace);
    trans->decEffects.push_back(waitingSlotPlace);
    trans->incEffects.push_back(beginPlace);
    addTransition(trans);

    for (unsigned k = 1; k < queueSize; ++k) {
        // the block waiting slot (queueSize-1) is the start place and has already be created by the "visitBlock" method from QPN
        if (k == queueSize - 1) {
            waitingSlotPlace = startPlace;
        } else {
            waitingSlotPlace = getBlockWaitingSlotPlace(queueName, blockName, k);
            addPlace(waitingSlotPlace, 0);
        }
        trans = new Transition();
        trans->guards.push_back(waitingSlotPlace);
        trans->guards.push_back(getQueueWaitingSlotPlace(queueName, k - 1, true));
        trans->guards.push_back(getQueueWaitingSlotPlace(queueName, k, false));
        trans->decEffects.push_back(waitingSlotPlace);
        trans->incEffects.push_back(getBlockWaitingSlotPlace(queueName, blockName, k - 1));
        trans->decEffects.push_back(getQueueWaitingSlotPlace(queueName, k - 1, true));
        trans->decEffects.push_back(getQueueWaitingSlotPlace(queueName, k, false));
        trans->incEffects.push_back(getQueueWaitingSlotPlace(queueName, k - 1, false));
        trans->incEffects.push_back(getQueueWaitingSlotPlace(queueName, k, true));
        addTransition(trans);
    }
}
Beispiel #2
0
void UAPN::visitQueue(const QDAS::Queue * q) {
    if (q->isSerial()) {
        for (unsigned i = 0; i < queueSize; ++i) {
            std::string qwsT = getQueueWaitingSlotPlace(q->name, i, true);
            std::string qwsF = getQueueWaitingSlotPlace(q->name, i, false);
            addPlace(qwsT, 1);
            addPlace(qwsF, 0);
            addInvariant(qwsT + "=1, " + qwsF + "=1");
        }
    }
}
Beispiel #3
0
void FavoritePlacesModel::addFavorite(const QString &favoriteId)
{
    KUrl favoriteUrl = FavoriteUtils::urlFromFavoriteId(favoriteId);
    if (favoriteUrl.isEmpty()) {
        return;
    }
    addPlace(favoriteUrl.fileName(), favoriteUrl);
}
Beispiel #4
0
std::string UAPN::createEndOfBlockOnSQ(std::string blockName, std::string queueName) {
    // when finished, the block needs to release the waiting slot 0.
    std::string endPlace = getUniqueScopedPlaceNameFrom("END", getBlockVersionNameOnSQ(blockName, queueName));
    addPlace(endPlace, 0);
    Transition * trans = new Transition();
    trans->guards.push_back(endPlace);
    trans->guards.push_back(getQueueWaitingSlotPlace(queueName, 0, false));
    trans->decEffects.push_back(endPlace);
    trans->incEffects.push_back(getQueueWaitingSlotPlace(queueName, 0, true));
    trans->decEffects.push_back(getQueueWaitingSlotPlace(queueName, 0, false));
    addTransition(trans);
    return endPlace;
}
// Reduce the list of places to those that are contained within the bounds
void GeoSearchReplyBb::boundPlaces( const QList<QtMobilitySubset::QGeoPlace> & unboundPlaces )
{
    // Bound only if the bounds are valid and not empty. If the bounds are empty the bounds area is zero, so assume the bounds
    // are only useful for the centre location, as a hint where to search in the case of geocoding.
    if ( _bounds && _bounds->isValid() && !_bounds->isEmpty() ) {
        for ( int i = 0 ; i < unboundPlaces.size() ; i++ ) {
            if ( _bounds->contains( unboundPlaces.at(i).coordinate() ) ) {
                addPlace( unboundPlaces.at(i) );
            }
        }
    } else {
        // there are no bounds, add all places.
        setPlaces( unboundPlaces );
    }

}
Beispiel #6
0
void NavigationView::plotLineIntersection() {
    if (scene()->selectedItems().count()<2)
        return;

    QPointF intersectPoint;
    QLineF line1, line2;

    line1 = ((QGraphicsLineItem*)(scene()->selectedItems().at(0)))->line();
    line2 = ((QGraphicsLineItem*)(scene()->selectedItems().at(1)))->line();

    if (line1.intersect(line2, &intersectPoint)!=QLineF::BoundedIntersection) {
        qDebug("lines did not intersect");
        return;
    }

    addPlace(intersectPoint, Qt::red, false);
    newLandmarkAdded(mapSceneToGeo(intersectPoint));
}
void MainWindow::prepareGUI()
{

    this->ui->mapLayout->addWidget(&this->map, 0, 0);
    this->map.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    this->textEditLog.append("Application log\nApplication started\n");
    this->textEditLog.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);

    this->ui->controlsLayout->addWidget(&this->browser, 0, 0);
    this->ui->controlsLayout->addWidget(&this->list, 1, 0);
    this->ui->controlsLayout->addWidget(&this->textEditLog, 2, 0);

    this->map.setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
    connect(&this->map, SIGNAL(placeSelected(double,double,QString)), this, SLOT(placeSelected(double,double,QString)));
    connect(&this->browser, SIGNAL(search_button_clicked(QString)), this, SLOT(searchButton_clicked(QString)));
    connect(&this->browser, SIGNAL(add_button_clicked()), this, SLOT(addPlace()));
    connect(&this->browser, SIGNAL(suggestion_clicked(QListWidgetItem*)), this, SLOT(suggestion_clicked(QListWidgetItem*)));
    connect(&this->list, SIGNAL(btn_delete_click(QListWidgetItem*)), this, SLOT(deletePlace(QListWidgetItem*)));
    connect(&this->list, SIGNAL(btn_calculate_click(int)), this, SLOT(calculate(int)));
    connect(&this->list, SIGNAL(item_clicked(QListWidgetItem*)), this, SLOT(place_clicked(QListWidgetItem*)));
}
Beispiel #8
0
std::string UAPN::visit(QDAS::DispatchAction * a, std::string continuationPlace, std::string scope) {
    const QDAS::Queue * q = qdas->getQueueNamed(a->queue);
    if (!q->isSerial()) {
        return QPN::visit(a, continuationPlace, scope);
    }
    std::string startPlace;
    if (a->label.empty()) {
        startPlace = getUniqueScopedPlaceNameFrom("DISP", scope);
    } else {
        startPlace = a->label + "_FROM_" + scope;
    }
    addPlace(startPlace, 0);
    std::string blockVersion = getBlockVersionNameOnSQ(a->block, a->queue);
    if (!isBlockVersionAlreadyEncoded(blockVersion)) {
        visitBlock(qdas->getBlockNamed(a->block), q);
    }
    // if the queue is already full: one token is produced in QUEUE_OVERFLOW
    Transition * trans = new Transition();
    trans->guards.push_back(startPlace);
    for (unsigned i = 0; i < queueSize; ++i) {
        trans->guards.push_back(getQueueWaitingSlotPlace(q->name, i, false));
    }
    trans->incEffects.push_back("QUEUE_OVERFLOW");
    addTransition(trans);

    // if the last waiting slot is free, take it and create the new instance of the block
    trans = new Transition();
    trans->guards.push_back(startPlace);
    trans->guards.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, true));
    trans->decEffects.push_back(startPlace);
    trans->decEffects.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, true));
    trans->incEffects.push_back(blockVersion); //start place of the block
    trans->incEffects.push_back(getQueueWaitingSlotPlace(q->name, queueSize - 1, false));
    addTransition(trans);
    return startPlace;
}
Beispiel #9
0
UAPN::UAPN(unsigned max, QDAS* q, unsigned queueSize) : QPN(max, q), queueSize(queueSize) {
    addPlace("QUEUE_OVERFLOW", 0);
    addTarget("QUEUE_OVERFLOW>=1");
}