code_production/code/base/test_base.cpp

2291 lines
77 KiB
C++
Raw Permalink Normal View History

2024-06-25 14:24:04 +00:00
#include"test_base.h"
#include<string>
2022-12-08 10:10:19 +00:00
#include <stdio.h>
#include <windows.h>
#include <iostream>
2022-12-14 06:58:06 +00:00
#include "huagao/hgscanner_error.h"
2024-06-25 14:24:04 +00:00
#include "sane/sane_option_definitions.h";
#include "log/log.h"
extern HLOG g_hLog;
test *test_ = nullptr;
2022-12-31 09:02:23 +00:00
static struct Test_Map
{
const wchar_t* name; // DIAL_SWITCH
const wchar_t* title; // 歪斜检测
}Test_Map_NO[] =
{
{HGPDTTOOLDB_NAME_DIAL_SWITCH ,HGPDTTOOLDB_TITLE_DIAL_SWITCH},
{HGPDTTOOLDB_NAME_ROCKER_SWITCH ,HGPDTTOOLDB_TITLE_ROCKER_SWITCH},
{HGPDTTOOLDB_NAME_BOOT_STATUS ,HGPDTTOOLDB_TITLE_BOOT_STATUS},
{HGPDTTOOLDB_NAME_LCD_DISPLAY ,HGPDTTOOLDB_TITLE_LCD_DISPLAY},
{HGPDTTOOLDB_NAME_KEY_FUNCTION ,HGPDTTOOLDB_TITLE_KEY_FUNCTION},
{HGPDTTOOLDB_NAME_COUNTING_MODE ,HGPDTTOOLDB_TITLE_COUNTING_MODE},
{HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE ,HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE},
{HGPDTTOOLDB_NAME_HOST_FAN ,HGPDTTOOLDB_TITLE_HOST_FAN},
{HGPDTTOOLDB_NAME_SCAN_WORKING_STATUS ,HGPDTTOOLDB_TITLE_SCAN_WORKING_STATUS},
{HGPDTTOOLDB_NAME_USB_PC_INTERFACE ,HGPDTTOOLDB_TITLE_USB_PC_INTERFACE},
{HGPDTTOOLDB_NAME_LED_LIGHT ,HGPDTTOOLDB_TITLE_LED_LIGHT},
{HGPDTTOOLDB_NAME_RESET ,HGPDTTOOLDB_TITLE_RESET},
{HGPDTTOOLDB_NAME_PAPER_FEED ,HGPDTTOOLDB_TITLE_PAPER_FEED},
{HGPDTTOOLDB_NAME_SCANNING_SENSOR ,HGPDTTOOLDB_TITLE_SCANNING_SENSOR},
{HGPDTTOOLDB_NAME_PLACE_CORRECTION_PAPER ,HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER},
{HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD ,HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_200DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_RGB_200DPI},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_200DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_RGB_300DPI},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_300DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_RGB_600DPI},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_300DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_GRAY_200DPI},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_600DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_GRAY_300DPI},
{HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_600DPI ,HGPDTTOOLDB_TITLE_PRESSUER_TEST_GRAY_600DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_RGB_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_GRAY_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_RGB_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_GRAY_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_RGB_600DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_GRAY_600DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO_RGB_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO_GRAY_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO_RGB_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO_GRAY_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_QUALITY_PHOTO_RGB_600DPI},
{HGPDTTOOLDB_NAME_IMAGER_QUALITY_PHOTO_GRAY_600DPI ,HGPDTTOOLDB_TITLE_IMAGER_QUALITY_PHOTO_GRAY_600DPI},
{HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY},
{HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY ,HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY},
{HGPDTTOOLDB_NAME_CLARITY_QUALITY ,HGPDTTOOLDB_TITLE_CLARITY_QUALITY},
{HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI ,HGPDTTOOLDB_TITLE_GET_DISTORTION_VAL_200DPI},
{HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI ,HGPDTTOOLDB_TITLE_GET_DISTORTION_VAL_300DPI},
{HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI ,HGPDTTOOLDB_TITLE_GET_DISTORTION_VAL_600DPI},
{HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_200DPI ,HGPDTTOOLDB_TITLE_SET_DISTORTION_VAL_200DPI},
{HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_300DPI ,HGPDTTOOLDB_TITLE_SET_DISTORTION_VAL_300DPI},
{HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_600DPI ,HGPDTTOOLDB_TITLE_SET_DISTORTION_VAL_600DPI},
{HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL ,HGPDTTOOLDB_TITLE_CONFIRM_DISTORTION_VAL},
{HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_200DPI ,HGPDTTOOLDB_TITLE_VERIFY_DISTORTION_VAL_200DPI},
{HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_300DPI ,HGPDTTOOLDB_TITLE_VERIFY_DISTORTION_VAL_300DPI},
{HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_600DPI ,HGPDTTOOLDB_TITLE_VERIFY_DISTORTION_VAL_600DPI},
{HGPDTTOOLDB_NAME_SEPARATER_MOTOR ,HGPDTTOOLDB_TITLE_SEPARATER_MOTOR},
{HGPDTTOOLDB_NAME_CLEAR_PAPER_PATH ,HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH},
{HGPDTTOOLDB_NAME_SKEW_DETECTION ,HGPDTTOOLDB_TITLE_SKEW_DETECTION},
{HGPDTTOOLDB_NAME_ULTRASONIC_MODULE ,HGPDTTOOLDB_TITLE_ULTRASONIC_MODULE},
{HGPDTTOOLDB_NAME_COVER_SENSOR ,HGPDTTOOLDB_TITLE_COVER_SENSOR },
{HGPDTTOOLDB_NAME_REBOOT_DEVICE ,HGPDTTOOLDB_TITLE_REBOOT_DEVICE},
{HGPDTTOOLDB_NAME_MECH_PAPER_FEEDING_INCLINATION ,HGPDTTOOLDB_TITLE_MECH_PAPER_FEEDING_INCLINATION},
{HGPDTTOOLDB_NAME_CLEAR_ROLLER_COUNT ,HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT},
{HGPDTTOOLDB_NAME_CLEAR_HISTORY_COUNT ,HGPDTTOOLDB_TITLE_CLEAR_HISTORY_COUNT},
{HGPDTTOOLDB_NAME_PAPER_SEPARATION_STRENGTH ,HGPDTTOOLDB_TITLE_PAPER_SEPARATION_STRENGTH},
{HGPDTTOOLDB_NAME_CONFIGURE_SPEED_MODE ,HGPDTTOOLDB_TITLE_CONFIGURE_SPEED_MODE},
{HGPDTTOOLDB_NAME_DORMANCY ,HGPDTTOOLDB_TITLE_DORMANCY},
{HGPDTTOOLDB_NAME_GET_DEVICE_CONFIG ,HGPDTTOOLDB_TITLE_GET_DEVICE_CONFIG},
{HGPDTTOOLDB_NAME_GET_DEVICE_CPU_DISK ,HGPDTTOOLDB_TITLE_GET_DEVICE_CPU_DISK},
{HGPDTTOOLDB_NAME_BACKUP ,HGPDTTOOLDB_TITLE_BACKUP},
{HGPDTTOOLDB_NAME_SHUTDOWN ,HGPDTTOOLDB_TITLE_SHUTDOWN},
{HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE ,HGPDTTOOLDB_TITLE_SET_FIRMWARE_LANGUAGE},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_600DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_600DPI},
{HGPDTTOOLDB_NAME_GET_SN ,HGPDTTOOLDB_TITLE_GET_SN},
2024-10-14 11:18:12 +00:00
{HGPDTTOOLDB_NAME_KEY_INSPECTION ,HGPDTTOOLDB_TITLE_KEY_INSPECTION},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_3399 ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_3399},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_MORR_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_MORR_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_MORR_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_MORR_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI},
{HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI ,HGPDTTOOLDB_TITLE_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI}
2022-12-31 09:02:23 +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;
}
static int wchar_to_char(std::string& str, wchar_t* s, size_t* strlen)
2023-01-04 09:25:14 +00:00
{
if (!s)
return ERROR_INSUFFICIENT_BUFFER;
int len = WideCharToMultiByte(CP_ACP, 0, s, -1, NULL, 0, NULL, NULL);
if (*strlen < len)
{
*strlen = len;
return ERROR_INSUFFICIENT_BUFFER;
}
WideCharToMultiByte(CP_ACP, 0, s, -1, (char*)str.c_str(), len, NULL, NULL);
2023-01-04 09:25:14 +00:00
return 0;
}
2022-12-26 09:18:25 +00:00
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;
2024-06-21 08:43:36 +00:00
}
static std::wstring set_test_name_ = L"";
2023-03-01 09:34:07 +00:00
std::atomic<bool> is_distortion_get_image_abnormal(false);
std::atomic<bool> is_distortion_get_image(false);
int g_imageCount = 0; //本轮出图数量
int g_currentCorrectType = 0; //动态校正正在进行的子项
int g_dynamicCorrectStatus = SCANNER_ERR_OK; //动态校正结果
std::string test::get_serial_num()
{
std::string sn = "";
unsigned int len = 0;
int ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &sn[0], &len);
sn.resize(len);
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &sn[0], &len);
return sn;
}
/*设置vid pid*/
int test::test_set_vidpid(void* data)
2022-12-08 10:10:19 +00:00
{
unsigned int len = sizeof(int);
int set_vidpid = *((int*)data),
get_vidpid = 0,
ret = SCANNER_ERR_OK;
ret = helper_->io_control(IO_CTRL_CODE_SET_VIDPID, &set_vidpid, &len);
if (ret == SCANNER_ERR_OK)
2023-01-03 03:12:53 +00:00
{
ret = helper_->io_control(IO_CTRL_CODE_GET_VIDPID, &get_vidpid, &len);
if (set_vidpid == get_vidpid)
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置vidpid成功", true);
else
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置vidpid失败", false);
2023-01-03 03:12:53 +00:00
}
return ret;
}
/*设置序列号*/
int test::test_set_serial_num(void* data)
{
wchar_t* sn = (wchar_t*)data;
std::string set_sn,
get_sn;
int ret = SCANNER_ERR_OK;
size_t len = 0;
ret = wchar_to_char(set_sn, sn, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2023-01-03 03:12:53 +00:00
{
set_sn.resize(len);
2023-01-04 09:25:14 +00:00
ret = wchar_to_char(set_sn, sn, &len);
}
unsigned int setlen = set_sn.size(),
getlen = 0;
2023-01-03 03:12:53 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_SERIAL, &set_sn[0], &setlen);
2023-01-03 03:12:53 +00:00
if (ret != SCANNER_ERR_OK)return ret;
2023-01-03 03:12:53 +00:00
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置序列号完成", true);
2023-01-03 03:12:53 +00:00
return ret;
}
/* 设置休眠 */
int test::test_dormancy(void* data)
{
const wchar_t sleep_buf[8] = { 0,5,10,20,30,60,120,240 };
int sleep_time = *((int*)data);
SANE_Power power;
unsigned int len = sizeof(SANE_Power);
2023-01-03 03:12:53 +00:00
for (size_t i = 0; i < 8; i++)
{
if (sleep_buf[i] == sleep_time)
2023-01-03 03:12:53 +00:00
{
power = (SANE_Power)i;
break;
2023-01-03 03:12:53 +00:00
}
else
power = SANE_POWER_NONE;
2023-01-03 03:12:53 +00:00
}
int ret = helper_->io_control(IO_CTRL_CODE_SET_POWER_LEVEL, &power, &len);
if (ret != SCANNER_ERR_OK)
2023-01-03 03:12:53 +00:00
{
return ret;
2023-01-03 03:12:53 +00:00
}
int gettime = 0;
unsigned int timelen = sizeof(int*);
ret = helper_->io_control(IO_CTRL_CODE_GET_POWER_LEVEL, &gettime, &timelen);
if (gettime == INT_MAX || gettime == -1)
gettime = 0;
else
gettime /= 60;
if (sleep_time == gettime)
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置休眠时间成功", true);
else
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置休眠时间失败", false);
return ret;
}
/*获取固件版本号*/
std::string test::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);
return fw;
}
/* 配置速度模式 */
int test::test_configure_speed_mode(void* data)
{
unsigned int len = sizeof(int);
int speed_mode = *((int*)data);
bool type = false;
const char G139[6] = { 60,70,80,90,110 };
const char G239[6] = { 90,100,110,120,130 };
const char G300[6] = { 40,50,60,70,80 };
const char G306[6] = { 30,40,50,60,70 };
const char G400[6] = { 40,50,60,70,80 };
std::string fv(get_firmware_version());
if (fv.empty())
2023-01-03 03:12:53 +00:00
{
return -1;
}
std::string str = fv.substr(0, 2);
std::string str1 = fv.substr(0, 4);
std::string str2 = fv.substr(3, 1);
2023-03-20 09:24:38 +00:00
//3399设备直接设置实际速度3288设备设置速度模式为1 2 3 4 5
if (str2 == "Z" && speed_mode >= 30 && speed_mode <= 70)
{
for (size_t i = 0; i < sizeof(G306) / sizeof(G306[0]); i++)
2023-01-03 03:12:53 +00:00
{
if (G306[i] == speed_mode)
2023-01-03 03:12:53 +00:00
{
speed_mode = i + 1;
break;
2023-01-03 03:12:53 +00:00
}
}
}
else if (str == "G3" && speed_mode >= 40 && speed_mode <= 90)
{
for (size_t i = 0; i < sizeof(G300) / sizeof(G300[0]); i++)
2023-01-03 03:12:53 +00:00
{
if (G300[i] == speed_mode)
2024-07-09 03:32:54 +00:00
{
speed_mode = i + 1;
break;
2024-07-09 03:32:54 +00:00
}
2023-01-03 03:12:53 +00:00
}
}
else if (str == "G4" && speed_mode >= 40 && speed_mode <= 80)
{
if (str1 != "G439")
2023-01-03 03:12:53 +00:00
{
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)
2024-07-09 03:32:54 +00:00
{
if (G400[i] == speed_mode)
2024-07-09 03:32:54 +00:00
{
speed_mode = i + 1;
break;
2024-07-09 03:32:54 +00:00
}
}
2023-01-03 03:12:53 +00:00
}
}
2024-07-09 03:32:54 +00:00
int ret = helper_->io_control(IO_CTRL_CODE_SET_SPEED_MODE, &speed_mode, &len);
return ret;
}
static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
{
if (!hdev && !param)
{
return -1;
2023-01-03 03:12:53 +00:00
}
ui_helper* h = (ui_helper*)param;
std::wstring wstr = L"";
size_t l = 0;
bool type = true;
wchar_t buf[128] = L"";
int ret = SCANNER_ERR_OK;
if (code != SANE_EVENT_IMAGE_OK)
2022-12-26 09:18:25 +00:00
{
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
{
wstr.resize(l);
ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l);
2022-12-26 09:18:25 +00:00
}
if (ret == ERROR_INSUFFICIENT_BUFFER)
2022-12-26 09:18:25 +00:00
{
type = false;
2023-01-06 07:34:35 +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
}
}
2023-01-06 07:34:35 +00:00
//std::string str = StringToUtf((char*)data);
switch (code)
{
case SANE_EVENT_SCAN_FINISHED:
{
SANE_Bool close = false;
unsigned int closelen = sizeof(SANE_Bool);
2022-12-28 02:21:16 +00:00
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_PAPER_SKEW) != 0)
{
type = false;
wcscpy(buf, L"未检测到纸张倾斜, 原因--->");
}
}
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)
2022-12-30 10:15:49 +00:00
{
type = false;
wcscpy(buf, L"未检测到双张, 原因--->");
2022-12-30 10:15:49 +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)
2022-12-30 10:15:49 +00:00
{
type = false;;
wcscpy(buf, L"未检测到设备开盖, 原因--->");
2022-12-30 10:15:49 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PAPER_FEED) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-31 03:13:04 +00:00
{
type = false;
wcscpy(buf, L"走纸检测失败, 原因--->");
2022-12-31 03:13:04 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_AUTO_FAIL_OVER) != 0)
2022-12-31 09:02:23 +00:00
{
type = false;
wcscpy(buf, L"平场校正失败, 原因--->");
2022-12-31 09:02:23 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_600DPI) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0 || strcmp((char*)data, STATU_DESC_SCANNER_ERR_DEVICE_DISTORTION) == 0)
2022-12-31 09:02:23 +00:00
{
type = false;
is_distortion_get_image = false;
is_distortion_get_image_abnormal = true;
wcscpy(buf, L"畸变修正值获取失败,原因--->");
2022-12-31 09:02:23 +00:00
}
else
2022-12-31 09:02:23 +00:00
{
is_distortion_get_image = true;
is_distortion_get_image_abnormal = false;
//type = true;
//wcscpy(buf, L"畸变修正值获取完成:");
break;
2022-12-31 09:02:23 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_600DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_600DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_600DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGER_QUALITY_PHOTO_GRAY_600DPI) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-31 09:02:23 +00:00
{
type = false;
wcscpy(buf, L"扫描图像质量确认失败, 原因--->");
2022-12-31 09:02:23 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-31 09:02:23 +00:00
{
type = false;
wcscpy(buf, L"扫描传感器检查失败, 原因--->");
2022-12-31 09:02:23 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-31 09:02:23 +00:00
{
type = false;
wcscpy(buf, L"CIS原图初检, 原因--->");
2022-12-31 09:02:23 +00:00
}
h->io_control(IO_CTRL_CODE_SET_CIS_IMAGE, &close, &closelen);
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY) == 0)
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
{
type = false;
wcscpy(buf, L"色卡纸成像质量评估失败, 原因--->");
}
2022-12-26 09:18:25 +00:00
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY) == 0)
2022-12-26 09:18:25 +00:00
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
{
type = false;
wcscpy(buf, L"色卡纸偏色成像质量评估失败, 原因--->");
}
2022-12-26 09:18:25 +00:00
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CLARITY_QUALITY) == 0)
2022-12-29 16:07:01 +00:00
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-29 16:07:01 +00:00
{
type = false;
wcscpy(buf, L"清晰度质量评估失败, 原因--->");
2022-12-29 16:07:01 +00:00
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST) == 0)
2022-12-26 09:18:25 +00:00
{
if (strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0)
2022-12-27 08:26:41 +00:00
{
type = false;
wcscpy(buf, L"单张测试失败, 原因--->");
2022-12-27 08:26:41 +00:00
}
2022-12-26 09:18:25 +00:00
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCAN_WORKING_STATUS) == 0)
{
if (g_imageCount < 20)
{
type = false;
wcscpy(buf, L"扫描走纸未达到要求(10张)");
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
break;
}
}
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI) == 0
2024-10-14 11:18:12 +00:00
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI) == 0
)
{
if (strcmp((char*)data, STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED) != 0)
{
type = false;
}
else
{
type = true;
}
}
2022-12-23 02:39:07 +00:00
wcscat(buf, wstr.c_str());
2022-12-27 08:26:41 +00:00
bool correctFail = false;
2024-10-14 11:18:12 +00:00
int thre = 0;
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0)
2024-10-14 11:18:12 +00:00
thre = 7;
else if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_3399) == 0)
thre = 15;
if (thre > 0)
2022-12-23 02:39:07 +00:00
{
2024-10-14 11:18:12 +00:00
if (g_currentCorrectType == thre)
{
while (1)
{
int count = 0;
if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
{
type = false;
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
correctFail = true;
break;
}
else if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FINISHED)
{
type = true;
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
break;
}
else if (count == 30000) //30s
{
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
count++;
}
}
if ((strcmp((char*)data, STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED) != 0 && strcmp((char*)data, STATU_DESC_SCAN_STOPPED) != 0) ||
g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
{
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL;
if (!correctFail)
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, false);
}
2022-12-23 02:39:07 +00:00
}
else
2022-12-23 02:39:07 +00:00
{
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
2022-12-23 02:39:07 +00:00
}
2024-10-14 11:18:12 +00:00
//h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
2024-10-14 11:18:12 +00:00
unsigned int l = 0;
bool isOriImg = false;
int ret = h->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
bool isMorr = false;
ret = h->io_control(IO_CTRL_CODE_SET_MORR, (void*)&isMorr, &l);
bool isLongText = false;
ret = h->io_control(IO_CTRL_CODE_SET_LONGTEXT, (void*)&isLongText, &l);
2024-10-15 08:21:55 +00:00
bool photoMode = false;
ret = h->io_control(IO_CTRL_CODE_SET_PICTURE_PHOTO_MODE, &photoMode, &l);
2022-12-15 11:53:41 +00:00
}
break;
case SANE_EVENT_ERROR:
2022-12-28 09:14:23 +00:00
{
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), false);
2022-12-28 09:14:23 +00:00
}
break;
case SANE_EVENT_STATUS:
2023-01-05 09:46:52 +00:00
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_AUTO_FLAT_FIELD) == 0)
2023-03-20 09:24:38 +00:00
{
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_FALT_INFO, (wchar_t*)wstr.c_str(), type);
2023-03-20 09:24:38 +00:00
}
}
break;
case SANE_EVENT_IMAGE_OK:
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGER_QUALITY_PHOTO_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCAN_WORKING_STATUS) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SKEW_DETECTION) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SCANNING_SENSOR) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CLARITY_QUALITY) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI) == 0
2024-10-14 11:18:12 +00:00
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_3399) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_200DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_300DPI) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_600DPI) == 0)
2023-01-05 09:46:52 +00:00
{
g_imageCount++;
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI) == 0)
2023-01-05 09:46:52 +00:00
{
is_distortion_get_image = true;
2023-01-05 09:46:52 +00:00
}
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_HAVE_IMAGE, data, true);
2023-01-05 09:46:52 +00:00
}
}
break;
}
return 0;
}
test::test(ui_helper* helper)
{
helper_ = helper;
helper_->register_sane_callback(sane_ex_callback, NULL);
init_test_map_();
m_sn = get_serial_num();
}
test::~test()
{
g_currentCorrectType = 0;
m_waitCorrect.notify_all();
if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable())
thread_dynamic_correct_handle->join();
m_waitDistortion.notify_all();
if (thread_distortion_handle.get() && thread_distortion_handle->joinable())
thread_distortion_handle->join();
}
2023-01-05 09:46:52 +00:00
void test::init_test_map_()
{
test_map_[WRITE_CFG_NAME] = &test::set_init_cfg;
test_map_[HGPDTTOOLDB_NAME_SET_JSON_SN] = &test::test_set_json_serial_num;
test_map_[HGPDTTOOLDB_NAME_GET_SN] = &test::test_get_serial_num;
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_SCAN_WORKING_STATUS] = &test::test_scan_work_status;
test_map_[HGPDTTOOLDB_NAME_USB_PC_INTERFACE] = &test::test_usb_pc_interface;
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_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_PRESSUER_TEST_RGB_200DPI] = &test::test_pressuer_test_rgb_200dpi;
test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_200DPI] = &test::test_pressuer_test_gray_200dpi;
test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_300DPI] = &test::test_pressuer_test_rgb_300dpi;
test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_300DPI] = &test::test_pressuer_test_gray_300dpi;
test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST_RGB_600DPI] = &test::test_pressuer_test_rgb_600dpi;
test_map_[HGPDTTOOLDB_NAME_PRESSUER_TEST_GRAY_600DPI] = &test::test_pressuer_test_gray_600dpi;
2024-10-15 08:21:55 +00:00
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_200DPI] = &test::test_image_quality_rgb_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_200DPI] = &test::test_image_quality_gray_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_300DPI] = &test::test_image_quality_rgb_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_300DPI] = &test::test_image_quality_gray_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_RGB_600DPI] = &test::test_image_quality_rgb_600dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_GRAY_600DPI] = &test::test_image_quality_gray_600dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_200DPI] = &test::test_image_quality_photo_rgb_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_200DPI] = &test::test_image_quality_photo_gray_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_300DPI] = &test::test_image_quality_photo_rgb_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_GRAY_300DPI] = &test::test_image_quality_photo_gray_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_QUALITY_PHOTO_RGB_600DPI] = &test::test_image_quality_photo_rgb_600dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGER_QUALITY_PHOTO_GRAY_600DPI] = &test::test_image_quality_photo_gray_600dpi;
test_map_[HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI] = &test::test_get_distortion_200dpi;
test_map_[HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI] = &test::test_get_distortion_300dpi;
test_map_[HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI] = &test::test_get_distortion_600dpi;
test_map_[HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_200DPI] = &test::test_set_distortion_200dpi;
test_map_[HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_300DPI] = &test::test_set_distortion_300dpi;
test_map_[HGPDTTOOLDB_NAME_SET_DISTORTION_VAL_600DPI] = &test::test_set_distortion_600dpi;
test_map_[HGPDTTOOLDB_NAME_CONFIRM_DISTORTION_VAL] = &test::test_confirm_auto_distortion;
test_map_[HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_200DPI] = &test::test_verify_distortion_200dpi;
test_map_[HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_300DPI] = &test::test_verify_distortion_300dpi;
test_map_[HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_600DPI] = &test::test_verify_distortion_600dpi;
test_map_[HGPDTTOOLDB_NAME_DORMANCY] = &test::test_dormancy;
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_CLEAR_ROLLER_COUNT] = &test::test_clear_roller_count;
test_map_[HGPDTTOOLDB_NAME_CLEAR_HISTORY_COUNT] = &test::test_clear_history_count;
test_map_[HGPDTTOOLDB_NAME_COVER_SENSOR] = &test::test_single_page_test;
test_map_[HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST] = &test::test_single_page_test;
test_map_[HGPDTTOOLDB_NAME_COLORCARD_IMAGEING_QUALITY] = &test::test_single_page_test;
test_map_[HGPDTTOOLDB_NAME_COLORCARD_BIAS_IMAGEING_QUALITY] = &test::test_single_page_test;
test_map_[HGPDTTOOLDB_NAME_CLARITY_QUALITY] = &test::test_single_page_test;
test_map_[HGPDTTOOLDB_NAME_GET_DEVICE_CONFIG] = &test::test_get_device_config;
test_map_[HGPDTTOOLDB_NAME_GET_DEVICE_CPU_DISK] = &test::test_get_device_cpu_disk;
test_map_[HGPDTTOOLDB_NAME_BACKUP] = &test::test_backup;
test_map_[HGPDTTOOLDB_NAME_SHUTDOWN] = &test::test_shutdown;
test_map_[HGPDTTOOLDB_NAME_SET_FIRMWARE_LANGUAGE] = &test::test_set_firmware_language;
2024-10-14 11:18:12 +00:00
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION] = &test::test_image_correct_all_306;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI] = &test::test_image_correct_rgb_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI] = &test::test_image_correct_gray_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI] = &test::test_image_correct_rgb_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI] = &test::test_image_correct_gray_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI] = &test::test_image_correct_rgb_600dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI] = &test::test_image_correct_gray_600dpi;
2024-10-14 11:18:12 +00:00
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_200DPI] = &test::test_image_correct_rgb_morr_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_3399] = &test::test_image_correct_all_3399;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_200DPI] = &test::test_image_correct_gray_morr_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_300DPI] = &test::test_image_correct_rgb_morr_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_300DPI] = &test::test_image_correct_gray_morr_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI] = &test::test_image_correct_rgb_longtext_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI] = &test::test_image_correct_gray_longtext_200dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI] = &test::test_image_correct_rgb_longtext_300dpi;
test_map_[HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI] = &test::test_image_correct_gray_longtext_300dpi;
}
int test::set_test(const wchar_t* name, const wchar_t* oper)
{
2023-01-05 09:46:52 +00:00
if (wcscmp(name, HGPDTTOOLDB_NAME_SET_JSON_SN) == 0
|| wcscmp(name, HGPDTTOOLDB_NAME_GET_DEVICE_CONFIG) == 0
|| wcscmp(name, HGPDTTOOLDB_NAME_CONFIGURE_SPEED_MODE) == 0
|| wcscmp(name, WRITE_CFG_NAME) == 0)
{
std::string fw1(get_firmware_version());
if (!fw1.empty())
{
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;
2023-01-05 09:46:52 +00:00
}
}
if (!name)
return SCANNER_ERR_NO_DATA;
set_test_name_ = name;
int ret = SCANNER_ERR_OK;
2023-01-05 09:46:52 +00:00
auto it = test_map_.find(name);
2023-01-03 03:12:53 +00:00
if (it == test_map_.end())
{
helper_->test_callback(name, ui_helper::TEST_EVENT_NOT_FIND_TEST, NULL, false);
2023-01-05 09:46:52 +00:00
return ret;
}
ret = (this->*test_map_[name])((void*)oper);
const wchar_t* info = NULL;
if (ret == SCANNER_ERR_DEVICE_NOT_SUPPORT
|| ret == SCANNER_ERR_IO
|| ret == SCANNER_ERR_TIMEOUT
|| ret == SCANNER_ERR_NO_DATA
)
2022-12-15 11:53:41 +00:00
{
if (ret == SCANNER_ERR_DEVICE_NOT_SUPPORT)
info = L"设备不支持该操作";
else if (ret == SCANNER_ERR_IO)
info = L"IO错误";
else if (ret == SCANNER_ERR_TIMEOUT)
info = L"超时错误";
else if (ret == SCANNER_ERR_NO_DATA)
info = L"没有数据";
helper_->test_callback(name, ui_helper::TEST_EVENT_IO_FAIL, (void*)info, ret);
2022-12-15 11:53:41 +00:00
}
return ret;
}
void test::thread_dynamic_correct(std::string correctData)
{
std::unique_lock<std::mutex> lock(m_lock);
while (g_currentCorrectType <= 6)
{
if (g_currentCorrectType > 1)
m_waitCorrect.wait(lock);
if (g_currentCorrectType == 0 || g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
{
break;
}
SANE_Bool type = true;
unsigned int len = sizeof(SANE_Bool);
int ret = helper_->io_control(IO_CTRL_CODE_GET_PAPER_ON, &type, &len);
if (!type)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"无纸", false);
return;
}
CorrectMode correctMode = m_correctModeMap.at(g_currentCorrectType);
int dpi = correctMode.dpi;
bool isColor = correctMode.isColor;
ret = public_test_image_correct(correctData, dpi, isColor);
g_currentCorrectType++;
2022-12-15 11:53:41 +00:00
}
}
2024-10-14 11:18:12 +00:00
void test::thread_dynamic_correct_3399(std::string correctData)
{
std::unique_lock<std::mutex> lock(m_lock);
while (g_currentCorrectType <= 14)
{
if (g_currentCorrectType > 1)
m_waitCorrect.wait(lock);
if (g_currentCorrectType == 0 || g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
{
break;
}
SANE_Bool type = true;
unsigned int len = sizeof(SANE_Bool);
int ret = helper_->io_control(IO_CTRL_CODE_GET_PAPER_ON, &type, &len);
if (!type)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"无纸", false);
return;
}
CorrectMode correctMode = m_correctModeMap_3399.at(g_currentCorrectType);
int dpi = correctMode.dpi;
bool isColor = correctMode.isColor;
bool isMorr = correctMode.isMorr;
bool isLongText = correctMode.isLongText;
ret = public_test_image_correct(correctData, dpi, isColor, isMorr, isLongText);
g_currentCorrectType++;
}
}
void test::thread_distortion()
{
std::unique_lock<std::mutex> lock(m_lock);
SANE_Bool type = true;
unsigned int len = sizeof(int);
int ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_IMAGE, &type, &len);
if (ret != SCANNER_ERR_OK)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"自动计算畸变值获取失败", false);
return;
}
int cnt = 0;
SANE_DISTORTION_VAL dis = { 0 };
if (is_distortion_get_image_abnormal)
{
return;
}
m_waitDistortion.wait(lock);
if (is_distortion_get_image_abnormal)
{
return;
}
ret = helper_->io_control(IO_CTRL_CODE_GET_PC_DISTORTION_CHECK_VAL, &dis, &len);
if (dis.h > 0 && dis.scaleXY < 10)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_DISTORTION_VAL, (void*)&dis, true);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"自动计算畸变值获取失败", false);
}
}
int test::set_init_cfg(void* data)
{
const wchar_t* p = (const wchar_t*)data;
LPWRITECFG cfg = (LPWRITECFG)p;
unsigned int len = 0;
int ret = SCANNER_ERR_OK;
switch (cfg->cat)
2022-12-15 11:53:41 +00:00
{
case WRITE_CAT_VID_PID:
ret = test_set_vidpid(cfg->val);
break;
case WRITE_CAT_SPEED:
ret = test_configure_speed_mode(cfg->val);
break;
case WRITE_CAT_SLEEP:
ret = test_dormancy(cfg->val);
break;
case WRITE_CAT_SERIALNUM:
ret = test_set_serial_num(cfg->val);
break;
case WRITE_CAT_DEVS_MODEL:
ret = test_set_devs_model(cfg->val);
break;
default:
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"协议未找到", false);
break;
}
return ret;
}
2022-12-26 09:18:25 +00:00
/*设置序列号*/
int test::test_set_json_serial_num(void* data)
{
int ret = SCANNER_ERR_OK,
val = 0;
wchar_t* sn;
std::string set_sn, get_sn;
size_t len = 0;
parameter* prt = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_FLOAT, set_test_name_.c_str(), L"请设置序列号");
if (!prt)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出序列号设置", false);
return -1;
}
else
{
sn = (wchar_t*)prt->get_data();
if (!sn)
2022-12-23 02:39:07 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号失败", false);
return -1;
2022-12-23 02:39:07 +00:00
}
2022-12-15 11:53:41 +00:00
}
std::string fv(get_firmware_version());
if (fv.empty())
{
return -1;
}
std::string fvv = fv.substr(0, 4);
if (fvv != "G439" && fvv != "G239" && fvv != "G139")
{
fvv = fv.substr(0, 2);
}
ret = wchar_to_char(set_sn, sn, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2022-12-15 11:53:41 +00:00
{
if (fvv == "G3" || fvv == "G4")
2022-12-28 04:04:50 +00:00
{
if (len != 14)
2022-12-28 09:14:23 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号不足:14位", false);
2022-12-28 09:14:23 +00:00
return -1;
}
2022-12-27 08:26:41 +00:00
}
set_sn.resize(len);
ret = wchar_to_char(set_sn, sn, &len);
}
unsigned int setlen = set_sn.size(),
getlen = 0;
2022-12-29 03:22:22 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_SERIAL, &set_sn[0], &setlen);
2022-12-23 02:39:07 +00:00
if (ret != SCANNER_ERR_OK)return ret;
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &getlen);
if (ret == SANE_STATUS_NO_MEM)
{
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &getlen);
2022-12-15 11:53:41 +00:00
}
if (set_sn == get_sn)
2022-12-15 11:53:41 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号完成", true);
2022-12-15 11:53:41 +00:00
}
else
2022-12-15 11:53:41 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置序列号失败", true);
2022-12-27 08:26:41 +00:00
}
return ret;
}
int test::test_get_serial_num(void* data)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, NULL, true);
return SCANNER_ERR_OK;
}
/* 清理纸道功能确认 */
int test::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(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认是否清理纸道成功", true);
return ret;
}
/* 按键功能检测 */
int test::test_key_funtion(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 计数模式检测 */
int test::test_count_mode(void* data)
{
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)
{
return ret;
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"请确认与液晶面板是否匹配", ismode);
return ret;
}
/* 歪斜检测 */
int test::test_skew_detection(void* data)
{
const wchar_t* NAME = set_test_name_.c_str();
SANE_Bool type = true;
unsigned int len = sizeof(SANE_Bool);
int num = 0;
void* get_data = NULL;
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_INT, NAME, L"请歪斜放纸...设置阈值0 - 5,值越小越容易检测,0为关闭歪斜检测");
if (ptr)
{
get_data = ptr->get_data();
if (!get_data)
2022-12-27 08:26:41 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false);
return -1;
2022-12-27 08:26:41 +00:00
}
num = *((int*)get_data);
2022-12-15 11:53:41 +00:00
}
else
2022-12-15 11:53:41 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出歪斜检测流程", false);
return -1;
2022-12-15 11:53:41 +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;
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_GET_IMAGE, NULL, NULL);
return ret;
}
/* 分纸电机检测 */
int test::test_separater_motor(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* cis原图初检 */
int test::test_cis__original_image(void* data)
{
const wchar_t* NAME = set_test_name_.c_str();
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_GET_IMAGE, NULL, NULL);
if (ret != SCANNER_ERR_OK)
{
return ret;
}
return ret;
}
/* 主机风扇功能检测 */
int test::test_host_fan(void* data)
{
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/* 扫描工作状态 */
int test::test_scan_work_status(void* data)
{
int count = 10;
int ret = helper_->io_control(IO_CTRL_CODE_SET_SCAN_COUNT, &count, NULL);
ret = helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
int count2 = -1;
ret = helper_->io_control(IO_CTRL_CODE_SET_SCAN_COUNT, &count2, NULL);
return ret;
}
/* USB-PC接口 */
int test::test_usb_pc_interface(void* data)
{
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/* 超声波模块检验 */
int test::test_ultrasonic_module(void* data)
{
const wchar_t* NAME = set_test_name_.c_str();
SANE_Bool type = true;
unsigned int len = sizeof(SANE_Bool);
void* get_data = NULL;
int ret = SCANNER_ERR_OK;
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_BOOL, NAME,
L"请选择是否开启超声波检查,并且请放置双张纸");
if (ptr)
2022-12-15 11:53:41 +00:00
{
get_data = ptr->get_data();
if (!get_data)
2022-12-29 03:22:22 +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;
}
else
type = *((bool*)get_data);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出超声波模块检测流程", false);
return -1;
}
ptr->release();
2022-12-29 03:22:22 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_ULTRASONIC_MODULE, &type, &len);
2022-12-29 03:22:22 +00:00
if (ret != SCANNER_ERR_OK)
{
2022-12-28 09:14:23 +00:00
return ret;
2022-12-15 11:53:41 +00:00
}
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
return ret;
}
/* led灯状态检查 */
int test::test_led_light(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 复位检查 */
int test::test_reset(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 走纸检查 */
int test::test_paper_feed(void* data)
{
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/* 扫描传感器检查 */
int test::test_scanning_sensor(void* data)
{
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/* 放置校正纸 */
int test::test_place_correction_paper(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 自动平场校正 */
int test::test_auto_flat_field(void* data)
{
if (!data)
return SCANNER_ERR_DATA_DAMAGED;
unsigned int len = sizeof(int);
wchar_t* p = (wchar_t*)data;
std::string str;
int ret = SCANNER_ERR_OK,
dpi_type = 0;
unsigned int llen = sizeof(int);
size_t strl = 0;
//ret = wchar_to_char(str, p, &strl);
//if (ret == ERROR_INSUFFICIENT_BUFFER)
//{
// str.resize(strl);
// ret = wchar_to_char(str, p, &strl);
// if (str.empty())
// {
// return SCANNER_ERR_DATA_DAMAGED;
// }
// dpi_type = atoi(str.c_str());
//}
return helper_->io_control(IO_CTRL_CODE_SET_AUTO_FALT, &dpi_type, &len);;
}
/* 重启设备 */
int test::test_reboot_device(void* data)
{
if (!data)
2022-12-15 11:53:41 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设备重启中失败", false);
return -1;
2022-12-15 11:53:41 +00:00
}
wchar_t* p = (wchar_t*)data;
int i = _wtoi(p);
unsigned int len = sizeof(int);
int ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_REBOOT, &i, &len);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设备重启中,请观察设备是否重启", true);
return ret;
}
2022-12-29 03:22:22 +00:00
int test::public_calculate_distortion(int dpi, bool isVerify)
{
SANE_Bool type = true;
unsigned int len = 0;
int ret = helper_->io_control(IO_CTRL_CODE_GET_PAPER_ON, &type, &len);
if (!type)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"自动计算畸变值获取失败: 无纸", false);
return ret;
}
2023-03-07 08:44:38 +00:00
if (dpi > 0)
{
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi, &len);
}
if (!isVerify) //验证畸变值无需初始化畸变值为1.0
{
float distortion = 1.0;
float getdistortion = 0;
ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_DEVS_CHECK_VAL, &distortion, &len);
ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_DEVS_CHECK_VAL, &getdistortion, &len);
}
2023-01-05 12:19:55 +00:00
if (thread_distortion_handle.get() && thread_distortion_handle->joinable())
thread_distortion_handle->join();
thread_distortion_handle.reset(new std::thread(&test::thread_distortion, this));
2023-01-10 06:25:38 +00:00
return SCANNER_ERR_OK;
}
int test::test_get_distortion_200dpi(void* data)
{
return public_calculate_distortion(200, false);
}
int test::test_get_distortion_300dpi(void* data)
{
return public_calculate_distortion(300, false);
}
2023-01-10 06:25:38 +00:00
int test::test_get_distortion_600dpi(void* data)
{
return public_calculate_distortion(600, false);
}
int test::public_set_distortion(int dpi)
{
int ret = SCANNER_ERR_OK;
unsigned int len = 0;
float distortion = 0.0;
if (dpi > 0)
{
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi, &len);
}
2023-01-10 06:25:38 +00:00
parameter* prt = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_FLOAT, set_test_name_.c_str(), L"请设置畸变值");
if (!prt)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出畸变值设置", false);
return -1;
}
else
{
void* p = prt->get_data();
distortion = *(float*)p;
}
if (distortion == 0.0)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出畸变值设置", false);
return -1;
}
float setdistortion = distortion;
float getdistortion = 0;
2023-01-10 06:22:02 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_DISTORTION_DEVS_CHECK_VAL, &setdistortion, &len);
if (ret != SCANNER_ERR_OK)
{
2023-01-05 09:46:52 +00:00
return ret;
}
ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_DEVS_CHECK_VAL, &getdistortion, &len);
if (setdistortion == getdistortion)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置畸变值成功", true);
InfoLog(g_hLog, "Serial Number: %s, set distortion value: %f", m_sn.c_str(), setdistortion);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置畸变值失败", false);
}
return ret;
}
int test::test_set_distortion_200dpi(void* data)
{
return public_set_distortion(200);
}
int test::test_set_distortion_300dpi(void* data)
{
return public_set_distortion(300);
}
int test::test_set_distortion_600dpi(void* data)
{
return public_set_distortion(600);
}
int test::test_confirm_auto_distortion(void* data)
{
if (!data)
{
return SCANNER_ERR_DATA_DAMAGED;
}
float distortion = 0;
unsigned int len = sizeof(int);
int ret = SCANNER_ERR_OK;
float value[3] = { 0 };
int dpi[3] = { 200, 300, 600 };
for (int i = 0; i < 3; i++)
{
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, &dpi[i], &len);
ret = helper_->io_control(IO_CTRL_CODE_GET_DISTORTION_DEVS_CHECK_VAL, &distortion, &len);
if (ret != SCANNER_ERR_OK)
break;
value[i] = distortion;
}
if (ret == SCANNER_ERR_OK)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(float*)value, true);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"获取设备畸变值失败", false);
}
return ret;
}
int test::test_verify_distortion_200dpi(void* data)
{
return public_calculate_distortion(200, true);
}
int test::test_verify_distortion_300dpi(void* data)
{
return public_calculate_distortion(300, true);
}
int test::test_verify_distortion_600dpi(void* data)
{
return public_calculate_distortion(600, true);
}
/* 分纸强度检测 */
int test::test_paper_separation_strength(void* data)
{
//parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_TIPS_VAL, NAME, (wchar_t*)&info_);
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 机械走纸倾斜检测 */
int test::test_mech_paper_feeding_inclination(void* data)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
}
/* 清除滚轴计数 */
int test::test_clear_roller_count(void* data)
{
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;
info = L"清除滚轴计数成功";
}
else
{
type = false;
info = L"清除滚轴计数失败";
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)info, type);
return ret;
}
/* 清除历史计数 */
int test::test_clear_history_count(void* data)
{
SANE_Int 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_HISTORY_COUNT, NULL, NULL);
if (ret != SCANNER_ERR_OK)
{
return SCANNER_ERR_DEVICE_NOT_SUPPORT;
2022-12-15 11:53:41 +00:00
}
ret = helper_->io_control(IO_CTRL_CODE_GET_HISTORY_SCAN_NUM, &num, &len);
if ((num == 0 && num != -1))
2022-12-15 11:53:41 +00:00
{
type = true;
info = L"清除历史计数成功";
2022-12-15 11:53:41 +00:00
}
else
2022-12-15 11:53:41 +00:00
{
type = false;
info = L"清除历史计数失败";
2022-12-15 11:53:41 +00:00
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)info, type);
return ret;
}
/* 单张测试 */
int test::test_single_page_test(void* data)
{
return helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
}
int test::public_image_test(bool isRgb, int dpi, bool isPhotoMode)
{
const char* color = isRgb ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
helper_->io_control(IO_CTRL_CODE_SET_PICTURE_PHOTO_MODE, &isPhotoMode, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*图像质量测试彩色_200dpi*/
int test::test_image_quality_rgb_200dpi(void* data)
{
return public_image_test(true, 200, false);
}
/*图像质量测试灰色_200dpi*/
int test::test_image_quality_gray_200dpi(void* data)
{
return public_image_test(false, 200, false);
}
/*图像质量测试彩色_300dpi*/
int test::test_image_quality_rgb_300dpi(void* data)
{
return public_image_test(true, 300, false);
}
/*图像质量测试灰色_300dpi*/
int test::test_image_quality_gray_300dpi(void* data)
{
return public_image_test(false, 300, false);
}
/*图像质量测试彩色_600dpi*/
int test::test_image_quality_rgb_600dpi(void* data)
{
return public_image_test(true, 600, false);
}
/*图像质量测试灰色_600dpi*/
int test::test_image_quality_gray_600dpi(void* data)
{
return public_image_test(false, 600, false);
}
/*照片模式图像质量测试彩色_200dpi*/
int test::test_image_quality_photo_rgb_200dpi(void* data)
{
return public_image_test(true, 200, true);
}
/*照片模式图像质量测试灰色_200dpi*/
int test::test_image_quality_photo_gray_200dpi(void* data)
{
return public_image_test(false, 200, true);
}
/*照片模式图像质量测试彩色_300dpi*/
int test::test_image_quality_photo_rgb_300dpi(void* data)
{
return public_image_test(true, 300, true);
}
/*照片模式图像质量测试灰色_300dpi*/
int test::test_image_quality_photo_gray_300dpi(void* data)
{
return public_image_test(false, 300, true);
}
/*照片模式图像质量测试彩色_600dpi*/
int test::test_image_quality_photo_rgb_600dpi(void* data)
{
return public_image_test(true, 600, true);
}
/*照片模式图像质量测试灰色_600dpi*/
int test::test_image_quality_photo_gray_600dpi(void* data)
{
return public_image_test(false, 600, true);
}
/*压力测试彩色_200dpi*/
int test::test_pressuer_test_rgb_200dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 200;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*压力测试灰色_200dpi*/
int test::test_pressuer_test_gray_200dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 200;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*压力测试彩色_300dpi*/
int test::test_pressuer_test_rgb_300dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 300;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*压力测试灰色_300dpi*/
int test::test_pressuer_test_gray_300dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 300;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*压力测试彩色_600dpi*/
int test::test_pressuer_test_rgb_600dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_24WCS;
int dpi = 600;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*压力测试灰色_600dpi*/
int test::test_pressuer_test_gray_600dpi(void* data)
{
const char* color = OPTION_VALUE_YSMS_256JHD;
int dpi = 600;
unsigned int len = strlen(color);
helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &len);
helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &len);
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
}
/*获取设备配置*/
int test::test_get_device_config(void* data)
{
unsigned int len = sizeof(int);
unsigned int getlen = 0;
2023-02-15 11:40:08 +00:00
int get_vidpid = 0,
ret = SCANNER_ERR_OK;
2023-02-15 11:40:08 +00:00
if (ret == SCANNER_ERR_OK)
{
ret = helper_->io_control(IO_CTRL_CODE_GET_VIDPID, &get_vidpid, &len);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_VIDPID, &get_vidpid, true);
}
2023-02-15 11:40:08 +00:00
std::string set_sn, get_sn;
std::wstring wstr;
size_t l = 0;
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &getlen);
if (ret == SANE_STATUS_NO_MEM)
{
2023-02-15 11:40:08 +00:00
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn[0], &getlen);
if (ret != SCANNER_ERR_OK)
2023-02-15 11:40:08 +00:00
{
return ret;
2023-02-15 11:40:08 +00:00
}
ret = str_to_wchar(get_sn.c_str(), (wchar_t*)wstr.c_str(), &l);
2023-03-20 09:24:38 +00:00
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
wstr.resize(l);
ret = str_to_wchar(get_sn.c_str(), (wchar_t*)wstr.c_str(), &l);
2023-03-20 09:24:38 +00:00
}
if (wstr.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SN, (void*)L"获取序列号失败", false);
2023-03-20 09:24:38 +00:00
return ret;
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SN, (void*)wstr.c_str(), true);
}
2023-03-20 09:24:38 +00:00
int gettime = 0;
unsigned int timelen = sizeof(int*);
2023-03-20 09:24:38 +00:00
ret = helper_->io_control(IO_CTRL_CODE_GET_POWER_LEVEL, &gettime, &timelen);
if (gettime == INT_MAX || gettime == -1)
gettime = 0;
else
gettime /= 60;
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SLEEPTIME, (void*)&gettime, true);
std::string fw(get_firmware_version());
size_t fwlen = 0;
wstr.clear();
ret = str_to_wchar(fw.c_str(), (wchar_t*)wstr.c_str(), &fwlen);
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
wstr.resize(fwlen);
ret = str_to_wchar(fw.c_str(), (wchar_t*)wstr.c_str(), &fwlen);
}
if (wstr.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_FW, (void*)L"获取固件号失败", false);
return ret;
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_FW, (void*)wstr.c_str(), true);
2023-03-20 09:24:38 +00:00
2023-02-15 11:40:08 +00:00
std::string fvv = fw.substr(0, 4);
if (fvv != "G439" && fvv != "G239" && fvv != "G139")
{
fvv = fw.substr(0, 2);
}
const wchar_t G139[6] = { 60,70,80,90,110 };
const wchar_t G239[6] = { 90,100,110,120,130 };
const wchar_t G300[6] = { 40,50,60,70,80 };
const wchar_t G306[6] = { 30,40,50,60,70 };
const wchar_t G400[6] = { 40,50,60,70,80 };
SANE_Int num = 0;
unsigned int lensp = sizeof(SANE_Int);
ret = helper_->io_control(IO_CTRL_CODE_GET_SPEED_MODE, &num, &lensp);
int save_num = 0;
if (fvv == "G3" || fvv == "G4" && num > 0 && num < 6)
{
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
2023-02-15 11:40:08 +00:00
{
if ((num - 1) == i)
2023-02-15 11:40:08 +00:00
{
save_num = G400[i];
break;
2023-02-15 11:40:08 +00:00
}
}
}
else
save_num = num;
2023-02-15 11:40:08 +00:00
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SP, (void*)&save_num, true);
2023-02-15 11:40:08 +00:00
2023-03-20 04:11:00 +00:00
std::string devs_model;
unsigned int devs_len = 0;
l = 0;
wstr.clear();
2023-03-20 04:11:00 +00:00
ret = helper_->io_control(IO_CTRL_CODE_GET_DEVS_MODEL, &devs_model[0], &devs_len);
if (ret == SANE_STATUS_NO_MEM)
{
devs_model.resize(devs_len);
2023-03-20 04:11:00 +00:00
ret = helper_->io_control(IO_CTRL_CODE_GET_DEVS_MODEL, &devs_model[0], &devs_len);
}
2023-03-20 04:11:00 +00:00
ret = str_to_wchar(devs_model.c_str(), (wchar_t*)wstr.c_str(), &l);
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
wstr.resize(l);
2023-03-20 04:11:00 +00:00
ret = str_to_wchar(devs_model.c_str(), (wchar_t*)wstr.c_str(), &l);
2023-02-15 11:40:08 +00:00
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_DEVS_MODEL, wstr.empty() ? (void*)L"获取设备类型失败" : (void*)wstr.c_str(), wstr.empty() ? false : true);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(L"配置获取完成"), true);
return ret;
}
/*获取设备内存和硬盘容量大小*/
int test::test_get_device_cpu_disk(void* data)
{
int cpu = 0;
unsigned len = 0;
int ret = helper_->io_control(IO_CTRL_CODE_GET_DEVS_CPU, &cpu, &len);
if (0 != cpu)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_DEVS_CPU, (void*)&cpu, true);
}
2023-10-13 01:54:59 +00:00
int disk = 0;
unsigned len2 = 0;
ret = helper_->io_control(IO_CTRL_CODE_GET_DEVS_DISK, &disk, &len2);
if (0 != disk)
2023-11-02 02:42:55 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_DEVS_DISK, (void*)&disk, true);
2023-11-02 02:42:55 +00:00
}
if (0 == cpu || 0 == disk)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, nullptr, false);
return -1;
}
else
2024-01-19 01:10:31 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, nullptr, true);
return -1;
}
2024-01-19 01:10:31 +00:00
return ret;
}
/* 备份设备配置 */
int test::test_backup(void* data)
{
int val = 0;
unsigned int len = 0;
int ret = helper_->io_control(IO_CTRL_CODE_SET_BACKUP, &val, &len);
if (SCANNER_ERR_OK == ret)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(L"备份配置完成"), true);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(L"备份配置失败"), false);
return -1;
}
return ret;
}
/* 关机 */
int test::test_shutdown(void* data)
{
int val = 0;
unsigned int len = 0;
int ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_SHUTDOWN, &val, &len);
if (SCANNER_ERR_OK != ret)
{
if (SCANNER_ERR_DEVICE_NOT_SUPPORT == ret)
2024-01-19 01:10:31 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(L"设备固件不支持"), false);
2024-01-19 01:10:31 +00:00
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)(L"关机失败"), false);
2024-01-19 01:10:31 +00:00
}
return -1;
}
return ret;
}
/* 设置固件语言模式 */
int test::test_set_firmware_language(void* data)
{
int mode = 0;
void* get_data = nullptr;
parameter* ptr = helper_->get_user_input(ui_helper::DATA_FROM_USER, ui_helper::VAL_TYPE_TIPS_VAL, set_test_name_.c_str(), L"请设置固件语言模式");
if (ptr)
{
get_data = ptr->get_data();
if (!get_data)
2024-01-19 01:10:31 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出设置固件语言模式流程", false);
2024-01-19 01:10:31 +00:00
return -1;
}
mode = *((int*)get_data);
}
else
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"已退出设置固件语言模式流程", false);
return -1;
}
2024-01-19 01:10:31 +00:00
int ret = helper_->io_control(IO_CTRL_CODE_SET_FIRMWARE_LANGUAGE, &mode, NULL);
if (ret != SCANNER_ERR_OK)
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"不支持设置固件语言模式", false);
return -1;
2024-01-19 01:10:31 +00:00
}
else
2023-03-20 04:11:00 +00:00
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置固件语言模式成功,设备即将重启", true);
2023-03-20 04:11:00 +00:00
int val = 0;
unsigned int len = sizeof(int);
int ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_REBOOT, &val, &len);
}
2023-03-20 06:21:49 +00:00
return ret;
}
/*设置设备型号*/
int test::test_set_devs_model(void* data)
{
if (!data)
{
return SCANNER_ERR_NO_DATA;
2023-03-20 04:11:00 +00:00
}
wchar_t* sc = (wchar_t*)data;
std::string str;
size_t len = 0;
int ret = wchar_to_char(str, sc, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2024-06-25 14:24:04 +00:00
{
str.resize(len);
ret = wchar_to_char(str, sc, &len);
}
if (str.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置设备类型失败", false);
2024-06-25 14:24:04 +00:00
return -1;
}
unsigned int l = str.size();
ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_MODEL, &str[0], &l);
if (ret != SCANNER_ERR_OK)
return ret;
2024-06-25 14:24:04 +00:00
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置设备类型成功", true);
return ret;
}
int test::public_test_image_correct(std::string correctData, int dpi, bool isColor)
{
if (correctData.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正失败", false);
2024-06-25 14:24:04 +00:00
return -1;
}
2024-06-25 14:24:04 +00:00
unsigned int l = correctData.size();
int ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &l);
const char* color = isColor ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
unsigned int colorlen = strlen(color);
ret = helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen);
2024-06-25 14:24:04 +00:00
SANE_Bool isOriImg = true;
ret = ret = helper_->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
2024-06-25 14:24:04 +00:00
ret = helper_->io_control(IO_CTRL_CODE_SET_CORRECT_IMAGE, &correctData[0], &l);
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
if (ret != SCANNER_ERR_OK)
2024-06-25 14:24:04 +00:00
return ret;
//helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正完成", true);
return ret;
}
int test::public_test_image_correct(void* data, int dpi, bool isColor)
{
if (!data)
2024-06-25 14:24:04 +00:00
{
return SCANNER_ERR_NO_DATA;
2024-06-25 14:24:04 +00:00
}
wchar_t* sc = (wchar_t*)data;
std::string str;
size_t len = 0;
int ret = wchar_to_char(str, sc, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2024-06-25 14:24:04 +00:00
{
str.resize(len);
ret = wchar_to_char(str, sc, &len);
2024-06-25 14:24:04 +00:00
}
if (str.empty())
2024-06-25 14:24:04 +00:00
{
2024-10-14 11:18:12 +00:00
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正失败,校正数据为空", false);
return -1;
}
unsigned int l = str.size();
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &l);
const char* color = isColor ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
unsigned int colorlen = strlen(color);
ret = helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen);
SANE_Bool isOriImg = true;
ret = ret = helper_->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
ret = helper_->io_control(IO_CTRL_CODE_SET_CORRECT_IMAGE, &str[0], &l);
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
if (ret != SCANNER_ERR_OK)
return ret;
//helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正完成", true);
return ret;
}
int test::public_test_image_correct(std::string correctData, int dpi, bool isColor, bool isMorr, bool isLongText)
{
if (correctData.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正失败,校正数据为空", false);
return -1;
}
unsigned int l = correctData.size();
int ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &l);
const char* color = isColor ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
unsigned int colorlen = strlen(color);
ret = helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen);
SANE_Bool isOriImg = true;
ret = helper_->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
if (isMorr)
ret = helper_->io_control(IO_CTRL_CODE_SET_MORR, (void*)&isMorr, &l);
if (isLongText)
ret = helper_->io_control(IO_CTRL_CODE_SET_LONGTEXT, (void*)&isLongText, &l);
ret = helper_->io_control(IO_CTRL_CODE_SET_CORRECT_IMAGE, &correctData[0], &l);
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
if (ret != SCANNER_ERR_OK)
return ret;
return ret;
}
int test::public_test_image_correct(void* data, int dpi, bool isColor, bool isMorr, bool isLongText)
{
if (!data)
{
return SCANNER_ERR_NO_DATA;
}
wchar_t* sc = (wchar_t*)data;
std::string str;
size_t len = 0;
int ret = wchar_to_char(str, sc, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
str.resize(len);
ret = wchar_to_char(str, sc, &len);
}
if (str.empty())
{
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正失败,校正数据为空", false);
return -1;
2024-06-25 14:24:04 +00:00
}
unsigned int l = str.size();
ret = helper_->io_control(IO_CTRL_CODE_SET_DPI, (void*)&dpi, &l);
const char* color = isColor ? OPTION_VALUE_YSMS_24WCS : OPTION_VALUE_YSMS_256JHD;
unsigned int colorlen = strlen(color);
ret = helper_->io_control(IO_CTRL_CODE_SET_COLOR, (void*)color, &colorlen);
SANE_Bool isOriImg = true;
ret = ret = helper_->io_control(IO_CTRL_CODE_ORIGINAL_IMAGE, (void*)&isOriImg, &l);
2024-10-14 11:18:12 +00:00
if (isMorr)
ret = helper_->io_control(IO_CTRL_CODE_SET_MORR, (void*)&isMorr, &l);
if (isLongText)
ret = helper_->io_control(IO_CTRL_CODE_SET_LONGTEXT, (void*)&isLongText, &l);
ret = helper_->io_control(IO_CTRL_CODE_SET_CORRECT_IMAGE, &str[0], &l);
ret = helper_->io_control(IO_CTRL_CODE_TEST_SINGLE, NULL, NULL);
if (ret != SCANNER_ERR_OK)
return ret;
//helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"校正完成", true);
return ret;
}
2024-10-14 11:18:12 +00:00
int test::test_image_correct_all_306(void* data)
{
if (!data)
2024-06-25 14:24:04 +00:00
{
return SCANNER_ERR_NO_DATA;
2024-06-25 14:24:04 +00:00
}
wchar_t* sc = (wchar_t*)data;
std::string str;
size_t len = 0;
int ret = wchar_to_char(str, sc, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
2024-06-25 14:24:04 +00:00
{
str.resize(len);
ret = wchar_to_char(str, sc, &len);
2024-06-25 14:24:04 +00:00
}
2022-12-15 11:53:41 +00:00
g_currentCorrectType = 1;
g_dynamicCorrectStatus = SCANNER_ERR_OK;
if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable())
thread_dynamic_correct_handle->join();
thread_dynamic_correct_handle.reset(new std::thread(&test::thread_dynamic_correct, this, str));
2022-12-15 11:53:41 +00:00
return SCANNER_ERR_OK;
}
2022-12-15 11:53:41 +00:00
2024-10-14 11:18:12 +00:00
int test::test_image_correct_all_3399(void* data)
{
if (!data)
{
return SCANNER_ERR_NO_DATA;
}
wchar_t* sc = (wchar_t*)data;
std::string str;
size_t len = 0;
int ret = wchar_to_char(str, sc, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
str.resize(len);
ret = wchar_to_char(str, sc, &len);
}
g_currentCorrectType = 1;
g_dynamicCorrectStatus = SCANNER_ERR_OK;
if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable())
thread_dynamic_correct_handle->join();
thread_dynamic_correct_handle.reset(new std::thread(&test::thread_dynamic_correct_3399, this, str));
return SCANNER_ERR_OK;
}
int test::test_image_correct_rgb_200dpi(void* data)
{
return public_test_image_correct(data, 200, true);
}
2022-12-27 08:26:41 +00:00
int test::test_image_correct_gray_200dpi(void* data)
2022-12-08 10:10:19 +00:00
{
return public_test_image_correct(data, 200, false);
}
int test::test_image_correct_rgb_300dpi(void* data)
{
return public_test_image_correct(data, 300, true);
}
int test::test_image_correct_gray_300dpi(void* data)
{
return public_test_image_correct(data, 300, false);
}
int test::test_image_correct_rgb_600dpi(void* data)
{
return public_test_image_correct(data, 600, true);
}
int test::test_image_correct_gray_600dpi(void* data)
{
return public_test_image_correct(data, 600, false);
2022-12-08 10:10:19 +00:00
}
2024-10-14 11:18:12 +00:00
int test::test_image_correct_rgb_morr_200dpi(void* data)
{
return public_test_image_correct(data, 200, true, true, false);
}
int test::test_image_correct_gray_morr_200dpi(void* data)
{
return public_test_image_correct(data, 200, false, true, false);
}
int test::test_image_correct_rgb_morr_300dpi(void* data)
{
return public_test_image_correct(data, 300, true, true, false);
}
int test::test_image_correct_gray_morr_300dpi(void* data)
{
return public_test_image_correct(data, 300, false, true, false);
}
int test::test_image_correct_rgb_longtext_200dpi(void* data)
{
return public_test_image_correct(data, 200, true, false, true);
}
int test::test_image_correct_gray_longtext_200dpi(void* data)
{
return public_test_image_correct(data, 200, false, false, true);
}
int test::test_image_correct_rgb_longtext_300dpi(void* data)
{
return public_test_image_correct(data, 300, true, false, true);
}
int test::test_image_correct_gray_longtext_300dpi(void* data)
{
return public_test_image_correct(data, 300, false, false, true);
}
DECL_API(int) func_test_init(void* init, ui_helper* helper)
2022-12-08 10:10:19 +00:00
{
if (test_ == nullptr)
{
test_ = new test(helper);
}
return 0;
2022-12-08 10:10:19 +00:00
}
DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper)
2022-12-08 10:10:19 +00:00
{
if (!NAME || !oper || !test_)
2022-12-08 10:10:19 +00:00
{
return -1;
}
g_imageCount = 0;
2023-01-06 09:56:19 +00:00
is_distortion_get_image = false;
is_distortion_get_image_abnormal = false;
2022-12-27 08:26:41 +00:00
int ret = 0;
SANE_Bool type = false;
unsigned int len = sizeof(SANE_Bool);
2023-03-06 07:35:58 +00:00
2022-12-30 09:13:18 +00:00
//ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
return test_->set_test(NAME, oper);
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
{
if (test_ != nullptr)
{
delete test_;
test_ = nullptr;
}
return 0;
}
DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex, bool *isCorrectItem)
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI) != 0 &&
2024-10-14 11:18:12 +00:00
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_3399) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_MORR_300DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_MORR_300DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_200DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_LONGTEXT_300DPI) != 0 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_LONGTEXT_300DPI) != 0)
{
return 0;
}
*currentIndex = g_currentCorrectType - 1;
*isCorrectItem = true;
if (!isSuccess)
{
//if (g_currentCorrectType == 7)
{
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL;
}
}
else
{
//if (g_currentCorrectType == 7)
{
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FINISHED;
}
}
test_->m_waitCorrect.notify_all();
2022-12-08 10:10:19 +00:00
return 0;
2022-12-30 01:28:56 +00:00
}
DECL_API(int) func_test_distortion()
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL_600DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_200DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_300DPI) == 0 ||
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL_600DPI) == 0)
{
test_->m_waitDistortion.notify_all();
}
return 0;
}