| | |
| | | * 读取状态 ====> 整块plc |
| | | */ |
| | | private void read() throws InterruptedException { |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 64); |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) 128); |
| | | if (result.IsSuccess) { |
| | | for (int i = 0; i < staNos.size(); i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2)); // 工作号 |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4+2)); // 目标站 |
| | | } |
| | | } |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 64); |
| | | if (result0.IsSuccess) { |
| | | for (int i = 0; i < staNos.size(); i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2)); // 目标站 |
| | | } |
| | | } |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 64); |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) 128); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 0; i < staNos.size(); i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*4+2, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | |
| | | charge2 = status[2]; |
| | | } |
| | | |
| | | if (result.IsSuccess && result0.IsSuccess && result1.IsSuccess) { |
| | | if (result.IsSuccess && result1.IsSuccess) { |
| | | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | | |