添加管控软件和相机的通讯
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
#include <atomic>
|
||||
|
||||
class QTimer;
|
||||
@@ -67,8 +68,14 @@ public:
|
||||
bool restoreActiveRun(QString *error = nullptr);
|
||||
void shutdown(const DeviceService::OperationCallback &callback);
|
||||
void setExternalStopFlag(std::atomic_bool *flag);
|
||||
void setExternalPauseFlag(std::atomic_bool *flag);
|
||||
void requestStopImmediate();
|
||||
|
||||
public slots:
|
||||
void onVisionAvailability(bool ready, bool busy, const QString &session);
|
||||
void onVisionResult(const QJsonObject &result);
|
||||
void publishVisionSnapshot();
|
||||
|
||||
signals:
|
||||
void stateChanged(ProductionService::State state, const QString &name);
|
||||
void deviceStatusChanged(const DeviceStatus &status);
|
||||
@@ -83,6 +90,10 @@ signals:
|
||||
void timeoutWarning(const QString &state, int elapsedMs, int timeoutMs);
|
||||
void timeoutRecoveryRequired(const QString &state, const QString &message);
|
||||
void recoveryCompleted(const QString &mode);
|
||||
void visionMeasureRequested(const QJsonObject &request);
|
||||
void visionCancelRequested(const QString &requestId);
|
||||
void visionCycleChanged(const QJsonObject &cycle);
|
||||
void visionProductionActiveChanged(bool active);
|
||||
|
||||
private slots:
|
||||
void tick();
|
||||
@@ -91,8 +102,28 @@ private slots:
|
||||
|
||||
public:
|
||||
explicit ProductionService(QObject *parent = nullptr);
|
||||
~ProductionService() override;
|
||||
|
||||
private:
|
||||
friend class VisionProductionTest;
|
||||
enum class VisionStage {
|
||||
Idle, Preflight, Armed, WaitRequest, SettingBusy, ReadingPose,
|
||||
Measuring, WritingPose, Publishing, WaitAck, WaitReset, Clearing,
|
||||
Complete, Fault
|
||||
};
|
||||
bool requiresVision(DeviceService::ProductionAction action) const;
|
||||
void prepareVision();
|
||||
void advanceVision();
|
||||
void handleVisionHandshake(const VisionHandshake &handshake);
|
||||
void beginVisionMeasurement();
|
||||
void clearVisionOutputs(int index, quint64 generation);
|
||||
bool visionCurrent(quint64 generation) const;
|
||||
void setVisionStage(VisionStage stage, const QString &message);
|
||||
void reportVision(const QString &phase, const QString &message, bool invalidated = false);
|
||||
void invalidateVision(const QString &reason);
|
||||
void visionFault(const QString &reason, bool reportComparisonError = false);
|
||||
bool recoverVision(QString *error);
|
||||
void resetVisionForRecovery(int index, quint64 generation);
|
||||
ProductionService(const ProductionService &) = delete;
|
||||
ProductionService &operator=(const ProductionService &) = delete;
|
||||
|
||||
@@ -180,6 +211,25 @@ private:
|
||||
std::atomic_bool *m_externalStopRequested;
|
||||
bool m_shutdownRequested;
|
||||
DeviceService::OperationCallback m_shutdownCallback;
|
||||
VisionStage m_visionStage = VisionStage::Idle;
|
||||
QElapsedTimer m_visionTimer;
|
||||
QJsonObject m_visionRequest;
|
||||
QJsonObject m_visionResult;
|
||||
quint64 m_visionGeneration = 0;
|
||||
int m_visionWorkpieceId = 0;
|
||||
int m_visionTrayNo = 0;
|
||||
QString m_visionSession;
|
||||
QString m_availableVisionSession;
|
||||
bool m_visionReady = false;
|
||||
bool m_visionBusy = false;
|
||||
bool m_visionIoPending = false;
|
||||
bool m_visionSuspended = false;
|
||||
bool m_visionCommitStarted = false;
|
||||
bool m_visionNeedsReconcile = false;
|
||||
bool m_visionRecoveryChecking = false;
|
||||
bool m_visionFaultCleanupPending = false;
|
||||
QString m_visionRecoverySession;
|
||||
std::atomic_bool *m_externalPauseRequested = nullptr;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(ProductionService::State)
|
||||
|
||||
Reference in New Issue
Block a user