code_production/app/HGProductionTool/form_maininterface.cpp

558 lines
19 KiB
C++
Raw Normal View History

2022-12-14 06:39:22 +00:00
#include "form_maininterface.h"
#include "ui_form_maininterface.h"
#include <QPainter>
2022-12-16 11:01:30 +00:00
#include <QMessageBox>
#include <QInputDialog>
#include "base/HGBase.h"
2022-12-14 06:39:22 +00:00
#include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h"
2022-12-27 08:25:47 +00:00
#include "HGString.h"
2022-12-14 06:39:22 +00:00
#include "form_texttips.h"
2022-12-14 12:28:25 +00:00
#include "test_base.h"
2022-12-16 11:01:30 +00:00
#include "hgscanner.h"
#include "mainwindow.h"
#include "dialog_excepdesc.h"
2022-12-30 02:43:17 +00:00
#include "huagao/hgscanner_error.h"
2022-12-14 06:39:22 +00:00
2022-12-23 02:42:46 +00:00
typedef struct
{
const wchar_t *title;
HGUInt entryName;
}RELA;
static const RELA Rela[] = {
{HGPDTTOOLDB_TITLE_DIAL_SWITCH, HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH},
{HGPDTTOOLDB_TITLE_ROCKER_SWITCH, HGPDTTOOLDB_ENTRYNAME_ROCKER_SWITCH},
{HGPDTTOOLDB_TITLE_BOOT_STATUS, HGPDTTOOLDB_ENTRYNAME_BOOT_STATUS},
{HGPDTTOOLDB_TITLE_LCD_DISPLAY, HGPDTTOOLDB_ENTRYNAME_LCD_DISPLAY},
{HGPDTTOOLDB_TITLE_CLEAR_PAPER_PATH, HGPDTTOOLDB_ENTRYNAME_CLEAR_PAPER_PATH},
{HGPDTTOOLDB_TITLE_KEY_FUNCTION, HGPDTTOOLDB_ENTRYNAME_KEY_FUNCTION},
{HGPDTTOOLDB_TITLE_COUNTING_MODE, HGPDTTOOLDB_ENTRYNAME_COUNTING_MODE},
{HGPDTTOOLDB_TITLE_SKEW_DETECTION, HGPDTTOOLDB_ENTRYNAME_SKEW_DETECTION},
{HGPDTTOOLDB_TITLE_SEPARATER_MOTOR, HGPDTTOOLDB_ENTRYNAME_SEPARATER_MOTOR},
{HGPDTTOOLDB_TITLE_CIS_ORIGINAL_IMAGE, HGPDTTOOLDB_ENTRYNAME_CIS_ORIGINAL_IMAGE},
{HGPDTTOOLDB_TITLE_HOST_FAN, HGPDTTOOLDB_ENTRYNAME_HOST_FAN},
{HGPDTTOOLDB_TITLE_ULTRASONIC_MODULE, HGPDTTOOLDB_ENTRYNAME_ULTRASONIC_MODULE},
{HGPDTTOOLDB_TITLE_LED_LIGHT, HGPDTTOOLDB_ENTRYNAME_LED_LIGHT},
{HGPDTTOOLDB_TITLE_RESET, HGPDTTOOLDB_ENTRYNAME_RESET},
{HGPDTTOOLDB_TITLE_PAPER_FEED, HGPDTTOOLDB_ENTRYNAME_PAPER_FEED},
{HGPDTTOOLDB_TITLE_COVER_SENSOR, HGPDTTOOLDB_ENTRYNAME_COVER_SENSOR},
{HGPDTTOOLDB_TITLE_SCANNING_SENSOR, HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR},
{HGPDTTOOLDB_TITLE_CONFIGURE_SPEED_MODE, HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE},
{HGPDTTOOLDB_TITLE_PLACE_CORRECTION_PAPER, HGPDTTOOLDB_ENTRYNAME_PLACE_CORRECTION_PAPER},
{HGPDTTOOLDB_TITLE_AUTO_FLAT_FIELD, HGPDTTOOLDB_ENTRYNAME_AUTO_FLAT_FIELD},
{HGPDTTOOLDB_TITLE_REBOOT_DEVICE, HGPDTTOOLDB_ENTRYNAME_REBOOT_DEVICE},
{HGPDTTOOLDB_TITLE_IMAGE_QUALITY, HGPDTTOOLDB_ENTRYNAME_IMAGE_QUALITY},
{HGPDTTOOLDB_TITLE_COLORCARD_IMAGEING_QUALITY, HGPDTTOOLDB_ENTRYNAME_COLORCARD_IMAGEING_QUALITY},
{HGPDTTOOLDB_TITLE_COLORCARD_BIAS_IMAGEING_QUALITY, HGPDTTOOLDB_ENTRYNAME_COLORCARD_BIAS_IMAGEING_QUALITY},
{HGPDTTOOLDB_TITLE_CLARITY_QUALITY, HGPDTTOOLDB_ENTRYNAME_CLARITY_QUALITY},
{HGPDTTOOLDB_TITLE_DISTORTION, HGPDTTOOLDB_ENTRYNAME_DISTORTION},
{HGPDTTOOLDB_TITLE_DORMANCY, HGPDTTOOLDB_ENTRYNAME_DORMANCY},
{HGPDTTOOLDB_TITLE_SKEW_GEAR, HGPDTTOOLDB_ENTRYNAME_SKEW_GEAR},
{HGPDTTOOLDB_TITLE_PAPER_SEPARATION_STRENGTH, HGPDTTOOLDB_ENTRYNAME_PAPER_SEPARATION_STRENGTH},
{HGPDTTOOLDB_TITLE_MECH_PAPER_FEEDING_INCLINATION, HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_1, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_2, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_2},
{HGPDTTOOLDB_TITLE_SINGLE_PAGE_TEST_3, HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_3},
{HGPDTTOOLDB_TITLE_PRESSUER_TEST, HGPDTTOOLDB_ENTRYNAME_PRESSUER_TEST},
{HGPDTTOOLDB_TITLE_CLEAR_ROLLER_COUNT, HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT}
};
2022-12-26 10:38:34 +00:00
Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle handle, HGPdtToolDbUserMgr pdtToolDbuserMgr, HGPdtToolDbDevice pdtToolDbDevice,
2022-12-23 10:32:57 +00:00
const QString &serialNum, const QString &devType, const QString &devName, const QString &devFwNum)
2022-12-16 11:01:30 +00:00
: QWidget(mainwnd)
2022-12-14 06:39:22 +00:00
, ui(new Ui::Form_mainInterface)
2022-12-16 11:01:30 +00:00
, m_mainwnd(mainwnd)
2022-12-26 10:38:34 +00:00
, m_hg(nullptr)
2022-12-16 11:01:30 +00:00
, m_handle(handle)
2022-12-17 05:48:03 +00:00
, m_pdtToolDbuserMgr(pdtToolDbuserMgr)
2022-12-16 11:01:30 +00:00
, m_pdtToolDbDevice(pdtToolDbDevice)
, m_serialNum(serialNum)
, m_devType(devType)
2022-12-23 10:32:57 +00:00
, m_devName(devName)
, m_devFwNum(devFwNum)
, m_isTesting(false)
2022-12-14 06:39:22 +00:00
{
ui->setupUi(this);
2022-12-28 06:57:00 +00:00
QFont ft;
ft.setPointSize(15);
this->setFont(ft);
2022-12-27 08:25:47 +00:00
connect(this, SIGNAL(testResult(QString)), this, SLOT(on_testResult(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(testResultImg(void*)), this, SLOT(on_testResultImg(void*)), Qt::QueuedConnection);
connect(this, SIGNAL(testFinish()), this, SLOT(on_testFinish()), Qt::QueuedConnection);
2022-12-27 08:25:47 +00:00
2022-12-23 10:32:57 +00:00
QString str;
if (m_handle)
str = tr("Device has connected");
else
str = tr("Device hasnot connected");
ui->label_sn->setText(tr("Device type:") + m_devType + tr(" SerialNum:") + m_serialNum + tr(" connect status:") + str);
setMinimumWidth(500);
2022-12-28 06:57:00 +00:00
ui->tableWidget->setMinimumWidth(400);
ui->tableWidget->setMaximumWidth(400);
2022-12-14 12:28:25 +00:00
m_textTips = new Form_textTips();
m_view = new HGImgView();
ui->stackedWidget->addWidget(m_textTips);
ui->stackedWidget->addWidget(m_view);
ui->pbtn_showImg->setToolTip(tr("load last image which uploaded last time"));
2022-12-14 12:28:25 +00:00
2022-12-23 02:42:46 +00:00
initTableWidgetUi();
2022-12-23 10:32:57 +00:00
if(!m_devType.isEmpty())
HGPdtToolDb_SetDeviceType(m_pdtToolDbDevice, m_devType.toStdString().c_str());
if(!m_devFwNum.isEmpty())
HGPdtToolDb_SetDeviceVersion(m_pdtToolDbDevice, m_devFwNum.toStdString().c_str());
if(!m_devName.isEmpty())
HGPdtToolDb_SetDeviceName(m_pdtToolDbDevice, m_devName.toStdString().c_str());
2022-12-26 10:38:34 +00:00
m_hg = new hgscanner(this, m_handle);
2022-12-14 06:39:22 +00:00
}
Form_mainInterface::~Form_mainInterface()
{
2022-12-26 10:38:34 +00:00
delete m_hg;
m_hg = nullptr;
2022-12-23 10:32:57 +00:00
sane_close(m_handle);
2022-12-26 10:38:34 +00:00
m_handle = nullptr;
2022-12-16 11:01:30 +00:00
HGPdtToolDb_CloseDevice(m_pdtToolDbDevice);
2022-12-26 10:38:34 +00:00
m_pdtToolDbDevice = nullptr;
2022-12-16 11:01:30 +00:00
2022-12-14 06:39:22 +00:00
delete ui;
}
bool Form_mainInterface::isTesting()
{
return m_isTesting;
}
2022-12-16 11:01:30 +00:00
QString Form_mainInterface::getSn()
{
return m_serialNum;
}
2022-12-23 10:32:57 +00:00
QString Form_mainInterface::getDevName()
{
return m_devName;
}
2022-12-26 10:38:34 +00:00
SANE_Handle Form_mainInterface::getDevHandle()
{
return m_handle;
}
hgscanner *Form_mainInterface::getScanner()
{
return m_hg;
}
2022-12-14 06:39:22 +00:00
void Form_mainInterface::paintEvent(QPaintEvent *event)
{
(void)event;
QPainter p(this);
p.setPen(QColor("gray"));
p.drawRect(0, 0, width() -1, height() -1);
}
2022-12-27 08:25:47 +00:00
void Form_mainInterface::on_testResult(QString text)
{
QMessageBox::information(this, tr("tips"), text);
}
void Form_mainInterface::on_testResultImg(void *img)
{
HGImage image = (HGImage)img;
ui->stackedWidget->setCurrentWidget(m_view);
m_view->addImage(image);
2022-12-28 06:57:00 +00:00
ui->pbtn_leftRotate->setVisible(true);
ui->pbtn_rightRotate->setVisible(true);
2022-12-27 08:25:47 +00:00
HGBase_DestroyImage(image);
}
2022-12-28 06:57:00 +00:00
void Form_mainInterface::on_testDistortion(QString name, void *data)
{
QString info = QString::fromStdWString((const wchar_t*)data);
QMessageBox msg(QMessageBox::Question, name, info, QMessageBox::Yes | QMessageBox::No, this);
msg.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() == msg.button(QMessageBox::Yes))
{
func_test_go(HGPDTTOOLDB_NAME_SINGLE_PAGE_TEST_1, L"null", m_hg);
}
}
void Form_mainInterface::on_testFinish()
{
updateUiEnabled(true);
m_isTesting = false;
}
2022-12-23 02:42:46 +00:00
void Form_mainInterface::on_pbtn_preStep_clicked()
2022-12-14 06:39:22 +00:00
{
2022-12-23 02:42:46 +00:00
int row = ui->tableWidget->currentRow();
if (row > 0)
2022-12-14 06:39:22 +00:00
{
2022-12-23 02:42:46 +00:00
ui->tableWidget->selectRow(row - 1);
2022-12-14 06:39:22 +00:00
}
}
void Form_mainInterface::on_pbtn_nextStep_clicked()
{
2022-12-23 02:42:46 +00:00
int row = ui->tableWidget->currentRow();
if (row < ui->tableWidget->rowCount() - 1)
{
ui->tableWidget->selectRow(row + 1);
}
2022-12-14 06:39:22 +00:00
}
void Form_mainInterface::on_pbtn_fail_clicked()
{
2022-12-23 02:42:46 +00:00
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
Dialog_ExcepDesc dlg(this);
if (dlg.exec())
{
ui->tableWidget->setItem(row, 2, new QTableWidgetItem(getItemStatusStr(HGPDTTOOLDB_ENTRYSTATUS_NOTPASS)));
ui->tableWidget->item(row, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(row, 2)->setBackgroundColor(QColor(255,0,0));
2022-12-23 02:42:46 +00:00
QString str = dlg.getExcepDesc();
setTestItemStatus(title, HGPDTTOOLDB_ENTRYSTATUS_NOTPASS);
HGPdtToolDb_SetDeviceEntryExcepDesc(m_pdtToolDbDevice, getTestItem(title), str.toStdString().c_str());
QTableWidgetItem *item2 = ui->tableWidget->item(row, 2);
item2->setToolTip(str);
}
2022-12-14 06:39:22 +00:00
}
void Form_mainInterface::on_pbtn_pass_clicked()
{
2022-12-23 02:42:46 +00:00
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
setTestItemStatus(title, HGPDTTOOLDB_ENTRYSTATUS_PASS);
ui->tableWidget->setItem(row, 2, new QTableWidgetItem(getItemStatusStr(HGPDTTOOLDB_ENTRYSTATUS_PASS)));
ui->tableWidget->item(row, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->item(row, 2)->setBackgroundColor(QColor(0,255,0));
HGPdtToolDb_SetDeviceEntryExcepDesc(m_pdtToolDbDevice, getTestItem(title), "");
QTableWidgetItem *item2 = ui->tableWidget->item(row, 2);
item2->setToolTip("");
2022-12-28 13:03:01 +00:00
HGImage img = nullptr;
m_view->getImage(&img);
if (img != nullptr)
{
QString fileName = getCacheFileName();
HGResult ret = HGImgFmt_SaveImage(img, 0, 0, getStdString(fileName).c_str());
if(ret == HGBASE_ERR_OK)
{
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
HGUInt entryName = getTestItem(title);
ret = HGPdtToolDb_UploadDeviceEntryImage(m_pdtToolDbDevice, entryName, m_mainwnd->m_ftpHost.toStdString().c_str(),
m_mainwnd->m_ftpPort, fileName.toStdString().c_str());
QFile file(fileName);
file.remove();
}
}
2022-12-14 12:28:25 +00:00
on_pbtn_nextStep_clicked();
2022-12-14 06:39:22 +00:00
}
2022-12-23 02:42:46 +00:00
void Form_mainInterface::on_pbtn_stop_clicked()
2022-12-16 11:01:30 +00:00
{
2022-12-23 02:42:46 +00:00
m_mainwnd->RemoveInterface(this);
}
void Form_mainInterface::initTableWidgetUi()
{
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->setColumnCount(3);
ui->tableWidget->horizontalHeader()->setDefaultSectionSize(200);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
QStringList header;
header<< tr("ID") << tr("Test items") << tr("status");
ui->tableWidget->setHorizontalHeaderLabels(header);
QFont font = ui->tableWidget->horizontalHeader()->font();
font.setBold(true);
ui->tableWidget->horizontalHeader()->setFont(font);
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->verticalHeader()->setDefaultSectionSize(10);
ui->tableWidget->setFrameShape(QFrame::NoFrame);
ui->tableWidget->setShowGrid(true);
ui->tableWidget->verticalHeader()->setVisible(false);
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableWidget->horizontalHeader()->setFixedHeight(30);
ui->tableWidget->clearContents();
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableWidget->setStyleSheet("selection-background-color:rgb(193,210,240)");
2022-12-17 05:48:03 +00:00
HGChar cfgPath[512] = {0};
HGBase_GetConfigPath(cfgPath, 512);
HGBase_CreateDir(cfgPath);
strcat(cfgPath, m_devType.toStdString().c_str());
strcat(cfgPath, ".json");
HGResult ret = HGPdtToolDb_DownloadFile(m_pdtToolDbuserMgr, m_devType.toStdString().c_str(), cfgPath);
2022-12-22 02:48:06 +00:00
if(ret == HGBASE_ERR_OK)
{
2022-12-17 05:48:03 +00:00
AnalysisJson analysisJson(QString::fromStdString(cfgPath));
2022-12-23 10:32:57 +00:00
std::map<HGUInt, bool> dbEntryItems;
for (int i = HGPDTTOOLDB_ENTRYNAME_DIAL_SWITCH; i <= HGPDTTOOLDB_ENTRYNAME_SCANNING_SENSOR; ++i)
dbEntryItems[i] = false;
for (int i = HGPDTTOOLDB_ENTRYNAME_CONFIGURE_SPEED_MODE; i <= HGPDTTOOLDB_ENTRYNAME_MECH_PAPER_FEEDING_INCLINATION; ++i)
dbEntryItems[i] = false;
for (int i = HGPDTTOOLDB_ENTRYNAME_SINGLE_PAGE_TEST_1; i <= HGPDTTOOLDB_ENTRYNAME_CLEAR_ROLLER_COUNT; ++i)
dbEntryItems[i] = false;
2022-12-17 05:48:03 +00:00
std::vector<AnalysisJson::json_node> list_jsonNode = analysisJson.GetNode();
2022-12-23 02:42:46 +00:00
int count = list_jsonNode.size();
ui->tableWidget->setRowCount(count);
for(int i = 0; i < count; ++i)
2022-12-17 05:48:03 +00:00
{
AnalysisJson::json_node node = list_jsonNode[i];
m_map_title_name.insert(node.title, node);
2022-12-23 02:42:46 +00:00
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(QString::number(i+1)));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(node.title));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
HGUInt status = getTestItemStatus(node.title);
QString statusStr = getItemStatusStr(status);
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(statusStr));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
if (HGPDTTOOLDB_ENTRYSTATUS_NOTPASS == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,0,0));
}
else if (HGPDTTOOLDB_ENTRYSTATUS_NOTSUPP == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(255,255,0));
}
else if (HGPDTTOOLDB_ENTRYSTATUS_PASS == status)
{
ui->tableWidget->item(i, 2)->setBackgroundColor(QColor(0,255,0));
}
2022-12-23 10:32:57 +00:00
HGUInt entry = getTestItem(node.title);
std::map<HGUInt, bool>::iterator iter;
for (iter = dbEntryItems.begin(); iter != dbEntryItems.end(); ++iter)
{
if (entry == iter->first)
{
iter->second = true;
break;
}
}
HGChar desc[512] = {0};
HGPdtToolDb_GetDeviceEntryExcepDesc(m_pdtToolDbDevice, getTestItem(node.title), desc, 512);
QTableWidgetItem *item = ui->tableWidget->item(i, 2);
item->setToolTip(desc);
2022-12-23 10:32:57 +00:00
}
std::map<HGUInt, bool>::iterator iter;
for (iter = dbEntryItems.begin(); iter != dbEntryItems.end(); ++iter)
{
if (!iter->second)
{
HGPdtToolDb_SetDeviceEntryStatus(m_pdtToolDbDevice, iter->first, HGPDTTOOLDB_ENTRYSTATUS_NOTSUPP);
}
2022-12-17 05:48:03 +00:00
}
2022-12-23 02:42:46 +00:00
ui->tableWidget->selectRow(0);
2022-12-22 02:48:06 +00:00
}
2022-12-16 11:01:30 +00:00
}
2022-12-23 10:32:57 +00:00
HGUInt Form_mainInterface::getTestItem(const QString &title)
{
HGUInt entry = 0;
for (int i = 0; i < sizeof(Rela) / sizeof(RELA); ++i)
{
if (0 == wcscmp(title.toStdWString().c_str(), Rela[i].title))
{
entry = Rela[i].entryName;
break;
}
}
return entry;
}
2022-12-23 02:42:46 +00:00
HGUInt Form_mainInterface::getTestItemStatus(const QString &title)
2022-12-16 11:01:30 +00:00
{
2022-12-23 02:42:46 +00:00
HGUInt status = 0;
for (int i = 0; i < sizeof(Rela) / sizeof(RELA); ++i)
{
if (0 == wcscmp(title.toStdWString().c_str(), Rela[i].title))
{
HGPdtToolDb_GetDeviceEntryStatus(m_pdtToolDbDevice, Rela[i].entryName, &status);
break;
}
}
2022-12-17 05:48:03 +00:00
2022-12-23 02:42:46 +00:00
return status;
}
2022-12-17 05:48:03 +00:00
2022-12-23 02:42:46 +00:00
bool Form_mainInterface::setTestItemStatus(const QString &title, HGUInt status)
{
bool ret = false;
for (int i = 0; i < sizeof(Rela) / sizeof(RELA); ++i)
{
if (0 == wcscmp(title.toStdWString().c_str(), Rela[i].title))
{
if (HGBASE_ERR_OK == HGPdtToolDb_SetDeviceEntryStatus(m_pdtToolDbDevice, Rela[i].entryName, status))
ret = true;
break;
}
}
2022-12-17 05:48:03 +00:00
2022-12-23 02:42:46 +00:00
return ret;
}
2022-12-17 05:48:03 +00:00
2022-12-23 02:42:46 +00:00
QString Form_mainInterface::getItemStatusStr(HGUInt status)
{
static const QString statusStr[] = {tr("not test"), tr("not pass"), tr("not support"), tr("pass") };
return statusStr[status];
}
2022-12-17 05:48:03 +00:00
2022-12-27 08:25:47 +00:00
QString Form_mainInterface::getCachePath()
{
HGChar cachePath[512];
HGBase_GetTmpPath(cachePath, 512);
strcat(cachePath, "/Cache/");
return getStdFileName(StdStringToUtf8(cachePath).c_str());
}
QString Form_mainInterface::getCacheFileName()
{
QString cachePath = getCachePath();
HGBase_CreateDir(getStdString(cachePath).c_str());
char uuid[256] = {0};
HGBase_GetUuid(uuid, 256);
QString suffix = ".jpg";
QString fileName = getStdFileName(cachePath + uuid + suffix);
return fileName;
}
void Form_mainInterface::updateUiEnabled(bool enable)
{
ui->tableWidget->setEnabled(enable);
ui->pbtn_preStep->setEnabled(enable);
ui->pbtn_nextStep->setEnabled(enable);
ui->pbtn_pass->setEnabled(enable);
ui->pbtn_fail->setEnabled(enable);
ui->pbtn_start->setEnabled(enable);
ui->pbtn_showImg->setEnabled(enable);
ui->pbtn_leftRotate->setEnabled(enable);
ui->pbtn_rightRotate->setEnabled(enable);
ui->pbtn_stop->setEnabled(enable);
}
2022-12-23 02:42:46 +00:00
void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous)
{
2022-12-26 08:24:20 +00:00
(void)previous;
ui->pbtn_showImg->setVisible(false);
2022-12-28 06:57:00 +00:00
ui->pbtn_leftRotate->setVisible(false);
ui->pbtn_rightRotate->setVisible(false);
2022-12-23 02:42:46 +00:00
int row = current->row();
int count = ui->tableWidget->rowCount();
ui->pbtn_preStep->setEnabled(row != 0);
ui->pbtn_nextStep->setEnabled(row != count- 1);
2022-12-17 05:48:03 +00:00
2022-12-23 02:42:46 +00:00
QTableWidgetItem *item2 = ui->tableWidget->item(row, 1);
QString title = item2->text();
2022-12-17 05:48:03 +00:00
2022-12-26 08:24:20 +00:00
bool man = m_map_title_name.value(title).is_man;
ui->pbtn_start->setEnabled(!man);
2022-12-27 08:25:47 +00:00
m_textTips->setViewContent(m_map_title_name.value(title).desc);
ui->stackedWidget->setCurrentWidget(m_textTips);
2022-12-28 13:03:01 +00:00
m_view->clearImage();
HGUInt entryName = getTestItem(title);
2022-12-28 13:03:01 +00:00
if (HGBASE_ERR_OK == HGPdtToolDb_CheckDeviceEntryImage(m_pdtToolDbDevice, entryName))
{
ui->pbtn_showImg->setVisible(true);
}
2022-12-26 08:24:20 +00:00
}
2022-12-17 05:48:03 +00:00
2022-12-26 08:24:20 +00:00
void Form_mainInterface::on_pbtn_start_clicked()
{
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
2022-12-27 08:25:47 +00:00
QString name = m_map_title_name.value(title).name;
int ret = func_test_go(name.toStdWString().c_str(), L"null", m_hg);
2022-12-30 02:43:17 +00:00
if (SCANNER_ERR_OK == ret)
{
updateUiEnabled(false);
m_isTesting = true;
}
2022-12-30 02:43:17 +00:00
else
{
updateUiEnabled(true);
m_isTesting = false;
}
2022-12-23 02:42:46 +00:00
}
void Form_mainInterface::on_pbtn_showImg_clicked()
{
QString fileName = getCacheFileName();
int row = ui->tableWidget->currentRow();
QTableWidgetItem *item = ui->tableWidget->item(row, 1);
QString title = item->text();
HGResult ret = HGPdtToolDb_DownloadDeviceEntryImage(m_pdtToolDbDevice, getTestItem(title), m_mainwnd->m_ftpHost.toStdString().c_str(),
m_mainwnd->m_ftpPort, fileName.toStdString().c_str());
if(ret == HGBASE_ERR_OK)
{
2022-12-28 06:57:00 +00:00
ui->pbtn_leftRotate->setVisible(true);
ui->pbtn_rightRotate->setVisible(true);
ui->stackedWidget->setCurrentWidget(m_view);
HGImage img;
HGImgFmt_LoadImage(fileName.toStdString().c_str(), 0, 0, 0, 0, &img);
m_view->addImage(img);
QFile file(fileName);
file.remove();
}
else
{
QMessageBox::information(this, tr("tips"), tr("no image"));
}
}
2022-12-28 06:57:00 +00:00
void Form_mainInterface::on_pbtn_leftRotate_clicked()
{
m_view->rotateLeft();
}
void Form_mainInterface::on_pbtn_rightRotate_clicked()
{
m_view->rotateRight();
}