Ejemplo n.º 1
0
return ___3358; } int FileStreamReader::fscanf(char const* format, void* ptr1, void* ptr2, void* ptr3) { REQUIRE(___2041()); REQUIRE(VALID_NON_ZERO_LEN_STR(format)); REQUIRE(VALID_REF(ptr1)); REQUIRE(VALID_REF(ptr2)); REQUIRE(VALID_REF(ptr3));
 #ifdef PROFILE_FILE_ACCESS
___1393 startLoc = fileLoc();
 #endif
int ___3358 = ::fscanf(m_fileIOStream.handle(), format, ptr1, ptr2, ptr3);
 #ifdef PROFILE_FILE_ACCESS
___1393 endLoc = fileLoc(); statistics().numReadWritesPerformed++; statistics().___2780 += (endLoc-startLoc);
 #endif
return ___3358; } }}
 void listStops() {
     std::ofstream fileLoc("/home/hpba/malvinDetailsOut.dat");
     for (auto &element : buses) {
         fileLoc << element.name << std::endl;
         for (auto &stopName : element.busStopNames) {
             fileLoc << stopName.second << " (lat: " 
                     << locations.get(stopName.first).lat() << ", lon: "
                     << locations.get(stopName.first).lon() << ")\n";
         }
     }
     fileLoc.close();
 }
void NewBlockWindow::createBlock(bool locations){
    int i, j;

    // -- Create locations, add them in the vector 'neuronLoc' and save them ---
    if(locations){
        QFile fileLoc(/*FOLDERNAME + "/" + */ui->nameLineEdit->text() + ".loc");
        if (!fileLoc.open(QIODevice::WriteOnly)) {
            std::cerr << "Cannot open fileLoc for writing: "
                 << qPrintable(fileLoc.errorString()) << std::endl;
            return;
        }
        QTextStream outLoc(&fileLoc);

        for(i=0; i<ui->spinBoxNeuronsX->value(); i++){
            for(j=0; j<ui->spinBoxNeuronsY->value(); j++){
                neuronLoc.append(NeuronUnit((float)i,(float)j, 0.0f));
                outLoc << QString::number((float)i, 'f', 7) << " "
                       << QString::number((float)j, 'f', 7) << " "
                       << QString::number(0.0f, 'f', 7) << "\n";
            }
        }
        fileLoc.close();
    }

    // -- Add block (including locations) to schema ----------------------------
    bool spiking = false;
    if(!BackendData::node_model.contains(ui->neuronModelComboBox->currentText())){
        qDebug() << "NewBlockWindow::createBlock: Error: node model not recognized!";
        return;
    }
    if(BackendData::node_model[ui->neuronModelComboBox->currentText()] == "spike")
        spiking = true;
    else if(BackendData::node_model[ui->neuronModelComboBox->currentText()] == "rate")
        spiking = false;
    else{
        qDebug() << "NewBlockWindow::createBlock: Error: node model not recognized!";
        return;
    }

    Block *block = new Block(ui->nameLineEdit->text(),
                             ui->neuronModelComboBox->currentText(),
                             spiking,
                             pos.x()-(ui->widthSlider->value()/2) - 5,
                             pos.y()-(ui->heightSlider->value()/2) - 5,
                             ui->widthSlider->value() + 10,
                             ui->heightSlider->value() + 10,
                             ui->colourLineEdit->text(),
                             "Default",
                             this->getNeurons(),
                             this->schema);

    QString model = ui->neuronModelComboBox->currentText();
    if(!BackendData::node_units_field.contains(model)){
        qDebug() << "NewBlockWindow::getNeurons: Error: model" << model
                 << "not contained!";
        exit(1);
    }

    for(int i=0; i<fieldsLabel.size(); i++){
        if(BackendData::node_fields[model][i][2] == "integer")
            block->setParam(fieldsLabel[i]->text(), QString::number(
                            ((QSpinBox*)fieldsWidget[i])->value()));
        else if(BackendData::node_fields[model][i][2] == "float")
            block->setParam(fieldsLabel[i]->text(), QString::number(
                            ((QDoubleSpinBox*)fieldsWidget[i])->value()));
        else if(BackendData::node_fields[model][i][2] == "bool")
            block->setParam(fieldsLabel[i]->text(),((QCheckBox*)
                            fieldsWidget[i])->isChecked() ?"True" : "False");
        if(BackendData::node_fields[model][i][2] == "string")
            block->setParam(fieldsLabel[i]->text(),
                            ((QLineEdit*)fieldsWidget[i])->text());
        else{
            qDebug() << "NewBlockWindow::getNeurons:"
                     << "Error: field type not contained!";
        }
    }

    for(int i=0; i<parsLineEdit.size(); i++){
        block->setParam(parsLabel[i]->text(), parsLineEdit[i]->text());
    }

    for(int i=0; i<statesLineEdit.size(); i++){
        block->setState(statesLabel[i]->text(), statesLineEdit[i]->text());
    }

    block->setParam("SpatiallyEmbedded",ui->spatiallyEmbeddedCheckBox->isChecked() ? "1" : "0");

    schema->addBlock(block);


    schema->setModified();
}