| | |
| | | private void read() throws InterruptedException { |
| | | ArrayList<BasConveyorSta> staNos = getStaNo(); |
| | | int staNoSize = staNos.size(); |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB1000.100", (short) (staNoSize*8)); |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB1000.100", (short) (staNoSize * 40)); |
| | | if (result.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | BasConveyorSta siteStation = staNos.get(i); |
| | |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setStaNo( siemensS7Net.getByteTransform().TransInt16(result.Content, i*8 + 4 )); // 目标站 |
| | | Thread.sleep(300); |
| | | staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, i * 8)); // 工作号 |
| | | |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, i*8+6, 2); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | | staProtocol.setOutEnable(status[3]);// 可出 |
| | | staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | staProtocol.setHigh(status[6]); // 高库位 |
| | | staProtocol.setLow(status[7]); // 低库位 |
| | | staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, i * 40 + 2)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 40 + 4)); // 目标站 |
| | | staProtocol.setAutoing(siemensS7Net.getByteTransform().TransInt32(result.Content, i * 40 + 6) == 2); // 自动 |
| | | staProtocol.setLoading(siemensS7Net.getByteTransform().TransInt32(result.Content, i * 40 + 6) == 2); // 有物 |
| | | // staProtocol.setInEnable(status[2]); // 可入 |
| | | // staProtocol.setOutEnable(status[3]);// 可出 |
| | | // staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | // staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | // staProtocol.setHigh(status[6]); // 高库位 |
| | | // staProtocol.setLow(status[7]); // 低库位 |
| | | |
| | | if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | ArrayList<BasConveyorSta> errorStaNo = getStaNo(); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.800.0", (short) (errorStaNo.size() * 4)); |
| | | if (result3.IsSuccess) { |
| | | for (int i = 0; i < errorStaNo.size(); i++) { |
| | | BasConveyorSta siteStation = errorStaNo.get(i); |
| | | Integer siteId = siteStation.getSiteNo(); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, (i * 4 + 2), 2); |
| | | staProtocol.setFrontErr(status[0]);//前超限 |
| | | staProtocol.setBackErr(status[1]);//后超限 |
| | | staProtocol.setHighErr(status[2]);//超高 |
| | | staProtocol.setLeftErr(status[3]);//左超限 |
| | | staProtocol.setRightErr(status[4]);//右超限 |
| | | staProtocol.setWeightErr(status[5]);//超重 |
| | | staProtocol.setBarcodeErr(status[6]);//扫码失败 |
| | | } |
| | | } |
| | | |