完善指令解析

This commit is contained in:
mhvhm 2024-08-27 22:19:05 +08:00
parent 80227d8e96
commit 0daf385ccf
4 changed files with 196 additions and 4 deletions

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -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
}

24
.vscode/launch.json vendored Normal file
View File

@ -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
}
]
}
]
}

59
.vscode/settings.json vendored Normal file
View File

@ -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
}

View File

@ -36,12 +36,12 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen)
{ {
QString DesktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); // 获取桌面路径 QString DesktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); // 获取桌面路径
QString filePath = QFileDialog::getOpenFileName(this, "选择文件", DesktopLocation, "文本文件(*.txt)"); QString filePath = QFileDialog::getOpenFileName(this, "选择文件", DesktopLocation, "文本文件(*.txt)");
if (filePath.isEmpty() != true) if (filePath.isEmpty() != true) // 判断路径是否有效
{ {
ui->textEdit->clear(); ui->textEdit->clear();
if (isOriFileOpen) if (isOriFileOpen)
{ {
if (pQfile_ori->isOpen()) if (pQfile_ori->fileName() != filePath)
{ {
pQfile_ori->close(); pQfile_ori->close();
} }
@ -50,12 +50,15 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen)
if (pQfile_ori->open(QIODevice::ReadWrite | QIODevice::Text)) // 打开成功 if (pQfile_ori->open(QIODevice::ReadWrite | QIODevice::Text)) // 打开成功
{ {
qDebug() << "opened file [" << filePath << "]"; qDebug() << "opened file [" << filePath << "]";
}
else
{
qDebug() << "open file ERROR";
} }
} }
else else
{ {
if (pQfile_key->isOpen()) if (pQfile_key->fileName() != filePath)
{ {
pQfile_key->close(); pQfile_key->close();
} }
@ -69,6 +72,10 @@ void MainWindow::OpenExplorerFile(bool isOriFileOpen)
QByteArray byteArr = QByteArray::fromHex(str.toLatin1()); QByteArray byteArr = QByteArray::fromHex(str.toLatin1());
memcpy(&key, byteArr.data(), 8); 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"); QFile file(":/event_code.js");
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
{ {
qDebug() << "open file ERROR";
return "ERROR1"; return "ERROR1";
} }
QJsonParseError err; QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err); QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err);
if (err.error != QJsonParseError::NoError) if (err.error != QJsonParseError::NoError)
{ {
qDebug() << "read Json ERROR";
return "ERROR2"; return "ERROR2";
} }
QJsonArray ja = doc.array(); // 转化为json数组 QJsonArray ja = doc.array(); // 转化为json数组
@ -106,12 +115,14 @@ QString MainWindow::GetLampType(uint8_t lampidx)
QFile file(":/lamp_type.js"); QFile file(":/lamp_type.js");
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
{ {
qDebug() << "open file ERROR";
return "ERROR1"; return "ERROR1";
} }
QJsonParseError err; QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err); QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err);
if (err.error != QJsonParseError::NoError) if (err.error != QJsonParseError::NoError)
{ {
qDebug() << "read Json ERROR";
return "ERROR2"; return "ERROR2";
} }
QJsonArray ja = doc.array(); // 转化为json数组 QJsonArray ja = doc.array(); // 转化为json数组
@ -275,6 +286,35 @@ QString MainWindow::AppendParse(DATA_TYPEDEF data)
case 0x12: case 0x12:
{ {
ret += "单点灯"; 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; }break;
case 0x13: case 0x13:
{ {
@ -287,10 +327,61 @@ QString MainWindow::AppendParse(DATA_TYPEDEF data)
case 0x15: case 0x15:
{ {
ret += "灯具启动停止"; 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; }break;
case 0x16: case 0x16:
{ {
ret += "单点灯启动停止"; 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; }break;
case 0x17: case 0x17:
{ {