2025-09-12 16:21:42 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
#include <QMetaType>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ImagerOperationBase.h"
|
|
|
|
|
|
#include "IrisMultiMotorController.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct PathLine
|
|
|
|
|
|
{
|
|
|
|
|
|
double targetYPosition;
|
|
|
|
|
|
double actualYPosition;
|
|
|
|
|
|
double speedTargetYPosition;
|
|
|
|
|
|
|
|
|
|
|
|
double targetXMinPosition;
|
|
|
|
|
|
double actualXMinPosition;
|
|
|
|
|
|
double speedTargetXMinPosition;
|
|
|
|
|
|
|
|
|
|
|
|
double targetXMaxPosition;
|
|
|
|
|
|
double actualXMaxPosition;
|
|
|
|
|
|
double speedTargetXMaxPosition;
|
|
|
|
|
|
|
|
|
|
|
|
QDateTime timestamp1;//开始航线
|
|
|
|
|
|
QDateTime timestamp2;//开始采集高光谱
|
|
|
|
|
|
QDateTime timestamp3;//结束采集高光谱
|
|
|
|
|
|
|
|
|
|
|
|
PathLine(double targetYPosition_=0, double targetXMinPosition_ = 0, double targetXMaxPosition_ = 0)
|
|
|
|
|
|
: targetYPosition(targetYPosition_), actualYPosition(0), speedTargetYPosition(0),
|
|
|
|
|
|
targetXMinPosition(targetXMinPosition_), actualXMinPosition(0), speedTargetXMinPosition(0),
|
|
|
|
|
|
targetXMaxPosition(targetXMaxPosition_), actualXMaxPosition(0), speedTargetXMaxPosition(0),
|
|
|
|
|
|
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()), timestamp3(QDateTime::currentDateTime()) {}
|
|
|
|
|
|
};
|
|
|
|
|
|
Q_DECLARE_METATYPE(PathLine);
|
|
|
|
|
|
//Q_DECLARE_METATYPE(QVector<PathLine>);
|
|
|
|
|
|
|
|
|
|
|
|
class TwoMotionCaptureCoordinator : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
|
|
|
|
|
QObject* parent = nullptr);
|
|
|
|
|
|
~TwoMotionCaptureCoordinator();
|
|
|
|
|
|
|
|
|
|
|
|
QVector<PathLine> pathLines() const;
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void sequenceComplete(int);//0:所有采集线正常运行完成,1:用户主动取消采集
|
2026-06-04 18:01:22 +08:00
|
|
|
|
void back2OriginSignal();
|
2026-06-11 15:27:02 +08:00
|
|
|
|
void gotoRecordLineNumSignal(int lineNum);
|
2025-09-12 16:21:42 +08:00
|
|
|
|
void startRecordLineNumSignal(int lineNum);
|
|
|
|
|
|
void finishRecordLineNumSignal(int lineNum);
|
|
|
|
|
|
|
|
|
|
|
|
void startRecordHSISignal(int lineNum);
|
|
|
|
|
|
void stopRecordHSISignal(int lineNum);
|
|
|
|
|
|
|
|
|
|
|
|
void errorOccurred(const QString& error);
|
|
|
|
|
|
void moveTo(int, double, double, int);
|
|
|
|
|
|
void moveTo(const std::vector<double>, const std::vector<double>, int);
|
|
|
|
|
|
void stopMotorSignal(int axis);
|
|
|
|
|
|
|
|
|
|
|
|
void recordState(bool state);
|
|
|
|
|
|
|
2026-06-01 16:54:09 +08:00
|
|
|
|
public slots:
|
|
|
|
|
|
void handleCaptureCompleteWhenFrameNumberMeet();
|
|
|
|
|
|
|
2025-09-12 16:21:42 +08:00
|
|
|
|
private slots:
|
|
|
|
|
|
void start(QVector<PathLine> pathLines);
|
|
|
|
|
|
void stop();
|
|
|
|
|
|
void getRecordState();
|
|
|
|
|
|
|
|
|
|
|
|
void handlePositionReached(int motorID, double pos);
|
|
|
|
|
|
void handleError(const QString& error);
|
|
|
|
|
|
|
|
|
|
|
|
void move2LocBeforeStart();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void processNextPathLine();
|
|
|
|
|
|
void startRecordHsi();
|
2026-06-04 18:01:22 +08:00
|
|
|
|
void isBack2Origin();
|
2025-09-12 16:21:42 +08:00
|
|
|
|
void getLocBeforeStart();
|
|
|
|
|
|
double getThre(double targetLoc, double actualLoc);
|
|
|
|
|
|
|
|
|
|
|
|
double getTimeDiffMinutes(QDateTime startTime, QDateTime endTime);
|
|
|
|
|
|
bool savePathLinesToCsv(QString filename= QString());
|
|
|
|
|
|
|
|
|
|
|
|
IrisMultiMotorController* m_motorCtrl;
|
|
|
|
|
|
ImagerOperationBase* m_cameraCtrl=nullptr;
|
|
|
|
|
|
QVector<PathLine> m_pathLines;
|
|
|
|
|
|
mutable QMutex m_dataMutex;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isRunning;
|
2026-06-04 18:01:22 +08:00
|
|
|
|
bool m_isValidCapturing;
|
2025-09-12 16:21:42 +08:00
|
|
|
|
bool m_isMoving2YTargeLoc;
|
|
|
|
|
|
bool m_isMoving2XMin;
|
|
|
|
|
|
bool m_isMoving2XMax;
|
|
|
|
|
|
|
|
|
|
|
|
int m_retryLimit = 3;
|
|
|
|
|
|
int m_retryTimesMoving2YTargeLoc;
|
|
|
|
|
|
int m_retryTimesMoving2XMin;
|
|
|
|
|
|
int m_retryTimesMoving2XMax;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isImagerFrameNumberMeet;//光谱仪帧数限制到了,主动停止采集
|
|
|
|
|
|
std::vector<double> m_locBeforeStart;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isMoving2XStartLoc;
|
|
|
|
|
|
bool m_isMoving2YStartLoc;
|
|
|
|
|
|
|
|
|
|
|
|
int m_numCurrentPathLine;
|
|
|
|
|
|
};
|
2025-09-15 11:18:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct OneMotionCapturePathLine
|
|
|
|
|
|
{
|
|
|
|
|
|
double startPosition;
|
|
|
|
|
|
double stopPosition;
|
|
|
|
|
|
double speedRecord;
|
|
|
|
|
|
double speedBack;
|
|
|
|
|
|
|
|
|
|
|
|
QDateTime timestamp1;//开始
|
|
|
|
|
|
QDateTime timestamp2;//结束
|
|
|
|
|
|
|
|
|
|
|
|
OneMotionCapturePathLine()
|
|
|
|
|
|
: startPosition(0), stopPosition(0), speedRecord(0), speedBack(0),
|
|
|
|
|
|
timestamp1(QDateTime::currentDateTime()), timestamp2(QDateTime::currentDateTime()) {}
|
|
|
|
|
|
};
|
|
|
|
|
|
Q_DECLARE_METATYPE(OneMotionCapturePathLine);
|
|
|
|
|
|
|
|
|
|
|
|
class OneMotionCaptureCoordinator : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
OneMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
|
|
|
|
|
ImagerOperationBase* cameraCtrl,
|
|
|
|
|
|
QObject* parent = nullptr);
|
|
|
|
|
|
~OneMotionCaptureCoordinator();
|
|
|
|
|
|
|
|
|
|
|
|
bool saveToCsv(const QString& filename);
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
void startStepMotion(OneMotionCapturePathLine pathLine);
|
|
|
|
|
|
void stopStepMotion();
|
|
|
|
|
|
|
|
|
|
|
|
void handleCaptureCompleteWhenFrameNumberMeet();
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
2026-07-22 18:29:20 +08:00
|
|
|
|
void sequenceComplete_cam_stop_before_motorback(int);
|
2025-09-15 11:18:38 +08:00
|
|
|
|
void sequenceComplete(int);
|
|
|
|
|
|
void errorOccurred(const QString& error);
|
|
|
|
|
|
void moveTo(int, double, double, int);
|
|
|
|
|
|
void moveSignal(int, bool, double, int);
|
|
|
|
|
|
void stopMotorSignal(int axis);
|
|
|
|
|
|
|
|
|
|
|
|
void startRecordHSISignal();
|
|
|
|
|
|
void stopRecordHSISignal();
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void handleMotorStoped(int motorID, double pos);
|
|
|
|
|
|
void handleCaptureComplete(double index);
|
|
|
|
|
|
void handleError(const QString& error);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
IrisMultiMotorController* m_motorCtrl;
|
|
|
|
|
|
ImagerOperationBase* m_cameraCtrl;
|
|
|
|
|
|
OneMotionCapturePathLine m_pathLine;
|
|
|
|
|
|
mutable QMutex m_dataMutex;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isRunning;
|
2026-07-22 18:29:20 +08:00
|
|
|
|
bool m_isHypercamStopRecord = false;
|
2025-09-15 11:18:38 +08:00
|
|
|
|
|
|
|
|
|
|
std::vector<double> m_locBeforeStart;
|
|
|
|
|
|
void getLocBeforeStart();
|
|
|
|
|
|
void move2LocBeforeStart();
|
2025-09-22 15:32:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class DarkAndWhiteCaptureCoordinator : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
DarkAndWhiteCaptureCoordinator(int model, IrisMultiMotorController* motorCtrl,
|
|
|
|
|
|
ImagerOperationBase* cameraCtrl,
|
|
|
|
|
|
QObject* parent = nullptr);
|
|
|
|
|
|
~DarkAndWhiteCaptureCoordinator();
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
void startStepMotion(double speed);
|
|
|
|
|
|
|
|
|
|
|
|
void handleCaptureCompleteWhenFrameNumberMeet();
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void sequenceComplete(int);
|
|
|
|
|
|
void moveTo(int, double, double, int);
|
|
|
|
|
|
void moveSignal(int, bool, double, int);
|
|
|
|
|
|
void stopMotorSignal(int axis);
|
|
|
|
|
|
|
|
|
|
|
|
void startRecordHSISignal();
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void handleMotorStoped(int motorID, double pos);
|
|
|
|
|
|
void handleCaptureComplete(double index);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
IrisMultiMotorController* m_motorCtrl;
|
|
|
|
|
|
ImagerOperationBase* m_cameraCtrl;
|
|
|
|
|
|
mutable QMutex m_dataMutex;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isRunning;
|
|
|
|
|
|
|
|
|
|
|
|
double m_speed;
|
|
|
|
|
|
int m_model;//0:dark,1:white
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<double> m_locBeforeStart;
|
|
|
|
|
|
void getLocBeforeStart();
|
|
|
|
|
|
void move2LocBeforeStart();
|
|
|
|
|
|
};
|
2026-08-06 13:42:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TwoMotor1PosCoordinator : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
public:
|
|
|
|
|
|
TwoMotor1PosCoordinator(IrisMultiMotorController* motorCtrl,
|
|
|
|
|
|
QObject* parent = nullptr);
|
|
|
|
|
|
~TwoMotor1PosCoordinator();
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
void moveToTarget(double xTarget, double yTarget, double xSpeed, double ySpeed);
|
|
|
|
|
|
void back2origin();
|
|
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void ArrivalSignal(double xPos, double yPos);
|
|
|
|
|
|
void back2OriginSignal();
|
|
|
|
|
|
void errorOccurred(const QString& error);
|
|
|
|
|
|
void moveTo(int, double, double, int);
|
|
|
|
|
|
void moveTo(const std::vector<double>, const std::vector<double>, int);
|
|
|
|
|
|
void stopMotorSignal(int axis);
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
|
void handlePositionReached(int motorID, double pos);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void moveToTargetPrivate(double xTarget, double yTarget, double xSpeed, double ySpeed);
|
|
|
|
|
|
double getErrorRate(double targetLoc, double actualLoc);
|
|
|
|
|
|
bool checkArrival();
|
|
|
|
|
|
void move2Origin();
|
|
|
|
|
|
|
|
|
|
|
|
IrisMultiMotorController* m_motorCtrl;
|
|
|
|
|
|
mutable QMutex m_dataMutex;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_isMoving2Target;
|
|
|
|
|
|
bool m_isMoving2Origin;
|
|
|
|
|
|
|
|
|
|
|
|
double m_targetX;
|
|
|
|
|
|
double m_targetY;
|
|
|
|
|
|
double m_speedX;
|
|
|
|
|
|
double m_speedY;
|
|
|
|
|
|
|
|
|
|
|
|
double m_actualX;
|
|
|
|
|
|
double m_actualY;
|
|
|
|
|
|
|
|
|
|
|
|
int m_retryLimit = 3;
|
|
|
|
|
|
int m_retryTimesX;
|
|
|
|
|
|
int m_retryTimesY;
|
|
|
|
|
|
|
|
|
|
|
|
bool m_xReached;
|
|
|
|
|
|
bool m_yReached;
|
|
|
|
|
|
};
|
2026-08-12 15:13:24 +08:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
};
|