- 删除订单启动、暂停、复位相关 PLC 握手及无效反馈配置 - 清除报警改为仅写 clearAlarmCommand,不等待反馈 - 将拍照位移动、视觉处理和 RackPick 拆分为三个独立动作 - 增加 M850/M851 拍照位动作及 R60/M852 视觉结果流程 - 暂停改为等待当前机器人动作完成,视觉结果不确定时转人工确认 - 删除复位按钮,合并为恢复/重试按钮 - 普通 PAUSED 订单通过启动按钮继续 - 恢复前检查 PLC、安全状态、订单及动作命令反馈 - 支持在途动作接管、已完成动作收尾、安全重试和人工确认 - 故障状态保持订单 RUNNING,并持久化实际恢复阶段 - 恢复成功后仅清除本次软件故障对应的报警 - 更新小轴 PLC 地址、Modbus 配置和视觉集成文档
148 lines
4.4 KiB
C++
148 lines
4.4 KiB
C++
#include "productionworker.h"
|
|
|
|
ProductionWorker::ProductionWorker(QObject *parent)
|
|
: QObject(parent)
|
|
, m_service(nullptr)
|
|
, m_stopRequested(false)
|
|
{
|
|
}
|
|
|
|
void ProductionWorker::ensureService()
|
|
{
|
|
if (m_service) {
|
|
return;
|
|
}
|
|
|
|
m_service = new ProductionService(this);
|
|
m_service->setExternalStopFlag(&m_stopRequested);
|
|
connect(m_service, &ProductionService::visionMeasureRequested, this, &ProductionWorker::visionMeasureRequested);
|
|
connect(m_service, &ProductionService::visionCancelRequested, this, &ProductionWorker::visionCancelRequested);
|
|
connect(m_service, &ProductionService::visionCycleChanged, this, &ProductionWorker::visionCycleChanged);
|
|
connect(m_service, &ProductionService::visionProductionActiveChanged, this, &ProductionWorker::visionProductionActiveChanged);
|
|
connect(m_service, &ProductionService::stateChanged,
|
|
this, &ProductionWorker::stateChanged);
|
|
connect(m_service, &ProductionService::deviceStatusChanged,
|
|
this, &ProductionWorker::deviceStatusChanged);
|
|
connect(m_service, &ProductionService::deviceCommunicationError,
|
|
this, &ProductionWorker::deviceCommunicationError);
|
|
connect(m_service, &ProductionService::currentWorkpieceChanged,
|
|
this, &ProductionWorker::currentWorkpieceChanged);
|
|
connect(m_service, &ProductionService::currentWorkpieceSnapshotChanged,
|
|
this, &ProductionWorker::currentWorkpieceSnapshotChanged);
|
|
connect(m_service, &ProductionService::currentPositionChanged,
|
|
this, &ProductionWorker::currentPositionChanged);
|
|
connect(m_service, &ProductionService::productionFinished,
|
|
this, &ProductionWorker::productionFinished);
|
|
connect(m_service, &ProductionService::productionError,
|
|
this, &ProductionWorker::productionError);
|
|
connect(m_service, &ProductionService::alarmRaised,
|
|
this, &ProductionWorker::alarmRaised);
|
|
connect(m_service, &ProductionService::processElapsedChanged,
|
|
this, &ProductionWorker::processElapsedChanged);
|
|
connect(m_service, &ProductionService::timeoutWarning,
|
|
this, &ProductionWorker::timeoutWarning);
|
|
connect(m_service, &ProductionService::timeoutRecoveryRequired,
|
|
this, &ProductionWorker::timeoutRecoveryRequired);
|
|
connect(m_service, &ProductionService::recoveryCompleted,
|
|
this, &ProductionWorker::recoveryCompleted);
|
|
}
|
|
|
|
void ProductionWorker::requestStopImmediate()
|
|
{
|
|
m_stopRequested.store(true);
|
|
}
|
|
|
|
void ProductionWorker::updateVisionAvailability(bool ready, bool busy, const QString &session)
|
|
{
|
|
ensureService();
|
|
m_service->onVisionAvailability(ready, busy, session);
|
|
}
|
|
|
|
void ProductionWorker::receiveVisionResult(const QJsonObject &result)
|
|
{
|
|
ensureService();
|
|
m_service->onVisionResult(result);
|
|
}
|
|
|
|
void ProductionWorker::requestVisionSnapshot()
|
|
{
|
|
ensureService();
|
|
m_service->publishVisionSnapshot();
|
|
}
|
|
|
|
void ProductionWorker::reportFailure(bool success, const QString &error)
|
|
{
|
|
if (!success && !error.isEmpty()) {
|
|
emit productionError(error);
|
|
}
|
|
}
|
|
|
|
void ProductionWorker::requestStart(int orderId)
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->start(orderId, &error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestPause()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->pause(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestResume()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->resume(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestStop()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->stop(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestClearAlarm()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->clearAlarm(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestRecover()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->recover(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestMarkNg()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->markCurrentWorkpieceNg(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestRestore()
|
|
{
|
|
ensureService();
|
|
QString error;
|
|
reportFailure(m_service->restoreActiveRun(&error), error);
|
|
}
|
|
|
|
void ProductionWorker::requestShutdown()
|
|
{
|
|
ensureService();
|
|
m_service->shutdown(
|
|
[this](bool success, const QString &error) {
|
|
if (!success) {
|
|
reportFailure(false, error);
|
|
return;
|
|
}
|
|
emit shutdownReady();
|
|
});
|
|
}
|