fix(Tray): 托盘传感器显示修改
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
/tests/
|
/tests/
|
||||||
/build/
|
/build/
|
||||||
|
/docs/
|
||||||
*.vision-state.json
|
*.vision-state.json
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ reconnectAttempts=2
|
|||||||
; Coils
|
; Coils
|
||||||
clearAlarmCommand=815
|
clearAlarmCommand=815
|
||||||
plcRunning=817
|
plcRunning=817
|
||||||
|
trayPresent1=820
|
||||||
|
trayPresent2=821
|
||||||
|
trayPresent3=822
|
||||||
|
trayPresent4=823
|
||||||
|
trayPresent5=824
|
||||||
|
trayPresent6=825
|
||||||
safetyDoorClosed=826
|
safetyDoorClosed=826
|
||||||
safetyDoor1Closed=827
|
safetyDoor1Closed=827
|
||||||
safetyDoor2Closed=828
|
safetyDoor2Closed=828
|
||||||
|
|||||||
@@ -86,6 +86,12 @@ bool ConfigManager::load(const QString &filePath)
|
|||||||
ModbusAddressMap &addresses = m_modbusConfig.addressMap;
|
ModbusAddressMap &addresses = m_modbusConfig.addressMap;
|
||||||
addresses.clearAlarmCommand = settings.value("modbus/clearAlarmCommand", addresses.clearAlarmCommand).toInt();
|
addresses.clearAlarmCommand = settings.value("modbus/clearAlarmCommand", addresses.clearAlarmCommand).toInt();
|
||||||
addresses.plcRunning = settings.value("modbus/plcRunning", addresses.plcRunning).toInt();
|
addresses.plcRunning = settings.value("modbus/plcRunning", addresses.plcRunning).toInt();
|
||||||
|
addresses.trayPresent1 = settings.value("modbus/trayPresent1", addresses.trayPresent1).toInt();
|
||||||
|
addresses.trayPresent2 = settings.value("modbus/trayPresent2", addresses.trayPresent2).toInt();
|
||||||
|
addresses.trayPresent3 = settings.value("modbus/trayPresent3", addresses.trayPresent3).toInt();
|
||||||
|
addresses.trayPresent4 = settings.value("modbus/trayPresent4", addresses.trayPresent4).toInt();
|
||||||
|
addresses.trayPresent5 = settings.value("modbus/trayPresent5", addresses.trayPresent5).toInt();
|
||||||
|
addresses.trayPresent6 = settings.value("modbus/trayPresent6", addresses.trayPresent6).toInt();
|
||||||
addresses.plcReady = settings.value("modbus/plcReady", addresses.plcReady).toInt();
|
addresses.plcReady = settings.value("modbus/plcReady", addresses.plcReady).toInt();
|
||||||
addresses.robotIdle = settings.value("modbus/robotIdle", addresses.robotIdle).toInt();
|
addresses.robotIdle = settings.value("modbus/robotIdle", addresses.robotIdle).toInt();
|
||||||
addresses.robotRunning = settings.value("modbus/robotRunning", addresses.robotRunning).toInt();
|
addresses.robotRunning = settings.value("modbus/robotRunning", addresses.robotRunning).toInt();
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ bool ModbusAddressMap::isValid(QString *error) const
|
|||||||
const QList<QPair<QString, int> > coilAddresses = QList<QPair<QString, int> >()
|
const QList<QPair<QString, int> > coilAddresses = QList<QPair<QString, int> >()
|
||||||
<< qMakePair(QString("clearAlarmCommand"), clearAlarmCommand)
|
<< qMakePair(QString("clearAlarmCommand"), clearAlarmCommand)
|
||||||
<< qMakePair(QString("plcRunning"), plcRunning)
|
<< qMakePair(QString("plcRunning"), plcRunning)
|
||||||
|
<< qMakePair(QString("trayPresent1"), trayPresent1)
|
||||||
|
<< qMakePair(QString("trayPresent2"), trayPresent2)
|
||||||
|
<< qMakePair(QString("trayPresent3"), trayPresent3)
|
||||||
|
<< qMakePair(QString("trayPresent4"), trayPresent4)
|
||||||
|
<< qMakePair(QString("trayPresent5"), trayPresent5)
|
||||||
|
<< qMakePair(QString("trayPresent6"), trayPresent6)
|
||||||
<< qMakePair(QString("plcReady"), plcReady)
|
<< qMakePair(QString("plcReady"), plcReady)
|
||||||
<< qMakePair(QString("robotIdle"), robotIdle)
|
<< qMakePair(QString("robotIdle"), robotIdle)
|
||||||
<< qMakePair(QString("robotRunning"), robotRunning)
|
<< qMakePair(QString("robotRunning"), robotRunning)
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ struct ModbusAddressMap
|
|||||||
int clearAlarmCommand = 3;
|
int clearAlarmCommand = 3;
|
||||||
|
|
||||||
int plcRunning = 817;
|
int plcRunning = 817;
|
||||||
|
int trayPresent1 = 820;
|
||||||
|
int trayPresent2 = 821;
|
||||||
|
int trayPresent3 = 822;
|
||||||
|
int trayPresent4 = 823;
|
||||||
|
int trayPresent5 = 824;
|
||||||
|
int trayPresent6 = 825;
|
||||||
int safetyDoorClosed = 826;
|
int safetyDoorClosed = 826;
|
||||||
int safetyDoor1Closed = 827;
|
int safetyDoor1Closed = 827;
|
||||||
int safetyDoor2Closed = 828;
|
int safetyDoor2Closed = 828;
|
||||||
|
|||||||
+15
-4
@@ -1152,6 +1152,7 @@ void DashboardPage::updateCurrentProcessDuration(int elapsedMs)
|
|||||||
|
|
||||||
void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
|
void DashboardPage::onDeviceStatusChanged(const DeviceStatus &status)
|
||||||
{
|
{
|
||||||
|
deviceStatus = status;
|
||||||
emit deviceStatusChanged(status);
|
emit deviceStatusChanged(status);
|
||||||
const bool offline = !status.statusValid || !status.plcConnected;
|
const bool offline = !status.statusValid || !status.plcConnected;
|
||||||
const QString plcText = offline ? "离线"
|
const QString plcText = offline ? "离线"
|
||||||
@@ -1254,14 +1255,24 @@ void DashboardPage::updateRackSummary()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Tray &tray = trays.at(index);
|
const Tray &tray = trays.at(index);
|
||||||
const QString status = tray.present ? tray.status : "离位";
|
const bool sensorAvailable = deviceStatus.statusValid
|
||||||
|
&& deviceStatus.plcConnected;
|
||||||
|
const bool present = !sensorAvailable || deviceStatus.trayPresent[index];
|
||||||
|
if (!present) {
|
||||||
|
updateStatusCell(cell,
|
||||||
|
QString("托盘 %1\n不在位:0/49").arg(index + 1),
|
||||||
|
"#90a4ae",
|
||||||
|
highlightedTrayIds.contains(tray.id));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString status = tray.status;
|
||||||
const QString statusText = status == "OK" ? "已完成"
|
const QString statusText = status == "OK" ? "已完成"
|
||||||
: status == "NG" ? "有 NG"
|
: status == "NG" ? "有 NG"
|
||||||
: status == "PROCESSING" ? "加工中"
|
: status == "PROCESSING" ? "加工中"
|
||||||
: status == "PENDING" ? "待检测"
|
: status == "PENDING" ? "待检测"
|
||||||
: tray.present ? "在位" : "离位";
|
: "有托盘";
|
||||||
const QString color = !tray.present ? "#90a4ae"
|
const QString color = status == "NG" ? "#d32f2f"
|
||||||
: status == "NG" ? "#d32f2f"
|
|
||||||
: status == "PROCESSING" ? "#1e88e5"
|
: status == "PROCESSING" ? "#1e88e5"
|
||||||
: status == "OK" ? "#2e7d32" : "#78909c";
|
: status == "OK" ? "#2e7d32" : "#78909c";
|
||||||
updateStatusCell(cell,
|
updateStatusCell(cell,
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ private:
|
|||||||
int currentOrderId;
|
int currentOrderId;
|
||||||
bool currentOrderStartable;
|
bool currentOrderStartable;
|
||||||
bool currentOrderResumable;
|
bool currentOrderResumable;
|
||||||
|
DeviceStatus deviceStatus;
|
||||||
Workpiece productionWorkpiece;
|
Workpiece productionWorkpiece;
|
||||||
int productionTrayNo;
|
int productionTrayNo;
|
||||||
int productionSlotNo;
|
int productionSlotNo;
|
||||||
|
|||||||
+27
-2
@@ -4,6 +4,7 @@
|
|||||||
#include "squaretraybutton.h"
|
#include "squaretraybutton.h"
|
||||||
#include "uihelpers.h"
|
#include "uihelpers.h"
|
||||||
|
|
||||||
|
#include "../services/deviceservice.h"
|
||||||
#include "../services/trayservice.h"
|
#include "../services/trayservice.h"
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
@@ -14,6 +15,19 @@
|
|||||||
#include <QSizePolicy>
|
#include <QSizePolicy>
|
||||||
#include <QtGlobal>
|
#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)
|
RackPage::RackPage(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::RackPage)
|
, ui(new Ui::RackPage)
|
||||||
@@ -106,6 +120,15 @@ void RackPage::refresh()
|
|||||||
loadTrays();
|
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()
|
void RackPage::loadTrays()
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
@@ -148,15 +171,17 @@ void RackPage::updateTrayButtons()
|
|||||||
for (int index = 0; index < rackTrayButtons.size(); ++index) {
|
for (int index = 0; index < rackTrayButtons.size(); ++index) {
|
||||||
SquareTrayButton *button = rackTrayButtons.at(index);
|
SquareTrayButton *button = rackTrayButtons.at(index);
|
||||||
if (index >= trays.size()) {
|
if (index >= trays.size()) {
|
||||||
button->setTrayInfo(0, QString(), 0, "无数据", false);
|
button->setTrayInfo(0, QString(), 0, "无数据", false, true);
|
||||||
button->setPlanned(false);
|
button->setPlanned(false);
|
||||||
button->setChecked(false);
|
button->setChecked(false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tray &tray = trays.at(index);
|
const Tray &tray = trays.at(index);
|
||||||
|
const bool sensorPresent = !trayPresenceAvailable || trayPresent[index];
|
||||||
button->setTrayInfo(tray.id, tray.code, tray.loadedCount,
|
button->setTrayInfo(tray.id, tray.code, tray.loadedCount,
|
||||||
tray.status, tray.present);
|
displayTrayStatus(tray.status), tray.present,
|
||||||
|
sensorPresent);
|
||||||
bool planned = false;
|
bool planned = false;
|
||||||
QString error;
|
QString error;
|
||||||
const QList<TraySlot> traySlots =
|
const QList<TraySlot> traySlots =
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class QLabel;
|
|||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class SquareTrayButton;
|
class SquareTrayButton;
|
||||||
|
struct DeviceStatus;
|
||||||
|
|
||||||
namespace Ui { class RackPage; }
|
namespace Ui { class RackPage; }
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refresh();
|
void refresh();
|
||||||
|
void updateDeviceStatus(const DeviceStatus &status);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void logRequested(const QString &type, const QString &module, const QString &action,
|
void logRequested(const QString &type, const QString &module, const QString &action,
|
||||||
@@ -48,6 +50,8 @@ private:
|
|||||||
QList<Tray> trays;
|
QList<Tray> trays;
|
||||||
int selectedTrayId;
|
int selectedTrayId;
|
||||||
int selectedTrayIndex;
|
int selectedTrayIndex;
|
||||||
|
bool trayPresenceAvailable = false;
|
||||||
|
bool trayPresent[6] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RACKPAGE_H
|
#endif // RACKPAGE_H
|
||||||
|
|||||||
+15
-10
@@ -7,6 +7,7 @@ SquareTrayButton::SquareTrayButton(int trayIndex, int loadedCount, QWidget *pare
|
|||||||
: QAbstractButton(parent)
|
: QAbstractButton(parent)
|
||||||
, m_trayId(0)
|
, m_trayId(0)
|
||||||
, m_planned(false)
|
, m_planned(false)
|
||||||
|
, m_sensorPresent(true)
|
||||||
{
|
{
|
||||||
setCheckable(true);
|
setCheckable(true);
|
||||||
setCursor(Qt::PointingHandCursor);
|
setCursor(Qt::PointingHandCursor);
|
||||||
@@ -14,16 +15,17 @@ SquareTrayButton::SquareTrayButton(int trayIndex, int loadedCount, QWidget *pare
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SquareTrayButton::setTrayInfo(int trayId, const QString &code, int loadedCount,
|
void SquareTrayButton::setTrayInfo(int trayId, const QString &code, int loadedCount,
|
||||||
const QString &status, bool present)
|
const QString &status, bool databasePresent,
|
||||||
|
bool sensorPresent)
|
||||||
{
|
{
|
||||||
m_trayId = trayId;
|
m_trayId = trayId;
|
||||||
|
m_sensorPresent = sensorPresent;
|
||||||
const QString displayCode = code.isEmpty() ? QString("托盘 %1").arg(trayId) : code;
|
const QString displayCode = code.isEmpty() ? QString("托盘 %1").arg(trayId) : code;
|
||||||
const QString displayStatus = present ? status : "离位";
|
setText(sensorPresent
|
||||||
setText(QString("%1\n7 x 7\n%2 %3/49")
|
? QString("%1\n7 x 7\n%2:%3/49")
|
||||||
.arg(displayCode)
|
.arg(displayCode).arg(status).arg(loadedCount)
|
||||||
.arg(displayStatus)
|
: QString("%1\n7 x 7\n不在位:0/49").arg(displayCode));
|
||||||
.arg(loadedCount));
|
setEnabled(databasePresent);
|
||||||
setEnabled(present);
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +53,14 @@ void SquareTrayButton::paintEvent(QPaintEvent *event)
|
|||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
const QRectF rect = QRectF(1, 1, width() - 2, height() - 2);
|
const QRectF rect = QRectF(1, 1, width() - 2, height() - 2);
|
||||||
const QColor background = isChecked() ? QColor("#00897b")
|
const QColor background = !m_sensorPresent ? QColor("#90a4ae")
|
||||||
|
: isChecked() ? QColor("#00897b")
|
||||||
: m_planned ? QColor("#f9a825") : QColor("#eceff1");
|
: m_planned ? QColor("#f9a825") : QColor("#eceff1");
|
||||||
const QColor border = isChecked() ? QColor("#004d40")
|
const QColor border = !m_sensorPresent ? QColor("#78909c")
|
||||||
|
: isChecked() ? QColor("#004d40")
|
||||||
: m_planned ? QColor("#ef6c00") : QColor("#b0bec5");
|
: m_planned ? QColor("#ef6c00") : QColor("#b0bec5");
|
||||||
const QColor textColor = isChecked() ? QColor("#ffffff") : QColor("#263238");
|
const QColor textColor = !m_sensorPresent || isChecked()
|
||||||
|
? QColor("#ffffff") : QColor("#263238");
|
||||||
|
|
||||||
painter.setPen(QPen(border, 2));
|
painter.setPen(QPen(border, 2));
|
||||||
painter.setBrush(background);
|
painter.setBrush(background);
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public:
|
|||||||
explicit SquareTrayButton(int trayIndex, int loadedCount, QWidget *parent = nullptr);
|
explicit SquareTrayButton(int trayIndex, int loadedCount, QWidget *parent = nullptr);
|
||||||
|
|
||||||
void setTrayInfo(int trayId, const QString &code, int loadedCount,
|
void setTrayInfo(int trayId, const QString &code, int loadedCount,
|
||||||
const QString &status, bool present);
|
const QString &status, bool databasePresent,
|
||||||
|
bool sensorPresent);
|
||||||
void setPlanned(bool planned);
|
void setPlanned(bool planned);
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
@@ -21,6 +22,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
int m_trayId;
|
int m_trayId;
|
||||||
bool m_planned;
|
bool m_planned;
|
||||||
|
bool m_sensorPresent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SQUARETRAYBUTTON_H
|
#endif // SQUARETRAYBUTTON_H
|
||||||
|
|||||||
+77
-34
@@ -182,7 +182,7 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
|
|||||||
{
|
{
|
||||||
const bool useErrorCode =
|
const bool useErrorCode =
|
||||||
ConfigManager::instance().productionConfig().usePlcErrorCode;
|
ConfigManager::instance().productionConfig().usePlcErrorCode;
|
||||||
if (index >= (useErrorCode ? 19 : 18)) {
|
if (index >= (useErrorCode ? 25 : 24)) {
|
||||||
finishStatusRequest(true, status, QString());
|
finishStatusRequest(true, status, QString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,23 +205,29 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
|
|||||||
DeviceStatus nextStatus = status;
|
DeviceStatus nextStatus = status;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 1: nextStatus.plcRunning = value != 0; break;
|
case 1: nextStatus.plcRunning = value != 0; break;
|
||||||
case 2: nextStatus.safetyDoorClosed = value != 0; break;
|
case 2: nextStatus.trayPresent[0] = value != 0; break;
|
||||||
case 3: nextStatus.safetyDoor1Closed = value != 0; break;
|
case 3: nextStatus.trayPresent[1] = value != 0; break;
|
||||||
case 4: nextStatus.safetyDoor2Closed = value != 0; break;
|
case 4: nextStatus.trayPresent[2] = value != 0; break;
|
||||||
case 5: nextStatus.safetyDoor3Closed = value != 0; break;
|
case 5: nextStatus.trayPresent[3] = value != 0; break;
|
||||||
case 6: nextStatus.emergencyStop = value != 0; break;
|
case 6: nextStatus.trayPresent[4] = value != 0; break;
|
||||||
case 7: nextStatus.robotIdle = value != 0; break;
|
case 7: nextStatus.trayPresent[5] = value != 0; break;
|
||||||
case 8: nextStatus.robotRunning = value != 0; break;
|
case 8: nextStatus.safetyDoorClosed = value != 0; break;
|
||||||
case 9: nextStatus.robotAlarm = value != 0; break;
|
case 9: nextStatus.safetyDoor1Closed = value != 0; break;
|
||||||
case 10: nextStatus.plcReady = value != 0; break;
|
case 10: nextStatus.safetyDoor2Closed = value != 0; break;
|
||||||
case 11: nextStatus.inspectionMachineReady = value != 0; break;
|
case 11: nextStatus.safetyDoor3Closed = value != 0; break;
|
||||||
case 12: nextStatus.visionReady = value != 0; break;
|
case 12: nextStatus.emergencyStop = value != 0; break;
|
||||||
case 13: nextStatus.robotControlCabinetReady = value != 0; break;
|
case 13: nextStatus.robotIdle = value != 0; break;
|
||||||
case 14: nextStatus.mainControlCabinetReady = value != 0; break;
|
case 14: nextStatus.robotRunning = value != 0; break;
|
||||||
case 15: nextStatus.activeAlarm = value != 0; break;
|
case 15: nextStatus.robotAlarm = value != 0; break;
|
||||||
case 16: nextStatus.currentStep = value; break;
|
case 16: nextStatus.plcReady = value != 0; break;
|
||||||
case 17: nextStatus.checkResult = value; break;
|
case 17: nextStatus.inspectionMachineReady = value != 0; break;
|
||||||
case 18: nextStatus.errorCode = value; break;
|
case 18: nextStatus.visionReady = value != 0; break;
|
||||||
|
case 19: nextStatus.robotControlCabinetReady = value != 0; break;
|
||||||
|
case 20: nextStatus.mainControlCabinetReady = value != 0; break;
|
||||||
|
case 21: nextStatus.activeAlarm = value != 0; break;
|
||||||
|
case 22: nextStatus.currentStep = value; break;
|
||||||
|
case 23: nextStatus.checkResult = value; break;
|
||||||
|
case 24: nextStatus.errorCode = value; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
readStatusStep(index + 1, nextStatus);
|
readStatusStep(index + 1, nextStatus);
|
||||||
@@ -236,96 +242,132 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
m_modbus->readCoil(addresses.safetyDoorClosed,
|
m_modbus->readCoil(addresses.trayPresent1,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
m_modbus->readCoil(addresses.safetyDoor1Closed,
|
m_modbus->readCoil(addresses.trayPresent2,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
m_modbus->readCoil(addresses.safetyDoor2Closed,
|
m_modbus->readCoil(addresses.trayPresent3,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
m_modbus->readCoil(addresses.safetyDoor3Closed,
|
m_modbus->readCoil(addresses.trayPresent4,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
m_modbus->readCoil(addresses.emergencyStop,
|
m_modbus->readCoil(addresses.trayPresent5,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
m_modbus->readCoil(addresses.robotIdle,
|
m_modbus->readCoil(addresses.trayPresent6,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
m_modbus->readCoil(addresses.robotRunning,
|
m_modbus->readCoil(addresses.safetyDoorClosed,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
m_modbus->readCoil(addresses.robotAlarm,
|
m_modbus->readCoil(addresses.safetyDoor1Closed,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
m_modbus->readCoil(addresses.plcReady,
|
m_modbus->readCoil(addresses.safetyDoor2Closed,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
m_modbus->readCoil(addresses.inspectionMachineReady,
|
m_modbus->readCoil(addresses.safetyDoor3Closed,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
m_modbus->readCoil(addresses.visionReady,
|
m_modbus->readCoil(addresses.emergencyStop,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
m_modbus->readCoil(addresses.robotControlCabinetReady,
|
m_modbus->readCoil(addresses.robotIdle,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
m_modbus->readCoil(addresses.mainControlCabinetReady,
|
m_modbus->readCoil(addresses.robotRunning,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
m_modbus->readCoil(addresses.activeAlarm,
|
m_modbus->readCoil(addresses.robotAlarm,
|
||||||
[next](bool ok, bool value, const QString &error) {
|
[next](bool ok, bool value, const QString &error) {
|
||||||
next(ok, value ? 1 : 0, error);
|
next(ok, value ? 1 : 0, error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
m_modbus->readHoldingRegister(addresses.currentStep, next);
|
m_modbus->readCoil(addresses.plcReady,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 17:
|
case 17:
|
||||||
m_modbus->readHoldingRegister(addresses.checkResult, next);
|
m_modbus->readCoil(addresses.inspectionMachineReady,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
|
m_modbus->readCoil(addresses.visionReady,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
m_modbus->readCoil(addresses.robotControlCabinetReady,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
m_modbus->readCoil(addresses.mainControlCabinetReady,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 21:
|
||||||
|
m_modbus->readCoil(addresses.activeAlarm,
|
||||||
|
[next](bool ok, bool value, const QString &error) {
|
||||||
|
next(ok, value ? 1 : 0, error);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 22:
|
||||||
|
m_modbus->readHoldingRegister(addresses.currentStep, next);
|
||||||
|
break;
|
||||||
|
case 23:
|
||||||
|
m_modbus->readHoldingRegister(addresses.checkResult, next);
|
||||||
|
break;
|
||||||
|
case 24:
|
||||||
m_modbus->readHoldingRegister(addresses.errorCode, next);
|
m_modbus->readHoldingRegister(addresses.errorCode, next);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -355,6 +397,7 @@ DeviceStatus DeviceService::simulatedStatus() const
|
|||||||
status.robotIdle = true;
|
status.robotIdle = true;
|
||||||
status.robotRunning = false;
|
status.robotRunning = false;
|
||||||
status.robotAlarm = false;
|
status.robotAlarm = false;
|
||||||
|
for (int index = 0; index < 6; ++index) status.trayPresent[index] = true;
|
||||||
status.safetyDoorClosed = true;
|
status.safetyDoorClosed = true;
|
||||||
status.emergencyStop = false;
|
status.emergencyStop = false;
|
||||||
status.inspectionMachineReady = true;
|
status.inspectionMachineReady = true;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ struct DeviceStatus
|
|||||||
bool robotIdle = false;
|
bool robotIdle = false;
|
||||||
bool robotRunning = false;
|
bool robotRunning = false;
|
||||||
bool robotAlarm = false;
|
bool robotAlarm = false;
|
||||||
|
bool trayPresent[6] = {};
|
||||||
bool safetyDoorClosed = false;
|
bool safetyDoorClosed = false;
|
||||||
bool emergencyStop = false;
|
bool emergencyStop = false;
|
||||||
bool inspectionMachineReady = false;
|
bool inspectionMachineReady = false;
|
||||||
|
|||||||
@@ -176,6 +176,8 @@ void Widget::setupMainArea(QVBoxLayout *rootLayout)
|
|||||||
});
|
});
|
||||||
connect(dashboardPage, &DashboardPage::deviceStatusChanged,
|
connect(dashboardPage, &DashboardPage::deviceStatusChanged,
|
||||||
devicePage, &DevicePage::updateStatus);
|
devicePage, &DevicePage::updateStatus);
|
||||||
|
connect(dashboardPage, &DashboardPage::deviceStatusChanged,
|
||||||
|
rackPage, &RackPage::updateDeviceStatus);
|
||||||
connect(dashboardPage, &DashboardPage::deviceStatusChanged,
|
connect(dashboardPage, &DashboardPage::deviceStatusChanged,
|
||||||
this, [this](const DeviceStatus &status) {
|
this, [this](const DeviceStatus &status) {
|
||||||
const bool offline = !status.statusValid || !status.plcConnected;
|
const bool offline = !status.statusValid || !status.plcConnected;
|
||||||
|
|||||||
Reference in New Issue
Block a user