-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
216 lines (142 loc) · 6.37 KB
/
mainwindow.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <memory>
#include <QVBoxLayout>
#include <QUdpSocket>
#include <QTimer>
#include <QNetworkAddressEntry>
#include <QProgressDialog>
#include <QThreadPool>
#include <QMetaType>
#include <QProcessEnvironment>
#include "deviceInfoWidget/deviceinfowidget.h"
#include "protocal/arinc615_struct_define.h"
#include "topology/createtopologyxml.h"
#include "operationInterface/findinfowidget.h"
#include "operationInterface/informationwidget.h"
#include "operationInterface/configwidget.h"
#include "operationInterface/uploadwidget.h"
#include "operationInterface/odownloadwidget.h"
#include "operationInterface/mdownloadwidget.h"
#include "successdialog.h"
#include "finddialog.h"
#include "arinc615A/api_615a_socket.h"
#include "device.h"
#include "thread/uploadthread.h"
#include "thread/informationthread.h"
#include "operationInterface/autoconfigwidget.h"
#include "tftp/tftprequest.h"
#include "globalDefine.h"
#include "paraconfigdialog.h"
#include "dir.h"
#include "thread/statusfilercvthread.h"
#include "protocal/findRequest.h"
#include "thread/waitthread.h"
#include "thread/findthread.h"
#include "thread/tftpserverthread.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class QUdpSocket;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void initMainWindow();
void getAllEntry();
void EnableOrdisableExceptFind(bool flag);
void checkIfAnyDeviceSelect();
private slots:
void execFindOperation();
void execInformationOperation();
void execUploadOperation();
void execMediaDownloadOperation();
void execOperatorDownloadOperation();
void execAbortOperation();
void execParaConfigOperation();
//
void execExitTool();
void selectAllDeviceOrNot(bool checked);
//void parseFindResponse();
void onTimerTimeout(const unsigned int steps);
void find(int index);
void on_radio_toggled(bool checked, const Device* device);
void execAutoConfigOperation();
void tftpServerTftpReadReady();
void finishInformation(File_LCL* LCL_struct, QString name, QString ip);
//void beginUpload(QStringList pathList);
void addLogToDockWidget(const int &operationCode, const QString log){
addLogToDockWidget(operationCode, log, "default");
}
void addLogToDockWidget(const int &operationCode, const QString log, const QString deviceName);
void onDeviceFound(const QStringList& deviceInfo);
void onRequestReceived(const QByteArray& tftpRequest, const QHostAddress& remote, const quint16 port);
private:
Ui::MainWindow *ui;
void enableAllExceptCurrentOperation(bool flag);
int createDeviceWidget(const Device&);
void clearDeviceList();
void addDevice(const Device&);
void focusOnCurrentOperation();
void unfocusOnCurrentOperation();
void appendBigEndian(void* arg, size_t size, QByteArray& byteArray);
void saveLog();
QByteArray makeFindRequest(); //构造FIND请求报文
void disableAllExceptCurrentOperation(const unsigned int& op_code);
void waitForAllWorkingThreadsDone();
std::shared_ptr<WaitThread> waitThread = nullptr;
QVector<DeviceInfoWidget *> mDevicesList; //存放设备列表
QVector<FileInfoWidget *> mFilesList; //存放文件列表
std::shared_ptr<FindInfoWidget> mFindInfoWidget; //FIND操作widget
std::shared_ptr<InformationWidget> mInformationWidget; //INFORMATION操作widget
std::shared_ptr<UploadWidget> mUploadWidget; //UPLOAD操作widget
std::shared_ptr<MDownloadWidget> mMDownloadWidget; //介质定义下载操作widget
std::shared_ptr<ODownloadWidget> mODownloadWidget; //用户定义下载操作widget
std::shared_ptr<AutoConfigWidget> mAutoConfigWidget; //自动配置widget
std::shared_ptr<QVBoxLayout> layout; //ui->operationWidget的layout
std::shared_ptr<QWidget> operationWidget = 0; //指向当前operationWidget显示的对象
QString uploadDir; //上传文件夹
QString localIp; //记录本地IP地址
QNetworkAddressEntry* entry = 0;
QUdpSocket* uSock; //FIND操作socket,用于发送FIND请求报文和接受FIND相应报文
int deviceCnt = 0; //记录规定时间内响应FIND请求的设备数目
//QList<Device> *devices = 0;
QMap<QString, const Device*> devices; //记录响应FIND请求的设备信息
QList<const Device*> *checkedDevices = 0; //记录选中的设备信息
int checkedDevicesCnt = 0; //记录选中的设备数量
int responseDevicesCnt = 0; //记录响应的设备数量
std::shared_ptr<QTimer> timer = nullptr;
QList<QNetworkAddressEntry> *entryList; //记录本地所有IP信息
std::shared_ptr<QProgressDialog> progressDialog = nullptr;
//QProgressDialog *progressDialog;
QThreadPool pool; //线程池
//MyThread* threads[15]; //操作线程
//QList<MyThread*> threads; //操作线程
QMap<QString, MyThread*> threads;
QUdpSocket* tftpServer = 0;
//单例模式
FindDialog* findDialog = 0;
FindDialog* getFindDialogInstance();
std::shared_ptr<ParaConfigDialog> paraConfigDialog = nullptr;
std::shared_ptr<ParaConfigDialog> getParaConfigDialogInstance();
std::shared_ptr<FindThread> findThread = nullptr;
std::shared_ptr<TftpServerThread> tftpServerThread = nullptr;
//QUdpSocket* tftpClient = 0;
//QList<QList<QByteArray>*> datagramFromAllDevices;
//QList<TftpRequest *> tftpRequests;
//a615_targets_find_list_t findList;
unsigned int threadsCnt = 0;
unsigned int steps = 0;
//maxThreadCount 的最佳值为与逻辑核对应的个数,比如i5-6600为4核4线程,那么最佳个数为4
//又比如i5-13600k为14核20线程,那么maxThreadCount的最佳值为20
const unsigned int maxThreadCount = 15;
QString userProfile;
signals:
void mainThreadExit();
void findThreadExitSignal();
void tftpServerThreadExitSignal();
};
#endif // MAINWINDOW_H