From 75375a0f68c8b91799482dc1cd2ec7d7f211167f Mon Sep 17 00:00:00 2001 From: wuyouming666 <2265557248@qq.com> Date: 星期五, 31 五月 2024 09:28:06 +0800 Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes --- springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java index 4de113f..99f639c 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java +++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java @@ -2,6 +2,7 @@ import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; +import lombok.extern.slf4j.Slf4j; import java.io.BufferedReader; import java.io.FileInputStream; @@ -15,6 +16,7 @@ import com.example.springboot.mapper.AlarmMapper; +@Slf4j public class Plcalarm extends Thread { private AlarmMapper alarmMapper; @@ -28,7 +30,7 @@ FileInputStream fileInputStream; try { // 浠庢枃浠朵腑璇诲彇瀛楄妭鏁版嵁瀛樺叆 fileInputStream - fileInputStream = new FileInputStream("D:/code/canadames/Alarm.json"); + fileInputStream = new FileInputStream("D:/canadames/Alarm.json"); // 璇诲彇 fileInputStream 涓瓧鑺傚苟灏嗗叾瑙g爜涓哄瓧绗� InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); // 鎻愰珮璇诲彇鏁堢巼锛屽湪 BufferedReader 鍐呭寘瑁� InputStreamReader @@ -78,16 +80,12 @@ while (this != null) { try { Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - -// this.readValue(); -// String PlcAddress = this.name; -// Integer Plccount = this.count; + this.readValue(); + String PlcAddress = this.name; + Integer Plccount = this.count; // 鏍规嵁鍦板潃璇诲彇PCL鏁版嵁 - List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71); + List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", Plccount); // List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); // System.out.println(plclist); // Boolean[] values = { false, false, true, false, true, false, true, false, @@ -117,7 +115,8 @@ } // 灏咺ntlist杞崲涓烘暟缁� - // System.out.println(Intlist); +// System.out.println(Intlist); +// System.out.println(Intlist.toArray().length); Integer[] shuzu1 = Intlist.toArray(new Integer[0]); // 瀹氫箟鐨勬姤璀﹀唴瀹规暟缁�,鑾峰彇json杩斿洖鐨勯泦鍚� @@ -140,7 +139,10 @@ } } } - } + } catch (InterruptedException e) { + e.printStackTrace(); } - } + } + } +} -- Gitblit v1.8.0