#
Junjie
2025-11-05 8b4f5b2b23023986db813242cd04f4650537decd
src/main/java/com/zy/core/model/protocol/CrnProtocol.java
New file
@@ -0,0 +1,202 @@
package com.zy.core.model.protocol;
import com.zy.core.enums.CrnForkPosType;
import com.zy.core.enums.CrnLiftPosType;
import com.zy.core.enums.CrnModeType;
import com.zy.core.enums.CrnStatusType;
import lombok.Data;
/**
 * Created by vincent on 2020/8/7
 */
@Data
public class CrnProtocol {
    private Integer crnNo;
    /**
     * 1 = 手动模式
     * 2 = 自动模式
     * 3 = 电脑模式
     */
    public Integer mode;
    public CrnModeType modeType;
    /**
     * 异常码
     */
    public Integer alarm;
    /**
     * 任务号
     */
    public Integer taskNo = 0;
    /**
     * 堆垛机当前状态
     * 0:空闲,无任务
     * 1:取货定位中
     * 2:取货中
     * 3:取货完成,放货定位中
     * 4:放货中
     * 5:回原点中
     * 6:反原点
     * 7:库位移位
     * 90:任务完成等待WCS确认
     * 99:报警
     */
    public Integer status;
    /**
     * 状态枚举
     */
    public CrnStatusType statusType;
    /**
     * 堆垛机当前列号
     */
    public Integer bay;
    /**
     * 堆垛机当前层号
     */
    public Integer level;
    /**
     * 当前货叉位置
     * 0 = 货叉原位
     * 1 = 货叉在左侧
     * 2 = 货叉在右侧
     */
    public Integer forkPos;
    public CrnForkPosType forkPosType;
    /**
     * 当前载货台位置
     * 0 = 下定位
     * 1 = 上定位
     */
    public Integer liftPos;
    public CrnLiftPosType liftPosType;
    /**
     * 走行在定位
     * 0 = 在定位
     * 1 = 不在定位
     */
    public Integer walkPos;
    /**
     * 载货台有物
     */
    public Integer loaded;
    private Integer temp1;
    private Integer temp2;
    private Integer temp3;
    private Integer temp4;
    /**
     * X行走线速度m/min
     */
    private Integer xSpeed;
    /**
     * Y行走线速度m/min
     */
    private Integer ySpeed;
    /**
     * Z行走线速度m/min
     */
    private Integer zSpeed;
    /**
     * 堆垛机累计走行距离km
     */
    public Integer xDistance;
    /**
     * 堆垛机累计升降距离km
     */
    public Integer yDistance;
    /**
     * 堆垛机累计走行时长h
     */
    public Integer xDuration;
    /**
     * 堆垛机累计升降时长h
     */
    public Integer yDuration;
    /**
     * 最近一次入出库类型
     *       I:入库
     *       O:出库
     */
    private String lastIo = "I";
    /**
     * 堆垛机所在巷道
     */
    private Integer crnLane = 1;
    /**
     * 日志采集时间
     */
    private Long deviceDataLog = System.currentTimeMillis();
    /**
     * 上一次指令下发时间
     */
    private Long lastCommandTime = System.currentTimeMillis();
    public void setMode(Integer mode) {
        this.mode = mode;
        this.modeType = CrnModeType.get(mode);
    }
    public void setMode(CrnModeType type) {
        this.modeType = type;
        this.mode = CrnModeType.get(type).id;
    }
    public void setForkPos(Integer forkPos) {
        this.forkPos = forkPos;
        this.forkPosType = CrnForkPosType.get(forkPos);
    }
    public void setForkPos(CrnForkPosType type) {
        this.forkPosType = type;
        this.forkPos = CrnForkPosType.get(type).id;
    }
    public void setLiftPos(Integer liftPos) {
        this.liftPos = liftPos;
        this.liftPosType = CrnLiftPosType.get(liftPos);
    }
    public void setLiftPos(CrnLiftPosType type) {
        this.liftPosType = type;
        this.liftPos = CrnLiftPosType.get(type).id;
    }
    public void setStatus(Integer status){
        this.status = status;
        this.statusType = CrnStatusType.get(status);
    }
    public void setStatus(CrnStatusType type){
        this.statusType = type;
        this.status = CrnStatusType.get(type).id;
    }
}