调整动态校正进度界面刷新功能,扫描工作状态测试项限制扫描10张

This commit is contained in:
yangjiaxuan 2024-09-25 16:14:53 +08:00
parent 8662f0b9bb
commit a972e9283a
4 changed files with 68 additions and 21 deletions

View File

@ -152,6 +152,21 @@ void Form_mainInterface::setDevDisconnect()
void Form_mainInterface::checkDynamicCorrectItem(bool pass, int correctType)
{
int type = correctType;
QString name = m_map_title_name.value(m_curItemName).name;
if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI)
type = 1;
else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI)
type = 2;
else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI)
type = 3;
else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI)
type = 4;
else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI)
type = 5;
else if (name == HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI)
type = 6;
bool allPass = false;
int correctItemId = -1;
for (int i = 0; i < ui->tableWidget->rowCount(); i++)
@ -167,37 +182,37 @@ void Form_mainInterface::checkDynamicCorrectItem(bool pass, int correctType)
correctItemId = i;
}
if (1 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name)
if (1 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
else if (2 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name)
else if (2 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
else if (3 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name)
else if (3 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
else if (4 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name)
else if (4 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
else if (5 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name)
else if (5 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
else if (6 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI == name)
else if (6 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI == name)
{
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));

View File

@ -368,11 +368,8 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
saneParams->data = content;
saneParams->len = *len;
if (code == SANE_EVENT_SCAN_FINISHED)
{
emit p->sane_create_interface(saneParams);
}
}
return 0;
}
@ -479,21 +476,21 @@ void MainWindow::on_sane_create_interface(SaneParams *saneParams)
{
if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_)
{
bool isCorrectItem = false;
int type = 0;
QString info = QString::fromStdString((char*)saneParams->data);
if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED))
{
int type = 0;
func_test_correct(true, &type);
if (type > 0)
func_test_correct(true, &type, &isCorrectItem);
if (isCorrectItem)
{
mainInterface->checkDynamicCorrectItem(true, type);
}
}
else //if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL))
{
int type = 0;
func_test_correct(false, &type);
if (type > 0)
func_test_correct(false, &type, &isCorrectItem);
if (isCorrectItem)
{
mainInterface->checkDynamicCorrectItem(false, type);
}

View File

@ -143,8 +143,9 @@ static std::wstring set_test_name_ = L"";
std::atomic<bool> is_distortion_get_image_abnormal(false);
std::atomic<bool> is_distortion_get_image(false);
int g_currentCorrectType = 0;
int g_dynamicCorrectStatus = SCANNER_ERR_OK;
int g_imageCount = 0; //本轮出图数量
int g_currentCorrectType = 0; //动态校正正在进行的子项
int g_dynamicCorrectStatus = SCANNER_ERR_OK; //动态校正结果
std::string test::get_serial_num()
{
@ -488,6 +489,16 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
wcscpy(buf, L"单张测试失败, 原因--->");
}
}
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
@ -569,6 +580,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
{
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_CIS_ORIGINAL_IMAGE) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_COLOR_QUALITY) == 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_IMAGE_GRAY_QUALITY) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0
@ -594,6 +606,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) == 0)
{
g_imageCount++;
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0)
{
is_distortion_get_image = true;
@ -1024,7 +1037,13 @@ int test::test_host_fan(void* data)
/* 扫描工作状态 */
int test::test_scan_work_status(void* data)
{
return helper_->io_control(IO_CTRL_CODE_GET_IMAGE, NULL, NULL);
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)
@ -1251,8 +1270,10 @@ int test::test_get_auto_distortion(void* data)
}
//先默认设置1
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);
if (thread_distortion_handle.get() && thread_distortion_handle->joinable())
thread_distortion_handle->join();
@ -1944,6 +1965,8 @@ DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper)
return -1;
}
g_imageCount = 0;
is_distortion_get_image = false;
is_distortion_get_image_abnormal = false;
@ -1965,9 +1988,21 @@ DECL_API(int) func_test_uninit(void* uninit)
return 0;
}
DECL_API(int) func_test_correct(bool isSuccess, int *currentIndex)
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 &&
wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_600DPI) != 0)
{
return 0;
}
*currentIndex = g_currentCorrectType - 1;
*isCorrectItem = true;
if (!isSuccess)
{

View File

@ -296,7 +296,7 @@ DECL_API(int) func_test_uninit(void*);
// isSuccess - Explain whether the correction was successful this time.
//
// Return: error code
DECL_API(int) func_test_correct(bool isSuccess, int* currentIndex);
DECL_API(int) func_test_correct(bool isSuccess, int* currentIndex, bool* isCorrectItem);
DECL_API(int) func_test_distortion();