mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 11:29:43 +08:00
提交
This commit is contained in:
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:08:00,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:09:27,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:11:07,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:11:20,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:13:36,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:14:30,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_02 10:15:41,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 01:50:36,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 01:51:49,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 01:52:15,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:09:45,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:15:37,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:22:22,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:22:54,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:25:26,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:26:51,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:27:30,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:28:30,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:29:07,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:29:49,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:31:39,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:32:27,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:37:08,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
@ -1 +0,0 @@
|
||||
EnvironmentalContext,CaseHumidity,,CaseTemperature,,GPS_Altitude,50,GPS_Latitude,118,GPS_Longtitude,117,GPS_North,on,Location,beijing,UTCDateTime,2021_12_03 02:41:27,DownlaodAddress,http://www.iris-rs.cn,DownloadUserID,newuser,HTTPServer,,InstallationTime,2021-11-18,NameOfMaintenanceStaff,renlixin,PhoneNumberOfMaintenanceStaff,110110110,
|
6
Data/2021_12_08/beijing_14_17_03.csv
Normal file
6
Data/2021_12_08/beijing_14_17_03.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_19_23.csv
Normal file
6
Data/2021_12_08/beijing_16_19_23.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_20_01.csv
Normal file
6
Data/2021_12_08/beijing_16_20_01.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_22_09.csv
Normal file
6
Data/2021_12_08/beijing_16_22_09.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_22_42.csv
Normal file
6
Data/2021_12_08/beijing_16_22_42.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_23_39.csv
Normal file
6
Data/2021_12_08/beijing_16_23_39.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_28_22.csv
Normal file
6
Data/2021_12_08/beijing_16_28_22.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_28_57.csv
Normal file
6
Data/2021_12_08/beijing_16_28_57.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_31_32.csv
Normal file
6
Data/2021_12_08/beijing_16_31_32.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_58_10.csv
Normal file
6
Data/2021_12_08/beijing_16_58_10.csv
Normal file
File diff suppressed because one or more lines are too long
6
Data/2021_12_08/beijing_16_58_25.csv
Normal file
6
Data/2021_12_08/beijing_16_58_25.csv
Normal file
File diff suppressed because one or more lines are too long
15
Data/2021_12_08/beijing_17_23_37.csv
Normal file
15
Data/2021_12_08/beijing_17_23_37.csv
Normal file
File diff suppressed because one or more lines are too long
15
Data/2021_12_08/beijing_17_25_45.csv
Normal file
15
Data/2021_12_08/beijing_17_25_45.csv
Normal file
File diff suppressed because one or more lines are too long
15
Data/2021_12_08/beijing_17_38_47.csv
Normal file
15
Data/2021_12_08/beijing_17_38_47.csv
Normal file
File diff suppressed because one or more lines are too long
@ -1,14 +1,21 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=1
|
||||
[FS2]
|
||||
Model=OSIFBeta
|
||||
Port=-1
|
||||
UID=QEP02975
|
||||
TotalSpectrometer=2
|
||||
|
||||
[FS1]
|
||||
Model=OSIFBeta
|
||||
Port=-1
|
||||
UID=FLMS15814
|
||||
UID=FLMS15815
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[FS2]
|
||||
Model=OSIFAlpha
|
||||
Port=-1
|
||||
UID=QEP02975
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[FS3]
|
||||
Model=Null
|
||||
[LINEAR SHUTTER]
|
||||
Port=4
|
||||
|
11
main.cpp
11
main.cpp
@ -30,21 +30,28 @@ int main(int argc, char *argv[])
|
||||
|
||||
testdp.SetEnvironmentContex(testEC);
|
||||
testdp.SetManmadeEnviromentalContext(testMEC);
|
||||
testdp.WriteDataFile();
|
||||
//testdp.WriteDataFile();
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
CMainDataGrabber testDG;
|
||||
QThread* m_pqDataGrabberThreadHolder = new QThread();
|
||||
testDG.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
testDG.SetGrabberFileProcessor(testdp);
|
||||
testDG.SetGrabberParams(testp);
|
||||
testDG.InitThreadStatus();
|
||||
testDG.InitializeWorkers();
|
||||
testDG.SetupMsgPipelines();
|
||||
testDG.StartWorkers();
|
||||
m_pqDataGrabberThreadHolder->start();
|
||||
|
||||
|
||||
|
||||
m_pqDataGrabberThreadHolder->start();
|
||||
testDG.StartGrab();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//QString qstrTest = "This is a test message 2";
|
||||
//qDebug() << qstrTest;
|
||||
//cout << "This is a test message";
|
||||
|
@ -366,13 +366,13 @@ int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fM
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeapSort(dfTemp.usData, m_daDeviceAttr.iPixels);
|
||||
HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_daDeviceAttr.iPixels / 100;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.usData[i];
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
@ -519,7 +519,7 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
|
||||
else
|
||||
{
|
||||
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
|
||||
memcpy(dfData.usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||
memcpy(dfData.lData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,23 @@ void DataFileProcessor::SetManmadeEnviromentalContext(MEContext struMEC)
|
||||
m_struMEC = struMEC;
|
||||
}
|
||||
|
||||
void DataFileProcessor::SetDeviceInfo(FSContext struDeviceContext)
|
||||
{
|
||||
m_struDeviceContext = struDeviceContext;
|
||||
}
|
||||
|
||||
void DataFileProcessor::SetData(std::vector<std::vector<DataFrame>> vecData)
|
||||
{
|
||||
m_vecData.clear();
|
||||
m_vecData = vecData;
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteDataFile()
|
||||
{
|
||||
GenerateFilePath();
|
||||
WriteInfo();
|
||||
WriteEnvironmentInfo();
|
||||
WriteDeviceInfo();
|
||||
WriteData();
|
||||
bool res = true;
|
||||
return res;
|
||||
}
|
||||
@ -46,7 +59,7 @@ void DataFileProcessor::GenerateFilePath()
|
||||
{
|
||||
m_struEC.qstrLocation = "Unknown";
|
||||
}
|
||||
m_qstrFullFileName= m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".txt";
|
||||
m_qstrFullFileName= m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".csv";
|
||||
|
||||
QDir qdirPath(m_qstrFilePath);
|
||||
if (!qdirPath.exists())
|
||||
@ -55,7 +68,7 @@ void DataFileProcessor::GenerateFilePath()
|
||||
}
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteInfo()
|
||||
bool DataFileProcessor::WriteEnvironmentInfo()
|
||||
{
|
||||
bool bRes = true;
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
@ -90,7 +103,6 @@ bool DataFileProcessor::WriteInfo()
|
||||
qfData.write("UTCDateTime,");
|
||||
qfData.write(m_struEC.qstrUTCDateTime.toLatin1());
|
||||
qfData.write(",");
|
||||
|
||||
//qfData.write("\n");
|
||||
|
||||
//MEC
|
||||
@ -112,14 +124,109 @@ bool DataFileProcessor::WriteInfo()
|
||||
qfData.write(",");
|
||||
qfData.write("PhoneNumberOfMaintenanceStaff,");
|
||||
qfData.write(m_struMEC.qstrPhoneNumberOfMaintenanceStaff.toLatin1());
|
||||
qfData.write(",");
|
||||
//qfData.write(",");
|
||||
|
||||
qfData.close();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
void DataFileProcessor::WriteDeviceInfo()
|
||||
{
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||
QString qstrTemp;
|
||||
|
||||
qfData.write("\n");
|
||||
qfData.write("TotalSpectrometer,");
|
||||
qstrTemp = QString::number(m_struDeviceContext.ucDeviceNumber);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write("\n");
|
||||
|
||||
for (int i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
||||
{
|
||||
qstrTemp = QString("FS%1_Info").arg(i + 1);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
|
||||
qfData.write("Model,");
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
qstrTemp = QString::fromStdString(GetDeviceModelName(m_struDeviceContext.ucDeviceModel[i]));
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
|
||||
qfData.write("SN,");
|
||||
qstrTemp = QString::fromStdString(m_struDeviceContext.strSN[i]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
|
||||
qfData.write("Pixels,");
|
||||
qstrTemp = QString::number(m_struDeviceContext.usPixels[i]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
|
||||
qfData.write("Depth,");
|
||||
qstrTemp = QString::number(m_struDeviceContext.lDepth[i]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
|
||||
qfData.write("\n");
|
||||
|
||||
qfData.write("Wavelength,");
|
||||
for (unsigned short j = 0; j < m_struDeviceContext.usPixels[i]-1; j++)
|
||||
{
|
||||
qstrTemp = QString::number(m_struDeviceContext.fWavelength[i][j]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
}
|
||||
|
||||
qstrTemp = QString::number(m_struDeviceContext.fWavelength[i][m_struDeviceContext.usPixels[i] - 1]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
|
||||
qfData.write("\n");
|
||||
}
|
||||
qfData.close();
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteData()
|
||||
{
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||
QString qstrTemp;
|
||||
qfData.write("Data Section");
|
||||
qfData.write("\n");
|
||||
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
for (int i=0;i<m_struDeviceContext.ucDeviceNumber;i++)
|
||||
{
|
||||
for (int j=0;j<m_vecData[i].size();j++)
|
||||
{
|
||||
qstrTemp = QString::fromStdString(GetDeviceModelName(m_struDeviceContext.ucDeviceModel[i]));
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qstrTemp = QString("_P%1").arg(j + 1);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("valid");
|
||||
qfData.write(",");
|
||||
qstrTemp = QString::number(m_vecData[i][j].usExposureTimeInMS);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
for (int k=0;k< m_struDeviceContext.usPixels[i];k++)
|
||||
{
|
||||
qfData.write(",");
|
||||
qstrTemp = QString::number(m_vecData[i][j].lData[k]);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
}
|
||||
qfData.write("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool res = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,18 +2,24 @@
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
class DataFileProcessor
|
||||
{
|
||||
public:
|
||||
DataFileProcessor();
|
||||
virtual ~DataFileProcessor();
|
||||
public:
|
||||
public:
|
||||
void SetEnvironmentContex(EContext struEC);
|
||||
void SetManmadeEnviromentalContext(MEContext truMEC);
|
||||
void SetManmadeEnviromentalContext(MEContext struMEC);
|
||||
void SetDeviceInfo(FSContext struDeviceContext);
|
||||
void SetData(std::vector<std::vector<DataFrame>> vecData);
|
||||
bool WriteDataFile();
|
||||
private:
|
||||
void GenerateFilePath();
|
||||
bool WriteInfo();
|
||||
bool WriteEnvironmentInfo();
|
||||
void WriteDeviceInfo();
|
||||
bool WriteData();
|
||||
|
||||
|
||||
@ -22,7 +28,11 @@ private:
|
||||
QString m_qstrFullFileName;
|
||||
QString m_qstrFileName;
|
||||
QString m_qstrFilePath;
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
|
||||
QDateTime m_qdtTime;
|
||||
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
FSContext m_struDeviceContext;
|
||||
std::vector<std::vector<DataFrame>> m_vecData;
|
||||
};
|
@ -9,6 +9,8 @@ class CIrisFSBase
|
||||
public:
|
||||
//CIrisFSBase();
|
||||
//virtual ~CIrisFSBase()= 0;
|
||||
private:
|
||||
//int m_iMaxDepth = 65535;
|
||||
public:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
|
@ -6,6 +6,7 @@ OceanOptics_lib::OceanOptics_lib()
|
||||
{
|
||||
m_iSpectralmeterHandle = -100;
|
||||
}
|
||||
|
||||
OceanOptics_lib::~OceanOptics_lib()
|
||||
{
|
||||
|
||||
@ -22,49 +23,68 @@ int OceanOptics_lib::Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; i++)
|
||||
{
|
||||
//printf("\nOpening spectrometer %d.\n", i);
|
||||
// printf("\nOpening spectrometer %d.\n", i);
|
||||
flag = seabreeze_open_spectrometer(i, &error);
|
||||
//printf("Open spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("Open spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
if (0 == flag)
|
||||
{
|
||||
device_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string sn = GetSerialNumber(i);
|
||||
|
||||
if (strcmp(sn.c_str(), strDeviceName.c_str()) == 0)
|
||||
{
|
||||
m_iSpectralmeterHandle = i;
|
||||
//printf("\nfind!!!!!!!!!!!!\n");
|
||||
// printf("\nfind!!!!!!!!!!!!\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("\nClosing spectrometer %d.\n", i);
|
||||
// printf("\nClosing spectrometer %d.\n", i);
|
||||
flag = seabreeze_close_spectrometer(i, &error);
|
||||
//printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
// printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
long test = seabreeze_get_buffer_capacity_minimum(m_iSpectralmeterHandle, &error);
|
||||
seabreeze_set_buffer_capacity(m_iSpectralmeterHandle, &error, test);
|
||||
//seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
//seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
// printf("seabreeze_set_trigger_mode: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
long minimum_time;
|
||||
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
//printf("...Minimum is %ld microseconds, result is [%s]\n", minimum_time, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
// printf("\n-------------------û<>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//SetExposureTime(minimum_time);
|
||||
SetExposureTime(minimum_time / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -80,7 +100,7 @@ int OceanOptics_lib::Initialize()
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; i++)
|
||||
{
|
||||
//printf("\nOpening spectrometer %d.\n", i);
|
||||
printf("\nOpening spectrometer %d.\n", i);
|
||||
flag = seabreeze_open_spectrometer(i, &error);
|
||||
//printf("Open spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
if (0 == flag)
|
||||
@ -88,25 +108,42 @@ int OceanOptics_lib::Initialize()
|
||||
m_iSpectralmeterHandle = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
// printf("seabreeze_set_trigger_mode: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
long minimum_time;
|
||||
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
//printf("...Minimum is %ld microseconds, result is [%s]\n", minimum_time, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
// printf("\n-------------------û<>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetExposureTime(minimum_time);
|
||||
SetExposureTime(minimum_time / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -197,7 +234,7 @@ void OceanOptics_lib::Close()
|
||||
int error;
|
||||
|
||||
flag = seabreeze_close_spectrometer(m_iSpectralmeterHandle, &error);
|
||||
//printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
@ -205,7 +242,7 @@ int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -213,23 +250,42 @@ int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
int flag;
|
||||
int spec_length;
|
||||
double *spectrum = 0;
|
||||
bool ret;
|
||||
|
||||
//printf("\n\nGetting formatted spectrum length.\n");
|
||||
// printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
//printf("Get formatted spectrum_length result is (%d) [%s]\n", spec_length, get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (spec_length > 0)
|
||||
{
|
||||
spectrum = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
|
||||
//printf("\nGetting a formatted spectrum.\n");
|
||||
|
||||
|
||||
seabreeze_clear_buffer(m_iSpectralmeterHandle, &error);
|
||||
|
||||
|
||||
|
||||
|
||||
printf("\nGetting a formatted spectrum.\n");
|
||||
flag = seabreeze_get_formatted_spectrum(m_iSpectralmeterHandle, &error, spectrum, spec_length);
|
||||
//printf("Get formatted spectrum result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
//printf("\tPixel value 20 is %1.2f\n", spectrum[20]);
|
||||
printf("\nGetting a formatted spectrum------------------------------.\n");
|
||||
// printf("Get formatted spectrum result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("\tPixel value 20 is %1.2f\n", spectrum[20]);
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int tmp = 0; tmp < spec_length; tmp++)
|
||||
{
|
||||
dfData.usData[tmp] = spectrum[tmp];
|
||||
dfData.lData[tmp] = spectrum[tmp];
|
||||
}
|
||||
|
||||
int exposureTimeInMS;
|
||||
@ -249,20 +305,40 @@ int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int OceanOptics_lib::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
iExposureTimeInMS = iExposureTimeInMS * 1000;
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
seabreeze_set_integration_time_microsec(m_iSpectralmeterHandle, &error, iExposureTimeInMS);
|
||||
//printf("Set integration time result is [%s]\n", get_error_string(error));
|
||||
seabreeze_set_integration_time_microsec(m_iSpectralmeterHandle, &error, iExposureTimeInMS * 1000);
|
||||
printf("Set integration time result is [%s]\n", get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
|
||||
|
||||
// //----------------------------------------------------------------------------------------------------------------
|
||||
// int error;
|
||||
// long *spectrometer_ids;
|
||||
// int number_of_spectrometers;
|
||||
//
|
||||
// number_of_spectrometers = sbapi_get_number_of_spectrometer_features(m_iSpectralmeterHandle, &error);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_spectrometers, sbapi_get_error_string(error));
|
||||
// spectrometer_ids = (long *)calloc(number_of_spectrometers, sizeof(long));
|
||||
// number_of_spectrometers = sbapi_get_spectrometer_features(m_iSpectralmeterHandle, &error, spectrometer_ids, number_of_spectrometers);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_spectrometers, sbapi_get_error_string(error));
|
||||
//
|
||||
// sbapi_spectrometer_set_integration_time_micros(m_iSpectralmeterHandle, spectrometer_ids[0], &error, iExposureTimeInMS*1000);
|
||||
// printf("\t\t\t\tResult is [%s]\n", sbapi_get_error_string(error));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -271,7 +347,7 @@ int OceanOptics_lib::GetExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -283,21 +359,34 @@ int OceanOptics_lib::GetExposureTime(int &iExposureTimeInMS)
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
//printf("\nSetting TEC temperature to -5C\n");
|
||||
// printf("\nSetting TEC temperature to -5C\n");
|
||||
seabreeze_set_tec_temperature(m_iSpectralmeterHandle, &error, fTemperature);
|
||||
//printf("Set tec temperature result is [%s]\n", get_error_string(error));
|
||||
// printf("Set tec temperature result is [%s]\n", get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//printf("\nSetting TEC enable to true\n");
|
||||
|
||||
// printf("\nSetting TEC enable to true\n");
|
||||
seabreeze_set_tec_enable(m_iSpectralmeterHandle, &error, 1);
|
||||
//printf("Set tec enable result is [%s]\n", get_error_string(error));
|
||||
// printf("Set tec enable result is [%s]\n", get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -307,7 +396,7 @@ int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -315,9 +404,14 @@ int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
int error;
|
||||
|
||||
// usleep(1000000);
|
||||
//printf("\nGetting TEC temperature\n");
|
||||
// printf("\nGetting TEC temperature\n");
|
||||
temp = seabreeze_read_tec_temperature(m_iSpectralmeterHandle, &error);
|
||||
//printf("Read tec temperature result is %1.2f C [%s]\n", temp, get_error_string(error));
|
||||
// printf("Read tec temperature result is %1.2f C [%s]\n", temp, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fTemperature = temp;
|
||||
|
||||
@ -329,7 +423,7 @@ int OceanOptics_lib::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -347,7 +441,7 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//printf("\nNo!!!!!!!!!!!!\n");
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -356,21 +450,34 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
int spec_length;
|
||||
double *wls = 0;
|
||||
|
||||
//printf("\n\nGetting formatted spectrum length.\n");
|
||||
// printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
//printf("Get formatted spectrum length result is (%d) [%s]\n", spec_length, get_error_string(error));
|
||||
// printf("Get formatted spectrum length result is (%d) [%s]\n", spec_length, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Attr.iPixels = spec_length;
|
||||
Attr.iMinIntegrationTimeInMS = 0;
|
||||
|
||||
long minimum_time;
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
Attr.iMinIntegrationTimeInMS = minimum_time;
|
||||
Attr.iMaxIntegrationTimeInMS = 60000;
|
||||
|
||||
if (spec_length > 0) {
|
||||
wls = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
|
||||
//printf("\nGetting wavelengths.\n");
|
||||
// printf("\nGetting wavelengths.\n");
|
||||
flag = seabreeze_get_wavelengths(m_iSpectralmeterHandle, &error, wls, spec_length);
|
||||
//printf("Get wavelengths result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
//printf("\tPixel 20 is wavelength %1.2f nm\n", wls[20]);
|
||||
// printf("Get wavelengths result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("\tPixel 20 is wavelength %1.2f nm\n", wls[20]);
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int tmp = 0; tmp < spec_length; tmp++)
|
||||
{
|
||||
@ -387,15 +494,16 @@ bool OceanOptics_lib::isSuccess(char* resultStr)
|
||||
{
|
||||
if (strstr(resultStr, "Success") == NULL)//<2F><>a<EFBFBD>в<EFBFBD><D0B2><EFBFBD>b<EFBFBD><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>
|
||||
{
|
||||
cout << "not found\n";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return true;
|
||||
//cout << "not found\n";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return false;
|
||||
}
|
||||
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>
|
||||
{
|
||||
cout << "found\n"; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return false;
|
||||
//cout <<"found\n"; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const char* OceanOptics_lib::get_error_string(int error)
|
||||
{
|
||||
static char buffer[32];
|
||||
@ -409,7 +517,13 @@ string OceanOptics_lib::GetDeviceType(int index)
|
||||
int error;
|
||||
|
||||
seabreeze_get_model(index, &error, type, sizeof(type));
|
||||
//printf("...Result is (%s) [%s]\n", type, get_error_string(error));
|
||||
// printf("...Result is (%s) [%s]\n", type, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
type[15] = '\0';
|
||||
|
||||
string deviceType = type;
|
||||
@ -423,12 +537,18 @@ string OceanOptics_lib::GetSerialNumber(int index)
|
||||
int flag;
|
||||
int error;
|
||||
|
||||
//printf("\n\nGetting serial number.\n");
|
||||
// printf("\n\nGetting serial number.\n");
|
||||
flag = seabreeze_get_serial_number(index, &error, serial_number, 32);
|
||||
//printf("Get serial number result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("Get serial number result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
serial_number[31] = '\0';
|
||||
if (flag > 0) {
|
||||
//printf("\tSerial number: [%s]\n", serial_number);
|
||||
printf("\tSerial number: [%s]\n", serial_number);
|
||||
}
|
||||
|
||||
string sn = serial_number;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <ctime>
|
||||
#include "api/SeaBreezeWrapper.h"
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OceanOptics_lib :public CIrisFSBase
|
||||
@ -14,7 +15,7 @@ public:
|
||||
public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值
|
||||
//0为无错误,不同错误请返回不同值(不能确定:当不成功时SeaBreeze返回的错误代码error不为0 → 不敢将error直接返回)
|
||||
int Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName);//ok
|
||||
int Initialize();//ok
|
||||
|
||||
@ -42,6 +43,8 @@ public:
|
||||
//获取设备特征数据
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);//ok
|
||||
|
||||
//tc
|
||||
static const char* get_error_string(int error);
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
@ -49,8 +52,6 @@ private:
|
||||
|
||||
bool isSuccess(char* resultStr);
|
||||
|
||||
static const char* get_error_string(int error);
|
||||
string GetDeviceType(int index);
|
||||
string GetSerialNumber(int index);
|
||||
|
||||
};
|
||||
|
@ -6,11 +6,14 @@
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
#define ZZ_Enum2String(x) #x
|
||||
|
||||
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;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
@ -21,11 +24,13 @@ namespace ZZ_MISCDEF
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U16 usExposureTimeInMS;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
ZZ_S32 lData[4096];
|
||||
float fTemperature = -1000;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
@ -40,6 +45,11 @@ namespace ZZ_MISCDEF
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
|
||||
// inline DataFrame GetIndex(DataFrame dfDark, DataFrame dfSignal)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
@ -51,46 +61,48 @@ namespace ZZ_MISCDEF
|
||||
IS2
|
||||
};
|
||||
|
||||
// inline std::string GetDeviceModelName(int iModel)
|
||||
// {
|
||||
// switch (iModel)
|
||||
// {
|
||||
// case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
// case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
// case DeviceModel::ISIF: return "ISIF"; break;
|
||||
// case DeviceModel::IS1: return "IS1"; break;
|
||||
// case DeviceModel::IS2: return "IS2"; break;
|
||||
// default: return "error"; break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// inline int GetIndex(std::string strDeviceModelName)
|
||||
// {
|
||||
// if (strDeviceModelName== "OSIFAlpha")
|
||||
// {
|
||||
// return DeviceModel::OSIFAlpha;
|
||||
// }
|
||||
// else if (strDeviceModelName == "OSIFBeta")
|
||||
// {
|
||||
// return DeviceModel::OSIFBeta;
|
||||
// }
|
||||
// else if (strDeviceModelName == "ISIF")
|
||||
// {
|
||||
// return DeviceModel::ISIF;
|
||||
// }
|
||||
// else if (strDeviceModelName == "IS1")
|
||||
// {
|
||||
// return DeviceModel::IS1;
|
||||
// }
|
||||
// else if(strDeviceModelName == "IS2")
|
||||
// {
|
||||
// return DeviceModel::IS2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
inline std::string GetDeviceModelName(int iModel)
|
||||
{
|
||||
switch (iModel)
|
||||
{
|
||||
case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
case DeviceModel::ISIF: return "ISIF"; break;
|
||||
case DeviceModel::IS1: return "IS1"; break;
|
||||
case DeviceModel::IS2: return "IS2"; break;
|
||||
default: return "error"; break;
|
||||
}
|
||||
}
|
||||
|
||||
inline int GetIndex(std::string strDeviceModelName)
|
||||
{
|
||||
if (strDeviceModelName == "OSIFAlpha")
|
||||
{
|
||||
return DeviceModel::OSIFAlpha;
|
||||
}
|
||||
else if (strDeviceModelName == "OSIFBeta")
|
||||
{
|
||||
return DeviceModel::OSIFBeta;
|
||||
}
|
||||
else if (strDeviceModelName == "ISIF")
|
||||
{
|
||||
return DeviceModel::ISIF;
|
||||
}
|
||||
else if (strDeviceModelName == "IS1")
|
||||
{
|
||||
return DeviceModel::IS1;
|
||||
}
|
||||
else if (strDeviceModelName == "IS2")
|
||||
{
|
||||
return DeviceModel::IS2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -173,6 +185,11 @@ namespace ZZ_MISCDEF
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
int iInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
long lDepth[MAX_DEVICENUMBER_FS];
|
||||
float fMinFactor[MAX_DEVICENUMBER_FS];
|
||||
float fMaxFactor[MAX_DEVICENUMBER_FS];
|
||||
ZZ_U16 usPixels[MAX_DEVICENUMBER_FS];
|
||||
float fWavelength[MAX_DEVICENUMBER_FS][4096];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
|
@ -49,6 +49,15 @@
|
||||
|
||||
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/UID").arg(i + 1), "Null").toString();
|
||||
m_struDeviceContext.strSN[i] = qstrTemp.toStdString();
|
||||
|
||||
float fAEMax= m_qsDeviceConfig->value(QString("FS%1/AEMax").arg(i + 1), 0.9).toFloat();
|
||||
m_struDeviceContext.fMaxFactor[i] = fAEMax;
|
||||
|
||||
float fAEMin = m_qsDeviceConfig->value(QString("FS%1/AEMin").arg(i + 1), 0.8).toFloat();
|
||||
m_struDeviceContext.fMinFactor[i] = fAEMin;
|
||||
|
||||
long lDepth = m_qsDeviceConfig->value(QString("FS%1/Depth").arg(i + 1), 63219).toInt();
|
||||
m_struDeviceContext.lDepth[i] = lDepth;
|
||||
}
|
||||
|
||||
m_struAcqPosition.iTotalPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/TotalPosition"), -1).toInt();
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "AbstractFSController.h"
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pFSCtrl = NULL;
|
||||
m_iThreadID = -1;
|
||||
m_vecDataFrameDark.clear();
|
||||
m_vecDataFrameSignal.clear();
|
||||
}
|
||||
|
||||
CAbstractFSController::~CAbstractFSController()
|
||||
@ -39,14 +42,15 @@ int CAbstractFSController::InitializeFSControl()
|
||||
qDebug() << "OSIFAlpha Not Opened";
|
||||
return 2;
|
||||
}
|
||||
|
||||
break;
|
||||
case DeviceModel::OSIFBeta:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
// if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) !=0)
|
||||
// {
|
||||
// qDebug() << "OSIFBeta Not Opened";
|
||||
// return 2;
|
||||
// }
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) !=0)
|
||||
{
|
||||
qDebug() << "OSIFBeta Not Opened";
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case DeviceModel::ISIF:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
@ -78,36 +82,212 @@ int CAbstractFSController::InitializeFSControl()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int iRes = m_pFSCtrl->GetDeviceAttribute(m_daDeviceAttr);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "GetDeviceAttribute Failed" << iRes;
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::GetDeviceAttr(DeviceAttribute &daAttr)
|
||||
{
|
||||
daAttr = m_daDeviceAttr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::PerformAutoExposure()
|
||||
{
|
||||
qDebug() << "Starting PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
QThread::msleep(5000);
|
||||
qDebug() << "Stop PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
qDebug() << "--------------------------Starting PerformAutoExposure" << " Thread ID:" << m_iThreadID;
|
||||
using namespace ZZ_MATH;
|
||||
float fPredictedExposureTime;
|
||||
int iDeviceDepth = (int)m_fsInfo.lDepth;
|
||||
|
||||
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;
|
||||
|
||||
//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";
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
{
|
||||
DataFrame dfTemp;
|
||||
|
||||
if (iRepeatCount++ > 30)
|
||||
{
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverTrying = true;
|
||||
break;
|
||||
}
|
||||
//m_pFSCtrl->SetExposureTime(5000);
|
||||
m_pFSCtrl->GetExposureTime(iExposureTime);
|
||||
//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";
|
||||
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)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime / 2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (iDeviceDepth * m_fsInfo.fMaxFactor >= dTemp && dTemp >= iDeviceDepth * m_fsInfo.fMinFactor)
|
||||
{
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * m_fsInfo.fMaxFactor)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
iExposureTime = iExposureTime * 3 / 4;
|
||||
}
|
||||
}
|
||||
else if (dTemp < iDeviceDepth * m_fsInfo.fMinFactor)
|
||||
{
|
||||
bIsValueOverflow = false;
|
||||
if (bIsLastValueOverflow)
|
||||
{
|
||||
iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
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 > 30000)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
float fPredictedExposureTime = 30000;
|
||||
iRes = m_pFSCtrl->SetExposureTime(30000);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec";
|
||||
}
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
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" << " Thread ID:" << m_iThreadID;
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::TakeDarkFrame()
|
||||
{
|
||||
qDebug() << "Starting TakeDarkFrame" << " Thread ID:" << m_iThreadID;
|
||||
QThread::msleep(1000);
|
||||
|
||||
m_vecDataFrameDark.push_back(TakeOneFrame());
|
||||
|
||||
|
||||
qDebug() << "Stop TakeDarkFrame" << " Thread ID:" << m_iThreadID;
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::TakeSignal()
|
||||
int CAbstractFSController::TakeSignalFrame()
|
||||
{
|
||||
qDebug() << "Starting TakeSignal" << " Thread ID:" << m_iThreadID;
|
||||
QThread::msleep(5000);
|
||||
|
||||
m_vecDataFrameSignal.push_back(TakeOneFrame());
|
||||
|
||||
qDebug() << "Stop TakeSignal" << " Thread ID:" << m_iThreadID;
|
||||
//emit SignalAcqFinished(m_iThreadID, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DataFrame CAbstractFSController::TakeOneFrame()
|
||||
{
|
||||
|
||||
DataFrame dfTemp;
|
||||
int iRes = m_pFSCtrl->SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err. SingleShot" << " Thread ID:" << m_iThreadID;
|
||||
}
|
||||
|
||||
return dfTemp;
|
||||
}
|
||||
|
||||
int CAbstractFSController::SaveDataFile()
|
||||
{
|
||||
return 0;
|
||||
@ -122,8 +302,11 @@ int CAbstractFSController::StartAcquisitionSignal()
|
||||
// m_pFSCtrl->SetExposureTime(10000000);
|
||||
// m_pFSCtrl->GetExposureTime(iii);
|
||||
// m_pFSCtrl->SingleShot(struDF);
|
||||
PerformAutoExposure();
|
||||
TakeSignal();
|
||||
|
||||
|
||||
|
||||
//PerformAutoExposure();
|
||||
TakeSignalFrame();
|
||||
|
||||
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
|
||||
emit SignalAcqFinished_Signal(m_iThreadID, 1);
|
||||
@ -145,5 +328,20 @@ int CAbstractFSController::StopAcquisition()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::ClearBuffer()
|
||||
{
|
||||
m_vecDataFrameDark.clear();
|
||||
m_vecDataFrameSignal.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::GetBuffer(std::vector<DataFrame> &pvecDataFrameDark, std::vector<DataFrame> &pvecDataFrameSignal)
|
||||
{
|
||||
for (size_t i=0; i < m_vecDataFrameSignal.size(); i++)
|
||||
{
|
||||
pvecDataFrameSignal.push_back(m_vecDataFrameSignal[i]);
|
||||
pvecDataFrameDark.push_back(m_vecDataFrameDark[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,16 @@
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "OControl_USB.h"
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
|
||||
typedef struct tagFSInfo
|
||||
{
|
||||
ZZ_U8 ucDeviceModel;
|
||||
int iInterface;
|
||||
std::string strSN;
|
||||
long lDepth;
|
||||
float fMinFactor;
|
||||
float fMaxFactor;
|
||||
}FSInfo;
|
||||
|
||||
class CAbstractFSController :public QObject
|
||||
@ -24,24 +28,32 @@ public:
|
||||
//create derived class from base class
|
||||
virtual int InitializeFSControl();
|
||||
|
||||
DataFrame GetLastDataFrame();
|
||||
//sync info
|
||||
virtual int GetDeviceAttr(DeviceAttribute &daAttr);
|
||||
//DataFrame GetLastDataFrame();
|
||||
|
||||
private:
|
||||
CIrisFSBase *m_pFSCtrl;
|
||||
int m_iThreadID;
|
||||
FSInfo m_fsInfo;
|
||||
DataFrame m_dfDark,m_dfSignal;
|
||||
//DataFrame m_dfDark,m_dfSignal;
|
||||
std::vector<DataFrame> m_vecDataFrameDark, m_vecDataFrameSignal;
|
||||
|
||||
DeviceAttribute m_daDeviceAttr;
|
||||
private:
|
||||
int PerformAutoExposure();
|
||||
int TakeDarkFrame();
|
||||
int TakeSignal();
|
||||
int TakeSignalFrame();
|
||||
DataFrame TakeOneFrame();
|
||||
int SaveDataFile();
|
||||
|
||||
public slots:
|
||||
virtual int StartAcquisitionSignal();
|
||||
virtual int StartAcquisitionDark();
|
||||
|
||||
virtual int StopAcquisition();
|
||||
virtual int ClearBuffer();
|
||||
virtual int GetBuffer(std::vector<DataFrame> &pvecDataFrameDark, std::vector<DataFrame> &pvecDataFrameSignal);
|
||||
|
||||
|
||||
signals:
|
||||
void SignalAcqStarted();
|
||||
|
@ -5,7 +5,7 @@ CMainDataGrabber::CMainDataGrabber(QObject* parent /*= nullptr*/)
|
||||
m_piFlagCaptureThreadStatus_Signal = NULL;
|
||||
m_piFlagCaptureThreadStatus_Dark = NULL;
|
||||
|
||||
//m_GrabTimer = new QTimer(this);
|
||||
m_GrabTimer = new QTimer(this);
|
||||
|
||||
m_iFlagIsCapturing = false;
|
||||
m_iFlagIsCapturing_Signal = false;
|
||||
@ -34,11 +34,11 @@ CMainDataGrabber::~CMainDataGrabber()
|
||||
}
|
||||
|
||||
|
||||
// if (m_GrabTimer!=NULL)
|
||||
// {
|
||||
// m_GrabTimer->stop();
|
||||
// delete m_GrabTimer;
|
||||
// }
|
||||
if (m_GrabTimer!=NULL)
|
||||
{
|
||||
m_GrabTimer->stop();
|
||||
delete m_GrabTimer;
|
||||
}
|
||||
}
|
||||
|
||||
void CMainDataGrabber::Delay_MSec(ZZ_U16 usMS)
|
||||
@ -48,6 +48,14 @@ void CMainDataGrabber::Delay_MSec(ZZ_U16 usMS)
|
||||
qeLoop.exec();
|
||||
}
|
||||
|
||||
void CMainDataGrabber::SubDataFrame(DataFrame& dfLeft, DataFrame const dfRight, int iCount)
|
||||
{
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dfLeft.lData[i] = dfLeft.lData[i]- dfRight.lData[i];
|
||||
}
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
||||
{
|
||||
m_struAcqTime = struGrabberRTParams.atsParams;
|
||||
@ -59,6 +67,12 @@ int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetGrabberFileProcessor(DataFileProcessor &dfpSaver)
|
||||
{
|
||||
m_pdfpSaver = &dfpSaver;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitThreadStatus()
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus_Signal!=NULL)
|
||||
@ -95,12 +109,25 @@ int CMainDataGrabber::InitializeWorkers()
|
||||
fsInfo.iInterface = m_struDeviceContext.iInterface[i];
|
||||
fsInfo.ucDeviceModel = m_struDeviceContext.ucDeviceModel[i];
|
||||
fsInfo.strSN = m_struDeviceContext.strSN[i];
|
||||
fsInfo.fMaxFactor = m_struDeviceContext.fMaxFactor[i];
|
||||
fsInfo.fMinFactor = m_struDeviceContext.fMinFactor[i];
|
||||
fsInfo.lDepth = m_struDeviceContext.lDepth[i];
|
||||
|
||||
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_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -131,12 +158,12 @@ int CMainDataGrabber::SetupMsgPipelines()
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished, this, &CMainDataGrabber::GrabOnceFinished);
|
||||
|
||||
//connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalStartGrab, this, &CMainDataGrabber::StartGrabTimer);
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Signal, this, &CMainDataGrabber::GrabOnceFinished_Signal);
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::SignalGrabOnceFinished_Dark);
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::GrabOnceFinished_Dark);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -203,6 +230,8 @@ int CMainDataGrabber::GrabOnceFinished_Dark()
|
||||
|
||||
int CMainDataGrabber::StartGrabTimer()
|
||||
{
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////start
|
||||
////check start time
|
||||
// bool bStopWait = false;
|
||||
@ -215,9 +244,9 @@ int CMainDataGrabber::StartGrabTimer()
|
||||
// }
|
||||
// }
|
||||
|
||||
////start
|
||||
//int iIntervalInMS =m_struAcqTime.qtInterval.hour()*3600*1000+ m_struAcqTime.qtInterval.minute()*60*1000+ m_struAcqTime.qtInterval.second()*1000;
|
||||
//m_GrabTimer->start(iIntervalInMS);
|
||||
//start
|
||||
int iIntervalInMS =m_struAcqTime.qtInterval.hour()*3600*1000+ m_struAcqTime.qtInterval.minute()*60*1000+ m_struAcqTime.qtInterval.second()*1000;
|
||||
m_GrabTimer->start(3000);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
// m_iFlagIsCapturing = true;
|
||||
@ -235,22 +264,39 @@ int CMainDataGrabber::StartGrabTimer()
|
||||
// QThread::msleep(1000);
|
||||
// }
|
||||
// qDebug() << "Allgrab stopped" << " Thread ID:" <<2;
|
||||
emit SignalStartGrabOnce_Signal();
|
||||
m_iFlagIsCapturing = 1;
|
||||
m_iFlagIsCapturing_Signal = 1;
|
||||
|
||||
while (m_iFlagIsCapturing_Signal)
|
||||
{
|
||||
Delay_MSec(200);
|
||||
qDebug() << "msleep" << 200;
|
||||
}
|
||||
qDebug() << "msleep quit";
|
||||
|
||||
////final test code eat my ass
|
||||
// m_iFlagIsCapturing = 1;
|
||||
//
|
||||
//
|
||||
// for (int i=0;i<5;i++)
|
||||
// {
|
||||
// m_iFlagIsCapturing_Signal = 1;
|
||||
// emit SignalStartGrabOnce_Signal();
|
||||
// while (m_iFlagIsCapturing_Signal)
|
||||
// {
|
||||
// Delay_MSec(200);
|
||||
// qDebug() << "msleep" << 200;
|
||||
// }
|
||||
//
|
||||
// m_iFlagIsCapturing_Dark = 1;
|
||||
// emit SignalStartGrabOnce_Dark();
|
||||
// while (m_iFlagIsCapturing_Dark)
|
||||
// {
|
||||
// Delay_MSec(200);
|
||||
// qDebug() << "msleep" << 200;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// qDebug() << "for quit";
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::GrabOnceFinished()
|
||||
{
|
||||
//m_iFlagIsCapturing = false;
|
||||
m_iFlagIsCapturing = false;
|
||||
// QTimer t;
|
||||
// t.start();
|
||||
// while (1)
|
||||
@ -261,17 +307,97 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int CMainDataGrabber::OnTimeCounter()
|
||||
// {
|
||||
//
|
||||
// if (m_iFlagIsCapturing)
|
||||
// {
|
||||
// qDebug() << "busy";
|
||||
// return 0;
|
||||
// }
|
||||
// m_iFlagIsCapturing = true;
|
||||
//
|
||||
// emit SignalGrabOnceFinished();
|
||||
// return 0;
|
||||
// }
|
||||
int CMainDataGrabber::OnTimeCounter()
|
||||
{
|
||||
if (m_iFlagIsCapturing)
|
||||
{
|
||||
qDebug() << "Fatal Thread Err.";
|
||||
return 1000;
|
||||
}
|
||||
m_iFlagIsCapturing = 1;
|
||||
|
||||
m_struAcqPosSetting.iTotalPosition = 5;
|
||||
|
||||
//m_pdfpSaver->WriteDataFile();
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
m_pControlThread[i]->ClearBuffer();
|
||||
}
|
||||
|
||||
for (int i=0;i< m_struAcqPosSetting.iTotalPosition-1;i++)
|
||||
{
|
||||
////move to
|
||||
m_struAcqPosSetting.iPosition[i + 1];
|
||||
m_iFlagIsCapturing_Signal = 1;
|
||||
emit SignalStartGrabOnce_Signal();
|
||||
while (m_iFlagIsCapturing_Signal)
|
||||
{
|
||||
Delay_MSec(1000);
|
||||
}
|
||||
|
||||
|
||||
////move to
|
||||
m_struAcqPosSetting.iPosition[0];
|
||||
m_iFlagIsCapturing_Dark = 1;
|
||||
emit SignalStartGrabOnce_Dark();
|
||||
while (m_iFlagIsCapturing_Dark)
|
||||
{
|
||||
Delay_MSec(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<std::vector<DataFrame>> vecData;
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
std::vector<DataFrame> vecDark, vecSignal, vecResult;
|
||||
m_pControlThread[i]->GetBuffer(vecDark, vecSignal);
|
||||
for (size_t j=0;j< vecDark.size();j++)
|
||||
{
|
||||
SubDataFrame(vecSignal[j], vecDark[j], m_struDeviceContext.usPixels[i]);
|
||||
}
|
||||
vecData.push_back(vecSignal);
|
||||
}
|
||||
m_pdfpSaver->SetData(vecData);
|
||||
m_pdfpSaver->WriteDataFile();
|
||||
// qDebug() << "-------------------------------------------busy" << QTime::currentTime().toString();
|
||||
// QThread::msleep(5000);
|
||||
// return 0;
|
||||
// if (m_iFlagIsCapturing)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// m_iFlagIsCapturing = 1;
|
||||
//qDebug() << "-------------------------------------------return";
|
||||
//return 1;
|
||||
// for (int i = 0; i < 5; i++)
|
||||
// {
|
||||
// m_iFlagIsCapturing_Signal = 1;
|
||||
// emit SignalStartGrabOnce_Signal();
|
||||
// while (m_iFlagIsCapturing_Signal)
|
||||
// {
|
||||
// //Delay_MSec(1000);
|
||||
// QThread::msleep(100);
|
||||
// QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
// //qDebug() << "msleep" << 1000;
|
||||
// }
|
||||
//
|
||||
// m_iFlagIsCapturing_Dark = 1;
|
||||
// emit SignalStartGrabOnce_Dark();
|
||||
// while (m_iFlagIsCapturing_Dark)
|
||||
// {
|
||||
// Delay_MSec(1000);
|
||||
// QThread::msleep(100);
|
||||
// QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
// //qDebug() << "msleep" << 1000;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// qDebug() << "for quit";
|
||||
//
|
||||
//
|
||||
// emit SignalGrabOnceFinished();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include"pch.h"
|
||||
#include <vector>
|
||||
#include "AbstractFSController.h"
|
||||
#include "DataFileProcessor.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
@ -26,19 +27,22 @@ private:
|
||||
int m_iFlagIsCapturing_Signal;
|
||||
int m_iFlagIsCapturing_Dark;
|
||||
|
||||
|
||||
DataFileProcessor* m_pdfpSaver;
|
||||
|
||||
FSContext m_struDeviceContext;
|
||||
LSContext m_struLinearShutterContext;
|
||||
AcqPosSettings m_struAcqPosSetting;
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
|
||||
|
||||
//QTimer *m_GrabTimer;
|
||||
QTimer *m_GrabTimer;
|
||||
private:
|
||||
void Delay_MSec(ZZ_U16 usMS);
|
||||
void SubDataFrame(DataFrame& dfLeft, DataFrame const dfRight,int iCount);
|
||||
public:
|
||||
//Call this first
|
||||
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
||||
int SetGrabberFileProcessor(DataFileProcessor &dfpSaver);
|
||||
|
||||
int InitThreadStatus();
|
||||
int InitializeWorkers();
|
||||
@ -49,7 +53,7 @@ public:
|
||||
|
||||
public slots:
|
||||
int StartGrabTimer();
|
||||
//int OnTimeCounter();
|
||||
int OnTimeCounter();
|
||||
|
||||
int HandleThreadEvent_Signal(int iThreadID, int iFlagStatus);
|
||||
int HandleThreadEvent_Dark(int iThreadID, int iFlagStatus);
|
||||
|
Reference in New Issue
Block a user