野心家
2025-05-23 d75bdc98e2bc456eecfa4003bf700cb701d52a9b
src/main/java/com/zy/core/model/protocol/RgvProtocol.java
@@ -18,9 +18,9 @@
     * 2 = 自动模式
     * 3 = 电脑模式
     */
    public Short mode;
    public Short mode = -1;
    public RgvModeType modeType;
    public RgvModeType modeType = RgvModeType.NONE;
    /**
     * RGV当前状态
@@ -28,41 +28,32 @@
     * 1:作业中
     * 2:报警
     */
    public Short status;
    public Short status = -1;
    /**
     * 状态枚举
     */
    public RgvStatusType statusType;
    public RgvStatusType statusType = RgvStatusType.NONE;
    /**
     * 工位1任务号
     * 任务号
     */
    public Short taskNo1 = 0;
    public Long taskNo = 0L;
    /**
     * RGV工位1当前状态
     * 0:空闲,无任务
     * 11:取货中
     * 12:放货中
     * 10:任务完成等待WCS确认
     * 有物
     */
    public Short status1;
    /**
     * 状态枚举
     */
    public RgvStatusType statusType1;
    /**
     * 工位1有物
     */
    public Short loaded1;//0 无物;1 有物
    public Short loaded = -1;//0 无物;1 有物
    /**
     * RGV当前位置
     */
    public Short RgvPos;
    public Long RgvPos = 0L;
    /**
     * RGV目的位置
     */
    public Long RgvPosDestination = 0L;
    /**
     * 走行在定位
@@ -71,51 +62,10 @@
     */
    public Short walkPos;
    //////////////////////     工位2定义   //////////////////////////////////////////////////
    /**
     * 工位2任务号
     */
    public Short taskNo2 = 0;
    /**
     * RGV工位2当前状态
     * 0:空闲,无任务
     * 11:取货中
     * 12:放货中
     * 10:任务完成等待WCS确认
     */
    public Short status2;
    /**
     * 状态枚举
     */
    public RgvStatusType statusType2;
    /**
     * 工位2有物
     */
    public Short loaded2;  //0 无物;1 一层无物二层有物(只能拆叠)  ;2一层有物二层无物 (只能满放);3  1、2层都有物  4:()只允许拆盘
    ///////////////////////////////////////////////////////////////////////////////////////
    /**
     * 异常码
     */
    public Short alarm;
    /**
     * 心跳指令 1-2每秒切换一次
     */
    public Short heart;
    private Short temp1;
    private Short temp2;
    private Short temp3;
    private Short temp4;
    private Short temp5;
    /**
     * X行走行速度m/min
@@ -123,14 +73,49 @@
    private Float xSpeed;
    /**
     * 堆垛机累计走行距离km
     * 累计走行距离km
     */
    public Float xDistance;
    /**
     * 堆垛机累计走行时长h
     * 累计走行时长h
     */
    public Float xDuration;
    /**
     * 车身
     */
    public Long carBodyJiaoMing = 2000L;
    /**
     * 车身
     */
    public Long carBodyKunPeng = 15000L;
    /**
     * 是否启用
     */
    public boolean statusEnable;//0\1\2
    // 急停
    private boolean err1;
    // 有物无资料
    private boolean err2;
    // 命令错误走行链条冲突
    private boolean err3;
    // 目标为超过走行极限
    private boolean err4;
    // 变频器异常
    private boolean err5;
    // 光电异常
    private boolean err6;
    public void setMode(Short mode) {
        this.mode = mode;
@@ -152,41 +137,20 @@
        this.status = RgvStatusType.get(type).id.shortValue();
    }
    public void setStatus1(Short status1){
        this.status1 = status1;
        this.statusType1 = RgvStatusType.get(status1);
    }
    public void setStatus1(RgvStatusType type1){
        this.statusType1 = type1;
        this.status1 = RgvStatusType.get(type1).id.shortValue();
    }
    public void setStatus2(Short status2){
        this.status2 = status2;
        this.statusType2 = RgvStatusType.get(status2);
    }
    public void setStatus2(RgvStatusType type2){
        this.statusType2 = type2;
        this.status2 = RgvStatusType.get(type2).id.shortValue();
    }
    /**
     * 最近一次入出库类型
     *       I:入库
     *       O:出库
     */
    private String lastIo = "I";
    public BasRgv toSqlModel(BasRgv basRgv){
        if (alarm!=null) {
            basRgv.setRgvErr(alarm.longValue());
        }
        basRgv.setWrkNo1(taskNo1.intValue());
        basRgv.setWrkNo2(taskNo2.intValue());
        basRgv.setWrkNo1(taskNo.intValue());
        return basRgv;
    }
    public long getRgvPosDestinationOrPos(boolean sign){
        if (!sign){
            return RgvPosDestination>RgvPos? RgvPosDestination:RgvPos;
        } else {
            return RgvPosDestination<RgvPos? RgvPosDestination:RgvPos;
        }
    }
    public void setxSpeed(Short xSpeed) {
@@ -201,10 +165,43 @@
        this.xDuration = Float.valueOf(xDuration);
    }
    public Integer getRgvPosI(){
        //需要根据现场改造  根据读到的值获取对应站点位置
        if (RgvPos==null) return 0;
        return RgvPos.intValue();
    public int getAlarm$(){
        if (err1){
            return 1;
        }
        if (err2){
            return 2;
        }
        if (err3){
            return 3;
        }
        if (err4){
            return 4;
        }
        if (err5){
            return 5;
        }
        if (err6){
            return 6;
        }
        return 0;
    }
    public String getAlarmM(){
        switch (getAlarm$()){
            case 1:
                return "急停";
            case 2:
                return "有物无资料";
            case 3:
                return "命令错误走行链条冲突";
            case 4:
                return "目标为超过走行极限";
            case 5:
                return "变频器异常";
            case 6:
                return "光电异常";
        }
        return "正常";
    }
}