Compare commits
4 Commits
5372a7806c
...
7ded94c2a4
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ded94c2a4 | |||
| cb5a74f576 | |||
| 4a31cc0f7f | |||
| 55609b7b3b |
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ icon
|
||||
ignore_*
|
||||
resources
|
||||
*.bkp
|
||||
.qwen
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
10
HPPA.sln
10
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
|
||||
|
||||
@ -100,3 +100,18 @@ void AppSettings::setDepthCameraDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/DepthCameraDataFolder", path);
|
||||
}
|
||||
|
||||
QString AppSettings::FiberImagerDataFolder() const
|
||||
{
|
||||
QString path = m_settings.value("General/FiberImagerDataFolder").toString();
|
||||
if (path.isEmpty())
|
||||
{
|
||||
return QCoreApplication::applicationDirPath() + "/CapturedFiberImagerData/";
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
void AppSettings::setFiberImagerDataFolder(const QString& path)
|
||||
{
|
||||
m_settings.setValue("General/FiberImagerDataFolder", path);
|
||||
}
|
||||
|
||||
@ -34,6 +34,9 @@ public:
|
||||
// 深度相机数据保存路径
|
||||
QString depthCameraDataFolder() const;
|
||||
void setDepthCameraDataFolder(const QString& path);
|
||||
|
||||
QString FiberImagerDataFolder() const;
|
||||
void setFiberImagerDataFolder(const QString& path);
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
|
||||
@ -97,6 +97,11 @@ void TwoMotionCaptureCoordinator::getLocBeforeStart()
|
||||
|
||||
loop.exec();
|
||||
|
||||
std::vector<double> pos;
|
||||
pos.push_back(0);
|
||||
pos.push_back(0);
|
||||
m_locBeforeStart = pos;
|
||||
|
||||
disconnect(conn);
|
||||
}
|
||||
|
||||
|
||||
61
HPPA/FiberSpectrometerOperationBase.h
Normal file
61
HPPA/FiberSpectrometerOperationBase.h
Normal file
@ -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
|
||||
90
HPPA/FodisWindow.cpp
Normal file
90
HPPA/FodisWindow.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#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::openFiberImager);
|
||||
connect(ui.close_btn, &QPushButton::clicked, this, &FodisWindow::closeFiberImager);
|
||||
|
||||
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()));
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD> AppSettings <20>ָ<EFBFBD><D6B8><EFBFBD>ʹ<EFBFBD><CAB9>Ĭ<EFBFBD>ϣ<EFBFBD>
|
||||
ui.dataFolderLineEdit->setText(AppSettings::instance().depthCameraDataFolder());
|
||||
|
||||
setDataFolder(AppSettings::instance().FiberImagerDataFolder());
|
||||
}
|
||||
|
||||
FodisWindow::~FodisWindow()
|
||||
{
|
||||
m_FiberImagerThread->quit();
|
||||
m_FiberImagerThread->wait();
|
||||
delete m_JinspFiberImagerOperation;
|
||||
m_JinspFiberImagerOperation = nullptr;
|
||||
}
|
||||
|
||||
void FodisWindow::onSelectDataFolder()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
QString::fromLocal8Bit("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD>"),
|
||||
ui.dataFolderLineEdit->text());
|
||||
|
||||
setDataFolder(dir);
|
||||
}
|
||||
|
||||
void FodisWindow::setDataFolder(QString dir)
|
||||
{
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
ui.dataFolderLineEdit->setText(dir);
|
||||
AppSettings::instance().setFiberImagerDataFolder(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void FodisWindow::setCaptureInterval(int captureIntervalSeconds)
|
||||
{
|
||||
m_JinspFiberImagerOperation->setCaptureInterval(captureIntervalSeconds);
|
||||
}
|
||||
|
||||
void FodisWindow::openFiberImager()
|
||||
{
|
||||
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("<EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD>"));
|
||||
}
|
||||
|
||||
void FodisWindow::closeFiberImager()
|
||||
{
|
||||
m_JinspFiberImagerOperation->disconnectFiberSpectrometer();
|
||||
}
|
||||
|
||||
void FodisWindow::onCamClosed()
|
||||
{
|
||||
ui.open_btn->setEnabled(true);
|
||||
ui.close_btn->setEnabled(false);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("<EFBFBD><EFBFBD> <20><>"));
|
||||
}
|
||||
50
HPPA/FodisWindow.h
Normal file
50
HPPA/FodisWindow.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QImage>
|
||||
#include <Qthread>
|
||||
#include <QDir>
|
||||
//#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <iostream>
|
||||
#include "ui_fodis.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#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 openFiberImager();
|
||||
void onCamOpened();
|
||||
void closeFiberImager();
|
||||
void onCamClosed();
|
||||
|
||||
void onSelectDataFolder();
|
||||
|
||||
signals:
|
||||
void openFiberImagerSignal();
|
||||
void PlotSpectralSignal();
|
||||
void FiberImagerClosedSignal();
|
||||
|
||||
private:
|
||||
Ui::FodisWindow ui;
|
||||
QThread* m_FiberImagerThread;
|
||||
|
||||
JinspFiberImager* m_JinspFiberImagerOperation;
|
||||
};
|
||||
308
HPPA/HPPA.cpp
308
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()));
|
||||
@ -553,6 +554,20 @@ HPPA::HPPA(QWidget* parent)
|
||||
}
|
||||
)");
|
||||
|
||||
m_ImageStretchThread = new QThread(this);
|
||||
m_ImageStretchWorker = new ImageStretchWorker();
|
||||
m_ImageStretchWorker->moveToThread(m_ImageStretchThread);
|
||||
// 注册QPixmap类型用于跨线程信号槽
|
||||
qRegisterMetaType<QPixmap>("QPixmap&");
|
||||
qRegisterMetaType<cv::Mat>("cv::Mat");
|
||||
qRegisterMetaType<cv::Mat>("cv::Mat");
|
||||
connect(m_ImageStretchWorker, &ImageStretchWorker::imageReady,
|
||||
this, &HPPA::onStretchedImageReady, Qt::QueuedConnection);
|
||||
connect(m_ImageStretchWorker, &ImageStretchWorker::processingError,
|
||||
this, &HPPA::onStretchProcessingError, Qt::QueuedConnection);
|
||||
m_ImageStretchThread->start();
|
||||
|
||||
|
||||
//光谱仪操作
|
||||
m_Imager = nullptr;
|
||||
m_RecordThread = nullptr;
|
||||
@ -632,6 +647,7 @@ void HPPA::setTimedDataCollectionHyperCamParm(int camType, double f, double e, Q
|
||||
{
|
||||
disconnectImagerAndCleanup();
|
||||
ui.mActionPica_L->setChecked(true);
|
||||
selectingImager(ui.mActionPica_L);
|
||||
|
||||
AppSettings::instance().setFrameRate(f);
|
||||
AppSettings::instance().setIntegrationTime(e);
|
||||
@ -647,6 +663,7 @@ void HPPA::setTimedDataCollectionHyperCamParm(int camType, double f, double e, Q
|
||||
{
|
||||
disconnectImagerAndCleanup();
|
||||
ui.mActionPica_NIR->setChecked(true);
|
||||
selectingImager(ui.mActionPica_NIR);
|
||||
|
||||
AppSettings::instance().setFrameRate(f);
|
||||
AppSettings::instance().setIntegrationTime(e);
|
||||
@ -667,10 +684,6 @@ void HPPA::setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
//唤醒单反相机
|
||||
m_pc3D->slrPowerDown();
|
||||
m_pc3D->slrPowerOn();
|
||||
|
||||
m_singleLensReflexCameraWindow->setDataFolder(folder);
|
||||
m_singleLensReflexCameraWindow->setCaptureInterval(captureIntervalSeconds);
|
||||
|
||||
@ -678,8 +691,6 @@ void HPPA::setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
m_pc3D->d65LampPowerOn();
|
||||
|
||||
m_depthCameraWindow->setDataFolder(folder);
|
||||
m_depthCameraWindow->setCaptureInterval(captureIntervalSeconds);
|
||||
|
||||
@ -1008,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)));
|
||||
@ -1186,6 +1202,14 @@ HPPA::~HPPA()
|
||||
{
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
m_ImageStretchThread->quit();
|
||||
m_ImageStretchThread->wait(3000);
|
||||
delete m_ImageStretchWorker;
|
||||
m_ImageStretchWorker = nullptr;
|
||||
delete m_ImageStretchThread;
|
||||
m_ImageStretchThread = nullptr;
|
||||
|
||||
}
|
||||
|
||||
void HPPA::removeLayerByTreeIndex()
|
||||
@ -1417,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);
|
||||
@ -1431,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);
|
||||
@ -1488,6 +1518,22 @@ void HPPA::createOneMotorScenario()
|
||||
|
||||
}
|
||||
|
||||
void HPPA::createGonggaRotatingPlatformScenario()
|
||||
{
|
||||
//在菜单中选择移动平台
|
||||
ui.mAction_1AxisMotor->setChecked(true);
|
||||
|
||||
//右下角控制tab
|
||||
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<double>)), m_view3DModelManager->m_viewPlant, SLOT(setLoc(std::vector<double>)));
|
||||
@ -2388,9 +2434,9 @@ void HPPA::onconnect()
|
||||
ui.gain_lineEdit->setValidator(new QRegExpValidator(rx));*/
|
||||
|
||||
//获取相机参数并显示到界面中
|
||||
m_hic->setFrameRate(AppSettings::instance().frameRate());
|
||||
m_hic->setIntegrationTime(AppSettings::instance().integrationTime());
|
||||
m_hic->setGain(AppSettings::instance().gain());
|
||||
onFramerateChanged(AppSettings::instance().frameRate());
|
||||
onIntegrationTimeChanged(AppSettings::instance().integrationTime());
|
||||
onGainChanged(AppSettings::instance().gain());
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
@ -2619,8 +2665,8 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
m_recordFrameCounter->updateFrameCount(static_cast<RasterLayer*>(mapLayer), m_Imager->getFrameCounter());
|
||||
}
|
||||
|
||||
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||
return;
|
||||
//if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||
// return;
|
||||
|
||||
//return;
|
||||
//获取绘图控件
|
||||
@ -2630,14 +2676,20 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
//创建需要显示的图像--opencv版本
|
||||
ImageProcessor imageProcessor;
|
||||
//cv::Mat rgbImage(*m_Imager->getRgbImage()->m_matRgbImage, cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());//2022.3.18重构的
|
||||
cv::Mat rgbImage(*m_Imager->getMatRgbImage(), cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());
|
||||
cv::Mat rgbImageStretched = imageProcessor.CStretch(rgbImage, 0.02);
|
||||
showQuickPreview(fileNumber, filePath, rgbImage);
|
||||
|
||||
//在界面中显示图像
|
||||
currentImageViewer[0]->SetImage(&QPixmap::fromImage(imageProcessor.Mat2QImage(rgbImageStretched)));//绘制图像
|
||||
|
||||
if (m_ImageStretchWorker) {
|
||||
// 深拷贝图像数据,因为原始数据可能在处理完成前被修改
|
||||
cv::Mat rgbImageCopy = rgbImage.clone();
|
||||
QMetaObject::invokeMethod(m_ImageStretchWorker, "processImage",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(cv::Mat, rgbImageCopy),
|
||||
Q_ARG(int, fileNumber),
|
||||
Q_ARG(QString, filePath),
|
||||
Q_ARG(float, 0.02f));
|
||||
}
|
||||
|
||||
//20241225
|
||||
//保存拉伸后的rgb
|
||||
@ -2656,6 +2708,43 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
//currentImageViewer[0]->SetImage(&QPixmap::fromImage(CuttedImage));//绘制图像
|
||||
}
|
||||
|
||||
void HPPA::showQuickPreview(int fileNumber, const QString& filePath, const cv::Mat& rgbImage)
|
||||
{
|
||||
// 可以显示一个简单缩放的预览图,或者显示"处理中..."的提示
|
||||
// 这里简单地跳过,等待拉伸后的图像
|
||||
// 如果需要快速预览,可以进行简单的缩放显示
|
||||
|
||||
/*
|
||||
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
||||
if (!currentWidget) return;
|
||||
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.isEmpty()) return;
|
||||
|
||||
// 显示一个简单的灰度或缩放版本作为预览
|
||||
cv::Mat preview;
|
||||
cv::resize(rgbImage, preview, cv::Size(), 0.25, 0.25); // 缩小到25%
|
||||
// ... 转换并显示
|
||||
*/
|
||||
}
|
||||
|
||||
void HPPA::onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap)
|
||||
{
|
||||
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
||||
if (!currentWidget) return;
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.isEmpty()) return;
|
||||
// 在界面中显示拉伸后的图像
|
||||
currentImageViewer[0]->SetImage(&pixmap);
|
||||
}
|
||||
// 处理错误的回调
|
||||
void HPPA::onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error)
|
||||
{
|
||||
qDebug() << "Image stretch error for file" << filePath << ":" << error;
|
||||
// 可以选择显示错误信息或保留之前的图像
|
||||
}
|
||||
|
||||
|
||||
void HPPA::focusPlotSpectralImg(int state)
|
||||
{
|
||||
if (!m_Imager) return;
|
||||
@ -2813,7 +2902,8 @@ void HPPA::onLayerCreatedFromFile(const QString& baseName, const QString& filePa
|
||||
|
||||
if (ui.mAction3DPlantPhenotypeScenario->isChecked())
|
||||
{
|
||||
addLayer(baseName, filePath, false, false);
|
||||
//addLayer(baseName, filePath, false, false);
|
||||
addLayer(baseName, filePath, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2969,3 +3059,185 @@ void HPPA::onBandSelectionChanged(double rWave, double gWave, double bWave)
|
||||
|
||||
mapcavas[0]->freshmap();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
ImageStretchWorker::ImageStretchWorker(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ImageStretchWorker::~ImageStretchWorker()
|
||||
{
|
||||
}
|
||||
|
||||
void ImageStretchWorker::processImage(const cv::Mat& rgbImage, int fileNumber, const QString& filePath, float ratio)
|
||||
{
|
||||
try {
|
||||
if (rgbImage.empty()) {
|
||||
emit processingError(fileNumber, filePath, "Empty image");
|
||||
return;
|
||||
}
|
||||
|
||||
// 执行耗时的拉伸操作
|
||||
cv::Mat rgbImageStretched = CStretch(rgbImage, ratio);
|
||||
|
||||
// 转换为QImage再转为QPixmap
|
||||
QImage qimg = Mat2QImage(rgbImageStretched);
|
||||
QPixmap pixmap = QPixmap::fromImage(qimg);
|
||||
|
||||
emit imageReady(fileNumber, filePath, pixmap);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
emit processingError(fileNumber, filePath, QString::fromStdString(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cv::Point2f> ImageStretchWorker::CHistogram(const cv::Mat& img)
|
||||
{
|
||||
cv::Mat mimg = img.clone();
|
||||
int rows = mimg.rows;
|
||||
int cols = mimg.cols;
|
||||
int maxValue = 65535;
|
||||
|
||||
std::vector<long int> hisnum(maxValue, 0);
|
||||
for (int i = 0; i < rows; ++i)
|
||||
{
|
||||
for (int j = 0; j < cols; ++j)
|
||||
{
|
||||
unsigned short gv = mimg.at<unsigned short>(i, j);
|
||||
if (gv >= maxValue)
|
||||
{
|
||||
++hisnum[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
++hisnum[gv];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long int pnum = rows * cols;
|
||||
std::vector<cv::Point2f> hisp;
|
||||
hisp.reserve(hisnum.size());
|
||||
for (size_t i = 0; i < hisnum.size(); ++i)
|
||||
{
|
||||
float p = static_cast<float>(hisnum[i]) / pnum;
|
||||
hisp.push_back(cv::Point2f(static_cast<float>(i), p));
|
||||
}
|
||||
return hisp;
|
||||
}
|
||||
|
||||
uint ImageStretchWorker::MaxRatio(const std::vector<cv::Point2f>& data, float ratio)
|
||||
{
|
||||
float maxp = 0;
|
||||
uint outnum = 0;
|
||||
for (int i = static_cast<int>(data.size()) - 1; i >= 0; --i)
|
||||
{
|
||||
maxp += data[i].y;
|
||||
if (maxp >= ratio)
|
||||
{
|
||||
outnum = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return outnum;
|
||||
}
|
||||
|
||||
uint ImageStretchWorker::MinRatio(const std::vector<cv::Point2f>& data, float ratio)
|
||||
{
|
||||
float minp = 0;
|
||||
uint outnum = 0;
|
||||
for (size_t i = 0; i < data.size(); ++i)
|
||||
{
|
||||
minp += data[i].y;
|
||||
if (minp >= ratio)
|
||||
{
|
||||
outnum = static_cast<uint>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return outnum;
|
||||
}
|
||||
|
||||
cv::Mat ImageStretchWorker::CStretchDeal(const cv::Mat& img, uint minnum, uint maxnum)
|
||||
{
|
||||
cv::Mat mimg = img.clone();
|
||||
int rows = mimg.rows;
|
||||
int cols = mimg.cols;
|
||||
cv::Mat nimg = cv::Mat::zeros(rows, cols, CV_8U);
|
||||
|
||||
float dertnum = static_cast<float>(maxnum - minnum);
|
||||
|
||||
for (int i = 0; i < rows; ++i)
|
||||
{
|
||||
for (int j = 0; j < cols; ++j)
|
||||
{
|
||||
unsigned short a = mimg.at<unsigned short>(i, j);
|
||||
if (a <= minnum)
|
||||
nimg.at<uchar>(i, j) = 0;
|
||||
else if (a >= maxnum)
|
||||
nimg.at<uchar>(i, j) = 255;
|
||||
else
|
||||
nimg.at<uchar>(i, j) = static_cast<uchar>(255 * (a - minnum) / dertnum);
|
||||
}
|
||||
}
|
||||
return nimg;
|
||||
}
|
||||
|
||||
cv::Mat ImageStretchWorker::CStretch(const cv::Mat& img, float ratio)
|
||||
{
|
||||
cv::Mat mimg = img.clone();
|
||||
cv::Mat bgr[3];
|
||||
cv::split(mimg, bgr);
|
||||
|
||||
std::vector<cv::Point2f> hb = CHistogram(bgr[0]);
|
||||
std::vector<cv::Point2f> hg = CHistogram(bgr[1]);
|
||||
std::vector<cv::Point2f> hr = CHistogram(bgr[2]);
|
||||
|
||||
uint minb = MinRatio(hb, ratio);
|
||||
uint ming = MinRatio(hg, ratio);
|
||||
uint minr = MinRatio(hr, ratio);
|
||||
uint maxb = MaxRatio(hb, ratio);
|
||||
uint maxg = MaxRatio(hg, ratio);
|
||||
uint maxr = MaxRatio(hr, ratio);
|
||||
|
||||
cv::Mat b = CStretchDeal(bgr[0], minb, maxb);
|
||||
cv::Mat g = CStretchDeal(bgr[1], ming, maxg);
|
||||
cv::Mat r = CStretchDeal(bgr[2], minr, maxr);
|
||||
|
||||
cv::Mat newbgr;
|
||||
newbgr.create(img.rows, img.cols, CV_32FC3);
|
||||
cv::Mat nbgr[3] = { b, g, r };
|
||||
cv::merge(nbgr, 3, newbgr);
|
||||
return newbgr;
|
||||
}
|
||||
|
||||
QImage ImageStretchWorker::Mat2QImage(const cv::Mat& cvImg)
|
||||
{
|
||||
QImage qImg;
|
||||
if (cvImg.channels() == 3)
|
||||
{
|
||||
cv::Mat rgbImg;
|
||||
cv::cvtColor(cvImg, rgbImg, cv::COLOR_BGR2RGB);
|
||||
qImg = QImage(rgbImg.data,
|
||||
rgbImg.cols, rgbImg.rows,
|
||||
static_cast<int>(rgbImg.step),
|
||||
QImage::Format_RGB888).copy(); // 使用copy()确保数据独立
|
||||
}
|
||||
else if (cvImg.channels() == 1)
|
||||
{
|
||||
qImg = QImage(cvImg.data,
|
||||
cvImg.cols, cvImg.rows,
|
||||
static_cast<int>(cvImg.step),
|
||||
QImage::Format_Indexed8).copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
qImg = QImage(cvImg.data,
|
||||
cvImg.cols, cvImg.rows,
|
||||
static_cast<int>(cvImg.step),
|
||||
QImage::Format_RGB888).copy();
|
||||
}
|
||||
return qImg;
|
||||
}
|
||||
|
||||
36
HPPA/HPPA.h
36
HPPA/HPPA.h
@ -87,6 +87,9 @@
|
||||
#include "TimedDataCollection.h"
|
||||
|
||||
#include "PowerControl3D.h"
|
||||
#include "FodisWindow.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
@ -194,6 +197,26 @@ private:
|
||||
QPixmap m_pixmap;
|
||||
};
|
||||
|
||||
class ImageStretchWorker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImageStretchWorker(QObject* parent = nullptr);
|
||||
~ImageStretchWorker();
|
||||
public slots:
|
||||
void processImage(const cv::Mat& rgbImage, int fileNumber, const QString& filePath, float ratio = 0.02f);
|
||||
signals:
|
||||
void imageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
||||
void processingError(int fileNumber, const QString& filePath, const QString& error);
|
||||
private:
|
||||
cv::Mat CStretch(const cv::Mat& img, float ratio);
|
||||
cv::Mat CStretchDeal(const cv::Mat& img, uint minnum, uint maxnum);
|
||||
std::vector<cv::Point2f> CHistogram(const cv::Mat& img);
|
||||
uint MaxRatio(const std::vector<cv::Point2f>& data, float ratio);
|
||||
uint MinRatio(const std::vector<cv::Point2f>& data, float ratio);
|
||||
QImage Mat2QImage(const cv::Mat& cvImg);
|
||||
};
|
||||
|
||||
class HPPA : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -297,6 +320,7 @@ private:
|
||||
RobotArmControl* m_rac;
|
||||
OneMotorControl* m_omc;
|
||||
TwoMotorControl* m_tmc;
|
||||
FodisWindow* m_fodisWindow;
|
||||
QPointer<TimedDataCollection> m_tdc;
|
||||
|
||||
View3DModelManager* m_view3DModelManager;
|
||||
@ -325,6 +349,13 @@ private:
|
||||
|
||||
void initTimedDataCollection();
|
||||
|
||||
QThread* m_ImageStretchThread = nullptr;
|
||||
ImageStretchWorker* m_ImageStretchWorker = nullptr;
|
||||
|
||||
// 用于临时显示的未拉伸图像(可选,用于快速预览)
|
||||
void showQuickPreview(int fileNumber, const QString& filePath, const cv::Mat& rgbImage);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||
void focusPlotSpectralImg(int state);
|
||||
@ -381,6 +412,7 @@ public Q_SLOTS:
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
void createOneMotorScenario();
|
||||
void createGonggaRotatingPlatformScenario();
|
||||
void createPlantPhenotypeScenario();
|
||||
void create3DPlantPhenotypeScenario();
|
||||
void onCreated3DModelPlantPhenotype();
|
||||
@ -408,6 +440,10 @@ public Q_SLOTS:
|
||||
void setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds, QString folder);
|
||||
void setTimedDataCollectionMotorParm(QString pathLineFilePath);
|
||||
void onStartTimedDataCollection(int camType);
|
||||
|
||||
void onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
||||
void onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error);
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
|
||||
@ -133,6 +133,7 @@ color:white;
|
||||
<string>应用场景</string>
|
||||
</property>
|
||||
<addaction name="mActionOneMotorScenario"/>
|
||||
<addaction name="mActionGonggaRotatingPlatformScenario"/>
|
||||
<addaction name="mActionPlantPhenotypeScenario"/>
|
||||
<addaction name="mActionMicroscopicMotionControlScenario"/>
|
||||
<addaction name="mAction3DPlantPhenotypeScenario"/>
|
||||
@ -749,6 +750,14 @@ QPushButton:pressed
|
||||
<string>定时采集</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="mActionGonggaRotatingPlatformScenario">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>贡嘎山旋转平台</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<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;$(IncludePath)</IncludePath>
|
||||
<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)</IncludePath>
|
||||
<LibraryPath>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)</LibraryPath>
|
||||
<TargetName>Spectral Insight</TargetName>
|
||||
</PropertyGroup>
|
||||
@ -66,7 +66,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Link>
|
||||
<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;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<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)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<ClCompile>
|
||||
@ -118,12 +118,14 @@
|
||||
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
||||
<ClCompile Include="DepthCameraWindow.cpp" />
|
||||
<ClCompile Include="FileNameLineEdit.cpp" />
|
||||
<ClCompile Include="FodisWindow.cpp" />
|
||||
<ClCompile Include="hppaConfigFile.cpp" />
|
||||
<ClCompile Include="HyperImagerControl.cpp" />
|
||||
<ClCompile Include="imageControl.cpp" />
|
||||
<ClCompile Include="ImagerOperationBase.cpp" />
|
||||
<ClCompile Include="imager_base.cpp" />
|
||||
<ClCompile Include="irisximeaimager.cpp" />
|
||||
<ClCompile Include="JinspFiberImager.cpp" />
|
||||
<ClCompile Include="LayerTree.cpp" />
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
||||
<ClCompile Include="LayerTreeImageNode.cpp" />
|
||||
@ -177,6 +179,7 @@
|
||||
<QtUic Include="adjustTable.ui" />
|
||||
<QtUic Include="DepthCamera.ui" />
|
||||
<QtUic Include="FocusDialog.ui" />
|
||||
<QtUic Include="fodis.ui" />
|
||||
<QtUic Include="HPPA.ui" />
|
||||
<QtMoc Include="HPPA.h" />
|
||||
<ClCompile Include="fileOperation.cpp" />
|
||||
@ -231,6 +234,8 @@
|
||||
<QtMoc Include="DepthCameraWindow.h" />
|
||||
<QtMoc Include="CommunicationViaTCP.h" />
|
||||
<QtMoc Include="CommunicationInterfaceBase.h" />
|
||||
<QtMoc Include="FodisWindow.h" />
|
||||
<ClInclude Include="FiberSpectrometerOperationBase.h" />
|
||||
<ClInclude Include="imager_base.h" />
|
||||
<ClInclude Include="irisximeaimager.h" />
|
||||
<QtMoc Include="OneMotorControl.h" />
|
||||
@ -245,6 +250,7 @@
|
||||
<QtMoc Include="RasterLayer.h" />
|
||||
<QtMoc Include="MapLayerStore.h" />
|
||||
<QtMoc Include="LayerTreeImageNode.h" />
|
||||
<QtMoc Include="JinspFiberImager.h" />
|
||||
<ClInclude Include="LayerTreeView.h" />
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
||||
<QtMoc Include="MapTool.h" />
|
||||
|
||||
@ -253,6 +253,12 @@
|
||||
<ClCompile Include="PathLine.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FodisWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JinspFiberImager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -414,6 +420,12 @@
|
||||
<QtMoc Include="TaskTreeModel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="FodisWindow.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="JinspFiberImager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -473,6 +485,9 @@
|
||||
<ClInclude Include="PathLine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FiberSpectrometerOperationBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
@ -529,6 +544,9 @@
|
||||
<QtUic Include="PowerControl3D.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="fodis.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
301
HPPA/JinspFiberImager.cpp
Normal file
301
HPPA/JinspFiberImager.cpp
Normal file
@ -0,0 +1,301 @@
|
||||
//
|
||||
// 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_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_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);
|
||||
|
||||
//输出到csv
|
||||
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)//将integratingSphereData_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;
|
||||
}
|
||||
|
||||
|
||||
//输出到csv
|
||||
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)//是否超过允许的最大迭代次数
|
||||
{
|
||||
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();
|
||||
|
||||
//采集
|
||||
m_record = true;
|
||||
while (m_record)
|
||||
{
|
||||
recordTarget(1, AppSettings::instance().FiberImagerDataFolder());
|
||||
|
||||
QThread::msleep(m_captureIntervalMilliseconds);
|
||||
}
|
||||
|
||||
std::cout << "close.........." << std::endl;
|
||||
m_FiberSpectrometer->Close();
|
||||
}
|
||||
67
HPPA/JinspFiberImager.h
Normal file
67
HPPA/JinspFiberImager.h
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Created by 73505 on 2023/5/7.
|
||||
//
|
||||
#pragma once
|
||||
#include <qthread.h>
|
||||
//#include <QFileDialog>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "JinspSpectralmeterControl.h"
|
||||
#include "FiberSpectrometerOperationBase.h"
|
||||
#include "utility_tc.h"
|
||||
#include "AppSettings.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;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
void OpenFiberImagerAndRecord();
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
};
|
||||
@ -2,6 +2,7 @@
|
||||
#include "RasterDataProvider.h"
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
MultibandRasterRenderer::MultibandRasterRenderer(RasterDataProvider* provider)
|
||||
: RasterRendererBase(provider)
|
||||
@ -26,6 +27,96 @@ void MultibandRasterRenderer::stretchTo8bit(const std::vector<float>& in, std::v
|
||||
}
|
||||
}
|
||||
|
||||
void MultibandRasterRenderer::computeHistogram(const std::vector<float>& in, std::vector<long>& hist, float& minVal, float& maxVal)
|
||||
{
|
||||
if (in.empty())
|
||||
{
|
||||
minVal = 0.0f;
|
||||
maxVal = 1.0f;
|
||||
hist.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
minVal = in[0];
|
||||
maxVal = in[0];
|
||||
for (size_t i = 0; i < in.size(); ++i)
|
||||
{
|
||||
if (in[i] < minVal) minVal = in[i];
|
||||
if (in[i] > maxVal) maxVal = in[i];
|
||||
}
|
||||
|
||||
if (maxVal <= minVal)
|
||||
{
|
||||
hist.assign(256, 0);
|
||||
hist[0] = static_cast<long>(in.size());
|
||||
minVal = 0.0f;
|
||||
maxVal = 1.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const int numBins = 65536;
|
||||
hist.assign(numBins, 0);
|
||||
|
||||
for (size_t i = 0; i < in.size(); ++i)
|
||||
{
|
||||
++hist[static_cast<int>(in[i])];
|
||||
}
|
||||
}
|
||||
|
||||
void MultibandRasterRenderer::findStretchValuesByRatio(const std::vector<long>& hist, float ratio, float& minVal, float& maxVal)
|
||||
{
|
||||
if (hist.empty()) return;
|
||||
|
||||
long totalPixels = 0;
|
||||
for (size_t i = 0; i < hist.size(); ++i)
|
||||
{
|
||||
totalPixels += hist[i];
|
||||
}
|
||||
if (totalPixels == 0) return;
|
||||
|
||||
long targetCount = static_cast<long>(totalPixels * ratio);
|
||||
|
||||
long cumulative = 0;
|
||||
for (size_t i = 0; i < hist.size(); ++i)
|
||||
{
|
||||
cumulative += hist[i];
|
||||
if (cumulative >= targetCount)
|
||||
{
|
||||
minVal = static_cast<float>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cumulative = 0;
|
||||
for (size_t i = hist.size(); i > 0; --i)
|
||||
{
|
||||
cumulative += hist[i - 1];
|
||||
if (cumulative >= targetCount)
|
||||
{
|
||||
maxVal = static_cast<float>(i - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MultibandRasterRenderer::stretchTo8bitByHistogram(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal)
|
||||
{
|
||||
size_t n = in.size();
|
||||
out.resize(n);
|
||||
if (maxVal <= minVal)
|
||||
{
|
||||
std::fill(out.begin(), out.end(), 0);
|
||||
return;
|
||||
}
|
||||
float denom = 1.0f / (maxVal - minVal);
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
float v = (in[i] - minVal) * denom;
|
||||
v = std::min(std::max(v, 0.0f), 1.0f);
|
||||
out[i] = static_cast<unsigned char>(v * 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
QImage MultibandRasterRenderer::render()
|
||||
{
|
||||
if (!m_provider) return QImage();
|
||||
@ -65,11 +156,39 @@ QImage MultibandRasterRenderer::render()
|
||||
if (bIdx >= 0) m_provider->readBandAsFloat(bIdx, bbuf);
|
||||
|
||||
std::vector<unsigned char> r8, g8, b8;
|
||||
float minV = static_cast<float>(m_params.minValue);
|
||||
float maxV = static_cast<float>(m_params.maxValue);
|
||||
if (!rbuf.empty()) stretchTo8bit(rbuf, r8, minV, maxV);
|
||||
if (!gbuf.empty()) stretchTo8bit(gbuf, g8, minV, maxV);
|
||||
if (!bbuf.empty()) stretchTo8bit(bbuf, b8, minV, maxV);
|
||||
|
||||
// Compute histogram-based stretch for each channel
|
||||
float ratio = m_stretchRatio;
|
||||
|
||||
// R channel stretch
|
||||
if (!rbuf.empty()) {
|
||||
std::vector<long> rHist;
|
||||
float rMin, rMax;
|
||||
computeHistogram(rbuf, rHist, rMin, rMax);
|
||||
float rStretchMin = rMin, rStretchMax = rMax;
|
||||
findStretchValuesByRatio(rHist, ratio, rStretchMin, rStretchMax);
|
||||
stretchTo8bitByHistogram(rbuf, r8, rStretchMin, rStretchMax);
|
||||
}
|
||||
|
||||
// G channel stretch
|
||||
if (!gbuf.empty()) {
|
||||
std::vector<long> gHist;
|
||||
float gMin, gMax;
|
||||
computeHistogram(gbuf, gHist, gMin, gMax);
|
||||
float gStretchMin = gMin, gStretchMax = gMax;
|
||||
findStretchValuesByRatio(gHist, ratio, gStretchMin, gStretchMax);
|
||||
stretchTo8bitByHistogram(gbuf, g8, gStretchMin, gStretchMax);
|
||||
}
|
||||
|
||||
// B channel stretch
|
||||
if (!bbuf.empty()) {
|
||||
std::vector<long> bHist;
|
||||
float bMin, bMax;
|
||||
computeHistogram(bbuf, bHist, bMin, bMax);
|
||||
float bStretchMin = bMin, bStretchMax = bMax;
|
||||
findStretchValuesByRatio(bHist, ratio, bStretchMin, bStretchMax);
|
||||
stretchTo8bitByHistogram(bbuf, b8, bStretchMin, bStretchMax);
|
||||
}
|
||||
|
||||
QImage out(w, h, QImage::Format_RGB888);
|
||||
for (int y = 0; y < h; ++y) {
|
||||
|
||||
@ -18,9 +18,22 @@ public:
|
||||
MultibandRenderParams params() const { return m_params; }
|
||||
void setParams(const MultibandRenderParams& params) { m_params = params; }
|
||||
|
||||
void setStretchRatio(float ratio) { m_stretchRatio = ratio; }
|
||||
float stretchRatio() const { return m_stretchRatio; }
|
||||
|
||||
private:
|
||||
MultibandRenderParams m_params;
|
||||
float m_stretchRatio = 0.02f;
|
||||
|
||||
// Helper to map float buffer to 8-bit with min/max stretch
|
||||
static void stretchTo8bit(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
||||
|
||||
// Helper to compute histogram from float buffer
|
||||
static void computeHistogram(const std::vector<float>& in, std::vector<long>& hist, float& minVal, float& maxVal);
|
||||
|
||||
// Helper to find stretch values by cumulative histogram ratio
|
||||
static void findStretchValuesByRatio(const std::vector<long>& hist, float ratio, float& minVal, float& maxVal);
|
||||
|
||||
// Helper to stretch to 8-bit using histogram-based stretch
|
||||
static void stretchTo8bitByHistogram(const std::vector<float>& in, std::vector<unsigned char>& out, float minVal, float maxVal);
|
||||
};
|
||||
|
||||
@ -6,6 +6,124 @@
|
||||
// 全局变量用于回调函数访问
|
||||
static SingleLensReflexCameraOperation* g_cameraOperation = nullptr;
|
||||
|
||||
// 将Canon EDSDK错误码转换为中文描述
|
||||
QString getEDSDKErrorMessage(EdsError err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case EDS_ERR_OK:
|
||||
return QString::fromLocal8Bit("操作成功,错误码:%1").arg(err);
|
||||
case EDS_ERR_UNIMPLEMENTED:
|
||||
return QString::fromLocal8Bit("功能未实现,错误码:%1").arg(err);
|
||||
case EDS_ERR_INTERNAL_ERROR:
|
||||
return QString::fromLocal8Bit("内部错误,错误码:%1").arg(err);
|
||||
case EDS_ERR_MEM_ALLOC_FAILED:
|
||||
return QString::fromLocal8Bit("内存分配失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_MEM_FREE_FAILED:
|
||||
return QString::fromLocal8Bit("内存释放失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_OPERATION_CANCELLED:
|
||||
return QString::fromLocal8Bit("操作已取消,错误码:%1").arg(err);
|
||||
case EDS_ERR_INCOMPATIBLE_VERSION:
|
||||
return QString::fromLocal8Bit("版本不兼容,错误码:%1").arg(err);
|
||||
case EDS_ERR_NOT_SUPPORTED:
|
||||
return QString::fromLocal8Bit("不支持该操作,错误码:%1").arg(err);
|
||||
case EDS_ERR_UNEXPECTED_EXCEPTION:
|
||||
return QString::fromLocal8Bit("意外异常,错误码:%1").arg(err);
|
||||
case EDS_ERR_PROTECTION_VIOLATION:
|
||||
return QString::fromLocal8Bit("保护违规,错误码:%1").arg(err);
|
||||
case EDS_ERR_MISSING_SUBCOMPONENT:
|
||||
return QString::fromLocal8Bit("缺少子组件,错误码:%1").arg(err);
|
||||
case EDS_ERR_SELECTION_UNAVAILABLE:
|
||||
return QString::fromLocal8Bit("选择不可用,错误码:%1").arg(err);
|
||||
case EDS_ERR_FILE_IO_ERROR:
|
||||
return QString::fromLocal8Bit("文件IO错误,错误码:%1").arg(err);
|
||||
case EDS_ERR_FILE_NOT_FOUND:
|
||||
return QString::fromLocal8Bit("文件未找到,错误码:%1").arg(err);
|
||||
case EDS_ERR_FILE_OPEN_ERROR:
|
||||
return QString::fromLocal8Bit("文件打开失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_NOT_FOUND:
|
||||
return QString::fromLocal8Bit("设备未找到,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_BUSY:
|
||||
return QString::fromLocal8Bit("设备忙,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_INVALID:
|
||||
return QString::fromLocal8Bit("设备无效,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_MEMORY_FULL:
|
||||
return QString::fromLocal8Bit("设备内存已满,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_INTERNAL_ERROR:
|
||||
return QString::fromLocal8Bit("设备内部错误,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_NO_DISK:
|
||||
return QString::fromLocal8Bit("设备无存储介质,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_DISK_ERROR:
|
||||
return QString::fromLocal8Bit("设备磁盘错误,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_CF_GATE_CHANGED:
|
||||
return QString::fromLocal8Bit("CF卡仓已改变,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_DIAL_CHANGED:
|
||||
return QString::fromLocal8Bit("拨盘已改变,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICE_NOT_INSTALLED:
|
||||
return QString::fromLocal8Bit("设备未安装,错误码:%1").arg(err);
|
||||
case EDS_ERR_SESSION_NOT_OPEN:
|
||||
return QString::fromLocal8Bit("会话未打开,错误码:%1").arg(err);
|
||||
case EDS_ERR_INVALID_TRANSACTIONID:
|
||||
return QString::fromLocal8Bit("无效的事务ID,错误码:%1").arg(err);
|
||||
case EDS_ERR_INCOMPLETE_TRANSFER:
|
||||
return QString::fromLocal8Bit("传输不完整,错误码:%1").arg(err);
|
||||
case EDS_ERR_INVALID_STRAGEID:
|
||||
return QString::fromLocal8Bit("无效的存储ID,错误码:%1").arg(err);
|
||||
case EDS_ERR_DEVICEPROP_NOT_SUPPORTED:
|
||||
return QString::fromLocal8Bit("设备属性不支持,错误码:%1").arg(err);
|
||||
case EDS_ERR_INVALID_OBJECTFORMATCODE:
|
||||
return QString::fromLocal8Bit("无效的对象格式代码,错误码:%1").arg(err);
|
||||
case EDS_ERR_SELF_TEST_FAILED:
|
||||
return QString::fromLocal8Bit("自检失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_UNKNOWN_VENDOR_CODE:
|
||||
return QString::fromLocal8Bit("未知的厂商代码,错误码:%1").arg(err);
|
||||
case EDS_ERR_CAPTURE_ALREADY_TERMINATED:
|
||||
return QString::fromLocal8Bit("拍摄已终止,错误码:%1").arg(err);
|
||||
case EDS_ERR_PTP_DEVICE_BUSY:
|
||||
return QString::fromLocal8Bit("PTP设备忙,错误码:%1").arg(err);
|
||||
case EDS_ERR_UNKNOWN_COMMAND:
|
||||
return QString::fromLocal8Bit("未知命令,错误码:%1").arg(err);
|
||||
case EDS_ERR_OPERATION_REFUSED:
|
||||
return QString::fromLocal8Bit("操作被拒绝,错误码:%1").arg(err);
|
||||
case EDS_ERR_LENS_COVER_CLOSE:
|
||||
return QString::fromLocal8Bit("镜头盖未关闭,错误码:%1").arg(err);
|
||||
case EDS_ERR_LOW_BATTERY:
|
||||
return QString::fromLocal8Bit("电池电量低,错误码:%1").arg(err);
|
||||
case EDS_ERR_OBJECT_NOTREADY:
|
||||
return QString::fromLocal8Bit("对象未就绪,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_AF_NG:
|
||||
return QString::fromLocal8Bit("自动对焦失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_MIRROR_UP_NG:
|
||||
return QString::fromLocal8Bit("反光镜升起失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_SENSOR_CLEANING_NG:
|
||||
return QString::fromLocal8Bit("传感器清洁失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_SILENCE_NG:
|
||||
return QString::fromLocal8Bit("静音拍摄失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_NO_CARD_NG:
|
||||
return QString::fromLocal8Bit("未检测到存储卡,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_CARD_NG:
|
||||
return QString::fromLocal8Bit("存储卡错误,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_CARD_PROTECT_NG:
|
||||
return QString::fromLocal8Bit("存储卡被保护,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_MOVIE_CROP_NG:
|
||||
return QString::fromLocal8Bit("短片裁切模式不支持,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_STROBO_CHARGE_NG:
|
||||
return QString::fromLocal8Bit("闪光灯充电失败,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_NO_LENS_NG:
|
||||
return QString::fromLocal8Bit("未安装镜头,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_SPECIAL_MOVIE_MODE_NG:
|
||||
return QString::fromLocal8Bit("特殊短片模式不支持,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_LV_REL_PROHIBIT_MODE_NG:
|
||||
return QString::fromLocal8Bit("实时显示释放被禁止,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_MOVIE_MODE_NG:
|
||||
return QString::fromLocal8Bit("短片模式下不支持,错误码:%1").arg(err);
|
||||
case EDS_ERR_TAKE_PICTURE_RETRUCTED_LENS_NG:
|
||||
return QString::fromLocal8Bit("伸缩镜头不支持,错误码:%1").arg(err);
|
||||
default:
|
||||
return QString::fromLocal8Bit("未知错误: 0x%1").arg(err, 8, 16, QChar('0'));
|
||||
}
|
||||
}
|
||||
|
||||
SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_isCapturing(false)
|
||||
@ -192,7 +310,7 @@ void SingleLensReflexCameraWindow::onImageCaptured(const QString& filePath)
|
||||
|
||||
void SingleLensReflexCameraWindow::onError(const QString& errorMsg)
|
||||
{
|
||||
QMessageBox::warning(this, QString::fromLocal8Bit("相机错误"), errorMsg);
|
||||
QMessageBox::warning(this, QString::fromLocal8Bit("单反相机错误"), errorMsg);
|
||||
}
|
||||
|
||||
void SingleLensReflexCameraWindow::onStartCapture()
|
||||
@ -764,7 +882,7 @@ void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||
err = initializeSDK();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -773,7 +891,7 @@ void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -783,7 +901,7 @@ void SingleLensReflexCameraOperation::OpenSLRCamera()
|
||||
{
|
||||
closeCamera();
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -829,7 +947,7 @@ void SingleLensReflexCameraOperation::OpenAndTakePhotoSLRCamera()
|
||||
err = initializeSDK();
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -838,7 +956,7 @@ void SingleLensReflexCameraOperation::OpenAndTakePhotoSLRCamera()
|
||||
if (err != EDS_ERR_OK)
|
||||
{
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -848,7 +966,7 @@ void SingleLensReflexCameraOperation::OpenAndTakePhotoSLRCamera()
|
||||
{
|
||||
closeCamera();
|
||||
terminateSDK();
|
||||
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -934,7 +1052,7 @@ void SingleLensReflexCameraOperation::onCaptureTimer()
|
||||
// 如果是设备忙,不发送错误信号,等待下次重试
|
||||
if (err != EDS_ERR_DEVICE_BUSY)
|
||||
{
|
||||
emit ErrorSignal(QString::fromLocal8Bit("拍照失败,错误码: %1").arg(err));
|
||||
emit ErrorSignal(QString::fromLocal8Bit("拍照失败: %1").arg(getEDSDKErrorMessage(err)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -212,13 +212,16 @@ QVariant TaskTreeModel::data(const QModelIndex& index, int role) const
|
||||
TaskStatus status = TaskStatus::Waiting;
|
||||
if (node->nodeType == TreeNodeType::Task && node->taskData) {
|
||||
status = node->taskData->status;
|
||||
return QBrush(QColor("#E2EDFF")); // 深绿色文字
|
||||
}
|
||||
else if (node->nodeType == TreeNodeType::SubTask && node->subTaskData) {
|
||||
status = node->subTaskData->status;
|
||||
return QBrush(QColor("#E2EDFF")); // 深绿色文字
|
||||
}
|
||||
if (status == TaskStatus::Running) {
|
||||
return QBrush(QColor(0, 100, 0)); // 深绿色文字
|
||||
return QBrush(QColor("#E2EDFF")); // 深绿色文字
|
||||
}
|
||||
return QBrush(QColor("#E2EDFF")); // 深绿色文字
|
||||
}
|
||||
else if (role == Qt::FontRole) {
|
||||
QFont font;
|
||||
@ -615,12 +618,12 @@ QString TaskTreeModel::formatDuration(double minutes) const
|
||||
QColor TaskTreeModel::statusColor(TaskStatus status) const
|
||||
{
|
||||
switch (status) {
|
||||
case TaskStatus::Waiting: return QColor(255, 255, 230); // 浅黄
|
||||
case TaskStatus::Running: return QColor(200, 255, 200); // 浅绿
|
||||
case TaskStatus::Finished: return QColor(220, 220, 255); // 浅蓝
|
||||
case TaskStatus::Skiped: return QColor(220, 220, 220); // 浅灰
|
||||
case TaskStatus::Waiting: return QColor("#121945"); // 浅黄
|
||||
case TaskStatus::Running: return QColor("#121945"); // 浅绿
|
||||
case TaskStatus::Finished: return QColor("#121945"); // 浅蓝
|
||||
case TaskStatus::Skiped: return QColor("#121945"); // 浅灰
|
||||
}
|
||||
return QColor(255, 255, 255);
|
||||
return QColor("#121945");
|
||||
}
|
||||
|
||||
QString TaskTreeModel::formatCountdown(qint64 seconds) const
|
||||
|
||||
@ -77,8 +77,8 @@ void TimedDataCollection::setupUI()
|
||||
// 创建状态标签
|
||||
ui.statusLabel->setStyleSheet(
|
||||
"QLabel {"
|
||||
" background-color: #f0f0f0;"
|
||||
" border: 1px solid #ccc;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
" font-size: 12px;"
|
||||
@ -215,11 +215,11 @@ void TimedDataCollection::onErrorOccurred(const QString& error)
|
||||
ui.statusLabel->setText(QString::fromLocal8Bit("错误: %1").arg(error));
|
||||
ui.statusLabel->setStyleSheet(
|
||||
"QLabel {"
|
||||
" background-color: #ffebee;"
|
||||
" border: 1px solid #f44336;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
" color: #c62828;"
|
||||
" color: #e6eeff;"
|
||||
"}"
|
||||
);
|
||||
|
||||
@ -354,11 +354,11 @@ void TimedDataCollection::updateStatusBar()
|
||||
|
||||
styleSheet =
|
||||
"QLabel {"
|
||||
" background-color: #e8f5e9;"
|
||||
" border: 1px solid #4CAF50;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
" color: #2e7d32;"
|
||||
" color: #e6eeff;"
|
||||
" font-weight: bold;"
|
||||
"}";
|
||||
}
|
||||
@ -381,8 +381,8 @@ void TimedDataCollection::updateStatusBar()
|
||||
|
||||
styleSheet =
|
||||
"QLabel {"
|
||||
" background-color: #f5f5f5;"
|
||||
" border: 1px solid #ccc;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
"}";
|
||||
@ -466,11 +466,11 @@ void TimedDataCollection::startScheduler()
|
||||
ui.statusLabel->setText(QString::fromLocal8Bit("调度器已启动,等待任务执行..."));
|
||||
ui.statusLabel->setStyleSheet(
|
||||
"QLabel {"
|
||||
" background-color: #fff3e0;"
|
||||
" border: 1px solid #ff9800;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
" color: #e65100;"
|
||||
" color: #e6eeff;"
|
||||
"}");
|
||||
}
|
||||
}
|
||||
@ -478,6 +478,12 @@ void TimedDataCollection::startScheduler()
|
||||
void TimedDataCollection::stopScheduler()
|
||||
{
|
||||
if (m_scheduler) {
|
||||
|
||||
for (size_t i = 0; i < m_taskModel->tasks().size(); i++)
|
||||
{
|
||||
m_taskModel->setTaskAndSubtaskStatus(m_taskModel->tasks()[i].id, TaskStatus::default);
|
||||
}
|
||||
|
||||
m_scheduler->stop();
|
||||
|
||||
m_currentTaskId = -1;
|
||||
@ -486,11 +492,11 @@ void TimedDataCollection::stopScheduler()
|
||||
ui.statusLabel->setText(QString::fromLocal8Bit("调度器已停止"));
|
||||
ui.statusLabel->setStyleSheet(
|
||||
"QLabel {"
|
||||
" background-color: #fce4ec;"
|
||||
" border: 1px solid #e91e63;"
|
||||
" background-color: #3856B8;"
|
||||
" border: 1px solid #2f6bff;"
|
||||
" border-radius: 4px;"
|
||||
" padding: 8px;"
|
||||
" color: #880e4f;"
|
||||
" color: #e6eeff;"
|
||||
"}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
@ -204,7 +206,7 @@ bool TimedDataCollectionDataStructuresReaderWriter::jsonToTimedTask(const QJsonO
|
||||
|
||||
TaskExecutor::TaskExecutor(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_currentSubTaskIndex(0)
|
||||
, m_currentSubTaskIndex(-1)
|
||||
, m_isRunning(false)
|
||||
{
|
||||
}
|
||||
@ -228,7 +230,7 @@ void TaskExecutor::execute(const TimedTask& task)
|
||||
emit taskUpdated(m_task);
|
||||
|
||||
|
||||
m_currentSubTaskIndex = 0;
|
||||
m_currentSubTaskIndex = -1;
|
||||
m_isRunning = true;
|
||||
|
||||
qDebug() << "TaskExecutor: Starting task" << task.id;
|
||||
@ -299,6 +301,17 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
subTask.durationMinutes = (double)subTask.startTime.secsTo(subTask.endTime) / 60;
|
||||
qDebug() << "TaskExecutor: subtask "<< m_currentSubTaskIndex<< " time consuming(Minutes): "<< subTask.durationMinutes;
|
||||
|
||||
// 拷贝subTask.pathLineFilePath到m_currentFolder
|
||||
if (!subTask.pathLineFilePath.isEmpty() && QFile::exists(subTask.pathLineFilePath)) {
|
||||
QFileInfo fileInfo(subTask.pathLineFilePath);
|
||||
QString destPath = m_currentFolder + QDir::separator() + fileInfo.fileName();
|
||||
if (QFile::copy(subTask.pathLineFilePath, destPath)) {
|
||||
qDebug() << "TaskExecutor: Copied path line file to" << destPath;
|
||||
} else {
|
||||
qDebug() << "TaskExecutor: Failed to copy path line file from" << subTask.pathLineFilePath << "to" << destPath;
|
||||
}
|
||||
}
|
||||
|
||||
emit subTaskFinished(m_currentSubTaskIndex, subTask.type, (status == 0));
|
||||
emit taskUpdated(m_task);
|
||||
}
|
||||
@ -309,7 +322,6 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchD65LampSignal(0);
|
||||
emit switchSlrSignal(0);
|
||||
break;
|
||||
}
|
||||
case SubTaskType::DepthCamera:
|
||||
@ -347,11 +359,21 @@ void TaskExecutor::onSequenceComplete(int status)
|
||||
|
||||
void TaskExecutor::onBack2Origin()
|
||||
{
|
||||
// 关闭单反电源
|
||||
switch (m_task.subTasks[m_currentSubTaskIndex].type)
|
||||
{
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
emit switchSlrSignal(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否还有更多子任务
|
||||
m_currentSubTaskIndex++;
|
||||
if (m_currentSubTaskIndex < m_task.subTasks.size()) {
|
||||
int nestSubTaskIndex = m_currentSubTaskIndex + 1;
|
||||
if (nestSubTaskIndex < m_task.subTasks.size()) {
|
||||
// 执行下一个子任务
|
||||
if(m_task.subTasks[m_currentSubTaskIndex].type== SubTaskType::SingleLensReflex)
|
||||
if(m_task.subTasks[nestSubTaskIndex].type== SubTaskType::SingleLensReflex)
|
||||
{
|
||||
printMsgAndTime("Slr task,for weak up,please wait 135 seconds!");
|
||||
emit switchSlrSignal(0);
|
||||
@ -390,7 +412,10 @@ void TaskExecutor::onError(const QString& error)
|
||||
|
||||
void TaskExecutor::executeNextSubTask()
|
||||
{
|
||||
if (!m_isRunning || m_currentSubTaskIndex >= m_task.subTasks.size()) {
|
||||
m_currentSubTaskIndex++;
|
||||
|
||||
if (!m_isRunning || m_currentSubTaskIndex >= m_task.subTasks.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -417,21 +442,24 @@ void TaskExecutor::executeNextSubTask()
|
||||
case SubTaskType::HyperSpectual400_1000nm:
|
||||
{
|
||||
camType = 0;
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, makeSubTaskDataFolder("L"), "test");
|
||||
m_currentFolder = makeSubTaskDataFolder("L");
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "L");
|
||||
|
||||
break;
|
||||
}
|
||||
case SubTaskType::HyperSpectual1000_1700nm:
|
||||
{
|
||||
camType = 1;
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, makeSubTaskDataFolder("NIR"), "test");
|
||||
m_currentFolder = makeSubTaskDataFolder("NIR");
|
||||
emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, m_currentFolder, "NIR");
|
||||
|
||||
break;
|
||||
}
|
||||
case SubTaskType::SingleLensReflex:
|
||||
{
|
||||
camType = 2;
|
||||
emit camParm(camType, 3, makeSubTaskDataFolder("SLR"));
|
||||
m_currentFolder = makeSubTaskDataFolder("SLR");
|
||||
emit camParm(camType, 3, m_currentFolder);
|
||||
|
||||
emit switchD65LampSignal(1);
|
||||
|
||||
@ -443,7 +471,8 @@ void TaskExecutor::executeNextSubTask()
|
||||
case SubTaskType::DepthCamera:
|
||||
{
|
||||
camType = 3;
|
||||
emit camParm(camType, 3, makeSubTaskDataFolder("DepthCamera"));
|
||||
m_currentFolder = makeSubTaskDataFolder("DepthCamera");
|
||||
emit camParm(camType, 3, m_currentFolder);
|
||||
|
||||
emit switchD65LampSignal(1);
|
||||
|
||||
|
||||
@ -161,6 +161,7 @@ public slots:
|
||||
void onError(const QString& error);
|
||||
|
||||
private:
|
||||
QString m_currentFolder;
|
||||
void executeNextSubTask();
|
||||
|
||||
void printMsgAndTime(QString msg);
|
||||
|
||||
@ -6,67 +6,200 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1182</width>
|
||||
<height>576</height>
|
||||
<width>1299</width>
|
||||
<height>658</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>定时采集</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QTreeView" name="taskTreeView"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="taskFileSelect_lineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="taskFileSelect_btn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="start_btn">
|
||||
<property name="text">
|
||||
<string>开始调度</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="expandAll_btn">
|
||||
<property name="text">
|
||||
<string>展开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="stop_btn">
|
||||
<property name="text">
|
||||
<string>停止调度</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="collapseAll_btn">
|
||||
<property name="text">
|
||||
<string>折叠</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #contentWidget
|
||||
{
|
||||
background: #192770;
|
||||
/*border-radius: 8px 8px 8px 8px;*/
|
||||
border: 1px solid #2f6bff;
|
||||
}
|
||||
|
||||
QLineEdit {
|
||||
background-color: #3856B8;
|
||||
color: #e6eeff;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 4px 8px;
|
||||
min-width: 70px;
|
||||
min-height: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
QLabel
|
||||
{
|
||||
background: #243A82;
|
||||
color: rgb(255, 255, 255);
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
QPushButton
|
||||
{
|
||||
/*width: 172px;
|
||||
height: 56px;*/
|
||||
font: 10pt "新宋体";
|
||||
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 8px;
|
||||
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;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="contentWidget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QTreeView" name="taskTreeView">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTreeView
|
||||
{
|
||||
background-color: #121945;
|
||||
border: 0px solid #444;
|
||||
}
|
||||
|
||||
QHeaderView::section
|
||||
{
|
||||
background-color: #121945;
|
||||
color: #ACCDFF;
|
||||
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
QScrollBar:vertical {
|
||||
background: #0b1440;
|
||||
width: 10px;
|
||||
border: 1px solid #1f2a5a;
|
||||
}
|
||||
|
||||
QScrollBar:horizontal {
|
||||
background: #0b1440;
|
||||
height: 10px;
|
||||
border: 1px solid #1f2a5a;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical,
|
||||
QScrollBar::handle:horizontal {
|
||||
background: #3a5bd6;
|
||||
border-radius: 4px;
|
||||
min-height: 20px;
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical:hover,
|
||||
QScrollBar::handle:horizontal:hover {
|
||||
background: #4f73ff;
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="taskFileSelect_lineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="taskFileSelect_btn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="start_btn">
|
||||
<property name="text">
|
||||
<string>开始调度</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="expandAll_btn">
|
||||
<property name="text">
|
||||
<string>展开</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="stop_btn">
|
||||
<property name="text">
|
||||
<string>停止调度</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="collapseAll_btn">
|
||||
<property name="text">
|
||||
<string>折叠</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>任务统计</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@ -288,7 +288,7 @@ QPushButton:pressed
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:3.0.2</string>
|
||||
<string>版本:3.1.0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
205
HPPA/fodis.ui
Normal file
205
HPPA/fodis.ui
Normal file
@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FodisWindow</class>
|
||||
<widget class="QDialog" name="FodisWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>857</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FodisWindow</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">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;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="close_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关 闭</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="open_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采 集</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>数据路径</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="dataFolderLineEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">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;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>./CapturedImages</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="dataFolderBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
43
JinspSpectralmeterControl/IrisFiberSpectrometerBase.h
Normal file
43
JinspSpectralmeterControl/IrisFiberSpectrometerBase.h
Normal file
@ -0,0 +1,43 @@
|
||||
#include "QObject"
|
||||
#include <string>
|
||||
#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:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode,std::string ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
virtual int SingleShot(DataFrame &dfData) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
virtual int SetExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
virtual int SetDeviceTemperature(float fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
|
||||
|
||||
};
|
||||
578
JinspSpectralmeterControl/JinspSpectralmeterControl.cpp
Normal file
578
JinspSpectralmeterControl/JinspSpectralmeterControl.cpp
Normal file
@ -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()
|
||||
{
|
||||
m_pSerialPort->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<unsigned char>(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<52>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ʼֵ
|
||||
// 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; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 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<6E><64><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
// 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();
|
||||
}
|
||||
132
JinspSpectralmeterControl/JinspSpectralmeterControl.h
Normal file
132
JinspSpectralmeterControl/JinspSpectralmeterControl.h
Normal file
@ -0,0 +1,132 @@
|
||||
#pragma once
|
||||
|
||||
#include "jinspspectralmetercontrol_global.h"
|
||||
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtEndian>
|
||||
#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();
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
//<2F><><EFBFBD>β<EFBFBD><CEB2>Բɼ<D4B2> <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SingleShot(int& iPixels);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int SingleShot(DataFrame& dfData);
|
||||
|
||||
//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||||
//int SingleShotDark(ATPDataFrame &dfData);
|
||||
|
||||
//int SingleShotDeducted(ATPDataFrame &dfData);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetExposureTime(int& iExposureTimeInMS);
|
||||
|
||||
//int GetWaveLength(float *pfWaveLength);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int GetDeviceInfo(DeviceInfo& Info);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetDeviceAttribute(DeviceAttribute& Attr);
|
||||
|
||||
//int GetDeviceListInfo(); //use type name to enum
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD>
|
||||
int GetDeviceTemperature(float& fTemperature);
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
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);
|
||||
|
||||
|
||||
};
|
||||
102
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
102
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{06B5BB62-F5F1-4F59-8F5B-CC50B6F168CB}</ProjectGuid>
|
||||
<Keyword>QtVS_v304</Keyword>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.26100.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.26100.0</WindowsTargetPlatformVersion>
|
||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||
<Import Project="$(QtMsBuild)\qt_defaults.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core;serialport</QtModules>
|
||||
<QtBuildConfig>debug</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
|
||||
<QtInstall>5.13.2_msvc2017_64</QtInstall>
|
||||
<QtModules>core</QtModules>
|
||||
<QtBuildConfig>release</QtBuildConfig>
|
||||
</PropertyGroup>
|
||||
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
|
||||
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
|
||||
</Target>
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="Shared" />
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(QtMsBuild)\Qt.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<IncludePath>D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
|
||||
<ClCompile>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>JINSPSPECTRALMETERCONTROL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IrisFiberSpectrometerBase.h" />
|
||||
<ClInclude Include="ZZ_Math.h" />
|
||||
<ClInclude Include="ZZ_Types.h" />
|
||||
<ClInclude Include="jinspspectralmetercontrol_global.h" />
|
||||
<QtMoc Include="JinspSpectralmeterControl.h" />
|
||||
<ClCompile Include="JinspSpectralmeterControl.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||
<Import Project="$(QtMsBuild)\qt.targets" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Form Files">
|
||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||
<Extensions>ui</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Translation Files">
|
||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||
<Extensions>ts</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="jinspspectralmetercontrol_global.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<QtMoc Include="JinspSpectralmeterControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<ClCompile Include="JinspSpectralmeterControl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="IrisFiberSpectrometerBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZZ_Math.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZZ_Types.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
121
JinspSpectralmeterControl/ZZ_Math.h
Normal file
121
JinspSpectralmeterControl/ZZ_Math.h
Normal file
@ -0,0 +1,121 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#//#include "Dense"
|
||||
#include "Eigen/Dense"
|
||||
#include <unsupported/Eigen/Splines>
|
||||
#pragma once
|
||||
|
||||
namespace ZZ_MATH
|
||||
{
|
||||
template<typename T>
|
||||
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<typename T>
|
||||
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 (lchild<size&&arry[lchild]>arry[element])
|
||||
{
|
||||
std::swap(arry[lchild], arry[element]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
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<double> &xv, const std::vector<double> &yv, std::vector<double> &coeff, int order);
|
||||
double Eigen_Polyeval(std::vector<double> coeffs, double x);
|
||||
};
|
||||
|
||||
namespace SplineFit
|
||||
{
|
||||
using namespace Eigen;
|
||||
VectorXd Eigen_Normalize(const VectorXd &x);
|
||||
void Test(std::vector<double> const &x_vec, std::vector<double> 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<double, 1> spline_;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
358
JinspSpectralmeterControl/ZZ_Types.h
Normal file
358
JinspSpectralmeterControl/ZZ_Types.h
Normal file
@ -0,0 +1,358 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <QTime>
|
||||
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
#define ZZ_Enum2String(x) #x
|
||||
|
||||
#pragma pack(1)//<2F>ṹ<EFBFBD>尴<EFBFBD><E5B0B4>1<EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD>洢
|
||||
|
||||
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<74><63><EFBFBD><EFBFBD>-----------------------
|
||||
{
|
||||
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????<3F><>???
|
||||
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
|
||||
};
|
||||
|
||||
//???????<3F><>??
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>??????<3F><>??
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>????<3F><>?<3F><>??
|
||||
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;
|
||||
}
|
||||
|
||||
//?????????????<3F><>??
|
||||
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()//<2F>ָ<EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>루<EFBFBD><EBA3A8><EFBFBD><EFBFBD>8<EFBFBD>ֽڣ<D6BD>
|
||||
13
JinspSpectralmeterControl/jinspspectralmetercontrol_global.h
Normal file
13
JinspSpectralmeterControl/jinspspectralmetercontrol_global.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user