package com.zy.acs.common.domain;
|
|
import com.zy.acs.framework.exception.CoolException;
|
import com.zy.acs.common.domain.protocol.ICommandBody;
|
import com.zy.acs.common.enums.AgvCommandType;
|
import lombok.Data;
|
|
import java.io.Serializable;
|
|
/**
|
* 动作命令包 - 子节点
|
* Created by vincent on 2023/3/14
|
*/
|
@Data
|
public class AgvCommandItem<T extends ICommandBody> implements Serializable {
|
|
private static final long serialVersionUID = -6988765550778795176L;
|
|
// 动作码
|
private AgvCommandType commandType;
|
|
// 属性值
|
private int val;
|
|
// 动作参数
|
private T commandBody;
|
|
public AgvCommandItem(Class<T> clazz) {
|
try {
|
commandBody = clazz.newInstance();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
this.commandType = AgvCommandType.find(commandBody.getClass());
|
if (null == commandType) {
|
throw new CoolException(clazz.getName() + "检索 AgvActionCmdType 枚举失败");
|
}
|
}
|
|
public AgvCommandItem<T> setVal(int val) {
|
this.val = val;
|
return this;
|
}
|
|
public AgvCommandItem<T> bodySync(DataSupport<T> dataSupport) {
|
dataSupport.sync(this.commandBody);
|
return this;
|
}
|
|
}
|