diff --git a/app/HGProductionTool/ProductionTool_zh_CN.qm b/app/HGProductionTool/ProductionTool_zh_CN.qm index 665de74..a5af882 100644 Binary files a/app/HGProductionTool/ProductionTool_zh_CN.qm and b/app/HGProductionTool/ProductionTool_zh_CN.qm differ diff --git a/app/HGProductionTool/ProductionTool_zh_CN.ts b/app/HGProductionTool/ProductionTool_zh_CN.ts index e4f69be..c021f6d 100644 --- a/app/HGProductionTool/ProductionTool_zh_CN.ts +++ b/app/HGProductionTool/ProductionTool_zh_CN.ts @@ -124,12 +124,12 @@ - + OK 确定 - + Cancel 取消 @@ -286,32 +286,32 @@ - + account: 账户: - + password: 密码: - + dbHost: 数据库地址: - + dbPort: 数据库端口: - + ftpHost: FTP地址: - + ftpPort: FTP端口: @@ -324,12 +324,12 @@ 端口号: - + LOG IN 登录 - + EXIT 退出 @@ -349,17 +349,17 @@ 关闭 - + LogIn 登录 - + tips 提示 - + Login failed: 登录失败: @@ -500,133 +500,145 @@ - + + devStatus + + + + Privious Step 上一步 - + PASS 通过 - + FAIL 不通过 - + START 开始测试 - + LeftRotate 左旋转 - + RightRotate 右旋转 - + STOP 关闭 - + SHOWIMG 加载图片 - + Next Step 下一步 - + + Device has connected 设备已连接 - + Device hasnot connected 设备未连接 - + Device type: 设备型号: - + SerialNum: 序列号: - + + connect status: 设备连接状态: - + load last image which uploaded last time 加载上一次上传的图片 - - + + Device has disconnected + 设备已断开 + + + + tips 提示 - + yes 确定 - + no 取消 - + ID 序号 - + Test items 测试项 - + status 测试状态 - + not test 未测试 - + not pass 不通过 - + not support 不支持 - + pass 通过 - + no image 无图 @@ -692,7 +704,7 @@ 上传配置文件 - + Account login elsewhere 账户在其他地方登录 @@ -701,104 +713,108 @@ 网络连接断开 - + You have been forced offline by the administrator account 你已被管理员账户强制下线 - + Data base error 数据库错误 - - - - - - - - - - + + + + + + + + + + tips 提示 - - - + + + Is testing, do not close! 测试中,请勿关闭! - + Are you sure to connect the new device 检测到设备连接,是否启动测试? - + yes 确定 - + no 取消 - - + + cannot create more table 不能创建更多项目 - The device has disconnected - 设备已断开连接 + 设备已断开连接 - + + Open device failed + 打开设备失败 + + + save 保存 - + xls(*.xls) xls表格(*.xls) - + export succeed 导出成功 - + export failed 导出失败 - + Illegal user 非法的用户 - + Wrong password 密码错误 - + Database error 数据库错误 - + connect error 连接错误 - + Failed 错误 @@ -806,14 +822,14 @@ QObject - + success: success 成功: - - + + failed: 失败: diff --git a/app/HGProductionTool/dialog_login.cpp b/app/HGProductionTool/dialog_login.cpp index 02c6496..00237fd 100644 --- a/app/HGProductionTool/dialog_login.cpp +++ b/app/HGProductionTool/dialog_login.cpp @@ -26,6 +26,13 @@ Dialog_logIn::Dialog_logIn(QWidget *parent) : ui->label_title->setText(tr("LogIn")); ui->lineEdit_password->setEchoMode(QLineEdit::EchoMode::Password); + QString ipStr = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; + QString portStr = "[0-9]+$"; + ui->lineEdit_dbHost->setValidator(new QRegExpValidator(QRegExp(ipStr))); + ui->lineEdit_ftpHost->setValidator(new QRegExpValidator(QRegExp(ipStr))); + ui->lineEdit_dbPort->setValidator(new QRegExpValidator(QRegExp(portStr))); + ui->lineEdit_ftpPort->setValidator(new QRegExpValidator(QRegExp(portStr))); + QString account("root"); QString dbHost("192.168.1.70"); QString dbPort("3306"); @@ -33,7 +40,6 @@ Dialog_logIn::Dialog_logIn(QWidget *parent) : QString ftpPort("21"); ui->lineEdit_account->setText(getCfgValue("login", "account", account)); - ui->lineEdit_dbHost->setText(getCfgValue("login", "dbHost", dbHost)); ui->lineEdit_dbPort->setText(getCfgValue("login", "dbPort", dbPort)); ui->lineEdit_ftpHost->setText(getCfgValue("login", "ftpHost", ftpHost)); @@ -161,7 +167,8 @@ QString Dialog_logIn::getCfgValue(const char *appName, const char *key, const QS HGBase_GetConfigPath(cfgPath, 512); strcat(cfgPath, "config.ini"); + std::string def2 = getStdString(def); HGChar value[512] = {0}; - HGBase_GetProfileString(cfgPath, appName, key, getStdString(def).c_str(), value, 512); + HGBase_GetProfileString(cfgPath, appName, key, def2.c_str(), value, 512); return StdStringToUtf8(value).c_str(); } diff --git a/app/HGProductionTool/dialog_login.ui b/app/HGProductionTool/dialog_login.ui index 58a65b6..e86a8ac 100644 --- a/app/HGProductionTool/dialog_login.ui +++ b/app/HGProductionTool/dialog_login.ui @@ -6,7 +6,7 @@ 0 0 - 455 + 473 278 @@ -146,7 +146,7 @@ QPushButton#pbtn_close::hover 40 40 - 381 + 411 141 @@ -220,7 +220,7 @@ QPushButton#pbtn_close::hover 150 20 - 151 + 171 20 @@ -243,7 +243,7 @@ QPushButton#pbtn_close::hover 150 50 - 151 + 171 20 @@ -266,7 +266,7 @@ QPushButton#pbtn_close::hover 150 80 - 151 + 171 20 @@ -289,7 +289,7 @@ QPushButton#pbtn_close::hover 150 110 - 151 + 171 20 diff --git a/app/HGProductionTool/form_maininterface.cpp b/app/HGProductionTool/form_maininterface.cpp index 4ec2992..2106a14 100644 --- a/app/HGProductionTool/form_maininterface.cpp +++ b/app/HGProductionTool/form_maininterface.cpp @@ -65,6 +65,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha , m_mainwnd(mainwnd) , m_hg(nullptr) , m_handle(handle) + , m_disconnect(false) , m_pdtToolDbuserMgr(pdtToolDbuserMgr) , m_pdtToolDbDevice(pdtToolDbDevice) , m_serialNum(serialNum) @@ -89,7 +90,8 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha 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); + ui->label_sn->setText(tr("Device type:") + m_devType + tr(" SerialNum:") + m_serialNum); + ui->label_devStatus->setText(tr(" connect status:") + str); setMinimumWidth(500); ui->tableWidget->setMinimumWidth(400); @@ -150,6 +152,13 @@ hgscanner *Form_mainInterface::getScanner() return m_hg; } +void Form_mainInterface::setDevDisconnect() +{ + QString str = tr("Device has disconnected"); + ui->label_devStatus->setText(tr(" connect status:") + str); + m_disconnect = true; +} + void Form_mainInterface::paintEvent(QPaintEvent *event) { (void)event; @@ -166,6 +175,11 @@ void Form_mainInterface::on_testResult(QString text) updateUiEnabled(true); m_isTesting = false; m_mainwnd->releaseTesting(); + + if (m_disconnect) + { + m_mainwnd->RemoveInterface(this); + } } void Form_mainInterface::on_testResultImg(void *img) @@ -195,6 +209,11 @@ void Form_mainInterface::on_testDistortion(QString name, void *data) updateUiEnabled(true); m_isTesting = false; m_mainwnd->releaseTesting(); + + if (m_disconnect) + { + m_mainwnd->RemoveInterface(this); + } } } @@ -489,7 +508,7 @@ void Form_mainInterface::updateUiEnabled(bool enable) void Form_mainInterface::setGlobalCfg(AnalysisJson analysisJson) { AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal(); - LPWRITECFG p; + LPWRITECFG p = new WRITECFG; p->cat = WRITE_CAT_VID; p->val = &jsonGlobal.vid_to; @@ -510,6 +529,8 @@ void Form_mainInterface::setGlobalCfg(AnalysisJson analysisJson) p->cat = WRITE_CAT_SERIALNUM; p->val = &m_serialNum; func_test_go((const wchar_t*)WRITE_CFG_NAME, (const wchar_t*)p, m_hg); + + delete p; } void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous) diff --git a/app/HGProductionTool/form_maininterface.h b/app/HGProductionTool/form_maininterface.h index 2d5e851..ffb4f08 100644 --- a/app/HGProductionTool/form_maininterface.h +++ b/app/HGProductionTool/form_maininterface.h @@ -29,6 +29,7 @@ public: QString getDevName(); SANE_Handle getDevHandle(); hgscanner *getScanner(); + void setDevDisconnect(); protected: void paintEvent(QPaintEvent *event) override; @@ -87,6 +88,7 @@ private: class MainWindow *m_mainwnd; hgscanner *m_hg; SANE_Handle m_handle; + bool m_disconnect; HGPdtToolDbUserMgr m_pdtToolDbuserMgr; HGPdtToolDbDevice m_pdtToolDbDevice; QString m_serialNum; diff --git a/app/HGProductionTool/form_maininterface.ui b/app/HGProductionTool/form_maininterface.ui index ece8e75..ee4b6c6 100644 --- a/app/HGProductionTool/form_maininterface.ui +++ b/app/HGProductionTool/form_maininterface.ui @@ -23,6 +23,13 @@ + + + + devStatus + + + diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index 8c814ba..2c12a31 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -374,24 +374,30 @@ void MainWindow::on_sane_dev_arrive(QString devName) { SANE_Handle devHandle = nullptr; sane_open(devName.toStdString().c_str(), &devHandle); - - Dialog_InputSerialNum dlg(this, getDevSn(devHandle), getDevType(devHandle)); - if (dlg.exec()) + if (nullptr != devHandle) { - HGPdtToolDbDevice pdtToolDbDevice = nullptr; - HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice); - - Form_mainInterface *mainInterface = new Form_mainInterface(this, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice, - dlg.GetSn(), dlg.GetDevType(), devName, getDevFwNum(devHandle)); - if (!AddInterface(mainInterface)) + Dialog_InputSerialNum dlg(this, getDevSn(devHandle), getDevType(devHandle)); + if (dlg.exec()) { - QMessageBox::information(this, tr("tips"), tr("cannot create more table")); - delete mainInterface; + HGPdtToolDbDevice pdtToolDbDevice = nullptr; + HGPdtToolDb_OpenDevice(m_pdtToolDbuserMgr, dlg.GetSn().toStdString().c_str(), &pdtToolDbDevice); + + Form_mainInterface *mainInterface = new Form_mainInterface(this, devHandle, m_pdtToolDbuserMgr, pdtToolDbDevice, + dlg.GetSn(), dlg.GetDevType(), devName, getDevFwNum(devHandle)); + if (!AddInterface(mainInterface)) + { + QMessageBox::information(this, tr("tips"), tr("cannot create more table")); + delete mainInterface; + } + } + else + { + sane_close(devHandle); } } else { - sane_close(devHandle); + QMessageBox::information(this, tr("tips"), tr("Open device failed")); } } } @@ -401,8 +407,11 @@ void MainWindow::on_sane_dev_remove(QString devName) Form_mainInterface *interface = FindInterfaceByDevName(devName); if (interface != nullptr) { - QMessageBox::information(this, tr("tips"), tr("The device has disconnected")); - RemoveInterface(interface); + interface->setDevDisconnect(); + if (!interface->isTesting()) + { + RemoveInterface(interface); + } } } diff --git a/cfg-tools/solution/Release/config/stored.txt b/cfg-tools/solution/Release/config/stored.txt index 63451f2..4bcedb9 100644 Binary files a/cfg-tools/solution/Release/config/stored.txt and b/cfg-tools/solution/Release/config/stored.txt differ