添加 初始化失败的重试功能
This commit is contained in:
@@ -17,8 +17,41 @@
|
||||
#pragma comment(lib,"./HslComunnicationCpp.lib")
|
||||
|
||||
#include "base.h"
|
||||
class MyThread;
|
||||
|
||||
class writeThread;
|
||||
class MyThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyThread() {};
|
||||
~MyThread();
|
||||
bool setIpAndPort(QString ip, QString port);
|
||||
void run();
|
||||
void readSocketData(); //读取数据
|
||||
void writeSocketData(); //写入数据
|
||||
void decodePack();
|
||||
void setMutexLock(QMutex* lock) { m_mutex_lock = lock; }
|
||||
void setRunStop() { init_flag = 2; }
|
||||
void setReadPackValue(int value);
|
||||
void closeSocket();
|
||||
bool getInitSuccessFlag() { return init_success; }
|
||||
bool disReconnects();
|
||||
void setSocketIp(QString Station) { m_Station = Station; }
|
||||
private:
|
||||
QString m_IP;
|
||||
QString m_Port;
|
||||
QString m_Station;
|
||||
QMutex m_Mutex;
|
||||
QByteArray reciveData;
|
||||
QString socketIp;
|
||||
bool init_success = false; // 初始化成功 返回true;失败返回false
|
||||
int init_flag = 0; // false为完整数据包,true为非完整数据包
|
||||
int m_readPackValue = 122; // 接受50个数据包的长度 为 122 ,加包头一起为 130, 如果是 100的话就是 222 加包头为230
|
||||
QMutex* m_mutex_lock = nullptr;
|
||||
//QTcpSocket *tcpsocket = nullptr; // tcp通信的socket
|
||||
HDTcpBase* tcpsocket = nullptr;
|
||||
};
|
||||
|
||||
class Hd_SocketModule_ModbusTcp :public Base
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -75,43 +108,7 @@ private:
|
||||
//MyThread *m_Thread = nullptr;
|
||||
//QTcpSocket* tcpsocket = nullptr; //tcp通信的socket
|
||||
QMutex* m_Mutex = nullptr;
|
||||
MyThread* m_Thread = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
//自己创建线程
|
||||
class MyThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MyThread(QObject *parent = nullptr):QThread(parent){}
|
||||
~MyThread();
|
||||
bool setIpAndPort(QString ip,QString port);
|
||||
void run();
|
||||
void readSocketData(); //读取数据
|
||||
void writeSocketData(); //写入数据
|
||||
void decodePack();
|
||||
void setMutexLock(QMutex* lock) { m_mutex_lock = lock; }
|
||||
void setRunStop(){ init_flag = 2;}
|
||||
void setReadPackValue(int value);
|
||||
void closeSocket();
|
||||
bool getInitSuccessFlag(){return init_success;}
|
||||
bool disReconnects();
|
||||
void setSocketIp(QString Station) { m_Station = Station; }
|
||||
private:
|
||||
QString m_IP;
|
||||
QString m_Port;
|
||||
QString m_Station;
|
||||
QMutex m_Mutex;
|
||||
QByteArray reciveData;
|
||||
QString socketIp;
|
||||
bool init_success = true; // 初始化成功 返回true;失败返回false
|
||||
int init_flag = 0; // false为完整数据包,true为非完整数据包
|
||||
int m_readPackValue = 122; // 接受50个数据包的长度 为 122 ,加包头一起为 130, 如果是 100的话就是 222 加包头为230
|
||||
QMutex* m_mutex_lock = nullptr;
|
||||
//QTcpSocket *tcpsocket = nullptr; // tcp通信的socket
|
||||
HDTcpBase* tcpsocket = nullptr;
|
||||
MyThread m_Thread;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
|
||||
Reference in New Issue
Block a user