Skip to content

Commit

Permalink
Des trucs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLortex committed May 17, 2014
1 parent 644cd0b commit cc0e206
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
11 changes: 6 additions & 5 deletions InPut/databasecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Data> 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");
Expand All @@ -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());
}
}
Expand Down
21 changes: 13 additions & 8 deletions dialog.cpp
Original file line number Diff line number Diff line change
@@ -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;i<portList.size();i++) {
selectEntry->addItem(portList.at(i));
if(prev_port == portList.at(i)) {
selectEntry->setCurrentIndex(i);
}
nItems++;
}

Expand All @@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "InPut/serial.h"
#include "FenPrincipale.h"
#include "QtSerialPort/QSerialPort"
#include <QSettings>

class AskDialog : public QDialog, public Ui::Dialog
{
Expand All @@ -20,6 +21,9 @@ private slots:
void on_selectEntry_currentIndexChanged(const QString &arg1);
private:
FenPrincipale* fen;


QSettings* settings;
int nItems;
};

Expand Down

0 comments on commit cc0e206

Please sign in to comment.