diff --git a/ruoyi-admin/src/main/java/com/ruoyi/schedule/plcRead/util/Tools.java b/ruoyi-admin/src/main/java/com/ruoyi/schedule/plcRead/util/Tools.java index b76525c..060590b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/schedule/plcRead/util/Tools.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/schedule/plcRead/util/Tools.java @@ -1,6 +1,7 @@ package com.ruoyi.schedule.plcRead.util; import HslCommunication.BasicFramework.SoftBasic; +import com.ruoyi.common.domain.SendData; import java.io.Serializable; import java.nio.charset.StandardCharsets; @@ -359,6 +360,29 @@ public class Tools implements Serializable { return df.format(t); } + /** + * 下发到PLC的反馈字节 + */ + public static byte[] sendData(SendData... list) { + byte[][] values = new byte[list.length][0]; + for (int i = 0; i < list.length; i++) { + byte[] bytes = Tools.intToBytes(list[i].getNum2(), list[i].getNum()); + //System.out.println(bytes.length); + values[i] = bytes; + } + int length_byte = 0; + for (byte[] value : values) { + length_byte += value.length; + } + byte[] all_byte = new byte[length_byte]; + int countLength = 0; + for (byte[] b : values) { + System.arraycopy(b, 0, all_byte, countLength, b.length); + countLength += b.length; + } + return all_byte; + } + //int 转2字节 public static byte[] intbyte(int res) {///Java中10进制转byte[] byte[] targets = new byte[2];