mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-20 11:59:42 +08:00
添加了位置定标程序 及位置移动相关程序源码
This commit is contained in:
327
othersoft/shuttercali/source_rlx/sensor/SensorQExPRO.cpp
Normal file
327
othersoft/shuttercali/source_rlx/sensor/SensorQExPRO.cpp
Normal file
@ -0,0 +1,327 @@
|
||||
#include "SensorQExPRO.h"
|
||||
#include "QDebug"
|
||||
#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
#include "logout.h"
|
||||
#include "QMetaEnum"
|
||||
#include "QThread"
|
||||
SensorQExPRO::SensorQExPRO(EMQEType qetype)
|
||||
|
||||
{
|
||||
QEType = qetype;
|
||||
if (qetype==QEPRO_QE)
|
||||
{
|
||||
|
||||
}
|
||||
else if(qetype == USB2000PLUS_QE)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputMod = nullptr;
|
||||
Shuteroffcom = nullptr;
|
||||
Shuteroncom = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SensorQExPRO::~SensorQExPRO()
|
||||
{
|
||||
if (SensorInfo.isSensorInit)
|
||||
{
|
||||
sbapi_shutdown();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool SensorQExPRO::initSensor(int id)
|
||||
{
|
||||
sbapi_shutdown();
|
||||
sbapi_initialize();
|
||||
sbapi_probe_devices();
|
||||
int number_of_QE = sbapi_get_number_of_device_ids();
|
||||
logout::out("<EFBFBD>ҵ<EFBFBD> " + QString::number(number_of_QE) + "<EFBFBD><EFBFBD><EFBFBD>豸",2);
|
||||
if (number_of_QE <= id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Device_ids=new long[number_of_QE]();
|
||||
sbapi_get_device_ids(Device_ids, number_of_QE);
|
||||
logout::out("<EFBFBD>豸idΪ<EFBFBD><EFBFBD>" + QString::number(Device_ids[id]),2);
|
||||
DeviceId = Device_ids[id];
|
||||
|
||||
char namearr[100];
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
FLAG= sbapi_get_device_type(DeviceId, &ERR, namearr, 99);
|
||||
if (FLAG!=0)
|
||||
{
|
||||
QString sensorname = QString(namearr);
|
||||
QEType = getEMUbyQstring(sensorname);
|
||||
SensorType = sensorname;
|
||||
SensorInfo.SensorName = sensorname;
|
||||
logout::out("<EFBFBD>豸<EFBFBD>ͺţ<EFBFBD>" + sensorname,2);
|
||||
}
|
||||
Sensorid = DeviceId;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>豸
|
||||
FLAG= sbapi_open_device(DeviceId, &ERR);
|
||||
logout::out("<EFBFBD>豸<EFBFBD><EFBFBD>" + QString(sbapi_get_error_string(ERR)),2);
|
||||
if (FLAG!=0)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7> <20><><EFBFBD><EFBFBD>false
|
||||
return false;
|
||||
}
|
||||
SensorInfo.isSensorInit = true;
|
||||
int maxf=sbapi_get_number_of_shutter_features(DeviceId, &ERR);;
|
||||
long fff;
|
||||
// sbapi_get_shutter_features(DeviceId, &ERR, &fff,maxf);
|
||||
// sbapi_shutter_set_shutter_open(DeviceId, fff,&ERR, 0);
|
||||
// logout::out("<22>豸<EFBFBD><EFBFBD>" + QString(sbapi_get_error_string(ERR)));
|
||||
// qDebug() << "hello";
|
||||
SensorInfo=GetSensorInfo();
|
||||
|
||||
|
||||
//Ϊ<>¶ȶ<C2B6><C8B6><EFBFBD><EFBFBD>õ<EFBFBD>
|
||||
Numberoftempratrue= sbapi_get_number_of_thermo_electric_features(DeviceId, &ERR);
|
||||
TemPratrueId=new long[Numberoftempratrue]();
|
||||
Numberoftempratrue=sbapi_get_thermo_electric_features(DeviceId, &ERR, TemPratrueId, Numberoftempratrue);
|
||||
sbapi_tec_set_enable(DeviceId, TemPratrueId[0], &ERR, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SensorQExPRO::Settingshuttertime(float msc)
|
||||
{
|
||||
if (!SensorInfo.isSensorInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shuttertime = msc;
|
||||
sbapi_spectrometer_set_integration_time_micros(DeviceId, SpecMetersId[0], &ERR, msc*1000);
|
||||
//logout::out("<22><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD>䣺" + QString(sbapi_get_error_string(ERR)),2);
|
||||
}
|
||||
|
||||
void SensorQExPRO::SettingTemprature(float temp)
|
||||
{
|
||||
sbapi_tec_set_temperature_setpoint_degrees_C(DeviceId, TemPratrueId[0], &ERR,temp);
|
||||
QThread::msleep(100);
|
||||
}
|
||||
|
||||
STRSensorInfo SensorQExPRO::GetSensorInfo()
|
||||
{
|
||||
STRSensorInfo sensorinof;
|
||||
//return sensorinof;
|
||||
if (!SensorInfo.isSensorInit)
|
||||
{
|
||||
return sensorinof;
|
||||
}
|
||||
int ERR=0;
|
||||
|
||||
sensorinof.isSensorInit = true;
|
||||
sensorinof.BandNum= sbapi_get_number_of_spectrometer_features(DeviceId, &ERR);
|
||||
SpecMetersId = new long[sensorinof.BandNum]();
|
||||
int numm= sbapi_get_spectrometer_features(DeviceId, &ERR, SpecMetersId, sensorinof.BandNum);
|
||||
sensorinof.BandNum = sbapi_spectrometer_get_formatted_spectrum_length(DeviceId, SpecMetersId[0], &ERR);
|
||||
double *wavelenth = new double[sensorinof.BandNum]();
|
||||
sbapi_spectrometer_get_wavelengths(DeviceId, SpecMetersId[0], &ERR,wavelenth, sensorinof.BandNum);
|
||||
sensorinof.wavelenthlist.clear();
|
||||
sensorinof.WavelenthStr = "";
|
||||
int i = 0;
|
||||
for (i = 0; i < sensorinof.BandNum-1; i++)
|
||||
{
|
||||
sensorinof.WavelenthStr = sensorinof.WavelenthStr + QString::number(wavelenth[i], 'f', 4)+",";
|
||||
sensorinof.wavelenthlist.append(QString::number(wavelenth[i], 'f', 4));
|
||||
|
||||
}
|
||||
sensorinof.WavelenthStr = sensorinof.WavelenthStr + QString::number(wavelenth[i], 'f', 4);
|
||||
sensorinof.wavelenthlist.append(QString::number(wavelenth[i], 'f', 4));
|
||||
sensorinof.maxValue = sbapi_spectrometer_get_maximum_intensity(DeviceId, SpecMetersId[0], &ERR);
|
||||
char namearr[100];
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||
FLAG = sbapi_get_device_type(DeviceId, &ERR, namearr, 99);
|
||||
if (FLAG != 0)
|
||||
{
|
||||
QString sensorname = QString(namearr);
|
||||
QEType = getEMUbyQstring(sensorname);
|
||||
SensorType = sensorname;
|
||||
sensorinof.SensorName = sensorname;
|
||||
logout::out("<EFBFBD>豸<EFBFBD>ͺţ<EFBFBD>" + sensorname, 2);
|
||||
}
|
||||
return sensorinof;
|
||||
}
|
||||
|
||||
void SensorQExPRO::SettingShutterOpen(bool isopen)
|
||||
{
|
||||
//<2F><>ݮ<EFBFBD><DDAE> 4<><34><EFBFBD><EFBFBD>
|
||||
system("gpio mode 4 output");
|
||||
if (isopen)
|
||||
{
|
||||
system("gpio write 4 1");
|
||||
logout::out("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> Shutter gpio",2);
|
||||
}
|
||||
else
|
||||
{
|
||||
system("gpio write 4 0");
|
||||
logout::out("<EFBFBD>ر<EFBFBD> Shutter gpio",2);
|
||||
}
|
||||
if (QEType==QEPRO_QE)
|
||||
{
|
||||
|
||||
SetQEProShutter(isopen);
|
||||
}
|
||||
QThread::msleep(100);
|
||||
|
||||
}
|
||||
|
||||
void SensorQExPRO::SettingSwitchShutter(bool isright)
|
||||
{
|
||||
system("gpio mode 5 output");
|
||||
if (isright)
|
||||
{
|
||||
system("gpio write 5 1");
|
||||
logout::out("<EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>SKY",2);
|
||||
}
|
||||
else
|
||||
{
|
||||
system("gpio write 5 0");
|
||||
logout::out("<EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>VEG",2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SensorQExPRO::GetOnePlot(STROnePlot &OnePlot, bool Dark)
|
||||
{
|
||||
if (!SensorInfo.isSensorInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!OnePlot.isInit || OnePlot.BandNum != SensorInfo.BandNum)
|
||||
{
|
||||
if (OnePlot.isInit)
|
||||
{
|
||||
|
||||
delete[] OnePlot.Plot;
|
||||
}
|
||||
OnePlot.Plot = new float[SensorInfo.BandNum];
|
||||
OnePlot.BandNum = SensorInfo.BandNum;
|
||||
|
||||
}
|
||||
if (!SensorInfo.isSensorInit)
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
double *tempvalue = new double[SensorInfo.BandNum];
|
||||
OnePlot.shutter = shuttertime;
|
||||
sbapi_spectrometer_get_formatted_spectrum(DeviceId,SpecMetersId[0], &ERR, tempvalue, SensorInfo.BandNum);
|
||||
logout::out("<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>" + QString(sbapi_get_error_string(ERR)),5);
|
||||
if (QEType != USB2000PLUS_QE)
|
||||
{
|
||||
OnePlot.temp = GettingTempratrue();
|
||||
logout::out("<EFBFBD><EFBFBD>ȡ<EFBFBD>¶ȣ<EFBFBD>" + QString(sbapi_get_error_string(ERR)) + " <20>¶<EFBFBD>Ϊ<EFBFBD><CEAA>" + QString::number(OnePlot.temp, 'f', 2) + "<EFBFBD><EFBFBD>",2);
|
||||
}
|
||||
|
||||
|
||||
for (size_t i = 0; i < SensorInfo.BandNum; i++)
|
||||
{
|
||||
OnePlot.Plot[i] = tempvalue[i];
|
||||
|
||||
}
|
||||
OnePlot.isInit = true;
|
||||
delete[] tempvalue;
|
||||
}
|
||||
|
||||
float SensorQExPRO::GettingTempratrue()
|
||||
{
|
||||
if (!SensorInfo.isSensorInit)
|
||||
{
|
||||
return -1000;
|
||||
}
|
||||
float temperature = (float)sbapi_tec_read_temperature_degrees_C(DeviceId, TemPratrueId[0], &ERR);
|
||||
logout::out("<EFBFBD><EFBFBD>ǰ<EFBFBD>¶<EFBFBD>Ϊ<EFBFBD><EFBFBD>"+QString::number(temperature,'f',2),2);
|
||||
return temperature;
|
||||
}
|
||||
|
||||
void SensorQExPRO::CloseSensor()
|
||||
{
|
||||
if (SensorInfo.isSensorInit)
|
||||
{
|
||||
sbapi_shutdown();
|
||||
SensorInfo.isSensorInit = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SensorQExPRO::GetOneDark(STROnePlot &darkplot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
EMQEType SensorQExPRO::getEMUbyQstring(QString str)
|
||||
{
|
||||
if (str=="USB2000PLUS")
|
||||
{
|
||||
return USB2000PLUS_QE;
|
||||
}
|
||||
if (str == "QE65PRO")
|
||||
{
|
||||
return QE65PRO_QE;
|
||||
}
|
||||
if (str == "QE-PRO")
|
||||
{
|
||||
return QEPRO_QE;
|
||||
}
|
||||
if (str == "QE65000")
|
||||
{
|
||||
return QE65000_QE;
|
||||
}
|
||||
return NONQE;
|
||||
}
|
||||
|
||||
void SensorQExPRO::SetQEProShutter( bool isopen)
|
||||
{
|
||||
unsigned char GPIO4output[64] = { 0xc1, 0xc0, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc5, 0xc4, 0xc3, 0xc2
|
||||
};
|
||||
unsigned char GPIO4on[64] = { 0xc1, 0xc0, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x03, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc5, 0xc4, 0xc3, 0xc2
|
||||
};
|
||||
unsigned char GPIO4_off[64] = { 0xc1, 0xc0, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00,
|
||||
0x10, 0x03, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
|
||||
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xc5, 0xc4, 0xc3, 0xc2
|
||||
};
|
||||
|
||||
long FNid;
|
||||
int FN = sbapi_get_number_of_raw_usb_bus_access_features(DeviceId, &ERR);
|
||||
FN = sbapi_get_raw_usb_bus_access_features(DeviceId, &ERR, &FNid, FN);
|
||||
QThread::msleep(100);
|
||||
int lenth = sbapi_raw_usb_bus_access_write(DeviceId, FNid, &ERR, GPIO4output, 64, 0x01);
|
||||
logout::out("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>shutter Ϊgpio",2);
|
||||
if (isopen)
|
||||
{
|
||||
lenth = sbapi_raw_usb_bus_access_write(DeviceId, FNid, &ERR, GPIO4on, 64, 0x01);
|
||||
logout::out("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Shutter",2);
|
||||
}
|
||||
else
|
||||
{
|
||||
lenth = sbapi_raw_usb_bus_access_write(DeviceId, FNid, &ERR, GPIO4_off, 64, 0x01);
|
||||
logout::out("<EFBFBD>ر<EFBFBD><EFBFBD>ڲ<EFBFBD>Shutter",2);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user