From 7ef134bdaf94d84e1905bf3d7363657384058aa8 Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Thu, 5 Jan 2023 17:46:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7=E5=92=8C=E7=95=B8?= =?UTF-8?q?=E5=8F=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HGProductionTool/hgscanner.cpp | 3 +- app/HGProductionTool/ui_helper.h | 2 +- code/base/test_base.cpp | 177 ++++++++++++++++++++++++++--- code/base/test_base.h | 8 +- 4 files changed, 173 insertions(+), 17 deletions(-) diff --git a/app/HGProductionTool/hgscanner.cpp b/app/HGProductionTool/hgscanner.cpp index d99ea95..d8953b1 100644 --- a/app/HGProductionTool/hgscanner.cpp +++ b/app/HGProductionTool/hgscanner.cpp @@ -96,8 +96,9 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si emit m_burnMode->testResult(flag); } } - else if (ev == TEST_EVENT_DISTORTION) + else if (ev == TEST_EVENT_DISTORTION_VAL) { + float f = *(float*)data; QString title = QString::fromStdWString(name); emit m_interface->testDistortion(title, data); } diff --git a/app/HGProductionTool/ui_helper.h b/app/HGProductionTool/ui_helper.h index 9890f21..1163624 100644 --- a/app/HGProductionTool/ui_helper.h +++ b/app/HGProductionTool/ui_helper.h @@ -92,7 +92,7 @@ public: TEST_EVENT_MANUAL_CONFIRMATION, // After send cmd ,need manual confirmation. TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass TEST_EVENT_HAVE_IMAGE, // have image. - TEST_EVENT_DISTORTION, // + TEST_EVENT_DISTORTION_VAL, // get distortion_val, data is (float) data > 0 flag is true else false TEST_EVENT_FALT_INFO, // }; virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag)=0 ; diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 9157d70..c1f1970 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -30,7 +30,7 @@ static struct Test_Map {HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY}, {HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY}, {HGPDTTOOLDB_NAME_CLARITY_QUALITY ,HGPDTTOOLDB_TITLE_CLARITY_QUALITY}, - {HGPDTTOOLDB_NAME_DISTORTION ,HGPDTTOOLDB_TITLE_DISTORTION}, + {HGPDTTOOLDB_NAME_GET_DISTORTION_VAL ,HGPDTTOOLDB_TITLE_DISTORTION}, {HGPDTTOOLDB_NAME_SEPARATER_MOTOR ,HGPDTTOOLDB_TITLE_SEPARATER_MOTOR}, {HGPDTTOOLDB_NAME_CLEAR_PAPER_PATH ,HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH}, {HGPDTTOOLDB_NAME_SKEW_DETECTION ,HGPDTTOOLDB_TITLE_SKEW_DETECTION}, @@ -121,11 +121,12 @@ int get_json_config_file() std::cout << buf << std::endl; } static std::wstring set_test_name_ =L""; +bool is_distortion_get_image = false; class test { ui_helper* helper_; int fw_; - + /*设置vid pid*/ int test_set_vidpid(void* data) { @@ -360,19 +361,19 @@ public: wcscpy(buf, L"平场校正失败, 原因--->"); } } - else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_DISTORTION) == 0) + else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0) { if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0 || strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_DISTORTION) == 0) { type = false; - wcscpy(buf, L"畸变修正失败,原因--->"); + wcscpy(buf, L"畸变修正值获取失败,原因--->"); } else { type = true; - wcscpy(buf, L"畸变修正完成:"); + wcscpy(buf, L"畸变修正值获取完成:"); } - ret = h->io_control(IO_CTRL_CODE_GET_DPI_COLOR_CHECK_VAL, &close, &closelen);//结束恢复默认 + //ret = h->io_control(IO_CTRL_CODE_GET_DPI_COLOR_CHECK_VAL, &close, &closelen);//结束恢复默认 } else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY) == 0) { @@ -471,13 +472,17 @@ public: { if ( wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0 ||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY) == 0 - //||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_DISTORTION) == 0 + ||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_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 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CLARITY_QUALITY) == 0 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST) == 0) { + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0) + { + is_distortion_get_image = true; + } h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true); } } @@ -527,7 +532,9 @@ public: test_map_[HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD] = &test::test_auto_flat_field; test_map_[HGPDTTOOLDB_NAME_REBOOT_DEVICE] = &test::test_reboot_device; test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY] = &test::test_image_quality; - test_map_[HGPDTTOOLDB_NAME_DISTORTION] = &test::test_distortion; + + 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_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; @@ -598,7 +605,73 @@ public: return ret; } + /*设置序列号*/ + int test_set_json_serial_num(void* data) + { + int ret = SCANNER_ERR_OK, + val = 0; + wchar_t* sn; + std::string set_sn,get_sn; + size_t len = 0; + parameter* prt = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_FLOAT, set_test_name_.c_str(), L"请设置序列号"); + if (!prt) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出序列号设置", false); + return -1; + } + else + { + sn = (wchar_t*)prt->get_data(); + if (!sn) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号失败", false); + return -1; + } + } + + + ret = wchar_to_char(set_sn, sn, &len); + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + if (fw_ == 3 || fw_ == 4) + { + if (len != 14) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号不足:14位", false); + return -1; + } + + } + set_sn.resize(len); + ret = wchar_to_char(set_sn, sn, &len); + } + unsigned int setlen = set_sn.size(), + getlen = 0; + + ret = helper_->io_control(IO_CTRL_CODE_SET_SERIAL, &set_sn[0], &setlen); + + if (ret != SCANNER_ERR_OK)return ret; + + ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &getlen); + if (ret == SANE_STATUS_NO_MEM) + { + ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &setlen); + } + + if (set_sn == get_sn) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号完成", true); + } + else + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号失败", true); + + } + + + return ret; + } /* 清理纸道功能确认 */ int tset_clear_paper_path(void *data) { @@ -785,15 +858,93 @@ public: { return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); } - /* 畸变修正 */ - int test_distortion(void *data) + /* 获取自动计算畸变值 */ + int test_get_auto_distortion(void *data) { - const wchar_t* NAME = set_test_name_.c_str(); + int ret = SCANNER_ERR_OK, + val = 0; SANE_Bool type = true; - unsigned int len = sizeof(SANE_Bool); - return helper_->io_control(IO_CTRL_CODE_GET_DPI_COLOR_CHECK_VAL, &type, &len); + unsigned int len = sizeof(SANE_Bool), + llen = sizeof(int); + helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_IMAGE, &type, &len); + while (1) + { + if (is_distortion_get_image) + { + ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_CHECK_VAL, &val, &llen); + break; + } + Sleep(2); + } + if (val > 0) + { + float f = *(float*)&val; + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION_VAL, (void *)&f, true); + } + else + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT,(void*)L"自动计算畸变值获取失败", false); + } + return ret; } + int test_set_auto_distortion(void* data) + { + int ret = SCANNER_ERR_OK, + val = 0; + unsigned int len = sizeof(int); + float distortion =0.0; + parameter* prt = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_FLOAT, set_test_name_.c_str(), L"请设置畸变值"); + if (!prt) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出畸变值设置", false); + return -1; + } + else + { + + void * p = prt->get_data(); + distortion = *(float*)p; + } + if (distortion == 0.0) + { + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void *)L"已退出畸变值设置", false); + return -1; + } + int setdistortion = *(int*)&distortion; + int getdistortion = 0; + ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_CHECK_VAL, &setdistortion, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_DEVS_CHECK_VAL, &getdistortion, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + wchar_t buf[128]; + if (setdistortion != getdistortion) + { + wchar_t buf[30] = L"设置畸变值失败...现在畸变值是:"; + wchar_t c[10]; + float f = *(float*)&getdistortion; + wsprintfW(c, L"%fppm", f); + wcscat(buf, c); + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, buf, false); + } + else + { + wchar_t buf[30] = L"设置畸变值成功...现在畸变值是:"; + wchar_t c[10]; + float f = *(float*)&getdistortion; + wsprintfW(c, L"%fppm", f); + wcscat(buf, c); + + helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, buf, 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 37a0875..f61309c 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -80,6 +80,8 @@ #define HGPDTTOOLDB_TITLE_PRESSUER_TEST_GRAY_300DPI L"压力测试灰色_300dpi" //////////////////////////////////////NAME////////////////////////////////////// #define WRITE_CFG_NAME L"write-cfg" +/* 设置json序列号 */ +#define HGPDTTOOLDB_NAME_SET_JSON_SN L"SET_JSON_SN" /* 拨码开关校验 */ #define HGPDTTOOLDB_NAME_DIAL_SWITCH L"DIAL_SWITCH" /* 检查船型开关功能 */ @@ -130,8 +132,10 @@ #define HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY L"COLORCARD_BIAS_IMAGEING_QUALITY" /* 清晰度质量评估 */ #define HGPDTTOOLDB_NAME_CLARITY_QUALITY L"CLARITY_QUALITY" -/* 畸变修正 */ -#define HGPDTTOOLDB_NAME_DISTORTION L"DISTORTION" +/* 获取畸变修正值 */ +#define HGPDTTOOLDB_NAME_GET_DISTORTION_VAL L"GET_DISTORTION_VAL" +/* 设置畸变修正值 */ +#define HGPDTTOOLDB_NAME_SET_DISTORTION_VAL L"SET_DISTORTION_VAL" /* 设置休眠 */ #define HGPDTTOOLDB_NAME_DORMANCY L"DORMANCY" /* 歪斜挡位检测 */