1.air部署,细节待修改
This commit is contained in:
396
Source/Capture/AbsFSController.cpp
Normal file
396
Source/Capture/AbsFSController.cpp
Normal file
@ -0,0 +1,396 @@
|
||||
#include "AbsFSController.h"
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
CAbsFSController::CAbsFSController(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_iFlagInit = 0;
|
||||
#ifdef _DEBUG
|
||||
m_qstrWaveLengthPath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data/WaveLengthInfo.txt";
|
||||
#else
|
||||
m_qstrWaveLengthPath = "/home/data/Data/WaveLengthInfo.txt";
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
CAbsFSController::~CAbsFSController()
|
||||
{
|
||||
}
|
||||
|
||||
void CAbsFSController::SetContext(OneFSContext struFSParam)
|
||||
{
|
||||
m_struFSParam = struFSParam;
|
||||
}
|
||||
|
||||
int CAbsFSController::Initialize()
|
||||
{
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
|
||||
m_iFlagInit = 0;
|
||||
|
||||
switch (m_struFSParam.ucDeviceModel)
|
||||
{
|
||||
case DeviceModel::FLAME:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "Flame Not Opened";
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::OSIFAlpha:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "OSIFAlpha Not Opened";
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::OSIFBeta:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "OSIFBeta Not Opened";
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::ISIF:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
//m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "ISIF Not Opened";
|
||||
return 3;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::IS1:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
//m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "IS1 Not Opened";
|
||||
return 3;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::IS2:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
//m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0)
|
||||
{
|
||||
qDebug() << "IS2 Not Opened";
|
||||
return 3;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int iRes = m_pFSCtrl->GetDeviceAttribute(m_struDeviceAttr);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "GetDeviceAttribute Failed" << iRes;
|
||||
return 4;
|
||||
}
|
||||
|
||||
iRes = m_pFSCtrl->SetDeviceTemperature(0);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "SetDeviceTemperature Failed" << iRes;
|
||||
//return 5;
|
||||
}
|
||||
m_iFlagInit = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbsFSController::Initialize_Self()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbsFSController::SetExposureTime(int iMilliSec)
|
||||
{
|
||||
return m_pFSCtrl->SetExposureTime(iMilliSec);
|
||||
}
|
||||
|
||||
int CAbsFSController::GetExposureTime(int& iMilliSec)
|
||||
{
|
||||
return m_pFSCtrl->GetExposureTime(iMilliSec);
|
||||
}
|
||||
|
||||
int CAbsFSController::SingleShot(DataFrame& struSingleFrame)
|
||||
{
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
|
||||
|
||||
|
||||
|
||||
int iRes = m_pFSCtrl->SingleShot(m_struSingleFrame);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err. SingleShot";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m_struFSParam.ucDeviceModel == DeviceModel::FLAME)
|
||||
{
|
||||
int iRes = m_pFSCtrl->SingleShot(m_struSingleFrame);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err. SingleShot";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_struFSParam.ucDeviceModel == DeviceModel::ISIF)
|
||||
{
|
||||
float fTemp;
|
||||
m_pFSCtrl->GetDeviceTemperature(fTemp);
|
||||
m_struSingleFrame.fTemperature = fTemp;
|
||||
}
|
||||
else if (m_struFSParam.ucDeviceModel == DeviceModel::IS2)
|
||||
{
|
||||
float fTemp;
|
||||
m_pFSCtrl->GetDeviceTemperature(fTemp);
|
||||
m_struSingleFrame.fTemperature = fTemp;
|
||||
}
|
||||
else if (m_struFSParam.ucDeviceModel == DeviceModel::IS1)
|
||||
{
|
||||
m_struSingleFrame.fTemperature = 1000;
|
||||
}
|
||||
else if (m_struFSParam.ucDeviceModel == DeviceModel::FLAME)
|
||||
{
|
||||
m_struSingleFrame.fTemperature = 1000;
|
||||
}
|
||||
|
||||
QDateTime qdtTime = QDateTime::currentDateTime();
|
||||
m_struSingleFrame.dTimes = qdtTime.toMSecsSinceEpoch();
|
||||
|
||||
struSingleFrame = m_struSingleFrame;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbsFSController::PerformAutoExposure()
|
||||
{
|
||||
|
||||
qDebug() << "--------------------------Starting PerformAutoExposure";
|
||||
using namespace ZZ_MATH;
|
||||
float fPredictedExposureTime;
|
||||
int iDeviceDepth = (int)m_struFSParam.lDepth;
|
||||
|
||||
qDebug() << "MAX---Min" << m_struFSParam.fMaxFactor << "---" << m_struFSParam.fMinFactor ;
|
||||
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
bool bFlagIsOverMaxExposureTime = false;
|
||||
bool bFlagIsAutoExposureOK = false;
|
||||
bool bFlagIsAutoExposureFailed = false;
|
||||
|
||||
bool bIsValueOverflow = false;
|
||||
bool bIsLastValueOverflow = false;
|
||||
|
||||
int iExposureTime = 0;
|
||||
float fTempExposureTime = 0;
|
||||
double fLastExposureTime = 0.1;
|
||||
int iRepeatCount = 0;
|
||||
|
||||
|
||||
while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
{
|
||||
DataFrame dfTemp;
|
||||
|
||||
if (iRepeatCount++ > 30)
|
||||
{
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverTrying = true;
|
||||
break;
|
||||
}
|
||||
|
||||
m_pFSCtrl->GetExposureTime(iExposureTime);
|
||||
qDebug() << "Current ExpTime:" << iExposureTime;
|
||||
fTempExposureTime = iExposureTime;
|
||||
|
||||
int iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeapSort(dfTemp.lData, m_struDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_struDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
qDebug() << "Avg " << dTemp ;
|
||||
|
||||
if (dTemp >= iDeviceDepth * 0.99)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime / 2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (iDeviceDepth * m_struFSParam.fMaxFactor >= dTemp && dTemp >= iDeviceDepth * m_struFSParam.fMinFactor)
|
||||
{
|
||||
qDebug() << "trace bFlagIsAutoExposureOK =1 " << iExposureTime;
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * m_struFSParam.fMaxFactor)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime * 3 / 4;
|
||||
}
|
||||
}
|
||||
else if (dTemp < iDeviceDepth * m_struFSParam.fMinFactor)
|
||||
{
|
||||
bIsValueOverflow = false;
|
||||
if (bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (iDeviceDepth * m_struFSParam.fMaxFactor);
|
||||
iExposureTime = (float)(iExposureTime / dFactor);
|
||||
}
|
||||
|
||||
}
|
||||
bIsLastValueOverflow = bIsValueOverflow;
|
||||
fLastExposureTime = fTempExposureTime;
|
||||
|
||||
|
||||
|
||||
if (iExposureTime <= m_struDeviceAttr.iMinIntegrationTimeInMS)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
|
||||
iRes = m_pFSCtrl->SetExposureTime(m_struDeviceAttr.iMinIntegrationTimeInMS);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3" ;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Warning:PerformAutoExposure lower than min integration time.Will be limited to " << m_struDeviceAttr.iMinIntegrationTimeInMS << "MS";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (iExposureTime > m_struDeviceAttr.iMaxIntegrationTimeInMS - 1)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
|
||||
iRes = m_pFSCtrl->SetExposureTime(m_struDeviceAttr.iMaxIntegrationTimeInMS - 1);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to " << m_struDeviceAttr.iMaxIntegrationTimeInMS - 1 << "MS";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
iRes = m_pFSCtrl->SetExposureTime((int)iExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4" ;
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime ;
|
||||
}
|
||||
}
|
||||
|
||||
fPredictedExposureTime = iExposureTime;
|
||||
qDebug() << "--------------------------Stop PerformAutoExposure";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbsFSController::CheckAndAdjust_Fast()
|
||||
{
|
||||
using namespace ZZ_MATH;
|
||||
|
||||
int iExposureTime = 0;
|
||||
|
||||
int iRes = m_pFSCtrl->GetExposureTime(iExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err. SingleShot";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
HeapSort(m_struSingleFrame.lData, m_struDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_struDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += m_struSingleFrame.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
|
||||
if (dTemp >= m_struFSParam.lDepth * 0.99)
|
||||
{
|
||||
iExposureTime = iExposureTime / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (float)(m_struFSParam.lDepth * m_struFSParam.fMaxFactor);
|
||||
iExposureTime = (float)(iExposureTime / dFactor);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CAbsFSController::GetDeviceAttr(DeviceAttribute& struDeviceAttr)
|
||||
{
|
||||
struDeviceAttr = m_struDeviceAttr;
|
||||
}
|
||||
|
||||
// int CAbsFSController::CreateWavelengthFile()
|
||||
// {
|
||||
// QDir qdirPath(qstrTemp);
|
||||
// if (!qdirPath.exists())
|
||||
// {
|
||||
// bool bRes = qdirPath.mkdir(qstrTemp);
|
||||
// if (!bRes)
|
||||
// {
|
||||
// qDebug() << "DataFileProcessor mkdir Failed.";
|
||||
// }
|
||||
// }
|
||||
// m_qstrWaveLengthPath
|
||||
// temp1 = "wavelength = ";
|
||||
// file.Write(temp1, temp1.GetLength());
|
||||
// file.Write("{", 1);
|
||||
// return 0;
|
||||
// }
|
44
Source/Capture/AbsFSController.h
Normal file
44
Source/Capture/AbsFSController.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "OControl_USB.h"
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::MISC_DETECTOR;
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
class CAbsFSController :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAbsFSController(QObject* parent = nullptr);
|
||||
virtual ~CAbsFSController();
|
||||
public:
|
||||
//call first
|
||||
virtual void SetContext(OneFSContext struFSParam);
|
||||
|
||||
virtual int Initialize();
|
||||
virtual int Initialize_Self();
|
||||
|
||||
int SetExposureTime(int iMilliSec);
|
||||
int GetExposureTime(int& iMilliSec);
|
||||
int SingleShot(DataFrame &struSingleFrame);
|
||||
|
||||
int PerformAutoExposure();
|
||||
int CheckAndAdjust_Fast();
|
||||
|
||||
void GetDeviceAttr(DeviceAttribute &struDeviceAttr);
|
||||
public:
|
||||
std::atomic_int m_iFlagInit;
|
||||
private:
|
||||
DeviceAttribute m_struDeviceAttr;
|
||||
CIrisFSBase* m_pFSCtrl;
|
||||
OneFSContext m_struFSParam;
|
||||
DataFrame m_struSingleFrame;
|
||||
QString m_qstrWaveLengthPath;
|
||||
private:
|
||||
//int CreateWavelengthFile();
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
};
|
221
Source/Capture/MainGrabber.cpp
Normal file
221
Source/Capture/MainGrabber.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
#include "MainGrabber.h"
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
CMainGrabber::CMainGrabber(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pctrlFS = NULL;
|
||||
m_pctrlGPS = NULL;
|
||||
m_dfpDataSaver = NULL;
|
||||
m_iFlagIsCapture = 0;
|
||||
|
||||
connect(this, &CMainGrabber::Signal_InitSelf, this, &CMainGrabber::Initialize_Self);
|
||||
}
|
||||
|
||||
CMainGrabber::~CMainGrabber()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CMainGrabber::SetRunParams(OneFSContext struFSRunParams)
|
||||
{
|
||||
m_struFSRunParams = struFSRunParams;
|
||||
}
|
||||
|
||||
int CMainGrabber::SetContext(BD357Controller &pctrlGPS, DataFileProcessor &dfpDataSaver)
|
||||
{
|
||||
if (&pctrlGPS == NULL)
|
||||
{
|
||||
qDebug() << "GPS Not Initialized";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_pctrlGPS = &pctrlGPS;
|
||||
m_dfpDataSaver = &dfpDataSaver;
|
||||
}
|
||||
|
||||
int CMainGrabber::Initialize()
|
||||
{
|
||||
emit Signal_InitSelf();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainGrabber::StartGrab()
|
||||
{
|
||||
m_pctrlFS->PerformAutoExposure();
|
||||
DataFrame dfTemp;
|
||||
m_iFlagIsCapture = 1;
|
||||
|
||||
while (m_iFlagIsCapture)
|
||||
{
|
||||
QTime qtTime;
|
||||
qtTime.start();
|
||||
|
||||
////////////
|
||||
m_pctrlFS->SingleShot(dfTemp);
|
||||
RemoveBackground(dfTemp);
|
||||
CheckExposureTime(dfTemp);
|
||||
m_dfpDataSaver->WriteData(dfTemp);
|
||||
////////////
|
||||
|
||||
//int iMillisec = qtTime.elapsed();
|
||||
int iSleep =m_struFSRunParams.dMinSamplingInterval - qtTime.elapsed();
|
||||
if (iSleep>0)
|
||||
{
|
||||
Delay_MSec(iSleep);
|
||||
}
|
||||
qDebug() << "Delay_MSec"<<iSleep;
|
||||
}
|
||||
}
|
||||
|
||||
int CMainGrabber::Initialize_Self()
|
||||
{
|
||||
InitializeWorkers();
|
||||
SetupMsgPipelines();
|
||||
LoadDCT();
|
||||
|
||||
emit Signal_InitFinished();
|
||||
}
|
||||
|
||||
void CMainGrabber::Delay_MSec(ZZ_U16 usMS)
|
||||
{
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(usMS, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
}
|
||||
|
||||
int CMainGrabber::InitializeWorkers()
|
||||
{
|
||||
if (m_pctrlFS == NULL)
|
||||
{
|
||||
m_pctrlFS = new CAbsFSController;
|
||||
}
|
||||
else
|
||||
{
|
||||
//???
|
||||
}
|
||||
m_pctrlFS->SetContext(m_struFSRunParams);
|
||||
|
||||
m_pctrlFS->Initialize();
|
||||
while (!m_pctrlFS->m_iFlagInit)
|
||||
{
|
||||
Delay_MSec(1000);
|
||||
}
|
||||
m_pctrlFS->GetDeviceAttr(m_struDeviceAttr);
|
||||
m_dfpDataSaver->GenerateFilePath();
|
||||
m_dfpDataSaver->WriteWavelengthInfo(m_struDeviceAttr.fWaveLengthInNM, m_struDeviceAttr.iPixels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainGrabber::SetupMsgPipelines()
|
||||
{
|
||||
bool bRes = connect(m_pctrlGPS,&BD357Controller::Signal_StartCapture, this, &CMainGrabber::StartGrab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainGrabber::LoadDCT()
|
||||
{
|
||||
m_vecDataFrame.clear();
|
||||
|
||||
m_DCTable.SetRunParams(m_struFSRunParams);
|
||||
m_DCTable.Initialize_Part();
|
||||
m_DCTable.LoadTable();
|
||||
m_DCTable.GetDCTable(m_vecDataFrame);
|
||||
}
|
||||
|
||||
int CMainGrabber::CheckExposureTime(DataFrame dfTemp)
|
||||
{
|
||||
using namespace ZZ_MATH;
|
||||
double dExpTimeMS;
|
||||
int idExpTimeMS;
|
||||
|
||||
m_pctrlFS->GetExposureTime(idExpTimeMS);
|
||||
|
||||
qDebug() << "GetExposureTime" << idExpTimeMS;
|
||||
|
||||
dExpTimeMS = idExpTimeMS;
|
||||
|
||||
HeapSort(dfTemp.lData, m_struDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_struDeviceAttr.iPixels / 200;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
if (dTemp >= m_struFSRunParams.lDepth * 0.99)
|
||||
{
|
||||
dExpTimeMS = dExpTimeMS /2;
|
||||
}
|
||||
|
||||
else if (m_struFSRunParams.lDepth*m_struFSRunParams.fMaxFactor >= dTemp && dTemp >= m_struFSRunParams.lDepth * m_struFSRunParams.fMinFactor)
|
||||
{
|
||||
qDebug() << "SetExposureTime" << dExpTimeMS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (m_struFSRunParams.lDepth * m_struFSRunParams.fMaxFactor);
|
||||
dExpTimeMS = (float)(dExpTimeMS / dFactor);
|
||||
}
|
||||
|
||||
if ((dExpTimeMS <= m_struDeviceAttr.iMinIntegrationTimeInMS)|| (dExpTimeMS > m_struDeviceAttr.iMaxIntegrationTimeInMS - 1))
|
||||
{
|
||||
qDebug() << "SetExposureTime out of range";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
m_pctrlFS->SetExposureTime((int)dExpTimeMS);
|
||||
|
||||
qDebug() << "SetExposureTime" << dExpTimeMS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainGrabber::RemoveBackground(DataFrame& dfTemp)
|
||||
{
|
||||
int iA = dfTemp.usExposureTimeInMS / 10;
|
||||
int iB = dfTemp.usExposureTimeInMS % 10;
|
||||
|
||||
qDebug() << "iA" << iA;
|
||||
qDebug() << "iB" << iB;
|
||||
|
||||
if (iA == 0)
|
||||
{
|
||||
m_dfBackground = m_vecDataFrame[iB];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iA>100)
|
||||
{
|
||||
m_dfBackground = m_vecDataFrame[m_vecDataFrame.size()-1];
|
||||
}
|
||||
else if(iA<=9&&iA>=1)
|
||||
{
|
||||
m_dfBackground = m_vecDataFrame[8 + iA];
|
||||
}
|
||||
else
|
||||
{
|
||||
int iAA= dfTemp.usExposureTimeInMS / 100;
|
||||
int iBB= dfTemp.usExposureTimeInMS % 100;
|
||||
|
||||
DataFrame dfTempX1, dfTempX2;
|
||||
dfTempX1 = m_vecDataFrame[17 + iAA];
|
||||
dfTempX2 = m_vecDataFrame[18 + iAA];
|
||||
|
||||
for (int i=0;i< m_struDeviceAttr.iPixels;i++)
|
||||
{
|
||||
m_dfBackground.lData[i] = dfTempX1.lData[i] + (dfTempX2.lData[i] - dfTempX1.lData[i]) * (double)iBB / (double)100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_struDeviceAttr.iPixels; i++)
|
||||
{
|
||||
dfTemp.lData[i] = dfTemp.lData[i] - m_dfBackground.lData[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
48
Source/Capture/MainGrabber.h
Normal file
48
Source/Capture/MainGrabber.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "AbsFSController.h"
|
||||
#include "DataFileProcessor.h"
|
||||
#include "BD357Ctrl.h"
|
||||
#include "MakeDarkCurrentTable.h"
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
|
||||
class CMainGrabber :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMainGrabber(QObject* parent = nullptr);
|
||||
~CMainGrabber();
|
||||
public:
|
||||
void SetRunParams(OneFSContext struFSRunParams);
|
||||
int SetContext(BD357Controller &pctrlGPS, DataFileProcessor &dfpDataSaver);
|
||||
|
||||
int Initialize();
|
||||
public:
|
||||
atomic_int m_iFlagIsCapture;
|
||||
private:
|
||||
MakeDCT m_DCTable;
|
||||
|
||||
OneFSContext m_struFSRunParams;
|
||||
|
||||
DataFileProcessor *m_dfpDataSaver;
|
||||
CAbsFSController *m_pctrlFS;
|
||||
BD357Controller *m_pctrlGPS;
|
||||
|
||||
std::vector<DataFrame> m_vecDataFrame;
|
||||
DataFrame m_dfBackground;
|
||||
DeviceAttribute m_struDeviceAttr;
|
||||
private:
|
||||
void Delay_MSec(ZZ_U16 usMS);
|
||||
int InitializeWorkers();
|
||||
int SetupMsgPipelines();
|
||||
int LoadDCT();
|
||||
int CheckExposureTime(DataFrame dfTemp);
|
||||
int RemoveBackground (DataFrame &dfTemp);
|
||||
public slots:
|
||||
int StartGrab();
|
||||
int Initialize_Self();
|
||||
signals:
|
||||
void Signal_InitSelf();
|
||||
void Signal_InitFinished();
|
||||
};
|
Reference in New Issue
Block a user