修改:

分离TwoMotionCaptureCoordinator和ImagerOperationBase
This commit is contained in:
tangchao0503
2026-06-01 16:54:09 +08:00
parent 6456232114
commit 4d42314a84
4 changed files with 19 additions and 46 deletions

View File

@ -2,11 +2,9 @@
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator( TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
IrisMultiMotorController* motorCtrl, IrisMultiMotorController* motorCtrl,
ImagerOperationBase* cameraCtrl,
QObject* parent) QObject* parent)
: QObject(parent) : QObject(parent)
, m_motorCtrl(motorCtrl) , m_motorCtrl(motorCtrl)
, m_cameraCtrl(cameraCtrl)
, m_isRunning(false) , m_isRunning(false)
{ {
//这些信号槽是按照逻辑顺序的 //这些信号槽是按照逻辑顺序的
@ -20,35 +18,6 @@ TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
this, &TwoMotionCaptureCoordinator::handlePositionReached); this, &TwoMotionCaptureCoordinator::handlePositionReached);
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed, //connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
// this, &TwoMotionCaptureCoordinator::handleError); // this, &TwoMotionCaptureCoordinator::handleError);
connect(this, &TwoMotionCaptureCoordinator::startRecordHSISignal,
m_cameraCtrl, &ImagerOperationBase::start_record);
connect(this, &TwoMotionCaptureCoordinator::stopRecordHSISignal,
m_cameraCtrl, &ImagerOperationBase::stop_record);
connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet,
this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
//connect(m_cameraCtrl, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberNotMeet,
// this, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberNotMeet);
//connect(m_cameraCtrl, &ImagerOperationBase::captureFailed,
// this, &TwoMotionCaptureCoordinator::handleError);
}
TwoMotionCaptureCoordinator::TwoMotionCaptureCoordinator(
IrisMultiMotorController* motorCtrl,
QObject* parent)
: QObject(parent)
, m_motorCtrl(motorCtrl)
, m_isRunning(false)
{
connect(this, SIGNAL(moveTo(int, double, double, int)),
m_motorCtrl, SLOT(moveTo(int, double, double, int)));
connect(this, SIGNAL(moveTo(const std::vector<double>, const std::vector<double>, int)),
m_motorCtrl, SLOT(moveTo(const std::vector<double>, const std::vector<double>, int)));
connect(m_motorCtrl, &IrisMultiMotorController::motorStopSignal,
this, &TwoMotionCaptureCoordinator::handlePositionReached);
//connect(m_motorCtrl, &IrisMultiMotorController::moveFailed,
// this, &TwoMotionCaptureCoordinator::handleError);
} }
TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator() TwoMotionCaptureCoordinator::~TwoMotionCaptureCoordinator()
@ -98,11 +67,7 @@ void TwoMotionCaptureCoordinator::stop()
savePathLinesToCsv(); savePathLinesToCsv();
emit finishRecordLineNumSignal(m_numCurrentPathLine); emit finishRecordLineNumSignal(m_numCurrentPathLine);
//emit stopRecordHSISignal(m_numCurrentPathLine); emit stopRecordHSISignal(m_numCurrentPathLine);
if (m_cameraCtrl != nullptr)
{
m_cameraCtrl->stop_record();
}
move2LocBeforeStart(); move2LocBeforeStart();
@ -324,11 +289,7 @@ void TwoMotionCaptureCoordinator::handlePositionReached(int motorID, double pos)
//停止采集高光谱数据 //停止采集高光谱数据
emit finishRecordLineNumSignal(m_numCurrentPathLine); emit finishRecordLineNumSignal(m_numCurrentPathLine);
//emit stopRecordHSISignal(m_numCurrentPathLine); emit stopRecordHSISignal(m_numCurrentPathLine);
if (m_cameraCtrl!=nullptr)
{
m_cameraCtrl->stop_record();
}
m_isMoving2XMax = false; m_isMoving2XMax = false;
m_isImagerFrameNumberMeet = false; m_isImagerFrameNumberMeet = false;

View File

@ -38,9 +38,6 @@ class TwoMotionCaptureCoordinator : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
ImagerOperationBase* cameraCtrl,
QObject* parent = nullptr);
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl, TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
QObject* parent = nullptr); QObject* parent = nullptr);
~TwoMotionCaptureCoordinator(); ~TwoMotionCaptureCoordinator();
@ -62,13 +59,15 @@ signals:
void recordState(bool state); void recordState(bool state);
public slots:
void handleCaptureCompleteWhenFrameNumberMeet();
private slots: private slots:
void start(QVector<PathLine> pathLines); void start(QVector<PathLine> pathLines);
void stop(); void stop();
void getRecordState(); void getRecordState();
void handlePositionReached(int motorID, double pos); void handlePositionReached(int motorID, double pos);
void handleCaptureCompleteWhenFrameNumberMeet();
void handleError(const QString& error); void handleError(const QString& error);
void move2LocBeforeStart(); void move2LocBeforeStart();

View File

@ -121,14 +121,20 @@ void TwoMotorControl::run()
} }
qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>"); qRegisterMetaType<QVector<PathLine>>("QVector<PathLine>");
m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController, m_Imager); m_coordinator = new TwoMotionCaptureCoordinator(m_multiAxisController);
m_coordinator->moveToThread(&m_coordinatorThread); m_coordinator->moveToThread(&m_coordinatorThread);
connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater())); connect(&m_coordinatorThread, SIGNAL(finished()), m_coordinator, SLOT(deleteLater()));
connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>))); connect(this, SIGNAL(start(QVector<PathLine>)), m_coordinator, SLOT(start(QVector<PathLine>)));
connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop())); connect(this, SIGNAL(stopSignal()), m_coordinator, SLOT(stop()));
connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int))); connect(m_coordinator, SIGNAL(startRecordLineNumSignal(int)), this, SLOT(receiveStartRecordLineNum(int)));
connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int))); connect(m_coordinator, SIGNAL(finishRecordLineNumSignal(int)), this, SLOT(receiveFinishRecordLineNum(int)));
connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete())); connect(m_coordinator, SIGNAL(sequenceComplete(int)), this, SLOT(onSequenceComplete()));
connect(m_coordinator, &TwoMotionCaptureCoordinator::startRecordHSISignal, m_Imager, &ImagerOperationBase::start_record);
connect(m_coordinator, &TwoMotionCaptureCoordinator::stopRecordHSISignal, this, &TwoMotorControl::stop_record);
connect(m_Imager, &ImagerOperationBase::RecordFinishedSignal_WhenFrameNumberMeet, m_coordinator, &TwoMotionCaptureCoordinator::handleCaptureCompleteWhenFrameNumberMeet);
m_coordinatorThread.start(); m_coordinatorThread.start();
QVector<PathLine> pathLines; QVector<PathLine> pathLines;
@ -158,6 +164,11 @@ void TwoMotorControl::run()
emit start(pathLines); emit start(pathLines);
} }
void TwoMotorControl::stop_record()
{
m_Imager->stop_record();
}
void TwoMotorControl::stop() void TwoMotorControl::stop()
{ {
emit stopSignal(); emit stopSignal();

View File

@ -70,6 +70,8 @@ public Q_SLOTS:
void receiveFinishRecordLineNum(int lineNum); void receiveFinishRecordLineNum(int lineNum);
void onSequenceComplete(); void onSequenceComplete();
void stop_record();
signals: signals:
void moveSignal(int, bool, double, int); void moveSignal(int, bool, double, int);
void move2LocSignal(int, double, double, int); void move2LocSignal(int, double, double, int);