fix(Tray): 托盘传感器显示修改

This commit is contained in:
lidg
2026-11-09 18:16:54 +08:00
parent a8b2b31ce7
commit c248954b87
14 changed files with 170 additions and 51 deletions
+77 -34
View File
@@ -182,7 +182,7 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
{
const bool useErrorCode =
ConfigManager::instance().productionConfig().usePlcErrorCode;
if (index >= (useErrorCode ? 19 : 18)) {
if (index >= (useErrorCode ? 25 : 24)) {
finishStatusRequest(true, status, QString());
return;
}
@@ -205,23 +205,29 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
DeviceStatus nextStatus = status;
switch (index) {
case 1: nextStatus.plcRunning = value != 0; break;
case 2: nextStatus.safetyDoorClosed = value != 0; break;
case 3: nextStatus.safetyDoor1Closed = value != 0; break;
case 4: nextStatus.safetyDoor2Closed = value != 0; break;
case 5: nextStatus.safetyDoor3Closed = value != 0; break;
case 6: nextStatus.emergencyStop = value != 0; break;
case 7: nextStatus.robotIdle = value != 0; break;
case 8: nextStatus.robotRunning = value != 0; break;
case 9: nextStatus.robotAlarm = value != 0; break;
case 10: nextStatus.plcReady = value != 0; break;
case 11: nextStatus.inspectionMachineReady = value != 0; break;
case 12: nextStatus.visionReady = value != 0; break;
case 13: nextStatus.robotControlCabinetReady = value != 0; break;
case 14: nextStatus.mainControlCabinetReady = value != 0; break;
case 15: nextStatus.activeAlarm = value != 0; break;
case 16: nextStatus.currentStep = value; break;
case 17: nextStatus.checkResult = value; break;
case 18: nextStatus.errorCode = value; break;
case 2: nextStatus.trayPresent[0] = value != 0; break;
case 3: nextStatus.trayPresent[1] = value != 0; break;
case 4: nextStatus.trayPresent[2] = value != 0; break;
case 5: nextStatus.trayPresent[3] = value != 0; break;
case 6: nextStatus.trayPresent[4] = value != 0; break;
case 7: nextStatus.trayPresent[5] = value != 0; break;
case 8: nextStatus.safetyDoorClosed = value != 0; break;
case 9: nextStatus.safetyDoor1Closed = value != 0; break;
case 10: nextStatus.safetyDoor2Closed = value != 0; break;
case 11: nextStatus.safetyDoor3Closed = value != 0; break;
case 12: nextStatus.emergencyStop = value != 0; break;
case 13: nextStatus.robotIdle = value != 0; break;
case 14: nextStatus.robotRunning = value != 0; break;
case 15: nextStatus.robotAlarm = value != 0; break;
case 16: nextStatus.plcReady = value != 0; break;
case 17: nextStatus.inspectionMachineReady = value != 0; 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;
}
readStatusStep(index + 1, nextStatus);
@@ -236,96 +242,132 @@ void DeviceService::readStatusStep(int index, const DeviceStatus &status)
});
break;
case 2:
m_modbus->readCoil(addresses.safetyDoorClosed,
m_modbus->readCoil(addresses.trayPresent1,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 3:
m_modbus->readCoil(addresses.safetyDoor1Closed,
m_modbus->readCoil(addresses.trayPresent2,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 4:
m_modbus->readCoil(addresses.safetyDoor2Closed,
m_modbus->readCoil(addresses.trayPresent3,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 5:
m_modbus->readCoil(addresses.safetyDoor3Closed,
m_modbus->readCoil(addresses.trayPresent4,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 6:
m_modbus->readCoil(addresses.emergencyStop,
m_modbus->readCoil(addresses.trayPresent5,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 7:
m_modbus->readCoil(addresses.robotIdle,
m_modbus->readCoil(addresses.trayPresent6,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 8:
m_modbus->readCoil(addresses.robotRunning,
m_modbus->readCoil(addresses.safetyDoorClosed,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 9:
m_modbus->readCoil(addresses.robotAlarm,
m_modbus->readCoil(addresses.safetyDoor1Closed,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 10:
m_modbus->readCoil(addresses.plcReady,
m_modbus->readCoil(addresses.safetyDoor2Closed,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 11:
m_modbus->readCoil(addresses.inspectionMachineReady,
m_modbus->readCoil(addresses.safetyDoor3Closed,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 12:
m_modbus->readCoil(addresses.visionReady,
m_modbus->readCoil(addresses.emergencyStop,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 13:
m_modbus->readCoil(addresses.robotControlCabinetReady,
m_modbus->readCoil(addresses.robotIdle,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 14:
m_modbus->readCoil(addresses.mainControlCabinetReady,
m_modbus->readCoil(addresses.robotRunning,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
case 15:
m_modbus->readCoil(addresses.activeAlarm,
m_modbus->readCoil(addresses.robotAlarm,
[next](bool ok, bool value, const QString &error) {
next(ok, value ? 1 : 0, error);
});
break;
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;
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;
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);
break;
}
@@ -355,6 +397,7 @@ DeviceStatus DeviceService::simulatedStatus() const
status.robotIdle = true;
status.robotRunning = false;
status.robotAlarm = false;
for (int index = 0; index < 6; ++index) status.trayPresent[index] = true;
status.safetyDoorClosed = true;
status.emergencyStop = false;
status.inspectionMachineReady = true;