Files
oceanControlLib/ocean_lib/main.cpp

220 lines
6.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by tangchao on 2021/11/29.
//
#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 << "设置温度失败!" << std::endl;
// }
// else
// {
// std::cout << "设置温度成功!" << std::endl;
// }
//
//
// ret = fiberImager.SetExposureTime(10000);
// if (ret)
// {
// std::cout << "设置曝光时间失败!" << std::endl;
// }
//
// int exposureTime;
// ret = fiberImager.GetExposureTime(exposureTime);
// if (ret)
// {
// std::cout << "获取曝光时间失败!" << std::endl;
// }
// else
// {
// std::cout << "获取的曝光时间为:" << exposureTime << std::endl;
// }
//
//
//
// ret = fiberImager.SetDeviceTemperature(-8);
//
// float fTemperature;
// ret = fiberImager.GetDeviceTemperature(fTemperature);
// if (ret)
// {
// std::cout << "获取仪器温度失败!" << std::endl;
// }
// else
// {
// std::cout << "获取的仪器温度为:" << fTemperature << std::endl;
// }
//
//
// DeviceInfo Info;
// ret = fiberImager.GetDeviceInfo(Info);
// if (ret)
// {
// std::cout << "获取DeviceInfo失败!" << std::endl;
// }
// else
// {
// std::cout << "获取的仪器类型为:" << Info.strPN << std::endl;
// std::cout << "获取的仪器SN为" << Info.strSN << std::endl;
// }
//
//
//
// DeviceAttribute Attr;
// ret = fiberImager.GetDeviceAttribute(Attr);
// if (ret)
// {
// std::cout << "获取DeviceAttribute失败!" << std::endl;
// }
// else
// {
// std::cout << "获取的波长个数为:" << Attr.iPixels << std::endl;
// std::cout << "获取的波长为:" << std::endl;
// for(int i=0;i<Attr.iPixels;i++)
// {
// std::cout << Attr.fWaveLengthInNM[i] << ",";
// }
// std::cout << std::endl;
// std::cout << "获取的最大曝光时间为:" << Attr.iMaxIntegrationTimeInMS << std::endl;
// std::cout << "获取的最小曝光时间为:" << Attr.iMinIntegrationTimeInMS << std::endl;
// }
//
//
// DataFrame dfData;
// ret = fiberImager.SingleShot(dfData);
// if (ret)
// {
// std::cout << "采集一次数据失败!" << 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 << "获取的一条光谱为:" << std::endl;
// for(int i=0;i<Attr.iPixels;i++)
// {
// std::cout << dfData.usData[i] << ",";
// }
// std::cout << std::endl;
// std::cout << "获取的温度为:" << dfData.fTemperature << std::endl;
// std::cout << "获取的曝光时间为:" << dfData.usExposureTimeInMS << std::endl;
// }
//---------------------------------------------------------------------------------------------------------------------------------------------------
int ret;
OceanOptics_lib fiberImager;
// fiberImager.Initialize(true,10,"FLMS15814");//QEP02975 FLMS15814
fiberImager.Initialize();
ret = fiberImager.SetExposureTime(10000);
if (ret)
{
std::cout << "设置曝光时间失败!" << std::endl;
}
DeviceAttribute Attr;
ret = fiberImager.GetDeviceAttribute(Attr);
DataFrame dfData;
ret = fiberImager.SingleShot(dfData);
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;
// int length;
// double *doubleBuffer = 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));
//
// number_of_devices = sbapi_get_device_ids(device_ids, number_of_devices);
//
// flag = sbapi_open_device(device_ids[0], &error);
// printf("\t\tsbapi_open_deviceResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
//
//
// number_of_spectrometers = sbapi_get_number_of_spectrometer_features(device_ids[0], &error);
// printf("\t\t\tsbapi_get_number_of_spectrometer_featuresResult 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_featuresResult 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_timeResult 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");
//
//
//}