Merge branch 'master' of http://192.168.10.5:8099/sane/code_production
This commit is contained in:
commit
255183fbbf
|
@ -1,16 +1,20 @@
|
|||
#include "dialog_inputserialnum.h"
|
||||
#include "ui_dialog_inputserialnum.h"
|
||||
#include "mainwindow.h"
|
||||
#include "base/HGBase.h"
|
||||
|
||||
Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &devName, SANE_Handle handle, const QString &serialNum, const QString &devType) :
|
||||
Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &devName, HGPdtToolDbUserMgr pdtToolDbuserMgr,
|
||||
SANE_Handle handle, const QString &serialNum, const QString &devType) :
|
||||
QDialog(mainWnd),
|
||||
ui(new Ui::Dialog_InputSerialNum),
|
||||
m_mainWnd(mainWnd),
|
||||
m_handle(handle),
|
||||
m_valid(true),
|
||||
m_serialNum(serialNum),
|
||||
m_devType(devType)
|
||||
, m_devName(devName)
|
||||
m_devType(devType),
|
||||
m_devName(devName),
|
||||
m_pdtToolDbuserMgr(pdtToolDbuserMgr),
|
||||
m_hg(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -21,6 +25,7 @@ Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QS
|
|||
this->setFont(ft);
|
||||
|
||||
ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
|
||||
ui->lineEdit_sn->setMaxLength(14);
|
||||
|
||||
if (handle != nullptr)
|
||||
{
|
||||
|
@ -35,6 +40,11 @@ Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, const QS
|
|||
ui->lineEdit_sn->setText("");
|
||||
ui->pbtn_setSn->setEnabled(false);
|
||||
}
|
||||
|
||||
if (m_handle != nullptr)
|
||||
m_hg = new hgscanner(nullptr, nullptr, this, m_handle);
|
||||
|
||||
connect(this, SIGNAL(testResult()), this, SLOT(on_testResult()));
|
||||
}
|
||||
|
||||
Dialog_InputSerialNum::~Dialog_InputSerialNum()
|
||||
|
@ -63,6 +73,53 @@ void Dialog_InputSerialNum::Invalid(const QString &devName)
|
|||
}
|
||||
}
|
||||
|
||||
void Dialog_InputSerialNum::setSpeedAndSleep()
|
||||
{
|
||||
if (m_hg != nullptr)
|
||||
{
|
||||
HGChar cfgPath[512] = {0};
|
||||
HGBase_GetConfigPath(cfgPath, 512);
|
||||
HGBase_CreateDir(cfgPath);
|
||||
strcat(cfgPath, m_devType.toStdString().c_str());
|
||||
strcat(cfgPath, ".json");
|
||||
|
||||
HGPdtToolDb_DownloadFile(m_pdtToolDbuserMgr, m_devType.toStdString().c_str(), cfgPath);
|
||||
|
||||
AnalysisJson analysisJson(QString::fromStdString(cfgPath));
|
||||
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
||||
LPWRITECFG lp = new WRITECFG;
|
||||
|
||||
VIDPID vidpid;
|
||||
vidpid.VID = jsonGlobal.vid_to;
|
||||
vidpid.PID = jsonGlobal.pid_to;
|
||||
int vidpidValue = vidpid.Value;
|
||||
lp->cat = WRITE_CAT_VID_PID;
|
||||
lp->val = (void*)&vidpidValue;
|
||||
func_test_go(WRITE_CFG_NAME, (const wchar_t*)lp, m_hg);
|
||||
m_mainWnd->addTestingRef();
|
||||
|
||||
int speedMode = jsonGlobal.speed_mode ;
|
||||
lp->cat = WRITE_CAT_SPEED;
|
||||
lp->val = (void*)&speedMode;
|
||||
func_test_go(WRITE_CFG_NAME, (const wchar_t*)lp, m_hg);
|
||||
m_mainWnd->addTestingRef();
|
||||
|
||||
int sleepTime = jsonGlobal.sleep_time;
|
||||
lp->cat = WRITE_CAT_SLEEP;
|
||||
lp->val = (void*)&sleepTime;
|
||||
func_test_go(WRITE_CFG_NAME, (const wchar_t*)lp, m_hg);
|
||||
m_mainWnd->addTestingRef();
|
||||
|
||||
delete lp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Dialog_InputSerialNum::on_testResult()
|
||||
{
|
||||
m_mainWnd->releaseTesting();
|
||||
}
|
||||
|
||||
void Dialog_InputSerialNum::on_pbtn_ok_clicked()
|
||||
{
|
||||
if (!m_valid)
|
||||
|
@ -114,4 +171,6 @@ void Dialog_InputSerialNum::on_pbtn_setSn_clicked()
|
|||
ui->lineEdit_sn->setText(m_mainWnd->getDevSn(m_handle));
|
||||
QMessageBox::information(this, tr("tips"), tr("set sn succeed"));
|
||||
}
|
||||
|
||||
setSpeedAndSleep();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include "sane/sane_ex.h"
|
||||
#include "HGPdtToolDb.h"
|
||||
#include "hgscanner.h"
|
||||
|
||||
namespace Ui {
|
||||
class Dialog_InputSerialNum;
|
||||
|
@ -13,12 +15,31 @@ class Dialog_InputSerialNum : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &devName, SANE_Handle handle, const QString &serialNum, const QString &devType);
|
||||
explicit Dialog_InputSerialNum(class MainWindow *mainWnd, const QString &devName, HGPdtToolDbUserMgr pdtToolDbuserMgr,
|
||||
SANE_Handle handle, const QString &serialNum, const QString &devType);
|
||||
~Dialog_InputSerialNum();
|
||||
|
||||
QString GetSn();
|
||||
QString GetDevType();
|
||||
void Invalid(const QString &devName);
|
||||
void setSpeedAndSleep();
|
||||
|
||||
signals:
|
||||
void testResult();
|
||||
|
||||
private slots:
|
||||
void on_testResult();
|
||||
|
||||
private:
|
||||
union VIDPID
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned short VID;
|
||||
unsigned short PID;
|
||||
};
|
||||
unsigned int Value;
|
||||
};
|
||||
|
||||
private slots:
|
||||
void on_pbtn_ok_clicked();
|
||||
|
@ -36,6 +57,8 @@ private:
|
|||
QString m_serialNum;
|
||||
QString m_devType;
|
||||
QString m_devName;
|
||||
HGPdtToolDbUserMgr m_pdtToolDbuserMgr;
|
||||
hgscanner *m_hg;
|
||||
};
|
||||
|
||||
#endif // DIALOG_INPUTSERIALNUM_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>536</width>
|
||||
<height>206</height>
|
||||
<width>572</width>
|
||||
<height>212</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -45,7 +45,7 @@
|
|||
<x>190</x>
|
||||
<y>80</y>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -107,7 +107,7 @@
|
|||
<x>190</x>
|
||||
<y>30</y>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -120,10 +120,10 @@
|
|||
<widget class="QPushButton" name="pbtn_setSn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<x>390</x>
|
||||
<y>30</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
<width>131</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
|
|
@ -45,8 +45,7 @@ Dialog_UserInput::Dialog_UserInput(ui_helper::value_type type, const QString &ti
|
|||
ft.setPointSize(15);
|
||||
this->setFont(ft);
|
||||
|
||||
|
||||
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^-?(([0-9]{0,16}(\\.[0-9]{1,16})$)|([0-9]+$))")));
|
||||
ui->lineEdit->setValidator(new QRegExpValidator(QRegExp("^-?(([0-9]{0,16}(\\.[0-9]{1,16})$)|([a-zA-Z0-9]+$))")));
|
||||
}
|
||||
|
||||
Dialog_UserInput::~Dialog_UserInput()
|
||||
|
|
|
@ -222,7 +222,7 @@ DeviceManager::DeviceManager(class MainWindow *mainwnd, HGPdtToolDbUserMgr pdtTo
|
|||
m_sn = sn;
|
||||
m_devType = devType;
|
||||
|
||||
m_hg = new hgscanner(nullptr, m_burnMode, m_handle);
|
||||
m_hg = new hgscanner(nullptr, m_burnMode, nullptr, m_handle);
|
||||
}
|
||||
|
||||
DeviceManager::~DeviceManager()
|
||||
|
|
|
@ -49,7 +49,7 @@ Form_mainInterface::Form_mainInterface(class MainWindow *mainwnd, Dialog_logIn::
|
|||
if (m_handle)
|
||||
{
|
||||
str = tr("Device has connected");
|
||||
m_hg = new hgscanner(this, nullptr, m_handle);
|
||||
m_hg = new hgscanner(this, nullptr, nullptr, m_handle);
|
||||
}
|
||||
else
|
||||
str = tr("Device hasnot connected");
|
||||
|
@ -470,13 +470,13 @@ QString Form_mainInterface::getSpeedMode(SANE_Int speedMode)
|
|||
int speed = 0;
|
||||
|
||||
if (m_devType == "G100")
|
||||
speed = G100[(int)speedMode];
|
||||
speed = G100[(int)speedMode - 1];
|
||||
else if (m_devType == "G200")
|
||||
speed = G200[(int)speedMode];
|
||||
speed = G200[(int)speedMode - 1];
|
||||
else if (m_devType == "G300")
|
||||
speed = G300[(int)speedMode];
|
||||
speed = G300[(int)speedMode - 1];
|
||||
else if (m_devType == "G400")
|
||||
speed = G400[(int)speedMode];
|
||||
speed = G400[(int)speedMode - 1];
|
||||
|
||||
return QString::number(speed) + "PPM";
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
#include <QMessageBox>
|
||||
#include "form_maininterface.h"
|
||||
#include "form_burnmode.h"
|
||||
#include "dialog_inputserialnum.h"
|
||||
#include "dialog_userinput.h"
|
||||
#include <QDebug>
|
||||
|
||||
hgscanner::hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, SANE_Handle h)
|
||||
hgscanner::hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, Dialog_InputSerialNum *inputSnDlg, SANE_Handle h)
|
||||
: m_interface(form)
|
||||
, m_burnMode(burnMode)
|
||||
, m_inputSnDlg(inputSnDlg)
|
||||
, devHandle_(h)
|
||||
{
|
||||
cb_ = nullptr;
|
||||
|
@ -71,10 +73,8 @@ void hgscanner::test_callback(const wchar_t* name, test_event ev, void* data, si
|
|||
{
|
||||
if (data != nullptr)
|
||||
{
|
||||
if (m_burnMode != nullptr)
|
||||
{
|
||||
emit m_burnMode->testResult(flag);
|
||||
}
|
||||
if (m_inputSnDlg != nullptr)
|
||||
emit m_inputSnDlg->testResult();
|
||||
}
|
||||
}
|
||||
else if (ev == TEST_EVENT_RESULT)
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
class Form_mainInterface;
|
||||
class Form_BurnMode;
|
||||
class Dialog_InputSerialNum;
|
||||
|
||||
class hgscanner :public ui_helper
|
||||
{
|
||||
public:
|
||||
hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, SANE_Handle h);
|
||||
hgscanner(Form_mainInterface *form, Form_BurnMode *burnMode, Dialog_InputSerialNum *inputSnDlg, SANE_Handle h);
|
||||
~hgscanner();
|
||||
virtual parameter* get_user_input(data_from from, value_type type, const wchar_t* title, const wchar_t* desc = NULL);
|
||||
virtual void test_callback(const wchar_t* name/*test name*/, test_event ev, void* data, size_t flag);
|
||||
|
@ -20,6 +21,7 @@ public:
|
|||
private:
|
||||
class Form_mainInterface *m_interface;
|
||||
class Form_BurnMode *m_burnMode;
|
||||
class Dialog_InputSerialNum *m_inputSnDlg;
|
||||
SANE_Handle devHandle_;
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, Dialog_logIn::LogInT
|
|||
if (m_loginType == Dialog_logIn::LogInType_Burn)
|
||||
{
|
||||
ui->act_newDevice->setVisible(false);
|
||||
ui->act_refreshDevice->setVisible(false);
|
||||
|
||||
m_formBurnMode = new Form_BurnMode(this, this);
|
||||
|
||||
|
@ -51,6 +52,8 @@ MainWindow::MainWindow(HGPdtToolDbUserMgr pdtToolDbuserMgr, Dialog_logIn::LogInT
|
|||
}
|
||||
else
|
||||
{
|
||||
ui->act_refreshDevice->setVisible(true);
|
||||
|
||||
m_top_splitter = new QSplitter(Qt::Horizontal);
|
||||
m_bot_splitter = new QSplitter(Qt::Horizontal);
|
||||
m_top_splitter->setMinimumWidth(600);
|
||||
|
@ -264,6 +267,7 @@ void MainWindow::addTestingRef()
|
|||
{
|
||||
++m_testingRef;
|
||||
|
||||
ui->act_refreshDevice->setEnabled(false);
|
||||
ui->act_close->setEnabled(false);
|
||||
ui->act_manage->setEnabled(false);
|
||||
ui->act_logOut->setEnabled(false);
|
||||
|
@ -278,6 +282,7 @@ void MainWindow::releaseTesting()
|
|||
|
||||
if (0 == m_testingRef)
|
||||
{
|
||||
ui->act_refreshDevice->setEnabled(true);
|
||||
ui->act_close->setEnabled(true);
|
||||
ui->act_manage->setEnabled(true);
|
||||
ui->act_logOut->setEnabled(true);
|
||||
|
@ -418,7 +423,7 @@ void MainWindow::on_sane_dev_arrive(QString devName)
|
|||
sane_open(devName.toStdString().c_str(), &devHandle);
|
||||
if (nullptr != devHandle)
|
||||
{
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, devName, devHandle, getDevSn(devHandle), getDevType(devHandle));
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, devName, m_pdtToolDbuserMgr, devHandle, getDevSn(devHandle), getDevType(devHandle));
|
||||
if (m_inputSnDlg->exec())
|
||||
{
|
||||
HGPdtToolDbDevice pdtToolDbDevice = nullptr;
|
||||
|
@ -507,7 +512,7 @@ void MainWindow::on_update_userStatus()
|
|||
|
||||
void MainWindow::on_act_newDevice_triggered()
|
||||
{
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, "", nullptr, "", "");
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, "", nullptr, nullptr, "", "");
|
||||
if (m_inputSnDlg->exec())
|
||||
{
|
||||
HGPdtToolDbDevice pdtToolDbDevice = nullptr;
|
||||
|
@ -619,7 +624,7 @@ void MainWindow::on_act_refreshDevice_triggered()
|
|||
sane_open(name[i].c_str(), &devHandle);
|
||||
if (nullptr != devHandle)
|
||||
{
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, name[i].c_str(), devHandle, getDevSn(devHandle), getDevType(devHandle));
|
||||
m_inputSnDlg = new Dialog_InputSerialNum(this, name[i].c_str(), m_pdtToolDbuserMgr, devHandle, getDevSn(devHandle), getDevType(devHandle));
|
||||
if (m_inputSnDlg->exec())
|
||||
{
|
||||
HGPdtToolDbDevice pdtToolDbDevice = nullptr;
|
||||
|
|
Loading…
Reference in New Issue