From abdb27b2281b92ff1b92d0d943869d41f03f82c6 Mon Sep 17 00:00:00 2001 From: tangchao0503 <735056338@qq.com> Date: Tue, 11 Aug 2026 16:52:32 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=8C=E8=AE=A1=E5=88=92=E9=87=87?= =?UTF-8?q?=E9=9B=8618=EF=BC=8C=E4=B8=8A=E6=B5=B7=E5=86=9C=E7=A7=91?= =?UTF-8?q?=E9=99=A23D=E6=A4=8D=E7=89=A9=E8=A1=A8=E5=9E=8B=EF=BC=9A=201?= =?UTF-8?q?=E3=80=81=E4=BB=BB=E5=8A=A1=E7=B1=BB=E5=9E=8BObtainingDepthInfo?= =?UTF-8?q?rmation=E5=85=BC=E5=AE=B9=E5=8A=9F=E8=83=BD=EF=BC=9A=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=A4=8D=E8=A2=AB=E5=92=8C=E5=8D=87=E9=99=8D=E5=8F=B0?= =?UTF-8?q?=E7=9A=84=E5=B9=B3=E5=9D=87=E6=B7=B1=E5=BA=A6=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=B9=B6=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6=EF=BC=9A3DPlantPh?= =?UTF-8?q?enotypeScenario\plant=5Fdepth=5Fvalues.txt=E5=92=8C3DPlantPheno?= =?UTF-8?q?typeScenario\LiftingPlatform=5Fdepth=5Fvalues.txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HPPA/DepthValueLogger.cpp | 138 +++++++++++ HPPA/DepthValueLogger.h | 41 ++++ HPPA/HPPA.cpp | 8 +- HPPA/HPPA.h | 1 + HPPA/HPPA.vcxproj | 2 + HPPA/HPPA.vcxproj.filters | 6 + HPPA/OneMotorControl.cpp | 273 +++++++++++++++++++++ HPPA/OneMotorControl.h | 58 +++++ HPPA/TimedDataCollectionDataStructures.cpp | 2 + HPPA/TimedDataCollectionDataStructures.h | 1 + HPPA/TwoMotorControl.cpp | 19 +- HPPA/TwoMotorControl.h | 7 +- 12 files changed, 552 insertions(+), 4 deletions(-) create mode 100644 HPPA/DepthValueLogger.cpp create mode 100644 HPPA/DepthValueLogger.h diff --git a/HPPA/DepthValueLogger.cpp b/HPPA/DepthValueLogger.cpp new file mode 100644 index 0000000..c465bde --- /dev/null +++ b/HPPA/DepthValueLogger.cpp @@ -0,0 +1,138 @@ +#include "stdafx.h" +#include "DepthValueLogger.h" +#include "AppSettings.h" +#include "fileOperation.h" +#include + +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); +} diff --git a/HPPA/DepthValueLogger.h b/HPPA/DepthValueLogger.h new file mode 100644 index 0000000..3488b29 --- /dev/null +++ b/HPPA/DepthValueLogger.h @@ -0,0 +1,41 @@ +#ifndef DEPTH_VALUE_LOGGER_H +#define DEPTH_VALUE_LOGGER_H + +#include +#include + +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 diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index 3dc38fc..b5b2b6f 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -776,7 +776,7 @@ void HPPA::onStartTimedDataCollection(int camType) 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::onTimedDataCollection() @@ -1057,6 +1057,11 @@ void HPPA::initControlTabwidget() m_omc->setWindowFlags(Qt::Widget); 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轴马达控制 m_tmc = new TwoMotorControl(this); //connect(m_tmc, SIGNAL(startLineNumSignal(int)), this, SLOT(onCreateTab(int))); @@ -1679,6 +1684,7 @@ void HPPA::create3DPlantPhenotypeScenario() //m_tabManager->showTab(m_pc); m_tabManager->showTab(m_pc3D); m_tabManager->showTab(m_tmc); + m_tabManager->showTab(m_omc_LiftingPlatform); m_view3DModelManager->switchScenario(View3DModelManager::ScenarioType::PlantPhenotype); diff --git a/HPPA/HPPA.h b/HPPA/HPPA.h index 973559d..3205363 100644 --- a/HPPA/HPPA.h +++ b/HPPA/HPPA.h @@ -321,6 +321,7 @@ private: PowerControl3D* m_pc3D; RobotArmControl* m_rac; OneMotorControl* m_omc; + OneMotorControl_LiftingPlatform* m_omc_LiftingPlatform; TwoMotorControl* m_tmc; FodisWindow* m_fodisWindow; GonggaShanRecordCtl* m_gonggaShanRecordCtl; diff --git a/HPPA/HPPA.vcxproj b/HPPA/HPPA.vcxproj index 6018b95..5fa1c3b 100644 --- a/HPPA/HPPA.vcxproj +++ b/HPPA/HPPA.vcxproj @@ -186,6 +186,7 @@ + @@ -212,6 +213,7 @@ + diff --git a/HPPA/HPPA.vcxproj.filters b/HPPA/HPPA.vcxproj.filters index 5a882a7..8b39ae5 100644 --- a/HPPA/HPPA.vcxproj.filters +++ b/HPPA/HPPA.vcxproj.filters @@ -283,6 +283,9 @@ Source Files\hyperImagerCtl + + Source Files + @@ -453,6 +456,9 @@ Header Files\hyperImagerCtl + + Header Files + diff --git a/HPPA/OneMotorControl.cpp b/HPPA/OneMotorControl.cpp index fd21d24..dd255b2 100644 --- a/HPPA/OneMotorControl.cpp +++ b/HPPA/OneMotorControl.cpp @@ -267,3 +267,276 @@ bool OneMotorControl::getMotorsConnectionStatus() { 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)), this, SLOT(display_x_loc(std::vector))); + 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)), this, SLOT(display_motors_connectivity(std::vector))); + + 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)), this, SLOT(display_x_loc(std::vector))); + + 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)), this, SLOT(display_motors_connectivity(std::vector))); + + m_motorThread.start(); + emit testConnectivitySignal(0, 1000); +} + +void OneMotorControl_LiftingPlatform::display_x_loc(std::vector 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 connectivity) +{ + //std::cout << "-----------------------------------"<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() +{ + if (m_coordinator)//当高光谱相机停止采集后,马达还未回到原点时,上次任务的m_coordinator还没有被销毁 + { + onSequenceComplete(0); + } + +} + +void OneMotorControl_LiftingPlatform::stop() +{ + emit stopStepMotionSignal(); +} + +void OneMotorControl_LiftingPlatform::onSequenceComplete(int state) +{ + emit sequenceComplete(); + + disconnect(this, SIGNAL(start(OneMotionCapturePathLine)), m_coordinator, SLOT(startStepMotion(OneMotionCapturePathLine))); + disconnect(this, SIGNAL(stopStepMotionSignal()), m_coordinator, SLOT(stopStepMotion())); + disconnect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete(int))); + + // Use deleteLater() instead of delete: this slot may have been called directly + // from OneMotionCaptureCoordinator's call stack (direct connection), so deleting + // the object here would cause a crash when execution returns to the destroyed object. + m_coordinator->deleteLater(); + m_coordinator = nullptr; +} + +bool OneMotorControl_LiftingPlatform::getMotorsConnectionStatus() +{ + return m_xMotorConnectionStatus; +} diff --git a/HPPA/OneMotorControl.h b/HPPA/OneMotorControl.h index b0abc90..db10314 100644 --- a/HPPA/OneMotorControl.h +++ b/HPPA/OneMotorControl.h @@ -77,3 +77,61 @@ private: 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 loc); + void display_motors_connectivity(std::vector connectivity); + void onxMove2Loc(); + void zeroStart(); + void onx_rangeMeasurement(); + + void onxMotorRight(); + void onxMotorLeft(); + void onxMotorStop(); + + void onSequenceComplete(int state); + +signals: + void moveSignal(int, bool, double, int); + void move2LocSignal(int, double, double, int); + void move2LocSignal(const std::vector, const std::vector, int); + void stopSignal(int); + + void rangeMeasurement(int, double, int); + void zeroStartSignal(int); + void testConnectivitySignal(int, int); + + void start(OneMotionCapturePathLine); + void stopStepMotionSignal(); + + void sequenceComplete(); + + void broadcastLocationSignal(std::vector); + +private: + Ui::OneMotorControl_UI ui; + + QThread m_motorThread; + IrisMultiMotorController* m_multiAxisController = nullptr; + + QPointer m_coordinator; + + bool m_xMotorConnectionStatus = false; +}; diff --git a/HPPA/TimedDataCollectionDataStructures.cpp b/HPPA/TimedDataCollectionDataStructures.cpp index d652ab7..61fdbdf 100644 --- a/HPPA/TimedDataCollectionDataStructures.cpp +++ b/HPPA/TimedDataCollectionDataStructures.cpp @@ -145,6 +145,7 @@ QJsonObject TimedDataCollectionDataStructuresReaderWriter::subTaskToJson(const S obj["depthInfoY"] = subTask.depthInfoY; obj["averageNumberOfTimes"] = subTask.averageNumberOfTimes; obj["percentageOfEffectiveArea"] = subTask.percentageOfEffectiveArea; + obj["depthType"] = subTask.depthType; return obj; } @@ -170,6 +171,7 @@ bool TimedDataCollectionDataStructuresReaderWriter::jsonToSubTask(const QJsonObj subTask.depthInfoY = json["depthInfoY"].toDouble(); subTask.averageNumberOfTimes = json["averageNumberOfTimes"].toInt(); subTask.percentageOfEffectiveArea = json["percentageOfEffectiveArea"].toDouble(); + subTask.depthType = json["depthType"].toInt(); return true; } diff --git a/HPPA/TimedDataCollectionDataStructures.h b/HPPA/TimedDataCollectionDataStructures.h index 084ea91..84c0046 100644 --- a/HPPA/TimedDataCollectionDataStructures.h +++ b/HPPA/TimedDataCollectionDataStructures.h @@ -50,6 +50,7 @@ struct SubTask { int captureIntervalSeconds = 5; // 单反/深度相机用 //任务ObtainingDepthInformation所需的x和y坐标 + int depthType = 0;//0表示植被深度,1表示白板/调焦版深度 double depthInfoX = 0.0; double depthInfoY = 0.0; int averageNumberOfTimes = 1; //任务ObtainingDepthInformation所需的平均次数 diff --git a/HPPA/TwoMotorControl.cpp b/HPPA/TwoMotorControl.cpp index d3eb038..a72c060 100644 --- a/HPPA/TwoMotorControl.cpp +++ b/HPPA/TwoMotorControl.cpp @@ -210,8 +210,10 @@ void TwoMotorControl::onBack2Origin2() 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->setPercentageOfEffectiveArea(percentageOfEffectiveArea); @@ -219,7 +221,8 @@ void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, doub 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, 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); @@ -229,6 +232,18 @@ void TwoMotorControl::run4_ObtainTargetDepthInfo(DepthCameraWindow* window, doub 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() { m_ObtainTargetDepthInfoCoordinator->deleteLater(); diff --git a/HPPA/TwoMotorControl.h b/HPPA/TwoMotorControl.h index c639bf4..4d27bb4 100644 --- a/HPPA/TwoMotorControl.h +++ b/HPPA/TwoMotorControl.h @@ -15,6 +15,8 @@ #include "PathLine.h" +#include "DepthValueLogger.h" + #define PI 3.1415926 class TwoMotorControl : public QDialog, public MotorWindowBase @@ -82,8 +84,9 @@ public Q_SLOTS: void run2(SingleLensReflexCameraWindow* w); 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 saveDepthValue(double depthValue); void onBack2Origin3(); void stop_record(); @@ -120,4 +123,6 @@ private: QThread m_motorThread; IrisMultiMotorController* m_multiAxisController = nullptr; + + int m_depthType; };