#
zy
2025-07-25 8e1cb9a0ff0f25f3c29fa05407e5ab35d3b484de
src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
@@ -5,29 +5,18 @@
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasLift;
import com.zy.asrs.entity.DeviceDataLog;
import com.zy.asrs.service.BasLiftService;
import com.zy.asrs.service.DeviceDataLogService;
import com.zy.asrs.utils.Utils;
import com.zy.common.ExecuteSupport;
import com.alibaba.fastjson.JSONObject;
import com.zy.common.SpringUtils;
import com.zy.common.utils.DateUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.action.ForkLiftAction;
import com.zy.core.action.ShuttleAction;
import com.zy.core.cache.OutputQueue;
import com.zy.core.enums.ForkLiftProtocolStatusType;
import com.zy.core.enums.ForkLiftTaskModeType;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.ForkLiftSlave;
import com.zy.core.model.command.ForkLiftCommand;
import com.zy.core.model.protocol.ForkLiftProtocol;
import com.zy.core.model.protocol.ForkLiftStaProtocol;
import com.zy.core.enums.*;
import com.zy.core.model.DeviceCommandMsgModel;
import com.zy.core.model.DeviceMsgModel;
import com.zy.core.properties.DeviceConfig;
import com.zy.core.thread.ForkLiftThread;
import com.zy.core.utils.DeviceMsgUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -38,43 +27,40 @@
@SuppressWarnings("all")
public class ZyForkLiftThread implements ForkLiftThread {
    private ForkLiftSlave slave;
    private ForkLiftProtocol forkLiftProtocol;
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private SiemensS7Net siemensS7Net;
    private List<ForkLiftStaProtocol> forkLiftStaProtocols = new ArrayList<>();
    private boolean connect = false;
    public ZyForkLiftThread(ForkLiftSlave slave, RedisUtil redisUtil) {
        this.slave = slave;
    public ZyForkLiftThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
        this.deviceConfig = deviceConfig;
        this.redisUtil = redisUtil;
        //初始化站点
        for (ForkLiftSlave.Sta sta : this.slave.getSta()) {
            ForkLiftStaProtocol forkLiftStaProtocol = new ForkLiftStaProtocol();
            forkLiftStaProtocol.setStaNo(sta.getStaNo());//站点号
            forkLiftStaProtocol.setLev(sta.getLev());//站点楼层
            String locNo = Utils.getLocNo(this.slave.getStaRow(), this.slave.getStaBay(), sta.getLev());
            forkLiftStaProtocol.setLocNo(locNo);//站点库位号
            forkLiftStaProtocol.setLiftNo(sta.getLiftNo());//提升机号
            forkLiftStaProtocols.add(forkLiftStaProtocol);
        }
    }
    @Override
    public boolean connect() {
        if (deviceConfig.getFake()) {
            this.connect = true;
            OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
            News.info("【{}】货叉提升机连接成功 ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
            return true;
        }
        boolean result = false;
        siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
        siemensS7Net.setRack(slave.getRack().byteValue());
        siemensS7Net.setSlot(slave.getSlot().byteValue());
        siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, deviceConfig.getIp());
        siemensS7Net.setRack(Integer.valueOf(0).byteValue());
        siemensS7Net.setSlot(Integer.valueOf(0).byteValue());
        OperateResult connect = siemensS7Net.ConnectServer();
        if(connect.IsSuccess){
            result = true;
            OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            News.info("货叉提升机连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
            News.info("【{}】货叉提升机连接成功 ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
        } else {
            OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            News.error("货叉提升机连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            OutputQueue.FORKLIFT.offer(MessageFormat.format( "【{0}】货叉提升机连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
            News.error("【{}】货叉提升机连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
        }
        // siemensS7Net.ConnectClose();
        this.connect = result;
        return result;
    }
@@ -85,302 +71,197 @@
    @Override
    public void run() {
        News.info("{}号货叉提升机线程启动", slave.getId());
        News.info("{}号货叉提升机线程启动", deviceConfig.getDeviceNo());
        this.connect();
        while (true) {
            try {
                read();
                DeviceMsgUtils deviceMsgUtils = null;
                try {
                    deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class);
                }catch (Exception e){}
                if (deviceMsgUtils == null) {
                    continue;
                }
                DeviceCommandMsgModel deviceCommandMsg = deviceMsgUtils.getDeviceCommandMsg(SlaveType.ForkLift, deviceConfig.getDeviceNo());
                if (deviceCommandMsg == null) {
                    continue;
                }
                executeCommand(deviceCommandMsg, deviceMsgUtils);
                Thread.sleep(200);
                execute();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private void execute() {
        ForkLiftAction forkLiftAction = SpringUtils.getBean(ForkLiftAction.class);
        if (forkLiftAction == null) {
    private void executeCommand(DeviceCommandMsgModel deviceCommandMsg, DeviceMsgUtils deviceMsgUtils) {
        if (deviceConfig.getFake()) {
            redisUtil.set(RedisKeyType.FAKE_DEVICE_FORK_LIFT_COMMAND_MSG_KEY.key + deviceConfig.getDeviceNo(), deviceCommandMsg, 60 * 60);
            return;
        }
        Object object = redisUtil.get(RedisKeyType.FORK_LIFT_FLAG.key + slave.getId());
        if (object == null) {
            return;
        }
        String command = JSON.toJSONString(deviceCommandMsg.getCommand());
        JSONObject commandObj = JSON.parseObject(command);
        Integer taskNo = Integer.valueOf(String.valueOf(object));
        if (taskNo != 0) {
            //存在任务需要执行
            boolean result = forkLiftAction.executeWork(slave.getId(), taskNo);
        }
    }
        HashMap<String, Object> resultData = new HashMap<>();
        resultData.put("result", "false");
    private void read() {
        try {
            readStatus();
        String deviceMsgType = "command";
        OperateResult result = null;
        OperateResult result2 = null;
        if (commandObj.getInteger("mode") == 3) {
            //取放货
            short[] array = new short[4];
            array[0] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            resultData.put("commandData", array);
            //提升机处于运行状态,将标记置为true
            if (forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.PICK_UP)
                    || forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.PUT_DOWN)
                    || forkLiftProtocol.getProtocolStatusType().equals(ForkLiftProtocolStatusType.WAITING)) {
                forkLiftProtocol.setPakMk(true);
            }
        } catch (Exception e) {
            OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
        }
    }
    private void readStatus() {
        try {
            //获取提升机数据
            OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) 16);
            if (result1.IsSuccess) {
                if (null == forkLiftProtocol) {
                    forkLiftProtocol = new ForkLiftProtocol();
                    forkLiftProtocol.setLiftNo(slave.getId());
                    forkLiftProtocol.setProtocolStatus(ForkLiftProtocolStatusType.NONE);
                    InnerForkLiftExtend innerForkLiftExtend = new InnerForkLiftExtend();
            result = siemensS7Net.Write("DB103.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
            }
        } else if (commandObj.getInteger("mode") == 4) {
            //小车换层
            short[] array = new short[4];
            array[0] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            resultData.put("commandData", array);
                //----------读取提升机状态-----------
            result = siemensS7Net.Write("DB103.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
            }
        } else if (commandObj.getInteger("mode") == 5) {
            //提升机移动
            short[] array = new short[4];
            array[0] = commandObj.getShort("taskNO");//任务号
            array[1] = commandObj.getShort("mode");//任务模式
            array[2] = commandObj.getShort("pick");//取货数据
            array[3] = commandObj.getShort("put");//放货数据
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.0", array);
            if (result.IsSuccess) {
                result2 = siemensS7Net.Write("DB103.8", (short) 1);
                if (result2.IsSuccess) {
                    resultData.put("result", "success");
                }
            }
        } else if (commandObj.getInteger("mode") == 9996) {
            //复位
            short[] array = new short[1];
            array[0] = 1;
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.10", array);
            if (result.IsSuccess) {
                resultData.put("result", "success");
            }
        } else if (commandObj.getInteger("mode") == 9997) {
            //切换入库模式
            short[] array = new short[1];
            array[0] = 1;
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.12", array);
            if (result.IsSuccess) {
                resultData.put("result", "success");
            }
        } else if (commandObj.getInteger("mode") == 9998) {
            //切换出库模式
            short[] array = new short[1];
            array[0] = 2;
            resultData.put("commandData", array);
            result = siemensS7Net.Write("DB103.12", array);
            if (result.IsSuccess) {
                resultData.put("result", "success");
            }
        } else if (commandObj.getInteger("mode") == 9999) {
            //读取状态
            JSONObject device = new JSONObject();
            OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB101.0", (short) 18);
            if (readResult1.IsSuccess) {
                //模式
                forkLiftProtocol.setModel((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 0));
                device.put("model", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 0));
                //PLC任务号
                forkLiftProtocol.setWrkNo((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 2));
                device.put("wrkNo", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 2));
                //任务状态
                forkLiftProtocol.setProtocolStatus((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 4));
                device.put("protocolStatus", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 4));
                //任务模式
                forkLiftProtocol.setTaskMode((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 6));
                device.put("taskMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 6));
                //取货数据
                forkLiftProtocol.setPick((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 8));
                device.put("pick", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 8));
                //放货数据
                forkLiftProtocol.setPut((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 10));
                device.put("put", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 10));
                //出入库模式
                forkLiftProtocol.setIOMode((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 12));
                device.put("iOMode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 12));
                //故障码
                forkLiftProtocol.setErrorCode((int) siemensS7Net.getByteTransform().TransInt16(result1.Content, 14));
                device.put("errorCode", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 14));
                //层
                device.put("lev", (int) siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 16));
                //************补充扩展字段*************
                InnerForkLiftExtend forkLiftExtend = (InnerForkLiftExtend) forkLiftProtocol.getExtend();
                forkLiftProtocol.setExtend(forkLiftExtend);
            }else {
                OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】{1}读取货叉提升机状态信息失败", DateUtils.convert(new Date()), slave.getId()));
                resultData.put("deviceStatus", device);
            }
            OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB102.0", (short) 8);
            if (result2.IsSuccess) {
                for (int i = 0; i < this.slave.getSta().size(); i++) {
                    ForkLiftSlave.Sta sta = this.slave.getSta().get(i);
                    if (forkLiftStaProtocols.isEmpty()) {
                        continue;
                    }
                    ForkLiftStaProtocol forkLiftStaProtocol = forkLiftStaProtocols.get(i);
                    boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result2.Content, i * 2, 2);
                    forkLiftStaProtocol.setHasTray(status1[0]);
                    forkLiftStaProtocol.setHasCar(status1[1]);
            //站点个数
            int staCount = 4;
            //读取托盘数据
            List<Integer> trayList = new ArrayList<>();
            OperateResultExOne<byte[]> readResult2 = siemensS7Net.Read("DB102.0", (short) (staCount * 2));
            if(readResult2.IsSuccess) {
                for (int i = 0; i < staCount; i++) {
                    short val = siemensS7Net.getByteTransform().TransInt16(readResult2.Content, i * 2);
                    trayList.add((int) val);
                }
            }
            if (System.currentTimeMillis() - forkLiftProtocol.getDeviceDataLog() > 1000 * 5) {
                //采集时间超过5s,保存一次数据记录
                //保存数据记录
                DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class);
                DeviceDataLog deviceDataLog = new DeviceDataLog();
                deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result1.Content));
                deviceDataLog.setWcsData(JSON.toJSONString(forkLiftProtocol));
                deviceDataLog.setType("forkLift");
                deviceDataLog.setDeviceNo(forkLiftProtocol.getLiftNo());
                deviceDataLog.setCreateTime(new Date());
                deviceDataLogService.insert(deviceDataLog);
                //更新采集时间
                forkLiftProtocol.setDeviceDataLog(System.currentTimeMillis());
            //读取小车数据
            OperateResultExOne<byte[]> readResult3 = siemensS7Net.Read("DB102.50", (short) (staCount * 2));
            List<Integer> carList = new ArrayList<>();
            if(readResult3.IsSuccess) {
                for (int i = 0; i < staCount; i++) {
                    short val = siemensS7Net.getByteTransform().TransInt16(readResult3.Content, i * 2);
                    carList.add((int) val);
                }
            }
            //将提升机状态保存至数据库
            BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class);
            BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>()
                    .eq("lift_no", slave.getId()));
            if (basLift == null) {
                basLift = new BasLift();
                //提升机号
                basLift.setLiftNo(forkLiftProtocol.getLiftNo());
                basLift.setStatus(1);
                basLiftService.insert(basLift);
            }
            //任务号
            basLift.setWrkNo(forkLiftProtocol.getTaskNo());
            //修改时间
            basLift.setUpdateTime(new Date());
            //设备状态
            basLift.setDeviceStatus(JSON.toJSONString(forkLiftProtocol));
            if (basLiftService.updateById(basLift)) {
                OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), forkLiftProtocol.getLiftNo()));
            }
            device.put("trayList", trayList);
            device.put("carList", carList);
        } catch (Exception e) {
            OutputQueue.FORKLIFT.offer(MessageFormat.format("【{0}】读取货叉提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
        }
    }
    @Override
    public ForkLiftProtocol getStatus(boolean clone) {
        if (this.forkLiftProtocol == null) {
            return null;
        }
        return clone ? this.forkLiftProtocol.clone() : this.forkLiftProtocol;
    }
    @Override
    public List<ForkLiftStaProtocol> getForkLiftStaProtocols() {
        return this.forkLiftStaProtocols;
    }
    @Override
    public ForkLiftProtocol getStatus() {
        return getStatus(true);
    }
    @Override
    public CommandResponse pickAndPut(ForkLiftCommand command) {
        CommandResponse response = new CommandResponse(false);
        short[] array = new short[4];
        array[0] = command.getTaskNo();//任务号
        array[1] = command.getMode();//任务模式
        array[2] = command.getPick();//取货数据
        array[3] = command.getPut();//放货数据
        OperateResult result = siemensS7Net.Write("DB103.0", array);
        if (result.IsSuccess) {
            OperateResult result2 = siemensS7Net.Write("DB103.8", command.getConfirm());
            if (result2.IsSuccess) {
                response.setResult(true);
            }
        }
        return response;
    }
    @Override
    public CommandResponse shuttleSwitch(ForkLiftCommand command) {
        CommandResponse response = new CommandResponse(false);
        short[] array = new short[4];
        array[0] = command.getTaskNo();//任务号
        array[1] = command.getMode();//任务模式
        array[2] = command.getPick();//取货数据
        array[3] = command.getPut();//放货数据
        OperateResult result = siemensS7Net.Write("DB103.0", array);
        if (result.IsSuccess) {
            OperateResult result2 = siemensS7Net.Write("DB103.8", command.getConfirm());
            if (result2.IsSuccess) {
                response.setResult(true);
            }
        }
        return response;
    }
    @Override
    public CommandResponse reset() {
        CommandResponse response = new CommandResponse(false);
        OperateResult result = siemensS7Net.Write("DB103.10", (short) 1);
        if (result.IsSuccess) {
            News.info("货叉提升机确认命令下发成功,提升机号={}", forkLiftProtocol.getLiftNo());
            response.setResult(true);
        }
        return response;
    }
    @Override
    public boolean isIdle() {
        if (this.forkLiftProtocol.getTaskNo() == null
                || this.forkLiftProtocol.getProtocolStatus() == null
                || this.forkLiftProtocol.getModel() == null
        ) {
            return false;
            deviceMsgType = "status";
        }
        boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id
                && this.forkLiftProtocol.getWrkNo() == 0
                && this.forkLiftProtocol.getTaskNo() == 0
                && this.forkLiftProtocol.getModel() == 2;
        return res;
    }
        resultData.put("commandResult1", JSON.toJSONString(result));
        resultData.put("commandResult2", JSON.toJSONString(result2));
    @Override
    public boolean isDeviceIdle() {
        return isDeviceIdle(null);
    }
    @Override
    public boolean isDeviceIdle(ExecuteSupport support) {
        if (null != support) {
            Boolean judgement = support.judgement();
            if (judgement != null && !judgement) {
                return true;
            }
        if (deviceMsgType.equals("command")) {
            log.info("收到Rcs ForkLift Command Data: {}", JSON.toJSONString(deviceCommandMsg));
        }
        if (this.forkLiftProtocol.getTaskNo() == null
                || this.forkLiftProtocol.getProtocolStatus() == null
                || this.forkLiftProtocol.getModel() == null
        ) {
            return false;
        }
        boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id
                && this.forkLiftProtocol.getWrkNo() == 0
                && this.forkLiftProtocol.getModel() == 2;
        return res;
        DeviceMsgModel deviceMsgModel = new DeviceMsgModel();
        deviceMsgModel.setDeviceId(deviceConfig.getDeviceNo());
        deviceMsgModel.setDeviceMsgType(deviceMsgType);
        deviceMsgModel.setDeviceMsg(JSON.toJSONString(resultData));
        deviceMsgModel.setDeviceOriginMsg(JSON.toJSONString(resultData));
        deviceMsgModel.setResultKey(deviceCommandMsg.getResultKey());
        deviceMsgUtils.sendDeviceMsg(SlaveType.ForkLift, deviceConfig.getDeviceNo(), deviceMsgModel);
    }
    @Override
    public boolean setProtocolStatus(ForkLiftProtocolStatusType status) {
        return false;
    }
    @Override
    public boolean setSyncTaskNo(Integer taskNo) {
        this.forkLiftProtocol.setSyncTaskNo(taskNo);
        return true;
    }
    @Override
    public int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type) {
        return taskNo;
    }
    @Override
    public List<ForkLiftCommand> getPickAndPutCommand(Integer taskNo, Integer pick, Integer put) {
        List<ForkLiftCommand> commands = new ArrayList<>();
        ForkLiftCommand command = new ForkLiftCommand();
        command.setLiftNo(slave.getId());
        command.setTaskNo(taskNo.shortValue());
        command.setMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue());
        command.setPick(pick.shortValue());
        command.setPut(put.shortValue());
        command.setConfirm((short) 1);
        commands.add(command);
        return commands;
    }
    @Override
    public List<ForkLiftCommand> getShuttleSwitchCommand(Integer taskNo, Integer originLev, Integer targetLev) {
        List<ForkLiftCommand> commands = new ArrayList<>();
        ForkLiftCommand command = new ForkLiftCommand();
        command.setLiftNo(slave.getId());
        command.setTaskNo(taskNo.shortValue());
        command.setMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue());
        command.setPick(originLev.shortValue());
        command.setPut(targetLev.shortValue());
        command.setConfirm((short) 1);
        commands.add(command);
        return commands;
    public DeviceConfig getDeviceConfig() {
        return this.deviceConfig;
    }
    /**