Compare commits
2 Commits
64cdc7591d
...
33e34aa125
| Author | SHA1 | Date | |
|---|---|---|---|
| 33e34aa125 | |||
| abdb27b228 |
@ -879,3 +879,96 @@ bool TwoMotor1PosCoordinator::checkArrival()
|
|||||||
{
|
{
|
||||||
return m_xReached && m_yReached;
|
return m_xReached && m_yReached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
OneMotionCoordinator::OneMotionCoordinator(IrisMultiMotorController* motorCtrl, QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_motorCtrl(motorCtrl)
|
||||||
|
, m_targetPosition(0)
|
||||||
|
, m_speed(0)
|
||||||
|
, m_actualPosition(0)
|
||||||
|
, m_isMoving(false)
|
||||||
|
, m_retryTimes(0)
|
||||||
|
, m_reached(false)
|
||||||
|
{
|
||||||
|
connect(this, SIGNAL(moveTo(int, double, double, int)), m_motorCtrl, SLOT(moveTo(int, double, double, int)));
|
||||||
|
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal, this, &OneMotionCoordinator::handlePositionReached);
|
||||||
|
}
|
||||||
|
|
||||||
|
OneMotionCoordinator::~OneMotionCoordinator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotionCoordinator::moveToTarget(double position, double speed)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&m_dataMutex);
|
||||||
|
m_targetPosition = position;
|
||||||
|
m_speed = speed;
|
||||||
|
m_retryTimes = 0;
|
||||||
|
m_reached = false;
|
||||||
|
m_isMoving = true;
|
||||||
|
|
||||||
|
qDebug() << "OneMotionCoordinator: moving to" << position;
|
||||||
|
emit moveTo(0, position, speed, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotionCoordinator::handlePositionReached(int motorID, double position)
|
||||||
|
{
|
||||||
|
if (!m_isMoving || motorID != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMutexLocker locker(&m_dataMutex);
|
||||||
|
m_actualPosition = position;
|
||||||
|
|
||||||
|
double errorRate = getErrorRate(m_targetPosition, m_actualPosition);
|
||||||
|
|
||||||
|
if (errorRate > 5 && m_retryTimes < m_retryLimit)
|
||||||
|
{
|
||||||
|
m_retryTimes++;
|
||||||
|
qDebug() << "OneMotionCoordinator: retry" << m_retryTimes << ", target:" << m_targetPosition << ", actual:" << m_actualPosition;
|
||||||
|
emit moveTo(0, m_targetPosition, m_speed, 1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_retryTimes = 0;
|
||||||
|
m_reached = true;
|
||||||
|
m_isMoving = false;
|
||||||
|
|
||||||
|
qDebug() << "OneMotionCoordinator: Arrived at" << m_actualPosition;
|
||||||
|
|
||||||
|
emit sequenceComplete(0);
|
||||||
|
emit ArrivalSignal(m_actualPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
double OneMotionCoordinator::getErrorRate(double targetLoc, double actualLoc)
|
||||||
|
{
|
||||||
|
double targetLocTmp;
|
||||||
|
if (targetLoc == 0)
|
||||||
|
{
|
||||||
|
targetLocTmp = 0.001;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetLocTmp = targetLoc;
|
||||||
|
}
|
||||||
|
double errorRate = abs(targetLoc - actualLoc) / targetLocTmp * 100;
|
||||||
|
|
||||||
|
return errorRate;
|
||||||
|
}
|
||||||
|
|||||||
@ -265,3 +265,38 @@ private:
|
|||||||
bool m_xReached;
|
bool m_xReached;
|
||||||
bool m_yReached;
|
bool m_yReached;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OneMotionCoordinator : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
OneMotionCoordinator(IrisMultiMotorController* motorCtrl, QObject* parent = nullptr);
|
||||||
|
~OneMotionCoordinator();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void moveToTarget(double position, double speed);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sequenceComplete(int status);
|
||||||
|
void ArrivalSignal(double position);
|
||||||
|
void moveTo(int, double, double, int);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handlePositionReached(int motorID, double position);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool checkArrival();
|
||||||
|
double getErrorRate(double targetLoc, double actualLoc);
|
||||||
|
|
||||||
|
IrisMultiMotorController* m_motorCtrl;
|
||||||
|
mutable QMutex m_dataMutex;
|
||||||
|
|
||||||
|
double m_targetPosition;
|
||||||
|
double m_speed;
|
||||||
|
double m_actualPosition;
|
||||||
|
bool m_isMoving;
|
||||||
|
|
||||||
|
int m_retryLimit = 3;
|
||||||
|
int m_retryTimes;
|
||||||
|
bool m_reached;
|
||||||
|
};
|
||||||
|
|||||||
138
HPPA/DepthValueLogger.cpp
Normal file
138
HPPA/DepthValueLogger.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
#include "DepthValueLogger.h"
|
||||||
|
#include "AppSettings.h"
|
||||||
|
#include "fileOperation.h"
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
DepthValueLogger& DepthValueLogger::instance()
|
||||||
|
{
|
||||||
|
static DepthValueLogger instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthValueLogger::DepthValueLogger()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthValueLogger::~DepthValueLogger()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DepthValueLogger::getLogFilePath(DepthValueType type) const
|
||||||
|
{
|
||||||
|
FileOperation* fileOperation = new FileOperation();
|
||||||
|
QString directory = QString::fromStdString(fileOperation->getDirectoryOfExe());
|
||||||
|
QString basePath = directory + QDir::separator() + "3DPlantPhenotypeScenario";
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DepthValueType::Plant:
|
||||||
|
return basePath + QDir::separator() + "plant_depth_values.txt";
|
||||||
|
case DepthValueType::LiftingPlatform:
|
||||||
|
return basePath + QDir::separator() + "LiftingPlatform_depth_values.txt";
|
||||||
|
default:
|
||||||
|
return basePath + QDir::separator() + "plant_depth_values.txt";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthValueLogger::appendDepthValue(double depthValue, DepthValueType type)
|
||||||
|
{
|
||||||
|
QString filePath = getLogFilePath(type);
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
QDir dir = fileInfo.absoluteDir();
|
||||||
|
if (!dir.exists())
|
||||||
|
{
|
||||||
|
dir.mkpath(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
|
||||||
|
{
|
||||||
|
QTextStream out(&file);
|
||||||
|
QString timestamp = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz");
|
||||||
|
out << timestamp << "\t" << QString::number(depthValue, 'f', 6) << "\n";
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
emit depthValueLogged(depthValue, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double DepthValueLogger::readLatestDepthValue(DepthValueType type) const
|
||||||
|
{
|
||||||
|
QString filePath = getLogFilePath(type);
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double latestValue = 0.0;
|
||||||
|
QTextStream in(&file);
|
||||||
|
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine().trimmed();
|
||||||
|
if (line.isEmpty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList parts = line.split("\t");
|
||||||
|
if (parts.size() >= 2)
|
||||||
|
{
|
||||||
|
latestValue = parts.last().toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
return latestValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DepthValueLogger::hasValidDepthValue(DepthValueType type) const
|
||||||
|
{
|
||||||
|
QString filePath = getLogFilePath(type);
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasValue = false;
|
||||||
|
QTextStream in(&file);
|
||||||
|
|
||||||
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine().trimmed();
|
||||||
|
if (!line.isEmpty())
|
||||||
|
{
|
||||||
|
hasValue = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
return hasValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthValueLogger::appendPlantDepthValue(double depthValue)
|
||||||
|
{
|
||||||
|
appendDepthValue(depthValue, DepthValueType::Plant);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthValueLogger::appendLiftingPlatformDepthValue(double depthValue)
|
||||||
|
{
|
||||||
|
appendDepthValue(depthValue, DepthValueType::LiftingPlatform);
|
||||||
|
}
|
||||||
|
|
||||||
|
double DepthValueLogger::readLatestPlantDepthValue() const
|
||||||
|
{
|
||||||
|
return readLatestDepthValue(DepthValueType::Plant);
|
||||||
|
}
|
||||||
|
|
||||||
|
double DepthValueLogger::readLatestLiftingPlatformDepthValue() const
|
||||||
|
{
|
||||||
|
return readLatestDepthValue(DepthValueType::LiftingPlatform);
|
||||||
|
}
|
||||||
41
HPPA/DepthValueLogger.h
Normal file
41
HPPA/DepthValueLogger.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef DEPTH_VALUE_LOGGER_H
|
||||||
|
#define DEPTH_VALUE_LOGGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
enum class DepthValueType
|
||||||
|
{
|
||||||
|
Plant,
|
||||||
|
LiftingPlatform
|
||||||
|
};
|
||||||
|
|
||||||
|
class DepthValueLogger : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static DepthValueLogger& instance();
|
||||||
|
|
||||||
|
void appendDepthValue(double depthValue, DepthValueType type);
|
||||||
|
double readLatestDepthValue(DepthValueType type) const;
|
||||||
|
bool hasValidDepthValue(DepthValueType type) const;
|
||||||
|
|
||||||
|
void appendPlantDepthValue(double depthValue);
|
||||||
|
void appendLiftingPlatformDepthValue(double depthValue);
|
||||||
|
double readLatestPlantDepthValue() const;
|
||||||
|
double readLatestLiftingPlatformDepthValue() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void depthValueLogged(double value, DepthValueType type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DepthValueLogger();
|
||||||
|
~DepthValueLogger();
|
||||||
|
DepthValueLogger(const DepthValueLogger&) = delete;
|
||||||
|
DepthValueLogger& operator=(const DepthValueLogger&) = delete;
|
||||||
|
|
||||||
|
QString getLogFilePath(DepthValueType type) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -659,6 +659,7 @@ void HPPA::initTimedDataCollection()
|
|||||||
m_tdc->setAttribute(Qt::WA_DeleteOnClose);
|
m_tdc->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
m_tmc->connectMotor(false);
|
m_tmc->connectMotor(false);
|
||||||
|
m_omc_LiftingPlatform->connectMotor(false);
|
||||||
|
|
||||||
// 定时采集控制器 → 相机/马达
|
// 定时采集控制器 → 相机/马达
|
||||||
connect(m_tdc, &TimedDataCollection::hyperCamParm, this, &HPPA::setTimedDataCollectionHyperCamParm);
|
connect(m_tdc, &TimedDataCollection::hyperCamParm, this, &HPPA::setTimedDataCollectionHyperCamParm);
|
||||||
@ -667,7 +668,7 @@ void HPPA::initTimedDataCollection()
|
|||||||
connect(m_tdc, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection);
|
connect(m_tdc, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection);
|
||||||
|
|
||||||
connect(m_tdc, &TimedDataCollection::ObtainingDepthInformationSignals, this, &HPPA::onObtainTargetDepthInformation);
|
connect(m_tdc, &TimedDataCollection::ObtainingDepthInformationSignals, this, &HPPA::onObtainTargetDepthInformation);
|
||||||
|
|
||||||
connect(m_tdc, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower);
|
connect(m_tdc, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower);
|
||||||
connect(m_tdc, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower);
|
connect(m_tdc, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower);
|
||||||
connect(m_tdc, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower);
|
connect(m_tdc, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower);
|
||||||
@ -676,6 +677,11 @@ void HPPA::initTimedDataCollection()
|
|||||||
connect(m_tmc, &TwoMotorControl::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
connect(m_tmc, &TwoMotorControl::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
||||||
connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
||||||
|
|
||||||
|
//升降台
|
||||||
|
connect(m_tdc, &TimedDataCollection::LiftingPlatformSignals, this, &HPPA::onLiftingPlatform);
|
||||||
|
connect(m_omc_LiftingPlatform, &OneMotorControl_LiftingPlatform::sequenceComplete, m_tdc, &TimedDataCollection::subTaskCompleted);
|
||||||
|
connect(m_omc_LiftingPlatform, &OneMotorControl_LiftingPlatform::back2OriginSignal_TimedDataCollection, m_tdc, &TimedDataCollection::onBack2Origin);
|
||||||
|
|
||||||
m_tdc->show();
|
m_tdc->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,7 +782,12 @@ void HPPA::onStartTimedDataCollection(int camType)
|
|||||||
|
|
||||||
void HPPA::onObtainTargetDepthInformation(SubTask subTaskParams)
|
void HPPA::onObtainTargetDepthInformation(SubTask subTaskParams)
|
||||||
{
|
{
|
||||||
m_tmc->run4_ObtainTargetDepthInfo(m_depthCameraWindow, subTaskParams.depthInfoX, subTaskParams.depthInfoY, subTaskParams.averageNumberOfTimes, subTaskParams.percentageOfEffectiveArea);
|
m_tmc->run4_ObtainTargetDepthInfo(m_depthCameraWindow, subTaskParams.depthType, subTaskParams.depthInfoX, subTaskParams.depthInfoY, subTaskParams.averageNumberOfTimes, subTaskParams.percentageOfEffectiveArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HPPA::onLiftingPlatform(SubTask subTaskParams)
|
||||||
|
{
|
||||||
|
m_omc_LiftingPlatform->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPPA::onTimedDataCollection()
|
void HPPA::onTimedDataCollection()
|
||||||
@ -1057,6 +1068,11 @@ void HPPA::initControlTabwidget()
|
|||||||
m_omc->setWindowFlags(Qt::Widget);
|
m_omc->setWindowFlags(Qt::Widget);
|
||||||
ui.controlTabWidget->addTab(m_omc, QString::fromLocal8Bit("1轴马达控制"));
|
ui.controlTabWidget->addTab(m_omc, QString::fromLocal8Bit("1轴马达控制"));
|
||||||
|
|
||||||
|
//1轴马达控制,上海3D植物表情,白板/调焦纸升降
|
||||||
|
m_omc_LiftingPlatform = new OneMotorControl_LiftingPlatform();
|
||||||
|
m_omc_LiftingPlatform->setWindowFlags(Qt::Widget);
|
||||||
|
ui.controlTabWidget->addTab(m_omc_LiftingPlatform, QString::fromLocal8Bit("白板/调焦升降台"));
|
||||||
|
|
||||||
//2轴马达控制
|
//2轴马达控制
|
||||||
m_tmc = new TwoMotorControl(this);
|
m_tmc = new TwoMotorControl(this);
|
||||||
//connect(m_tmc, SIGNAL(startLineNumSignal(int)), this, SLOT(onCreateTab(int)));
|
//connect(m_tmc, SIGNAL(startLineNumSignal(int)), this, SLOT(onCreateTab(int)));
|
||||||
@ -1679,6 +1695,7 @@ void HPPA::create3DPlantPhenotypeScenario()
|
|||||||
//m_tabManager->showTab(m_pc);
|
//m_tabManager->showTab(m_pc);
|
||||||
m_tabManager->showTab(m_pc3D);
|
m_tabManager->showTab(m_pc3D);
|
||||||
m_tabManager->showTab(m_tmc);
|
m_tabManager->showTab(m_tmc);
|
||||||
|
m_tabManager->showTab(m_omc_LiftingPlatform);
|
||||||
|
|
||||||
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype);
|
m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype);
|
||||||
|
|
||||||
|
|||||||
@ -321,6 +321,7 @@ private:
|
|||||||
PowerControl3D* m_pc3D;
|
PowerControl3D* m_pc3D;
|
||||||
RobotArmControl* m_rac;
|
RobotArmControl* m_rac;
|
||||||
OneMotorControl* m_omc;
|
OneMotorControl* m_omc;
|
||||||
|
OneMotorControl_LiftingPlatform* m_omc_LiftingPlatform;
|
||||||
TwoMotorControl* m_tmc;
|
TwoMotorControl* m_tmc;
|
||||||
FodisWindow* m_fodisWindow;
|
FodisWindow* m_fodisWindow;
|
||||||
GonggaShanRecordCtl* m_gonggaShanRecordCtl;
|
GonggaShanRecordCtl* m_gonggaShanRecordCtl;
|
||||||
@ -450,6 +451,7 @@ public Q_SLOTS:
|
|||||||
void setTimedDataCollectionMotorParm(QString pathLineFilePath);
|
void setTimedDataCollectionMotorParm(QString pathLineFilePath);
|
||||||
void onStartTimedDataCollection(int camType);
|
void onStartTimedDataCollection(int camType);
|
||||||
void onObtainTargetDepthInformation(SubTask subTaskParams);
|
void onObtainTargetDepthInformation(SubTask subTaskParams);
|
||||||
|
void onLiftingPlatform(SubTask subTaskParams);
|
||||||
|
|
||||||
void onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
void onStretchedImageReady(int fileNumber, const QString& filePath, QPixmap& pixmap);
|
||||||
void onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error);
|
void onStretchProcessingError(int fileNumber, const QString& filePath, const QString& error);
|
||||||
|
|||||||
@ -186,6 +186,7 @@
|
|||||||
<QtUic Include="gonggashanCtl.ui" />
|
<QtUic Include="gonggashanCtl.ui" />
|
||||||
<QtUic Include="HPPA.ui" />
|
<QtUic Include="HPPA.ui" />
|
||||||
<QtMoc Include="HPPA.h" />
|
<QtMoc Include="HPPA.h" />
|
||||||
|
<ClCompile Include="DepthValueLogger.cpp" />
|
||||||
<ClCompile Include="fileOperation.cpp" />
|
<ClCompile Include="fileOperation.cpp" />
|
||||||
<ClCompile Include="focusWindow.cpp" />
|
<ClCompile Include="focusWindow.cpp" />
|
||||||
<ClCompile Include="HPPA.cpp" />
|
<ClCompile Include="HPPA.cpp" />
|
||||||
@ -212,6 +213,7 @@
|
|||||||
<QtUic Include="twoMotorControl.ui" />
|
<QtUic Include="twoMotorControl.ui" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<QtMoc Include="DepthValueLogger.h" />
|
||||||
<QtMoc Include="fileOperation.h" />
|
<QtMoc Include="fileOperation.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -283,6 +283,9 @@
|
|||||||
<ClCompile Include="ResononNirImager.cpp">
|
<ClCompile Include="ResononNirImager.cpp">
|
||||||
<Filter>Source Files\hyperImagerCtl</Filter>
|
<Filter>Source Files\hyperImagerCtl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="DepthValueLogger.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="fileOperation.h">
|
<QtMoc Include="fileOperation.h">
|
||||||
@ -453,6 +456,9 @@
|
|||||||
<QtMoc Include="resononImager.h">
|
<QtMoc Include="resononImager.h">
|
||||||
<Filter>Header Files\hyperImagerCtl</Filter>
|
<Filter>Header Files\hyperImagerCtl</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="DepthValueLogger.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="imageProcessor.h">
|
<ClInclude Include="imageProcessor.h">
|
||||||
|
|||||||
@ -267,3 +267,278 @@ bool OneMotorControl::getMotorsConnectionStatus()
|
|||||||
{
|
{
|
||||||
return m_xMotorConnectionStatus;
|
return m_xMotorConnectionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
OneMotorControl_LiftingPlatform::OneMotorControl_LiftingPlatform(QWidget* parent) : QDialog(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
connect(this->ui.connect_btn, SIGNAL(pressed()), this, SLOT(onConnectMotor()));
|
||||||
|
|
||||||
|
connect(this->ui.right_btn, SIGNAL(pressed()), this, SLOT(onxMotorRight()));
|
||||||
|
connect(this->ui.right_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
connect(this->ui.left_btn, SIGNAL(pressed()), this, SLOT(onxMotorLeft()));
|
||||||
|
connect(this->ui.left_btn, SIGNAL(released()), this, SLOT(onxMotorStop()));
|
||||||
|
|
||||||
|
connect(this->ui.move2loc_pushButton, SIGNAL(pressed()), this, SLOT(onxMove2Loc()));
|
||||||
|
|
||||||
|
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_LiftingPlatform::~OneMotorControl_LiftingPlatform()
|
||||||
|
{
|
||||||
|
m_motorThread.quit();
|
||||||
|
m_motorThread.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onConnectMotor()
|
||||||
|
{
|
||||||
|
connectMotor(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::connectMotor(bool isNotification)
|
||||||
|
{
|
||||||
|
if (getMotorsConnectionStatus())
|
||||||
|
{
|
||||||
|
if (isNotification)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("马达已连接!"));
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_multiAxisController != nullptr)
|
||||||
|
{
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||||
|
disconnect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
|
disconnect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
|
disconnect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
disconnect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
disconnect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
disconnect(this, SIGNAL(testConnectivitySignal(int, int)), m_multiAxisController, SLOT(testConnectivity(int, int)));
|
||||||
|
disconnect(m_multiAxisController, SIGNAL(broadcastConnectivity(std::vector<int>)), this, SLOT(display_motors_connectivity(std::vector<int>)));
|
||||||
|
|
||||||
|
m_motorThread.quit();
|
||||||
|
m_motorThread.wait();
|
||||||
|
m_multiAxisController = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileOperation* fileOperation = new FileOperation();
|
||||||
|
string directory = fileOperation->getDirectoryOfExe();
|
||||||
|
QString configFilePath = QString::fromStdString(directory) + "\\oneMotorConfigFile_LiftingPlatform.cfg";
|
||||||
|
|
||||||
|
m_multiAxisController = new IrisMultiMotorController(configFilePath);
|
||||||
|
}
|
||||||
|
catch (std::exception const& e)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(QString::fromLocal8Bit("请连接马达!"));
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_multiAxisController->moveToThread(&m_motorThread);
|
||||||
|
connect(&m_motorThread, SIGNAL(finished()), m_multiAxisController, SLOT(deleteLater()));
|
||||||
|
|
||||||
|
connect(m_multiAxisController, SIGNAL(broadcastLocationSignal(std::vector<double>)), this, SLOT(display_x_loc(std::vector<double>)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(moveSignal(int, bool, double, int)), m_multiAxisController, SLOT(move(int, bool, double, int)));
|
||||||
|
connect(this, SIGNAL(move2LocSignal(int, double, double, int)), m_multiAxisController, SLOT(moveTo(int, double, double, int)));
|
||||||
|
connect(this, SIGNAL(stopSignal(int)), m_multiAxisController, SLOT(stop(int)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(zeroStartSignal(int)), m_multiAxisController, SLOT(zeroStart(int)));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(rangeMeasurement(int, double, int)), m_multiAxisController, SLOT(rangeMeasurement(int, double, int)));
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::display_x_loc(std::vector<double> loc)
|
||||||
|
{
|
||||||
|
double tmp = round(loc[0] * 100) / 100;
|
||||||
|
this->ui.realTimeLoc_lineEdit->setText(QString::number(tmp));
|
||||||
|
|
||||||
|
emit broadcastLocationSignal(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::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.connect_btn->setText(QString::fromLocal8Bit("已连接"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->ui.connect_btn->setText(QString::fromLocal8Bit("重新连接"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::zeroStart()
|
||||||
|
{
|
||||||
|
zeroStartSignal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onx_rangeMeasurement()
|
||||||
|
{
|
||||||
|
double s0 = ui.speed_lineEdit->text().toDouble();
|
||||||
|
emit rangeMeasurement(0, s0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onxMove2Loc()
|
||||||
|
{
|
||||||
|
double s = ui.speed_lineEdit->text().toDouble();
|
||||||
|
double l = ui.move2loc_lineEdit->text().toDouble();
|
||||||
|
|
||||||
|
emit move2LocSignal(0, l, s, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onxMotorRight()
|
||||||
|
{
|
||||||
|
double s = ui.speed_lineEdit->text().toDouble();
|
||||||
|
|
||||||
|
emit moveSignal(0, false, s, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onxMotorLeft()
|
||||||
|
{
|
||||||
|
double s = ui.speed_lineEdit->text().toDouble();
|
||||||
|
|
||||||
|
emit moveSignal(0, true, s, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onxMotorStop()
|
||||||
|
{
|
||||||
|
emit stopSignal(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::run()
|
||||||
|
{
|
||||||
|
m_coordinator = new OneMotionCoordinator(m_multiAxisController,this);
|
||||||
|
connect(m_coordinator, &OneMotionCoordinator::sequenceComplete, this, &OneMotorControl_LiftingPlatform::sequenceComplete);
|
||||||
|
connect(m_coordinator, &OneMotionCoordinator::ArrivalSignal, this, &OneMotorControl_LiftingPlatform::onBack2Origin);
|
||||||
|
|
||||||
|
double plantDepthValue = DepthValueLogger::instance().readLatestPlantDepthValue();
|
||||||
|
double liftingPlatformDepthValue = DepthValueLogger::instance().readLatestLiftingPlatformDepthValue();
|
||||||
|
double targetDepth = liftingPlatformDepthValue - plantDepthValue;
|
||||||
|
|
||||||
|
if (targetDepth < 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_coordinator->moveToTarget(targetDepth, ui.speed_lineEdit->text().toDouble());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::stop()
|
||||||
|
{
|
||||||
|
emit stopStepMotionSignal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OneMotorControl_LiftingPlatform::onBack2Origin(double pos)
|
||||||
|
{
|
||||||
|
emit back2OriginSignal_TimedDataCollection();
|
||||||
|
|
||||||
|
m_coordinator->deleteLater();
|
||||||
|
m_coordinator = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OneMotorControl_LiftingPlatform::getMotorsConnectionStatus()
|
||||||
|
{
|
||||||
|
return m_xMotorConnectionStatus;
|
||||||
|
}
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
#include "MotorWindowBase.h"
|
#include "MotorWindowBase.h"
|
||||||
#include "AppSettings.h"
|
#include "AppSettings.h"
|
||||||
|
|
||||||
|
#include "DepthValueLogger.h"
|
||||||
|
|
||||||
class OneMotorControl : public QDialog, public MotorWindowBase
|
class OneMotorControl : public QDialog, public MotorWindowBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -77,3 +79,62 @@ private:
|
|||||||
|
|
||||||
bool m_xMotorConnectionStatus = false;
|
bool m_xMotorConnectionStatus = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OneMotorControl_LiftingPlatform : public QDialog, public MotorWindowBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
OneMotorControl_LiftingPlatform(QWidget* parent = nullptr);
|
||||||
|
~OneMotorControl_LiftingPlatform();
|
||||||
|
|
||||||
|
void run();
|
||||||
|
void stop();
|
||||||
|
|
||||||
|
bool getMotorsConnectionStatus();
|
||||||
|
|
||||||
|
void connectMotor(bool isNotification);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void onConnectMotor();
|
||||||
|
|
||||||
|
void display_x_loc(std::vector<double> loc);
|
||||||
|
void display_motors_connectivity(std::vector<int> connectivity);
|
||||||
|
void onxMove2Loc();
|
||||||
|
void zeroStart();
|
||||||
|
void onx_rangeMeasurement();
|
||||||
|
|
||||||
|
void onxMotorRight();
|
||||||
|
void onxMotorLeft();
|
||||||
|
void onxMotorStop();
|
||||||
|
|
||||||
|
void onBack2Origin(double pos);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void moveSignal(int, bool, double, int);
|
||||||
|
void move2LocSignal(int, double, double, int);
|
||||||
|
void move2LocSignal(const std::vector<double>, const std::vector<double>, int);
|
||||||
|
void stopSignal(int);
|
||||||
|
|
||||||
|
void rangeMeasurement(int, double, int);
|
||||||
|
void zeroStartSignal(int);
|
||||||
|
void testConnectivitySignal(int, int);
|
||||||
|
|
||||||
|
void start(OneMotionCapturePathLine);
|
||||||
|
void stopStepMotionSignal();
|
||||||
|
|
||||||
|
void sequenceComplete(int status);
|
||||||
|
void back2OriginSignal_TimedDataCollection();
|
||||||
|
|
||||||
|
void broadcastLocationSignal(std::vector<double>);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::OneMotorControl_UI ui;
|
||||||
|
|
||||||
|
QThread m_motorThread;
|
||||||
|
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||||
|
|
||||||
|
QPointer<OneMotionCoordinator> m_coordinator;
|
||||||
|
|
||||||
|
bool m_xMotorConnectionStatus = false;
|
||||||
|
};
|
||||||
|
|||||||
@ -587,15 +587,17 @@ QString TaskTreeModel::statusToString(TaskStatus status) const
|
|||||||
|
|
||||||
QString TaskTreeModel::subTaskTypeToString(SubTaskType type) const
|
QString TaskTreeModel::subTaskTypeToString(SubTaskType type) const
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type)
|
||||||
case SubTaskType::HyperSpectual400_1000nm: return QString::fromLocal8Bit("高光谱 400-1000nm");
|
{
|
||||||
case SubTaskType::HyperSpectual1000_1700nm: return QString::fromLocal8Bit("高光谱 1000-1700nm");
|
case SubTaskType::HyperSpectual400_1000nm: return QString::fromLocal8Bit("高光谱 400-1000nm");
|
||||||
case SubTaskType::SingleLensReflex: return QString::fromLocal8Bit("单反相机");
|
case SubTaskType::HyperSpectual1000_1700nm: return QString::fromLocal8Bit("高光谱 1000-1700nm");
|
||||||
case SubTaskType::DepthCamera: return QString::fromLocal8Bit("深度相机");
|
case SubTaskType::SingleLensReflex: return QString::fromLocal8Bit("单反相机");
|
||||||
case SubTaskType::ObtainingDepthInformation: return QString::fromLocal8Bit("探测深度信息");
|
case SubTaskType::DepthCamera: return QString::fromLocal8Bit("深度相机");
|
||||||
case SubTaskType::AutoFocus: return QString::fromLocal8Bit("自动调焦");
|
case SubTaskType::ObtainingDepthInformation: return QString::fromLocal8Bit("探测深度信息");
|
||||||
|
case SubTaskType::AutoFocus: return QString::fromLocal8Bit("自动调焦");
|
||||||
|
case SubTaskType::LiftingPlatform: return QString::fromLocal8Bit("升降平台");
|
||||||
}
|
}
|
||||||
return "未知类型";
|
return QString::fromLocal8Bit("未知类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TaskTreeModel::formatDuration(double minutes) const
|
QString TaskTreeModel::formatDuration(double minutes) const
|
||||||
|
|||||||
@ -113,6 +113,7 @@ void TimedDataCollection::setupConnections()
|
|||||||
this, &TimedDataCollection::startRecordSignal);
|
this, &TimedDataCollection::startRecordSignal);
|
||||||
|
|
||||||
connect(m_scheduler, &TaskScheduler::ObtainingDepthInformationSignals, this, &TimedDataCollection::ObtainingDepthInformationSignals);
|
connect(m_scheduler, &TaskScheduler::ObtainingDepthInformationSignals, this, &TimedDataCollection::ObtainingDepthInformationSignals);
|
||||||
|
connect(m_scheduler, &TaskScheduler::LiftingPlatformSignals, this, &TimedDataCollection::LiftingPlatformSignals);
|
||||||
|
|
||||||
connect(m_scheduler, &TaskScheduler::switchHalogenLampSignal,
|
connect(m_scheduler, &TaskScheduler::switchHalogenLampSignal,
|
||||||
this, &TimedDataCollection::switchHalogenLampSignal);
|
this, &TimedDataCollection::switchHalogenLampSignal);
|
||||||
|
|||||||
@ -53,6 +53,7 @@ Q_SIGNALS:
|
|||||||
void startRecordSignal(int camType);
|
void startRecordSignal(int camType);
|
||||||
|
|
||||||
void ObtainingDepthInformationSignals(SubTask info);
|
void ObtainingDepthInformationSignals(SubTask info);
|
||||||
|
void LiftingPlatformSignals(SubTask info);
|
||||||
|
|
||||||
void switchHalogenLampSignal(int state);
|
void switchHalogenLampSignal(int state);
|
||||||
void switchD65LampSignal(int state);
|
void switchD65LampSignal(int state);
|
||||||
|
|||||||
@ -116,6 +116,7 @@ SubTaskType TimedDataCollectionDataStructuresReaderWriter::stringToSubTaskType(c
|
|||||||
|
|
||||||
if (str == "ObtainingDepthInformation") return SubTaskType::ObtainingDepthInformation;
|
if (str == "ObtainingDepthInformation") return SubTaskType::ObtainingDepthInformation;
|
||||||
if (str == "AutoFocus") return SubTaskType::AutoFocus;
|
if (str == "AutoFocus") return SubTaskType::AutoFocus;
|
||||||
|
if (str == "LiftingPlatform") return SubTaskType::LiftingPlatform;
|
||||||
|
|
||||||
return SubTaskType::SingleLensReflex;
|
return SubTaskType::SingleLensReflex;
|
||||||
}
|
}
|
||||||
@ -145,6 +146,7 @@ QJsonObject TimedDataCollectionDataStructuresReaderWriter::subTaskToJson(const S
|
|||||||
obj["depthInfoY"] = subTask.depthInfoY;
|
obj["depthInfoY"] = subTask.depthInfoY;
|
||||||
obj["averageNumberOfTimes"] = subTask.averageNumberOfTimes;
|
obj["averageNumberOfTimes"] = subTask.averageNumberOfTimes;
|
||||||
obj["percentageOfEffectiveArea"] = subTask.percentageOfEffectiveArea;
|
obj["percentageOfEffectiveArea"] = subTask.percentageOfEffectiveArea;
|
||||||
|
obj["depthType"] = subTask.depthType;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +172,7 @@ bool TimedDataCollectionDataStructuresReaderWriter::jsonToSubTask(const QJsonObj
|
|||||||
subTask.depthInfoY = json["depthInfoY"].toDouble();
|
subTask.depthInfoY = json["depthInfoY"].toDouble();
|
||||||
subTask.averageNumberOfTimes = json["averageNumberOfTimes"].toInt();
|
subTask.averageNumberOfTimes = json["averageNumberOfTimes"].toInt();
|
||||||
subTask.percentageOfEffectiveArea = json["percentageOfEffectiveArea"].toDouble();
|
subTask.percentageOfEffectiveArea = json["percentageOfEffectiveArea"].toDouble();
|
||||||
|
subTask.depthType = json["depthType"].toInt();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,6 +480,12 @@ void TaskExecutor::executeNextSubTask()
|
|||||||
//执行自动调焦任务
|
//执行自动调焦任务
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SubTaskType::LiftingPlatform:
|
||||||
|
{
|
||||||
|
//执行升降平台任务
|
||||||
|
emit LiftingPlatformSignals(subTask);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SubTaskType::HyperSpectual400_1000nm:
|
case SubTaskType::HyperSpectual400_1000nm:
|
||||||
{
|
{
|
||||||
m_camType = 0;
|
m_camType = 0;
|
||||||
@ -719,6 +728,7 @@ void TaskScheduler::executeTask(TimedTask& task)
|
|||||||
this, &TaskScheduler::startRecordSignal);
|
this, &TaskScheduler::startRecordSignal);
|
||||||
|
|
||||||
connect(m_currentExecutor, &TaskExecutor::ObtainingDepthInformationSignals, this, &TaskScheduler::ObtainingDepthInformationSignals);
|
connect(m_currentExecutor, &TaskExecutor::ObtainingDepthInformationSignals, this, &TaskScheduler::ObtainingDepthInformationSignals);
|
||||||
|
connect(m_currentExecutor, &TaskExecutor::LiftingPlatformSignals, this, &TaskScheduler::LiftingPlatformSignals);
|
||||||
|
|
||||||
connect(m_currentExecutor, &TaskExecutor::switchHalogenLampSignal, this, &TaskScheduler::switchHalogenLampSignal);
|
connect(m_currentExecutor, &TaskExecutor::switchHalogenLampSignal, this, &TaskScheduler::switchHalogenLampSignal);
|
||||||
connect(m_currentExecutor, &TaskExecutor::switchD65LampSignal, this, &TaskScheduler::switchD65LampSignal);
|
connect(m_currentExecutor, &TaskExecutor::switchD65LampSignal, this, &TaskScheduler::switchD65LampSignal);
|
||||||
|
|||||||
@ -27,7 +27,8 @@ enum class SubTaskType {
|
|||||||
SingleLensReflex, // 单反相机
|
SingleLensReflex, // 单反相机
|
||||||
DepthCamera, // 深度相机采集任务
|
DepthCamera, // 深度相机采集任务
|
||||||
ObtainingDepthInformation, //通过深度相机获取被测物体的深度信息
|
ObtainingDepthInformation, //通过深度相机获取被测物体的深度信息
|
||||||
AutoFocus // 自动对焦
|
AutoFocus, // 自动对焦
|
||||||
|
LiftingPlatform // 升降平台
|
||||||
};
|
};
|
||||||
|
|
||||||
// ==================== 统一子任务封装 ====================
|
// ==================== 统一子任务封装 ====================
|
||||||
@ -50,6 +51,7 @@ struct SubTask {
|
|||||||
int captureIntervalSeconds = 5; // 单反/深度相机用
|
int captureIntervalSeconds = 5; // 单反/深度相机用
|
||||||
|
|
||||||
//任务ObtainingDepthInformation所需的x和y坐标
|
//任务ObtainingDepthInformation所需的x和y坐标
|
||||||
|
int depthType = 0;//0表示植被深度,1表示白板/调焦版深度
|
||||||
double depthInfoX = 0.0;
|
double depthInfoX = 0.0;
|
||||||
double depthInfoY = 0.0;
|
double depthInfoY = 0.0;
|
||||||
int averageNumberOfTimes = 1; //任务ObtainingDepthInformation所需的平均次数
|
int averageNumberOfTimes = 1; //任务ObtainingDepthInformation所需的平均次数
|
||||||
@ -165,6 +167,7 @@ signals:
|
|||||||
void startRecordSignal(int camType);
|
void startRecordSignal(int camType);
|
||||||
|
|
||||||
void ObtainingDepthInformationSignals(SubTask info);
|
void ObtainingDepthInformationSignals(SubTask info);
|
||||||
|
void LiftingPlatformSignals(SubTask info);
|
||||||
|
|
||||||
void switchHalogenLampSignal(int state);
|
void switchHalogenLampSignal(int state);
|
||||||
void switchD65LampSignal(int state);
|
void switchD65LampSignal(int state);
|
||||||
@ -236,6 +239,7 @@ signals:
|
|||||||
void startRecordSignal(int camType);
|
void startRecordSignal(int camType);
|
||||||
|
|
||||||
void ObtainingDepthInformationSignals(SubTask info);
|
void ObtainingDepthInformationSignals(SubTask info);
|
||||||
|
void LiftingPlatformSignals(SubTask info);
|
||||||
|
|
||||||
void switchHalogenLampSignal(int state);
|
void switchHalogenLampSignal(int state);
|
||||||
void switchD65LampSignal(int state);
|
void switchD65LampSignal(int state);
|
||||||
|
|||||||
@ -210,8 +210,10 @@ void TwoMotorControl::onBack2Origin2()
|
|||||||
emit back2OriginSignal_TimedDataCollection();
|
emit back2OriginSignal_TimedDataCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea)
|
void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, int depthType, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea)
|
||||||
{
|
{
|
||||||
|
m_depthType = depthType;
|
||||||
|
|
||||||
window->m_DepthCameraOperation->setAverageNumberOfTimes(averageNumberOfTimes);
|
window->m_DepthCameraOperation->setAverageNumberOfTimes(averageNumberOfTimes);
|
||||||
window->m_DepthCameraOperation->setPercentageOfEffectiveArea(percentageOfEffectiveArea);
|
window->m_DepthCameraOperation->setPercentageOfEffectiveArea(percentageOfEffectiveArea);
|
||||||
|
|
||||||
@ -219,7 +221,8 @@ void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, doub
|
|||||||
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::ArrivalSignal, window, &DepthCameraWindow::OpenDepthCamera_getDepthValue);
|
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::ArrivalSignal, window, &DepthCameraWindow::OpenDepthCamera_getDepthValue);
|
||||||
|
|
||||||
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2origin);
|
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2origin);
|
||||||
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, this, &TwoMotorControl::sequenceComplete);//关灯
|
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, this, &TwoMotorControl::sequenceComplete, Qt::UniqueConnection);//关灯
|
||||||
|
connect(window->m_DepthCameraOperation, &DepthCameraOperation::DepthValueSignal, this, &TwoMotorControl::saveDepthValue, Qt::UniqueConnection);
|
||||||
|
|
||||||
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin3);
|
connect(m_ObtainTargetDepthInfoCoordinator, &TwoMotor1PosCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin3);
|
||||||
|
|
||||||
@ -229,6 +232,18 @@ void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, doub
|
|||||||
m_ObtainTargetDepthInfoCoordinator->moveToTarget(depthInfoX, depthInfoY, xmotor_move_speed, ymotor_move_speed);
|
m_ObtainTargetDepthInfoCoordinator->moveToTarget(depthInfoX, depthInfoY, xmotor_move_speed, ymotor_move_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TwoMotorControl::saveDepthValue(double depthValue)
|
||||||
|
{
|
||||||
|
if (m_depthType == 0)//0表示植被深度,1表示白板/调焦版深度
|
||||||
|
{
|
||||||
|
DepthValueLogger::instance().appendPlantDepthValue(depthValue);
|
||||||
|
}
|
||||||
|
else if (m_depthType == 1)
|
||||||
|
{
|
||||||
|
DepthValueLogger::instance().appendLiftingPlatformDepthValue(depthValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TwoMotorControl::onBack2Origin3()
|
void TwoMotorControl::onBack2Origin3()
|
||||||
{
|
{
|
||||||
m_ObtainTargetDepthInfoCoordinator->deleteLater();
|
m_ObtainTargetDepthInfoCoordinator->deleteLater();
|
||||||
|
|||||||
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include "PathLine.h"
|
#include "PathLine.h"
|
||||||
|
|
||||||
|
#include "DepthValueLogger.h"
|
||||||
|
|
||||||
#define PI 3.1415926
|
#define PI 3.1415926
|
||||||
|
|
||||||
class TwoMotorControl : public QDialog, public MotorWindowBase
|
class TwoMotorControl : public QDialog, public MotorWindowBase
|
||||||
@ -82,8 +84,9 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
void run2(SingleLensReflexCameraWindow* w);
|
void run2(SingleLensReflexCameraWindow* w);
|
||||||
void run3(DepthCameraWindow* window);
|
void run3(DepthCameraWindow* window);
|
||||||
void run4_ObtainTargetDepthInfo(DepthCameraWindow* window, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea);
|
void run4_ObtainTargetDepthInfo(DepthCameraWindow* window, int depthType, double depthInfoX, double depthInfoY, int averageNumberOfTimes, double percentageOfEffectiveArea);
|
||||||
void onBack2Origin2();
|
void onBack2Origin2();
|
||||||
|
void saveDepthValue(double depthValue);
|
||||||
void onBack2Origin3();
|
void onBack2Origin3();
|
||||||
|
|
||||||
void stop_record();
|
void stop_record();
|
||||||
@ -120,4 +123,6 @@ private:
|
|||||||
|
|
||||||
QThread m_motorThread;
|
QThread m_motorThread;
|
||||||
IrisMultiMotorController* m_multiAxisController = nullptr;
|
IrisMultiMotorController* m_multiAxisController = nullptr;
|
||||||
|
|
||||||
|
int m_depthType;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user