|
|
|
@ -15,16 +15,12 @@
|
|
|
|
int Station::s_nTrigWaitTimes = 5;
|
|
|
|
int Station::s_nTrigWaitTimes = 5;
|
|
|
|
|
|
|
|
|
|
|
|
Station::Station(QSqliteWheelHubWf *p1, ICoreCtrl *p2, IWfCtrl * p3)
|
|
|
|
Station::Station(QSqliteWheelHubWf *p1, ICoreCtrl *p2, IWfCtrl * p3)
|
|
|
|
: m_pView(NULL), m_pLblImage(NULL), m_pLblStationName(NULL),
|
|
|
|
: m_pView(NULL),m_pDbWf(p1)
|
|
|
|
m_pDbWf(p1)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_pResultTextShow = NULL;
|
|
|
|
|
|
|
|
m_pCoreCtrl = p2;
|
|
|
|
m_pCoreCtrl = p2;
|
|
|
|
m_pWfCtrl = p3;
|
|
|
|
m_pWfCtrl = p3;
|
|
|
|
m_pTrigDetector = new CTrigDetector;
|
|
|
|
m_pTrigDetector = new CTrigDetector;
|
|
|
|
connect(m_pTrigDetector, SIGNAL(sgErrorTrig(int)), this, SLOT(onErrTrig(int)));
|
|
|
|
connect(m_pTrigDetector, SIGNAL(sgErrorTrig(int)), this, SLOT(onErrTrig(int)));
|
|
|
|
connect(this, SIGNAL(sgPrint2Window(QString &)), this, SLOT(onAddResult2TextEdit(QString &)));
|
|
|
|
|
|
|
|
connect(this, SIGNAL(sgShowImage(const QImage&)), this, SLOT(showImage(const QImage&)));
|
|
|
|
|
|
|
|
connect(this, SIGNAL(sgUpdateLable()), this, SLOT(updateAll()));
|
|
|
|
connect(this, SIGNAL(sgUpdateLable()), this, SLOT(updateAll()));
|
|
|
|
connect(this, SIGNAL(sgaddTrigCount(int)), m_pTrigDetector, SLOT(addTrigCount(int)));
|
|
|
|
connect(this, SIGNAL(sgaddTrigCount(int)), m_pTrigDetector, SLOT(addTrigCount(int)));
|
|
|
|
connect(this, SIGNAL(sgaddRevCount(int)), m_pTrigDetector, SLOT(addRevCount(int)));
|
|
|
|
connect(this, SIGNAL(sgaddRevCount(int)), m_pTrigDetector, SLOT(addRevCount(int)));
|
|
|
|
@ -155,7 +151,6 @@ bool Station::initCurrentModel()
|
|
|
|
|
|
|
|
|
|
|
|
bool Station::updateCurrentModel2Label()
|
|
|
|
bool Station::updateCurrentModel2Label()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_pLblStationName) {
|
|
|
|
|
|
|
|
bool bCali = false;
|
|
|
|
bool bCali = false;
|
|
|
|
WfModel *pModel = wfModel(m_strCurrentModel);
|
|
|
|
WfModel *pModel = wfModel(m_strCurrentModel);
|
|
|
|
if (pModel) {
|
|
|
|
if (pModel) {
|
|
|
|
@ -168,9 +163,7 @@ bool Station::updateCurrentModel2Label()
|
|
|
|
.arg(nId).arg(m_strCurrentModel == "" ? "?" : m_strCurrentModel)
|
|
|
|
.arg(nId).arg(m_strCurrentModel == "" ? "?" : m_strCurrentModel)
|
|
|
|
.arg(bCali == true ? QObject::tr("已标定") : QObject::tr("未标定"));
|
|
|
|
.arg(bCali == true ? QObject::tr("已标定") : QObject::tr("未标定"));
|
|
|
|
|
|
|
|
|
|
|
|
m_pLblStationName->setText(strText);
|
|
|
|
emit sgShowModeName(nId, strText);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,14 +174,6 @@ bool Station::updateAll()
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Station::onAddResult2TextEdit(QString &str)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!m_pResultTextShow) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pResultTextShow->append(str);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVariant Station::getVariant()
|
|
|
|
QVariant Station::getVariant()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -205,12 +190,12 @@ void Station::onErrTrig(int nErrCount)
|
|
|
|
else if (s_nTrigWaitTimes * 3 == nErrCount) {
|
|
|
|
else if (s_nTrigWaitTimes * 3 == nErrCount) {
|
|
|
|
qWarning() << "stationid =" << nId << ",nErrCount = " << nErrCount;
|
|
|
|
qWarning() << "stationid =" << nId << ",nErrCount = " << nErrCount;
|
|
|
|
QString str = genTimerInfo() + "camera disconnect!";
|
|
|
|
QString str = genTimerInfo() + "camera disconnect!";
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
str = genTimerInfo() + "camera count reset, but not trig again!";
|
|
|
|
str = genTimerInfo() + "camera count reset, but not trig again!";
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
m_pTrigDetector->correct();
|
|
|
|
m_pTrigDetector->correct();
|
|
|
|
str = genTimerInfo() + "try reopen camera!";
|
|
|
|
str = genTimerInfo() + "try reopen camera!";
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
m_pCoreCtrl->IStopCamera(szCamKey);
|
|
|
|
m_pCoreCtrl->IStopCamera(szCamKey);
|
|
|
|
m_pCoreCtrl->ICloseCamera(szCamKey);
|
|
|
|
m_pCoreCtrl->ICloseCamera(szCamKey);
|
|
|
|
if (m_pWfCtrl->IBatchModel()) {
|
|
|
|
if (m_pWfCtrl->IBatchModel()) {
|
|
|
|
@ -218,7 +203,7 @@ void Station::onErrTrig(int nErrCount)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool bb = m_pCoreCtrl->IOpenCamera(szCamKey);
|
|
|
|
bool bb = m_pCoreCtrl->IOpenCamera(szCamKey);
|
|
|
|
str = QString("reopen_%1").arg(bb);
|
|
|
|
str = QString("reopen_%1").arg(bb);
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
bool b = m_pCoreCtrl->IStartCamera(szCamKey);
|
|
|
|
bool b = m_pCoreCtrl->IStartCamera(szCamKey);
|
|
|
|
if (b) {
|
|
|
|
if (b) {
|
|
|
|
str = genTimerInfo() + "try reopen successful!";
|
|
|
|
str = genTimerInfo() + "try reopen successful!";
|
|
|
|
@ -228,7 +213,7 @@ void Station::onErrTrig(int nErrCount)
|
|
|
|
str = genTimerInfo() + "reopen failed!";
|
|
|
|
str = genTimerInfo() + "reopen failed!";
|
|
|
|
qWarning() << "stationid = " << nId << ", try reopen camera:" << szCamKey << " failed";
|
|
|
|
qWarning() << "stationid = " << nId << ", try reopen camera:" << szCamKey << " failed";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
if (m_pWfCtrl->IBatchModel()) {
|
|
|
|
if (m_pWfCtrl->IBatchModel()) {
|
|
|
|
trigImage();
|
|
|
|
trigImage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -238,9 +223,9 @@ void Station::onErrTrig(int nErrCount)
|
|
|
|
else if (s_nTrigWaitTimes == nErrCount || s_nTrigWaitTimes * 2 == nErrCount) {
|
|
|
|
else if (s_nTrigWaitTimes == nErrCount || s_nTrigWaitTimes * 2 == nErrCount) {
|
|
|
|
qWarning() << "camera trig failed!";
|
|
|
|
qWarning() << "camera trig failed!";
|
|
|
|
QString str = genTimerInfo() + "camera trig failed!";
|
|
|
|
QString str = genTimerInfo() + "camera trig failed!";
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
str = genTimerInfo() + "try to trig again!";
|
|
|
|
str = genTimerInfo() + "try to trig again!";
|
|
|
|
onAddResult2TextEdit(str);
|
|
|
|
emit sgPrint2Window(str);
|
|
|
|
|
|
|
|
|
|
|
|
QStringList strList = m_pCoreCtrl->ICameraKeys();
|
|
|
|
QStringList strList = m_pCoreCtrl->ICameraKeys();
|
|
|
|
if (strList.contains(szCamKey))
|
|
|
|
if (strList.contains(szCamKey))
|
|
|
|
@ -339,31 +324,9 @@ bool Station::trigImage(const QString folder/* = QString()*/)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Station::setWidget(QString str, QWidget *pWgt)
|
|
|
|
bool Station::setView(QWidget *pWgt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if (str.startsWith(_WF_CAM_LISTWIDGET_PREFIX)) {
|
|
|
|
|
|
|
|
m_pView = new ModelView(qobject_cast<QTableView*>(pWgt), this);
|
|
|
|
m_pView = new ModelView(qobject_cast<QTableView*>(pWgt), this);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (str.startsWith(_WF_LABEL_IMAGE_SHOW_PREFIX)) {
|
|
|
|
|
|
|
|
// m_pLblImage = qobject_cast<QLabel*>(pWgt);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (str.startsWith(_WF_LABEL_STATION_NAME_PREFIX)) {
|
|
|
|
|
|
|
|
// m_pLblStationName = qobject_cast<QLabel*>(pWgt);
|
|
|
|
|
|
|
|
// updateCurrentModel2Label();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else if (str.startsWith(_WF_TEXT_EDIT_RESULT_PREFIX)) {
|
|
|
|
|
|
|
|
// m_pResultTextShow = qobject_cast<QTextEdit*>(pWgt);
|
|
|
|
|
|
|
|
// if (m_pResultTextShow) {
|
|
|
|
|
|
|
|
// m_pResultTextShow->clear();
|
|
|
|
|
|
|
|
// QTextDocument *pDoc = m_pResultTextShow->document();
|
|
|
|
|
|
|
|
// pDoc->setMaximumBlockCount(200);
|
|
|
|
|
|
|
|
// m_pResultTextShow->append(Station::genTimerInfo() + "start successful");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -474,49 +437,6 @@ bool Station::sendResult(double angleValue)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Station::setComInfo(QString strName, int nCmd)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_strComName = strName;
|
|
|
|
|
|
|
|
m_nCmd = nCmd;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void Station::showImage(const QImage &img)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// if (m_pImgViewer)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// QImage imgShow = img;
|
|
|
|
|
|
|
|
// m_pImgViewer->setImg(imgShow);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_pLblImage) {
|
|
|
|
|
|
|
|
qDebug() << "label image is null";
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "show image";
|
|
|
|
|
|
|
|
//QRect rt = m_pLblImage->rect();
|
|
|
|
|
|
|
|
if (img.isNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString str = QObject::tr("检测到错误: 模型与图像尺寸不匹配,请重新标定模型!!!");
|
|
|
|
|
|
|
|
m_pLblImage->setText(str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QRect rt = m_pLblImage->rect();
|
|
|
|
|
|
|
|
int h = img.height();
|
|
|
|
|
|
|
|
int w = img.width();
|
|
|
|
|
|
|
|
float d = w*1.0 / h;
|
|
|
|
|
|
|
|
if (d > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int h2 = rt.width() / d;
|
|
|
|
|
|
|
|
rt.setHeight(h2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QImage imgShow = img.scaled(QSize(rt.size()));
|
|
|
|
|
|
|
|
m_pLblImage->setPixmap(QPixmap::fromImage(imgShow));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString Station::currentSelectModel()
|
|
|
|
QString Station::currentSelectModel()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m_pView) {
|
|
|
|
if (m_pView) {
|
|
|
|
|