添加状态点位表
This commit is contained in:
+269
-76
@@ -2,6 +2,7 @@
|
||||
#include "ui_dashboardpage.h"
|
||||
|
||||
#include "../services/orderservice.h"
|
||||
#include "../services/trayservice.h"
|
||||
#include "../services/workpieceservice.h"
|
||||
#include "../repositories/productionrepository.h"
|
||||
#include "uihelpers.h"
|
||||
@@ -26,17 +27,89 @@
|
||||
#include <QThread>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace {
|
||||
|
||||
QString displayState(const QString &state)
|
||||
{
|
||||
if (state == "IDLE") return "待机";
|
||||
if (state == "PREPARING") return "准备中";
|
||||
if (state == "WAITING_DEVICE_READY") return "等待设备就绪";
|
||||
if (state == "RACK_PICKING") return "料架取料";
|
||||
if (state == "FRONT_LOADING") return "正面上料";
|
||||
if (state == "LOADING") return "上料";
|
||||
if (state == "FRONT_CHECKING") return "正面检测";
|
||||
if (state == "FRONT_UNLOADING") return "正面下料";
|
||||
if (state == "FLIPPING") return "翻面";
|
||||
if (state == "BACK_LOADING") return "反面上料";
|
||||
if (state == "BACK_CHECKING") return "反面检测";
|
||||
if (state == "BACK_UNLOADING") return "反面下料";
|
||||
if (state == "RACK_PLACING") return "料架放料";
|
||||
if (state == "JUDGING") return "结果判定";
|
||||
if (state == "UNLOADING") return "下料";
|
||||
if (state == "PAUSED") return "已暂停";
|
||||
if (state == "ERROR") return "故障";
|
||||
if (state == "COMPLETED") return "已完成";
|
||||
if (state == "TIMEOUT_WARNING") return "工序耗时提示";
|
||||
if (state == "TIMEOUT_PAUSED") return "等待人工恢复";
|
||||
if (state == "RECOVERY_CHECKING") return "恢复检查";
|
||||
if (state == "MANUAL_CONFIRM") return "等待人工确认";
|
||||
if (state == "RETRYING") return "重试中";
|
||||
if (state == "TERMINATING") return "终止中";
|
||||
return state.isEmpty() ? "未采集" : state;
|
||||
}
|
||||
|
||||
QString displayProcessStep(const QString &step)
|
||||
{
|
||||
return displayState(step);
|
||||
}
|
||||
|
||||
QString displayProcessStatus(const QString &status)
|
||||
{
|
||||
if (status == "RUNNING") return "执行中";
|
||||
if (status == "COMPLETED") return "已完成";
|
||||
if (status == "FAILED") return "失败";
|
||||
if (status == "PAUSED") return "已暂停";
|
||||
if (status == "CANCELED") return "已取消";
|
||||
return status.isEmpty() ? "未采集" : status;
|
||||
}
|
||||
|
||||
void updateStatusCell(QLabel *cell, const QString &text, const QString &color)
|
||||
{
|
||||
if (!cell) {
|
||||
return;
|
||||
}
|
||||
cell->setText(text);
|
||||
cell->setStyleSheet(QString("QLabel { background: %1; border: 1px solid #ffffff; "
|
||||
"border-radius: 3px; color: white; font-size: 11px; }")
|
||||
.arg(color));
|
||||
}
|
||||
|
||||
QString boolStatus(bool valid, bool value, const QString &yes, const QString &no)
|
||||
{
|
||||
return !valid ? "未采集" : value ? yes : no;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DashboardPage::DashboardPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::DashboardPage)
|
||||
, orderCombo(new QComboBox(this))
|
||||
, rackBox(nullptr)
|
||||
, deviceStatusLabel(new QLabel("PLC: - | Robot: - | Safety: -", this))
|
||||
, recoverButton(new QPushButton("Recover", this))
|
||||
, retryButton(new QPushButton("Retry", this))
|
||||
, markNgButton(new QPushButton("Mark NG", this))
|
||||
, stopButton(new QPushButton("Terminate", this))
|
||||
, processBox(new QGroupBox("Process timing", this))
|
||||
, deviceStatusLabel(new QLabel("PLC:未采集 | 机器人:未采集 | 安全回路:未采集", this))
|
||||
, inspectionMachineCell(nullptr)
|
||||
, robotCell(nullptr)
|
||||
, robotControlCabinetCell(nullptr)
|
||||
, mainControlCabinetCell(nullptr)
|
||||
, safetyDoor1Cell(nullptr)
|
||||
, safetyDoor2Cell(nullptr)
|
||||
, safetyDoor3Cell(nullptr)
|
||||
, alarmCell(nullptr)
|
||||
, recoverButton(new QPushButton("恢复", this))
|
||||
, retryButton(new QPushButton("重试", this))
|
||||
, markNgButton(new QPushButton("标记 NG", this))
|
||||
, stopButton(new QPushButton("终止", this))
|
||||
, processBox(new QGroupBox("工序耗时", this))
|
||||
, currentProcessLabel(new QLabel("-", processBox))
|
||||
, processElapsedLabel(new QLabel("00:00:00.000", processBox))
|
||||
, processTotalElapsedLabel(new QLabel("00:00:00.000", processBox))
|
||||
@@ -85,15 +158,15 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
ui->taskLayout->insertWidget(1, deviceStatusLabel);
|
||||
|
||||
QFormLayout *processSummaryLayout = new QFormLayout;
|
||||
processSummaryLayout->addRow("Current process:", currentProcessLabel);
|
||||
processSummaryLayout->addRow("Elapsed:", processElapsedLabel);
|
||||
processSummaryLayout->addRow("Total:", processTotalElapsedLabel);
|
||||
processSummaryLayout->addRow("当前工序:", currentProcessLabel);
|
||||
processSummaryLayout->addRow("当前耗时:", processElapsedLabel);
|
||||
processSummaryLayout->addRow("累计耗时:", processTotalElapsedLabel);
|
||||
|
||||
QVBoxLayout *processLayout = new QVBoxLayout(processBox);
|
||||
processLayout->addLayout(processSummaryLayout);
|
||||
processTable->setColumnCount(4);
|
||||
processTable->setHorizontalHeaderLabels(
|
||||
QStringList() << "Process" << "Status" << "Attempt" << "Duration");
|
||||
QStringList() << "工序" << "状态" << "次数" << "耗时");
|
||||
processTable->horizontalHeader()->setStretchLastSection(true);
|
||||
processTable->horizontalHeader()->setSectionResizeMode(
|
||||
0, QHeaderView::Stretch);
|
||||
@@ -124,16 +197,24 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
ui->deviceLayout->setRowStretch(3, 1);
|
||||
ui->deviceLayout->setRowStretch(4, 1);
|
||||
ui->deviceLayout->setRowStretch(5, 1);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("检测机\n待机", "#607d8b"), 0, 0, 2, 2);
|
||||
inspectionMachineCell = UiHelpers::makeStatusCell("检测机\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(inspectionMachineCell, 0, 0, 2, 2);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("总控电脑", "#43a047"), 0, 3);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("安全门1\n关闭", "#2e7d32"), 0, 4);
|
||||
QLabel *robotCell = UiHelpers::makeStatusCell("机器人\n空闲", "#f9a825");
|
||||
safetyDoor1Cell = UiHelpers::makeStatusCell("安全门 1\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(safetyDoor1Cell, 0, 4);
|
||||
robotCell = UiHelpers::makeStatusCell("机器人\n未采集", "#607d8b");
|
||||
robotCell->setFixedSize(82, 58);
|
||||
ui->deviceLayout->addWidget(robotCell, 2, 3, 2, 2, Qt::AlignCenter);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("机器人\n控制柜", "#546e7a"), 3, 0);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("总控柜", "#546e7a"), 4, 0);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("安全门2\n关闭", "#2e7d32"), 2, 5);
|
||||
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("安全门3\n关闭", "#2e7d32"), 5, 0);
|
||||
robotControlCabinetCell = UiHelpers::makeStatusCell("机器人控制柜\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(robotControlCabinetCell, 3, 0);
|
||||
mainControlCabinetCell = UiHelpers::makeStatusCell("总控柜\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(mainControlCabinetCell, 4, 0);
|
||||
safetyDoor2Cell = UiHelpers::makeStatusCell("安全门 2\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(safetyDoor2Cell, 2, 5);
|
||||
safetyDoor3Cell = UiHelpers::makeStatusCell("安全门 3\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(safetyDoor3Cell, 5, 0);
|
||||
alarmCell = UiHelpers::makeStatusCell("PLC 报警\n未采集", "#607d8b");
|
||||
ui->deviceLayout->addWidget(alarmCell, 5, 5);
|
||||
|
||||
rackBox = new QGroupBox("料架 2x3");
|
||||
rackBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@@ -141,8 +222,8 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
rackLayout->setContentsMargins(8, 18, 8, 8);
|
||||
rackLayout->setSpacing(4);
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
QLabel *trayCell = UiHelpers::makeSquareStatusCell(QString("托盘%1\n%2/49").arg(i + 1).arg(49 - i * 4),
|
||||
i == 0 ? "#00897b" : "#78909c");
|
||||
QLabel *trayCell = UiHelpers::makeSquareStatusCell(
|
||||
QString("托盘 %1\n未采集").arg(i + 1), "#607d8b");
|
||||
rackTrayCells.append(trayCell);
|
||||
rackLayout->addWidget(trayCell, i / 3, i % 3, Qt::AlignCenter);
|
||||
}
|
||||
@@ -203,6 +284,7 @@ DashboardPage::DashboardPage(QWidget *parent)
|
||||
this, &DashboardPage::refreshProcessRecords);
|
||||
processRefreshTimer->start();
|
||||
refreshProcessRecords();
|
||||
updateRackSummary();
|
||||
}
|
||||
|
||||
DashboardPage::~DashboardPage()
|
||||
@@ -263,24 +345,29 @@ void DashboardPage::updateRackSize()
|
||||
|
||||
void DashboardPage::startProduction()
|
||||
{
|
||||
if (productionState != ProductionService::Idle
|
||||
&& productionState != ProductionService::Completed) {
|
||||
return;
|
||||
}
|
||||
|
||||
int selectedOrderId = orderCombo->currentData().toInt();
|
||||
if (selectedOrderId <= 0) {
|
||||
loadOrderOptions();
|
||||
selectedOrderId = orderCombo->currentData().toInt();
|
||||
}
|
||||
if (selectedOrderId <= 0) {
|
||||
QMessageBox::information(this, "Start production",
|
||||
"No prepared order is available");
|
||||
QMessageBox::information(this, "启动生产",
|
||||
"没有可生产的订单,请先生成工件。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (productionState == ProductionService::Paused) {
|
||||
QMetaObject::invokeMethod(productionWorker, "requestResume",
|
||||
Qt::QueuedConnection);
|
||||
} else {
|
||||
QMetaObject::invokeMethod(
|
||||
ui->startButton->setEnabled(false);
|
||||
if (!QMetaObject::invokeMethod(
|
||||
productionWorker, "requestStart", Qt::QueuedConnection,
|
||||
Q_ARG(int, selectedOrderId));
|
||||
Q_ARG(int, selectedOrderId))) {
|
||||
updateRecoveryButtons();
|
||||
QMessageBox::warning(this, "启动生产",
|
||||
"提交生产启动请求失败。");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,8 +394,8 @@ void DashboardPage::clearAlarm()
|
||||
{
|
||||
QMetaObject::invokeMethod(productionWorker, "requestClearAlarm",
|
||||
Qt::QueuedConnection);
|
||||
emit logRequested("Alarm log", "Dashboard", "Clear alarm",
|
||||
"PLC alarm clear command requested", "Pending");
|
||||
emit logRequested("报警日志", "控制面板", "清除报警",
|
||||
"已请求 PLC 清除报警", "待处理");
|
||||
}
|
||||
|
||||
void DashboardPage::onOrderChanged(int)
|
||||
@@ -320,10 +407,11 @@ void DashboardPage::onProductionStateChanged(ProductionService::State state,
|
||||
const QString &name)
|
||||
{
|
||||
productionState = state;
|
||||
ui->actionLabel->setText("Production state: " + name);
|
||||
const QString stateText = displayState(name);
|
||||
ui->actionLabel->setText("生产状态:" + stateText);
|
||||
updateRecoveryButtons();
|
||||
emit systemStateChanged(name);
|
||||
emit currentStepChanged(name);
|
||||
emit systemStateChanged(stateText);
|
||||
emit currentStepChanged(stateText);
|
||||
refreshProcessRecords();
|
||||
updateProductionStats();
|
||||
}
|
||||
@@ -332,12 +420,14 @@ void DashboardPage::onCurrentWorkpieceChanged(int workpieceId,
|
||||
const QString &barcode)
|
||||
{
|
||||
if (workpieceId <= 0) {
|
||||
ui->workpieceLabel->setText("Current workpiece: -");
|
||||
ui->trayLabel->setText("Current tray: -");
|
||||
ui->workpieceLabel->setText("当前工件:-");
|
||||
ui->trayLabel->setText("当前托盘:-");
|
||||
currentProcessElapsedMs = 0;
|
||||
emit currentWorkpieceChanged("-");
|
||||
} else {
|
||||
ui->workpieceLabel->setText(
|
||||
QString("Current workpiece: %1").arg(barcode));
|
||||
QString("当前工件:%1").arg(barcode));
|
||||
emit currentWorkpieceChanged(barcode);
|
||||
}
|
||||
refreshProcessRecords();
|
||||
updateRecoveryButtons();
|
||||
@@ -357,31 +447,33 @@ void DashboardPage::onCurrentPositionChanged(int trayNo, int slotNo)
|
||||
productionTrayNo = trayNo;
|
||||
productionSlotNo = slotNo;
|
||||
ui->trayLabel->setText(trayNo > 0
|
||||
? QString("Current tray: %1 / slot: %2").arg(trayNo).arg(slotNo)
|
||||
: "Current tray: -");
|
||||
? QString("当前托盘:%1,位置:%2").arg(trayNo).arg(slotNo)
|
||||
: "当前托盘:-");
|
||||
}
|
||||
|
||||
void DashboardPage::onProductionError(const QString &error)
|
||||
{
|
||||
ui->actionLabel->setText("Production error: " + error);
|
||||
emit systemStateChanged("ERROR");
|
||||
emit logRequested("Alarm log", "Production", "Production error",
|
||||
error, "Failed");
|
||||
ui->actionLabel->setText("生产故障:" + error);
|
||||
updateRecoveryButtons();
|
||||
emit systemStateChanged("故障");
|
||||
emit logRequested("报警日志", "生产流程", "生产故障",
|
||||
error, "失败");
|
||||
}
|
||||
|
||||
void DashboardPage::onProductionFinished(int orderId)
|
||||
{
|
||||
emit logRequested("Production log", "Production", "Order completed",
|
||||
QString("Order %1 completed").arg(orderId), "Success");
|
||||
emit logRequested("生产日志", "生产流程", "订单完成",
|
||||
QString("订单 %1 已完成").arg(orderId), "成功");
|
||||
loadOrderOptions();
|
||||
updateProductionStats();
|
||||
updateRackSummary();
|
||||
}
|
||||
|
||||
void DashboardPage::onProcessElapsedChanged(const QString &processStep,
|
||||
int elapsedMs)
|
||||
{
|
||||
currentProcessElapsedMs = elapsedMs;
|
||||
currentProcessLabel->setText(processStep);
|
||||
currentProcessLabel->setText(displayProcessStep(processStep));
|
||||
processElapsedLabel->setText(formatDuration(elapsedMs));
|
||||
updateCurrentProcessDuration(elapsedMs);
|
||||
}
|
||||
@@ -389,23 +481,23 @@ void DashboardPage::onProcessElapsedChanged(const QString &processStep,
|
||||
void DashboardPage::onTimeoutRecoveryRequired(const QString &state,
|
||||
const QString &message)
|
||||
{
|
||||
ui->actionLabel->setText("Manual recovery required: " + message);
|
||||
emit logRequested("Operation log", "Production", "Manual recovery",
|
||||
state + ": " + message, "Pending");
|
||||
ui->actionLabel->setText("需要人工恢复:" + message);
|
||||
emit logRequested("操作日志", "生产流程", "人工恢复",
|
||||
displayState(state) + ":" + message, "待处理");
|
||||
}
|
||||
|
||||
void DashboardPage::onRecoveryCompleted(const QString &mode)
|
||||
{
|
||||
emit logRequested("Production log", "Production", "Recovery completed",
|
||||
mode, "Success");
|
||||
emit logRequested("生产日志", "生产流程", "恢复完成",
|
||||
displayState(mode), "成功");
|
||||
}
|
||||
|
||||
void DashboardPage::recoverProduction()
|
||||
{
|
||||
if (productionState == ProductionService::ManualConfirm
|
||||
&& QMessageBox::question(
|
||||
this, "Continue production",
|
||||
"Continue only after confirming the equipment and current PLC step are safe?",
|
||||
this, "继续生产",
|
||||
"请确认设备和 PLC 当前步骤安全后再继续生产。",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)
|
||||
!= QMessageBox::Yes) {
|
||||
return;
|
||||
@@ -424,8 +516,8 @@ void DashboardPage::retryRecovery()
|
||||
void DashboardPage::markWorkpieceNg()
|
||||
{
|
||||
if (QMessageBox::question(
|
||||
this, "Mark workpiece NG",
|
||||
"Mark the current workpiece as NG and continue with the next workpiece?",
|
||||
this, "标记工件 NG",
|
||||
"确认将当前工件标记为 NG,并继续处理下一个工件吗?",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
!= QMessageBox::Yes) {
|
||||
return;
|
||||
@@ -443,15 +535,18 @@ void DashboardPage::updateRecoveryButtons()
|
||||
const bool running = state != ProductionService::Idle
|
||||
&& state != ProductionService::Completed;
|
||||
const bool terminating = state == ProductionService::Terminating;
|
||||
const bool canStart = state == ProductionService::Idle
|
||||
|| state == ProductionService::Completed;
|
||||
ui->startButton->setEnabled(canStart);
|
||||
recoverButton->setVisible(recoveryRequired);
|
||||
retryButton->setVisible(recoveryRequired);
|
||||
markNgButton->setVisible(recoveryRequired
|
||||
&& productionWorkpiece.id > 0);
|
||||
stopButton->setVisible(running);
|
||||
stopButton->setEnabled(!terminating);
|
||||
stopButton->setText(terminating ? "Terminating..." : "Terminate");
|
||||
stopButton->setText(terminating ? "终止中..." : "终止");
|
||||
recoverButton->setText(state == ProductionService::ManualConfirm
|
||||
? "Continue" : "Recover");
|
||||
? "继续" : "恢复");
|
||||
}
|
||||
|
||||
QString DashboardPage::formatDuration(int elapsedMs)
|
||||
@@ -509,10 +604,14 @@ void DashboardPage::refreshProcessRecords()
|
||||
totalElapsedMs += durationMs;
|
||||
}
|
||||
|
||||
processTable->setItem(row, 0,
|
||||
new QTableWidgetItem(record.processStep));
|
||||
processTable->setItem(row, 1,
|
||||
new QTableWidgetItem(record.processState));
|
||||
QTableWidgetItem *stepItem = new QTableWidgetItem(
|
||||
displayProcessStep(record.processStep));
|
||||
stepItem->setData(Qt::UserRole, record.processStep);
|
||||
processTable->setItem(row, 0, stepItem);
|
||||
QTableWidgetItem *statusItem = new QTableWidgetItem(
|
||||
displayProcessStatus(record.processState));
|
||||
statusItem->setData(Qt::UserRole, record.processState);
|
||||
processTable->setItem(row, 1, statusItem);
|
||||
processTable->setItem(row, 2,
|
||||
new QTableWidgetItem(
|
||||
QString::number(record.attemptNo)));
|
||||
@@ -523,7 +622,7 @@ void DashboardPage::refreshProcessRecords()
|
||||
}
|
||||
|
||||
if (!currentStep.isEmpty()) {
|
||||
currentProcessLabel->setText(currentStep);
|
||||
currentProcessLabel->setText(displayProcessStep(currentStep));
|
||||
}
|
||||
processTotalElapsedLabel->setText(formatDuration(totalElapsedMs));
|
||||
}
|
||||
@@ -537,11 +636,13 @@ void DashboardPage::updateCurrentProcessDuration(int elapsedMs)
|
||||
|
||||
for (int row = 0; row < processTable->rowCount(); ++row) {
|
||||
QTableWidgetItem *stepItem = processTable->item(row, 0);
|
||||
if (!stepItem || stepItem->text() != workpiece.processStep) {
|
||||
if (!stepItem || stepItem->data(Qt::UserRole).toString()
|
||||
!= workpiece.processStep) {
|
||||
continue;
|
||||
}
|
||||
QTableWidgetItem *statusItem = processTable->item(row, 1);
|
||||
if (!statusItem || statusItem->text() != "RUNNING") {
|
||||
if (!statusItem || statusItem->data(Qt::UserRole).toString()
|
||||
!= "RUNNING") {
|
||||
continue;
|
||||
}
|
||||
processTable->setItem(row, 3,
|
||||
@@ -553,12 +654,101 @@ void DashboardPage::updateCurrentProcessDuration(int elapsedMs)
|
||||
void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
|
||||
{
|
||||
emit deviceStatusChanged(status);
|
||||
const QString plcText = boolStatus(status.statusValid,
|
||||
status.plcReady, "就绪", "未就绪");
|
||||
const QString robotText = boolStatus(status.statusValid,
|
||||
status.robotReady, "就绪", "未就绪");
|
||||
const QString safetyText = !status.statusValid ? "未采集"
|
||||
: status.safetyDoorClosed ? "正常" : "异常";
|
||||
deviceStatusLabel->setText(
|
||||
QString("PLC: %1 | Robot: %2 | Safety door: %3 | E-stop: %4")
|
||||
.arg(status.plcConnected ? "ONLINE" : "OFFLINE")
|
||||
.arg(status.robotReady ? "READY" : "NOT_READY")
|
||||
.arg(status.safetyDoorClosed ? "CLOSED" : "OPEN")
|
||||
.arg(status.emergencyStop ? "ACTIVE" : "CLEAR"));
|
||||
QString("PLC:%1 | 机器人:%2 | 安全回路:%3 | 急停:%4")
|
||||
.arg(!status.statusValid ? "未采集"
|
||||
: status.plcConnected ? "在线" : "离线")
|
||||
.arg(robotText)
|
||||
.arg(safetyText)
|
||||
.arg(boolStatus(status.statusValid, status.emergencyStop,
|
||||
"已触发", "正常")));
|
||||
|
||||
updateStatusCell(inspectionMachineCell,
|
||||
QString("检测机\n%1").arg(boolStatus(
|
||||
status.statusValid, status.inspectionMachineReady,
|
||||
"就绪", "未就绪")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.inspectionMachineReady ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(robotCell,
|
||||
QString("机器人\n%1").arg(robotText),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.robotReady ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(robotControlCabinetCell,
|
||||
QString("机器人控制柜\n%1").arg(boolStatus(
|
||||
status.statusValid, status.robotControlCabinetReady,
|
||||
"正常", "未就绪")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.robotControlCabinetReady ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(mainControlCabinetCell,
|
||||
QString("总控柜\n%1").arg(boolStatus(
|
||||
status.statusValid, status.mainControlCabinetReady,
|
||||
"正常", "未就绪")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.mainControlCabinetReady ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(safetyDoor1Cell,
|
||||
QString("安全门 1\n%1").arg(boolStatus(
|
||||
status.statusValid, status.safetyDoor1Closed,
|
||||
"关闭", "打开")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.safetyDoor1Closed ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(safetyDoor2Cell,
|
||||
QString("安全门 2\n%1").arg(boolStatus(
|
||||
status.statusValid, status.safetyDoor2Closed,
|
||||
"关闭", "打开")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.safetyDoor2Closed ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(safetyDoor3Cell,
|
||||
QString("安全门 3\n%1").arg(boolStatus(
|
||||
status.statusValid, status.safetyDoor3Closed,
|
||||
"关闭", "打开")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.safetyDoor3Closed ? "#2e7d32" : "#d32f2f");
|
||||
updateStatusCell(alarmCell,
|
||||
QString("PLC 报警\n%1").arg(boolStatus(
|
||||
status.statusValid, status.activeAlarm,
|
||||
"有报警", "无报警")),
|
||||
!status.statusValid ? "#607d8b"
|
||||
: status.activeAlarm ? "#d32f2f" : "#2e7d32");
|
||||
updateRackSummary();
|
||||
}
|
||||
|
||||
void DashboardPage::updateRackSummary()
|
||||
{
|
||||
QString error;
|
||||
const QList<Tray> trays = TrayService::instance().listTrays(&error);
|
||||
for (int index = 0; index < rackTrayCells.size(); ++index) {
|
||||
QLabel *cell = rackTrayCells.at(index);
|
||||
if (!error.isEmpty() || index >= trays.size()) {
|
||||
updateStatusCell(cell,
|
||||
QString("托盘 %1\n未采集").arg(index + 1),
|
||||
"#607d8b");
|
||||
continue;
|
||||
}
|
||||
|
||||
const Tray &tray = trays.at(index);
|
||||
const QString status = tray.present ? tray.status : "离位";
|
||||
const QString statusText = status == "OK" ? "已完成"
|
||||
: status == "NG" ? "有 NG"
|
||||
: status == "PROCESSING" ? "加工中"
|
||||
: status == "PENDING" ? "待检测"
|
||||
: tray.present ? "在位" : "离位";
|
||||
const QString color = !tray.present ? "#90a4ae"
|
||||
: status == "NG" ? "#d32f2f"
|
||||
: status == "PROCESSING" ? "#1e88e5"
|
||||
: status == "OK" ? "#2e7d32" : "#78909c";
|
||||
updateStatusCell(cell,
|
||||
QString("托盘 %1\n%2:%3/49")
|
||||
.arg(index + 1)
|
||||
.arg(statusText)
|
||||
.arg(tray.loadedCount),
|
||||
color);
|
||||
}
|
||||
}
|
||||
|
||||
void DashboardPage::loadOrderOptions()
|
||||
@@ -567,9 +757,9 @@ void DashboardPage::loadOrderOptions()
|
||||
const QList<Order> orders = OrderService::instance().listOrders(&error);
|
||||
if (!error.isEmpty()) {
|
||||
orderCombo->clear();
|
||||
orderCombo->addItem("No order data", 0);
|
||||
emit logRequested("Operation log", "Dashboard", "Load orders",
|
||||
error, "Failed");
|
||||
orderCombo->addItem("无订单数据", 0);
|
||||
emit logRequested("操作日志", "控制面板", "加载订单",
|
||||
error, "失败");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -591,7 +781,7 @@ void DashboardPage::loadOrderOptions()
|
||||
}
|
||||
|
||||
if (orderCombo->count() == 0) {
|
||||
orderCombo->addItem("No prepared order", 0);
|
||||
orderCombo->addItem("暂无可生产订单", 0);
|
||||
} else {
|
||||
const int previousIndex = orderCombo->findData(previousOrderId);
|
||||
orderCombo->setCurrentIndex(previousIndex >= 0 ? previousIndex : 0);
|
||||
@@ -603,9 +793,10 @@ void DashboardPage::updateOrderSummary()
|
||||
{
|
||||
const int selectedOrderId = orderCombo->currentData().toInt();
|
||||
if (selectedOrderId <= 0) {
|
||||
ui->orderLabel->setText("Current order: -");
|
||||
ui->trayLabel->setText("Current tray: -");
|
||||
ui->workpieceLabel->setText("Current workpiece: -");
|
||||
ui->orderLabel->setText("当前订单:-");
|
||||
ui->trayLabel->setText("当前托盘:-");
|
||||
ui->workpieceLabel->setText("当前工件:-");
|
||||
emit currentOrderChanged("-");
|
||||
updateProductionStats();
|
||||
return;
|
||||
}
|
||||
@@ -613,10 +804,12 @@ void DashboardPage::updateOrderSummary()
|
||||
Order order;
|
||||
QString error;
|
||||
if (!OrderService::instance().findOrder(selectedOrderId, &order, &error)) {
|
||||
ui->orderLabel->setText("Current order: -");
|
||||
ui->orderLabel->setText("当前订单:-");
|
||||
emit currentOrderChanged("-");
|
||||
return;
|
||||
}
|
||||
ui->orderLabel->setText("Current order: " + order.no);
|
||||
ui->orderLabel->setText("当前订单:" + order.no);
|
||||
emit currentOrderChanged(order.no);
|
||||
updateProductionStats();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user