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 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 From e473fe14614401342cdc3afe3f6deee4831e6e24 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 30 Oct 2022 10:21:38 +0100 Subject: remove client.pro.user --- .gitignore | 1 + client/client.pro.user | 260 ------------------------------------------------- 2 files changed, 1 insertion(+), 260 deletions(-) delete mode 100644 client/client.pro.user diff --git a/.gitignore b/.gitignore index 90d7960..5b91ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ stm32f091/wifi.h client/makefile client/client client/moc_* +**/.user # others shared/main diff --git a/client/client.pro.user b/client/client.pro.user deleted file mode 100644 index 7ccbc7b..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 - - -- cgit v1.2.3 From e8b58762643f0a20454068e352738ecffc372c7e Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 30 Oct 2022 11:40:14 +0100 Subject: fix request send routine --- client/Client.cpp | 16 +++++++++------- client/Client.h | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/client/Client.cpp b/client/Client.cpp index 10d288e..4d948fa 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -1,5 +1,8 @@ +#include + #include "Client.h" #include "consts.h" +#include "../shared/util.h" Client::Client(QObject *parent) : QObject(parent) @@ -34,13 +37,12 @@ void Client::ClientEcho() void Client::timeFunction() { - if(_missingRecords>1){ - totalRecords = _missingRecords; - } - else{ - totalRecords=1; - } - QByteArray msgToSend= (msg.toUtf8() + totalRecords + offsetRecords +'\n'); + totalRecords = WS_MAX(1, _missingRecords); + + char* msg = NULL; + asprintf(&msg, "last-records %x %x\n", totalRecords, offsetRecords); + QByteArray msgToSend = msg; + free(msg); QTime time = QTime::currentTime(); qint16 currentSeconds = time.second(); diff --git a/client/Client.h b/client/Client.h index f675a89..b90e5e9 100644 --- a/client/Client.h +++ b/client/Client.h @@ -35,9 +35,8 @@ private: int tcpPortAddress = WS_SERVER_PORT; // port of communication via tcp QString networkAddress = WS_ESP8266_WLAN_IP; // network address for commincation via tcp - QString msg = "last-records "; // part of mesage to send to wheather staion - char totalRecords = '1'; // total records to ask wheather station - char offsetRecords = '0'; // offset from reqeusting records + uint8_t totalRecords = 1; // total records to ask wheather station + uint8_t offsetRecords = 0; // offset from reqeusting records }; #endif // CLIENT_H -- cgit v1.2.3