| | |
| | | import java.util.Arrays; |
| | | |
| | | public class Plcsign extends Thread { |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | public Plcsign() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | |
| | | String name = ""; |
| | | Integer count = 0; |
| | | |
| | |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | Thread.sleep(100); |
| | | } 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", 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)); |
| | | |
| | | List<String> addressList21 = Arrays.asList(config.getProperty("PlcIO.State").split(",")); |
| | | List<Boolean> plclist = S7control.getinstance().readBits(addressList21); |
| | | // List<String> addressListName = Arrays.asList(config.getProperty("PlcIO.Name").split(",")); |
| | | // List<String> addressListName1 = Arrays.asList(config.getProperty("PlcIO.Name1").split(",")); |
| | | // System.out.println("急停"+S7control.getinstance().ReadBits("DB10.0.5", 1)); |
| | | |
| | | if (plclist != null) { |
| | | // 将获取的布尔类型转换为整数类型 |
| | | List<Integer> Intlist = new ArrayList<>(); |
| | |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.append("sig", Intlist); |
| | | // jsonObject.append("addressListName", addressListName); |
| | | // jsonObject.append("addressListName1", addressListName1); |
| | | // WebSocketServer sendwServer3 = WebSocketServer.sessionMap.get("Sign"); |
| | | // if (sendwServer3 != null) { |
| | | // sendwServer3.sendMessage(jsonObject.toString()); |