From 79f33da4df32fc139c3855a8ecca6545723e0815 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期二, 19 九月 2023 08:08:17 +0800 Subject: [PATCH] 删除不需要的代码,玻璃信息放入其他数据库 方便测试显示数据库连接的信息 --- springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 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..a539781 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,26 +4,31 @@ import java.util.ArrayList; import java.util.List; +import java.util.Arrays; public class Plcstate extends Thread { @Override public void run() { while (this != null) { try { - Thread.sleep(10000); + Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } - List<Short> plclist = S7control.getinstance().ReadWord("DB103.DBW0", 10); - if (plclist == null) { + List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 10); + // 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