mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 19:49:42 +08:00
更新支持使用asd测定的积分球标准能量曲线
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
//#include "pch.h"
|
||||
#include "Header_Files/ATPControl_Serial_QT.h"
|
||||
//#include "ZZ_Math_HDRONLY.h"
|
||||
#include <QDebug>
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
@ -64,26 +63,27 @@ int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumbe
|
||||
return 2;
|
||||
}
|
||||
|
||||
// int testi;
|
||||
// GetDeviceAttribute(m_daDeviceAttr);
|
||||
// GetExposureTime(testi);
|
||||
// SetExposureTime(10000);
|
||||
// DataFrame test;
|
||||
// SingleShot(test);
|
||||
// int testi;
|
||||
// GetDeviceAttribute(m_daDeviceAttr);
|
||||
// GetExposureTime(testi);
|
||||
// SetExposureTime(10000);
|
||||
// DataFrame test;
|
||||
// SingleShot(test);
|
||||
|
||||
GetDeviceInfo(m_diDeviceInfo);
|
||||
GetExposureTime_Init();
|
||||
//
|
||||
// std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName);
|
||||
// if (szPostion == std::string::npos)
|
||||
// {
|
||||
// qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
// return 3;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName);
|
||||
if (szPostion == std::string::npos)
|
||||
{
|
||||
qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ void ZZ_ATPControl_Serial_Qt::Close()
|
||||
{
|
||||
m_pSerialPort->close();
|
||||
}
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo& Info)
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
|
||||
@ -146,7 +146,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo& Info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr)
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
|
||||
@ -197,6 +197,9 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr)
|
||||
m_daDeviceAttr.iMaxIntegrationTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
|
||||
|
||||
int iTempExpTime = 0;
|
||||
GetExposureTime(iTempExpTime);
|
||||
|
||||
iRes = SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS);
|
||||
if (iRes != 0)
|
||||
{
|
||||
@ -210,6 +213,8 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr)
|
||||
return 3;
|
||||
}
|
||||
|
||||
SetExposureTime(iTempExpTime);
|
||||
|
||||
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
@ -239,7 +244,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr)
|
||||
memcpy(fWaveLengthCoef, qbRecv.data() + 16, 4 * sizeof(float));
|
||||
for (int i = 0; i < m_daDeviceAttr.iPixels; i++)
|
||||
{
|
||||
m_daDeviceAttr.fWaveLengthInNM[i] = fWaveLengthCoef[0] * i * i * i + fWaveLengthCoef[1] * i * i + fWaveLengthCoef[2] * i + fWaveLengthCoef[3];
|
||||
m_daDeviceAttr.fWaveLengthInNM[i] = fWaveLengthCoef[0] * i*i*i + fWaveLengthCoef[1] * i*i + fWaveLengthCoef[2] * i + fWaveLengthCoef[3];
|
||||
}
|
||||
|
||||
Attr = m_daDeviceAttr;
|
||||
@ -313,7 +318,7 @@ int ZZ_ATPControl_Serial_Qt::SendCommand(QByteArray qbCommand)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData)
|
||||
int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
{
|
||||
qbData.clear();
|
||||
qbData = m_pSerialPort->readAll();
|
||||
@ -321,11 +326,11 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData)
|
||||
int iCounter = 0;
|
||||
while (qbData.size() < 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(1000);
|
||||
m_pSerialPort->waitForReadyRead(600);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 150)
|
||||
if (iCounter > 25)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
return 1;
|
||||
@ -377,7 +382,71 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray& qbData)
|
||||
int ZZ_ATPControl_Serial_Qt::RecvData_ShortLag(QByteArray &qbData)
|
||||
{
|
||||
qbData.clear();
|
||||
qbData = m_pSerialPort->readAll();
|
||||
|
||||
int iCounter = 0;
|
||||
while (qbData.size() < 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(100);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 6)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
return 1;
|
||||
}
|
||||
iCounter++;
|
||||
}
|
||||
|
||||
if ((ZZ_U8)qbData[0] != (ZZ_U8)0xaa || (ZZ_U8)qbData[1] != (ZZ_U8)0x55)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Wrong Header.Exit Code:2" << qbData.size();
|
||||
return 2;
|
||||
}
|
||||
|
||||
iCounter = 0;
|
||||
int iLength = qbData[2] * 256 + qbData[3] + 2;
|
||||
while (qbData.size() < iLength)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(100);
|
||||
qbData.append(m_pSerialPort->readAll());
|
||||
|
||||
if (iCounter > 6)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Incomplete Data.Exit Code:3" << qbData.size();
|
||||
return 3;
|
||||
}
|
||||
iCounter++;
|
||||
}
|
||||
|
||||
if (qbData.size() > iLength)
|
||||
{
|
||||
qbData.remove(iLength - 1, qbData.size() - iLength);
|
||||
}
|
||||
int iCheckSumLength = iLength - 3;
|
||||
ZZ_U16 usCheckSum = 0;
|
||||
for (int i = 0; i < iCheckSumLength; i++)
|
||||
{
|
||||
usCheckSum += qbData[i + 2];
|
||||
}
|
||||
usCheckSum = usCheckSum % 256;
|
||||
ZZ_U8 ucTemp = qbData[qbData.size() - 1];
|
||||
if ((ZZ_U8)usCheckSum != ucTemp)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Incorrect Check Sum.Exit Code:4" << "Total Recv:" << qbData.size() << "Check Sum:" << usCheckSum << "Not Equal To" << ucTemp;
|
||||
//qbData.clear();
|
||||
//return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
|
||||
{
|
||||
if (qbData.size() < 6)
|
||||
{
|
||||
@ -395,301 +464,166 @@ int ZZ_ATPControl_Serial_Qt::Init_Self()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime)
|
||||
int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime)
|
||||
{
|
||||
// using namespace ZZ_MATH;
|
||||
// int iDeviceDepth = 65535;
|
||||
//
|
||||
// bool bFlagIsOverTrying = false;
|
||||
// bool bFlagIsLowerMinExposureTime = false;
|
||||
// bool bFlagIsOverMaxExposureTime = false;
|
||||
// bool bFlagIsAutoExposureOK = false;
|
||||
// bool bFlagIsAutoExposureFailed = false;
|
||||
//
|
||||
// bool bIsValueOverflow = false;
|
||||
// bool bIsLastValueOverflow = false;
|
||||
//
|
||||
// float fExposureTime = 0;
|
||||
// float fTempExposureTime = 0;
|
||||
// double fLastExposureTime = 0.1;
|
||||
// int iRepeatCount = 0;
|
||||
//
|
||||
// int iRes = SetExposureTime(2000);//need change to load from files
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1";
|
||||
// return 1;
|
||||
// }
|
||||
//
|
||||
// while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
// {
|
||||
// DataFrame dfTemp;
|
||||
//
|
||||
// if (iRepeatCount++ > 30)
|
||||
// {
|
||||
// bFlagIsAutoExposureFailed = true;
|
||||
// bFlagIsOverTrying = true;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
// fTempExposureTime = fExposureTime;
|
||||
//
|
||||
// iRes = SingleShot(dfTemp);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2";
|
||||
// return 2;
|
||||
// }
|
||||
//
|
||||
// HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
//
|
||||
// double dSum = 0;
|
||||
// int iCount = m_daDeviceAttr.iPixels / 100;
|
||||
// for (int i = 0; i < iCount; i++)
|
||||
// {
|
||||
// dSum += dfTemp.lData[i];
|
||||
// }
|
||||
// double dTemp = dSum / iCount;
|
||||
//
|
||||
// if (dTemp >= iDeviceDepth * 0.99)
|
||||
// {
|
||||
// bIsValueOverflow = true;
|
||||
// if (!bIsLastValueOverflow)
|
||||
// {
|
||||
// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// fExposureTime = fExposureTime / 2;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor)
|
||||
// {
|
||||
// bFlagIsAutoExposureOK = 1;
|
||||
// }
|
||||
// else if (dTemp > iDeviceDepth * fMaxScaleFactor)
|
||||
// {
|
||||
// bIsValueOverflow = true;
|
||||
// if (!bIsLastValueOverflow)
|
||||
// {
|
||||
// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// fExposureTime = fExposureTime * 3 / 4;
|
||||
// }
|
||||
// }
|
||||
// else if (dTemp < iDeviceDepth * fMinScaleFactor)
|
||||
// {
|
||||
// bIsValueOverflow = false;
|
||||
// if (bIsLastValueOverflow)
|
||||
// {
|
||||
// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// double dFactor;
|
||||
// dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor);
|
||||
// fExposureTime = (float)(fExposureTime / dFactor);
|
||||
// }
|
||||
// if (/*fExposureTime > 100 || */fExposureTime < 10)
|
||||
// {
|
||||
// bFlagIsAutoExposureOK = false;
|
||||
// bFlagIsAutoExposureFailed = true;
|
||||
// bFlagIsLowerMinExposureTime = true;
|
||||
// }
|
||||
// }
|
||||
// bIsLastValueOverflow = bIsValueOverflow;
|
||||
// fLastExposureTime = fTempExposureTime;
|
||||
//
|
||||
// if (fExposureTime > 13000)
|
||||
// {
|
||||
// bFlagIsAutoExposureOK = false;
|
||||
// bFlagIsAutoExposureFailed = true;
|
||||
// fPredictedExposureTime = 13000;
|
||||
// iRes = SetExposureTime(13000);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
|
||||
// return 3;
|
||||
// }
|
||||
// bFlagIsOverMaxExposureTime = true;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// iRes = SetExposureTime((int)fExposureTime);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4";
|
||||
// return 3;
|
||||
// }
|
||||
// }
|
||||
// fPredictedExposureTime = fExposureTime;
|
||||
// return 0;
|
||||
|
||||
int m_iThreadID=0;
|
||||
// qDebug() << "--------------------------Starting PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
using namespace ZZ_MATH;
|
||||
using namespace ZZ_MATH;
|
||||
// float fPredictedExposureTime;
|
||||
int iDeviceDepth = 65535;
|
||||
int iDeviceDepth = 65535;
|
||||
|
||||
|
||||
|
||||
// qDebug() << "MAX---Min" << fMaxScaleFactor << "---" << fMinScaleFactor << " Thread ID:" << m_iThreadID;
|
||||
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
bool bFlagIsOverMaxExposureTime = false;
|
||||
bool bFlagIsAutoExposureOK = false;
|
||||
bool bFlagIsAutoExposureFailed = false;
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
bool bFlagIsOverMaxExposureTime = false;
|
||||
bool bFlagIsAutoExposureOK = false;
|
||||
bool bFlagIsAutoExposureFailed = false;
|
||||
|
||||
bool bIsValueOverflow = false;
|
||||
bool bIsLastValueOverflow = false;
|
||||
bool bIsValueOverflow = false;
|
||||
bool bIsLastValueOverflow = false;
|
||||
|
||||
int iExposureTime = 0;
|
||||
float fTempExposureTime = 0;
|
||||
double fLastExposureTime = 0.1;
|
||||
int iRepeatCount = 0;
|
||||
int iExposureTime = 0;
|
||||
float fTempExposureTime = 0;
|
||||
double fLastExposureTime = 0.1;
|
||||
int iRepeatCount = 0;
|
||||
|
||||
//int iRes = m_pFSCtrl->SetExposureTime(1000);//need change to load from files
|
||||
int iRes = 0;
|
||||
if (iRes != 0)
|
||||
{
|
||||
//int iRes = m_pFSCtrl->SetExposureTime(1000);//need change to load from files
|
||||
int iRes = 0;
|
||||
if (iRes != 0)
|
||||
{
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1" << " Thread ID:" << m_iThreadID;
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
{
|
||||
DataFrame dfTemp;
|
||||
while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
{
|
||||
DataFrame dfTemp;
|
||||
|
||||
if (iRepeatCount++ > 30)
|
||||
{
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverTrying = true;
|
||||
break;
|
||||
}
|
||||
//m_pFSCtrl->SetExposureTime(5000);
|
||||
GetExposureTime(iExposureTime);
|
||||
if (iRepeatCount++ > 30)
|
||||
{
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverTrying = true;
|
||||
break;
|
||||
}
|
||||
//m_pFSCtrl->SetExposureTime(5000);
|
||||
GetExposureTime(iExposureTime);
|
||||
// qDebug() << "Current ExpTime:" << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
//m_pFSCtrl->SetExposureTime(2500);
|
||||
//fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
fTempExposureTime = iExposureTime;
|
||||
//m_pFSCtrl->SetExposureTime(2500);
|
||||
//fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
fTempExposureTime = iExposureTime;
|
||||
|
||||
iRes = SingleShot(dfTemp);
|
||||
//iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
iRes = SingleShot(dfTemp);
|
||||
//iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2" << " Thread ID:" << m_iThreadID;
|
||||
return 2;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_daDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
double dSum = 0;
|
||||
int iCount = m_daDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
// qDebug() << "Avg " << dTemp << " Thread ID:" << m_iThreadID;
|
||||
|
||||
if (dTemp >= iDeviceDepth * 0.99)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime / 2;
|
||||
}
|
||||
}
|
||||
if (dTemp >= iDeviceDepth * 0.99)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime / 2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
// qDebug() << "trace bFlagIsAutoExposureOK =1 " << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * fMaxScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime * 3 / 4;
|
||||
}
|
||||
}
|
||||
else if (dTemp < iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = false;
|
||||
if (bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor);
|
||||
iExposureTime = (float)(iExposureTime / dFactor);
|
||||
}
|
||||
if (/*fExposureTime > 100 || */iExposureTime < 10)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
}
|
||||
}
|
||||
bIsLastValueOverflow = bIsValueOverflow;
|
||||
fLastExposureTime = fTempExposureTime;
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * fMaxScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime * 3 / 4;
|
||||
}
|
||||
}
|
||||
else if (dTemp < iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = false;
|
||||
if (bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor);
|
||||
iExposureTime = (float)(iExposureTime / dFactor);
|
||||
}
|
||||
if (/*fExposureTime > 100 || */iExposureTime < 10)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
}
|
||||
}
|
||||
bIsLastValueOverflow = bIsValueOverflow;
|
||||
fLastExposureTime = fTempExposureTime;
|
||||
|
||||
if (iExposureTime > 120000)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
float fPredictedExposureTime = 120000;
|
||||
iRes = SetExposureTime(120000);
|
||||
if (iRes != 0)
|
||||
{
|
||||
if (iExposureTime > 120000)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
float fPredictedExposureTime = 120000;
|
||||
iRes = SetExposureTime(120000);
|
||||
if (iRes != 0)
|
||||
{
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3" << " Thread ID:" << m_iThreadID;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec";
|
||||
// qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to " << m_daDeviceAttr.iMaxIntegrationTimeInMS << "MS" << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
break;
|
||||
}
|
||||
|
||||
iRes = SetExposureTime((int)iExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
iRes = SetExposureTime((int)iExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4" << " Thread ID:" << m_iThreadID;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
}
|
||||
fPredictedExposureTime = iExposureTime;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
}
|
||||
fPredictedExposureTime = iExposureTime;
|
||||
// qDebug() << "--------------------------Stop PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -739,40 +673,40 @@ int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetExposureTime(int& iExposureTimeInMS)
|
||||
int ZZ_ATPControl_Serial_Qt::GetExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
// QByteArray qbSend, qbRecv;
|
||||
// qbSend.clear();
|
||||
// qbRecv.clear();
|
||||
// qbSend.append(GET_INTEGRATION_TIME);
|
||||
// qbSend.resize(3);
|
||||
// qbSend[1] = 0x00;
|
||||
// qbSend[2] = 0x01;
|
||||
// int iRes = SendCommand(qbSend);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:1";
|
||||
// return 1;
|
||||
// }
|
||||
// iRes = RecvData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:2";
|
||||
// return 2;
|
||||
// }
|
||||
// iRes = ParseData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:3";
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// iExposureTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
// QByteArray qbSend, qbRecv;
|
||||
// qbSend.clear();
|
||||
// qbRecv.clear();
|
||||
// qbSend.append(GET_INTEGRATION_TIME);
|
||||
// qbSend.resize(3);
|
||||
// qbSend[1] = 0x00;
|
||||
// qbSend[2] = 0x01;
|
||||
// int iRes = SendCommand(qbSend);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:1";
|
||||
// return 1;
|
||||
// }
|
||||
// iRes = RecvData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:2";
|
||||
// return 2;
|
||||
// }
|
||||
// iRes = ParseData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:3";
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// iExposureTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
iExposureTimeInMS = m_iExposureTime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData)
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
|
||||
QByteArray qbSend, qbRecv;
|
||||
@ -780,10 +714,11 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData)
|
||||
qbRecv.clear();
|
||||
qbSend.append(SYNC_GET_DATA);
|
||||
qbSend.resize(3);
|
||||
// qbSend[1] = 0x00;
|
||||
// qbSend[2] = 0x01;
|
||||
qbSend[1] = m_iExposureTime >> 8;;
|
||||
qbSend[2] = m_iExposureTime & 0xFF;
|
||||
// qbSend[1] = 0x00;
|
||||
// qbSend[2] = 0x01;
|
||||
int iTemp=m_iExposureTime;
|
||||
qbSend[1] = iTemp >> 8;;
|
||||
qbSend[2] = iTemp & 0xFF;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
@ -821,16 +756,22 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData)
|
||||
|
||||
|
||||
}
|
||||
// for (int i = 0; i < iDataSizeInPixel; i++)
|
||||
// {
|
||||
// dfData.lData[i] = usData[i];
|
||||
// }
|
||||
// for (int i = 0; i < iDataSizeInPixel; i++)
|
||||
// {
|
||||
// dfData.lData[i] = usData[i];
|
||||
// }
|
||||
}
|
||||
float fTemp;
|
||||
GetDeviceTemperature(fTemp);
|
||||
|
||||
dfData.usExposureTimeInMS = m_iExposureTime;
|
||||
dfData.fTemperature = fTemp;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(int& iPixels)
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
@ -878,7 +819,7 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(int& iPixels)
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float& fTemperature)
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
fTemperature = 0;
|
||||
|
||||
@ -895,7 +836,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float& fTemperature)
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
iRes = RecvData_ShortLag(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:2";
|
||||
|
Reference in New Issue
Block a user