feat(layout): 导航菜单自动刷新

-点击导航菜单对应页面自动刷新
-设备布局示意,添加背景图片及显示修改
This commit is contained in:
lidg
2026-11-11 10:44:12 +08:00
parent 43e38f0aa8
commit 6e22fe5672
13 changed files with 268 additions and 154 deletions
+30 -64
View File
@@ -4,46 +4,50 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="5db5cc8f-5d2a-4f2f-97b5-7b9eba909e66" name="更改" comment="fix: 文件删除">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<list default="true" id="a0d69ac9-cdfe-4203-ba79-e40e0903c9d7" name="更改" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/services/deviceservice.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/services/deviceservice.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/services/productionworker.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/services/productionworker.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/dashboardpage.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/pages/dashboardpage.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/dashboardpage.h" beforeDir="false" afterPath="$PROJECT_DIR$/pages/dashboardpage.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/logpage.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/pages/logpage.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/logpage.h" beforeDir="false" afterPath="$PROJECT_DIR$/pages/logpage.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/qualitypage.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/pages/qualitypage.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/qualitypage.h" beforeDir="false" afterPath="$PROJECT_DIR$/pages/qualitypage.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/repositories/productionrepository.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/repositories/productionrepository.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ssp.pro" beforeDir="false" afterPath="$PROJECT_DIR$/ssp.pro" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ssp.pro.user" beforeDir="false" afterPath="$PROJECT_DIR$/ssp.pro.user" afterDir="false" />
<change beforePath="$PROJECT_DIR$/widget.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/widget.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="GOROOT" url="file://D:/GoPath/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.5.windows-amd64" />
<component name="GOROOT" url="file://D:/GoPath/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.9.windows-amd64" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 0
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="3I4I0dCX6m5Jmayd8vIaWzjij7V" />
<component name="ProjectId" id="3LuL0W3t1JFHPBk68vdwpWEeZTN" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.GoLinterPluginOnboardingV2&quot;: &quot;true&quot;,
&quot;RunOnceActivity.GoLinterPluginStorageMigration&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.go.formatter.settings.were.checked&quot;: &quot;true&quot;,
&quot;RunOnceActivity.go.modules.go.list.on.any.changes.was.set&quot;: &quot;true&quot;,
&quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;go.sdk.automatically.set&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;E:/QTCode/ssp/ssp&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.GoLinterPluginOnboardingV2": "true",
"RunOnceActivity.GoLinterPluginStorageMigration": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.go.formatter.settings.were.checked": "true",
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
"git-widget-placeholder": "master",
"go.sdk.automatically.set": "true",
"last_opened_file_path": "C:/Users/18612"
}
}</component>
}]]></component>
<component name="SharedIndexes">
<attachedChunks>
<set>
@@ -54,53 +58,15 @@
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="5db5cc8f-5d2a-4f2f-97b5-7b9eba909e66" name="更改" comment="" />
<created>1787017192111</created>
<changelist id="a0d69ac9-cdfe-4203-ba79-e40e0903c9d7" name="更改" comment="" />
<created>1794298786565</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1787017192111</updated>
<updated>1794298786565</updated>
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="first commit" />
<MESSAGE value="订单流程添加修改" />
<MESSAGE value="订单流程修改--QThread事件循环导致的逻辑修改" />
<MESSAGE value="添加状态点位表" />
<MESSAGE value="Commit" />
<MESSAGE value="添加管控软件和相机的通讯" />
<MESSAGE value="feat(vision): 新增拍照到位前置流程并支持视觉失败降级取料&#10;&#10;- 在普通 RackPick 前写托盘号、格位并置 M850,收到 M851 后清除两位&#10;- 使用 vision/enabled 控制识别,关闭时仍执行拍照到位流程&#10;- 识别成功且 R60 写入确认后写 M852=1,视觉关闭或失败时写 M852=0&#10;- 确认 M852 写入后启动 RackPick,动作结束保留 M852&#10;- 移除旧 850–854 五信号握手,更新配置和协议文档&#10;- 允许未就绪的视觉服务接收测量,扩展超时以覆盖初始化重试&#10;- 保留 PLC 写入失败阻断、暂停发送门控及迟到结果拒绝&#10;- 持久化未完成事务,支持 PLC 暂停后的视觉维护与人工恢复&#10;&#10;验证:MinGW 32/64 位编译通过;生产流程47、IPC14、PLC11项测试通过" />
<MESSAGE value="feat(vision): 状态栏增加相机状态" />
<MESSAGE value="feat: 重构视觉取料流程及生产故障恢复&#10;- 删除订单启动、暂停、复位相关 PLC 握手及无效反馈配置&#10;- 清除报警改为仅写 clearAlarmCommand,不等待反馈&#10;- 将拍照位移动、视觉处理和 RackPick 拆分为三个独立动作&#10;- 增加 M850/M851 拍照位动作及 R60/M852 视觉结果流程&#10;- 暂停改为等待当前机器人动作完成,视觉结果不确定时转人工确认&#10;- 删除复位按钮,合并为恢复/重试按钮&#10;- 普通 PAUSED 订单通过启动按钮继续&#10;- 恢复前检查 PLC、安全状态、订单及动作命令反馈&#10;- 支持在途动作接管、已完成动作收尾、安全重试和人工确认&#10;- 故障状态保持订单 RUNNING,并持久化实际恢复阶段&#10;- 恢复成功后仅清除本次软件故障对应的报警&#10;- 更新小轴 PLC 地址、Modbus 配置和视觉集成文档" />
<MESSAGE value="feat: 视觉引导页面优化&#10;&#10;- 点击各个按钮后,能在界面显示操作后结果&#10;- 对排版进行优化&#10;- 下面的位姿拍照删除" />
<MESSAGE value="feat(production): 持久化动作检查点并完善恢复重试流程&#10;&#10;- production_runs 新增动作阶段、尝试次数、版本及人工确认字段&#10;- 提供兼容 PostgreSQL 9.5 的幂等升级脚本和数据库结构检查&#10;- 工序推进、动作完成检查点和审计记录使用同一事务&#10;- 机器人命令单次发送,完成反馈先持久化再清握手&#10;- 已完成动作恢复仅补握手或数据库记录,避免重复执行&#10;- 恢复/重试按钮固定显示在清除报警前,加入明确人工处理选项&#10;- 记录人工决定、操作人及现场核对信息,拒绝过期确认&#10;- 区分普通暂停继续、故障恢复与终止后的视觉锁解除&#10;- 补齐视觉目标跨重启校验、异步失败及迟到回调防护&#10;- 检测结果关联动作和尝试次数,重试清除旧结果缓存" />
<MESSAGE value="feat(production): modify&#10;&#10;- 添加终止按钮&#10;- 点击操作前进行提示&#10;- 取放料的时候,除了写slot,也写行和列" />
<MESSAGE value="feat(production): 界面表格优化" />
<MESSAGE value="feat(production): 删除动作记录、释放料位、删除工件及订单等" />
<MESSAGE value="feat(production): 修改订单流程卡死流程问题" />
<MESSAGE value="feat(production): 修改删除订单问题" />
<MESSAGE value="feat(production): 修改订单清除按钮功能---除了清除报警、也复位状态,让订单能继续执行" />
<MESSAGE value="feat(production): 修改订单加工位置不一致问题&#10;&#10;-创建订单时解除所有占用&#10;-修改数据库位置唯一约束&#10;-严格按照订单起始位置分配&#10;-订单启动时重新初始化位置" />
<MESSAGE value="feat(production): 放料流程前需要加两个步骤&#10;-1、移动相机到拍照位置 &#10;-2、相机识别凹槽是否有料(这个步骤先用伪代码实现);" />
<MESSAGE value="fix(dashboard): 显示问题修改&#10;-PLC-未采集、机器人-未采集、安全回路-未采集 问题修改&#10;-生成工件,成功后添加弹出提示生成成功" />
<MESSAGE value="fix(Tray): 托盘传感器显示修改" />
<MESSAGE value="fix(order): 工序耗时--下面的累计耗时和表格没有数据" />
<MESSAGE value="fix(order): 修改设备状态显示问题" />
<MESSAGE value="fix: 文件删除" />
<option name="LAST_COMMIT_MESSAGE" value="fix: 文件删除" />
</component>
</project>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 968 KiB

