调整设置序列号的流程

This commit is contained in:
13038267101 2023-01-04 17:25:14 +08:00
parent 4013e3f7da
commit 669fa9a7a5
1 changed files with 26 additions and 19 deletions

View File

@ -76,6 +76,22 @@ static int str_to_wchar(std::string str, wchar_t* s, size_t* strlen)
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)
{
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);
return 0;
}
int get_json_config_file()
{
int len = 0;
@ -122,9 +138,9 @@ class test
{
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_RESULT, (void*)L"设置vidpid成功", true);
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_RESULT, (void*)L"设置vidpid失败", false);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置vidpid失败", false);
}
return ret;
}
@ -133,14 +149,15 @@ class test
{
wchar_t* sn = (wchar_t*)data;
std::string set_sn = (char*)data,
std::string set_sn,
get_sn;
int ret = SCANNER_ERR_OK;
size_t len = 0;
ret = str_to_wchar(set_sn, sn, &len);
ret = wchar_to_char(set_sn, sn, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
ret = str_to_wchar(set_sn, sn, &len);
set_sn.resize(len);
ret = wchar_to_char(set_sn, sn, &len);
}
unsigned int setlen = set_sn.size(),
getlen = 0;
@ -149,18 +166,8 @@ class test
if (ret != SCANNER_ERR_OK)return ret;
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn, &getlen);
if (ret == SCANNER_ERR_INSUFFICIENT_MEMORY)
{
get_sn.resize(getlen);
ret = helper_->io_control(IO_CTRL_CODE_GET_SERIAL, &get_sn, &getlen);
}
if (ret != SCANNER_ERR_OK)return ret;
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置序列号完成", true);
if (set_sn == get_sn)
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 ret;
}
/* 设置休眠 */
@ -194,9 +201,9 @@ class test
gettime /= 60;
if (sleep_time == gettime)
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)L"设置休眠时间成功", true);
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_RESULT, (void*)L"设置休眠时间失败", false);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)L"设置休眠时间失败", false);
return ret;
}
/*获取固件版本号*/
@ -275,7 +282,7 @@ class test
wcscat(buf, c);
infocat = buf;
}
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)infocat, type);
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_MANUAL_CONFIRMATION, (void*)infocat, type);
return SCANNER_ERR_OK;
}
public: