订单流程修改--QThread事件循环导致的逻辑修改
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
ProductionWorker::ProductionWorker(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_service(nullptr)
|
||||
, m_stopRequested(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -13,8 +14,13 @@ void ProductionWorker::ensureService()
|
||||
}
|
||||
|
||||
m_service = new ProductionService(this);
|
||||
m_service->setExternalStopFlag(&m_stopRequested);
|
||||
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,
|
||||
@@ -37,6 +43,11 @@ void ProductionWorker::ensureService()
|
||||
this, &ProductionWorker::recoveryCompleted);
|
||||
}
|
||||
|
||||
void ProductionWorker::requestStopImmediate()
|
||||
{
|
||||
m_stopRequested.store(true);
|
||||
}
|
||||
|
||||
void ProductionWorker::reportFailure(bool success, const QString &error)
|
||||
{
|
||||
if (!success && !error.isEmpty()) {
|
||||
@@ -79,6 +90,13 @@ void ProductionWorker::requestReset()
|
||||
reportFailure(m_service->reset(&error), error);
|
||||
}
|
||||
|
||||
void ProductionWorker::requestClearAlarm()
|
||||
{
|
||||
ensureService();
|
||||
QString error;
|
||||
reportFailure(m_service->clearAlarm(&error), error);
|
||||
}
|
||||
|
||||
void ProductionWorker::requestRecover()
|
||||
{
|
||||
ensureService();
|
||||
@@ -106,3 +124,16 @@ void ProductionWorker::requestRestore()
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user