From a972e9283a2a9dbe3e45fc85edef492c6bb6c116 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Wed, 25 Sep 2024 16:14:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8A=A8=E6=80=81=E6=A0=A1?= =?UTF-8?q?=E6=AD=A3=E8=BF=9B=E5=BA=A6=E7=95=8C=E9=9D=A2=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=89=AB=E6=8F=8F=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B5=8B=E8=AF=95=E9=A1=B9=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=89=AB=E6=8F=8F10=E5=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HGProductionTool/form_maininterface.cpp | 27 ++++++++++--- app/HGProductionTool/mainwindow.cpp | 17 ++++---- code/base/test_base.cpp | 43 +++++++++++++++++++-- code/base/test_base.h | 2 +- 4 files changed, 68 insertions(+), 21 deletions(-) diff --git a/app/HGProductionTool/form_maininterface.cpp b/app/HGProductionTool/form_maininterface.cpp index 9e701b2..28efe82 100644 --- a/app/HGProductionTool/form_maininterface.cpp +++ b/app/HGProductionTool/form_maininterface.cpp @@ -152,6 +152,21 @@ void Form_mainInterface::setDevDisconnect() void Form_mainInterface::checkDynamicCorrectItem(bool pass, int correctType) { + int type = correctType; + QString name = m_map_title_name.value(m_curItemName).name; + if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI) + type = 1; + else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) + type = 2; + else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI) + type = 3; + else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI) + type = 4; + else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI) + type = 5; + else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) + type = 6; + bool allPass = false; int correctItemId = -1; for (int i = 0; i < ui->tableWidget->rowCount(); i++) @@ -167,37 +182,37 @@ void Form_mainInterface::checkDynamicCorrectItem(bool pass, int correctType) correctItemId = i; } - if (1 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name) + if (1 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass")); } - else if (2 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name) + else if (2 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass")); } - else if (3 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name) + else if (3 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass")); } - else if (4 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name) + else if (4 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass")); } - else if (5 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name) + else if (5 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass")); } - else if (6 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI == name) + else if (6 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI == name) { ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0)); diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index dc53e14..a5f1de3 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -368,10 +368,7 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne saneParams->data = content; saneParams->len = *len; - if (code == SANE_EVENT_SCAN_FINISHED) - { - emit p->sane_create_interface(saneParams); - } + emit p->sane_create_interface(saneParams); } return 0; @@ -479,21 +476,21 @@ void MainWindow::on_sane_create_interface(SaneParams *saneParams) { if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_) { + bool isCorrectItem = false; + int type = 0; QString info = QString::fromStdString((char*)saneParams->data); if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED)) { - int type = 0; - func_test_correct(true, &type); - if (type > 0) + func_test_correct(true, &type, &isCorrectItem); + if (isCorrectItem) { mainInterface->checkDynamicCorrectItem(true, type); } } else //if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL)) { - int type = 0; - func_test_correct(false, &type); - if (type > 0) + func_test_correct(false, &type, &isCorrectItem); + if (isCorrectItem) { mainInterface->checkDynamicCorrectItem(false, type); } diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 95cf39c..d53fc2f 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -143,8 +143,9 @@ static std::wstring set_test_name_ = L""; std::atomic is_distortion_get_image_abnormal(false); std::atomic is_distortion_get_image(false); -int g_currentCorrectType = 0; -int g_dynamicCorrectStatus = SCANNER_ERR_OK; +int g_imageCount = 0; //本轮出图数量 +int g_currentCorrectType = 0; //动态校正正在进行的子项 +int g_dynamicCorrectStatus = SCANNER_ERR_OK; //动态校正结果 std::string test::get_serial_num() { @@ -488,6 +489,16 @@ 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_SCAN_WORKING_STATUS) == 0) + { + if (g_imageCount < 20) + { + type = false; + wcscpy(buf, L"扫描走纸未达到要求(10张)"); + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type); + break; + } + } 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 @@ -569,6 +580,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int { if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 0 + || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCAN_WORKING_STATUS) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0 @@ -594,6 +606,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) == 0) { + g_imageCount++; if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0) { is_distortion_get_image = true; @@ -1024,7 +1037,13 @@ int test::test_host_fan(void* data) /* 扫描工作状态 */ int test::test_scan_work_status(void* data) { - return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); + int count = 10; + int ret = helper_->io_control(IO_CTRL_CODE_SET_SCAN_COUNT, &count, NULL); + ret = helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); + + int count2 = -1; + ret = helper_->io_control(IO_CTRL_CODE_SET_SCAN_COUNT, &count2, NULL); + return ret; } /* USB-PC接口 */ int test::test_usb_pc_interface(void* data) @@ -1251,8 +1270,10 @@ int test::test_get_auto_distortion(void* data) } //先默认设置1 float distortion = 1.0; + float getdistortion = 0; ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_DEVS_CHECK_VAL, &distortion, &len); + ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_DEVS_CHECK_VAL, &getdistortion, &len); if (thread_distortion_handle.get() && thread_distortion_handle->joinable()) thread_distortion_handle->join(); @@ -1944,6 +1965,8 @@ DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper) return -1; } + + g_imageCount = 0; is_distortion_get_image = false; is_distortion_get_image_abnormal = false; @@ -1965,9 +1988,21 @@ DECL_API(int) func_test_uninit(void* uninit) return 0; } -DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex) +DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex, bool *isCorrectItem) { + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) != 0 && + 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) + { + return 0; + } + *currentIndex = g_currentCorrectType - 1; + *isCorrectItem = true; if (!isSuccess) { diff --git a/code/base/test_base.h b/code/base/test_base.h index 6b0abdb..f6469cc 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -296,7 +296,7 @@ DECL_API(int) func_test_uninit(void*); // isSuccess - Explain whether the correction was successful this time. // // Return: error code -DECL_API(int) func_test_correct(bool isSuccess, int* currentIndex); +DECL_API(int) func_test_correct(bool isSuccess, int* currentIndex, bool* isCorrectItem); DECL_API(int) func_test_distortion();