From a579da892eab9451d8b022fd9b1328fb5ec3121c Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Thu, 25 Jul 2024 15:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E5=B7=A5=E5=85=B7=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=A0=A1=E6=AD=A3=E6=B5=81=E7=A8=8B=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=85=B6=E4=B8=AD=E4=B8=80=E9=A1=B9=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=8C=E5=88=99=E5=9C=A8=E5=AD=90=E9=A1=B9=E4=B8=AD?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=B8=BA=E7=BA=A2=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/base/test_base.cpp | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index b44bf3b..647e880 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -472,14 +472,14 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int wcscpy(buf, L"单张测试失败, 原因--->"); } } - else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) == 0 + else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) == 0) { - if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL) == 0) + if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED) != 0) { type = false; } @@ -494,9 +494,30 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0) { - if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL || g_currentCorrectType == 6) + if (g_currentCorrectType == 7) { - h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type); + while (1) + { + int count = 0; + if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL) + { + type = false; + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type); + break; + } + else if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FINISHED) + { + type = true; + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type); + break; + } + else if (count == 30000) //30s + { + break; + } + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + count++; + } } } else @@ -695,8 +716,10 @@ void test::thread_dynamic_correct(std::string correctData) if (g_currentCorrectType > 1) m_waitCorrect.wait(lock); - if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL) - break; + if (g_currentCorrectType == 0) + { + return; + } CorrectMode correctMode = m_correctModeMap.at(g_currentCorrectType); int dpi = correctMode.dpi; @@ -1833,8 +1856,18 @@ DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex) { if (!isSuccess) { - g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL; *currentIndex = g_currentCorrectType - 1; + if (g_currentCorrectType == 7) + { + g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL; + } + } + else + { + if (g_currentCorrectType == 7) + { + g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FINISHED; + } } test_->m_waitCorrect.notify_all();