增加触发日志打印和超时1s再触发相机监测功能

master
bob.pan 4 years ago
parent ea9579e77d
commit e8b7e66434

@ -23,9 +23,9 @@
#include <QProcess> #include <QProcess>
#include "lpCryptokey.h" #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 VERSION_ALG "3.0.1.6"
#define UPDATE_TIME "2022-05-19" #define UPDATE_TIME "2022-05-27"
#define WHEELHIGHTTHRESH 260.0 //轮毂高度阈值,当轮毂高度大于这个值时,启用相机升高的直径算法 #define WHEELHIGHTTHRESH 260.0 //轮毂高度阈值,当轮毂高度大于这个值时,启用相机升高的直径算法
#define CAMERAUPHEIGHT 254.0 //相机上升高度默认10英寸 #define CAMERAUPHEIGHT 254.0 //相机上升高度默认10英寸
@ -303,6 +303,9 @@ lpMainWin::lpMainWin(QWidget *parent)
m_timerID = startTimer(1000); m_timerID = startTimer(1000);
m_timerID_Init = startTimer(1000); m_timerID_Init = startTimer(1000);
QTimer::singleShot(1000, m_pNet, SLOT(onOpenServer()));//延迟2s打开网络TCP服务 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() lpMainWin::~lpMainWin()
@ -727,7 +730,7 @@ void lpMainWin::IVariantMapToUI(const QString& camKey, const QVariantMap& vMap)
QVariant lpMainWin::IGetVariantById(int id) QVariant lpMainWin::IGetVariantById(int id)
{ {
m_nDiffTrigNum--;//进入到这里 表示获取到了图片 m_nDiffTrigNum--;//进入到这里 表示获取到了图片
emit sgRecvImg();//停止超时定时器计算
qWarning() << "Alg get An Image:" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")"; qWarning() << "Alg get An Image:" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")";
emit(sgShowImgState(tr("获得图像,正在计算中..."))); emit(sgShowImgState(tr("获得图像,正在计算中...")));
emit(sgGetImg()); emit(sgGetImg());
@ -1117,6 +1120,20 @@ void lpMainWin::timerEvent(QTimerEvent *event)
DetectState::instance()->IsDetect = true; DetectState::instance()->IsDetect = true;
m_pCtrl->onStart(); 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) 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()->m_CameraTrigeType == 0)//软件触发模式
{ {
if (DetectState::instance()->IsDetect == true) { if (DetectState::instance()->IsDetect == true)
{
// if (m_exposureTimeCount != 0) // if (m_exposureTimeCount != 0)
// { // {
// m_pCoreCtrl->ISetExposureTime(m_camKey, m_exposureTimeArray[m_exposureTimeCount]); // m_pCoreCtrl->ISetExposureTime(m_camKey, m_exposureTimeArray[m_exposureTimeCount]);
// } // }
onTriggerCam(); onTriggerCam();
qWarning() << "soft ctrol camera :" << "(" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss zzz") << ")"; 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); ui.main_lb_res_Channle_Show->setText(str);
} }
//触发相机 打开超时定时器 记录信号
Q_SLOT void lpMainWin::onTriggerCam() Q_SLOT void lpMainWin::onTriggerCam()
{ {
if (m_pCoreCtrl) 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(); QStringList strLst = m_pCoreCtrl->ICameraKeys();
m_pCoreCtrl->ISnapImage(strLst); 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() 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);
}

@ -65,6 +65,9 @@ signals:
void sgNetData(int, QVariantMap); void sgNetData(int, QVariantMap);
void sgAutoExposure(); void sgAutoExposure();
void sgShowRatioVal(double val); void sgShowRatioVal(double val);
void sgShowLog(QString strlog);
void sgRecvImg();
private: private:
Q_SLOT void onLogInOut(QString strName, int level, int state); Q_SLOT void onLogInOut(QString strName, int level, int state);
Q_SLOT void onActionClicked(); Q_SLOT void onActionClicked();
@ -75,6 +78,7 @@ private:
Q_SLOT void onLineseCheck(bool bFlag); Q_SLOT void onLineseCheck(bool bFlag);
Q_SLOT void onUpdateExposureSetting(); Q_SLOT void onUpdateExposureSetting();
void onStrongButton(); void onStrongButton();
Q_SLOT void onShowLog(QString strLog);
protected: protected:
bool onInitCoreCtrl(); bool onInitCoreCtrl();
@ -116,6 +120,7 @@ protected:
Q_SLOT void onSendDisLibDone(); Q_SLOT void onSendDisLibDone();
Q_SLOT void onShowChannel(QString str); Q_SLOT void onShowChannel(QString str);
Q_SLOT void onTriggerCam(); Q_SLOT void onTriggerCam();
Q_SLOT void onTriggerCamRecv();//触发动作完成 有图像
Q_SLOT void onChangePLCParam(); Q_SLOT void onChangePLCParam();
void onInitAbout(); void onInitAbout();
@ -215,6 +220,7 @@ private:
int m_timerID_btn{ 0 };//强制改变开始检测按钮用 用于提醒 int m_timerID_btn{ 0 };//强制改变开始检测按钮用 用于提醒
int m_timerID_Init{ 0 };//启动初始化 如延时开启服务 开启检测 int m_timerID_Init{ 0 };//启动初始化 如延时开启服务 开启检测
int m_timerID_TrigerTimeOut{ 0 };//相机触发超时ID
}; };
#endif #endif

Loading…
Cancel
Save