From a7d5e6c4a45ca1f7bb1560ef4e76f4c1680c41db Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期六, 18 五月 2024 10:43:29 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java | 89 +++++++++++++++++++++++--------------------- 1 files changed, 47 insertions(+), 42 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java index 8ce012d..9ca36f9 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/action/ShuttleAction.java @@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.zy.asrs.wcs.common.ExecuteSupport; import com.zy.asrs.wcs.core.entity.Loc; import com.zy.asrs.wcs.core.entity.Task; import com.zy.asrs.wcs.core.model.NavigateNode; import com.zy.asrs.wcs.core.model.command.ShuttleAssignCommand; import com.zy.asrs.wcs.core.model.command.ShuttleCommand; import com.zy.asrs.wcs.core.model.command.ShuttleRedisCommand; +import com.zy.asrs.wcs.core.model.enums.MotionCtgType; import com.zy.asrs.wcs.core.model.enums.ShuttleCommandModeType; import com.zy.asrs.wcs.core.model.enums.ShuttleTaskModeType; import com.zy.asrs.wcs.core.service.BasShuttleService; @@ -26,12 +28,12 @@ import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; -import org.aspectj.apache.bcel.generic.RET; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.List; +import java.util.Objects; @Component public class ShuttleAction { @@ -110,16 +112,6 @@ if (shuttleProtocol == null) { return false; } - - //鍒ゆ柇璁惧鏄惁绌洪棽 - if (!shuttleThread.isDeviceIdle()) { - return false; - } -// if (!shuttleThread.isIdle(() -> { -// return shuttleProtocol.getTaskNo().equals(taskNo); -// })) { -// return false; -// } //鍒ゆ柇宸ヤ綔鍙锋槸鍚︾浉鍚� if (!shuttleProtocol.getTaskNo().equals(taskNo)) { @@ -223,6 +215,20 @@ //鍙栧嚭鍛戒护 ShuttleCommand command = commands.get(commandStep); + Integer mode = command.getMode(); + //鍒ゆ柇璁惧鏄惁绌洪棽 + if (!shuttleThread.isDeviceIdle(new ExecuteSupport() { + @Override + public Boolean judgement() { + if (ShuttleCommandModeType.CHARGE_CLOSE.id.equals(mode)) {//鍏抽棴鍏呯數motion + return false;//涓嶉渶瑕佸垽鏂姸鎬� + } + return true;//闇�瑕佸垽鏂姸鎬� + } + })) { + return false; + } + // 涓嬪彂鍛戒护 if (!write(command, device)) { News.error("鍥涘悜绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); @@ -244,8 +250,7 @@ if (shuttleThread == null) { return; } - - ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(false); if (shuttleProtocol == null) { return; } @@ -275,35 +280,6 @@ } if (shuttleProtocol.getMoveType() == 0) {//璺戣建閬� - ArrayList<String> locs = new ArrayList<>(); - for (int i = shuttleProtocol.getXCurrent(); i <= shuttleProtocol.getXTarget(); i++) { - String locNo = Utils.getLocNo(i, shuttleProtocol.getYCurrent(), lev); - locs.add(locNo); - } - - List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>() - .in(Loc::getLocNo, locs)); - if (locList.isEmpty()) { - //绌哄簱浣� - shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); - return; - } - - Loc start = locList.get(0); - Loc target = locList.get(locList.size() - 1); - //鍒ゆ柇灏忚溅鏄惁鍦ㄨ捣鐐逛綅缃� - if (!shuttleProtocol.getCurrentLocNo().equals(start.getLocNo())) {//涓嶅湪璧风偣浣嶇疆锛岃皟搴﹀幓璧风偣浣嶇疆 - shuttleDispatcher.generateMoveTask(device, start.getLocNo()); - }else { - //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃� - if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) { - shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝璺宠繃 - }else { - shuttleDispatcher.generateMoveTask(device, start.getLocNo()); - shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); - } - } - } else if (shuttleProtocol.getMoveType() == 1) {//璺戝簱浣� Integer xCurrent = shuttleProtocol.getXCurrent(); if (xCurrent > shuttleProtocol.getXTarget()) {//褰揦鍊煎ぇ浜嶺鐩爣鍊硷紝杩涜褰掗浂涓擸鏂瑰悜+1 shuttleProtocol.setXCurrent(shuttleProtocol.getXStart()); @@ -333,6 +309,35 @@ shuttleDispatcher.generateMoveTask(device, target.getLocNo()); shuttleProtocol.setXCurrent(shuttleProtocol.getXCurrent() + 1); } + } else if (shuttleProtocol.getMoveType() == 1) {//璺戝簱浣� + ArrayList<String> locs = new ArrayList<>(); + for (int i = shuttleProtocol.getXCurrent(); i <= shuttleProtocol.getXTarget(); i++) { + String locNo = Utils.getLocNo(i, shuttleProtocol.getYCurrent(), lev); + locs.add(locNo); + } + + List<Loc> locList = locService.list(new LambdaQueryWrapper<Loc>() + .in(Loc::getLocNo, locs)); + if (locList.isEmpty()) { + //绌哄簱浣� + shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); + return; + } + + Loc start = locList.get(0); + Loc target = locList.get(locList.size() - 1); + //鍒ゆ柇灏忚溅鏄惁鍦ㄨ捣鐐逛綅缃� + if (!shuttleProtocol.getCurrentLocNo().equals(start.getLocNo())) {//涓嶅湪璧风偣浣嶇疆锛岃皟搴﹀幓璧风偣浣嶇疆 + shuttleDispatcher.generateMoveTask(device, start.getLocNo()); + }else { + //鍦ㄨ捣鐐逛綅缃紝璋冨害鍘荤洰鏍囦綅缃� + if (shuttleProtocol.getCurrentLocNo().equals(target.getLocNo())) { + shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1);//灏忚溅鍜岀洰鏍囦綅缃竴鑷达紝璺宠繃 + }else { + shuttleDispatcher.generateMoveTask(device, start.getLocNo()); + shuttleProtocol.setYCurrent(shuttleProtocol.getYCurrent() + 1); + } + } } else if (shuttleProtocol.getMoveType() == 2) {//姣嶈建閬撳惊鐜窇 Integer xCurrent = shuttleProtocol.getXCurrent(); Integer yCurrent = shuttleProtocol.getYCurrent(); -- Gitblit v1.9.1