|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
#include "CMainWin.h"
|
|
|
|
|
#include "CMainWin.h"
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include "lpSysLog.h"
|
|
|
|
|
#include "IStation.h"
|
|
|
|
|
@ -18,6 +18,11 @@
|
|
|
|
|
CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
{
|
|
|
|
|
{//加载语言设置
|
|
|
|
|
QSettings languageSetting(lpSysConfig::instance()->getCfgPath(), QSettings::IniFormat);
|
|
|
|
|
QString strLanguage = languageSetting.value("language/select", "Chinese").toString();
|
|
|
|
|
SetLanguage(strLanguage);
|
|
|
|
|
}
|
|
|
|
|
setWindowIcon(QIcon(":/leaper/Resource/app.png"));
|
|
|
|
|
onInitCoreCtrl();
|
|
|
|
|
|
|
|
|
|
@ -26,8 +31,8 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
lpSysConfig::instance()->readConfig();
|
|
|
|
|
lpSysConfig::instance()->writeConfig();
|
|
|
|
|
|
|
|
|
|
SetLanguage(m_strCurLanguage);
|
|
|
|
|
SYSLOG_STATUS << "系统启动";
|
|
|
|
|
|
|
|
|
|
SYSLOG_STATUS << "系统启动";
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
QString strPath = QCoreApplication::applicationDirPath();
|
|
|
|
|
@ -42,6 +47,7 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
connect(m_pCameraTrig, SIGNAL(sgTrig()), this, SLOT(onTrigImage()));
|
|
|
|
|
onInitStatus();
|
|
|
|
|
|
|
|
|
|
connect(&m_devMgrWid, SIGNAL(sgChangeLanguage(QString)), this, SLOT(onLanguageChange(QString)));
|
|
|
|
|
connect(m_pDesignerMgr, SIGNAL(sgCloseWindow()), this, SLOT(onMainFrameClose()));
|
|
|
|
|
connect(&m_testWid, SIGNAL(sgTestMode(int)), this, SLOT(onTestMode(int)));
|
|
|
|
|
|
|
|
|
|
@ -57,7 +63,7 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
m_mangeWid.onInitModelList(m_pWfCtrl);
|
|
|
|
|
|
|
|
|
|
{//用户管理模块加载
|
|
|
|
|
{//用户管理模块加载
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
QLibrary lib("QUserInfod");
|
|
|
|
|
#else
|
|
|
|
|
@ -70,28 +76,28 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{//串口设备加载
|
|
|
|
|
{//串口设备加载
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
QLibrary lib("SerialPortToold");//库文件名
|
|
|
|
|
QLibrary lib("SerialPortToold");//库文件名
|
|
|
|
|
#else
|
|
|
|
|
QLibrary lib("SerialPortTool");//库文件名
|
|
|
|
|
QLibrary lib("SerialPortTool");//库文件名
|
|
|
|
|
#endif
|
|
|
|
|
_SerialPortCreate func = (_SerialPortCreate)lib.resolve("SerialPortCreate");
|
|
|
|
|
if (func)
|
|
|
|
|
m_pSerialPort = func();
|
|
|
|
|
|
|
|
|
|
//load seriport dll
|
|
|
|
|
if (m_pSerialPort)//如果文件存在 使用自定义的串口
|
|
|
|
|
if (m_pSerialPort)//如果文件存在 使用自定义的串口
|
|
|
|
|
{
|
|
|
|
|
m_pSerialPort->loadAnalysefunc(this, &CMainWin::onAppanalysis);
|
|
|
|
|
|
|
|
|
|
//关闭框架的串口使用
|
|
|
|
|
//关闭框架的串口使用
|
|
|
|
|
QString strDefaultPort = lpSysConfig::instance()->m_ComName;
|
|
|
|
|
int baut = lpSysConfig::instance()->m_Baut;
|
|
|
|
|
bool bOpen = m_pSerialPort->OpenCom(strDefaultPort, QString::number(baut));
|
|
|
|
|
if (bOpen == false)
|
|
|
|
|
{
|
|
|
|
|
// QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString("Com %1 %2 open failed").arg(strDefaultPort).arg(baut), QMessageBox::Yes | QMessageBox::No, NULL);
|
|
|
|
|
// QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString("Com %1 %2 open failed").arg(strDefaultPort).arg(baut), QMessageBox::Yes | QMessageBox::No, NULL);
|
|
|
|
|
// infobox.setWindowIcon(QIcon(LEAPER_LOGO));
|
|
|
|
|
// infobox.exec();
|
|
|
|
|
}
|
|
|
|
|
@ -100,7 +106,7 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//工具栏按钮事件绑定
|
|
|
|
|
//工具栏按钮事件绑定
|
|
|
|
|
connect(ui.actionSetting, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.actionManage, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.actionTest, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
@ -110,7 +116,7 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
connect(ui.main_Login_action, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.main_action_userManager, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
|
|
|
|
|
//图像结果展示
|
|
|
|
|
//图像结果展示
|
|
|
|
|
connect(this, SIGNAL(sgShowImg(int, QImage)), this, SLOT(onShowImage(int, QImage)));
|
|
|
|
|
connect(this, SIGNAL(sgSelModel(int, QString)), this, SLOT(onSelModel(int, QString)));
|
|
|
|
|
connect(this, SIGNAL(sgShowLog(int, QString)), this, SLOT(onShowLog(int, QString)));
|
|
|
|
|
@ -175,7 +181,7 @@ CMainWin::~CMainWin()
|
|
|
|
|
rmTranslator();
|
|
|
|
|
lpSysLog::uninstance();
|
|
|
|
|
}
|
|
|
|
|
//相机原图接收回调 用于展示图像
|
|
|
|
|
//相机原图接收回调 用于展示图像
|
|
|
|
|
void CMainWin::INewCameraImage(const QString& camKey, QImage img)
|
|
|
|
|
{
|
|
|
|
|
emit sgShowSrcImg(camKey, img);
|
|
|
|
|
@ -216,7 +222,7 @@ void CMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
|
|
|
|
|
pStation->sendResult(dAngle);
|
|
|
|
|
if (image.isNull())
|
|
|
|
|
int b = 0;
|
|
|
|
|
SYSLOG_STATUS << QString("◎工位%1收到算法结果,当前型号为[%2],发送角度为:%3").arg(pStation->stationId()).arg(pStation->currentRunningModel()).arg(dAngle);
|
|
|
|
|
SYSLOG_STATUS << QString("◎工位%1收到算法结果,当前型号为[%2],发送角度为:%3").arg(pStation->stationId()).arg(pStation->currentRunningModel()).arg(dAngle);
|
|
|
|
|
emit sgShowImg(pStation->stationId(),image);
|
|
|
|
|
emit sgShowLog(pStation->stationId(), strResult);
|
|
|
|
|
pStation->revResult();
|
|
|
|
|
@ -299,7 +305,7 @@ QString CMainWin::genSavePath(QString modelName, QImage &img)
|
|
|
|
|
|
|
|
|
|
Q_SLOT void CMainWin::onAppanalysis(SComFrame frame)
|
|
|
|
|
{
|
|
|
|
|
//数据接收
|
|
|
|
|
//数据接收
|
|
|
|
|
int nCmd = frame.cmd;
|
|
|
|
|
if (0x43 == nCmd)
|
|
|
|
|
{
|
|
|
|
|
@ -332,21 +338,21 @@ Q_SLOT void CMainWin::onAppanalysis(SComFrame frame)
|
|
|
|
|
pStation->trigImage();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QString strMsg = QString("%1:该型号ID:%2在模型库中不存在,不能拍照!!!").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(m_StationInfo_1.m_PLCID);
|
|
|
|
|
QString strMsg = QString("%1:该型号ID:%2在模型库中不存在,不能拍照!!!").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(m_StationInfo_1.m_PLCID);
|
|
|
|
|
emit sgShowLog(1, strMsg);
|
|
|
|
|
if (m_StationInfo_1.m_PLCID > 0) {
|
|
|
|
|
pStation->setSerialPortPtr(m_pSerialPort);
|
|
|
|
|
pStation->sendResult(999);
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,发送了999角度数据,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,发送了999角度数据,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nCameraID)
|
|
|
|
|
.arg(m_StationInfo_1.strModelName.isEmpty() == true ? "空" : m_StationInfo_1.strModelName)
|
|
|
|
|
.arg(m_StationInfo_1.strModelName.isEmpty() == true ? "空" : m_StationInfo_1.strModelName)
|
|
|
|
|
.arg(m_StationInfo_1.m_PLCID)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nCameraID)
|
|
|
|
|
.arg(m_StationInfo_1.strModelName.isEmpty() == true ? "空" : m_StationInfo_1.strModelName)
|
|
|
|
|
.arg(m_StationInfo_1.strModelName.isEmpty() == true ? "空" : m_StationInfo_1.strModelName)
|
|
|
|
|
.arg(m_StationInfo_1.m_PLCID)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
}
|
|
|
|
|
@ -360,22 +366,22 @@ Q_SLOT void CMainWin::onAppanalysis(SComFrame frame)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QString strMsg = QString("%1:该型号ID:%2在模型库中不存在,不能拍照!!!").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(m_StationInfo_2.m_PLCID);
|
|
|
|
|
QString strMsg = QString("%1:该型号ID:%2在模型库中不存在,不能拍照!!!").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(m_StationInfo_2.m_PLCID);
|
|
|
|
|
emit sgShowLog(2, strMsg);
|
|
|
|
|
if (m_StationInfo_2.m_PLCID > 0) {
|
|
|
|
|
pStation->setSerialPortPtr(m_pSerialPort);
|
|
|
|
|
pStation->sendResult(999);
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,发送了999角度数据,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,发送了999角度数据,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nCameraID)
|
|
|
|
|
.arg(m_StationInfo_2.strModelName.isEmpty() == true ? "空" : m_StationInfo_2.strModelName)
|
|
|
|
|
.arg(m_StationInfo_2.strModelName.isEmpty() == true ? "空" : m_StationInfo_2.strModelName)
|
|
|
|
|
.arg(m_StationInfo_2.m_PLCID)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("●工位%1:收到触发信号,因索引不合法所以没触发相机拍照,型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nCameraID)
|
|
|
|
|
.arg(m_StationInfo_2.strModelName.isEmpty() == true ? "空" : m_StationInfo_2.strModelName)
|
|
|
|
|
.arg(m_StationInfo_2.strModelName.isEmpty() == true ? "空" : m_StationInfo_2.strModelName)
|
|
|
|
|
.arg(m_StationInfo_2.m_PLCID)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
}
|
|
|
|
|
@ -386,7 +392,7 @@ Q_SLOT void CMainWin::onAppanalysis(SComFrame frame)
|
|
|
|
|
pStation->trigImage();
|
|
|
|
|
}
|
|
|
|
|
else if (0xf1 == nCmd)
|
|
|
|
|
{//接收到下位机的命令关闭所有窗口 关机
|
|
|
|
|
{//接收到下位机的命令关闭所有窗口 关机
|
|
|
|
|
qApp->closeAllWindows();
|
|
|
|
|
//shutDown();
|
|
|
|
|
}
|
|
|
|
|
@ -455,7 +461,7 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
{
|
|
|
|
|
m_StationInfo_1.m_PLCID = mmCmd;
|
|
|
|
|
m_StationInfo_1.strModelName = strModel;
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:切换型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:切换型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(strModel)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
@ -468,7 +474,7 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
if (m_StationInfo_2.m_PLCID != mmCmd) {
|
|
|
|
|
m_StationInfo_2.m_PLCID = mmCmd;
|
|
|
|
|
m_StationInfo_2.strModelName = strModel;
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:切换型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:切换型号为[%2],型号索引ID为[%3],时间:%4")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(strModel)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
@ -484,12 +490,12 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
m_StationInfo_1.m_PLCID = mmCmd;
|
|
|
|
|
m_StationInfo_1.strModelName = strModel;
|
|
|
|
|
if (mmCmd <= 0)
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号清零,型号索引ID为[%2],时间:%3")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号清零,型号索引ID为[%2],时间:%3")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
else
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号切换失败,对应的索引不存在,型号索引ID为[%2],时间:%3")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号切换失败,对应的索引不存在,型号索引ID为[%2],时间:%3")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
@ -498,7 +504,7 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
m_StationInfo_1.m_bRunEnable = false;
|
|
|
|
|
if (mmCmd > 0)
|
|
|
|
|
{
|
|
|
|
|
QString strMsg = QString("%1:型号设置失败,模型库中不存在索引%2").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(mmCmd);
|
|
|
|
|
QString strMsg = QString("%1:型号设置失败,模型库中不存在索引%2").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(mmCmd);
|
|
|
|
|
emit sgShowLog(1, strMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -508,12 +514,12 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
m_StationInfo_2.m_PLCID = mmCmd;
|
|
|
|
|
m_StationInfo_2.strModelName = strModel;
|
|
|
|
|
if (mmCmd <= 0)
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号清零,型号索引ID为[%2],时间:%3")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号清零,型号索引ID为[%2],时间:%3")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
else
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号切换失败,对应的索引不存在,型号索引ID为[%2],时间:%3")
|
|
|
|
|
SYSLOG_STATUS << QString("★工位%1:型号切换失败,对应的索引不存在,型号索引ID为[%2],时间:%3")
|
|
|
|
|
.arg(nId)
|
|
|
|
|
.arg(mmCmd)
|
|
|
|
|
.arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz"));
|
|
|
|
|
@ -521,7 +527,7 @@ void CMainWin::onHeartComm(SComFrame &frame)
|
|
|
|
|
m_StationInfo_2.m_bRunEnable = false;
|
|
|
|
|
|
|
|
|
|
if (mmCmd > 0) {
|
|
|
|
|
QString strMsg = QString("%1:型号设置失败,模型库中不存在索引%2").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(mmCmd);
|
|
|
|
|
QString strMsg = QString("%1:型号设置失败,模型库中不存在索引%2").arg(QTime::currentTime().toString("hh:mm:ss zzz:")).arg(mmCmd);
|
|
|
|
|
emit sgShowLog(2, strMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -545,27 +551,27 @@ Q_SLOT void CMainWin::onHeardBit()
|
|
|
|
|
Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
|
{
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if ("actionSetting" == strObj) {//标定
|
|
|
|
|
if ("actionSetting" == strObj) {//标定
|
|
|
|
|
IDetectorUI* pDetectorUI = GetDesignerInterface();
|
|
|
|
|
if (pDetectorUI) {
|
|
|
|
|
pDetectorUI->ShowMainFrame();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("actionManage" == strObj) {//模板管理
|
|
|
|
|
else if ("actionManage" == strObj) {//模板管理
|
|
|
|
|
m_mangeWid.setParent(this);
|
|
|
|
|
m_mangeWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_mangeWid.setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_mangeWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_mangeWid.show();
|
|
|
|
|
}
|
|
|
|
|
else if ("actionTest" == strObj) {//测试
|
|
|
|
|
else if ("actionTest" == strObj) {//测试
|
|
|
|
|
m_testWid.setParent(this);
|
|
|
|
|
m_testWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
m_testWid.setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
m_testWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_testWid.show();
|
|
|
|
|
}
|
|
|
|
|
else if ("actionHelp" == strObj) {//帮助
|
|
|
|
|
else if ("actionHelp" == strObj) {//帮助
|
|
|
|
|
m_aboutWid.setParent(this);
|
|
|
|
|
m_aboutWid.setWindowIcon(QIcon(LEAPER_LOGO));
|
|
|
|
|
m_aboutWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
@ -573,7 +579,7 @@ Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
|
m_aboutWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_aboutWid.show();
|
|
|
|
|
}
|
|
|
|
|
else if ("action_Check" == strObj) {//历史记录查询
|
|
|
|
|
else if ("action_Check" == strObj) {//历史记录查询
|
|
|
|
|
QProcess process;
|
|
|
|
|
process.setWorkingDirectory(QCoreApplication::applicationDirPath());
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
@ -583,7 +589,7 @@ Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
|
#endif
|
|
|
|
|
process.startDetached(strTaskName);
|
|
|
|
|
}
|
|
|
|
|
else if ("action" == strObj) {//系统参数设置
|
|
|
|
|
else if ("action" == strObj) {//系统参数设置
|
|
|
|
|
m_devMgrWid.setParent(this);
|
|
|
|
|
m_devMgrWid.setWindowIcon(QIcon(LEAPER_LOGO));
|
|
|
|
|
m_devMgrWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
|
@ -591,14 +597,14 @@ Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
|
m_devMgrWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
m_devMgrWid.show();
|
|
|
|
|
}
|
|
|
|
|
else if ("main_Login_action" == strObj) {//用户登陆
|
|
|
|
|
else if ("main_Login_action" == strObj) {//用户登陆
|
|
|
|
|
if (m_pUserCtrl) {
|
|
|
|
|
if (m_pUserCtrl->getLoginState() == EM_LOGIN)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("你确定要注销%1 ?")).arg(m_pUserCtrl->CurUser()), QMessageBox::Yes | QMessageBox::No, NULL);
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("你确定要注销%1 ?")).arg(m_pUserCtrl->CurUser()), QMessageBox::Yes | QMessageBox::No, NULL);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString("确认"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::No, QString("取消"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString("确认"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::No, QString("取消"));
|
|
|
|
|
if (infobox.exec() == QMessageBox::Yes) {
|
|
|
|
|
m_pUserCtrl->LogOutUser();
|
|
|
|
|
}
|
|
|
|
|
@ -608,21 +614,21 @@ Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("该功能未启用.")), QMessageBox::Yes, NULL);
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("该功能未启用.")), QMessageBox::Yes, NULL);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString(QObject::tr("确认")));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString(QObject::tr("确认")));
|
|
|
|
|
infobox.exec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("main_action_userManager" == strObj) {//用户管理
|
|
|
|
|
else if ("main_action_userManager" == strObj) {//用户管理
|
|
|
|
|
if (m_pUserCtrl) {
|
|
|
|
|
m_pUserCtrl->ShowUserMgrDlg(this);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("该功能未启用.")), QMessageBox::Yes, NULL);
|
|
|
|
|
QMessageBox infobox(QMessageBox::Information, QString(QObject::tr("提示")), QString(QObject::tr("该功能未启用.")), QMessageBox::Yes, NULL);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString(QObject::tr("确认")));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, QString(QObject::tr("确认")));
|
|
|
|
|
infobox.exec();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -640,11 +646,11 @@ void CMainWin::closeEvent(QCloseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox info(this);
|
|
|
|
|
info.setWindowIcon(QIcon(LEAPER_LOGO));
|
|
|
|
|
info.setWindowTitle(QObject::tr("警告"));
|
|
|
|
|
info.setText(QObject::tr("本检测系统正在运行,您真的要关闭?"));
|
|
|
|
|
info.setWindowTitle(QObject::tr("警告"));
|
|
|
|
|
info.setText(QObject::tr("本检测系统正在运行,您真的要关闭?"));
|
|
|
|
|
info.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
|
|
|
|
info.setButtonText(QMessageBox::Ok, QObject::tr("确定"));
|
|
|
|
|
info.setButtonText(QMessageBox::Cancel, QObject::tr("取消"));
|
|
|
|
|
info.setButtonText(QMessageBox::Ok, QObject::tr("确定"));
|
|
|
|
|
info.setButtonText(QMessageBox::Cancel, QObject::tr("取消"));
|
|
|
|
|
if (info.exec() != QMessageBox::Ok)
|
|
|
|
|
{
|
|
|
|
|
event->ignore();
|
|
|
|
|
@ -653,24 +659,24 @@ void CMainWin::closeEvent(QCloseEvent *event)
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//初始化状态栏
|
|
|
|
|
//初始化状态栏
|
|
|
|
|
void CMainWin::onInitStatus()
|
|
|
|
|
{
|
|
|
|
|
const int c_nWidth = 170;
|
|
|
|
|
m_pLbCurrentTime = new QLabel(QObject::tr("系统时间"));
|
|
|
|
|
m_pLbCurrentTime = new QLabel(QObject::tr("系统时间"));
|
|
|
|
|
m_pLbCurrentTime->setMinimumHeight(40);
|
|
|
|
|
m_pLbCurrentTime->setMinimumWidth(c_nWidth);
|
|
|
|
|
|
|
|
|
|
m_pLbOnLine = new class QLabel(QObject::tr("模式:"));
|
|
|
|
|
m_pLbOnLine = new class QLabel(QObject::tr("模式:"));
|
|
|
|
|
m_pLbOnLine->setMinimumWidth(c_nWidth);
|
|
|
|
|
|
|
|
|
|
m_pLbUser = new class QLabel(QObject::tr("用户:无"));
|
|
|
|
|
m_pLbUser = new class QLabel(QObject::tr("用户:无"));
|
|
|
|
|
m_pLbUser->setMinimumWidth(c_nWidth);
|
|
|
|
|
|
|
|
|
|
m_pLbConnect = new class QLabel(QObject::tr("连接状态:"));
|
|
|
|
|
m_pLbConnect = new class QLabel(QObject::tr("连接状态:"));
|
|
|
|
|
m_pLbConnect->setMinimumWidth(c_nWidth);
|
|
|
|
|
|
|
|
|
|
//m_pLbDiskSpace = new class QLabel(QObject::tr("硬盘剩余空间:xxx.xG"));
|
|
|
|
|
//m_pLbDiskSpace = new class QLabel(QObject::tr("硬盘剩余空间:xxx.xG"));
|
|
|
|
|
//m_pLbDiskSpace->setMinimumWidth(c_nWidth);
|
|
|
|
|
|
|
|
|
|
ui.statusBar->addWidget(m_pLbOnLine);
|
|
|
|
|
@ -684,29 +690,29 @@ void CMainWin::onUpdateStatus()
|
|
|
|
|
{
|
|
|
|
|
if (m_pLbCurrentTime) {
|
|
|
|
|
QString m_currentTimerString = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
m_pLbCurrentTime->setText(QObject::tr("系统时间: ") + m_currentTimerString + " ");
|
|
|
|
|
m_pLbCurrentTime->setText(QObject::tr("系统时间: ") + m_currentTimerString + " ");
|
|
|
|
|
//m_pLbCurrentTime->setStyleSheet("font: 14px;");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pLbOnLine && m_pWfCtrl) {
|
|
|
|
|
QString strOnlineState = QString(QObject::tr("检测模式:"))
|
|
|
|
|
+ (m_pWfCtrl->IOnlineMode() == true ? QObject::tr("在线模式") : QObject::tr("离线模式"));
|
|
|
|
|
QString strOnlineState = QString(QObject::tr("检测模式:"))
|
|
|
|
|
+ (m_pWfCtrl->IOnlineMode() == true ? QObject::tr("在线模式") : QObject::tr("离线模式"));
|
|
|
|
|
m_pLbOnLine->setText(strOnlineState);
|
|
|
|
|
// m_pLbOnLine->setStyleSheet("font: bold 14px;");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pLbConnect && m_pWfCtrl) {
|
|
|
|
|
QString strOnlineState = QString(QObject::tr("连接状态:"))
|
|
|
|
|
+ (m_pWfCtrl->IConnectStatus() == true ? QObject::tr("连接正常") : QObject::tr("连接异常"));
|
|
|
|
|
QString strOnlineState = QString(QObject::tr("连接状态:"))
|
|
|
|
|
+ (m_pWfCtrl->IConnectStatus() == true ? QObject::tr("连接正常") : QObject::tr("连接异常"));
|
|
|
|
|
m_pLbConnect->setText(strOnlineState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_pLbUser) {
|
|
|
|
|
m_pLbUser->setText(QObject::tr("用户: %1").arg(m_strUserName.isEmpty()==true?QObject::tr("未登录"):m_strUserName));
|
|
|
|
|
m_pLbUser->setText(QObject::tr("用户: %1").arg(m_strUserName.isEmpty()==true?QObject::tr("未登录"):m_strUserName));
|
|
|
|
|
}
|
|
|
|
|
// if (m_pLbDiskSpace)
|
|
|
|
|
// {
|
|
|
|
|
// QString strDiskSpace = QString(QObject::tr("硬盘剩余空间:%1G")).arg(100 / 1024.0);
|
|
|
|
|
// QString strDiskSpace = QString(QObject::tr("硬盘剩余空间:%1G")).arg(100 / 1024.0);
|
|
|
|
|
// m_pLbDiskSpace->setText(strDiskSpace);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
@ -767,7 +773,7 @@ bool CMainWin::onInitDevice()
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//======系统翻译相关
|
|
|
|
|
//======系统翻译相关
|
|
|
|
|
void CMainWin::SearchQmFile(const QString & strDir)
|
|
|
|
|
{
|
|
|
|
|
QDir dir(strDir);
|
|
|
|
|
@ -776,8 +782,8 @@ void CMainWin::SearchQmFile(const QString & strDir)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
dir.setSorting(QDir::DirsFirst); // 文件夹优先
|
|
|
|
|
// 转换成一个List
|
|
|
|
|
dir.setSorting(QDir::DirsFirst); // 文件夹优先
|
|
|
|
|
// 转换成一个List
|
|
|
|
|
QFileInfoList list = dir.entryInfoList();
|
|
|
|
|
if (list.size() < 1)
|
|
|
|
|
{
|
|
|
|
|
@ -788,7 +794,7 @@ void CMainWin::SearchQmFile(const QString & strDir)
|
|
|
|
|
{
|
|
|
|
|
QFileInfo fileInfo = list.at(i);
|
|
|
|
|
QString tt = fileInfo.fileName();
|
|
|
|
|
// 如果是文件夹
|
|
|
|
|
// 如果是文件夹
|
|
|
|
|
bool bisDir = fileInfo.isDir();
|
|
|
|
|
if (bisDir)
|
|
|
|
|
{
|
|
|
|
|
@ -810,7 +816,7 @@ void CMainWin::SetTranslator(const QString strPath)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QTranslator *pTrans = new QTranslator;
|
|
|
|
|
if (pTrans->load(strPath)) // 如果加载成功
|
|
|
|
|
if (pTrans->load(strPath)) // 如果加载成功
|
|
|
|
|
{
|
|
|
|
|
qApp->installTranslator(pTrans);
|
|
|
|
|
m_VecTranPtr.append(pTrans);
|
|
|
|
|
@ -821,11 +827,17 @@ void CMainWin::SetTranslator(const QString strPath)
|
|
|
|
|
pTrans = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Q_SLOT void CMainWin::onLanguageChange(QString strLanguage)
|
|
|
|
|
{
|
|
|
|
|
QSettings languageSetting(lpSysConfig::instance()->getCfgPath(), QSettings::IniFormat);
|
|
|
|
|
languageSetting.value("language/select", "Chinese").toString();
|
|
|
|
|
SetLanguage(strLanguage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMainWin::SetLanguage(QString strLangage)
|
|
|
|
|
{
|
|
|
|
|
QString strDirPath = QString(QCoreApplication::applicationDirPath() + "/language/");
|
|
|
|
|
QString translatorFileName = strLangage;
|
|
|
|
|
QString translatorFileName = strLangage;
|
|
|
|
|
if (!translatorFileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
rmTranslator();
|
|
|
|
|
@ -852,10 +864,10 @@ void CMainWin::rmTranslator()
|
|
|
|
|
|
|
|
|
|
void CMainWin::writeConfig()
|
|
|
|
|
{
|
|
|
|
|
QSettings setting("language.ini", QSettings::IniFormat);
|
|
|
|
|
setting.setValue("language", m_strCurLanguage);
|
|
|
|
|
// QSettings setting("language.ini", QSettings::IniFormat);
|
|
|
|
|
// setting.setValue("language", m_strCurLanguage);
|
|
|
|
|
}
|
|
|
|
|
//======翻译
|
|
|
|
|
//======翻译
|
|
|
|
|
|
|
|
|
|
IDetectorUI* CMainWin::GetDesignerInterface() const
|
|
|
|
|
{
|
|
|
|
|
@ -940,11 +952,11 @@ Q_SLOT void CMainWin::onLogInOut(QString strName, int level, int state)
|
|
|
|
|
onChangeUI(strName, level);
|
|
|
|
|
m_strUserName = strName;
|
|
|
|
|
if (state == 0) {
|
|
|
|
|
ui.main_Login_action->setText(QObject::tr("注 销"));
|
|
|
|
|
ui.main_Login_action->setText(QObject::tr("注 销"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ui.main_Login_action->setText(QObject::tr("登 录"));
|
|
|
|
|
ui.main_Login_action->setText(QObject::tr("登 录"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -963,7 +975,7 @@ Q_SLOT void CMainWin::onTestMode(int val)
|
|
|
|
|
onSnapImage(2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//展示结果图片
|
|
|
|
|
//展示结果图片
|
|
|
|
|
Q_SLOT void CMainWin::onShowImage(int ID, QImage img)
|
|
|
|
|
{
|
|
|
|
|
auto ShowImg=[&](QLabel* pLab ,QImage& img) {
|
|
|
|
|
@ -973,7 +985,7 @@ Q_SLOT void CMainWin::onShowImage(int ID, QImage img)
|
|
|
|
|
}
|
|
|
|
|
if (img.isNull())
|
|
|
|
|
{
|
|
|
|
|
QString str = QObject::tr("检测到错误: 模型与图像尺寸不匹配,请重新标定模型!!!");
|
|
|
|
|
QString str = QObject::tr("检测到错误: 模型与图像尺寸不匹配,请重新标定模型!!!");
|
|
|
|
|
pLab->setText(str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
@ -1000,7 +1012,7 @@ Q_SLOT void CMainWin::onShowImage(int ID, QImage img)
|
|
|
|
|
ShowImg(ui.wf_lb_image_show_2, img);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//展示正在检测的型号名
|
|
|
|
|
//展示正在检测的型号名
|
|
|
|
|
Q_SLOT void CMainWin::onShowName(int ID, QString strName)
|
|
|
|
|
{
|
|
|
|
|
if (ID == 1) {
|
|
|
|
|
@ -1010,7 +1022,7 @@ Q_SLOT void CMainWin::onShowName(int ID, QString strName)
|
|
|
|
|
ui.wf_lb_station_name_2->setText(strName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//展示log
|
|
|
|
|
//展示log
|
|
|
|
|
Q_SLOT void CMainWin::onShowLog(int nID, QString strMsg)
|
|
|
|
|
{
|
|
|
|
|
if (nID == 1) {
|
|
|
|
|
@ -1025,7 +1037,7 @@ Q_SLOT void CMainWin::onPopMenu(const QPoint& pt)
|
|
|
|
|
{
|
|
|
|
|
if (!m_pWfCtrl)
|
|
|
|
|
return;
|
|
|
|
|
/*根据UI名判断是哪个工位需要设置相机*/
|
|
|
|
|
/*根据UI名判断是哪个工位需要设置相机*/
|
|
|
|
|
int nStationID = 1;
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if ("wf_lb_image_show_1" == strObj)
|
|
|
|
|
@ -1035,12 +1047,12 @@ Q_SLOT void CMainWin::onPopMenu(const QPoint& pt)
|
|
|
|
|
|
|
|
|
|
IStation *pStation = m_pWfCtrl->IGetStationById(nStationID);
|
|
|
|
|
if (!pStation) {
|
|
|
|
|
//相机没配置,需要处理 添加相机
|
|
|
|
|
//相机没配置,需要处理 添加相机
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QString strCamKey = pStation->stationKey();
|
|
|
|
|
QMenu menu;
|
|
|
|
|
QAction *pSetAction = menu.addAction(tr("相机属性配置"));
|
|
|
|
|
QAction *pSetAction = menu.addAction(tr("相机属性配置"));
|
|
|
|
|
pSetAction->setObjectName("setAction");
|
|
|
|
|
|
|
|
|
|
QAction *pSelect = menu.exec(QCursor::pos());
|
|
|
|
|
|