mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-20 19:59:42 +08:00
添加了calibration first
This commit is contained in:
186
othersoft/calibration_console/Source_Files/atpFiberImager.cpp
Normal file
186
othersoft/calibration_console/Source_Files/atpFiberImager.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
#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();
|
||||
|
||||
m_FiberSpectrometer->Initialize(false, mUcPortNumber, "ocean_optics");
|
||||
|
||||
DeviceInfo deviceInfo;//
|
||||
DeviceAttribute deviceAttribute;
|
||||
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ATPFiberImager::recordDark(QString path)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
//<2F>ɼ<EFBFBD><C9BC><EFBFBD>֡
|
||||
singleShot(m_DarkData);
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral.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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral.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();
|
||||
}
|
||||
|
||||
void ATPFiberImager::autoExpose()
|
||||
{
|
||||
float fPredictedExposureTime;
|
||||
m_FiberSpectrometer->PerformAutoExposure(0.7,0.8,fPredictedExposureTime);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user