diff options
| author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2022-10-30 12:40:53 +0100 |
|---|---|---|
| committer | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2022-10-30 12:40:53 +0100 |
| commit | 26564caa92d02a85a23fcd768a301fc76ec7c4cd (patch) | |
| tree | f0c3845ee79a3c29d0b8a8c4cb2d3caaeb1efb5d /client/Client.cpp | |
| parent | 6b2ff1c137773b91ce9552446a7ac91dd951b02b (diff) | |
| parent | 75064a08587bc960c06d2324a0334ee88441fb35 (diff) | |
Merge branch 'qt-settings' of https://github.com/UnavailableDev/avans-whether-station-Qt into qt-settings
Diffstat (limited to 'client/Client.cpp')
| -rw-r--r-- | client/Client.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/client/Client.cpp b/client/Client.cpp index 46952b6..4d948fa 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -1,5 +1,8 @@ -#include "Client.h" +#include <stdio.h> +#include "Client.h" +#include "consts.h" +#include "../shared/util.h" Client::Client(QObject *parent) : QObject(parent) @@ -17,8 +20,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 @@ -36,22 +37,19 @@ 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 currentMinute = time.minute(); + qint16 currentSeconds = time.second(); + if((currentSeconds % WS_CLIENT_STATION_POLL_INTERVAL) == 1){ - if(currentMinute==NextMinute){ socket->connectToHost(networkAddress, tcpPortAddress); - socket->write(msgToSend); - NextMinute++; } } |