Compare commits
9 Commits
3.1.0
...
64bc8a9d27
| Author | SHA1 | Date | |
|---|---|---|---|
| 64bc8a9d27 | |||
| 6b63d28d2c | |||
| 3feefe45c1 | |||
| 245fc7f4ef | |||
| a49f416551 | |||
| 39578dc9fe | |||
| e326dcb20c | |||
| 7ded94c2a4 | |||
| cb5a74f576 |
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
|
||||
|
||||
@ -8,6 +8,9 @@ const int AppSettings::kDefaultIntegrationTime = 1;
|
||||
const int AppSettings::kDefaultGain = 0;
|
||||
const QString AppSettings::kDefaultSLRDataFolder = QString();
|
||||
const QString AppSettings::kDefaultDepthCameraDataFolder = QString();
|
||||
const double AppSettings::kDefaultScanSpeed = 1.0;
|
||||
const double AppSettings::kDefaultReturnSpeed = 5.0;
|
||||
const int AppSettings::kDefaultGonggaShanRecordPort = 666;
|
||||
|
||||
AppSettings::AppSettings()
|
||||
: m_settings(QSettings::IniFormat, QSettings::UserScope,
|
||||
@ -100,3 +103,48 @@ 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);
|
||||
}
|
||||
|
||||
double AppSettings::scanSpeed() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/ScanSpeed", kDefaultScanSpeed).toDouble();
|
||||
}
|
||||
|
||||
void AppSettings::setScanSpeed(double value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/ScanSpeed", value);
|
||||
}
|
||||
|
||||
double AppSettings::returnSpeed() const
|
||||
{
|
||||
return m_settings.value("OneMotorControl/ReturnSpeed", kDefaultReturnSpeed).toDouble();
|
||||
}
|
||||
|
||||
void AppSettings::setReturnSpeed(double value)
|
||||
{
|
||||
m_settings.setValue("OneMotorControl/ReturnSpeed", value);
|
||||
}
|
||||
|
||||
int AppSettings::gonggaShanRecordPort() const
|
||||
{
|
||||
return m_settings.value("GonggaShanRecordCtl/Port", kDefaultGonggaShanRecordPort).toInt();
|
||||
}
|
||||
|
||||
void AppSettings::setGonggaShanRecordPort(int value)
|
||||
{
|
||||
m_settings.setValue("GonggaShanRecordCtl/Port", value);
|
||||
}
|
||||
|
||||
@ -34,6 +34,21 @@ public:
|
||||
// 深度相机数据保存路径
|
||||
QString depthCameraDataFolder() const;
|
||||
void setDepthCameraDataFolder(const QString& path);
|
||||
|
||||
QString FiberImagerDataFolder() const;
|
||||
void setFiberImagerDataFolder(const QString& path);
|
||||
|
||||
// 扫描速度
|
||||
double scanSpeed() const;
|
||||
void setScanSpeed(double value);
|
||||
|
||||
// 返回速度
|
||||
double returnSpeed() const;
|
||||
void setReturnSpeed(double value);
|
||||
|
||||
// 贡嘎山记录端口
|
||||
int gonggaShanRecordPort() const;
|
||||
void setGonggaShanRecordPort(int value);
|
||||
// 在此处添加更多参数的 getter/setter ...
|
||||
|
||||
private:
|
||||
@ -51,4 +66,7 @@ private:
|
||||
static const int kDefaultGain;
|
||||
static const QString kDefaultSLRDataFolder;
|
||||
static const QString kDefaultDepthCameraDataFolder;
|
||||
static const double kDefaultScanSpeed;
|
||||
static const double kDefaultReturnSpeed;
|
||||
static const int kDefaultGonggaShanRecordPort;
|
||||
};
|
||||
|
||||
@ -498,7 +498,8 @@ void OneMotionCaptureCoordinator::stopStepMotion()
|
||||
m_cameraCtrl->stop_record();
|
||||
}
|
||||
|
||||
emit stopMotorSignal(0);
|
||||
//emit stopMotorSignal(0);
|
||||
move2LocBeforeStart();
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet()
|
||||
@ -528,6 +529,10 @@ void OneMotionCaptureCoordinator::getLocBeforeStart()
|
||||
loop.exec();
|
||||
|
||||
disconnect(conn);
|
||||
|
||||
std::vector<double> pos;
|
||||
pos.push_back(0);
|
||||
m_locBeforeStart = pos;
|
||||
}
|
||||
|
||||
void OneMotionCaptureCoordinator::move2LocBeforeStart()
|
||||
|
||||
@ -32,6 +32,7 @@ void CommunicationViaTCP::onNewConnection()
|
||||
m_bConnected = true;
|
||||
m_tcpSocket = m_tcpServer->nextPendingConnection();
|
||||
connect(m_tcpSocket, SIGNAL(disconnected()), this, SLOT(onTcpSocketDisconnected()));
|
||||
connect(m_tcpSocket, &QTcpSocket::readyRead, this, &CommunicationViaTCP::receiveData);
|
||||
|
||||
emit connected();
|
||||
}
|
||||
@ -49,6 +50,32 @@ void CommunicationViaTCP::onTcpSocketDisconnected()
|
||||
m_tcpSocket->deleteLater();
|
||||
}
|
||||
|
||||
void CommunicationViaTCP::receiveData()
|
||||
{
|
||||
if (!isConnected())
|
||||
{
|
||||
qWarning() << "receiveData: No client connected";
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data = m_tcpSocket->readAll();
|
||||
if (data.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
int position = QString::fromUtf8(data).toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
qDebug() << "Received position:" << position;
|
||||
emit positionReceived(position);
|
||||
} else
|
||||
{
|
||||
qWarning() << "Failed to parse position data:" << data;
|
||||
}
|
||||
}
|
||||
|
||||
int CommunicationViaTCP::sendCommand(const QString cmd)
|
||||
{
|
||||
if (!isConnected()) {
|
||||
|
||||
@ -37,9 +37,11 @@ namespace MotorParams {
|
||||
|
||||
public Q_SLOTS:
|
||||
void onNewConnection();
|
||||
void receiveData();
|
||||
void onTcpSocketDisconnected();
|
||||
|
||||
signals:
|
||||
void commandSendResult(int bytesWritten, const QString& error = QString());
|
||||
void positionReceived(int position);
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>557</width>
|
||||
<height>432</height>
|
||||
<width>582</width>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -154,7 +154,7 @@ QSlider::handle:horizontal:pressed {
|
||||
border: 1px solid #2f6bff;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -168,7 +168,7 @@ QSlider::handle:horizontal:pressed {
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="titlebarWidget" native="true">
|
||||
@ -242,23 +242,11 @@ QSlider::handle:horizontal:pressed {
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2" columnstretch="2,3">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="connectFocusModule_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #connectFocusModule_widget
|
||||
@ -274,31 +262,85 @@ QRadioButton
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>连接调焦线性平台</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>连接调焦模块</string>
|
||||
<string>新版</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoExclusive">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QStackedWidget" name="stackedWidget_connetcParm">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_12">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -307,52 +349,98 @@ QRadioButton
|
||||
<string>线性平台</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="motorPort_comboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="ultrasound_radioButton">
|
||||
<property name="text">
|
||||
<string>超声</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="ultrasoundPort_comboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QRadioButton" name="is_new_version_radioButton">
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>新版</string>
|
||||
<string>连接</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>107</width>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="connectMotor_btn">
|
||||
<property name="text">
|
||||
<string>连接线性平台</string>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>状态</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="motor_state_label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel#motor_state_label
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -368,60 +456,13 @@ QRadioButton
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
<item row="0" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>调整线性平台</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="updateCurrentLocation_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
@ -440,8 +481,29 @@ QRadioButton
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="add_btn">
|
||||
<property name="text">
|
||||
<string>+</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="logicZero_btn">
|
||||
<property name="text">
|
||||
<string>LogicZero</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="move2_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
@ -449,21 +511,37 @@ QRadioButton
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>10</string>
|
||||
<string>0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="subtractStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="moveto_btn">
|
||||
<property name="text">
|
||||
<string>移动至</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="currentLocation_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -482,37 +560,43 @@ QRadioButton
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="subtract_btn">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="max_btn">
|
||||
<property name="text">
|
||||
<string>max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="rangeMeasurement_btn">
|
||||
<property name="text">
|
||||
<string>量程测量</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="addStepSize_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>88</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>调整线性平台</string>
|
||||
<string>1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QWidget" name="controlFocus_widget" native="true">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget #controlFocus_widget
|
||||
@ -521,34 +605,27 @@ QRadioButton
|
||||
border-radius: 5px 5px 5px 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>采样率</string>
|
||||
<string>采样数</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="sample_ratio_lineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -564,7 +641,14 @@ QRadioButton
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QProgressBar" name="autoFocusProgress_progressBar">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QProgressBar {
|
||||
@ -585,27 +669,16 @@ QRadioButton
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="autoFocus_btn">
|
||||
<property name="text">
|
||||
<string>自动调焦</string>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>手动调焦</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>171</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="manualFocus_btn">
|
||||
<property name="text">
|
||||
<string>手动调焦</string>
|
||||
@ -623,6 +696,9 @@ QRadioButton
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="HPPA.qrc"/>
|
||||
</resources>
|
||||
|
||||
99
HPPA/FodisWindow.cpp
Normal file
99
HPPA/FodisWindow.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
#include "FodisWindow.h"
|
||||
#include "JinspFiberImagerConfig.h"
|
||||
|
||||
FodisWindow::FodisWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
m_FiberImagerThread = new QThread();
|
||||
m_JinspFiberImagerOperation = new JinspFiberImager(false, JinspFiberImagerConfig::instance().portName().toStdString(), "JINSP");
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::spectalCaptured, this, &FodisWindow::spectalCaptured);
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::startExposureSignal, this, &FodisWindow::startExposureSignal);
|
||||
connect(m_JinspFiberImagerOperation, &JinspFiberImager::exposureCompleteSignal, this, &FodisWindow::exposureCompleteSignal);
|
||||
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()));
|
||||
|
||||
// 初始化数据保存路径显示(从 AppSettings 恢复或使用默认)
|
||||
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("选择数据保存路径"),
|
||||
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()
|
||||
{
|
||||
openFiberImager_expose_record("pos_null");
|
||||
}
|
||||
|
||||
void FodisWindow::openFiberImager_expose_record(QString posInfo)
|
||||
{
|
||||
if (!m_JinspFiberImagerOperation->getRecordStatus())
|
||||
{
|
||||
emit openFiberImagerSignal(posInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void FodisWindow::onCamOpened()
|
||||
{
|
||||
ui.open_btn->setEnabled(false);
|
||||
ui.close_btn->setEnabled(true);
|
||||
|
||||
ui.open_btn->setText(QString::fromLocal8Bit("已打开"));
|
||||
}
|
||||
|
||||
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("打 开"));
|
||||
}
|
||||
56
HPPA/FodisWindow.h
Normal file
56
HPPA/FodisWindow.h
Normal file
@ -0,0 +1,56 @@
|
||||
#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 openFiberImager_expose_record(QString posInfo);
|
||||
void onCamOpened();
|
||||
void closeFiberImager();
|
||||
void onCamClosed();
|
||||
|
||||
void onSelectDataFolder();
|
||||
|
||||
signals:
|
||||
void openFiberImagerSignal(QString posInfo);
|
||||
void PlotSpectralSignal();
|
||||
void FiberImagerClosedSignal();
|
||||
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void startExposureSignal();
|
||||
void exposureCompleteSignal(int exposureTime);
|
||||
|
||||
private:
|
||||
Ui::FodisWindow ui;
|
||||
QThread* m_FiberImagerThread;
|
||||
|
||||
JinspFiberImager* m_JinspFiberImagerOperation;
|
||||
};
|
||||
146
HPPA/GonggaShanRecordCtl.cpp
Normal file
146
HPPA/GonggaShanRecordCtl.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
#include "GonggaShanRecordCtl.h"
|
||||
|
||||
GonggashanTaskScheduler::GonggashanTaskScheduler(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_taskState(TaskState::Idle)
|
||||
{
|
||||
}
|
||||
|
||||
GonggashanTaskScheduler::~GonggashanTaskScheduler()
|
||||
{
|
||||
}
|
||||
|
||||
bool GonggashanTaskScheduler::isTaskRunning() const
|
||||
{
|
||||
return m_taskState == TaskState::Running;
|
||||
}
|
||||
|
||||
void GonggashanTaskScheduler::setTaskRunning(bool running)
|
||||
{
|
||||
m_taskState = running ? TaskState::Running : TaskState::Idle;
|
||||
Q_EMIT taskStateChanged(m_taskState);
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::logStatus(const QString& message, bool isHearderBlankLine, bool isTailBlankLine)
|
||||
{
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if (isHearderBlankLine)
|
||||
{
|
||||
ui.status_textEdit->append("\n");
|
||||
}
|
||||
ui.status_textEdit->append(QString("[%1] %2").arg(timestamp, message));
|
||||
if (isTailBlankLine)
|
||||
{
|
||||
ui.status_textEdit->append("\n");
|
||||
}
|
||||
|
||||
if (m_logStream.device())
|
||||
{
|
||||
if (isHearderBlankLine)
|
||||
{
|
||||
m_logStream << "\n";
|
||||
}
|
||||
m_logStream << "[" << timestamp << "] " << message << "\n";
|
||||
if (isTailBlankLine)
|
||||
{
|
||||
m_logStream << "\n";
|
||||
}
|
||||
|
||||
m_logStream.flush();
|
||||
m_logFile.flush();
|
||||
}
|
||||
}
|
||||
|
||||
GonggaShanRecordCtl::GonggaShanRecordCtl(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_taskScheduler(new GonggashanTaskScheduler(this))
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
ui.spinbox_Port->setValue(settings.gonggaShanRecordPort());
|
||||
|
||||
connect(ui.btnListen, &QPushButton::clicked, this, &GonggaShanRecordCtl::startListen);
|
||||
connect(ui.btnDisListen, &QPushButton::clicked, this, &GonggaShanRecordCtl::stopListen);
|
||||
connect(ui.spinbox_Port, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) {
|
||||
AppSettings::instance().setGonggaShanRecordPort(value);
|
||||
});
|
||||
}
|
||||
|
||||
GonggaShanRecordCtl::~GonggaShanRecordCtl()
|
||||
{
|
||||
if (m_logFile.isOpen()) {
|
||||
m_logStream.flush();
|
||||
m_logFile.close();
|
||||
}
|
||||
tcpServer6005->deleteLater();
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::startListen()
|
||||
{
|
||||
if (m_logFile.isOpen()) {
|
||||
m_logStream.flush();
|
||||
m_logFile.close();
|
||||
}
|
||||
|
||||
QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
|
||||
QString logFileName = QString("%1_log.txt").arg(timestamp);
|
||||
m_logFilePath = AppSettings::instance().dataFolder() + QDir::separator() + logFileName;
|
||||
m_logFile.setFileName(m_logFilePath);
|
||||
m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
|
||||
m_logStream.setDevice(&m_logFile);
|
||||
|
||||
logStatus("Start listen....", true, true);
|
||||
|
||||
MotorParams::TCPConnectionParams tcpConnectionParams6005;
|
||||
tcpConnectionParams6005.port = ui.spinbox_Port->text().toInt();
|
||||
tcpConnectionParams6005.serverIP = "192.168.1.2";//此ip地址没有使用,可以随便填入
|
||||
tcpServer6005 = new MotorParams::CommunicationViaTCP(tcpConnectionParams6005, this);
|
||||
|
||||
connect(tcpServer6005, &MotorParams::CommunicationViaTCP::positionReceived, this, &GonggaShanRecordCtl::startRecord);
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::stopListen()
|
||||
{
|
||||
logStatus("Stop listen", true, true);
|
||||
|
||||
disconnect(tcpServer6005, &MotorParams::CommunicationViaTCP::positionReceived, this, &GonggaShanRecordCtl::startRecord);
|
||||
|
||||
tcpServer6005->deleteLater();
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::startRecord(int position)
|
||||
{
|
||||
if (m_taskScheduler->isTaskRunning())
|
||||
{
|
||||
logStatus("Data collection has begun....");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString pos = QString::number(position);
|
||||
logStatus("Reach pos: " + pos, true);
|
||||
|
||||
m_taskScheduler->setTaskRunning(true);
|
||||
emit startRcordSignal("pos_" + pos);
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::onFiberImagerStartExposureSignal()
|
||||
{
|
||||
logStatus("FiberImager: start exposure...");
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::onFiberImagerExposureCompleteSignal(int exposureTime)
|
||||
{
|
||||
logStatus(QString("FiberImager: exposure finished, %1").arg(exposureTime));
|
||||
|
||||
logStatus("Start recording...");
|
||||
}
|
||||
|
||||
void GonggaShanRecordCtl::onRcordFinished()
|
||||
{
|
||||
m_taskScheduler->setTaskRunning(false);
|
||||
|
||||
logStatus("Record Finished.");
|
||||
}
|
||||
76
HPPA/GonggaShanRecordCtl.h
Normal file
76
HPPA/GonggaShanRecordCtl.h
Normal file
@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
#include <QDialog>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <vector>
|
||||
#include <QPointer>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDir>
|
||||
|
||||
#include "ui_gonggashanCtl.h"
|
||||
|
||||
#include "CommunicationViaTCP.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
class GonggashanTaskScheduler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class TaskState
|
||||
{
|
||||
Idle,
|
||||
Running
|
||||
};
|
||||
|
||||
explicit GonggashanTaskScheduler(QObject* parent = nullptr);
|
||||
~GonggashanTaskScheduler();
|
||||
|
||||
bool isTaskRunning() const;
|
||||
void setTaskRunning(bool running);
|
||||
|
||||
Q_SIGNALS:
|
||||
void taskStateChanged(TaskState state);
|
||||
|
||||
private:
|
||||
TaskState m_taskState;
|
||||
};
|
||||
|
||||
class GonggaShanRecordCtl : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GonggaShanRecordCtl(QWidget* parent = nullptr);
|
||||
~GonggaShanRecordCtl();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onFiberImagerStartExposureSignal();
|
||||
void onRcordFinished();
|
||||
void onFiberImagerExposureCompleteSignal(int exposureTime);
|
||||
|
||||
Q_SIGNALS:
|
||||
// Emitted when user changes any of the R/G/B wavelength values
|
||||
void startRcordSignal(QString posInfo);
|
||||
|
||||
private Q_SLOTS:
|
||||
void startListen();
|
||||
void stopListen();
|
||||
|
||||
void startRecord(int position);
|
||||
|
||||
private:
|
||||
void logStatus(const QString& message, bool isHearderBlankLine = false, bool isTailBlankLine = false);
|
||||
|
||||
Ui::gongga_control ui;
|
||||
QPointer<MotorParams::CommunicationViaTCP> tcpServer6005;
|
||||
GonggashanTaskScheduler* m_taskScheduler;
|
||||
QString m_logFilePath;
|
||||
QFile m_logFile;
|
||||
QTextStream m_logStream;
|
||||
};
|
||||
163
HPPA/HPPA.cpp
163
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()));
|
||||
@ -454,6 +455,44 @@ HPPA::HPPA(QWidget* parent)
|
||||
m_carousel->addWidget(sa_SingleLensReflexCamera);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
QChartView * m_FiberImagerChartView = new QChartView();
|
||||
m_FiberImagerChartView->setRenderHint(QPainter::Antialiasing);
|
||||
m_FiberImagerChartView->setStyleSheet(R"(
|
||||
background: #0D1233;
|
||||
)");
|
||||
|
||||
m_FiberImagerChart = new QChart();
|
||||
m_FiberImagerChart->setBackgroundBrush(QColor("#0D1233"));
|
||||
m_FiberImagerChart->legend()->hide();
|
||||
//m_FiberImagerChart->setTitle("Simple line chart example");
|
||||
|
||||
QValueAxis* axisX_FiberImagerChart = new QValueAxis();
|
||||
QValueAxis* axisY_FiberImagerChart = new QValueAxis();
|
||||
setAxis(axisX, axisY);
|
||||
m_FiberImagerChart->addAxis(axisX_FiberImagerChart, Qt::AlignBottom);
|
||||
m_FiberImagerChart->addAxis(axisY_FiberImagerChart, Qt::AlignLeft);
|
||||
m_FiberImagerChartView->setChart(m_FiberImagerChart);
|
||||
|
||||
QScrollArea* sa_FiberImager = new QScrollArea();
|
||||
sa_FiberImager->setObjectName("sa_FiberImager");
|
||||
sa_FiberImager->setStyleSheet(R"(
|
||||
border: none;
|
||||
background-color: #0D1233;
|
||||
)");
|
||||
QGridLayout* gridLayout_sa_FiberImager = new QGridLayout(sa_FiberImager);
|
||||
gridLayout_sa_FiberImager->setSpacing(6);
|
||||
gridLayout_sa_FiberImager->setObjectName(QString::fromUtf8("gridLayout_sa_FiberImager"));
|
||||
gridLayout_sa_FiberImager->setVerticalSpacing(0);
|
||||
gridLayout_sa_FiberImager->setContentsMargins(0, 0, 0, 0);
|
||||
gridLayout_sa_FiberImager->addWidget(m_FiberImagerChartView);
|
||||
|
||||
m_carousel->addWidget(sa_FiberImager);
|
||||
m_carousel->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
m_carousel->play();
|
||||
|
||||
gridLayout_carouselContainer->addWidget(m_carousel);
|
||||
@ -1018,11 +1057,61 @@ void HPPA::initControlTabwidget()
|
||||
m_tmc->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_tmc, QString::fromLocal8Bit("2轴控制"));
|
||||
|
||||
//贡嘎山定时采集
|
||||
m_gonggaShanRecordCtl = new GonggaShanRecordCtl(this);
|
||||
m_gonggaShanRecordCtl->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_gonggaShanRecordCtl, QString::fromLocal8Bit("触发采集"));
|
||||
|
||||
//is11
|
||||
m_fodisWindow = new FodisWindow(this);
|
||||
connect(m_fodisWindow, &FodisWindow::spectalCaptured, this, &HPPA::showFiberImagerSpectral);
|
||||
m_fodisWindow->setWindowFlags(Qt::Widget);
|
||||
ui.controlTabWidget->addTab(m_fodisWindow, QString::fromLocal8Bit("FODIS"));
|
||||
|
||||
setupGonggashanAutoRecordConnection();
|
||||
|
||||
|
||||
// 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)));
|
||||
}
|
||||
|
||||
void HPPA::setupGonggashanAutoRecordConnection()
|
||||
{
|
||||
connect(m_gonggaShanRecordCtl, &GonggaShanRecordCtl::startRcordSignal, this, &HPPA::onGonggashanRecord);
|
||||
|
||||
connect(m_fodisWindow, &FodisWindow::startExposureSignal, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::onFiberImagerStartExposureSignal);
|
||||
connect(m_fodisWindow, &FodisWindow::exposureCompleteSignal, this, &HPPA::onStartRecordStep1);
|
||||
connect(m_fodisWindow, &FodisWindow::exposureCompleteSignal, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::onFiberImagerExposureCompleteSignal);
|
||||
|
||||
connect(m_omc, &OneMotorControl::sequenceComplete, m_fodisWindow, &FodisWindow::closeFiberImager);
|
||||
connect(m_omc, &OneMotorControl::sequenceComplete, m_gonggaShanRecordCtl, &GonggaShanRecordCtl::onRcordFinished);
|
||||
}
|
||||
|
||||
void HPPA::onGonggashanRecord(QString posInfo)
|
||||
{
|
||||
//设置文件名
|
||||
//AppSettings::instance().setFrameRate(f);
|
||||
//AppSettings::instance().setIntegrationTime(e);
|
||||
//AppSettings::instance().setDataFolder(filePath);
|
||||
|
||||
QString dateStr = QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss");
|
||||
//QString fi = AppSettings::instance().fileName() + "_" + dateStr;
|
||||
AppSettings::instance().setFileName(dateStr + "_" + posInfo);
|
||||
|
||||
this->frame_number->setText("100000");
|
||||
|
||||
//连接马达和光谱仪
|
||||
m_omc->connectMotor(false);
|
||||
|
||||
if (!testImagerVality())
|
||||
{
|
||||
onconnect();
|
||||
}
|
||||
|
||||
m_fodisWindow->openFiberImager_expose_record(posInfo);
|
||||
}
|
||||
|
||||
void HPPA::recordFromRobotArm(int fileCounter)
|
||||
{
|
||||
if (!testImagerVality())
|
||||
@ -1435,6 +1524,7 @@ void HPPA::createScenarioActionGroup()
|
||||
{
|
||||
m_ScenarioActionGroup = new QActionGroup(this);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionOneMotorScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionGonggaRotatingPlatformScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionPlantPhenotypeScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mAction3DPlantPhenotypeScenario);
|
||||
m_ScenarioActionGroup->addAction(ui.mActionMicroscopicMotionControlScenario);
|
||||
@ -1449,6 +1539,11 @@ void HPPA::createScenarioActionGroup()
|
||||
ui.mActionOneMotorScenario->setChecked(true);
|
||||
ui.mActionOneMotorScenario->trigger();
|
||||
}
|
||||
else if (lastSelectedAction == "mActionGonggaRotatingPlatformScenario")
|
||||
{
|
||||
ui.mActionGonggaRotatingPlatformScenario->setChecked(true);
|
||||
ui.mActionGonggaRotatingPlatformScenario->trigger();
|
||||
}
|
||||
else if (lastSelectedAction == "mActionPlantPhenotypeScenario")
|
||||
{
|
||||
ui.mActionPlantPhenotypeScenario->setChecked(true);
|
||||
@ -1506,6 +1601,23 @@ 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_tabManager->showTab(m_gonggaShanRecordCtl);
|
||||
|
||||
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>)));
|
||||
@ -1903,6 +2015,10 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
||||
//获取绘图控件
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->widget(index);
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-apply the current active map tool to the new canvas
|
||||
Mapcavas* canvas = currentImageViewer[0];
|
||||
@ -2056,6 +2172,37 @@ void HPPA::setAxis(QValueAxis* axisX, QValueAxis* axisY)
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::showFiberImagerSpectral(DeviceAttribute attribute, DataFrame dataFrame)
|
||||
{
|
||||
try
|
||||
{
|
||||
QLineSeries* series = new QLineSeries();
|
||||
|
||||
const int count = qMin(attribute.iPixels, 4096);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
double wavelength = attribute.fWaveLengthInNM[i];
|
||||
double intensity = dataFrame.lData[i];
|
||||
series->append(wavelength, intensity);
|
||||
}
|
||||
|
||||
series->setPen(QPen(QColor("#FF928A"), 2));
|
||||
|
||||
m_FiberImagerChart->removeAllSeries();
|
||||
m_FiberImagerChart->addSeries(series);
|
||||
m_FiberImagerChart->createDefaultAxes();
|
||||
|
||||
QValueAxis* axisX = qobject_cast<QValueAxis*>(m_FiberImagerChart->axisX());
|
||||
QValueAxis* axisY = qobject_cast<QValueAxis*>(m_FiberImagerChart->axisY());
|
||||
|
||||
setAxis(axisX, axisY);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
std::cout << "显示光谱有错误!" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void HPPA::timerEvent(QTimerEvent* event)
|
||||
{
|
||||
}
|
||||
@ -2646,6 +2793,10 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
//QWidget* currentWidget = m_imageViewerTabWidget->widget(fileNumber);
|
||||
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
cv::Mat rgbImage(*m_Imager->getMatRgbImage(), cv::Range(0, m_Imager->getFrameCounter()), cv::Range::all());
|
||||
@ -2705,6 +2856,10 @@ void HPPA::onStretchedImageReady(int fileNumber, const QString& filePath, QPixma
|
||||
QWidget* currentWidget = m_MapLayerStore->widgetForLayer(filePath);
|
||||
if (!currentWidget) return;
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentImageViewer.isEmpty()) return;
|
||||
// 在界面中显示拉伸后的图像
|
||||
currentImageViewer[0]->SetImage(&pixmap);
|
||||
@ -2726,6 +2881,10 @@ void HPPA::focusPlotSpectralImg(int state)
|
||||
//显示影像
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
QList<Mapcavas*> currentImageViewer = currentWidget->findChildren<Mapcavas*>();
|
||||
if (currentImageViewer.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
currentImageViewer[0]->DisplayFrameNumber(m_Imager->getFocusFrameCounter());//界面中显示已经采集的帧数
|
||||
|
||||
ImageProcessor imageProcessor;
|
||||
@ -2909,6 +3068,10 @@ void HPPA::newImage(RasterLayer* ml, RasterImageLayer::RendererType type, LayerT
|
||||
QWidget* mapcavasContainer = onCreateTab(ml->name());
|
||||
RasterImageLayer* rasterImageLayer = new RasterImageLayer(ml, type);
|
||||
QList<Mapcavas*> mapcavas = mapcavasContainer->findChildren<Mapcavas*>();
|
||||
if (mapcavas.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mapcavas[0]->setImageLayer(rasterImageLayer);
|
||||
|
||||
QString title = ml->name();
|
||||
|
||||
14
HPPA/HPPA.h
14
HPPA/HPPA.h
@ -87,6 +87,9 @@
|
||||
#include "TimedDataCollection.h"
|
||||
|
||||
#include "PowerControl3D.h"
|
||||
#include "FodisWindow.h"
|
||||
|
||||
#include "GonggaShanRecordCtl.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -319,6 +322,8 @@ private:
|
||||
RobotArmControl* m_rac;
|
||||
OneMotorControl* m_omc;
|
||||
TwoMotorControl* m_tmc;
|
||||
FodisWindow* m_fodisWindow;
|
||||
GonggaShanRecordCtl* m_gonggaShanRecordCtl;
|
||||
QPointer<TimedDataCollection> m_tdc;
|
||||
|
||||
View3DModelManager* m_view3DModelManager;
|
||||
@ -354,6 +359,12 @@ private:
|
||||
void showQuickPreview(int fileNumber, const QString& filePath, const cv::Mat& rgbImage);
|
||||
|
||||
|
||||
QChart* m_FiberImagerChart;
|
||||
void showFiberImagerSpectral(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void setupGonggashanAutoRecordConnection();
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QString filePath);
|
||||
void focusPlotSpectralImg(int state);
|
||||
@ -410,6 +421,7 @@ public Q_SLOTS:
|
||||
void recordFromRobotArm(int fileCounter);
|
||||
|
||||
void createOneMotorScenario();
|
||||
void createGonggaRotatingPlatformScenario();
|
||||
void createPlantPhenotypeScenario();
|
||||
void create3DPlantPhenotypeScenario();
|
||||
void onCreated3DModelPlantPhenotype();
|
||||
@ -441,6 +453,8 @@ public Q_SLOTS:
|
||||
void onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
||||
void onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error);
|
||||
|
||||
void onGonggashanRecord(QString posInfo);
|
||||
|
||||
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,27 +55,28 @@
|
||||
</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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|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;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;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\vincecontrol_vs2017_release;D:\cpp_library\gdal2.2.3_vs2017\lib;C:\Program Files\ResononAPI\lib64;D:\cpp_project_vs2022\AutoFocus_InspireLinearMotor_DLL\x64\Release;D:\cpp_library\libconfig-1.7.3\build\x64;D:\cpp_project_vs2022\IrisMultiMotorController\x64\Release;C:\XIMEA\API\xiAPI;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>
|
||||
<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>
|
||||
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpp14</LanguageStandard>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Link>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>opencv_world3411.lib;vincecontrol.lib;gdal_i.lib;resonon-basler.lib;resonon-allied.lib;AutoFocus_InspireLinearMotor_DLL.lib;libconfig++.lib;xiapi64.lib;IrisMultiMotorController.lib;OrbbecSDK.lib;EDSDK.lib;JinspSpectralmeterControl.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>D:\cpp_project_vs2022\HPPA\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -118,12 +119,16 @@
|
||||
<ClCompile Include="CustomDockWidgetBase.cpp" />
|
||||
<ClCompile Include="DepthCameraWindow.cpp" />
|
||||
<ClCompile Include="FileNameLineEdit.cpp" />
|
||||
<ClCompile Include="FodisWindow.cpp" />
|
||||
<ClCompile Include="GonggaShanRecordCtl.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="JinspFiberImagerConfig.cpp" />
|
||||
<ClCompile Include="LayerTree.cpp" />
|
||||
<ClCompile Include="LayerTreeGroupNode.cpp" />
|
||||
<ClCompile Include="LayerTreeImageNode.cpp" />
|
||||
@ -177,6 +182,8 @@
|
||||
<QtUic Include="adjustTable.ui" />
|
||||
<QtUic Include="DepthCamera.ui" />
|
||||
<QtUic Include="FocusDialog.ui" />
|
||||
<QtUic Include="fodis.ui" />
|
||||
<QtUic Include="gonggashanCtl.ui" />
|
||||
<QtUic Include="HPPA.ui" />
|
||||
<QtMoc Include="HPPA.h" />
|
||||
<ClCompile Include="fileOperation.cpp" />
|
||||
@ -231,6 +238,9 @@
|
||||
<QtMoc Include="DepthCameraWindow.h" />
|
||||
<QtMoc Include="CommunicationViaTCP.h" />
|
||||
<QtMoc Include="CommunicationInterfaceBase.h" />
|
||||
<QtMoc Include="FodisWindow.h" />
|
||||
<ClInclude Include="FiberSpectrometerOperationBase.h" />
|
||||
<QtMoc Include="GonggaShanRecordCtl.h" />
|
||||
<ClInclude Include="imager_base.h" />
|
||||
<ClInclude Include="irisximeaimager.h" />
|
||||
<QtMoc Include="OneMotorControl.h" />
|
||||
@ -245,6 +255,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,18 @@
|
||||
<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>
|
||||
<ClCompile Include="JinspFiberImagerConfig.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GonggaShanRecordCtl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -414,6 +426,15 @@
|
||||
<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>
|
||||
<QtMoc Include="GonggaShanRecordCtl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -473,6 +494,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 +553,12 @@
|
||||
<QtUic Include="PowerControl3D.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="fodis.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
<QtUic Include="gonggashanCtl.ui">
|
||||
<Filter>Form Files</Filter>
|
||||
</QtUic>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
348
HPPA/JinspFiberImager.cpp
Normal file
348
HPPA/JinspFiberImager.cpp
Normal file
@ -0,0 +1,348 @@
|
||||
//
|
||||
// Created by 73505 on 2023/5/7.
|
||||
//
|
||||
#include <algorithm>
|
||||
|
||||
#include "JinspFiberImager.h"
|
||||
|
||||
JinspFiberImager::JinspFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
m_FiberSpectrometer = NULL;
|
||||
|
||||
mUcPortNumber=ucPortNumber;
|
||||
|
||||
m_record = false;
|
||||
|
||||
m_captureIntervalMilliseconds = 1 * 1000;
|
||||
|
||||
qRegisterMetaType<DeviceAttribute>("DeviceAttribute");
|
||||
qRegisterMetaType<DataFrame>("DataFrame");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//将m_IntegratingSphereData通过信号发送
|
||||
emit spectalCaptured(attribute, m_IntegratingSphereData);
|
||||
|
||||
//输出到csv
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString fileName = path + "/" + currentTime + "_" + m_posInfo + "_" + 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()
|
||||
{
|
||||
int allowMaxExposure = 6000;
|
||||
|
||||
DeviceAttribute attribute;
|
||||
getDeviceAttribute(attribute);
|
||||
|
||||
const ZZ_U32 maxPixelValue = m_MaxValueOfFiberSpectrometer;
|
||||
const double targetMinRatio = 0.80;
|
||||
const double targetMaxRatio = 0.90;
|
||||
const ZZ_U32 targetMin = maxPixelValue * targetMinRatio;
|
||||
const ZZ_U32 targetMax = maxPixelValue * targetMaxRatio;
|
||||
|
||||
ZZ_U32 thresholdLow = targetMin;
|
||||
ZZ_U32 thresholdHigh = targetMax;
|
||||
|
||||
// 自适应初始曝光时间:先快速探测亮度水平
|
||||
int exposureTime = 10;
|
||||
setExposureTime(exposureTime);
|
||||
DataFrame dataFrame;
|
||||
singleShot(dataFrame);
|
||||
ZZ_S32 maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
|
||||
// 探测阶段:快速逼近目标区间
|
||||
if (maxValue > 0)
|
||||
{
|
||||
// 预测达到目标区间所需的曝光时间
|
||||
ZZ_U32 targetValue = (targetMin + targetMax) / 2;
|
||||
double predictedRatio = static_cast<double>(targetValue) / maxValue;
|
||||
// 曝光时间与亮度为对数关系,使用对数预测更准确
|
||||
double logRatio = log(static_cast<double>(targetValue) / maxValue + 0.001);
|
||||
int predictedExposure = static_cast<int>(exposureTime * pow(predictedRatio, 0.7));
|
||||
|
||||
if (predictedExposure < 1)
|
||||
predictedExposure = 1;
|
||||
if (predictedExposure > allowMaxExposure)
|
||||
predictedExposure = allowMaxExposure;
|
||||
//predictedExposure = std::clamp(predictedExposure, 1, allowMaxExposure);
|
||||
|
||||
exposureTime = predictedExposure;
|
||||
setExposureTime(exposureTime);
|
||||
singleShot(dataFrame);
|
||||
maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
}
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
// 二分查找阶段:在目标区间内精确查找
|
||||
int lowExposure = 1;
|
||||
int highExposure = allowMaxExposure;
|
||||
int iterations = 0;
|
||||
const int maxIterations = 10;
|
||||
|
||||
while (iterations < maxIterations)
|
||||
{
|
||||
// 检查是否已在目标区间内
|
||||
if (maxValue >= thresholdLow && maxValue <= thresholdHigh)
|
||||
{
|
||||
std::cout << "自动曝光完成 - 曝光时间:" << exposureTime
|
||||
<< "ms, 最大值:" << maxValue << std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// 获取当前曝光时间
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
|
||||
if (maxValue < thresholdLow)
|
||||
{
|
||||
// 曝光不足,增大曝光时间 - 使用二分策略
|
||||
lowExposure = exposureTime;
|
||||
int newExposure = (exposureTime + highExposure) / 2;
|
||||
if (newExposure <= exposureTime)
|
||||
{
|
||||
newExposure = exposureTime * 2;
|
||||
}
|
||||
exposureTime = std::min(newExposure, allowMaxExposure);
|
||||
std::cout << "自动曝光 +++ (" << iterations << ") 曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 曝光过度,减小曝光时间 - 使用二分策略
|
||||
highExposure = exposureTime;
|
||||
int newExposure = (lowExposure + exposureTime) / 2;
|
||||
if (newExposure >= exposureTime) {
|
||||
newExposure = exposureTime / 2;
|
||||
}
|
||||
exposureTime = std::max(newExposure, 1);
|
||||
std::cout << "自动曝光 --- (" << iterations << ") 曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
|
||||
setExposureTime(exposureTime);
|
||||
singleShot(dataFrame);
|
||||
maxValue = GetMaxValue(dataFrame.lData, attribute.iPixels);
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
iterations++;
|
||||
}
|
||||
|
||||
if (iterations >= maxIterations) {
|
||||
std::cout << "自动曝光达到最大迭代次数,最终曝光时间:"
|
||||
<< exposureTime << "ms, 最大值:" << maxValue << std::endl;
|
||||
}
|
||||
|
||||
m_iExposureTime = exposureTime;
|
||||
}
|
||||
|
||||
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 posInfo)
|
||||
{
|
||||
m_posInfo = posInfo;
|
||||
|
||||
//连接光谱仪
|
||||
QString SN;
|
||||
QString pixelCount;
|
||||
QString wavelengthInfo;
|
||||
|
||||
connectFiberSpectrometer(SN, pixelCount, wavelengthInfo);
|
||||
|
||||
//曝光
|
||||
emit startExposureSignal();
|
||||
autoExpose();
|
||||
emit exposureCompleteSignal(m_iExposureTime);
|
||||
|
||||
//采集
|
||||
m_record = true;
|
||||
while (m_record)
|
||||
{
|
||||
recordTarget(1, AppSettings::instance().FiberImagerDataFolder());
|
||||
|
||||
QThread::msleep(m_captureIntervalMilliseconds);
|
||||
}
|
||||
|
||||
std::cout << "close.........." << std::endl;
|
||||
m_FiberSpectrometer->Close();
|
||||
}
|
||||
75
HPPA/JinspFiberImager.h
Normal file
75
HPPA/JinspFiberImager.h
Normal file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
int m_iExposureTime;
|
||||
|
||||
QString m_posInfo;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
void OpenFiberImagerAndRecord(QString posInfo);
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
void spectalCaptured(DeviceAttribute attribute, DataFrame dataFrame);
|
||||
|
||||
void exposureCompleteSignal(int exposureTime);
|
||||
void startExposureSignal();
|
||||
};
|
||||
85
HPPA/JinspFiberImagerConfig.cpp
Normal file
85
HPPA/JinspFiberImagerConfig.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
#include "JinspFiberImagerConfig.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QDebug>
|
||||
|
||||
const QString JinspFiberImagerConfig::kDefaultPortName = QStringLiteral("COM9");
|
||||
const QString JinspFiberImagerConfig::kConfigFileName = QStringLiteral("jinsp_fiber_imager_config.json");
|
||||
|
||||
JinspFiberImagerConfig::JinspFiberImagerConfig()
|
||||
: m_configFilePath(QCoreApplication::applicationDirPath() + "/" + kConfigFileName)
|
||||
, m_portName(kDefaultPortName)
|
||||
{
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
JinspFiberImagerConfig& JinspFiberImagerConfig::instance()
|
||||
{
|
||||
static JinspFiberImagerConfig s;
|
||||
return s;
|
||||
}
|
||||
|
||||
QString JinspFiberImagerConfig::portName() const
|
||||
{
|
||||
return m_portName;
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::setPortName(const QString& port)
|
||||
{
|
||||
if (m_portName != port)
|
||||
{
|
||||
m_portName = port;
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::loadConfig()
|
||||
{
|
||||
QFile file(m_configFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug() << "JinspFiberImagerConfig: No config file found, using default port:" << kDefaultPortName;
|
||||
saveConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray jsonData = file.readAll();
|
||||
file.close();
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonData, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError)
|
||||
{
|
||||
qWarning() << "JinspFiberImagerConfig: JSON parse error:" << parseError.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject obj = doc.object();
|
||||
if (obj.contains("portName"))
|
||||
{
|
||||
m_portName = obj["portName"].toString(kDefaultPortName);
|
||||
}
|
||||
}
|
||||
|
||||
void JinspFiberImagerConfig::saveConfig()
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj["portName"] = m_portName;
|
||||
|
||||
QJsonDocument doc(obj);
|
||||
|
||||
QFile file(m_configFilePath);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qWarning() << "JinspFiberImagerConfig: Failed to open config file for writing:" << m_configFilePath;
|
||||
return;
|
||||
}
|
||||
|
||||
file.write(doc.toJson(QJsonDocument::Indented));
|
||||
file.close();
|
||||
|
||||
qDebug() << "JinspFiberImagerConfig: Config saved to" << m_configFilePath;
|
||||
}
|
||||
26
HPPA/JinspFiberImagerConfig.h
Normal file
26
HPPA/JinspFiberImagerConfig.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
class JinspFiberImagerConfig
|
||||
{
|
||||
public:
|
||||
static JinspFiberImagerConfig& instance();
|
||||
|
||||
QString portName() const;
|
||||
void setPortName(const QString& port);
|
||||
|
||||
static const QString kDefaultPortName;
|
||||
static const QString kConfigFileName;
|
||||
|
||||
private:
|
||||
JinspFiberImagerConfig();
|
||||
JinspFiberImagerConfig(const JinspFiberImagerConfig&) = delete;
|
||||
JinspFiberImagerConfig& operator=(const JinspFiberImagerConfig&) = delete;
|
||||
|
||||
QString m_configFilePath;
|
||||
QString m_portName;
|
||||
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
};
|
||||
@ -16,6 +16,19 @@ OneMotorControl::OneMotorControl(QWidget* parent) : QDialog(parent)
|
||||
connect(this->ui.zero_start_btn, SIGNAL(released()), this, SLOT(zeroStart()));
|
||||
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
|
||||
// 从 AppSettings 读取速度参数
|
||||
AppSettings& settings = AppSettings::instance();
|
||||
ui.speed_lineEdit->setText(QString::number(settings.scanSpeed()));
|
||||
ui.return_speed_lineEdit->setText(QString::number(settings.returnSpeed()));
|
||||
|
||||
// 连接信号,当控件数值变化时保存到 AppSettings
|
||||
connect(ui.speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setScanSpeed(ui.speed_lineEdit->text().toDouble());
|
||||
});
|
||||
connect(ui.return_speed_lineEdit, &QLineEdit::editingFinished, [this]() {
|
||||
AppSettings::instance().setReturnSpeed(ui.return_speed_lineEdit->text().toDouble());
|
||||
});
|
||||
}
|
||||
|
||||
OneMotorControl::~OneMotorControl()
|
||||
@ -25,13 +38,21 @@ OneMotorControl::~OneMotorControl()
|
||||
}
|
||||
|
||||
void OneMotorControl::onConnectMotor()
|
||||
{
|
||||
connectMotor(true);
|
||||
}
|
||||
|
||||
void OneMotorControl::connectMotor(bool isNotification)
|
||||
{
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
if (isNotification)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "fileOperation.h"
|
||||
#include "CaptureCoordinator.h"
|
||||
#include "MotorWindowBase.h"
|
||||
#include "AppSettings.h"
|
||||
|
||||
class OneMotorControl : public QDialog, public MotorWindowBase
|
||||
{
|
||||
@ -27,6 +28,8 @@ public:
|
||||
|
||||
bool getMotorsConnectionStatus();
|
||||
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
|
||||
|
||||
@ -288,7 +288,7 @@ QPushButton:pressed
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>版本:3.1.0</string>
|
||||
<string>版本:3.1.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -53,6 +53,10 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
connect(this->ui.rangeMeasurement_btn, SIGNAL(pressed()), this, SLOT(onx_rangeMeasurement()));
|
||||
connect(this->ui.closeBtn, SIGNAL(released()), this, SLOT(onExit()));
|
||||
|
||||
connect(this->ui.is_new_version_radioButton, &QRadioButton::toggled, this, [this](bool checked) {
|
||||
ui.stackedWidget_connetcParm->setCurrentIndex(checked ? 0 : 1);
|
||||
});
|
||||
|
||||
//查找可用串口,并显示
|
||||
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
|
||||
{
|
||||
@ -72,7 +76,40 @@ focusWindow::focusWindow(QWidget *parent, ImagerOperationBase* imager)
|
||||
ui.autoFocusProgress_progressBar->reset();
|
||||
|
||||
m_dSpeed = 1.0;
|
||||
}
|
||||
|
||||
void focusWindow::showMessageBox(QString msg, QString title)
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(title);
|
||||
msgBox.setText(msg);
|
||||
msgBox.setStyleSheet(R"(
|
||||
QMessageBox {
|
||||
background-color: #0D1233;
|
||||
}
|
||||
QMessageBox QLabel {
|
||||
color: #ACCDFF;
|
||||
font-size: 14px;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #142D7F;
|
||||
color: #e6eeff;
|
||||
border: 1px solid #2f6bff;
|
||||
border-radius: 6px;
|
||||
padding: 6px 20px;
|
||||
min-width: 60px;
|
||||
font-size: 13px;
|
||||
}
|
||||
QPushButton:hover {
|
||||
border: 1px solid #4d8dff;
|
||||
background-color: red;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #23345c;
|
||||
}
|
||||
)");
|
||||
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
focusWindow::~focusWindow()
|
||||
@ -160,33 +197,7 @@ void focusWindow::onConnectMotor()
|
||||
{
|
||||
if (ui.is_new_version_radioButton->isChecked())
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
m_motorThread.start();
|
||||
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
connectMotor(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -257,6 +268,131 @@ void focusWindow::onConnectMotor()
|
||||
disableBeforeConnect(false);
|
||||
}
|
||||
|
||||
void focusWindow::connectMotor(bool isNotification)//需要修改这个函数
|
||||
{
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
if (isNotification)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("马达已连接!"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_multiAxisController)
|
||||
{
|
||||
disconnect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
disconnect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
disconnect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
disconnect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
disconnect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
|
||||
m_motorThread.quit();
|
||||
m_motorThread.wait();
|
||||
m_multiAxisController->deleteLater();
|
||||
}
|
||||
|
||||
if (m_coordinator)
|
||||
{
|
||||
disconnect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
disconnect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
disconnect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
disconnect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
|
||||
m_MotionCaptureCoordinatorThread.quit();
|
||||
m_MotionCaptureCoordinatorThread.wait();
|
||||
m_coordinator->deleteLater();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
FileOperation* fileOperation = new FileOperation();
|
||||
string directory = fileOperation->getDirectoryOfExe();
|
||||
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_focus.cfg";
|
||||
|
||||
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||
}
|
||||
catch (std::exception const& e)
|
||||
{
|
||||
showMessageBox(QString::fromLocal8Bit("请连接马达!"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_multiAxisController->moveToThread(&m_motorThread);
|
||||
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(rmoveSignal(int, double, double, int)), m_multiAxisController, SLOT(rmove(int, double, double, int)));
|
||||
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||
connect(this, SIGNAL(rangeMeasurementSignal(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||
connect(this, SIGNAL(move2MaxLocSignal(int, double, int)), m_multiAxisController, SLOT(moveToMax(int, double, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||
connect(m_multiAxisController, SIGNAL(motorStopSignal(int, double)), this, SLOT(moveAfterAutoFocus(int, double)));
|
||||
connect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||
connect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||
m_motorThread.start();
|
||||
emit testConnectivitySignal(0, 1000);
|
||||
|
||||
//归零
|
||||
//emit zeroStartSignal(0);
|
||||
|
||||
//自动调焦逻辑
|
||||
m_coordinator = new MotionCaptureCoordinator(m_multiAxisController, m_Imager);
|
||||
m_coordinator->moveToThread(&m_MotionCaptureCoordinatorThread);
|
||||
connect(&m_MotionCaptureCoordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(startStepMotion(double, int, double, double)), m_coordinator, SLOT(startStepMotion(double, int, double, double)));
|
||||
connect(m_coordinator, SIGNAL(progressChanged(int)), this, SLOT(onAutoFocusProgress(int)));
|
||||
connect(m_coordinator, SIGNAL(sequenceComplete()), this, SLOT(onAutoFocusFinished()));
|
||||
m_MotionCaptureCoordinatorThread.start();
|
||||
|
||||
}
|
||||
|
||||
void focusWindow::display_motors_connectivity(std::vector<int> connectivity)
|
||||
{
|
||||
//std::cout << "-----------------------------------"<<connectivity.size()<< std::endl;
|
||||
if (connectivity[0])
|
||||
{
|
||||
m_xMotorConnectionStatus = true;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: #08FACE;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xMotorConnectionStatus = false;
|
||||
|
||||
this->ui.motor_state_label->setStyleSheet(R"(
|
||||
QLabel
|
||||
{
|
||||
background-color: red;
|
||||
border-radius: 4px;
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
if (getMotorsConnectionStatus())
|
||||
{
|
||||
this->ui.connectMotor_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui.connectMotor_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||
}
|
||||
}
|
||||
|
||||
bool focusWindow::getMotorsConnectionStatus()
|
||||
{
|
||||
return m_xMotorConnectionStatus;
|
||||
}
|
||||
|
||||
void focusWindow::display_x_loc(std::vector<double> loc)
|
||||
{
|
||||
double tmp = round(loc[0] * 100) / 100;
|
||||
@ -498,32 +634,38 @@ void focusWindow::onAutoFocusFinished()
|
||||
|
||||
void focusWindow::moveAfterAutoFocus(int motorID, double location)
|
||||
{
|
||||
//QObject* obj = sender();
|
||||
|
||||
//if (obj == m_multiAxisController)
|
||||
//{
|
||||
// qDebug() << "sender is m_multiAxisController.";
|
||||
//}
|
||||
|
||||
if (!m_isMoveAfterAutoFocus)
|
||||
{
|
||||
//std::cout << "focusWindow::moveAfterAutoFocus" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\n已经到达位置:" << location << std::endl;
|
||||
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
|
||||
double tmp = abs(location - m_goodPos) / m_goodPos * 100;
|
||||
if (tmp<5)
|
||||
if (tmp < 5 || m_goodPos == 0)
|
||||
{
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
if (!m_isAutoFocusSuccess)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
msgBox.exec();
|
||||
showMessageBox(QString::fromLocal8Bit("纹理较弱,自动调焦效果不佳!请使用调焦纸进行自动调焦!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
msgBox.exec();
|
||||
showMessageBox(QString::fromLocal8Bit("自动调焦成功!"));
|
||||
}
|
||||
m_isMoveAfterAutoFocus = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//移动马达到最佳位置
|
||||
emit move2LocSignal(0, (double)m_goodPos, m_dSpeed, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDateTime>
|
||||
#include <QMutex>
|
||||
#include <QPointer>
|
||||
|
||||
#include "ui_FocusDialog.h"
|
||||
#include "AbstractPortMiscDefines.h"
|
||||
@ -123,11 +124,11 @@ private:
|
||||
void disableBeforeConnect(bool disable);
|
||||
|
||||
QThread m_motorThread;
|
||||
IrisMultiMotorController* m_multiAxisController;
|
||||
QPointer<IrisMultiMotorController> m_multiAxisController;
|
||||
double m_dSpeed;
|
||||
|
||||
QThread m_MotionCaptureCoordinatorThread;
|
||||
MotionCaptureCoordinator* m_coordinator;
|
||||
QPointer<MotionCaptureCoordinator> m_coordinator;
|
||||
|
||||
int m_iStepSize;
|
||||
double m_goodPos;
|
||||
@ -136,6 +137,11 @@ private:
|
||||
void getGaussianInitParam(const std::vector<double>& pos, const std::vector<double>& index, double& a_init, double& mu_init, double& sigma_init, double& c_init);
|
||||
void gaussian_fit(const std::vector<double>& x_data, const std::vector<double>& y_data, double& a, double& mu, double& sigma, double& c);
|
||||
|
||||
bool m_xMotorConnectionStatus = false;
|
||||
bool getMotorsConnectionStatus();
|
||||
void connectMotor(bool isNotification);
|
||||
|
||||
void showMessageBox(QString msg, QString title = QString::fromLocal8Bit("提示"));
|
||||
|
||||
public Q_SLOTS:
|
||||
void onConnectMotor();
|
||||
@ -158,6 +164,8 @@ public Q_SLOTS:
|
||||
|
||||
void onExit();
|
||||
|
||||
void display_motors_connectivity(std::vector<int> connectivity);
|
||||
|
||||
signals:
|
||||
void StartManualFocusSignal(int);//1:开始调焦;0:停止调焦;
|
||||
|
||||
@ -166,6 +174,7 @@ signals:
|
||||
void rmoveSignal(int, double, double, int);
|
||||
void rangeMeasurementSignal(int, double, int);
|
||||
void zeroStartSignal(int);
|
||||
void testConnectivitySignal(int, int);
|
||||
|
||||
void startStepMotion(double speed, int stepInterval = 100, double startPos = 0, double endPos = -1);
|
||||
void closeSignal();
|
||||
|
||||
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>
|
||||
262
HPPA/gonggashanCtl.ui
Normal file
262
HPPA/gonggashanCtl.ui
Normal file
@ -0,0 +1,262 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>gongga_control</class>
|
||||
<widget class="QWidget" name="gongga_control">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>572</width>
|
||||
<height>384</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>贡嘎山触发采集</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;
|
||||
}
|
||||
|
||||
QSpinBox
|
||||
{
|
||||
font: 10pt "新宋体";
|
||||
background-color: #142D7F;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
color: rgb(255, 255, 255);
|
||||
}
|
||||
</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupAdjustments">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel
|
||||
{
|
||||
color: #ACCDFF;
|
||||
font-size: 14px;
|
||||
font: 9pt "Adobe Devanagari";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>通讯参数</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="spinbox_Port">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>666</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelPort">
|
||||
<property name="text">
|
||||
<string>端口</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupPresets">
|
||||
<property name="title">
|
||||
<string>采集</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnListen">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>开始监听</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="btnDisListen">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>43</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>停止监听</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>系统状态</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextEdit" name="status_textEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextEdit
|
||||
{
|
||||
font: 10pt "新宋体";
|
||||
background-color: #142D7F;
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QScrollBar:vertical {
|
||||
background: #0E1C4C;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:vertical {
|
||||
background: #4B60A6;
|
||||
border-radius: 6px;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
QScrollBar:horizontal {
|
||||
background: #0E1C4C;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
QScrollBar::handle:horizontal {
|
||||
background: #4B60A6;
|
||||
border-radius: 6px;
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {
|
||||
width: 0px;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'新宋体'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<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);
|
||||
|
||||
|
||||
};
|
||||
103
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
103
JinspSpectralmeterControl/JinspSpectralmeterControl.vcxproj
Normal file
@ -0,0 +1,103 @@
|
||||
<?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;serialport</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'">
|
||||
<IncludePath>D:\cpp_library\eigen-3.4-rc1;$(IncludePath)</IncludePath>
|
||||
</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