Compare commits

...

2 Commits

7 changed files with 229 additions and 71 deletions

View File

@ -53,7 +53,7 @@ Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QS
ui->pbtn_enterTest->setEnabled(false); ui->pbtn_enterTest->setEnabled(false);
ui->label_scanner->setText(tr("Device name: %1").arg(m_devName)); ui->label_scanner->setText(tr("Device name: %1").arg(m_devName));
ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$"))); //ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
ui->lineEdit_sn->setMaxLength(14); ui->lineEdit_sn->setMaxLength(14);
if (handle != nullptr) if (handle != nullptr)

View File

@ -150,8 +150,25 @@ void Form_mainInterface::setDevDisconnect()
m_disconnect = true; m_disconnect = true;
} }
void Form_mainInterface::checkWrongCorrectItem(int correctType) 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++) for (int i = 0; i < ui->tableWidget->rowCount(); i++)
{ {
QTableWidgetItem *item = ui->tableWidget->item(i, 1); QTableWidgetItem *item = ui->tableWidget->item(i, 1);
@ -160,41 +177,57 @@ void Form_mainInterface::checkWrongCorrectItem(int correctType)
QString title = item->text(); QString title = item->text();
QString name = m_map_title_name.value(title).name; QString name = m_map_title_name.value(title).name;
if (1 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name) if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION == name)
{ {
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); correctItemId = i;
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass"));
} }
else if (2 == correctType && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_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)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0)); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass")); 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 (2 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name)
{ {
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0)); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass")); 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 (3 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name)
{ {
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0)); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass")); 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 (4 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name)
{ {
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0)); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass")); 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 (5 == type && HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_600DPI == name)
{ {
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0)); ui->tableWidget->item(i, 2)->setBackgroundColor(pass ? QColor(0,255,0) : QColor(255,0,0));
ui->tableWidget->item(i, 2)->setText(tr("not pass")); ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
}
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));
ui->tableWidget->item(i, 2)->setText(pass ? tr("pass") : tr("not pass"));
allPass = true;
int row = item->row();
ui->tableWidget->selectRow(row + 1);
if (correctItemId >= 0)
{
ui->tableWidget->item(correctItemId, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(correctItemId, 2)->setBackgroundColor(QColor(0,255,0));
ui->tableWidget->item(correctItemId, 2)->setText(tr("pass"));
}
} }
} }
} }
@ -210,7 +243,8 @@ void Form_mainInterface::resetCorrectItems()
QString title = item->text(); QString title = item->text();
QString name = m_map_title_name.value(title).name; QString name = m_map_title_name.value(title).name;
if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name || if (HGPDTTOOLDB_NAME_IMAGE_CORRECTION == name ||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_200DPI == name ||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name || HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_200DPI == name ||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name || HGPDTTOOLDB_NAME_IMAGE_CORRECTION_RGB_300DPI == name ||
HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name || HGPDTTOOLDB_NAME_IMAGE_CORRECTION_GRAY_300DPI == name ||
@ -225,6 +259,34 @@ void Form_mainInterface::resetCorrectItems()
} }
} }
void Form_mainInterface::updateDistortionItem(bool pass)
{
for (int i = 0; i < ui->tableWidget->rowCount(); i++)
{
QTableWidgetItem *item = ui->tableWidget->item(i, 1);
if (item != nullptr)
{
QString name = m_map_title_name.value(m_curItemName).name;
if (m_curItemName== item->text() && HGPDTTOOLDB_NAME_VERIFY_DISTORTION_VAL == 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"));
if (pass)
{
item->setToolTip("");
writeTestLog(tr("Tester: %1, Test item: %2, Test result: Pass!")
.arg(m_accountName).arg(m_curItemName));
on_pbtn_nextStep_clicked();
break;
}
}
}
}
}
void Form_mainInterface::paintEvent(QPaintEvent *event) void Form_mainInterface::paintEvent(QPaintEvent *event)
{ {
(void)event; (void)event;
@ -244,7 +306,7 @@ void Form_mainInterface::on_testResult(QString text)
updateUiEnabled(true); updateUiEnabled(true);
m_isTesting = false; m_isTesting = false;
m_mainwnd->releaseTesting(); m_mainwnd->initTestingRef();
if (m_disconnect) if (m_disconnect)
{ {
@ -276,44 +338,71 @@ void Form_mainInterface::on_testDistortion(float width, float height, float dist
{ {
ui->label_imgInfo->setVisible(true); ui->label_imgInfo->setVisible(true);
ui->label_destortionInfo_200dpi->setVisible(!verify); ui->label_destortionInfo_200dpi->setVisible(true);
ui->label_destortionInfo_300dpi->setVisible(!verify); ui->label_destortionInfo_300dpi->setVisible(true);
ui->label_imgInfo->setText(tr("image pixel: ") + QString::number((width > 0 && width < 9999) ? width : 0.0, 'f', 4) + ui->label_imgInfo->setText(tr("image pixel: ") + QString::number((width > 0 && width < 9999) ? width : 0.0, 'f', 4) +
" * " + QString::number((height > 0 && height < 9999) ? height : 0.0, 'f', 4)); " * " + QString::number((height > 0 && height < 9999) ? height : 0.0, 'f', 4));
if (!verify) if (200 == m_curDpi)
{ {
m_distortion_200dpi = distortion > 0 ? distortion : 0;
ui->label_destortionInfo_200dpi->setText(" 200dpi" + tr("destortion value: ") + QString::number(m_distortion_200dpi, 'f', 4));
if (m_hg != nullptr)
{
m_hg->setDistortValue(m_distortion_200dpi);
}
}
else if (300 == m_curDpi)
{
m_distortion_300dpi = distortion > 0 ? distortion : 0;
ui->label_destortionInfo_300dpi->setText(" 300dpi" + tr("destortion value: ") + QString::number(m_distortion_300dpi, 'f', 4));
if (m_hg != nullptr)
{
m_hg->setDistortValue(m_distortion_300dpi);
}
}
else if (600 == m_curDpi)
{
m_distortion_600dpi = distortion > 0 ? distortion : 0;
ui->label_destortionInfo_600dpi->setText(" 600dpi" + tr("destortion value: ") + QString::number(m_distortion_600dpi, 'f', 4));
if (m_hg != nullptr)
{
m_hg->setDistortValue(m_distortion_600dpi);
}
}
if (verify)
{
bool pass = false;
float absPixcel = std::abs(width - height);
float absDistortion = std::abs(1 - distortion);
if (200 == m_curDpi) if (200 == m_curDpi)
{ {
m_distortion_200dpi = distortion > 0 ? distortion : 0; if ((absPixcel > 0 && absPixcel < 6.0f) || (absDistortion > 0 && absDistortion < 0.002))
ui->label_destortionInfo_200dpi->setText(" 200dpi" + tr("destortion value: ") + QString::number(m_distortion_200dpi, 'f', 4));
if (m_hg != nullptr)
{ {
m_hg->setDistortValue(m_distortion_200dpi); pass = true;
} }
} }
else if (300 == m_curDpi) else if (300 == m_curDpi)
{ {
m_distortion_300dpi = distortion > 0 ? distortion : 0; if ((absPixcel > 0 && absPixcel < 8.0f) || (absDistortion > 0 && absDistortion < 0.002))
ui->label_destortionInfo_300dpi->setText(" 300dpi" + tr("destortion value: ") + QString::number(m_distortion_300dpi, 'f', 4));
if (m_hg != nullptr)
{ {
m_hg->setDistortValue(m_distortion_300dpi); pass = true;
} }
} }
else if (600 == m_curDpi) else if (600 == m_curDpi)
{ {
m_distortion_600dpi = distortion > 0 ? distortion : 0; if ((absPixcel > 0 && absPixcel < 15.0f) || (absDistortion > 0 && absDistortion < 0.002))
ui->label_destortionInfo_600dpi->setText(" 600dpi" + tr("destortion value: ") + QString::number(m_distortion_600dpi, 'f', 4));
if (m_hg != nullptr)
{ {
m_hg->setDistortValue(m_distortion_600dpi); pass = true;
} }
} }
updateDistortionItem(pass);
} }
updateUiEnabled(true); updateUiEnabled(true);

View File

@ -32,8 +32,9 @@ public:
SANE_Handle getDevHandle(); SANE_Handle getDevHandle();
hgscanner *getScanner(); hgscanner *getScanner();
void setDevDisconnect(); void setDevDisconnect();
void checkWrongCorrectItem(int correctType); //1:200dpi-color; 2:200dpi-gray;3:300dpi-color; 4:300dpi-gray;5:600dpi-color; 6:600dpi-gray; void checkDynamicCorrectItem(bool pass, int correctType); //1:200dpi-color; 2:200dpi-gray;3:300dpi-color; 4:300dpi-gray;5:600dpi-color; 6:600dpi-gray;
void resetCorrectItems(); void resetCorrectItems();
void updateDistortionItem(bool pass);
protected: protected:
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent *event) override;

View File

@ -310,6 +310,12 @@ void MainWindow::releaseTesting()
} }
} }
void MainWindow::initTestingRef()
{
m_testingRef = 0;
updateActionStatus(true);
}
bool MainWindow::isTesting() bool MainWindow::isTesting()
{ {
return (m_testingRef != 0); return (m_testingRef != 0);
@ -317,11 +323,11 @@ bool MainWindow::isTesting()
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (isTesting()) // if (isTesting())
{ // {
QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!")); // QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!"));
event->ignore(); // event->ignore();
} // }
} }
int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param) int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param)
@ -453,7 +459,7 @@ void MainWindow::on_sane_dev_remove(QString devName)
if (mainInterface != nullptr) if (mainInterface != nullptr)
{ {
mainInterface->setDevDisconnect(); mainInterface->setDevDisconnect();
//if (!mainInterface->isTesting()) if (!mainInterface->isTesting())
{ {
RemoveInterface(mainInterface); RemoveInterface(mainInterface);
} }
@ -470,19 +476,23 @@ void MainWindow::on_sane_create_interface(SaneParams *saneParams)
{ {
if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_) if (nullptr != mainInterface->getScanner() && nullptr != mainInterface->getScanner()->cb_)
{ {
bool isCorrectItem = false;
int type = 0;
QString info = QString::fromStdString((char*)saneParams->data); QString info = QString::fromStdString((char*)saneParams->data);
if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED)) if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FINISHED))
{ {
int type = 0; func_test_correct(true, &type, &isCorrectItem);
func_test_correct(true, &type); if (isCorrectItem)
}
else if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL))
{
int type = 0;
func_test_correct(false, &type);
if (type > 0)
{ {
mainInterface->checkWrongCorrectItem(type); mainInterface->checkDynamicCorrectItem(true, type);
}
}
else //if (info == QString(STATU_DESC_SCANNER_ERR_IMAGE_CORRECTION_FAIL))
{
func_test_correct(false, &type, &isCorrectItem);
if (isCorrectItem)
{
mainInterface->checkDynamicCorrectItem(false, type);
} }
} }

