2022-12-08 10:10:19 +00:00
|
|
|
|
#include"test_base.h"
|
|
|
|
|
#include<string>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <iostream>
|
2022-12-14 06:58:06 +00:00
|
|
|
|
#include "huagao/hgscanner_error.h"
|
2022-12-08 10:10:19 +00:00
|
|
|
|
|
2022-12-15 11:53:41 +00:00
|
|
|
|
|
|
|
|
|
class test
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
2022-12-15 11:53:41 +00:00
|
|
|
|
ui_helper* helper_;
|
|
|
|
|
public:
|
|
|
|
|
test(ui_helper* helper) :helper_(helper)
|
|
|
|
|
{}
|
|
|
|
|
~test()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
std::map<const wchar_t*, test> test_map_;
|
|
|
|
|
void init_test_map_()
|
|
|
|
|
{
|
|
|
|
|
// test_map_[HGPDTTOOLDB_NAME_DIAL_SWITCH] = &test::test_dial_switch;
|
|
|
|
|
}
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD>뿪<EFBFBD><EBBFAA>У<EFBFBD><D0A3> */
|
|
|
|
|
int test_dial_switch()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ui_helper::test_event ev = ui_helper::TEST_EVENT_TIPS;
|
|
|
|
|
int ret = helper_->io_control(IO_CTRL_CODE_BASE, NULL, NULL);
|
|
|
|
|
helper_->test_callback(HGPDTTOOLDB_NAME_DIAL_SWITCH, ev, NULL, ret);
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD>鴬<EFBFBD>Ϳ<EFBFBD><CDBF>ع<EFBFBD><D8B9><EFBFBD> */
|
|
|
|
|
int test_pocker_switch()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20>豸<EFBFBD>ϵ粢<CFB5>۲쿪<DBB2><ECBFAA>״̬ */
|
|
|
|
|
int test_boot_status()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD>ʾ */
|
|
|
|
|
int test_lcd_display()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> */
|
|
|
|
|
int tset_clear_paper_path()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD><DCBC><EFBFBD> */
|
|
|
|
|
int test_key_funtion()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_count_mode()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><>б<EFBFBD><D0B1><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_skew_detection()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_separater_motor()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* cisԭͼ<D4AD><CDBC><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_cis__original_image()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȹ<EFBFBD><C8B9>ܼ<EFBFBD><DCBC><EFBFBD> */
|
|
|
|
|
int test_host_fan()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_ultrasonic_module()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* led<65><64>״̬<D7B4><CCAC><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_led_light()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_reset()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_paper_feed()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_cover_sensor()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* ɨ<>贫<EFBFBD><E8B4AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_scanning_sensor()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>ģʽ */
|
|
|
|
|
int test_configure_speed_mode()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ֽ */
|
|
|
|
|
int test_place_correction_paper()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20>Զ<EFBFBD>ƽ<EFBFBD><C6BD>У<EFBFBD><D0A3> */
|
|
|
|
|
int test_auto_flat_field()
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>豸 */
|
|
|
|
|
int test_reboot_device()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* ɨ<><C9A8>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7> */
|
|
|
|
|
int test_image_quality()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* ɫ<><C9AB>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_colorcard_imageing_quality()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* ɫ<><C9AB>ֽƫɫ<C6AB><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_colorcard_bias_imageing_quality()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_clarity_quality()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_distortion()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_dormancy()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><>б<EFBFBD><D0B1>λ<EFBFBD><CEBB><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_skew_gear()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><>ֽǿ<D6BD>ȼ<EFBFBD><C8BC><EFBFBD> */
|
|
|
|
|
int test_paper_separation_strength()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><>е<EFBFBD><D0B5>ֽ<EFBFBD><D6BD>б<EFBFBD><D0B1><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_mech_paper_feeding_inclination()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>1 */
|
|
|
|
|
int test_single_page_test_1()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>2 */
|
|
|
|
|
int test_single_page_test_2()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>3 */
|
|
|
|
|
int test_single_page_test_3()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32> */
|
|
|
|
|
int test_pressuer_test()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int test_clear_roller_count()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
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-14 06:58:06 +00:00
|
|
|
|
static std::string jsontext1("{\"1\":{\"name\":\"test-8\",\"ver\":1}}");
|
2022-12-15 11:53:41 +00:00
|
|
|
|
std::string str_ret_call_= "";
|
|
|
|
|
bool have_img_ = false;
|
2022-12-15 02:54:09 +00:00
|
|
|
|
int sane_ex_callback1(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param)
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
switch (code)
|
|
|
|
|
{
|
|
|
|
|
case SANE_EVENT_WORKING:
|
|
|
|
|
{
|
2022-12-15 11:53:41 +00:00
|
|
|
|
str_ret_call_ = (char*)data;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SANE_EVENT_SCAN_FINISHED:
|
|
|
|
|
{
|
2022-12-15 11:53:41 +00:00
|
|
|
|
str_ret_call_ = (char*)data;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SANE_EVENT_STATUS:
|
|
|
|
|
{
|
2022-12-15 11:53:41 +00:00
|
|
|
|
str_ret_call_ = (char*)data;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SANE_EVENT_ERROR:
|
|
|
|
|
{
|
2022-12-15 11:53:41 +00:00
|
|
|
|
str_ret_call_ = (char*)data;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case SANE_EVENT_IMAGE_OK:
|
|
|
|
|
{
|
|
|
|
|
SANE_Image* sane_img = (SANE_Image*)data;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
have_img_ = true;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int str_to_wchar(std::string str, wchar_t* s, size_t* strlen)
|
|
|
|
|
{
|
|
|
|
|
if (str.empty())
|
|
|
|
|
return ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
|
|
|
|
|
|
size_t size = str.length();
|
|
|
|
|
int len = 0;
|
|
|
|
|
len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, NULL, 0);
|
|
|
|
|
if (*strlen < len)
|
|
|
|
|
{
|
|
|
|
|
*strlen = len;
|
|
|
|
|
return ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
|
}
|
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, s, len);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int get_json_config_file()
|
|
|
|
|
{
|
|
|
|
|
int len = 0;
|
|
|
|
|
char exePath[256];
|
|
|
|
|
char* buf = NULL;
|
|
|
|
|
GetModuleFileNameA(NULL, exePath, 255);
|
|
|
|
|
(strrchr(exePath, '\\'))[1] = 0; //ȥ<><C8A5>ִ<EFBFBD>е<EFBFBD><D0B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
strcat(exePath, "DLLs\\G302.hsc");
|
|
|
|
|
FILE* fp = fopen(exePath, "rb");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
fseek(fp, 0, SEEK_END);
|
|
|
|
|
len = ftell(fp);
|
|
|
|
|
fseek(fp, 0, SEEK_SET);
|
|
|
|
|
buf = new char[len];
|
|
|
|
|
if (!buf)
|
|
|
|
|
{
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
memset(buf, 0, len);
|
|
|
|
|
fread(buf, len, 1, fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
std::cout << buf << std::endl;
|
|
|
|
|
}
|
2022-12-15 02:54:09 +00:00
|
|
|
|
|
2022-12-15 06:39:32 +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-15 06:39:32 +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
|
|
|
|
{
|
|
|
|
|
if (!name || !oper || !helper)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-12-15 02:54:09 +00:00
|
|
|
|
//helper->add_ref();
|
|
|
|
|
helper->register_sane_callback(sane_ex_callback1, NULL);
|
2022-12-08 10:10:19 +00:00
|
|
|
|
|
|
|
|
|
bool flag = false;
|
|
|
|
|
wchar_t* des = NULL;
|
|
|
|
|
int ret = 0;
|
2022-12-12 02:33:25 +00:00
|
|
|
|
size_t map_bool_len = sizeof(Test_Map_Bool) / sizeof(Test_Map_Bool[0]);
|
|
|
|
|
size_t map_str_len = sizeof(Test_Map_String) / sizeof(Test_Map_String[0]);
|
|
|
|
|
size_t map_int_len = sizeof(Test_Map_Int) / sizeof(Test_Map_Int[0]);
|
2022-12-08 10:10:19 +00:00
|
|
|
|
ui_helper::test_event ev = ui_helper::TEST_EVENT_TIPS; //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TEST_EVENT_TIPS<50><53><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TEST_EVENT_RESULT
|
|
|
|
|
|
2022-12-15 11:53:41 +00:00
|
|
|
|
for (size_t i = 0; i < map_bool_len; i++)
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
des = (wchar_t*)Test_Map_Bool[i].title;
|
|
|
|
|
if (wcscmp(name, Test_Map_Bool[i].name) == 0) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><C7B2>ᴫ<EFBFBD><E1B4AB><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
SANE_Bool map_bool = true;
|
|
|
|
|
unsigned int len = sizeof(SANE_Bool);
|
2022-12-15 02:54:09 +00:00
|
|
|
|
ret = helper->io_control(Test_Map_Bool[i].num,(void *)&map_bool, &len);
|
2022-12-08 10:10:19 +00:00
|
|
|
|
ev = ui_helper::TEST_EVENT_RESULT;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
helper->test_callback(Test_Map_Bool[i].name, ev, NULL, ret);
|
|
|
|
|
|
2022-12-15 02:54:09 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
2022-12-15 11:53:41 +00:00
|
|
|
|
/*else if(wcscmp(name, Test_Map_String[i].name) == 0)
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
2022-12-12 02:33:25 +00:00
|
|
|
|
else if (wcscmp(name, Test_Map_Int[i].name) == 0)
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_OK;
|
2022-12-15 11:53:41 +00:00
|
|
|
|
}*/
|
2022-12-08 10:10:19 +00:00
|
|
|
|
}
|
2022-12-15 06:39:32 +00:00
|
|
|
|
ret = helper->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);
|
2022-12-15 02:54:09 +00:00
|
|
|
|
//helper->release();
|
|
|
|
|
//helper->unregister_sane_callback(sane_ex_callback);
|
2022-12-15 11:53:41 +00:00
|
|
|
|
if (!helper)
|
|
|
|
|
{
|
|
|
|
|
return SCANNER_ERR_NO_DATA;
|
|
|
|
|
}
|
|
|
|
|
//test ts(helper);
|
2022-12-08 10:10:19 +00:00
|
|
|
|
return SCANNER_ERR_OK;
|
|
|
|
|
}
|
2022-12-15 06:39:32 +00:00
|
|
|
|
DECL_API(int) func_test_uninit(void* uninit)
|
2022-12-08 10:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|