| | |
| | | // System.out.println(stt); |
| | | // List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12); |
| | | // List<Short> state = S7control.getinstance().ReadWord("DB103.0", 10); |
| | | Short[] values1 = { 1, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 }; |
| | | Short[] values1 = { 1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 }; |
| | | List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | |
| | | Short[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| | | List<Short> state = new ArrayList<>(Arrays.asList(values2)); |
| | | |
| | | Boolean[] values = { false, true, true, true, true, true, true, true, true, |
| | | true, true, true, true, true, true, true, true, true, true, true, true, true, true, |
| | | true, false, true }; |
| | | List<Boolean> paramlist = new ArrayList<>(Arrays.asList(values)); |
| | | |
| | | short[] sholist = new short[paramlist.size()]; |
| | | |
| | | for (int i = 0; i < paramlist.size(); i++) { |
| | | boolean value = paramlist.get(i); |
| | | sholist[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5} |
| | |
| | | |
| | | jsonObject.append("params", arraylist); |
| | | jsonObject.append("state", state); |
| | | jsonObject.append("action", sholist); |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter"); |
| | | if (sendwServer != null) { |
| | | sendwServer.sendMessage(jsonObject.toString()); |
| | |
| | | } |
| | | |
| | | // 将消息值写入 PLC |
| | | S7control.getinstance().WriteWord(addressList, messageValues); |
| | | // S7control.getinstance().WriteWord(addressList, messageValues); |
| | | System.out.println("messageValues:" + messageValues); |
| | | System.out.println("addressList:" + addressList); |
| | | // 清空消息列表 |