修改了函数执行失败后返回值
This commit is contained in:
@ -11,9 +11,25 @@ include_directories(.)#包含头文件
|
||||
file(GLOB_RECURSE SRC_CPP ./*.cpp)
|
||||
|
||||
|
||||
add_library(oceanlib SHARED ${SRC_CPP})
|
||||
#add_library(${CMAKE_PROJECT_NAME} SHARED ${SRC_CPP})
|
||||
#
|
||||
#TARGET_LINK_LIBRARIES(oceanlib
|
||||
# seabreeze
|
||||
# usb
|
||||
# )
|
||||
|
||||
TARGET_LINK_LIBRARIES(oceanlib
|
||||
|
||||
### Outputs:提示
|
||||
#add_executable(${CMAKE_PROJECT_NAME}
|
||||
# ${SRC_CPP}
|
||||
# )
|
||||
|
||||
add_executable(${CMAKE_PROJECT_NAME}
|
||||
library.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
seabreeze
|
||||
usb
|
||||
)
|
||||
|
@ -22,12 +22,12 @@ namespace ZZ_MISCDEF
|
||||
ZZ_U16 usExposureTimeInMS;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;//
|
||||
double dTimes = 0;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}DataFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;//
|
||||
std::string strPN;//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
|
@ -3,10 +3,14 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
//void hello() {
|
||||
// std::cout << "Hello, World!" << std::endl;
|
||||
//}
|
||||
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,ZZ_U8 ucPortNumber,std::string strDeviceName)
|
||||
@ -21,7 +25,7 @@ int OceanOptics_lib::Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string s
|
||||
{
|
||||
printf("\nOpening spectrometer %d.\n", i);
|
||||
flag = seabreeze_open_spectrometer(i, &error);
|
||||
printf("...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++;
|
||||
@ -34,18 +38,78 @@ int OceanOptics_lib::Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string s
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
// for(i = 0; i < device_count; i++)
|
||||
// {
|
||||
// printf("\nGetting device %d name.\n", i);
|
||||
// seabreeze_get_model(i, &error, type, sizeof(type));
|
||||
// printf("...Result is (%s) [%s]\n", type, get_error_string(error));
|
||||
//
|
||||
// GetSerialNumber(i);
|
||||
// }
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
//<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));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
//<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));
|
||||
if(minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
}
|
||||
|
||||
SetExposureTime(minimum_time/1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -134,12 +198,18 @@ void OceanOptics_lib::Close()
|
||||
int error;
|
||||
|
||||
flag = seabreeze_close_spectrometer(m_iSpectralmeterHandle, &error);
|
||||
printf("...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>
|
||||
int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
int flag;
|
||||
int spec_length;
|
||||
@ -147,14 +217,15 @@ int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
|
||||
printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
printf("...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));
|
||||
|
||||
if(spec_length > 0) {
|
||||
if(spec_length > 0)
|
||||
{
|
||||
spectrum = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
|
||||
printf("\nGetting a formatted spectrum.\n");
|
||||
flag = seabreeze_get_formatted_spectrum(m_iSpectralmeterHandle, &error, spectrum, spec_length);
|
||||
printf("...Result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
printf("Get formatted spectrum result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
printf("\tPixel value 20 is %1.2f\n", spectrum[20]);
|
||||
|
||||
for(int tmp = 0; tmp<spec_length; tmp++)
|
||||
@ -173,82 +244,113 @@ int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
free(spectrum);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int OceanOptics_lib::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
int flag;
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
seabreeze_set_integration_time_microsec(m_iSpectralmeterHandle, &error, iExposureTimeInMS);
|
||||
printf("...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));
|
||||
|
||||
return 1;
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
long minimum_time;
|
||||
int error;
|
||||
|
||||
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));
|
||||
if(minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
iExposureTimeInMS = minimum_time;
|
||||
iExposureTimeInMS = m_iExposureTime;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
{
|
||||
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("...Result is [%s]\n", get_error_string(error));
|
||||
printf("Set tec temperature result is [%s]\n", get_error_string(error));
|
||||
|
||||
printf("\nSetting TEC enable to true\n");
|
||||
seabreeze_set_tec_enable(m_iSpectralmeterHandle, &error, 1);
|
||||
printf("...Result is [%s]\n", get_error_string(error));
|
||||
printf("Set tec enable result is [%s]\n", get_error_string(error));
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
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("...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));
|
||||
|
||||
fTemperature = temp;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int OceanOptics_lib::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
string sn = GetSerialNumber(m_iSpectralmeterHandle);
|
||||
Info.strSN = sn;
|
||||
return 1;
|
||||
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;
|
||||
@ -256,7 +358,7 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
|
||||
printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
printf("...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));
|
||||
|
||||
Attr.iPixels = spec_length;
|
||||
Attr.iMinIntegrationTimeInMS = 0;
|
||||
@ -267,7 +369,7 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
|
||||
printf("\nGetting wavelengths.\n");
|
||||
flag = seabreeze_get_wavelengths(m_iSpectralmeterHandle, &error, wls, spec_length);
|
||||
printf("...Result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
printf("Get wavelengths result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
printf("\tPixel 20 is wavelength %1.2f nm\n", wls[20]);
|
||||
|
||||
for(int tmp = 0; tmp<spec_length; tmp++)
|
||||
@ -278,9 +380,22 @@ int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
free(wls);
|
||||
}
|
||||
|
||||
return 1;
|
||||
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 true;
|
||||
}
|
||||
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>
|
||||
{
|
||||
cout <<"found\n"; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const char* OceanOptics_lib::get_error_string(int error)
|
||||
{
|
||||
static char buffer[32];
|
||||
@ -288,6 +403,20 @@ const char* OceanOptics_lib::get_error_string(int error)
|
||||
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));
|
||||
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>
|
||||
@ -296,7 +425,7 @@ string OceanOptics_lib::GetSerialNumber(int index)
|
||||
|
||||
printf("\n\nGetting serial number.\n");
|
||||
flag = seabreeze_get_serial_number(index, &error, serial_number, 32);
|
||||
printf("...Result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
printf("Get serial number result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
serial_number[31] = '\0';
|
||||
if(flag > 0) {
|
||||
printf("\tSerial number: [%s]\n", serial_number);
|
||||
|
@ -11,53 +11,56 @@
|
||||
//#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
|
||||
|
||||
//void hello();
|
||||
using namespace std;
|
||||
|
||||
class OceanOptics_lib:public CIrisFSBase
|
||||
{
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
public:
|
||||
OceanOptics_lib();
|
||||
virtual ~OceanOptics_lib();
|
||||
public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值
|
||||
int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName);
|
||||
int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName);//ok
|
||||
int Initialize();//ok
|
||||
|
||||
//关闭设备
|
||||
void Close();
|
||||
void Close();//ok
|
||||
|
||||
//单次数据采集
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//设置曝光时间
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
int SetExposureTime(int iExposureTimeInMS);//ok
|
||||
|
||||
//获取曝光时间设置
|
||||
int GetExposureTime(int &iExposureTimeInMS);
|
||||
int GetExposureTime(int &iExposureTimeInMS);//ok
|
||||
|
||||
//设置目标温度
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
int SetDeviceTemperature(float fTemperature);//ok
|
||||
|
||||
//获取温度设置
|
||||
int GetDeviceTemperature(float &fTemperature);
|
||||
int GetDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
//获取设备信息
|
||||
int GetDeviceInfo(DeviceInfo &Info);//ok
|
||||
|
||||
//获取设备特征数据
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);//ok
|
||||
|
||||
//tc
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
int m_iExposureTime;
|
||||
|
||||
bool isSuccess(char* resultStr);
|
||||
|
||||
static const char* get_error_string(int error);
|
||||
string GetDeviceType(int index);
|
||||
string GetSerialNumber(int index);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //OCEAN_LIB_LIBRARY_H
|
||||
|
123
ocean_lib/main.cpp
Normal file
123
ocean_lib/main.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
//
|
||||
// Created by tangchao on 2021/11/29.
|
||||
//
|
||||
|
||||
#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "library.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
OceanOptics_lib fiberImager;
|
||||
fiberImager.Initialize(true,10,"FLMS15814");//QEP02975 FLMS15814
|
||||
|
||||
fiberImager.SetExposureTime(5000);
|
||||
|
||||
int exposureTime;
|
||||
fiberImager.GetExposureTime(exposureTime);
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << exposureTime << std::endl;
|
||||
|
||||
|
||||
fiberImager.SetDeviceTemperature(-8);
|
||||
|
||||
float fTemperature;
|
||||
fiberImager.GetDeviceTemperature(fTemperature);
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>Ϊ<EFBFBD><EFBFBD>" << fTemperature << std::endl;
|
||||
|
||||
DeviceInfo Info;
|
||||
fiberImager.GetDeviceInfo(Info);
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << Info.strPN << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SNΪ<EFBFBD><EFBFBD>" << Info.strSN << std::endl;
|
||||
|
||||
|
||||
DeviceAttribute Attr;
|
||||
fiberImager.GetDeviceAttribute(Attr);
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << Attr.iPixels << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << std::endl;
|
||||
for(int i=0;i<Attr.iPixels;i++)
|
||||
{
|
||||
std::cout << Attr.fWaveLengthInNM[i] << ",";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << Attr.fWaveLengthInNM << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << Attr.iMaxIntegrationTimeInMS << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << Attr.iMinIntegrationTimeInMS << std::endl;
|
||||
|
||||
|
||||
|
||||
DataFrame dfData;
|
||||
fiberImager.SingleShot(dfData);
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << std::endl;
|
||||
for(int i=0;i<Attr.iPixels;i++)
|
||||
{
|
||||
std::cout << dfData.usData[i] << ",";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>Ϊ<EFBFBD><EFBFBD>" << dfData.fTemperature << std::endl;
|
||||
std::cout << "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>" << dfData.usExposureTimeInMS << std::endl;
|
||||
|
||||
|
||||
fiberImager.Close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//int main()
|
||||
//{
|
||||
// int number_of_devices;
|
||||
// long *device_ids;
|
||||
// int i;
|
||||
// int test_index;
|
||||
// int flag;
|
||||
// int unsupportedFeatureCount;
|
||||
// int testFailureCount;
|
||||
// int error = 0;
|
||||
// char nameBuffer[80];
|
||||
// int number_of_spectrometers;
|
||||
// long *spectrometer_ids = 0;
|
||||
//
|
||||
//
|
||||
// sbapi_initialize();
|
||||
// sbapi_probe_devices();
|
||||
//
|
||||
// printf("Getting device count...\n"); fflush(stdout);
|
||||
// number_of_devices = sbapi_get_number_of_device_ids();
|
||||
//
|
||||
// printf("Device count is %d\n", number_of_devices);
|
||||
// if(0 == number_of_devices) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// printf("Getting device IDs...\n");
|
||||
// device_ids = (long *)calloc(number_of_devices, sizeof(long));
|
||||
//
|
||||
// std::cout<<"ssss"<<device_ids[0];
|
||||
//
|
||||
// number_of_devices = sbapi_get_device_ids(device_ids, number_of_devices);
|
||||
//
|
||||
// flag = sbapi_open_device(device_ids[0], &error);
|
||||
//
|
||||
//
|
||||
// number_of_spectrometers = sbapi_get_number_of_spectrometer_features(device_ids[0], &error);
|
||||
//
|
||||
// spectrometer_ids = (long *)calloc(10, sizeof(long));
|
||||
//
|
||||
// number_of_spectrometers = sbapi_get_spectrometer_features(2, &error,
|
||||
// spectrometer_ids, 10);
|
||||
//
|
||||
// for(int i=0;i<10;i++)
|
||||
// {
|
||||
// std::cout<<std::endl;
|
||||
// std::cout<<"ssss:"<<spectrometer_ids[i]<<std::endl;
|
||||
// }
|
||||
//
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_spectrometers,
|
||||
// sbapi_get_error_string(error));
|
||||
//
|
||||
//
|
||||
// std::cout<<"ssss:"<<error<<std::endl;
|
||||
//}
|
Reference in New Issue
Block a user