自动化立体仓库 - WCS系统
Junjie
2023-06-10 e1783e196a4ada918268b9f81bfb3a19641e0626
提升机状态读取、提升机高度设定、提升机操作方案
1个文件已修改
161 ■■■■■ 已修改文件
src/main/java/com/zy/core/thread/LiftThread.java 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LiftThread.java
@@ -5,18 +5,13 @@
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.ModBus.ModbusTcpNet;
import com.alibaba.fastjson.JSON;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasLift;
import com.zy.asrs.entity.BasLiftOpt;
import com.zy.asrs.entity.BasShuttle;
import com.zy.asrs.entity.BasShuttleOpt;
import com.zy.asrs.service.BasLiftOptService;
import com.zy.asrs.service.BasLiftService;
import com.zy.asrs.service.BasShuttleOptService;
import com.zy.asrs.service.BasShuttleService;
import com.zy.common.utils.CommonUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
@@ -114,7 +109,7 @@
    private void readStatus() {
        try {
            OperateResultExOne<byte[]> result = modbusTcpNet.Read("29", (short) 50);
            OperateResultExOne<byte[]> result = modbusTcpNet.Read("41117", (short) 50);
            if (result.IsSuccess) {
                if (null == liftProtocol) {
                    liftProtocol = new LiftProtocol();
@@ -128,46 +123,49 @@
                liftProtocol.setLiftLock(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content, 0)));
                //位置到达反馈
                liftProtocol.setPositionArrivalFeedback(modbusTcpNet.getByteTransform().TransInt16(content,2));
                //准备就绪
                liftProtocol.setReady(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content,4)));
                //运行中
                liftProtocol.setRunning(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content,6)));
                //联机/单机
                liftProtocol.setMode(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content,8)));
                //以下参数并未进行调整(需要后续针对实机进行获取和调试)
                byte by = modbusTcpNet.getByteTransform().TransByte(content, 5);
                int[] datas = CommonUtils.byteToBits(by);
                //准备就绪
                liftProtocol.setReady(CommonUtils.intToBoolean(datas[0]));
                //运行中
                liftProtocol.setRunning(CommonUtils.intToBoolean(datas[1]));
                //联机/单机
                liftProtocol.setMode(CommonUtils.intToBoolean(datas[2]));
                //输送线前端光电有货
                liftProtocol.setLineFrontHasStock(modbusTcpNet.getByteTransform().TransBool(content,10));
                liftProtocol.setLineFrontHasStock(CommonUtils.intToBoolean(datas[3]));
                //输送线正转反馈
                liftProtocol.setForwardRotationFeedback(modbusTcpNet.getByteTransform().TransBool(content,12));
                liftProtocol.setForwardRotationFeedback(CommonUtils.intToBoolean(datas[4]));
                //输送线反转反馈
                liftProtocol.setReverseFeedback(modbusTcpNet.getByteTransform().TransBool(content,14));
                liftProtocol.setReverseFeedback(CommonUtils.intToBoolean(datas[5]));
                //输送线电机过载
                liftProtocol.setMotorOverload(modbusTcpNet.getByteTransform().TransBool(content,16));
                liftProtocol.setMotorOverload(CommonUtils.intToBoolean(datas[6]));
                //输送线末端光电有货
                liftProtocol.setLineEndHasStock(modbusTcpNet.getByteTransform().TransBool(content,18));
                liftProtocol.setLineEndHasStock(CommonUtils.intToBoolean(datas[7]));
                //进输送线卡托盘报警
                liftProtocol.setInConveyLineCardTrayAlarm(modbusTcpNet.getByteTransform().TransBool(content,20));
                liftProtocol.setInConveyLineCardTrayAlarm(CommonUtils.intToBoolean(datas[8]));
                //出输送线卡托盘报警
                liftProtocol.setOutConveyLineCardTrayAlarm(modbusTcpNet.getByteTransform().TransBool(content,22));
                liftProtocol.setOutConveyLineCardTrayAlarm(CommonUtils.intToBoolean(datas[9]));
                //平台位置偏差报警
                liftProtocol.setPlatPositionDeviationAlarm(modbusTcpNet.getByteTransform().TransBool(content,24));
                liftProtocol.setPlatPositionDeviationAlarm(CommonUtils.intToBoolean(datas[10]));
                //平台扭矩偏差报警
                liftProtocol.setPlatTorqueDeviationAlarm(modbusTcpNet.getByteTransform().TransBool(content,26));
                liftProtocol.setPlatTorqueDeviationAlarm(CommonUtils.intToBoolean(datas[11]));
                //平台四向车检测
                liftProtocol.setPlatShuttleCheck(modbusTcpNet.getByteTransform().TransBool(content,28));
                liftProtocol.setPlatShuttleCheck(CommonUtils.intToBoolean(datas[12]));
                //未就绪状态
                liftProtocol.setNotReady(modbusTcpNet.getByteTransform().TransInt16(content,30));
                liftProtocol.setNotReady(modbusTcpNet.getByteTransform().TransInt16(content,6));
                //伺服1错误
                liftProtocol.setServoError1(modbusTcpNet.getByteTransform().TransInt16(content,32));
                liftProtocol.setServoError1(modbusTcpNet.getByteTransform().TransInt16(content,8));
                //伺服2错误
                liftProtocol.setServoError2(modbusTcpNet.getByteTransform().TransInt16(content,34));
                liftProtocol.setServoError2(modbusTcpNet.getByteTransform().TransInt16(content,10));
                //伺服3错误
                liftProtocol.setServoError3(modbusTcpNet.getByteTransform().TransInt16(content,36));
                liftProtocol.setServoError3(modbusTcpNet.getByteTransform().TransInt16(content,12));
                //伺服4错误
                liftProtocol.setServoError4(modbusTcpNet.getByteTransform().TransInt16(content,38));
                liftProtocol.setServoError4(modbusTcpNet.getByteTransform().TransInt16(content,14));
                //提升机实际速度反馈
                liftProtocol.setLiftActualSpeed(modbusTcpNet.getByteTransform().TransInt16(content,40));
                liftProtocol.setLiftActualSpeed(modbusTcpNet.getByteTransform().TransInt16(content,16));
                ///读取提升机状态-end
