From 4af6e1a9f2c41523b5b99b685c7eb316b601f81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Fri, 25 Jul 2025 20:49:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iflytop/colortitration/app/core/crafts/CraftsDispatcher.java | 6 +++--- .../java/com/iflytop/colortitration/app/core/state/DeviceState.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsDispatcher.java b/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsDispatcher.java index 3e8cd23..ed89aa1 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsDispatcher.java +++ b/src/main/java/com/iflytop/colortitration/app/core/crafts/CraftsDispatcher.java @@ -109,7 +109,7 @@ public class CraftsDispatcher { public void waitIfPaused() throws InterruptedException { pauseLock.lock(); try { - while (deviceState.isPaused()) { + while (deviceState.isCraftsPaused()) { // 如果已暂停,当前线程将被挂起,直到调用 notifyAll() 唤醒 pauseCondition.await(); } @@ -124,7 +124,7 @@ public class CraftsDispatcher { public void pause() { pauseLock.lock(); try { - deviceState.setPaused(true); + deviceState.setCraftsPaused(true); log.info("所有任务已暂停。"); } finally { pauseLock.unlock(); @@ -137,7 +137,7 @@ public class CraftsDispatcher { public void resume() { pauseLock.lock(); try { - deviceState.setPaused(false); + deviceState.setCraftsPaused(false); pauseCondition.signalAll(); // 唤醒所有等待的线程 log.info("所有任务已恢复。"); } finally { diff --git a/src/main/java/com/iflytop/colortitration/app/core/state/DeviceState.java b/src/main/java/com/iflytop/colortitration/app/core/state/DeviceState.java index d465a27..62a3142 100644 --- a/src/main/java/com/iflytop/colortitration/app/core/state/DeviceState.java +++ b/src/main/java/com/iflytop/colortitration/app/core/state/DeviceState.java @@ -18,7 +18,7 @@ import java.util.Map; @JsonIgnoreProperties(value = {"advisors", "frozen", "preFiltered", "proxyTargetClass", "targetSource", "exposeProxy", "advisorCount", "proxiedInterfaces", "targetClass"}) public class DeviceState { @Schema(description = "当前设备是否暂停") - private volatile boolean paused = false; + private volatile boolean craftsPaused = false; @Schema(description = "滴定模块") private final Map titrationModuleStateMap = new HashMap<>(); @@ -52,7 +52,9 @@ public class DeviceState { public JSONObject toJSON() { JSONObject json = new JSONObject(); + json.putOnce("craftsPaused", craftsPaused); json.putOnce("titrationModule", new ArrayList<>(titrationModuleStateMap.values())); + json.putOnce("heatModuleStateMap", new ArrayList<>(heatModuleStateMap.values())); json.putOnce("trayTubeState", new ArrayList<>(trayTubeStateMap.values())); json.putOnce("trayExist1", virtual); json.putOnce("trayExist2", virtual);