From 3c950f857725441dbae41ae35b7145a658db5624 Mon Sep 17 00:00:00 2001 From: yangjiaxuan <171295266@qq.com> Date: Tue, 14 Mar 2023 18:00:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A1=AE=E8=AE=A4=E7=95=B8?= =?UTF-8?q?=E5=8F=98=E5=80=BC=E6=B5=8B=E8=AF=95=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/base/test_base.cpp | 68 ++++++++++++++++++++++++++++++++++++++++- code/base/test_base.h | 2 ++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 6a86087..ec24a81 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -369,7 +369,7 @@ public: wcscpy(buf, L"平场校正失败, 原因--->"); } } - else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0) + else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0) { if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0 || strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_DISTORTION) == 0) @@ -489,6 +489,7 @@ public: ||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 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 + ||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY) == 0 @@ -546,6 +547,7 @@ public: test_map_[HGPDTTOOLDB_NAME_GET_DISTORTION_VAL] = &test::test_get_auto_distortion; test_map_[HGPDTTOOLDB_NAME_SET_DISTORTION_VAL] = &test::test_set_auto_distortion; + test_map_[HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL] = &test::test_confirm_auto_distortion; test_map_[HGPDTTOOLDB_NAME_DORMANCY] = &test::test_dormancy; test_map_[HGPDTTOOLDB_NAME_PAPER_SEPARATION_STRENGTH] = &test::test_paper_separation_strength; test_map_[HGPDTTOOLDB_NAME_MECH_PAPER_FEEDING_INCLINATION] = &test::test_mech_paper_feeding_inclination; @@ -1130,6 +1132,70 @@ public: return ret; } + int test_confirm_auto_distortion(void *data) + { + if (!data ) + { + return SCANNER_ERR_DATA_DAMAGED; + } + wchar_t* p = (wchar_t*)data; + std::string str; + + int ret = SCANNER_ERR_OK, + dpi = 0; + SANE_Bool type = true; + unsigned int len = sizeof(SANE_Bool), + llen = sizeof(int); + size_t strl = 0; + ret = wchar_to_char(str, p, &strl); + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + str.resize(strl); + ret = wchar_to_char(str, p, &strl); + if (str.empty()) + { + return SCANNER_ERR_DATA_DAMAGED; + } + dpi = atoi(str.c_str()); + } + if (dpi > 0) + { + ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi, &llen); + } + + ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_IMAGE, &type, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + int cnt = 0; + SANE_DISTORTION_VAL dis = { 0 }; + while (ret == SCANNER_ERR_OK) + { + if (is_distortion_get_image) + { + ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_CHECK_VAL, &dis, &llen); + break; + } + else if (cnt == 30) + break; + + if (is_distortion_get_image_abnormal) + return -1; + + Sleep(1000); + cnt++; + } + if (dis.h > 0 && dis.scaleXY < 10) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION_VAL, (void *)&dis, true); + } + else + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT,(void*)L"自动计算畸变值获取失败", false); + } + return ret; + } /* 分纸强度检测 */ int test_paper_separation_strength(void *data) { diff --git a/code/base/test_base.h b/code/base/test_base.h index 71885c5..fe3acc0 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -142,6 +142,8 @@ #define HGPDTTOOLDB_NAME_GET_DISTORTION_VAL L"GET_DISTORTION_VAL" /* 设置畸变修正值 */ #define HGPDTTOOLDB_NAME_SET_DISTORTION_VAL L"SET_DISTORTION_VAL" +/* 确认畸变修正值 */ +#define HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL L"CONFIRM_DISTORTION_VAL" /* 设置休眠 */ #define HGPDTTOOLDB_NAME_DORMANCY L"DORMANCY" /* 歪斜挡位检测 */