@@ -266,12 +264,16 @@
            //四层高度设定
            array[5] = command.getHeight4();
        }
        if (command.getHeight5() != null) {
            //四层高度设定
            array[6] = command.getHeight5();
        }
        if (command.getLiftLockShortValue() != null) {
            //提升机锁定
            array[29] = command.getLiftLockShortValue();
        }
        OperateResult result = modbusTcpNet.Write("0", array);;
        OperateResult result = modbusTcpNet.Write("41088", array);;
        if (result != null && result.IsSuccess) {
            News.info("提升机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
@@ -296,19 +298,25 @@
            }
            liftProtocol.setTaskNo(assignCommand.getTaskNo());
            switch (assignCommand.getTaskMode()) {
                case 1://上升一层
                    command = getLiftUpDownCommand(++lev);//获取提升机上升下降命令
                case 1://移动提升机
                    command = getLiftUpDownCommand(assignCommand.getLev());//获取提升机上升下降命令
                    break;
                case 2://下降一层
                    command = getLiftUpDownCommand(--lev);//获取提升机上升下降命令
                case 3://无货正转
                    command = getLiftTurnCommand(3);//获取提升机转动命令
                    break;
                case 3://有货正转
                case 4://无货反转
                    command = getLiftTurnCommand(4);//获取提升机转动命令
                    break;
                case 5://有货正转
                    command = getLiftTurnCommand(1);//获取提升机转动命令
                    break;
                case 4://有货反转
                case 6://有货反转
                    command = getLiftTurnCommand(2);//获取提升机转动命令
                    break;
                case 5://复位
                case 7://链条停止
                    command = getLiftTurnCommand(5);//获取提升机转动命令
                    break;
                case 0://复位
                    command = getResetCommand();//获取复位命令
                    break;
                default:
@@ -402,12 +410,6 @@
                    News.info("提升机手动任务执行完成,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
                }
                //下发一条提升机解锁命令
                LiftCommand unlockCommand = getUnlockCommand(command.getLiftNo());
                if (write(unlockCommand)) {
                    News.info("提升机状态已解锁,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
                }
            }
        }
@@ -430,7 +432,7 @@
     */
    public LiftCommand getResetCommand() {
        LiftCommand command = new LiftCommand();
        command.setRun((short) 0);
        command.setRun((short) 5);
        command.setLiftLock(false);
        return command;
    }
@@ -438,10 +440,35 @@
    /**
     * 获取提升机上升下降命令
     */
    public LiftCommand getLiftUpDownCommand(Short lev) {
    public LiftCommand getLiftUpDownCommand(Integer lev) {
        LiftCommand command = new LiftCommand();
        command.setRun((short) 1);//升降
        command.setDistPosition(lev);
        Short position = 1;
        switch (lev) {
            case 1:
                position = 1;
                break;
            case 2:
                position = 2;
                break;
            case 3:
                position = 4;
                break;
            case 4:
                position = 8;
                break;
            case 5:
                position = 16;
                break;
            default:
                position = 1;
        }
        command.setDistPosition(position);
        command.setSpeed((short) 200);
        command.setHeight2((short) 180);
        command.setHeight3((short) 1645);
        command.setHeight4((short) (2 * 1645));
        command.setHeight5((short) (3 * 1645));
        return command;
    }
@@ -454,16 +481,32 @@
        command.setLiftNo(liftNo);//提升机号
        command.setTaskNo(taskNo);//任务号
        command.setDistPosition(lev);//目标楼层1层
        command.setLiftLock(true);//锁定提升机
        return command;
    }
    /**
     * 获取提升机转动命令,direction:1=》有货正转,2=》有货反转
     * 获取提升机转动命令,direction:1=》有货正转,2=》有货反转,3=>无货正转,4=>无货反转
     */
    public LiftCommand getLiftTurnCommand(Integer direction) {
        LiftCommand command = new LiftCommand();
        command.setRun(direction == 1 ? (short) 6 : (short) 3);
        Short run = 0;
        switch (direction) {
            case 1:
                run = 6;//有货正转
                break;
            case 2:
                run = 3;//有货反转
                break;
            case 3:
                run = 2;//无货正转
                break;
            case 4:
                run = 7;//无货反转
                break;
            case 5:
                run = 4;//链条停止
        }
        command.setRun(run);
        return command;
    }
@@ -472,10 +515,26 @@
     */
    public LiftCommand getLiftTurnCommand(Short liftNo, Short taskNo, Integer direction) {
        LiftCommand command = new LiftCommand();
        command.setRun(direction == 1 ? (short) 6 : (short) 3);
        Short run = 0;
        switch (direction) {
            case 1:
                run = 6;//有货正转
                break;
            case 2:
                run = 3;//有货反转
                break;
            case 3:
                run = 2;//无货正转
                break;
            case 4:
                run = 7;//无货反转
                break;
            case 5:
                run = 4;//链条停止
        }
        command.setRun(run);
        command.setLiftNo(liftNo);//提升机号
        command.setTaskNo(taskNo);//任务号
        command.setLiftLock(true);//锁定提升机
        return command;
    }