| | |
| | | |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read( |
| | | DeviceField.BARCODE.buildAddress(), |
| | | (short) ( DeviceField.BARCODE.getByteLength() * DeviceField.BARCODE.getArrLength())); |
| | | (short) (DeviceField.BARCODE.getByteLength() * DeviceField.BARCODE.getArrLength())); |
| | | |
| | | if (!result.IsSuccess) { |
| | | log.warn("读取条码失败 [id:{}]", slave.getId()); |
| | |
| | | byte[] content = result.Content; |
| | | for (int i = 0; i < DeviceField.BARCODE.getArrLength(); i++) { |
| | | int[] seg = DeviceField.BARCODE.getSeg(); |
| | | Short staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0]+i * DeviceField.BARCODE.getByteLength()); |
| | | int staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0] + i * DeviceField.BARCODE.getByteLength()); |
| | | String barcode = siemensS7Net.getByteTransform().TransString( |
| | | content, seg[1]+i * DeviceField.BARCODE.getByteLength(), |
| | | DeviceField.BARCODE.getByteLength()-seg[1], "UTF-8"); |
| | | content, seg[1] + i * DeviceField.BARCODE.getByteLength(), |
| | | DeviceField.BARCODE.getByteLength() - seg[1], "UTF-8"); |
| | | |
| | | if (!Cools.isEmpty(barcode)&& staNo !=null) { |
| | | if (!Cools.isEmpty(barcode) && staNo != 0) { |
| | | StaProtocol staProtocol = station.get(staNo); |
| | | if (staProtocol == null) { |
| | | log.warn("扫码站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo); |
| | |
| | | * 读取重量信息 |
| | | */ |
| | | private void readWeight() { |
| | | if ( slave.getWeight() == null || ! slave.getWeight()) { |
| | | if (slave.getWeight() == null || !slave.getWeight()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | byte[] content = result.Content; |
| | | for (int i = 0; i < DeviceField.WEIGHT.getArrLength() ; i++) { |
| | | for (int i = 0; i < DeviceField.WEIGHT.getArrLength(); i++) { |
| | | int[] seg = DeviceField.WEIGHT.getSeg(); |
| | | Short staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0]+i * DeviceField.WEIGHT.getByteLength()); |
| | | int staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0] + i * DeviceField.WEIGHT.getByteLength()); |
| | | Double weight = (double) siemensS7Net.getByteTransform().TransSingle( |
| | | content, seg[1] + i * DeviceField.WEIGHT.getByteLength()); |
| | | if (!Cools.isEmpty(weight)&& staNo !=null) { |
| | | if (!Cools.isEmpty(weight) && staNo != 0) { |
| | | StaProtocol staProtocol = station.get(staNo); |
| | | if (staProtocol == null) { |
| | | log.warn("称重站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo); |
| | |
| | | } |
| | | staProtocol.setWeight(BigDecimal.valueOf(weight).setScale(4, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 读取外形检测错误 |
| | | */ |
| | | private void readDimensionErrors() { |
| | | if ( slave.getStaNosError() == null || !slave.getStaNosError()) { |
| | | if (slave.getStaNosError() == null || !slave.getStaNosError()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | byte[] content = result.Content; |
| | | for (int i = 0; i < DeviceField.DIMENSION_WORD.getArrLength(); i++) { |
| | | int[] seg = DeviceField.DIMENSION_WORD.getSeg(); |
| | | Short staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | int staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0]); |
| | | if ( staNo !=null) { |
| | | if (staNo != 0) { |
| | | StaProtocol staProtocol = station.get(staNo); |
| | | if (staProtocol == null){ |
| | | if (staProtocol == null) { |
| | | log.warn("异常站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo); |
| | | continue; |
| | | } |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool( |
| | | content, seg[1]+i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | content, seg[1] + i * DeviceField.DIMENSION_WORD.getByteLength(), |
| | | 1); |
| | | //未使用,预留 |
| | | // boolean[] status1 = siemensS7Net.getByteTransform().TransBool( |