2022-09-29 16:17:51 +00:00
|
|
|
#ifndef CLUSTER_H
|
|
|
|
#define CLUSTER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QUdpSocket>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QDomDocument>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QDateTime>
|
2022-09-30 16:05:42 +00:00
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QTimer>
|
2022-10-05 12:43:07 +00:00
|
|
|
|
|
|
|
#ifdef USESQL
|
2022-10-05 10:03:15 +00:00
|
|
|
#include <QSqlDatabase>
|
|
|
|
#include <QSqlQuery>
|
2022-10-05 12:43:07 +00:00
|
|
|
#endif
|
|
|
|
|
2022-09-29 16:17:51 +00:00
|
|
|
#include <qcustomplot.h>
|
2022-10-05 11:43:39 +00:00
|
|
|
|
|
|
|
#ifdef USESQL
|
2022-10-05 10:03:15 +00:00
|
|
|
#include "database.h"
|
2022-10-05 11:43:39 +00:00
|
|
|
#endif
|
2022-09-29 16:17:51 +00:00
|
|
|
|
|
|
|
struct spotData {
|
|
|
|
QString dxcall;
|
|
|
|
double frequency;
|
|
|
|
QString spottercall;
|
|
|
|
QDateTime timestamp;
|
|
|
|
QString mode;
|
|
|
|
QString comment;
|
|
|
|
QCPItemText* text = Q_NULLPTR;
|
2022-10-05 10:03:15 +00:00
|
|
|
bool current = false;
|
2022-09-29 16:17:51 +00:00
|
|
|
};
|
|
|
|
|
2022-09-30 16:05:42 +00:00
|
|
|
struct clusterSettings {
|
|
|
|
QString server;
|
2022-09-30 17:41:57 +00:00
|
|
|
int port=7300;
|
2022-09-30 16:05:42 +00:00
|
|
|
QString userName;
|
|
|
|
QString password;
|
|
|
|
int timeout=30;
|
2022-09-30 16:26:21 +00:00
|
|
|
bool isdefault;
|
2022-09-30 16:05:42 +00:00
|
|
|
};
|
2022-09-29 16:17:51 +00:00
|
|
|
|
|
|
|
class dxClusterClient : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit dxClusterClient(QObject* parent = nullptr);
|
|
|
|
virtual ~dxClusterClient();
|
|
|
|
|
|
|
|
signals:
|
2022-09-30 16:05:42 +00:00
|
|
|
void addSpot(spotData* spot);
|
2022-09-29 16:17:51 +00:00
|
|
|
void deleteSpot(QString dxcall);
|
|
|
|
void deleteOldSpots(int minutes);
|
2022-09-30 16:05:42 +00:00
|
|
|
void sendOutput(QString text);
|
2022-10-05 10:03:15 +00:00
|
|
|
void sendSpots(QList<spotData> spots);
|
2022-09-29 16:17:51 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void udpDataReceived();
|
2022-09-30 16:05:42 +00:00
|
|
|
void tcpDataReceived();
|
2022-10-05 10:03:15 +00:00
|
|
|
void tcpDisconnected();
|
2022-09-29 16:17:51 +00:00
|
|
|
void enableUdp(bool enable);
|
|
|
|
void enableTcp(bool enable);
|
|
|
|
void setUdpPort(int p) { udpPort = p; }
|
|
|
|
void setTcpServerName(QString s) { tcpServerName = s; }
|
2022-09-30 16:05:42 +00:00
|
|
|
void setTcpPort(int p) { tcpPort = p; }
|
2022-09-29 16:17:51 +00:00
|
|
|
void setTcpUserName(QString s) { tcpUserName = s; }
|
|
|
|
void setTcpPassword(QString s) { tcpPassword = s; }
|
2022-09-30 16:05:42 +00:00
|
|
|
void setTcpTimeout(int p) { tcpTimeout = p; }
|
|
|
|
void tcpCleanup();
|
2022-10-05 10:03:15 +00:00
|
|
|
void freqRange(double low, double high);
|
2022-10-31 12:39:27 +00:00
|
|
|
void enableSkimmerSpots(bool enable);
|
2022-09-29 16:17:51 +00:00
|
|
|
|
|
|
|
private:
|
2022-09-30 16:05:42 +00:00
|
|
|
void sendTcpData(QString data);
|
2022-10-05 10:03:15 +00:00
|
|
|
bool databaseOpen();
|
|
|
|
void updateSpots();
|
2022-09-30 16:05:42 +00:00
|
|
|
|
2022-09-29 16:17:51 +00:00
|
|
|
bool udpEnable;
|
|
|
|
bool tcpEnable;
|
|
|
|
QUdpSocket* udpSocket=Q_NULLPTR;
|
|
|
|
QTcpSocket* tcpSocket=Q_NULLPTR;
|
|
|
|
int udpPort;
|
|
|
|
QString tcpServerName;
|
2022-09-30 16:05:42 +00:00
|
|
|
int tcpPort;
|
2022-09-29 16:17:51 +00:00
|
|
|
QString tcpUserName;
|
|
|
|
QString tcpPassword;
|
2022-09-30 16:05:42 +00:00
|
|
|
int tcpTimeout;
|
2022-09-29 16:17:51 +00:00
|
|
|
QDomDocument udpSpotReader;
|
2022-09-30 16:05:42 +00:00
|
|
|
QRegularExpression tcpRegex;
|
|
|
|
QMutex mutex;
|
|
|
|
bool authenticated=false;
|
|
|
|
QTimer* tcpCleanupTimer=Q_NULLPTR;
|
2022-10-05 12:43:07 +00:00
|
|
|
#ifdef USESQL
|
2022-10-05 10:03:15 +00:00
|
|
|
QSqlDatabase db;
|
2022-10-05 12:43:07 +00:00
|
|
|
#endif
|
2022-10-05 10:03:15 +00:00
|
|
|
double lowFreq;
|
|
|
|
double highFreq;
|
2022-10-05 11:43:39 +00:00
|
|
|
QMap<QString,spotData*> allSpots;
|
2022-10-31 12:39:27 +00:00
|
|
|
bool skimmerSpots = false;
|
2022-09-29 16:17:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|