| | |
| | | } |
| | | |
| | | |
| | | //读取String |
| | | //读取StringList |
| | | public List<String> readStrings(List<String> addressList) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | //读取字符串 |
| | | public String readString(String address) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | return s7PLC.readString(address); |
| | | } catch (Exception e) { |
| | | System.out.println("读取 " + address + " 失败:" + e.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<Short> data = new ArrayList<>(); |
| | | |
| | | for (String address : addresses) { |
| | | try { |
| | | |
| | | // 单个地址 |
| | | Short value = s7PLC.readInt16(address); |
| | | data.add(value); |
| | |
| | | return data; |
| | | } |
| | | |
| | | //读取单个word |
| | | public Short readWord(String address) { |
| | | if (s7PLC == null) { |
| | | return null; |
| | | } |
| | | try { |
| | | // 单个地址 |
| | | return s7PLC.readInt16(address); |
| | | } catch (Exception e) { |
| | | System.out.println("读取 " + address + " 失败:" + e.getMessage()); |
| | | |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | //读取时间 |
| | | public Long readtime(String address) { |
| | | if (s7PLC == null) { |