mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 03:49:42 +08:00
提交
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user