wfview/cluster.h

83 wiersze
1.8 KiB
C
Czysty Zwykły widok Historia

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-09-29 16:17:51 +00:00
#include <qcustomplot.h>
struct spotData {
QString dxcall;
double frequency;
QString spottercall;
QDateTime timestamp;
QString mode;
QString comment;
QCPItemText* text = Q_NULLPTR;
};
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-09-29 16:17:51 +00:00
public slots:
void udpDataReceived();
2022-09-30 16:05:42 +00:00
void tcpDataReceived();
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-09-29 16:17:51 +00:00
private:
2022-09-30 16:05:42 +00:00
void sendTcpData(QString data);
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-09-29 16:17:51 +00:00
};
#endif