From cc0e2064612256630bd55040d378bd0a93a858d2 Mon Sep 17 00:00:00 2001 From: JeanMouloude Date: Sat, 17 May 2014 15:55:45 +0200 Subject: [PATCH] Des trucs --- InPut/databasecontroller.cpp | 11 ++++++----- dialog.cpp | 21 +++++++++++++-------- dialog.h | 4 ++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/InPut/databasecontroller.cpp b/InPut/databasecontroller.cpp index 5407876..7329fba 100644 --- a/InPut/databasecontroller.cpp +++ b/InPut/databasecontroller.cpp @@ -9,6 +9,7 @@ void DatabaseController::run() { setup(); forever { if(!work.isEmpty()) { + qDebug() << "[DB] Queue size: " << work.size(); QStringList req = work.dequeue().split(";"); if(req.size() < 4) break; @@ -30,7 +31,7 @@ void DatabaseController::run() { rep = db.exec("SELECT value,time FROM data WHERE sensor=\""+idc+"\" AND sensorvalue=\""+idv+"\" ORDER BY time DESC LIMIT 0,1"); QVector dataset; - qDebug() << "READ"; + //qDebug() << "READ"; while(rep.next()) { double value = rep.value(0).toDouble(); QDateTime time = QDateTime::fromString(rep.value(1).toString(),"yyyy-MM-dd hh:mm:ss"); @@ -39,17 +40,17 @@ void DatabaseController::run() { d.time = time; dataset.push_back(d); - qDebug() << "[" << time.toString("yyyy-MM-dd hh:mm:ss") << "|" << value << "]"; + //qDebug() << "[" << time.toString("yyyy-MM-dd hh:mm:ss") << "|" << value << "]"; } - qDebug() << "FINREAD"; - qDebug() << "req=" << req.at(5) << ";" << last; + //qDebug() << "FINREAD"; + //qDebug() << "req=" << req.at(5) << ";" << last; emit dataRead(idc.toInt(),idv.toInt(),dataset,req.at(5)); } else if(req.at(0) == "set") { QString value = req.at(3); db.exec("INSERT INTO data (sensor,sensorvalue,value,time) VALUES (\""+idc+"\",\""+idv+"\",\""+value+"\",\""+QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")+"\")"); - qDebug() << "INSERT (" << idc << ";" << idv<<") " << value << " [" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << "]"; + //qDebug() << "INSERT (" << idc << ";" << idv<<") " << value << " [" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") << "]"; emit dataWritten(idc.toInt(),idv.toInt()); } } diff --git a/dialog.cpp b/dialog.cpp index 1fd2c55..887d61d 100644 --- a/dialog.cpp +++ b/dialog.cpp @@ -1,20 +1,27 @@ #include "dialog.h" - using namespace std; AskDialog::AskDialog() { - setupUi(this); + + settings = new QSettings("Cookie Project","Logger"); + this->setWindowTitle("Bonjour, veuillez choisir le port halal de connexion série."); connect(pushButton,SIGNAL(clicked()),this,SLOT(continueClicked())); fen=NULL; - QStringList portList = Serial::getPortList(); + QString prev_port = settings->value("serial/port","").toString(); + int prev_baudrate = settings->value("serial/baud",0).toInt(); + baudrate->setCurrentIndex(prev_baudrate); + QStringList portList = Serial::getPortList(); for(int i=0;iaddItem(portList.at(i)); + if(prev_port == portList.at(i)) { + selectEntry->setCurrentIndex(i); + } nItems++; } @@ -38,18 +45,16 @@ void AskDialog::continueClicked() else port = selectEntry->currentText(); - Serial* com; - com = new Serial(port, baudrate->currentText().toInt()); - - + settings->setValue("serial/port",port); + settings->setValue("serial/baud",baudrate->currentIndex()); + Serial* com = new Serial(port, baudrate->currentText().toInt()); com->init(); fen = new FenPrincipale(com); fen->show(); - this->close(); } diff --git a/dialog.h b/dialog.h index 3e235c8..b825062 100644 --- a/dialog.h +++ b/dialog.h @@ -6,6 +6,7 @@ #include "InPut/serial.h" #include "FenPrincipale.h" #include "QtSerialPort/QSerialPort" +#include class AskDialog : public QDialog, public Ui::Dialog { @@ -20,6 +21,9 @@ private slots: void on_selectEntry_currentIndexChanged(const QString &arg1); private: FenPrincipale* fen; + + + QSettings* settings; int nItems; };