From c0ce0718e95c216927fd8d3c461f3d514250b00e Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Tue, 27 Dec 2022 16:26:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/base/test_base.cpp | 254 +++++++++++++++++++++++----------------- 1 file changed, 148 insertions(+), 106 deletions(-) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 6a0be82..23a3b64 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -89,7 +89,7 @@ public: return -1; } - if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_TITLE_SKEW_DETECTION) == 0) + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0) { type = strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_PAPER_SKEW) == 0 ? true : false; } @@ -109,8 +109,17 @@ public: break; case SANE_EVENT_IMAGE_OK: { - //SANE_Image* sane_img = (SANE_Image*)data; - //have_img_ = true; + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0 || + wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY) == 0) + { + if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0) + { + SANE_Bool type = false; + unsigned int len = sizeof(SANE_Bool); + h->io_control(IO_CTRL_CODE_SET_CIS_IMAGE, &type, &len); //使用完恢复默认 + } + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true); + } } break; } @@ -126,65 +135,68 @@ public: struct ptrcmp { - bool operator()(const wchar_t* TITLE1, const wchar_t* TITLE2)const + bool operator()(const wchar_t* NAME1, const wchar_t* NAME2)const { - return wcscmp(TITLE1, TITLE2) < 0; + return wcscmp(NAME1, NAME2) < 0; } }; - std::map test_map_; + std::map test_map_; void init_test_map_() { - test_map_[HGPDTTOOLDB_TITLE_DIAL_SWITCH] = &test::test_dial_switch; - test_map_[HGPDTTOOLDB_TITLE_ROCKER_SWITCH] = &test::test_pocker_switch; - test_map_[HGPDTTOOLDB_TITLE_BOOT_STATUS] = &test::test_boot_status; - test_map_[HGPDTTOOLDB_TITLE_LCD_DISPLAY] = &test::test_lcd_display; - test_map_[HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH] = &test::tset_clear_paper_path; - test_map_[HGPDTTOOLDB_TITLE_KEY_FUNCTION] = &test::test_key_funtion; - test_map_[HGPDTTOOLDB_TITLE_COUNTING_MODE] = &test::test_count_mode; - test_map_[HGPDTTOOLDB_TITLE_SKEW_DETECTION] = &test::test_skew_detection; - test_map_[HGPDTTOOLDB_TITLE_SEPARATER_MOTOR] = &test::test_separater_motor; - test_map_[HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE] = &test::test_cis__original_image; - test_map_[HGPDTTOOLDB_TITLE_HOST_FAN] = &test::test_host_fan; - test_map_[HGPDTTOOLDB_TITLE_ULTRASONIC_MODULE] = &test::test_ultrasonic_module; - test_map_[HGPDTTOOLDB_TITLE_LED_LIGHT] = &test::test_led_light; - test_map_[HGPDTTOOLDB_TITLE_RESET] = &test::test_reset; - test_map_[HGPDTTOOLDB_TITLE_PAPER_FEED] = &test::test_paper_feed; - test_map_[HGPDTTOOLDB_TITLE_COVER_SENSOR] = &test::test_cover_sensor; - test_map_[HGPDTTOOLDB_TITLE_SCANNING_SENSOR] = &test::test_scanning_sensor; - test_map_[HGPDTTOOLDB_TITLE_CONFIGURE_SPEED_MODE] = &test::test_configure_speed_mode; - test_map_[HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER] = &test::test_place_correction_paper; - test_map_[HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD] = &test::test_auto_flat_field; - test_map_[HGPDTTOOLDB_TITLE_REBOOT_DEVICE] = &test::test_reboot_device; - test_map_[HGPDTTOOLDB_TITLE_IMAGE_QUALITY] = &test::test_image_quality; - test_map_[HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY] = &test::test_colorcard_imageing_quality; - test_map_[HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY] = &test::test_colorcard_bias_imageing_quality; - test_map_[HGPDTTOOLDB_TITLE_CLARITY_QUALITY] = &test::test_clarity_quality; - test_map_[HGPDTTOOLDB_TITLE_DISTORTION] = &test::test_distortion; - test_map_[HGPDTTOOLDB_TITLE_DORMANCY] = &test::test_dormancy; - test_map_[HGPDTTOOLDB_TITLE_SKEW_GEAR] = &test::test_skew_gear; - test_map_[HGPDTTOOLDB_TITLE_PAPER_SEPARATION_STRENGTH] = &test::test_paper_separation_strength; - test_map_[HGPDTTOOLDB_TITLE_MECH_PAPER_FEEDING_INCLINATION] = &test::test_mech_paper_feeding_inclination; - test_map_[HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_1] = &test::test_single_page_test_1; - test_map_[HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_2] = &test::test_single_page_test_2; - test_map_[HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_3] = &test::test_single_page_test_3; - test_map_[HGPDTTOOLDB_TITLE_PRESSUER_TEST] = &test::test_pressuer_test; - test_map_[HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT] = &test::test_clear_roller_count; + 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; set_test_name_ = str; int ret = SCANNER_ERR_OK; auto it = test_map_.find(str); + if (it != test_map_.end()) { - ret = (this->*test_map_[str])(); + ret = (this->*test_map_[str])((void *)str); } else { helper_->test_callback(str, ui_helper::TEST_EVENT_NOT_FIND_TEST, NULL, false); + return ret; } if (ret != SCANNER_ERR_OK) { @@ -195,212 +207,242 @@ public: public: /* 拨码开关校验 */ - int test_dial_switch() + int test_dial_switch(void *data) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 检查船型开关功能 */ - int test_pocker_switch() + int test_pocker_switch(void *data) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 设备上电并观察开机状态 */ - int test_boot_status() + int test_boot_status(void *data) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 检查液晶显示 */ - int test_lcd_display() + int test_lcd_display(void *data) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 清理纸道功能确认 */ - int tset_clear_paper_path() + int tset_clear_paper_path(void *data) { int ret = helper_->io_control(IO_CTRL_CODE_GET_CLEAN_PAPER_ROAD, NULL, NULL); if (ret != SCANNER_ERR_OK) { return ret; } - helper_->test_callback(HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH, ui_helper::TEST_EVENT_RESULT, NULL, true); + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认是否清理纸道成功", true); return ret; } /* 按键功能检测 */ - int test_key_funtion() + int test_key_funtion(void *data) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } /* 计数模式检测 */ - int test_count_mode() + int test_count_mode(void *data) { - - 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_IS_MODE, &ismode, &len); if (ret != SCANNER_ERR_OK) { - helper_->test_callback(HGPDTTOOLDB_TITLE_COUNTING_MODE, test_ev_, NULL, ret); return ret; } - - helper_->test_callback(HGPDTTOOLDB_TITLE_COUNTING_MODE, test_ev_, NULL, ismode); + helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认与液晶面板是否匹配", ismode); return ret; } /* 歪斜检测 */ - int test_skew_detection() + int test_skew_detection(void *data) { + const wchar_t* NAME = (wchar_t*)data; SANE_Bool type = true; unsigned int len = sizeof(SANE_Bool); - int checknum = 1; + int num = 0; + parameter * ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_INT, NAME,L"请设置阈值:1-5。默认:1"); + if (ptr) + num = *((int*)ptr->get_data()); + + if (num == 0) + num = 1; int ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK, &type, &len); if (ret != SCANNER_ERR_OK) + { return ret; - ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK_VAL, &checknum, &len); + } + + ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK_VAL, &num, &len); if (ret != SCANNER_ERR_OK) + { return ret; + } ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); - if (ret != SCANNER_ERR_OK) - return ret; return ret; } /* 分纸电机检测 */ - int test_separater_motor() + int test_separater_motor(void *data) { return SCANNER_ERR_OK; } /* cis原图初检 */ - int test_cis__original_image() + int test_cis__original_image(void *data) { - return SCANNER_ERR_OK; + const wchar_t* NAME = (wchar_t*)data; + SANE_Bool type = true; + unsigned int len = sizeof(SANE_Bool); + int ret = SCANNER_ERR_OK; + + ret = helper_->io_control(IO_CTRL_CODE_SET_CIS_IMAGE, &type, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + return ret; } /* 主机风扇功能检测 */ - int test_host_fan() + int test_host_fan(void *data) { return SCANNER_ERR_OK; } /* 超声波模块检验 */ - int test_ultrasonic_module() + int test_ultrasonic_module(void *data) { return SCANNER_ERR_OK; } /* led灯状态检查 */ - int test_led_light() + int test_led_light(void *data) { return SCANNER_ERR_OK; } /* 复位检查 */ - int test_reset() + int test_reset(void *data) { return SCANNER_ERR_OK; } /* 走纸检查 */ - int test_paper_feed() //使用单张扫描测试 + int test_paper_feed(void *data) //使用单张扫描测试 { return SCANNER_ERR_OK; } /* 开盖传感器检查 */ - int test_cover_sensor() //int端点返回 使用单张扫描测试 + int test_cover_sensor(void *data) //int端点返回 使用单张扫描测试 { return SCANNER_ERR_OK; } /* 扫描传感器检查 */ - int test_scanning_sensor() + int test_scanning_sensor(void *data) { return SCANNER_ERR_OK; } /* 配置速度模式 */ - int test_configure_speed_mode() + int test_configure_speed_mode(void *data) { return SCANNER_ERR_OK; } /* 放置校正纸 */ - int test_place_correction_paper() + int test_place_correction_paper(void *data) { return SCANNER_ERR_OK; } /* 自动平场校正 */ - int test_auto_flat_field() + int test_auto_flat_field(void *data) { return SCANNER_ERR_OK; } /* 重启设备 */ - int test_reboot_device() + int test_reboot_device(void *data) { return SCANNER_ERR_OK; } /* 扫描图像质量确认 */ - int test_image_quality() + int test_image_quality(void *data) { - return SCANNER_ERR_OK; + const wchar_t* NAME = (wchar_t*)data; + SANE_Bool type = false; + unsigned int len = sizeof(SANE_Bool); + int ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK, &type, &len); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + ret = helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL); + return ret; } /* 色卡纸成像质量评估 */ - int test_colorcard_imageing_quality() + int test_colorcard_imageing_quality(void *data) { return SCANNER_ERR_OK; } /* 色卡纸偏色成像质量评估 */ - int test_colorcard_bias_imageing_quality() + int test_colorcard_bias_imageing_quality(void *data) { return SCANNER_ERR_OK; } /* 清晰度质量评估 */ - int test_clarity_quality() + int test_clarity_quality(void *data) { return SCANNER_ERR_OK; } /* 畸变修正 */ - int test_distortion() + int test_distortion(void *data) { return SCANNER_ERR_OK; } /* 设置休眠 */ - int test_dormancy() + int test_dormancy(void *data) { return SCANNER_ERR_OK; } /* 歪斜挡位检测 */ - int test_skew_gear() + int test_skew_gear(void *data) { return SCANNER_ERR_OK; } /* 分纸强度检测 */ - int test_paper_separation_strength() + int test_paper_separation_strength(void *data) { return SCANNER_ERR_OK; } /* 机械走纸倾斜检测 */ - int test_mech_paper_feeding_inclination() + int test_mech_paper_feeding_inclination(void *data) { return SCANNER_ERR_OK; } /* 单张测试1 */ - int test_single_page_test_1() + int test_single_page_test_1(void *data) { return SCANNER_ERR_OK; } /* 单张测试2 */ - int test_single_page_test_2() + int test_single_page_test_2(void *data) { return SCANNER_ERR_OK; } /* 单张测试3 */ - int test_single_page_test_3() + int test_single_page_test_3(void *data) { return SCANNER_ERR_OK; } /* 压力测试2轮 */ - int test_pressuer_test() + int test_pressuer_test(void *data) { return SCANNER_ERR_OK; } /* 清除滚轴计数 */ - int test_clear_roller_count() + int test_clear_roller_count(void *data) { return SCANNER_ERR_OK; } @@ -410,39 +452,39 @@ private: //test -static std::string jsontext1("{\"1\":{\"TITLE\":\"test-8\",\"ver\":1}}"); +static std::string jsontext1("{\"1\":{\"NAME\":\"test-8\",\"ver\":1}}"); bool have_img_ = false; -#define TEST_PTR(ptr) ((test*)ptr) -DECL_API(int) func_test_init(void** hanld, ui_helper* helper) + +DECL_API(int) func_test_init(void* init) { - if (helper) - { - test* ts = new test(helper); - *hanld = (void*)ts; - } return 0; } DECL_API(int) func_test_get_list(wchar_t* buf, size_t* len) { return str_to_wchar(jsontext1, buf, len); } -DECL_API(int) func_test_go(void* hanld, const wchar_t* TITLE, const wchar_t* oper) +DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper, ui_helper* helper) { - if (!TITLE || !oper) + if (!NAME || !oper || !helper) { return -1; } - //helper->add_ref(); + //helper->add_ref(void *data); - int ret = TEST_PTR(hanld)->set_test(TITLE); + int ret = 0; + SANE_Bool type = false; + unsigned int len = sizeof(SANE_Bool); + test ts(helper); + ret = ts.set_test(NAME); + if (ret != SCANNER_ERR_OK) + { + return ret; + } + ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认 return ret; } -DECL_API(int) func_test_uninit(void* hanld) +DECL_API(int) func_test_uninit(void* uninit) { - if (hanld) - { - delete TEST_PTR(hanld); - } return 0; } \ No newline at end of file From 885edff104d4861e374ed5378722c33ca19cd108 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Tue, 27 Dec 2022 16:30:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/HGPdtToolDb/HGPdtToolDbImpl.cpp | 2 +- db/HGPdtToolDbTest/HGPdtToolDbTest.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/HGPdtToolDb/HGPdtToolDbImpl.cpp b/db/HGPdtToolDb/HGPdtToolDbImpl.cpp index 4d45f44..f22bcb4 100644 --- a/db/HGPdtToolDb/HGPdtToolDbImpl.cpp +++ b/db/HGPdtToolDb/HGPdtToolDbImpl.cpp @@ -1837,7 +1837,7 @@ HGResult HGPdtToolDbDeviceImpl::UploadFile(const HGChar* host, HGUShort port, co CURLcode res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) - fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); + HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "curl_easy_perform() failed: %s", curl_easy_strerror(res)); else ret = HGBASE_ERR_OK; diff --git a/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp b/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp index a6772ca..ee3f809 100644 --- a/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp +++ b/db/HGPdtToolDbTest/HGPdtToolDbTest.cpp @@ -12,9 +12,9 @@ int main() //HGPdtToolDb_DownloadFile(userMgr, "G100", "D:\\123.txt"); HGPdtToolDbDevice device = NULL; - HGPdtToolDb_OpenDevice(userMgr, "G123456", &device); - HGPdtToolDb_UploadDeviceEntryImage(device, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY, "127.0.0.1", 21, "D:\\1.jpg"); - HGPdtToolDb_DownloadDeviceEntryImage(device, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY, "127.0.0.1", 21, "D:\\22.jpg"); + HGPdtToolDb_OpenDevice(userMgr, "G654321", &device); + HGPdtToolDb_UploadDeviceEntryImage(device, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY, "192.168.1.70", 21, "D:\\1.jpg"); + HGPdtToolDb_DownloadDeviceEntryImage(device, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY, "192.168.1.70", 21, "D:\\22.jpg"); //HGPdtToolDb_CloseDevice(device); HGPdtToolDb_Export(userMgr, "D:\\1.xls");