diff --git a/CMakeSettings.json b/CMakeSettings.json index d7a047c..f8ea439 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,27 +1,5 @@ 锘縶 "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${workspaceRoot}/build_d", - "installRoot": "${workspaceRoot}/build_d", - "cmakeCommandArgs": "", - "buildCommandArgs": "-v", - "ctestCommandArgs": "" - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "Release", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${workspaceRoot}/build_r", - "installRoot": "${workspaceRoot}/build_r", - "cmakeCommandArgs": "", - "buildCommandArgs": "-v", - "ctestCommandArgs": "" - }, { "name": "Linux-GCC-Debug", "generator": "Unix Makefiles", @@ -40,6 +18,18 @@ "rsyncCommandArgs": "-t --delete --delete-excluded", "remoteCopyBuildOutput": true, "remoteCopySourcesMethod": "rsync" + }, + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [] } ] } \ No newline at end of file diff --git a/CmakeLists.txt b/CmakeLists.txt index a443857..b5b74aa 100644 --- a/CmakeLists.txt +++ b/CmakeLists.txt @@ -6,6 +6,7 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) set(QT Core Network WebSockets SerialPort Widgets) set(CMAKE_CXX_STANDARD 14) + find_package(Qt5 REQUIRED ${QT}) diff --git a/source_rlx/sensor/OptoSkyManager.cpp b/source_rlx/sensor/OptoSkyManager.cpp deleted file mode 100644 index 58069ad..0000000 --- a/source_rlx/sensor/OptoSkyManager.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "OptoSkyManager.h" - -OptoSkyManager::OptoSkyManager(QObject *parent) - : QObject(parent) -{ -} - -OptoSkyManager::~OptoSkyManager() -{ -} - -void OptoSkyManager::optall() -{ - -} - -void OptoSkyManager::getdata() -{ - -} - -void OptoSkyManager::readconnect() -{ - -} - -void OptoSkyManager::loadtcp() -{ - -} - -bool OptoSkyManager::readbutdonothing(int size) -{ - return true; -} - -bool OptoSkyManager::reloadtcp() -{ - return true; -} - -void OptoSkyManager::ChangeArrEnding(float *data, int lenth) -{ - -} - -void OptoSkyManager::conecet() -{ - -} - -void OptoSkyManager::sendMessage() -{ - -} - -void OptoSkyManager::onReciveData() -{ - -} - -void OptoSkyManager::sendgotdata() -{ - -} - -void OptoSkyManager::ComFromUI(QString commom) -{ - -} - -void OptoSkyManager::ondisconnect() -{ - -} - -void OptoSkyManager::ReadError(QAbstractSocket::SocketError) -{ - -} - - diff --git a/source_rlx/sensor/OptoSkyManager.h b/source_rlx/sensor/OptoSkyManager.h deleted file mode 100644 index f2cafed..0000000 --- a/source_rlx/sensor/OptoSkyManager.h +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include -#include "QtEndian" -#include "QTimer" -#include "QTcpSocket" -class OptoSkyManager : public QObject -{ - Q_OBJECT - -public: - OptoSkyManager(QObject *parent); - ~OptoSkyManager(); - void optall(); - void getdata(); - void readconnect(); - QString actionmod; - QTimer *timer; - int waittime; - int temp1, temp2; - void loadtcp(); - bool isreadtogotdata; - bool readbutdonothing(int size); - bool reloadtcp(); - float darkarry[2151]; - int flatwite; - int flatdark; - QString processstr; - QString IP_Address; - int SampleAverage; - int WhiteReferenceAverage; - int DarkCurrentAverage; - -private: - void ChangeArrEnding(float *data, int lenth); -public slots: - void conecet(); - void sendMessage(); - void onReciveData(); - void sendgotdata(); - void ComFromUI(QString commom); - /* void gotdata();*/ - void ondisconnect(); - void ReadError(QAbstractSocket::SocketError); - - -signals: - void Senddatatoui(QString datatype, QByteArray data); - void UpdataProcessBar(QString str, int val); -}; diff --git a/source_rlx/sensor/OptoSkyType.cpp b/source_rlx/sensor/OptoSkyType.cpp deleted file mode 100644 index bc516cf..0000000 --- a/source_rlx/sensor/OptoSkyType.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "OptoSkyType.h" -#include -#include -#include "QTime" -#include "logout.h" -QSerialPort *optoskyserial = nullptr; -bool IsOptoskyinit = false; -void OptoSky::SetPortName(QString comname, qint32 bandrate) -{ - - QSerialPortInfo info; - QList infos = QSerialPortInfo::availablePorts(); - int i = 0; - - foreach(info, infos) { - if (info.portName() == comname) break; - i++; - } - if (i != infos.size()) - { - if (optoskyserial == nullptr) - { - optoskyserial = new QSerialPort; - } - optoskyserial->close(); - optoskyserial->setPort(info); - optoskyserial->open(QIODevice::ReadWrite); - qint32 b = bandrate; - optoskyserial->setBaudRate(b); - } - else - { - IsOptoskyinit = false; - return; - } - IsOptoskyinit = true; - -} - -void OptoSky::closeport() -{ - if (optoskyserial!=nullptr) - { - delete optoskyserial; - optoskyserial = nullptr; - } -} - -void OptoSky::SendComment(QByteArray Comment) -{ - unsigned short lenth = Comment.size() + 3; - QByteArray header; - header.resize(4); - header[0] = 0xaa; - header[1] = 0x55; - header[2] = lenth / 256; - header[3] = lenth % 256; - header.append(Comment); - int sum = 0; - for (int i = 0; i < lenth-1; i++) - { - sum = sum +header[i+2]; - } - header.append(sum % 256); - if (IsOptoskyinit) - { - optoskyserial->readAll(); - optoskyserial->write(header); - optoskyserial->waitForBytesWritten(200); - - } - //char *a = header.data(); - //int c=sizeof(header); - -} - -bool OptoSky::GetReturn(char id, QByteArray &data) -{ - QByteArray b; - b.append(id); - return GetReturn(b, data); -} - -bool OptoSky::GetReturn(QByteArray &data) -{ - data.clear(); - - data = optoskyserial->readAll(); - QTime time; - time.start(); -lable1: - while (data.size() < 5) - { - optoskyserial->waitForReadyRead(50); - QByteArray tempbuf = optoskyserial->readAll(); - data.append(tempbuf); - - if (time.elapsed() > 50000) - { - logout::out("long time no data retrun "); - return false; - - } - } - if ((unsigned char)data[0] != 0xaa || (unsigned char)data[1] != 0x55) - { - data.remove(0, 1); - goto lable1; - } - - int datalenth = data[2] * 256 + data[3] + 2; - - while (data.size() < datalenth) - { - optoskyserial->waitForReadyRead(50); - data.append(optoskyserial->readAll()); - - if (time.elapsed() > 50000) - { - logout::out("long time no data retrun " ); - return false; - - } - } - - if (data.size() > datalenth) - { - data.remove(datalenth - 1, data.size() - datalenth); - } - int checkleth = datalenth - 3; - unsigned int checknum = 0; - for (size_t i = 0; i < checkleth; i++) - { - - checknum = checknum + data.at(i + 2); - } - checknum = checknum % 256; - if (checknum != (unsigned char)data[data.size() - 1]) - { - logout::out("checkerro " ); - data.clear(); - return false; - } - return true; - -} - -bool OptoSky::GetReturn(QByteArray id, QByteArray &data) -{ - if (!GetReturn(data)) - { - return false; - } - - if (data[4]!=id[0]) - { - logout::out("retrun is not correct with ComId:" + QString::number(id[0], 16)); - return false;//如果返回不是需要的则返回错误 - } - - RemoveHeaderandEnd(data); - return true; - -} - -void OptoSky::SendComment(char comid, QByteArray Data) -{ - QByteArray tem; - tem.append(comid); - tem.append(Data); - SendComment(tem); -} - -void OptoSky::SendComment(char com) -{ - QByteArray temp; - temp.append(com); - SendComment(temp); -} - -bool OptoSky::isSensorInit() -{ - return IsOptoskyinit; -} - -void OptoSky::RemoveHeaderandEnd(QByteArray &buf) -{ - if (buf.size() < 6) - { - return; - } - buf.remove(0, 5); - buf.remove(buf.size() - 1, 1); -} - -void OptoSky::SendComment(QByteArray Comment, QByteArray Data) -{ - Comment.append(Data); - SendComment(Comment); -} - - diff --git a/source_rlx/sensor/OptoSkyType.h b/source_rlx/sensor/OptoSkyType.h deleted file mode 100644 index b71044a..0000000 --- a/source_rlx/sensor/OptoSkyType.h +++ /dev/null @@ -1,77 +0,0 @@ -#pragma once -/****************************************************** -* 文件名 : OptoSkyType.h -* 类名 : -* 作用 : -* 作者 : xin -* 邮箱 : renlixin@iris-rs.cn -* 日期 : 2021-2-22 -******************************************************** -* * -* _ooOoo_ * -* o8888888o * -* 88" . "88 * -* (| -_- |) * -* O\ = /O * -* ____/`---'\____ * -* .' \\| |// `. * -* / \\||| : |||// \ * -* / _||||| -:- |||||- \ * -* | | \\\ - /// | | * -* | \_| ''\---/'' | | * -* \ .-\__ `-` ___/-. / * -* ___`. .' /--.--\ `. . __ * -* ."" '< `.___\_<|>_/___.' >'"". * -* | | : `- \`.;`\ _ /`;.`/ - ` : | | * -* \ \ `-. \_ __\ /__ _/ .-` / / * -* ======`-.____`-.___\_____/___.-`____.-'====== * -* `=---=' * -* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * -* 佛祖保佑 长发永存 * -* * -********************************************************/ - - - -#include "QByteArray" -#include"QString" -#define GET_MODEBOARD_TEMP 0x01 -#define GET_PN_NUMBER 0x03 -#define GET_SN_NUMBER 0x04 -#define GET_MANUFACTURE_DATA 0x06 -#define GET_MANUFACTOR_INFO 0x09 -#define GET_PIXEL_LENGTH 0x0a -#define GET_TEC_TEMP 0x13 -#define SET_TEC_TEMP 0x12 -#define GET_OPTICFLAT_TEMP 0x35 -#define GET_CIRCUIT_BOARD_TEMP 0x36 -#define SET_INTEGRAL_TIME 0x14 -#define GET_INTEGRAL_TIME 0x41 -#define GET_MAX_INTEGRAL_TIME 0x42 -#define GET_MIN_INTEGRAL_TIME 0x43 -#define ASYNCHRONOUS_COLLECT_DARK 0x23 -#define ASYNCHRONOUS_START_COLLECTION 0x16 -#define ASYNCHRONOUS_READ_DATA 0x17 -#define SET_AVERAGE_NUMBER 0x28 -#define SYNCHRONIZATION_GET_DATA 0x1e -#define SYNCHRONIZATION_GET_DARK 0x2f -#define EXTERNAL_TRIGGER_ENABLE 0x1f -#define SET_XENON_LAMP_DELAY_TIME 0x24 -#define GET_WAVELENGTH_CALIBRATION_COFF 0x55 -#define GET_STAT_OF_LAMPOUT 0x60 -#define SET_GPIO 0x61 -namespace OptoSky -{ - -void SetPortName(QString comname, qint32 bandrate=115200); -void closeport(); -void SendComment(QByteArray Comment); -void SendComment(char comid); -void SendComment(QByteArray Comment, QByteArray Data); -bool GetReturn(QByteArray id, QByteArray &data); -bool GetReturn(char id, QByteArray &data); -bool GetReturn(QByteArray &data); -void SendComment(char comid, QByteArray Data); -bool isSensorInit(); -void RemoveHeaderandEnd(QByteArray &buf); -} \ No newline at end of file diff --git a/source_rlx/sensor/OptoskyCommunicater.cpp b/source_rlx/sensor/OptoskyCommunicater.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source_rlx/sensor/SeaBreeze.dll b/source_rlx/sensor/SeaBreeze.dll deleted file mode 100644 index 607b18d..0000000 Binary files a/source_rlx/sensor/SeaBreeze.dll and /dev/null differ diff --git a/source_rlx/sensor/SensorBase.cpp b/source_rlx/sensor/SensorBase.cpp deleted file mode 100644 index 92f3143..0000000 --- a/source_rlx/sensor/SensorBase.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -#include "SensorBase.h" - - - -SensorBase::SensorBase() - -{ - SensorInfo.isSensorInit = false; -} - -SensorBase::~SensorBase() -{ -} diff --git a/source_rlx/sensor/SensorBase.h b/source_rlx/sensor/SensorBase.h deleted file mode 100644 index 6c89081..0000000 --- a/source_rlx/sensor/SensorBase.h +++ /dev/null @@ -1,132 +0,0 @@ -#pragma once - -#include -/****************************************************** -* 文件名 : SensorBase.cpp -* 类名 : 设备基类 -* 作用 : -* 作者 : xin -* 邮箱 : renlixin@iris-rs.cn -* 日期 : 2021-1-15 -******************************************************** -* * -* _ooOoo_ * -* o8888888o * -* 88" . "88 * -* (| -_- |) * -* O\ = /O * -* ____/`---'\____ * -* .' \\| |// `. * -* / \\||| : |||// \ * -* / _||||| -:- |||||- \ * -* | | \\\ - /// | | * -* | \_| ''\---/'' | | * -* \ .-\__ `-` ___/-. / * -* ___`. .' /--.--\ `. . __ * -* ."" '< `.___\_<|>_/___.' >'"". * -* | | : `- \`.;`\ _ /`;.`/ - ` : | | * -* \ \ `-. \_ __\ /__ _/ .-` / / * -* ======`-.____`-.___\_____/___.-`____.-'====== * -* `=---=' * -* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * -* 佛祖保佑 长发永存 * -* * -********************************************************/ -///一组数据 可以delete -enum emDataType -{ - DNVALUE=1, - REFVALUE=2, - DARKNESS=3 -}; -struct STROnePlot -{ - long BandNum; - float *Plot; - bool isInit; - float temp; - float shutter; - QStringList wavelenthlist; - long maxDNvalue; - bool hasDarkCorrect; - emDataType DataType; - STROnePlot() { - BandNum = 0; - isInit = false; - hasDarkCorrect = false; - Plot = nullptr; - DataType = DNVALUE; - } - ~STROnePlot() { - if (!isInit) - { - delete[] Plot; - isInit = false; - } - - } - -}; -struct STRSensorInfo -{ - QString SensorName; - long maxValue; - long BandNum; - QString WavelenthStr; - QStringList wavelenthlist; - //double *wavelenth; - bool isSensorInit; - QString serialnumber; - -}; - -class SensorBase : public QObject -{ - Q_OBJECT - -public: - SensorBase(); - virtual ~SensorBase(); - //************************************ - // Method: 初始化传感器 - // FullName: SensorBase::initSensor - // Access: virtual public - // Returns: void - // Qualifier: - //************************************ - virtual bool initSensor(int id=0)=0; - //************************************ - // Method: Settingshuttertime 设置积分时间 - // FullName: SensorBase::Settingshuttertime - // Access: virtual public - // Returns: void - // Qualifier: - // Parameter: int msc - //************************************ - virtual void Settingshuttertime(float msc)=0; - //************************************ - // Method: SettingTemprature 设置温度 - // FullName: SensorBase::SettingTemprature - // Access: virtual public - // Returns: void - // Qualifier: - // Parameter: float temp - //************************************ - virtual void SettingTemprature(float temp)=0; - virtual float GettingTempratrue() = 0; - virtual STRSensorInfo GetSensorInfo()=0; - virtual void SettingShutterOpen(bool isopen)=0; - virtual void SettingSwitchShutter(bool isright)=0; - virtual void GetOnePlot(STROnePlot &OnePlot,bool Dark=false)=0; - virtual void CloseSensor()=0; - - virtual void GetOneDark(STROnePlot &darkplot) = 0; - - - - QString SensorType; - int Sensorid; - STRSensorInfo SensorInfo; - STROnePlot DarkNess; - -}; diff --git a/source_rlx/sensor/SensorMannager.cpp b/source_rlx/sensor/SensorMannager.cpp deleted file mode 100644 index d4e983f..0000000 --- a/source_rlx/sensor/SensorMannager.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "SensorMannager.h" -#include "SensorQExPRO.h" -#include"qthread" -#include "logout.h" -#include "QDateTime" -#include "QLocale" -#include"SensorOptoSky.h" -int maxtime = 30000; -SensorMannager::SensorMannager(QObject *parent ) - : QObject(parent) -{ - - Numberofscan = 5; - //Sensor = new SensorQExPRO(QEPRO_QE); - Sensor = new SensorOptoSky(ATP6500,"COM12"); - Sensor->initSensor(); -} - -SensorMannager::~SensorMannager() -{ - delete Sensor; - logout::out("退出",1); - -} - -void SensorMannager::opensensor() -{ - Sensor->initSensor(); -} - -void SensorMannager::CloseSensor() -{ - Sensor->CloseSensor(); -} - -long SensorMannager::SensorOpt(int persent) -{ - long maxvalue = Sensor->SensorInfo.maxValue*1.0*persent / 100; - STROnePlot plot; - long maxvaluenow = 0; - float shutternow = 10; - if (Sensor->SensorType=="USB2000PLUS") - { - // shutternow = 1; - } - - Sensor->Settingshuttertime(shutternow); - - Sensor->GetOnePlot(plot); - if (!plot.isInit) - { - return -1; - } - maxvaluenow = Getmaxvalue(plot.Plot,4, plot.BandNum-4); - logout::out("自动曝光为: " + QString::number(shutternow) + " 毫秒 最大值为" + QString::number(maxvaluenow),1); - //QThread::msleep(1000); - int numberoftry = 0; - while (maxvaluenowmaxvalue) - { - - if (maxvaluenow > maxvalue) - { - shutternow = shutternow *0.9; - } - else - { - shutternow = maxvalue * 0.98 / (maxvaluenow * 1.0)*shutternow + 1; - } - if (shutternow>maxtime) - { - shutternow = maxtime; - } - //QThread::msleep(100); - Sensor->Settingshuttertime(shutternow); - Sensor->GetOnePlot(plot); - if (plot.isInit) - { - maxvaluenow = Getmaxvalue(plot.Plot, 4, plot.BandNum - 4); - - } - - - numberoftry++; - - logout::out("自动曝光为: " + QString::number(shutternow) + " 毫秒 最大值为"+QString::number(maxvaluenow),1); - if (numberoftry>200) - { - logout::out("曝光尝试次数过多 曝光失败",3); - return -1; - - } - if (shutternow == maxtime) - { - logout::out("曝光时间达到最大允许时间",3); - return -1*maxtime; - } - - } - logout::out("曝光成功 曝光时间为: "+QString::number(shutternow)+" 毫秒",1); - return shutternow; - -} - -long SensorMannager::Getmaxvalue(float *arr, int start, int lenth) -{ - long val = -1; - for (size_t i = start; i < lenth; i++) - { - if (val <= arr[i]) - { - val = arr[i]; - } - - } - return val; -} - -void SensorMannager::SetnumbertoGot(int nscan) -{ - Numberofscan = nscan; -} - -void SensorMannager::GetSifData(QString outfilepath, bool isskyfirs /*= true*/) -{ - - Sensor->SettingShutterOpen(true);//确保shutter打开 - QThread::msleep(50); - Sensor->SettingSwitchShutter(true);//切换为sky - logout::out("Switch 切换至SKY",1); - QThread::msleep(50); - //////////////////////////优化定标//////////////////////////////////////////////// - float skyshutter=SensorOpt(); - for (size_t i = 0; i < 3; i++) - { - - if (skyshutter!=-1) - { - break; - } - skyshutter = SensorOpt(); - - } - ///////////////////////////////////////////// - if (skyshutter==-1)//opt三次后仍未-1 说明错误 - { - logout::out("错误 结束程序",3); - return; - } - skyshutter = abs(skyshutter); - Sensor->SettingSwitchShutter(false);//切换为VEG - logout::out("Switch 切换至VEG",1); - QThread::msleep(50); - //////////////////////////veg//////////////////////////////////////////////// - float vegshutter = SensorOpt(); - for (size_t i = 0; i < 3; i++) - { - if (vegshutter ==-1 ) - { - break; - } - vegshutter = SensorOpt(); - - } - if (vegshutter == -1) - { - logout::out("错误 结束程序",3); - return; - } - vegshutter = abs(vegshutter); - //////////////////////////模块分割//////////////////////////////////////////////// - - //////////////////////////打开带输出文件//////////////////////////////////////////////// - FILE *fp = fopen(outfilepath.toStdString().c_str(), "w"); - if (fp==NULL) - { - logout::out("打开文件" + outfilepath + "失败!!", 3); - return; - } - //fprintf(fp, "%s) - STROnePlot oneplot; - float tempp = Sensor->GettingTempratrue(); - WriteTitletoCSV(fp, Sensor->SensorInfo.SensorName,Numberofscan, tempp, Sensor->SensorInfo.WavelenthStr, skyshutter, vegshutter); - logout::setoutlevel(10); - Sensor->SettingSwitchShutter(true);//切换至sky - Sensor->Settingshuttertime(skyshutter); - for (size_t i = 0; i < Numberofscan; i++) - { - logout::out("开始采集第"+QString::number(i+1)+"次Sky 数据"); - Sensor->GetOnePlot(oneplot,true); - writeonedatatoCSV(fp, oneplot); - } - - Sensor->SettingSwitchShutter(false);//切换为VEG - Sensor->Settingshuttertime(vegshutter); - for (size_t i = 0; i < Numberofscan; i++) - { - logout::out("开始采集第" + QString::number(i+1) + "次Veg 数据"); - Sensor->GetOnePlot(oneplot,true); - writeonedatatoCSV(fp, oneplot); - } - fflush(fp); - fclose(fp); - logout::out("采集完成",1); - logout::setoutlevel(); - -} - -void SensorMannager::writeonedatatoCSV(FILE *fp, STROnePlot plot) -{ - //.fprintf(fp, "%s,%s,%s\n", xvaluetoWrite.at(i).toStdString().c_str() - size_t lenth = plot.BandNum; - size_t i; - for (i = 0; i < lenth-1; i++) - { - fprintf(fp, "%s,", QString::number(plot.Plot[i], 'f', 1).toStdString().c_str()); - - } - fprintf(fp, "%s\n", QString::number(plot.Plot[i], 'f', 1).toStdString().c_str()); -} - -void SensorMannager::WriteTitletoCSV(FILE *fp, QString sensname, int NmberofScan, float temp, QString wavestring, float skyshutter, float vegshutter) -{ - if (fp == NULL) - { - return; - } - QDateTime datetime = QDateTime::currentDateTime(); - QLocale locale = QLocale::English; - QString datestr = locale.toString(datetime, "ddd MMM dd hh:mm:ss yyyy"); - fprintf(fp, "observation date and time: %s\n", datestr.toStdString().c_str()); - fprintf(fp, "numberofscan: %s\n", QString::number(Numberofscan).toStdString().c_str()); - fprintf(fp, "spectrometer: %s\n", sensname.toStdString().c_str()); - fprintf(fp, "ambient temperature: %s\n", QString::number(temp,'f',2).toStdString().c_str()); - fprintf(fp, "%s\n", wavestring.toStdString().c_str()); - fprintf(fp, "integration time 1: %s\n", QString::number(skyshutter, 'f', 2).toStdString().c_str()); - fprintf(fp, "integration time 2: %s\n", QString::number(vegshutter, 'f', 2).toStdString().c_str()); -} - diff --git a/source_rlx/sensor/SensorMannager.h b/source_rlx/sensor/SensorMannager.h deleted file mode 100644 index 10d4bd7..0000000 --- a/source_rlx/sensor/SensorMannager.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once -/****************************************************** -* 文件名 : SensorMannager.h -* 类名 : -* 作用 : -* 作者 : xin -* 邮箱 : renlixin@iris-rs.cn -* 日期 : 2021-2-22 -******************************************************** -* * -* _ooOoo_ * -* o8888888o * -* 88" . "88 * -* (| -_- |) * -* O\ = /O * -* ____/`---'\____ * -* .' \\| |// `. * -* / \\||| : |||// \ * -* / _||||| -:- |||||- \ * -* | | \\\ - /// | | * -* | \_| ''\---/'' | | * -* \ .-\__ `-` ___/-. / * -* ___`. .' /--.--\ `. . __ * -* ."" '< `.___\_<|>_/___.' >'"". * -* | | : `- \`.;`\ _ /`;.`/ - ` : | | * -* \ \ `-. \_ __\ /__ _/ .-` / / * -* ======`-.____`-.___\_____/___.-`____.-'====== * -* `=---=' * -* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * -* 佛祖保佑 长发永存 * -* * -********************************************************/ - - - -#include -#include "SensorBase.h" -enum SensorType -{ - QESENSOR = 1, - - -}; - - - - -class SensorMannager : public QObject -{ - Q_OBJECT - -public: - SensorMannager(QObject *parent=0 ); - ~SensorMannager(); - SensorBase *Sensor; - //************************************ - // Method: SensorOpt 自动优化 其中persent为默认优化到的目标 0到100 默认是100 - // FullName: SensorMannager::SensorOpt - // Access: public - // Returns: void - // Qualifier: - // Parameter: int persent - //************************************ - void opensensor(); - void CloseSensor(); - long SensorOpt(int persent=100); - - long Getmaxvalue(float *arr, int start, int lenth); - void SetnumbertoGot(int nscan); - void GetSifData(QString outfilepath,bool isskyfirs = true); -private: - int Numberofscan; - void writeonedatatoCSV(FILE *fp, STROnePlot plot); - void WriteTitletoCSV(FILE *fp,QString sensname, int NmberofScan, float temp, QString wavestring, float skyshutter, float vegshutter); -}; - - - diff --git a/source_rlx/sensor/SensorOptoSky.cpp b/source_rlx/sensor/SensorOptoSky.cpp deleted file mode 100644 index 0258871..0000000 --- a/source_rlx/sensor/SensorOptoSky.cpp +++ /dev/null @@ -1,306 +0,0 @@ -#include "SensorOptoSky.h" -#include "OptoSkyType.h" -#include "logout.h" -#include "QtEndian" -using namespace OptoSky; -SensorOptoSky::SensorOptoSky(OPTOSENSORTYPE type, QString comname, qint32 bandrate) - -{ - sensortype = type; - SensorType = "opt"; - SensorInfo.SensorName = "opotsky"; - COMname = comname; - BandRate = bandrate; - shutter.resize(2); - - //SendComment(comi); -} - -SensorOptoSky::SensorOptoSky(OPTOSENSORTYPE type, QString comname) -{ - - sensortype = type; - SensorType = "opt"; - SensorInfo.SensorName = "opotsky"; - COMname = comname; - BandRate = 115200; - shutter.resize(2); -} - -bool SensorOptoSky::initSensor(int id /*= 0*/) -{ - - - OptoSky::SetPortName(COMname, BandRate); - if (!OptoSky::isSensorInit()) - { - return false; - } - - SensorInfo = GetSensorInfo(); - float a = GettingTempratrue(); - //SendComment() - return true; -} - -void SensorOptoSky::Settingshuttertime(float msc) -{ - if (!OptoSky::isSensorInit()) - { - return; - } - shuttertime = (int)msc; - shutter[0] = (int)msc / 256; - shutter[1] = (int)msc % 256; - QByteArray temp; - SendComment(SET_INTEGRAL_TIME,shutter); - GetReturn(SET_INTEGRAL_TIME,temp); -} - -void SensorOptoSky::SettingTemprature(float temp) -{ - QByteArray buf; - buf.resize(2); - - if (temp<0) - { - buf[0] = 0xff; - } - else - { - buf[1] = 0x00; - - } - buf[1] = (int)abs(temp); - SendComment(SET_TEC_TEMP, buf); - GetReturn(SET_TEC_TEMP, buf); - -} - -float SensorOptoSky::GettingTempratrue() -{ - if (!OptoSky::isSensorInit()) - { - return 0; - } - QByteArray buf; - SendComment(GET_TEC_TEMP); - GetReturn(GET_TEC_TEMP, buf); - QString str; - str.append(buf); - float ret = str.toFloat(); - return ret; -} - -STRSensorInfo SensorOptoSky::GetSensorInfo() -{ - STRSensorInfo setem; - if (!OptoSky::isSensorInit()) - { - return setem; - } - STRSensorInfo se; - QByteArray buf; - SendComment(GET_PN_NUMBER); - GetReturn(GET_PN_NUMBER, buf); - QString str; - str.append(buf); - se.SensorName = str; - logout::out("设备型号为:" + str); - SendComment(GET_SN_NUMBER); - GetReturn(GET_SN_NUMBER, buf); - str.clear(); - str.append(buf); - logout::out("序列号为:" + str); - SendComment(GET_PIXEL_LENGTH); - GetReturn(GET_PIXEL_LENGTH, buf); - se.BandNum = buf[0] * 256 + buf[1]; - //////////////////////////模块分割//////////////////////////////////////////////// - Settingshuttertime(6); - SendComment(SYNCHRONIZATION_GET_DATA); - GetReturn(SYNCHRONIZATION_GET_DATA, buf); - se.BandNum = (buf.size() - 1)/2; - //////////////////////////模块分割//////////////////////////////////////////////// - getwavelenthlist(se); - //波长获取仍无法获取 最大值仍未获取 - //////////////////////////模块分割//////////////////////////////////////////////// - QByteArray bbb; - bbb.resize(2); - bbb[0] = 0x00; - bbb[1] = 0x01; - SendComment(SET_AVERAGE_NUMBER, bbb); - GetReturn(SET_AVERAGE_NUMBER, bbb); - se.maxValue = 65535; - return se; -} - -void SensorOptoSky::SettingShutterOpen(bool isopen) -{ - -} - -void SensorOptoSky::SettingSwitchShutter(bool isright) -{ - -} - -void SensorOptoSky::GetOnePlot(STROnePlot &OnePlot, bool Dark) -{ - OnePlot.temp = GettingTempratrue(); - - SendComment(SYNCHRONIZATION_GET_DATA,shutter); - OnePlot.shutter = shuttertime; - QByteArray buf; - if (!GetReturn(SYNCHRONIZATION_GET_DATA, buf)) - { - OnePlot.isInit = false; - return; - } - - - if ((unsigned char )buf[0]==0x00) - { - //OnePlot.isInit = true; - } - else - { - OnePlot.isInit = false; - } - int bandsumnwo = SensorInfo.BandNum; - unsigned short *arr = new unsigned short[bandsumnwo]; - memcpy(arr, buf.data() + 1, bandsumnwo*2); - if (!OnePlot.isInit) - { - OnePlot.Plot = new float[bandsumnwo]; - OnePlot.isInit = true; - } - - for (size_t i = 0; i < bandsumnwo; i++) - { - OnePlot.Plot[i] = qToBigEndian(arr[i]); - } - delete[] arr; - OnePlot.BandNum = bandsumnwo; - OnePlot.maxDNvalue = SensorInfo.maxValue; - OnePlot.wavelenthlist = SensorInfo.wavelenthlist; - if (Dark) - { - if (DarkNess.isInit) - { - if (DarkNess.shutter != shuttertime) - { - GetOneDark(DarkNess); - } - - } - else - { - GetOneDark(DarkNess); - } - - for (size_t i = 0; i < bandsumnwo; i++) - { - OnePlot.Plot[i] = OnePlot.Plot[i] - DarkNess.Plot[i]; - } - } - -} - -void SensorOptoSky::CloseSensor() -{ - closeport(); -} - -void SensorOptoSky::GetOneDark(STROnePlot &darkplot) -{ - STROnePlot &OnePlot = darkplot; - OnePlot.temp = GettingTempratrue(); - OnePlot.shutter = shuttertime; - SendComment(SYNCHRONIZATION_GET_DARK, shutter); - QByteArray buf; - if (!GetReturn(SYNCHRONIZATION_GET_DARK, buf)) - { - OnePlot.isInit = false; - return; - } - - - if ((unsigned char)buf[0] == 0x00) - { - //OnePlot.isInit = true; - } - else - { - OnePlot.isInit = false; - } - int bandsumnwo = SensorInfo.BandNum; - unsigned short *arr = new unsigned short[bandsumnwo]; - memcpy(arr, buf.data() + 1, bandsumnwo * 2); - if (!OnePlot.isInit) - { - OnePlot.Plot = new float[bandsumnwo]; - OnePlot.isInit = true; - } - for (size_t i = 0; i < bandsumnwo; i++) - { - OnePlot.Plot[i] = qToBigEndian(arr[i]); - - - } - delete[] arr; - OnePlot.BandNum = bandsumnwo; - OnePlot.maxDNvalue = SensorInfo.maxValue; - OnePlot.wavelenthlist = SensorInfo.wavelenthlist; - OnePlot.DataType = DARKNESS; - -} - -SensorOptoSky::~SensorOptoSky() -{ - CloseSensor(); -} - -void SensorOptoSky::RemoveHeaderandEnd(QByteArray &buf) -{ - if (buf.size()<6) - { - return; - } - buf.remove(0, 5); - buf.remove(buf.size() - 1,1); - -} - -void SensorOptoSky::getwavelenthlist(STRSensorInfo &se) -{ - if (!OptoSky::isSensorInit()) - { - return ; - } - QByteArray bufin; - bufin.resize(2); - bufin[0] = 0x00; - bufin[1] = 0x01; - QByteArray buf; - SendComment(GET_WAVELENGTH_CALIBRATION_COFF,bufin); - GetReturn(GET_WAVELENGTH_CALIBRATION_COFF, buf); - float a[4]; - memcpy(a, buf.data() + 16, 4 * 4); - int bandsss = se.BandNum; - QStringList strlist; - QString str=""; - int i = 0; - for ( i = 0; i _/___.' >'"". * -* | | : `- \`.;`\ _ /`;.`/ - ` : | | * -* \ \ `-. \_ __\ /__ _/ .-` / / * -* ======`-.____`-.___\_____/___.-`____.-'====== * -* `=---=' * -* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * -* 佛祖保佑 长发永存 * -* * -********************************************************/ - - - -#include -enum OPTOSENSORTYPE -{ - ATP6500 = 1 -}; -class SensorOptoSky : public SensorBase -{ - Q_OBJECT - -public: - SensorOptoSky(OPTOSENSORTYPE type, QString comname); - SensorOptoSky(OPTOSENSORTYPE type, QString comname, qint32 bandrate); - bool initSensor(int id = 0); - void Settingshuttertime(float msc) ; - //************************************ - // Method: SettingTemprature 设置温度 - // FullName: SensorBase::SettingTemprature - // Access: virtual public - // Returns: void - // Qualifier: - // Parameter: float temp - //************************************ - void SettingTemprature(float temp); - float GettingTempratrue() ; - STRSensorInfo GetSensorInfo(); - void SettingShutterOpen(bool isopen); - void SettingSwitchShutter(bool isright); - void GetOnePlot(STROnePlot &OnePlot, bool Dark=false) ; - void CloseSensor() ; - - void GetOneDark(STROnePlot &darkplot); - - - - OPTOSENSORTYPE sensortype; - QString COMname; - qint32 BandRate; - ~SensorOptoSky(); -private: - void RemoveHeaderandEnd(QByteArray &buf); - void getwavelenthlist( STRSensorInfo &se); - QByteArray shutter; - int shuttertime; - -}; diff --git a/source_rlx/sensor/SensorQExPRO.cpp b/source_rlx/sensor/SensorQExPRO.cpp deleted file mode 100644 index 677cc93..0000000 --- a/source_rlx/sensor/SensorQExPRO.cpp +++ /dev/null @@ -1,327 +0,0 @@ -#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("找到 " + QString::number(number_of_QE) + "个设备",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("设备id为:" + QString::number(Device_ids[id]),2); - DeviceId = Device_ids[id]; - - char namearr[100]; - //获取名称 - 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("设备型号:" + sensorname,2); - } - Sensorid = DeviceId; - //打开设备 - FLAG= sbapi_open_device(DeviceId, &ERR); - logout::out("设备打开:" + QString(sbapi_get_error_string(ERR)),2); - if (FLAG!=0) - { - //如果失败 返回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("设备打开:" + QString(sbapi_get_error_string(ERR))); -// qDebug() << "hello"; - SensorInfo=GetSensorInfo(); - - - //为温度二设置的 - 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("设置曝光时间:" + 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]; - //获取名称 - 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("设备型号:" + sensorname, 2); - } - return sensorinof; -} - -void SensorQExPRO::SettingShutterOpen(bool isopen) -{ - //树莓派 4针脚 - system("gpio mode 4 output"); - if (isopen) - { - system("gpio write 4 1"); - logout::out("打开 Shutter gpio",2); - } - else - { - system("gpio write 4 0"); - logout::out("关闭 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("切换至SKY",2); - } - else - { - system("gpio write 5 0"); - logout::out("切换至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("获取数据:" + QString(sbapi_get_error_string(ERR)),5); - if (QEType != USB2000PLUS_QE) - { - OnePlot.temp = GettingTempratrue(); - logout::out("获取温度:" + QString(sbapi_get_error_string(ERR)) + " 温度为:" + QString::number(OnePlot.temp, 'f', 2) + "℃",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("当前温度为:"+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("设置shutter 为gpio",2); - if (isopen) - { - lenth = sbapi_raw_usb_bus_access_write(DeviceId, FNid, &ERR, GPIO4on, 64, 0x01); - logout::out("打开内部Shutter",2); - } - else - { - lenth = sbapi_raw_usb_bus_access_write(DeviceId, FNid, &ERR, GPIO4_off, 64, 0x01); - logout::out("关闭内部Shutter",2); - } - - -} diff --git a/source_rlx/sensor/SensorQExPRO.h b/source_rlx/sensor/SensorQExPRO.h deleted file mode 100644 index 88e11d7..0000000 --- a/source_rlx/sensor/SensorQExPRO.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once -#pragma execution_character_set("utf-8") -#include "SensorBase.h" -enum EMQEType -{ - QEPRO_QE=1, - QE65PRO_QE=2, - USB2000PLUS_QE =3, - QE65000_QE = 4, - NONQE=-1 -}; -class SensorQExPRO : public SensorBase -{ - Q_OBJECT - -public: - SensorQExPRO(EMQEType qetype); - ~SensorQExPRO(); - bool initSensor(int id=0); - void Settingshuttertime(float msc); - //************************************ - // Method: SettingTemprature 设置温度 - // FullName: SensorBase::SettingTemprature - // Access: virtual public - // Returns: void - // Qualifier: - // Parameter: float temp - //************************************ - void SettingTemprature(float temp); - STRSensorInfo GetSensorInfo() ; - void SettingShutterOpen(bool isopen); - //************************************ - // Method: SettingSwitchShutter sky为right - // FullName: SensorQExPRO::SettingSwitchShutter - // Access: public - // Returns: void - // Qualifier: - // Parameter: bool isright sky为right - //************************************ - void SettingSwitchShutter(bool isright); - void GetOnePlot(STROnePlot &OnePlot, bool Dark=false); - float GettingTempratrue(); - void CloseSensor(); - void GetOneDark(STROnePlot &darkplot); - EMQEType QEType; -private: - - long *Device_ids; - long DeviceId; - int ERR = 0; - int FLAG = 0; - unsigned char *OutputMod, *Shuteroncom, *Shuteroffcom; - long Numberoftempratrue; - long *TemPratrueId; - long *SpecMetersId; - EMQEType getEMUbyQstring(QString str); - - void SetQEProShutter(bool isopen); - float shuttertime; -; - - -}; diff --git a/source_rlx/sensor/TCPServer.h b/source_rlx/sensor/TCPServer.h deleted file mode 100644 index 548fdc1..0000000 --- a/source_rlx/sensor/TCPServer.h +++ /dev/null @@ -1,301 +0,0 @@ - -#ifndef _TCPSERVER_H_ -#define _TCPSERVER_H_ -// -// Return Header values. -// -#define H_NO_ERROR (100) -#define H_COLLECT_ERROR (200) -#define H_COLLECT_NOT_LOADED (300) -#define H_INIT_ERROR (400) -#define H_FLASH_ERROR (500) -#define H_RESET_ERROR (600) -#define H_INTERPOLATE_ERROR (700) -#define H_OPTIMIZE_ERROR (800) -#define H_INSTRUMENT_CONTROL_ERROR (900) -// -// Return error codes. -// -#define NO_ERROR_ (0) -#define NOT_READY (-1) -#define NO_INDEX_MARKS (-2) -#define TOO_MANY_ZEROS (-3) -#define SCANSIZE_ERROR (-4) -// -5 unused -#define COMMAND_ERROR (-6) -#define INI_FULL (-7) -#define MISSING_PARAMETER (-8) -// -9 unused - now -20, -21, -22 -#define VNIR_TIMEOUT (-10) -#define SWIR_TIMEOUT (-11) -#define VNIR_NOT_READY (-12) -#define SWIR1_NOT_READY (-13) -#define SWIR2_NOT_READY (-14) -#define VNIR_OPT_ERROR (-15) -#define SWIR1_OPT_ERROR (-16) -#define SWIR2_OPT_ERROR (-17) -#define ABORT_ERROR (-18) -#define PARAM_ERROR (-19) -#define VNIR_INTERP_ERROR (-20) -#define SWIR1_INTERP_ERROR (-21) -#define SWIR2_INTERP_ERROR (-22) -// -// -// -#define MAX_PARAMETERS (200) -// -// Detector Index Value -// -#define SWIR1 (0) -#define SWIR2 (1) -#define VNIR (2) -// -// Instrument Type values -// -#define V_INSTRUMENT_TYPE (1) // VNIR Only -#define DUAL_VNIR_INSTRUMENT_TYPE (2) // Dual VNIR -#define S1_INSTRUMENT_TYPE (4) // SWIR1 Only -#define VS1_INSTRUMENT_TYPE (5) // VNIR and SWIR1 -#define S2_INSTRUMENT_TYPE (8) // SWIR2 ONly -#define VS2_INSTRUMENT_TYPE (9) // VNIR and SWIR2 -#define S1S2_INSTRUMENT_TYPE (12) // SWIR1 and SWIR2 -#define FR_INSTRUMENT_TYPE (13) // VNIR and SWIR1 and SWIR2 -// -// Instrument Control values -// -#define IC_IT (0) -#define IC_GAIN (1) -#define IC_OFFSET (2) -#define IC_SHUTTER (3) -#define IC_TRIGGER (4) -// -// Union used to swap word to make double value -// -union dv -{ - double d; - unsigned long l[sizeof(double) / sizeof(long)]; - unsigned char c[sizeof(double)]; -}; -// -// Vnir Header section -// -struct Vnir_Header -{ - int IT; - int scans; - int max_channel; - int min_channel; - int saturation; - int shutter; - int drift; - int dark_subtracted; - int reserved[8]; -}; -// -// Swir Header section -// -struct Swir_Header -{ - int tec_status; - int tec_current; - int max_channel; - int min_channel; - int saturation; - int A_Scans; - int B_Scans; - int dark_current; - int gain; - int offset; - int scansize1; - int scansize2; - int dark_subtracted; - int reserved[3]; -}; -// -// return Spectrum Header -// -struct SpectrumHeader -{ - int Header; - int errbyte; - int sample_count; - int trigger; - int voltage; - int current; - int temperature; - int motor_current; - int instrument_hours; - int instrument_minutes; - int instrument_type; - int AB; - int reserved[4]; - Vnir_Header v_header; - Swir_Header s1_header; - Swir_Header s2_header; -}; -// -// Acquire structure to return for Full Range Spectrometers -// -struct FRSpecStruct -{ - SpectrumHeader FRHeader; - union - { - float f; - int i; - }SpecBuffer[2151]; -}; - -// -// Acquire structure to return for Vnir Spectrometers -// -struct VSpecStruct -{ - SpectrumHeader VHeader; - union - { - float f; - int i; - }SpecBuffer[701]; -}; -// -// Acquire structure to return for Swir1 Swir2 Spectrometers -// -struct S1S2SpecStruct -{ - SpectrumHeader S1S2Header; - union - { - float f; - int i; - }SpecBuffer[1502]; -}; -// -// Acquire structure to return for Swir1 Spectrometers -// -struct S1SpecStruct -{ - SpectrumHeader S1SpectrumHeader; - union - { - float f; - int i; - }SpecBuffer[801]; -}; -// -// Acquire structure to return for Swir2 Spectrometers -// -struct S2SpecStruct -{ - SpectrumHeader S2Header; - union - { - float f; - int i; - }SpecBuffer[701]; -}; -// -// Acquire structure to return for Vnir/Swir1 Spectrometers -// -struct VS1SpecStruct -{ - SpectrumHeader VS1Header; - union - { - float f; - int i; - }SpecBuffer[1502]; -}; -// -// Acquire structure to return for Vnir/Swir2 Spectrometers -// -struct VS2SpecStruct -{ - SpectrumHeader VS2Header; - union - { - float f; - int i; - }SpecBuffer[1402]; -}; -// -// Ini struct for the flash -// -struct InitStruct -{ - int Header; //header type used in TCP transfer. - int errbyte; //error code - char name[MAX_PARAMETERS][30]; //space for 200 entries with 30 character names - double value[MAX_PARAMETERS]; //corresponding data values for the 200 entries - int count; //The number of used entries - int verify; //the checksum -}; -// -// Version structure for V Command -// -struct VersionStruct -{ - int Header; //header type used in TCP transfer. - int errbyte; //error code - char version[30]; //30 character version string - double value; //version value - int type; // Type of instrument 1-Vnir, 4-Swir1, 5-Vnir/Swir1 -}; // 8-Siwr2, 9-Vnir/Swir2 -// 12-Swir1/Swir2, 13-Vnir/Swir1/Swir2 -// -// Optimize structure for OPT command -// -struct OptimizeStruct -{ - int Header; //header type used in TCP transfer. - int errbyte; //error code - int itime; //optimized integration time - int gain[2]; //optimized gain for 2 SWIRs - int offset[2]; //optimized offset for 2 SWIRs -}; -// -// Param structure for INIT command -// -struct ParamStruct -{ - int Header; //header type used in TCP transfer. - int errbyte; //error code - char name[30]; //30 character name - double value; //corresponding data values - int count; //number of entries used -}; -// -// Instrument Control Structure for IC command -// -struct InstrumentControlStruct -{ - int Header; //header type used in TCP transfer. - int errbyte; //error code - int detector; //detector value - IC_IT,IC_GAIN,IC_OFFSET,IC_SHUTTER - int cmdType; //detector command - int value; //command value -}; -// -// Header Struct for Restore Command -// -struct HeaderStruct -{ - int Header; // Header value used in TCP transfer - int errbyte; // error code -}; - - - - -struct FRInterpSpecStruct -{ - - SpectrumHeader FRSpectrumHeader; //256 bytes (64 words) - //int arr[761]; - float SpecBuffer[2151]; -}; - - - -#endif diff --git a/source_rlx/sensor/logout.cpp b/source_rlx/sensor/logout.cpp deleted file mode 100644 index 17e444d..0000000 --- a/source_rlx/sensor/logout.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "logout.h" -#include "QDebug" -#include "QTextCodec" -QString colorcode = "\033["; -int outputlevel = 4; -logout::logout(QObject *parent) - : QObject(parent) -{ -} - -logout::~logout() -{ -} - -void logout::out(QString str,int level) -{ - if (level>outputlevel) - { - return; - } - QTextCodec *codec = QTextCodec::codecForName("GBK");//修改这两行 - int colorint; - switch (level) - { - case 0: - { - - - break; - } - case 1: - { - - qDebug() << "\033[32m";//绿色 - break; - } - case 2: - { - - qDebug() << "\033[35m";//绿色 - break; - } - case 3: - { - - qDebug() << "\033[31m";//红色 - break; - } - default: - { - break; - } - } - //str=codec->toUnicode(str.toStdString().c_str()); - qDebug() < - -class logout : public QObject -{ - Q_OBJECT - - - -public: - logout(QObject *parent); - ~logout(); - static void out(QString str, int level=0); - static void setoutlevel(int level = 4); -};