diff --git a/app/HGProductionTool/ProductionTool_zh_CN.qm b/app/HGProductionTool/ProductionTool_zh_CN.qm index 69bc9ae..665de74 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 2a69151..e4f69be 100644 --- a/app/HGProductionTool/ProductionTool_zh_CN.ts +++ b/app/HGProductionTool/ProductionTool_zh_CN.ts @@ -124,22 +124,22 @@ - + OK 确定 - + Cancel 取消 - + tips 提示 - + please input valid contents 请输入有效内容 @@ -545,88 +545,88 @@ 下一步 - + Device has connected 设备已连接 - + Device hasnot connected 设备未连接 - + Device type: 设备型号: - + SerialNum: 序列号: - + connect status: 设备连接状态: - + load last image which uploaded last time 加载上一次上传的图片 - - + + tips 提示 - + yes 确定 - + no 取消 - + ID 序号 - + Test items 测试项 - + status 测试状态 - + not test 未测试 - + not pass 不通过 - + not support 不支持 - + pass 通过 - + no image 无图 @@ -692,7 +692,7 @@ 上传配置文件 - + Account login elsewhere 账户在其他地方登录 @@ -701,94 +701,104 @@ 网络连接断开 - + 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 设备已断开连接 - + save 保存 - + xls(*.xls) xls表格(*.xls) - + export succeed 导出成功 - + export failed 导出失败 - + Illegal user 非法的用户 - + Wrong password 密码错误 - + Database error 数据库错误 - + connect error 连接错误 - + Failed 错误 @@ -796,18 +806,19 @@ QObject - + success: success 成功: - + + failed: 失败: - + Not find test item 没有找到该测试项 diff --git a/app/HGProductionTool/dialog_login.cpp b/app/HGProductionTool/dialog_login.cpp index ff73a60..486e366 100644 --- a/app/HGProductionTool/dialog_login.cpp +++ b/app/HGProductionTool/dialog_login.cpp @@ -23,17 +23,21 @@ Dialog_logIn::Dialog_logIn(QWidget *parent) : ui->pbtn_setting->setToolTip(tr("Set host and port")); ui->pbtn_minum->setToolTip(tr("Minimize")); ui->pbtn_close->setToolTip(tr("Close")); - ui->label_title->setText(tr("LogIn")); + ui->lineEdit_password->setEchoMode(QLineEdit::EchoMode::Password); QString account("root"); + QString dbHost("192.168.1.70"); + QString dbPort("3306"); + QString ftpHost("192.168.1.70"); + QString ftpPort("21"); + ui->lineEdit_account->setText(getCfgValue("login", "account", account)); -// ui->lineEdit_password->setText("123456"); - ui->lineEdit_password->setEchoMode(QLineEdit::EchoMode::Password); - ui->lineEdit_dbHost->setText("192.168.1.70"); - ui->lineEdit_dbPort->setText("3306"); - ui->lineEdit_ftpHost->setText("192.168.1.70"); - ui->lineEdit_ftpPort->setText("21"); + + ui->lineEdit_dbHost->setText(getCfgValue("login", "dbHost", dbHost)); + ui->lineEdit_dbPort->setText(getCfgValue("login", "dbPort", dbPort)); + ui->lineEdit_ftpHost->setText(getCfgValue("login", "ftpHost", ftpHost)); + ui->lineEdit_ftpPort->setText(getCfgValue("login", "ftpPort", ftpPort)); ui->label_dbHost->setVisible(false); ui->label_dbPort->setVisible(false); @@ -96,12 +100,19 @@ void Dialog_logIn::on_pbtn_login_clicked() { QString account = ui->lineEdit_account->text(); QString password = ui->lineEdit_password->text(); - QString host = ui->lineEdit_dbHost->text(); - QString port = ui->lineEdit_dbPort->text(); + QString dbHost = ui->lineEdit_dbHost->text(); + QString dbPort = ui->lineEdit_dbPort->text(); + QString ftpHost = ui->lineEdit_ftpHost->text(); + QString ftpPort = ui->lineEdit_ftpPort->text(); + saveCfgValue("login", "account", account); + saveCfgValue("login", "dbHost", dbHost); + saveCfgValue("login", "dbPort", dbPort); + saveCfgValue("login", "ftpHost", ftpHost); + saveCfgValue("login", "ftpPort", ftpPort); HGPdtToolDbUserMgr pdtToolDbuserMgr = nullptr; - HGResult ret = HGPdtToolDb_CreateUserMgr(host.toStdString().c_str(), port.toInt(), account.toStdString().c_str(), password.toStdString().c_str(), + HGResult ret = HGPdtToolDb_CreateUserMgr(dbHost.toStdString().c_str(), dbPort.toInt(), account.toStdString().c_str(), password.toStdString().c_str(), &pdtToolDbuserMgr); if (NULL != pdtToolDbuserMgr) { diff --git a/app/HGProductionTool/form_maininterface.cpp b/app/HGProductionTool/form_maininterface.cpp index a4b4683..dab538f 100644 --- a/app/HGProductionTool/form_maininterface.cpp +++ b/app/HGProductionTool/form_maininterface.cpp @@ -70,6 +70,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha , m_devType(devType) , m_devName(devName) , m_devFwNum(devFwNum) + , m_isTesting(false) { ui->setupUi(this); @@ -79,6 +80,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, SANE_Handle ha 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); QString str; if (m_handle) @@ -121,6 +123,11 @@ Form_mainInterface::~Form_mainInterface() delete ui; } +bool Form_mainInterface::isTesting() +{ + return m_isTesting; +} + QString Form_mainInterface::getSn() { return m_serialNum; @@ -178,6 +185,12 @@ void Form_mainInterface::on_testDistortion(QString name, void *data) } } +void Form_mainInterface::on_testFinish() +{ + updateUiEnabled(true); + m_isTesting = false; +} + void Form_mainInterface::on_pbtn_preStep_clicked() { int row = ui->tableWidget->currentRow(); @@ -445,6 +458,20 @@ QString Form_mainInterface::getCacheFileName() 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); +} + void Form_mainInterface::on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous) { (void)previous; @@ -480,6 +507,11 @@ void Form_mainInterface::on_pbtn_start_clicked() QString title = item->text(); QString name = m_map_title_name.value(title).name; int ret = func_test_go(name.toStdWString().c_str(), L"null", m_hg); + if (ret == 0) + { + updateUiEnabled(false); + m_isTesting = true; + } } void Form_mainInterface::on_pbtn_showImg_clicked() diff --git a/app/HGProductionTool/form_maininterface.h b/app/HGProductionTool/form_maininterface.h index 32880d4..47610cb 100644 --- a/app/HGProductionTool/form_maininterface.h +++ b/app/HGProductionTool/form_maininterface.h @@ -24,6 +24,7 @@ public: const QString &serialNum, const QString &devType, const QString &devName, const QString &devFwNum); ~Form_mainInterface(); + bool isTesting(); QString getSn(); QString getDevName(); SANE_Handle getDevHandle(); @@ -36,11 +37,13 @@ signals: void testResult(QString text); void testResultImg(void* img); void testDistortion(QString title, void *data); + void testFinish(); private slots: void on_testResult(QString text); void on_testResultImg(void* img); void on_testDistortion(QString title, void *data); + void on_testFinish(); private slots: void on_pbtn_preStep_clicked(); @@ -71,6 +74,7 @@ private: QString getItemStatusStr(HGUInt status); QString getCachePath(); QString getCacheFileName(); + void updateUiEnabled(bool enable); private: Ui::Form_mainInterface *ui; @@ -88,6 +92,7 @@ private: QString m_devType; QString m_devName; QString m_devFwNum; + bool m_isTesting; QMap m_map_title_name; }; diff --git a/app/HGProductionTool/hgscanner.cpp b/app/HGProductionTool/hgscanner.cpp index cb49541..25b324f 100644 --- a/app/HGProductionTool/hgscanner.cpp +++ b/app/HGProductionTool/hgscanner.cpp @@ -34,22 +34,37 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si if (ev == TEST_EVENT_TIPS) { - } - else if (ev == TEST_EVENT_RESULT) - { - QString ret; - QString info = QString::fromStdWString((const wchar_t*)data); - if (flag) - ret = QObject::tr("success: ") + info; - else - ret = QObject::tr("failed: ") + info; - - emit m_interface->testResult(ret); } else if (ev == TEST_EVENT_NOT_FIND_TEST) { QString info = QObject::tr("Not find test item"); emit m_interface->testResult(info); + emit m_interface->testFinish(); + } + else if (ev == TEST_EVENT_IO_FAIL) + { + QString info = QString::fromStdWString((const wchar_t*)data); + info = QObject::tr("failed: ") + info; + + emit m_interface->testResult(info); + emit m_interface->testFinish(); + } + else if (ev == TEST_EVENT_MANUAL_CONFIRMATION) + { + QString info = QString::fromStdWString((const wchar_t*)data); + emit m_interface->testResult(info); + emit m_interface->testFinish(); + } + else if (ev == TEST_EVENT_RESULT) + { + QString info = QString::fromStdWString((const wchar_t*)data); + if (flag) + info = QObject::tr("success: ") + info; + else + info = QObject::tr("failed: ") + info; + + emit m_interface->testResult(info); + emit m_interface->testFinish(); } else if (ev == TEST_EVENT_DISTORTION) { diff --git a/app/HGProductionTool/mainwindow.cpp b/app/HGProductionTool/mainwindow.cpp index 27df5b0..307b7ff 100644 --- a/app/HGProductionTool/mainwindow.cpp +++ b/app/HGProductionTool/mainwindow.cpp @@ -232,6 +232,42 @@ bool MainWindow::RemoveInterface(Form_mainInterface *interface) return true; } +bool MainWindow::isTesting() +{ + bool isTesting = false; + for (int i = 0; i < m_top_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_top_splitter->widget(i); + if (interface->isTesting()) + { + isTesting = true; + break; + } + } + if (!isTesting) + { + for (int i = 0; i < m_bot_splitter->count(); ++i) + { + Form_mainInterface *interface = (Form_mainInterface *)m_bot_splitter->widget(i); + if (interface->isTesting()) + { + isTesting = true; + break; + } + } + } + return isTesting; +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + if (isTesting()) + { + QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!")); + event->ignore(); + } +} + int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigned int *len, void *param) { MainWindow* p = (MainWindow*)param; @@ -387,9 +423,12 @@ void MainWindow::on_update_userStatus() if (!tips.isEmpty()) { - QMessageBox::information(this, (tr("tips")), tips); - m_isLogOut = true; - close(); + if (!isTesting()) + { + QMessageBox::information(this, (tr("tips")), tips); + m_isLogOut = true; + close(); + } } } @@ -440,6 +479,11 @@ void MainWindow::on_act_export_triggered() void MainWindow::on_act_logOut_triggered() { + if (isTesting()) + { + QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!")); + return; + } m_isLogOut = true; close(); } @@ -447,6 +491,12 @@ void MainWindow::on_act_logOut_triggered() void MainWindow::on_act_close_triggered() { + if (isTesting()) + { + QMessageBox::information(this, tr("tips"), tr("Is testing, do not close!")); + return; + } + close(); } diff --git a/app/HGProductionTool/mainwindow.h b/app/HGProductionTool/mainwindow.h index 4928556..31cd0dd 100644 --- a/app/HGProductionTool/mainwindow.h +++ b/app/HGProductionTool/mainwindow.h @@ -30,7 +30,10 @@ public: Form_mainInterface* FindInterface(SANE_Handle handle); bool AddInterface(Form_mainInterface *interface); bool RemoveInterface(Form_mainInterface *interface); - + bool isTesting(); + +protected: + void closeEvent(QCloseEvent *event); private: static int sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned int* len, void* param); diff --git a/cfg-tools/apps/scanner-check/CDlgInput.cpp b/cfg-tools/apps/scanner-check/CDlgInput.cpp new file mode 100644 index 0000000..ead99ad --- /dev/null +++ b/cfg-tools/apps/scanner-check/CDlgInput.cpp @@ -0,0 +1,84 @@ +// CDlgInput.cpp: 实现文件 +// + +#include "pch.h" +#include "scanner-check.h" +#include "CDlgInput.h" +#include "afxdialogex.h" + + +// CDlgInput 对话框 + +IMPLEMENT_DYNAMIC(CDlgInput, CDialogEx) + +CDlgInput::CDlgInput(CWnd* pParent /*=nullptr*/) + : CDialogEx(IDD_INPUT, pParent), val_(L""), title_(L"\u4FEE\u6539") +{ + +} + +CDlgInput::~CDlgInput() +{ +} + +void CDlgInput::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + + +BEGIN_MESSAGE_MAP(CDlgInput, CDialogEx) + ON_BN_CLICKED(IDOK, &CDlgInput::OnBnClickedOk) + ON_EN_CHANGE(IDC_EDIT1, &CDlgInput::OnEnChangeEdit1) +END_MESSAGE_MAP() + + +// CDlgInput 消息处理程序 +BOOL CDlgInput::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + ::SetWindowTextW(m_hWnd, title_.c_str()); + + size_t pos = val_.find(L"\\n"); + while (pos != std::wstring::npos) + { + val_.replace(pos, 2, L"\r\n"); + pos = val_.find(L"\\n"); + } + while ((pos = val_.find(L"\\t")) != std::wstring::npos) + val_.replace(pos, 2, L"\t"); + ::SetDlgItemTextW(m_hWnd, IDC_EDIT1, val_.c_str()); + + return FALSE; +} + +void CDlgInput::OnBnClickedOk() +{ + // TODO: 在此添加控件通知处理程序代码 + wchar_t val[1024] = { 0 }; + + ::GetDlgItemTextW(m_hWnd, IDC_EDIT1, val, _countof(val) - 1); + val_ = val; + + size_t pos = val_.find(L"\r\n"); + while (pos != std::wstring::npos) + { + val_.replace(pos, 2, L"\\n"); + pos = val_.find(L"\r\n"); + } + while ((pos = val_.find(L"\t")) != std::wstring::npos) + val_.replace(pos, 1, L"\\t"); + CDialogEx::OnOK(); +} + + +void CDlgInput::OnEnChangeEdit1() +{ + // TODO: 如果该控件是 RICHEDIT 控件,它将不 + // 发送此通知,除非重写 CDialogEx::OnInitDialog() + // 函数并调用 CRichEditCtrl().SetEventMask(), + // 同时将 ENM_CHANGE 标志“或”运算到掩码中。 + + // TODO: 在此添加控件通知处理程序代码 +} diff --git a/cfg-tools/apps/scanner-check/CDlgInput.h b/cfg-tools/apps/scanner-check/CDlgInput.h new file mode 100644 index 0000000..e07dbe7 --- /dev/null +++ b/cfg-tools/apps/scanner-check/CDlgInput.h @@ -0,0 +1,35 @@ +#pragma once + + +// CDlgInput 对话框 +#include + +class CDlgInput : public CDialogEx +{ + DECLARE_DYNAMIC(CDlgInput) + +public: + CDlgInput(CWnd* pParent = nullptr); // 标准构造函数 + virtual ~CDlgInput(); + + std::wstring val_; + std::wstring title_; + +// 对话框数据 +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_INPUT }; +#endif + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 + virtual BOOL OnInitDialog(); + + DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedOk(); + void set_title(const wchar_t* title) + { + title_ = title ? title : L"\u4FEE\u6539"; + } + afx_msg void OnEnChangeEdit1(); +}; diff --git a/cfg-tools/apps/scanner-check/CDlgItemMgr.cpp b/cfg-tools/apps/scanner-check/CDlgItemMgr.cpp index 10ed44d..1b55dc2 100644 --- a/cfg-tools/apps/scanner-check/CDlgItemMgr.cpp +++ b/cfg-tools/apps/scanner-check/CDlgItemMgr.cpp @@ -1,4 +1,4 @@ -// CDlgItemMgr.cpp: 实现文件 +// CDlgItemMgr.cpp: 实现文件 // #include "pch.h" @@ -78,7 +78,7 @@ END_MESSAGE_MAP() void CDlgItemMgr::OnBnClickedButtonAdd() { // TODO: 在此添加控件通知处理程序代码 - wchar_t text[128] = { 0 }, name[128] = { 0 }, desc[128] = { 0 }; + wchar_t text[1024] = { 0 }, name[1024] = { 0 }, desc[1024] = { 0 }; bool online = is_checked(this, IDC_CHECK_ONLINE), fatal = is_checked(this, IDC_CHECK_FATAL); int ind = -1; @@ -91,7 +91,7 @@ void CDlgItemMgr::OnBnClickedButtonAdd() } for (int i = 0; i < list_.GetItemCount(); ++i) { - wchar_t val[128] = { 0 }; + wchar_t val[1024] = { 0 }; list_.GetItemText(i, 1, val, _countof(val) - 1); if (wcscmp(name, val) == 0) { @@ -141,7 +141,7 @@ void CDlgItemMgr::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) { if (pos.x <= width[i]) { - wchar_t text[128] = { 0 }; + wchar_t text[1024] = { 0 }; if (i < 3) { std::wstring tips(L"\u5220\u9664\u6D4B\u8BD5\u9879\uFF1A"); @@ -170,7 +170,7 @@ void CDlgItemMgr::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) else { CDlgInput input; - wchar_t val[128] = { 0 }; + wchar_t val[1024] = { 0 }; std::wstring def(L""); list_.GetItemText(ind, 2, val, _countof(val) - 1); @@ -215,22 +215,24 @@ std::wstring CDlgItemMgr::get_stored_config_file(void) } void CDlgItemMgr::get_item(int ind, page_config::ITEM* item) { - wchar_t text[128] = { 0 }; + size_t len = 1024; + wchar_t *text = (wchar_t*)malloc(len + 1); - list_.GetItemText(ind, 1, text, _countof(text) - 1); + list_.GetItemText(ind, 1, text, len); item->name = text; - list_.GetItemText(ind, 2, text, _countof(text) - 1); + list_.GetItemText(ind, 2, text, len); item->title = text; - list_.GetItemText(ind, 3, text, _countof(text) - 1); + list_.GetItemText(ind, 3, text, len); item->man = wcscmp(text, L"false") == 0; - list_.GetItemText(ind, 4, text, _countof(text) - 1); + list_.GetItemText(ind, 4, text, len); item->fatal = wcscmp(text, L"true") == 0; - list_.GetItemText(ind, 5, text, _countof(text) - 1); + list_.GetItemText(ind, 5, text, len); item->desc = text; + free(text); } void CDlgItemMgr::load_from_file(const wchar_t* file) { - wchar_t path[MAX_PATH] = { 0 }, + wchar_t *path = (wchar_t*)malloc(MAX_PATH * 4), *sn = path, *n = sn + 40, *t = n + 40, @@ -272,6 +274,7 @@ void CDlgItemMgr::load_from_file(const wchar_t* file) cont.erase(0, pos + 2); } ::PostMessage(GetParent()->m_hWnd, WM_TEST_ITEM_CHANGED, 0, 0); + free(path); } void CDlgItemMgr::load_stored_config(void) { @@ -299,7 +302,7 @@ void CDlgItemMgr::item_changed(void) } bool CDlgItemMgr::get_name(const wchar_t* title, page_config::ITEM* item) { - wchar_t text[128] = { 0 }; + wchar_t text[1024] = { 0 }; for (size_t i = 0; i < list_.GetItemCount(); ++i) { @@ -316,7 +319,7 @@ bool CDlgItemMgr::get_name(const wchar_t* title, page_config::ITEM* item) } bool CDlgItemMgr::get_title(const wchar_t* name, page_config::ITEM* item) { - wchar_t text[128] = { 0 }; + wchar_t text[1024] = { 0 }; for (size_t i = 0; i < list_.GetItemCount(); ++i) { @@ -333,7 +336,7 @@ bool CDlgItemMgr::get_title(const wchar_t* name, page_config::ITEM* item) } void CDlgItemMgr::get_all_items(std::vector& items) { - wchar_t text[128] = { 0 }; + wchar_t text[1024] = { 0 }; for (size_t i = 0; i < list_.GetItemCount(); ++i) { diff --git a/cfg-tools/apps/scanner-check/scannercheck.rc b/cfg-tools/apps/scanner-check/scannercheck.rc index 0fe3a16..8ee34fc 100644 Binary files a/cfg-tools/apps/scanner-check/scannercheck.rc and b/cfg-tools/apps/scanner-check/scannercheck.rc differ diff --git a/cfg-tools/solution/Release/config/stored.txt b/cfg-tools/solution/Release/config/stored.txt index a99b2f0..e20804b 100644 Binary files a/cfg-tools/solution/Release/config/stored.txt and b/cfg-tools/solution/Release/config/stored.txt differ diff --git a/cfg-tools/solution/Release/scanner-check.exe b/cfg-tools/solution/Release/scanner-check.exe index 9605584..4e26d5c 100644 Binary files a/cfg-tools/solution/Release/scanner-check.exe and b/cfg-tools/solution/Release/scanner-check.exe differ