| | |
| | | |
| | | byte[] content = result.Content; |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | StaProtocol staProtocol = station.get(staNos.get(staNoSize)); |
| | | StaProtocol staProtocol = station.get(staNos.get(i)); |
| | | parseStationStatus(content, i, staProtocol); |
| | | } |
| | | |
| | |
| | | */ |
| | | private void parseStationStatus(byte[] content, int index, StaProtocol staProtocol) { |
| | | int offset = index * StationStatusField.ALL.getByteLength(); |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(content, offset)); |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(content, offset + StationStatusField.TASK_NUMBER.getOffset())); |
| | | staProtocol.setStaNo((int) siemensS7Net.getByteTransform().TransInt16( |
| | | content, offset + StationStatusField.FINAL_TARGET.getOffset())); |
| | | |
| | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | StaProtocol staProtocol = station.get(barcodeArr.get(i)); |
| | | if (staProtocol == null) { |
| | | log.warn("站点不存在 [id:{}] [staNo:{}]", slave.getId(), barcodeArr.get(i)); |
| | | continue; |
| | | } |
| | | staProtocol.setBarcode(barcode); |
| | |
| | | for (int i = 0; i < weightArr.size(); i++) { |
| | | StaProtocol staProtocol = station.get(weightArr.get(i)); |
| | | if (staProtocol == null) { |
| | | log.warn("站点不存在 [id:{}] [staNo:{}]", slave.getId(), weightArr.get(i)); |
| | | continue; |
| | | } |
| | | double weight = siemensS7Net.getByteTransform().TransSingle(result.Content, i * 4); |
| | | staProtocol.setWeight(BigDecimal.valueOf(weight).setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | double weight = siemensS7Net.getByteTransform().TransSingle(result.Content, i * DeviceField.WEIGHT.getByteLength()); |
| | | staProtocol.setWeight(BigDecimal.valueOf(weight).setScale(4, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | } |
| | | |
| | |
| | | for (int i = 0; i < staNosError.size(); i++) { |
| | | Integer siteId = staNosError.get(i); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | |
| | | if (staProtocol == null){ |
| | | log.warn("站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNosError.get(i)); |
| | | continue; |
| | | } |
| | | short i1 = siemensS7Net.getByteTransform().TransInt16( |
| | | content, 0); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool( |
| | | content, i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | DeviceField.DIMENSION_WORD.getByteLength()); |
| | | content, 2+i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | 1); |
| | | |
| | | boolean[] status1 = siemensS7Net.getByteTransform().TransBool( |
| | | content, 2+i * DeviceField.DIMENSION_WORD.getByteLength()+1, |
| | | 1); |
| | | |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | |
| | | Integer siteId = staNos.get(i); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (staProtocol == null) { |
| | | log.warn("站点不存在 [id:{}] [staNo:{}]", slave.getId(), siteId); |
| | | continue; |
| | | } |
| | | |