2022-12-16 11:01:30 +00:00
|
|
|
#include "dialog_inputserialnum.h"
|
|
|
|
#include "ui_dialog_inputserialnum.h"
|
2023-01-06 07:17:48 +00:00
|
|
|
#include "base/HGBase.h"
|
2023-09-12 03:02:45 +00:00
|
|
|
#include "HGString.h"
|
2023-09-07 08:45:32 +00:00
|
|
|
#include "HGUIGlobal.h"
|
2023-09-12 03:02:45 +00:00
|
|
|
#include "app_cfg.h"
|
|
|
|
#include "dialog_setlogpath.h"
|
2022-12-16 11:01:30 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
Dialog_InputSerialNum::Dialog_InputSerialNum(class MainWindow *mainWnd, Dialog_logIn::LogInType logInType, const QString &devName, const QString &profileName,
|
|
|
|
const QString &accountName, SANE_Handle handle, const QString &serialNum, const QString &devType) :
|
2022-12-16 11:01:30 +00:00
|
|
|
QDialog(mainWnd),
|
|
|
|
ui(new Ui::Dialog_InputSerialNum),
|
|
|
|
m_mainWnd(mainWnd),
|
2023-09-07 08:45:32 +00:00
|
|
|
m_logInType(logInType),
|
2023-01-06 05:39:49 +00:00
|
|
|
m_handle(handle),
|
|
|
|
m_valid(true),
|
2023-08-31 07:15:14 +00:00
|
|
|
m_profileName(profileName),
|
2023-09-07 08:45:32 +00:00
|
|
|
m_accountName(accountName),
|
2022-12-16 11:01:30 +00:00
|
|
|
m_serialNum(serialNum),
|
2023-01-06 07:17:48 +00:00
|
|
|
m_devType(devType),
|
|
|
|
m_devName(devName),
|
2023-09-07 08:45:32 +00:00
|
|
|
m_hg(nullptr),
|
2023-09-13 03:11:53 +00:00
|
|
|
m_curIndex(0),
|
|
|
|
m_originVid(0),
|
|
|
|
m_originPid(0)
|
2022-12-16 11:01:30 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
2022-12-28 06:57:00 +00:00
|
|
|
QFont ft;
|
|
|
|
ft.setPointSize(15);
|
|
|
|
this->setFont(ft);
|
|
|
|
|
2023-09-13 05:47:34 +00:00
|
|
|
QFont ft2;
|
|
|
|
ft2.setPointSize(20);
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
if (m_logInType != Dialog_logIn::LogInType_InitTest)
|
|
|
|
{
|
|
|
|
ui->lineEdit_sn->setEnabled(false);
|
|
|
|
ui->pbtn_setSn->setEnabled(false);
|
|
|
|
ui->pbtn_setConfig->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2023-09-12 03:02:45 +00:00
|
|
|
ui->pbtn_slectLogPath->setVisible(false);
|
|
|
|
if (m_accountName == "admin")
|
|
|
|
{
|
|
|
|
ui->pbtn_slectLogPath->setVisible(true);
|
|
|
|
}
|
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
updatePassStatus(false);
|
2023-09-13 05:47:34 +00:00
|
|
|
ui->pushButton_status->setFont(ft2);
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
ui->pbtn_enterTest->setEnabled(false);
|
2023-09-07 08:45:32 +00:00
|
|
|
ui->label_scanner->setText(tr("Device name: %1").arg(m_devName));
|
2022-12-16 11:01:30 +00:00
|
|
|
ui->lineEdit_sn->setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
|
2023-01-06 07:17:48 +00:00
|
|
|
ui->lineEdit_sn->setMaxLength(14);
|
2023-01-04 12:48:53 +00:00
|
|
|
|
|
|
|
if (handle != nullptr)
|
2022-12-23 10:32:57 +00:00
|
|
|
{
|
2023-01-04 12:48:53 +00:00
|
|
|
ui->lineEdit_sn->setText(serialNum);
|
2023-01-06 05:39:49 +00:00
|
|
|
ui->lineEdit_sn->selectAll();
|
2023-01-04 12:48:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->lineEdit_sn->setText("");
|
2023-01-06 05:39:49 +00:00
|
|
|
ui->pbtn_setSn->setEnabled(false);
|
2022-12-23 10:32:57 +00:00
|
|
|
}
|
2023-01-06 07:17:48 +00:00
|
|
|
|
|
|
|
if (m_handle != nullptr)
|
|
|
|
m_hg = new hgscanner(nullptr, nullptr, this, m_handle);
|
|
|
|
|
|
|
|
connect(this, SIGNAL(testResult()), this, SLOT(on_testResult()));
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
m_originVid = getDevVid();
|
|
|
|
m_originPid = getDevPid();
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
setSleepTime();
|
|
|
|
updateTargetCfg();
|
|
|
|
updateCurDeviceCfg();
|
2022-12-16 11:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Dialog_InputSerialNum::~Dialog_InputSerialNum()
|
|
|
|
{
|
2023-01-06 08:18:57 +00:00
|
|
|
delete m_hg;
|
|
|
|
m_hg = nullptr;
|
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Dialog_InputSerialNum::GetSn()
|
|
|
|
{
|
|
|
|
return ui->lineEdit_sn->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Dialog_InputSerialNum::GetDevType()
|
|
|
|
{
|
2023-09-07 08:45:32 +00:00
|
|
|
return m_devType;
|
2022-12-16 11:01:30 +00:00
|
|
|
}
|
|
|
|
|
2023-01-06 05:39:49 +00:00
|
|
|
void Dialog_InputSerialNum::Invalid(const QString &devName)
|
|
|
|
{
|
|
|
|
if (devName == m_devName)
|
|
|
|
{
|
|
|
|
sane_close(m_handle);
|
|
|
|
m_handle = nullptr;
|
|
|
|
m_valid = false;
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
void Dialog_InputSerialNum::setSpeedMode()
|
2023-01-06 07:17:48 +00:00
|
|
|
{
|
2023-09-07 08:45:32 +00:00
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
LPWRITECFG lp = new WRITECFG;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
delete lp;
|
2023-09-11 08:00:44 +00:00
|
|
|
|
|
|
|
QString info = tr("Set") + tr("Speep mode: %1PPM").arg(QString::number(speedMode));
|
|
|
|
addInteractInfo(info, true);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::setSleepTime()
|
|
|
|
{
|
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
LPWRITECFG lp = new WRITECFG;
|
2023-01-06 08:18:57 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
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);
|
2023-08-08 10:29:16 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
delete lp;
|
2023-09-11 08:00:44 +00:00
|
|
|
|
|
|
|
QString info = tr("Set") + (sleepTime > 0 ? tr("Sleep time: %1minute").arg(QString::number(sleepTime)) : tr("Sleep time: Not sleeping"));
|
|
|
|
addInteractInfo(info, true);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::setVidPid()
|
|
|
|
{
|
2023-08-31 07:15:14 +00:00
|
|
|
AnalysisJson analysisJson(m_profileName);
|
2023-08-08 10:29:16 +00:00
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
LPWRITECFG lp = new WRITECFG;
|
2023-01-06 07:17:48 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
delete lp;
|
2023-09-11 08:00:44 +00:00
|
|
|
|
|
|
|
char buf[10];
|
|
|
|
sprintf(buf, "%x", jsonGlobal.vid_to);
|
|
|
|
char buf2[10];
|
|
|
|
sprintf(buf2, "%x", jsonGlobal.pid_to);
|
|
|
|
QString info = tr("Set") + tr("Vid: %1 Pid: %2").arg(QString::fromStdString(buf)).arg(QString::fromStdString(buf2));
|
|
|
|
addInteractInfo(info, true);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
2023-11-02 06:48:51 +00:00
|
|
|
void Dialog_InputSerialNum::setDevceModel()
|
|
|
|
{
|
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
|
|
|
|
std::string deviceModel = jsonGlobal.device_model.toStdString();
|
|
|
|
unsigned int len = deviceModel.size();
|
|
|
|
SANE_Status ret = sane_io_control(m_handle, IO_CTRL_CODE_SET_DEVS_MODEL, &deviceModel[0], &len);
|
|
|
|
|
|
|
|
QString info("");
|
2024-01-15 06:08:27 +00:00
|
|
|
if (ret == SANE_STATUS_GOOD)
|
2023-11-02 06:48:51 +00:00
|
|
|
{
|
|
|
|
info = tr("Set") + tr("Device model: %1").arg(QString::fromStdString(deviceModel));
|
|
|
|
}
|
|
|
|
addInteractInfo(info, true);
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
void Dialog_InputSerialNum::rebootDevice()
|
|
|
|
{
|
|
|
|
const wchar_t *p = L"0";
|
|
|
|
func_test_go(HGPDTTOOLDB_NAME_REBOOT_DEVICE, p, m_hg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Dialog_InputSerialNum::getSpeedMode()
|
|
|
|
{
|
|
|
|
SANE_Int speedMode = 0;
|
|
|
|
unsigned int len = sizeof(SANE_Int);
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_SPEED_MODE, &speedMode, &len);
|
|
|
|
|
2024-07-09 03:32:54 +00:00
|
|
|
const wchar_t G100[6] = { 60,70,80,90,110 };
|
|
|
|
const wchar_t G200[6] = { 90,100,110,120,130 };
|
2023-09-07 08:45:32 +00:00
|
|
|
const wchar_t G300[6] = { 40,50,60,70,80,90 };
|
2024-06-07 09:55:30 +00:00
|
|
|
const wchar_t G306[6] = { 30,40,50,60,70 };
|
2023-09-07 08:45:32 +00:00
|
|
|
const wchar_t G400[6] = { 40,50,60,70,80,90 };
|
|
|
|
|
|
|
|
int speed = 0;
|
2024-06-07 09:55:30 +00:00
|
|
|
QString devType = m_devType;
|
2024-06-26 14:10:39 +00:00
|
|
|
if (getDeviceFwVersion().mid(3, 1) == "Z") //306
|
2024-06-07 09:55:30 +00:00
|
|
|
{
|
2024-06-14 06:25:41 +00:00
|
|
|
devType = "G306";
|
2024-06-07 09:55:30 +00:00
|
|
|
}
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2024-06-07 09:55:30 +00:00
|
|
|
if ((int)speedMode >= 30)
|
2023-09-07 08:45:32 +00:00
|
|
|
speed = (int)speedMode;
|
|
|
|
else
|
2023-08-08 10:29:16 +00:00
|
|
|
{
|
2024-06-07 09:55:30 +00:00
|
|
|
if (devType == "G100")
|
2024-07-12 02:22:38 +00:00
|
|
|
speed = (int)speedMode;
|
2024-06-07 09:55:30 +00:00
|
|
|
else if (devType == "G200")
|
2024-07-12 02:22:38 +00:00
|
|
|
speed = (int)speedMode;
|
2024-06-07 09:55:30 +00:00
|
|
|
else if (devType == "G300")
|
2023-09-07 08:45:32 +00:00
|
|
|
speed = G300[(int)speedMode - 1];
|
2024-06-07 09:55:30 +00:00
|
|
|
else if (devType == "G306")
|
|
|
|
speed = G306[(int)speedMode - 1];
|
|
|
|
else if (devType == "G400")
|
2023-09-07 08:45:32 +00:00
|
|
|
speed = G400[(int)speedMode - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Dialog_InputSerialNum::getSleepTime()
|
|
|
|
{
|
|
|
|
int sleepTime = SANE_POWER_FIRST;
|
|
|
|
unsigned int len2 = sizeof(int);
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_POWER_LEVEL, &sleepTime, &len2);
|
|
|
|
|
|
|
|
if (sleepTime > 99999 || sleepTime == -1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (sleepTime / 60);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Dialog_InputSerialNum::getDevVid()
|
|
|
|
{
|
|
|
|
VIDPID vidpid;
|
|
|
|
int vidpid_val;
|
|
|
|
unsigned int len = sizeof(int);
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_VIDPID, &vidpid_val, &len);
|
|
|
|
vidpid.Value = vidpid_val;
|
|
|
|
int vid = vidpid.VID;
|
|
|
|
return vid;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Dialog_InputSerialNum::getDevPid()
|
|
|
|
{
|
|
|
|
VIDPID vidpid;
|
|
|
|
int vidpid_val;
|
|
|
|
unsigned int len = sizeof(int);
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_VIDPID, &vidpid_val, &len);
|
|
|
|
vidpid.Value = vidpid_val;
|
|
|
|
int pid = vidpid.PID;
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
|
2023-11-02 06:48:51 +00:00
|
|
|
QString Dialog_InputSerialNum::getDeviceModel()
|
|
|
|
{
|
|
|
|
std::string devs_model;
|
|
|
|
unsigned int devs_len = 0;
|
|
|
|
|
|
|
|
SANE_Status ret = sane_io_control(m_handle, IO_CTRL_CODE_GET_DEVS_MODEL, &devs_model[0], &devs_len);
|
|
|
|
if (ret == SANE_STATUS_NO_MEM)
|
|
|
|
{
|
|
|
|
devs_model.resize(devs_len);
|
|
|
|
ret = sane_io_control(m_handle, IO_CTRL_CODE_GET_DEVS_MODEL, &devs_model[0], &devs_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString::fromStdString(devs_model);
|
|
|
|
}
|
|
|
|
|
2024-03-01 03:22:32 +00:00
|
|
|
QString Dialog_InputSerialNum::getDeviceFwVersion()
|
|
|
|
{
|
|
|
|
std::string firmwareVersion;
|
|
|
|
unsigned int devs_len = 0;
|
|
|
|
|
|
|
|
SANE_Status ret = sane_io_control(m_handle, IO_CTRL_CODE_GET_HARDWARE_VERSION, &firmwareVersion[0], &devs_len);
|
|
|
|
if (ret == SANE_STATUS_NO_MEM)
|
|
|
|
{
|
|
|
|
firmwareVersion.resize(devs_len);
|
|
|
|
ret = sane_io_control(m_handle, IO_CTRL_CODE_GET_HARDWARE_VERSION, &firmwareVersion[0], &devs_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString::fromStdString(firmwareVersion).left(10);
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
void Dialog_InputSerialNum::updateTargetCfg()
|
|
|
|
{
|
2023-09-11 08:00:44 +00:00
|
|
|
ui->textBrowser_target->clear();
|
2023-01-06 08:18:57 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
|
|
|
|
int speedMode = jsonGlobal.speed_mode;
|
|
|
|
int sleepTime = jsonGlobal.sleep_time;
|
|
|
|
int vid_to = jsonGlobal.vid_to;
|
|
|
|
int pid_to = jsonGlobal.pid_to;
|
2023-11-02 06:48:51 +00:00
|
|
|
QString devideModel = jsonGlobal.device_model;
|
2024-03-01 03:22:32 +00:00
|
|
|
QString fwVersion = jsonGlobal.firmware_version;
|
2023-09-07 08:45:32 +00:00
|
|
|
|
|
|
|
char buf[10];
|
|
|
|
sprintf(buf, "%x", vid_to);
|
|
|
|
|
|
|
|
char buf2[10];
|
|
|
|
sprintf(buf2, "%x", pid_to);
|
|
|
|
|
|
|
|
QString content;
|
2023-09-11 08:00:44 +00:00
|
|
|
content.append(tr("Target Configration:") + "\n\n");
|
2023-11-02 06:48:51 +00:00
|
|
|
|
|
|
|
if (!devideModel.isEmpty())
|
|
|
|
content.append(tr("Device model: %1").arg(devideModel) + "\n");
|
|
|
|
|
2024-03-01 03:22:32 +00:00
|
|
|
if (!fwVersion.isEmpty())
|
|
|
|
content.append(tr("Firmware version: %1").arg(fwVersion) + "\n");
|
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
content.append(tr("Speep mode: %1PPM").arg(QString::number(speedMode)) + "\n");
|
|
|
|
content.append((sleepTime > 0 ? tr("Sleep time: %1minute").arg(QString::number(sleepTime)) : tr("Sleep time: Not sleeping")) + "\n");
|
2024-03-01 03:22:32 +00:00
|
|
|
content.append(tr("Vid: %1\nPid: %2").arg(QString::fromStdString(buf)).arg(QString::fromStdString(buf2)) + "\n");
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
ui->textBrowser_target->setText(content);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::updateCurDeviceCfg()
|
|
|
|
{
|
2023-09-11 08:00:44 +00:00
|
|
|
ui->textBrowser_curConfig->clear();
|
2023-09-07 08:45:32 +00:00
|
|
|
|
|
|
|
if (m_handle == nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int speedMode = getSpeedMode();
|
|
|
|
int sleepTime = getSleepTime();
|
|
|
|
int vid_to = getDevVid();
|
|
|
|
int pid_to = getDevPid();
|
|
|
|
|
2023-11-06 06:44:21 +00:00
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
QString devideModel("");
|
|
|
|
if (!jsonGlobal.device_model.isEmpty())
|
|
|
|
{
|
|
|
|
devideModel = getDeviceModel();
|
|
|
|
}
|
2024-03-01 03:22:32 +00:00
|
|
|
|
|
|
|
QString fwVersion("");
|
|
|
|
if (!jsonGlobal.firmware_version.isEmpty())
|
|
|
|
{
|
|
|
|
fwVersion = getDeviceFwVersion();
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
char buf[10];
|
|
|
|
sprintf(buf, "%x", vid_to);
|
|
|
|
|
|
|
|
char buf2[10];
|
|
|
|
sprintf(buf2, "%x", pid_to);
|
|
|
|
|
|
|
|
QString content;
|
2023-09-11 08:00:44 +00:00
|
|
|
content.append(tr("Current Configration of device:") + "\n\n");
|
2023-11-02 06:48:51 +00:00
|
|
|
|
2024-03-14 12:04:19 +00:00
|
|
|
if (!devideModel.isEmpty() && !jsonGlobal.device_model.isEmpty())
|
2023-11-02 06:48:51 +00:00
|
|
|
content.append(tr("Device model: %1").arg(devideModel) + "\n");
|
|
|
|
|
2024-03-01 03:22:32 +00:00
|
|
|
if (!fwVersion.isEmpty())
|
|
|
|
content.append(tr("Firmware version: %1").arg(fwVersion) + "\n");
|
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
content.append(tr("Speep mode: %1PPM").arg(QString::number(speedMode)) + "\n");
|
2023-10-13 01:54:59 +00:00
|
|
|
content.append(sleepTime > 0 ? tr("Sleep time: %1minute").arg(QString::number(sleepTime)) + "\n" : tr("Sleep time: Not sleeping") + "\n");
|
2024-03-01 03:22:32 +00:00
|
|
|
content.append(tr("Vid: %1\nPid: %2").arg(QString::fromStdString(buf)).arg(QString::fromStdString(buf2)) + "\n");
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
ui->textBrowser_curConfig->setText(content);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Dialog_InputSerialNum::getLogPath()
|
|
|
|
{
|
2023-09-12 03:02:45 +00:00
|
|
|
HGChar logPath[512];
|
|
|
|
HGBase_GetDocumentsPath(logPath, 512);
|
2023-09-07 08:45:32 +00:00
|
|
|
HGChar procName[512];
|
|
|
|
HGBase_GetProcessName(procName, 512);
|
2023-09-12 03:02:45 +00:00
|
|
|
strcat(logPath, procName);
|
|
|
|
strcat(logPath, "/Test_Log/");
|
|
|
|
strcat(logPath, m_devType.toStdString().c_str());
|
|
|
|
strcat(logPath, "/");
|
2023-09-07 08:45:32 +00:00
|
|
|
|
2023-09-21 01:26:12 +00:00
|
|
|
return getCfgValue(m_devType.toStdString().c_str(), "logPath", getStdFileName(StdStringToUtf8(logPath).c_str()));
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::writeTestLog(QString logContent)
|
|
|
|
{
|
|
|
|
QString logPath = getLogPath();
|
|
|
|
HGBase_CreateDir(getStdString(logPath).c_str());
|
|
|
|
|
|
|
|
QString fileName = logPath + m_serialNum + ".log";
|
|
|
|
QFile file(fileName);
|
|
|
|
if(!file.open(QIODevice::ReadWrite | QIODevice::Append))
|
|
|
|
{
|
2023-08-08 10:29:16 +00:00
|
|
|
return;
|
2023-01-06 07:17:48 +00:00
|
|
|
}
|
2023-08-08 10:29:16 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
QDateTime dateTime= QDateTime::currentDateTime();
|
|
|
|
QString curTime = dateTime .toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
QString content = "[" + curTime + "] ";
|
|
|
|
content += logContent;
|
2023-08-08 10:29:16 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
QTextStream txtOutput(&file);
|
|
|
|
txtOutput << content << endl;
|
|
|
|
file.close();
|
2023-01-06 07:17:48 +00:00
|
|
|
}
|
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
void Dialog_InputSerialNum::addInteractInfo(QString info, bool isNormal)
|
|
|
|
{
|
|
|
|
QDateTime dateTime= QDateTime::currentDateTime();
|
|
|
|
QString curTime = dateTime .toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
QString content = "[" + curTime + "] ";
|
|
|
|
content.append(info + "\n");
|
|
|
|
|
|
|
|
if (isNormal)
|
|
|
|
ui->textBrowser_info->insertPlainText(content);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->textBrowser_info->setTextColor(Qt::red);
|
|
|
|
ui->textBrowser_info->insertPlainText(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->textBrowser_info->moveCursor(QTextCursor::End);
|
|
|
|
ui->textBrowser_info->setTextColor(Qt::black);
|
|
|
|
}
|
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
void Dialog_InputSerialNum::updatePassStatus(bool pass)
|
|
|
|
{
|
|
|
|
if (pass)
|
|
|
|
{
|
|
|
|
ui->pushButton_status->setText(tr("Pass"));
|
2023-09-13 05:47:34 +00:00
|
|
|
ui->pushButton_status->setStyleSheet("background-color: green");
|
2023-09-13 03:11:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->pushButton_status->setText(tr("Fail"));
|
|
|
|
ui->pushButton_status->setStyleSheet("background-color: red");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-06 07:17:48 +00:00
|
|
|
void Dialog_InputSerialNum::on_testResult()
|
|
|
|
{
|
2023-09-07 08:45:32 +00:00
|
|
|
//m_mainWnd->releaseTesting();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::on_pbtn_setSn_clicked()
|
|
|
|
{
|
|
|
|
QString sn = ui->lineEdit_sn->text();
|
|
|
|
std::string serialNum = sn.toStdString();
|
|
|
|
|
|
|
|
QString testLog = tr("Tester: %1, Test item: %2").arg(m_accountName).arg(QString(tr("Set serial number: %1 ").arg(sn)));
|
|
|
|
if(SANE_STATUS_GOOD != sane_io_control(m_handle, IO_CTRL_CODE_SET_SERIAL, &serialNum[0], nullptr))
|
|
|
|
{
|
2023-09-11 08:00:44 +00:00
|
|
|
//QMessageBox::information(this, tr("tips"), tr("set sn failed"));
|
|
|
|
QString info = QString(tr("Set serial number: %1 ").arg(sn)) + tr("Failed!");
|
|
|
|
writeTestLog(testLog + tr("set sn failed"));
|
|
|
|
addInteractInfo(info, false);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-09-11 08:00:44 +00:00
|
|
|
//QMessageBox::information(this, tr("tips"), tr("set sn succeed"));
|
|
|
|
QString info = QString(tr("Set serial number: %1 ").arg(sn)) + tr("Succeed!");
|
|
|
|
writeTestLog(testLog + tr("set sn succeed"));
|
|
|
|
addInteractInfo(info, true);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::on_pbtn_checkConfig_clicked()
|
|
|
|
{
|
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
|
|
|
|
int speedMode_to = jsonGlobal.speed_mode;
|
|
|
|
int sleepTime_to = jsonGlobal.sleep_time;
|
|
|
|
int vid_to = jsonGlobal.vid_to;
|
|
|
|
int pid_to = jsonGlobal.pid_to;
|
2023-11-02 06:48:51 +00:00
|
|
|
QString deviceModel_to = jsonGlobal.device_model;
|
2024-03-01 03:22:32 +00:00
|
|
|
QString firmwareVersion_to = jsonGlobal.firmware_version;
|
2023-09-07 08:45:32 +00:00
|
|
|
|
|
|
|
int speedMode = getSpeedMode();
|
|
|
|
int sleepTime = getSleepTime();
|
|
|
|
int vid = getDevVid();
|
|
|
|
int pid = getDevPid();
|
|
|
|
|
|
|
|
QString item;
|
|
|
|
bool right = true;
|
|
|
|
LPWRITECFG lp = new WRITECFG;
|
2023-11-02 06:48:51 +00:00
|
|
|
|
2023-11-02 07:12:00 +00:00
|
|
|
if (!deviceModel_to.isEmpty())
|
2023-11-02 06:48:51 +00:00
|
|
|
{
|
2023-11-02 07:12:00 +00:00
|
|
|
QString deviceModel = getDeviceModel();
|
|
|
|
if (deviceModel_to != deviceModel)
|
|
|
|
{
|
|
|
|
item.append(tr("Device model"));
|
|
|
|
item.append(" ");
|
|
|
|
right = false;
|
|
|
|
|
|
|
|
QString info = tr("Inconsistent configuration %1detected, please reconfigure, and check again").arg(item);
|
|
|
|
addInteractInfo(info, false);
|
|
|
|
}
|
2023-11-02 06:48:51 +00:00
|
|
|
}
|
|
|
|
|
2024-03-01 03:22:32 +00:00
|
|
|
if (!firmwareVersion_to.isEmpty())
|
|
|
|
{
|
|
|
|
QString fwVersion = getDeviceFwVersion();
|
|
|
|
if (firmwareVersion_to != fwVersion)
|
|
|
|
{
|
|
|
|
right = false;
|
|
|
|
|
|
|
|
QString info = tr("Inconsistent firmware detected, please burn the correct firmware, and check again");
|
|
|
|
addInteractInfo(info, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
if (speedMode_to != speedMode)
|
|
|
|
{
|
|
|
|
item.append(tr("Speed mode"));
|
|
|
|
item.append(" ");
|
|
|
|
right = false;
|
2023-09-11 08:00:44 +00:00
|
|
|
|
|
|
|
QString info = tr("Inconsistent configuration %1detected, please reconfigure, and check again").arg(item);
|
|
|
|
addInteractInfo(info, false);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sleepTime_to != sleepTime)
|
|
|
|
{
|
|
|
|
item.append(tr("Sleep time"));
|
|
|
|
item.append(" ");
|
|
|
|
right = false;
|
2023-09-11 08:00:44 +00:00
|
|
|
QString info = tr("Inconsistent configuration %1detected, please reconfigure, and check again").arg(item);
|
|
|
|
addInteractInfo(info, false);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (vid != vid_to || pid != pid_to)
|
|
|
|
{
|
|
|
|
item.append(tr("Vid and Pid"));
|
|
|
|
item.append(" ");
|
|
|
|
right = false;
|
2023-09-11 08:00:44 +00:00
|
|
|
QString info = tr("Inconsistent configuration %1detected, please reboot and reconfigure, and check again").arg(item);
|
|
|
|
addInteractInfo(info, false);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
if (m_originVid != vid_to || m_originPid != pid_to)
|
|
|
|
{
|
|
|
|
right = false;
|
2023-09-13 05:47:34 +00:00
|
|
|
|
|
|
|
QString info = tr("Detected that the current device's vid-pid and device object are not consistent. ");
|
|
|
|
addInteractInfo(info + tr("Please reboot device to update. "), false);
|
2023-09-13 03:11:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updatePassStatus(right);
|
2023-09-11 08:00:44 +00:00
|
|
|
ui->pbtn_enterTest->setEnabled(right);
|
|
|
|
if (right)
|
2023-09-07 08:45:32 +00:00
|
|
|
{
|
2023-09-11 08:00:44 +00:00
|
|
|
QString info = tr("Consistent configuration");
|
|
|
|
addInteractInfo(info, true);
|
2023-09-07 08:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete lp;
|
|
|
|
|
|
|
|
updateTargetCfg();
|
|
|
|
updateCurDeviceCfg();
|
2023-01-06 07:17:48 +00:00
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
void Dialog_InputSerialNum::on_pbtn_enterTest_clicked()
|
2022-12-16 11:01:30 +00:00
|
|
|
{
|
2023-01-06 05:39:49 +00:00
|
|
|
if (!m_valid)
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("device is lost"));
|
|
|
|
reject();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
if (ui->lineEdit_sn->text().isEmpty())
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("Serial num is empty"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-01-04 14:24:41 +00:00
|
|
|
QString str = ui->lineEdit_sn->text();
|
|
|
|
for (int i = 0; i < str.size(); ++i)
|
|
|
|
{
|
|
|
|
if ((str.at(i) < '0' && str.at(i) > '9') || (str.at(i) < 'A' && str.at(i) > 'Z'))
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("sn is illegal"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 12:48:53 +00:00
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
if (m_mainWnd->FindInterface(ui->lineEdit_sn->text()) != nullptr)
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("The device is testing"));
|
|
|
|
return;
|
|
|
|
}
|
2023-08-08 10:29:16 +00:00
|
|
|
|
2022-12-16 11:01:30 +00:00
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
void Dialog_InputSerialNum::on_pbtn_setConfig_clicked()
|
2022-12-16 11:01:30 +00:00
|
|
|
{
|
2023-11-02 06:48:51 +00:00
|
|
|
AnalysisJson analysisJson(m_profileName);
|
|
|
|
AnalysisJson::json_global jsonGlobal = analysisJson.GetGlobal();
|
|
|
|
|
|
|
|
bool supportDevModel = false;
|
|
|
|
QString deviceModel = jsonGlobal.device_model;
|
|
|
|
if (!deviceModel.isEmpty())
|
|
|
|
{
|
|
|
|
supportDevModel = true;
|
|
|
|
setDevceModel();
|
|
|
|
}
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
setSpeedMode();
|
|
|
|
setSleepTime();
|
|
|
|
setVidPid();
|
2023-01-06 05:39:49 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
int speedMode = jsonGlobal.speed_mode;
|
|
|
|
int sleepTime = jsonGlobal.sleep_time;
|
|
|
|
int vid_to = jsonGlobal.vid_to;
|
|
|
|
int pid_to = jsonGlobal.pid_to;
|
|
|
|
|
|
|
|
char buf[10];
|
|
|
|
sprintf(buf, "%x", vid_to);
|
|
|
|
char buf2[10];
|
|
|
|
sprintf(buf2, "%x", pid_to);
|
|
|
|
|
|
|
|
QString content;
|
2023-11-02 06:48:51 +00:00
|
|
|
|
|
|
|
if (supportDevModel)
|
|
|
|
content.append(tr("Device model: %1").arg(deviceModel) + " ");
|
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
content.append(tr("Speep mode: %1PPM").arg(QString::number(speedMode)) + " ");
|
|
|
|
content.append((sleepTime > 0 ? tr("Sleep time: %1minute").arg(QString::number(sleepTime)) : tr("Sleep time: Not sleeping")) + " ");
|
|
|
|
content.append(tr("Vid: %1 Pid: %2").arg(QString::fromStdString(buf)).arg(QString::fromStdString(buf2)));
|
|
|
|
|
|
|
|
writeTestLog(tr("Tester: %1, Test item: %2").arg(m_accountName).arg(tr("Set configuration to device ") +
|
|
|
|
tr("Test content: ") + content));
|
2023-01-06 07:17:48 +00:00
|
|
|
|
2023-09-07 08:45:32 +00:00
|
|
|
updateTargetCfg();
|
|
|
|
updateCurDeviceCfg();
|
2023-09-07 09:17:09 +00:00
|
|
|
|
2023-09-13 03:11:53 +00:00
|
|
|
if (m_originVid != vid_to || m_originPid != pid_to)
|
|
|
|
{
|
|
|
|
QString info = tr("Detected that the current device's vid-pid and device object are not consistent. ");
|
|
|
|
addInteractInfo(info + tr("Please reboot device to update. "), false);
|
2023-09-13 05:47:34 +00:00
|
|
|
// QMessageBox msg(QMessageBox::Question, tr("tips"),
|
|
|
|
// info + tr("Do you want to restart now?"),
|
|
|
|
// QMessageBox::Yes | QMessageBox::No, this);
|
|
|
|
// msg.exec();
|
|
|
|
// if (msg.clickedButton() == msg.button(QMessageBox::Yes))
|
|
|
|
// {
|
|
|
|
// rebootDevice();
|
|
|
|
// }
|
2023-09-13 03:11:53 +00:00
|
|
|
}
|
|
|
|
|
2023-09-11 08:00:44 +00:00
|
|
|
//QMessageBox::information(this, tr("Prompt"), (tr("Success, please check the configuration")));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dialog_InputSerialNum::on_pbtn_reboot_clicked()
|
|
|
|
{
|
|
|
|
rebootDevice();
|
2023-01-06 05:39:49 +00:00
|
|
|
}
|
2023-09-12 03:02:45 +00:00
|
|
|
|
|
|
|
void Dialog_InputSerialNum::on_pbtn_slectLogPath_clicked()
|
|
|
|
{
|
|
|
|
Dialog_SetLogPath dlg(m_devType, this);
|
|
|
|
dlg.exec();
|
|
|
|
}
|