fix(Tray): 托盘传感器显示修改
This commit is contained in:
+27
-2
@@ -4,6 +4,7 @@
|
||||
#include "squaretraybutton.h"
|
||||
#include "uihelpers.h"
|
||||
|
||||
#include "../services/deviceservice.h"
|
||||
#include "../services/trayservice.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
@@ -14,6 +15,19 @@
|
||||
#include <QSizePolicy>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace {
|
||||
|
||||
QString displayTrayStatus(const QString &status)
|
||||
{
|
||||
if (status == "OK") return "已完成";
|
||||
if (status == "NG") return "有 NG";
|
||||
if (status == "PROCESSING") return "加工中";
|
||||
if (status == "PENDING") return "待检测";
|
||||
return "有托盘";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RackPage::RackPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::RackPage)
|
||||
@@ -106,6 +120,15 @@ void RackPage::refresh()
|
||||
loadTrays();
|
||||
}
|
||||
|
||||
void RackPage::updateDeviceStatus(const DeviceStatus &status)
|
||||
{
|
||||
trayPresenceAvailable = status.statusValid && status.plcConnected;
|
||||
for (int index = 0; index < 6; ++index) {
|
||||
trayPresent[index] = status.trayPresent[index];
|
||||
}
|
||||
updateTrayButtons();
|
||||
}
|
||||
|
||||
void RackPage::loadTrays()
|
||||
{
|
||||
QString error;
|
||||
@@ -148,15 +171,17 @@ void RackPage::updateTrayButtons()
|
||||
for (int index = 0; index < rackTrayButtons.size(); ++index) {
|
||||
SquareTrayButton *button = rackTrayButtons.at(index);
|
||||
if (index >= trays.size()) {
|
||||
button->setTrayInfo(0, QString(), 0, "无数据", false);
|
||||
button->setTrayInfo(0, QString(), 0, "无数据", false, true);
|
||||
button->setPlanned(false);
|
||||
button->setChecked(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
const Tray &tray = trays.at(index);
|
||||
const bool sensorPresent = !trayPresenceAvailable || trayPresent[index];
|
||||
button->setTrayInfo(tray.id, tray.code, tray.loadedCount,
|
||||
tray.status, tray.present);
|
||||
displayTrayStatus(tray.status), tray.present,
|
||||
sensorPresent);
|
||||
bool planned = false;
|
||||
QString error;
|
||||
const QList<TraySlot> traySlots =
|
||||
|
||||
Reference in New Issue
Block a user