Compare commits
5 Commits
fae1a5e462
...
86534c10f3
Author | SHA1 | Date | |
---|---|---|---|
86534c10f3 | |||
b33e5a08ee | |||
5b9429f4eb | |||
f1db1457e6 | |||
6334ea9e41 |
83
.gitignore
vendored
83
.gitignore
vendored
@ -1,2 +1,81 @@
|
||||
/ocean_lib/build
|
||||
/ocean_lib/.idea
|
||||
# tc
|
||||
/.idea/*
|
||||
/build/*
|
||||
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 14)
|
||||
include_directories(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/include/)
|
||||
LINK_DIRECTORIES(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/lib/)
|
||||
|
||||
include_directories(.)#包含头文件
|
||||
include_directories(ocean_lib)#包含头文件
|
||||
#file(GLOB_RECURSE SRC_H ./*.h)
|
||||
file(GLOB_RECURSE SRC_CPP ./*.cpp)
|
||||
|
||||
@ -25,8 +25,8 @@ file(GLOB_RECURSE SRC_CPP ./*.cpp)
|
||||
# )
|
||||
|
||||
add_executable(${CMAKE_PROJECT_NAME}
|
||||
library.cpp
|
||||
main.cpp
|
||||
ocean_lib/library.cpp
|
||||
ocean_lib/main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
@ -7,6 +7,7 @@ OceanOptics_lib::OceanOptics_lib()
|
||||
{
|
||||
m_iSpectralmeterHandle=-100;
|
||||
}
|
||||
|
||||
OceanOptics_lib::~OceanOptics_lib()
|
||||
{
|
||||
|
||||
@ -23,42 +24,58 @@ int OceanOptics_lib::Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string s
|
||||
|
||||
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);
|
||||
|
||||
long test = seabreeze_get_buffer_capacity_minimum(m_iSpectralmeterHandle, &error);
|
||||
seabreeze_set_buffer_capacity(m_iSpectralmeterHandle, &error, test);
|
||||
|
||||
// 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));
|
||||
//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;
|
||||
@ -81,30 +98,53 @@ 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));
|
||||
//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");
|
||||
printf("\nNo Device found!!!!!!!!!!!!\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);
|
||||
|
||||
long test = seabreeze_get_buffer_capacity_minimum(m_iSpectralmeterHandle, &error);
|
||||
// printf("seabreeze_get_buffer_capacity_minimum: Result is [%s]\n", get_error_string(error));
|
||||
seabreeze_set_buffer_capacity(m_iSpectralmeterHandle, &error, test);
|
||||
// printf("seabreeze_set_buffer_capacity: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
// 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));
|
||||
//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);
|
||||
@ -198,7 +238,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>
|
||||
@ -214,19 +254,37 @@ 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));
|
||||
//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);
|
||||
|
||||
auto startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
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]);
|
||||
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double, std::milli> fp_ms = endTime - startTime;
|
||||
std::cout <<"<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>ʱΪ<EFBFBD><EFBFBD>"<< fp_ms.count()/1000 <<"s."<< std::endl;
|
||||
|
||||
// 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++)
|
||||
{
|
||||
@ -252,17 +310,40 @@ int OceanOptics_lib::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
// printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0); // trigger to normal
|
||||
seabreeze_set_integration_time_microsec(m_iSpectralmeterHandle, &error, iExposureTimeInMS*1000);
|
||||
printf("Set integration time result is [%s]\n", get_error_string(error));
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -283,6 +364,8 @@ 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");
|
||||
@ -291,13 +374,24 @@ int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
|
||||
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;
|
||||
}
|
||||
@ -305,6 +399,8 @@ int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
dark_pixel_count = seabreeze_get_electric_dark_pixel_indices(index,
|
||||
error_code, dark_pixels, MAX_DARK_PIXELS);
|
||||
if(m_iSpectralmeterHandle==-100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
@ -315,9 +411,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;
|
||||
|
||||
@ -356,21 +457,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/1000;
|
||||
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 +501,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];
|
||||
@ -403,13 +518,74 @@ const char* OceanOptics_lib::get_error_string(int error)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void OceanOptics_lib::test_nonlinearity_coeffs_feature()
|
||||
{
|
||||
int error = 0;
|
||||
int number_of_nonlinearity_coeff_features;
|
||||
long *nonlinearity_coeff_feature_ids = 0;
|
||||
double buffer[10];
|
||||
int i;
|
||||
int length;
|
||||
|
||||
printf("\n\tTesting nonlinearity coefficient features:\n");
|
||||
|
||||
printf("\t\tGetting number of nonlinearity coefficient features:\n");
|
||||
number_of_nonlinearity_coeff_features =
|
||||
sbapi_get_number_of_nonlinearity_coeffs_features(m_iSpectralmeterHandle, &error);
|
||||
printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
sbapi_get_error_string(error));
|
||||
|
||||
if(0 == number_of_nonlinearity_coeff_features) {
|
||||
printf("\tNo nonlinearity coefficient capabilities found.\n");
|
||||
// tallyUnsupportedFeatures(unsupportedFeatureCount);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nonlinearity_coeff_feature_ids =
|
||||
(long *)calloc(number_of_nonlinearity_coeff_features, sizeof(long));
|
||||
printf("\t\tGetting nonlinearity coefficient feature IDs...\n");
|
||||
number_of_nonlinearity_coeff_features = sbapi_get_nonlinearity_coeffs_features(
|
||||
m_iSpectralmeterHandle, &error, nonlinearity_coeff_feature_ids,
|
||||
number_of_nonlinearity_coeff_features);
|
||||
printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
sbapi_get_error_string(error));
|
||||
|
||||
for(i = 0; i < number_of_nonlinearity_coeff_features; i++) {
|
||||
printf("\t\t%d: Testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
i, m_iSpectralmeterHandle, nonlinearity_coeff_feature_ids[i]);
|
||||
|
||||
printf("\t\t\tAttempting to get nonlinearity coefficients...\n");
|
||||
memset(buffer, (int)0, sizeof(buffer));
|
||||
length = sbapi_nonlinearity_coeffs_get(m_iSpectralmeterHandle,
|
||||
nonlinearity_coeff_feature_ids[i], &error, buffer, 10);
|
||||
printf("\t\t\t\tResult is %d [%s]\n", length, sbapi_get_error_string(error));
|
||||
|
||||
if(0 == error && length > 0) {
|
||||
printf("\t\t\t\tFirst calibration term: %1.2e\n", buffer[0]);
|
||||
}
|
||||
|
||||
printf("\t\t%d: Finished testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
i, m_iSpectralmeterHandle, nonlinearity_coeff_feature_ids[i]);
|
||||
}
|
||||
free(nonlinearity_coeff_feature_ids);
|
||||
|
||||
printf("\tFinished testing nonlinearity coefficient capabilities.\n");
|
||||
}
|
||||
|
||||
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));
|
||||
// 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 +599,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;
|
||||
|
@ -5,10 +5,12 @@
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "api/SeaBreezeWrapper.h"
|
||||
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
//#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
@ -21,7 +23,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
|
||||
|
||||
@ -50,6 +52,8 @@ public:
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);//ok
|
||||
|
||||
//tc
|
||||
static const char* get_error_string(int error);
|
||||
void test_nonlinearity_coeffs_feature();
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
@ -57,10 +61,8 @@ private:
|
||||
|
||||
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
|
||||
|
@ -4,61 +4,146 @@
|
||||
|
||||
#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "library.h"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
//
|
||||
// int ret;
|
||||
// OceanOptics_lib fiberImager;
|
||||
//// fiberImager.Initialize(true,10,"FLMS15814");//QEP02975 FLMS15814
|
||||
// fiberImager.Initialize();
|
||||
// ret = fiberImager.SetDeviceTemperature(-1);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>ʧ<EFBFBD><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD>¶ȳɹ<C8B3><C9B9><EFBFBD>" << std::endl;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// ret = fiberImager.SetExposureTime(10000);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>ʧ<EFBFBD><CAA7>!" << std::endl;
|
||||
// }
|
||||
//
|
||||
// int exposureTime;
|
||||
// ret = fiberImager.GetExposureTime(exposureTime);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>ʧ<EFBFBD><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA>" << exposureTime << std::endl;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// ret = fiberImager.SetDeviceTemperature(-8);
|
||||
//
|
||||
// float fTemperature;
|
||||
// ret = fiberImager.GetDeviceTemperature(fTemperature);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>ʧ<EFBFBD><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>Ϊ<EFBFBD><CEAA>" << fTemperature << std::endl;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// DeviceInfo Info;
|
||||
// ret = fiberImager.GetDeviceInfo(Info);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><>ȡDeviceInfoʧ<6F><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>" << Info.strPN << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SNΪ<4E><CEAA>" << Info.strSN << std::endl;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// DeviceAttribute Attr;
|
||||
// ret = fiberImager.GetDeviceAttribute(Attr);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22><>ȡDeviceAttributeʧ<65><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "<22><>ȡ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>" << Attr.iPixels << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ϊ<EFBFBD><CEAA>" << std::endl;
|
||||
// for(int i=0;i<Attr.iPixels;i++)
|
||||
// {
|
||||
// std::cout << Attr.fWaveLengthInNM[i] << ",";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA>" << Attr.iMaxIntegrationTimeInMS << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>С<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA>" << Attr.iMinIntegrationTimeInMS << std::endl;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// DataFrame dfData;
|
||||
// ret = fiberImager.SingleShot(dfData);
|
||||
// if (ret)
|
||||
// {
|
||||
// std::cout << "<22>ɼ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!" << std::endl;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string fileName = "integratingSphereSpectral.csv";
|
||||
// std::ofstream outfile(fileName.c_str());
|
||||
//
|
||||
// for (int i = 0; i < Attr.iPixels; i++)
|
||||
// {
|
||||
// outfile << Attr.fWaveLengthInNM[i] << "," << dfData.usData[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile.close();
|
||||
//
|
||||
//
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>" << std::endl;
|
||||
// for(int i=0;i<Attr.iPixels;i++)
|
||||
// {
|
||||
// std::cout << dfData.usData[i] << ",";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD>¶<EFBFBD>Ϊ<EFBFBD><CEAA>" << dfData.fTemperature << std::endl;
|
||||
// std::cout << "<22><>ȡ<EFBFBD><C8A1><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD><CEAA>" << dfData.usExposureTimeInMS << std::endl;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
int ret;
|
||||
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.Initialize(true,10,"FLMS15814");//QEP02975 FLMS15814
|
||||
fiberImager.Initialize();
|
||||
|
||||
|
||||
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;
|
||||
|
||||
ret = fiberImager.SetExposureTime(10000);
|
||||
if (ret)
|
||||
{
|
||||
std::cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>!" << 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;
|
||||
|
||||
|
||||
ret = fiberImager.GetDeviceAttribute(Attr);
|
||||
|
||||
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;
|
||||
|
||||
ret = fiberImager.SingleShot(dfData);
|
||||
|
||||
fiberImager.Close();
|
||||
|
||||
@ -66,6 +151,9 @@ int main()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//int main()
|
||||
//{
|
||||
// int number_of_devices;
|
||||
@ -79,6 +167,8 @@ int main()
|
||||
// char nameBuffer[80];
|
||||
// int number_of_spectrometers;
|
||||
// long *spectrometer_ids = 0;
|
||||
// int length;
|
||||
// double *doubleBuffer = 0;
|
||||
//
|
||||
//
|
||||
// sbapi_initialize();
|
||||
@ -95,29 +185,35 @@ int main()
|
||||
// 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);
|
||||
// printf("\t\tsbapi_open_device<63><65>Result is (%d) [%s]\n", flag, sbapi_get_error_string(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));
|
||||
// printf("\t\t\tsbapi_get_number_of_spectrometer_features<65><73>Result 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(device_ids[0], &error, spectrometer_ids, 10);
|
||||
// printf("\t\t\tsbapi_get_spectrometer_features<65><73>Result is %d [%s]\n", number_of_spectrometers, sbapi_get_error_string(error));
|
||||
//
|
||||
//
|
||||
// sbapi_spectrometer_set_integration_time_micros(device_ids[0], spectrometer_ids[0], &error, 10000000);
|
||||
// printf("\t\t\t\tset_integration_time<6D><65>Result is [%s]\n", sbapi_get_error_string(error));
|
||||
//
|
||||
//
|
||||
// printf("\t\t\tGetting spectrum length\n");
|
||||
// length = sbapi_spectrometer_get_formatted_spectrum_length(device_ids[0], spectrometer_ids[0], &error);
|
||||
// printf("\t\t\t\tResult is %d [%s]\n", length, sbapi_get_error_string(error));
|
||||
// doubleBuffer = (double *)calloc(length, sizeof(double));
|
||||
//
|
||||
//
|
||||
// printf("\t\t\tGetting spectrum111111111111111111111111111111111111111111111111111\n");
|
||||
// length = sbapi_spectrometer_get_formatted_spectrum(device_ids[0],spectrometer_ids[0], &error, doubleBuffer, length);
|
||||
// printf("\t\t\t\tResult is %d [%s]\n", length, sbapi_get_error_string(error));
|
||||
//
|
||||
//
|
||||
// printf("\t\t\tGetting spectrum222222222222222222222222222222222222222222222222222222222\n");
|
||||
//
|
||||
//
|
||||
// std::cout<<"ssss:"<<error<<std::endl;
|
||||
//}
|
||||
|
Reference in New Issue
Block a user