调整测试项

This commit is contained in:
13038267101 2022-12-23 10:39:07 +08:00
parent 86e4b458b4
commit 2096414e1e
2 changed files with 157 additions and 60 deletions

View File

@ -12,61 +12,176 @@ class test
ui_helper* helper_; ui_helper* helper_;
public: public:
test(ui_helper* helper) :helper_(helper) test(ui_helper* helper) :helper_(helper)
{} {
init_test_map_();
}
~test() ~test()
{} {}
std::map<const wchar_t*, test> test_map_; struct ptrcmp
{
bool operator()(const wchar_t* name1, const wchar_t* name2)const
{
return wcscmp(name1, name2) < 0;
}
};
std::map<std::wstring, int(test::*)()> test_map_;
void init_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: public:
/* 拨码开关校验 */ /* 拨码开关校验 */
int test_dial_switch() int test_dial_switch()
{ {
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
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;
} }
/* 检查船型开关功能 */ /* 检查船型开关功能 */
int test_pocker_switch() int test_pocker_switch()
{ {
return SCANNER_ERR_OK; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
/* 设备上电并观察开机状态 */ /* 设备上电并观察开机状态 */
int test_boot_status() int test_boot_status()
{ {
return SCANNER_ERR_OK; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
/* 检查液晶显示 */ /* 检查液晶显示 */
int test_lcd_display() int test_lcd_display()
{ {
return SCANNER_ERR_OK; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
/* 清理纸道功能确认 */ /* 清理纸道功能确认 */
int tset_clear_paper_path() 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() int test_key_funtion()
{ {
return SCANNER_ERR_OK; return SCANNER_ERR_DEVICE_NOT_SUPPORT;
} }
/* 计数模式检测 */ /* 计数模式检测 */
int test_count_mode() 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() 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; return SCANNER_ERR_OK;
} }
/* 分纸电机检测 */ /* 分纸电机检测 */
@ -132,62 +247,77 @@ public:
/* 重启设备 */ /* 重启设备 */
int test_reboot_device() int test_reboot_device()
{ {
return SCANNER_ERR_OK;
} }
/* 扫描图像质量确认 */ /* 扫描图像质量确认 */
int test_image_quality() int test_image_quality()
{ {
return SCANNER_ERR_OK;
} }
/* 色卡纸成像质量评估 */ /* 色卡纸成像质量评估 */
int test_colorcard_imageing_quality() int test_colorcard_imageing_quality()
{ {
return SCANNER_ERR_OK;
} }
/* 色卡纸偏色成像质量评估 */ /* 色卡纸偏色成像质量评估 */
int test_colorcard_bias_imageing_quality() int test_colorcard_bias_imageing_quality()
{ {
return SCANNER_ERR_OK;
} }
/* 清晰度质量评估 */ /* 清晰度质量评估 */
int test_clarity_quality() int test_clarity_quality()
{ {
return SCANNER_ERR_OK;
} }
/* 畸变修正 */ /* 畸变修正 */
int test_distortion() int test_distortion()
{ {
return SCANNER_ERR_OK;
} }
/* 设置休眠 */ /* 设置休眠 */
int test_dormancy() int test_dormancy()
{ {
return SCANNER_ERR_OK;
} }
/* 歪斜挡位检测 */ /* 歪斜挡位检测 */
int test_skew_gear() int test_skew_gear()
{ {
return SCANNER_ERR_OK;
} }
/* 分纸强度检测 */ /* 分纸强度检测 */
int test_paper_separation_strength() int test_paper_separation_strength()
{ {
return SCANNER_ERR_OK;
} }
/* 机械走纸倾斜检测 */ /* 机械走纸倾斜检测 */
int test_mech_paper_feeding_inclination() int test_mech_paper_feeding_inclination()
{ {
return SCANNER_ERR_OK;
} }
/* 单张测试1 */ /* 单张测试1 */
int test_single_page_test_1() int test_single_page_test_1()
{ {
return SCANNER_ERR_OK;
} }
/* 单张测试2 */ /* 单张测试2 */
int test_single_page_test_2() int test_single_page_test_2()
{ {
return SCANNER_ERR_OK;
} }
/* 单张测试3 */ /* 单张测试3 */
int test_single_page_test_3() int test_single_page_test_3()
{ {
return SCANNER_ERR_OK;
} }
/* 压力测试2轮 */ /* 压力测试2轮 */
int test_pressuer_test() int test_pressuer_test()
{ {
return SCANNER_ERR_OK;
} }
/* 清除滚轴计数 */ /* 清除滚轴计数 */
int test_clear_roller_count() int test_clear_roller_count()
{ {
return SCANNER_ERR_OK;
} }
private: private:
@ -197,7 +327,7 @@ private:
//test //test
static std::string jsontext1("{\"1\":{\"name\":\"test-8\",\"ver\":1}}"); static std::string jsontext1("{\"1\":{\"name\":\"test-8\",\"ver\":1}}");
std::string str_ret_call_= ""; std::string ret_call_= "";
bool have_img_ = false; bool have_img_ = false;
int sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param) 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: case SANE_EVENT_WORKING:
{ {
str_ret_call_ = (char*)data; ret_call_ = (char*)data;
} }
break; break;
case SANE_EVENT_SCAN_FINISHED: case SANE_EVENT_SCAN_FINISHED:
{ {
str_ret_call_ = (char*)data; ret_call_ = (char*)data;
} }
break; break;
case SANE_EVENT_STATUS: case SANE_EVENT_STATUS:
{ {
str_ret_call_ = (char*)data; ret_call_ = (char*)data;
} }
break; break;
case SANE_EVENT_ERROR: case SANE_EVENT_ERROR:
{ {
str_ret_call_ = (char*)data; ret_call_ = (char*)data;
} }
break; break;
case SANE_EVENT_IMAGE_OK: 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->add_ref();
helper->register_sane_callback(sane_ex_callback1, NULL); helper->register_sane_callback(sane_ex_callback1, NULL);
bool flag = false;
wchar_t* des = NULL;
int ret = 0; int ret = 0;
size_t map_bool_len = sizeof(Test_Map_Bool) / sizeof(Test_Map_Bool[0]); test ts(helper);
size_t map_str_len = sizeof(Test_Map_String) / sizeof(Test_Map_String[0]); ret = ts.set_test(name);
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++) ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//½áÊø»Ö¸´Ä¬ÈÏ
{ return ret;
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);
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;
} }
DECL_API(int) func_test_uninit(void* uninit) DECL_API(int) func_test_uninit(void* uninit)
{ {

View File

@ -13,13 +13,13 @@
/* 检查液晶显示 */ /* 检查液晶显示 */
#define HGPDTTOOLDB_TITLE_LCD_DISPLAY L"检查液晶显示" #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_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"分纸电机检测" #define HGPDTTOOLDB_TITLE_SEPARATER_MOTOR L"分纸电机检测"
/* CIS原图初检 */ /* CIS原图初检 */
@ -146,6 +146,7 @@
#define HGPDTTOOLDB_NAME_PRESSUER_TEST L"test-34" #define HGPDTTOOLDB_NAME_PRESSUER_TEST L"test-34"
/* 清除滚轴计数 */ /* 清除滚轴计数 */
#define HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT L"test-35" #define HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT L"test-35"
static struct Test_Map static struct Test_Map
{ {
const wchar_t* name; //test-1 const wchar_t* name; //test-1