+5
View File
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/layout">
<file>Layout.png</file>
</qresource>
</RCC>
+183 -83
View File
@@ -16,8 +16,8 @@
#include <QComboBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QEvent>
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
#include <QLineEdit>
@@ -26,6 +26,7 @@
#include <QtGlobal>
#include <QPushButton>
#include <QMetaObject>
#include <QPixmap>
#include <QResizeEvent>
#include <QSizePolicy>
#include <QTableWidgetItem>
@@ -125,6 +126,13 @@ QString displayOrderStatus(const QString &status)
return status.isEmpty() ? "未采集" : status;
}
QString displayInspectionMode(const QString &mode)
{
if (mode == "BEFORE_PLATING") return "镀金前";
if (mode == "AFTER_PLATING") return "镀金后";
return mode.isEmpty() ? "未设置" : mode;
}
void updateStatusCell(QLabel *cell, const QString &text, const QString &color,
bool highlighted = false)
{
@@ -132,10 +140,16 @@ void updateStatusCell(QLabel *cell, const QString &text, const QString &color,
return;
}
cell->setText(text);
cell->setStyleSheet(QString("QLabel { background: %1; border: %2; "
"border-radius: 3px; color: white; font-size: 11px; }")
.arg(color)
.arg(highlighted ? "3px solid #ffb300" : "1px solid #ffffff"));
const QString border = highlighted
? "3px solid #ffb300"
: QString("1px solid %1").arg(color);
const bool compact = cell->property("compactStatus").toBool();
cell->setStyleSheet(QString("QLabel { background: rgba(18, 31, 38, 190); "
"border: %1; border-radius: 3px; color: white; "
"font-size: %2px; padding: %3; }")
.arg(border)
.arg(compact ? 9 : 11)
.arg(compact ? "2px" : "4px 6px"));
}
QString boolStatus(bool valid, bool value, const QString &yes, const QString &no)
@@ -148,6 +162,8 @@ QString boolStatus(bool valid, bool value, const QString &yes, const QString &no
DashboardPage::DashboardPage(QWidget *parent)
: QWidget(parent)
, ui(new Ui::DashboardPage)
, layoutCanvas(nullptr)
, layoutBackground(nullptr)
, rackBox(nullptr)
, deviceStatusLabel(new QLabel("PLC:未采集 | 机器人:未采集 | 安全回路:未采集", this))
, inspectionMachineCell(nullptr)
@@ -156,7 +172,6 @@ DashboardPage::DashboardPage(QWidget *parent)
, mainControlCabinetCell(nullptr)
, safetyDoor1Cell(nullptr)
, safetyDoor2Cell(nullptr)
, safetyDoor3Cell(nullptr)
, alarmCell(nullptr)
, markNgButton(new QPushButton("标记 NG", this))
, stopButton(new QPushButton("终止", this))
@@ -212,6 +227,7 @@ DashboardPage::DashboardPage(QWidget *parent)
QVBoxLayout *processLayout = new QVBoxLayout(processBox);
processLayout->addLayout(processSummaryLayout);
processBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
processTable->setColumnCount(4);
processTable->setHorizontalHeaderLabels(
QStringList() << "工序" << "状态" << "次数" << "耗时");
@@ -221,8 +237,18 @@ DashboardPage::DashboardPage(QWidget *parent)
processTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
processTable->setAlternatingRowColors(true);
processTable->setMinimumHeight(150);
processLayout->addWidget(processTable);
ui->taskLayout->insertWidget(6, processBox);
processTable->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
processLayout->addWidget(processTable, 1);
ui->taskSpacer->changeSize(0, 0, QSizePolicy::Minimum, QSizePolicy::Fixed);
ui->taskLayout->insertWidget(6, processBox, 1);
ui->layoutGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->taskGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->middleLayout->setStretch(0, 1);
ui->middleLayout->setStretch(1, 1);
ui->mainLayout->setStretch(0, 0);
ui->mainLayout->setStretch(1, 4);
ui->mainLayout->setStretch(2, 1);
ui->recentLogTable->setColumnCount(5);
ui->recentLogTable->setHorizontalHeaderLabels(QStringList() << "时间" << "类型" << "模块" << "内容" << "状态");
@@ -233,51 +259,66 @@ DashboardPage::DashboardPage(QWidget *parent)
ui->recentLogTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->recentLogTable->setAlternatingRowColors(true);
ui->deviceLayout->setSpacing(10);
ui->deviceLayout->setColumnStretch(0, 1);
ui->deviceLayout->setColumnStretch(1, 1);
ui->deviceLayout->setColumnStretch(2, 2);
ui->deviceLayout->setColumnStretch(3, 2);
ui->deviceLayout->setColumnStretch(4, 2);
ui->deviceLayout->setColumnStretch(5, 1);
ui->deviceLayout->setRowStretch(0, 1);
ui->deviceLayout->setRowStretch(1, 1);
ui->deviceLayout->setRowStretch(2, 1);
ui->deviceLayout->setRowStretch(3, 1);
ui->deviceLayout->setRowStretch(4, 1);
ui->deviceLayout->setRowStretch(5, 1);
inspectionMachineCell = UiHelpers::makeStatusCell("检测机\n未采集", "#607d8b");
ui->deviceLayout->addWidget(inspectionMachineCell, 0, 0, 2, 2);
ui->deviceLayout->addWidget(UiHelpers::makeStatusCell("总控电脑", "#43a047"), 0, 3);
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);
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);
ui->deviceLayout->setContentsMargins(8, 8, 8, 8);
ui->deviceLayout->setSpacing(0);
ui->layoutGroup->setMinimumSize(480, 500);
ui->layoutGroup->installEventFilter(this);
rackBox = new QGroupBox("料架 2x3");
rackBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QGridLayout *rackLayout = new QGridLayout(rackBox);
rackLayout->setContentsMargins(8, 18, 8, 8);
rackLayout->setSpacing(4);
layoutCanvas = new QWidget(ui->layoutGroup);
layoutCanvas->setObjectName("deviceLayoutCanvas");
layoutCanvas->setMinimumSize(440, 441);
layoutCanvas->setStyleSheet(
"QWidget#deviceLayoutCanvas { background: #dfe4e8; }");
ui->deviceLayout->addWidget(layoutCanvas, 0, 0, Qt::AlignCenter);
layoutBackground = new QLabel(layoutCanvas);
layoutBackground->setAlignment(Qt::AlignCenter);
layoutBackground->setStyleSheet("background: #dfe4e8;");
inspectionMachineCell = UiHelpers::makeStatusCell("检测机\n未采集", "#607d8b");
inspectionMachineCell->setParent(layoutCanvas);
safetyDoor1Cell = UiHelpers::makeStatusCell("安全门 1\n未采集", "#607d8b");
safetyDoor1Cell->setParent(layoutCanvas);
robotCell = UiHelpers::makeStatusCell("机器人\n未采集", "#607d8b");
robotCell->setParent(layoutCanvas);
robotControlCabinetCell = UiHelpers::makeStatusCell("机器人控制柜\n未采集", "#607d8b");
robotControlCabinetCell->setParent(layoutCanvas);
mainControlCabinetCell = UiHelpers::makeStatusCell("总控柜\n未采集", "#607d8b");
mainControlCabinetCell->setParent(layoutCanvas);
safetyDoor2Cell = UiHelpers::makeStatusCell("安全门 2\n未采集", "#607d8b");
safetyDoor2Cell->setParent(layoutCanvas);
alarmCell = UiHelpers::makeStatusCell("PLC 报警\n未采集", "#607d8b");
alarmCell->setParent(layoutCanvas);
rackBox = new QGroupBox("料架 2x3", layoutCanvas);
rackBox->setObjectName("deviceRack");
rackBox->setStyleSheet(
"QGroupBox#deviceRack { border: 0; background: transparent; color: white; "
"font-size: 11px; font-weight: bold; }"
"QGroupBox#deviceRack::title { subcontrol-origin: margin; "
"background: rgba(18, 31, 38, 190); border: 1px solid #2e7d32; "
"border-radius: 3px; padding: 3px 8px; }");
for (int i = 0; i < 6; ++i) {
QLabel *trayCell = UiHelpers::makeSquareStatusCell(
QString("托盘 %1\n未采集").arg(i + 1), "#607d8b");
trayCell->setParent(rackBox);
trayCell->setMinimumSize(0, 0);
trayCell->setProperty("compactStatus", true);
rackTrayCells.append(trayCell);
rackLayout->addWidget(trayCell, i / 3, i % 3, Qt::AlignCenter);
}
ui->deviceLayout->addWidget(rackBox, 4, 2, 2, 3);
updateRackSize();
updateStatusCell(inspectionMachineCell, "检测机\n未采集", "#607d8b");
updateStatusCell(robotCell, "机器人\n未采集", "#607d8b");
updateStatusCell(robotControlCabinetCell, "机器人控制柜\n未采集", "#607d8b");
updateStatusCell(mainControlCabinetCell, "总控柜\n未采集", "#607d8b");
updateStatusCell(safetyDoor1Cell, "安全门 1\n未采集", "#607d8b");
updateStatusCell(safetyDoor2Cell, "安全门 2\n未采集", "#607d8b");
updateStatusCell(alarmCell, "PLC 报警\n未采集", "#607d8b");
for (int i = 0; i < rackTrayCells.size(); ++i) {
updateStatusCell(rackTrayCells.at(i),
QString("托盘 %1\n未采集").arg(i + 1), "#607d8b");
}
QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
connect(ui->startButton, &QPushButton::clicked,
this, &DashboardPage::startProduction);
@@ -404,34 +445,102 @@ void DashboardPage::addLog(const QString &type, const QString &module, const QSt
}
}
bool DashboardPage::eventFilter(QObject *watched, QEvent *event)
{
if (watched == ui->layoutGroup
&& (event->type() == QEvent::Resize
|| event->type() == QEvent::Show
|| event->type() == QEvent::LayoutRequest)) {
QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
}
return QWidget::eventFilter(watched, event);
}
void DashboardPage::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
updateRackSize();
QTimer::singleShot(0, this, [this]() { updateDeviceLayout(); });
}
void DashboardPage::updateRackSize()
void DashboardPage::updateDeviceLayout()
{
if (!rackBox || rackTrayCells.isEmpty()) {
if (!layoutCanvas || !layoutBackground || !rackBox
|| rackTrayCells.size() != 6) {
return;
}
const int spacing = 4;
const int leftMargin = 8;
const int rightMargin = 8;
const int topMargin = 18;
const int bottomMargin = 8;
const int maxRackHeight = qMax(150, ui->layoutGroup->height() / 3);
const int maxCellByHeight = (maxRackHeight - topMargin - bottomMargin - spacing) / 2;
const int maxCellByWidth = (ui->layoutGroup->width() - leftMargin - rightMargin - spacing * 2) / 3;
const int cellSide = qMax(52, qMin(maxCellByHeight, maxCellByWidth));
const int rackWidth = leftMargin + rightMargin + cellSide * 3 + spacing * 2;
const int rackHeight = topMargin + bottomMargin + cellSide * 2 + spacing;
for (QLabel *cell : rackTrayCells) {
cell->setFixedSize(cellSide, cellSide);
static const QPixmap sourcePixmap(":/layout/Layout.png");
if (sourcePixmap.isNull()) {
return;
}
const QSize available = ui->deviceLayout->contentsRect().size();
if (available.width() <= 0 || available.height() <= 0) {
return;
}
const qreal imageRatio = qreal(sourcePixmap.width()) / sourcePixmap.height();
int canvasWidth = available.width();
int canvasHeight = qRound(canvasWidth / imageRatio);
if (canvasHeight > available.height()) {
canvasHeight = available.height();
canvasWidth = qRound(canvasHeight * imageRatio);
}
const QSize canvasSize(qMax(1, canvasWidth), qMax(1, canvasHeight));
if (layoutCanvas->size() != canvasSize) {
layoutCanvas->setFixedSize(canvasSize);
}
layoutBackground->setGeometry(layoutCanvas->rect());
layoutBackground->setPixmap(sourcePixmap.scaled(
canvasSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
layoutBackground->lower();
const int width = canvasSize.width();
const int height = canvasSize.height();
const auto place = [width, height](QWidget *widget, qreal x, qreal y,
qreal relativeWidth, int minimumWidth) {
if (!widget) {
return;
}
const int widgetWidth = qMin(width,
qMax(minimumWidth, qRound(width * relativeWidth)));
const int widgetHeight = qMin(height,
qMax(30, widget->sizeHint().height()));
const int left = qBound(0, qRound(width * x), width - widgetWidth);
const int top = qBound(0, qRound(height * y), height - widgetHeight);
widget->setGeometry(left, top, widgetWidth, widgetHeight);
widget->raise();
};
place(inspectionMachineCell, 0.09, 0.09, 0.27, 100);
place(safetyDoor1Cell, 0.435, 0.025, 0.13, 72);
place(robotCell, 0.67, 0.29, 0.21, 86);
place(robotControlCabinetCell, 0.07, 0.57, 0.17, 84);
place(mainControlCabinetCell, 0.07, 0.77, 0.15, 76);
place(safetyDoor2Cell, 0.38, 0.93, 0.12, 72);
place(alarmCell, 0.86, 0.93, 0.125, 82);
const int rackX = qRound(width * 0.53);
const int rackY = qRound(height * 0.615);
const int rackWidth = qMin(width - rackX, qRound(width * 0.36));
const int rackHeight = qMin(height - rackY, qRound(height * 0.30));
rackBox->setGeometry(rackX, rackY, rackWidth, rackHeight);
rackBox->raise();
const int trayWidth = qMin(rackWidth, qMax(1, qRound(rackWidth * 0.30)));
const int trayHeight = qMin(rackHeight,
qMax(30, qRound(rackHeight * 0.22)));
const qreal trayX[] = {0.03, 0.35, 0.67};
const qreal trayY[] = {0.28, 0.70};
for (int i = 0; i < rackTrayCells.size(); ++i) {
const int left = qBound(0, qRound(rackWidth * trayX[i % 3]),
rackWidth - trayWidth);
const int top = qBound(0, qRound(rackHeight * trayY[i / 3]),
rackHeight - trayHeight);
rackTrayCells.at(i)->setGeometry(left, top, trayWidth, trayHeight);
rackTrayCells.at(i)->raise();
}
rackBox->setFixedSize(rackWidth, rackHeight);
}
void DashboardPage::startProduction()
@@ -1186,17 +1295,13 @@ void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
: status.robotRunning || status.robotIdle
? "#2e7d32" : "#d32f2f");
updateStatusCell(robotControlCabinetCell,
QString("机器人控制柜\n%1").arg(boolStatus(
status.statusValid, status.robotControlCabinetReady,
"正常", "未就绪")),
!status.statusValid ? "#607d8b"
: status.robotControlCabinetReady ? "#2e7d32" : "#d32f2f");
QString("机器人控制柜\n%1").arg(
offline ? "离线" : "就绪"),
offline ? "#607d8b" : "#2e7d32");
updateStatusCell(mainControlCabinetCell,
QString("总控柜\n%1").arg(boolStatus(
status.statusValid, status.mainControlCabinetReady,
"正常", "未就绪")),
!status.statusValid ? "#607d8b"
: status.mainControlCabinetReady ? "#2e7d32" : "#d32f2f");
QString("总控柜\n%1").arg(
offline ? "离线" : "就绪"),
offline ? "#607d8b" : "#2e7d32");
updateStatusCell(safetyDoor1Cell,
QString("安全门 1\n%1").arg(boolStatus(
status.statusValid, status.safetyDoor1Closed,
@@ -1209,12 +1314,6 @@ void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
"关闭", "打开")),
!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,
@@ -1331,9 +1430,10 @@ void DashboardPage::loadCurrentOrder()
&& !workpieces.isEmpty();
}
ui->orderLabel->setText(QString("当前订单:%1(%2)")
ui->orderLabel->setText(QString("当前订单:%1(%2,%3)")
.arg(order.no)
.arg(displayOrderStatus(order.status)));
.arg(displayOrderStatus(order.status))
.arg(displayInspectionMode(order.inspectionMode)));
emit currentOrderChanged(order.no);
updateProductionStats();
updateRackSummary();
+5 -2
View File
@@ -10,6 +10,7 @@
class QTableWidget;
class QGroupBox;
class QResizeEvent;
class QEvent;
class QLabel;
class QPushButton;
class QTimer;
@@ -70,13 +71,14 @@ private slots:
void markWorkpieceNg();
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
void loadCurrentOrder();
void updateProductionStats();
void updateRackSummary();
void updateRackSize();
void updateDeviceLayout();
void updateRecoveryButtons();
QString controlOperationContext(QString *identity) const;
bool confirmControlOperation(const QString &title, const QString &effect);
@@ -85,6 +87,8 @@ private:
static QString formatDuration(int elapsedMs);
Ui::DashboardPage *ui;
QWidget *layoutCanvas;
QLabel *layoutBackground;
QGroupBox *rackBox;
QVector<QLabel *> rackTrayCells;
QLabel *deviceStatusLabel;
@@ -94,7 +98,6 @@ private:
QLabel *mainControlCabinetCell;
QLabel *safetyDoor1Cell;
QLabel *safetyDoor2Cell;
QLabel *safetyDoor3Cell;
QLabel *alarmCell;
QPushButton *markNgButton;
QPushButton *stopButton;
+5
View File
@@ -37,6 +37,11 @@ LogPage::~LogPage()
delete ui;
}
void LogPage::refresh()
{
loadLogs();
}
void LogPage::addLog(const QString &type, const QString &module, const QString &action,
const QString &content, const QString &status)
{
+3
View File
@@ -17,6 +17,9 @@ public:
void addLog(const QString &type, const QString &module, const QString &action,
const QString &content, const QString &status);
public slots:
void refresh();
private:
void loadLogs();
void addLogRow(const QString &time, const QString &type, const QString &module,
+12 -3
View File
@@ -266,6 +266,15 @@ QualityPage::~QualityPage()
{
}
void QualityPage::refresh()
{
loadInspectionRecords();
loadStatistics();
if (!traceBarcodeEdit->text().trimmed().isEmpty()) {
loadTrace();
}
}
void QualityPage::setupInspectionTab()
{
inspectionOrderEdit = new QLineEdit;
@@ -357,10 +366,10 @@ void QualityPage::setupTraceTab()
void QualityPage::loadInspectionRecords()
{
const QString slotText = inspectionSlotEdit->text().trimmed();
bool slotOk = true;
const int trayPos = inspectionSlotEdit->text().trimmed().isEmpty()
? 0 : inspectionSlotEdit->text().trimmed().toInt(&slotOk);
if (!slotOk || trayPos < 1 || trayPos > 49) {
const int trayPos = slotText.isEmpty() ? 0 : slotText.toInt(&slotOk);
if (!slotText.isEmpty() && (!slotOk || trayPos < 1 || trayPos > 49)) {
setMessage(inspectionMessageLabel, "位置号必须是 1 到 49", true);
return;
}
+1
View File
@@ -13,6 +13,7 @@ class QualityPage : public QWidget
public:
explicit QualityPage(QWidget *parent = nullptr);
~QualityPage();
void refresh();
private:
void setupInspectionTab();
+1 -1
View File
@@ -543,7 +543,7 @@ QList<WorkpieceProcessRecord> ProductionRepository::listProcessRecords(
"result_state, duration_ms, started_at, completed_at "
"from workpiece_process_records "
"where workpiece_id = :workpiece_id "
"order by started_at, id");
"order by started_at desc, id desc");
query.bindValue(":workpiece_id", workpieceId);
if (!query.exec()) {
setError(query, error);
+3
View File
@@ -97,6 +97,9 @@ FORMS += \
pages/rackpage.ui \
widget.ui
RESOURCES += \
layout/layout.qrc
DISTFILES += \
config.ini
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2026-11-09T19:39:43. -->
<!-- Written by QtCreator 4.11.0, 2026-11-10T16:35:47. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+19
View File
@@ -161,6 +161,25 @@ void Widget::setupMainArea(QVBoxLayout *rootLayout)
rootLayout->addLayout(bodyLayout, 1);
connect(navList, &QListWidget::currentRowChanged, pageStack, &QStackedWidget::setCurrentIndex);
connect(pageStack, &QStackedWidget::currentChanged,
this, [this, orderPage, rackPage](int index) {
switch (index) {
case 1:
orderPage->refresh();
break;
case 2:
rackPage->refresh();
break;
case 4:
logPage->refresh();
break;
case 5:
qualityPage->refresh();
break;
default:
break;
}
});
connect(dashboardPage, &DashboardPage::systemStateChanged, this, [this](const QString &state) {
systemStateLabel->setText("系统:" + state);
});