diff --git a/HPPA/HPPA.cpp b/HPPA/HPPA.cpp index 23f0ac0..aef6536 100644 --- a/HPPA/HPPA.cpp +++ b/HPPA/HPPA.cpp @@ -602,10 +602,17 @@ void HPPA::initTimedDataCollection() connect(mTimedDataCollectionWindow, &TimedDataCollection::motorParm, this, &HPPA::setTimedDataCollectionMotorParm); connect(mTimedDataCollectionWindow, &TimedDataCollection::startRecordSignal, this, &HPPA::onStartTimedDataCollection); + connect(mTimedDataCollectionWindow, &TimedDataCollection::switchHalogenLampSignal, m_pc3D, &PowerControl3D::switchHalogenLampPower); + connect(mTimedDataCollectionWindow, &TimedDataCollection::switchD65LampSignal, m_pc3D, &PowerControl3D::switchD65LampPower); + connect(mTimedDataCollectionWindow, &TimedDataCollection::switchSlrSignal, m_pc3D, &PowerControl3D::switchSlrPower); + // 相机/马达 → 定时采集控制器 connect(m_tmc, &TwoMotorControl::sequenceComplete, mTimedDataCollectionWindow, &TimedDataCollection::subTaskCompleted); connect(m_tmc, &TwoMotorControl::back2OriginSignal_TimedDataCollection, mTimedDataCollectionWindow, &TimedDataCollection::onBack2Origin); + //电源控制m_pc3D + + //连接马达控制和单反/深度 } @@ -652,6 +659,10 @@ void HPPA::setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds { case 2: { + //唤醒单反相机 + m_pc3D->slrPowerDown(); + m_pc3D->slrPowerOn(); + m_singleLensReflexCameraWindow->setDataFolder(folder); m_singleLensReflexCameraWindow->setCaptureInterval(captureIntervalSeconds); @@ -659,6 +670,8 @@ void HPPA::setTimedDataCollectionCamParm(int camType, int captureIntervalSeconds } case 3: { + m_pc3D->d65LampPowerOn(); + m_depthCameraWindow->setDataFolder(folder); m_depthCameraWindow->setCaptureInterval(captureIntervalSeconds); diff --git a/HPPA/PowerControl3D.cpp b/HPPA/PowerControl3D.cpp index ef8b148..7b9c598 100644 --- a/HPPA/PowerControl3D.cpp +++ b/HPPA/PowerControl3D.cpp @@ -43,6 +43,18 @@ void PowerControl3D::halogenLampPowerDown() tcpServer6003->sendCommand(R"({"key1":0,"type":"event"})"); } +void PowerControl3D::switchHalogenLampPower(int state) +{ + if (state==0) + { + halogenLampPowerDown(); + } + else if(state == 1) + { + halogenLampPowerOn(); + } +} + void PowerControl3D::d65LampPowerOn() { tcpServer6004->sendCommand(R"({"key1":1,"type":"event"})"); @@ -53,6 +65,18 @@ void PowerControl3D::d65LampPowerDown() tcpServer6004->sendCommand(R"({"key1":0,"type":"event"})"); } +void PowerControl3D::switchD65LampPower(int state) +{ + if (state == 0) + { + d65LampPowerDown(); + } + else if (state == 1) + { + d65LampPowerOn(); + } +} + void PowerControl3D::slrPowerOn() { tcpServer6003->sendCommand(R"({"key2":1,"type":"event"})"); @@ -62,3 +86,15 @@ void PowerControl3D::slrPowerDown() { tcpServer6003->sendCommand(R"({"key2":0,"type":"event"})"); } + +void PowerControl3D::switchSlrPower(int state) +{ + if (state == 0) + { + slrPowerDown(); + } + else if (state == 1) + { + slrPowerOn(); + } +} diff --git a/HPPA/PowerControl3D.h b/HPPA/PowerControl3D.h index 7a3dee9..44cd754 100644 --- a/HPPA/PowerControl3D.h +++ b/HPPA/PowerControl3D.h @@ -21,12 +21,15 @@ public: public Q_SLOTS: void halogenLampPowerOn(); void halogenLampPowerDown(); + void switchHalogenLampPower(int state); void d65LampPowerOn(); void d65LampPowerDown(); + void switchD65LampPower(int state); void slrPowerOn(); void slrPowerDown(); + void switchSlrPower(int state); signals: //void powerOpened(); diff --git a/HPPA/TimedDataCollection.cpp b/HPPA/TimedDataCollection.cpp index 08dbfbb..ef344d0 100644 --- a/HPPA/TimedDataCollection.cpp +++ b/HPPA/TimedDataCollection.cpp @@ -29,6 +29,10 @@ TimedDataCollection::TimedDataCollection(QWidget* parent) connect(m_scheduler, &TaskScheduler::motorParm, this, &TimedDataCollection::motorParm); connect(m_scheduler, &TaskScheduler::startRecordSignal, this, &TimedDataCollection::startRecordSignal); + connect(m_scheduler, &TaskScheduler::switchHalogenLampSignal, this, &TimedDataCollection::switchHalogenLampSignal); + connect(m_scheduler, &TaskScheduler::switchD65LampSignal, this, &TimedDataCollection::switchD65LampSignal); + connect(m_scheduler, &TaskScheduler::switchSlrSignal, this, &TimedDataCollection::switchSlrSignal); + connect(this, &TimedDataCollection::sequenceCompleteSignal, m_scheduler, &TaskScheduler::sequenceCompleteSignal); connect(this, &TimedDataCollection::Back2OriginSignal, m_scheduler, &TaskScheduler::Back2OriginSignal); diff --git a/HPPA/TimedDataCollection.h b/HPPA/TimedDataCollection.h index 6ea86d8..afc88f9 100644 --- a/HPPA/TimedDataCollection.h +++ b/HPPA/TimedDataCollection.h @@ -38,6 +38,10 @@ Q_SIGNALS: void motorParm(QString pathLineFilePath); void startRecordSignal(int camType); + void switchHalogenLampSignal(int state); + void switchD65LampSignal(int state); + void switchSlrSignal(int state); + // 马达反馈的信号 void sequenceCompleteSignal(int status); void Back2OriginSignal(); diff --git a/HPPA/TimedDataCollectionDataStructures.cpp b/HPPA/TimedDataCollectionDataStructures.cpp index 6d98f3b..21dd35c 100644 --- a/HPPA/TimedDataCollectionDataStructures.cpp +++ b/HPPA/TimedDataCollectionDataStructures.cpp @@ -222,9 +222,12 @@ void TaskExecutor::execute(const TimedTask& task) qDebug() << "TaskExecutor: Starting task" << task.id; - // 开始执行第一个子任务 + // 打开卤素灯预热 + emit switchHalogenLampSignal(1); makeFolder(m_task.savePath); - executeNextSubTask(); + + // 开始执行第一个子任务 + QTimer::singleShot(20*1000, this, &TaskExecutor::executeNextSubTask); } void TaskExecutor::stop() @@ -273,6 +276,42 @@ void TaskExecutor::onSequenceComplete(int status) emit subTaskFinished(m_currentSubTaskIndex, subTask.type, (status == 0)); } + + // + switch (m_task.subTasks[m_currentSubTaskIndex].type) + { + case SubTaskType::SingleLensReflex: + { + emit switchD65LampSignal(0); + break; + } + case SubTaskType::DepthCamera: + { + emit switchD65LampSignal(0); + break; + } + } + + // 判断下一次的任务是否为高光谱任务,如果不是关闭卤素灯 + int nestSubTaskIndex = m_currentSubTaskIndex + 1; + if (nestSubTaskIndex >= m_task.subTasks.size()) + { + emit switchHalogenLampSignal(0); + return; + } + switch (m_task.subTasks[nestSubTaskIndex].type) + { + case SubTaskType::SingleLensReflex: + { + emit switchHalogenLampSignal(0); + break; + } + case SubTaskType::DepthCamera: + { + emit switchHalogenLampSignal(0); + break; + } + } } void TaskExecutor::onBack2Origin() @@ -281,7 +320,7 @@ void TaskExecutor::onBack2Origin() m_currentSubTaskIndex++; if (m_currentSubTaskIndex < m_task.subTasks.size()) { // 执行下一个子任务 - QTimer::singleShot(100, this, &TaskExecutor::executeNextSubTask); + QTimer::singleShot(1000, this, &TaskExecutor::executeNextSubTask); } else { // 所有子任务完成 @@ -325,6 +364,7 @@ void TaskExecutor::executeNextSubTask() { case SubTaskType::HyperSpectual400_1000nm: { + //提前需做:需要打开卤素灯进行预热5分钟,具体的实现方式:通过QTcpServer通讯,ip:192.168.1.2:6003, camType = 0; emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, makeSubTaskDataFolder("L"), "test"); @@ -332,6 +372,7 @@ void TaskExecutor::executeNextSubTask() } case SubTaskType::HyperSpectual1000_1700nm: { + //提前需做:需要打开卤素灯进行预热5分钟 camType = 1; emit hyperCamParm(camType, subTask.frameRate, subTask.exposureTime, makeSubTaskDataFolder("NIR"), "test"); @@ -339,16 +380,24 @@ void TaskExecutor::executeNextSubTask() } case SubTaskType::SingleLensReflex: { + //提前需做:(1)需要打开D65灯(2)需要将单反的电源重新上电 camType = 2; emit camParm(camType, 3, makeSubTaskDataFolder("SLR")); + emit switchD65LampSignal(1); + + QThread::msleep(1000); + break; } case SubTaskType::DepthCamera: { + //提前需做:需要打开D65灯 camType = 3; emit camParm(camType, 3, makeSubTaskDataFolder("DepthCamera")); + emit switchD65LampSignal(1); + break; } } @@ -501,6 +550,10 @@ void TaskScheduler::executeTask(TimedTask& task) connect(m_currentExecutor, &TaskExecutor::startRecordSignal, this, &TaskScheduler::startRecordSignal); + connect(m_currentExecutor, &TaskExecutor::switchHalogenLampSignal, this, &TaskScheduler::switchHalogenLampSignal); + connect(m_currentExecutor, &TaskExecutor::switchD65LampSignal, this, &TaskScheduler::switchD65LampSignal); + connect(m_currentExecutor, &TaskExecutor::switchSlrSignal, this, &TaskScheduler::switchSlrSignal); + connect(this, &TaskScheduler::sequenceCompleteSignal, m_currentExecutor, &TaskExecutor::onSequenceComplete); connect(this, &TaskScheduler::Back2OriginSignal, m_currentExecutor, &TaskExecutor::onBack2Origin); diff --git a/HPPA/TimedDataCollectionDataStructures.h b/HPPA/TimedDataCollectionDataStructures.h index ecab499..d700bb6 100644 --- a/HPPA/TimedDataCollectionDataStructures.h +++ b/HPPA/TimedDataCollectionDataStructures.h @@ -145,6 +145,10 @@ signals: void motorParm(QString pathLineFilePath); void startRecordSignal(int camType); + void switchHalogenLampSignal(int state); + void switchD65LampSignal(int state); + void switchSlrSignal(int state); + public slots: void onSequenceComplete(int status); void onBack2Origin(); @@ -187,11 +191,12 @@ signals: void taskStarted(int taskId); // 任务开始 void taskFinished(int taskId, bool success); // 任务完成 + void schedulerStateChanged(bool running); // 调度器状态变化 + // 子任务的信号 void subTaskStarted(int taskId, int subTaskIndex); // 子任务开始 void subTaskFinished(int taskId, int subTaskIndex); // 子任务完成 void errorOccurred(const QString& error); // 错误发生 - void schedulerStateChanged(bool running); // 调度器状态变化 // 采集相关信号 (透传 TaskExecutor) void hyperCamParm(int camType, double f, double e, QString filePath, QString fileName); @@ -199,6 +204,10 @@ signals: void motorParm(QString pathLineFilePath); void startRecordSignal(int camType); + void switchHalogenLampSignal(int state); + void switchD65LampSignal(int state); + void switchSlrSignal(int state); + // 马达反馈的信号 void sequenceCompleteSignal(int status); void Back2OriginSignal(); diff --git a/HPPA/TwoMotorControl.cpp b/HPPA/TwoMotorControl.cpp index 44174e1..275558d 100644 --- a/HPPA/TwoMotorControl.cpp +++ b/HPPA/TwoMotorControl.cpp @@ -122,6 +122,7 @@ void TwoMotorControl::run2(SingleLensReflexCameraWindow* window) connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::startRecordLineNumSignal, window, &SingleLensReflexCameraWindow::onStartTimedDataCollection); connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::sequenceComplete, window, &SingleLensReflexCameraWindow::onStopTimedDataCollection); + connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::sequenceComplete, this, &TwoMotorControl::sequenceComplete); connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin2); @@ -171,6 +172,7 @@ void TwoMotorControl::run3(DepthCameraWindow* window) connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::startRecordLineNumSignal, window, &DepthCameraWindow::openDepthCamera); connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::sequenceComplete, window, &DepthCameraWindow::closeDepthCamera); + connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::sequenceComplete, this, &TwoMotorControl::sequenceComplete); connect(m_coordinator_TimedDataCollection, &TwoMotionCaptureCoordinator::back2OriginSignal, this, &TwoMotorControl::onBack2Origin2);