157 lines
6.7 KiB
C++
157 lines
6.7 KiB
C++
// MainWidget.h
|
|
#pragma once
|
|
#ifndef MAINWIDGET_H
|
|
#define MAINWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QTcpServer>
|
|
#include <QJsonArray>
|
|
#include <QListWidget>
|
|
#include <QCheckBox>
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
#include <QThreadPool>
|
|
#include <QMutex>
|
|
#include <QFileDialog>
|
|
#include <QLineEdit>
|
|
#include <QTabWidget>
|
|
#include <QTimer>
|
|
#include <QGroupBox>
|
|
#include <QLabel>
|
|
#include <QJsonDocument>
|
|
#include <QFile>
|
|
#include <QDebug>
|
|
#include <QHBoxLayout>
|
|
#include <QTcpSocket>
|
|
#include <QNetworkInterface>
|
|
#include <QTextStream>
|
|
#include <QScrollArea>
|
|
|
|
#include "../Network/ClientHandler.h"
|
|
#include "FocusWindow.h"
|
|
|
|
class MainWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
// 构造函数
|
|
explicit MainWidget(QWidget* parent = nullptr);
|
|
~MainWidget();
|
|
|
|
private slots:
|
|
// 处理开始服务器按钮点击事件
|
|
void onStartServerClicked();
|
|
// 处理发送获取设备信息按键点击事件
|
|
void onSendGetDevInfoClicked();
|
|
// 处理发送取图按键点击事件
|
|
void onSendGetPicClicked();
|
|
// 处理发送拉视频流按键点击事件
|
|
void onSendGetVideoClicked();
|
|
void onLicenseButtonClicked();
|
|
// 处理一键发送按钮点击事件
|
|
void onSendAllClicked();
|
|
// 处理单独发送项按钮点击事件
|
|
void onSendItemClicked();
|
|
// 处理单独发送功能配置项按钮点击事件
|
|
void onSendFuncItemClicked();
|
|
// 处理数据接收信号
|
|
//void onDataReceived(const QString& client, const QByteArray& data);
|
|
// 处理状态更新信号
|
|
void onStatusUpdated(const QString& client, int itemIndex, int funcItemIndex,
|
|
bool success, const QString& itemData, const QString& funcItemData);
|
|
// 处理所有项目处理完毕信号
|
|
void onAllItemsProcessed(const QString& client, int itemsProcessedCount);
|
|
// 处理客户端断开连接
|
|
void onClientDisconnected(ClientHandler* handler);
|
|
// 启动超时定时器
|
|
void onStartTimeout(int clientId, int timeout);
|
|
// 为了使滚动条在最下面,不用手动鼠标下拉
|
|
void scrollToBottom();
|
|
// 处理点击 Save Log 按键
|
|
void onSelectFileButtonClicked();
|
|
// 处理点击 Clear Log 按键
|
|
void onclearLogButtonClicked();
|
|
// 处理复选框的状态
|
|
void onSaveCheckBoxStateChanged(int state);
|
|
// 处理打开调焦的大窗口
|
|
void onOpenFocusWindowClicked();
|
|
void printThreadPoolInfo();
|
|
void onCheckThreadStatus();
|
|
void onCheckConnectionStatus();
|
|
void startClientReadTimer(int clientId);
|
|
void stopClientReadTimer(int clientId);
|
|
|
|
|
|
private:
|
|
// 读取 test JSON 配置文件
|
|
void readJsonConfig();
|
|
// 设置 UI
|
|
void setupUI();
|
|
// 保存日志到文件
|
|
void saveStatusListToFile(const QString& filePath);
|
|
// 用于更新按键文本的函数
|
|
void updateServerButtonText();
|
|
void onDisconnectClient(int clientId);
|
|
void setupTimerForThreadPoolInfo();
|
|
|
|
bool isSendingAll; // 一键功能测试 状态
|
|
QTcpServer* server; // TCP 服务器
|
|
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
|
|
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
|
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
|
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
|
QJsonArray frontBoardLicenseJson; // 前板License JSON
|
|
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
|
QJsonArray testJsonConfig; // 功能测试区 JSON 配置
|
|
QJsonArray funcJsonConfig; // 功能配置区 JSON 配置
|
|
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
|
|
QJsonArray getPicJson; // 发送取图指令 JSON 配置
|
|
QJsonArray getVideoJson; // 发送拉视频指令 JSON 配置
|
|
QVBoxLayout* mainLayout; // 主布局
|
|
QListWidget* statusListWidget; // 状态列表
|
|
QPushButton* startServerButton; // 开始服务器按键
|
|
QPushButton* focusWindowsButton; // 调焦窗口按键
|
|
QPushButton* sendAllButton; // 一键发送按键
|
|
QThreadPool threadPool; // 线程池
|
|
QMutex mutex; // 互斥锁
|
|
int nextClientId; // 新增的客户端编号
|
|
int connectedClientsCount = 0; // 连接客户端的数量
|
|
bool manualSend; // 判断是否是手动触发的发送
|
|
bool deviceConnected = false; // 判断是否有设备连接过
|
|
|
|
QVector<QPushButton*> itemButtons; // 项目按键集合
|
|
QVector<QPushButton*> funcItemButtons; // 功能配置项目按键集合
|
|
QVector<QPushButton*> getPicButtons; // 保存两个取图的摄像头的按键的指针
|
|
QVector<QPushButton*> getVideoButtons; // 保存拉视频设备的按键的指针
|
|
QList<ClientHandler*> clients; // 客户端处理器集合
|
|
QMap<int, QTimer*> clientTimers; // 每个客户端的定时器
|
|
|
|
QCheckBox* saveCheckBox; // 保存文件复选框
|
|
QPushButton* selectFileButton; // Save Log 按键
|
|
QPushButton* clearLogButton; // clear Log 按键
|
|
QLineEdit* filePathLineEdit; // 文件路径显示
|
|
QLabel* leftLens_imageLabel; // 左边镜头图像显示
|
|
QLabel* rightLens_imageLabel; // 右边镜头图像显示
|
|
QLabel* videoLabel; // 视频显示
|
|
QLineEdit* funcConfigLineEdit; // 功能配置编辑框
|
|
|
|
QTabWidget* tabWidget; // 标签页
|
|
QWidget* functionTestArea; // 功能测试区
|
|
QWidget* functionConfigArea; // 功能配置区
|
|
|
|
int lastClickedGetPicCamIndex; // 记录上一次点击取图的摄像头的按键索引
|
|
int lastClickedGetPicDevIndex; // 记录上一次点击取图的设备的按键索引
|
|
int lastClickedGetVideoCamIndex; // 记录上一次点击拉视频的摄像头的按键索引
|
|
int lastClickedGetVideoDevIndex; // 记录上一次点击拉视频的设备的按键索引
|
|
|
|
|
|
QTimer* threadStatusTimer;
|
|
QTimer* connectionStatusCheckTimer; // 添加检查连接状态的定时器
|
|
QMap<int, QThread*> clientThreads;
|
|
QMap<int, ClientHandler*> clients_1;
|
|
QMap<int, QTimer*> clientReadTimers;
|
|
};
|
|
|
|
#endif // MAINWIDGET_H
|