feat(vision): 状态栏增加相机状态

This commit is contained in:
lidg
2026-10-29 11:57:47 +08:00
parent a7af930a0a
commit 31454722a0
9 changed files with 92 additions and 26 deletions
+19
View File
@@ -19,6 +19,7 @@
#include <QLabel>
#include <QListWidget>
#include <QStackedWidget>
#include <QTimer>
#include <QVBoxLayout>
Widget::Widget(QWidget *parent)
@@ -38,6 +39,7 @@ Widget::Widget(QWidget *parent)
, plcStatusLabel(nullptr)
, robotStatusLabel(nullptr)
, safetyStatusLabel(nullptr)
, cameraStatusLabel(nullptr)
{
ui->setupUi(this);
setWindowTitle("小轴多参数上下料单元管控系统");
@@ -103,9 +105,14 @@ void Widget::setupTopBar(QVBoxLayout *rootLayout)
plcStatusLabel = UiHelpers::makeBadge("PLC:未采集", "#607d8b");
robotStatusLabel = UiHelpers::makeBadge("机器人:未采集", "#607d8b");
safetyStatusLabel = UiHelpers::makeBadge("安全回路:未采集", "#607d8b");
cameraStatusLabel = UiHelpers::makeBadge(
ConfigManager::instance().visionConfig().enabled
? "相机:离线" : "相机:未启用",
"#607d8b");
topLayout->addWidget(plcStatusLabel);
topLayout->addWidget(robotStatusLabel);
topLayout->addWidget(safetyStatusLabel);
topLayout->addWidget(cameraStatusLabel);
rootLayout->addWidget(topBar);
}
@@ -184,6 +191,18 @@ void Widget::setupMainArea(QVBoxLayout *rootLayout)
connect(visionService, &VisionService::logMessage, this, [this](const QString &message) {
appendLog("生产日志", "视觉引导", "通信/测量", message, "记录");
});
connect(visionService, &VisionService::availabilityChanged,
this, [this](bool ready, bool, const QString &session) {
if (!ConfigManager::instance().visionConfig().enabled) {
cameraStatusLabel->setText("相机:未启用");
} else if (session.isEmpty()) {
cameraStatusLabel->setText("相机:离线");
} else {
cameraStatusLabel->setText(ready ? "相机:就绪" : "相机:在线");
}
});
if (ConfigManager::instance().visionConfig().enabled)
QTimer::singleShot(0, visionService, &VisionService::startService);
}
void Widget::appendLog(const QString &type, const QString &module, const QString &action,