| | |
| | | import com.github.xingshuangs.iot.protocol.s7.service.MultiAddressWrite; |
| | | import com.github.xingshuangs.iot.protocol.s7.service.S7PLC; |
| | | import com.google.common.primitives.Bytes; |
| | | import org.apache.ibatis.jdbc.Null; |
| | | |
| | | public class S7control { |
| | | |
| | |
| | | |
| | | for (String address : addressList) { |
| | | byte[] bytes = s7PLC.readByte(address, 14); |
| | | |
| | | if (bytes != null) { |
| | | String str = new String(bytes, StandardCharsets.US_ASCII); |
| | | // System.out.println(bytes.toString()); |
| | | if (bytes != null) { |
| | | String str = new String(bytes, StandardCharsets.UTF_8); |
| | | // System.out.println(str); |
| | | // if(str == null ){ |
| | | // str = ""; |
| | | // } |
| | | result.add(str); |
| | | } |
| | | // if ( bytes.toString().contains("@")) { |
| | | // String str = ""; |
| | | // |
| | | // result.add(str); |
| | | // }else{ |
| | | // |
| | | // String str = new String(bytes, StandardCharsets.US_ASCII); |
| | | // result.add(str); |
| | | // } |
| | | // System.out.println(bytes.toString()); |
| | | } |
| | | |
| | | return result; |
| | |
| | | } |
| | | |
| | | public void outmesid(String data, String addr) { |
| | | System.out.println("outmesid: " + data); |
| | | // System.out.println("outmesid: " + data); |
| | | List<Byte> glassidlist = new ArrayList<>(); |
| | | String[] parts = addr.split("-"); |
| | | if (parts.length == 2) { |