211 lines
5.5 KiB
C++
211 lines
5.5 KiB
C++
#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,
|
||
ImagerOperationBase* cameraCtrl,
|
||
QObject* parent = nullptr);
|
||
TwoMotionCaptureCoordinator(IrisMultiMotorController* motorCtrl,
|
||
QObject* parent = nullptr);
|
||
~TwoMotionCaptureCoordinator();
|
||
|
||
QVector<PathLine> pathLines() const;
|
||
|
||
signals:
|
||
void sequenceComplete(int);//0:所有采集线正常运行完成,1:用户主动取消采集
|
||
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);
|
||
|
||
private slots:
|
||
void start(QVector<PathLine> pathLines);
|
||
void stop();
|
||
void getRecordState();
|
||
|
||
void handlePositionReached(int motorID, double pos);
|
||
void handleCaptureCompleteWhenFrameNumberMeet();
|
||
void handleError(const QString& error);
|
||
|
||
void move2LocBeforeStart();
|
||
|
||
private:
|
||
void processNextPathLine();
|
||
void startRecordHsi();
|
||
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;
|
||
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;
|
||
};
|
||
|
||
|
||
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:
|
||
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;
|
||
|
||
std::vector<double> m_locBeforeStart;
|
||
void getLocBeforeStart();
|
||
void move2LocBeforeStart();
|
||
};
|
||
|
||
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();
|
||
};
|