sane回调增加获取设备状态
This commit is contained in:
parent
06085b9fb8
commit
68a947ca67
|
@ -81,6 +81,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
|
||||||
, m_devSerialNum("")
|
, m_devSerialNum("")
|
||||||
, m_devVersionNum("")
|
, m_devVersionNum("")
|
||||||
, m_currDeviceName("")
|
, m_currDeviceName("")
|
||||||
|
, m_devPid("")
|
||||||
, m_cacheDirNotify(false)
|
, m_cacheDirNotify(false)
|
||||||
, m_AquirePathNotify(false)
|
, m_AquirePathNotify(false)
|
||||||
, m_bSideflag(false)
|
, m_bSideflag(false)
|
||||||
|
@ -344,6 +345,7 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent)
|
||||||
connect(this, SIGNAL(scan_working(QString)), this, SLOT(on_scan_working(QString)), Qt::QueuedConnection);
|
connect(this, SIGNAL(scan_working(QString)), this, SLOT(on_scan_working(QString)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(scan_finish(QString, int)), this, SLOT(on_scan_finish(QString, int)), Qt::QueuedConnection);
|
connect(this, SIGNAL(scan_finish(QString, int)), this, SLOT(on_scan_finish(QString, int)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(sane_dev_error(QString)), this, SLOT(on_sane_dev_error(QString)), Qt::QueuedConnection);
|
connect(this, SIGNAL(sane_dev_error(QString)), this, SLOT(on_sane_dev_error(QString)), Qt::QueuedConnection);
|
||||||
|
connect(this, SIGNAL(sane_dev_readyStatus(QString)), this, SLOT(on_sane_dev_readyStatus(QString)), Qt::QueuedConnection);
|
||||||
connect(m_dialogLog, SIGNAL(continueScan()), this, SLOT(on_continueScan()));
|
connect(m_dialogLog, SIGNAL(continueScan()), this, SLOT(on_continueScan()));
|
||||||
connect(m_dialogLog, SIGNAL(stopScan()), this, SLOT(on_stopScan()));
|
connect(m_dialogLog, SIGNAL(stopScan()), this, SLOT(on_stopScan()));
|
||||||
connect(m_dialogLog, SIGNAL(exportScanned()), this, SLOT(on_export_scanned_image()));
|
connect(m_dialogLog, SIGNAL(exportScanned()), this, SLOT(on_export_scanned_image()));
|
||||||
|
@ -682,7 +684,7 @@ void MainWindow::on_AcquireInto2()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid()))
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid))
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -1096,6 +1098,28 @@ void MainWindow::on_sane_dev_error(QString errorInfo)
|
||||||
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(errorInfo).c_str());
|
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(errorInfo).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_sane_dev_readyStatus(QString promptInfo)
|
||||||
|
{
|
||||||
|
if (STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING == promptInfo)
|
||||||
|
{
|
||||||
|
m_wndStatusBar->setDeviceStatusInfo(promptInfo, true);
|
||||||
|
m_dialogLog->addLog(promptInfo, true);
|
||||||
|
//Enable ui...
|
||||||
|
}
|
||||||
|
else if (STATU_DESC_SCANNER_ERR_DEVICE_DEVS_START_SUCCES == promptInfo)
|
||||||
|
{
|
||||||
|
m_devSerialNum = getDevSerialNum();
|
||||||
|
m_devVersionNum = getDevFwVersionNum();
|
||||||
|
m_devPid = getDevPid();
|
||||||
|
|
||||||
|
if (!m_currDeviceName.isEmpty())
|
||||||
|
m_versionDll->PostDeviceOpenInfo(m_currDeviceName.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str());
|
||||||
|
|
||||||
|
m_wndStatusBar->setDeviceStatusInfo(promptInfo, true);
|
||||||
|
m_dialogLog->addLog(promptInfo, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_pre_new_image(void *img)
|
void MainWindow::on_pre_new_image(void *img)
|
||||||
{
|
{
|
||||||
m_saveType = 0;
|
m_saveType = 0;
|
||||||
|
@ -1448,7 +1472,7 @@ void MainWindow::on_continueScan()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid()))
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid))
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -2794,6 +2818,8 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
|
||||||
break;
|
break;
|
||||||
case SANE_EVENT_STATUS:
|
case SANE_EVENT_STATUS:
|
||||||
{
|
{
|
||||||
|
QString promptInfo((char*)data);
|
||||||
|
emit p->sane_dev_readyStatus(promptInfo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SANE_EVENT_ERROR:
|
case SANE_EVENT_ERROR:
|
||||||
|
@ -3473,7 +3499,7 @@ void MainWindow::on_act_acquire_triggered()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid() || "7039" == getDevPid()))//Previous versions of this firmware number and 439 device can only be manually awakened.
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid || "7039" == m_devPid))//Previous versions of this firmware number and 439 device can only be manually awakened.
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -3552,7 +3578,7 @@ void MainWindow::on_act_acquireSingle_triggered()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid()))
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid))
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -3650,7 +3676,7 @@ void MainWindow::on_act_acquireInto_triggered()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid()))
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid))
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -3744,7 +3770,7 @@ void MainWindow::on_act_insertFromScanner_triggered()
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
|
|
||||||
if (m_devVersionNum < "G4393B1001"
|
if (m_devVersionNum < "G4393B1001"
|
||||||
&& ("439" == getDevPid() || "9220" == getDevPid() || "8529" == getDevPid()))
|
&& ("439" == m_devPid || "9220" == m_devPid || "8529" == m_devPid))
|
||||||
{
|
{
|
||||||
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
m_dialogLog->addLog(tr("Please wake up the device manually"), true);
|
||||||
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
m_wndStatusBar->setDeviceStatusInfo(tr("Please wake up the device manually"), true);
|
||||||
|
@ -3867,34 +3893,10 @@ bool MainWindow::open_scanner(const QString& name, const QString& scheme)
|
||||||
{
|
{
|
||||||
bool ret = dev_que_.open_scanner(name.toStdString().c_str(), scheme.toStdString().c_str()) == SANE_STATUS_GOOD;
|
bool ret = dev_que_.open_scanner(name.toStdString().c_str(), scheme.toStdString().c_str()) == SANE_STATUS_GOOD;
|
||||||
QString info(tr("open scanner ") + " " + name + " ");
|
QString info(tr("open scanner ") + " " + name + " ");
|
||||||
QString title(tr("app name"));
|
|
||||||
|
|
||||||
if(ret)
|
if(ret)
|
||||||
{
|
{
|
||||||
std::string serialNum;
|
|
||||||
unsigned int serialNumLen = 0;
|
|
||||||
if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, nullptr, &serialNumLen)
|
|
||||||
&& serialNumLen)
|
|
||||||
{
|
|
||||||
serialNum.resize(serialNumLen);
|
|
||||||
sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, &serialNum[0], &serialNumLen);
|
|
||||||
}
|
|
||||||
m_devSerialNum = QString::fromStdString(serialNum.c_str());
|
|
||||||
|
|
||||||
std::string versionNum;
|
|
||||||
unsigned int versionNumLen = 0;
|
|
||||||
if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, nullptr, &versionNumLen)
|
|
||||||
&& versionNumLen)
|
|
||||||
{
|
|
||||||
versionNum.resize(versionNumLen);
|
|
||||||
sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, &versionNum[0], &versionNumLen);
|
|
||||||
}
|
|
||||||
m_devVersionNum = QString::fromStdString(versionNum.c_str());
|
|
||||||
|
|
||||||
m_versionDll->PostDeviceOpenInfo(name.toStdString().c_str(), m_devSerialNum.toStdString().c_str(), "", m_devVersionNum.toStdString().c_str());
|
|
||||||
m_currDeviceName = name;
|
m_currDeviceName = name;
|
||||||
|
|
||||||
title = name;
|
|
||||||
info += tr("success");
|
info += tr("success");
|
||||||
m_wndStatusBar->setDeviceStatusInfo(info, false);
|
m_wndStatusBar->setDeviceStatusInfo(info, false);
|
||||||
m_dialogLog->addLog(info, false);
|
m_dialogLog->addLog(info, false);
|
||||||
|
@ -3912,7 +3914,6 @@ bool MainWindow::open_scanner(const QString& name, const QString& scheme)
|
||||||
|
|
||||||
m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning);
|
m_dialogLog->updateStatus(dev_que_.is_online() && 0 != m_scanType, m_isScanning);
|
||||||
updateActionStatus();
|
updateActionStatus();
|
||||||
// setWindowTitle(title);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4346,6 +4347,32 @@ QString MainWindow::getDevPid()
|
||||||
return QString::fromStdString(buf2);
|
return QString::fromStdString(buf2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MainWindow::getDevSerialNum()
|
||||||
|
{
|
||||||
|
std::string serialNum;
|
||||||
|
unsigned int serialNumLen = 0;
|
||||||
|
if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, nullptr, &serialNumLen)
|
||||||
|
&& serialNumLen)
|
||||||
|
{
|
||||||
|
serialNum.resize(serialNumLen);
|
||||||
|
sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_SERIAL, &serialNum[0], &serialNumLen);
|
||||||
|
}
|
||||||
|
return QString::fromStdString(serialNum.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MainWindow::getDevFwVersionNum()
|
||||||
|
{
|
||||||
|
std::string versionNum;
|
||||||
|
unsigned int versionNumLen = 0;
|
||||||
|
if(SANE_STATUS_NO_MEM == sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, nullptr, &versionNumLen)
|
||||||
|
&& versionNumLen)
|
||||||
|
{
|
||||||
|
versionNum.resize(versionNumLen);
|
||||||
|
sane_io_control(dev_que_.handle(), IO_CTRL_CODE_GET_HARDWARE_VERSION, &versionNum[0], &versionNumLen);
|
||||||
|
}
|
||||||
|
return QString::fromStdString(versionNum.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::initAcquireIntoComboBox()
|
void MainWindow::initAcquireIntoComboBox()
|
||||||
{
|
{
|
||||||
m_cbtn_acquireIntoCfg = new QComboBox;
|
m_cbtn_acquireIntoCfg = new QComboBox;
|
||||||
|
|
|
@ -99,6 +99,7 @@ signals:
|
||||||
void sane_dev_arrive(QString devName, bool opened);
|
void sane_dev_arrive(QString devName, bool opened);
|
||||||
void sane_dev_remove(QString devName);
|
void sane_dev_remove(QString devName);
|
||||||
void sane_dev_error(QString errorInfo);
|
void sane_dev_error(QString errorInfo);
|
||||||
|
void sane_dev_readyStatus(QString promptInfo);
|
||||||
void pre_new_image(void *img);
|
void pre_new_image(void *img);
|
||||||
void post_new_image(unsigned int ret, int statu);
|
void post_new_image(unsigned int ret, int statu);
|
||||||
void scan_working(QString workingInfo);
|
void scan_working(QString workingInfo);
|
||||||
|
@ -127,6 +128,7 @@ private slots:
|
||||||
void on_sane_dev_arrive(QString devName, bool opened);
|
void on_sane_dev_arrive(QString devName, bool opened);
|
||||||
void on_sane_dev_remove(QString devName);
|
void on_sane_dev_remove(QString devName);
|
||||||
void on_sane_dev_error(QString errorInfo);
|
void on_sane_dev_error(QString errorInfo);
|
||||||
|
void on_sane_dev_readyStatus(QString promptInfo);
|
||||||
void on_pre_new_image(void *img);
|
void on_pre_new_image(void *img);
|
||||||
void on_post_new_image(unsigned int ret, int statu);
|
void on_post_new_image(unsigned int ret, int statu);
|
||||||
void on_scan_working(QString workingInfo);
|
void on_scan_working(QString workingInfo);
|
||||||
|
@ -261,6 +263,8 @@ private:
|
||||||
void deleteOverdueLogFile(const QString& logFilePath);
|
void deleteOverdueLogFile(const QString& logFilePath);
|
||||||
void deleteUpgradePkg(const QString& cfgFilePath);
|
void deleteUpgradePkg(const QString& cfgFilePath);
|
||||||
QString getDevPid();
|
QString getDevPid();
|
||||||
|
QString getDevSerialNum();
|
||||||
|
QString getDevFwVersionNum();
|
||||||
void initAcquireIntoComboBox();
|
void initAcquireIntoComboBox();
|
||||||
void updateSideBar();
|
void updateSideBar();
|
||||||
|
|
||||||
|
@ -336,6 +340,7 @@ private:
|
||||||
QString m_devSerialNum;
|
QString m_devSerialNum;
|
||||||
QString m_devVersionNum;
|
QString m_devVersionNum;
|
||||||
QString m_currDeviceName;
|
QString m_currDeviceName;
|
||||||
|
QString m_devPid;
|
||||||
const char* m_oemName;
|
const char* m_oemName;
|
||||||
bool m_cacheDirNotify;
|
bool m_cacheDirNotify;
|
||||||
bool m_AquirePathNotify;
|
bool m_AquirePathNotify;
|
||||||
|
|
Loading…
Reference in New Issue