| | |
| | | package com.zy.core.model.protocol; |
| | | |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.core.News; |
| | | import com.zy.asrs.entity.BasLiftErr; |
| | | import com.zy.asrs.service.BasLiftErrService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.enums.LiftProtocolStatusType; |
| | | import com.zy.core.enums.ShuttleErrorCodeType; |
| | | import com.zy.core.enums.ShuttleProtocolStatusType; |
| | | import com.zy.core.enums.ShuttleStatusType; |
| | | import com.zy.core.model.command.LiftAssignCommand; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * 提升机 |
| | | */ |
| | | @Slf4j |
| | | @Data |
| | | public class LiftProtocol { |
| | | public class LiftProtocol implements Cloneable { |
| | | |
| | | //**********************必须存在属性********************** |
| | | /** |
| | | * 提升机号 |
| | | */ |
| | | private Short liftNo; |
| | | private Integer liftNo; |
| | | |
| | | /** |
| | | * 任务号 |
| | | */ |
| | | private Short taskNo = 0; |
| | | private Integer taskNo; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | */ |
| | | private Short shuttleNo = 0; |
| | | private Integer shuttleNo = 0; |
| | | |
| | | /** |
| | | * 当前提升机状态(内部自我维护) |
| | | */ |
| | | private Integer protocolStatus = 1; |
| | | private Integer protocolStatus = -1; |
| | | |
| | | /** |
| | | * 当前提升机状态枚举 |
| | | */ |
| | | private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.IDLE; |
| | | private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.NONE; |
| | | |
| | | /** |
| | | * 层 |
| | | * 模式 => 自动/手动 |
| | | */ |
| | | private Short lev; |
| | | private Boolean model; |
| | | |
| | | /** |
| | | * 提升机锁定 |
| | | * 运行状态 |
| | | */ |
| | | private Boolean liftLock; |
| | | private Boolean run; |
| | | |
| | | /** |
| | | * 位置到达反馈 |
| | | */ |
| | | private Short positionArrivalFeedback; |
| | | |
| | | /** |
| | | * 准备就绪 |
| | | * 就绪为1,未就绪为0 |
| | | * 就绪状态 |
| | | */ |
| | | private Boolean ready; |
| | | |
| | | /** |
| | | * 运行中 |
| | | * 运行中为1,未运行为0 |
| | | * 前超限 |
| | | */ |
| | | private Boolean running; |
| | | private Boolean frontOverrun; |
| | | |
| | | /** |
| | | * 联机/单机 |
| | | * 联机为1,单机为0 |
| | | * 后超限 |
| | | */ |
| | | private Boolean mode; |
| | | private Boolean backOverrun; |
| | | |
| | | /** |
| | | * 输送线前端光电有货 |
| | | * 有货为1,无货为0(前端指靠近货架侧) |
| | | * 左超限 |
| | | */ |
| | | private Boolean lineFrontHasStock; |
| | | private Boolean leftOverrun; |
| | | |
| | | /** |
| | | * 输送线正转反馈 |
| | | * 正转运行为1,否则为0 |
| | | * 右超限 |
| | | */ |
| | | private Boolean forwardRotationFeedback; |
| | | private Boolean rightOverrun; |
| | | |
| | | /** |
| | | * 输送线反转反馈 |
| | | * 反转运行为1,否则为0 |
| | | * 超高 |
| | | */ |
| | | private Boolean reverseFeedback; |
| | | private Boolean overHeight; |
| | | |
| | | /** |
| | | * 输送线电机过载 |
| | | * 过载为0,正常为1 |
| | | * 超重 |
| | | */ |
| | | private Boolean motorOverload; |
| | | private Boolean overWeight; |
| | | |
| | | /** |
| | | * 输送线末端光电有货 |
| | | * 有货为1,无货为0 |
| | | * 有托盘 |
| | | */ |
| | | private Boolean lineEndHasStock; |
| | | private Boolean hasTray; |
| | | |
| | | /** |
| | | * 进输送线卡托盘报警 |
| | | * 报警为1,未报警为0 |
| | | * 有小车 |
| | | */ |
| | | private Boolean inConveyLineCardTrayAlarm; |
| | | private Boolean hasCar; |
| | | |
| | | /** |
| | | * 出输送线卡托盘报警 |
| | | * 报警为1,未报警为0 |
| | | * 故障 |
| | | */ |
| | | private Boolean outConveyLineCardTrayAlarm; |
| | | private Boolean error; |
| | | |
| | | /** |
| | | * 平台位置偏差报警 |
| | | * 报警为1,未报警为0 |
| | | * 故障码 |
| | | */ |
| | | private Boolean platPositionDeviationAlarm; |
| | | private String errorCode; |
| | | |
| | | /** |
| | | * 平台扭矩偏差报警 |
| | | * 报警为1,未报警为0 |
| | | * 任务地址 |
| | | */ |
| | | private Boolean platTorqueDeviationAlarm; |
| | | private Short taskAddress; |
| | | |
| | | /** |
| | | * 平台四向车检测 |
| | | * 有车为1,无车为0 |
| | | * 目的地址 |
| | | */ |
| | | private Boolean platShuttleCheck; |
| | | private Short distAddress; |
| | | |
| | | /** |
| | | * 未就绪状态 |
| | | * 1. 不在指定层 |
| | | * 2. 四轴不同步 |
| | | * 3. 平台前限光电被挡到(靠近货架) |
| | | * 4. 平台后限光电被挡到(远离货架) |
| | | * 5. 平台上限位报警 |
| | | * 6. 平台下限位报警 |
| | | * 7. 电柜急停报警 |
| | | * 8. 输送线前限位被挡到(靠近货架) |
| | | * 9. 输送线后限位被挡到(远离货架) |
| | | * 10. 触摸屏紧急停止被按下 |
| | | * 11. 四轴动力线断线 |
| | | * 12. 单机模式 |
| | | * 13. 四轴报警 |
| | | * 14. 位置偏差过大 |
| | | * 15. 扭矩偏差过大 |
| | | * 16. 输送线过载 |
| | | * 17. 进提升机卡托盘 |
| | | * 18. 出提升机卡托盘 |
| | | * 已完成的任务号 |
| | | */ |
| | | private Short notReady; |
| | | private String completeTaskNo; |
| | | |
| | | /** |
| | | * 伺服1错误 |
| | | * 层 |
| | | */ |
| | | private Short servoError1; |
| | | |
| | | /** |
| | | * 伺服2错误 |
| | | */ |
| | | private Short servoError2; |
| | | |
| | | /** |
| | | * 伺服3错误 |
| | | */ |
| | | private Short servoError3; |
| | | |
| | | /** |
| | | * 伺服4错误 |
| | | */ |
| | | private Short servoError4; |
| | | |
| | | /** |
| | | * 提升机实际速度反馈 |
| | | */ |
| | | private Short liftActualSpeed; |
| | | private Integer lev; |
| | | |
| | | /** |
| | | * 作业标记 |
| | |
| | | private Boolean pakMk = true; |
| | | |
| | | /** |
| | | * 任务命令 |
| | | * 指令下发时间 |
| | | */ |
| | | private LiftAssignCommand assignCommand; |
| | | private Long sendTime = 0L; |
| | | |
| | | public Short getLiftLockShortValue() { |
| | | return liftLock ? (short) 1 : (short) 0; |
| | | /** |
| | | * 日志采集时间 |
| | | */ |
| | | private Long deviceDataLog = System.currentTimeMillis(); |
| | | |
| | | /** |
| | | * 扩展字段 |
| | | */ |
| | | private Object extend; |
| | | |
| | | public String getRun$() { |
| | | if (this.run == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.run ? "运行中" : "空闲"; |
| | | } |
| | | |
| | | public String getReady$() { |
| | | if (this.ready == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.ready ? "就绪" : "未就绪"; |
| | | } |
| | | |
| | | public String getModel$() { |
| | | if (this.model == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.model ? "自动" : "手动"; |
| | | } |
| | | |
| | | public String getHasTray$() { |
| | | if (this.hasTray == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.hasTray ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getHasCar$() { |
| | | if (this.hasCar == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.hasCar ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getFrontOverrun$() { |
| | | if (this.frontOverrun == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.frontOverrun ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getBackOverrun$() { |
| | | if (this.backOverrun == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.backOverrun ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getLeftOverrun$() { |
| | | if (this.leftOverrun == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.leftOverrun ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getRightOverrun$() { |
| | | if (this.rightOverrun == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.rightOverrun ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getOverHeight$() { |
| | | if (this.overHeight == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.overHeight ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getOverWeight$() { |
| | | if (this.overWeight == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.overWeight ? "Y" : "N"; |
| | | } |
| | | |
| | | public String getProtocolStatus$() { |
| | | if (this.protocolStatusType == null) { |
| | | return "未知"; |
| | | } |
| | | |
| | | return this.protocolStatusType.desc; |
| | | } |
| | | |
| | | /** |
| | |
| | | this.protocolStatusType = status; |
| | | } |
| | | |
| | | // 是否处于空闲待命状态 |
| | | public Boolean isIdle() { |
| | | boolean res = this.taskNo == 0 |
| | | && !this.liftLock |
| | | && this.ready |
| | | && !this.running |
| | | && this.mode |
| | | && this.pakMk.equals(true) |
| | | ; |
| | | return res; |
| | | public synchronized void setTaskNo(Integer taskNo) { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | if (null != redisUtil) { |
| | | redisUtil.set(RedisKeyType.LIFT_FLAG.key + this.liftNo, taskNo); |
| | | this.taskNo = taskNo; |
| | | } |
| | | } |
| | | |
| | | public void setPositionArrivalFeedback(Short position) { |
| | | this.lev = position;//层高 |
| | | this.positionArrivalFeedback = position;//位置到达反馈 |
| | | public Integer getTaskNo() { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | if (null != redisUtil) { |
| | | Object o = redisUtil.get(RedisKeyType.LIFT_FLAG.key + this.liftNo); |
| | | if (!Cools.isEmpty(o)) { |
| | | this.taskNo = Integer.valueOf(String.valueOf(o)); |
| | | } |
| | | } |
| | | return this.taskNo == null ? 0 : this.taskNo; |
| | | } |
| | | |
| | | /** |
| | | * 错误码 |
| | | */ |
| | | public String getErrCode$() { |
| | | if (this.errorCode == null) { |
| | | return ""; |
| | | } |
| | | BasLiftErrService basLiftErrService = SpringUtils.getBean(BasLiftErrService.class); |
| | | BasLiftErr basLiftErr = basLiftErrService.selectById(this.errorCode); |
| | | if (basLiftErr == null) { |
| | | return String.valueOf(this.errorCode); |
| | | } |
| | | return basLiftErr.getErrName(); |
| | | } |
| | | |
| | | @Override |
| | | public LiftProtocol clone() { |
| | | try { |
| | | return (LiftProtocol) super.clone(); |
| | | } catch (CloneNotSupportedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |