From 28ded8102d83cf74bc232d1cdfc89b7f22c41952 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期二, 03 十二月 2024 09:09:31 +0800
Subject: [PATCH] 增加点击防抖事件 增加笼子使用详情的计算优化。 增加数据推送时的报错处理 测量台交互逻辑增加 参数界面增加翻转加减速度

---
 springboot-vue3/src/main/java/com/example/springboot/component/S7control.java |   67 ++++++++++++++++++++++++++++++++-
 1 files changed, 64 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..be24e33 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
@@ -10,6 +10,7 @@
 import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
 import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite;
 import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import com.github.xingshuangs.iot.utils.FloatUtil;
 import com.google.common.primitives.Bytes;
 import org.apache.ibatis.jdbc.Null;
 
@@ -176,7 +177,7 @@
         }
     }
 
-
+    
 
 
     private int getIndexFromAddress(String address) {
@@ -201,7 +202,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 +211,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 +471,59 @@
         }
         return addresslist;
     }
+    public void writeString(String addr,String data) {
+        s7PLC.writeString(addr,data);
+    }
+    
+    public String readStrings(String addr) {
+        return s7PLC.readString(addr);
+    }
+
+    public float readFloat32(String addr) {
+        return s7PLC.readFloat32(addr);
+    }
+
+    public double readFloat64(String addr) {
+        return s7PLC.readFloat64(addr);
+    }
+    // public float[] readfloat32(List<String> addr) {
+    //     float[] result=new float[addr.size()];
+    //     for (int i=0;i<addr.size();i++) {
+    //         String address=addr.get(i);
+    //         result[i]=readFloat32(address);
+    //     }
+    //     return result;
+    // }
+
+    public List<Float> readFloat32(List<String> addr) {
+        List<Float> result=new ArrayList<>();
+        for (String string : addr) {
+            if(string.equals("DB10.2000")||string.equals("DB10.2008")){
+                result.add((float)s7PLC.readFloat64(string));
+            }else if (string.equals("DB10.224")||string.equals("DB10.226")||string.equals("DB10.228")||string.equals("DB10.230")) {
+                List<Short> word=ReadWord(string,1);
+                for (Short short1 : word) {
+                    result.add((float)short1);
+                }
+            }
+            else{
+                result.add(s7PLC.readFloat32(string));
+            }
+            
+        }
+        return result;
+    }
+
+    public void writeFloat32(String addr, float data) {
+      s7PLC.writeFloat32(addr,data);
+   }
+
+   public List<Long> readtimes(List<String> addr) {
+    List<Long> result=new ArrayList<>();
+    for (String string : addr) {
+        result.add(s7PLC.readTime(string));
+        
+    }
+    return result;
+}
 }

--
Gitblit v1.8.0