-
Notifications
You must be signed in to change notification settings - Fork 15
/
SCStatusTcp.h
59 lines (43 loc) · 1.29 KB
/
SCStatusTcp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef SCStatusTcp_H
#define SCStatusTcp_H
#include <QTcpSocket>
#include <QObject>
#include <QElapsedTimer>
class SCStatusTcp : public QObject
{
Q_OBJECT
public:
explicit SCStatusTcp(QObject *parent = 0);
~SCStatusTcp();
void releaseTcpSocket();
QString lastError() const;
void setLastError(const QString &lastError);
bool writeTcpData(uint16_t sendCommand,
const QByteArray &jsonData,
const QByteArray &sendData,
uint16_t &number, uint8_t byte15);
QTcpSocket *tcpSocket() const;
QElapsedTimer time() const;
int connectHost(const QString &ip, quint16 port);
QString getCurrentDateTime() const;
QString hexToQString(const QByteArray &b);
int getTimeOut() const;
void setTimeOut(int timeOut);
public slots:
void receiveTcpReadyRead();
signals:
void sigPrintInfo(QString);
void sigChangedText(bool ,int ,QByteArray ,QByteArray ,int ,int );
private:
QTcpSocket *_tcpSocket;
QString _lastError;
QString _ip; //ip
quint16 _port; //端口号
uint16_t _number;//序号
QByteArray _lastMessage;//存放所有读取的数据
QElapsedTimer _time;//用来监测时间
int _oldSendCommand;
int _oldNumber;
int _timeOut;
};
#endif // SCStatusTcp_H