订单流程修改--QThread事件循环导致的逻辑修改
This commit is contained in:
+19
-19
@@ -35,7 +35,7 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
, recoverButton(new QPushButton("Recover", this))
|
||||
, retryButton(new QPushButton("Retry", this))
|
||||
, markNgButton(new QPushButton("Mark NG", this))
|
||||
, stopButton(new QPushButton("Stop", this))
|
||||
, stopButton(new QPushButton("Terminate", this))
|
||||
, processBox(new QGroupBox("Process timing", this))
|
||||
, currentProcessLabel(new QLabel("-", processBox))
|
||||
, processElapsedLabel(new QLabel("00:00:00.000", processBox))
|
||||
@@ -54,6 +54,8 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
productionWorker->moveToThread(productionThread);
|
||||
connect(productionThread, &QThread::finished,
|
||||
productionWorker, &QObject::deleteLater);
|
||||
connect(productionWorker, &ProductionWorker::shutdownReady,
|
||||
productionThread, &QThread::quit, Qt::DirectConnection);
|
||||
|
||||
const QList<QLabel *> values = QList<QLabel *>()
|
||||
<< ui->planValue << ui->pendingValue << ui->frontValue
|
||||
@@ -184,15 +186,18 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
this, &DashboardPage::onTimeoutRecoveryRequired);
|
||||
connect(productionWorker, &ProductionWorker::recoveryCompleted,
|
||||
this, &DashboardPage::onRecoveryCompleted);
|
||||
connect(&DeviceService::instance(), &DeviceService::statusChanged,
|
||||
connect(productionWorker, &ProductionWorker::deviceStatusChanged,
|
||||
this, &DashboardPage::onDeviceStatusChanged);
|
||||
connect(productionWorker, &ProductionWorker::deviceCommunicationError,
|
||||
this, [this](const QString &error) {
|
||||
emit deviceCommunicationError(error);
|
||||
});
|
||||
|
||||
productionThread->start();
|
||||
QMetaObject::invokeMethod(productionWorker, "requestRestore",
|
||||
Qt::QueuedConnection);
|
||||
|
||||
loadOrderOptions();
|
||||
DeviceService::instance().startPolling();
|
||||
processRefreshTimer->setInterval(1000);
|
||||
connect(processRefreshTimer, &QTimer::timeout,
|
||||
this, &DashboardPage::refreshProcessRecords);
|
||||
@@ -203,7 +208,9 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
DashboardPage::~DashboardPage()
|
||||
{
|
||||
if (productionThread->isRunning()) {
|
||||
productionThread->quit();
|
||||
productionWorker->requestStopImmediate();
|
||||
QMetaObject::invokeMethod(productionWorker, "requestShutdown",
|
||||
Qt::QueuedConnection);
|
||||
productionThread->wait();
|
||||
}
|
||||
delete ui;
|
||||
@@ -285,6 +292,7 @@ void DashboardPage::pauseProduction()
|
||||
|
||||
void DashboardPage::stopProduction()
|
||||
{
|
||||
productionWorker->requestStopImmediate();
|
||||
QMetaObject::invokeMethod(productionWorker, "requestStop",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
@@ -297,22 +305,10 @@ void DashboardPage::resetProduction()
|
||||
|
||||
void DashboardPage::clearAlarm()
|
||||
{
|
||||
QString error;
|
||||
if (!DeviceService::instance().clearAlarm(&error)) {
|
||||
QMessageBox::warning(this, "Clear alarm failed", error);
|
||||
emit logRequested("Alarm log", "Dashboard", "Clear alarm",
|
||||
error, "Failed");
|
||||
return;
|
||||
}
|
||||
if (!ProductionRepository().clearActiveAlarms(
|
||||
QString(), "OPERATOR", &error)) {
|
||||
QMessageBox::warning(this, "Clear alarm failed", error);
|
||||
emit logRequested("Alarm log", "Dashboard", "Clear alarm",
|
||||
error, "Failed");
|
||||
return;
|
||||
}
|
||||
QMetaObject::invokeMethod(productionWorker, "requestClearAlarm",
|
||||
Qt::QueuedConnection);
|
||||
emit logRequested("Alarm log", "Dashboard", "Clear alarm",
|
||||
"PLC alarm clear command completed", "Success");
|
||||
"PLC alarm clear command requested", "Pending");
|
||||
}
|
||||
|
||||
void DashboardPage::onOrderChanged(int)
|
||||
@@ -446,11 +442,14 @@ void DashboardPage::updateRecoveryButtons()
|
||||
|| state == ProductionService::ManualConfirm;
|
||||
const bool running = state != ProductionService::Idle
|
||||
&& state != ProductionService::Completed;
|
||||
const bool terminating = state == ProductionService::Terminating;
|
||||
recoverButton->setVisible(recoveryRequired);
|
||||
retryButton->setVisible(recoveryRequired);
|
||||
markNgButton->setVisible(recoveryRequired
|
||||
&& productionWorkpiece.id > 0);
|
||||
stopButton->setVisible(running);
|
||||
stopButton->setEnabled(!terminating);
|
||||
stopButton->setText(terminating ? "Terminating..." : "Terminate");
|
||||
recoverButton->setText(state == ProductionService::ManualConfirm
|
||||
? "Continue" : "Recover");
|
||||
}
|
||||
@@ -553,6 +552,7 @@ void DashboardPage::updateCurrentProcessDuration(int elapsedMs)
|
||||
|
||||
void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
|
||||
{
|
||||
emit deviceStatusChanged(status);
|
||||
deviceStatusLabel->setText(
|
||||
QString("PLC: %1 | Robot: %2 | Safety door: %3 | E-stop: %4")
|
||||
.arg(status.plcConnected ? "ONLINE" : "OFFLINE")
|
||||
|
||||
Reference in New Issue
Block a user