mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-22 12:39:43 +08:00
Compare commits
22 Commits
f04f058b9c
...
zhangzhuo
Author | SHA1 | Date | |
---|---|---|---|
00ef87ab2a | |||
e9cbf077af | |||
d266e1d7d0 | |||
847e4b4061 | |||
d15ec2b237 | |||
29be390ece | |||
9da7bc31aa | |||
f94173dba3 | |||
c92eed7145 | |||
ac7f13f7c0 | |||
ae336678d0 | |||
d306f93f8b | |||
393a16c67d | |||
4a0b50337f | |||
de6c6b8efd | |||
4e5168d513 | |||
200fda19dc | |||
d9359603f5 | |||
ea3f04a9f3 | |||
28281519a2 | |||
acdbd9e459 | |||
6d20b2d3fb |
BIN
Cal/FS1_P1.dat
BIN
Cal/FS1_P1.dat
Binary file not shown.
BIN
Cal/FS1_P2.dat
BIN
Cal/FS1_P2.dat
Binary file not shown.
BIN
Cal/FS1_P3.dat
BIN
Cal/FS1_P3.dat
Binary file not shown.
BIN
Cal/FS1_P4.dat
BIN
Cal/FS1_P4.dat
Binary file not shown.
BIN
Cal/FS2_P1.dat
Normal file
BIN
Cal/FS2_P1.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P2.dat
Normal file
BIN
Cal/FS2_P2.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P3.dat
Normal file
BIN
Cal/FS2_P3.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P4.dat
Normal file
BIN
Cal/FS2_P4.dat
Normal file
Binary file not shown.
9
Data/2022_01_14/beijing_16_36_46.csv
Normal file
9
Data/2022_01_14/beijing_16_36_46.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_37_51.csv
Normal file
9
Data/2022_01_14/beijing_16_37_51.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_38_01.csv
Normal file
9
Data/2022_01_14/beijing_16_38_01.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_38_11.csv
Normal file
9
Data/2022_01_14/beijing_16_38_11.csv
Normal file
File diff suppressed because one or more lines are too long
0
Data/2022_01_14/beijing_16_40_17.csv
Normal file
0
Data/2022_01_14/beijing_16_40_17.csv
Normal file
|
9
Data/2022_01_17/beijing_11_25_44.csv
Normal file
9
Data/2022_01_17/beijing_11_25_44.csv
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,7 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=1
|
||||
[FS1]
|
||||
Model=ISIF
|
||||
Model=IS1
|
||||
Port=COM7
|
||||
UID=21351029
|
||||
AEMax=0.85
|
||||
|
25
main.cpp
25
main.cpp
@ -46,12 +46,7 @@ int main(int argc, char *argv[])
|
||||
HumitureDeviceInfo m_struHumitureDI;
|
||||
//////////////////////////////////////////////////////////////////////////logger
|
||||
///create main system logger
|
||||
//QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||
|
||||
|
||||
//m_test123;
|
||||
//m_test123.Initialize("COM11");
|
||||
//m_test123.GetHumiture(fTemp, fHum);
|
||||
QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||
//////////////////////////////////////////////////////////////////////////config
|
||||
///turn on power supply
|
||||
system("gpio write 1 1");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
||||
@ -70,6 +65,7 @@ int main(int argc, char *argv[])
|
||||
m_dfpSaver.SetManmadeEnviromentalContext(m_struMEC);
|
||||
|
||||
m_mduUploader.SetContext(m_struEC, m_struMEC);
|
||||
m_mduUploader.Initialize();
|
||||
//m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
||||
//////////////////////////////////////////////////////////////////////////prepare
|
||||
m_sTimer.Preheating();
|
||||
@ -174,6 +170,23 @@ int main(int argc, char *argv[])
|
||||
// m_ctrlATP.GetDeviceAttribute();
|
||||
// m_ctrlATP.SetExposureTime(m_ctrlATP.m_adaDeviceAttr.iMinIntegrationTime);
|
||||
// m_ctrlATP.RecvData(qbTest);
|
||||
//m_test123;
|
||||
//m_test123.Initialize("COM11");
|
||||
//m_test123.GetHumiture(fTemp, fHum);
|
||||
// int aaaaa = sizeof(unsigned long int);
|
||||
// CalFrame OneFile;
|
||||
// QString aa = "C:/Users/ZhangZhuo/Desktop/qepro.cal";
|
||||
// QFile qfCalFile(aa);
|
||||
// bRes = qfCalFile.open(QFile::ReadOnly);
|
||||
// using namespace ZZ_MISCDEF;
|
||||
// qfCalFile.read((char *)&OneFile.uiExposureTimeInMS, sizeof(ZZ_U32));//U32
|
||||
// qfCalFile.read((char*)&OneFile.fTemperature, sizeof(double));
|
||||
// qfCalFile.read((char*)&OneFile.iPixels, sizeof(int));
|
||||
// qfCalFile.read((char*)OneFile.fWaveLength, sizeof(double)*OneFile.iPixels);
|
||||
// qfCalFile.read((char*)OneFile.dCal_Gain, sizeof(double)*OneFile.iPixels);
|
||||
// qfCalFile.read((char*)OneFile.dCal_Offset, sizeof(double)*OneFile.iPixels);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return a.exec();
|
||||
|
@ -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;
|
||||
@ -94,9 +96,16 @@ int CAbstractFSController::InitializeFSControl()
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "SetDeviceTemperature Failed" << iRes;
|
||||
return 5;
|
||||
//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,29 +158,30 @@ 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];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
qDebug() << "Avg " << dTemp;
|
||||
qDebug() << "Avg " << dTemp << " Thread ID:" << m_iThreadID;
|
||||
|
||||
if (dTemp >= iDeviceDepth * 0.99)
|
||||
{
|
||||
@ -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)
|
||||
@ -216,46 +226,88 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
dFactor = dTemp / (iDeviceDepth * m_fsInfo.fMaxFactor);
|
||||
iExposureTime = (float)(iExposureTime / dFactor);
|
||||
}
|
||||
if (/*fExposureTime > 100 || */iExposureTime < 10)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
}
|
||||
|
||||
}
|
||||
bIsLastValueOverflow = bIsValueOverflow;
|
||||
fLastExposureTime = fTempExposureTime;
|
||||
|
||||
if (iExposureTime > 120000)
|
||||
|
||||
|
||||
if (/*fExposureTime > 100 || */iExposureTime <= m_daDeviceAttr.iMinIntegrationTimeInMS)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
float fPredictedExposureTime = 120000;
|
||||
iRes = m_pFSCtrl->SetExposureTime(120000);
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
|
||||
// qDebug() << "Warning:PerformAutoExposure lower than min integration time.Will be limited to " << m_daDeviceAttr.iMinIntegrationTimeInMS - 1 << "MS" << " Thread ID:" << m_iThreadID;
|
||||
// iRes = m_pFSCtrl->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;
|
||||
// }
|
||||
|
||||
iRes = m_pFSCtrl->SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS);
|
||||
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 lower than min integration time.Will be limited to " << m_daDeviceAttr.iMinIntegrationTimeInMS << "MS" << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (iExposureTime > m_daDeviceAttr.iMaxIntegrationTimeInMS-1)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
//float fPredictedExposureTime = m_daDeviceAttr.iMaxIntegrationTimeInMS-1;
|
||||
//iRes = m_pFSCtrl->SetExposureTime(m_daDeviceAttr.iMaxIntegrationTimeInMS-1);
|
||||
//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";
|
||||
//}
|
||||
|
||||
iRes = m_pFSCtrl->SetExposureTime(m_daDeviceAttr.iMaxIntegrationTimeInMS - 1);
|
||||
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 " << m_daDeviceAttr.iMaxIntegrationTimeInMS - 1 << "MS" << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
qDebug() << "--------------------------Stop PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
@ -288,8 +340,24 @@ int CAbstractFSController::TakeSignalFrame()
|
||||
|
||||
DataFrame CAbstractFSController::TakeOneFrame()
|
||||
{
|
||||
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
//int iExpTime = 0;
|
||||
DataFrame dfTemp;
|
||||
// m_pFSCtrl->GetExposureTime(iExpTime);
|
||||
// dfTemp.usExposureTimeInMS = iExpTime;
|
||||
// m_pFSCtrl->GetDeviceTemperature(dfTemp.fTemperature);
|
||||
|
||||
if (m_fsInfo.ucDeviceModel== DeviceModel::ISIF)
|
||||
{
|
||||
float fTemp;
|
||||
m_pFSCtrl->GetDeviceTemperature(fTemp);
|
||||
dfTemp.fTemperature = fTemp;
|
||||
}
|
||||
else if(m_fsInfo.ucDeviceModel == DeviceModel::IS1)
|
||||
{
|
||||
dfTemp.fTemperature = 0;
|
||||
}
|
||||
|
||||
int iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
@ -297,6 +365,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 +392,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)
|
||||
@ -131,6 +131,7 @@ int CMainDataGrabber::InitLS()
|
||||
|
||||
m_ctrlLS.ILMES_SetPosition(m_struAcqPosSetting.iPosition, m_struAcqPosSetting.iTotalPosition);
|
||||
|
||||
//m_ctrlLS.ILMES_MoveToPos(2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -159,6 +160,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 +187,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 +213,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;
|
||||
}
|
||||
@ -234,6 +252,7 @@ int CMainDataGrabber::SetupMsgPipelines()
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished, this, &CMainDataGrabber::GrabOnceFinished);
|
||||
connect(m_psScheduler, &Scheduler::SignalGrabOnce, this, &CMainDataGrabber::OnTimeCounter);
|
||||
connect(m_psScheduler, &Scheduler::SignalZeroHoldCurrent, this, &CMainDataGrabber::OnZeroHoldCurrent);
|
||||
connect(this, &CMainDataGrabber::SignalStartGrab, this, &CMainDataGrabber::StartGrabTimer);
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Signal, this, &CMainDataGrabber::GrabOnceFinished_Signal);
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::GrabOnceFinished_Dark);
|
||||
@ -267,7 +286,7 @@ int CMainDataGrabber::StartGrab()
|
||||
|
||||
void CMainDataGrabber::Init_Self()
|
||||
{
|
||||
//emit SignalLSInit();
|
||||
emit SignalLSInit();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -411,7 +430,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
{
|
||||
if (m_iFlagIsCapturing)
|
||||
{
|
||||
qDebug() << "Fatal Thread Err.";
|
||||
qDebug() << "Fatal Warning.Last capture not finished.New acquisition will not start";
|
||||
return 1000;
|
||||
}
|
||||
m_iFlagIsCapturing = 1;
|
||||
@ -425,13 +444,32 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
m_pControlThread[i]->ClearBuffer();
|
||||
}
|
||||
|
||||
|
||||
////hold current
|
||||
bool bRes = m_ctrlLS.SetHoldCurrent(0.4f);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "SetHoldCurrent 0.4 Failed";
|
||||
}
|
||||
Delay_MSec(1000);
|
||||
////
|
||||
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);
|
||||
if (i==0)
|
||||
{
|
||||
m_ctrlLS.ILMES_MoveToPos(i + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctrlLS.MoveTo(m_struAcqPosSetting.iPosition[1]);
|
||||
}
|
||||
m_ctrlLS.ILMES_MoveToPos(i+1);
|
||||
////
|
||||
qDebug() << "Stop ILMES_MoveToPos:" << i + 1;
|
||||
m_struAcqPosSetting.iPosition[i + 1];
|
||||
// m_struAcqPosSetting.iPosition[i + 1];
|
||||
m_iFlagIsCapturing_Signal = 1;
|
||||
emit SignalStartGrabOnce_Signal();
|
||||
while (m_iFlagIsCapturing_Signal)
|
||||
@ -442,18 +480,24 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
|
||||
////move to
|
||||
qDebug() << "Start ILMES_MoveToPos:" << 0;
|
||||
//m_ctrlLS.ILMES_MoveToPos(0);
|
||||
m_ctrlLS.ILMES_MoveToPos(0);
|
||||
qDebug() << "Stop ILMES_MoveToPos:" << 0;
|
||||
m_struAcqPosSetting.iPosition[0];
|
||||
//m_struAcqPosSetting.iPosition[0];
|
||||
m_iFlagIsCapturing_Dark = 1;
|
||||
emit SignalStartGrabOnce_Dark();
|
||||
while (m_iFlagIsCapturing_Dark)
|
||||
{
|
||||
Delay_MSec(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////hold current
|
||||
bRes = m_ctrlLS.SetHoldCurrent(0);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "SetHoldCurrent 0 Failed";
|
||||
}
|
||||
Delay_MSec(1000);
|
||||
////
|
||||
std::vector<std::vector<DataFrame>> vecData;
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
@ -465,11 +509,13 @@ 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);
|
||||
m_pmduUploader->SetData(vecData);
|
||||
// emit SignalPushOneDataFrame();
|
||||
emit SignalPushOneDataFrame();
|
||||
m_pdfpSaver->SetData(vecData);
|
||||
m_pdfpSaver->WriteDataFile();
|
||||
m_iFlagIsCapturing = 0;
|
||||
@ -514,3 +560,14 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::OnZeroHoldCurrent()
|
||||
{
|
||||
bool bRes = m_ctrlLS.SetHoldCurrent(0);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "OnZeroHoldCurrent Failed";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
@ -74,6 +75,7 @@ public slots:
|
||||
int InitLS();
|
||||
int StartGrabTimer();
|
||||
int OnTimeCounter();
|
||||
int OnZeroHoldCurrent();
|
||||
|
||||
int HandleThreadEvent_Signal(int iThreadID, int iFlagStatus);
|
||||
int HandleThreadEvent_Dark(int iThreadID, int iFlagStatus);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
Scheduler::Scheduler(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_iFlagIsOnRestart = 0;
|
||||
m_GrabTimer = new QTimer(this);
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &Scheduler::OnTimeCounter);
|
||||
connect(this, &Scheduler::SignalSelfStart, this, &Scheduler::StartAsPlanned);
|
||||
@ -27,7 +28,7 @@ void Scheduler::Preheating()
|
||||
#ifdef _DEBUG
|
||||
QThread::msleep(5000);
|
||||
#else
|
||||
QThread::msleep(10000);//NEED TO CHANGE BEFOR HAND TO CUSTOM
|
||||
QThread::msleep(900000);//NEED TO CHANGE BEFOR HAND TO CUSTOM
|
||||
#endif
|
||||
qDebug() << "Preheating Finished";
|
||||
}
|
||||
@ -40,10 +41,11 @@ void Scheduler::SelfStart()
|
||||
void Scheduler::StartAsPlanned()
|
||||
{
|
||||
bool bStopWait = false;
|
||||
QTime qtTime = QTime::currentTime();
|
||||
|
||||
while (!bStopWait)
|
||||
{
|
||||
QThread::msleep(100);
|
||||
QThread::msleep(10000);
|
||||
QTime qtTime = QTime::currentTime();
|
||||
if (m_struAcqTime.qtStartTime <= qtTime && qtTime < m_struAcqTime.qtStopTime)
|
||||
{
|
||||
bStopWait = true;
|
||||
@ -53,6 +55,8 @@ 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);
|
||||
//this->OnTimeCounter();
|
||||
//emit &QTimer::timeout;
|
||||
}
|
||||
|
||||
int Scheduler::OnTimeCounter()
|
||||
@ -60,12 +64,22 @@ int Scheduler::OnTimeCounter()
|
||||
QTime qtTime = QTime::currentTime();
|
||||
if (m_struAcqTime.qtStartTime <= qtTime && qtTime < m_struAcqTime.qtStopTime)
|
||||
{
|
||||
if (m_iFlagIsOnRestart)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
qDebug() << "it's time to work...work work.";
|
||||
emit SignalGrabOnce();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_iFlagIsOnRestart)
|
||||
{
|
||||
m_iFlagIsOnRestart = 1;
|
||||
}
|
||||
emit SignalZeroHoldCurrent();
|
||||
system("gpio write 1 0");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
||||
qDebug() << "gpio write 1 0......"<<endl;
|
||||
qDebug() << "Non working time. Idling......";
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
Scheduler(QObject* parent = nullptr);
|
||||
~Scheduler();
|
||||
private:
|
||||
int m_iFlagIsOnRestart;
|
||||
QTimer *m_GrabTimer;
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
private:
|
||||
@ -21,6 +22,7 @@ public:
|
||||
public slots:
|
||||
int OnTimeCounter();
|
||||
signals:
|
||||
void SignalZeroHoldCurrent();
|
||||
void SignalGrabOnce();
|
||||
void SignalSelfStart();
|
||||
};
|
@ -15,7 +15,7 @@ ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::ReInit()
|
||||
@ -63,10 +63,19 @@ 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);
|
||||
|
||||
GetDeviceInfo(m_diDeviceInfo);
|
||||
GetExposureTime_Init();
|
||||
SetAvgTimes(1);
|
||||
|
||||
std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName);
|
||||
if (szPostion==std::string::npos)
|
||||
if (szPostion == std::string::npos)
|
||||
{
|
||||
qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
return 3;
|
||||
@ -187,12 +196,15 @@ 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)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Call SetExposureTime error.Exit Code:2";
|
||||
return 2;
|
||||
//return 2;
|
||||
}
|
||||
iRes = SingleShot(m_daDeviceAttr.iPixels);
|
||||
if (iRes != 0)
|
||||
@ -201,7 +213,8 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
SetExposureTime(iTempExpTime);
|
||||
///
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_WAVELENGTH_CALIBRATION_COEF);
|
||||
@ -227,11 +240,11 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
return 1;
|
||||
}
|
||||
float fWaveLengthCoef[4];
|
||||
memcpy(fWaveLengthCoef, qbRecv.data()+16, 4 * sizeof(float));
|
||||
for (int i=0;i< m_daDeviceAttr.iPixels;i++)
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
Attr = m_daDeviceAttr;
|
||||
|
||||
@ -243,6 +256,68 @@ int ZZ_ATPControl_Serial_Qt::SetDeviceTemperature(float fTemperature)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SetAvgTimes(int iTimes /*= 1*/)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(SET_AVERAGE_NUMBER);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetExposureTime_Init()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
m_iExposureTime = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SendCommand(QByteArray qbCommand)
|
||||
{
|
||||
int iSize = qbCommand.size() + 3;
|
||||
@ -262,10 +337,10 @@ int ZZ_ATPControl_Serial_Qt::SendCommand(QByteArray qbCommand)
|
||||
|
||||
qbSend.append(iSum % 256);
|
||||
|
||||
qint64 qi64Write= m_pSerialPort->write(qbSend);
|
||||
qint64 qi64Write = m_pSerialPort->write(qbSend);
|
||||
if (qi64Write != qbSend.size())
|
||||
{
|
||||
qDebug() << "Err:write Failed.Exit Code:1"<< qi64Write;
|
||||
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -280,13 +355,13 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
int iCounter = 0;
|
||||
while (qbData.size() < 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(50);
|
||||
m_pSerialPort->waitForReadyRead(5000);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 10)
|
||||
if (iCounter > 150)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1"<< qbData.size();
|
||||
qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
return 1;
|
||||
}
|
||||
iCounter++;
|
||||
@ -294,7 +369,7 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
|
||||
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();
|
||||
qDebug() << "Err:RecvData Failed,Wrong Header.Exit Code:2" << qbData.size();
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -302,12 +377,12 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
int iLength = qbData[2] * 256 + qbData[3] + 2;
|
||||
while (qbData.size() < iLength)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(50);
|
||||
m_pSerialPort->waitForReadyRead(5000);
|
||||
qbData.append(m_pSerialPort->readAll());
|
||||
|
||||
if (iCounter > 100)
|
||||
if (iCounter > 200)
|
||||
{
|
||||
qDebug() << "Err:RecvData Failed,Incomplete Data.Exit Code:3" << qbData.size();
|
||||
qDebug() << "Err:RecvData Failed,Incomplete Data.Exit Code:3" << qbData.size();
|
||||
return 3;
|
||||
}
|
||||
iCounter++;
|
||||
@ -321,15 +396,80 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
ZZ_U16 usCheckSum = 0;
|
||||
for (int i = 0; i < iCheckSumLength; i++)
|
||||
{
|
||||
usCheckSum += qbData[i+2];
|
||||
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" << qbData.size();
|
||||
qbData.clear();
|
||||
return 4;
|
||||
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::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_ShortLag 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_ShortLag 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_ShortLag 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_ShortLag 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;
|
||||
@ -339,7 +479,7 @@ int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
|
||||
{
|
||||
if (qbData.size() < 6)
|
||||
{
|
||||
qDebug() << "Err:ParseData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
qDebug() << "Err:ParseData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
return 1;
|
||||
}
|
||||
qbData.remove(0, 5);
|
||||
@ -498,19 +638,37 @@ int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fM
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
QByteArray qbExposureTime,qbRecv;
|
||||
qbExposureTime.append(SET_INTEGRATION_TIME);
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
QByteArray qbExposureTime, qbRecv;
|
||||
//qbExposureTime.append(SET_INTEGRATION_TIME);
|
||||
qbExposureTime.resize(3);
|
||||
qbExposureTime[0] = SET_INTEGRATION_TIME;
|
||||
qbExposureTime[1] = iExposureTimeInMS >> 8;
|
||||
qbExposureTime[2] = iExposureTimeInMS & 0xFF;
|
||||
|
||||
SendCommand(qbExposureTime);
|
||||
RecvData(qbRecv);
|
||||
ParseData(qbRecv);
|
||||
int iRes = SendCommand(qbExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:1" ;
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -519,16 +677,34 @@ int ZZ_ATPControl_Serial_Qt::SetExposureTime(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;
|
||||
SendCommand(qbSend);
|
||||
RecvData(qbRecv);
|
||||
ParseData(qbRecv);
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -540,13 +716,30 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
|
||||
qbRecv.clear();
|
||||
qbSend.append(SYNC_GET_DATA);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
SendCommand(qbSend);
|
||||
RecvData(qbRecv);
|
||||
ParseData(qbRecv);
|
||||
// qbSend[1] = 0x00;
|
||||
// qbSend[2] = 0x01;
|
||||
qbSend[1] = m_iExposureTime >> 8;;
|
||||
qbSend[2] = m_iExposureTime & 0xFF;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
ZZ_U16 usData[4096] = {0};
|
||||
ZZ_U16 usData[4096] = { 0 };
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
@ -558,12 +751,22 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
|
||||
//int aaa = qbRecv.size();
|
||||
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
|
||||
memcpy(usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||
for (int i=0;i< iDataSizeInPixel;i++)
|
||||
for (size_t i = 0; i < iDataSizeInPixel; i++)
|
||||
{
|
||||
dfData.lData[i] = usData[i];
|
||||
dfData.lData[i] = qToBigEndian(usData[i]);
|
||||
|
||||
|
||||
}
|
||||
// for (int i = 0; i < iDataSizeInPixel; i++)
|
||||
// {
|
||||
// dfData.lData[i] = usData[i];
|
||||
// }
|
||||
}
|
||||
|
||||
dfData.usExposureTimeInMS = m_iExposureTime;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -576,14 +779,29 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
SendCommand(qbSend);
|
||||
RecvData(qbRecv);
|
||||
ParseData(qbRecv);
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||
return 1;
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -602,6 +820,8 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
fTemperature = 0;
|
||||
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
@ -609,9 +829,28 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature)
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
SendCommand(qbSend);
|
||||
RecvData(qbRecv);
|
||||
ParseData(qbRecv);
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData_ShortLag(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
QString qstrTemp = qbRecv.data();
|
||||
fTemperature = qstrTemp.toFloat();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime);
|
||||
private:
|
||||
int SetAvgTimes(int iTimes = 1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
@ -76,11 +78,15 @@ private:
|
||||
DeviceInfo m_diDeviceInfo;
|
||||
DeviceAttribute m_daDeviceAttr;
|
||||
|
||||
//Attr
|
||||
int m_iExposureTime;
|
||||
//////////////////////////////////////////////////////////////////////////shutter control stub code s
|
||||
//int SetExtShutter(int iShutterUP0, int iShutterDOWN1,int iShutterDOWN2,int iShutterDOWN3); //0:close 1:open
|
||||
//////////////////////////////////////////////////////////////////////////shutter control stub code e
|
||||
int GetExposureTime_Init();
|
||||
int SendCommand(QByteArray qbCommand);
|
||||
int RecvData(QByteArray &qbData);
|
||||
int RecvData_ShortLag(QByteArray &qbData);
|
||||
int ParseData(QByteArray &qbData);
|
||||
public slots:
|
||||
int Init_Self();
|
||||
|
@ -231,7 +231,7 @@ bool DataFileProcessor::WriteData()
|
||||
qstrTemp = QString("_P%1").arg(j + 1);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
if ((m_vecData[i][j].fTemperature < 5) && (m_vecData[i][j].fTemperature> -5))
|
||||
if ((m_vecData[i][j].fTemperature < 5) /*&& (m_vecData[i][j].fTemperature> -5)*/)
|
||||
{
|
||||
qfData.write("valid");
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
|
||||
long minimum_time;
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
Attr.iMinIntegrationTimeInMS = minimum_time;
|
||||
Attr.iMinIntegrationTimeInMS = (int)((double)minimum_time / (double)1000);
|
||||
Attr.iMaxIntegrationTimeInMS = 60000;
|
||||
|
||||
if (spec_length > 0) {
|
||||
|
@ -12,8 +12,8 @@ namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned long int ZZ_U32;
|
||||
typedef long int ZZ_S32;
|
||||
typedef unsigned int ZZ_U32;
|
||||
typedef long int ZZ_S32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
@ -23,8 +23,8 @@ namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
ZZ_S32 lData[4096];
|
||||
ZZ_U32 usExposureTimeInMS = 0;
|
||||
ZZ_S32 lData[4096] = {0};
|
||||
float fTemperature = 0;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
@ -193,7 +193,21 @@
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm");
|
||||
QString qstrTemp;
|
||||
int iTemp = m_qjoJObj.value("IntervalTime").toInt();
|
||||
if (iTemp < 10)
|
||||
{
|
||||
qstrTemp = m_qjoJObj.value("IntervalTime").toString();
|
||||
if (qstrTemp.size() == 1)
|
||||
{
|
||||
qstrTemp = "0" + qstrTemp;
|
||||
}
|
||||
m_struAcqTime.qtInterval = QTime::fromString(qstrTemp, "mm");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm");
|
||||
}
|
||||
if (!m_struAcqTime.qtInterval.isValid())
|
||||
{
|
||||
qDebug() << "Invalid IntervalTime";
|
||||
@ -227,6 +241,7 @@
|
||||
m_struMEC.qstrPhoneNumberOfMaintenanceStaff = m_qjoJObj.value("PhoneNumberOfMaintenanceStaff").toString();
|
||||
m_struMEC.qstrDownloadUserID = m_qjoJObj.value("DownloadUserID").toString();
|
||||
m_struMEC.qstrDownlaodAddress = m_qjoJObj.value("DownlaodAddress").toString();
|
||||
m_struMEC.qstrHTTPServer = m_qjoJObj.value("HTTPServer").toString();
|
||||
|
||||
|
||||
|
||||
|
@ -51,13 +51,13 @@ int ZZ_HttpTransfer::SendData()
|
||||
qstrSend += /*"ExpTime:" +*/ QString("%1").arg(m_vecCalcedData[i][j].usExposureTimeInMS) + "##";
|
||||
qstrSend += /*"Bands:" +*/ QString("%1").arg(m_vecCalcedData[i][j].iPixels) + "##";
|
||||
qstrSend += /*"temp:" +*/ QString("%1").arg(m_vecCalcedData[i][j].fTemperature) + "##";
|
||||
|
||||
//send
|
||||
qbSend.clear();
|
||||
qbSend.append(qstrSend.toLatin1());
|
||||
qbSend.append((char*)m_vecCalcedData[i][j].fData, sizeof(float)*m_vecCalcedData[i][j].iPixels);
|
||||
|
||||
m_pNetworkManagerThread->post(qnRequest, qbSend);
|
||||
qDebug() << "Network Sending: Data";
|
||||
m_iFlagIsReplied = 0;
|
||||
int iCount = 0;
|
||||
while (!m_iFlagIsReplied)
|
||||
@ -68,6 +68,7 @@ int ZZ_HttpTransfer::SendData()
|
||||
{
|
||||
m_iFlagIsReplied = 1;
|
||||
qDebug() << "Reply Timeout:Upload Data ";
|
||||
qDebug() << "UpLoadAddr:" << qstrURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,6 +130,7 @@ int ZZ_HttpTransfer::SendInfo()
|
||||
|
||||
qbSend = qstrSend.toLatin1();
|
||||
m_pNetworkManager->post(qnRequest, qbSend);
|
||||
qDebug() << "Network Sending:Dev Info ";
|
||||
m_iFlagIsReplied = 0;
|
||||
int iCount = 0;
|
||||
while (!m_iFlagIsReplied)
|
||||
@ -139,6 +141,7 @@ int ZZ_HttpTransfer::SendInfo()
|
||||
{
|
||||
m_iFlagIsReplied = 1;
|
||||
qDebug() << "Reply Timeout:Upload Info ";
|
||||
qDebug() << "UpLoadAddr:" << qstrURL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,6 +202,7 @@ int ZZ_HttpTransfer::SendErr()
|
||||
|
||||
qbSend = qstrSend.toLatin1();
|
||||
m_pNetworkManager->post(qnRequest, qbSend);
|
||||
qDebug() << "Network Sending:Warning Info ";
|
||||
m_iFlagIsReplied = 0;
|
||||
int iCount = 0;
|
||||
while (!m_iFlagIsReplied)
|
||||
@ -209,6 +213,7 @@ int ZZ_HttpTransfer::SendErr()
|
||||
{
|
||||
m_iFlagIsReplied = 1;
|
||||
qDebug() << "Reply Timeout:Upload Info ";
|
||||
qDebug() << "UpLoadAddr:" << qstrURL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -252,8 +257,13 @@ int ZZ_HttpTransfer::SlotReplyFinished(QNetworkReply* qnReply)
|
||||
QByteArray qbData = qnReply->readAll();
|
||||
if (qnReply->error()== QNetworkReply::NoError)
|
||||
{
|
||||
qDebug() << "Reply NoError:" << "Server:" << qstrURL;
|
||||
m_iFlagIsReplied = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Reply Error:" << qnReply->error() << "Server:" << qstrURL;
|
||||
}
|
||||
qnReply->abort();
|
||||
qnReply->close();
|
||||
qnReply->deleteLater();
|
||||
@ -269,8 +279,13 @@ int ZZ_HttpTransfer::SlotReplyFinishedThread(QNetworkReply* qnReply)
|
||||
QByteArray qbData = qnReply->readAll();
|
||||
if (qnReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
qDebug() << "Reply NoError:" << "Server:"<<qstrURL;
|
||||
m_iFlagIsReplied = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Reply Error:" << qnReply->error()<< "Server:"<<qstrURL;
|
||||
}
|
||||
qnReply->abort();
|
||||
qnReply->close();
|
||||
qnReply->deleteLater();
|
||||
|
@ -17,6 +17,8 @@ int RadConverter::LoadCalibrationFrames(RunTimeGrabberParams struGrabberRTParams
|
||||
/////param
|
||||
int iScanPoints = struGrabberRTParams.apsParams.iTotalPosition - 1;
|
||||
int iDevices = struGrabberRTParams.fscParams.ucDeviceNumber;
|
||||
//int iScanPoints = 4;
|
||||
//int iDevices = 1;
|
||||
/////check dir
|
||||
QDir qdirPath(m_qstrCalFilePath);
|
||||
if (!qdirPath.exists())
|
||||
@ -29,7 +31,7 @@ int RadConverter::LoadCalibrationFrames(RunTimeGrabberParams struGrabberRTParams
|
||||
qslFilter << "*.dat";
|
||||
qdirPath.setNameFilters(qslFilter);
|
||||
QFileInfoList qfiInfo = qdirPath.entryInfoList(qslFilter);
|
||||
if (qfiInfo.size()!= iScanPoints * iDevices)
|
||||
if (qfiInfo.size()<iScanPoints * iDevices)
|
||||
{
|
||||
qDebug() << "Calibration Files quantities not match";
|
||||
return -2;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QMetaType>
|
||||
#include <QtEndian>
|
||||
////////////////////////////Thread
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
|
Reference in New Issue
Block a user