From 895ba96b4d49ebd0e65edf6c778da950c4c1d9d6 Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Wed, 28 Dec 2022 17:14:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/HGProductionTool/ui_helper.h | 1 + code/base/test_base.cpp | 128 ++++++++++++++++++++++++++----- 2 files changed, 109 insertions(+), 20 deletions(-) diff --git a/app/HGProductionTool/ui_helper.h b/app/HGProductionTool/ui_helper.h index fe253e2..03170ad 100644 --- a/app/HGProductionTool/ui_helper.h +++ b/app/HGProductionTool/ui_helper.h @@ -69,6 +69,7 @@ public: VAL_TYPE_INT, VAL_TYPE_FLOAT, VAL_TYPE_STRING, + VAL_TYPE_RANGE, VAL_TYPE_CUSTOM, // custom data, such as gamma table ... }; diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 37595cc..46f83e6 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -57,7 +57,7 @@ static std::wstring set_test_name_ =L""; class test { ui_helper* helper_; - + int fw_; public: static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param) @@ -125,10 +125,22 @@ public: } return 0; } - test(ui_helper* helper) :helper_(helper) + test(ui_helper* helper) :helper_(helper), fw_(0) { helper->register_sane_callback(sane_ex_callback, NULL); init_test_map_(); + std::string fw1(get_firmware_version()); + if (fw1.size() > 5) + { + if ("G1" == fw1.substr(0, 2)) + fw_ = 1; + else if ("G2" == fw1.substr(0, 2)) + fw_ = 2; + else if ("G3" == fw1.substr(0, 2)) + fw_ = 3; + else if ("G4" == fw1.substr(0, 2)) + fw_ = 4; + } } ~test() {} @@ -205,7 +217,17 @@ public: return ret; } public: + /*获取固件版本号*/ + std::string get_firmware_version() + { + std::string fw = ""; + unsigned int len = 0; + int ret = helper_->io_control(IO_CTRL_CODE_GET_HARDWARE_VERSION, &fw[0], &len); + fw.resize(len); + ret = helper_->io_control(IO_CTRL_CODE_GET_HARDWARE_VERSION, &fw[0], &len); + return fw; + } /* 拨码开关校验 */ int test_dial_switch(void *data) { @@ -265,14 +287,17 @@ public: SANE_Bool type = true; unsigned int len = sizeof(SANE_Bool); int num = 0; - + void* get_data = NULL; parameter * ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_INT, NAME,L"请歪斜放纸...设置阈值:1 - 5,值越小越容易检测"); if (ptr) - num = *((int*)ptr->get_data()); - if (num == -1) { - helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false); - return -1; + get_data = ptr->get_data(); + if (!get_data) + { + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false); + return -1; + } + num = *((int*)get_data); } if (num == 0) num = 1; @@ -300,16 +325,6 @@ public: /* cis原图初检 */ int test_cis__original_image(void *data) { - bool status = 0; - parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, set_test_name_.c_str(), L"请放纸,CIS原图检测,默认走纸一张"); - if (ptr) - status = *((bool*)ptr->get_data()); - if (status) - { - helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false); - return -1; - } - const wchar_t* NAME = (wchar_t*)data; SANE_Bool type = true; unsigned int len = sizeof(SANE_Bool); @@ -335,7 +350,28 @@ public: /* 超声波模块检验 */ int test_ultrasonic_module(void *data) { - return SCANNER_ERR_OK; + const wchar_t* NAME = (wchar_t*)data; + SANE_Bool type = true; + unsigned int len = sizeof(SANE_Bool); + void* get_data = NULL; + int ret = SCANNER_ERR_OK; + parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, NAME, L"请确认是否已放双张测试纸..."); + if (ptr) + { + get_data = ptr->get_data(); + if (!get_data || (*((bool*)get_data) == false)) + { + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出超声波模块检测流程", false); + return -1; + } + } + ret = helper_->io_control(IO_CTRL_CODE_SET_ULTRASONIC_MODULE, &type, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); + return ret; } /* led灯状态检查 */ int test_led_light(void *data) @@ -350,12 +386,27 @@ public: /* 走纸检查 */ int test_paper_feed(void *data) //使用单张扫描测试 { - return SCANNER_ERR_OK; + return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); } /* 开盖传感器检查 */ int test_cover_sensor(void *data) //int端点返回 使用单张扫描测试 { - return SCANNER_ERR_OK; + const wchar_t* NAME = (wchar_t*)data; + SANE_Bool type = true; + unsigned int len = sizeof(SANE_Bool); + void* get_data = NULL; + int ret = SCANNER_ERR_OK; + parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, NAME, L"请确认是否已打开扫描仪盖..."); + if (ptr) + { + get_data = ptr->get_data(); + if (!get_data || (*((bool*)get_data) == false)) + { + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出开盖传感器检测流程", false); + return -1; + } + } + return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); } /* 扫描传感器检查 */ int test_scanning_sensor(void *data) @@ -365,6 +416,43 @@ public: /* 配置速度模式 */ int test_configure_speed_mode(void *data) { + const wchar_t* NAME = (wchar_t*)data; + SANE_Bool type = true; + unsigned int len = sizeof(SANE_Bool); + int num = 0; + void* get_data = NULL; + /*parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_RANGE, + NAME, L"请设置速度模式,值越大速度越快");*/ + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_TIPS, (void*)L"请设置速度模式,值越大速度越快", true); + const wchar_t *range=L""; + const wchar_t G139[6] = { 70,80,90,110}; + const wchar_t G239[6] = { 100,110,120,130}; + const wchar_t G300[6] = { 40,50,60,70 }; + const wchar_t G400[6] = { 40,50,60,70,80}; + if (fw_ == 1 ) + range = G139; + else if(fw_ == 2) + range = G239; + else if (fw_ == 3) + range = G300; + else if (fw_ == 4) + range = G400; + + parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_RANGE, + NAME, range); + + if (ptr) + { + get_data = ptr->get_data(); + if (!get_data) + { + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false); + return -1; + } + num = *((int*)get_data); + } + + return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); return SCANNER_ERR_OK; } /* 放置校正纸 */