code_production/code/base/test_base.cpp

642 lines
17 KiB
C++
Raw Normal View History

2022-12-08 10:10:19 +00:00
#include"test_base.h"
#include<string>
#include <stdio.h>
#include <windows.h>
#include <map>
#include <iostream>
2022-12-14 06:58:06 +00:00
#include "huagao/hgscanner_error.h"
2022-12-08 10:10:19 +00:00
2022-12-15 11:53:41 +00:00
2022-12-26 09:18:25 +00:00
static int str_to_wchar(std::string str, wchar_t* s, size_t* strlen)
{
if (str.empty())
return ERROR_INSUFFICIENT_BUFFER;
size_t size = str.length();
int len = 0;
len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
if (*strlen < len)
{
*strlen = len;
return ERROR_INSUFFICIENT_BUFFER;
}
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, s, len);
return 0;
}
int get_json_config_file()
{
int len = 0;
char exePath[256];
char* buf = NULL;
GetModuleFileNameA(NULL, exePath, 255);
(strrchr(exePath, '\\'))[1] = 0; //ȥ<><C8A5>ִ<EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
strcat(exePath, "DLLs\\G302.hsc");
FILE* fp = fopen(exePath, "rb");
if (fp == NULL)
{
return -1;
}
fseek(fp, 0, SEEK_END);
len = ftell(fp);
fseek(fp, 0, SEEK_SET);
buf = new char[len];
if (!buf)
{
fclose(fp);
return -1;
}
memset(buf, 0, len);
fread(buf, len, 1, fp);
fclose(fp);
std::cout << buf << std::endl;
}
2022-12-28 02:21:16 +00:00
static std::wstring set_test_name_ =L"";
2022-12-15 11:53:41 +00:00
class test
2022-12-08 10:10:19 +00:00
{
2022-12-15 11:53:41 +00:00
ui_helper* helper_;
2022-12-28 09:14:23 +00:00
int fw_;
2022-12-15 11:53:41 +00:00
public:
2022-12-26 09:18:25 +00:00
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
{
if (!hdev && !param)
{
return -1;
}
ui_helper* h= (ui_helper*)param;
2022-12-28 02:21:16 +00:00
std::wstring wstr = L"";
size_t l = 0;
bool type = true;
int ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
if (ret == ERROR_INSUFFICIENT_BUFFER)
ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2022-12-26 09:18:25 +00:00
{
2022-12-28 02:21:16 +00:00
type = false;
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type);
return -1;
2022-12-26 09:18:25 +00:00
}
2022-12-28 02:21:16 +00:00
switch (code)
{
2022-12-26 09:18:25 +00:00
case SANE_EVENT_SCAN_FINISHED:
{
2022-12-28 02:21:16 +00:00
SANE_Bool io_type = false;
unsigned int io_len = sizeof(SANE_Bool);
2022-12-27 08:26:41 +00:00
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0)
2022-12-26 09:18:25 +00:00
{
type = strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_PAPER_SKEW) == 0 ? true : false;
}
2022-12-28 02:21:16 +00:00
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0)
{
h->io_control(IO_CTRL_CODE_SET_CIS_IMAGE, &io_type, &io_len);
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_DISTORTION) == 0)
{
int ret = h->io_control(IO_CTRL_CODE_GET_DPI_COLOR_CHECK_VAL, &io_type, &io_len);
2022-12-28 04:04:50 +00:00
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) == 0)
2022-12-28 02:21:16 +00:00
{
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION, (void*)L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>е<EFBFBD>ҳɨ<D2B3><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", type);
return 0;
}
}
2022-12-26 09:18:25 +00:00
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type);
}
break;
case SANE_EVENT_ERROR:
{
2022-12-28 02:21:16 +00:00
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), false);
2022-12-26 09:18:25 +00:00
}
break;
case SANE_EVENT_IMAGE_OK:
{
2022-12-28 02:21:16 +00:00
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)
2022-12-27 08:26:41 +00:00
{
2022-12-28 02:21:16 +00:00
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true);
2022-12-27 08:26:41 +00:00
}
2022-12-26 09:18:25 +00:00
}
break;
}
return 0;
}
2022-12-28 09:14:23 +00:00
test(ui_helper* helper) :helper_(helper), fw_(0)
2022-12-23 02:39:07 +00:00
{
2022-12-26 09:18:25 +00:00
helper->register_sane_callback(sane_ex_callback, NULL);
2022-12-23 02:39:07 +00:00
init_test_map_();
2022-12-28 09:14:23 +00:00
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;
}
2022-12-23 02:39:07 +00:00
}
2022-12-15 11:53:41 +00:00
~test()
{}
2022-12-23 02:39:07 +00:00
struct ptrcmp
{
2022-12-27 08:26:41 +00:00
bool operator()(const wchar_t* NAME1, const wchar_t* NAME2)const
2022-12-23 02:39:07 +00:00
{
2022-12-27 08:26:41 +00:00
return wcscmp(NAME1, NAME2) < 0;
2022-12-23 02:39:07 +00:00
}
};
2022-12-27 08:26:41 +00:00
std::map<std::wstring, int(test::*)(void *)> test_map_;
2022-12-15 11:53:41 +00:00
void init_test_map_()
{
2022-12-27 08:26:41 +00:00
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;
2022-12-23 02:39:07 +00:00
}
int set_test(const wchar_t* str)
{
2022-12-27 08:26:41 +00:00
2022-12-23 02:39:07 +00:00
if (!str)
return SCANNER_ERR_NO_DATA;
2022-12-26 09:18:25 +00:00
set_test_name_ = str;
2022-12-23 02:39:07 +00:00
int ret = SCANNER_ERR_OK;
auto it = test_map_.find(str);
2022-12-27 08:26:41 +00:00
2022-12-23 02:39:07 +00:00
if (it != test_map_.end())
{
2022-12-27 08:26:41 +00:00
ret = (this->*test_map_[str])((void *)str);
2022-12-23 02:39:07 +00:00
}
else
{
2022-12-26 09:18:25 +00:00
helper_->test_callback(str, ui_helper::TEST_EVENT_NOT_FIND_TEST, NULL, false);
2022-12-27 08:26:41 +00:00
return ret;
2022-12-23 02:39:07 +00:00
}
if (ret != SCANNER_ERR_OK)
{
2022-12-26 09:18:25 +00:00
helper_->test_callback(str, ui_helper::TEST_EVENT_IO_FAIL, NULL, ret);
2022-12-23 02:39:07 +00:00
}
return ret;
2022-12-15 11:53:41 +00:00
}
public:
2022-12-28 09:14:23 +00:00
/*<2A><>ȡ<EFBFBD>̼<EFBFBD><CCBC><EFBFBD><E6B1BE>*/
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);
2022-12-15 11:53:41 +00:00
2022-12-28 09:14:23 +00:00
return fw;
}
2022-12-15 11:53:41 +00:00
/* <20><><EFBFBD><EFBFBD><EBBFAA>У<EFBFBD><D0A3> */
2022-12-27 08:26:41 +00:00
int test_dial_switch(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF>ع<EFBFBD><D8B9><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_pocker_switch(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
/* <20><EFBFBD>ϵ粢<CFB5>۲쿪<DBB2><ECBFAA>״̬ */
2022-12-27 08:26:41 +00:00
int test_boot_status(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD>ʾ */
2022-12-27 08:26:41 +00:00
int test_lcd_display(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> */
2022-12-27 08:26:41 +00:00
int tset_clear_paper_path(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
int ret = helper_->io_control(IO_CTRL_CODE_GET_CLEAN_PAPER_ROAD, NULL, NULL);
if (ret != SCANNER_ERR_OK)
{
2022-12-26 09:18:25 +00:00
return ret;
2022-12-23 02:39:07 +00:00
}
2022-12-27 08:26:41 +00:00
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", true);
2022-12-23 02:39:07 +00:00
return ret;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_key_funtion(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_count_mode(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
SANE_Bool ismode = false;
unsigned int len = sizeof(SANE_Bool);
2022-12-26 09:18:25 +00:00
int ret = helper_->io_control(IO_CTRL_CODE_GET_IS_MODE, &ismode, &len);
2022-12-23 02:39:07 +00:00
if (ret != SCANNER_ERR_OK)
{
return ret;
}
2022-12-27 08:26:41 +00:00
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ƥ<EFBFBD><EFBFBD>", ismode);
2022-12-23 02:39:07 +00:00
return ret;
2022-12-15 11:53:41 +00:00
}
/* <20><>б<EFBFBD><D0B1><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_skew_detection(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-27 08:26:41 +00:00
const wchar_t* NAME = (wchar_t*)data;
2022-12-26 09:18:25 +00:00
SANE_Bool type = true;
2022-12-23 02:39:07 +00:00
unsigned int len = sizeof(SANE_Bool);
2022-12-27 08:26:41 +00:00
int num = 0;
2022-12-28 09:14:23 +00:00
void* get_data = NULL;
2022-12-29 03:22:22 +00:00
parameter * ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_INT, NAME,L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD>ֽ...<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0 - 5,ֵԽСԽ<D0A1><D4BD><EFBFBD>׼<EFBFBD><D7BC><EFBFBD>,0Ϊ<30>ر<EFBFBD><D8B1><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>");
2022-12-27 08:26:41 +00:00
if (ptr)
2022-12-28 04:04:50 +00:00
{
2022-12-28 09:14:23 +00:00
get_data = ptr->get_data();
if (!get_data)
{
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
return -1;
}
num = *((int*)get_data);
2022-12-28 04:04:50 +00:00
}
2022-12-29 03:22:22 +00:00
else
2022-12-27 08:26:41 +00:00
{
2022-12-29 03:22:22 +00:00
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
return -1;
2022-12-27 08:26:41 +00:00
}
2022-12-29 03:22:22 +00:00
type = num == 0 ? false:true;
ptr->release();
int ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK, &type, &len);
if (ret != SCANNER_ERR_OK)return ret;
2022-12-27 08:26:41 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK_VAL, &num, &len);
2022-12-29 03:22:22 +00:00
if (ret != SCANNER_ERR_OK)return ret;
2022-12-23 02:39:07 +00:00
2022-12-29 03:22:22 +00:00
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
2022-12-23 02:39:07 +00:00
return ret;
2022-12-15 11:53:41 +00:00
}
/* <20><>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_separater_motor(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* cisԭͼ<D4AD><CDBC><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_cis__original_image(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-27 08:26:41 +00:00
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;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><C8B9>ܼ<EFBFBD><DCBC><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_host_fan(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_ultrasonic_module(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-28 09:14:23 +00:00
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;
2022-12-29 03:22:22 +00:00
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, NAME,
L"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD><EFBFBD>ֽ");
2022-12-28 09:14:23 +00:00
if (ptr)
{
get_data = ptr->get_data();
2022-12-29 03:22:22 +00:00
if (!get_data)
2022-12-28 09:14:23 +00:00
{
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
return -1;
}
2022-12-29 03:22:22 +00:00
else
type = *((bool*)get_data);
2022-12-28 09:14:23 +00:00
}
2022-12-29 03:22:22 +00:00
else
{
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", false);
return -1;
}
ptr->release();
2022-12-28 09:14:23 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_ULTRASONIC_MODULE, &type, &len);
2022-12-29 03:22:22 +00:00
2022-12-28 09:14:23 +00:00
if (ret != SCANNER_ERR_OK)
{
return ret;
}
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
return ret;
2022-12-15 11:53:41 +00:00
}
/* led<65><64>״̬<D7B4><CCAC><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_led_light(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_reset(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20><>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_paper_feed(void *data) //ʹ<>õ<EFBFBD><C3B5><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-12-15 11:53:41 +00:00
{
2022-12-28 09:14:23 +00:00
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-29 03:22:22 +00:00
int test_cover_sensor(void *data) //<2F>˵㷵<CBB5><E3B7B5> ʹ<>õ<EFBFBD><C3B5><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-12-15 11:53:41 +00:00
{
2022-12-28 09:14:23 +00:00
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
2022-12-15 11:53:41 +00:00
}
/* ɨ<><EFBFBD><E8B4AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_scanning_sensor(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽ */
2022-12-27 08:26:41 +00:00
int test_configure_speed_mode(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-28 09:14:23 +00:00
const wchar_t* NAME = (wchar_t*)data;
2022-12-29 02:11:18 +00:00
unsigned int len = sizeof(int);
2022-12-28 13:04:11 +00:00
int speed_mode = 0;
2022-12-28 09:14:23 +00:00
void* get_data = NULL;
2022-12-29 02:11:18 +00:00
bool type = false;
ui_helper::_INFOTIPS info_;
2022-12-28 09:14:23 +00:00
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};
2022-12-28 11:46:48 +00:00
wchar_t info[128] = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽ,ֵԽ<D6B5><D4BD><EFBFBD>ٶ<EFBFBD>Խ<EFBFBD><D4BD>.";
2022-12-29 02:11:18 +00:00
info_.info = info;
if (fw_ == 1)info_.desc = G139;
else if(fw_ == 2)info_.desc = G239;
else if(fw_ == 3)info_.desc = G300;
2022-12-29 02:20:27 +00:00
else if(fw_ == 4)info_.desc = G400;
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_TIPS_VAL,NAME, (wchar_t *) &info_);
2022-12-28 09:14:23 +00:00
if (ptr)
{
get_data = ptr->get_data();
if (!get_data)
{
2022-12-29 02:11:18 +00:00
type = false;
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD>ٶ<EFBFBD>ģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>...", type);
2022-12-28 09:14:23 +00:00
return -1;
}
2022-12-28 13:04:11 +00:00
speed_mode = *((int*)get_data);
2022-12-29 02:11:18 +00:00
if (fw_ == 3 || fw_ == 4 && speed_mode >= 40 && speed_mode <= 80) //3288<38><38><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽΪ1 2 3 4 5
{
if (speed_mode == 40)speed_mode = 1;
else if (speed_mode == 50)speed_mode = 2;
else if (speed_mode == 60)speed_mode = 3;
else if (speed_mode == 70)speed_mode = 4;
else if (speed_mode == 80)speed_mode = 5;
else speed_mode = 1;
}
2022-12-28 09:14:23 +00:00
}
2022-12-28 11:46:48 +00:00
else
{
2022-12-29 02:11:18 +00:00
type = false;
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)L"<EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>---><3E><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽ...", type);
2022-12-28 11:46:48 +00:00
return -1;
}
2022-12-29 03:22:22 +00:00
ptr->release();
2022-12-28 13:04:11 +00:00
int ret = helper_->io_control(IO_CTRL_CODE_SET_SPEED_MODE, &speed_mode, &len);
if (ret != SCANNER_ERR_OK)
{
return ret;
}
SANE_Int num = 0;
unsigned int l = sizeof(SANE_Int);
ret = helper_->io_control(IO_CTRL_CODE_GET_SPEED_MODE, &num, &l);
2022-12-29 02:11:18 +00:00
int save_num = 0;
2022-12-29 03:37:16 +00:00
2022-12-29 02:11:18 +00:00
if (fw_ == 3 || fw_ == 4 && num > 0 && num < 6)
{
if (num == 1)save_num = 40;
else if (num == 2)save_num = 50;
else if (num == 3)save_num = 60;
else if (num == 4)save_num = 70;
else if (num == 5)save_num = 80;
}
else
save_num = num;
2022-12-29 03:37:16 +00:00
wchar_t* infocat = NULL;
2022-12-28 13:04:11 +00:00
if (num != speed_mode)
{
2022-12-29 03:37:16 +00:00
wchar_t buf[30] = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽʧ<EFBFBD><EFBFBD>...<2E><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>:";
2022-12-29 02:11:18 +00:00
type = false;
2022-12-29 03:37:16 +00:00
wchar_t c[4];
wsprintfW(c, L"%dppm", save_num);
wcscat(buf, c);
infocat = buf;
2022-12-28 13:04:11 +00:00
}
else
{
2022-12-29 03:37:16 +00:00
wchar_t buf[30] = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽ<EFBFBD>ɹ<EFBFBD>...<2E><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>:";
2022-12-29 02:11:18 +00:00
type = true;
2022-12-29 03:37:16 +00:00
wchar_t c[6];
wsprintfW(c,L"%dppm", save_num);
wcscat(buf, c);
infocat = buf;
2022-12-28 13:04:11 +00:00
}
2022-12-29 03:37:16 +00:00
helper_->test_callback((wchar_t*)data, ui_helper::TEST_EVENT_RESULT, (void*)infocat, type);
2022-12-15 11:53:41 +00:00
return SCANNER_ERR_OK;
}
/* <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ֽ */
2022-12-27 08:26:41 +00:00
int test_place_correction_paper(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20>Զ<EFBFBD>ƽ<EFBFBD><C6BD>У<EFBFBD><D0A3> */
2022-12-27 08:26:41 +00:00
int test_auto_flat_field(void *data)
2022-12-15 11:53:41 +00:00
{
return SCANNER_ERR_OK;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD>豸 */
2022-12-27 08:26:41 +00:00
int test_reboot_device(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-29 03:22:22 +00:00
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* ɨ<><C9A8>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> */
2022-12-27 08:26:41 +00:00
int test_image_quality(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-27 08:26:41 +00:00
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;
2022-12-15 11:53:41 +00:00
}
/* ɫ<><C9AB>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_colorcard_imageing_quality(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* ɫ<><C9AB>ֽƫɫ<C6AB><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_colorcard_bias_imageing_quality(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_clarity_quality(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_distortion(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-28 02:21:16 +00:00
const wchar_t* NAME = (wchar_t*)data;
SANE_Bool type = true;
unsigned int len = sizeof(SANE_Bool);
return helper_->io_control(IO_CTRL_CODE_GET_DPI_COLOR_CHECK_VAL, &type, &len);
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_dormancy(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><>б<EFBFBD><D0B1>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_skew_gear(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><>ֽǿ<D6BD>ȼ<EFBFBD><C8BC><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_paper_separation_strength(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><>е<EFBFBD><D0B5>ֽ<EFBFBD><D6BD>б<EFBFBD><D0B1><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_mech_paper_feeding_inclination(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>1 */
2022-12-27 08:26:41 +00:00
int test_single_page_test_1(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>2 */
2022-12-27 08:26:41 +00:00
int test_single_page_test_2(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>3 */
2022-12-27 08:26:41 +00:00
int test_single_page_test_3(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32> */
2022-12-27 08:26:41 +00:00
int test_pressuer_test(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
2022-12-27 08:26:41 +00:00
int test_clear_roller_count(void *data)
2022-12-15 11:53:41 +00:00
{
2022-12-23 02:39:07 +00:00
return SCANNER_ERR_OK;
2022-12-15 11:53:41 +00:00
}
private:
2022-12-08 10:10:19 +00:00
};
2022-12-15 11:53:41 +00:00
2022-12-08 10:10:19 +00:00
//test
2022-12-27 08:26:41 +00:00
static std::string jsontext1("{\"1\":{\"NAME\":\"test-8\",\"ver\":1}}");
2022-12-15 11:53:41 +00:00
bool have_img_ = false;
2022-12-27 08:26:41 +00:00
DECL_API(int) func_test_init(void* init)
2022-12-08 10:10:19 +00:00
{
return 0;
}
2022-12-15 06:39:32 +00:00
DECL_API(int) func_test_get_list(wchar_t* buf, size_t* len)
2022-12-08 10:10:19 +00:00
{
2022-12-14 06:58:06 +00:00
return str_to_wchar(jsontext1, buf, len);
2022-12-08 10:10:19 +00:00
}
2022-12-27 08:26:41 +00:00
DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper, ui_helper* helper)
2022-12-08 10:10:19 +00:00
{
2022-12-27 08:26:41 +00:00
if (!NAME || !oper || !helper)
2022-12-08 10:10:19 +00:00
{
return -1;
}
2022-12-27 08:26:41 +00:00
//helper->add_ref(void *data);
2022-12-08 10:10:19 +00:00
2022-12-27 08:26:41 +00:00
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);//<2F><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>Ĭ<EFBFBD><C4AC>
2022-12-23 02:39:07 +00:00
return ret;
2022-12-08 10:10:19 +00:00
}
2022-12-27 08:26:41 +00:00
DECL_API(int) func_test_uninit(void* uninit)
2022-12-08 10:10:19 +00:00
{
return 0;
2022-12-26 09:18:25 +00:00
}