feat(production): 持久化动作检查点并完善恢复重试流程
- production_runs 新增动作阶段、尝试次数、版本及人工确认字段 - 提供兼容 PostgreSQL 9.5 的幂等升级脚本和数据库结构检查 - 工序推进、动作完成检查点和审计记录使用同一事务 - 机器人命令单次发送,完成反馈先持久化再清握手 - 已完成动作恢复仅补握手或数据库记录,避免重复执行 - 恢复/重试按钮固定显示在清除报警前,加入明确人工处理选项 - 记录人工决定、操作人及现场核对信息,拒绝过期确认 - 区分普通暂停继续、故障恢复与终止后的视觉锁解除 - 补齐视觉目标跨重启校验、异步失败及迟到回调防护 - 检测结果关联动作和尝试次数,重试清除旧结果缓存
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "deviceservice.h"
|
||||
|
||||
#include "../models/workpiece.h"
|
||||
#include "../repositories/productionrepository.h"
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QObject>
|
||||
@@ -64,6 +65,7 @@ public:
|
||||
bool stop(QString *error = nullptr);
|
||||
bool clearAlarm(QString *error = nullptr);
|
||||
bool recover(QString *error = nullptr);
|
||||
bool submitRecoveryDecision(const QJsonObject &decision, QString *error = nullptr);
|
||||
bool markCurrentWorkpieceNg(QString *error = nullptr);
|
||||
bool restoreActiveRun(QString *error = nullptr);
|
||||
void shutdown(const DeviceService::OperationCallback &callback);
|
||||
@@ -89,6 +91,8 @@ signals:
|
||||
void timeoutWarning(const QString &state, int elapsedMs, int timeoutMs);
|
||||
void timeoutRecoveryRequired(const QString &state, const QString &message);
|
||||
void recoveryCompleted(const QString &mode);
|
||||
void recoveryDecisionRequired(const QJsonObject &context);
|
||||
void recoveryBusyChanged(bool busy);
|
||||
void visionMeasureRequested(const QJsonObject &request);
|
||||
void visionCancelRequested(const QString &requestId);
|
||||
void visionCycleChanged(const QJsonObject &cycle);
|
||||
@@ -118,14 +122,29 @@ private:
|
||||
void reportVision(const QString &phase, const QString &message, bool invalidated = false);
|
||||
void invalidateVision(const QString &reason);
|
||||
void visionFault(const QString &reason);
|
||||
bool recoverVision(QString *error);
|
||||
void publishVisionControl();
|
||||
bool saveVisionRecoveryState(bool pending, QString *error);
|
||||
void loadVisionRecoveryState();
|
||||
ProductionService(const ProductionService &) = delete;
|
||||
ProductionService &operator=(const ProductionService &) = delete;
|
||||
|
||||
void setState(State state);
|
||||
bool setState(State state);
|
||||
QString actionTypeForState(State state) const;
|
||||
QString nextStepForState(State state) const;
|
||||
bool ensureActionCheckpoint(State state, QString *error);
|
||||
bool saveActionPhase(const QString &phase, QString *error);
|
||||
bool saveActionCompletion(ProductionActionCheckpoint *action,
|
||||
const QString &nextStep, int nextWorkpieceId,
|
||||
QString *error);
|
||||
bool actionCallbackCurrent(quint64 generation, const QString &token, int attempt) const;
|
||||
bool loadRecoverySnapshot(QString *error);
|
||||
void finishRecoveryCheck(const QString &error = QString());
|
||||
void requestManualDecision(State state, const ProductionActionStatus &status,
|
||||
const QString &reason, const QStringList &options);
|
||||
void resumeRecoveredState(State state);
|
||||
bool saveManualDecision(const QJsonObject &decision, QString *error);
|
||||
void checkVisionRecovery(const QJsonObject &decision = QJsonObject());
|
||||
bool pickTargetValid() const;
|
||||
bool claimNextWorkpiece(QString *error);
|
||||
bool updateCurrentProcessStep(const QString &processStep, QString *error,
|
||||
bool forceRestart = false);
|
||||
@@ -157,7 +176,6 @@ private:
|
||||
QString resultStateForRawResult(int rawResult) const;
|
||||
bool ensureOrderRunning(QString *error);
|
||||
bool checkRecoverySafety(QString *error) const;
|
||||
bool mapPlcStepToState(State *state, QString *processStep) const;
|
||||
void startProcessTimer(const QString &processStep);
|
||||
void pauseProcessTimer();
|
||||
void resumeProcessTimer();
|
||||
@@ -199,18 +217,31 @@ private:
|
||||
bool m_actionStarting;
|
||||
bool m_actionPollPending;
|
||||
bool m_actionCompleted;
|
||||
bool m_actionWasSent;
|
||||
QString m_actionError;
|
||||
bool m_actionCancelRequested;
|
||||
DeviceService::OperationCallback m_deferredCancelCallback;
|
||||
bool m_inspectionStatusPending;
|
||||
bool m_inspectionStatusReady;
|
||||
int m_inspectionRawResult = 0;
|
||||
QString m_inspectionStatusError;
|
||||
bool m_starting;
|
||||
bool m_plcStarted;
|
||||
bool m_tickRunning;
|
||||
bool m_pauseAfterCurrentAction;
|
||||
bool m_recoveryCheckPending;
|
||||
quint64 m_actionGeneration = 0;
|
||||
quint64 m_recoveryGeneration = 0;
|
||||
ProductionActionCheckpoint m_checkpoint;
|
||||
QJsonObject m_manualContext;
|
||||
bool m_recoveryKeepPaused = false;
|
||||
bool m_recoveryIdleUnlock = false;
|
||||
bool m_targetReady = false;
|
||||
int m_targetWorkpieceId = 0;
|
||||
QString m_targetSession;
|
||||
bool m_targetUsesVision = false;
|
||||
bool m_forceNormalPick = false;
|
||||
bool m_restoredRun = false;
|
||||
bool m_persistenceUncertain = false;
|
||||
DeviceService::ProductionAction m_pendingAction;
|
||||
QString m_inspectionMode;
|
||||
QString m_frontResultState;
|
||||
@@ -235,8 +266,6 @@ private:
|
||||
bool m_visionSuspended = false;
|
||||
bool m_visionCommitStarted = false;
|
||||
bool m_visionNeedsReconcile = false;
|
||||
bool m_visionRecoveryChecking = false;
|
||||
bool m_visionFaultCleanupPending = false;
|
||||
QString m_visionStatePath;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user