package com.zy.core.model.protocol;
|
|
import com.core.common.SpringUtils;
|
import com.zy.asrs.entity.BasLiftErr;
|
import com.zy.asrs.service.BasLiftErrService;
|
import com.zy.core.enums.LiftProtocolStatusType;
|
import com.zy.core.model.command.LiftAssignCommand;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
|
/**
|
* 提升机
|
*/
|
@Slf4j
|
@Data
|
public class LiftProtocol {
|
|
/**
|
* 提升机号
|
*/
|
private Short liftNo;
|
|
/**
|
* 任务号
|
*/
|
private Short taskNo = 0;
|
|
/**
|
* 四向穿梭车号
|
*/
|
private Short shuttleNo = 0;
|
|
/**
|
* 当前提升机状态(内部自我维护)
|
*/
|
private Integer protocolStatus = 1;
|
|
/**
|
* 当前提升机状态枚举
|
*/
|
private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.IDLE;
|
|
/**
|
* 模式
|
*/
|
private Boolean model;
|
|
/**
|
* 忙闲
|
*/
|
private Boolean busy;
|
|
/**
|
* 前超限
|
*/
|
private Boolean frontOverrun;
|
|
/**
|
* 后超限
|
*/
|
private Boolean backOverrun;
|
|
/**
|
* 左超限
|
*/
|
private Boolean leftOverrun;
|
|
/**
|
* 右超限
|
*/
|
private Boolean rightOverrun;
|
|
/**
|
* 超高
|
*/
|
private Boolean overHeight;
|
|
/**
|
* 超重
|
*/
|
private Boolean overWeight;
|
|
/**
|
* 有托盘
|
*/
|
private Boolean hasTray;
|
|
/**
|
* 有小车
|
*/
|
private Boolean hasCar;
|
|
/**
|
* 设备故障
|
*/
|
private Boolean deviceError;
|
|
/**
|
* 故障码
|
*/
|
private Short errorCode;
|
|
/**
|
* 任务地址
|
*/
|
private Short taskAddress;
|
|
/**
|
* 目的地址
|
*/
|
private Short distAddress;
|
|
/**
|
* 已完成的任务号
|
*/
|
private Short completeTaskNo;
|
|
/**
|
* 层
|
*/
|
private Short lev;
|
|
/**
|
* 作业标记
|
*/
|
private Boolean pakMk = false;
|
|
/**
|
* 独占令牌
|
* 未被任务占据,令牌为0
|
* 被任务占据,将任务号赋值给令牌
|
*/
|
private Integer token = 0;
|
|
/**
|
* 任务命令
|
*/
|
private LiftAssignCommand assignCommand;
|
|
/**
|
* 指令下发时间
|
*/
|
private Long sendTime = 0L;
|
|
/**
|
* 设置提升机状态
|
*/
|
public void setProtocolStatus(Integer status) {
|
this.protocolStatus = status;
|
this.protocolStatusType = LiftProtocolStatusType.get(status);
|
}
|
|
/**
|
* 设置提升机状态
|
*/
|
public void setProtocolStatus(LiftProtocolStatusType status) {
|
this.protocolStatus = status.id;
|
this.protocolStatusType = status;
|
}
|
|
// 是否处于空闲待命状态
|
public Boolean isIdle(Short taskNo) {
|
if(this.busy == null
|
|| this.model == null
|
|| this.deviceError == null
|
|| this.pakMk == null
|
|| this.token == null
|
){
|
return false;
|
}
|
|
boolean res =
|
// (this.taskNo.equals(this.completeTaskNo) || this.taskNo.intValue() == taskNo.intValue())
|
!this.busy
|
&& this.model
|
&& !this.pakMk
|
&& !this.deviceError
|
&& this.protocolStatusType.equals(LiftProtocolStatusType.IDLE)
|
;
|
return res;
|
}
|
|
// 是否处于空闲待命状态
|
public Boolean isIdle() {
|
if(this.taskNo == null
|
|| this.busy == null
|
|| this.model == null
|
|| this.deviceError == null
|
|| this.pakMk == null
|
|| this.token == null
|
){
|
return false;
|
}
|
|
boolean res =
|
// this.taskNo.equals(this.completeTaskNo)
|
!this.busy
|
&& this.model
|
&& !this.pakMk
|
&& !this.deviceError
|
&& this.token == 0
|
&& this.protocolStatusType.equals(LiftProtocolStatusType.IDLE)
|
;
|
return res;
|
}
|
|
// 是否处于空闲待命状态,不判断任务号
|
public Boolean isIdleNoTask() {
|
if(this.busy == null
|
|| this.model == null
|
|| this.deviceError == null
|
|| this.pakMk == null
|
){
|
return false;
|
}
|
|
boolean res = !this.busy
|
&& this.model
|
&& !this.pakMk
|
&& !this.deviceError
|
;
|
return res;
|
}
|
|
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();
|
}
|
|
|
}
|