-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathmainwindow.h
More file actions
135 lines (123 loc) · 3.31 KB
/
mainwindow.h
File metadata and controls
135 lines (123 loc) · 3.31 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include <QFont>
#include <QPushButton>
#include <QLineEdit>
#include <QtSerialPort>
#include <QIntValidator>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
struct Settings {
QString name;
qint32 baudRate;
QString stringBaudRate;
QSerialPort::DataBits dataBits;
QString stringDataBits;
QSerialPort::Parity parity;
QString stringParity;
QSerialPort::StopBits stopBits;
QString stringStopBits;
QSerialPort::FlowControl flowControl;
QString stringFlowControl;
bool localEchoEnabled;
bool sendNewLineEnabled;
QString stringStatus;
bool isDtr;
bool isRts;
bool isHexDisplay;
bool isHexSend;
bool isTimerSend;
qint32 timerLength;
QString sendCache;
QString sendStringCache;
qint32 sendNum;
qint32 receiveNum;
}DEF_SETTINGS = {
"",
QSerialPort::BaudRate::Baud115200,
QString::number(QSerialPort::Baud115200),
QSerialPort::DataBits::Data8,
QString::number(QSerialPort::DataBits::Data8),
QSerialPort::Parity::NoParity,
QString::number(QSerialPort::Parity::NoParity),
QSerialPort::StopBits::OneStop,
QString::number(QSerialPort::StopBits::OneStop),
QSerialPort::FlowControl::NoFlowControl,
QString::number(QSerialPort::FlowControl::NoFlowControl),
false,
true,
"",
false,
false,
false,
false,
false,
1000,
"",
"",
0,
0
};
Settings settings() const;
private slots:
void checkCustomBaudRatePolicy(int idx);
void on_openserial_pushButton_pressed();
void on_openfile_pushButton_released();
void handleError(QSerialPort::SerialPortError error);
void writeData();
void readData();
void currentIndexChanged();
void serialPortChanged();
void onSendButtonRelease();
void on_clear_pushButton_released();
void on_hexsend_checkBox_released();
private:
Ui::MainWindow *ui;
QStatusBar *mStatusBar;
/** 网址 */
QLabel *mStatusLabel;
/** 网址 */
QLabel *mFinallyLabel;
/** 状态标签 */
QLabel *mNetAddrLabel;
/** led */
QLabel *mLedLabel;
QFont font;
/** 总接收数量显示标签 */
QLabel *mReceiveLabel;
/** 总发送数量显示标签 */
QLabel *mSendLabel;
bool isOn;
void init();
/** 文件路径 */
QString mFilePath;
QPushButton *mSendButton;
QPushButton *mSendFileButton;
QPushButton *mOpenSerialButton;
QLineEdit *mOpenFileLineEdit;
QLineEdit *mTimerSendLineEdit;
QSerialPort *serial;
QIntValidator *intValidator;
void fillPortsParameters();
Settings currentSettings;
void updateSettings();
void updateUi(Settings p);
void fillPortsInfo();
bool openSerialPort();
void closeSerialPort();
void about();
bool setParameter(QSerialPort *serial, Settings settings);
Settings doSettings(bool isWrite, Settings inSettings);
QTimer *autoSendTimer;
const bool DEBUG = true;
};
#endif // MAINWINDOW_H