自动化立体仓库 - WCS系统
Junjie
2023-08-01 3c8b4f87fa61885f3c28d00eb6b9c9abde9bd462
src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -17,11 +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.*;
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;
@@ -356,6 +358,11 @@
            return false;
        }
        //检测穿梭车是否在提升机内
        if (!checkShuttleInTheLift(wrkNo)) {
            return false;
        }
        //检查路径是否可行走(检查路径锁定状态,检测路径是否有其他小车)
        //检测当前行走路径,和下一步路径
        boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(command.getNodes(), shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(shuttleProtocol.getCurrentLocNo()));
@@ -496,4 +503,46 @@
        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;//默认不放行
    }
}