From eb10a1a6dc03d83284788128d3f77ff57852c3c6 Mon Sep 17 00:00:00 2001 From: NielsCoding Date: Sun, 30 Oct 2022 10:15:05 +0100 Subject: intervals added and consts.h --- client/Client.cpp | 11 ++++------- client/Client.h | 2 +- client/HandleMessage.h | 2 -- client/client.pro | 1 + client/client.pro.user | 8 +++++--- client/consts.h | 10 ++++++++++ client/dbconnector.cpp | 2 +- client/dbconnector.h | 1 - client/dbconnector.ui | 8 ++++---- 9 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 client/consts.h (limited to 'client') diff --git a/client/Client.cpp b/client/Client.cpp index 46952b6..01c3867 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -1,5 +1,5 @@ #include "Client.h" - +#include "consts.h" Client::Client(QObject *parent) : QObject(parent) @@ -17,8 +17,6 @@ Client::~Client() void Client::ClientEcho() { - QTime time1 = QTime::currentTime(); - NextMinute = time1.minute()+1; connect(timer, SIGNAL(timeout()),this,SLOT(timeFunction())); // connect timer to time every minute @@ -45,13 +43,12 @@ void Client::timeFunction() QByteArray msgToSend= (msg.toUtf8() + totalRecords + offsetRecords +'\n'); QTime time = QTime::currentTime(); - qint16 currentMinute = time.minute(); + qint16 currentSeconds = time.second(); + auto _intervals = intervals; + if(currentSeconds % _intervals==0){ - if(currentMinute==NextMinute){ socket->connectToHost(networkAddress, tcpPortAddress); - socket->write(msgToSend); - NextMinute++; } } diff --git a/client/Client.h b/client/Client.h index 10af3e1..38419a8 100644 --- a/client/Client.h +++ b/client/Client.h @@ -1,5 +1,6 @@ #ifndef CLIENT_H #define CLIENT_H + #include #include #include @@ -27,7 +28,6 @@ private: QTcpSocket *socket; // tcpsocket for communicating QTimer *timer; // timer to read every second what time it curruntly is. - qint16 NextMinute; // timing for next minute // qint16 currentMinute; // timing for currentMinute HandleMessage Handlemsg; // add HandleMessage to Client.h diff --git a/client/HandleMessage.h b/client/HandleMessage.h index bfc5063..f228633 100644 --- a/client/HandleMessage.h +++ b/client/HandleMessage.h @@ -16,8 +16,6 @@ public: QString ParseMessage(const QString , int); void ParseToSQL(QString); - - private: }; diff --git a/client/client.pro b/client/client.pro index 76f2b56..8305949 100644 --- a/client/client.pro +++ b/client/client.pro @@ -3,6 +3,7 @@ QT += core gui sql charts network HEADERS += \ Client.h \ HandleMessage.h \ + consts.h \ dbconnector.h \ main.h \ mainwindow.h diff --git a/client/client.pro.user b/client/client.pro.user index 7ccbc7b..78fe5c2 100644 --- a/client/client.pro.user +++ b/client/client.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -235,12 +235,14 @@ 2 - ProjectExplorer.CustomExecutableRunConfiguration - + Qt4ProjectManager.Qt4RunConfiguration:D:/Github2/avans-whether-station/client/client.pro + D:/Github2/avans-whether-station/client/client.pro false true + true false true + D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug 1 diff --git a/client/consts.h b/client/consts.h new file mode 100644 index 0000000..1bc6040 --- /dev/null +++ b/client/consts.h @@ -0,0 +1,10 @@ +#ifndef CONSTS_H +#define CONSTS_H + + + + +#define intervals 10; + + +#endif // CONSTS_H diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp index 186f8f7..8643014 100644 --- a/client/dbconnector.cpp +++ b/client/dbconnector.cpp @@ -3,7 +3,7 @@ #include "main.h" #include "mainwindow.h" - +# dbConnector::dbConnector(QWidget *parent) : QDialog(parent), ui(new Ui::dbConnector) diff --git a/client/dbconnector.h b/client/dbconnector.h index db8ac4e..b989e57 100644 --- a/client/dbconnector.h +++ b/client/dbconnector.h @@ -6,7 +6,6 @@ //#include //#include - namespace Ui { class dbConnector; } diff --git a/client/dbconnector.ui b/client/dbconnector.ui index 1159faf..5c5b326 100644 --- a/client/dbconnector.ui +++ b/client/dbconnector.ui @@ -6,8 +6,8 @@ 0 0 - 362 - 273 + 401 + 288 @@ -18,8 +18,8 @@ 60 60 - 241 - 173 + 270 + 171 -- cgit v1.2.3