|  |  |  | 
|---|
|  |  |  | package com.zy.core.model.protocol; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.BasCrnp; | 
|---|
|  |  |  | 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 com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.SpringUtils; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasSte; | 
|---|
|  |  |  | import com.zy.asrs.service.BasSteService; | 
|---|
|  |  |  | import com.zy.core.enums.SteHisTaskStatusType; | 
|---|
|  |  |  | import com.zy.core.enums.SteLocaType; | 
|---|
|  |  |  | import com.zy.core.enums.SteStatusType; | 
|---|
|  |  |  | import lombok.Data; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 2020/8/7 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Data | 
|---|
|  |  |  | public class SteProtocol { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 1 = 手动模式 | 
|---|
|  |  |  | * 2 = 自动模式 | 
|---|
|  |  |  | * 3 = 电脑模式 | 
|---|
|  |  |  | * 设备号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Short steNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 1 = 联机模式 | 
|---|
|  |  |  | * 0 = 脱机模式 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short mode; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public CrnModeType modeType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 1 = 急停 | 
|---|
|  |  |  | IDLE(0, "空闲"), | 
|---|
|  |  |  | MOVING(1, "作业中"), | 
|---|
|  |  |  | SOS(2, "报警"), | 
|---|
|  |  |  | WAITING(3, "任务完成等待WCS确认"), | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short eStop; | 
|---|
|  |  |  | public Short status; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short alarm; | 
|---|
|  |  |  | public SteStatusType statusType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务号 | 
|---|
|  |  |  | 
|---|
|  |  |  | public Short taskNo = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机当前状态 | 
|---|
|  |  |  | * 0:空闲,无任务 | 
|---|
|  |  |  | * 1:取货定位中 | 
|---|
|  |  |  | * 2:取货中 | 
|---|
|  |  |  | * 3:取货完成,放货定位中 | 
|---|
|  |  |  | * 4:放货中 | 
|---|
|  |  |  | * 5:回原点中 | 
|---|
|  |  |  | * 6:反原点 | 
|---|
|  |  |  | * 7:库位移位 | 
|---|
|  |  |  | * 90:任务完成等待WCS确认 | 
|---|
|  |  |  | * 99:报警 | 
|---|
|  |  |  | * 正在执行任务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short status; | 
|---|
|  |  |  | public Boolean execute; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 状态枚举 | 
|---|
|  |  |  | * 任务完成,等待WCS确认 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public CrnStatusType statusType; | 
|---|
|  |  |  | public Boolean waiting; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机当前列号 | 
|---|
|  |  |  | * 异常码1 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short alarm; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常码2 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short alarm0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池电量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Float charge = 0.0F; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 满电 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean fullCharge; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 低电量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean lowCharge; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 电池馈电    0,欠电,1低电 2满电 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short feed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前位置     1,近点,2远点,3A点,4B点 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short loca; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public SteLocaType locaType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 近点距离 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Double closer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前速度 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Double speed = 0.0D; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 高低位 0,低位,1高位 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short pos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 有货 0,没货,1有货 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short load; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 在轨道上 0不在,1在 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short track; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务类型 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short taskType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 排 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short row; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 列 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short bay; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机当前层号 | 
|---|
|  |  |  | * 层 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short level; | 
|---|
|  |  |  | public Short lev; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前货叉位置 | 
|---|
|  |  |  | * 0 = 货叉原位 | 
|---|
|  |  |  | * 1 = 货叉在左侧 | 
|---|
|  |  |  | * 2 = 货叉在右侧 | 
|---|
|  |  |  | * 过账指令任务号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short forkPos; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public CrnForkPosType forkPosType; | 
|---|
|  |  |  | public Integer hisTaskNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前载货台位置 | 
|---|
|  |  |  | * 0 = 下定位 | 
|---|
|  |  |  | * 1 = 上定位 | 
|---|
|  |  |  | * 过账指令状态 | 
|---|
|  |  |  | * 0初始 1执行完成 2删除 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short liftPos; | 
|---|
|  |  |  | public Short hisTaskStatus; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public CrnLiftPosType liftPosType; | 
|---|
|  |  |  | public SteHisTaskStatusType hisTaskStatusType; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 走行在定位 | 
|---|
|  |  |  | * 0 = 在定位 | 
|---|
|  |  |  | * 1 = 不在定位 | 
|---|
|  |  |  | * 盘点数量 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short walkPos; | 
|---|
|  |  |  | public Short checkQty; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 载货台有物 | 
|---|
|  |  |  | * 就绪状态  0未就绪 1就绪 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Short loaded; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Short temp1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnTemp1 crnTemp1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Short temp2; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Short temp3; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Short temp4; | 
|---|
|  |  |  | public Short ready; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常1 | 
|---|
|  |  |  | * 打开充电桩号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError1 crnError1; | 
|---|
|  |  |  | public Short chargeNo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常2 | 
|---|
|  |  |  | * 心跳指令 1-2每秒切换一次 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error2; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError2 crnError2; | 
|---|
|  |  |  | public Short heart; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常3 | 
|---|
|  |  |  | * 堆垛机禁止运行 1运行,0禁止 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error3; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError3 crnError3; | 
|---|
|  |  |  | public Short crnStopRun; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常4 | 
|---|
|  |  |  | * 堆垛机禁止伸叉 1运行,0禁止 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error4; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError4 crnError4; | 
|---|
|  |  |  | public Short crnStopFork; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常5 | 
|---|
|  |  |  | * 堆垛机搬移允许 0不允许   1允许 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error5; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError5 crnError5; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常6 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private boolean[] error6; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CrnError6 crnError6; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * X行走线速度m/min | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Float xSpeed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Y行走线速度m/min | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Float ySpeed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Z行走线速度m/min | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Float zSpeed; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机累计走行距离km | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Float xDistance; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机累计升降距离km | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Float yDistance; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机累计走行时长h | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Float xDuration; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 堆垛机累计升降时长h | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Float yDuration; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setMode(Short mode) { | 
|---|
|  |  |  | this.mode = mode; | 
|---|
|  |  |  | this.modeType = CrnModeType.get(mode); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setMode(CrnModeType type) { | 
|---|
|  |  |  | this.modeType = type; | 
|---|
|  |  |  | this.mode = CrnModeType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setForkPos(Short forkPos) { | 
|---|
|  |  |  | this.forkPos = forkPos; | 
|---|
|  |  |  | this.forkPosType = CrnForkPosType.get(forkPos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setForkPos(CrnForkPosType type) { | 
|---|
|  |  |  | this.forkPosType = type; | 
|---|
|  |  |  | this.forkPos = CrnForkPosType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setLiftPos(Short liftPos) { | 
|---|
|  |  |  | this.liftPos = liftPos; | 
|---|
|  |  |  | this.liftPosType = CrnLiftPosType.get(liftPos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setLiftPos(CrnLiftPosType type) { | 
|---|
|  |  |  | this.liftPosType = type; | 
|---|
|  |  |  | this.liftPos = CrnLiftPosType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public Short crnAllowRun; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setStatus(Short status){ | 
|---|
|  |  |  | this.status = status; | 
|---|
|  |  |  | this.statusType = CrnStatusType.get(status); | 
|---|
|  |  |  | this.statusType = SteStatusType.get(status); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setStatus(CrnStatusType type){ | 
|---|
|  |  |  | public void setStatus(SteStatusType type){ | 
|---|
|  |  |  | this.statusType = type; | 
|---|
|  |  |  | this.status = CrnStatusType.get(type).id.shortValue(); | 
|---|
|  |  |  | this.status = SteStatusType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Short getTemp1() { | 
|---|
|  |  |  | return temp1; | 
|---|
|  |  |  | public void setLoca(Short loca){ | 
|---|
|  |  |  | this.loca = loca; | 
|---|
|  |  |  | this.locaType = SteLocaType.get(loca); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setTemp1(Short temp1) { | 
|---|
|  |  |  | this.temp1 = temp1; | 
|---|
|  |  |  | public void setLoca(SteLocaType type){ | 
|---|
|  |  |  | this.locaType = type; | 
|---|
|  |  |  | this.loca = SteLocaType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHisTaskStatus(Short hisTaskStatus){ | 
|---|
|  |  |  | this.hisTaskStatus = hisTaskStatus; | 
|---|
|  |  |  | this.hisTaskStatusType = SteHisTaskStatusType.get(hisTaskStatus); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHisTaskStatus(SteHisTaskStatusType type){ | 
|---|
|  |  |  | this.hisTaskStatusType = type; | 
|---|
|  |  |  | this.hisTaskStatus = SteHisTaskStatusType.get(type).id.shortValue(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String lastIo = "I"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String pakMk = "-"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public BasCrnp toSqlModel(BasCrnp basCrnp){ | 
|---|
|  |  |  | public BasSte toSqlModel(BasSte basSte){ | 
|---|
|  |  |  | if (alarm!=null) { | 
|---|
|  |  |  | basCrnp.setCrnErr(alarm.longValue()); | 
|---|
|  |  |  | basSte.setSteErr(alarm.longValue()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | basCrnp.setWrkNo(taskNo.intValue()); | 
|---|
|  |  |  | return basCrnp; | 
|---|
|  |  |  | basSte.setWrkNo(taskNo.intValue()); | 
|---|
|  |  |  | //        if (basSte.getPakMk().equals("N")) { | 
|---|
|  |  |  | //            if (!Cools.isEmpty(row)) { | 
|---|
|  |  |  | //                basSte.setRow(row.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if (!Cools.isEmpty(bay)) { | 
|---|
|  |  |  | //                basSte.setBay(bay.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //            if (!Cools.isEmpty(lev)) { | 
|---|
|  |  |  | //                basSte.setLev(lev.intValue()); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | return basSte; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 是否处于空闲待命状态 | 
|---|
|  |  |  | public Boolean isIdle() { | 
|---|
|  |  |  | boolean res = this.statusType.equals(SteStatusType.IDLE) | 
|---|
|  |  |  | && this.pakMk.equals("N") | 
|---|
|  |  |  | && !isAlarm(); | 
|---|
|  |  |  | if (!res) { | 
|---|
|  |  |  | return res; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 电量 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String chargeLine = SpringUtils.getBean(BasSteService.class).selectById(this.steNo).getChargeLine(); | 
|---|
|  |  |  | return charge > Float.parseFloat(chargeLine); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("fail", e); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 是否处于报警状态 | 
|---|
|  |  |  | public Boolean isAlarm() { | 
|---|
|  |  |  | return this.alarm > 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|