Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
# Conflicts:
# springboot-vue3/src/main/java/com/example/springboot/mapper/HomeMapper.java
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 根据地址读取PCL数据 |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 40); |
| | | // Boolean[] values = { true, false, true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, |
| | |
| | | if (plclist != null) { |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | jsonObject.append("params", plclist); |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("alarm"); |
| | | if (sendwServer != null) { |
| | |
| | | Intlist.add(value == true ? 1 : 0); |
| | | |
| | | } |
| | | |
| | | // 将Intlist转换为数组 |
| | | Integer[] shuzu1 = Intlist.toArray(new Integer[0]); |
| | | |
| | | // 定义的报警内容数组 |
| | | String[] shuzu = { |
| | | "D01 VFD error", |
| | | "D02 VFD error", |
| | |
| | | }; |
| | | alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class); |
| | | for (short i = 0; i < shuzu.length; i++) { |
| | | // 查询对应报警信息结束时间为null的条数 |
| | | short result = alarmMapper.selectnullti(shuzu[i]); |
| | | // 读取到PLC的值为1并且对应报警信息结束时间为null的条数的条数为0 |
| | | if (shuzu1[i] == 1 && result == 0) { |
| | | // 填加一条报警信息,有开始时间 |
| | | alarmMapper.Insertalarm(shuzu[i]); |
| | | } else if (shuzu1[i] == 0 && result > 0) { |
| | | // 修改该条报警信息的结束时间 |
| | | alarmMapper.updatealarm(shuzu[i]); |
| | | } |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 58); |
| | | List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 44); |
| | | List<Boolean> plclist2 = S7control.getinstance().ReadBits("DB102.5.5", 13); |
| | | |
| | | // Boolean[] values = { 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, true, false, true, false, true, false, |
| | | // true, false, true, false, true, false, true, false, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | |
| | | // Boolean[] values2 = { true, false, |
| | | // true, false, true, false, true, false, |
| | | // true, false, true, false, true, }; |
| | | // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values)); |
| | | // List<Boolean> plclist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | |
| | | // 将plclist2的元素添加到plclist中 |
| | | plclist.addAll(plclist2); |
| | | // System.out.println(plclist); |
| | | if (plclist != null) { |
| | | // 将获取的布尔类型转换为整数类型 |
| | | List<Integer> Intlist = new ArrayList<>(); |
| | |
| | | } |
| | | s7PLC.writeMultiData(addressWrite); |
| | | } |
| | | /** |
| | | * 按指定的地址 写入多个byte |
| | | * |
| | | * @param address 地址 |
| | | * @param datas byte的值 |
| | | */ |
| | | public void WriteByte(String address, byte[] datas) { |
| | | if (s7PLC==null) |
| | | return; |
| | | // s7PLC.write(address, data); |
| | | s7PLC.writeByte(address, datas); |
| | | } |
| | | |
| | | /** |
| | | * 按指定的地址 读取word结果集 |
| | |
| | | List<String> addresslist = GetAddressList(address, count, 16); |
| | | return s7PLC.readInt16(addresslist); |
| | | } |
| | | /** |
| | | * 按指定的地址 读取byte结果集 |
| | | * |
| | | * @param address 地址 |
| | | * @param count 连续读多少个byte |
| | | * @return 结果 |
| | | */ |
| | | public byte[] ReadByte(String address, int count) { |
| | | if (s7PLC==null) |
| | | return null; |
| | | |
| | | // List<String> addresslist = GetAddressList(address, count, 16); |
| | | return s7PLC.readByte(address,count); |
| | | } |
| | | |
| | | /** |
| | | * 按指定的地址 按bit位 0 flase 1 true 读取结果 |