自动化立体仓库 - WCS系统
Junjie
2023-05-11 d3696ce1ba6071f264aa3db8cc94bf090094a906
提升机命令封装
1个文件已修改
60 ■■■■ 已修改文件
src/main/java/com/zy/core/thread/LiftThread.java 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LiftThread.java
@@ -297,22 +297,19 @@
            liftProtocol.setTaskNo(assignCommand.getTaskNo());
            switch (assignCommand.getTaskMode()) {
                case 1://上升一层
                    command.setRun((short) 1);//升降
                    command.setDistPosition(++lev);
                    command = getLiftUpDownCommand(++lev);//获取提升机上升下降命令
                    break;
                case 2://下降一层
                    command.setRun((short) 1);//下降
                    command.setDistPosition(--lev);
                    command = getLiftUpDownCommand(--lev);//获取提升机上升下降命令
                    break;
                case 3://有货正转
                    command.setRun((short) 6);
                    command = getLiftTurnCommand(1);//获取提升机转动命令
                    break;
                case 4://有货反转
                    command.setRun((short) 3);
                    command = getLiftTurnCommand(2);//获取提升机转动命令
                    break;
                case 5://复位
                    command.setRun((short) 0);
                    command.setLiftLock(false);
                    command = getResetCommand();//获取复位命令
                    break;
                default:
            }
@@ -406,11 +403,8 @@
                }
                //下发一条提升机解锁命令
                LiftCommand liftCommand = new LiftCommand();
                liftCommand.setRun((short) 0);
                liftCommand.setLiftNo(command.getLiftNo());
                liftCommand.setLiftLock(false);
                if (write(liftCommand)) {
                LiftCommand unlockCommand = getUnlockCommand(command.getLiftNo());
                if (write(unlockCommand)) {
                    News.info("提升机状态已解锁,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command));
                }
@@ -421,6 +415,46 @@
    }
    /**
     * 获取提升机解锁命令
     */
    private LiftCommand getUnlockCommand(Short liftNo) {
        LiftCommand command = new LiftCommand();
        command.setRun((short) 0);
        command.setLiftNo(liftNo);
        command.setLiftLock(false);
        return command;
    }
    /**
     * 获取复位命令
     */
    private LiftCommand getResetCommand() {
        LiftCommand command = new LiftCommand();
        command.setRun((short) 0);
        command.setLiftLock(false);
        return command;
    }
    /**
     * 获取提升机上升下降命令
     */
    private LiftCommand getLiftUpDownCommand(Short lev) {
        LiftCommand command = new LiftCommand();
        command.setRun((short) 1);//升降
        command.setDistPosition(lev);
        return command;
    }
    /**
     * 获取提升机转动命令,direction:1=》有货正转,2=》有货反转
     */
    private LiftCommand getLiftTurnCommand(Integer direction) {
        LiftCommand command = new LiftCommand();
        command.setRun(direction == 1 ? (short) 6 : (short) 3);
        return command;
    }
    /**
     * 初始化提升机
     */
    private void initLift() {