diff --git a/FactoryTestTool/SourceCode/Json/JsonFile/backBoardTest.json b/FactoryTestTool/SourceCode/Json/JsonFile/backBoardTest.json index 9de80fa..b5b62f6 100644 --- a/FactoryTestTool/SourceCode/Json/JsonFile/backBoardTest.json +++ b/FactoryTestTool/SourceCode/Json/JsonFile/backBoardTest.json @@ -88,14 +88,20 @@ { "cmd": "VIDEO_TEST", "val": 0, - "lable": "开启视频", - "timeout": 0 + "lable": "关闭视频", + "timeout": 2000 }, { "cmd": "VIDEO_TEST", "val": 1, - "lable": "关闭视频", - "timeout": 0 + "lable": "开启RGB视频", + "timeout": 2000 + }, + { + "cmd": "VIDEO_TEST", + "val": 2, + "lable": "开启IR视频", + "timeout": 2000 }, { "cmd": "WIFI_SIGNAL_TEST", diff --git a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp index 23cec82..1ab502f 100644 --- a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp +++ b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp @@ -232,7 +232,7 @@ void FFmpegDecoder::run() labelSize = currentVideoLabel->size(); } mutex.unlock(); - qWarning() << "-------currentVideoLabel"; + //qWarning() << "-------currentVideoLabel"; QImage img = avFrameToQImage(frame); QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); //currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage)); diff --git a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp index 17ed94a..57e6e95 100644 --- a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp +++ b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp @@ -176,14 +176,14 @@ void ClientHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, con if (jsonArray == backBoardTest) { QJsonObject tempItem = jsonArray[itemIndex].toObject(); if (tempItem["cmd"] == "VIDEO_TEST") { - if (tempItem["val"] == 0) { + if (tempItem["val"] == 1 || tempItem["val"] == 2) { isSingleSend = false; isClickedSend = false; isRecvVideoData = true; isStartVideo = true; startReadVideoDataTimer(isBackBoardOrAllBoard); } - else if (tempItem["val"] == 1) { + else if (tempItem["val"] == 0) { isRecvVideoData = false; isStartVideo = false; stopReadVideoDataTimer(isBackBoardOrAllBoard); diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp index 10cfb51..ccddc9b 100644 --- a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp +++ b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp @@ -145,7 +145,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv (static_cast(buffer->at(7)) << 8) | (static_cast(buffer->at(6))); //qDebug() << "---Received dataSize:" << dataSize; - qDebug() << "---Received buffer->size():" << buffer->size(); + //qDebug() << "---Received buffer->size():" << buffer->size(); //qDebug() << "---msg_id:" << QString::number(msg_id, 16).toUpper(); // 第11字节为返回 OK/NG bool success = (static_cast(buffer->at(10)) != 0x00); @@ -159,7 +159,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recv break; } } - qDebug() << "---Received totalSize:" << totalSize; + //qDebug() << "---Received totalSize:" << totalSize; if (buffer->size() >= totalSize) { // 调试查看收到的前19个字节 /*for (int i = 0; i < 19; i++) { @@ -233,7 +233,9 @@ std::map commandValueMap = { {"FACE_ANGLE_RANGE", FACE_ANGLE_RANGE}, {"GET_BACK_MAC", GET_BACK_MAC}, - {"WRITE_BACK_UID_SN", WRITE_BACK_UID_SN} + {"WRITE_BACK_UID_SN", WRITE_BACK_UID_SN}, + + {"VIDEO_TEST", VIDEO_TEST}, }; bool DataHandler::getCommandNameFromValue(int receivedValue) { @@ -559,10 +561,10 @@ void DataHandler::handleBackCmd(int msg_id, const QString& client, QByteArray ac } } QJsonObject jsonObject = jsonArray[itemJsonIndex].toObject(); - if (jsonObject["val"] == 0) { + if (jsonObject["val"] == 1 || jsonObject["val"] == 2) { showVideo(client, actual_data); } - else if (jsonObject["val"] == 1) { + else if (jsonObject["val"] == 0) { isStartVideo = false; emit statusUpdated(1, client, true, jsonArray, itemJsonIndex); qDebug() << "--- STOP_VIDEO"; diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp index adeb5bc..c5cb193 100644 --- a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp +++ b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp @@ -1756,6 +1756,34 @@ void MainWidget::saveStatusListToFile(const QString& filePath) file.close(); } +void MainWidget::saveDeviceInfoToFile(const QString& filePath, const QString& info) +{ + QString actualFilePath = filePath; + if (actualFilePath.isEmpty()) { + QString defaultDirPath = QDir::currentPath() + "/TestLog"; + QDir dir(defaultDirPath); + if (!dir.exists()) { + if (!dir.mkpath(defaultDirPath)) { + qWarning() << "Failed to create directory:" << defaultDirPath; + return; + } + } + //QString currentTime = QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss"); + QString currentTime = QDateTime::currentDateTime().toString("yyyyMMdd"); + actualFilePath = defaultDirPath + "/device_info_" + currentTime + ".txt"; + } + + QFile file(actualFilePath); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qWarning() << "Failed to open file:" << actualFilePath; + return; + } + + QTextStream out(&file); + out << info; + file.close(); +} + void MainWidget::onCheckSerialRecvStatus() { } @@ -2087,6 +2115,7 @@ void MainWidget::onUuidButtonClicked() UuidHwInfoEdit->setPlainText(displayText); qDebug() << "HTTP Server backBoardUuid is:" << backBoardUuid; qDebug() << "HTTP Server backBoardSn is:" << backBoardSn; + saveDeviceInfoToFile(filePathLineEdit->text(), QString("MAC:") + cur_mac_addr + displayText); isRequestSuccessful = 0; return; } @@ -2412,7 +2441,7 @@ void MainWidget::onOpenFocusWindowClicked() QPushButton* button = qobject_cast(sender()); if (button) { int itemIndex = button->property("getVideoIndex").toInt(); - qDebug() << "New Button clicked with itemIndex:" << itemIndex; + qDebug() << "New Button clicked with itemIndex:" << itemIndex << " bord_id: " << isBackBoardOrAllBoard; if (itemIndex == FOCUS_WINDOWS_BUTTON) { if (isBackBoardOrAllBoard) { for (ClientHandler* handler : clients) { @@ -2652,14 +2681,18 @@ void MainWidget::onSendBackItemClicked() { qDebug() << "onSendBackItemClicked"; if (connectedClientsCount) { + qDebug() << "onSendBackItemClicked -- start 000"; if (isBackBoardOrAllBoard == 0) { onHandleInvalidOperate("当前连接的是前板,请勿操作后板或整机页面的按键!!!"); return; } + qDebug() << "onSendBackItemClicked -- start 111"; QPushButton* button = qobject_cast(sender()); int itemIndex = button->property("backBoardTest").toInt(); for (ClientHandler* handler : clients) { + qDebug() << "onSendBackItemClicked -- start 222"; if (isReplyOrTimeout && ((isBackBoardOrAllBoard) || (handler->getClientId() == handler->controlClientId))) { + qDebug() << "onSendBackItemClicked -- start 333"; handler->sendBackItem(itemIndex); isReplyOrTimeout = false; break; diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.h b/FactoryTestTool/SourceCode/Widget/MainWidget.h index 9382eb7..9f87163 100644 --- a/FactoryTestTool/SourceCode/Widget/MainWidget.h +++ b/FactoryTestTool/SourceCode/Widget/MainWidget.h @@ -212,6 +212,8 @@ private: QGroupBox* createBackConnectServerGroupBox(); // 保存日志到文件 void saveStatusListToFile(const QString& filePath); + // 保存服务器获取的信息 + void saveDeviceInfoToFile(const QString& filePath, const QString& info); // 用于更新按键文本的函数 void updateServerButtonText(); void updateGetVideoButtonState(int state, int connectedDevices, const QVector& buttons); diff --git a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/SerialPortHandler.cpp b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/SerialPortHandler.cpp index c2a7ea1..e1cf10a 100644 --- a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/SerialPortHandler.cpp +++ b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/SerialPortHandler.cpp @@ -150,9 +150,9 @@ void SerialPortHandler::onSendHeartBeatData(const QByteArray& data, bool heartBe serialPort->flush(); // 确保数据立即发送 } else { - qDebug() << "Serial port is not open!"; + //qDebug() << "Serial port is not open!"; } - qDebug() << "当前时间:" << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"); + //qDebug() << "当前时间:" << QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"); } void readBmpFile_1(const QString& filePath) { @@ -370,7 +370,7 @@ void SerialPortHandler::updateAvailablePorts() { QStringList currentPorts; foreach(const QSerialPortInfo & info, QSerialPortInfo::availablePorts()) { currentPorts.append(info.portName()); - qDebug() << "info.portName(): " << info.portName(); + //qDebug() << "info.portName(): " << info.portName(); } //qDebug() << "Available ports: " << currentPorts; @@ -550,16 +550,32 @@ void SerialPortHandler::sendJsonItem(const QJsonArray& jsonArray, int itemIndex, QJsonObject tempItem = jsonArray[itemIndex].toObject(); if (tempItem["cmd"] == "VIDEO_TEST") { if (tempItem["val"] == 0) { +#if 0 isSingleSend = false; isClickedSend = false; isRecvVideoData = true; isStartVideo = true; //startReadVideoDataTimer(isBackBoardOrAllBoard); +#endif + isRecvVideoData = false; + isStartVideo = false; } else if (tempItem["val"] == 1) { +#if 0 isRecvVideoData = false; isStartVideo = false; //stopReadVideoDataTimer(isBackBoardOrAllBoard); +#endif + isSingleSend = false; + isClickedSend = false; + isRecvVideoData = true; + isStartVideo = true; + } + else if (tempItem["val"] == 2) { + isSingleSend = false; + isClickedSend = false; + isRecvVideoData = true; + isStartVideo = true; } } } diff --git a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.cpp b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.cpp index 311b7f5..623d0a5 100644 --- a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.cpp +++ b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.cpp @@ -1,3 +1,4 @@ +#include "crc32.h" #include static const unsigned int crc_table[256] = { diff --git a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.h b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.h index 60e264b..42b0017 100644 --- a/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.h +++ b/FactoryTestTool/SourceCode/Widget/SerialPortHandler/crc32.h @@ -1,6 +1,8 @@ -#ifndef _crc32_h_ +#ifndef _crc32_h_ #define _crc32_h_ +#include + #pragma pack(push, 1) struct BMPHeader { char bfType[2]; @@ -21,17 +23,17 @@ struct BMPHeader { uint32_t biClrImportant; }; #pragma pack(pop) - -#ifdef __cplusplus -extern "C" { -#endif -unsigned int crc32(unsigned int crc, const void *buf, size_t len); -void crc32init(unsigned int *crc); -void crc32update(unsigned int *crc, const void * b, size_t len); -void crc32final(unsigned int *crc); -unsigned int crcsimple(const void *buf, size_t len); -#ifdef __cplusplus -} -#endif - -#endif + +#ifdef __cplusplus +extern "C" { +#endif +unsigned int crc32(unsigned int crc, const void *buf, size_t len); +void crc32init(unsigned int *crc); +void crc32update(unsigned int *crc, const void * b, size_t len); +void crc32final(unsigned int *crc); +unsigned int crcsimple(const void *buf, size_t len); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp b/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp index bbbdbf6..99373f8 100644 --- a/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp +++ b/FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp @@ -47,7 +47,7 @@ UI_config loadUIConfig(const QString& filePath) config.SL100_FACTORY_TOOL_W = settings.value("Window/width", "1340").toInt(); config.SL100_FACTORY_TOOL_H = settings.value("Window/height", "900").toInt(); config.LOG_LEVEL = settings.value("LogLevel/log_level", "2").toInt(); - config.TOOL_VERSION = settings.value("Labels/tool_version", "SL100 工厂产测工具 - V0.0.18"); + config.TOOL_VERSION = settings.value("Labels/tool_version", "SL100 工厂产测工具 - V0.0.19"); config.START_LISTENING = settings.value("Labels/start_listening", "开始监听\n(Start Listening...)"); config.ONE_CLICKED_TEST = settings.value("Labels/one_clicked_test", "一键功能测试"); config.SELECT_MDSN_IP = settings.value("Labels/select_mdns_ip", "Select MDns IP:"); @@ -94,7 +94,7 @@ UI_config loadUIConfig(const QString& filePath) config.THIS_DEV_DISCONNECT = settings.value("Labels/this_device_disconnect", "This device is not connected !!!"); config.PLEASE_SELECT_IMG_LENS = settings.value("Labels/please_select_img_lens", "Please select \"左边镜头\" or \"右边镜头\" to get image!!!"); config.PLEASE_SELECT_VID_LENS = settings.value("Labels/please_select_vid_lens", "Please select lens to get video!!!"); - config.MDNS_HOSE_NAME = settings.value("Labels/mdns_host_name", "SL100-FactoryTool-Mdns"); + config.MDNS_HOSE_NAME = settings.value("Labels/mdns_host_name", "sl100"); config.MDNS_SERVICE_NAME = settings.value("Labels/mdns_service_name", "_myservice._tcp.local."); quint16 port = settings.value("Labels/tcp_connect_port", "12412").toUInt(); config.TCP_CONNECT_PORT = (port > 0 && port <= 65535) ? port : 12412; // 防止异常值 diff --git a/FactoryTestTool/SourceCode/main.cpp b/FactoryTestTool/SourceCode/main.cpp index 4880575..c2b0a68 100644 --- a/FactoryTestTool/SourceCode/main.cpp +++ b/FactoryTestTool/SourceCode/main.cpp @@ -25,6 +25,8 @@ int main(int argc, char* argv[]) { //FreeConsole(); // 关闭控制台窗口 QApplication app(argc, argv); + qSetMessagePattern("%{time yyyy-MM-dd HH:mm:ss.zzz} %{message}"); + // **注册 QItemSelection 和 SelectionFlags 以支持 QueuedConnection** qRegisterMetaType("QItemSelection"); qRegisterMetaType("QItemSelectionModel::SelectionFlags"); diff --git a/FactoryTestTool/UI_config.ini b/FactoryTestTool/UI_config.ini index 2426cf2..f3da453 100644 --- a/FactoryTestTool/UI_config.ini +++ b/FactoryTestTool/UI_config.ini @@ -67,6 +67,6 @@ no_device_connected = No device is connected !!! this_device_disconnect = This device is not connected !!! please_select_img_lens = Please select \"左边镜头\" or \"右边镜头\" to get image!!! please_select_vid_lens = Please select lens to get video!!! -mdns_host_name = SL100-FactoryTool-Mdns +mdns_host_name = sl100 mdns_service_name = _myservice._tcp.local. tcp_connect_port = 12412 \ No newline at end of file