From 0daf385ccfc58e1817f7db09b159f0c62466180d Mon Sep 17 00:00:00 2001 From: mhvhm <1308784381@qq.com> Date: Tue, 27 Aug 2024 22:19:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8C=87=E4=BB=A4=E8=A7=A3?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/c_cpp_properties.json | 18 +++++++ .vscode/launch.json | 24 +++++++++ .vscode/settings.json | 59 +++++++++++++++++++++ ComParseTool/mainwindow.cpp | 99 +++++++++++++++++++++++++++++++++-- 4 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c11e7b2 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "D:/_ENV/mingw/mingw64_13.2.0/bin/gcc.exe", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..2fba69f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "e:/Project/QT_Projects/ComParseTool/ComParseTool", + "program": "e:/Project/QT_Projects/ComParseTool/ComParseTool/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/ComParseTool/mainwindow.cpp b/ComParseTool/mainwindow.cpp index 52a2d26..142d06c 100644 --- a/ComParseTool/mainwindow.cpp +++ b/ComParseTool/mainwindow.cpp @@ -36,12 +36,12 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen) { QString DesktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); // 获取桌面路径 QString filePath = QFileDialog::getOpenFileName(this, "选择文件", DesktopLocation, "文本文件(*.txt)"); - if (filePath.isEmpty() != true) + if (filePath.isEmpty() != true) // 判断路径是否有效 { ui->textEdit->clear(); if (isOriFileOpen) { - if (pQfile_ori->isOpen()) + if (pQfile_ori->fileName() != filePath) { pQfile_ori->close(); } @@ -50,12 +50,15 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen) if (pQfile_ori->open(QIODevice::ReadWrite | QIODevice::Text)) // 打开成功 { qDebug() << "opened file [" << filePath << "]"; - + } + else + { + qDebug() << "open file ERROR"; } } else { - if (pQfile_key->isOpen()) + if (pQfile_key->fileName() != filePath) { pQfile_key->close(); } @@ -69,6 +72,10 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen) QByteArray byteArr = QByteArray::fromHex(str.toLatin1()); memcpy(&key, byteArr.data(), 8); } + else + { + qDebug() << "open file ERROR"; + } } } } @@ -79,12 +86,14 @@ QString MainWindow::GetEventCode(uint8_t eventidx) QFile file(":/event_code.js"); if (!file.open(QIODevice::ReadOnly)) { + qDebug() << "open file ERROR"; return "ERROR1"; } QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err); if (err.error != QJsonParseError::NoError) { + qDebug() << "read Json ERROR"; return "ERROR2"; } QJsonArray ja = doc.array(); // 转化为json数组 @@ -106,12 +115,14 @@ QString MainWindow::GetLampType(uint8_t lampidx) QFile file(":/lamp_type.js"); if (!file.open(QIODevice::ReadOnly)) { + qDebug() << "open file ERROR"; return "ERROR1"; } QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err); if (err.error != QJsonParseError::NoError) { + qDebug() << "read Json ERROR"; return "ERROR2"; } QJsonArray ja = doc.array(); // 转化为json数组 @@ -275,6 +286,35 @@ QString MainWindow::AppendParse(DATA_TYPEDEF data) case 0x12: { ret += "单点灯"; + ret += "-" + QString::number(data.buf[6] | data.buf[5] << 8 | data.buf[4] << 16 | data.buf[3] << 24, 10); + ret += "-"; + if (data.buf[7] & 0x08) + { + ret += "m点亮," + } + else + { + ret += "m熄灭" + } + + if (data.buf[7] & 0x02) + { + ret += "r点亮," + } + else + { + ret += "r熄灭" + } + + if (data.buf[7] & 0x01) + { + ret += "l点亮," + } + else + { + ret += "l熄灭" + } + }break; case 0x13: { @@ -287,10 +327,61 @@ QString MainWindow::AppendParse(DATA_TYPEDEF data) case 0x15: { ret += "灯具启动停止"; + if (data.buf[1] == 0x00) + { + ret += "-全部回路"; + } + else + { + ret += "-回路" + QString::number(data.buf[1], 10); + } + switch(data.buf[2]) + { + case 0x00: + ret += "-停止";break; + case 0x01: + ret += "-闪烁";break; + case 0x02: + ret += "-常量";break; + case 0x03: + ret += "-0号预案";break; + case 0x04: + ret += "-方向测试左亮";break; + case 0x05: + ret += "-方向测试右亮";break; + case 0x06: + ret += "-方向测试全亮";break; + } }break; case 0x16: { ret += "单点灯启动停止"; + ret += "-" + QString::number(data.buf[6] | data.buf[5] << 8 | data.buf[4] << 16 | data.buf[3] << 24, 10); + + if (data.buf[7] & 0x01) + { + ret += "-标志灯"; + } + else + { + ret += "-照明灯"; + } + if (data.buf[7] & 0x08) + { + ret += "-启动"; + } + else + { + ret += "-停止"; + } + if (data.buf[7] & 0x04) + { + ret += "-闪亮"; + } + else + { + ret += "-常亮"; + } }break; case 0x17: {