696 lines
27 KiB
C++
696 lines
27 KiB
C++
|
#include "settingUiDevTest.h"
|
|||
|
#include <QVBoxLayout>
|
|||
|
#include <QGridLayout>
|
|||
|
#include <QHBoxLayout>
|
|||
|
#include <functional>
|
|||
|
#include <QDebug>
|
|||
|
#include "rw_zlog.h"
|
|||
|
#include "common_utils.h"
|
|||
|
#include "dev_version.h"
|
|||
|
|
|||
|
int settingUiDevTest::m_pageIndex = 0;
|
|||
|
settingUiDevTest::settingUiDevTest(int pageIndex, QWidget *parent) : MyWidgetWithMainStyleColor(parent)
|
|||
|
{
|
|||
|
m_pageIndex = pageIndex;
|
|||
|
|
|||
|
QVBoxLayout* vlayAuto = new QVBoxLayout();
|
|||
|
m_gbAuto = new QGroupBox("自动检测", this);
|
|||
|
m_gbAuto->setLayout(vlayAuto);
|
|||
|
|
|||
|
m_btnTest = new QPushButton("立即检测", this);
|
|||
|
m_btnTest->setFixedSize(UiConfig::GetInstance()->getUiWidth() / 8, UiConfig::GetInstance()->getUiWidth() / 12);
|
|||
|
m_btnTest->setFlat(true);
|
|||
|
connect(m_btnTest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
//m_btnTest->setStyleSheet("background-color:rgb(24, 144, 255);border-radius:50px;focus{padding:-1;}");
|
|||
|
m_btnTest->setStyleSheet("QPushButton {"
|
|||
|
"border: 0px;"
|
|||
|
"border-radius:10px;"
|
|||
|
"background-color:rgb(24, 144, 255);"
|
|||
|
"focus{outline: none;}"
|
|||
|
"}"
|
|||
|
"QPushButton:hover { "
|
|||
|
"background-color:rgb(24, 144, 255);"
|
|||
|
"}"
|
|||
|
"QPushButton:pressed {"
|
|||
|
"background-color:rgb(222, 222, 222);"
|
|||
|
"}");
|
|||
|
vlayAuto->addWidget(m_btnTest, 1, Qt::AlignCenter);
|
|||
|
|
|||
|
QGridLayout* glayAutoTestItems = new QGridLayout();
|
|||
|
glayAutoTestItems->setMargin(0);
|
|||
|
//glayAutoTestItems->setColumnStretch(0, 98);
|
|||
|
//glayAutoTestItems->setColumnStretch(1, 1);
|
|||
|
//glayAutoTestItems->setColumnStretch(1, 98);
|
|||
|
int row = 0;
|
|||
|
int col = 0;
|
|||
|
QLabel* testOpn = new QLabel("检测项", this);
|
|||
|
glayAutoTestItems->addWidget(testOpn, row, col++, Qt::AlignCenter);
|
|||
|
QLabel* testStatus = new QLabel("结果", this);
|
|||
|
glayAutoTestItems->addWidget(testStatus, row, col++, Qt::AlignRight);
|
|||
|
QLabel* operation = new QLabel("操作", this);
|
|||
|
glayAutoTestItems->addWidget(operation, row, col++, Qt::AlignRight);
|
|||
|
row++;
|
|||
|
col = 0;
|
|||
|
const QString style = "QPushButton {"
|
|||
|
"border: 0px;"
|
|||
|
"border-radius:4px;"
|
|||
|
"background-color:rgb(6, 119, 194);"
|
|||
|
"focus{outline: none;}"
|
|||
|
"}"
|
|||
|
"QPushButton:hover { "
|
|||
|
"background-color:rgb(6, 119, 194);"
|
|||
|
"}"
|
|||
|
"QPushButton:pressed {"
|
|||
|
"background-color:rgb(222, 222, 222);"
|
|||
|
"}";
|
|||
|
for(const auto& testItem : m_autoTest){
|
|||
|
QLabel* itemName = new QLabel(testItem, this);
|
|||
|
itemName->adjustSize();
|
|||
|
m_labelsAutoTestItem.push_back(itemName);
|
|||
|
glayAutoTestItems->addWidget(itemName, row, col++, Qt::AlignCenter);
|
|||
|
QLabel* testRes = new QLabel(this);
|
|||
|
m_labelsAutoTestRes.push_back(testRes);
|
|||
|
glayAutoTestItems->addWidget(testRes, row, col++);
|
|||
|
QPushButton* retest = new QPushButton("复测", this);
|
|||
|
connect(retest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
retest->setStyleSheet(style);
|
|||
|
m_btnsAutoTestRetest.push_back(retest);
|
|||
|
glayAutoTestItems->addWidget(retest, row, col++, Qt::AlignCenter);
|
|||
|
row++;
|
|||
|
col = 0;
|
|||
|
}
|
|||
|
vlayAuto->addLayout(glayAutoTestItems);
|
|||
|
vlayAuto->addStretch(5);
|
|||
|
|
|||
|
|
|||
|
QVBoxLayout* vlayMal = new QVBoxLayout();
|
|||
|
m_gbMal = new QGroupBox("人工检测", this);
|
|||
|
m_gbMal->setLayout(vlayMal);
|
|||
|
row = 0;
|
|||
|
col = 0;
|
|||
|
QGridLayout* glayMalTestItems = new QGridLayout();
|
|||
|
glayMalTestItems->setSpacing(5);
|
|||
|
for(const auto& testItem : m_malTest){
|
|||
|
QLabel* itemName = new QLabel(testItem, this);
|
|||
|
m_labelsMalTestItem.push_back(itemName);
|
|||
|
glayMalTestItems->addWidget(itemName, row, col++, 1, 2);
|
|||
|
QLabel* testRes = new QLabel(this);
|
|||
|
m_labelsMalTestRes.push_back(testRes);
|
|||
|
glayMalTestItems->addWidget(testRes, row, col++, Qt::AlignRight);
|
|||
|
QPushButton* retest = new QPushButton("检测", this);
|
|||
|
connect(retest, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
retest->setStyleSheet(style);
|
|||
|
m_btnsMalTest.push_back(retest);
|
|||
|
glayMalTestItems->addWidget(retest, row, col++, Qt::AlignRight);
|
|||
|
row++;
|
|||
|
col = 0;
|
|||
|
}
|
|||
|
vlayMal->addLayout(glayMalTestItems);
|
|||
|
|
|||
|
QLabel* labelNtp = new QLabel("NTP", this);
|
|||
|
glayMalTestItems->addWidget(labelNtp, row, col++);
|
|||
|
|
|||
|
col++;//放到第三列
|
|||
|
m_btnNtp = new QPushButton("校时", this);
|
|||
|
m_btnNtp->setStyleSheet(style);
|
|||
|
connect(m_btnNtp, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
glayMalTestItems->addWidget(m_btnNtp, row, col++);
|
|||
|
row++;
|
|||
|
col = 0;
|
|||
|
|
|||
|
|
|||
|
QVBoxLayout* vlayAgeing = new QVBoxLayout();
|
|||
|
QGroupBox* m_gbAgeing = new QGroupBox("老化", this);
|
|||
|
m_gbAgeing->setLayout(vlayAgeing);
|
|||
|
|
|||
|
QHBoxLayout* hlayAgeing = new QHBoxLayout();
|
|||
|
QLabel* labelAgeing = new QLabel("老化(小时)", this);
|
|||
|
hlayAgeing->addWidget(labelAgeing);
|
|||
|
m_editAgeing = new LineEditWithKeyboard(this);
|
|||
|
m_editAgeing->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
hlayAgeing->addWidget(m_editAgeing);
|
|||
|
m_btnAgeing = new QPushButton("开始", this);
|
|||
|
connect(m_btnAgeing, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
m_btnAgeing->setStyleSheet(style);
|
|||
|
hlayAgeing->addWidget(m_btnAgeing);
|
|||
|
vlayAgeing->addLayout(hlayAgeing);
|
|||
|
|
|||
|
QLabel* labelAgeingTip = new QLabel(this);
|
|||
|
labelAgeingTip->setWordWrap(true);
|
|||
|
labelAgeingTip->setText(QString("<font color = #000000 >%1</font>").arg("提示::") + "<br>" +
|
|||
|
QString("<font color = #000000 >%1</font>").arg("1.开始老化后,满足老化时间,手动关掉老""化开关,恢复出厂设置,才可退出老化模式;") + "<br>" +
|
|||
|
QString("<font color = #000000 >%1</font>").arg("2.老化时间时断电,之后再次上电,重新开始计时进行老化;") + "<br>" +
|
|||
|
QString("<font color = #FF0000 >%1</font>").arg("3.老化测试结束后,功能测试完成,需恢复出厂设置") );
|
|||
|
vlayAgeing->addWidget(labelAgeingTip, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
|
|||
|
QVBoxLayout* vlayDev = new QVBoxLayout();
|
|||
|
m_gbDev = new QGroupBox("MAC烧录", this);
|
|||
|
m_gbDev->setLayout(vlayDev);
|
|||
|
|
|||
|
QLabel* labelSoftVer = new QLabel("软件版本", this);
|
|||
|
vlayDev->addWidget(labelSoftVer, 1, Qt::AlignLeft);
|
|||
|
m_editSoftVer = new QLineEdit(this);
|
|||
|
m_editSoftVer->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
|
|||
|
m_editSoftVer->setReadOnly(true);
|
|||
|
m_editSoftVer->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
vlayDev->addWidget(m_editSoftVer, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
QLabel* labelDevCfg = new QLabel("设备配置信息", this);
|
|||
|
vlayDev->addWidget(labelDevCfg, 1, Qt::AlignLeft);
|
|||
|
m_editDevCfg = new QLineEdit(this);
|
|||
|
m_editDevCfg->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
|
|||
|
m_editDevCfg->setReadOnly(true);
|
|||
|
m_editDevCfg->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
vlayDev->addWidget(m_editDevCfg, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
QLabel* labelMes = new QLabel("MES服务器地址及工单信息", this);
|
|||
|
vlayDev->addWidget(labelMes, 1, Qt::AlignLeft);
|
|||
|
m_editMesAddrAndProdNo = new QLineEdit(this);
|
|||
|
m_editMesAddrAndProdNo->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
|
|||
|
m_editMesAddrAndProdNo->setReadOnly(true);
|
|||
|
m_editMesAddrAndProdNo->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
vlayDev->addWidget(m_editMesAddrAndProdNo, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
QLabel* labelDevCode = new QLabel("设备条码", this);
|
|||
|
vlayDev->addWidget(labelDevCode, 1, Qt::AlignLeft);
|
|||
|
m_editPcbSeq = new QLineEdit(this);
|
|||
|
m_editPcbSeq->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
|
|||
|
m_editPcbSeq->setReadOnly(true);
|
|||
|
m_editPcbSeq->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
vlayDev->addWidget(m_editPcbSeq, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
QLabel* labelMac = new QLabel("MAC", this);
|
|||
|
vlayDev->addWidget(labelMac, 1, Qt::AlignLeft);
|
|||
|
m_editMac = new QLineEdit(this);
|
|||
|
m_editMac->setMinimumWidth(UiConfig::GetInstance()->getUiWidth() / 3);
|
|||
|
m_editMac->setReadOnly(true);
|
|||
|
m_editMac->setStyleSheet("QLineEdit {border : 1px solid blue;}");
|
|||
|
vlayDev->addWidget(m_editMac, 1, Qt::AlignLeft);
|
|||
|
|
|||
|
vlayDev->setSpacing(5);
|
|||
|
|
|||
|
QVBoxLayout* vlayOperation = new QVBoxLayout();
|
|||
|
QGroupBox* m_gbOperation = new QGroupBox("操作", this);
|
|||
|
m_gbOperation->setLayout(vlayOperation);
|
|||
|
|
|||
|
|
|||
|
m_btnReboot = new QPushButton("手动重启", this);
|
|||
|
connect(m_btnReboot, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
m_btnReboot->setStyleSheet(style);
|
|||
|
vlayOperation->addWidget(m_btnReboot, 1, Qt::AlignCenter);
|
|||
|
|
|||
|
m_btnRecover = new QPushButton("恢复出厂设置", this);
|
|||
|
connect(m_btnRecover, &QPushButton::clicked, this, &settingUiDevTest::slotBtnClicked);
|
|||
|
m_btnRecover->setStyleSheet(style);
|
|||
|
vlayOperation->addWidget(m_btnRecover, 1, Qt::AlignCenter);
|
|||
|
|
|||
|
QVBoxLayout* vlayLeft = new QVBoxLayout();
|
|||
|
vlayLeft->addWidget(m_gbAuto, 1, Qt::AlignTop);
|
|||
|
vlayLeft->addWidget(m_gbDev, 1, Qt::AlignTop);
|
|||
|
vlayLeft->addStretch(5);
|
|||
|
|
|||
|
QVBoxLayout* vlayRight = new QVBoxLayout();
|
|||
|
vlayRight->addWidget(m_gbMal, 1, Qt::AlignTop);
|
|||
|
vlayRight->addWidget(m_gbAgeing, 1, Qt::AlignTop);
|
|||
|
vlayRight->addWidget(m_gbOperation, 1, Qt::AlignTop);
|
|||
|
vlayRight->addStretch(5);
|
|||
|
|
|||
|
QHBoxLayout* hlay = new QHBoxLayout();
|
|||
|
hlay->addLayout(vlayLeft);
|
|||
|
hlay->addLayout(vlayRight);
|
|||
|
|
|||
|
setLayout(hlay);
|
|||
|
setStyleSheet(QString("font-size:%1px;background-color:rgb(200, 200, 200);"
|
|||
|
"border-radius:8px;padding:2px 4px;focus{outline: none;}")
|
|||
|
.arg(QString::number(FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()])));
|
|||
|
|
|||
|
m_timer = new QTimer(this);
|
|||
|
connect(m_timer, &QTimer::timeout, [this]{delete m_colorScreen;
|
|||
|
if(m_colorIndex >= color.size()){
|
|||
|
m_colorIndex = 0;
|
|||
|
m_timer->stop();
|
|||
|
showSelectionWin(enMalTestLcd);
|
|||
|
return;
|
|||
|
}
|
|||
|
m_colorScreen = new PureColorPage(color[m_colorIndex++]);
|
|||
|
m_colorScreen->show();});
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::reset()
|
|||
|
{
|
|||
|
m_backstageIf->stopIdentyState(true, false);
|
|||
|
|
|||
|
//const int btnSize = m_btnsMalTest.at(0)->width();
|
|||
|
const int btnSize = UiConfig::GetInstance()->getUiWidth() / 15;
|
|||
|
m_btnNtp->setFixedSize(btnSize, btnSize);
|
|||
|
m_btnAgeing->setFixedSize(btnSize, btnSize);
|
|||
|
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
|
|||
|
m_btnsAutoTestRetest.at(i)->setFixedSize(btnSize, btnSize);
|
|||
|
}
|
|||
|
for(int i=0; i<m_btnsMalTest.size(); i++){
|
|||
|
m_btnsMalTest.at(i)->setFixedSize(btnSize, btnSize);
|
|||
|
}
|
|||
|
|
|||
|
std::string mac;
|
|||
|
if(m_backstageIf->getKeyDataMac(mac) > 0){
|
|||
|
m_editMac->setText(mac.c_str());
|
|||
|
}
|
|||
|
std::string hours;
|
|||
|
if(m_backstageIf->isAgeing(hours)){
|
|||
|
m_editAgeing->setText(hours.c_str());
|
|||
|
m_btnAgeing->setText("结束");
|
|||
|
//m_gbAuto->setEnabled(false);
|
|||
|
//m_gbDev->setEnabled(false);
|
|||
|
m_btnTest->setEnabled(false);
|
|||
|
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
|
|||
|
m_btnsAutoTestRetest.at(i)->setEnabled(false);
|
|||
|
}
|
|||
|
for(int i=0; i<m_btnsMalTest.size(); i++){
|
|||
|
m_btnsMalTest.at(i)->setEnabled(false);
|
|||
|
}
|
|||
|
m_btnNtp->setEnabled(false);
|
|||
|
m_btnRecover->setEnabled(false);
|
|||
|
m_btnReboot->setEnabled(false);
|
|||
|
}
|
|||
|
else{
|
|||
|
m_editAgeing->setText("8");
|
|||
|
m_btnAgeing->setText("开始");
|
|||
|
//m_gbAuto->setEnabled(true);
|
|||
|
//m_gbDev->setEnabled(true);
|
|||
|
m_btnTest->setEnabled(true);
|
|||
|
for(int i=0; i<m_btnsAutoTestRetest.size(); i++){
|
|||
|
m_btnsAutoTestRetest.at(i)->setEnabled(true);
|
|||
|
}
|
|||
|
for(int i=0; i<m_labelsMalTestItem.size(); i++){
|
|||
|
m_btnsMalTest.at(i)->setEnabled(true);
|
|||
|
}
|
|||
|
m_btnNtp->setEnabled(true);
|
|||
|
m_btnRecover->setEnabled(true);
|
|||
|
m_btnReboot->setEnabled(true);
|
|||
|
}
|
|||
|
for(auto& item : m_labelsAutoTestRes){
|
|||
|
item->clear();
|
|||
|
}
|
|||
|
|
|||
|
const int iBufSize = 64;
|
|||
|
char buf[iBufSize] = {'\0'};
|
|||
|
if(0 == m_backstageIf->getAppVersion(buf, iBufSize)){
|
|||
|
m_editSoftVer->setText(buf);
|
|||
|
buf[strlen("FG_B0xx")] = '\0';
|
|||
|
if(!QString(buf).contains("B045")){
|
|||
|
m_labelsAutoTestItem.at(enAutoTestSerial1)->hide();
|
|||
|
m_labelsAutoTestRes.at(enAutoTestSerial1)->hide();
|
|||
|
m_btnsAutoTestRetest.at(enAutoTestSerial1)->hide();
|
|||
|
}
|
|||
|
}
|
|||
|
//if(0 == m_backstageIf->getHardwareConfig(buf, iBufSize)){
|
|||
|
std::string hardware;
|
|||
|
if(m_backstageIf->getKeyDataHardware(hardware) > 0){
|
|||
|
refreshUiByHardwareConfig(hardware.c_str());
|
|||
|
}
|
|||
|
|
|||
|
emit signalShowSettingUi();
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::slotDevTestMesAddrAndProdNoText(const QString& text)
|
|||
|
{
|
|||
|
m_editMesAddrAndProdNo->setText(text);
|
|||
|
if(!m_editPcbSeq->text().isEmpty()){
|
|||
|
QTimer::singleShot(100, this, [this]{
|
|||
|
std::string mac;
|
|||
|
if(0 == m_backstageIf->getMacFromMes(m_editMesAddrAndProdNo->text().toStdString().c_str(),
|
|||
|
m_editPcbSeq->text().toStdString().c_str(), mac)){
|
|||
|
m_editMac->setText(mac.c_str());
|
|||
|
}
|
|||
|
else{
|
|||
|
InfoDialog("获取mac地址失败,请重试!").exec();
|
|||
|
}});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::slotDevTestPcbSeqText(const QString& text)
|
|||
|
{
|
|||
|
m_editPcbSeq->setText(text);
|
|||
|
if(!m_editMesAddrAndProdNo->text().isEmpty()){
|
|||
|
QTimer::singleShot(100, this, [this]{
|
|||
|
std::string mac;
|
|||
|
if(0 == m_backstageIf->getMacFromMes(m_editMesAddrAndProdNo->text().toStdString().c_str(),
|
|||
|
m_editPcbSeq->text().toStdString().c_str(), mac)){
|
|||
|
m_editMac->setText(mac.c_str());
|
|||
|
}
|
|||
|
else{
|
|||
|
InfoDialog("获取mac地址失败,请重试!").exec();
|
|||
|
}});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::slotDevTestConfigInfo(const QString& text)
|
|||
|
{
|
|||
|
if(text.isEmpty()){
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
std::string hardware;
|
|||
|
if(m_backstageIf->getKeyDataHardware(hardware) < 0){
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
do{
|
|||
|
if(hardware.length() && hardware != text.toStdString()){
|
|||
|
QString que{"设备已有配置信息:"};
|
|||
|
que += hardware.c_str();
|
|||
|
que += "\n";
|
|||
|
que += "是否更新为:";
|
|||
|
que += text;
|
|||
|
|
|||
|
QuestionDialog dlg(que, nullptr, "是的");
|
|||
|
if(QDialog::Rejected == dlg.exec()){
|
|||
|
break;
|
|||
|
}
|
|||
|
QCoreApplication::processEvents();
|
|||
|
}
|
|||
|
|
|||
|
if(hardware == text.toStdString()){
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
m_backstageIf->setKeyDataHardwareAndUpdataFunction(text.toStdString());
|
|||
|
refreshUiByHardwareConfig(text);
|
|||
|
}while(0);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void settingUiDevTest::slotClosed()
|
|||
|
{
|
|||
|
//m_draw->hide();
|
|||
|
showSelectionWin(enMalTestTp);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void settingUiDevTest::slotBtnClicked()
|
|||
|
{
|
|||
|
int index = 0;
|
|||
|
const QVector<std::function<bool()>>funcsAuto{std::bind(&BackstageInterfaceForUi::isWiegandIoTestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isRelayAndGpioTestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isRs485TestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isWifiTestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isRtcTestOk, m_backstageIf),
|
|||
|
//std::bind(&BackstageInterfaceForUi::isWireEthTestOk, m_backstageIf),
|
|||
|
//std::bind(&BackstageInterfaceForUi::is4gTestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isReaderUnderScreenTestOk, m_backstageIf),
|
|||
|
std::bind(&BackstageInterfaceForUi::isSerial1TestOk, m_backstageIf)
|
|||
|
//std::bind(&BackstageInterfaceForUi::isIdModuleInfoUploaded, m_backstageIf)
|
|||
|
};
|
|||
|
const QVector<std::function<void()>>funcsMal{std::bind([this]{m_colorScreen = new PureColorPage(color[m_colorIndex++]);
|
|||
|
m_colorScreen->show();m_timer->start(2000);}),
|
|||
|
std::bind(&settingUiDevTest::doMicrophoneTest, this),
|
|||
|
std::bind([this]{m_backstageIf->speakerTest();
|
|||
|
showSelectionWin(enMalTestSpeaker);}),
|
|||
|
std::bind([this]{if(!m_draw){
|
|||
|
m_draw = new DrawPage(UiConfig::GetInstance()->getUiWidth(),
|
|||
|
UiConfig::GetInstance()->getUiHeight());
|
|||
|
connect(m_draw, SIGNAL(signalClosed()), this, SLOT(slotClosed()));
|
|||
|
m_draw->show();}else{m_draw->show();}}),
|
|||
|
std::bind([this]{static_cast<QWidget*>(this->parent()->parent())->hide();
|
|||
|
QTimer::singleShot(100,this,[this]{
|
|||
|
m_backstageIf->irCamTest();
|
|||
|
static_cast<QWidget*>(this->parent()->parent())->show();
|
|||
|
showSelectionWin(enMalTestIrCam);});}),
|
|||
|
std::bind([this]{static_cast<QWidget*>(this->parent()->parent())->hide();
|
|||
|
QTimer::singleShot(100,this,[this]{
|
|||
|
m_backstageIf->irLedTest();
|
|||
|
static_cast<QWidget*>(this->parent()->parent())->show();
|
|||
|
showSelectionWin(enMalTestIrLed);});})
|
|||
|
};
|
|||
|
const int size = m_btnsAutoTestRetest.at(0)->height() * 0.6;
|
|||
|
QPixmap pmOk(":/res/image/ok_small.png");
|
|||
|
pmOk = pmOk.scaled(size, size);
|
|||
|
QPixmap pmFailed(":/res/image/fail2_large.png");
|
|||
|
pmFailed = pmFailed.scaled(size, size);
|
|||
|
|
|||
|
const QObject* send = sender();
|
|||
|
if (send == m_btnTest) {
|
|||
|
int testItemNum = 0;
|
|||
|
for(auto& item : m_labelsAutoTestRes){
|
|||
|
if(!item->isHidden()){
|
|||
|
item->clear();
|
|||
|
testItemNum++;
|
|||
|
}
|
|||
|
}
|
|||
|
ProgressWidget pw("自动检测中...");
|
|||
|
pw.setFixedSize(UiConfig::GetInstance()->getUiWidth() / 2, UiConfig::GetInstance()->getUiHeight() / 6);
|
|||
|
pw.move((UiConfig::GetInstance()->getUiWidth() - pw.width()) / 2, (UiConfig::GetInstance()->getUiHeight() - pw.height()) / 2);
|
|||
|
pw.show();
|
|||
|
int curTestItem = 1;
|
|||
|
for(auto& item : m_labelsAutoTestRes){
|
|||
|
if(!item->isHidden()){
|
|||
|
pw.setMsg(curTestItem++, testItemNum);
|
|||
|
QCoreApplication::processEvents();
|
|||
|
m_labelsAutoTestRes[index]->setPixmap(funcsAuto.at(index)() ? pmOk : pmFailed);
|
|||
|
QCoreApplication::processEvents();
|
|||
|
}
|
|||
|
index++;
|
|||
|
}
|
|||
|
}
|
|||
|
else if (send == m_btnNtp) {
|
|||
|
int ret = 0;
|
|||
|
{
|
|||
|
m_backstageIf->setNtpServerSw(true);
|
|||
|
|
|||
|
#if 0 //测试代码
|
|||
|
QString testText("192.168.100.250/B045220509-40");
|
|||
|
std::string ip = getMesSeverIpFromText(testText);
|
|||
|
LOGI("expect 1 %d", utils::isValidIp(ip));
|
|||
|
QString testText1("");
|
|||
|
ip = getMesSeverIpFromText(testText1);
|
|||
|
LOGI("expect 0 %d", utils::isValidIp(ip));
|
|||
|
QString testText2("abc");
|
|||
|
ip = getMesSeverIpFromText(testText2);
|
|||
|
LOGI("expect 0 %d", utils::isValidIp(ip));
|
|||
|
#endif
|
|||
|
std::string mesServerIp = getMesSeverIpFromText(m_editMesAddrAndProdNo->text());
|
|||
|
#if 0 //工装ntp校时不依赖mes server ip
|
|||
|
if(!utils::isValidIp(mesServerIp))
|
|||
|
{
|
|||
|
InfoDialog("MES服务器地址无效,请重新扫码").exec();
|
|||
|
return;
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#if 0
|
|||
|
ProgressWidget pw("NTP校时中...");
|
|||
|
pw.setFixedSize(UiConfig::GetInstance()->getUiWidth() / 2, UiConfig::GetInstance()->getUiHeight() / 6);
|
|||
|
pw.move((UiConfig::GetInstance()->getUiWidth() - pw.width()) / 2, (UiConfig::GetInstance()->getUiHeight() - pw.height()) / 2);
|
|||
|
pw.show();
|
|||
|
#else
|
|||
|
MsgDialog msgdlg("NTP校时中...");
|
|||
|
msgdlg.show();
|
|||
|
#endif
|
|||
|
QCoreApplication::processEvents();
|
|||
|
ret = m_backstageIf->ntpTimeCorrectForDevTest(mesServerIp);
|
|||
|
}
|
|||
|
InfoDialog(0 == ret ? "NTP校时成功" : "NTP校时失败,请检查网络!").exec();
|
|||
|
}
|
|||
|
else if (send == m_btnAgeing) {
|
|||
|
if(m_btnAgeing->text() == "开始"){
|
|||
|
unsigned hours = m_editAgeing->text().toUInt();
|
|||
|
if(hours > 0){
|
|||
|
m_backstageIf->ageingTest(hours);
|
|||
|
m_btnAgeing->setText("结束");
|
|||
|
m_btnTest->setEnabled(false);
|
|||
|
for(int i=0; i<m_btnsAutoTestRetest .size(); i++){
|
|||
|
m_btnsAutoTestRetest.at(i)->setEnabled(false);
|
|||
|
}
|
|||
|
for(int i=0; i<m_btnsMalTest.size(); i++){
|
|||
|
m_btnsMalTest.at(i)->setEnabled(false);
|
|||
|
}
|
|||
|
m_btnNtp->setEnabled(false);
|
|||
|
m_btnRecover->setEnabled(false);
|
|||
|
m_btnReboot->setEnabled(false);
|
|||
|
}
|
|||
|
}
|
|||
|
else if(m_btnAgeing->text() == "结束"){
|
|||
|
m_backstageIf->ageingTest(0);
|
|||
|
m_btnAgeing->setText("开始");
|
|||
|
m_btnTest->setEnabled(true);
|
|||
|
for(int i=0; i<m_btnsAutoTestRetest .size(); i++){
|
|||
|
m_btnsAutoTestRetest.at(i)->setEnabled(true);
|
|||
|
}
|
|||
|
for(int i=0; i<m_labelsMalTestItem.size(); i++){
|
|||
|
m_btnsMalTest.at(i)->setEnabled(true);
|
|||
|
}
|
|||
|
m_btnNtp->setEnabled(true);
|
|||
|
m_btnRecover->setEnabled(true);
|
|||
|
m_btnReboot->setEnabled(true);
|
|||
|
//在工装界面结束老化,会恢复人脸识别,需要重新停止识别,并且延迟一段时间停止保证在恢复之后执行
|
|||
|
QTimer::singleShot(200, this, [this]{m_backstageIf->stopIdentyState(true, false);});
|
|||
|
}
|
|||
|
}
|
|||
|
else if (send == m_btnRecover || send == m_btnReboot) {
|
|||
|
QString que;
|
|||
|
QString btnText;
|
|||
|
if(send == m_btnReboot){
|
|||
|
que = tr("您确定重新启动FaceTick吗?");
|
|||
|
btnText = tr("重新启动");
|
|||
|
}
|
|||
|
else if(send == m_btnRecover){
|
|||
|
que = tr("您确定恢复出厂设置吗?");
|
|||
|
btnText = tr("恢复");
|
|||
|
}
|
|||
|
QuestionDialog dlg(que, nullptr, btnText);
|
|||
|
if(QDialog::Accepted == dlg.exec()){
|
|||
|
if(send == m_btnRecover){
|
|||
|
qDebug() << "recoveryFactorySetting";
|
|||
|
m_backstageIf->recoveryFactorySetting();
|
|||
|
}
|
|||
|
PureColorPage* black = new PureColorPage(0);
|
|||
|
black->show();
|
|||
|
QTimer::singleShot(1000, this, [this]{qDebug() << "devReboot";m_backstageIf->devReboot();});
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
index = 0;
|
|||
|
for(auto& btn : m_btnsAutoTestRetest){
|
|||
|
if(send == btn){
|
|||
|
m_labelsAutoTestRes[index]->clear();
|
|||
|
MsgDialog msgdlg("检测中...");
|
|||
|
msgdlg.show();
|
|||
|
QCoreApplication::processEvents();
|
|||
|
m_labelsAutoTestRes[index]->setPixmap(funcsAuto.at(index)() ? pmOk : pmFailed);
|
|||
|
return;
|
|||
|
}
|
|||
|
index++;
|
|||
|
}
|
|||
|
|
|||
|
index = 0;
|
|||
|
for(auto& btn : m_btnsMalTest){
|
|||
|
if(send == btn){
|
|||
|
btn->setEnabled(false);
|
|||
|
//InfoDialog(QString("通过要求:\n") + m_malTestTips.at(index)).exec();
|
|||
|
QCoreApplication::processEvents();
|
|||
|
funcsMal.at(index)();
|
|||
|
btn->setEnabled(true);
|
|||
|
return;
|
|||
|
}
|
|||
|
index++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::showSelectionWin(int testIndex) {
|
|||
|
const int size = m_btnsMalTest.at(0)->height() * 0.6;
|
|||
|
QPixmap pmOk(":/res/image/ok_small.png");
|
|||
|
pmOk = pmOk.scaled(size, size);
|
|||
|
QPixmap pmFailed(":/res/image/fail2_large.png");
|
|||
|
pmFailed = pmFailed.scaled(size, size);
|
|||
|
SelectionDialog dlg(m_malTestTips.at(testIndex), "不通过", "通过");
|
|||
|
|
|||
|
auto manufacturer = DevVersion::getInstance()->getManu();
|
|||
|
if (testIndex == enMalTestAuidoSwitch) {
|
|||
|
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(dlg.selecion() == 1 ? pmOk : pmFailed);
|
|||
|
} else if (testIndex == enMalTestSpeaker &&
|
|||
|
(manufacturer == Manu_E::ManuRWRk1109V05)) { // V05以上 板载喇叭测试成功后,再测试外部音频输出
|
|||
|
if (dlg.selecion() == 1) {
|
|||
|
doAuidoSwitchTest();
|
|||
|
} else {
|
|||
|
m_labelsMalTestRes.at(testIndex)->setPixmap(pmFailed);
|
|||
|
}
|
|||
|
} else {
|
|||
|
|
|||
|
m_labelsMalTestRes.at(testIndex)->setPixmap(dlg.selecion() == 1 ? pmOk : pmFailed);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::doMicrophoneTest() {
|
|||
|
m_backstageIf->microphoneTest(true);
|
|||
|
SelectionDialog dlg("录音中,请面对设备屏幕70CM说话", "", "录音结束并播放录音");
|
|||
|
if (dlg.selecion() == 1) {
|
|||
|
m_backstageIf->microphoneTest(false);
|
|||
|
showSelectionWin(enMalTestMicrophone);
|
|||
|
} else {
|
|||
|
const int size = m_btnsMalTest.at(0)->height() * 0.6;
|
|||
|
QPixmap pmFailed(":/res/image/fail2_large.png");
|
|||
|
pmFailed = pmFailed.scaled(size, size);
|
|||
|
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(pmFailed);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::doAuidoSwitchTest() {
|
|||
|
SelectionDialog dlg("请接入外部音响,并将开关拨至正确位置", "", "已完成");
|
|||
|
if (dlg.selecion() == 1) {
|
|||
|
m_backstageIf->audioSwitchTest();
|
|||
|
showSelectionWin(enMalTestAuidoSwitch);
|
|||
|
} else {
|
|||
|
const int size = m_btnsMalTest.at(0)->height() * 0.6;
|
|||
|
QPixmap pmFailed(":/res/image/fail2_large.png");
|
|||
|
pmFailed = pmFailed.scaled(size, size);
|
|||
|
m_labelsMalTestRes.at(enMalTestSpeaker)->setPixmap(pmFailed);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void settingUiDevTest::refreshUiByHardwareConfig(const QString& hardware)
|
|||
|
{
|
|||
|
m_editDevCfg->setText(hardware);
|
|||
|
|
|||
|
//HW300102 0 1 C1 1 01H
|
|||
|
bool hasReaderUnderScreen = (hardware[8] == '2');
|
|||
|
if(hasReaderUnderScreen){//注意测试项索引
|
|||
|
m_labelsAutoTestItem.at(enAutoTestReaderUnderScreen)->show();
|
|||
|
m_labelsAutoTestRes.at(enAutoTestReaderUnderScreen)->show();
|
|||
|
m_btnsAutoTestRetest.at(enAutoTestReaderUnderScreen)->show();
|
|||
|
}
|
|||
|
else{
|
|||
|
m_labelsAutoTestItem.at(enAutoTestReaderUnderScreen)->hide();
|
|||
|
m_labelsAutoTestRes.at(enAutoTestReaderUnderScreen)->hide();
|
|||
|
m_btnsAutoTestRetest.at(enAutoTestReaderUnderScreen)->hide();
|
|||
|
}
|
|||
|
bool hasWifi = (hardware[9] == '2');
|
|||
|
if(hasWifi){//注意测试项索引
|
|||
|
m_labelsAutoTestItem.at(enAutoTestWifi)->show();
|
|||
|
m_labelsAutoTestRes.at(enAutoTestWifi)->show();
|
|||
|
m_btnsAutoTestRetest.at(enAutoTestWifi)->show();
|
|||
|
}
|
|||
|
else{
|
|||
|
m_labelsAutoTestItem.at(enAutoTestWifi)->hide();
|
|||
|
m_labelsAutoTestRes.at(enAutoTestWifi)->hide();
|
|||
|
m_btnsAutoTestRetest.at(enAutoTestWifi)->hide();
|
|||
|
}
|
|||
|
bool hasTp = (hardware[12] == '1');
|
|||
|
if(hasTp){//注意测试项索引
|
|||
|
m_labelsMalTestItem.at(enMalTestTp)->show();
|
|||
|
m_labelsMalTestRes.at(enMalTestTp)->show();
|
|||
|
m_btnsMalTest.at(enMalTestTp)->show();
|
|||
|
}
|
|||
|
else{
|
|||
|
m_labelsMalTestItem.at(enMalTestTp)->hide();
|
|||
|
m_labelsMalTestRes.at(enMalTestTp)->hide();
|
|||
|
m_btnsMalTest.at(enMalTestTp)->hide();
|
|||
|
}
|
|||
|
|
|||
|
auto manufacturer = DevVersion::getInstance()->getManu();
|
|||
|
if (manufacturer == Manu_E::ManuRWRk1109V05) {
|
|||
|
m_malTest[enMalTestSpeaker] = "喇叭/音频输出";
|
|||
|
} else {
|
|||
|
m_malTest[enMalTestSpeaker] = "喇叭";
|
|||
|
}
|
|||
|
m_labelsMalTestItem.at(enMalTestSpeaker)->setText(m_malTest.at(enMalTestSpeaker));
|
|||
|
}
|
|||
|
|
|||
|
std::string settingUiDevTest::getMesSeverIpFromText(const QString& text)
|
|||
|
{
|
|||
|
//text 例"192.168.100.250:8080/B045220509-40" "192.168.100.250/B045220509-40"
|
|||
|
|
|||
|
QString mesServerIp("");
|
|||
|
if(!text.isEmpty())
|
|||
|
{
|
|||
|
QStringList list = text.split("/");
|
|||
|
QStringList strList = list[0].split(":");
|
|||
|
mesServerIp = strList[0];
|
|||
|
}
|
|||
|
LOGI("mesServerIp %s", mesServerIp.toStdString().c_str());
|
|||
|
//qDebug()<<"mesServerIp "<<mesServerIp;
|
|||
|
return mesServerIp.toStdString();
|
|||
|
}
|
|||
|
|