diff --git a/.gitignore b/.gitignore
index ae38382..4bc67eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/tests/
/build/
/docs/
+/.idea/
*.vision-state.json
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7011d77..46926ed 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -100,6 +100,7 @@
-
+
+
\ No newline at end of file
diff --git a/services/deviceservice.cpp b/services/deviceservice.cpp
index 43a44c6..0590e19 100644
--- a/services/deviceservice.cpp
+++ b/services/deviceservice.cpp
@@ -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);
+ });
+ });
});
}
diff --git a/services/productionworker.cpp b/services/productionworker.cpp
index 62fc219..142c656 100644
--- a/services/productionworker.cpp
+++ b/services/productionworker.cpp
@@ -7,6 +7,7 @@ ProductionWorker::ProductionWorker(QObject *parent)
{
qRegisterMetaType("ProductionService::Snapshot");
qRegisterMetaType("Workpiece");
+ qRegisterMetaType("DeviceStatus");
}
void ProductionWorker::ensureService()