From e8b7e664348fa1e463dfa33713939993c510c905 Mon Sep 17 00:00:00 2001 From: "bob.pan" Date: Fri, 27 May 2022 10:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A6=E5=8F=91=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0=E5=92=8C=E8=B6=85=E6=97=B61s?= =?UTF-8?q?=E5=86=8D=E8=A7=A6=E5=8F=91=E7=9B=B8=E6=9C=BA=E7=9B=91=E6=B5=8B?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tpvs17/tpMain/lpMainWin.cpp | 59 +++++++++++++++++++++++++++++++++---- tpvs17/tpMain/lpMainWin.h | 6 ++++ 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/tpvs17/tpMain/lpMainWin.cpp b/tpvs17/tpMain/lpMainWin.cpp index 65ebf0c..062834a 100644 --- a/tpvs17/tpMain/lpMainWin.cpp +++ b/tpvs17/tpMain/lpMainWin.cpp @@ -23,9 +23,9 @@ #include #include "lpCryptokey.h" -#define VERSION_HUB "3.0.3.1" +#define VERSION_HUB "3.0.3.3" #define VERSION_ALG "3.0.1.6" -#define UPDATE_TIME "2022-05-19" +#define UPDATE_TIME "2022-05-27" #define WHEELHIGHTTHRESH 260.0 //轮毂高度阈值,当轮毂高度大于这个值时,启用相机升高的直径算法 #define CAMERAUPHEIGHT 254.0 //相机上升高度,默认10英寸 @@ -303,6 +303,9 @@ lpMainWin::lpMainWin(QWidget *parent) m_timerID = startTimer(1000); m_timerID_Init = startTimer(1000); QTimer::singleShot(1000, m_pNet, SLOT(onOpenServer()));//延迟2s打开网络TCP服务 + + connect(this, SIGNAL(sgShowLog(QString)), this, SLOT(onShowLog(QString))); + connect(this, SIGNAL(sgRecvImg()), this, SLOT(onTriggerCamRecv())); } lpMainWin::~lpMainWin() @@ -727,7 +730,7 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap) QVariant lpMainWin::IGetVariantById(int id) { m_nDiffTrigNum--;//进入到这里 表示获取到了图片 - + emit sgRecvImg();//停止超时定时器计算 qWarning() << "Alg get An Image:" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")"; emit(sgShowImgState(tr("获得图像,正在计算中..."))); emit(sgGetImg()); @@ -1117,6 +1120,20 @@ void lpMainWin::timerEvent(QTimerEvent *event) DetectState::instance()->IsDetect = true; m_pCtrl->onStart(); } + else if (m_timerID_TrigerTimeOut == event->timerId())//相机触发超时 + { + killTimer(m_timerID_TrigerTimeOut); + m_timerID_TrigerTimeOut = 0; + QString strMsg = QString("%1-triger Cam timeout 1s.").arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz")); + emit sgShowLog(strMsg); + if (m_nDiffTrigNum > 5) + { + QString strMsg = QString("%1-try triger out of 5 times,stop to try.").arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz")); + emit sgShowLog(strMsg); + return; + } + onTriggerCam(); + } } void lpMainWin::closeEvent(QCloseEvent *event) @@ -1391,14 +1408,20 @@ Q_SLOT void lpMainWin::onTrigRecv(int m_value,double dRatio) { //if (DetectState::instance()->m_CameraTrigeType == 0)//软件触发模式 { - if (DetectState::instance()->IsDetect == true) { + if (DetectState::instance()->IsDetect == true) + { // if (m_exposureTimeCount != 0) // { // m_pCoreCtrl->ISetExposureTime(m_camKey, m_exposureTimeArray[m_exposureTimeCount]); // } onTriggerCam(); + qWarning() << "soft ctrol camera :" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")"; } + else { + QString strMsg = QString("%1-detect is false,but recv triger").arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz")); + emit sgShowLog(strMsg); + } } } } @@ -1494,14 +1517,28 @@ Q_SLOT void lpMainWin::onShowChannel(QString str) { ui.main_lb_res_Channle_Show->setText(str); } - +//触发相机 打开超时定时器 记录信号 Q_SLOT void lpMainWin::onTriggerCam() { if (m_pCoreCtrl) { + m_timerID_TrigerTimeOut = startTimer(1000); + m_nDiffTrigNum++; + QString strMsg = QString("%1-try triger cam").arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz")); + emit sgShowLog(strMsg); QStringList strLst = m_pCoreCtrl->ICameraKeys(); m_pCoreCtrl->ISnapImage(strLst); } + +} +//接收到相机触发反馈信号 有图像了 关闭超时定时器 +Q_SLOT void lpMainWin::onTriggerCamRecv() +{ + QString strMsg = QString("%1-recv Image").arg(QDateTime::currentDateTime().toString("hh:mm:ss zzz")); + emit sgShowLog(strMsg); + killTimer(m_timerID_TrigerTimeOut); + m_timerID_TrigerTimeOut = 0; + m_nDiffTrigNum = 0; } Q_SLOT void lpMainWin::onChangePLCParam() @@ -1977,3 +2014,15 @@ void lpMainWin::onStrongButton() } } +Q_SLOT void lpMainWin::onShowLog(QString strLog) +{ + if (ui.main_textBrowser->toPlainText().size() > 10240) + { + ui.main_textBrowser->clear(); + } + + ui.main_textBrowser->append(strLog); + QTextCursor cursor = ui.main_textBrowser->textCursor(); + cursor.movePosition(QTextCursor::End); + ui.main_textBrowser->setTextCursor(cursor); +} diff --git a/tpvs17/tpMain/lpMainWin.h b/tpvs17/tpMain/lpMainWin.h index b8eafde..9bf88a9 100644 --- a/tpvs17/tpMain/lpMainWin.h +++ b/tpvs17/tpMain/lpMainWin.h @@ -65,6 +65,9 @@ signals: void sgNetData(int, QVariantMap); void sgAutoExposure(); void sgShowRatioVal(double val); + void sgShowLog(QString strlog); + + void sgRecvImg(); private: Q_SLOT void onLogInOut(QString strName, int level, int state); Q_SLOT void onActionClicked(); @@ -75,6 +78,7 @@ private: Q_SLOT void onLineseCheck(bool bFlag); Q_SLOT void onUpdateExposureSetting(); void onStrongButton(); + Q_SLOT void onShowLog(QString strLog); protected: bool onInitCoreCtrl(); @@ -116,6 +120,7 @@ protected: Q_SLOT void onSendDisLibDone(); Q_SLOT void onShowChannel(QString str); Q_SLOT void onTriggerCam(); + Q_SLOT void onTriggerCamRecv();//触发动作完成 有图像 Q_SLOT void onChangePLCParam(); void onInitAbout(); @@ -215,6 +220,7 @@ private: int m_timerID_btn{ 0 };//强制改变开始检测按钮用 用于提醒 int m_timerID_Init{ 0 };//启动初始化 如延时开启服务 开启检测 + int m_timerID_TrigerTimeOut{ 0 };//相机触发超时ID }; #endif