View File

@ -34,6 +34,7 @@ public:
void updateActionStatus(bool enable); void updateActionStatus(bool enable);
void addTestingRef(); void addTestingRef();
void releaseTesting(); void releaseTesting();
void initTestingRef();
bool isTesting(); bool isTesting();
QString getDevSn(SANE_Handle handle); QString getDevSn(SANE_Handle handle);

View File

@ -140,13 +140,12 @@ int get_json_config_file()
std::cout << buf << std::endl; std::cout << buf << std::endl;
} }
static std::wstring set_test_name_ = L""; static std::wstring set_test_name_ = L"";
//bool is_distortion_get_image = false;
//bool is_distortion_get_image_abnormal = false;
std::atomic<bool> is_distortion_get_image_abnormal(false); std::atomic<bool> is_distortion_get_image_abnormal(false);
std::atomic<bool> is_distortion_get_image(false); std::atomic<bool> is_distortion_get_image(false);
int g_currentCorrectType = 0; int g_imageCount = 0; //本轮出图数量
int g_dynamicCorrectStatus = SCANNER_ERR_OK; int g_currentCorrectType = 0; //动态校正正在进行的子项
int g_dynamicCorrectStatus = SCANNER_ERR_OK; //动态校正结果
std::string test::get_serial_num() std::string test::get_serial_num()
{ {
@ -404,11 +403,11 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
is_distortion_get_image = false; is_distortion_get_image = false;
is_distortion_get_image_abnormal = true; is_distortion_get_image_abnormal = true;
wcscpy(buf, L"畸变修正值获取失败,原因--->"); wcscpy(buf, L"畸变修正值获取失败,原因--->");
break;
} }
else else
{ {
is_distortion_get_image = true; is_distortion_get_image = true;
is_distortion_get_image_abnormal = false;
//type = true; //type = true;
//wcscpy(buf, L"畸变修正值获取完成:"); //wcscpy(buf, L"畸变修正值获取完成:");
break; break;
@ -490,6 +489,16 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
wcscpy(buf, L"单张测试失败, 原因--->"); 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 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_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_RGB_300DPI) == 0
@ -510,6 +519,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
wcscat(buf, wstr.c_str()); wcscat(buf, wstr.c_str());
//ret = h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认 //ret = h->io_control(IO_CTRL_CODE_RESTORE_SETTINGS, NULL, NULL);//结束恢复默认
bool correctFail = false;
if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0) if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_CORRECTION) == 0)
{ {
if (g_currentCorrectType == 7) if (g_currentCorrectType == 7)
@ -521,6 +531,7 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
{ {
type = false; type = false;
h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type); h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)buf, type);
correctFail = true;
break; break;
} }
else if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FINISHED) else if (g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FINISHED)
@ -537,6 +548,14 @@ static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int
count++; 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);
}
} }
else else
{ {
@ -561,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 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_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_SKEW_DETECTION) == 0
|| wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_IMAGE_GRAY_QUALITY) == 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 || wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0
@ -586,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) || 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) if (wcscmp(set_test_name_.c_str(), HGPDTTOOLDB_NAME_GET_DISTORTION_VAL) == 0)
{ {
is_distortion_get_image = true; is_distortion_get_image = true;
@ -739,13 +760,13 @@ void test::thread_dynamic_correct(std::string correctData)
{ {
std::unique_lock<std::mutex> lock(m_lock); std::unique_lock<std::mutex> lock(m_lock);
while (g_currentCorrectType <= 6) while (g_currentCorrectType <= 6)
{ {
if (g_currentCorrectType > 1) if (g_currentCorrectType > 1)
m_waitCorrect.wait(lock); m_waitCorrect.wait(lock);
if (g_currentCorrectType == 0) if (g_currentCorrectType == 0 || g_dynamicCorrectStatus == SCANNER_ERR_IMAGE_CORRECTION_FAIL)
{ {
return; break;
} }
SANE_Bool type = true; SANE_Bool type = true;
@ -775,12 +796,24 @@ void test::thread_distortion()
if (ret != SCANNER_ERR_OK) if (ret != SCANNER_ERR_OK)
{ {
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_RESULT, (void*)L"自动计算畸变值获取失败", false);
return;
} }
int cnt = 0; int cnt = 0;
SANE_DISTORTION_VAL dis = { 0 }; SANE_DISTORTION_VAL dis = { 0 };
if (is_distortion_get_image_abnormal)
{
return;
}
m_waitDistortion.wait(lock); 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); ret = helper_->io_control(IO_CTRL_CODE_GET_PC_DISTORTION_CHECK_VAL, &dis, &len);
if (dis.h > 0 && dis.scaleXY < 10) if (dis.h > 0 && dis.scaleXY < 10)
@ -1004,7 +1037,13 @@ int test::test_host_fan(void* data)
/* 扫描工作状态 */ /* 扫描工作状态 */
int test::test_scan_work_status(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接口 */ /* USB-PC接口 */
int test::test_usb_pc_interface(void* data) int test::test_usb_pc_interface(void* data)
@ -1231,8 +1270,10 @@ int test::test_get_auto_distortion(void* data)
} }
//先默认设置1 //先默认设置1
float distortion = 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_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()) if (thread_distortion_handle.get() && thread_distortion_handle->joinable())
thread_distortion_handle->join(); thread_distortion_handle->join();
@ -1874,6 +1915,7 @@ int test::test_image_correct_all(void* data)
} }
g_currentCorrectType = 1; g_currentCorrectType = 1;
g_dynamicCorrectStatus = SCANNER_ERR_OK;
if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable()) if (thread_dynamic_correct_handle.get() && thread_dynamic_correct_handle->joinable())
thread_dynamic_correct_handle->join(); thread_dynamic_correct_handle->join();
thread_dynamic_correct_handle.reset(new std::thread(&test::thread_dynamic_correct, this, str)); thread_dynamic_correct_handle.reset(new std::thread(&test::thread_dynamic_correct, this, str));
@ -1923,6 +1965,8 @@ DECL_API(int) func_test_go(const wchar_t* NAME, const wchar_t* oper)
return -1; return -1;
} }
g_imageCount = 0;
is_distortion_get_image = false; is_distortion_get_image = false;
is_distortion_get_image_abnormal = false; is_distortion_get_image_abnormal = false;
@ -1944,19 +1988,32 @@ DECL_API(int) func_test_uninit(void* uninit)
return 0; 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) if (!isSuccess)
{ {
*currentIndex = g_currentCorrectType - 1; //if (g_currentCorrectType == 7)
if (g_currentCorrectType == 7)
{ {
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL; g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FAIL;
} }
} }
else else
{ {
if (g_currentCorrectType == 7) //if (g_currentCorrectType == 7)
{ {
g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FINISHED; g_dynamicCorrectStatus = SCANNER_ERR_IMAGE_CORRECTION_FINISHED;
} }

View File

@ -296,7 +296,7 @@ DECL_API(int) func_test_uninit(void*);
// isSuccess - Explain whether the correction was successful this time. // isSuccess - Explain whether the correction was successful this time.
// //
// Return: error code // 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(); DECL_API(int) func_test_distortion();