2022-12-30 01:28:56 +00:00
|
|
|
|
#include"test_base.h"
|
2022-12-08 10:10:19 +00:00
|
|
|
|
#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-29 16:07:01 +00:00
|
|
|
|
static std::string StringToUtf(std::string strValue)
|
|
|
|
|
{
|
|
|
|
|
int nwLen = MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), -1, NULL, 0);
|
2022-12-30 01:28:56 +00:00
|
|
|
|
wchar_t* pwBuf = new wchar_t[nwLen + 1];//加上末尾'\0'
|
2022-12-29 16:07:01 +00:00
|
|
|
|
memset(pwBuf, 0, nwLen * 2 + 2);
|
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, strValue.c_str(), strValue.length(), pwBuf, nwLen);
|
|
|
|
|
int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
|
|
|
|
|
char* pBuf = new char[nLen + 1];
|
|
|
|
|
memset(pBuf, 0, nLen + 1);
|
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
|
|
|
|
|
std::string retStr = pBuf;
|
|
|
|
|
delete[]pBuf;
|
|
|
|
|
delete[]pwBuf;
|
|
|
|
|
return retStr;
|
|
|
|
|
}
|
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);
|
2022-12-30 01:28:56 +00:00
|
|
|
|
(strrchr(exePath, '\\'))[1] = 0; //去掉执行的文件名。
|
2022-12-26 09:18:25 +00:00
|
|
|
|
|
|
|
|
|
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;
|
2022-12-29 16:07:01 +00:00
|
|
|
|
|
2022-12-28 02:21:16 +00:00
|
|
|
|
int ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
|
|
|
|
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
2022-12-30 01:28:56 +00:00
|
|
|
|
{
|
|
|
|
|
wstr.resize(l);
|
2022-12-28 02:21:16 +00:00
|
|
|
|
ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
|
2022-12-30 01:28:56 +00:00
|
|
|
|
}
|
2022-12-28 02:21:16 +00:00
|
|
|
|
if (ret == ERROR_INSUFFICIENT_BUFFER)
|
2022-12-26 09:18:25 +00:00
|
|
|
|
{
|
2022-12-28 02:21:16 +00:00
|
|
|
|
type = false;
|
2022-12-29 12:46:32 +00:00
|
|
|
|
|
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(), type);
|
|
|
|
|
return -1;
|
2022-12-26 09:18:25 +00:00
|
|
|
|
}
|
2022-12-29 16:07:01 +00:00
|
|
|
|
//std::string str = StringToUtf((char*)data);
|
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
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_PAPER_SKEW) != 0)
|
|
|
|
|
{
|
|
|
|
|
type = false;
|
2022-12-30 01:28:56 +00:00
|
|
|
|
wchar_t buf[128] = L"未检测到纸张倾斜,原因--->";
|
2022-12-29 10:07:00 +00:00
|
|
|
|
wcscat(buf, wstr.c_str());
|
|
|
|
|
wstr = buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
type = true;
|
|
|
|
|
|
2022-12-26 09:18:25 +00:00
|
|
|
|
}
|
2022-12-28 02:21:16 +00:00
|
|
|
|
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0)
|
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
io_type = false;
|
2022-12-28 02:21:16 +00:00
|
|
|
|
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
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION, (void*)L"畸变修正完成,是否进行单页扫描测试", type);
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return 0;
|
2022-12-28 02:21:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-29 10:30:29 +00:00
|
|
|
|
else if(wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_ULTRASONIC_MODULE) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_DOUBLE_FEEDING) != 0)
|
|
|
|
|
{
|
|
|
|
|
type = false;
|
2022-12-30 01:28:56 +00:00
|
|
|
|
wchar_t buf[128] = L"未检测到双张,原因--->";
|
2022-12-29 10:30:29 +00:00
|
|
|
|
wcscat(buf, wstr.c_str());
|
|
|
|
|
wstr = buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
type = true;
|
|
|
|
|
}
|
2022-12-30 06:35:26 +00:00
|
|
|
|
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COVER_SENSOR) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_COVER_OPENNED) != 0)
|
|
|
|
|
{
|
|
|
|
|
type = false;
|
|
|
|
|
wchar_t buf[128] = L"未检测到设备开盖,原因--->";
|
|
|
|
|
wcscat(buf, wstr.c_str());
|
|
|
|
|
wstr = buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
type = true;
|
|
|
|
|
}
|
2022-12-29 16:07:01 +00:00
|
|
|
|
|
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;
|
2022-12-29 16:07:01 +00:00
|
|
|
|
case SANE_EVENT_STATUS:
|
|
|
|
|
{
|
|
|
|
|
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD) == 0)
|
|
|
|
|
{
|
2022-12-30 06:35:26 +00:00
|
|
|
|
std::string str = StringToUtf((char*)data);
|
|
|
|
|
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_FALT_INFO, (void*)&str[0], type);
|
2022-12-29 16:07:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2022-12-26 09:18:25 +00:00
|
|
|
|
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
|
2022-12-29 13:17:20 +00:00
|
|
|
|
||wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_DISTORTION) == 0
|
|
|
|
|
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 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
|
|
|
|
}
|
2022-12-29 10:07:00 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK && ret != -1)
|
2022-12-23 02:39:07 +00:00
|
|
|
|
{
|
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-30 01:28:56 +00:00
|
|
|
|
/*获取固件版本号*/
|
2022-12-28 09:14:23 +00:00
|
|
|
|
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-30 01:28:56 +00:00
|
|
|
|
/* 拨码开关校验 */
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 检查船型开关功能 */
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 设备上电并观察开机状态 */
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 检查液晶显示 */
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 清理纸道功能确认 */
|
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-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认是否清理纸道成功", true);
|
2022-12-23 02:39:07 +00:00
|
|
|
|
return ret;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 按键功能检测 */
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 计数模式检测 */
|
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-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认与液晶面板是否匹配", ismode);
|
2022-12-23 02:39:07 +00:00
|
|
|
|
return ret;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 歪斜检测 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_skew_detection(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
const wchar_t* NAME = set_test_name_.c_str();
|
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-30 01:28:56 +00:00
|
|
|
|
parameter * ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_INT, NAME,L"请歪斜放纸...设置阈值:0 - 5,值越小越容易检测,0为关闭歪斜检测");
|
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)
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false);
|
2022-12-28 09:14:23 +00:00
|
|
|
|
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-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false);
|
2022-12-29 03:22:22 +00:00
|
|
|
|
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);
|
2022-12-29 10:07:00 +00:00
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
|
|
|
|
return ret;
|
2022-12-29 03:22:22 +00:00
|
|
|
|
|
2022-12-27 08:26:41 +00:00
|
|
|
|
ret = helper_->io_control(IO_CTRL_CODE_SET_SKEW_CHECK_VAL, &num, &len);
|
2022-12-29 10:07:00 +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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 分纸电机检测 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_separater_motor(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* cis原图初检 */
|
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-29 10:07:00 +00:00
|
|
|
|
const wchar_t* NAME = set_test_name_.c_str();
|
2022-12-27 08:26:41 +00:00
|
|
|
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 主机风扇功能检测 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_host_fan(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 13:17:20 +00:00
|
|
|
|
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 超声波模块检验 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_ultrasonic_module(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
const wchar_t* NAME = set_test_name_.c_str();
|
2022-12-28 09:14:23 +00:00
|
|
|
|
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,
|
2022-12-30 01:28:56 +00:00
|
|
|
|
L"请选择是否开启超声波检查,并且请放置双张纸");
|
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
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出超声波模块检测流程", false);
|
2022-12-28 09:14:23 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出超声波模块检测流程", false);
|
2022-12-29 03:22:22 +00:00
|
|
|
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* led灯状态检查 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_led_light(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 复位检查 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_reset(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 走纸检查 */
|
|
|
|
|
int test_paper_feed(void *data) //使用单张扫描测试
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 06:35:26 +00:00
|
|
|
|
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 开盖传感器检查 */
|
|
|
|
|
int test_cover_sensor(void *data) //端点返回 使用单张扫描测试
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 扫描传感器检查 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_scanning_sensor(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 13:17:20 +00:00
|
|
|
|
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 配置速度模式 */
|
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-29 10:07:00 +00:00
|
|
|
|
const wchar_t* NAME = set_test_name_.c_str();
|
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-30 01:28:56 +00:00
|
|
|
|
const wchar_t *info = L"请设置速度模式,值越大速度越快.";
|
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-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"速度模式设置失败...", false);
|
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 10:07:00 +00:00
|
|
|
|
if (fw_ == 3 || fw_ == 4 && speed_mode >= 40 && speed_mode <= 80)
|
2022-12-29 02:11:18 +00:00
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
|
2022-12-29 10:07:00 +00:00
|
|
|
|
{
|
2022-12-29 13:17:20 +00:00
|
|
|
|
if (G400[i] == speed_mode)
|
|
|
|
|
{
|
|
|
|
|
speed_mode = i + 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-12-29 10:07:00 +00:00
|
|
|
|
}
|
2022-12-29 02:11:18 +00:00
|
|
|
|
}
|
2022-12-28 09:14:23 +00:00
|
|
|
|
}
|
2022-12-28 11:46:48 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出--->设置速度模式...", false);
|
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)
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
|
2022-12-29 10:07:00 +00:00
|
|
|
|
{
|
2022-12-29 13:17:20 +00:00
|
|
|
|
if ((num -1)== i)
|
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
save_num = G400[i];
|
2022-12-29 13:17:20 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2022-12-29 10:07:00 +00:00
|
|
|
|
}
|
2022-12-29 02:11:18 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
save_num = num;
|
|
|
|
|
|
2022-12-29 03:37:16 +00:00
|
|
|
|
wchar_t* infocat = NULL;
|
2022-12-29 10:07:00 +00:00
|
|
|
|
wchar_t c[6];
|
2022-12-28 13:04:11 +00:00
|
|
|
|
if (num != speed_mode)
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
wchar_t buf[30] = L"设置速度模式失败...现在速度是:";
|
2022-12-29 02:11:18 +00:00
|
|
|
|
type = false;
|
2022-12-29 03:37:16 +00:00
|
|
|
|
wsprintfW(c, L"%dppm", save_num);
|
|
|
|
|
|
|
|
|
|
wcscat(buf, c);
|
|
|
|
|
infocat = buf;
|
2022-12-28 13:04:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
wchar_t buf[30] = L"设置速度模式成功...现在速度是:";
|
2022-12-29 02:11:18 +00:00
|
|
|
|
type = true;
|
2022-12-29 03:37:16 +00:00
|
|
|
|
wsprintfW(c,L"%dppm", save_num);
|
|
|
|
|
wcscat(buf, c);
|
|
|
|
|
infocat = buf;
|
2022-12-28 13:04:11 +00:00
|
|
|
|
}
|
2022-12-29 10:07:00 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)infocat, type);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 放置校正纸 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_place_correction_paper(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 自动平场校正 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_auto_flat_field(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 16:07:01 +00:00
|
|
|
|
return helper_->io_control(IO_CTRL_CODE_SET_AUTO_FALT, NULL, NULL);;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 重启设备 */
|
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 10:07:00 +00:00
|
|
|
|
bool is_reboot = false;
|
|
|
|
|
void* get_data = NULL;
|
|
|
|
|
int i = 0;
|
|
|
|
|
unsigned int len = sizeof(SANE_Int);
|
2022-12-30 01:28:56 +00:00
|
|
|
|
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, set_test_name_.c_str(),L"是否进入烧录模式,是:进入烧写模式(rebootloader) 否:设备普通重启(reboot)");
|
2022-12-29 10:07:00 +00:00
|
|
|
|
if (ptr)
|
|
|
|
|
{
|
|
|
|
|
get_data = ptr->get_data();
|
|
|
|
|
if (!get_data)
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"重启设备设置失败...", false);
|
2022-12-29 10:07:00 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
is_reboot = *((bool*)get_data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出--->重启设备模式...", false);
|
2022-12-29 10:07:00 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
i = is_reboot;
|
|
|
|
|
int ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_REBOOT, &i, &len);
|
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
|
|
|
|
return ret;
|
2022-12-29 03:22:22 +00:00
|
|
|
|
|
2022-12-30 06:35:26 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设备重启中,请观察设备是否重启", true);
|
2022-12-29 10:07:00 +00:00
|
|
|
|
return ret;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 扫描图像质量确认 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_image_quality(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 13:17:20 +00:00
|
|
|
|
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 色卡纸成像质量评估 */
|
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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 色卡纸偏色成像质量评估 */
|
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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 清晰度质量评估 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_clarity_quality(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 畸变修正 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_distortion(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
const wchar_t* NAME = set_test_name_.c_str();
|
2022-12-28 02:21:16 +00:00
|
|
|
|
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
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 设置休眠 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_dormancy(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-29 10:07:00 +00:00
|
|
|
|
const wchar_t sleep_buf[10] = { 9999,5,10,30,60,120,240 };
|
|
|
|
|
ui_helper::_INFOTIPS info_;
|
|
|
|
|
void *get_data = NULL;
|
|
|
|
|
int sleep_time = 0;
|
|
|
|
|
SANE_Power power;
|
|
|
|
|
unsigned int len = sizeof(SANE_Power);
|
|
|
|
|
info_.desc = sleep_buf;
|
2022-12-30 01:28:56 +00:00
|
|
|
|
info_.info = L"9999:为不设置休眠,值越大休眠越久,单位是分钟";
|
2022-12-29 10:07:00 +00:00
|
|
|
|
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_TIPS_VAL, set_test_name_.c_str(), (wchar_t*)&info_);
|
|
|
|
|
if (ptr)
|
|
|
|
|
{
|
|
|
|
|
get_data = ptr->get_data();
|
|
|
|
|
if (get_data)
|
|
|
|
|
{
|
|
|
|
|
sleep_time = *((int*)get_data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT,(void*)L"已退出设置休眠模式",false);
|
2022-12-29 10:07:00 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
ptr->release();
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
if (sleep_buf[i] == sleep_time)
|
|
|
|
|
{
|
|
|
|
|
power = (SANE_Power)i;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-29 10:30:29 +00:00
|
|
|
|
int ret = helper_->io_control(IO_CTRL_CODE_SET_POWER_LEVEL, &power, &len);
|
|
|
|
|
if (ret != SCANNER_ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2022-12-29 12:46:32 +00:00
|
|
|
|
int gettime = 0;
|
|
|
|
|
unsigned int timelen = sizeof(int*);
|
|
|
|
|
|
|
|
|
|
ret = helper_->io_control(IO_CTRL_CODE_GET_POWER_LEVEL, &gettime, &timelen);
|
|
|
|
|
|
|
|
|
|
if (gettime == 999999 || gettime == -1)
|
|
|
|
|
gettime = 9999;
|
|
|
|
|
else
|
|
|
|
|
gettime /= 60;
|
|
|
|
|
|
|
|
|
|
if (sleep_time == gettime)
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置休眠时间成功", true);
|
2022-12-29 12:46:32 +00:00
|
|
|
|
else
|
2022-12-30 01:28:56 +00:00
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置休眠时间失败", false);
|
2022-12-29 10:30:29 +00:00
|
|
|
|
return ret;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 歪斜挡位检测 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_skew_gear(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 分纸强度检测 */
|
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-29 10:07:00 +00:00
|
|
|
|
//parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_TIPS_VAL, NAME, (wchar_t*)&info_);
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 机械走纸倾斜检测 */
|
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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 单张测试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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 单张测试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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 单张测试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-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 压力测试2轮 */
|
2022-12-27 08:26:41 +00:00
|
|
|
|
int test_pressuer_test(void *data)
|
2022-12-15 11:53:41 +00:00
|
|
|
|
{
|
2022-12-30 02:36:33 +00:00
|
|
|
|
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}
|
2022-12-30 01:28:56 +00:00
|
|
|
|
/* 清除滚轴计数 */
|
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-29 10:07:00 +00:00
|
|
|
|
SANE_Int roller_num = -1;
|
|
|
|
|
const wchar_t* info = NULL;
|
|
|
|
|
bool type = false;
|
|
|
|
|
unsigned int len = sizeof(SANE_Int);
|
|
|
|
|
int ret = helper_->io_control(IO_CTRL_CODE_SET_CLEAR_ROLLER_COUNT, NULL, NULL);
|
|
|
|
|
ret = helper_->io_control(IO_CTRL_CODE_GET_ROLLER_NUM, &roller_num, &len);
|
|
|
|
|
|
|
|
|
|
if ((roller_num == 0 && roller_num != -1))
|
|
|
|
|
{
|
|
|
|
|
type = true;
|
2022-12-30 01:28:56 +00:00
|
|
|
|
info = L"清除滚轴计数成功";
|
2022-12-29 10:07:00 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
type = false;
|
2022-12-30 01:28:56 +00:00
|
|
|
|
info = L"清除滚轴计数失败";
|
2022-12-29 10:07:00 +00:00
|
|
|
|
}
|
|
|
|
|
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)info, type);
|
|
|
|
|
|
|
|
|
|
return ret;
|
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;
|
|
|
|
|
}
|
2022-12-30 09:13:18 +00:00
|
|
|
|
//ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
|
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-30 01:28:56 +00:00
|
|
|
|
}
|