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
+1
View File
@@ -1,4 +1,5 @@
/tests/
/build/
/docs/
/.idea/
*.vision-state.json
+7 -6
View File
@@ -4,11 +4,11 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="5db5cc8f-5d2a-4f2f-97b5-7b9eba909e66" name="更改" comment="fix(order): 修改设备状态显示问题">
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/ssp.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/ssp.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ssp.pro.user" beforeDir="false" afterPath="$PROJECT_DIR$/ssp.pro.user" afterDir="false" />
<list default="true" id="5db5cc8f-5d2a-4f2f-97b5-7b9eba909e66" name="更改" comment="fix: 文件删除">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/services/deviceservice.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/services/deviceservice.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/services/productionworker.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/services/productionworker.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -100,6 +100,7 @@
<MESSAGE value="fix(Tray): 托盘传感器显示修改" />
<MESSAGE value="fix(order): 工序耗时--下面的累计耗时和表格没有数据" />
<MESSAGE value="fix(order): 修改设备状态显示问题" />
<option name="LAST_COMMIT_MESSAGE" value="fix(order): 修改设备状态显示问题" />
<MESSAGE value="fix: 文件删除" />
<option name="LAST_COMMIT_MESSAGE" value="fix: 文件删除" />
</component>
</project>
+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);
});
});
});
}
+1
View File
@@ -7,6 +7,7 @@ ProductionWorker::ProductionWorker(QObject *parent)
{
qRegisterMetaType<ProductionService::Snapshot>("ProductionService::Snapshot");
qRegisterMetaType<Workpiece>("Workpiece");
qRegisterMetaType<DeviceStatus>("DeviceStatus");
}
void ProductionWorker::ensureService()