|
|
|
@ -13,6 +13,7 @@
|
|
|
|
#include "lpGlobalConfig.h"
|
|
|
|
#include "lpGlobalConfig.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define LEAPER_LOGO ":/leaper/Resource/app.png"
|
|
|
|
#define LEAPER_LOGO ":/leaper/Resource/app.png"
|
|
|
|
|
|
|
|
#define WINDOWS_ICON ":/leaper/Resource/app.png"
|
|
|
|
#define DELETE_POINTER(p) if (p) {delete p; p = NULL;}
|
|
|
|
#define DELETE_POINTER(p) if (p) {delete p; p = NULL;}
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
@ -80,10 +81,11 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
onInitSerial();
|
|
|
|
onInitSerial();
|
|
|
|
onInitUser();
|
|
|
|
onInitUser();
|
|
|
|
onInitUI();
|
|
|
|
onInitUI();
|
|
|
|
|
|
|
|
onInitStatus();
|
|
|
|
lpSysLog::instance()->Init();
|
|
|
|
lpSysLog::instance()->Init();
|
|
|
|
lpSysConfig::instance()->readConfig();
|
|
|
|
lpSysConfig::instance()->readConfig();
|
|
|
|
lpSysConfig::instance()->writeConfig();
|
|
|
|
lpSysConfig::instance()->writeConfig();
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->readConfig();
|
|
|
|
SYSLOG_STATUS << "系统启动";
|
|
|
|
SYSLOG_STATUS << "系统启动";
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString strPath = QCoreApplication::applicationDirPath();
|
|
|
|
QString strPath = QCoreApplication::applicationDirPath();
|
|
|
|
@ -96,7 +98,7 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
|
|
m_pCameraTrig = new AutoTrigger;
|
|
|
|
m_pCameraTrig = new AutoTrigger;
|
|
|
|
connect(m_pCameraTrig, SIGNAL(sgTrig()), this, SLOT(onTrigImage()));
|
|
|
|
connect(m_pCameraTrig, SIGNAL(sgTrig()), this, SLOT(onTrigImage()));
|
|
|
|
onInitStatus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(&m_devMgrWid, SIGNAL(sgChangeLanguage(QString)), this, SLOT(onLanguageChange(QString)));
|
|
|
|
connect(&m_devMgrWid, SIGNAL(sgChangeLanguage(QString)), this, SLOT(onLanguageChange(QString)));
|
|
|
|
connect(&m_testWid, SIGNAL(sgTestMode(int)), this, SLOT(onTestMode(int)));
|
|
|
|
connect(&m_testWid, SIGNAL(sgTestMode(int)), this, SLOT(onTestMode(int)));
|
|
|
|
@ -105,6 +107,22 @@ CMainWin::CMainWin(QWidget *parent)
|
|
|
|
m_pWfCtrl->onInit();
|
|
|
|
m_pWfCtrl->onInit();
|
|
|
|
m_mangeWid.onInitModelList(m_pWfCtrl);
|
|
|
|
m_mangeWid.onInitModelList(m_pWfCtrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStringList strList = m_pWfCtrl->IGetStationKeys();
|
|
|
|
|
|
|
|
foreach(QString str, strList) {
|
|
|
|
|
|
|
|
IStation *pS = m_pWfCtrl->IGetStationByKey(str);
|
|
|
|
|
|
|
|
connect(pS, SIGNAL(sgShowModeName(QString, QString)), this, SLOT(onShowName(QString, QString)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (m_pDetectorEngine)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QStringList Names = m_pDetectorEngine->getSolutionMgr()->GetAllSolutions().keys();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_pWfCtrl->ISelModel(lpGlobalConfig::instance()->m_StationSolution_1, lpGlobalConfig::instance()->m_StationRunModel_1);
|
|
|
|
|
|
|
|
m_pWfCtrl->ISelModel(lpGlobalConfig::instance()->m_StationSolution_2, lpGlobalConfig::instance()->m_StationRunModel_2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CMainWin::~CMainWin()
|
|
|
|
CMainWin::~CMainWin()
|
|
|
|
@ -160,29 +178,46 @@ CMainWin::~CMainWin()
|
|
|
|
void CMainWin::INewCameraImage(const QString& camKey, QImage img)
|
|
|
|
void CMainWin::INewCameraImage(const QString& camKey, QImage img)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emit sgShowSrcImg(camKey, img);
|
|
|
|
emit sgShowSrcImg(camKey, img);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString solutionName;
|
|
|
|
|
|
|
|
QString strRunModel;
|
|
|
|
|
|
|
|
int stationID = 0;
|
|
|
|
|
|
|
|
if (camKey == lpGlobalConfig::instance()->m_StationCamKey_1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
solutionName = lpGlobalConfig::instance()->m_StationSolution_1;
|
|
|
|
|
|
|
|
strRunModel = lpGlobalConfig::instance()->m_StationRunModel_1;
|
|
|
|
|
|
|
|
stationID = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (camKey == lpGlobalConfig::instance()->m_StationCamKey_2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
solutionName = lpGlobalConfig::instance()->m_StationSolution_2;
|
|
|
|
|
|
|
|
strRunModel = lpGlobalConfig::instance()->m_StationRunModel_2;
|
|
|
|
|
|
|
|
stationID = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowImage(stationID, img);
|
|
|
|
|
|
|
|
|
|
|
|
QString solutionName = lpGlobalConfig::instance()->m_CamKeySolution.value(camKey);
|
|
|
|
|
|
|
|
if (solutionName.isEmpty())
|
|
|
|
if (solutionName.isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
QString strMode = lpGlobalConfig::instance()->m_curRunModel.value(solutionName);
|
|
|
|
QString strMode = strRunModel;
|
|
|
|
cv::Mat srcMat = QImageToMat(img);
|
|
|
|
cv::Mat srcMat = QImageToMat(img);
|
|
|
|
AlgResultCallBack func = std::bind(&CMainWin::IEngineResult, this, std::placeholders::_1);
|
|
|
|
AlgResultCallBack func = std::bind(&CMainWin::IEngineResult, this, std::placeholders::_1);
|
|
|
|
m_pDetectorEngine->detectByName(srcMat, solutionName, strMode, func);
|
|
|
|
m_pDetectorEngine->detectByName(srcMat, solutionName, strMode, func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//算法结果接收
|
|
|
|
//算法结果接收
|
|
|
|
void CMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
|
|
|
|
void CMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
// return;
|
|
|
|
QImage srcImg = vMap.value("srcImage").value<QImage>();
|
|
|
|
// QImage srcImg = vMap.value("srcImage").value<QImage>();
|
|
|
|
cv::Mat srcMat = QImageToMat(srcImg);
|
|
|
|
// cv::Mat srcMat = QImageToMat(srcImg);
|
|
|
|
QString strMode;// = pResult->m_strModel;
|
|
|
|
// QString strMode;// = pResult->m_strModel;
|
|
|
|
AlgResultCallBack func = std::bind(&CMainWin::IEngineResult, this, std::placeholders::_1);
|
|
|
|
// AlgResultCallBack func = std::bind(&CMainWin::IEngineResult, this, std::placeholders::_1);
|
|
|
|
m_pDetectorEngine->detect(srcMat, strMode, func);
|
|
|
|
// m_pDetectorEngine->detect(srcMat, strMode, func);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -581,6 +616,12 @@ Q_SLOT void CMainWin::onActionClicked()
|
|
|
|
m_devMgrWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
m_devMgrWid.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
|
|
|
m_devMgrWid.setWindowModality(Qt::ApplicationModal);
|
|
|
|
m_devMgrWid.setWindowModality(Qt::ApplicationModal);
|
|
|
|
m_devMgrWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
m_devMgrWid.setAttribute(Qt::WA_ShowModal, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QStringList camkeys = m_pCoreCtrl->ICameraKeys();
|
|
|
|
|
|
|
|
QStringList solutions = m_pDetectorEngine->getSolutionMgr()->GetAllSolutions().keys();
|
|
|
|
|
|
|
|
m_devMgrWid.setSystemConfig(camkeys, solutions);
|
|
|
|
|
|
|
|
|
|
|
|
m_devMgrWid.show();
|
|
|
|
m_devMgrWid.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ("main_Login_action" == strObj) {//用户登陆
|
|
|
|
else if ("main_Login_action" == strObj) {//用户登陆
|
|
|
|
@ -994,13 +1035,16 @@ Q_SLOT void CMainWin::onMainFrameClose()
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void CMainWin::onSnapImage(int nCamera /*= -1*/)
|
|
|
|
Q_SLOT void CMainWin::onSnapImage(int nCamera /*= -1*/)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* IStation *pStation = m_pWfCtrl->IGetStationById(nCamera);
|
|
|
|
if (nCamera == 1)
|
|
|
|
if (!pStation) {
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
QString camKey = lpGlobalConfig::instance()->m_StationCamKey_1;
|
|
|
|
|
|
|
|
m_pCoreCtrl->ISnapImage(QStringList() << camKey);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nCamera == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString camKey = lpGlobalConfig::instance()->m_StationCamKey_2;
|
|
|
|
|
|
|
|
m_pCoreCtrl->ISnapImage(QStringList() << camKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
pStation->trigImage();
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void CMainWin::onTrigImage()
|
|
|
|
Q_SLOT void CMainWin::onTrigImage()
|
|
|
|
@ -1109,12 +1153,12 @@ Q_SLOT void CMainWin::onShowImage(int ID, QImage img)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//展示正在检测的型号名
|
|
|
|
//展示正在检测的型号名
|
|
|
|
Q_SLOT void CMainWin::onShowName(int ID, QString strName)
|
|
|
|
Q_SLOT void CMainWin::onShowName(QString ID, QString strName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ID == 1) {
|
|
|
|
if (ID == lpGlobalConfig::instance()->m_StationSolution_1) {
|
|
|
|
ui.wf_lb_station_name_1->setText(strName);
|
|
|
|
ui.wf_lb_station_name_1->setText(strName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ID == 2) {
|
|
|
|
else if (ID == lpGlobalConfig::instance()->m_StationSolution_2) {
|
|
|
|
ui.wf_lb_station_name_2->setText(strName);
|
|
|
|
ui.wf_lb_station_name_2->setText(strName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1132,19 +1176,27 @@ Q_SLOT void CMainWin::onShowLog(int nID, QString strMsg)
|
|
|
|
Q_SLOT void CMainWin::onPopMenu(const QPoint& pt)
|
|
|
|
Q_SLOT void CMainWin::onPopMenu(const QPoint& pt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/*根据UI名判断是哪个工位需要设置相机*/
|
|
|
|
/*根据UI名判断是哪个工位需要设置相机*/
|
|
|
|
/* int nStationID = 1;
|
|
|
|
QString strCamKey;
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
if ("wf_lb_image_show_1" == strObj)
|
|
|
|
if ("wf_lb_image_show_1" == strObj)
|
|
|
|
nStationID = 1;
|
|
|
|
{
|
|
|
|
|
|
|
|
strCamKey = lpGlobalConfig::instance()->m_StationCamKey_1;
|
|
|
|
|
|
|
|
}
|
|
|
|
else if ("wf_lb_image_show_2" == strObj)
|
|
|
|
else if ("wf_lb_image_show_2" == strObj)
|
|
|
|
nStationID = 2;
|
|
|
|
{
|
|
|
|
|
|
|
|
strCamKey = lpGlobalConfig::instance()->m_StationCamKey_2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IStation *pStation = m_pWfCtrl->IGetStationById(nStationID);
|
|
|
|
QStringList camkeys = m_pCoreCtrl->ICameraKeys();
|
|
|
|
if (!pStation) {
|
|
|
|
if (!camkeys.contains(strCamKey) || strCamKey.isEmpty())
|
|
|
|
//相机没配置,需要处理 添加相机
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
QMessageBox infobox(QMessageBox::Critical, tr("提示"), tr("请对该工位的相机进行绑定!"), QMessageBox::Yes, this);
|
|
|
|
|
|
|
|
infobox.setWindowIcon(QIcon(WINDOWS_ICON));
|
|
|
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, tr("确认"));
|
|
|
|
|
|
|
|
infobox.exec();
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QString strCamKey = pStation->stationKey();
|
|
|
|
|
|
|
|
QMenu menu;
|
|
|
|
QMenu menu;
|
|
|
|
QAction *pSetAction = menu.addAction(tr("相机属性配置"));
|
|
|
|
QAction *pSetAction = menu.addAction(tr("相机属性配置"));
|
|
|
|
pSetAction->setObjectName("setAction");
|
|
|
|
pSetAction->setObjectName("setAction");
|
|
|
|
@ -1167,7 +1219,6 @@ Q_SLOT void CMainWin::onPopMenu(const QPoint& pt)
|
|
|
|
m_camSetWid.show();
|
|
|
|
m_camSetWid.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu.clear();
|
|
|
|
menu.clear();
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void CMainWin::onSlotAddNewModel(QString strName)
|
|
|
|
Q_SLOT void CMainWin::onSlotAddNewModel(QString strName)
|
|
|
|
@ -1199,11 +1250,11 @@ Q_SLOT void CMainWin::onSlotDelOldModel(QString strName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CMainWin::IEngineResult(QVariantMap vMap)
|
|
|
|
void CMainWin::IEngineResult(QVariantMap vMap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QImage srcImg = vMap.value("originImage").value<QImage>();
|
|
|
|
QImage srcImg = vMap.value("originImage").value<QImage>();
|
|
|
|
bool taskCali = vMap.value("taskCali").toBool();
|
|
|
|
bool taskCali = vMap.value("taskCali").toBool();
|
|
|
|
|
|
|
|
QString solutionName = vMap.value("solutionName").toString();
|
|
|
|
if (taskCali == false)//模板未标定
|
|
|
|
if (taskCali == false)//模板未标定
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// ui.main_value_Result->setText("该型号未标定");
|
|
|
|
// ui.main_value_Result->setText("该型号未标定");
|
|
|
|
@ -1243,18 +1294,29 @@ void CMainWin::IEngineResult(QVariantMap vMap)
|
|
|
|
// valueRlt.pixmap = QPixmap::fromImage(srcImg);
|
|
|
|
// valueRlt.pixmap = QPixmap::fromImage(srcImg);
|
|
|
|
// valueRlt.resultType = 3;//识别出型号 但未标定
|
|
|
|
// valueRlt.resultType = 3;//识别出型号 但未标定
|
|
|
|
// onSaveValveResult(valueRlt);
|
|
|
|
// onSaveValveResult(valueRlt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int stationID = 0;
|
|
|
|
|
|
|
|
if (solutionName == lpGlobalConfig::instance()->m_StationSolution_1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stationID = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (solutionName == lpGlobalConfig::instance()->m_StationSolution_2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stationID = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowImage(stationID, srcImg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// QVariantMap algResult = vMap.value("AlgoResult").toMap();
|
|
|
|
QVariantMap algResult = vMap.value("AlgoResult").toMap();
|
|
|
|
//
|
|
|
|
|
|
|
|
// double dAngle = algResult.contains("angle") ? algResult.value("angle").toDouble() : 365;
|
|
|
|
double dAngle = algResult.contains("angle") ? algResult.value("angle").toDouble() : 365;
|
|
|
|
// int errorType = algResult.contains("error") ? algResult.value("error").toInt() : 16;
|
|
|
|
int errorType = algResult.contains("error") ? algResult.value("error").toInt() : 16;
|
|
|
|
// double matchScore = algResult.value("score").toDouble() * 100;
|
|
|
|
double matchScore = algResult.value("score").toDouble() * 100;
|
|
|
|
// QImage maskImg = algResult.value("image").value<QImage>();
|
|
|
|
QImage maskImg = algResult.value("image").value<QImage>();
|
|
|
|
// QString str = algResult.value("resultTip").toString();
|
|
|
|
QString str = algResult.value("resultTip").toString();
|
|
|
|
// QPointF centerPoint = algResult.value("centerPoint").toPointF();
|
|
|
|
QPointF centerPoint = algResult.value("centerPoint").toPointF();
|
|
|
|
// QString taskName = vMap.value("taskName").toString();
|
|
|
|
QString taskName = vMap.value("taskName").toString();
|
|
|
|
// double taskTime = vMap.value("tasktime").toDouble();
|
|
|
|
double taskTime = vMap.value("tasktime").toDouble();
|
|
|
|
// ui.main_label_angle->setText(QString("%1").arg(dAngle));
|
|
|
|
// ui.main_label_angle->setText(QString("%1").arg(dAngle));
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ValueResult valueRlt;
|
|
|
|
// ValueResult valueRlt;
|
|
|
|
@ -1297,6 +1359,16 @@ void CMainWin::IEngineResult(QVariantMap vMap)
|
|
|
|
// if (!maskImg.isNull())
|
|
|
|
// if (!maskImg.isNull())
|
|
|
|
// m_ImgViewer->setImg(maskImg);
|
|
|
|
// m_ImgViewer->setImg(maskImg);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
int stationID = 0;
|
|
|
|
|
|
|
|
if (solutionName == lpGlobalConfig::instance()->m_StationSolution_1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stationID = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (solutionName == lpGlobalConfig::instance()->m_StationSolution_2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stationID = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowImage(stationID, maskImg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|