Files
gcs-nf/dlink/dlink.h
T

238 lines
4.9 KiB
C++
Raw Normal View History

#ifndef DLINK_H
#define DLINK_H
#include <QObject>
#include "QtSerialPort"
#include <QHostAddress>
#include <QUdpSocket>
#include "QDebug"
#include "mavlinknode.h"
2021-01-13 21:51:51 +08:00
2021-06-04 19:26:47 +08:00
#include "QEvent"
2020-04-09 20:19:56 +08:00
QT_BEGIN_NAMESPACE
#ifdef QtDlink
#include <dlinkglobal.h>
class DLINKSHARED_EXPORT DLink : public QObject {
#else
class DLink : public QObject
{
#endif
Q_OBJECT
2020-04-09 20:19:56 +08:00
//Q_DECLARE_PRIVATE(DLink)
2021-07-16 20:59:05 +08:00
enum devtype{
ganeral = 0,
datalink,
remote,
2022-08-26 14:28:12 +08:00
rtk,
video
2021-07-16 20:59:05 +08:00
};
struct clientNode{
QUdpSocket * sock;
QHostAddress addr;
quint16 port;
2021-07-16 20:59:05 +08:00
devtype type;
2022-08-26 14:28:12 +08:00
bool operator==(const clientNode& other)
{
if (this->sock == other.sock)
{
return true;
}
return false;
}
};
2021-01-05 19:24:48 +08:00
struct serialNode{
QSerialPort * port;
QString name;
qint32 baud;
QSerialPort::Parity parity;
2021-07-16 20:59:05 +08:00
devtype type;
2022-08-26 14:28:12 +08:00
bool operator==(const serialNode& other)
{
if (this->name == other.name)
{
return true;
}
return false;
}
2021-01-05 19:24:48 +08:00
};
public:
explicit DLink(QObject *parent = nullptr);
~DLink();
2020-06-15 18:24:22 +08:00
bool setupPort(const QString port, qint32 baudrate, QSerialPort::Parity parity);
2021-07-16 20:59:05 +08:00
//bool statesPort(const QString name);
//void stopPort(const QString name);
2022-08-26 14:28:12 +08:00
bool PortSetup(devtype type,const QString port, qint32 baud, QSerialPort::Parity parity, const char *method);
2021-07-16 20:59:05 +08:00
bool PortState(const QString name);
bool PortStop(const QString name);
bool setup_remote(const QString port, qint32 baud, QSerialPort::Parity parity);
bool setup_rtk(const QString port, qint32 baudrate, QSerialPort::Parity parity);
2021-01-05 19:24:48 +08:00
bool setupClient(const QHostAddress &local_addr,int local_port,const QHostAddress &remote_addr,int remote_port);
MavLinkNode *mavlinknode = nullptr;
2020-08-20 17:48:09 +08:00
bool setup_multicast(const QString &recieveIP, qint32 recievePort,
const QString &transmitIP, qint32 transmitPort);
2020-10-13 18:41:23 +08:00
2022-02-13 14:06:45 +08:00
bool isExportInfo = true;
2020-05-19 19:02:32 +08:00
signals:
2020-07-01 18:22:49 +08:00
void showMessage(const QString &message,int TimeOut = 0);
void recieveMessage(quint32 src,QByteArray data);
2020-06-15 18:24:22 +08:00
void PortConnected(QVariant m_state,
QVariant m_usrName,QVariant m_Type,
QVariant m_Param1,QVariant m_Param2,
QVariant m_Param3,QVariant m_Param4,
QVariant m_Param5);
2021-04-29 09:54:21 +08:00
void getRemote(quint32,QByteArray);
void getRTK(quint32,QByteArray);
void RTCM_Byte(uint32_t);
void RC_Byte(uint32_t);
2021-04-28 15:39:44 +08:00
void info(double rssi,double in,double out);
2021-04-19 22:07:09 +08:00
2020-05-19 19:02:32 +08:00
public slots:
2022-02-25 15:51:18 +08:00
void setExportInfo(QVariant value, QVariant id);
2022-02-13 14:06:45 +08:00
2020-05-19 19:02:32 +08:00
void connectSignal(QVariant m_state,
QVariant m_usrName,QVariant m_Type,
QVariant m_Param1,QVariant m_Param2,
QVariant m_Param3,QVariant m_Param4,
QVariant m_Param5);
void readPendingDatagramsSerialPort(void);
void readPendingDatagramsClient(void);
void processPendingMulticastDatagrams(void);
2020-08-19 14:12:36 +08:00
2021-01-05 19:24:48 +08:00
void readRemotePendingDatagrams(void);
void readRTKPendingDatagrams(void);
2022-02-13 14:06:45 +08:00
int SendMessageToExport(quint8 ch, quint8 *msg, quint16 len);
2020-08-04 17:19:40 +08:00
int SendMessageTo(quint8 ch, quint8 *msg, quint16 len);
2020-08-19 22:21:48 +08:00
2020-08-20 17:48:09 +08:00
//void replay(QString file);
2020-08-19 22:21:48 +08:00
void setSendRTCM(bool flag)
{
sendRTCM = flag;
}
bool isSendRTCM(void)
{
return sendRTCM;
}
private slots:
2021-04-19 22:07:09 +08:00
void bitTimerout(void);
2020-08-04 23:18:58 +08:00
protected:
enum SourceType{
2020-08-19 14:12:36 +08:00
c_sock = 0,
2020-08-19 14:12:36 +08:00
s_port = 1,
p_port = 2,
};
2021-01-13 21:51:51 +08:00
2021-01-05 19:24:48 +08:00
QMap<uint32_t,unsigned> cnts_in;
QMap<uint32_t,unsigned> cnts_out;
QSerialPort *serialPort = nullptr;
QUdpSocket *Clientsock = nullptr;
2022-02-13 14:06:45 +08:00
QUdpSocket *Exportsock = nullptr;
2021-01-05 19:24:48 +08:00
QSerialPort *serialPortRemote = nullptr;
QSerialPort *serialPortRTK = nullptr;
2021-07-16 20:59:05 +08:00
QList<clientNode> clientSockets;
2021-07-07 18:30:41 +08:00
QList<serialNode> serials;
QUdpSocket * multicast_sock=NULL;
QHostAddress multicast_recieve_addr;
qint32 multicast_recieve_port;
QHostAddress multicast_transmit_addr;
qint32 multicast_transmit_port;
2021-01-13 21:51:51 +08:00
2021-01-05 19:24:48 +08:00
QMap<quint8,QIODevice *> Device;
2021-04-19 22:07:09 +08:00
QTimer *bitTimer = nullptr;
quint32 outCount = 0;
quint32 inCount = 0;
quint32 errCount = 0;
quint32 frameCount = 0;
double out_bits = 0;
double in_bits = 0;
double rssi_bits = 0;
bool sendRTCM = false;
bool isRecieveRC = false;
bool isRecieveRTCM = false;
uint64_t RecieveRCtime = 0;
uint64_t RecieveRTCMtime = 0;
2021-04-19 22:07:09 +08:00
2022-11-19 10:20:14 +08:00
uint64_t RecieveRCcount = 0;
uint64_t RecieveRTCMcount = 0;
2021-04-19 22:07:09 +08:00
};
2020-04-10 15:46:03 +08:00
2020-04-09 20:19:56 +08:00
QT_END_NAMESPACE
2020-04-10 15:46:03 +08:00
#endif // DLINK_H