| | |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | // System.out.println(PlcAddress); |
| | | |
| | | // List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, |
| | | // Plccount); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 112); |
| | | |
| | | // Boolean[] values = { true, true, true, true, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, |
| | | // false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, null, |
| | | // true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | |
| | | if (plclist != null) { |
| | | // 将获取的布尔类型转换为整数类型 |
| | | List<Integer> Intlist = new ArrayList<>(); |
| | | for (Boolean value : plclist) { |
| | | if (value != null) { |
| | | Intlist.add(value == true ? 0 : 1); |
| | | } |
| | | |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.append("sig", Intlist); |
| | | // WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign"); |
| | | // if (sendwServer3 != null) { |
| | | // sendwServer3.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Sign"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } |
| | | } |
| | | } |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | // System.out.println(PlcAddress); |
| | | |
| | | // List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 64); |
| | | |
| | | // Boolean[] values = { true, true, true, true, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, |
| | | // false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, null, |
| | | // true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | |
| | | if (plclist != null) { |
| | | // 将获取的布尔类型转换为整数类型 |
| | | List<Integer> Intlist = new ArrayList<>(); |
| | | for (Boolean value : plclist) { |
| | | if (value != null) { |
| | | Intlist.add(value == true ? 0 : 1); |
| | | } |
| | | |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.append("sig", Intlist); |
| | | // WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign"); |
| | | // if (sendwServer3 != null) { |
| | | // sendwServer3.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Sign"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |