mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-12-16 03:23:32 +08:00
主采集逻辑修改中,添加了部分写文件实现
This commit is contained in:
@ -1 +0,0 @@
|
||||
#pragma once
|
||||
125
source/FS/DataFileProcessor.cpp
Normal file
125
source/FS/DataFileProcessor.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
#include "DataFileProcessor.h"
|
||||
|
||||
DataFileProcessor::DataFileProcessor()
|
||||
{
|
||||
#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;
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteDataFile()
|
||||
{
|
||||
GenerateFilePath();
|
||||
WriteInfo();
|
||||
bool res = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
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;
|
||||
m_qstrFilePath= m_qstrFullFileName;
|
||||
if (m_struEC.qstrLocation=="")
|
||||
{
|
||||
m_struEC.qstrLocation = "Unknown";
|
||||
}
|
||||
m_qstrFullFileName= m_qstrFullFileName+"/"+m_struEC.qstrLocation + qstrAddHMS+".txt";
|
||||
|
||||
QDir qdirPath(m_qstrFilePath);
|
||||
if (!qdirPath.exists())
|
||||
{
|
||||
qdirPath.mkdir(m_qstrFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteInfo()
|
||||
{
|
||||
bool bRes = true;
|
||||
QFile qfData(m_qstrFullFileName);
|
||||
bRes = qfData.open(QFile::WriteOnly|QFile::Text|QFile::Truncate);
|
||||
if (!bRes)
|
||||
{
|
||||
return bRes;
|
||||
}
|
||||
//EC
|
||||
qfData.write("EnvironmentalContext,");
|
||||
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;
|
||||
}
|
||||
|
||||
bool DataFileProcessor::WriteData()
|
||||
{
|
||||
bool res = true;
|
||||
return res;
|
||||
}
|
||||
28
source/FS/DataFileProcessor.h
Normal file
28
source/FS/DataFileProcessor.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||
class DataFileProcessor
|
||||
{
|
||||
public:
|
||||
DataFileProcessor();
|
||||
virtual ~DataFileProcessor();
|
||||
public:
|
||||
void SetEnvironmentContex(EContext struEC);
|
||||
void SetManmadeEnviromentalContext(MEContext truMEC);
|
||||
bool WriteDataFile();
|
||||
private:
|
||||
void GenerateFilePath();
|
||||
bool WriteInfo();
|
||||
bool WriteData();
|
||||
|
||||
|
||||
public:
|
||||
private:
|
||||
QString m_qstrFullFileName;
|
||||
QString m_qstrFileName;
|
||||
QString m_qstrFilePath;
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
QDateTime m_qdtTime;
|
||||
};
|
||||
437
source/FS/OControl_USB.cpp
Normal file
437
source/FS/OControl_USB.cpp
Normal file
@ -0,0 +1,437 @@
|
||||
#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, ZZ_U8 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++;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<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);
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
//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));
|
||||
|
||||
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("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++)
|
||||
{
|
||||
dfData.usData[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)
|
||||
{
|
||||
iExposureTimeInMS = iExposureTimeInMS * 1000;
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
//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));
|
||||
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
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)
|
||||
{
|
||||
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));
|
||||
|
||||
//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));
|
||||
|
||||
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("Read tec temperature result is %1.2f C [%s]\n", temp, get_error_string(error));
|
||||
|
||||
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));
|
||||
|
||||
Attr.iPixels = spec_length;
|
||||
Attr.iMinIntegrationTimeInMS = 0;
|
||||
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]);
|
||||
|
||||
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 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];
|
||||
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));
|
||||
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));
|
||||
serial_number[31] = '\0';
|
||||
if (flag > 0) {
|
||||
//printf("\tSerial number: [%s]\n", serial_number);
|
||||
}
|
||||
|
||||
string sn = serial_number;
|
||||
|
||||
return sn;
|
||||
}
|
||||
BIN
source/FS/OControl_USB.h
Normal file
BIN
source/FS/OControl_USB.h
Normal file
Binary file not shown.
Reference in New Issue
Block a user