From 2096414e1ecec829bf38f13a7c914c2082343afc Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Fri, 23 Dec 2022 10:39:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=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 | 210 +++++++++++++++++++++++++++++----------- code/base/test_base.h | 7 +- 2 files changed, 157 insertions(+), 60 deletions(-) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 0994af6..7b8a142 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -12,61 +12,176 @@ class test ui_helper* helper_; public: test(ui_helper* helper) :helper_(helper) - {} + { + init_test_map_(); + } ~test() {} - std::map test_map_; + struct ptrcmp + { + bool operator()(const wchar_t* name1, const wchar_t* name2)const + { + return wcscmp(name1, name2) < 0; + } + }; + std::map test_map_; void init_test_map_() { - // test_map_[HGPDTTOOLDB_NAME_DIAL_SWITCH] = &test::test_dial_switch; + test_map_[HGPDTTOOLDB_NAME_DIAL_SWITCH] = &test::test_dial_switch; + test_map_[HGPDTTOOLDB_NAME_ROCKER_SWITCH] = &test::test_pocker_switch; + test_map_[HGPDTTOOLDB_NAME_BOOT_STATUS] = &test::test_boot_status; + test_map_[HGPDTTOOLDB_NAME_LCD_DISPLAY] = &test::test_lcd_display; + test_map_[HGPDTTOOLDB_NAME_CLEAR_PAPER_PATH] = &test::tset_clear_paper_path; + test_map_[HGPDTTOOLDB_NAME_KEY_FUNCTION] = &test::test_key_funtion; + test_map_[HGPDTTOOLDB_NAME_COUNTING_MODE] = &test::test_count_mode; + test_map_[HGPDTTOOLDB_NAME_SKEW_DETECTION] = &test::test_skew_detection; + test_map_[HGPDTTOOLDB_NAME_SEPARATER_MOTOR] = &test::test_separater_motor; + test_map_[HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE] = &test::test_cis__original_image; + test_map_[HGPDTTOOLDB_NAME_HOST_FAN] = &test::test_host_fan; + test_map_[HGPDTTOOLDB_NAME_ULTRASONIC_MODULE] = &test::test_ultrasonic_module; + test_map_[HGPDTTOOLDB_NAME_LED_LIGHT] = &test::test_led_light; + test_map_[HGPDTTOOLDB_NAME_RESET] = &test::test_reset; + test_map_[HGPDTTOOLDB_NAME_PAPER_FEED] = &test::test_paper_feed; + test_map_[HGPDTTOOLDB_NAME_COVER_SENSOR] = &test::test_cover_sensor; + test_map_[HGPDTTOOLDB_NAME_SCANNING_SENSOR] = &test::test_scanning_sensor; + test_map_[HGPDTTOOLDB_NAME_CONFIGURE_SPEED_MODE] = &test::test_configure_speed_mode; + test_map_[HGPDTTOOLDB_NAME_PLACE_CORRECTION_PAPER] = &test::test_place_correction_paper; + 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_COLORCARD_IMAGEING_QUALITY] = &test::test_colorcard_imageing_quality; + test_map_[HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY] = &test::test_colorcard_bias_imageing_quality; + test_map_[HGPDTTOOLDB_NAME_CLARITY_QUALITY] = &test::test_clarity_quality; + test_map_[HGPDTTOOLDB_NAME_DISTORTION] = &test::test_distortion; + test_map_[HGPDTTOOLDB_NAME_DORMANCY] = &test::test_dormancy; + test_map_[HGPDTTOOLDB_NAME_SKEW_GEAR] = &test::test_skew_gear; + 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; + test_map_[HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1] = &test::test_single_page_test_1; + test_map_[HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_2] = &test::test_single_page_test_2; + test_map_[HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_3] = &test::test_single_page_test_3; + test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST] = &test::test_pressuer_test; + test_map_[HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT] = &test::test_clear_roller_count; + } + int set_test(const wchar_t* str) + { + if (!str) + return SCANNER_ERR_NO_DATA; + + ui_helper::test_event test_ev_; + int ret = SCANNER_ERR_OK; + std::wstring s = str; + //int count = test_map_.count(str) > 0; + wchar_t* start = (wchar_t*)L"START TEST "; + wchar_t* stop = (wchar_t*)L"STOP TEST "; + wchar_t ss[10]; + wcscpy(ss,str); + /*if (!count) + { + ret = SCANNER_ERR_NO_DATA; + return ret; + }*/ + //wcscat(start,str); + //helper_->test_callback(str, ui_helper::TEST_EVENT_TIPS, start, NULL); + + auto it = test_map_.find(str); + if (it != test_map_.end()) + { + ret = (this->*test_map_[str])(); + } + else + { + return SCANNER_ERR_OK; + } + if (ret != SCANNER_ERR_OK) + { + helper_->test_callback(str, ui_helper::TEST_EVENT_TIPS, NULL, ret); + return ret; + } + + helper_->test_callback(str, ui_helper::TEST_EVENT_TIPS, stop, ret); + return ret; } public: /* 拨码开关校验 */ int test_dial_switch() { - - ui_helper::test_event ev = ui_helper::TEST_EVENT_TIPS; - int ret = helper_->io_control(IO_CTRL_CODE_BASE, NULL, NULL); - helper_->test_callback(HGPDTTOOLDB_NAME_DIAL_SWITCH, ev, NULL, ret); - return SCANNER_ERR_OK; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 检查船型开关功能 */ int test_pocker_switch() { - return SCANNER_ERR_OK; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 设备上电并观察开机状态 */ int test_boot_status() { - return SCANNER_ERR_OK; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 检查液晶显示 */ int test_lcd_display() { - return SCANNER_ERR_OK; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 清理纸道功能确认 */ int tset_clear_paper_path() { - return SCANNER_ERR_OK; + ui_helper::test_event test_ev_ = ui_helper::TEST_EVENT_RESULT; + int ret = helper_->io_control(IO_CTRL_CODE_GET_CLEAN_PAPER_ROAD, NULL, NULL); + if (ret != SCANNER_ERR_OK) + { + helper_->test_callback(HGPDTTOOLDB_NAME_DIAL_SWITCH, test_ev_, NULL, ret); + } + return ret; } /* 按键功能检测 */ int test_key_funtion() { - return SCANNER_ERR_OK; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 计数模式检测 */ int test_count_mode() { - return SCANNER_ERR_OK; + + ui_helper::test_event test_ev_= ui_helper::TEST_EVENT_RESULT; + SANE_Bool ismode = false; + unsigned int len = sizeof(SANE_Bool); + + int ret = helper_->io_control(IO_CTRL_CODE_GET_CLEAN_PAPER_ROAD, &ismode, &len); + if (ret != SCANNER_ERR_OK) + { + helper_->test_callback(HGPDTTOOLDB_NAME_DIAL_SWITCH, test_ev_, NULL, ret); + return ret; + } + + helper_->test_callback(HGPDTTOOLDB_NAME_DIAL_SWITCH, test_ev_, NULL, ismode); + return ret; } /* 歪斜检测 */ int test_skew_detection() { + + ui_helper::test_event test_ev_ = ui_helper::TEST_EVENT_RESULT; + SANE_Bool ismode = true; + unsigned int len = sizeof(SANE_Bool); + + int ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK, &ismode, &len); + if (ret != SCANNER_ERR_OK) + { + helper_->test_callback(HGPDTTOOLDB_NAME_SKEW_DETECTION, test_ev_, NULL, ret); + return ret; + } + int i = 5; + ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK_VAL, &i, &len); + ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); + + + helper_->test_callback(HGPDTTOOLDB_NAME_SKEW_DETECTION, test_ev_, NULL, ismode); + return ret; return SCANNER_ERR_OK; } /* 分纸电机检测 */ @@ -132,62 +247,77 @@ public: /* 重启设备 */ int test_reboot_device() { + return SCANNER_ERR_OK; } /* 扫描图像质量确认 */ int test_image_quality() { + return SCANNER_ERR_OK; } /* 色卡纸成像质量评估 */ int test_colorcard_imageing_quality() { + return SCANNER_ERR_OK; } /* 色卡纸偏色成像质量评估 */ int test_colorcard_bias_imageing_quality() { + return SCANNER_ERR_OK; } /* 清晰度质量评估 */ int test_clarity_quality() { + return SCANNER_ERR_OK; } /* 畸变修正 */ int test_distortion() { + return SCANNER_ERR_OK; } /* 设置休眠 */ int test_dormancy() { + return SCANNER_ERR_OK; } /* 歪斜挡位检测 */ int test_skew_gear() { + return SCANNER_ERR_OK; } /* 分纸强度检测 */ int test_paper_separation_strength() { + return SCANNER_ERR_OK; } /* 机械走纸倾斜检测 */ int test_mech_paper_feeding_inclination() { + return SCANNER_ERR_OK; } /* 单张测试1 */ int test_single_page_test_1() { + return SCANNER_ERR_OK; } /* 单张测试2 */ int test_single_page_test_2() { + return SCANNER_ERR_OK; } /* 单张测试3 */ int test_single_page_test_3() { + return SCANNER_ERR_OK; } /* 压力测试2轮 */ int test_pressuer_test() { + return SCANNER_ERR_OK; } /* 清除滚轴计数 */ int test_clear_roller_count() { + return SCANNER_ERR_OK; } private: @@ -197,7 +327,7 @@ private: //test static std::string jsontext1("{\"1\":{\"name\":\"test-8\",\"ver\":1}}"); -std::string str_ret_call_= ""; +std::string ret_call_= ""; bool have_img_ = false; int sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param) { @@ -205,22 +335,22 @@ int sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, { case SANE_EVENT_WORKING: { - str_ret_call_ = (char*)data; + ret_call_ = (char*)data; } break; case SANE_EVENT_SCAN_FINISHED: { - str_ret_call_ = (char*)data; + ret_call_ = (char*)data; } break; case SANE_EVENT_STATUS: { - str_ret_call_ = (char*)data; + ret_call_ = (char*)data; } break; case SANE_EVENT_ERROR: { - str_ret_call_ = (char*)data; + ret_call_ = (char*)data; } break; case SANE_EVENT_IMAGE_OK: @@ -295,46 +425,12 @@ DECL_API(int) func_test_go(const wchar_t* name, const wchar_t* oper, ui_helper* //helper->add_ref(); helper->register_sane_callback(sane_ex_callback1, NULL); - bool flag = false; - wchar_t* des = NULL; int ret = 0; - size_t map_bool_len = sizeof(Test_Map_Bool) / sizeof(Test_Map_Bool[0]); - size_t map_str_len = sizeof(Test_Map_String) / sizeof(Test_Map_String[0]); - size_t map_int_len = sizeof(Test_Map_Int) / sizeof(Test_Map_Int[0]); - ui_helper::test_event ev = ui_helper::TEST_EVENT_TIPS; //项目测试设置TEST_EVENT_TIPS,测试结果设置TEST_EVENT_RESULT - - for (size_t i = 0; i < map_bool_len; i++) - { - des = (wchar_t*)Test_Map_Bool[i].title; - if (wcscmp(name, Test_Map_Bool[i].name) == 0) //理论上手动处理的事项是不会传下来 - { - SANE_Bool map_bool = true; - unsigned int len = sizeof(SANE_Bool); - ret = helper->io_control(Test_Map_Bool[i].num,(void *)&map_bool, &len); - ev = ui_helper::TEST_EVENT_RESULT; - helper->test_callback(Test_Map_Bool[i].name, ev, NULL, ret); + test ts(helper); + ret = ts.set_test(name); - return SCANNER_ERR_OK; - } - /*else if(wcscmp(name, Test_Map_String[i].name) == 0) - { - - return SCANNER_ERR_OK; - } - else if (wcscmp(name, Test_Map_Int[i].name) == 0) - { - return SCANNER_ERR_OK; - }*/ - } - ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL); - //helper->release(); - //helper->unregister_sane_callback(sane_ex_callback); - if (!helper) - { - return SCANNER_ERR_NO_DATA; - } - //test ts(helper); - return SCANNER_ERR_OK; + ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认 + return ret; } DECL_API(int) func_test_uninit(void* uninit) { diff --git a/code/base/test_base.h b/code/base/test_base.h index 81f3510..4ee8ad0 100644 --- a/code/base/test_base.h +++ b/code/base/test_base.h @@ -13,13 +13,13 @@ /* 妫鏌ユ恫鏅舵樉绀 */ #define HGPDTTOOLDB_TITLE_LCD_DISPLAY L"妫鏌ユ恫鏅舵樉绀" /* 娓呯悊绾搁亾鍔熻兘纭 */ -#define HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH L"娓呯悊绾搁亾鍔熻兘纭" +#define HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH L"娓呯悊绾搁亾鍔熻兘纭" //1 /* 鎸夐敭鍔熻兘妫娴 */ #define HGPDTTOOLDB_TITLE_KEY_FUNCTION L"鎸夐敭鍔熻兘妫娴" /* 璁℃暟妯″紡妫娴 */ -#define HGPDTTOOLDB_TITLE_COUNTING_MODE L"璁℃暟妯″紡妫娴" +#define HGPDTTOOLDB_TITLE_COUNTING_MODE L"璁℃暟妯″紡妫娴"//1 /* 姝枩妫娴 */ -#define HGPDTTOOLDB_TITLE_SKEW_DETECTION L"姝枩妫娴" +#define HGPDTTOOLDB_TITLE_SKEW_DETECTION L"姝枩妫娴"//1 /* 鍒嗙焊鐢垫満妫娴 */ #define HGPDTTOOLDB_TITLE_SEPARATER_MOTOR L"鍒嗙焊鐢垫満妫娴" /* CIS鍘熷浘鍒濇 */ @@ -146,6 +146,7 @@ #define HGPDTTOOLDB_NAME_PRESSUER_TEST L"test-34" /* 娓呴櫎婊氳酱璁℃暟 */ #define HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT L"test-35" + static struct Test_Map { const wchar_t* name; //test-1