fix(plc): 读取plc显示问题及置位AlarmClearCommond

This commit is contained in:
lidg
2026-11-10 14:54:47 +08:00
parent 9731166686
commit 43e38f0aa8
4 changed files with 44 additions and 12 deletions
+35 -6
View File
@@ -442,14 +442,29 @@ void DeviceService::clearAlarm(const OperationCallback &callback)
return;
}
const int clearAlarmAddress = m_modbus->config().addressMap.clearAlarmCommand;
m_controlRequestPending = true;
m_modbus->writeCoil(
m_modbus->config().addressMap.clearAlarmCommand, true,
[this, callback](bool success, const QString &error) {
m_controlRequestPending = false;
if (callback) {
callback(success, error);
clearAlarmAddress, true,
[this, callback, clearAlarmAddress](bool success, const QString &error) {
if (!success) {
m_controlRequestPending = false;
if (callback) {
callback(false, error);
}
return;
}
QTimer::singleShot(1000, this, [this, callback, clearAlarmAddress]() {
m_modbus->writeCoil(
clearAlarmAddress, false,
[this, callback](bool resetSuccess, const QString &resetError) {
m_controlRequestPending = false;
if (callback) {
callback(resetSuccess, resetError);
}
});
});
});
}
@@ -602,7 +617,21 @@ void DeviceService::resetProductionSignals(const OperationCallback &callback)
.arg(addresses.clearAlarmCommand).arg(error));
return;
}
clearNextResetSignal(generation);
QTimer::singleShot(1000, this, [this, generation, addresses]() {
if (generation != m_resetGeneration || !m_terminationActive) return;
m_modbus->writeCoil(addresses.clearAlarmCommand, false,
[this, generation, addresses](bool resetSuccess,
const QString &resetError) {
if (generation != m_resetGeneration || !m_terminationActive) return;
if (!resetSuccess) {
finishTermination(false, QString("Reset clear alarm M%1 failed: %2")
.arg(addresses.clearAlarmCommand).arg(resetError));
return;
}
clearNextResetSignal(generation);
});
});
});
}