Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Tässä

...

esimerkissä

...

haetaan

...

anturin

...

kalibrointikäyrän

...

arvot

...

Sqlite

...

tietokannasta

{
Code Block
}
bool SensorUnlinearityCorrection::LoadFromDatabase()
{
    int i;
    double todellinen, mitattu;
    QSqlQueryModel model;
    model.setQuery("SELECT todellinen, mitattu FROM kalibrointi");
    CorrectVal.clear();
    ValFromSensor.clear();
    for (i = 0; i < model.rowCount(); i++) {
        todellinen = model.record(i).value("todellinen").toDouble();
        mitattu = model.record(i).value("mitattu").toDouble();
        CorrectVal.append(todellinen);
        ValFromSensor.append((mitattu));
    }
    return true;
}
{code}

Esimerkki

...

tietokannan

...

toteutuksesta

...

ja

...

käytöstä:

{
Code Block
}
 CREATE TABLE "kalibrointi" (
    "kalibrointi_id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  
    "Todellinen" REAL NOT NULL,
    "Mitattu" REAL NOT NULL
);

insert into kalibrointi ("kalibrointi_id", "Todellinen", "Mitattu") values ('1', '0', '0');
insert into kalibrointi values ('2','25','25.5');
insert into kalibrointi values ('3','50','50.6');
insert into kalibrointi values ('4','75','75.9');
insert into kalibrointi values ('5','90','90.4');
insert into kalibrointi values ('7','100','100.8');
{code}