2022-01-14 14:26:03 +08:00
|
|
|
|
#include "Header_Files/atpFiberImager.h"
|
|
|
|
|
|
|
|
|
|
ATPFiberImager::ATPFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer = NULL;
|
|
|
|
|
|
|
|
|
|
mUcPortNumber=ucPortNumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ATPFiberImager::~ATPFiberImager()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::connectFiberSpectrometer(QString& SN, QString& pixelCount, QString& wavelengthInfo)
|
|
|
|
|
{
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
m_FiberSpectrometer = new ZZ_ATPControl_Serial_Qt();
|
|
|
|
|
|
2022-04-21 14:00:45 +08:00
|
|
|
|
m_FiberSpectrometer->Initialize(false, mUcPortNumber, "OPTOSKY");
|
2022-01-14 14:26:03 +08:00
|
|
|
|
|
|
|
|
|
DeviceInfo deviceInfo;//
|
|
|
|
|
DeviceAttribute deviceAttribute;
|
|
|
|
|
|
|
|
|
|
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
2022-04-21 14:00:45 +08:00
|
|
|
|
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-01-14 14:26:03 +08:00
|
|
|
|
|
|
|
|
|
SN = QString::fromStdString(deviceInfo.strSN);
|
|
|
|
|
pixelCount = QString::number(deviceAttribute.iPixels);
|
|
|
|
|
wavelengthInfo = QString::number(deviceAttribute.fWaveLengthInNM[0]) + "--" + QString::number(deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1]);
|
|
|
|
|
|
|
|
|
|
m_FiberSpectrometer->SetDeviceTemperature(-10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>
|
|
|
|
|
string qepro = "QEP";//?????????????????????????????????????????????????????????????????????????????????????????
|
|
|
|
|
string flame = "FLMS";//?????????????????????????????????????????????????????????????????????????????????????????
|
|
|
|
|
if (deviceInfo.strSN.find(qepro) != string::npos)
|
|
|
|
|
{
|
|
|
|
|
m_MaxValueOfFiberSpectrometer = 200000;
|
|
|
|
|
}
|
|
|
|
|
else if (deviceInfo.strSN.find(flame) != string::npos)
|
|
|
|
|
{
|
|
|
|
|
m_MaxValueOfFiberSpectrometer = 65535;
|
|
|
|
|
}
|
|
|
|
|
else//û<><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::disconnectFiberSpectrometer()
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::getDeviceAttribute(DeviceAttribute& deviceAttribute)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::getDeviceInfo(DeviceInfo& deviceInfo)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::setExposureTime(int iExposureTimeInMS)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->SetExposureTime(iExposureTimeInMS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::getExposureTime(int &iExposureTimeInMS)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->GetExposureTime(iExposureTimeInMS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::getDeviceTemperature(float &fTemperature)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->GetDeviceTemperature(fTemperature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::singleShot(DataFrame &dfData)
|
|
|
|
|
{
|
|
|
|
|
m_FiberSpectrometer->SingleShot(dfData);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 14:00:45 +08:00
|
|
|
|
void ATPFiberImager::getNonlinearityCoeffs(coeffsFrame &coeffs)
|
|
|
|
|
{
|
|
|
|
|
printf("This is ATPFiberImager.\n");
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 14:26:03 +08:00
|
|
|
|
void ATPFiberImager::recordDark(QString path)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
|
|
|
|
DeviceAttribute attribute;
|
|
|
|
|
DeviceInfo deviceInfo;
|
|
|
|
|
getDeviceAttribute(attribute);
|
|
|
|
|
getDeviceInfo(deviceInfo);
|
|
|
|
|
|
|
|
|
|
//<2F>ɼ<EFBFBD><C9BC><EFBFBD>֡
|
|
|
|
|
singleShot(m_DarkData);
|
|
|
|
|
|
2022-10-12 13:13:13 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
|
|
|
|
QDateTime curDateTime = QDateTime::currentDateTime();
|
|
|
|
|
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
|
|
|
|
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral_dn.csv";
|
|
|
|
|
std::ofstream outfile(fileName.toStdString().c_str());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < attribute.iPixels; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i==0)
|
|
|
|
|
{
|
|
|
|
|
outfile << m_DarkData.usExposureTimeInMS << std::endl;
|
|
|
|
|
}
|
|
|
|
|
outfile << attribute.fWaveLengthInNM[i] << "," << m_DarkData.lData[i] << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outfile.close();
|
2022-01-14 14:26:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::recordTarget(int recordTimes, QString path)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
|
|
|
|
DeviceAttribute attribute;
|
|
|
|
|
DeviceInfo deviceInfo;
|
|
|
|
|
getDeviceAttribute(attribute);
|
|
|
|
|
getDeviceInfo(deviceInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DataFrame integratingSphereData_tmp;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < recordTimes; i++)
|
|
|
|
|
{
|
|
|
|
|
singleShot(integratingSphereData_tmp);
|
|
|
|
|
|
|
|
|
|
if (i == 0)//<2F><>integratingSphereData_tmp<6D>е<EFBFBD><D0B5>ع<EFBFBD>ʱ<EFBFBD>䡢<EFBFBD>¶ȵ<C2B6><C8B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>m_IntegratingSphereData
|
|
|
|
|
{
|
|
|
|
|
m_IntegratingSphereData = integratingSphereData_tmp;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < attribute.iPixels; i++)
|
|
|
|
|
{
|
|
|
|
|
m_IntegratingSphereData.lData[i] += integratingSphereData_tmp.lData[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < attribute.iPixels; i++)
|
|
|
|
|
{
|
|
|
|
|
m_IntegratingSphereData.lData[i] = m_IntegratingSphereData.lData[i] / recordTimes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-12 13:13:13 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
|
|
|
|
QDateTime curDateTime = QDateTime::currentDateTime();
|
|
|
|
|
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
|
|
|
|
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral_dn.csv";
|
|
|
|
|
std::ofstream outfile(fileName.toStdString().c_str());
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < attribute.iPixels; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i==0)
|
|
|
|
|
{
|
|
|
|
|
outfile << m_IntegratingSphereData.usExposureTimeInMS << std::endl;
|
|
|
|
|
}
|
|
|
|
|
outfile << attribute.fWaveLengthInNM[i] << "," << m_IntegratingSphereData.lData[i] << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outfile.close();
|
2022-01-14 14:26:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ATPFiberImager::autoExpose()
|
|
|
|
|
{
|
|
|
|
|
float fPredictedExposureTime;
|
2022-04-29 17:10:40 +08:00
|
|
|
|
m_FiberSpectrometer->PerformAutoExposure(0.6,0.9,fPredictedExposureTime);
|
2022-01-14 14:26:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZZ_S32 ATPFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
|
|
|
|
{
|
|
|
|
|
ZZ_S32 max = 0;
|
|
|
|
|
for (size_t i = 0; i < number; i++)
|
|
|
|
|
{
|
|
|
|
|
if (dark[i] > max)
|
|
|
|
|
{
|
|
|
|
|
max = dark[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
|
|
|
|
return max;
|
|
|
|
|
}
|