From c1d88895501846c4ad1ba2b16f4a8ae10ca2b061 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期二, 26 三月 2024 15:32:35 +0800 Subject: [PATCH] 代码更新 --- springboot-vue3/src/main/java/com/example/springboot/component/S7control.java | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java index ce4f674..9ad8e83 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java +++ b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java @@ -176,7 +176,7 @@ } } - + private int getIndexFromAddress(String address) { @@ -201,7 +201,6 @@ public List<Short> ReadWord(String address, int count) { if (s7PLC == null) return null; - List<String> addresslist = GetAddressList(address, count, 16); try { return s7PLC.readInt16(addresslist); @@ -211,7 +210,13 @@ return null; } } - + public byte[] Readbyte(String address, int count) { + byte[] byt=new byte[count]; + int wordcount=((count%2==0)?count/2:count+1); + List<Short> word=ReadWord(address,wordcount); + + return byt; + } /** * 鎸夋寚瀹氱殑鍦板潃 璇诲彇byte缁撴灉闆� * @@ -465,4 +470,11 @@ } return addresslist; } + public void writeString(String addr,String data) { + s7PLC.writeString(addr,data); + } + + public String readStrings(String addr) { + return s7PLC.readString(addr); + } } -- Gitblit v1.8.0