严智鑫
2024-03-25 5fb507ab11cf9ac3d1bceae718bcb9bb50c37651
springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
@@ -18,7 +18,7 @@
    S7PLC s7PLC; // PLC通讯类实例
    private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型
    private String ip = "192.168.10.1"; // plc ip地址
    private int port = 65; // plc 端口号
    private int port = 102; // plc 端口号
    private static volatile S7control instance = null;
@@ -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结果集
     *