添加广播MDNS服务
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <QMutex>
|
||||
#include <QFileDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QTextEdit>
|
||||
#include <QTabWidget>
|
||||
#include <QTimer>
|
||||
#include <QGroupBox>
|
||||
@@ -23,13 +24,25 @@
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTcpSocket>
|
||||
#include <QUdpSocket>
|
||||
#include <QNetworkInterface>
|
||||
#include <QTextStream>
|
||||
#include <QScrollArea>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "../Json/readJsonFile.h"
|
||||
#include "../RecvDataHandler/RecvDataHandler.h"
|
||||
#include "../LicenseGenerate/LicenseGenerate.h"
|
||||
#include "../LicenseGenerate/LicenseConfirmWindow.h"
|
||||
#include "../Network/mdns/servicemodel.h"
|
||||
#include "../Network/ClientHandler.h"
|
||||
#include "FocusWindow.h"
|
||||
|
||||
// 用于测试 UDP 组播实现 mdns 功能 非标准 mdns
|
||||
#define TEST_UDP_BROADCAST 0
|
||||
|
||||
#define TCP_CONNECT_PORT 12412
|
||||
|
||||
class MainWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -81,7 +94,9 @@ private slots:
|
||||
void onCheckConnectionStatus();
|
||||
void startClientReadTimer(int clientId);
|
||||
void stopClientReadTimer(int clientId);
|
||||
|
||||
#if TEST_UDP_BROADCAST
|
||||
void sendMulticastMessage();
|
||||
#endif
|
||||
|
||||
private:
|
||||
// 读取 test JSON 配置文件
|
||||
@@ -95,62 +110,77 @@ private:
|
||||
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; // 判断是否有设备连接过
|
||||
bool isSendingAll; // 一键功能测试 状态
|
||||
QTcpServer* server; // TCP 服务器
|
||||
//QUdpSocket* udpSocket;
|
||||
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
|
||||
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
||||
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
||||
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
||||
QJsonArray frontBoardLicenseJson; // 前板License JSON
|
||||
QJsonArray backBoardOneClickTest; // 后板一键功能测试 JSON
|
||||
QJsonArray backBoardTest; // 后板单项测试 JSON
|
||||
QJsonArray backBoardFuncConfig; // 后板功能配置参数 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; // 每个客户端的定时器
|
||||
QVector<QPushButton*> itemButtons; // 项目按键集合
|
||||
QVector<QPushButton*> funcItemButtons; // 功能配置项目按键集合
|
||||
QVector<QPushButton*> getPicButtons; // 保存两个取图的摄像头的按键的指针
|
||||
QVector<QPushButton*> getVideoButtons; // 保存拉视频设备的按键的指针
|
||||
QList<ClientHandler*> clients; // 客户端处理器集合
|
||||
QMap<int, QTimer*> clientTimers; // 每个客户端的定时器
|
||||
QMap<QString, QLineEdit*> devInfoLineEdits;// msg_id 和对应的 QLineEdit 的映射关系
|
||||
|
||||
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; // 功能配置区
|
||||
QCheckBox* saveCheckBox; // 保存文件复选框
|
||||
QPushButton* selectFileButton; // Save Log 按键
|
||||
QPushButton* clearLogButton; // clear Log 按键
|
||||
QLineEdit* filePathLineEdit; // 文件路径显示
|
||||
QLabel* leftLens_imageLabel; // 左边镜头图像显示
|
||||
QLabel* rightLens_imageLabel; // 右边镜头图像显示
|
||||
QLabel* videoLabel; // 视频显示
|
||||
QLineEdit* funcConfigLineEdit; // 功能配置编辑框
|
||||
QTextEdit* licenseHwInfoEdit; // 获取license的硬件信息
|
||||
MainWidget* mainWidget;
|
||||
QTabWidget* tabWidget; // 标签页
|
||||
QWidget* functionTestArea; // 功能测试区
|
||||
QWidget* functionConfigArea; // 功能配置区
|
||||
|
||||
int lastClickedGetPicCamIndex; // 记录上一次点击取图的摄像头的按键索引
|
||||
int lastClickedGetPicDevIndex; // 记录上一次点击取图的设备的按键索引
|
||||
int lastClickedGetVideoCamIndex; // 记录上一次点击拉视频的摄像头的按键索引
|
||||
int lastClickedGetVideoDevIndex; // 记录上一次点击拉视频的设备的按键索引
|
||||
int lastClickedGetPicCamIndex; // 记录上一次点击取图的摄像头的按键索引
|
||||
int lastClickedGetPicDevIndex; // 记录上一次点击取图的设备的按键索引
|
||||
int lastClickedGetVideoCamIndex; // 记录上一次点击拉视频的摄像头的按键索引
|
||||
int lastClickedGetVideoDevIndex; // 记录上一次点击拉视频的设备的按键索引
|
||||
|
||||
|
||||
QTimer* threadStatusTimer;
|
||||
QTimer* connectionStatusCheckTimer; // 添加检查连接状态的定时器
|
||||
QMap<int, QThread*> clientThreads;
|
||||
QTimer* threadStatusTimer; // 检查线程状态的定时器
|
||||
QTimer* connectionStatusCheckTimer; // 检查连接状态的定时器
|
||||
QMap<int, QThread*> clientThreads;
|
||||
QMap<int, QTimer*> clientReadTimers;
|
||||
QMap<int, ClientHandler*> clients_1;
|
||||
QMap<int, QTimer*> clientReadTimers;
|
||||
|
||||
ServiceProvider* mServiceProvider;
|
||||
QTimer* mdnsTimer;
|
||||
void startMdnsService();
|
||||
void stopMdnsService();
|
||||
#if TEST_UDP_BROADCAST
|
||||
QUdpSocket* multicastSocket;
|
||||
QTimer* multicastTimer;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // MAINWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user