自动化立体仓库 - WCS系统
Junjie
2023-08-01 3c8b4f87fa61885f3c28d00eb6b9c9abde9bd462
src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -17,14 +17,13 @@
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
import com.zy.core.model.LiftSlave;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.NyShuttleHttpCommand;
import com.zy.core.model.command.ShuttleAssignCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.ShuttleRedisCommand;
import com.zy.core.model.command.*;
import com.zy.core.model.protocol.LiftProtocol;
import com.zy.core.model.protocol.NyShuttleProtocol;
import com.zy.core.properties.SlaveProperties;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -359,6 +358,11 @@
            return false;
        }
        //检测穿梭车是否在提升机内
        if (!checkShuttleInTheLift(wrkNo)) {
            return false;
        }
        //检查路径是否可行走(检查路径锁定状态,检测路径是否有其他小车)
        //检测当前行走路径,和下一步路径
        boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(command.getNodes(), shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()));
@@ -480,6 +484,64 @@
            return true;//提升机达到小车楼层,放行
        }
        //提升机未到达小车楼层,呼叫提升机
        //获取提升机命令
        NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, null, basDevp.getDevNo(), wrkNo.intValue());
        ArrayList<NyLiftCommand> liftCommands = new ArrayList<>();
        liftCommands.add(liftCommand);
        //提交到线程去工作
        LiftAssignCommand assignCommand = new LiftAssignCommand();
        assignCommand.setCommands(liftCommands);
        assignCommand.setLiftNo(liftProtocol.getLiftNo());
        assignCommand.setTaskNo(wrkNo);
        assignCommand.setTaskMode(NyLiftTaskModelType.MOVE_CAR.id.shortValue());
        //下发任务
        MessageQueue.offer(SlaveType.Lift, liftProtocol.getLiftNo().intValue(), new Task(3, assignCommand));
        return false;//默认不放行
    }
    /**
     * 检测穿梭车是否在提升机内
     * 如穿梭车在提升机内,必须等待提升机空闲才可执行穿梭车命令
     */
    private boolean checkShuttleInTheLift(Short wrkNo) {
        //读取redis数据
        if (wrkNo == null) {
            return false;
        }
        Object o = redisUtil.get("shuttle_wrk_no_" + wrkNo);
        if (o == null) {
            return false;
        }
        SlaveProperties slaveProperties = SpringUtils.getBean(SlaveProperties.class);
        BasLiftService liftService = SpringUtils.getBean(BasLiftService.class);
        for (LiftSlave liftSlave : slaveProperties.getLift()) {
            BasLift basLift = liftService.selectById(liftSlave.getId());
            if (basLift == null) {
                continue;
            }
            if (basLift.getPoint().equals(shuttleProtocol.getPoint())) {
                //小车在提升机内
                //判断提升机是否空闲
                LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId());
                if (liftThread == null) {
                    return false;
                }
                LiftProtocol liftProtocol = liftThread.getLiftProtocol();
                if (liftProtocol == null) {
                    return false;
                }
                if (liftProtocol.isIdle()) {
                    //提升机处于空闲,放行
                    return true;
                }
            }
        }
        return false;//默认不放行
    }