mainwindow.h
3.68 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMessageBox>
#include <QDebug>
//FOR serialport
#include <QString>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
enum my_skin
{
black = 0,
white,
};
class QTcpSocket;
class TcpServer;
class QUdpSocket;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void ui_style_init();
void config_init(void);
void tcp_serial_init(void);
void tcp_init();
void serial_init();
void writeConfig();
void data_processing(const QByteArray receive_tmp);
void data_processing(const QByteArray receive_tmp, const QString ip);
void data_show(QByteArray &receive_tmp);
void data_save(QByteArray receive_tmp);
qint64 serialport_write(const char *data, qint64 len);
private slots:
/* custom system btn */
void onMin( bool );
void onMaxOrNormal( bool );
void onClose( bool );
private:
bool maxOrNormal;//true表示当前窗口状态为normal,图标应显示为max
/* custom title bar */
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
QPoint dragPosition;
public slots:
void readComDataSlot(void);
void read_serial_timer();
void readSendData(); //读取发送配置文件数据
void readDeviceData(); //读取设备转发文件数据
void sendDataTcpServer();
void sendDataTcpServer(QString data);
void sendDataTcpServer(QString ip, int port, QString data);
void sendDataTcpClient();
void sendDataTcpClient(QString data);
void sendDataUdpServer();
void sendDataUdpServer(QString data);
void sendDataUdpServer(QString ip, int port, QString data);
void appendTcpClient(quint8 type, QString msg);
void appendTcpServer(quint8 type, QString msg);
void appendUdpServer(quint8 type, QString msg);
private slots:
void tcpClientReadData();
void tcpClientReadError();
void clientReadData(int, QString ip, int port, QByteArray data);
void clientConnect(int, QString ip, int port);
void clientDisConnect(int, QString ip, int port);
void udpServerReadData();
void udpServerReadError();
void on_connectPushButton_clicked();
void on_sendPushButton_clicked();
private slots:
void on_dataSavePushButton_clicked();
void on_configTabWidget_currentChanged(int index);
void on_tcpTypeComboBox_currentIndexChanged(int index);
void on_clear_pushButton_clicked();
void on_quit_pushButton_clicked();
void on_timerCheckBox_clicked(bool checked);
void on_receiveCheckBox_toggled(bool checked);
void on_serialPortCBox_currentIndexChanged(const QString &arg1);
void on_skinButton_clicked();
public:
int skin_mode;
private:
Ui::MainWindow *ui;
QSerialPort *my_serialport;
QTimer *myTimer_serial;
int rfid_clear_times;
uint8_t sn_num;
int msgMaxCount;
int countTcpServer;
int countTcpClient;
int countUdpServer;
QString current_time;
QStringList keys; //模拟设备回复数据key
QStringList values; //模拟设备回复数据value
QString server_ip;
int server_port;
QTcpSocket *tcpClient;
TcpServer *tcpServer;
QUdpSocket *udpServer;
QTimer *timerTcpClient;
QTimer *timerTcpServer;
QTimer *timerUdpServer;
QTimer *timerDevUpdate;
int timer_dev_update_n;
#define TCP_IP_TYPE 0
#define SERIAL_TYPE 1
int communication_type = TCP_IP_TYPE; //通讯方式
};
#endif // MAINWINDOW_H