mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 03:49:42 +08:00
1.修改了Grabber中FSController的初始化过程,现在不会再出现QSerialPort跨线程调用问题。 2.修改了Grabber中主采集线程的一个信号量重置bug,该bug可能会引发采集慢的光谱仪在串口模式下数据不全。
3.修改了采集单帧功能函数,现在ATP控制类中的singleshot函数依旧会检查数据校验和,但不会应为校验和错误删除数据,以适配IS1校验和问题。注意,数据长度不对时还是会放弃本帧数据。 4.优化了ATP谱仪控制类中的多个函数,提高了其响应速度。
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
iFlagInit = 0;
|
||||
m_pFSCtrl = NULL;
|
||||
m_iThreadID = -1;
|
||||
m_vecDataFrameDark.clear();
|
||||
@ -18,6 +19,7 @@ CAbstractFSController::~CAbstractFSController()
|
||||
|
||||
int CAbstractFSController::SetRunParas(int iThreadID, FSInfo fsInfo)
|
||||
{
|
||||
connect(this, &CAbstractFSController::SignalInit_Self, this, &CAbstractFSController::InitializeFSControl);
|
||||
m_iThreadID = iThreadID;
|
||||
m_fsInfo = fsInfo;
|
||||
return 0;
|
||||
@ -96,7 +98,14 @@ int CAbstractFSController::InitializeFSControl()
|
||||
qDebug() << "SetDeviceTemperature Failed" << iRes;
|
||||
return 5;
|
||||
}
|
||||
iFlagInit = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::InitializeFSControl_Self()
|
||||
{
|
||||
//InitializeFSControl();
|
||||
emit SignalInit_Self();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -113,7 +122,7 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
float fPredictedExposureTime;
|
||||
int iDeviceDepth = (int)m_fsInfo.lDepth;
|
||||
|
||||
qDebug() << "MAX---Min" << m_fsInfo.fMaxFactor << "---" << m_fsInfo.fMinFactor;
|
||||
qDebug() << "MAX---Min" << m_fsInfo.fMaxFactor << "---" << m_fsInfo.fMinFactor << " Thread ID:" << m_iThreadID;
|
||||
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
@ -133,7 +142,7 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
int iRes = 0;
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1";
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1" << " Thread ID:" << m_iThreadID;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -149,22 +158,23 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
}
|
||||
//m_pFSCtrl->SetExposureTime(5000);
|
||||
m_pFSCtrl->GetExposureTime(iExposureTime);
|
||||
qDebug() << "Current ExpTime:" << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
//m_pFSCtrl->SetExposureTime(2500);
|
||||
//fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
fTempExposureTime = iExposureTime;
|
||||
|
||||
|
||||
iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
//iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2";
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2" << " Thread ID:" << m_iThreadID;
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_daDeviceAttr.iPixels / 100;
|
||||
int iCount = m_daDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
@ -188,7 +198,7 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
|
||||
else if (iDeviceDepth * m_fsInfo.fMaxFactor >= dTemp && dTemp >= iDeviceDepth * m_fsInfo.fMinFactor)
|
||||
{
|
||||
qDebug() << "trace bFlagIsAutoExposureOK =1" << iExposureTime;
|
||||
qDebug() << "trace bFlagIsAutoExposureOK =1 " << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * m_fsInfo.fMaxFactor)
|
||||
@ -234,12 +244,13 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
iRes = m_pFSCtrl->SetExposureTime(120000);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
|
||||
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";
|
||||
//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;
|
||||
@ -248,12 +259,12 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
iRes = m_pFSCtrl->SetExposureTime((int)iExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4";
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4" << " Thread ID:" << m_iThreadID;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Success:PerformAutoExposure. Value"<< iExposureTime;
|
||||
qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
}
|
||||
fPredictedExposureTime = iExposureTime;
|
||||
@ -288,8 +299,11 @@ int CAbstractFSController::TakeSignalFrame()
|
||||
|
||||
DataFrame CAbstractFSController::TakeOneFrame()
|
||||
{
|
||||
|
||||
//int iExpTime = 0;
|
||||
DataFrame dfTemp;
|
||||
// m_pFSCtrl->GetExposureTime(iExpTime);
|
||||
// dfTemp.usExposureTimeInMS = iExpTime;
|
||||
// m_pFSCtrl->GetDeviceTemperature(dfTemp.fTemperature);
|
||||
int iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
@ -297,6 +311,14 @@ DataFrame CAbstractFSController::TakeOneFrame()
|
||||
}
|
||||
|
||||
return dfTemp;
|
||||
// DataFrame dfTemp;
|
||||
// int iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err. SingleShot" << " Thread ID:" << m_iThreadID;
|
||||
// }
|
||||
//
|
||||
// return dfTemp;
|
||||
}
|
||||
|
||||
int CAbstractFSController::SaveDataFile()
|
||||
@ -316,7 +338,7 @@ int CAbstractFSController::StartAcquisitionSignal()
|
||||
|
||||
|
||||
|
||||
//PerformAutoExposure();
|
||||
PerformAutoExposure();
|
||||
TakeSignalFrame();
|
||||
|
||||
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
|
||||
|
@ -21,12 +21,15 @@ class CAbstractFSController :public QObject
|
||||
public:
|
||||
CAbstractFSController(QObject* parent = nullptr);
|
||||
virtual ~CAbstractFSController();
|
||||
public:
|
||||
std::atomic_int iFlagInit{ 0 };
|
||||
public:
|
||||
//call first
|
||||
virtual int SetRunParas(int iThreadID, FSInfo fsInfo);
|
||||
|
||||
//create derived class from base class
|
||||
virtual int InitializeFSControl();
|
||||
virtual int InitializeFSControl_Self();
|
||||
|
||||
//sync info
|
||||
virtual int GetDeviceAttr(DeviceAttribute &daAttr);
|
||||
@ -56,6 +59,7 @@ public slots:
|
||||
|
||||
|
||||
signals:
|
||||
void SignalInit_Self();
|
||||
void SignalAcqStarted();
|
||||
void SignalAcqFinished_Signal(int iThreadID, int iFlagStatus);
|
||||
void SignalAcqFinished_Dark (int iThreadID, int iFlagStatus);
|
||||
|
@ -81,8 +81,8 @@ void CMainDataGrabber::Init_Normal()
|
||||
{
|
||||
InitThreadStatus();
|
||||
InitializeWorkers();
|
||||
SetupMsgPipelines();
|
||||
StartWorkers();
|
||||
SetupMsgPipelines();
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
||||
@ -159,6 +159,16 @@ int CMainDataGrabber::InitThreadStatus()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::ResetThreadStatus()
|
||||
{
|
||||
for (int i = 0; i < m_iTotalThreads; i++)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus_Signal[i] = 0;
|
||||
m_piFlagCaptureThreadStatus_Dark[i] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitializeWorkers()
|
||||
{
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
@ -176,20 +186,20 @@ int CMainDataGrabber::InitializeWorkers()
|
||||
|
||||
CAbstractFSController* m_pWorkThread = new CAbstractFSController;
|
||||
m_pWorkThread->SetRunParas(i, fsInfo);
|
||||
m_pWorkThread->InitializeFSControl();
|
||||
|
||||
DeviceAttribute daAttrTemp;
|
||||
m_pWorkThread->GetDeviceAttr(daAttrTemp);
|
||||
m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
|
||||
for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
|
||||
{
|
||||
m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
||||
}
|
||||
m_pControlThread.push_back(m_pWorkThread);
|
||||
// m_pWorkThread->InitializeFSControl();
|
||||
//
|
||||
// DeviceAttribute daAttrTemp;
|
||||
// m_pWorkThread->GetDeviceAttr(daAttrTemp);
|
||||
// m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
|
||||
// for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
|
||||
// {
|
||||
// m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
||||
// }
|
||||
m_pControlThread.push_back(m_pWorkThread);
|
||||
}
|
||||
m_struRTGP.fscParams = m_struDeviceContext;
|
||||
m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||
m_pmduUploader->SetRTGP(m_struRTGP);
|
||||
// m_struRTGP.fscParams = m_struDeviceContext;
|
||||
// m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||
// m_pmduUploader->SetRTGP(m_struRTGP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -202,19 +212,26 @@ int CMainDataGrabber::StartWorkers()
|
||||
m_pControlThread[i]->moveToThread(pWorkThreadHolder);
|
||||
pWorkThreadHolder->start();
|
||||
|
||||
// m_pControlThread[i]->InitializeFSControl();
|
||||
// DeviceAttribute daAttrTemp;
|
||||
// m_pControlThread[i]->GetDeviceAttr(daAttrTemp);
|
||||
// m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
|
||||
// for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
|
||||
// {
|
||||
// m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
||||
// }
|
||||
m_pControlThread[i]->InitializeFSControl_Self();
|
||||
/// <summary>
|
||||
while (!m_pControlThread[i]->iFlagInit)
|
||||
{
|
||||
Delay_MSec(1000);
|
||||
}
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
DeviceAttribute daAttrTemp;
|
||||
m_pControlThread[i]->GetDeviceAttr(daAttrTemp);
|
||||
m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
|
||||
for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
|
||||
{
|
||||
m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
||||
}
|
||||
}
|
||||
|
||||
// m_struRTGP.fscParams = m_struDeviceContext;
|
||||
// m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||
// m_pmduUploader->SetRTGP(m_struRTGP);
|
||||
m_struRTGP.fscParams = m_struDeviceContext;
|
||||
m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||
m_pmduUploader->SetRTGP(m_struRTGP);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -427,6 +444,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
|
||||
for (int i=0;i< m_struAcqPosSetting.iTotalPosition-1;i++)
|
||||
{
|
||||
ResetThreadStatus();
|
||||
////move to
|
||||
qDebug()<<"Start ILMES_MoveToPos:"<<i+1;
|
||||
//m_ctrlLS.ILMES_MoveToPos(i+1);
|
||||
@ -465,6 +483,8 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
|
||||
}
|
||||
vecData.push_back(vecSignal);
|
||||
qDebug() << "ucDeviceNumber" << i << " Data Size" << vecSignal.size();
|
||||
//vecData[i].push_back();
|
||||
}
|
||||
|
||||
//emit SignalPushOneDataFrame(vecData);
|
||||
|
@ -17,7 +17,7 @@ class CMainDataGrabber :public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMainDataGrabber(QObject* parent = nullptr);
|
||||
~CMainDataGrabber();
|
||||
~CMainDataGrabber();
|
||||
|
||||
private:
|
||||
vector<CAbstractFSController *> m_pControlThread;
|
||||
@ -56,6 +56,7 @@ private:
|
||||
int SetUploader(CMainDataUploader &mduUploader/*, RunTimeGrabberParams struGrabberRTParams*/);
|
||||
|
||||
int InitThreadStatus();
|
||||
int ResetThreadStatus();
|
||||
int InitializeWorkers();
|
||||
int StartWorkers();
|
||||
int SetupMsgPipelines();
|
||||
|
@ -52,7 +52,9 @@ void Scheduler::StartAsPlanned()
|
||||
|
||||
int iIntervalInMS = m_struAcqTime.qtInterval.hour() * 3600 * 1000 + m_struAcqTime.qtInterval.minute() * 60 * 1000 + m_struAcqTime.qtInterval.second() * 1000;
|
||||
|
||||
m_GrabTimer->start(iIntervalInMS);
|
||||
m_GrabTimer->start(5000);
|
||||
//this->OnTimeCounter();
|
||||
//emit &QTimer::timeout;
|
||||
}
|
||||
|
||||
int Scheduler::OnTimeCounter()
|
||||
|
Reference in New Issue
Block a user