| | |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() !=staProtocol.isFullPlt() ? (staProtocol.isEmptyMk()?"空" : "满"): "-"); // 空板信号 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() != staProtocol.isFullPlt() ? (staProtocol.isEmptyMk() ? "空" : "满") : "-"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setWeight(staProtocol.getWeight() == null ? 0D : staProtocol.getWeight()); |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow()? ( staProtocol.isLow() ? "低" : "高"): "-"); //高低库位 |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() ? (staProtocol.isLow() ? "低" : "高") : "-"); //高低库位 |
| | | |
| | | } |
| | | |
| | |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() !=staProtocol.isFullPlt() ? (staProtocol.isEmptyMk()?"空" : "满"): "-"); // 空板信号 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() != staProtocol.isFullPlt() ? (staProtocol.isEmptyMk() ? "空" : "满") : "-"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setWeight(staProtocol.getWeight() ==null ? 0D : staProtocol.getWeight()); |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow()? ( staProtocol.isLow() ? "低" : "高"): "-"); //高低库位 |
| | | vo.setWeight(staProtocol.getWeight() == null ? 0D : staProtocol.getWeight()); |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() ? (staProtocol.isLow() ? "低" : "高") : "-"); //高低库位 |
| | | return R.ok().add(vo); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public enum DeviceField { |
| | | // 扫码器:每站点16字节,String[14] |
| | | BARCODE("DB103", 254, 18,new int[]{0,2},21), |
| | | BARCODE("DB103", 254, 18, new int[]{0, 2}, 21), |
| | | // 出入库模式 |
| | | IO_MODE("DB103", 170, 4,new int[]{0,2},21), |
| | | IO_MODE("DB103", 170, 4, new int[]{0, 2}, 21), |
| | | // 称重:每站点4字节,Float |
| | | WEIGHT("DB103", 634, 6,new int[]{0,2},21), |
| | | WEIGHT("DB103", 634, 6, new int[]{0, 2}, 21), |
| | | // 尺寸异常:每站点2字节,Bit数组 |
| | | DIMENSION_WORD("DB103", 2, 8,new int[]{0,2,4,6},21); |
| | | DIMENSION_WORD("DB103", 2, 8, new int[]{0, 2, 4, 6}, 21); |
| | | |
| | | private final String addressPattern; |
| | | private final int offset; |
| | |
| | | private final int[] seg; |
| | | private final int arrLength; |
| | | |
| | | DeviceField(String addressPattern, int offset, int byteLength,int[] seg, int arrLength) { |
| | | DeviceField(String addressPattern, int offset, int byteLength, int[] seg, int arrLength) { |
| | | this.addressPattern = addressPattern; |
| | | this.offset = offset; |
| | | this.byteLength = byteLength; |
| | |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class OutOperationHandler implements OperationHandler { |
| | | public class OutOperationHandler implements OperationHandler { |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | |
| | | |
| | | private Boolean weight; |
| | | |
| | | private Boolean barcode ; |
| | | private Boolean barcode; |
| | | |
| | | private Boolean staNosError ; |
| | | private Boolean staNosError; |
| | | |
| | | private List<Sta> releaseSta = new ArrayList<>(); |
| | | |
| | |
| | | private List<Sta> inSta = new ArrayList<>(); |
| | | |
| | | private List<Integer> staNos = new ArrayList<>(); |
| | | |
| | | |
| | | |
| | | @Data |
| | |
| | | return; |
| | | } |
| | | |
| | | int baseOffset = TaskField.ALL.getOffset() + index * TaskField.ALL.getByteLength(); |
| | | int baseOffset = TaskField.ALL.getOffset() + index * TaskField.ALL.getByteLength(); |
| | | String workNoAddr = TaskField.TASK_NUMBER.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | | + (baseOffset + TaskField.TASK_NUMBER.getOffset()); |
| | | String destStaAddr = TaskField.DEST_STATION.getAddressPattern() + PlcConstant.ADDRESS_CONCATENATION |
| | |
| | | |
| | | 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()); |
| | |
| | | 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()); |
| | | 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 != null) { |
| | | 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()); |
| | | 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 != null) { |
| | | 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; |
| | | } |
| | | |
| | |
| | | int[] seg = DeviceField.DIMENSION_WORD.getSeg(); |
| | | Short staNo = siemensS7Net.getByteTransform().TransInt16( |
| | | content, seg[0]); |
| | | if ( staNo !=null) { |
| | | if (staNo != null) { |
| | | 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( |
| | |
| | | <input id="staNo" name="staNo" type="number" min="0" class="form-input" |
| | | autocomplete="off"> |
| | | </div> |
| | | <!-- <div class="form-group">--> |
| | | <!-- <label class="form-label" for="pakMk">入库标记:</label>--> |
| | | <!-- <input id="pakMk" name="pakMk" type="text" class="form-input"--> |
| | | <!-- autocomplete="off">--> |
| | | <!-- </div>--> |
| | | <!-- <div class="form-group">--> |
| | | <!-- <label class="form-label" for="pakMk">入库标记:</label>--> |
| | | <!-- <input id="pakMk" name="pakMk" type="text" class="form-input"--> |
| | | <!-- autocomplete="off">--> |
| | | <!-- </div>--> |
| | | </form> |
| | | </div> |
| | | <div class="modal-footer"> |