aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/Client.cpp10
-rw-r--r--client/Client.h10
-rw-r--r--client/HandleMessage.h2
-rw-r--r--client/client.pro1
-rw-r--r--client/consts.h5
-rw-r--r--client/dbconnector.h1
-rw-r--r--client/dbconnector.ui8
-rw-r--r--client/ui_dbconnector.h163
-rw-r--r--client/ui_mainwindow.h110
9 files changed, 17 insertions, 293 deletions
diff --git a/client/Client.cpp b/client/Client.cpp
index 46952b6..10d288e 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,11 @@ void Client::timeFunction()
QByteArray msgToSend= (msg.toUtf8() + totalRecords + offsetRecords +'\n');
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++;
}
}
diff --git a/client/Client.h b/client/Client.h
index 10af3e1..f675a89 100644
--- a/client/Client.h
+++ b/client/Client.h
@@ -1,5 +1,6 @@
#ifndef CLIENT_H
#define CLIENT_H
+
#include <QTcpSocket>
#include <QTextStream>
#include <QTimer>
@@ -7,6 +8,7 @@
#include <QSqlQuery>
#include "HandleMessage.h"
+#include "../shared/wifi.h"
// class client for wheather station
class Client : public QObject
@@ -27,19 +29,15 @@ 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
- int tcpPortAddress = 80; // port of communication via tcp
- QString networkAddress = "192.168.137.76"; // network address for commincation via tcp
+ 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
-
-
-
};
#endif // 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/consts.h b/client/consts.h
new file mode 100644
index 0000000..7ee81c8
--- /dev/null
+++ b/client/consts.h
@@ -0,0 +1,5 @@
+#pragma once
+
+// delay between new record request in seconds
+#define WS_CLIENT_STATION_POLL_INTERVAL 10
+
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 <QtSql>
//#include <QSqlDatabase>
-
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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>362</width>
- <height>273</height>
+ <width>401</width>
+ <height>288</height>
</rect>
</property>
<property name="windowTitle">
@@ -18,8 +18,8 @@
<rect>
<x>60</x>
<y>60</y>
- <width>241</width>
- <height>173</height>
+ <width>270</width>
+ <height>171</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
diff --git a/client/ui_dbconnector.h b/client/ui_dbconnector.h
deleted file mode 100644
index dec4d7b..0000000
--- a/client/ui_dbconnector.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/********************************************************************************
-** Form generated from reading UI file 'dbconnector.ui'
-**
-** Created by: Qt User Interface Compiler version 5.15.6
-**
-** WARNING! All changes made in this file will be lost when recompiling UI file!
-********************************************************************************/
-
-#ifndef UI_DBCONNECTOR_H
-#define UI_DBCONNECTOR_H
-
-#include <QtCore/QVariant>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QDialog>
-#include <QtWidgets/QFormLayout>
-#include <QtWidgets/QFrame>
-#include <QtWidgets/QHBoxLayout>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QPushButton>
-#include <QtWidgets/QWidget>
-
-QT_BEGIN_NAMESPACE
-
-class Ui_dbConnector
-{
-public:
- QWidget *formLayoutWidget;
- QFormLayout *formLayout;
- QLabel *label_3;
- QLineEdit *lineEdit_adress;
- QLabel *label_4;
- QLineEdit *lineEdit_database;
- QFrame *line;
- QLabel *label;
- QLineEdit *lineEdit_username;
- QLabel *label_2;
- QLineEdit *lineEdit_password;
- QLabel *connectLabel;
- QHBoxLayout *horizontalLayout;
- QPushButton *pushButton_login;
- QPushButton *pushButton_cancel;
-
- void setupUi(QDialog *dbConnector)
- {
- if (dbConnector->objectName().isEmpty())
- dbConnector->setObjectName(QString::fromUtf8("dbConnector"));
- dbConnector->resize(362, 273);
- formLayoutWidget = new QWidget(dbConnector);
- formLayoutWidget->setObjectName(QString::fromUtf8("formLayoutWidget"));
- formLayoutWidget->setGeometry(QRect(60, 60, 241, 173));
- formLayout = new QFormLayout(formLayoutWidget);
- formLayout->setObjectName(QString::fromUtf8("formLayout"));
- formLayout->setContentsMargins(0, 0, 0, 0);
- label_3 = new QLabel(formLayoutWidget);
- label_3->setObjectName(QString::fromUtf8("label_3"));
-
- formLayout->setWidget(0, QFormLayout::LabelRole, label_3);
-
- lineEdit_adress = new QLineEdit(formLayoutWidget);
- lineEdit_adress->setObjectName(QString::fromUtf8("lineEdit_adress"));
-
- formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit_adress);
-
- label_4 = new QLabel(formLayoutWidget);
- label_4->setObjectName(QString::fromUtf8("label_4"));
-
- formLayout->setWidget(1, QFormLayout::LabelRole, label_4);
-
- lineEdit_database = new QLineEdit(formLayoutWidget);
- lineEdit_database->setObjectName(QString::fromUtf8("lineEdit_database"));
-
- formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit_database);
-
- line = new QFrame(formLayoutWidget);
- line->setObjectName(QString::fromUtf8("line"));
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
-
- formLayout->setWidget(2, QFormLayout::SpanningRole, line);
-
- label = new QLabel(formLayoutWidget);
- label->setObjectName(QString::fromUtf8("label"));
-
- formLayout->setWidget(3, QFormLayout::LabelRole, label);
-
- lineEdit_username = new QLineEdit(formLayoutWidget);
- lineEdit_username->setObjectName(QString::fromUtf8("lineEdit_username"));
- lineEdit_username->setEchoMode(QLineEdit::PasswordEchoOnEdit);
-
- formLayout->setWidget(3, QFormLayout::FieldRole, lineEdit_username);
-
- label_2 = new QLabel(formLayoutWidget);
- label_2->setObjectName(QString::fromUtf8("label_2"));
-
- formLayout->setWidget(4, QFormLayout::LabelRole, label_2);
-
- lineEdit_password = new QLineEdit(formLayoutWidget);
- lineEdit_password->setObjectName(QString::fromUtf8("lineEdit_password"));
- QFont font;
- font.setUnderline(false);
- font.setStrikeOut(false);
- font.setKerning(true);
- lineEdit_password->setFont(font);
- lineEdit_password->setEchoMode(QLineEdit::Password);
-
- formLayout->setWidget(4, QFormLayout::FieldRole, lineEdit_password);
-
- connectLabel = new QLabel(formLayoutWidget);
- connectLabel->setObjectName(QString::fromUtf8("connectLabel"));
-
- formLayout->setWidget(5, QFormLayout::LabelRole, connectLabel);
-
- horizontalLayout = new QHBoxLayout();
- horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
- pushButton_login = new QPushButton(formLayoutWidget);
- pushButton_login->setObjectName(QString::fromUtf8("pushButton_login"));
-
- horizontalLayout->addWidget(pushButton_login);
-
- pushButton_cancel = new QPushButton(formLayoutWidget);
- pushButton_cancel->setObjectName(QString::fromUtf8("pushButton_cancel"));
-
- horizontalLayout->addWidget(pushButton_cancel);
-
-
- formLayout->setLayout(5, QFormLayout::FieldRole, horizontalLayout);
-
-
- retranslateUi(dbConnector);
-
- QMetaObject::connectSlotsByName(dbConnector);
- } // setupUi
-
- void retranslateUi(QDialog *dbConnector)
- {
- dbConnector->setWindowTitle(QCoreApplication::translate("dbConnector", "Dialog", nullptr));
- label_3->setText(QCoreApplication::translate("dbConnector", "Adress", nullptr));
- lineEdit_adress->setText(QCoreApplication::translate("dbConnector", "localhost", nullptr));
- lineEdit_adress->setPlaceholderText(QCoreApplication::translate("dbConnector", "Hostname/IP-Adress", nullptr));
- label_4->setText(QCoreApplication::translate("dbConnector", "Database", nullptr));
- lineEdit_database->setText(QCoreApplication::translate("dbConnector", "WSdb", nullptr));
- lineEdit_database->setPlaceholderText(QCoreApplication::translate("dbConnector", "Database name", nullptr));
- label->setText(QCoreApplication::translate("dbConnector", "Username", nullptr));
- lineEdit_username->setText(QCoreApplication::translate("dbConnector", "root", nullptr));
- lineEdit_username->setPlaceholderText(QCoreApplication::translate("dbConnector", "Username", nullptr));
- label_2->setText(QCoreApplication::translate("dbConnector", "Password", nullptr));
- lineEdit_password->setText(QCoreApplication::translate("dbConnector", "Ab12345!", nullptr));
- lineEdit_password->setPlaceholderText(QCoreApplication::translate("dbConnector", "Password", nullptr));
- connectLabel->setText(QCoreApplication::translate("dbConnector", "Connect", nullptr));
- pushButton_login->setText(QCoreApplication::translate("dbConnector", "Login", nullptr));
- pushButton_cancel->setText(QCoreApplication::translate("dbConnector", "Cancel", nullptr));
- } // retranslateUi
-
-};
-
-namespace Ui {
- class dbConnector: public Ui_dbConnector {};
-} // namespace Ui
-
-QT_END_NAMESPACE
-
-#endif // UI_DBCONNECTOR_H
diff --git a/client/ui_mainwindow.h b/client/ui_mainwindow.h
deleted file mode 100644
index 69c476b..0000000
--- a/client/ui_mainwindow.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/********************************************************************************
-** Form generated from reading UI file 'mainwindow.ui'
-**
-** Created by: Qt User Interface Compiler version 5.15.6
-**
-** WARNING! All changes made in this file will be lost when recompiling UI file!
-********************************************************************************/
-
-#ifndef UI_MAINWINDOW_H
-#define UI_MAINWINDOW_H
-
-#include <QtCore/QVariant>
-// #include <QtWidgets/QAction>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QLabel>
-#include <QtWidgets/QMainWindow>
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QStatusBar>
-#include <QtWidgets/QWidget>
-
-QT_BEGIN_NAMESPACE
-
-class Ui_MainWindow
-{
-public:
- QAction *actionRefresh;
- QAction *actionLOAD;
- QAction *actionQuerry;
- QAction *actionConnection;
- QAction *actionDisconnenct;
- QWidget *centralwidget;
- QLabel *label;
- QMenuBar *menubar;
- QMenu *menuAbouy;
- QMenu *menuDatabase;
- QStatusBar *statusbar;
-
- void setupUi(QMainWindow *MainWindow)
- {
- if (MainWindow->objectName().isEmpty())
- MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
- MainWindow->resize(800, 600);
- actionRefresh = new QAction(MainWindow);
- actionRefresh->setObjectName(QString::fromUtf8("actionRefresh"));
- actionLOAD = new QAction(MainWindow);
- actionLOAD->setObjectName(QString::fromUtf8("actionLOAD"));
- actionQuerry = new QAction(MainWindow);
- actionQuerry->setObjectName(QString::fromUtf8("actionQuerry"));
- actionConnection = new QAction(MainWindow);
- actionConnection->setObjectName(QString::fromUtf8("actionConnection"));
- actionDisconnenct = new QAction(MainWindow);
- actionDisconnenct->setObjectName(QString::fromUtf8("actionDisconnenct"));
- centralwidget = new QWidget(MainWindow);
- centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
- label = new QLabel(centralwidget);
- label->setObjectName(QString::fromUtf8("label"));
- label->setGeometry(QRect(270, 190, 181, 51));
- MainWindow->setCentralWidget(centralwidget);
- menubar = new QMenuBar(MainWindow);
- menubar->setObjectName(QString::fromUtf8("menubar"));
- menubar->setGeometry(QRect(0, 0, 800, 24));
- menuAbouy = new QMenu(menubar);
- menuAbouy->setObjectName(QString::fromUtf8("menuAbouy"));
- menuDatabase = new QMenu(menubar);
- menuDatabase->setObjectName(QString::fromUtf8("menuDatabase"));
- MainWindow->setMenuBar(menubar);
- statusbar = new QStatusBar(MainWindow);
- statusbar->setObjectName(QString::fromUtf8("statusbar"));
- MainWindow->setStatusBar(statusbar);
-
- menubar->addAction(menuAbouy->menuAction());
- menubar->addAction(menuDatabase->menuAction());
- menuAbouy->addAction(actionRefresh);
- menuDatabase->addAction(actionConnection);
- menuDatabase->addAction(actionDisconnenct);
-
- retranslateUi(MainWindow);
-
- QMetaObject::connectSlotsByName(MainWindow);
- } // setupUi
-
- void retranslateUi(QMainWindow *MainWindow)
- {
- MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
- actionRefresh->setText(QCoreApplication::translate("MainWindow", "Refresh", nullptr));
-#if QT_CONFIG(shortcut)
- actionRefresh->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+R", nullptr));
-#endif // QT_CONFIG(shortcut)
- actionLOAD->setText(QCoreApplication::translate("MainWindow", "Load", nullptr));
- actionQuerry->setText(QCoreApplication::translate("MainWindow", "Query", nullptr));
- actionConnection->setText(QCoreApplication::translate("MainWindow", "Connect", nullptr));
-#if QT_CONFIG(shortcut)
- actionConnection->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+O", nullptr));
-#endif // QT_CONFIG(shortcut)
- actionDisconnenct->setText(QCoreApplication::translate("MainWindow", "Disconnenct", nullptr));
- label->setText(QCoreApplication::translate("MainWindow", "Please load data first", nullptr));
- menuAbouy->setTitle(QCoreApplication::translate("MainWindow", "Home", nullptr));
- menuDatabase->setTitle(QCoreApplication::translate("MainWindow", "Database", nullptr));
- } // retranslateUi
-
-};
-
-namespace Ui {
- class MainWindow: public Ui_MainWindow {};
-} // namespace Ui
-
-QT_END_NAMESPACE
-
-#endif // UI_MAINWINDOW_H