first commnit
This commit is contained in:
882
source/FS/ATPControl_Serial_QT.cpp
Normal file
882
source/FS/ATPControl_Serial_QT.cpp
Normal file
@ -0,0 +1,882 @@
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
m_iBaudRate = 115200;
|
||||
//emit SignalInit_Self();
|
||||
}
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
|
||||
{
|
||||
if (m_pSerialPort != NULL)
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::ReInit()
|
||||
// {
|
||||
// m_pSerialPort->close();
|
||||
// delete m_pSerialPort;
|
||||
//
|
||||
// m_pSerialPort = new QSerialPort;
|
||||
//
|
||||
// m_pSerialPort->setPortName("COM7");
|
||||
// m_pSerialPort->setReadBufferSize(512);
|
||||
// bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
|
||||
// bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
// }
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::SetBaudRate(int iBaud)
|
||||
// {
|
||||
// m_iBaudRate = iBaud;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
//connect(this, &ZZ_ATPControl_Serial_Qt::SignalInit_Self, this, &ZZ_ATPControl_Serial_Qt::Init_Self);
|
||||
//emit SignalInit_Self();
|
||||
|
||||
QString qstrPortName = QString::fromStdString(ucPortNumber);
|
||||
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "Err:setBaudRate Failed.Exit Code:1";
|
||||
//std::cout << "Err.setBaudRate Failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "Err:open Failed.Exit Code:2";
|
||||
//std::cout << "Err.open Failed" << std::endl;
|
||||
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)
|
||||
{
|
||||
qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZZ_ATPControl_Serial_Qt::Close()
|
||||
{
|
||||
m_pSerialPort->close();
|
||||
}
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_PN_NUMBER);
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
m_diDeviceInfo.strPN = qbRecv.data();
|
||||
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_SN_NUMBER);
|
||||
iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
m_diDeviceInfo.strSN = qbRecv.data();
|
||||
|
||||
|
||||
Info = m_diDeviceInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_MIN_INTEGRATION_TIME);
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
m_daDeviceAttr.iMinIntegrationTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_MAX_INTEGRATION_TIME);
|
||||
iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
iRes = SingleShot(m_daDeviceAttr.iPixels);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Call SingleShot error.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
SetExposureTime(iTempExpTime);
|
||||
///
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_WAVELENGTH_CALIBRATION_COEF);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
float fWaveLengthCoef[4];
|
||||
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;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_pSerialPort->clear();
|
||||
|
||||
int iSize = qbCommand.size() + 3;
|
||||
QByteArray qbSend;
|
||||
qbSend.resize(4);
|
||||
qbSend[0] = (ZZ_U8)0xAA;
|
||||
qbSend[1] = 0x55;
|
||||
qbSend[2] = iSize / 256;
|
||||
qbSend[3] = iSize % 256;
|
||||
qbSend.append(qbCommand);
|
||||
|
||||
int iSum = 0;
|
||||
for (int i = 0; i < iSize - 1; i++)
|
||||
{
|
||||
iSum = iSum + qbSend[i + 2];
|
||||
}
|
||||
|
||||
qbSend.append(iSum % 256);
|
||||
|
||||
qint64 qi64Write = m_pSerialPort->write(qbSend);
|
||||
if (qi64Write != qbSend.size())
|
||||
{
|
||||
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
|
||||
{
|
||||
|
||||
qbData.clear();
|
||||
qbData = m_pSerialPort->readAll();
|
||||
|
||||
int iCounter = 0;
|
||||
while (qbData.size() < 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(5000);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 150)
|
||||
{
|
||||
qDebug() << "Err:RecvData 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 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(5000);
|
||||
qbData.append(m_pSerialPort->readAll());
|
||||
|
||||
if (iCounter > 200)
|
||||
{
|
||||
qDebug() << "Err:RecvData 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 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;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
|
||||
{
|
||||
if (qbData.size() < 6)
|
||||
{
|
||||
qDebug() << "Err:ParseData Failed,Not Enough Data.Exit Code:1" << qbData.size();
|
||||
return 1;
|
||||
}
|
||||
qbData.remove(0, 5);
|
||||
qbData.remove(qbData.size() - 1, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::Init_Self()
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime)
|
||||
{
|
||||
using namespace ZZ_MATH;
|
||||
int iDeviceDepth = 65535;
|
||||
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
bool bFlagIsOverMaxExposureTime = false;
|
||||
bool bFlagIsAutoExposureOK = false;
|
||||
bool bFlagIsAutoExposureFailed = false;
|
||||
|
||||
bool bIsValueOverflow = false;
|
||||
bool bIsLastValueOverflow = false;
|
||||
|
||||
float fExposureTime = 0;
|
||||
float fTempExposureTime = 0;
|
||||
double fLastExposureTime = 0.1;
|
||||
int iRepeatCount = 0;
|
||||
|
||||
int iRes = SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS);//need change to load from files
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
|
||||
{
|
||||
DataFrame dfTemp;
|
||||
|
||||
if (iRepeatCount++ > 30)
|
||||
{
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsOverTrying = true;
|
||||
qDebug() << "over 30 Times" << endl;
|
||||
break;
|
||||
}
|
||||
|
||||
//fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
int fTemp;
|
||||
GetExposureTime(fTemp);
|
||||
fExposureTime = fTemp;
|
||||
fTempExposureTime = fExposureTime;
|
||||
|
||||
iRes = 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)
|
||||
{
|
||||
fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
fExposureTime = fExposureTime / 2;
|
||||
}
|
||||
}
|
||||
|
||||
else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * fMaxScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
if (!bIsLastValueOverflow)
|
||||
{
|
||||
fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
fExposureTime = fExposureTime * 3 / 4;
|
||||
}
|
||||
}
|
||||
else if (dTemp < iDeviceDepth * fMinScaleFactor)
|
||||
{
|
||||
bIsValueOverflow = false;
|
||||
if (bIsLastValueOverflow)
|
||||
{
|
||||
fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dFactor;
|
||||
dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor);
|
||||
fExposureTime = (float)(fExposureTime / dFactor);
|
||||
}
|
||||
if (fExposureTime < m_daDeviceAttr.iMinIntegrationTimeInMS)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
qDebug() << "lower than minimum" << endl;
|
||||
|
||||
}
|
||||
}
|
||||
bIsLastValueOverflow = bIsValueOverflow;
|
||||
fLastExposureTime = fTempExposureTime;
|
||||
|
||||
if (fExposureTime > 13000)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
fPredictedExposureTime = 13000;
|
||||
iRes = SetExposureTime(13000);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
bFlagIsOverMaxExposureTime = true;
|
||||
break;
|
||||
}
|
||||
|
||||
iRes = SetExposureTime((int)fExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4";
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
fPredictedExposureTime = fExposureTime;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::SetExtShutter(int iShutterUP0, int iShutterDOWN1, int iShutterDOWN2, int iShutterDOWN3)
|
||||
// {
|
||||
// qDebug() << "stub code not implemented";
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
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;
|
||||
|
||||
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";
|
||||
/*m_pSerialPort->waitForReadyRead(5000);
|
||||
m_pSerialPort->clear();*/
|
||||
//return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(SYNC_GET_DATA);
|
||||
qbSend.resize(3);
|
||||
// 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 };
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//int aaa = qbRecv.size();
|
||||
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
|
||||
memcpy(usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||
for (size_t i = 0; i < iDataSizeInPixel; 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;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(SYNC_GET_DATA);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
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:SingleShotP Failed.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
iPixels = (qbRecv.size() - 1) / 2;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::SingleShotDark(ATPDataFrame &dfData)
|
||||
// {
|
||||
// SetExtShutter(0,0,0,0);
|
||||
// SingleShot(dfData);
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
fTemperature = 0;
|
||||
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_TEC_TEMP);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
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;
|
||||
}
|
||||
|
||||
//void ZZ_ATPControl_Serial_Qt::ReadMessage()
|
||||
//{
|
||||
// QByteArray qbTemp, qbTemp1;
|
||||
// qbTemp = m_pSerialPort->readAll();
|
||||
// while (qbTemp.size()<2)
|
||||
// {
|
||||
// m_pSerialPort->waitForReadyRead(50);
|
||||
// qbTemp1 = m_pSerialPort->readAll();
|
||||
// qbTemp.append(qbTemp1);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//return;
|
||||
// }
|
97
source/FS/ATPControl_Serial_QT.h
Normal file
97
source/FS/ATPControl_Serial_QT.h
Normal file
@ -0,0 +1,97 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//ATP<54><50><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::ATP;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class ZZ_ATPControl_Serial_Qt:public CIrisFSBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_ATPControl_Serial_Qt(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ATPControl_Serial_Qt();
|
||||
|
||||
public:
|
||||
//do not call
|
||||
//int ReInit();
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
//<2F><><EFBFBD>β<EFBFBD><CEB2>Բɼ<D4B2> <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SingleShot(int &iPixels);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||||
//int SingleShotDark(ATPDataFrame &dfData);
|
||||
|
||||
//int SingleShotDeducted(ATPDataFrame &dfData);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetExposureTime(int &iExposureTimeInMS);
|
||||
|
||||
//int GetWaveLength(float *pfWaveLength);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int GetDeviceInfo(DeviceInfo &Info);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);
|
||||
|
||||
//int GetDeviceListInfo(); //use type name to enum
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD>
|
||||
int GetDeviceTemperature(float &fTemperature);
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime);
|
||||
private:
|
||||
int SetAvgTimes(int iTimes = 1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
#else //
|
||||
private:
|
||||
#endif
|
||||
//port
|
||||
int m_iBaudRate;
|
||||
QSerialPort *m_pSerialPort;
|
||||
|
||||
//ATP
|
||||
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();
|
||||
signals:
|
||||
void SignalInit_Self();
|
||||
//private slots :
|
||||
//void ReadMessage();
|
||||
};
|
260
source/FS/DataFileProcessor.cpp
Normal file
260
source/FS/DataFileProcessor.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
#include "DataFileProcessor.h"
|
||||
|
||||
DataFileProcessor::DataFileProcessor(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
|
||||
#else
|
||||
m_qstrFilePath = "/home/data/Data";
|
||||
#endif // DEBUG
|
||||
|
||||
}
|
||||
|
||||
DataFileProcessor::~DataFileProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
void DataFileProcessor::SetEnvironmentContex(EContext struEC)
|
||||
{
|
||||
m_struEC = struEC;
|
||||
}
|
||||
|
||||
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();
|
||||
WriteEnvironmentInfo();
|
||||
WriteDeviceInfo();
|
||||
WriteData();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void DataFileProcessor::GenerateFilePath()
|
||||
{
|
||||
m_qdtTime = QDateTime::currentDateTime();
|
||||
QString qstrAddYMD = m_qdtTime.toString("/yyyy_MM_dd");
|
||||
QString qstrAddHMS = m_qdtTime.toString("_hh_mm_ss");
|
||||
|
||||
m_struEC.qstrUTCDateTime = m_qdtTime.toUTC().toString("yyyy_MM_dd hh:mm:ss");
|
||||
|
||||
m_qstrFullFileName = m_qstrFilePath + qstrAddYMD;
|
||||
QString qstrTemp= m_qstrFullFileName;
|
||||
if (m_struEC.qstrLocation=="")
|
||||
{
|
||||
m_struEC.qstrLocation = "Unknown";
|
||||
}
|
||||
m_qstrFullFileName= m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".csv";
|
||||
|
||||
QDir qdirPath(qstrTemp);
|
||||
if (!qdirPath.exists())
|
||||
{
|
||||
bool bRes = qdirPath.mkpath(qstrTemp);//20220812 mkdir change to mkpath
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "DataFileProcessor mkdir Failed.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteEnvironmentInfo()
|
||||
{
|
||||
bool bRes = true;
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
bRes = qfData.open(QFile::WriteOnly|QFile::Text|QFile::Truncate);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "WriteEnvironmentInfo open Failed.";
|
||||
return bRes;
|
||||
}
|
||||
qDebug() << m_qstrFullFileName;
|
||||
//EC
|
||||
qfData.write("EnvironmentalContext,");
|
||||
qfData.write("DEV_SN,");
|
||||
qfData.write(m_struEC.qstrDEV_SN.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("CaseHumidity,");
|
||||
qfData.write(m_struEC.qstrCaseHumidity.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("CaseTemperature,");
|
||||
qfData.write(m_struEC.qstrCaseTemperature.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("GPS_Altitude,");
|
||||
qfData.write(m_struEC.qstrGPS_Altitude.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("GPS_Latitude,");
|
||||
qfData.write(m_struEC.qstrGPS_Latitude.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("GPS_Longtitude,");
|
||||
qfData.write(m_struEC.qstrGPS_Longtitude.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("GPS_North,");
|
||||
qfData.write(m_struEC.qstrGPS_North.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("Location,");
|
||||
qfData.write(m_struEC.qstrLocation.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("UTCDateTime,");
|
||||
qfData.write(m_struEC.qstrUTCDateTime.toLatin1());
|
||||
qfData.write(",");
|
||||
//qfData.write("\n");
|
||||
|
||||
//MEC
|
||||
//qfData.write("ManmadeEnvironmentalContext\n");
|
||||
qfData.write("DownlaodAddress,");
|
||||
qfData.write(m_struMEC.qstrDownlaodAddress.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("DownloadUserID,");
|
||||
qfData.write(m_struMEC.qstrDownloadUserID.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("HTTPServer,");
|
||||
qfData.write(m_struMEC.qstrHTTPServer.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("InstallationTime,");
|
||||
qfData.write(m_struMEC.qstrInstallationTime.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("NameOfMaintenanceStaff,");
|
||||
qfData.write(m_struMEC.qstrNameOfMaintenanceStaff.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("PhoneNumberOfMaintenanceStaff,");
|
||||
qfData.write(m_struMEC.qstrPhoneNumberOfMaintenanceStaff.toLatin1());
|
||||
//qfData.write(",");
|
||||
|
||||
qfData.close();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
void DataFileProcessor::WriteDeviceInfo()
|
||||
{
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
bool bRes = qfData.open(QFile::WriteOnly | QFile::Text | QIODevice::Append);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "WriteDeviceInfo open Failed.";
|
||||
return;
|
||||
}
|
||||
QString qstrTemp;
|
||||
|
||||
qfData.write("\n");
|
||||
qfData.write("TotalSpectrometer,");
|
||||
qstrTemp = QString::number(m_struDeviceContext.ucDeviceNumber);
|
||||
qfData.write(qstrTemp.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("TotalScanPoints,");
|
||||
qstrTemp = QString::number(m_vecData[0].size());
|
||||
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(",");
|
||||
|
||||
qfData.write("TEC Temperature,");
|
||||
qstrTemp = QString::number(m_vecData[i][0].fTemperature);
|
||||
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);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "WriteData open Failed.";
|
||||
return 0;
|
||||
}
|
||||
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(",");
|
||||
if ((m_vecData[i][j].fTemperature < 5) /*&& (m_vecData[i][j].fTemperature> -5)*/)
|
||||
{
|
||||
qfData.write("valid");
|
||||
}
|
||||
else
|
||||
{
|
||||
qfData.write("invalid");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
39
source/FS/DataFileProcessor.h
Normal file
39
source/FS/DataFileProcessor.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#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 QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataFileProcessor(QObject* parent = nullptr);
|
||||
virtual ~DataFileProcessor();
|
||||
public:
|
||||
public:
|
||||
void SetEnvironmentContex(EContext struEC);
|
||||
void SetManmadeEnviromentalContext(MEContext struMEC);
|
||||
void SetDeviceInfo(FSContext struDeviceContext);
|
||||
void SetData(std::vector<std::vector<DataFrame>> vecData);
|
||||
bool WriteDataFile();
|
||||
private:
|
||||
void GenerateFilePath();
|
||||
bool WriteEnvironmentInfo();
|
||||
void WriteDeviceInfo();
|
||||
bool WriteData();
|
||||
|
||||
|
||||
public:
|
||||
private:
|
||||
QString m_qstrFullFileName;
|
||||
QString m_qstrFileName;
|
||||
QString m_qstrFilePath;
|
||||
|
||||
QDateTime m_qdtTime;
|
||||
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
FSContext m_struDeviceContext;
|
||||
std::vector<std::vector<DataFrame>> m_vecData;
|
||||
};
|
45
source/FS/IrisFiberSpectrometerBase.h
Normal file
45
source/FS/IrisFiberSpectrometerBase.h
Normal file
@ -0,0 +1,45 @@
|
||||
#include <string>
|
||||
#include "ZZ_Types.h"
|
||||
#include "pch.h"
|
||||
#pragma once
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class CIrisFSBase:public QObject
|
||||
{
|
||||
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>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode, std::string ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
virtual int SingleShot(DataFrame &dfData) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
virtual int SetExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
virtual int SetDeviceTemperature(float fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
|
||||
|
||||
};
|
559
source/FS/OControl_USB.cpp
Normal file
559
source/FS/OControl_USB.cpp
Normal file
@ -0,0 +1,559 @@
|
||||
#include "OControl_USB.h"
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
OceanOptics_lib::OceanOptics_lib()
|
||||
{
|
||||
m_iSpectralmeterHandle = -100;
|
||||
}
|
||||
|
||||
OceanOptics_lib::~OceanOptics_lib()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/SeaBreezeWrapper.h"
|
||||
int OceanOptics_lib::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
//char type[16];
|
||||
int device_count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; 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)
|
||||
{
|
||||
device_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string sn = GetSerialNumber(i);
|
||||
|
||||
if (strcmp(sn.c_str(), strDeviceName.c_str()) == 0)
|
||||
{
|
||||
m_iSpectralmeterHandle = i;
|
||||
// printf("\nfind!!!!!!!!!!!!\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
// printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
|
||||
|
||||
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 / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/SeaBreezeWrapper.h"
|
||||
int OceanOptics_lib::Initialize()
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
//char type[16];
|
||||
int device_count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; 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)
|
||||
{
|
||||
m_iSpectralmeterHandle = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
//int OceanOptics_lib::Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName)
|
||||
//{
|
||||
// int number_of_devices;
|
||||
// long *device_ids;
|
||||
// int i;
|
||||
// int flag;
|
||||
// int error = 0;
|
||||
// char nameBuffer[80];
|
||||
// char *serialNumber;
|
||||
//
|
||||
//
|
||||
//// /* Give the driver a chance to initialize itself */
|
||||
//// sbapi_initialize();
|
||||
//
|
||||
// printf("Probing for devices...\n"); fflush(stdout);
|
||||
// sbapi_probe_devices();
|
||||
//
|
||||
// printf("Getting device count...\n"); fflush(stdout);
|
||||
// number_of_devices = sbapi_get_number_of_device_ids();
|
||||
// std::cout<<"Device count is "<< number_of_devices <<std::endl;
|
||||
// if(0 == number_of_devices) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// printf("Getting device IDs...\n");
|
||||
// device_ids = (long *)calloc(number_of_devices, sizeof(long));
|
||||
// number_of_devices = sbapi_get_device_ids(device_ids, number_of_devices);
|
||||
// printf("Got %d device ID%s.\n", number_of_devices, number_of_devices == 1 ? "" : "s"); fflush(stdout);
|
||||
//
|
||||
//
|
||||
// for(i = 0; i < number_of_devices; i++)
|
||||
// {
|
||||
// printf("%d: Device 0x%02lX:\n", i, device_ids[i]);
|
||||
//// printf("\tGetting device type...\n");
|
||||
// flag = sbapi_get_device_type(device_ids[i], &error, nameBuffer, 79);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
// if(flag > 0) {
|
||||
// printf("\tDevice type: [%s]\n", nameBuffer);
|
||||
// }
|
||||
//
|
||||
// serialNumber = GetSerialNumber(device_ids[i]);
|
||||
// serialNumber = GetSerialNumber(device_ids[i]);
|
||||
//
|
||||
// printf("\tSerial number tc: [%s]\n", serialNumber);
|
||||
//
|
||||
//// /* Open the device */
|
||||
//// printf("\tAttempting to open:\n");
|
||||
//// flag = sbapi_open_device(device_ids[i], &error);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
////
|
||||
//// // jump to the next iteration if there was a problem
|
||||
//// if(flag != 0) {
|
||||
//// continue;
|
||||
//// }
|
||||
////
|
||||
//// // log deviations
|
||||
//// unsupportedFeatureCount=0;
|
||||
//// testFailureCount=0;
|
||||
////
|
||||
//// /* Test the device */
|
||||
//// for(test_index = 0; test_index < __test_function_count; test_index++) {
|
||||
//// /* Invoke each of the test functions against this device */
|
||||
//// __test_functions[test_index](device_ids[i], &unsupportedFeatureCount, &testFailureCount);
|
||||
//// }
|
||||
////
|
||||
//// /* Close the device */
|
||||
//// printf("\tAttempting to close:\n");
|
||||
//// sbapi_close_device(device_ids[i], &error);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
//// printf("%d: Device 0x%02lX: \n\tNumber of unsupported features = %d\n\tNumber of test failures = %d\n", i, device_ids[i], unsupportedFeatureCount, testFailureCount);
|
||||
// }
|
||||
//
|
||||
// flag = sbapi_get_device_type(device_ids[i], &error, nameBuffer, 79);
|
||||
//
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void OceanOptics_lib::Close()
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
|
||||
flag = seabreeze_close_spectrometer(m_iSpectralmeterHandle, &error);
|
||||
// printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
int flag;
|
||||
int spec_length;
|
||||
double *spectrum = 0;
|
||||
bool ret;
|
||||
|
||||
// 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));
|
||||
|
||||
|
||||
|
||||
seabreeze_clear_buffer(m_iSpectralmeterHandle, &error);
|
||||
|
||||
|
||||
|
||||
|
||||
printf("\nGetting a formatted spectrum.\n");
|
||||
flag = seabreeze_get_formatted_spectrum(m_iSpectralmeterHandle, &error, spectrum, spec_length);
|
||||
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.lData[tmp] = spectrum[tmp];
|
||||
}
|
||||
|
||||
int exposureTimeInMS;
|
||||
GetExposureTime(exposureTimeInMS);
|
||||
dfData.usExposureTimeInMS = exposureTimeInMS;
|
||||
|
||||
float temperature;
|
||||
GetDeviceTemperature(temperature);
|
||||
dfData.fTemperature = temperature;
|
||||
|
||||
free(spectrum);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int OceanOptics_lib::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int 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;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
iExposureTimeInMS = m_iExposureTime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
// 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));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// 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));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
fTemperature = 0;
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
double temp;
|
||||
int error;
|
||||
|
||||
// usleep(1000000);
|
||||
// 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));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fTemperature = temp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int OceanOptics_lib::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
string deviceType = GetDeviceType(m_iSpectralmeterHandle);
|
||||
string SN = GetSerialNumber(m_iSpectralmeterHandle);
|
||||
|
||||
Info.strPN = deviceType;
|
||||
Info.strSN = SN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
int flag;
|
||||
int spec_length;
|
||||
double *wls = 0;
|
||||
|
||||
// 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));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Attr.iPixels = spec_length;
|
||||
|
||||
long minimum_time;
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
Attr.iMinIntegrationTimeInMS = (int)((double)minimum_time / (double)1000);
|
||||
Attr.iMaxIntegrationTimeInMS = 60000;
|
||||
|
||||
if (spec_length > 0) {
|
||||
wls = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
|
||||
// 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]);
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int tmp = 0; tmp < spec_length; tmp++)
|
||||
{
|
||||
Attr.fWaveLengthInNM[tmp] = wls[tmp];
|
||||
}
|
||||
|
||||
free(wls);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 false;
|
||||
}
|
||||
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>
|
||||
{
|
||||
//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];
|
||||
seabreeze_get_error_string(error, buffer, sizeof(buffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
string OceanOptics_lib::GetDeviceType(int index)
|
||||
{
|
||||
char type[16];
|
||||
int error;
|
||||
|
||||
seabreeze_get_model(index, &error, type, sizeof(type));
|
||||
// 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;
|
||||
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
string OceanOptics_lib::GetSerialNumber(int index)
|
||||
{
|
||||
static char serial_number[32];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<69><63><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD>ᶨ<EFBFBD><E1B6A8><EFBFBD><EFBFBD>stack<63><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<D8BA><F3A3ACBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int flag;
|
||||
int error;
|
||||
|
||||
// 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));
|
||||
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);
|
||||
}
|
||||
|
||||
string sn = serial_number;
|
||||
|
||||
return sn;
|
||||
}
|
57
source/FS/OControl_USB.h
Normal file
57
source/FS/OControl_USB.h
Normal file
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include "api/SeaBreezeWrapper.h"
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OceanOptics_lib :public CIrisFSBase
|
||||
{
|
||||
public:
|
||||
OceanOptics_lib();
|
||||
virtual ~OceanOptics_lib();
|
||||
public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值(不能确定:当不成功时SeaBreeze返回的错误代码error不为0 → 不敢将error直接返回)
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);//ok
|
||||
int Initialize();//ok
|
||||
|
||||
//关闭设备
|
||||
void Close();//ok
|
||||
|
||||
//单次数据采集
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//设置曝光时间
|
||||
int SetExposureTime(int iExposureTimeInMS);//ok
|
||||
|
||||
//获取曝光时间设置
|
||||
int GetExposureTime(int &iExposureTimeInMS);//ok
|
||||
|
||||
//设置目标温度
|
||||
int SetDeviceTemperature(float fTemperature);//ok
|
||||
|
||||
//获取温度设置
|
||||
int GetDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
//获取设备信息
|
||||
int GetDeviceInfo(DeviceInfo &Info);//ok
|
||||
|
||||
//获取设备特征数据
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);//ok
|
||||
|
||||
//tc
|
||||
static const char* get_error_string(int error);
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
int m_iExposureTime;
|
||||
|
||||
bool isSuccess(char* resultStr);
|
||||
|
||||
string GetDeviceType(int index);
|
||||
string GetSerialNumber(int index);
|
||||
};
|
359
source/FS/ZZ_Types.h
Normal file
359
source/FS/ZZ_Types.h
Normal file
@ -0,0 +1,359 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#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 int ZZ_U32;
|
||||
typedef long int ZZ_S32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS = 0;
|
||||
ZZ_S32 lData[4096] = {0};
|
||||
float fTemperature = 0;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
|
||||
// inline DataFrame GetIndex(DataFrame dfDark, DataFrame dfSignal)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
{
|
||||
OSIFAlpha=0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
||||
namespace ATP
|
||||
{
|
||||
const int MAX_SPECTRUM_SIZE = 4096;
|
||||
|
||||
const int GET_MODULECIRCUIT_TEMP = 0x01;
|
||||
const int GET_PN_NUMBER = 0x03;
|
||||
const int GET_SN_NUMBER = 0x04;
|
||||
const int GET_MANUFACTURE_DATA = 0x06;
|
||||
const int GET_MANUFACTURE_INFO = 0x09;
|
||||
const int GET_PIXEL_LENGTH = 0x0a;
|
||||
const int GET_TEC_TEMP = 0x13;
|
||||
const int SET_TEC_TEMP = 0x12;
|
||||
const int GET_OPTICS_TEMP = 0x35;
|
||||
const int GET_CIRCUITBOARD_TEMP = 0x36;
|
||||
const int SET_INTEGRATION_TIME = 0x14;
|
||||
const int GET_INTEGRATION_TIME = 0x41;
|
||||
const int GET_MAX_INTEGRATION_TIME = 0x42;
|
||||
const int GET_MIN_INTEGRATION_TIME = 0x43;
|
||||
const int ASYNC_COLLECT_DARK = 0x23;
|
||||
const int ASYNC_START_COLLECTION = 0x16;
|
||||
const int ASYNC_READ_DATA = 0x17;
|
||||
const int SET_AVERAGE_NUMBER = 0x28;
|
||||
const int SYNC_GET_DATA = 0x1e;
|
||||
const int SYNC_GET_DARK = 0x2f;
|
||||
const int EXTERNAL_TRIGGER_ENABLE = 0x1f;
|
||||
const int SET_XENON_LAMP_DELAY_TIME = 0x24;
|
||||
const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55;
|
||||
const int GET_STAT_LAMPOUT = 0x60;
|
||||
const int SET_GPIO = 0x61;
|
||||
//const int SYNCHRONIZATION_GET_DARK = 0x23
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////device
|
||||
enum Model
|
||||
{
|
||||
ATP1010 = 0,
|
||||
ATP6500
|
||||
};
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagErrorInfo
|
||||
{
|
||||
int iDataTransferErr = -1000;
|
||||
float fTecTempErr = -1000;
|
||||
int iShutterErr = -1000;
|
||||
float fChassisTempErr = -1000;
|
||||
}ErrInfo;
|
||||
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
std::string strInterface[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 tagDualShutterStatus
|
||||
{
|
||||
std::string strChannelA;
|
||||
std::string strChannelB;
|
||||
int iChannelA = 0;
|
||||
int iChannelB = 0;
|
||||
}DSStatus;
|
||||
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
std::string strInterface;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U16 usCmdID;
|
||||
}LSContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
QTime qtStartTime;
|
||||
QTime qtStopTime;
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
LSContext lscParam;
|
||||
FSContext fscParams;
|
||||
AcqTimeSettings atsParams;
|
||||
AcqPosSettings apsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
QString qsISIF_CalibrationFilePath[4];
|
||||
QString qsIS1_CalibrationFilePath[4];
|
||||
}ATPCalibrationSettings;
|
||||
}
|
||||
|
||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
||||
namespace ZZ_DATAFILE
|
||||
{
|
||||
typedef struct tagEnvironmentalContext
|
||||
{
|
||||
QString qstrUTCDateTime;
|
||||
QString qstrLocation;
|
||||
QString qstrGPS_Longtitude;
|
||||
QString qstrGPS_Latitude;
|
||||
QString qstrGPS_Altitude;
|
||||
QString qstrGPS_North;
|
||||
QString qstrCaseTemperature;
|
||||
QString qstrCaseHumidity;
|
||||
QString qstrDEV_SN;
|
||||
}EContext;
|
||||
|
||||
typedef struct tagManmadeEnviromentalContext
|
||||
{
|
||||
QString qstrOriFileName;
|
||||
QString qstrInstallationTime;
|
||||
QString qstrISIFCalibrationTime;
|
||||
QString qstrIS1CalibrationTime;
|
||||
QString qstrNameOfMaintenanceStaff;
|
||||
QString qstrPhoneNumberOfMaintenanceStaff;
|
||||
QString qstrDownloadUserID;
|
||||
QString qstrDownlaodAddress;
|
||||
QString qstrHTTPServer;
|
||||
}MEContext;
|
||||
|
||||
|
||||
typedef struct tagIS1Information
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}IS1Info;
|
||||
|
||||
typedef struct tagISIFInformation
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}ISIFInfo;
|
||||
|
||||
typedef struct tagATPDataHeader
|
||||
{
|
||||
|
||||
|
||||
}ATPDataHeader;
|
||||
|
||||
typedef struct tagCalibrationFrame
|
||||
{
|
||||
ZZ_U32 uiExposureTimeInMS;
|
||||
float fTemperature;
|
||||
int iPixels;
|
||||
float fWaveLength[4096] = { 0 };
|
||||
double dCal_Gain[4096] = { 0 };
|
||||
double dCal_Offset[4096] = { 0 };
|
||||
}CalFrame;
|
||||
|
||||
typedef struct tagCalDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
float fTemperature = 0;
|
||||
int iPixels;
|
||||
float fData[4096];
|
||||
QString qstrGrabDate;
|
||||
}CalDataFrame;
|
||||
}
|
||||
|
||||
//misc detector
|
||||
namespace MISC_DETECTOR
|
||||
{
|
||||
typedef struct tagHumitureDeviceInfo
|
||||
{
|
||||
QString qstrInterfaceName;
|
||||
}HumitureDeviceInfo;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user