From 11b9b5a2cfd5b23e80ce6a3be3f9b341a2cd1be0 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期三, 13 九月 2023 17:36:55 +0800 Subject: [PATCH] 增加小车任务逻辑判断 --- springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java index ba8d08b..69a97b7 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java +++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Arrays; public class Plcstate extends Thread { @Override @@ -16,14 +17,18 @@ } List<Short> plclist = S7control.getinstance().ReadWord("DB103.DBW0", 10); - if (plclist == null) { + // Short[] values = { 0, 1, 1, 0, 1, 0, 1, 0, + // 1, 0, }; + // List<Short> plclist = new ArrayList<>(Arrays.asList(values)); + if (plclist != null) { - } else { + List<String> Intlist = new ArrayList<>(); + for (Short value : plclist) { + Intlist.add(value == 1 ? "鑷姩" : "鎵嬪姩"); + } JSONObject jsonObject = new JSONObject(); - // jsonObject.append("sta", - // new short[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, }); - jsonObject.append("sta", plclist); + jsonObject.append("sta", Intlist); WebSocketServer sendwServer = WebSocketServer.sessionMap.get("State"); if (sendwServer != null) { sendwServer.sendMessage(jsonObject.toString()); -- Gitblit v1.8.0