From 09c6f1847a1ba1e1a08c129b71ae50ed9910a4af Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 30 Oct 2022 22:49:22 +0100 Subject: janky/buggy auto-refresh --- client/Client.cpp | 4 +- client/Client.h | 2 +- client/client.pro.user | 260 ------------------------------------------------- client/mainwindow.cpp | 23 ++--- client/mainwindow.h | 1 + 5 files changed, 15 insertions(+), 275 deletions(-) delete mode 100644 client/client.pro.user (limited to 'client') diff --git a/client/Client.cpp b/client/Client.cpp index 16b9bf3..263a57f 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -34,7 +34,7 @@ void Client::ClientEcho() { connect(socket, &QTcpSocket::disconnected, [&]() { socket->disconnectFromHost(); lineCounter = 0; - refreshChart=true; + refreshChart=true; }); timer->start(1000); @@ -53,8 +53,6 @@ void Client::timeFunction() { socket->connectToHost(networkAddress, tcpPortAddress); socket->write(msgToSend); - - } void Client::missingRecords() { diff --git a/client/Client.h b/client/Client.h index cb6e6b8..59e0841 100644 --- a/client/Client.h +++ b/client/Client.h @@ -17,11 +17,11 @@ class Client : public QObject public: Client(QObject *parent = 0); virtual ~Client(); + bool refreshChart; public slots: void ClientEcho(); // function to ask data from wheather station void timeFunction(); // function to look every second what time currently is en handle if minute is passed - bool refreshChart; private: void missingRecords(); diff --git a/client/client.pro.user b/client/client.pro.user deleted file mode 100644 index 0490100..0000000 --- a/client/client.pro.user +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - EnvironmentId - {aa240e53-c124-4cf0-84a8-30bfe8a2cf83} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - false - true - false - 0 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 4 - - - - true - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop Qt 6.4.0 MinGW 64-bit - Desktop Qt 6.4.0 MinGW 64-bit - qt.qt6.640.win64_mingw_kit - 0 - 0 - 0 - - 0 - D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug - D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - - - D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Release - D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Release - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - - - 0 - D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Profile - D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Profile - - - true - QtProjectManager.QMakeBuildStep - false - - - - true - Qt4ProjectManager.MakeStep - - 2 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - true - Qt4ProjectManager.MakeStep - clean - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - 0 - 0 - - 3 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - true - - 2 - - ProjectExplorer.CustomExecutableRunConfiguration - - false - true - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 6f2337d..597b122 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -12,6 +12,9 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); client.ClientEcho(); + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(timeFunction())); + timer->start(1000); _dbConenctor = new dbConnector(this); } @@ -22,15 +25,14 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::timeFunction() -{ - client.timeFunction(); - if(client.refreshChart==true){ - drawGraph(); - client.refreshChart=false; - } - - +void MainWindow::timeFunction() { + printf("timeFunction\n"); + client.timeFunction(); // segfault ->? + if(client.refreshChart == true){ + client.refreshChart = false; + printf("redrawing...\n"); + drawGraph(); + } } void MainWindow::on_actionConnection_triggered() @@ -41,7 +43,7 @@ void MainWindow::on_actionConnection_triggered() void MainWindow::on_actionRefresh_triggered() { - // drawGraph(); + drawGraph(); } void MainWindow::on_actionDisconnenct_triggered() @@ -55,7 +57,6 @@ void MainWindow::drawGraph(){ QLineSeries *seriesHumidity = new QLineSeries(); QLineSeries *seriesPressure = new QLineSeries(); - if(dbRef.open()){ QSqlQuery queryGraphData; // queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); diff --git a/client/mainwindow.h b/client/mainwindow.h index 6bcc329..8b5395b 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -45,6 +45,7 @@ private: Ui::MainWindow *ui; Client client; dbConnector *_dbConenctor; + QTimer *timer; // timer to read every second what time it curruntly is. QChart *_pChart; // QLineSeries *_pSeries; -- cgit v1.2.3