diff --git a/FactoryTestTool/FactoryTestTool.vcxproj b/FactoryTestTool/FactoryTestTool.vcxproj index 15f2471..4709079 100644 --- a/FactoryTestTool/FactoryTestTool.vcxproj +++ b/FactoryTestTool/FactoryTestTool.vcxproj @@ -134,7 +134,6 @@ - diff --git a/FactoryTestTool/FactoryTestTool.vcxproj.filters b/FactoryTestTool/FactoryTestTool.vcxproj.filters index dbe674a..cdb8103 100644 --- a/FactoryTestTool/FactoryTestTool.vcxproj.filters +++ b/FactoryTestTool/FactoryTestTool.vcxproj.filters @@ -94,9 +94,6 @@ Media\VideoDecoder - - Widget - Network diff --git a/FactoryTestTool/SourceCode/LicenseGenerate/LicenseConfirmWindow.h b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseConfirmWindow.h index aabe2a3..e1cc07b 100644 --- a/FactoryTestTool/SourceCode/LicenseGenerate/LicenseConfirmWindow.h +++ b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseConfirmWindow.h @@ -14,6 +14,7 @@ public: explicit LicenseConfirmWindow(const QString& message, QWidget* parent = nullptr) { messageLabel = new QLabel(message, this); + messageLabel->setStyleSheet("QLabel { color : red; }"); confirmButton = new QPushButton("确认", this); cancelButton = new QPushButton("取消", this); diff --git a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp index 0e3b4ec..8d8a133 100644 --- a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp +++ b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp @@ -33,7 +33,7 @@ FFmpegDecoder::~FFmpegDecoder() void FFmpegDecoder::processVideo(int itemIndex) { -#if 0 +#if 1 int width = 720; int height = 1280; #elif 1 @@ -43,6 +43,7 @@ void FFmpegDecoder::processVideo(int itemIndex) int width = 480; int height = 640; #endif + qDebug() << "------ processVideo"; if (width * 16 == height * 9) { FocusWindowDialog* dialog = new FocusWindowDialog(nullptr, QSize(540, 960)); dialog->exec(); @@ -75,11 +76,12 @@ void FFmpegDecoder::stopFFmpegDecoder() mutex.unlock(); } -void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoDisplayLabel) +void FFmpegDecoder::decodeFile(const QString& videoFilePath, QLabel* videoDisplayLabel, QLineEdit* VideoResolutionEdit) { QMutexLocker locker(&mutex); - this->filePath = filePath; - this->videoLabel = videoDisplayLabel; + this->filePath = videoFilePath; + this->videoLabel = videoDisplayLabel; + this->resolutionEdit = VideoResolutionEdit; if (!isRunning()) { qDebug() << "Starting decoder thread"; start(NormalPriority); @@ -107,8 +109,8 @@ void FFmpegDecoder::run() QSize labelSize = currentVideoLabel->size(); mutex.unlock(); - if (labelSize.width() < 740 || labelSize.height() < 357) { - labelSize = QSize(740, 357); + if (labelSize.width() < 220 || labelSize.height() < 357) { + labelSize = QSize(220, 357); currentVideoLabel->setFixedSize(labelSize); qDebug() << "Adjusting video label size to: Width =" << labelSize.width() << ", Height =" << labelSize.height(); } @@ -275,7 +277,9 @@ QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame) { int width = frame->width; int height = frame->height; - qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height; + QString resolutionText = QString::number(width) + " x " + QString::number(height); + resolutionEdit->setText(resolutionText); + //qDebug() << "H264 video resolution: Width =" << frame->width << ", Height =" << frame->height; AVPixelFormat pixFmt = (AVPixelFormat)frame->format; diff --git a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h index 908f654..7b56fc0 100644 --- a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h +++ b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "RingBuffer.h" #include "FocusWindow.h" @@ -38,7 +39,7 @@ public: ~FFmpegDecoder() override; void initialize(); - void decodeFile(const QString& filePath, QLabel* videoLabel); + void decodeFile(const QString& videoFilePath, QLabel* videoLabel, QLineEdit* VideoResolutionEdit); void decodeSingleFrame(const QByteArray& data, QLabel* videoLabel); // 添加 videoLabel 参数 void FFmpegDecoder::processVideo(int itemIndex); bool initializeFFmpeg(const QString& filePath); @@ -55,6 +56,7 @@ private: QWaitCondition condition; QString filePath; QLabel* videoLabel; + QLineEdit* resolutionEdit; bool abort; bool restart; diff --git a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp index c6ed2c8..e40df41 100644 --- a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp +++ b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp @@ -201,16 +201,22 @@ void ClientHandler::sendGetDevInfoItem(int itemIndex) } // 发送取图按键 -void ClientHandler::sendGetPicItem(int itemIndex, int lastClickedGetVideoCamIndex) +void ClientHandler::sendGetPicItem(int itemIndex, int GetPicCamIndex) { - sendJsonItem(getPicJson, itemIndex, QString::number(lastClickedGetVideoCamIndex), "getPic"); + sendJsonItem(getPicJson, itemIndex, QString::number(GetPicCamIndex), "getPic"); } // 发送拉视频按键 -void ClientHandler::sendGetVideoItem(int itemIndex, int video_flag) +void ClientHandler::sendGetVideoItem(int itemIndex, int GetVideoCamIndex) { qDebug() << "sendGetVideoItem itemIndex:" << itemIndex; - sendJsonItem(getVideoJson, itemIndex, "", "handleVideo"); + qDebug() << "sendGetVideoItem GetVideoCamIndex:" << GetVideoCamIndex; + if(isBackBoardOrAllBoard) { + sendJsonItem(getVideoJson, itemIndex, QString::number(GetVideoCamIndex), "handleVideo"); + } + else { + sendJsonItem(getVideoJson, itemIndex, "", "handleVideo"); + } } // 发送License处理按键 diff --git a/FactoryTestTool/SourceCode/Network/ClientHandler.h b/FactoryTestTool/SourceCode/Network/ClientHandler.h index 9539721..43d6f2d 100644 --- a/FactoryTestTool/SourceCode/Network/ClientHandler.h +++ b/FactoryTestTool/SourceCode/Network/ClientHandler.h @@ -52,9 +52,9 @@ public: // 发送获取设备信息按键 void sendGetDevInfoItem(int itemIndex); // 发送取图按键 - void sendGetPicItem(int itemIndex, int lastClickedGetVideoCamIndex); + void sendGetPicItem(int itemIndex, int GetPicCamIndex); // 发送拉视频流按键 - void sendGetVideoItem(int itemIndex, int video_flag); + void sendGetVideoItem(int itemIndex, int GetVideoCamIndex); // 发送License处理按键 void sendLicenseItem(int itemIndex, const QString text); void sendUuidItem(int itemIndex, const QString text); diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp index d7eac15..b75ca96 100644 --- a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp +++ b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp @@ -3,6 +3,7 @@ #include "../Network/ClientHandler.h" DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel, + QLineEdit* VideoResolutionEdit, QTextEdit* licenseHwInfoEdit, QMap* devInfoLineEdits, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, @@ -13,6 +14,7 @@ DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLab leftLens_m_imageLabel(leftLens_imageLabel), rightLens_m_imageLabel(rightLens_imageLabel), videoLabel(videoLabel), + VideoResolutionEdit(VideoResolutionEdit), licenseHwInfoEdit(licenseHwInfoEdit), devInfoLineEdits(devInfoLineEdits), frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest), @@ -48,6 +50,7 @@ DataHandler::~DataHandler() void DataHandler::handleOpenFocusWindow(int itemIndex) { if (ffmpegDecoder) { + qDebug() << "------- handleOpenFocusWindow"; ffmpegDecoder->processVideo(itemIndex); // 调用 FFmpegDecoder 的处理函数 } } @@ -86,7 +89,7 @@ void DataHandler::showVideo(const QString& client, const QByteArray& valData) if (!start_run) { start_run = 1; - ffmpegDecoder->decodeFile(h264filePath, videoLabel); + ffmpegDecoder->decodeFile(h264filePath, videoLabel, VideoResolutionEdit); } //ffmpegDecoder->decodeFile(filePath_1, videoLabel); } diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h index fe0e1e0..369000e 100644 --- a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h +++ b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h @@ -34,6 +34,7 @@ class DataHandler : public QObject public: explicit DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLabel, QLabel* videoLabel, + QLineEdit* VideoResolutionEdit, QTextEdit* licenseHwInfoEdit, QMap* devInfoLineEdits, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, @@ -69,6 +70,7 @@ private: QLabel* leftLens_m_imageLabel; QLabel* rightLens_m_imageLabel; QLabel* videoLabel; + QLineEdit* VideoResolutionEdit; QTextEdit* licenseHwInfoEdit; QByteArray allRecvData; // 完整的一帧数据 int remain = 0; diff --git a/FactoryTestTool/SourceCode/Widget/FocusWindow.h b/FactoryTestTool/SourceCode/Widget/FocusWindow.h deleted file mode 100644 index cdf5a7c..0000000 --- a/FactoryTestTool/SourceCode/Widget/FocusWindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include - -class NewButtonDialog : public QDialog -{ - Q_OBJECT - -public: - NewButtonDialog(QWidget* parent = nullptr, const QSize& labelSize = QSize(480, 640)) : QDialog(parent) - { - QVBoxLayout* layout = new QVBoxLayout(this); - QLabel* label = new QLabel("This is a new window opened by clicking the new button.", this); - label->setFixedSize(labelSize); // 设置QLabel的固定大小 - layout->addWidget(label); - - QPushButton* closeButton = new QPushButton("Close", this); - layout->addWidget(closeButton); - connect(closeButton, &QPushButton::clicked, this, &NewButtonDialog::accept); - - setLayout(layout); - setWindowTitle("SL100 视频播放窗口"); - //resize(500, 700); // 设置对话框的大小 - } -}; diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp index a6f40f7..54848c7 100644 --- a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp +++ b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp @@ -1,10 +1,11 @@ // MainWidget.cpp #include "MainWidget.h" -void onThreadFinished(QThread* thread, ClientHandler* handler) +void onThreadFinished(QThread* thread, ClientHandler* handler, DataHandler* dataHandler) { qDebug() << "Thread finished. Deleting handler and thread."; handler->deleteLater(); + dataHandler->deleteLater(); thread->deleteLater(); } @@ -34,44 +35,11 @@ MainWidget::MainWidget(QWidget* parent) : licenseHwInfoEdit = new QTextEdit(this); UuidHwInfoEdit = new QTextEdit(this); - - - // 创建 mDNS 服务的 Server 和 Hostname 对象 - QMdnsEngine::Server myserver; - QMdnsEngine::Hostname hostname(&myserver); - - // 创建服务提供者(Provider) - QMdnsEngine::Provider provider(&myserver, &hostname); - - // 定义要广播的服务 - QMdnsEngine::Service service; - service.setName("Test Service"); - service.setType("_test._tcp"); // 服务类型,包括 _tcp 或 _udp - service.setPort(12345); // 服务使用的端口号 - - // 启动服务广播 - provider.update(service); - - qDebug() << "mDNS service started. Broadcasting service:" - << service.name() << service.type() << "on port" << service.port(); - - - setupUI(); // 打印线程池状态信息 setupTimerForThreadPoolInfo(); server = new QTcpServer(this); - /* - // 创建 DataHandler 对象并连接信号 - DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, licenseHwInfoEdit, &devInfoLineEdits, - frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, - frontBoardDevInfoJson, frontBoardLicenseJson, - backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson, - backBoardUuidJson, getPicJson, getVideoJson, this); - - connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow); - connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated); - */ + connect(server, &QTcpServer::newConnection, this, [this]() { // 检查是否有挂起的连接 while (server->hasPendingConnections()) { @@ -124,13 +92,21 @@ MainWidget::MainWidget(QWidget* parent) : backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson, backBoardUuidJson, getPicJson, getVideoJson, clientId, isBackBoardOrAllBoard, nullptr); - // 将 ClientHandler 移动到线程池中的线程 + // 将 ClientHandler 移到线程池中的线程 handler->moveToThread(thread); - // 当线程结束时删除 handler - connect(thread, &QThread::finished, this, [=]() { - onThreadFinished(thread, handler); - }); + // 创建 DataHandler 对象并连接信号 + DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, + VideoResolutionEdit, + licenseHwInfoEdit, &devInfoLineEdits, + frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, + frontBoardDevInfoJson, frontBoardLicenseJson, + backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson, + backBoardUuidJson, getPicJson, getVideoJson, nullptr); + qDebug() << "dataHandler->moveToThread(thread)"; + // 将 DataHandler 移到线程池中的线程 + dataHandler->moveToThread(thread); + // 将sendData信号连接到主线程中的槽上 connect(handler, &ClientHandler::sendData, this, [socket](const QByteArray& data, int isBoardType) { @@ -160,9 +136,6 @@ MainWidget::MainWidget(QWidget* parent) : this->onStartTimeout(clientId, timeout); }); - // 启动新的线程 - thread->start(); - clients.append(handler); clients_1[clientId] = handler; clientThreads[clientId] = thread; @@ -171,22 +144,23 @@ MainWidget::MainWidget(QWidget* parent) : connect(handler, &ClientHandler::allItemsProcessed, this, &MainWidget::onAllItemsProcessed); connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient); -#if 1 - // 创建 DataHandler 对象并连接信号 - DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, licenseHwInfoEdit, &devInfoLineEdits, - frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, - frontBoardDevInfoJson, frontBoardLicenseJson, - backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson, - backBoardUuidJson, getPicJson, getVideoJson, this); + dataHandlers[clientId] = dataHandler; - connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow); - connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData); - connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated); -#else - connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData); -#endif + connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData); + connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated); + // 当线程结束时删除 handler + connect(thread, &QThread::finished, this, [=]() { + onThreadFinished(thread, handler, dataHandler); + }); + // 启动新的线程 + thread->start(); + connect(handler, &ClientHandler::startReadTimer, this, &MainWidget::startClientReadTimer); connect(handler, &ClientHandler::stopReadTimer, this, &MainWidget::stopClientReadTimer); + //handler->getClientId() == handler->preVideoClientId + qDebug() << "---- handler->getClientId():" << handler->getClientId(); + qDebug() << "---- handler->preVideoClientId:" << handler->preVideoClientId; + connect(this, &MainWidget::openFocusWindowRequested, dataHandler, &DataHandler::handleOpenFocusWindow); // 创建和管理定时器 QTimer* readTimer = new QTimer(this); @@ -924,13 +898,20 @@ void MainWidget::onLicenseButtonClicked() QString dataStr = ""; if (jsonObject["lable"].toString() == "get_license") { QString hwInfoText = licenseHwInfoEdit->toPlainText(); + if (hwInfoText.count("0x") != PIX_HARDWARE_INFO_BYTES) { + isRequestSuccessful = 0; + //licenseHwInfoEdit->setPlainText("您使用了License去获取License,这是不允许的!!!"); + LicenseConfirmWindow dialog("您使用了License去获取License,这是不允许的!!!"); + dialog.exec(); + return; + } dataStr = hwInfoText.remove(","); // 去掉所有的逗号 QString sendToHttpServerDataStr = dataStr.replace("0x", "").replace(" ", ""); // 去掉0x和空格 #if 1 qDebug() << "sendToHttpServerDataStr:" << sendToHttpServerDataStr; FactoryToolSendGetLicenseToHttpServer(sendToHttpServerDataStr); while (isRequestSuccessful == 0) { - QCoreApplication::processEvents(); // 防止阻塞UI线程 + QCoreApplication::processEvents(); // 防止阻塞线程 } qDebug() << "isRequestSuccessful:" << isRequestSuccessful; if (isRequestSuccessful == 2) { @@ -960,18 +941,18 @@ void MainWidget::onLicenseButtonClicked() qDebug() << "License Key set in licenseHwInfoEdit:" << licenseKey; return; #endif - QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8()); + QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8()); memcpy(hardware_info, dataByteArray.data(), qMin(dataByteArray.size(), PIX_HARDWARE_INFO_BYTES)); //unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { 0x46,0x0b,0x5d,0x11,0x58,0x17,0x4d,0x5e,0x55,0x5c,0x51,0x4a,0x5a,0x07,0x59,0x4c,0x5f,0x45,0x5b,0x5f,0x5a,0x45,0x1c,0x5a,0x45,0x43,0x44,0x47,0x51,0x5e,0x44,0x30 }; LicenseConfirmWindow dialog("你确定要获取此授权吗?\n请确认你的hw_info是否正确"); if (dialog.exec() == QDialog::Accepted) { #if !MANUAL_UPLOAD_LICENSE if (!(licenseGenerate(hardware_info, license_info))) { - qDebug() << "从U盘获取License失败" ; + qDebug() << "从U盘获取License失败"; isRequestSuccessful = 0; licenseHwInfoEdit->setPlainText("从U盘获取License失败,请检查U盘是否插入电脑!!!"); return; - } + } QString licenseInfoHex = QByteArray(reinterpret_cast(license_info), PIX_LICENCE_BYTES).toHex().toUpper(); #else //unsigned char license_info_1[PIX_LICENCE_BYTES] = { 0x07, 0xe8, 0xf3, 0x80, 0xa8, 0x07, 0x72, 0xa1, 0x17, 0xfe, 0xda, 0x67, 0xbd, 0x4a, 0x5a, 0xb5, 0xbb, 0x8b, 0x2d, 0xb2, 0xbf, 0x89, 0x74, 0xe5, 0xb0, 0x99, 0x70, 0x74, 0x3c, 0x6f, 0xf8, 0x82, 0x79, 0xab, 0x31, 0x9c, 0xdf, 0xe8, 0x9e, 0x75, 0x8f, 0x42, 0xb3, 0xcf, 0x00, 0x60, 0xa0, 0x38, 0xa4, 0xb8, 0xbe, 0xa6, 0x5d, 0x9f, 0x8b, 0x41, 0xf3, 0x0a, 0x69, 0xf6, 0x50, 0x94, 0x3f, 0xd0, 0xa5, 0xee, 0x88, 0x20, 0x93, 0x9a, 0x1c, 0xe9, 0x64, 0xd3, 0xaf, 0x9f, 0xc7, 0x66, 0x00, 0x7d, 0x7d, 0x68, 0xf1, 0xa4, 0xe1, 0x58, 0x00, 0x1d, 0x03, 0x0d, 0x40, 0x08, 0xa4, 0xcc, 0x0b, 0xd8, 0x19, 0x70, 0x9a, 0x83, 0x81, 0xbf, 0x27, 0x35, 0xb8, 0xec, 0x59, 0xa8, 0xd0, 0x03, 0xdb, 0xf6, 0xcf, 0x83, 0xaa, 0x0e, 0xfc, 0x95, 0x29, 0x77, 0xec, 0x89, 0xc5, 0x79, 0x10, 0x40, 0xd8, 0xbb }; @@ -995,7 +976,7 @@ void MainWidget::onLicenseButtonClicked() printf("\n"); licenseHwInfoEdit->setPlainText(licenseInfoStr); isRequestSuccessful = 0; - } + } } else { #if 0 @@ -1211,6 +1192,9 @@ void MainWidget::onSendGetPicClicked() button->setStyleSheet("background-color: green;"); if (lastClickedGetPicCamIndex != -1 && lastClickedGetPicCamIndex != itemIndex) { getPicButtons[lastClickedGetPicCamIndex]->setStyleSheet(""); + if (lastClickedGetPicDevIndex != -1) { + getPicButtons[lastClickedGetPicDevIndex]->setStyleSheet(""); + } } lastClickedGetPicCamIndex = itemIndex; } @@ -1254,26 +1238,27 @@ void MainWidget::onSendGetVideoClicked() QPushButton* button = qobject_cast(sender()); int itemIndex = button->property("getVideoIndex").toInt(); - if (itemIndex < 2) { + if (itemIndex < 4) { button->setStyleSheet("background-color: green;"); if (lastClickedGetVideoCamIndex != -1 && lastClickedGetVideoCamIndex != itemIndex) { getVideoButtons[lastClickedGetVideoCamIndex]->setStyleSheet(""); + if (lastClickedGetVideoDevIndex != -1) { + getVideoButtons[lastClickedGetVideoDevIndex - 2]->setStyleSheet(""); + } } lastClickedGetVideoCamIndex = itemIndex; } else { if (lastClickedGetVideoCamIndex == -1) { - QListWidgetItem* listItem = new QListWidgetItem(QString("Please select IR or RGB lens to get video!!!"), statusListWidget); + QListWidgetItem* listItem = new QListWidgetItem(QString("Please select lens to get video!!!"), statusListWidget); listItem->setBackground(Qt::red); } else { - if (itemIndex - 6 >= connectedClientsCount) { - QListWidgetItem* listItem = new QListWidgetItem(QString("This device is not connected !!!").arg(itemIndex - 4), statusListWidget); + if (itemIndex - 8 >= connectedClientsCount) { + QListWidgetItem* listItem = new QListWidgetItem(QString("This device is not connected !!!").arg(itemIndex - 6), statusListWidget); listItem->setBackground(Qt::red); } else { - //qDebug() << "lastClickedGetVideoDevIndex:" << lastClickedGetVideoDevIndex; - //qDebug() << "itemIndex:" << itemIndex; button->setStyleSheet("background-color: green;"); if (lastClickedGetVideoDevIndex != -1 && lastClickedGetVideoDevIndex != itemIndex) { //qDebug() << "itemIndex:" << itemIndex; @@ -1283,11 +1268,11 @@ void MainWidget::onSendGetVideoClicked() //QMutexLocker locker(&mutex); for (ClientHandler* handler : clients) { if (handler->getClientId() == handler->controlClientId) { - handler->sendGetVideoItem(itemIndex - 5, lastClickedGetVideoCamIndex); + handler->sendGetVideoItem(itemIndex - 7, lastClickedGetVideoCamIndex); break; } } - getVideoButtons[2]->setEnabled(true); + getVideoButtons[FOCUS_WINDOWS_BUTTON]->setEnabled(true); } } } @@ -1303,9 +1288,15 @@ void MainWidget::onOpenFocusWindowClicked() QPushButton* button = qobject_cast(sender()); if (button) { int itemIndex = button->property("getVideoIndex").toInt(); - //qDebug() << "New Button clicked with itemIndex:" << itemIndex; - if (itemIndex == 2) { - emit openFocusWindowRequested(itemIndex); // 发送信号 + qDebug() << "New Button clicked with itemIndex:" << itemIndex; + if (itemIndex == FOCUS_WINDOWS_BUTTON) { + for (ClientHandler* handler : clients) { + if (handler->getClientId() == handler->preVideoClientId) { + emit openFocusWindowRequested(itemIndex); // 发送信号 + } + + } + } } } diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.h b/FactoryTestTool/SourceCode/Widget/MainWidget.h index 6329a95..cf1f4c9 100644 --- a/FactoryTestTool/SourceCode/Widget/MainWidget.h +++ b/FactoryTestTool/SourceCode/Widget/MainWidget.h @@ -51,7 +51,6 @@ #include "../Network/mdns/servicemodel.h" #include "../Network/ClientHandler.h" #include "../Network/httpClient.h" -#include "FocusWindow.h" #include "../Network/mdns/qmdnsengine/include/server.h" @@ -63,8 +62,8 @@ #define TEST_UDP_BROADCAST 0 // 用于测试 UDP 组播实现 mdns 功能 非标准 mdns #define MANUAL_UPLOAD_LICENSE 0 // 打开手动上传 License的功能 -#define START_MDNS 1 - +#define START_MDNS 1 +#define FOCUS_WINDOWS_BUTTON 4 // 大窗口播放视频的按键编号 #define TCP_CONNECT_PORT 12412 // TCP监听的端口 class MainWidget : public QWidget @@ -209,6 +208,8 @@ private: QPushButton* selectFileButton; // Save Log 按键 QPushButton* clearLogButton; // clear Log 按键 QLineEdit* filePathLineEdit; // 文件路径显示 + QLineEdit* VideoResolutionEdit; // 视频分辨率显示 + //QLineEdit* frameRateEdit; // 视频帧率显示 QLabel* leftLens_imageLabel; // 左边镜头图像显示 QLabel* rightLens_imageLabel; // 右边镜头图像显示 QLabel* videoLabel; // 视频显示 diff --git a/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp b/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp index 87f72a5..6c99367 100644 --- a/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp +++ b/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp @@ -186,7 +186,6 @@ QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig, return functionConfigTab; } - QWidget* MainWidget::createImageDisplayTab() { QWidget* imageDisplayTab = new QWidget(this); @@ -245,13 +244,16 @@ QWidget* MainWidget::createVideoDisplayTab() QWidget* videoDisplayTab = new QWidget(this); QVBoxLayout* videoDisplayLayout = new QVBoxLayout(videoDisplayTab); QVBoxLayout* videoButtonsColumnLayout = new QVBoxLayout; + for (int i = 0; i < 6; ++i) { QHBoxLayout* videoButtonsRowLayout = new QHBoxLayout; + for (int j = 0; j < 2; ++j) { QPushButton* button; + if (i == 0 && j == 0) { - button = new QPushButton(QString("左边镜头"), this); - button->setFixedSize(73, 50); + button = new QPushButton(QString("猫眼镜头(IR)"), this); + button->setFixedSize(110, 50); videoButtonsRowLayout->addWidget(button); button->setProperty("getVideoIndex", i * 2 + j); connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked); @@ -259,8 +261,8 @@ QWidget* MainWidget::createVideoDisplayTab() continue; } else if (i == 0 && j == 1) { - button = new QPushButton(QString("右边镜头"), this); - button->setFixedSize(73, 50); + button = new QPushButton(QString("猫眼镜头(RGB)"), this); + button->setFixedSize(110, 50); videoButtonsRowLayout->addWidget(button); button->setProperty("getVideoIndex", i * 2 + j); connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked); @@ -268,27 +270,47 @@ QWidget* MainWidget::createVideoDisplayTab() continue; } - // 调价调焦窗口按键 if (i == 1 && j == 0) { + button = new QPushButton(QString("左边镜头"), this); + button->setFixedSize(110, 50); + videoButtonsRowLayout->addWidget(button); + button->setProperty("getVideoIndex", i * 2 + j); + connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked); + getVideoButtons.append(button); + continue; + } + else if (i == 1 && j == 1) { + button = new QPushButton(QString("右边镜头"), this); + button->setFixedSize(110, 50); + videoButtonsRowLayout->addWidget(button); + button->setProperty("getVideoIndex", i * 2 + j); + connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked); + getVideoButtons.append(button); + continue; + } + + if (i == 2 && j == 0) { button = new QPushButton(QString("大窗口播放视频"), this); - button->setFixedSize(150, 50); + button->setFixedSize(224, 50); button->setEnabled(false); videoButtonsRowLayout->addWidget(button); button->setProperty("getVideoIndex", i * 2 + j); connect(button, &QPushButton::clicked, this, &MainWidget::onOpenFocusWindowClicked); getVideoButtons.append(button); break; // 跳出内层循环,只添加一个按键 - } - if (i >= 2 && i <= 5) { - if(j == 0) - button = new QPushButton(QString("Device %1\n打开视频").arg(i - 1), this); - else if(j == 1) - button = new QPushButton(QString("Device %1\n关闭视频").arg(i - 1), this); + } + + if (i >= 3 && i <= 5) { + if (j == 0) + button = new QPushButton(QString("Device %1\n打开视频").arg(i - 2), this); + else if (j == 1) + button = new QPushButton(QString("Device %1\n关闭视频").arg(i - 2), this); } else { - button = new QPushButton(QString("Device %1").arg(i * 2 + (j * 1 - 1) - 3), this); - } - button->setFixedSize(73, 50); + continue; + } + + button->setFixedSize(110, 50); videoButtonsRowLayout->addWidget(button); button->setProperty("getVideoIndex", i * 2 + j + 1); connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked); @@ -298,10 +320,23 @@ QWidget* MainWidget::createVideoDisplayTab() } QHBoxLayout* videoAndButtonsLayout = new QHBoxLayout; + QFormLayout* formLayout = new QFormLayout; + QLabel* VideoResolution = new QLabel("分辨率:"); + VideoResolutionEdit = new QLineEdit; + VideoResolutionEdit->setFixedWidth(120); + formLayout->addRow(VideoResolution, VideoResolutionEdit); + /*QLabel* frameRate = new QLabel("帧率:"); + frameRateEdit = new QLineEdit; + frameRateEdit->setFixedWidth(120); + formLayout->addRow(frameRate, frameRateEdit);*/ videoLabel = new QLabel(this); videoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - videoAndButtonsLayout->addLayout(videoButtonsColumnLayout, 1); - videoAndButtonsLayout->addWidget(videoLabel, 6); + videoAndButtonsLayout->addLayout(videoButtonsColumnLayout); + videoAndButtonsLayout->addLayout(formLayout); + videoAndButtonsLayout->addWidget(videoLabel); + videoAndButtonsLayout->setStretch(0, 1); + videoAndButtonsLayout->setStretch(1, 1); + videoAndButtonsLayout->setStretch(2, 1); videoDisplayLayout->addLayout(videoAndButtonsLayout); return videoDisplayTab; diff --git a/FactoryTestTool/SourceCode/main.cpp b/FactoryTestTool/SourceCode/main.cpp index 67efc08..cd1dae6 100644 --- a/FactoryTestTool/SourceCode/main.cpp +++ b/FactoryTestTool/SourceCode/main.cpp @@ -11,7 +11,6 @@ //将“子系统”设置为“Windows(/ SUBSYSTEM)”而不是“控制台(/ SUBSYSTEM)”。 //这种方法不需要任何额外的代码,且最为简洁。如果你已经在代码中使用了WinMain而不是main函数,这个设置就是默认的。 // -//通过这些方法,你应该可以彻底隐藏或者关闭控制台窗口。 // 关闭控制台窗口的函数 void closeConsole() { diff --git a/FactoryTestTool/TestLog/20240828_185905.txt b/FactoryTestTool/TestLog/20240828_185905.txt deleted file mode 100644 index b6fe3a1..0000000 --- a/FactoryTestTool/TestLog/20240828_185905.txt +++ /dev/null @@ -1,12 +0,0 @@ -device ID: 1 - Item 1: Ƕע ---> NG -device ID: 1 - Item 2: Ƕע ---> NG -device ID: 1 - Item 3: ƾע ---> NG -device ID: 1 - Item 4: ʶ ---> NG -device ID: 1 - Item 5: ƾʶ ---> NG -device ID: 1 - Item 6: ɾû ---> NG -device ID: 1 - Item 7: ɾû ---> NG -device ID: 1 - Item 8: ȡû ---> NG -device ID: 1 - Item 9: ȡû ---> NG -device ID: 1 - Item 10: ע ---> NG -device ID: 1 - Item 11: ͼƬע ---> NG -device ID:-1 ---> All 25 items test completed !!! diff --git a/FactoryTestTool/TestLog/20240828_190217.txt b/FactoryTestTool/TestLog/20240828_190217.txt deleted file mode 100644 index cc4c5dc..0000000 --- a/FactoryTestTool/TestLog/20240828_190217.txt +++ /dev/null @@ -1,24 +0,0 @@ -device ID: 1 - Item 1: Ƕע ---> NG -device ID: 1 - Item 2: Ƕע ---> NG -device ID: 1 - Item 3: ƾע ---> NG -device ID: 1 - Item 4: ʶ ---> NG -device ID: 1 - Item 5: ƾʶ ---> NG -device ID: 1 - Item 6: ɾû ---> NG -device ID: 1 - Item 7: ɾû ---> NG -device ID: 1 - Item 8: ȡû ---> NG -device ID: 1 - Item 9: ȡû ---> NG -device ID: 1 - Item 10: ע ---> NG -device ID: 1 - Item 11: ͼƬע ---> NG -device ID:-1 ---> All 25 items test completed !!! -device ID: 1 - Item 1: Ƕע ---> NG -device ID: 1 - Item 2: Ƕע ---> NG -device ID: 1 - Item 3: ƾע ---> NG -device ID: 1 - Item 4: ʶ ---> NG -device ID: 1 - Item 5: ƾʶ ---> NG -device ID: 1 - Item 6: ɾû ---> NG -device ID: 1 - Item 7: ɾû ---> NG -device ID: 1 - Item 8: ȡû ---> NG -device ID: 1 - Item 9: ȡû ---> NG -device ID: 1 - Item 10: ע ---> NG -device ID: 1 - Item 11: ͼƬע ---> NG -device ID:-1 ---> All 25 items test completed !!! diff --git a/FactoryTestTool/TestLog/20240829_191522.txt b/FactoryTestTool/TestLog/20240829_191522.txt deleted file mode 100644 index ad7ea84..0000000 --- a/FactoryTestTool/TestLog/20240829_191522.txt +++ /dev/null @@ -1,6 +0,0 @@ -device ID: 1 - Item 0: ---> NG -device ID: 1 - Item 0: ---> NG -device ID: 1 - Item 0: ---> NG -device ID: 1 - Item 0: ---> NG -device ID: 1 - Item 0: ---> NG -device ID:-1 ---> All 5 items test completed !!! diff --git a/FactoryTestTool/auth_error_log_v1_0.txt b/FactoryTestTool/auth_error_log_v1_0.txt deleted file mode 100644 index e69de29..0000000 diff --git a/FactoryTestTool/icon.rc b/FactoryTestTool/icon.rc new file mode 100644 index 0000000..dab53c3 Binary files /dev/null and b/FactoryTestTool/icon.rc differ