diff --git a/FactoryTestTool/FactoryTestTool.vcxproj b/FactoryTestTool/FactoryTestTool.vcxproj
index 87817c7..50b6339 100644
--- a/FactoryTestTool/FactoryTestTool.vcxproj
+++ b/FactoryTestTool/FactoryTestTool.vcxproj
@@ -27,6 +27,7 @@
+
@@ -61,6 +62,7 @@
+
@@ -80,7 +82,11 @@
+
+
+
+
@@ -95,6 +101,7 @@
10.0.20348.0
$(MSBuildProjectDirectory)\QtMsBuild
FactoryTestTool
+ 7.0
@@ -174,40 +181,42 @@
/utf-8
+ D:\QT\qt\5.15.2\msvc2019_64\include\QtNetwork;D:\QT\qt\5.15.2\msvc2019_64\include\QtGui;D:\QT\qt\5.15.2\msvc2019_64\include\QtCore;D:\QT\qt\5.15.2\msvc2019_64\include\QtWidgets;D:\QT\qt\5.15.2\msvc2019_64\include
- libYTDoorLockAuthTool.lib;%(AdditionalDependencies)
- .\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)
+ libYTDoorLockAuthTool.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;%(AdditionalDependencies)
+ D:\QT\qt\5.15.2\msvc2019_64\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)
/utf-8
DEBUG;%(PreprocessorDefinitions)
+ D:\QT\qt\5.15.2\msvc2019_64\include\QtNetwork;D:\QT\qt\5.15.2\msvc2019_64\include\QtGui;D:\QT\qt\5.15.2\msvc2019_64\include\QtCore;D:\QT\qt\5.15.2\msvc2019_64\include\QtWidgets;D:\QT\qt\5.15.2\msvc2019_64\include
- libYTDoorLockAuthTool.lib;%(AdditionalDependencies)
- .\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)
+ libYTDoorLockAuthTool.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;%(AdditionalDependencies)
+ D:\QT\qt\5.15.2\msvc2019_64\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)
/utf-8
DEBUG;%(PreprocessorDefinitions)
- E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)
+ D:\QT\qt\5.15.2\msvc2019_64\include;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)
- E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)
+ D:\QT\qt\5.15.2\msvc2019_64\lib;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)
libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)
/utf-8
- E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)
+ D:\QT\qt\5.15.2\msvc2019_64\include;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)
- E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)
+ D:\QT\qt\5.15.2\msvc2019_64\lib;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)
libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)
diff --git a/FactoryTestTool/FactoryTestTool.vcxproj.filters b/FactoryTestTool/FactoryTestTool.vcxproj.filters
index cd73898..11652d2 100644
--- a/FactoryTestTool/FactoryTestTool.vcxproj.filters
+++ b/FactoryTestTool/FactoryTestTool.vcxproj.filters
@@ -29,6 +29,9 @@
Media\VideoDecoder
+
+ LicenseGenerate
+
@@ -52,6 +55,9 @@
Network
+
+ Network
+
@@ -94,6 +100,9 @@
Json\JsonFile
+
+ Json\JsonFile
+
@@ -105,9 +114,6 @@
{8f2d3c5e-4c9e-45a5-b3fa-6e3e5d18311c}
-
- {06e02411-f304-43f0-9f87-cfad902da874}
-
{418fba92-36fe-46e4-88ae-ec0b9c7cfea8}
@@ -126,6 +132,9 @@
{fee8fd4c-8ed1-42b8-98d1-6d5cb4b01abf}
+
+ {463f4c83-c88f-4815-b160-19430dd30eda}
+
@@ -143,5 +152,14 @@
Media\VideoDecoder
+
+ RecvDataHandler
+
+
+ LicenseGenerate
+
+
+ LicenseGenerate
+
\ No newline at end of file
diff --git a/FactoryTestTool/SourceCode/Json/JsonFile/backDevInfo.json b/FactoryTestTool/SourceCode/Json/JsonFile/backDevInfo.json
index a682411..cc23980 100644
--- a/FactoryTestTool/SourceCode/Json/JsonFile/backDevInfo.json
+++ b/FactoryTestTool/SourceCode/Json/JsonFile/backDevInfo.json
@@ -2,25 +2,31 @@
{
"cmd": "GET_BACK_SW_VERSION",
"val": 0,
- "lable": "后板软件版本",
+ "lable": "鍚庢澘V851鐗堟湰:",
+ "timeout": 2000
+ },
+ {
+ "cmd": "GET_BACK_SW_VERSION",
+ "val": 0,
+ "lable": "鍚庢澘806鐗堟湰:",
"timeout": 2000
},
{
"cmd": "GET_BACK_HW_VERSION",
"val": 0,
- "lable": "后板硬件版本",
+ "lable": "鍚庢澘纭欢鐗堟湰:",
"timeout": 2000
},
{
"cmd": "GET_BACK_SN",
"val": 0,
- "lable": "后板SN号",
+ "lable": "SN鍙:",
"timeout": 2000
},
{
"cmd": "GET_BACK_UID",
"val": 0,
- "lable": "后板UID",
+ "lable": "UID:",
"timeout": 2000
}
]
diff --git a/FactoryTestTool/SourceCode/Json/JsonFile/frontBoardLicense.json b/FactoryTestTool/SourceCode/Json/JsonFile/frontBoardLicense.json
new file mode 100644
index 0000000..00cdeae
--- /dev/null
+++ b/FactoryTestTool/SourceCode/Json/JsonFile/frontBoardLicense.json
@@ -0,0 +1,20 @@
+[
+ {
+ "cmd": "GET_FRONT_HW_INFO",
+ "val": 0,
+ "lable": "get_hw_info",
+ "timeout": 0
+ },
+ {
+ "cmd": "GET_FRONT_LICENSE",
+ "val": 0,
+ "lable": "get_license",
+ "timeout": 0
+ },
+ {
+ "cmd": "WRITE_FRONT_LICENSE",
+ "val": 0,
+ "lable": "write_license",
+ "timeout": 0
+ }
+]
\ No newline at end of file
diff --git a/FactoryTestTool/SourceCode/Json/JsonFile/frontDevInfo.json b/FactoryTestTool/SourceCode/Json/JsonFile/frontDevInfo.json
index 88de217..3d11434 100644
--- a/FactoryTestTool/SourceCode/Json/JsonFile/frontDevInfo.json
+++ b/FactoryTestTool/SourceCode/Json/JsonFile/frontDevInfo.json
@@ -2,25 +2,31 @@
{
"cmd": "GET_FRONT_V851_VERSION",
"val": 0,
- "lable": "鍓嶆澘V851鐗堟湰",
+ "lable": "鍓嶆澘V851鐗堟湰:",
"timeout": 2000
},
{
"cmd": "GET_FRONT_MCU_VERSION",
"val": 0,
- "lable": "鍓嶆澘MCU鐗堟湰",
+ "lable": "鍓嶆澘MCU鐗堟湰:",
"timeout": 2000
},
{
"cmd": "GET_FRONT_HW_VERSION",
"val": 0,
- "lable": "鍓嶆澘纭欢鐗堟湰",
+ "lable": "鍓嶆澘纭欢鐗堟湰:",
"timeout": 2000
},
{
"cmd": "GET_FRONT_ALGO_VERSION",
"val": 0,
- "lable": "绠楁硶鐗堟湰",
+ "lable": "绠楁硶鐗堟湰:",
+ "timeout": 2000
+ },
+ {
+ "cmd": "GET_FRONT_SN",
+ "val": 0,
+ "lable": "SN鍙:",
"timeout": 2000
}
]
diff --git a/FactoryTestTool/SourceCode/Json/readJsonFile.cpp b/FactoryTestTool/SourceCode/Json/readJsonFile.cpp
index f4155c1..651b906 100644
--- a/FactoryTestTool/SourceCode/Json/readJsonFile.cpp
+++ b/FactoryTestTool/SourceCode/Json/readJsonFile.cpp
@@ -1,305 +1,64 @@
#include "readJsonFile.h"
-QJsonArray readJson_testConfig()
+QJsonArray readJsonArrayFromFile(const QString& filePath)
{
- /*QDir dir(JsonDir);
- QString filePath = dir.absoluteFilePath("testConfig.json");*/
- QJsonArray testJsonConfig;
- //QFile file(filePath);
- QFile file("./SourceCode/Json/JsonFile/testConfig.json");
- //QFile file("funcConfig.json");
+ QJsonArray jsonArray;
+ QFile file(filePath);
if (file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open testConfig.json";
- QByteArray data = file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "File content:" << data;
+ qDebug() << "Successfully opened" << filePath;
+ QByteArray data = file.readAll();
QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- testJsonConfig = doc.array();
- qDebug() << "JSON array size:" << testJsonConfig.size();
- }
- else {
- qDebug() << "JSON document is not an array!";
- }
+ if (!doc.isNull() && doc.isArray()) {
+ jsonArray = doc.array();
+ qDebug() << filePath << "JSON array size:" << jsonArray.size();
}
else {
- qDebug() << "Failed to parse JSON document!";
+ qDebug() << "Failed to parse JSON document from" << filePath;
}
file.close();
}
else {
- qDebug() << "Failed to open testConfig.json";
+ qDebug() << "Failed to open" << filePath;
}
- return testJsonConfig;
+ return jsonArray;
}
-QJsonArray readJson_funcConfig()
-{
- QJsonArray funcJsonConfig;
- QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
- if (funcConfig_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open funcConfig.json";
- QByteArray data = funcConfig_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "funcConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- funcJsonConfig = doc.array();
- qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
- }
- else {
- qDebug() << "funcJsonConfig JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse funcJsonConfig JSON document!";
- }
- funcConfig_file.close();
- }
- else {
- qDebug() << "Failed to open funcConfig.json";
- }
- return funcJsonConfig;
+QJsonArray readJson_testConfig() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/testConfig.json");
}
-QJsonArray readJson_frontBoardOneClickTest()
-{
- QJsonArray frontBoardOneClickTest;
- QFile frontBoardOneClickTest_file("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
- if (frontBoardOneClickTest_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open frontBoardOneClickTest.json";
- QByteArray data = frontBoardOneClickTest_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "frontBoardOneClickTest_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- frontBoardOneClickTest = doc.array();
- qDebug() << "frontBoardOneClickTest JSON array size:" << frontBoardOneClickTest.size();
- }
- else {
- qDebug() << "frontBoardOneClickTest JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse frontBoardOneClickTest JSON document!";
- }
- frontBoardOneClickTest_file.close();
- }
- else {
- qDebug() << "Failed to open frontBoardOneClickTest.json";
- }
- return frontBoardOneClickTest;
+QJsonArray readJson_funcConfig() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/funcConfig.json");
}
-QJsonArray readJson_frontBoardTest()
-{
- QJsonArray frontBoardTest;
- QFile frontBoardTest_file("./SourceCode/Json/JsonFile/frontBoardTest.json");
- if (frontBoardTest_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open frontBoardTest.json";
- QByteArray data = frontBoardTest_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "frontBoardTest_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- frontBoardTest = doc.array();
- qDebug() << "frontBoardTest JSON array size:" << frontBoardTest.size();
- }
- else {
- qDebug() << "frontBoardTest JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse frontBoardTest JSON document!";
- }
- frontBoardTest_file.close();
- }
- else {
- qDebug() << "Failed to open frontBoardTest.json";
- }
- return frontBoardTest;
+QJsonArray readJson_frontBoardOneClickTest() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
}
-QJsonArray readJson_frontBoardFuncConfig()
-{
- QJsonArray frontBoardFuncConfig;
- QFile frontBoardFuncConfig_file("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
- if (frontBoardFuncConfig_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open frontBoardFuncConfig.json";
- QByteArray data = frontBoardFuncConfig_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "frontBoardFuncConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- frontBoardFuncConfig = doc.array();
- qDebug() << "frontBoardFuncConfig JSON array size:" << frontBoardFuncConfig.size();
- }
- else {
- qDebug() << "frontBoardFuncConfig JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse frontBoardFuncConfig JSON document!";
- }
- frontBoardFuncConfig_file.close();
- }
- else {
- qDebug() << "Failed to open frontBoardFuncConfig.json";
- }
- return frontBoardFuncConfig;
+QJsonArray readJson_frontBoardTest() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardTest.json");
}
-//QJsonArray readJson_funcConfig()
-//{
-// QJsonArray funcJsonConfig;
-// QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
-// if (funcConfig_file.open(QIODevice::ReadOnly)) {
-// qDebug() << "success to open funcConfig.json";
-// QByteArray data = funcConfig_file.readAll();
-// // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
-// //qDebug() << "funcConfig_file content:" << data;
-// QJsonDocument doc = QJsonDocument::fromJson(data);
-// if (!doc.isNull()) {
-// if (doc.isArray()) {
-// funcJsonConfig = doc.array();
-// qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
-// }
-// else {
-// qDebug() << "funcJsonConfig JSON document is not an array!";
-// }
-// }
-// else {
-// qDebug() << "Failed to parse funcJsonConfig JSON document!";
-// }
-// funcConfig_file.close();
-// }
-// else {
-// qDebug() << "Failed to open funcConfig.json";
-// }
-// return funcJsonConfig;
-//}
-
-QJsonArray readJson_frontDevInfo()
-{
- QJsonArray frontDevInfo;
- QFile frontDevInfo_file("./SourceCode/Json/JsonFile/frontDevInfo.json");
- if (frontDevInfo_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open frontDevInfo.json";
- QByteArray data = frontDevInfo_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "funcConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- frontDevInfo = doc.array();
- qDebug() << "frontDevInfo JSON array size:" << frontDevInfo.size();
- }
- else {
- qDebug() << "frontDevInfo JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse frontDevInfo JSON document!";
- }
- frontDevInfo_file.close();
- }
- else {
- qDebug() << "Failed to open frontDevInfo.json";
- }
- return frontDevInfo;
+QJsonArray readJson_frontBoardFuncConfig() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
}
-QJsonArray readJson_backDevInfo()
-{
- QJsonArray backDevInfo;
- QFile backDevInfo_file("./SourceCode/Json/JsonFile/backDevInfo.json");
- if (backDevInfo_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open backDevInfo.json";
- QByteArray data = backDevInfo_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "funcConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- backDevInfo = doc.array();
- qDebug() << "backDevInfo JSON array size:" << backDevInfo.size();
- }
- else {
- qDebug() << "backDevInfo JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse backDevInfo JSON document!";
- }
- backDevInfo_file.close();
- }
- else {
- qDebug() << "Failed to open backDevInfo.json";
- }
- return backDevInfo;
+QJsonArray readJson_frontDevInfo() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontDevInfo.json");
}
-QJsonArray readJson_getPic()
-{
- QJsonArray getPicJson;
- QFile getPic_file("./SourceCode/Json/JsonFile/getPic.json");
- if (getPic_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open getPic.json";
- QByteArray data = getPic_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "funcConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- getPicJson = doc.array();
- qDebug() << "getPic JSON array size:" << getPicJson.size();
- }
- else {
- qDebug() << "getPic JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse getPic JSON document!";
- }
- getPic_file.close();
- }
- else {
- qDebug() << "Failed to open getPic.json";
- }
- return getPicJson;
+QJsonArray readJson_frontLicense() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardLicense.json");
}
-QJsonArray readJson_getVideo()
-{
- QJsonArray getVideoJson;
- QFile getVideo_file("./SourceCode/Json/JsonFile/getVideo.json");
- if (getVideo_file.open(QIODevice::ReadOnly)) {
- qDebug() << "success to open getVideo.json";
- QByteArray data = getVideo_file.readAll();
- // 杈撳嚭鏂囦欢鍐呭锛屾鏌ユ槸鍚︽纭鍙
- //qDebug() << "funcConfig_file content:" << data;
- QJsonDocument doc = QJsonDocument::fromJson(data);
- if (!doc.isNull()) {
- if (doc.isArray()) {
- getVideoJson = doc.array();
- qDebug() << "getVideo JSON array size:" << getVideoJson.size();
- }
- else {
- qDebug() << "getVideo JSON document is not an array!";
- }
- }
- else {
- qDebug() << "Failed to parse getVideo JSON document!";
- }
- getVideo_file.close();
- }
- else {
- qDebug() << "Failed to open getVideo.json";
- }
- return getVideoJson;
+QJsonArray readJson_backDevInfo() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/backDevInfo.json");
+}
+
+QJsonArray readJson_getPic() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getPic.json");
+}
+
+QJsonArray readJson_getVideo() {
+ return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getVideo.json");
}
diff --git a/FactoryTestTool/SourceCode/Json/readJsonFile.h b/FactoryTestTool/SourceCode/Json/readJsonFile.h
index 28e895d..f240436 100644
--- a/FactoryTestTool/SourceCode/Json/readJsonFile.h
+++ b/FactoryTestTool/SourceCode/Json/readJsonFile.h
@@ -11,6 +11,7 @@ QJsonArray readJson_frontBoardOneClickTest();
QJsonArray readJson_frontBoardTest();
QJsonArray readJson_frontBoardFuncConfig();
QJsonArray readJson_frontDevInfo();
+QJsonArray readJson_frontLicense();
QJsonArray readJson_backDevInfo();
QJsonArray readJson_testConfig();
diff --git a/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.cpp b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.cpp
new file mode 100644
index 0000000..f9f8260
--- /dev/null
+++ b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.cpp
@@ -0,0 +1,68 @@
+// LicenseGenerate.cpp
+#include "LicenseGenerate.h"
+
+#define PIX_HARDWARE_INFO_BYTES 32
+#define PIX_LICENCE_BYTES 128
+
+typedef const char* (*pix_license_generate_version_func)();
+typedef int (*pix_license_generate_func)(const unsigned char*, int, unsigned char*, int);
+
+void licenseGenerate()
+{
+ unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { };
+ unsigned char license_info[PIX_LICENCE_BYTES] = { 0 };
+
+ // 鑾峰彇褰撳墠璺緞
+ wchar_t currentPath[MAX_PATH];
+ GetCurrentDirectoryW(MAX_PATH, currentPath);
+ std::wcout << L"Current Directory: " << currentPath << std::endl;
+
+ // 鎵撳嵃 DLL 鐨勫畬鏁磋矾寰
+ std::wstring dllPath = std::wstring(currentPath) + L"\\ThirdParty\\LicenseGenerate\\pix_license.dll";
+ std::wcout << L"DLL Path: " << dllPath << std::endl;
+
+ // 鍔犺浇 DLL 鏂囦欢
+ HINSTANCE hDLL = LoadLibraryW(dllPath.c_str());
+ if (hDLL == NULL) {
+ std::cerr << "Failed to load DLL. Error code: " << GetLastError() << std::endl;
+ FreeLibrary(hDLL);
+ return;
+ }
+ pix_license_generate_version_func pix_license_generate_version =
+ (pix_license_generate_version_func)GetProcAddress(hDLL, "pix_license_generate_version");
+ pix_license_generate_func pix_license_generate =
+ (pix_license_generate_func)GetProcAddress(hDLL, "pix_license_generate");
+ if (pix_license_generate_version == NULL || pix_license_generate == NULL) {
+ std::cerr << "Failed to find one or more functions." << std::endl;
+ FreeLibrary(hDLL);
+ return;
+ }
+ printf("pix_license_generate_version is %s\n",
+ pix_license_generate_version());
+
+ printf("Hardware info:");
+ for (int j = 0; j < PIX_HARDWARE_INFO_BYTES; ++j) {
+ hardware_info[j] = j;
+ printf("0x%02x, ", hardware_info[j]);
+ }
+ printf("\n");
+ // return 闄愬埗涓嶈皟鐢 pix_license_generate, 闃叉鍑忓皯license涓暟
+ return;
+ int ret = pix_license_generate(hardware_info, PIX_HARDWARE_INFO_BYTES,
+ license_info, PIX_LICENCE_BYTES);
+ if (ret != SDK_CODE_OK) {
+ printf("Fail to generate license with %d\n", ret);
+ }
+ else {
+ printf("License is\n");
+ for (int j = 0; j < PIX_LICENCE_BYTES; ++j) {
+ printf("0x%02x, ", license_info[j]);
+ }
+ printf("\n");
+ }
+
+ FreeLibrary(hDLL);
+
+ return;
+}
+
diff --git a/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.h b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.h
new file mode 100644
index 0000000..80efc77
--- /dev/null
+++ b/FactoryTestTool/SourceCode/LicenseGenerate/LicenseGenerate.h
@@ -0,0 +1,15 @@
+#ifndef LICENSEGENERATE_H
+#define LICENSEGENERATE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "p_code.h"
+
+void licenseGenerate();
+
+#endif
diff --git a/FactoryTestTool/SourceCode/LicenseGenerate/p_code.h b/FactoryTestTool/SourceCode/LicenseGenerate/p_code.h
new file mode 100644
index 0000000..260aad5
--- /dev/null
+++ b/FactoryTestTool/SourceCode/LicenseGenerate/p_code.h
@@ -0,0 +1,41 @@
+#ifndef FACEKITASM_P_CODE_H
+#define FACEKITASM_P_CODE_H
+
+#define SDK_CODE_OK 0
+#define SDK_CODE_INVALID_ARG -4
+#define SDK_CODE_MODEL_NOT_INIT -44
+#define SDK_CODE_REID_MODEL_NOT_INIT -550
+#define SDK_CODE_INNER_ERROR -444
+#define SDK_CODE_MODEL_NOT_FOUND -404
+#define SDK_CODE_LICENCE_NOT_FOUND -405
+#define SDK_CODE_INVALID_LICENCE -406
+#define SDK_CODE_BROKEN_MODEL_FILE -407
+#define SDK_CODE_MODEL_FILE_VERSION_MISMATCH -408
+#define SDK_CODE_INVALID_LICENCE_STATUS -501
+#define SDK_CODE_INVALID_HW_LICENCE_STATUS -505
+#define SDK_CODE_INVALID_STATUS -600
+#define SDK_CODE_DECODE_ERROR -1001
+#define SDK_CODE_DETECT_ERROR -1002
+#define SDK_CODE_SHIELDING -1010
+#define SDK_CODE_MATCH_ERROR -2010
+#define SDK_CODE_EXTRACT_POINT_ERROR -2011
+#define SDK_CODE_FILE_NOT_EXIST -3010
+
+#define SDK_CODE_SYS_TIME_ERROR -5001
+#define SDK_CODE_IMAGE_NOT_EXIST -5002
+#define SDK_CODE_IMAGE_DECODE_FAIL -5003
+#define SDK_CODE_FLOOD_SPECKLE_IMAGE_SIZE_ERROR -5004
+#define SDK_CODE_SPECKLE_IMAGE_TOO_LESS_POINT -5005
+#define SDK_CODE_CALI_TOO_LESS_POINT_MATCH -5006
+#define SDK_CODE_FAILED_TO_FIND_CHECKER -5007
+#define SDK_CODE_REF_IMAGE_LOSS_POINT -5008
+#define SDK_CODE_CALIBRATION_ERROR -5009
+#define SDK_CODE_GET_DEPTH_ERROR -5010
+
+#define SDK_CODE_NOT_IMPLEMENT -6868
+
+#define SDK_CODE_AUTH_ERROR -8888
+
+//#define TRIVAL_VERSION 1
+
+#endif //FACEKITASM_P_CODE_HPP
diff --git a/FactoryTestTool/SourceCode/LicenseGenerate/鍔犲瘑鐙楅┍鍔╛20220110.zip b/FactoryTestTool/SourceCode/LicenseGenerate/鍔犲瘑鐙楅┍鍔╛20220110.zip
new file mode 100644
index 0000000..ed136ea
Binary files /dev/null and b/FactoryTestTool/SourceCode/LicenseGenerate/鍔犲瘑鐙楅┍鍔╛20220110.zip differ
diff --git a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp
index 96fe0ee..d323d06 100644
--- a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp
+++ b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.cpp
@@ -1,3 +1,255 @@
+// FFmpegDecoder.cpp
+//#include "FFmpegDecoder.h"
+//
+//FFmpegDecoder::FFmpegDecoder(QObject* parent) :
+// QThread(parent),
+// videoLabel(nullptr),
+// abort(false),
+// restart(false),
+// formatContext(nullptr),
+// codecContext(nullptr),
+// frame(nullptr),
+// packet(nullptr),
+// swsContext(nullptr),
+// videoStreamIndex(-1) // 鍒濆鍖栨垚鍛樺彉閲
+//{
+// av_log_set_level(AV_LOG_QUIET); // 璁剧疆鏃ュ織绾у埆涓哄畨闈欐ā寮
+// avformat_network_init(); // 鍒濆鍖栫綉缁
+//}
+//
+//FFmpegDecoder::~FFmpegDecoder()
+//{
+// mutex.lock();
+// abort = true;
+// condition.wakeOne();
+// mutex.unlock();
+// wait();
+// if (codecContext) {
+// avcodec_free_context(&codecContext);
+// }
+// if (frame) {
+// av_frame_free(&frame);
+// }
+// if (packet) {
+// av_packet_free(&packet);
+// }
+// if (swsContext) {
+// sws_freeContext(swsContext);
+// }
+// if (formatContext) {
+// avformat_close_input(&formatContext);
+// }
+// avformat_network_deinit(); // 鍙嶅垵濮嬪寲缃戠粶
+//}
+//
+//void FFmpegDecoder::initialize()
+//{
+// // 鍒濆鍖朏Fmpeg搴
+// avformat_network_init();
+//}
+//
+//void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoLabel)
+//{
+// QMutexLocker locker(&mutex);
+// this->filePath = filePath;
+// this->videoLabel = videoLabel;
+// if (!isRunning()) {
+// //start(LowPriority);
+// start(NormalPriority);
+// }
+// restart = true;
+// condition.wakeOne();
+//}
+//
+//void FFmpegDecoder::run()
+//{
+// QFile file(filePath);
+// qint64 fileSize = 0;
+//
+// for (;;) {
+// mutex.lock();
+// while (!restart && !abort) {
+// condition.wait(&mutex);
+// }
+// if (abort) {
+// mutex.unlock();
+// break;
+// }
+// restart = false;
+// QLabel* currentVideoLabel = videoLabel;
+// QSize labelSize = currentVideoLabel->size();
+// mutex.unlock();
+// qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
+//
+// if (!file.open(QIODevice::ReadOnly)) {
+// qWarning() << "Failed to open file:" << filePath;
+// continue;
+// }
+// // 浠庝笂娆″鐞嗙殑浣嶇疆寮濮嬭鍙
+// file.seek(fileSize);
+//
+// formatContext = nullptr;
+// codecContext = nullptr;
+// frame = nullptr;
+// packet = nullptr;
+//
+// // 閫氳繃 FFmpeg 鍒濆鍖栨牸寮忎笂涓嬫枃鍜岃В鐮佸櫒
+// if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
+// qWarning() << "Failed to open file with FFmpeg:" << filePath;
+// file.close();
+// continue;
+// }
+//
+// if (avformat_find_stream_info(formatContext, nullptr) < 0) {
+// qWarning() << "Failed to retrieve stream info";
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// videoStreamIndex = -1;
+// for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
+// if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+// videoStreamIndex = i;
+// break;
+// }
+// }
+// if (videoStreamIndex == -1) {
+// qWarning() << "No video stream found";
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
+// const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
+// if (!codec) {
+// qWarning() << "Unsupported codec";
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// codecContext = avcodec_alloc_context3(codec);
+// if (!codecContext) {
+// qWarning() << "Failed to allocate codec context";
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
+// qWarning() << "Failed to copy codec parameters to context";
+// avcodec_free_context(&codecContext);
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// if (avcodec_open2(codecContext, codec, nullptr) < 0) {
+// qWarning() << "Failed to open codec";
+// avcodec_free_context(&codecContext);
+// avformat_close_input(&formatContext);
+// file.close();
+// continue;
+// }
+//
+// frame = av_frame_alloc();
+// packet = av_packet_alloc();
+//
+// // 涓昏В鐮佸惊鐜
+// while (!abort) {
+// qint64 currentFileSize = file.size();
+// if (currentFileSize > fileSize) {
+// fileSize = currentFileSize;
+// file.seek(fileSize); // 璁剧疆鏂囦欢璇诲彇浣嶇疆鍒版湯灏
+//
+// // 璇诲彇骞跺鐞嗘暟鎹寘
+// while (av_read_frame(formatContext, packet) >= 0) {
+// if (packet->stream_index == videoStreamIndex) {
+// int ret = avcodec_send_packet(codecContext, packet);
+// if (ret < 0) {
+// qWarning() << "Error sending packet for decoding";
+// av_packet_unref(packet);
+// continue;
+// }
+// while (ret >= 0) {
+// ret = avcodec_receive_frame(codecContext, frame);
+// if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
+// qWarning() << "----------- break";
+// av_packet_unref(packet);
+// continue;
+// //break;
+// }
+// else if (ret < 0) {
+// qWarning() << "Error during decoding";
+// break;
+// }
+//
+// /*mutex.lock();
+// QSize labelSize = currentVideoLabel->size();
+// mutex.unlock();*/
+// //qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
+// QImage img = avFrameToQImage(frame);
+// QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+// currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
+// //currentVideoLabel->setPixmap(QPixmap::fromImage(img));
+// QThread::msleep(10); // Simulate 25 FPS frame rate
+// }
+// }
+// av_packet_unref(packet);
+// }
+// }
+//
+// mutex.lock();
+// if (restart) {
+// restart = false;
+// mutex.unlock();
+// break;
+// }
+// mutex.unlock();
+// }
+//
+// avcodec_free_context(&codecContext);
+// avformat_close_input(&formatContext);
+// av_frame_free(&frame);
+// av_packet_free(&packet);
+// file.close();
+// sws_freeContext(swsContext);
+//
+// mutex.lock();
+// if (!restart) {
+// condition.wait(&mutex);
+// }
+// mutex.unlock();
+// }
+//}
+//
+//
+//QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
+//{
+// int width = frame->width;
+// int height = frame->height;
+// AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
+//
+// SwsContext* swsCtx = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
+// if (!swsCtx) {
+// qWarning() << "Failed to initialize the conversion context";
+// return QImage();
+// }
+//
+// QImage img(width, height, QImage::Format_RGB888);
+// uint8_t* dest[4] = { img.bits(), nullptr, nullptr, nullptr };
+// int destLinesize[4] = { img.bytesPerLine(), 0, 0, 0 };
+//
+// sws_scale(swsCtx, frame->data, frame->linesize, 0, height, dest, destLinesize);
+// sws_freeContext(swsCtx);
+//
+// return img;
+//}
+//
+//
+
// FFmpegDecoder.cpp
#include "FFmpegDecoder.h"
@@ -15,35 +267,25 @@ FFmpegDecoder::FFmpegDecoder(QObject* parent) :
{
av_log_set_level(AV_LOG_QUIET); // 璁剧疆鏃ュ織绾у埆涓哄畨闈欐ā寮
avformat_network_init(); // 鍒濆鍖栫綉缁
+ qDebug() << "FFmpegDecoder created";
}
FFmpegDecoder::~FFmpegDecoder()
{
+ qDebug() << "Destroying FFmpegDecoder";
mutex.lock();
abort = true;
condition.wakeOne();
mutex.unlock();
wait();
- if (codecContext) {
- avcodec_free_context(&codecContext);
- }
- if (frame) {
- av_frame_free(&frame);
- }
- if (packet) {
- av_packet_free(&packet);
- }
- if (swsContext) {
- sws_freeContext(swsContext);
- }
- if (formatContext) {
- avformat_close_input(&formatContext);
- }
+ cleanup();
avformat_network_deinit(); // 鍙嶅垵濮嬪寲缃戠粶
+ qDebug() << "FFmpegDecoder destroyed";
}
void FFmpegDecoder::initialize()
{
+ qDebug() << "Initializing FFmpeg library";
// 鍒濆鍖朏Fmpeg搴
avformat_network_init();
}
@@ -54,7 +296,7 @@ void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoLabel)
this->filePath = filePath;
this->videoLabel = videoLabel;
if (!isRunning()) {
- //start(LowPriority);
+ qDebug() << "Starting decoder thread";
start(NormalPriority);
}
restart = true;
@@ -66,13 +308,14 @@ void FFmpegDecoder::run()
QFile file(filePath);
qint64 fileSize = 0;
- for (;;) {
+ while (true) {
mutex.lock();
while (!restart && !abort) {
condition.wait(&mutex);
}
if (abort) {
mutex.unlock();
+ qDebug() << "Decoder thread aborting";
break;
}
restart = false;
@@ -85,78 +328,14 @@ void FFmpegDecoder::run()
qWarning() << "Failed to open file:" << filePath;
continue;
}
- // 浠庝笂娆″鐞嗙殑浣嶇疆寮濮嬭鍙
- file.seek(fileSize);
- formatContext = nullptr;
- codecContext = nullptr;
- frame = nullptr;
- packet = nullptr;
-
- // 閫氳繃 FFmpeg 鍒濆鍖栨牸寮忎笂涓嬫枃鍜岃В鐮佸櫒
- if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
- qWarning() << "Failed to open file with FFmpeg:" << filePath;
+ if (!initializeFFmpeg(filePath)) {
+ qDebug() << "Failed to initialize FFmpeg for file:" << filePath;
+ cleanup();
file.close();
continue;
}
- if (avformat_find_stream_info(formatContext, nullptr) < 0) {
- qWarning() << "Failed to retrieve stream info";
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- videoStreamIndex = -1;
- for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
- if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
- videoStreamIndex = i;
- break;
- }
- }
- if (videoStreamIndex == -1) {
- qWarning() << "No video stream found";
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
- const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
- if (!codec) {
- qWarning() << "Unsupported codec";
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- codecContext = avcodec_alloc_context3(codec);
- if (!codecContext) {
- qWarning() << "Failed to allocate codec context";
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
- qWarning() << "Failed to copy codec parameters to context";
- avcodec_free_context(&codecContext);
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- if (avcodec_open2(codecContext, codec, nullptr) < 0) {
- qWarning() << "Failed to open codec";
- avcodec_free_context(&codecContext);
- avformat_close_input(&formatContext);
- file.close();
- continue;
- }
-
- frame = av_frame_alloc();
- packet = av_packet_alloc();
-
// 涓昏В鐮佸惊鐜
while (!abort) {
qint64 currentFileSize = file.size();
@@ -176,24 +355,17 @@ void FFmpegDecoder::run()
while (ret >= 0) {
ret = avcodec_receive_frame(codecContext, frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
- qWarning() << "----------- break";
av_packet_unref(packet);
continue;
- //break;
}
else if (ret < 0) {
qWarning() << "Error during decoding";
break;
}
- /*mutex.lock();
- QSize labelSize = currentVideoLabel->size();
- mutex.unlock();*/
- //qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
QImage img = avFrameToQImage(frame);
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
- //currentVideoLabel->setPixmap(QPixmap::fromImage(img));
QThread::msleep(10); // Simulate 25 FPS frame rate
}
}
@@ -210,12 +382,8 @@ void FFmpegDecoder::run()
mutex.unlock();
}
- avcodec_free_context(&codecContext);
- avformat_close_input(&formatContext);
- av_frame_free(&frame);
- av_packet_free(&packet);
+ cleanup();
file.close();
- sws_freeContext(swsContext);
mutex.lock();
if (!restart) {
@@ -225,25 +393,102 @@ void FFmpegDecoder::run()
}
}
+bool FFmpegDecoder::initializeFFmpeg(const QString& filePath)
+{
+ if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
+ qWarning() << "Failed to open file with FFmpeg:" << filePath;
+ return false;
+ }
+
+ if (avformat_find_stream_info(formatContext, nullptr) < 0) {
+ qWarning() << "Failed to retrieve stream info";
+ return false;
+ }
+
+ videoStreamIndex = -1;
+ for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
+ if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ videoStreamIndex = i;
+ break;
+ }
+ }
+ if (videoStreamIndex == -1) {
+ qWarning() << "No video stream found";
+ return false;
+ }
+
+ AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
+ const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
+ if (!codec) {
+ qWarning() << "Unsupported codec";
+ return false;
+ }
+
+ codecContext = avcodec_alloc_context3(codec);
+ if (!codecContext) {
+ qWarning() << "Failed to allocate codec context";
+ return false;
+ }
+
+ if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
+ qWarning() << "Failed to copy codec parameters to context";
+ return false;
+ }
+
+ if (avcodec_open2(codecContext, codec, nullptr) < 0) {
+ qWarning() << "Failed to open codec";
+ return false;
+ }
+
+ frame = av_frame_alloc();
+ packet = av_packet_alloc();
+
+ return true;
+}
+
+void FFmpegDecoder::cleanup()
+{
+ if (codecContext) {
+ avcodec_free_context(&codecContext);
+ codecContext = nullptr;
+ }
+ if (frame) {
+ av_frame_free(&frame);
+ frame = nullptr;
+ }
+ if (packet) {
+ av_packet_free(&packet);
+ packet = nullptr;
+ }
+ if (swsContext) {
+ sws_freeContext(swsContext);
+ swsContext = nullptr;
+ }
+ if (formatContext) {
+ avformat_close_input(&formatContext);
+ formatContext = nullptr;
+ }
+}
QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
{
- int width = frame->width;
+ int width = frame->width;
int height = frame->height;
AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
- SwsContext* swsCtx = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
- if (!swsCtx) {
- qWarning() << "Failed to initialize the conversion context";
- return QImage();
+ if (!swsContext) {
+ swsContext = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
+ if (!swsContext) {
+ qWarning() << "Failed to initialize the conversion context";
+ return QImage();
+ }
}
QImage img(width, height, QImage::Format_RGB888);
uint8_t* dest[4] = { img.bits(), nullptr, nullptr, nullptr };
int destLinesize[4] = { img.bytesPerLine(), 0, 0, 0 };
- sws_scale(swsCtx, frame->data, frame->linesize, 0, height, dest, destLinesize);
- sws_freeContext(swsCtx);
+ sws_scale(swsContext, frame->data, frame->linesize, 0, height, dest, destLinesize);
return img;
}
diff --git a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h
index 0e75e6c..811ed7f 100644
--- a/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h
+++ b/FactoryTestTool/SourceCode/Media/VideoDecoder/FFmpegDecoder.h
@@ -36,6 +36,9 @@ public:
void decodeFile(const QString& filePath, QLabel* videoLabel);
void decodeSingleFrame(const QByteArray& data, QLabel* videoLabel); // 娣诲姞 videoLabel 鍙傛暟
+ bool initializeFFmpeg(const QString& filePath);
+ void cleanup();
+
protected:
void run() override;
diff --git a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp
index a26da89..7aeb43f 100644
--- a/FactoryTestTool/SourceCode/Network/ClientHandler.cpp
+++ b/FactoryTestTool/SourceCode/Network/ClientHandler.cpp
@@ -1,12 +1,21 @@
// ClientHandler.cpp
#include "ClientHandler.h"
+#include "LicenseConfirmWindow.h"
-ClientHandler::ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray getDevInfoJson,
- QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent)
- : QObject(parent), socket(socket), frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest), frontBoardFuncConfig(frontBoardFuncConfig), getDevInfoJson(getDevInfoJson),
- getPicJson(getPicJson), getVideoJson(getVideoJson), currentItemIndex(0), clientId(clientId),
- isManualSend(false), isSingleSend(false), isClickedSend(false), size(0), isFirstDataReceived(true), processDataFunction(nullptr),
- isDataStuck(false), dataProcessingActive(false), isRecvVideoData(false)
+ClientHandler::ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
+ QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, QJsonArray backBoardDevInfoJson,
+ QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent)
+ : QObject(parent), socket(socket),
+ frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
+ frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson),
+ frontBoardLicenseJson(frontBoardLicenseJson),
+ backBoardDevInfoJson(backBoardDevInfoJson), getPicJson(getPicJson),
+ getVideoJson(getVideoJson), currentItemIndex(0), clientId(clientId),
+ isManualSend(false), isSingleSend(false), isClickedSend(false), size(0),
+ isFirstDataReceived(true), processDataFunction(nullptr),
+ isDataStuck(false), dataProcessingActive(false), isRecvVideoData(false),
+ currentFrontBoardIndex(0), // 鍒濆鍖栦负0
+ currentBackBoardIndex(0)
{
connect(socket, &QTcpSocket::readyRead, this, &ClientHandler::onDataReceived);
connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::onDisconnected);
@@ -179,6 +188,30 @@ void ClientHandler::sendGetVideoItem(int itemIndex, int video_flag)
sendJsonItem(getVideoJson, itemIndex, "", "getVideo");
}
+// 鍙戦丩icense澶勭悊鎸夐敭
+void ClientHandler::sendLicenseItem(int itemIndex)
+{
+ if (itemIndex < 0 || itemIndex >= frontBoardLicenseJson.size()) {
+ qDebug() << "Invalid itemIndex";
+ return;
+ }
+
+ QJsonObject item = frontBoardLicenseJson[itemIndex].toObject();
+ QString label = item["lable"].toString();
+
+ if (label == "write_license" || label == "get_license") {
+ LicenseConfirmWindow dialog("浣犵‘瀹氳鍙戦佹鎺堟潈椤瑰悧?");
+ int result = dialog.exec();
+
+ if (result == QDialog::Accepted) {
+ sendJsonItem(frontBoardLicenseJson, itemIndex, "", "License");
+ }
+ }
+ else {
+ sendJsonItem(frontBoardLicenseJson, itemIndex, "", "License");
+ }
+}
+
// 鍙戦佸崟鐙竴涓姛鑳介厤缃 JSON 椤圭洰
void ClientHandler::sendFuncItem(int itemIndex, const QString text)
{
@@ -192,6 +225,50 @@ void ClientHandler::sendItem(int itemIndex)
sendJsonItem(frontBoardTest, itemIndex, "", "test");
}
+void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemIndex)
+{
+ QMutexLocker locker(&mutex);
+ isPowerOnSend = true;
+ qDebug() << "itemIndex锛" << itemIndex;
+ qDebug() << "jsonItem.size()锛" << jsonItem.size();
+
+ QString itemData = QJsonDocument(jsonItem).toJson();
+ emit sendData(itemData.toUtf8());
+
+ if (jsonItem.contains("timeout")) {
+ int timeout = jsonItem.value("timeout").toInt();
+ if (timeout > 0) {
+ emit startTimeout(timeout);
+ }
+ }
+ else {
+ // 濡傛灉娌℃湁 timeout 瀛楁锛屽垯涓嶈缃秴鏃跺鐞嗭紝涓鐩寸瓑寰呮暟鎹帴鏀
+ }
+
+}
+
+void ClientHandler::sendDevInfoItem()
+{
+ // 鍓嶆澘
+ if (1) {
+ qDebug() << "frontBoardDevInfoJson.size()锛" << frontBoardDevInfoJson.size();
+ if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
+ sendDevInfoJsonItem(frontBoardDevInfoJson[currentFrontBoardIndex].toObject(), 1);
+ currentFrontBoardIndex ++;
+ }
+ else
+ isPowerOnSend = false;
+ }
+ // 鍚庢澘
+ else {
+ if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
+ sendDevInfoJsonItem(backBoardDevInfoJson[currentBackBoardIndex ++].toObject(), 1);
+ }
+ else
+ isPowerOnSend = false;
+ }
+}
+
// 鍙戦佷笅涓涓 JSON 椤圭洰
void ClientHandler::sendNextItem()
{
@@ -330,11 +407,11 @@ void ClientHandler::onDataReceived()
{
// 鎺ユ敹鍏朵粬鏁版嵁 娣诲姞鍖哄垎 瑙嗛涓庡叾浠栨暟鎹 鐨勬爣蹇椾綅
if (!isRecvVideoData &&
- (isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
+ (isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
QByteArray allData;
while (socket->bytesAvailable() > 0) {
qint64 bytesAvailableBefore = socket->bytesAvailable();
- qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
+ //qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
QByteArray buffer;
buffer.resize(qMin(bytesAvailableBefore, qint64(5 * 1024))); // 姣忔璇诲彇鏈澶 5KB
qint64 bytesRead = socket->read(buffer.data(), buffer.size());
@@ -349,7 +426,7 @@ void ClientHandler::onDataReceived()
}
if (!allData.isEmpty()) {
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
- if (!isSingleSend) {
+ if (!isSingleSend && !isPowerOnSend) {
currentItemIndex ++;
itemsProcessedCount ++;
}
@@ -360,17 +437,25 @@ void ClientHandler::onDataReceived()
isSingleSend = false; // 閲嶇疆鏍囧織
isClickedSend = false;
}
- else if (currentItemIndex < frontBoardOneClickTest.size()) {
+ else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
+ sendDevInfoItem();
+ }
+ /*else if (isPowerOnSend) {
+ qDebug() << "All items processed in onDataReceived.";
+ emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
+ isPowerOnSend = false;
+ }*/
+ else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
//qDebug() << "-------- start sendNextItem";
sendNextItem();
}
- else {
- qDebug() << "All items processed in onDataReceived.";
+ else if(isClickedSend) {
+ //qDebug() << "All items processed in onDataReceived.";
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
isClickedSend = false;
//resetCurrentItemIndex();
}
- qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount 锛" << itemsProcessedCount;
+ //qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount 锛" << itemsProcessedCount;
}
// 鎺ユ敹瑙嗛娴佹暟鎹 isRecvVideoData 缃 0
else if (!dataProcessingActive) {
@@ -387,7 +472,7 @@ void ClientHandler::processPendingData()
QByteArray allData;
while (socket->bytesAvailable() > 0 && maxIterations-- > 0) {
qint64 bytesAvailableBefore = socket->bytesAvailable();
- qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
+ //qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
RETRY:
// 鍒嗗潡璇诲彇鏁版嵁锛岄伩鍏嶄竴娆℃ц鍙栬繃澶氭暟鎹
QByteArray buffer;
@@ -398,9 +483,9 @@ void ClientHandler::processPendingData()
buffer.resize(bytesRead);
allData.append(buffer);
qint64 bytesAvailableAfter = socket->bytesAvailable();
- qDebug() << "--1--Received data size:" << buffer.size() << "clientId:" << clientId
+ /*qDebug() << "--1--Received data size:" << buffer.size() << "clientId:" << clientId
<< "at" << QDateTime::currentDateTime().toString(Qt::ISODate)
- << "bytesAvailable after read:" << bytesAvailableAfter;
+ << "bytesAvailable after read:" << bytesAvailableAfter; */
if (isFirstDataReceived) {
RNDISFirstData(buffer);
@@ -474,23 +559,31 @@ void ClientHandler::onTimeout()
//emit statusUpdated(socket->peerAddress().toString(), currentItemIndex, false, itemData);
emit statusUpdated(getClientAddress(), currentItemIndex + 1, currentFuncItemIndex + 1,
false, getCurrentItemLable(), getCurrentFuncItemLable());
- if (isSingleSend == false) {
+ if (!isSingleSend && !isPowerOnSend) {
currentItemIndex ++;
itemsProcessedCount ++;
}
}
if (isSingleSend) {
- isSingleSend = false; // 閲嶇疆鏍囧織
+ isSingleSend = false;
}
- else if (currentItemIndex < frontBoardOneClickTest.size()) {
+ else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
+ sendDevInfoItem();
+ }
+ else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
//qDebug() << "------> onTimeout";
sendNextItem();
}
- else {
+ else if(isClickedSend) {
qDebug() << "All items processed in onTimeout.";
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
//resetCurrentItemIndex();
}
+ else if (isPowerOnSend) {
+ qDebug() << "All items processed in onTimeout.";
+ emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
+ //resetCurrentItemIndex();
+ }
//qDebug() << "------> end mutex 锛" << __FUNCTION__;
qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount 锛" << itemsProcessedCount;
}
diff --git a/FactoryTestTool/SourceCode/Network/ClientHandler.h b/FactoryTestTool/SourceCode/Network/ClientHandler.h
index a15c240..8a3b1b3 100644
--- a/FactoryTestTool/SourceCode/Network/ClientHandler.h
+++ b/FactoryTestTool/SourceCode/Network/ClientHandler.h
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include "DelUserWindows.h"
@@ -28,11 +29,15 @@ class ClientHandler : public QObject, public QRunnable
Q_OBJECT
public:
- explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray getDevInfoJson,
- QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent = nullptr);
+ explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest,
+ QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
+ QJsonArray backBoardDevInfoJson, QJsonArray getPicJson, QJsonArray getVideoJson,
+ int clientId, QObject* parent = nullptr);
~ClientHandler();
+ void sendDevInfoItem();
+
bool isData_Stuck() const;
//static int pre_H264_clientId; // 棰勮H264鐨勫鎴风ID
QTcpSocket* getSocket() const { return socket; }
@@ -48,6 +53,8 @@ public:
void sendGetPicItem(int itemIndex);
// 鍙戦佹媺瑙嗛娴佹寜閿
void sendGetVideoItem(int itemIndex, int video_flag);
+ // 鍙戦丩icense澶勭悊鎸夐敭
+ void sendLicenseItem(int itemIndex);
// 鍙戦佷笅涓涓姛鑳介厤缃 JSON 椤圭洰
void sendFuncItem(int itemIndex, QString text);
// 鍙戦佷笅涓涓 JSON 椤圭洰
@@ -110,7 +117,10 @@ private:
QTcpSocket* socket; // 瀹㈡埛绔 socket
QJsonArray frontBoardOneClickTest; // 鍓嶆澘涓閿姛鑳芥祴璇 JSON
QJsonArray frontBoardTest; // 鍓嶆澘鍗曢」娴嬭瘯 JSON
- QJsonArray frontBoardFuncConfig; // 鍓嶆澘鍔熻兘閰嶇疆鍙傛暟 JSON
+ QJsonArray frontBoardFuncConfig; // 鍓嶆澘鍔熻兘閰嶇疆鍙傛暟 JSON
+ QJsonArray frontBoardDevInfoJson; // 鍓嶆澘璁惧淇℃伅鍙傛暟 JSON
+ QJsonArray frontBoardLicenseJson; // 鍓嶆澘license淇℃伅 JSON
+ QJsonArray backBoardDevInfoJson; // 鍚庢澘璁惧淇℃伅鍙傛暟 JSON
QJsonArray jsonConfig; // 娴嬭瘯鍖 JSON 閰嶇疆
QJsonArray funcJsonConfig; // 鍔熻兘鍖 JSON 閰嶇疆
QJsonArray getDevInfoJson; // 鑾峰彇璁惧淇℃伅 JSON 閰嶇疆
@@ -127,9 +137,12 @@ private:
bool isSingleSend; // 鍗曠嫭鐐瑰嚮鎸夐敭鍙戦佺殑鏍囧織
bool isClickedSend; // 鐐瑰嚮鎸夐敭鍙戦佺殑鏍囧織锛屾病鏈夌偣鍑讳笉鎺ユ敹鏁版嵁
bool isRecvVideoData;
+ bool isPowerOnSend = false; // 涓婄數鍙戦佽澶囦俊鎭
//QTimer* timeoutTimer; // 瓒呮椂瀹氭椂鍣
int size;
+ int currentFrontBoardIndex; // 褰撳墠鍙戦佺殑鍓嶆澘璁惧淇℃伅椤圭殑绱㈠紩
+ int currentBackBoardIndex; // 褰撳墠鍙戦佺殑鍚庢澘璁惧淇℃伅椤圭殑绱㈠紩
void checkThreadStatus();
bool isFirstDataReceived;
@@ -141,6 +154,9 @@ private:
void RNDISClient3Data(QByteArray& data);
void RNDISClient4Data(QByteArray& data);
+ void sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemIndex);
+ //void sendDevInfoItem();
+
QTimer* readTimer;
QTimer* threadStatusTimer;
QTimer* connectionCheckTimer;
diff --git a/FactoryTestTool/SourceCode/Network/LicenseConfirmWindow.h b/FactoryTestTool/SourceCode/Network/LicenseConfirmWindow.h
new file mode 100644
index 0000000..aabe2a3
--- /dev/null
+++ b/FactoryTestTool/SourceCode/Network/LicenseConfirmWindow.h
@@ -0,0 +1,52 @@
+#ifndef LICENSECONFIRMWINDOW_H
+#define LICENSECONFIRMWINDOW_H
+
+#include
+#include
+#include
+#include
+
+class LicenseConfirmWindow : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit LicenseConfirmWindow(const QString& message, QWidget* parent = nullptr)
+ {
+ messageLabel = new QLabel(message, this);
+ confirmButton = new QPushButton("纭", this);
+ cancelButton = new QPushButton("鍙栨秷", this);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(messageLabel);
+ QHBoxLayout* buttonLayout = new QHBoxLayout;
+ buttonLayout->addWidget(confirmButton);
+ buttonLayout->addWidget(cancelButton);
+ layout->addLayout(buttonLayout);
+
+ setLayout(layout);
+ setWindowTitle("鑾峰彇License");
+ resize(260, 100); // 璁剧疆瀵硅瘽妗嗙殑澶у皬
+
+ connect(confirmButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onConfirmClicked);
+ connect(cancelButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onCancelClicked);
+ }
+
+private slots:
+ void onConfirmClicked()
+ {
+ accept();
+ }
+
+ void onCancelClicked()
+ {
+ reject();
+ }
+
+private:
+ QLabel* messageLabel;
+ QPushButton* confirmButton;
+ QPushButton* cancelButton;
+};
+
+#endif // LICENSECONFIRMWINDOW_H
diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/MsgTpye.h b/FactoryTestTool/SourceCode/RecvDataHandler/MsgTpye.h
new file mode 100644
index 0000000..5b90460
--- /dev/null
+++ b/FactoryTestTool/SourceCode/RecvDataHandler/MsgTpye.h
@@ -0,0 +1,61 @@
+#ifndef MSGTYPE_H
+#define MSGTYPE_H
+
+// 鍓嶆澘娴嬭瘯椤
+#define FACE_ENROLL_SINGLE 0x0200
+#define FACE_ENROLL 0x0201
+#define HAND_ENROLL 0x0202
+#define FACE_VERIFY 0x0203
+#define HAND_VERIFY 0x0204
+#define DEL_USER 0x0205
+#define DEL_ALLUSER 0x0206
+#define GET_USER 0x0207
+#define GET_ALLUSER 0x0208
+#define PASSWD_ENROLL 0x0209
+#define IMG_ENROLL 0x020A
+
+#define GET_IMG 0x0220
+#define START_VIDEO 0x0221
+#define STOP_VIDEO 0x0222
+
+#define TOUCH_TEST 0x0240
+#define MIC_TEST 0x0241
+#define SPK_TEST 0x0242
+#define RADAR_TEST 0x0243
+#define NFC_TEST 0x0244
+#define PR_SWITCH 0x0245
+#define PS_TEST 0x0246
+#define BACKLIGHT 0x0247
+#define IR_LED 0x0248
+#define UART_TEST 0x0249
+#define PIR_TEST 0x024A
+
+// 鍓嶆澘閰嶇疆
+#define FACE_VERIFY_THRES 0x0300
+#define FACE_THRES_LEVEL 0x0301
+#define FACE_LIVE_THRES 0x0302
+#define FACE_ACC_THRES 0x0303
+#define FACE_ACC_LEVEL 0x0304
+#define FACE_DIS_RANGE 0x0305
+#define FACE_ANGLE_RANGE 0x0306
+#define HAND_VERIFY_THRES 0x0307
+#define HANS_THRES_LEVEL 0x0308
+#define HAND_LIVE_THRES 0x0309
+#define USER_MAX_NUM 0x030A
+#define ADMI_USER_MAX_NUM 0x030B
+#define FACE_REPEAT 0x030C
+#define HAND_REPEAT 0x030D
+
+#define SET_IP 0x0320
+#define SET_PORT 0x0321
+
+#define SET_VOLUME 0x0340
+#define SET_BACKLIGHT 0x0341
+#define SET_RADAR_DIS 0x0342
+#define SET_UART_BARTRATE 0x0343
+
+#define SET_LOG_LEVEL 0x0360
+
+
+
+#endif
diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp
index d1fe431..2930a27 100644
--- a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp
+++ b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.cpp
@@ -16,8 +16,14 @@ DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLab
DataHandler::~DataHandler()
{
- delete ffmpegDecoder; // 閲婃斁瑙g爜鍣
- delete buffer;
+ if (ffmpegDecoder) {
+ ffmpegDecoder->requestInterruption();
+ ffmpegDecoder->wait(); // 绛夊緟瑙g爜鍣ㄧ嚎绋嬪畬鎴
+ delete ffmpegDecoder;
+ ffmpegDecoder = nullptr;
+ }
+ delete buffer;
+ buffer = nullptr;
}
// 灏嗗崄鍏繘鍒跺瓧绗︿覆杞崲涓 QByteArray
@@ -47,14 +53,10 @@ void DataHandler::showVideo(const QString& client, const QByteArray& valData)
}
}
- //qDebug() << "==========valData.size:" << valData.size();
if (!valData.isEmpty()) {
file.write(valData);
- file.flush(); // 鍒锋柊鏂囦欢缂撳啿鍖猴紝浠ョ‘淇濇暟鎹啓鍏ョ鐩
- qWarning() << " ------------ write ------------" ;
+ file.flush(); // 鍒锋柊鏂囦欢缂撳啿鍖
}
- //qint64 elapsed = timer.elapsed(); // 鑾峰彇缁忚繃鐨勬椂闂达紙姣锛
- //qDebug() << "Time spent writing file:" << elapsed << "ms";
if (!start_run) {
start_run = 1;
@@ -69,29 +71,8 @@ void DataHandler::clearAllRecvData() {
dataLen = 0;
}
-void DataHandler::handleCmd(unsigned char msg_id, const QString& client, QByteArray actual_data)
-{
- switch (msg_id) {
- case 0x19:
- {
- showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
- }
- break;
-
- case 0x11:
- {
- showVideo(client, actual_data);
- }
- break;
-
- default:
- {}
- break;
- }
-}
-
// 澶勭悊鎺ユ敹鍒扮殑鏁版嵁
-void DataHandler::handleData(const QString& client, const QByteArray& recvData, unsigned char msg_id,
+void DataHandler::handleData(const QString& client, const QByteArray& recvData, int msg_id,
int currentRecvItemIndex, int currentRecvFuncItemIndex,
const QString& itemData, const QString& funcItemData)
{
@@ -111,7 +92,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
qDebug() << "read file data size:" << recvdata.size();
#endif
- qDebug() << "---Received data size:" << recvData.size();
+ //qDebug() << "---Received data size:" << recvData.size();
// 灏嗘帴鏀跺埌鐨勬暟鎹拷鍔犲埌buffer
buffer->append(recvData);
@@ -119,7 +100,8 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
while (buffer->size() >= 11) { // 鑷冲皯闇瑕11涓瓧鑺傛潵瑙f瀽鏁版嵁澶
// 妫鏌ユ暟鎹ご
if (buffer->mid(0, 4) == QByteArray::fromHex("aa55aa55")) {
- msg_id = static_cast(buffer->at(4));
+ msg_id = (static_cast(buffer->at(5)) << 8) |
+ (static_cast(buffer->at(4)));
int dataSize = (static_cast(buffer->at(9)) << 24) |
(static_cast(buffer->at(8)) << 16) |
(static_cast(buffer->at(7)) << 8) |
@@ -138,8 +120,8 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
buffer->remove(0, totalSize); // 绉婚櫎宸插鐞嗙殑鏁版嵁
// 鏆傛椂璁剧疆 NG
// 鍚屼竴涓猚lient浠呭綋 msg_id 涓嶈繛缁负 0x11/0x21 鎴栫涓娆″鐞嗘椂鎵嶆墽琛 emit statusUpdated
- if ((msg_id != 0x11 || clientLastMsgId.value(client, 0) != 0x11) &&
- (msg_id != 0x21 || clientLastMsgId.value(client, 0) != 0x21)){
+ if ((msg_id != 0x0011 || clientLastMsgId.value(client, 0) != 0x0011) &&
+ (msg_id != 0x0021 || clientLastMsgId.value(client, 0) != 0x0021)){
qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << msg_id;
emit statusUpdated(client, currentRecvItemIndex + 1, currentRecvFuncItemIndex + 1,
true, itemData, funcItemData);
@@ -156,3 +138,269 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
}
}
}
+
+void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data)
+{
+ switch (msg_id) {
+ case 0x0019:
+ {
+ showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
+ }
+ break;
+ case 0x0011:
+ {
+ showVideo(client, actual_data);
+ }
+ break;
+ case 0x0021:
+ {
+ //showVideo(client, actual_data);
+ }
+ break;
+ case FACE_ENROLL_SINGLE:
+ {
+
+ }
+ break;
+ case FACE_ENROLL:
+ {
+
+ }
+ break;
+ case HAND_ENROLL:
+ {
+
+ }
+ break;
+ case FACE_VERIFY:
+ {
+
+ }
+ break;
+ case HAND_VERIFY:
+ {
+
+ }
+ break;
+ case DEL_USER:
+ {
+
+ }
+ break;
+ case DEL_ALLUSER:
+ {
+
+ }
+ break;
+ case GET_USER:
+ {
+
+ }
+ break;
+ case GET_ALLUSER:
+ {
+
+ }
+ break;
+ case PASSWD_ENROLL:
+ {
+
+ }
+ break;
+ case IMG_ENROLL:
+ {
+
+ }
+ break;
+ case GET_IMG:
+ {
+
+ }
+ break;
+ case START_VIDEO:
+ {
+
+ }
+ break;
+ case STOP_VIDEO:
+ {
+
+ }
+ break;
+ case TOUCH_TEST:
+ {
+
+ }
+ break;
+ case MIC_TEST:
+ {
+
+ }
+ break;
+ case SPK_TEST:
+ {
+
+ }
+ break;
+ case RADAR_TEST:
+ {
+
+ }
+ break;
+ case NFC_TEST:
+ {
+
+ }
+ break;
+ case PR_SWITCH:
+ {
+
+ }
+ break;
+ case PS_TEST:
+ {
+
+ }
+ break;
+ case BACKLIGHT:
+ {
+
+ }
+ break;
+ case IR_LED:
+ {
+
+ }
+ break;
+ case UART_TEST:
+ {
+
+ }
+ break;
+ case PIR_TEST:
+ {
+
+ }
+ break;
+ case FACE_VERIFY_THRES:
+ {
+
+ }
+ break;
+ case FACE_THRES_LEVEL:
+ {
+
+ }
+ break;
+ case FACE_LIVE_THRES:
+ {
+
+ }
+ break;
+ case FACE_ACC_THRES:
+ {
+
+ }
+ break;
+ case FACE_ACC_LEVEL:
+ {
+
+ }
+ break;
+ case FACE_DIS_RANGE:
+ {
+
+ }
+ break;
+ case FACE_ANGLE_RANGE:
+ {
+
+ }
+ break;
+ case HAND_VERIFY_THRES:
+ {
+
+ }
+ break;
+ case HANS_THRES_LEVEL:
+ {
+
+ }
+ break;
+ case HAND_LIVE_THRES:
+ {
+
+ }
+ break;
+ case USER_MAX_NUM:
+ {
+
+ }
+ break;
+ case ADMI_USER_MAX_NUM:
+ {
+
+ }
+ break;
+ case FACE_REPEAT:
+ {
+
+ }
+ break;
+ case HAND_REPEAT:
+ {
+
+ }
+ break;
+ case SET_IP:
+ {
+
+ }
+ break;
+ case SET_PORT:
+ {
+
+ }
+ break;
+ case SET_VOLUME:
+ {
+
+ }
+ break;
+ case SET_BACKLIGHT:
+ {
+
+ }
+ break;
+ case SET_RADAR_DIS:
+ {
+
+ }
+ break;
+ case SET_UART_BARTRATE:
+ {
+
+ }
+ break;
+ default:
+ {}
+ break;
+ }
+}
+
+void DataHandler::handleBackCmd(int msg_id, const QString& client, QByteArray actual_data)
+{
+ switch (msg_id) {
+
+ }
+}
+
+void DataHandler::handleCmd(int msg_id, const QString& client, QByteArray actual_data)
+{
+ if (msg_id < 0x0400) {
+ handleFrontCmd(msg_id, client, actual_data);
+ }
+ else if (msg_id < 0x0800) {
+ handleBackCmd(msg_id, client, actual_data);
+ }
+}
diff --git a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h
index 7f32ce3..7b4b6c4 100644
--- a/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h
+++ b/FactoryTestTool/SourceCode/RecvDataHandler/RecvDataHandler.h
@@ -20,6 +20,7 @@
#include "../Media/Media.h"
#include "../ParseDataHandler/msgID.h"
#include "../Media/VideoDecoder/FFmpegDecoder.h"
+#include "MsgTpye.h"
#define YUV420 1
#define YUV422 2
@@ -33,7 +34,7 @@ public:
~DataHandler();
public slots:
- void handleData(const QString& client, const QByteArray& data, unsigned char msg_id, int currentRecvItemIndex,
+ void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
signals:
@@ -56,7 +57,9 @@ private:
QByteArray hexStringToByteArray(const QString& hexString);
void showVideo(const QString& client, const QByteArray& valData);
void clearAllRecvData();
- void handleCmd(unsigned char msg_id, const QString& client, QByteArray actual_data);
+ void handleCmd(int msg_id, const QString& client, QByteArray actual_data);
+ void handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data);
+ void handleBackCmd(int msg_id, const QString& client, QByteArray actual_data);
};
#endif // DATAHANDLER_H
diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp
index 2653dec..758d9a6 100644
--- a/FactoryTestTool/SourceCode/Widget/MainWidget.cpp
+++ b/FactoryTestTool/SourceCode/Widget/MainWidget.cpp
@@ -2,6 +2,7 @@
#include "MainWidget.h"
#include "../RecvDataHandler/RecvDataHandler.h"
#include "../Json/readJsonFile.h"
+#include "../LicenseGenerate/LicenseGenerate.h"
void onThreadFinished(QThread* thread, ClientHandler* handler)
{
@@ -10,7 +11,7 @@ void onThreadFinished(QThread* thread, ClientHandler* handler)
thread->deleteLater();
}
-// 鏋勯犲嚱鏁帮紝鍒濆鍖 UI 缁勪欢鍜屾湇鍔″櫒
+// 鍒濆鍖 UI 缁勪欢鍜屾湇鍔″櫒
MainWidget::MainWidget(QWidget* parent) :
QWidget(parent),
nextClientId(1),
@@ -61,12 +62,9 @@ MainWidget::MainWidget(QWidget* parent) :
}
});
- // 姣忚繛鎺ヤ竴涓柊瀹㈡埛绔垱寤轰竴涓柊鐨勭嚎绋
QThread* thread = new QThread(this);
-
- /*ClientHandler* handler = new ClientHandler(socket, testJsonConfig, funcJsonConfig, getDevInfoJson,
- getPicJson, getVideoJson, clientId, nullptr);*/
- ClientHandler* handler = new ClientHandler(socket, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, getDevInfoJson,
+ ClientHandler* handler = new ClientHandler(socket, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
+ frontBoardDevInfoJson, frontBoardLicenseJson, backBoardDevInfoJson,
getPicJson, getVideoJson, clientId, nullptr);
// 灏 ClientHandler 绉诲姩鍒扮嚎绋嬫睜涓殑绾跨▼
@@ -101,7 +99,6 @@ MainWidget::MainWidget(QWidget* parent) :
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
// 鍒涘缓 DataHandler 瀵硅薄骞惰繛鎺ヤ俊鍙
- //QLabel* imageDisplayLabel = new QLabel;
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, this);
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
@@ -137,6 +134,28 @@ MainWidget::~MainWidget() {
handler->deleteLater();
}
server->close();
+
+ for (auto thread : clientThreads) {
+ thread->quit();
+ thread->wait();
+ delete thread;
+ }
+ clientThreads.clear();
+
+ for (auto handler : clients_1) {
+ handler->deleteLater();
+ }
+ clients_1.clear();
+
+ for (auto timer : clientTimers) {
+ timer->stop();
+ delete timer;
+ }
+ clientTimers.clear();
+
+ if (server->isListening()) {
+ server->close();
+ }
qDebug() << "MainWidget destroyed";
}
@@ -228,7 +247,8 @@ void MainWidget::setupUI()
sendAllButton->setEnabled(false);
statusListWidget = new QListWidget(this);
- statusListWidget->setMinimumSize(350, 880);
+ //statusListWidget->setMinimumSize(350, 880);
+ statusListWidget->setMinimumSize(350, 680);
statusListWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // 璁剧疆澶у皬绛栫暐涓烘墿灞
QHBoxLayout* buttonLayout = new QHBoxLayout;
@@ -240,7 +260,7 @@ void MainWidget::setupUI()
leftLayout->addLayout(buttonLayout);
leftLayout->setStretch(0, 1);
leftLayout->addWidget(statusListWidget);
- leftLayout->setStretch(1, 20);
+ leftLayout->setStretch(1, 200);
saveCheckBox = new QCheckBox("", this);
selectFileButton = new QPushButton("Save", this);
@@ -260,31 +280,78 @@ void MainWidget::setupUI()
leftLayout->addLayout(fileLayout);
leftLayout->setStretch(2, 1);
+ // 璇诲彇 JSON 閰嶇疆鏂囦欢
+ readJsonConfig();
+
+ QGroupBox* groupBox = new QGroupBox("绠楁硶 license", this);
+ QHBoxLayout* buttonRowLayout = new QHBoxLayout;
+ for (int i = 0; i < frontBoardLicenseJson.size(); ++i) {
+ QJsonObject item = frontBoardLicenseJson[i].toObject();
+ QString buttonText = item["lable"].toString();
+ QPushButton* button = new QPushButton(buttonText, this);
+ button->setProperty("licenseIndex", i);
+ buttonRowLayout->addWidget(button);
+ connect(button, &QPushButton::clicked, this, &MainWidget::onLicenseButtonClicked);
+ }
+ QLineEdit* readOnlyLineEdit = new QLineEdit(this);
+ readOnlyLineEdit->setReadOnly(true);
+ readOnlyLineEdit->setText("This is a read-only text");
+ readOnlyLineEdit->setFixedHeight(80);
+
+ QVBoxLayout* groupBoxLayout_license = new QVBoxLayout;
+ groupBoxLayout_license->addLayout(buttonRowLayout);
+ groupBoxLayout_license->addWidget(readOnlyLineEdit);
+ groupBox->setLayout(groupBoxLayout_license);
+
+ leftLayout->addWidget(groupBox);
+ leftLayout->setStretch(3, 1);
+
QWidget* leftContainer = new QWidget(this);
leftContainer->setLayout(leftLayout);
leftContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- // 璇诲彇 JSON 閰嶇疆鏂囦欢
- readJsonConfig();
-
QTabWidget* tabWidget = new QTabWidget(this);
tabWidget->setFixedSize(900, 315); // 璁剧疆 QTabWidget 鐨勫浐瀹氬ぇ灏
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox("鍓嶆澘璁惧淇℃伅", this);
QVBoxLayout* frontDeviceInfoLayout = new QVBoxLayout(frontDeviceInfoGroupBox);
- QHBoxLayout* frontDeviceButtonsLayout = new QHBoxLayout;
- for (int i = 0; i < 2; ++i) {
- QPushButton* button = new QPushButton(QString("Device %1").arg(i + 1), this);
- button->setProperty("deviceInfoIndex", i);
- frontDeviceButtonsLayout->addWidget(button);
- connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetDevInfoClicked);
+ QVBoxLayout* frontDeviceLabelsLayout = new QVBoxLayout;
+ for (const QJsonValue& value : frontBoardDevInfoJson) {
+ QJsonObject item = value.toObject();
+ QString label = item["lable"].toString();
+ QLabel* itemLabel = new QLabel(label, this);
+ QLineEdit* itemLineEdit = new QLineEdit(this);
+ itemLineEdit->setReadOnly(true);
+
+ QHBoxLayout* itemLayout = new QHBoxLayout;
+ itemLayout->addWidget(itemLabel);
+ itemLayout->addWidget(itemLineEdit);
+
+ frontDeviceLabelsLayout->addLayout(itemLayout);
}
- frontDeviceInfoLayout->addLayout(frontDeviceButtonsLayout);
+ frontDeviceInfoLayout->addLayout(frontDeviceLabelsLayout);
frontDeviceInfoLayout->addStretch();
- QGroupBox* backDeviceInfoGroupBox = new QGroupBox("鍚庢澘璁惧淇℃伅", this);
- QVBoxLayout* backDeviceInfoLayout = new QVBoxLayout(backDeviceInfoGroupBox);
+ QGroupBox* backDeviceInfoGroupBox = new QGroupBox("鍚庢澘璁惧淇℃伅", this);
+ QVBoxLayout* backDeviceInfoLayout = new QVBoxLayout(backDeviceInfoGroupBox);
+
+ QVBoxLayout* backDeviceLabelsLayout = new QVBoxLayout;
+ for (const QJsonValue& value : backBoardDevInfoJson) {
+ QJsonObject item = value.toObject();
+ QString label = item["lable"].toString();
+ QLabel* itemLabel = new QLabel(label, this);
+ QLineEdit* itemLineEdit = new QLineEdit(this);
+ itemLineEdit->setReadOnly(true);
+
+ QHBoxLayout* itemLayout = new QHBoxLayout;
+ itemLayout->addWidget(itemLabel);
+ itemLayout->addWidget(itemLineEdit);
+
+ backDeviceLabelsLayout->addLayout(itemLayout);
+ }
+ backDeviceInfoLayout->addLayout(backDeviceLabelsLayout);
+ backDeviceInfoLayout->addStretch();
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
groupBoxLayout->addWidget(frontDeviceInfoGroupBox, 1);
@@ -568,6 +635,7 @@ void MainWidget::readJsonConfig()
frontBoardTest = readJson_frontBoardTest();
frontBoardFuncConfig = readJson_frontBoardFuncConfig();
frontBoardDevInfoJson = readJson_frontDevInfo();
+ frontBoardLicenseJson = readJson_frontLicense();
backBoardDevInfoJson = readJson_backDevInfo();
testJsonConfig = readJson_testConfig();
funcJsonConfig = readJson_funcConfig();
@@ -640,6 +708,29 @@ void MainWidget::updateServerButtonText()
}
}
+// 澶勭悊 License 鎸夐敭鐐瑰嚮浜嬩欢
+void MainWidget::onLicenseButtonClicked()
+{
+ if (connectedClientsCount) {
+ QPushButton* button = qobject_cast(sender());
+ if (button) {
+ int index = button->property("licenseIndex").toInt();
+ if (index >= 0 && index < frontBoardLicenseJson.size()) {
+ QJsonObject jsonObject = frontBoardLicenseJson[index].toObject();
+ QString jsonString = QJsonDocument(jsonObject).toJson(QJsonDocument::Compact);
+ //qDebug() << "license Button clicked, sending JSON:" << jsonString;
+ for (ClientHandler* handler : clients) {
+ handler->sendLicenseItem(index);
+ }
+ }
+ }
+ }
+ else {
+ QListWidgetItem* listItem = new QListWidgetItem(QString("No device is connected !!!"), statusListWidget);
+ listItem->setBackground(Qt::red);
+ }
+}
+
// 澶勭悊寮濮嬫湇鍔″櫒鎸夐敭鐐瑰嚮浜嬩欢
void MainWidget::onStartServerClicked()
{
@@ -792,6 +883,11 @@ void MainWidget::onOpenFocusWindowClicked()
}
}
+//void MainWidget::onPowerOnSend()
+//{
+//
+//}
+
// 澶勭悊涓閿彂閫佹寜閿偣鍑讳簨浠
void MainWidget::onSendAllClicked()
{
@@ -805,8 +901,9 @@ void MainWidget::onSendAllClicked()
for (ClientHandler* handler : clients) {
// 閲嶇疆绱㈠紩
handler->resetCurrentItemIndex();
- qDebug() << "------> handler->sendNextItem()";
- handler->sendNextItem();
+ //handler->sendNextItem();
+ handler->sendDevInfoItem();
+ //licenseGenerate();
}
}
else {
diff --git a/FactoryTestTool/SourceCode/Widget/MainWidget.h b/FactoryTestTool/SourceCode/Widget/MainWidget.h
index 1fd6e18..d3e95d5 100644
--- a/FactoryTestTool/SourceCode/Widget/MainWidget.h
+++ b/FactoryTestTool/SourceCode/Widget/MainWidget.h
@@ -48,6 +48,7 @@ private slots:
void onSendGetPicClicked();
// 澶勭悊鍙戦佹媺瑙嗛娴佹寜閿偣鍑讳簨浠
void onSendGetVideoClicked();
+ void onLicenseButtonClicked();
// 澶勭悊涓閿彂閫佹寜閽偣鍑讳簨浠
void onSendAllClicked();
// 澶勭悊鍗曠嫭鍙戦侀」鎸夐挳鐐瑰嚮浜嬩欢
@@ -81,6 +82,7 @@ private slots:
void startClientReadTimer(int clientId);
void stopClientReadTimer(int clientId);
+
private:
// 璇诲彇 test JSON 閰嶇疆鏂囦欢
void readJsonConfig();
@@ -99,6 +101,7 @@ private:
QJsonArray frontBoardTest; // 鍓嶆澘鍗曢」娴嬭瘯 JSON
QJsonArray frontBoardFuncConfig; // 鍓嶆澘鍔熻兘閰嶇疆鍙傛暟 JSON
QJsonArray frontBoardDevInfoJson; // 鍓嶆澘璁惧淇℃伅鍙傛暟 JSON
+ QJsonArray frontBoardLicenseJson; // 鍓嶆澘License JSON
QJsonArray backBoardDevInfoJson; // 鍚庢澘璁惧淇℃伅鍙傛暟 JSON
QJsonArray testJsonConfig; // 鍔熻兘娴嬭瘯鍖 JSON 閰嶇疆
QJsonArray funcJsonConfig; // 鍔熻兘閰嶇疆鍖 JSON 閰嶇疆
diff --git a/FactoryTestTool/SourceCode/main.cpp b/FactoryTestTool/SourceCode/main.cpp
index b1d5167..7e85b84 100644
--- a/FactoryTestTool/SourceCode/main.cpp
+++ b/FactoryTestTool/SourceCode/main.cpp
@@ -1,9 +1,16 @@
#include "./Widget/MainWidget.h"
#include
+#include
+#include
+#include
int main(int argc, char* argv[]) {
- QApplication a(argc, argv);
+ QApplication app(argc, argv);
+
+ QIcon appIcon("./app_icon.ico");
+ app.setWindowIcon(appIcon);
+
MainWidget w;
w.show();
- return a.exec();
+ return app.exec();
}
diff --git a/FactoryTestTool/ThirdParty/LicenseGenerate/pix_license.dll b/FactoryTestTool/ThirdParty/LicenseGenerate/pix_license.dll
new file mode 100644
index 0000000..d65b6c2
Binary files /dev/null and b/FactoryTestTool/ThirdParty/LicenseGenerate/pix_license.dll differ
diff --git a/FactoryTestTool/add1.h264 b/FactoryTestTool/add1.h264
new file mode 100644
index 0000000..a483bcf
Binary files /dev/null and b/FactoryTestTool/add1.h264 differ
diff --git a/FactoryTestTool/app_icon.ico b/FactoryTestTool/app_icon.ico
new file mode 100644
index 0000000..5e9d307
Binary files /dev/null and b/FactoryTestTool/app_icon.ico differ
diff --git a/FactoryTestTool/auth_error_log_v1_0.txt b/FactoryTestTool/auth_error_log_v1_0.txt
new file mode 100644
index 0000000..e69de29
diff --git a/enc_temp_folder/5bf8884c911d5fb8bc3e9be6a43ae9/LicenseGenerate.cpp b/enc_temp_folder/5bf8884c911d5fb8bc3e9be6a43ae9/LicenseGenerate.cpp
new file mode 100644
index 0000000..94e823f
--- /dev/null
+++ b/enc_temp_folder/5bf8884c911d5fb8bc3e9be6a43ae9/LicenseGenerate.cpp
@@ -0,0 +1,73 @@
+// LicenseGenerate.cpp
+#include "LicenseGenerate.h"
+
+#define PIX_HARDWARE_INFO_BYTES 32
+#define PIX_LICENCE_BYTES 128
+
+//const char* pix_license_generate_version();
+//int pix_license_generate(const unsigned char* hardware_info_ptr, int hardware_info_bytes,
+// unsigned char* license_ptr, int license_bytes);
+
+
+typedef const char* (*pix_license_generate_version_func)();
+typedef int (*pix_license_generate_func)(const unsigned char*, int, unsigned char*, int);
+
+
+void licenseGenerate()
+{
+ unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { };
+ unsigned char license_info[PIX_LICENCE_BYTES] = { 0 };
+
+ // 鑾峰彇骞舵墦鍗板綋鍓嶅伐浣滅洰褰
+ wchar_t currentPath[MAX_PATH];
+ GetCurrentDirectoryW(MAX_PATH, currentPath);
+ std::wcout << L"Current Directory: " << currentPath << std::endl;
+
+ // 鎵撳嵃 DLL 鐨勫畬鏁磋矾寰
+ std::wstring dllPath = std::wstring(currentPath) + L"\\ThirdParty\\LicenseGenerate\\pix_license.dll";
+ std::wcout << L"DLL Path: " << dllPath << std::endl;
+
+ // 鍔犺浇 DLL 鏂囦欢
+ HINSTANCE hDLL = LoadLibraryW(dllPath.c_str()); // 浣跨敤 LoadLibraryW 鍔犺浇瀹藉瓧绗﹁矾寰
+ if (hDLL == NULL) {
+ std::cerr << "Failed to load DLL. Error code: " << GetLastError() << std::endl;
+ FreeLibrary(hDLL);
+ return;
+ }
+ pix_license_generate_version_func pix_license_generate_version =
+ (pix_license_generate_version_func)GetProcAddress(hDLL, "pix_license_generate_version");
+ pix_license_generate_func pix_license_generate =
+ (pix_license_generate_func)GetProcAddress(hDLL, "pix_license_generate");
+ if (pix_license_generate_version == NULL || pix_license_generate == NULL) {
+ std::cerr << "Failed to find one or more functions." << std::endl;
+ FreeLibrary(hDLL);
+ return;
+ }
+ printf("pix_license_generate_version is %s\n",
+ pix_license_generate_version());
+
+ printf("Hardware info:");
+ for (int j = 0; j < PIX_HARDWARE_INFO_BYTES; ++j) {
+ hardware_info[j] = j;
+ printf("0x%02x, ", hardware_info[j]);
+ }
+ printf("\n");
+ return;
+ int ret = pix_license_generate(hardware_info, PIX_HARDWARE_INFO_BYTES,
+ license_info, PIX_LICENCE_BYTES);
+ if (ret != SDK_CODE_OK) {
+ printf("Fail to generate license with %d\n", ret);
+ }
+ else {
+ printf("License is\n");
+ for (int j = 0; j < PIX_LICENCE_BYTES; ++j) {
+ printf("0x%02x, ", license_info[j]);
+ }
+ printf("\n");
+ }
+ // 閲婃斁 DLL
+ FreeLibrary(hDLL);
+
+ return;
+}
+