争对版本固件做处理

This commit is contained in:
13038267101 2023-03-20 17:24:38 +08:00
parent 9118a4a81d
commit c89a4c8700
2 changed files with 63 additions and 36 deletions

View File

@ -89,7 +89,7 @@ public:
TEST_EVENT_TIPS = 0, // messages in testing process, data is (wchar_t*), flag is unused
TEST_EVENT_NOT_FIND_TEST, // dll. not find test ,data is (wchar_t*)description, flag is (false)
TEST_EVENT_IO_FAIL, // IO. err flag is SCANNER_ERR_DEVICE_NOT_SUPPORT or io err,data is null
TEST_EVENT_MANUAL_CONFIRMATION, // After send cmd need manual confirmation.
TEST_EVENT_MANUAL_CONFIRMATION, // After send cmd need manual confirmation. struct_write_cfg
TEST_EVENT_RESULT, // test result, data is (wchar_t*)description, flag is (bool)result, true - test pass
TEST_EVENT_HAVE_IMAGE, // have image.
TEST_EVENT_DISTORTION_VAL, // get distortion_val, data is (float) data > 0 flag is true else false

View File

@ -227,12 +227,23 @@ class test
unsigned int len = sizeof(int);
int speed_mode = *((int*)data);
bool type = false;
const wchar_t G139[6] = { 70,80,90,110 };
const wchar_t G239[6] = { 100,110,120,130 };
const wchar_t G300[6] = { 40,50,60,70 };
const wchar_t G400[6] = { 40,50,60,70,80 };
const char G139[6] = { 70,80,90,110 };
const char G239[6] = { 100,110,120,130 };
const char G300[6] = { 40,50,60,70 };
const char G400[6] = { 40,50,60,70,80 };
if (fw_ == 3 || fw_ == 4 && speed_mode >= 40 && speed_mode <= 80)
std::string fv(get_firmware_version());
if (fv.empty())
{
return -1;
}
std::string str = fv.substr(0, 4);
if (str != "G439" && str != "G239" && str != "G139")
{
str = fv.substr(0, 2);
}
if (str == "G3" || str == "G4" && speed_mode >= 40 && speed_mode <= 80)
{
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
{
@ -253,7 +264,7 @@ class test
ret = helper_->io_control(IO_CTRL_CODE_GET_SPEED_MODE, &num, &l);
int save_num = 0;
if (fw_ == 3 || fw_ == 4 && num > 0 && num < 6)
if (str == "G3" || str == "G4" && num > 0 && num < 6)
{
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
{
@ -677,12 +688,21 @@ public:
return -1;
}
}
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)
{
if (fw_ == 3 || fw_ == 4)
if (fvv == "G3" || fvv == "G4")
{
if (len != 14)
{
@ -1359,31 +1379,6 @@ public:
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SLEEPTIME, (void*)&gettime, true);
const wchar_t G139[6] = { 70,80,90,110 };
const wchar_t G239[6] = { 100,110,120,130 };
const wchar_t G300[6] = { 40,50,60,70 };
const wchar_t G400[6] = { 40,50,60,70,80 };
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 (fw_ == 3 || fw_ == 4 && num > 0 && num < 6)
{
for (size_t i = 0; i < sizeof(G400) / sizeof(G400[0]); i++)//3288设置速度模式为1 2 3 4 5
{
if ((num - 1) == i)
{
save_num = G400[i];
break;
}
}
}
else
save_num = num;
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SP, (void*)&save_num, true);
std::string fw(get_firmware_version());
size_t fwlen= 0;
wstr.clear();
@ -1401,6 +1396,38 @@ public:
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_FW, (void*)wstr.c_str(), true);
std::string fvv = fw.substr(0, 4);
if (fvv != "G439" && fvv != "G239" && fvv != "G139")
{
fvv = fw.substr(0, 2);
}
const wchar_t G139[6] = { 70,80,90,110 };
const wchar_t G239[6] = { 100,110,120,130 };
const wchar_t G300[6] = { 40,50,60,70 };
const wchar_t G400[6] = { 40,50,60,70,80 };
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
{
if ((num - 1) == i)
{
save_num = G400[i];
break;
}
}
}
else
save_num = num;
helper_->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVEB_GET_DEVICE_CONFIG_SP, (void*)&save_num, true);
std::string devs_model;
unsigned int devs_len = 0;
l = 0;
@ -1443,7 +1470,7 @@ public:
}
if (str.empty())
{
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 -1;
}
@ -1451,7 +1478,7 @@ public:
ret = helper_->io_control(IO_CTRL_CODE_SET_DEVS_MODEL, &str[0], &l);
if (ret != SCANNER_ERR_OK)return ret;
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"设置设备类型成功", true);
return ret;
}
private: