From cb5a74f57680b285bab534e6cbb75d8f7afaa497 Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Wed, 1 Jul 2026 23:16:14 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=20=E5=B1=B1=E5=9C=B0=E6=89=80?= =?UTF-8?q?=E8=B4=A1=E5=98=8E=E5=B1=B1=EF=BC=8C=E9=83=A8=E5=88=86=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=9A=EF=BC=881=EF=BC=89=E5=8F=B3=E4=B8=8B?= =?UTF-8?q?=E8=A7=92=E6=B7=BB=E5=8A=A0=E6=8E=A7=E5=88=B6is11=E7=9A=84?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=882=EF=BC=89=E6=B7=BB=E5=8A=A0is11?= =?UTF-8?q?=EF=BC=88=E9=89=B4=E7=9F=A5=EF=BC=89=E6=8E=A7=E5=88=B6=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HPPA.sln | 10 + HPPA/FiberSpectrometerOperationBase.h | 61 ++ HPPA/FodisWindow.cpp | 88 +++ HPPA/FodisWindow.h | 50 ++ HPPA/HPPA.cpp | 28 + HPPA/HPPA.h | 3 + HPPA/HPPA.ui | 9 + HPPA/HPPA.vcxproj | 10 +- HPPA/HPPA.vcxproj.filters | 18 + HPPA/JinspFiberImager.cpp | 312 ++++++++++ HPPA/JinspFiberImager.h | 68 +++ HPPA/fodis.ui | 205 +++++++ .../IrisFiberSpectrometerBase.h | 43 ++ .../JinspSpectralmeterControl.cpp | 578 ++++++++++++++++++ .../JinspSpectralmeterControl.h | 132 ++++ .../JinspSpectralmeterControl.vcxproj | 102 ++++ .../JinspSpectralmeterControl.vcxproj.filters | 45 ++ JinspSpectralmeterControl/ZZ_Math.h | 121 ++++ JinspSpectralmeterControl/ZZ_Types.h | 358 +++++++++++ .../jinspspectralmetercontrol_global.h | 13 + 20 files changed, 2252 insertions(+), 2 deletions(-) create mode 100644 HPPA/FiberSpectrometerOperationBase.h create mode 100644 HPPA/FodisWindow.cpp create mode 100644 HPPA/FodisWindow.h create mode 100644 HPPA/JinspFiberImager.cpp create mode 100644 HPPA/JinspFiberImager.h create mode 100644 HPPA/fodis.ui create mode 100644 JinspSpectralmeterControl/IrisFiberSpectrometerBase.h create mode 100644 JinspSpectralmeterControl/JinspSpectralmeterControl.cpp create mode 100644 JinspSpectralmeterControl/JinspSpectralmeterControl.h create mode 100644 JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj create mode 100644 JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj.filters create mode 100644 JinspSpectralmeterControl/ZZ_Math.h create mode 100644 JinspSpectralmeterControl/ZZ_Types.h create mode 100644 JinspSpectralmeterControl/jinspspectralmetercontrol_global.h diff --git a/HPPA.sln b/HPPA.sln index 7f6148e..fdbd8ff 100644 --- a/HPPA.sln +++ b/HPPA.sln @@ -12,6 +12,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vincecontrol", "vincecontro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrisMultiMotorController", "IrisMultiMotorController\IrisMultiMotorController\IrisMultiMotorController.vcxproj", "{2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JinspSpectralmeterControl", "JinspSpectralmeterControl\JinspSpectralmeterControl.vcxproj", "{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -44,6 +46,14 @@ Global {2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x64.Build.0 = Release|x64 {2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.ActiveCfg = Release|x64 {2E792AA6-1BCB-4CDA-BE01-4D455EC5C473}.Release|x86.Build.0 = Release|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x64.ActiveCfg = Debug|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x64.Build.0 = Debug|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x86.ActiveCfg = Debug|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Debug|x86.Build.0 = Debug|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x64.ActiveCfg = Release|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x64.Build.0 = Release|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x86.ActiveCfg = Release|x64 + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}.Release|x86.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/HPPA/FiberSpectrometerOperationBase.h b/HPPA/FiberSpectrometerOperationBase.h new file mode 100644 index 0000000..5318d9e --- /dev/null +++ b/HPPA/FiberSpectrometerOperationBase.h @@ -0,0 +1,61 @@ +// +// Created by tangchao on 2022/1/11. +// + +#ifndef OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H +#define OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H + + +#include "ZZ_Types.h" + +using namespace ZZ_MISCDEF; +using namespace ZZ_MISCDEF::IRIS::FS; + +class FiberSpectrometerOperationBase +{ + +public: +// FiberSpectrometerOperationBase(); +// ~FiberSpectrometerOperationBase(); + + virtual void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo) = 0; + virtual void disconnectFiberSpectrometer() = 0; + virtual void getDeviceAttribute(DeviceAttribute& deviceAttribute) = 0; + virtual void getDeviceInfo(DeviceInfo& deviceInfo) = 0; + + virtual void setExposureTime(int iExposureTimeInMS) = 0; + + virtual void getExposureTime(int &iExposureTimeInMS) = 0; + virtual void getDeviceTemperature(float &fTemperature) = 0; + + virtual void singleShot(DataFrame &dfData) = 0; + +// typedef struct coeffs +// { +// ZZ_U32 coeffsCounter; +// double coeffs[100]; +// }coeffsFrame; + virtual void getNonlinearityCoeffs(coeffsFrame &coeffs) = 0; + + +// ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number) = 0; + + DataFrame m_IntegratingSphereData; + DataFrame m_DarkData; +protected: + ZZ_U32 m_MaxValueOfFiberSpectrometer; +private: + + + +public slots: + virtual void recordDark(QString path) = 0; + virtual void recordTarget(int recordTimes, QString path) = 0; + virtual void autoExpose() = 0; + + signals: + void sendExposureTimeSignal(int exposureTime); + +}; + +#endif //OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H diff --git a/HPPA/FodisWindow.cpp b/HPPA/FodisWindow.cpp new file mode 100644 index 0000000..17a7790 --- /dev/null +++ b/HPPA/FodisWindow.cpp @@ -0,0 +1,88 @@ +#include "FodisWindow.h" + +FodisWindow::FodisWindow(QWidget* parent) + : QDialog(parent) +{ + ui.setupUi(this); + + m_FiberImagerThread = new QThread(); + m_JinspFiberImagerOperation = new JinspFiberImager(false, "COM9", "JINSP"); + m_JinspFiberImagerOperation->moveToThread(m_FiberImagerThread); + m_FiberImagerThread->start(); + + connect(ui.open_btn, &QPushButton::clicked, this, &FodisWindow::openDepthCamera); + connect(ui.close_btn, &QPushButton::clicked, this, &FodisWindow::closeDepthCamera); + + connect(this, &FodisWindow::openFiberImagerSignal, m_JinspFiberImagerOperation, &JinspFiberImager::OpenFiberImagerAndRecord); + + //connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamOpenedSignal, this, &FodisWindow::onCamOpened); + //connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamClosedSignal, this, &FodisWindow::onCamClosed); + + //connect(m_JinspFiberImagerOperation, &JinspFiberImager::PlotSignal, this, &FodisWindow::PlotSpectralSignal); + //connect(m_JinspFiberImagerOperation, &JinspFiberImager::CamClosedSignal, this, &FodisWindow::FiberImagerClosedSignal); + + connect(this->ui.dataFolderBtn, SIGNAL(clicked()), this, SLOT(onSelectDataFolder())); + + // 初始化数据保存路径显示(从 AppSettings 恢复或使用默认) + ui.dataFolderLineEdit->setText(AppSettings::instance().depthCameraDataFolder()); +} + +FodisWindow::~FodisWindow() +{ + m_FiberImagerThread->quit(); + m_FiberImagerThread->wait(); + delete m_JinspFiberImagerOperation; + m_JinspFiberImagerOperation = nullptr; +} + +void FodisWindow::onSelectDataFolder() +{ + QString dir = QFileDialog::getExistingDirectory(this, + QString::fromLocal8Bit("选择数据保存路径"), + ui.dataFolderLineEdit->text()); + + setDataFolder(dir); +} + +void FodisWindow::setDataFolder(QString dir) +{ + if (!dir.isEmpty()) + { + ui.dataFolderLineEdit->setText(dir); + AppSettings::instance().setDepthCameraDataFolder(dir); + } +} + +void FodisWindow::setCaptureInterval(int captureIntervalSeconds) +{ + m_JinspFiberImagerOperation->setCaptureInterval(captureIntervalSeconds); +} + +void FodisWindow::openDepthCamera() +{ + if (!m_JinspFiberImagerOperation->getRecordStatus()) + { + emit openFiberImagerSignal(); + } +} + +void FodisWindow::onCamOpened() +{ + ui.open_btn->setEnabled(false); + ui.close_btn->setEnabled(true); + + ui.open_btn->setText(QString::fromLocal8Bit("已打开")); +} + +void FodisWindow::closeDepthCamera() +{ + m_JinspFiberImagerOperation->disconnectFiberSpectrometer(); +} + +void FodisWindow::onCamClosed() +{ + ui.open_btn->setEnabled(true); + ui.close_btn->setEnabled(false); + + ui.open_btn->setText(QString::fromLocal8Bit("打 开")); +} diff --git a/HPPA/FodisWindow.h b/HPPA/FodisWindow.h new file mode 100644 index 0000000..b3147ea --- /dev/null +++ b/HPPA/FodisWindow.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +//#include +#include + +#include +#include "ui_fodis.h" +#include "AppSettings.h" + +#include + +#include "JinspFiberImager.h" + +class FodisWindow : public QDialog +{ + Q_OBJECT + +public: + FodisWindow(QWidget* parent = nullptr); + ~FodisWindow(); + + void setDataFolder(QString dir); + void setCaptureInterval(int captureIntervalSeconds); + +public Q_SLOTS: + void openDepthCamera(); + void onCamOpened(); + void closeDepthCamera(); + void onCamClosed(); + + void onSelectDataFolder(); + +signals: + void openFiberImagerSignal(); + void PlotSpectralSignal(); + void FiberImagerClosedSignal(); + +private: + Ui::FodisWindow ui; + QThread* m_FiberImagerThread; + + JinspFiberImager* m_JinspFiberImagerOperation; +}; diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index 22f3fec..c2a4eb6 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -116,6 +116,7 @@ HPPA::HPPA(QWidget* parent) connect(this->ui.mSetting, SIGNAL(triggered()), this, SLOT(settingWindow())); connect(this->ui.action_about, SIGNAL(triggered()), this, SLOT(onAbout())); connect(this->ui.mActionOneMotorScenario, SIGNAL(triggered()), this, SLOT(createOneMotorScenario())); + connect(this->ui.mActionGonggaRotatingPlatformScenario, SIGNAL(triggered()), this, SLOT(createGonggaRotatingPlatformScenario())); connect(this->ui.mActionPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(createPlantPhenotypeScenario())); connect(this->ui.mAction3DPlantPhenotypeScenario, SIGNAL(triggered()), this, SLOT(create3DPlantPhenotypeScenario())); connect(this->ui.mActionMicroscopicMotionControlScenario, SIGNAL(triggered()), this, SLOT(createMicroscopicMotionControlScenario())); @@ -1018,6 +1019,11 @@ void HPPA::initControlTabwidget() m_tmc->setWindowFlags(Qt::Widget); ui.controlTabWidget->addTab(m_tmc, QString::fromLocal8Bit("2杞存帶鍒")); + //is11 + m_fodisWindow = new FodisWindow(this); + m_fodisWindow->setWindowFlags(Qt::Widget); + ui.controlTabWidget->addTab(m_fodisWindow, QString::fromLocal8Bit("FODIS")); + // Connect ImageControl band change to re-render (m_ic created in initControlTabwidget) //connect(m_ic, SIGNAL(bandSelectionChanged(double, double, double)), // this, SLOT(onBandSelectionChanged(double, double, double))); @@ -1435,6 +1441,7 @@ void HPPA::createScenarioActionGroup() { m_ScenarioActionGroup = new QActionGroup(this); m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario); + m_ScenarioActionGroup->addAction(ui.mActionGonggaRotatingPlatformScenario); m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario); m_ScenarioActionGroup->addAction(ui.mAction3DPlantPhenotypeScenario); m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario); @@ -1449,6 +1456,11 @@ void HPPA::createScenarioActionGroup() ui.mActionOneMotorScenario->setChecked(true); ui.mActionOneMotorScenario->trigger(); } + else if (lastSelectedAction == "mActionGonggaRotatingPlatformScenario") + { + ui.mActionGonggaRotatingPlatformScenario->setChecked(true); + ui.mActionGonggaRotatingPlatformScenario->trigger(); + } else if (lastSelectedAction == "mActionPlantPhenotypeScenario") { ui.mActionPlantPhenotypeScenario->setChecked(true); @@ -1506,6 +1518,22 @@ void HPPA::createOneMotorScenario() } +void HPPA::createGonggaRotatingPlatformScenario() +{ + //鍦ㄨ彍鍗曚腑閫夋嫨绉诲姩骞冲彴 + ui.mAction_1AxisMotor->setChecked(true); + + //鍙充笅瑙掓帶鍒秚ab + m_tabManager->hideAllTabs(); + + m_tabManager->showTab(m_hic); + m_tabManager->showTab(m_ic); + m_tabManager->showTab(m_fodisWindow); + m_tabManager->showTab(m_omc); + + m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::OneMotor); +} + void HPPA::onCreated3DModelPlantPhenotype() { connect(m_tmc, SIGNAL(broadcastLocationSignal(std::vector)), m_view3DModelManager->m_viewPlant, SLOT(setLoc(std::vector))); diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h index b6398d3..fd2eb08 100644 --- a/HPPA/HPPA.h +++ b/HPPA/HPPA.h @@ -87,6 +87,7 @@ #include "TimedDataCollection.h" #include "PowerControl3D.h" +#include "FodisWindow.h" #include @@ -319,6 +320,7 @@ private: RobotArmControl* m_rac; OneMotorControl* m_omc; TwoMotorControl* m_tmc; + FodisWindow* m_fodisWindow; QPointer m_tdc; View3DModelManager* m_view3DModelManager; @@ -410,6 +412,7 @@ public Q_SLOTS: void recordFromRobotArm(int fileCounter); void createOneMotorScenario(); + void createGonggaRotatingPlatformScenario(); void createPlantPhenotypeScenario(); void create3DPlantPhenotypeScenario(); void onCreated3DModelPlantPhenotype(); diff --git a/HPPA/HPPA.ui b/HPPA/HPPA.ui index 16c3dc1..b556dbf 100644 --- a/HPPA/HPPA.ui +++ b/HPPA/HPPA.ui @@ -133,6 +133,7 @@ color:white; 搴旂敤鍦烘櫙 + @@ -749,6 +750,14 @@ QPushButton:pressed 瀹氭椂閲囬泦 + + + true + + + 璐″槑灞辨棆杞钩鍙 + + diff --git a/HPPA/HPPA.vcxproj b/HPPA/HPPA.vcxproj index bab3e65..660b733 100644 --- a/HPPA/HPPA.vcxproj +++ b/HPPA/HPPA.vcxproj @@ -55,7 +55,7 @@ - D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;$(IncludePath) + D:\cpp_library\gdal2.2.3_vs2017\include;C:\Program Files\ResononAPI\include;D:\cpp_library\opencv3.4.11\opencv\build\include;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv;D:\cpp_library\opencv3.4.11\opencv\build\include\opencv2;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PCOMM\Include;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL\SDKs\PortControl;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\AutoFocus_InspireLinearMotor_DLL;D:\cpp_project_vs2022\HPPA\HPPA;D:\cpp_library\libconfig-1.7.3\lib;D:\cpp_project_vs2022\HPPA\vincecontrol;D:\cpp_library\vincecontrol_vs2017;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\IrisMultiMotorController;D:\cpp_library\eigen-3.4-rc1;C:\Program Files\OrbbecSDK 2.7.6\include;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Header;D:\cpp_project_vs2022\HPPA\JinspSpectralmeterControl;$(IncludePath) D:\cpp_library\opencv3.4.11\opencv\build\x64\vc15\lib;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Debug;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\HPPA\x64\Debug;C:\XIMEA\API\xiAPI;D:\cpp_project_vs2022\HPPA\IrisMultiMotorController\x64\Debug;C:\Program Files\OrbbecSDK 2.7.6\lib;D:\cpp_library\EDSDK132010CD(13.20.10)\Windows\EDSDK_64\Library;$(LibraryPath) Spectral Insight @@ -66,7 +66,7 @@ - opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies) + opencv_world3411.lib;opencv_world3411d.lib;gdal_i.lib;resonon-basler.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++d.lib;vincecontrol.lib;resonon-allied.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;JinspSpectralmeterControl.lib;%(AdditionalDependencies) D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories) @@ -118,12 +118,14 @@ + + @@ -177,6 +179,7 @@ + @@ -231,6 +234,8 @@ + + @@ -245,6 +250,7 @@ + diff --git a/HPPA/HPPA.vcxproj.filters b/HPPA/HPPA.vcxproj.filters index d9c467b..f4c4a53 100644 --- a/HPPA/HPPA.vcxproj.filters +++ b/HPPA/HPPA.vcxproj.filters @@ -253,6 +253,12 @@ Source Files + + Source Files + + + Source Files + @@ -414,6 +420,12 @@ Header Files + + Header Files + + + Header Files + @@ -473,6 +485,9 @@ Header Files + + Header Files + @@ -529,6 +544,9 @@ Form Files + + Form Files + diff --git a/HPPA/JinspFiberImager.cpp b/HPPA/JinspFiberImager.cpp new file mode 100644 index 0000000..651f86e --- /dev/null +++ b/HPPA/JinspFiberImager.cpp @@ -0,0 +1,312 @@ +// +// Created by 73505 on 2023/5/7. +// + +#include "JinspFiberImager.h" + +JinspFiberImager::JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName) +{ + m_FiberSpectrometer = NULL; + + mUcPortNumber=ucPortNumber; + + m_record = false; + + m_captureTimer = new QTimer(this); + connect(m_captureTimer, &QTimer::timeout, this, &JinspFiberImager::recordSpectral); + + m_captureIntervalMilliseconds = 5 * 1000; +} + +JinspFiberImager::~JinspFiberImager() +{ + +} + +void JinspFiberImager::connectFiberSpectrometer(QString& SN, QString& pixelCount, QString& wavelengthInfo) +{ + using namespace std; + + m_FiberSpectrometer = new JinspSpectralmeterControl(); + + m_FiberSpectrometer->Initialize(false, mUcPortNumber, "OPTOSKY"); + + DeviceInfo deviceInfo;// + DeviceAttribute deviceAttribute; + + m_FiberSpectrometer->GetDeviceInfo(deviceInfo); + m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);//锛燂紵锛燂紵锛 + + SN = QString::fromStdString(deviceInfo.strSN); + pixelCount = QString::number(deviceAttribute.iPixels); + wavelengthInfo = QString::number(deviceAttribute.fWaveLengthInNM[0]) + "--" + QString::number(deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1]); + + m_FiberSpectrometer->SetDeviceTemperature(-10); + + + //璁剧疆dn鍊肩殑鏈澶у硷紙鍜屼綅娣辩浉鍏筹級 + string qepro = "QEP";//????????????????????????????????????????????????????????????????????????????????????????? + string flame = "FLMS";//????????????????????????????????????????????????????????????????????????????????????????? + if (deviceInfo.strSN.find(qepro) != string::npos) + { + m_MaxValueOfFiberSpectrometer = 200000; + } + else if (deviceInfo.strSN.find(flame) != string::npos) + { + m_MaxValueOfFiberSpectrometer = 65535; + } + else//娌℃湁鎵惧埌鍖归厤鐨勪华鍣ㄦ潵璁剧疆 dn鍊肩殑鏈澶у + { + m_MaxValueOfFiberSpectrometer = 65535; + } + +} + +void JinspFiberImager::disconnectFiberSpectrometer() +{ + m_FiberSpectrometer->Close(); + + m_captureTimer->stop(); + + m_record = false; +} + +void JinspFiberImager::getDeviceAttribute(DeviceAttribute& deviceAttribute) +{ + m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute); +} + +void JinspFiberImager::getDeviceInfo(DeviceInfo& deviceInfo) +{ + m_FiberSpectrometer->GetDeviceInfo(deviceInfo); +} + +void JinspFiberImager::setExposureTime(int iExposureTimeInMS) +{ + m_FiberSpectrometer->SetExposureTime(iExposureTimeInMS); +} + +void JinspFiberImager::getExposureTime(int &iExposureTimeInMS) +{ + m_FiberSpectrometer->GetExposureTime(iExposureTimeInMS); +} + +void JinspFiberImager::getDeviceTemperature(float &fTemperature) +{ + m_FiberSpectrometer->GetDeviceTemperature(fTemperature); +} + +void JinspFiberImager::singleShot(DataFrame &dfData) +{ + m_FiberSpectrometer->SingleShot(dfData); +} + +void JinspFiberImager::getNonlinearityCoeffs(coeffsFrame &coeffs) +{ + printf("This is JinspFiberImager.\n"); +} + +void JinspFiberImager::recordDark(QString path) +{ + //鑾峰彇璁惧淇℃伅 + DeviceAttribute attribute; + DeviceInfo deviceInfo; + getDeviceAttribute(attribute); + getDeviceInfo(deviceInfo); + + //閲囬泦鏆楀抚 + singleShot(m_DarkData); + + //杈撳嚭鍒癱sv + QDateTime curDateTime = QDateTime::currentDateTime(); + QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss"); + QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral_dn.csv"; + std::ofstream outfile(fileName.toStdString().c_str()); + + for (int i = 0; i < attribute.iPixels; i++) + { + if (i==0) + { + outfile << m_DarkData.usExposureTimeInMS << std::endl; + } + outfile << attribute.fWaveLengthInNM[i] << "," << m_DarkData.lData[i] << std::endl; + } + + outfile.close(); +} + +void JinspFiberImager::recordTarget(int recordTimes, QString path) +{ + //鑾峰彇璁惧淇℃伅 + DeviceAttribute attribute; + DeviceInfo deviceInfo; + getDeviceAttribute(attribute); + getDeviceInfo(deviceInfo); + + + DataFrame integratingSphereData_tmp; + + for (int i = 0; i < recordTimes; i++) + { + singleShot(integratingSphereData_tmp); + + if (i == 0)//灏唅ntegratingSphereData_tmp涓殑鏇濆厜鏃堕棿銆佹俯搴︾瓑淇℃伅浼犵粰m_IntegratingSphereData + { + m_IntegratingSphereData = integratingSphereData_tmp; + } + else + { + for (int i = 0; i < attribute.iPixels; i++) + { + m_IntegratingSphereData.lData[i] += integratingSphereData_tmp.lData[i]; + } + } + + } + + for (int i = 0; i < attribute.iPixels; i++) + { + m_IntegratingSphereData.lData[i] = m_IntegratingSphereData.lData[i] / recordTimes; + } + + + //杈撳嚭鍒癱sv + QDateTime curDateTime = QDateTime::currentDateTime(); + QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss"); + QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral_dn.csv"; + std::ofstream outfile(fileName.toStdString().c_str()); + + for (int i = 0; i < attribute.iPixels; i++) + { + if (i==0) + { + outfile << m_IntegratingSphereData.usExposureTimeInMS << "," << getNanosecondsSinceMidnight() << std::endl; + } + outfile << attribute.fWaveLengthInNM[i] << "," << m_IntegratingSphereData.lData[i] << std::endl; + } + + outfile.close(); +} + +void JinspFiberImager::autoExpose() +{ +// float fPredictedExposureTime; +// m_FiberSpectrometer->PerformAutoExposure(0.6,0.9,fPredictedExposureTime); + + //tc + DeviceAttribute attribute; + getDeviceAttribute(attribute); + + int iterations = 0;//璁板綍鑷姩鏇濆厜宸茬粡杩唬鐨勬鏁 + int maxIterations = 10;//鍏佽鏈澶х殑杩唬娆℃暟 + + ZZ_U32 thresholdValue = m_MaxValueOfFiberSpectrometer * 0.8;//鏈浣崇嚎鎬у尯闂翠负80% + ZZ_U16 range = 10000; + + //璁剧疆鍒濆鏇濆厜鏃堕棿 + int exposureTimeInMS = 200; + setExposureTime(exposureTimeInMS); + +// int exposureTime; +// m_FiberSpectrometer->GetExposureTime(exposureTime); + + emit sendExposureTimeSignal(exposureTimeInMS); + + DataFrame integratingSphereData_tmp; + ZZ_S32 maxValue; + while (true) + { + if (iterations > maxIterations)//鏄惁瓒呰繃鍏佽鐨勬渶澶ц凯浠f鏁 + { + break; + } + + singleShot(integratingSphereData_tmp); + maxValue = GetMaxValue(integratingSphereData_tmp.lData, attribute.iPixels); + + if (maxValue < thresholdValue && maxValue < (thresholdValue - range))//鏇濆厜鏃堕棿杩囧皬 + { + double scale = 1 + ((double)(thresholdValue - maxValue) / (double)thresholdValue); + + int exposureTime; + m_FiberSpectrometer->GetExposureTime(exposureTime); + m_FiberSpectrometer->SetExposureTime(exposureTime * scale); + + emit sendExposureTimeSignal(exposureTime); + + std::cout << "鑷姩鏇濆厜-----------" << "鏈澶у间负" << maxValue << std::endl; + } + else if (maxValue > thresholdValue)//鏇濆厜鏃堕棿杩囧ぇ + { + double scale = 1 - ((double)(maxValue - thresholdValue) / (double)thresholdValue); + + int exposureTime; + m_FiberSpectrometer->GetExposureTime(exposureTime); + m_FiberSpectrometer->SetExposureTime(exposureTime * scale); + + emit sendExposureTimeSignal(exposureTime); + + std::cout << "鑷姩鏇濆厜++++++++++++" << "鏈澶у间负" << maxValue << std::endl; + } + else//鎵惧埌鏈浣虫洕鍏夋椂闂达紝璺冲嚭while寰幆 + { + break; + } + + iterations++; + } + + int a = 2; +} + +ZZ_S32 JinspFiberImager::GetMaxValue(ZZ_S32 * dark, int number) +{ + ZZ_S32 max = 0; + //std::cout << "鏈抚鏈澶у间负" << max << std::endl; + for (size_t i = 0; i < number; i++) + { +// std::cout << dark[i] << std::endl; + if(dark[i]>65535) + continue; + if (dark[i] > max) + { + max = dark[i]; + } + } + //std::cout << "鏈抚鏈澶у间负" << max << std::endl; + return max; +} + +void JinspFiberImager::setCaptureInterval(int captureIntervalSeconds) +{ + m_captureIntervalMilliseconds = captureIntervalSeconds * 1000; +} + +void JinspFiberImager::OpenFiberImagerAndRecord() +{ + //杩炴帴鍏夎氨浠 + QString SN; + QString pixelCount; + QString wavelengthInfo; + + connectFiberSpectrometer(SN, pixelCount, wavelengthInfo); + + //鏇濆厜 + autoExpose(); + + //瀹氭椂閲囬泦 + + if (m_captureTimer && !m_captureTimer->isActive()) + { + m_captureTimer->start(m_captureIntervalMilliseconds); + } + + m_record = true; +} + +void JinspFiberImager::recordSpectral() +{ + //recordDark("D:\\0tmp\\is11"); + + recordTarget(1, "D:\\0tmp\\is11"); +} diff --git a/HPPA/JinspFiberImager.h b/HPPA/JinspFiberImager.h new file mode 100644 index 0000000..1cb873a --- /dev/null +++ b/HPPA/JinspFiberImager.h @@ -0,0 +1,68 @@ +// +// Created by 73505 on 2023/5/7. +// +#pragma once +#include +//#include +#include +#include +#include +#include + +#include "JinspSpectralmeterControl.h" +#include "FiberSpectrometerOperationBase.h" +#include "utility_tc.h" + +class JinspFiberImager :public QObject,public FiberSpectrometerOperationBase +{ +Q_OBJECT + +public: + JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName); + ~JinspFiberImager(); + + JinspSpectralmeterControl* m_FiberSpectrometer; + + void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo); + void disconnectFiberSpectrometer(); + void getDeviceAttribute(DeviceAttribute& deviceAttribute); + void getDeviceInfo(DeviceInfo& deviceInfo); + + void setExposureTime(int iExposureTimeInMS); + + void getExposureTime(int &iExposureTimeInMS);//ok + void getDeviceTemperature(float &fTemperature);//ok + + void singleShot(DataFrame &dfData); + + void getNonlinearityCoeffs(coeffsFrame &coeffs); + + ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number); + + bool getRecordStatus() const { return m_record; } + void setCaptureInterval(int captureIntervalSeconds); + + +// DataFrame m_IntegratingSphereData; +// DataFrame m_DarkData; +protected: +private: + std::string mUcPortNumber; + + bool m_record; + int m_captureIntervalMilliseconds; + QTimer* m_captureTimer; // 拍照定时器 + +// ZZ_U32 m_MaxValueOfFiberSpectrometer; + +public slots: + void recordDark(QString path); + void recordTarget(int recordTimes, QString path); + void autoExpose(); + + void OpenFiberImagerAndRecord(); + void recordSpectral(); + +signals: + void sendExposureTimeSignal(int exposureTime); +}; diff --git a/HPPA/fodis.ui b/HPPA/fodis.ui new file mode 100644 index 0000000..494e298 --- /dev/null +++ b/HPPA/fodis.ui @@ -0,0 +1,205 @@ + + + FodisWindow + + + + 0 + 0 + 857 + 477 + + + + + 0 + 0 + + + + FodisWindow + + + QGroupBox +{ + border: 12px solid transparent; + /*border-top: 12px solid transparent; + border-right: 0px solid transparent; + border-bottom: 0px solid transparent; + border-left: 0px solid transparent;*/ + color: #ACCDFF; +} + +QPushButton +{ + /*width: 172px; + height: 56px;*/ + font: 19pt "鏂板畫浣"; + background-color: qlineargradient( + spread:pad, + x1:0.5, y1:0, x2:0.5, y2:1, + stop:0 #283D86, + stop:1 #0F1A40 + ); + color: white; + border: none; + padding: 8px 16px; + border-radius: 4px; +} +QPushButton:hover +{ + background-color: qlineargradient( + spread:pad, + x1:0, y1:0, x2:1, y2:0, + stop:0 #3A4875, + stop:1 #5F6B91 + ); +} +/* 鎸変笅鏃剁殑鏁堟灉 */ +QPushButton:pressed +{ + background-color: qlineargradient( + spread:pad, + x1:0, y1:0, x2:1, y2:0, + stop:0 #1A254F, + stop:1 #3A466B + ); + /* 鍙夛細娣诲姞涓嬪帇鏁堟灉 */ + padding-top: 9px; + padding-bottom: 7px; +} + + + + + + Qt::Vertical + + + + 18 + 100 + + + + + + + + + + + 0 + 0 + + + + 鍏 闂 + + + + + + + + 0 + 0 + + + + 閲 闆 + + + + + + + + + Qt::Horizontal + + + + 135 + 20 + + + + + + + + Qt::Horizontal + + + + 135 + 20 + + + + + + + + + + QLabel { + color: rgb(255, 255, 255); +} + + + 鏁版嵁璺緞 + + + + + + + QLineEdit { + background-color: #142D7F; + color: #e6eeff; + border: 1px solid #2f6bff; + border-radius: 6px; + padding: 4px 8px; + min-width: 70px; + min-height: 20px; + font-size: 13px; +} + + + ./CapturedImages + + + true + + + + + + + ... + + + + + + + + + Qt::Vertical + + + + 18 + 100 + + + + + + + + + + diff --git a/JinspSpectralmeterControl/IrisFiberSpectrometerBase.h b/JinspSpectralmeterControl/IrisFiberSpectrometerBase.h new file mode 100644 index 0000000..dcc7b7d --- /dev/null +++ b/JinspSpectralmeterControl/IrisFiberSpectrometerBase.h @@ -0,0 +1,43 @@ +#include "QObject" +#include +#include "ZZ_Types.h" +#pragma once +using namespace ZZ_MISCDEF; +using namespace ZZ_MISCDEF::IRIS::FS; + +class CIrisFSBase:public QObject +{ +public: + //CIrisFSBase(); + //virtual ~CIrisFSBase()= 0; +public: + //初始化设备 + //此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型 + //0为无错误,不同错误请返回不同值 + virtual int Initialize(bool bIsUSBMode,std::string ucPortNumber,std::string strDeviceName) = 0; + + //关闭设备 + virtual void Close() = 0; + + //单次数据采集 + virtual int SingleShot(DataFrame &dfData) = 0; + + //设置曝光时间 + virtual int SetExposureTime(int iExposureTimeInMS) = 0; + + //获取曝光时间设置 + virtual int GetExposureTime(int &iExposureTimeInMS) = 0; + + //设置目标温度 + virtual int SetDeviceTemperature(float fTemperature) = 0; + + //获取温度设置 + virtual int GetDeviceTemperature(float &fTemperature) = 0; + + //获取设备信息 + virtual int GetDeviceInfo(DeviceInfo &Info) = 0; + + //获取设备特征数据 + virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0; + +}; diff --git a/JinspSpectralmeterControl/JinspSpectralmeterControl.cpp b/JinspSpectralmeterControl/JinspSpectralmeterControl.cpp new file mode 100644 index 0000000..457333d --- /dev/null +++ b/JinspSpectralmeterControl/JinspSpectralmeterControl.cpp @@ -0,0 +1,578 @@ +锘#include "JinspSpectralmeterControl.h" + +JinspSpectralmeterControl::JinspSpectralmeterControl(QObject* parent /*= nullptr*/) +{ + m_pSerialPort = new QSerialPort; + m_iBaudRate = 921600; +} + +JinspSpectralmeterControl::~JinspSpectralmeterControl() +{ + delete m_pSerialPort; +} + +int JinspSpectralmeterControl::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName) +{ + QString qstrPortName = QString::fromStdString(ucPortNumber); + m_pSerialPort->setPortName(qstrPortName); + m_pSerialPort->setReadBufferSize(512); + + bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate); + if (!bRes) + { + //qDebug() << "Err:setBaudRate Failed.Exit Code:1"; + //std::cout << "Err.setBaudRate Failed" << std::endl; + printf("Err:setBaudRate Failed.Exit Code:1"); + return 1; + } + + bRes = m_pSerialPort->open(QIODevice::ReadWrite); + if (!bRes) + { + //qDebug() << "Err:open Failed.Exit Code:2"; + //std::cout << "Err.open Failed" << std::endl; + printf("Err:open Failed.Exit Code:2"); + return 2; + } + + + // int testi; + // GetDeviceAttribute(m_daDeviceAttr); + // GetExposureTime(testi); + // SetExposureTime(10000); + // DataFrame test; + // SingleShot(test); + + GetDeviceInfo(m_diDeviceInfo); + //GetExposureTime_Init(); + + std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName); + if (szPostion == std::string::npos) + { + printf("Err:FS serial number not match.Exit Code:3"); + //qDebug() << "Err:FS serial number not match.Exit Code:3"; + //return 3; + } + else + { + return 0; + } + return 0; +} + +void JinspSpectralmeterControl::Close() +{ + +} + +int JinspSpectralmeterControl::SingleShot(DataFrame& dfData) +{ + SendData_CMD03((char*)GET_ALL_DN, sizeof(GET_ALL_DN)); + RecvData_CMD03(dfData); + + GetExposureTime(m_iExposureTime); + dfData.usExposureTimeInMS = (unsigned short)m_iExposureTime; + return 0; +} + +int JinspSpectralmeterControl::SetExposureTime(int iExposureTimeInMS) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + + unsigned char pucExposureTime[2]; + pucExposureTime[0] = iExposureTimeInMS / 256; + pucExposureTime[1] = iExposureTimeInMS % 256; + SendData_CMD06((char*)SET_INTEGRAL_TIME, sizeof(SET_INTEGRAL_TIME), (char*)pucExposureTime, 2); + //SendData_CMD03((char *)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME)); + int iRes = RecvData_CMD06(qbaRecv); + return iRes; +} + +int JinspSpectralmeterControl::GetExposureTime(int& iExposureTimeInMS) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + SendData_CMD03((char*)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME)); + int iRes = RecvData_CMD03(qbaRecv); + + iExposureTimeInMS = qbaRecv[0] * 256 + static_cast(qbaRecv[1]); + return iRes; +} + +int JinspSpectralmeterControl::GetDeviceInfo(DeviceInfo& Info) +{ + Info.strPN = "IS11"; + Info.strSN = "NULL"; + return 0; +} + +int JinspSpectralmeterControl::GetDeviceAttribute(DeviceAttribute& Attr) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + float fCoef[4]; + unsigned short usTempCoef[8]; + + Attr.iPixels = 2048; + Attr.iMinIntegrationTimeInMS = 1; + Attr.iMaxIntegrationTimeInMS = 60000; + + SendData_CMD03((char*)GET_WAVELENTH_COEFF, sizeof(GET_WAVELENTH_COEFF)); + RecvData_CMD03(qbaRecv); + + //memcpy(fTempCoef,qbaRecv,16); + memcpy(usTempCoef, qbaRecv, 16); + + for (int i = 0; i < 8; i++) + { + usTempCoef[i] = qToBigEndian(usTempCoef[i]); + } + + //float *pfTemp = (float*)usTempCoef; + memcpy(fCoef, usTempCoef, 16); + + //Conv_LTB((char*)fTempCoef,16); + + for (int i = 0; i <= 2048; i++) + { + Attr.fWaveLengthInNM[i] = fCoef[0] * i * i * i + fCoef[1] * i * i + fCoef[2] * i + fCoef[3]; + //setem.WavelenthStr = setem.WavelenthStr + String(setem.wavelenthlist[i - 1]).c_str() + ","; + } + return 0; +} + +int JinspSpectralmeterControl::SetDeviceTemperature(float fTemperature) +{ + return 0; +} + +int JinspSpectralmeterControl::GetDeviceTemperature(float& fTemperature) +{ + fTemperature = -1000; + return 0; +} + +int JinspSpectralmeterControl::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime) +{ + return 0; +} + +// unsigned short JinspSpectralmeterControl::crc16(const uint8_t *pbdata, size_t sz) +// { +// uint16_t i, j, tmp, CRC16; +// +// CRC16 = 0xFFFF; // CRC锟侥达拷锟斤拷锟斤拷始值 +// for (i = 0; i < sz; i++) +// { +// CRC16 ^= pbdata[i]; +// for (j = 0; j < 8; j++) +// { +// tmp = (uint16_t)(CRC16 & 0x0001); +// CRC16 >>= 1; +// if (tmp == 1) +// { +// CRC16 ^= 0xa001; // 锟斤拷锟斤拷锟斤拷式 +// } +// } +// } +// return CRC16; +// } + +unsigned short JinspSpectralmeterControl::CalCRC16(const uint8_t* pbData, size_t szLength) +{ + uint16_t usCRC16 = CRC16_INIT; + for (size_t i = 0; i < szLength; i++) + { + usCRC16 ^= pbData[i]; + for (size_t j = 0; j < 8; j++) + { + if ((usCRC16 & 0x0001) != 0) + { + usCRC16 = (usCRC16 >> 1) ^ CRC16_POLYNOMIAL; + } + else + { + usCRC16 = usCRC16 >> 1; + } + } + } + return usCRC16; +} + +void JinspSpectralmeterControl::Conv_LTB(char* pcData, int iLength) +{ + char* TempData = new char[iLength]; + memcpy(TempData, pcData, iLength); + + for (int i = 0; i < iLength / 2; i++) + { + pcData[2 * i] = TempData[2 * i + 1]; + pcData[2 * i + 1] = TempData[2 * i]; + /* code */ + } + delete[] TempData; +} + +int JinspSpectralmeterControl::SendData_CMD03(char* pcCMD, size_t szCMDLength) +{ + QString qstrSend, qstrCRC16; + QByteArray qbaSend; + qbaSend.clear(); + + //char *pctest=new char[szCMDLength+2]; + //memcpy(pctest, pcCMD, szCMDLength); + //ushort ustest = crc16((unsigned char*)pcCMD,szCMDLength); + //qstrCRC16= QString::fromLatin1((const char*)usCRC16, (int)sizeof(uint16_t)); + //memcpy(pctest+ szCMDLength,&usCRC16, 2); + //int iReturn = m_pSerialPort->write(pctest,szCMDLength+2); + //delete[] pctest; + uint16_t usCRC16 = CalCRC16((unsigned char*)pcCMD, szCMDLength); + qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength); + const char* pucSend = (char*)&usCRC16; + + qbaSend.append(qstrSend); + qbaSend.append(pucSend, (int)sizeof(uint16_t)); + + int iReturn = m_pSerialPort->write(qbaSend); + + return iReturn; +} + +int JinspSpectralmeterControl::RecvData_CMD03(QByteArray& qbaRecv) +{ + int iRetryCount = 0; + QByteArray qbaOriRecv, qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + ///read all once + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 100) + { + qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD03"; + return 1; + } + } + + iRetryCount = 0; + while (qbaOriRecv.size() < qbaOriRecv[2] + 5) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 66) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size() != qbaOriRecv[2] + 5) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD03_QBA"; + return 3; + } + + unsigned short usCRCC = CalCRC16((unsigned char*)qbaOriRecv.data(), qbaOriRecv.size() - 2); + char* pc = (char*)&usCRCC; + if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || + (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) + { + qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); + } + else + { + ///error crc + qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; + return 4; + } + + + /*while (ParseHdr(qbaOriRecv, 3)==1) + { + m_pSerialPort->waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + }*/ + + return 0; +} + +int JinspSpectralmeterControl::RecvData_CMD03(DataFrame& dfData) +{ + int iRecvDataLength = 0; + int iRetryCount = 0; + QByteArray qbaOriRecv, qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + ///read all once + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 4 || ParseHdr(qbaOriRecv, 3) == 1) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 66) + { + qDebug() << "Recv Hdr Err.out of retry time"; + return 1; + } + } + + int length = qbaOriRecv[2] * 256 + qbaOriRecv[3]; + iRetryCount = 0; + while (qbaOriRecv.size() < length + 4) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 66) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size() != length + 4) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD03_DF"; + return 3; + } + + QByteArray qbaData; + qbaData = qbaOriRecv.right(length); + + int iDataSizeInPixel = qbaData.size() / 2; + unsigned short* pusData = new unsigned short[iDataSizeInPixel]; + + memcpy(pusData, qbaData, iDataSizeInPixel * 2); + for (size_t i = 0; i < iDataSizeInPixel; i++) + { + dfData.lData[i] = qToBigEndian(pusData[i]); + //qDebug() << dfData.lData[i]; + + } + ///it seems the manufacture not enable crc16 check for this function +// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2); +// char *pc = (char *)&usCRCC; +// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || +// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) +// { +// //qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); +// //dataframe process here +// +// } +// else +// { +// ///error crc +// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; +// return 4; +// } + + return 0; +} + + +//int JinspSpectralmeterControl::RecvData_CMD03(float& fWavelength) +//{ +// int iRetryCount = 0; +// QByteArray qbaOriRecv, qbaTemp,qbaRecv; +// qbaOriRecv.clear(); +// qbaTemp.clear(); +// qbaRecv.clear(); +// +// ///read all once +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1) +// { +// m_pSerialPort->waitForReadyRead(100); +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// iRetryCount++; +// if (iRetryCount > 20) +// { +// qDebug() << "Recv Hdr Err.out of retry time"; +// return 1; +// } +// } +// +// iRetryCount = 0; +// while (qbaOriRecv.size() < qbaOriRecv[2] + 5) +// { +// m_pSerialPort->waitForReadyRead(100); +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// iRetryCount++; +// if (iRetryCount > 20) +// { +// qDebug() << "Recv Data Err.out of retry time"; +// return 2; +// } +// } +// +// if (qbaOriRecv.size() != qbaOriRecv[2] + 5) +// { +// /// can be handled but dont want to +// qDebug() << "Wrong Recv data size."; +// return 3; +// } +// +// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2); +// char *pc = (char *)&usCRCC; +// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || +// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) +// { +// qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); +// } +// else +// { +// ///error crc +// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; +// return 4; +// } +// +// fWavelength = qbaRecv.toFloat(); +// return 0; +//} + +int JinspSpectralmeterControl::SendData_CMD06(char* pcCMD, size_t szCMDLength, char* pcValue, size_t szValueLenth) +{ + // QString qstrSend, qstrSend1, qstrCRC16;///QByteArray append锟斤拷锟街讹拷锟斤拷锟街斤拷 + // QByteArray qbaSend; + // qbaSend.clear(); + // + // qstrSend = QString::fromLatin1(pcCMD, (int)szCMDLength); + // qbaSend.append(qstrSend); + // + // qstrSend1.clear(); + // qstrSend1 = QString::fromLatin1(pcValue,(int)szValueLenth); + // qbaSend.append(qstrSend1); + + QByteArray qbaSend; + qbaSend.append(pcCMD, szCMDLength); + qbaSend.append(pcValue, szValueLenth); + + unsigned short usCRC16 = CalCRC16((unsigned char*)qbaSend.data(), qbaSend.size()); + const char* pucSend = (char*)&usCRC16; + qbaSend.append(pucSend, (int)sizeof(unsigned short)); + + int iReturn = m_pSerialPort->write(qbaSend); + + return 0; + +} + +int JinspSpectralmeterControl::RecvData_CMD06(QByteArray& qbaRecv) +{ + int iRetryCount = 0; + QByteArray qbaOriRecv, qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 6) == 1) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 100) + { + qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD06"; + return 1; + } + } + + iRetryCount = 0; + while (qbaOriRecv.size() < 8) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 66) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size() != 8) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD06"; + return 3; + } + + unsigned short usCRCC = CalCRC16((unsigned char*)qbaOriRecv.data(), qbaOriRecv.size() - 2); + char* pc = (char*)&usCRCC; + if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || + (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) + { + qbaRecv = qbaOriRecv.mid(2, 4); + } + else + { + ///error crc + qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; + return 4; + } + + return 0; +} + +int JinspSpectralmeterControl::ParseHdr(QByteArray& qbaData, char cHdrType) +{ + QByteArray qbaTemp(qbaData); + while ((qbaTemp[0] != (char)0x01) && (qbaTemp[1] != cHdrType)) + { + qbaTemp.remove(0, 1); + if (qbaTemp.size() <= 2) + { + return 1; + } + } + + if (qbaTemp != qbaData) + { + ///warning some communication error may happened. + qbaData = qbaTemp; + return 1000; + } + + return 0; +} + +int JinspSpectralmeterControl::Write_IS11(char* pcCMD, size_t szCMDLength) +{ + QString qstrSend; + QByteArray qbaSend; + qbaSend.clear(); + + qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength); + return (int)m_pSerialPort->write(qbaSend); +} + +int JinspSpectralmeterControl::Read_IS11(QByteArray& qbaRecv) +{ + //m_pSerialPort->waitForReadyRead(100); + qbaRecv = m_pSerialPort->readAll(); + return qbaRecv.size(); +} diff --git a/JinspSpectralmeterControl/JinspSpectralmeterControl.h b/JinspSpectralmeterControl/JinspSpectralmeterControl.h new file mode 100644 index 0000000..3fe6c05 --- /dev/null +++ b/JinspSpectralmeterControl/JinspSpectralmeterControl.h @@ -0,0 +1,132 @@ +#pragma once + +#include "jinspspectralmetercontrol_global.h" + +#include "IrisFiberSpectrometerBase.h" +#include + +#include +#include +#include "ZZ_Math.h" + +#define CRC16_INIT 0xFFFF +#define CRC16_POLYNOMIAL 0xa001 + +const uint8_t GET_ADDRESS[] = { 0x01,0x03,0x00,0x01,0x00,0x01 }; +const uint8_t GET_BANDRATE[] = { 0x01,0x03,0x00,0x02,0x00,0x01 }; +const uint8_t GET_INTEGRAL_TIME[] = { 0x01,0x03,0x00,0x06,0x00,0x01 }; +const uint8_t GET_AVERAGE_NUMBER[] = { 0x01,0x03,0x00,0x07,0x00,0x01 }; +const uint8_t GET_WAVELENTH_AT_BAND[] = { 0x01,0x03,0x00,0x10,0x00,0x02 }; +const uint8_t GET_VALUE_AT_BAND[] = { 0x01,0x03,0x00,0x30,0x00,0x02 }; +const uint8_t GET_SETTING_OF_LAMP[] = { 0x01,0x03,0x00,0x04,0x00,0x01 }; +const uint8_t GET_WAVELENTH_COEFF[] = { 0x01,0x03,0x00,0x20,0x00,0x08 }; +const uint8_t GET_ALL_DN[] = { 0x01,0x03,0x01,0x00,0x10,0x00 }; +const uint8_t GET_SERIAL_NUMBER[] = { 0x01,0x03,0x00,0x40,0x00,0x00 }; +const uint8_t GET_PRODUCT_NAME[] = { 0x01,0x03,0x00,0x50,0x00,0x00 }; + +const uint8_t SET_ADDRESS[] = { 0x01,0x06,0x00,0x01 }; +const uint8_t SET_BandRATE[] = { 0x01,0x06,0x00,0x02 }; +const uint8_t SET_INTEGRAL_TIME[] = { 0x01,0x06,0x00,0x06 }; +const uint8_t SET_AVERAGE_NUMBER[] = { 0x01,0x06,0x00,0x07 }; +const uint8_t SET_WORK_MODE[] = { 0x01,0x06,0x00,0x01 }; + +const uint8_t SET_WAVELENTH_COEFF[] = { 0x01,0x10,0x00,0x20,0x00,0x08,0x16 }; + +class JINSPSPECTRALMETERCONTROL_EXPORT JinspSpectralmeterControl :public CIrisFSBase +{ + Q_OBJECT +public: + JinspSpectralmeterControl(QObject* parent = nullptr); + virtual ~JinspSpectralmeterControl(); +public: + //do not call + //int ReInit(); + //设置波特率 + //int SetBaudRate(int iBaud); + //初始化设备 + int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName); + + //关闭设备 + void Close(); + + //单次测试采集 用以确认设备像素数 + //int SingleShot(int& iPixels); + + //单次数据采集 + int SingleShot(DataFrame& dfData); + + //单次暗背景采集 + //int SingleShotDark(ATPDataFrame &dfData); + + //int SingleShotDeducted(ATPDataFrame &dfData); + //设置曝光时间 + int SetExposureTime(int iExposureTimeInMS); + + //获取曝光时间设置 + int GetExposureTime(int& iExposureTimeInMS); + + //int GetWaveLength(float *pfWaveLength); + + //获取设备信息 + int GetDeviceInfo(DeviceInfo& Info); + + //获取设备特征数据 + int GetDeviceAttribute(DeviceAttribute& Attr); + + //int GetDeviceListInfo(); //use type name to enum + + //设置温度 + int SetDeviceTemperature(float fTemperature); + + //获取温度 + int GetDeviceTemperature(float& fTemperature); + + //自动曝光 + int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime); + +#ifdef _DEBUG +public: +#else // +private: +#endif + //port + int m_iBaudRate; + QSerialPort* m_pSerialPort; + + //ATP + DeviceInfo m_diDeviceInfo; + DeviceAttribute m_daDeviceAttr; + + //Attr + int m_iExposureTime; + +#ifdef _DEBUG +public: +#else // +private: +#endif + //unsigned short crc16(const uint8_t *pbdata, size_t sz); + unsigned short CalCRC16(const uint8_t* pbData, size_t szLength); + void Conv_LTB(char* pcData, int iLength); + + int Write_IS11(char* pcCMD, size_t szCMDLength); + int Read_IS11(QByteArray& qbaRecv); + + + + int SendData_CMD03(char* pcCMD, size_t szCMDLength); + int RecvData_CMD03(QByteArray& qbaRecv); + int RecvData_CMD03(DataFrame& dfData); + //int RecvData_CMD03(float& fWavelength); + //int RecvData_CMD03(DeviceAttribute& Attr); + + int SendData_CMD06(char* pcCMD, size_t szCMDLength, char* pcValue, size_t szValueLenth); + int RecvData_CMD06(QByteArray& qbaRecv); + + int SendData_CMD10(char* pcCMD, size_t szCMDLength); + int RecvData_CMD10(QByteArray& qbaRecv); + + int ParseHdr(QByteArray& qbaData, char cHdrType); + + +}; diff --git a/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj b/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj new file mode 100644 index 0000000..6695cbd --- /dev/null +++ b/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj @@ -0,0 +1,102 @@ +锘 + + + + Debug + x64 + + + Release + x64 + + + + {06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB} + QtVS_v304 + 10.0.26100.0 + 10.0.26100.0 + $(MSBuildProjectDirectory)\QtMsBuild + + + + DynamicLibrary + v143 + + + DynamicLibrary + v143 + + + + + + + 5.13.2_msvc2017_64 + core;serialport + debug + + + 5.13.2_msvc2017_64 + core + release + + + + + + + + + + + + + + + + + D:\cpp_library\eigen-3.4-rc1;$(IncludePath) + + + + + + true + true + ProgramDatabase + Disabled + JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions) + + + Windows + true + + + + + true + true + None + MaxSpeed + JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions) + + + Windows + false + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj.filters b/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj.filters new file mode 100644 index 0000000..7cfe298 --- /dev/null +++ b/JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj.filters @@ -0,0 +1,45 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {639EADAA-A684-42e4-A9AD-28FC9BCB8F7C} + ts + + + + + Header Files + + + Header Files + + + Source Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/JinspSpectralmeterControl/ZZ_Math.h b/JinspSpectralmeterControl/ZZ_Math.h new file mode 100644 index 0000000..73e75e8 --- /dev/null +++ b/JinspSpectralmeterControl/ZZ_Math.h @@ -0,0 +1,121 @@ +#include +#include +#//#include "Dense" +#include "Eigen/Dense" +#include +#pragma once + +namespace ZZ_MATH +{ + template + void MinHeapify(T*arry, int size, int element) + { + int lchild = element * 2 + 1, rchild = lchild + 1; + while (rchild < size) + { + if (arry[element] <= arry[lchild] && arry[element] <= arry[rchild]) + { + return; + } + if (arry[lchild] <= arry[rchild]) + { + std::swap(arry[element], arry[lchild]); + element = lchild; + } + else + { + std::swap(arry[element], arry[rchild]); + element = rchild; + } + lchild = element * 2 + 1; + rchild = lchild + 1; + } + if (lchild < size&&arry[lchild] < arry[element]) + { + std::swap(arry[lchild], arry[element]); + } + return; + } + + template + void MaxHeapify(T*arry, int size, int element) + { + int lchild = element * 2 + 1, rchild = lchild + 1; + while (rchild < size) + { + if (arry[element] >= arry[lchild] && arry[element] >= arry[rchild]) + { + return; + } + if (arry[lchild] >= arry[rchild]) + { + std::swap(arry[element], arry[lchild]); + element = lchild; + } + else + { + std::swap(arry[element], arry[rchild]); + element = rchild; + } + lchild = element * 2 + 1; + rchild = lchild + 1; + } + if (lchildarry[element]) + { + std::swap(arry[lchild], arry[element]); + } + return; + } + + + template + void HeapSort(T*arry, int size) + { + int i; + for (i = size - 1; i >= 0; i--) + { + MinHeapify(arry, size, i); + } + while (size > 0) + { + std::swap(arry[size - 1], arry[0]); + + size--; + MinHeapify(arry, size, 0); + } + return; + } + + namespace PolyFit + { + void Eigen_Polyfit(const std::vector &xv, const std::vector &yv, std::vector &coeff, int order); + double Eigen_Polyeval(std::vector coeffs, double x); + }; + + namespace SplineFit + { + using namespace Eigen; + VectorXd Eigen_Normalize(const VectorXd &x); + void Test(std::vector const &x_vec, std::vector const &y_vec);// do not call + + + class SplineInterpolation + { + public: + SplineInterpolation(Eigen::VectorXd const &x_vec,Eigen::VectorXd const &y_vec); + double operator()(double x) const; + + private: + double x_min; + double x_max; + + double scaled_value(double x) const; + Eigen::RowVectorXd scaled_values(Eigen::VectorXd const &x_vec) const; + + Eigen::Spline spline_; + }; + }; +}; + + + diff --git a/JinspSpectralmeterControl/ZZ_Types.h b/JinspSpectralmeterControl/ZZ_Types.h new file mode 100644 index 0000000..22440e4 --- /dev/null +++ b/JinspSpectralmeterControl/ZZ_Types.h @@ -0,0 +1,358 @@ +////////////////////////////////////////////////////////////////////////// +//类型说明文件 +////////////////////////////////////////////////////////////////////////// +#pragma once + +#include +#include + +#define MAX_DEVICENUMBER_FS 2 +#define MAX_LINEARSHUTTER_POSITION 12 +#define ZZ_Enum2String(x) #x + +#pragma pack(1)//结构体按照1字节对齐存储 + +namespace ZZ_MISCDEF +{ + typedef unsigned char ZZ_U8; + typedef unsigned short int ZZ_U16; + typedef unsigned int ZZ_U32; + typedef int ZZ_S32; + + + namespace IRIS + { + //Fiber Spectrometer + namespace FS + { + typedef struct tagDataFrame + { + ZZ_U32 usExposureTimeInMS; + ZZ_S32 lData[4096]; + float fTemperature = 0; + double dTimes = 0; + }DataFrame; + + typedef struct coeffs//tc添加----------------------- + { + ZZ_U32 coeffsCounter; + double coeffs[100]; + }coeffsFrame; + + typedef struct tagDeviceInfo + { + std::string strPN; + std::string strSN; + }DeviceInfo; + + typedef struct tagDeviceAttribute + { + int iPixels; + int iMaxIntegrationTimeInMS; + int iMinIntegrationTimeInMS; + float fWaveLengthInNM[4096]; + + }DeviceAttribute; + +// inline DataFrame GetIndex(DataFrame dfDark, DataFrame dfSignal) +// { +// +// } + } + + enum DeviceModel + { + OSIFAlpha=0, + OSIFBeta, + ISIF, + IS1, + IS2 + }; + + + + inline std::string GetDeviceModelName(int iModel) + { + switch (iModel) + { + case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break; + case DeviceModel::OSIFBeta: return "OSIFBeta"; break; + case DeviceModel::ISIF: return "ISIF"; break; + case DeviceModel::IS1: return "IS1"; break; + case DeviceModel::IS2: return "IS2"; break; + default: return "error"; break; + } + } + + inline int GetIndex(std::string strDeviceModelName) + { + if (strDeviceModelName == "OSIFAlpha") + { + return DeviceModel::OSIFAlpha; + } + else if (strDeviceModelName == "OSIFBeta") + { + return DeviceModel::OSIFBeta; + } + else if (strDeviceModelName == "ISIF") + { + return DeviceModel::ISIF; + } + else if (strDeviceModelName == "IS1") + { + return DeviceModel::IS1; + } + else if (strDeviceModelName == "IS2") + { + return DeviceModel::IS2; + } + else + { + return -1; + } + } + + }; + + //ATP????×??? + namespace ATP + { + const int MAX_SPECTRUM_SIZE = 4096; + + const int GET_MODULECIRCUIT_TEMP = 0x01; + const int GET_PN_NUMBER = 0x03; + const int GET_SN_NUMBER = 0x04; + const int GET_MANUFACTURE_DATA = 0x06; + const int GET_MANUFACTURE_INFO = 0x09; + const int GET_PIXEL_LENGTH = 0x0a; + const int GET_TEC_TEMP = 0x13; + const int SET_TEC_TEMP = 0x12; + const int GET_OPTICS_TEMP = 0x35; + const int GET_CIRCUITBOARD_TEMP = 0x36; + const int SET_INTEGRATION_TIME = 0x14; + const int GET_INTEGRATION_TIME = 0x41; + const int GET_MAX_INTEGRATION_TIME = 0x42; + const int GET_MIN_INTEGRATION_TIME = 0x43; + const int ASYNC_COLLECT_DARK = 0x23; + const int ASYNC_START_COLLECTION = 0x16; + const int ASYNC_READ_DATA = 0x17; + const int SET_AVERAGE_NUMBER = 0x28; + const int SYNC_GET_DATA = 0x1e; + const int SYNC_GET_DARK = 0x2f; + const int EXTERNAL_TRIGGER_ENABLE = 0x1f; + const int SET_XENON_LAMP_DELAY_TIME = 0x24; + const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55; + const int GET_STAT_LAMPOUT = 0x60; + const int SET_GPIO = 0x61; + //const int SYNCHRONIZATION_GET_DARK = 0x23 + + //////////////////////////////////////////////////////////////////////////device + enum Model + { + ATP1010 = 0, + ATP6500 + }; + + //???????è?? + typedef struct tagATPDataFrame + { + unsigned short usExposureTime; + ZZ_U16 usData[4096]; + float fTemperature; + double dTimes = 0; + }ATPDataFrame; + + //?è±??????è?? + typedef struct tagATPDeviceInfo + { + std::string strPN; + std::string strSN; + }ATPDeviceInfo; + + //?è±????÷?è?? + typedef struct tagATPDeviceAttribute + { + int iPixels; + int iMaxIntegrationTime; + int iMinIntegrationTime; + float fWaveLength[4096]; + + }ATPDeviceAttribute; + //////////////////////////////////////////////////////////////////////////config file + + + + } + + //???????? + namespace ZZ_RUNPARAMS + { + typedef struct tagErrorInfo + { + int iDataTransferErr = -1000; + float fTecTempErr = -1000; + int iShutterErr = -1000; + float fChassisTempErr = -1000; + }ErrInfo; + + typedef struct tagFiberSpecContext + { + ZZ_U8 ucDeviceNumber; + ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS]; + std::string strInterface[MAX_DEVICENUMBER_FS]; + std::string strSN[MAX_DEVICENUMBER_FS]; + long lDepth[MAX_DEVICENUMBER_FS]; + float fMinFactor[MAX_DEVICENUMBER_FS]; + float fMaxFactor[MAX_DEVICENUMBER_FS]; + ZZ_U16 usPixels[MAX_DEVICENUMBER_FS]; + float fWavelength[MAX_DEVICENUMBER_FS][4096]; + }FSContext; + + typedef struct tagLinearShutterContext + { + std::string strInterface; + ZZ_U8 ucProtocolType; + ZZ_U8 ucCmdID; + }LSContext; + + typedef struct tagAcquisitionTimeSettings + { + QTime qtStartTime; + QTime qtStopTime; + QTime qtInterval; + }AcqTimeSettings; + + typedef struct tagAcquisitionPositionSettings + { + int iTotalPosition; + int iPosition[MAX_LINEARSHUTTER_POSITION]; + }AcqPosSettings; + + typedef struct tagRunTimeGrabberParams + { + LSContext lscParam; + FSContext fscParams; + AcqTimeSettings atsParams; + AcqPosSettings apsParams; + }RunTimeGrabberParams; + + typedef struct tagATPCalibrationSettings + { + //Up0 Down1,2,3 + QString qsISIF_CalibrationFilePath[4]; + QString qsIS1_CalibrationFilePath[4]; + }ATPCalibrationSettings; + } + + //?????????????á?? + namespace ZZ_DATAFILE + { + typedef struct tagEnvironmentalContext + { + QString qstrUTCDateTime; + QString qstrLocation; + QString qstrGPS_Longtitude; + QString qstrGPS_Latitude; + QString qstrGPS_Altitude; + QString qstrGPS_North; + QString qstrCaseTemperature; + QString qstrCaseHumidity; + QString qstrDEV_SN; + }EContext; + + typedef struct tagManmadeEnviromentalContext + { + QString qstrOriFileName; + QString qstrInstallationTime; + QString qstrISIFCalibrationTime; + QString qstrIS1CalibrationTime; + QString qstrNameOfMaintenanceStaff; + QString qstrPhoneNumberOfMaintenanceStaff; + QString qstrDownloadUserID; + QString qstrDownlaodAddress; + QString qstrHTTPServer; + }MEContext; + + + typedef struct tagIS1Information + { + QString qstrSN_ATP; + QString qstrSN_IRIS; + + QString qstrCalFile_U0; + QString qstrCalFile_D1; + QString qstrCalFile_D2; + QString qstrCalFile_D3; + + int iPixelCount; + + int iExposureTimeInMS_U0; + int iExposureTimeInMS_D1; + int iExposureTimeInMS_D2; + int iExposureTimeInMS_D3; + + float fTemperature_U0; + float fTemperature_D1; + float fTemperature_D2; + float fTemperature_D3; + }IS1Info; + + typedef struct tagISIFInformation + { + QString qstrSN_ATP; + QString qstrSN_IRIS; + + QString qstrCalFile_U0; + QString qstrCalFile_D1; + QString qstrCalFile_D2; + QString qstrCalFile_D3; + + int iPixelCount; + + int iExposureTimeInMS_U0; + int iExposureTimeInMS_D1; + int iExposureTimeInMS_D2; + int iExposureTimeInMS_D3; + + float fTemperature_U0; + float fTemperature_D1; + float fTemperature_D2; + float fTemperature_D3; + }ISIFInfo; + + typedef struct tagATPDataHeader + { + + + }ATPDataHeader; + + typedef struct tagCalibrationFrame + { + ZZ_U32 uiExposureTimeInMS; + float fTemperature; + int iPixels; + float fWaveLength[4096] = { 0 }; + double dCal_Gain[4096] = { 0 }; + double dCal_Offset[4096] = { 0 }; + }CalFrame; + + typedef struct tagCalDataFrame + { + ZZ_U32 usExposureTimeInMS; + float fTemperature = 0; + int iPixels; + float fData[4096]; + QString qstrGrabDate; + }CalDataFrame; + } + + //misc detector + namespace MISC_DETECTOR + { + typedef struct tagHumitureDeviceInfo + { + QString qstrInterfaceName; + }HumitureDeviceInfo; + } +}; +#pragma pack()//恢复默认内存对齐(按照8字节) diff --git a/JinspSpectralmeterControl/jinspspectralmetercontrol_global.h b/JinspSpectralmeterControl/jinspspectralmetercontrol_global.h new file mode 100644 index 0000000..f62c18d --- /dev/null +++ b/JinspSpectralmeterControl/jinspspectralmetercontrol_global.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +#ifndef BUILD_STATIC +# if defined(JINSPSPECTRALMETERCONTROL_LIB) +# define JINSPSPECTRALMETERCONTROL_EXPORT Q_DECL_EXPORT +# else +# define JINSPSPECTRALMETERCONTROL_EXPORT Q_DECL_IMPORT +# endif +#else +# define JINSPSPECTRALMETERCONTROL_EXPORT +#endif