修改:IBP盘部分功能实现
This commit is contained in:
parent
62027d50ee
commit
d7c5e7cd32
@ -79,14 +79,22 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
MapConfig config = simulation.getRepository().getConfig();
|
||||
|
||||
VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode);
|
||||
if (VirtualRealityIbp.Type.KEY.equals(element.getType())) {
|
||||
element.setOn(!element.isOn());
|
||||
return;
|
||||
}
|
||||
List<Stand> stands = chooseStands(station, element, config);
|
||||
boolean change = false;
|
||||
VirtualRealityIbp.SquareButton button = null;
|
||||
if (element instanceof VirtualRealityIbp.SquareButton) {
|
||||
if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) {
|
||||
button = (VirtualRealityIbp.SquareButton) element;
|
||||
if (!button.isPressed())
|
||||
change = true;
|
||||
button.setPressed(true);
|
||||
if (button.getMean() == null) {
|
||||
button.setOn(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
switch (element.getMean()) {
|
||||
case KC:
|
||||
@ -139,6 +147,9 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
case PRERESET_Z:
|
||||
element.setOn(true);
|
||||
break;
|
||||
case SD:
|
||||
ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(true));
|
||||
break;
|
||||
default:
|
||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(String.format("不正确的按钮类型[%s]", element.getMean()));
|
||||
}
|
||||
@ -157,11 +168,15 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
||||
VirtualRealityIbp ibp = makeSureIbpExistAndCollectStatus(simulation, station);
|
||||
VirtualRealityIbp.IbpElement element = ibp.getByCode(buttonCode);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(VirtualRealityIbp.Type.BUTTON.equals(element.getType()), "元素非按钮");
|
||||
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
|
||||
button.setPressed(false);
|
||||
if (!button.getMean().equals(VirtualRealityIbp.Mean.AXLE_PRE_RESET)) {
|
||||
if (!VirtualRealityIbp.Mean.AXLE_PRE_RESET.equals(button.getMean())) {
|
||||
button.setOn(false);
|
||||
}
|
||||
if (VirtualRealityIbp.Mean.SD.equals(button.getMean())) {
|
||||
ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,7 +219,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
VirtualRealityIbp ibp = station.getVrIbp();
|
||||
if (ibp == null)
|
||||
continue;
|
||||
List<VirtualRealityIbp.IbpElement> buttons = ibp.queryByType(VirtualRealityIbp.Mean.PRERESET_Z);
|
||||
List<VirtualRealityIbp.IbpElement> buttons = ibp.queryByMean(VirtualRealityIbp.Mean.PRERESET_Z);
|
||||
if (CollectionUtils.isEmpty(buttons))
|
||||
continue;
|
||||
VirtualRealityIbp.SquareButton preResetButton =
|
||||
@ -212,7 +227,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
if (!preResetButton.isPressed())
|
||||
continue;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (VirtualRealityIbp.IbpElement ibpElement : ibp.queryByType(VirtualRealityIbp.Mean.AXLE_PRE_RESET)) {
|
||||
for (VirtualRealityIbp.IbpElement ibpElement : ibp.queryByMean(VirtualRealityIbp.Mean.AXLE_PRE_RESET)) {
|
||||
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) ibpElement;
|
||||
if (!button.isPressed())
|
||||
continue;
|
||||
@ -255,6 +270,8 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
MapConfig config = repository.getConfig();
|
||||
for (VirtualRealityIbp.IbpElement element : vrIbp.getElementList()) {
|
||||
List<Stand> stands = chooseStands(station, element, config);
|
||||
if (element.getMean() == null)
|
||||
continue;
|
||||
switch (element.getMean()) {
|
||||
case KC:
|
||||
case XXYS:
|
||||
@ -267,6 +284,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
|
||||
case AXLE_RESET:
|
||||
case PRERESET_Z:
|
||||
case ALARM:
|
||||
case SD:
|
||||
break;
|
||||
case kcLight:
|
||||
element.setOn(stands.stream().anyMatch(Stand::isIbpHoldTrain));
|
||||
|
@ -23,36 +23,34 @@ public class VirtualRealityIbp {
|
||||
public VirtualRealityIbp(IbpData ibpData) {
|
||||
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getSquareButtonList())) {
|
||||
for (IbpData.SquareButtonVO vo : ibpData.getDrawData().getSquareButtonList()) {
|
||||
if (vo.getMean() == null)
|
||||
continue;
|
||||
SquareButton button = new SquareButton(vo.getCode(), vo.getMean(), false, vo.getSectionCode(), vo.getDirection());
|
||||
addElement(button);
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getCircularLampList())) {
|
||||
for (IbpData.CircularLampVO vo : ibpData.getDrawData().getCircularLampList()) {
|
||||
if (vo.getMean() == null)
|
||||
continue;
|
||||
addElement(new IbpElement(vo.getCode(), vo.getMean(), false, vo.getDirection()));
|
||||
addElement(new IbpElement(vo.getCode(), Type.LIGHT, vo.getMean(), false, vo.getDirection()));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getAlarmList())) {
|
||||
for (IbpData.AlarmVO vo : ibpData.getDrawData().getAlarmList()) {
|
||||
addElement(new IbpElement(vo.getCode(), Mean.ALARM, false, vo.getDirection()));
|
||||
addElement(new IbpElement(vo.getCode(), Type.ALARM, Mean.ALARM, false, vo.getDirection()));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getKeyList())) {
|
||||
for (IbpData.KeyVO vo : ibpData.getDrawData().getKeyList()) {
|
||||
if (vo.getMean() == null)
|
||||
continue;
|
||||
addElement(new IbpElement(vo.getCode(), vo.getMean(), false, vo.getMean().equals(Mean.SXYS)));
|
||||
if (vo.getMean() == null) {
|
||||
addElement(new IbpElement(vo.getCode(), Type.KEY, vo.getMean(), false, null));
|
||||
} else {
|
||||
addElement(new IbpElement(vo.getCode(), Type.KEY, vo.getMean(), false, vo.getMean().equals(Mean.SXYS)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.queryByType(Mean.SXYS).forEach(element -> element.setOn(false));
|
||||
this.queryByType(Mean.XXYS).forEach(element -> element.setOn(false));
|
||||
this.queryByMean(Mean.SXYS).forEach(element -> element.setOn(false));
|
||||
this.queryByMean(Mean.XXYS).forEach(element -> element.setOn(false));
|
||||
}
|
||||
|
||||
public void addElement(IbpElement element) {
|
||||
@ -63,10 +61,14 @@ public class VirtualRealityIbp {
|
||||
return (T) elementMap.get(code);
|
||||
}
|
||||
|
||||
public List<IbpElement> queryByType(Mean mean) {
|
||||
public List<IbpElement> queryByMean(Mean mean) {
|
||||
return elementMap.values().stream().filter(element -> mean.equals(element.getMean())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<IbpElement> queryByType(Type type) {
|
||||
return elementMap.values().stream().filter(element -> type.equals(element.getType())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<IbpElement> query(Mean mean, Boolean up) {
|
||||
return elementMap.values().stream()
|
||||
.filter(element -> mean.equals(element.getMean()) && Objects.equals(element.getUp(), up))
|
||||
@ -82,14 +84,17 @@ public class VirtualRealityIbp {
|
||||
public class IbpElement {
|
||||
private String code;
|
||||
|
||||
private Type type;
|
||||
|
||||
private Mean mean;
|
||||
|
||||
private boolean on;
|
||||
|
||||
private Boolean up;
|
||||
|
||||
public IbpElement(String code, Mean mean, boolean on, Boolean up) {
|
||||
public IbpElement(String code, Type type, Mean mean, boolean on, Boolean up) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
this.mean = mean;
|
||||
this.on = on;
|
||||
this.up = up;
|
||||
@ -113,11 +118,20 @@ public class VirtualRealityIbp {
|
||||
private String sectionCode;
|
||||
|
||||
public SquareButton(String code, Mean mean, boolean status, String sectionCode, Boolean up) {
|
||||
super(code, mean, status, up);
|
||||
super(code, Type.BUTTON, mean, status, up);
|
||||
this.sectionCode = sectionCode;
|
||||
}
|
||||
}
|
||||
|
||||
/** 元素类型 */
|
||||
public enum Type {
|
||||
LIGHT,
|
||||
BUTTON,
|
||||
KEY,
|
||||
ALARM,
|
||||
}
|
||||
|
||||
/** 元素意义 */
|
||||
public enum Mean {
|
||||
//------------------ 信号 ------------------
|
||||
/**
|
||||
@ -175,5 +189,7 @@ public class VirtualRealityIbp {
|
||||
jjtcLight,
|
||||
gmLight,
|
||||
kmLight,
|
||||
//------------------ 按钮 ------------------
|
||||
SD,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user