|
|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
#include "IWheelModel.h"
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include "qnettickthread.h"
|
|
|
|
|
#include "QMessageBox"
|
|
|
|
|
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
@ -21,7 +22,7 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
m_screen.ShowMsg(tr("加载必要模块....."));
|
|
|
|
|
onInitCoreCtrl();
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
|
|
onInitAbout();
|
|
|
|
|
{
|
|
|
|
|
connect(ui.action_userManager, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.action_Login, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
@ -33,6 +34,9 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
connect(ui.action_connect_mode, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.action_checkdata, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.action_modelmgr, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
|
|
|
|
|
connect(ui.btn_start_detect, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
connect(ui.btn_clear_data, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
}
|
|
|
|
|
{//加载语言设置
|
|
|
|
|
QSettings languageSetting("hubdetect.ini", QSettings::IniFormat);
|
|
|
|
|
@ -47,10 +51,14 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
m_pCtrl = new WheelCtrl(QCoreApplication::applicationDirPath(), &m_screen);
|
|
|
|
|
pWorkCtrl = new QWorkMgrCtlr(m_pCtrl);
|
|
|
|
|
pWorkCtrl->readManageFile();
|
|
|
|
|
pworkUI = new QWorkMgrUI(pWorkCtrl, m_pCtrl);
|
|
|
|
|
pworkUI->InitUI();
|
|
|
|
|
connect(pworkUI, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));
|
|
|
|
|
m_pworkUI = new QWorkMgrUI(pWorkCtrl, m_pCtrl);
|
|
|
|
|
m_pworkUI->InitUI();
|
|
|
|
|
connect(m_pworkUI, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));
|
|
|
|
|
m_pState = m_pCtrl->getDetectState();
|
|
|
|
|
|
|
|
|
|
m_pModelMgrDlg = new QModelMgrDlg();
|
|
|
|
|
m_pDebugDlg = new QDebugDlg();
|
|
|
|
|
m_pTimerMgrDlg = new QTimeMgrDlg();
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
/*发送模板库线程*/
|
|
|
|
|
@ -202,10 +210,23 @@ lpMainWin::~lpMainWin()
|
|
|
|
|
delete pWorkCtrl;
|
|
|
|
|
pWorkCtrl = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (pworkUI)
|
|
|
|
|
if (m_pworkUI)
|
|
|
|
|
{
|
|
|
|
|
delete pworkUI;
|
|
|
|
|
pworkUI = nullptr;
|
|
|
|
|
delete m_pworkUI;
|
|
|
|
|
m_pworkUI = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_pModelMgrDlg)
|
|
|
|
|
{
|
|
|
|
|
delete m_pModelMgrDlg;
|
|
|
|
|
m_pModelMgrDlg = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_pDebugDlg) {
|
|
|
|
|
delete m_pDebugDlg;
|
|
|
|
|
m_pDebugDlg = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_pTimerMgrDlg) {
|
|
|
|
|
delete m_pTimerMgrDlg;
|
|
|
|
|
m_pTimerMgrDlg = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_pDllCoreCtrl)
|
|
|
|
|
{
|
|
|
|
|
@ -372,13 +393,24 @@ Q_SLOT void lpMainWin::onActionClicked()
|
|
|
|
|
{
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if ("action_userManager" == strObj) {
|
|
|
|
|
|
|
|
|
|
if (m_pUserCtrl)
|
|
|
|
|
{
|
|
|
|
|
m_pUserCtrl->ShowUserMgrDlg();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("action_Login" == strObj) {
|
|
|
|
|
|
|
|
|
|
if (m_pUserCtrl)
|
|
|
|
|
{
|
|
|
|
|
m_pUserCtrl->CheckLogin();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("action_about" == strObj) {
|
|
|
|
|
|
|
|
|
|
m_aboutDlg.setParent(this);
|
|
|
|
|
m_aboutDlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_aboutDlg.setWindowIcon(QIcon(":/resource/logo-8.png"));
|
|
|
|
|
m_aboutDlg.setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_aboutDlg.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_aboutDlg.show();
|
|
|
|
|
}
|
|
|
|
|
else if ("action_setting_ip" == strObj) {
|
|
|
|
|
|
|
|
|
|
@ -387,22 +419,88 @@ Q_SLOT void lpMainWin::onActionClicked()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if ("action_setting_ban" == strObj) {
|
|
|
|
|
|
|
|
|
|
if (m_pTimerMgrDlg) {
|
|
|
|
|
m_pTimerMgrDlg->setParent(this);
|
|
|
|
|
m_pTimerMgrDlg->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_pTimerMgrDlg->setWindowIcon(QIcon(":/resource/logo-8.png"));
|
|
|
|
|
m_pTimerMgrDlg->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_pTimerMgrDlg->setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_pTimerMgrDlg->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("action_debug" == strObj) {
|
|
|
|
|
|
|
|
|
|
if (m_pDebugDlg) {
|
|
|
|
|
m_pDebugDlg->setParent(this);
|
|
|
|
|
m_pDebugDlg->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_pDebugDlg->setWindowIcon(QIcon(":/resource/logo-8.png"));
|
|
|
|
|
m_pDebugDlg->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_pDebugDlg->setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_pDebugDlg->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("action_connect_mode" == strObj) {
|
|
|
|
|
if (pworkUI)
|
|
|
|
|
if (m_pworkUI)
|
|
|
|
|
{
|
|
|
|
|
pworkUI->onExec();
|
|
|
|
|
m_pworkUI->setParent(this);
|
|
|
|
|
m_pworkUI->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_pworkUI->setWindowIcon(QIcon(":/resource/logo-8.png"));
|
|
|
|
|
m_pworkUI->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_pworkUI->setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_pworkUI->onExec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("action_checkdata" == strObj) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if ("action_modelmgr" == strObj) {
|
|
|
|
|
if (m_pModelMgrDlg)
|
|
|
|
|
{
|
|
|
|
|
m_pModelMgrDlg->setParent(this);
|
|
|
|
|
m_pModelMgrDlg->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_pModelMgrDlg->setWindowIcon(QIcon(":/resource/logo-8.png"));
|
|
|
|
|
m_pModelMgrDlg->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_pModelMgrDlg->setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_pModelMgrDlg->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpMainWin::onButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if ("btn_start_detect" == strObj)//开始
|
|
|
|
|
{
|
|
|
|
|
//开始检测按钮
|
|
|
|
|
if (m_pState->IsDetect == false) {
|
|
|
|
|
ui.btn_start_detect->setText(tr("停止检测"));
|
|
|
|
|
m_pCtrl->onStart();
|
|
|
|
|
QString str = tr("按下了开始检测按钮,检测功能开启");
|
|
|
|
|
m_pCtrl->addLog(str, emTypeRunState);
|
|
|
|
|
|
|
|
|
|
//QTimer::singleShot(3000, [&](){m_pState->bLockDetect = true; });
|
|
|
|
|
QTimer::singleShot(3000, this, SLOT(onChangeDetect()));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
m_pCtrl->onFinish();
|
|
|
|
|
ui.btn_start_detect->setText(tr("开始检测"));
|
|
|
|
|
QString str = tr("按下了停止检测按钮,检测功能关闭");
|
|
|
|
|
m_pCtrl->addLog(str, emTypeRunState);
|
|
|
|
|
m_pState->bLockDetect = false;
|
|
|
|
|
}
|
|
|
|
|
m_pState->IsDetect = !m_pState->IsDetect;
|
|
|
|
|
}
|
|
|
|
|
else if ("btn_clear_data" == strObj) {//交班清零
|
|
|
|
|
QMessageBox infobox(QMessageBox::Warning, tr("提示"), tr("将清空所有数据"), QMessageBox::Yes | QMessageBox::Cancel, this);
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, tr("确定"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Cancel, tr("取消"));
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
if (QMessageBox::Cancel != infobox.exec()) {
|
|
|
|
|
m_pCtrl->onClear();
|
|
|
|
|
ui.main_lb_res_ok_num->setText(QString::number(0));
|
|
|
|
|
ui.main_lb_res_ng_num->setText(QString::number(0));
|
|
|
|
|
QString str = m_pCtrl->getUserName() + ":" + tr("按下了清零按钮,数据全部清零");
|
|
|
|
|
m_pCtrl->addLog(str, emTypeUseState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -630,6 +728,7 @@ Q_SLOT void lpMainWin::onReadDetectStateASK()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpMainWin::onTrigRecv(int m_value)
|
|
|
|
|
{
|
|
|
|
|
/*用于接收PLC触发相机的信号 自检是否收到图像 */
|
|
|
|
|
@ -641,7 +740,7 @@ Q_SLOT void lpMainWin::onTrigRecv(int m_value)
|
|
|
|
|
{
|
|
|
|
|
if (m_pState->bLockDetect == true) {
|
|
|
|
|
//CC_Action(CC_AC_NEXT);
|
|
|
|
|
// trigerCamera();
|
|
|
|
|
onTriggerCam();
|
|
|
|
|
qWarning() << "soft ctrol camera :" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -740,3 +839,124 @@ Q_SLOT void lpMainWin::onShowChannel(QString str)
|
|
|
|
|
{
|
|
|
|
|
ui.main_lb_res_Channle_Show->setText(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpMainWin::onTriggerCam()
|
|
|
|
|
{
|
|
|
|
|
if (m_pCoreCtrl)
|
|
|
|
|
{
|
|
|
|
|
QStringList strLst = m_pCoreCtrl->ICameraKeys();
|
|
|
|
|
m_pCoreCtrl->ISnapImage(strLst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpMainWin::onInitAbout()
|
|
|
|
|
{
|
|
|
|
|
QString aboutString;
|
|
|
|
|
aboutString = QString(
|
|
|
|
|
"<h1>%1</h1>"
|
|
|
|
|
"<p>%2.</p>"
|
|
|
|
|
"<p>%3:www.hzleaper.com</p>"
|
|
|
|
|
"<p>%4:%5</p>"
|
|
|
|
|
"<p>%6:%7</p>"
|
|
|
|
|
"<p>%8:%9</p>"
|
|
|
|
|
"<p> </p>"
|
|
|
|
|
).arg(tr("轮毂型号识别系统"))
|
|
|
|
|
.arg(tr("本软件由杭州利珀科技开发,用于轮毂型号识别和分类,可搭配流水线运输系统使用"))
|
|
|
|
|
.arg(tr("若需要进一步了解该产品的相关信息,请访问我们的网站"))
|
|
|
|
|
.arg(tr("软件版本")).arg(111)
|
|
|
|
|
//.arg(tr("算法版本")).arg(strWhelAlgoType)
|
|
|
|
|
.arg(tr("算法版本")).arg(111)
|
|
|
|
|
.arg(tr("最后更新时间")).arg(111)
|
|
|
|
|
.arg(tr("版权 (c) 属 杭州利珀科技有限公司 所有"));
|
|
|
|
|
m_aboutDlg.setFixedSize(500, 300);
|
|
|
|
|
//QLabel* lbTitle = new QLabel(m_lightBox);
|
|
|
|
|
//QLabel* lbTitle = new QLabel(&m_mainWidget);
|
|
|
|
|
//lbTitle->setPixmap(QPixmap(":/image/Resource/logo-8.png").scaled(50,50));
|
|
|
|
|
//lbTitle->setStyleSheet("font-size: 28px; font-weight: bold; color: white");
|
|
|
|
|
//QTextEdit* pEdit = new QTextEdit(m_lightBox);
|
|
|
|
|
QTextEdit* pEdit = new QTextEdit(&m_aboutDlg);
|
|
|
|
|
//QLabel* pEdit = new QLabel(&m_mainWidget);
|
|
|
|
|
pEdit->setReadOnly(true);
|
|
|
|
|
pEdit->append(aboutString);
|
|
|
|
|
//pEdit->setText(aboutString);
|
|
|
|
|
//pEdit->setStyleSheet("background-color: rgb(0, 0, 0, 255);color:#1E296B;border:0px solid gray;color: black");
|
|
|
|
|
pEdit->setAttribute(Qt::WA_TranslucentBackground, true);
|
|
|
|
|
QPalette pl = pEdit->palette();
|
|
|
|
|
pl.setBrush(QPalette::Base, QBrush(QColor(255, 0, 0, 0)));
|
|
|
|
|
pEdit->setPalette(pl);
|
|
|
|
|
QPushButton* lbClose = new QPushButton(tr("关闭"));
|
|
|
|
|
//QGridLayout* lbLayout = new QGridLayout(m_lightBox);
|
|
|
|
|
QGridLayout* lbLayout = new QGridLayout(&m_aboutDlg);
|
|
|
|
|
//lbLayout->addWidget(lbTitle, 1, 1);
|
|
|
|
|
lbLayout->addWidget(pEdit, 2, 1, 1, 3);
|
|
|
|
|
|
|
|
|
|
lbLayout->addWidget(lbClose, 3, 2);
|
|
|
|
|
lbClose->setMaximumSize(QSize(100, 50));
|
|
|
|
|
//connect(lbClose, SIGNAL(clicked()), m_lightBox, SLOT(hide()));
|
|
|
|
|
connect(lbClose, SIGNAL(clicked()), &m_aboutDlg, SLOT(hide()));
|
|
|
|
|
//m_lightBox->setLayout(lbLayout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpMainWin::onShowResult(Result2Ui* pRlt)
|
|
|
|
|
{
|
|
|
|
|
if (!pRlt)
|
|
|
|
|
return;
|
|
|
|
|
/*
|
|
|
|
|
ui.main_lb_res_model_pic;//匹配结果图
|
|
|
|
|
ui.main_lb_res_okng;//匹配结果 OK NG
|
|
|
|
|
ui.main_lb_res_model_id;//匹配型号
|
|
|
|
|
ui.main_lb_res_model_score;//匹配分数
|
|
|
|
|
ui.main_lb_res_model_thickness;//厚度
|
|
|
|
|
ui.main_lb_res_model_diameter;//直径
|
|
|
|
|
ui.main_lb_res_model_time;//识别耗时时间
|
|
|
|
|
ui.main_lb_res_ok_num;//识别总数
|
|
|
|
|
ui.main_lb_res_ng_num;//NG 数量
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int scareh = ui.main_lb_res_model_pic->height();
|
|
|
|
|
int scarew = ui.main_lb_res_model_pic->width();
|
|
|
|
|
int scare = 0;
|
|
|
|
|
if (scareh > scarew)
|
|
|
|
|
scare = scarew;
|
|
|
|
|
else
|
|
|
|
|
scare = scareh;
|
|
|
|
|
if (pRlt->m_strModel.isEmpty()) {
|
|
|
|
|
m_pState->totalUnDetectNum++;
|
|
|
|
|
QPixmap pix(":/image/none.jpg");
|
|
|
|
|
|
|
|
|
|
ui.main_lb_res_model_pic->setPixmap(pix.scaled(scare - 15, scare - 15));
|
|
|
|
|
ui.main_lb_res_model_pic->setStyleSheet(QString("QLabel{border: 5px solid rgb(250,0,0,250);background-color: rgb(200, 200, 200);}"));
|
|
|
|
|
pRlt->m_strModel = "NG";
|
|
|
|
|
ui.main_lb_res_okng->setText("NG");
|
|
|
|
|
ui.main_lb_res_okng->setStyleSheet("background-color: rgb(255, 0, 0);");
|
|
|
|
|
IWheelModel *pModel = m_pCtrl->getModel("NG");
|
|
|
|
|
if (pModel) {
|
|
|
|
|
pModel->increCount();
|
|
|
|
|
emit m_pTableCheck->sgValueChange(pModel->getModelID());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IWheelModel *pModel = m_pCtrl->getModel(pRlt->m_strModel);
|
|
|
|
|
if (pModel) {
|
|
|
|
|
QString filepath = m_pCtrl->appRoot() + pModel->getPicPath();
|
|
|
|
|
QPixmap pix(filepath);
|
|
|
|
|
ui.main_lb_res_model_pic->setPixmap(pix.scaled(scare - 15, scare - 15));
|
|
|
|
|
pModel->increCount();
|
|
|
|
|
ui.main_lb_res_okng->setText("OK");
|
|
|
|
|
ui.main_lb_res_okng->setStyleSheet("background-color: rgb(0, 255, 0);");
|
|
|
|
|
ui.main_lb_res_model_pic->setStyleSheet(QString("QLabel{border: 5px solid rgb(0,250,0,250);background-color: rgb(200, 200, 200);}"));
|
|
|
|
|
emit m_pTableCheck->sgValueChange(pModel->getModelID());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_pState->totalDetectNum++;
|
|
|
|
|
|
|
|
|
|
//show
|
|
|
|
|
ui.main_lb_res_ng_num->setText(QString::number(m_pState->totalUnDetectNum));
|
|
|
|
|
ui.main_lb_res_ok_num->setText(QString::number(m_pState->totalDetectNum));
|
|
|
|
|
ui.main_lb_res_model_time->setText(QString::number(pRlt->m_dRunTime, 'f', 2));
|
|
|
|
|
ui.main_lb_res_model_thickness->setText(QString::number((int)pRlt->m_dThickness));
|
|
|
|
|
ui.main_lb_res_model_diameter->setText(QString::number((int)pRlt->m_dDiameter));
|
|
|
|
|
ui.main_lb_res_model_score->setText(pRlt->m_strModel);
|
|
|
|
|
|
|
|
|
|
ui.main_lb_res_model_score->setText(QString::number(pRlt->m_dScore * 100, 'f', 1) + "%");
|
|
|
|
|
}
|
|
|
|
|
|