红河财经IBP盘;实体IBP盘与虚拟IBP盘交互逻辑修改(zjd的实体IBP盘逻辑相应修改)

This commit is contained in:
joylink_zhangsai 2022-06-09 09:41:10 +08:00
parent a951c621d2
commit f4f3f677f9
8 changed files with 523 additions and 132 deletions

View File

@ -20,12 +20,17 @@ public interface IVirtualRealityIbpService {
void pressTheButton(String group, String stationCode, String buttonCode); void pressTheButton(String group, String stationCode, String buttonCode);
/** /**
* 更新IBP元素状态按下和松开二合一 * 按下或松开
*/ */
void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, void pressOrRelease(Simulation simulation, VirtualRealityIbp ibp,
VirtualRealityIbp.IbpElement element, boolean pressed); VirtualRealityIbp.IbpElement element, boolean pressed);
void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean pressed); void pressOrRelease(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean pressed);
/**
* 更新打开或关闭状态
*/
void updateOnOrOff(VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean on);
/** /**
* 收集并发送IBP的状态数据 * 收集并发送IBP的状态数据

View File

@ -72,14 +72,14 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
private void pressTheButton(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) { private void pressTheButton(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.IbpElement element) {
boolean change = false; boolean change = false;
if (VirtualRealityIbp.Type.KEY.equals(element.getType())) { if (VirtualRealityIbp.Type.KEY.equals(element.getType())) {
element.setOn(!element.isOn()); element.orderTo(!element.isOn());
return; return;
} else if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) { } else if (VirtualRealityIbp.Type.BUTTON.equals(element.getType())) {
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
if (!button.isOn()) if (!button.isOn())
change = true; change = true;
button.setPressed(true); button.setPressed(true);
element.setOn(true); element.orderTo(true);
} }
if (change) if (change)
effective(simulation, ibp, element); effective(simulation, ibp, element);
@ -93,8 +93,9 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
return; return;
Station station = ibp.getStation(); Station station = ibp.getStation();
MapConfig config = simulation.getRepository().getConfig(); MapConfig config = simulation.getRepository().getConfig();
List<Stand> stands = chooseStands(station, element, config); List<Stand> stands = chooseStands(station, element.getUp(), config);
switch (element.getMean()) { switch (element.getMean()) {
//------------------- 信号 -------------------
case KC: case KC:
stands.forEach(stand -> ciApiService.ibpHoldTrain(simulation, stand.getCode())); stands.forEach(stand -> ciApiService.ibpHoldTrain(simulation, stand.getCode()));
break; break;
@ -103,38 +104,46 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
break; break;
case JJTC: case JJTC:
stands.forEach(stand -> ciApiService.standEC(simulation, stand)); stands.forEach(stand -> ciApiService.standEC(simulation, stand));
ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(alarm -> alarm.setOn(true)); ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).orderToOn();
break; break;
case QXJJTC: case QXJJTC:
stands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); stands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand));
break; break;
case BJQC: case BJQC:
ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).forEach(ele -> ele.setOn(false)); ibp.query(VirtualRealityIbp.Mean.ALARM, element.getUp()).orderToOff();
break; break;
case ALARM: case SD: //试灯在IBP盘状态收集逻辑里生效
break; break;
//------------------- 屏蔽门 -------------------
case KM: { case KM: {
stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP)); stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP));
break; break;
} }
case PSD_SMKM: //逻辑未知
break;
case GM: { case GM: {
stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP)); stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.IBP));
break; break;
} }
case XXYS: { case XXYS: {
List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.CZ_LIGHT, false); List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false);
czLights.forEach(light -> light.setOn(true)); czLights.forEach(light -> light.orderTo(true));
break; break;
} }
case SXYS: { case SXYS: {
List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.CZ_LIGHT, true); List<VirtualRealityIbp.IbpElement> czLights = ibp.query(VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true);
czLights.forEach(light -> light.setOn(true)); czLights.forEach(light -> light.orderTo(true));
break; break;
} }
case HSJC: { case PSD_HSJC: {
stands.forEach(stand -> stand.getPsd().getVirtualScreenDoor().setInterlockRelease(true)); stands.forEach(stand -> stand.getPsd().getVirtualScreenDoor().setInterlockRelease(true));
break; break;
} }
case PSD_BJQC:
ibp.query(VirtualRealityIbp.Mean.PSD_ALARM, element.getUp()).orderToOff();
break;
case PSD_SD:
break;
case AXLE_RESET: { case AXLE_RESET: {
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
ciApiService.axleReset(simulation, button.getSectionCode()); ciApiService.axleReset(simulation, button.getSectionCode());
@ -149,20 +158,27 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
break; break;
} }
case PRERESET_Z: case PRERESET_Z:
break; case kcLight:
case SD: case jjtcLight:
ibp.queryByType(VirtualRealityIbp.Type.LIGHT).forEach(light -> light.setOn(true)); case ALARM:
case PSD_ALARM:
case gmLight:
case kmLight:
case PSD_CZYX_LIGHT:
case PSD_HSJC_LIGHT:
case PSD_SDCZ_LIGHT:
case PSD_GZBJ_LIGHT:
break; break;
default: default:
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(String.format("不正确的按钮类型[%s]", element.getMean())); throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(String.format("不正确的按钮类型[%s]", element.getMean()));
} }
} }
private List<Stand> chooseStands(Station station, VirtualRealityIbp.IbpElement element, MapConfig config) { private List<Stand> chooseStands(Station station, Boolean up, MapConfig config) {
if (element.getUp() == null) { if (up == null) {
return station.getAllNormalStands(); return station.getAllNormalStands();
} }
return station.getStandOf(config.isRight(element.getUp())); return station.getStandOf(config.isRight(up));
} }
@Override @Override
@ -178,7 +194,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(VirtualRealityIbp.Type.BUTTON.equals(element.getType()), "元素非按钮"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(VirtualRealityIbp.Type.BUTTON.equals(element.getType()), "元素非按钮");
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
if (!VirtualRealityIbp.Mean.AXLE_PRE_RESET.equals(button.getMean())) { if (!VirtualRealityIbp.Mean.AXLE_PRE_RESET.equals(button.getMean())) {
button.setOn(false); button.orderTo(false);
} else { } else {
button.setEffective(false); button.setEffective(false);
} }
@ -186,11 +202,12 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
/** /**
* 更新IBP元素状态 * 更新IBP元素状态
*
* @param pressed true-按下false-松开 * @param pressed true-按下false-松开
*/ */
@Override @Override
public void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, public void pressOrRelease(Simulation simulation, VirtualRealityIbp ibp,
VirtualRealityIbp.IbpElement element, boolean pressed) { VirtualRealityIbp.IbpElement element, boolean pressed) {
if (pressed) { if (pressed) {
pressTheButton(simulation, ibp, element); pressTheButton(simulation, ibp, element);
} else { } else {
@ -199,7 +216,7 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
} }
@Override @Override
public void updateElementStatus(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean pressed) { public void pressOrRelease(Simulation simulation, VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean pressed) {
List<VirtualRealityIbp.IbpElement> elements = ibp.query(mean, up); List<VirtualRealityIbp.IbpElement> elements = ibp.query(mean, up);
if (pressed) { if (pressed) {
elements.forEach(element -> pressTheButton(simulation, ibp, element)); elements.forEach(element -> pressTheButton(simulation, ibp, element));
@ -208,6 +225,12 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
} }
} }
@Override
public void updateOnOrOff(VirtualRealityIbp ibp, VirtualRealityIbp.Mean mean, Boolean up, boolean on) {
List<VirtualRealityIbp.IbpElement> elements = ibp.query(mean, up);
elements.forEach(element -> element.setOn(on));
}
@Override @Override
public void collectAndDispatcher(Simulation simulation) { public void collectAndDispatcher(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
@ -282,26 +305,27 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
MapConfig config = repository.getConfig(); MapConfig config = repository.getConfig();
List<VirtualRealityIbp.SquareButton> sdList = vrIbp.queryByMean(VirtualRealityIbp.Mean.SD); List<VirtualRealityIbp.SquareButton> sdList = vrIbp.queryByMean(VirtualRealityIbp.Mean.SD);
Set<String> sdSignalCodes; //处于试灯状态的信号灯 Set<VirtualRealityIbp.Mean> sdLightMeans; //处于试灯状态的元素的意义
if (!CollectionUtils.isEmpty(sdList)) { if (!CollectionUtils.isEmpty(sdList)) {
sdSignalCodes = sdList.stream() sdLightMeans = sdList.stream()
.filter(VirtualRealityIbp.SquareButton::isPressed) .filter(VirtualRealityIbp.SquareButton::isPressed)
.flatMap(button -> button.getSignalCodes().stream()) .flatMap(button -> button.getSdLightMeans().stream())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} else { } else {
sdSignalCodes = new HashSet<>(); sdLightMeans = new HashSet<>();
} }
for (VirtualRealityIbp.IbpElement element : vrIbp.getElementList()) { for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) {
if (sdSignalCodes.contains(element.getCode())) { //如果是处于试灯状态的元素直接点亮 if (sdLightMeans.contains(element.getMean())) { //如果是处于试灯状态的元素直接点亮
element.setOn(true); element.orderTo(true);
continue; continue;
} }
List<Stand> stands = chooseStands(station, element, config); List<Stand> stands = chooseStands(station, element.getUp(), config);
if (element.getMean() == null) if (element.getMean() == null)
continue; continue;
switch (element.getMean()) { switch (element.getMean()) {
case HSJC: case PSD_SMKM:
case PSD_HSJC:
case KC: case KC:
case XXYS: case XXYS:
case SXYS: case SXYS:
@ -314,28 +338,37 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService {
case AXLE_RESET: case AXLE_RESET:
case PRERESET_Z: case PRERESET_Z:
case ALARM: case ALARM:
case CZ_LIGHT: case PSD_CZYX_LIGHT:
case SD: case SD:
case PSD_ALARM:
case PSD_BJQC:
break; break;
case kcLight: case kcLight:
element.setOn(stands.stream().anyMatch(Stand::isIbpHoldTrain)); element.orderTo(stands.stream().anyMatch(Stand::isIbpHoldTrain));
break; break;
case jjtcLight: case jjtcLight:
element.setOn(stands.stream().allMatch(Stand::isEmergencyClosed)); element.orderTo(stands.stream().allMatch(Stand::isEmergencyClosed));
break; break;
case gmLight: case gmLight:
element.setOn(stands.stream().allMatch(stand -> stand.getPsd().isCloseAndLock())); element.orderTo(stands.stream().allMatch(stand -> stand.getPsd().isCloseAndLock()));
break; break;
case kmLight: case kmLight:
element.setOn(!stands.stream().allMatch(stand -> stand.getPsd().isClose())); element.orderTo(!stands.stream().allMatch(stand -> stand.getPsd().isClose()));
break; break;
case HSJC_LIGHT: case PSD_HSJC_LIGHT:
element.setOn(stands.stream().anyMatch(stand -> stand.getPsd().isInterlockRelease())); element.orderTo(stands.stream().anyMatch(stand -> stand.getPsd().isInterlockRelease()));
break; break;
case AXLE_PRE_RESET: case AXLE_PRE_RESET:
VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element; VirtualRealityIbp.SquareButton button = (VirtualRealityIbp.SquareButton) element;
Section section = repository.getByCode(button.getSectionCode(), Section.class); Section section = repository.getByCode(button.getSectionCode(), Section.class);
element.setOn(section.isPreReset()); element.orderTo(section.isPreReset());
break;
case PSD_SDCZ_LIGHT: //逻辑未知
break;
case PSD_GZBJ_LIGHT:
element.orderTo(stands.stream().anyMatch(Stand::hasCheckedPsdFault));
break;
case PSD_SD:
break; break;
default: default:
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("未知的IBP元素类型"); throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("未知的IBP元素类型");

View File

@ -331,6 +331,16 @@ public class Stand extends MayOutOfOrderDevice {
this.runTimeMap.put(groupNumber, runLevelTime); this.runTimeMap.put(groupNumber, runLevelTime);
} }
/**
* 有能被检测到的屏蔽门故障
*/
public boolean hasCheckedPsdFault() {
DeviceFault fault = this.getFault();
return Fault.PSD_CANNOT_BE_CLOSED.equals(fault)
|| Fault.PSD_CANNOT_BE_OPENED.equals(fault)
|| Fault.NO_CLOSE_AND_LOCK.equals(fault);
}
/** /**
* 站台折返类型策略 * 站台折返类型策略
*/ */

View File

@ -9,7 +9,6 @@ import org.springframework.util.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
@Getter @Getter
@Setter @Setter
@ -18,7 +17,7 @@ public class IbpStatus {
private Map<String, IbpElementStatus> statusMap = new HashMap<>(); private Map<String, IbpElementStatus> statusMap = new HashMap<>();
public IbpStatus(VirtualRealityIbp vrIbp) { public IbpStatus(VirtualRealityIbp vrIbp) {
for (VirtualRealityIbp.IbpElement ibpElement : vrIbp.getElementList()) { for (VirtualRealityIbp.IbpElement ibpElement : vrIbp.getAllElements()) {
statusMap.put(ibpElement.getCode(), new IbpElementStatus(ibpElement)); statusMap.put(ibpElement.getCode(), new IbpElementStatus(ibpElement));
} }
} }
@ -26,7 +25,7 @@ public class IbpStatus {
public IbpStatus collectDifference(VirtualRealityIbp vrIbp) { public IbpStatus collectDifference(VirtualRealityIbp vrIbp) {
IbpStatus ibpStatus = new IbpStatus(); IbpStatus ibpStatus = new IbpStatus();
Map<String, IbpElementStatus> diffMap = ibpStatus.getStatusMap(); Map<String, IbpElementStatus> diffMap = ibpStatus.getStatusMap();
for (VirtualRealityIbp.IbpElement ibpElement : vrIbp.getElementList()) { for (VirtualRealityIbp.IbpElement ibpElement : vrIbp.getAllElements()) {
IbpElementStatus status = statusMap.get(ibpElement.getCode()); IbpElementStatus status = statusMap.get(ibpElement.getCode());
if (status == null) { if (status == null) {
status = new IbpElementStatus(ibpElement); status = new IbpElementStatus(ibpElement);

View File

@ -8,10 +8,7 @@ import lombok.Setter;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -28,7 +25,7 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
super(code, name, DeviceType.IBP); super(code, name, DeviceType.IBP);
if (!CollectionUtils.isEmpty(ibpData.getDrawData().getSquareButtonList())) { if (!CollectionUtils.isEmpty(ibpData.getDrawData().getSquareButtonList())) {
for (IbpData.SquareButtonVO vo : ibpData.getDrawData().getSquareButtonList()) { for (IbpData.SquareButtonVO vo : ibpData.getDrawData().getSquareButtonList()) {
SquareButton button = new SquareButton(vo.getCode(), vo.getMean(), false, vo.getSectionCode(), vo.getSignalCodes(), vo.getDirection()); SquareButton button = new SquareButton(vo.getCode(), vo.getMean(), false, vo.getSectionCode(), vo.getDirection());
addElement(button); addElement(button);
} }
} }
@ -55,8 +52,8 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
} }
public void reset() { public void reset() {
this.queryByMean(Mean.SXYS).forEach(element -> element.setOn(false)); this.queryByMean(Mean.SXYS).forEach(element -> element.orderTo(false));
this.queryByMean(Mean.XXYS).forEach(element -> element.setOn(false)); this.queryByMean(Mean.XXYS).forEach(element -> element.orderTo(false));
} }
public void addElement(IbpElement element) { public void addElement(IbpElement element) {
@ -87,19 +84,27 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public <T extends IbpElement> List<T> query(Mean mean, Boolean up) { public <T extends IbpElement> T query(Mean mean, Boolean up) {
return elementMap.values().stream() return elementMap.values().stream()
.filter(element -> mean.equals(element.getMean()) && Objects.equals(element.getUp(), up)) .filter(element -> mean.equals(element.getMean()) && Objects.equals(element.getUp(), up))
.map(element -> (T) element) .map(element -> (T) element)
.collect(Collectors.toList()); .findAny().orElse(null);
} }
public Collection<IbpElement> getElementList() { public <T extends IbpElement> T get(Mean mean, Boolean up) {
T t = query(mean, up);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(t,
String.format("[%s]的IBP盘上无[%s]元素", station.debugStr(), up, mean));
return t;
}
public Collection<IbpElement> getAllElements() {
return this.elementMap.values(); return this.elementMap.values();
} }
/** /**
* 是否允许操作 * 是否允许操作
*
* @param up 是否是上行 * @param up 是否是上行
* @return * @return
*/ */
@ -109,7 +114,6 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
} }
@Getter @Getter
@Setter
public class IbpElement { public class IbpElement {
private String code; private String code;
@ -117,10 +121,24 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
private Mean mean; private Mean mean;
/** 是否开启/亮灯 */ /**
* 是否开启/亮灯
*/
private boolean on; private boolean on;
/** 是否上行 */ /**
* 要转为开启状态
*/
private boolean turnOn;
/**
* 要转为关闭状态
*/
private boolean turnOff;
/**
* 是否上行
*/
private Boolean up; private Boolean up;
public IbpElement(String code, Type type, Mean mean, boolean on, Boolean up) { public IbpElement(String code, Type type, Mean mean, boolean on, Boolean up) {
@ -131,18 +149,50 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
this.up = up; this.up = up;
} }
/**
* 下令
*/
public void orderTo(boolean on) {
if (isConnectReal()) {
if (on)
orderToOn();
else
orderToOff();
} else {
setOn(on);
}
}
public void setOn(boolean on) { public void setOn(boolean on) {
this.on = on; this.on = on;
if (on)
turnOn = false;
else
turnOff = false;
}
public void orderToOn() {
this.turnOn = true;
this.turnOff = false;
}
public void orderToOff() {
this.turnOn = false;
this.turnOff = true;
} }
} }
@Getter @Getter
@Setter @Setter
public class SquareButton extends IbpElement { public class SquareButton extends IbpElement {
/** 是否被按下 */ /**
* 是否被按下
*/
private boolean pressed; private boolean pressed;
/** 按钮被按下的时刻 */ /**
* 按钮被按下的时刻
*/
private LocalDateTime pressTime; private LocalDateTime pressTime;
/** /**
@ -151,21 +201,42 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
private String sectionCode; private String sectionCode;
/** /**
* 试灯按钮关联的灯 * 这些意义的元素受试灯按钮影响
*/ */
private List<String> signalCodes; private Set<Mean> sdLightMeans;
/** 有效的(防止计轴预复位按钮多次生效) */ /**
* 有效的防止计轴预复位按钮多次生效
*/
private boolean effective; private boolean effective;
public SquareButton(String code, Mean mean, boolean on, String sectionCode, List<String> signalCodes, Boolean up) { public SquareButton(String code, Mean mean, boolean on, String sectionCode, Boolean up) {
super(code, Type.BUTTON, mean, on, up); super(code, Type.BUTTON, mean, on, up);
this.sectionCode = sectionCode; this.sectionCode = sectionCode;
this.signalCodes = signalCodes; if (mean != null) {
switch (mean) {
case SD: {
sdLightMeans = new HashSet<>();
sdLightMeans.add(Mean.kcLight);
sdLightMeans.add(Mean.jjtcLight);
break;
}
case PSD_SD: {
sdLightMeans = new HashSet<>();
sdLightMeans.add(Mean.gmLight);
sdLightMeans.add(Mean.kmLight);
sdLightMeans.add(Mean.PSD_CZYX_LIGHT);
sdLightMeans.add(Mean.PSD_HSJC_LIGHT);
break;
}
}
}
} }
} }
/** 元素类型 */ /**
* 元素类型
*/
public enum Type { public enum Type {
LIGHT, LIGHT,
BUTTON, BUTTON,
@ -173,7 +244,9 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
ALARM, ALARM,
} }
/** 元素意义 */ /**
* 元素意义
*/
public enum Mean { public enum Mean {
//------------------ 信号 ------------------ //------------------ 信号 ------------------
/** /**
@ -203,15 +276,17 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
kcLight, kcLight,
jjtcLight, jjtcLight,
gmLight,
kmLight,
SD, SD,
//------------------ 屏蔽门 ------------------ //------------------ 屏蔽门 ------------------
/** /**
* 下行屏蔽门开门 * 开门
*/ */
KM, KM,
/**
* 首末开门
*/
PSD_SMKM,
GM, GM,
/** /**
* 下行钥匙 * 下行钥匙
@ -221,19 +296,33 @@ public class VirtualRealityIbp extends VirtualRealityDevice {
/** /**
* 互锁解除 * 互锁解除
*/ */
HSJC, PSD_HSJC,
/** /**
* 屏蔽门的蜂鸣器 * 屏蔽门板块的蜂鸣器
*/ */
PSD_ALARM, PSD_ALARM,
/**
* 屏蔽门板块的报警切除
*/
PSD_BJQC,
gmLight,
kmLight,
/** /**
* 操作允许灯 * 操作允许灯
*/ */
CZ_LIGHT, PSD_CZYX_LIGHT,
/** /**
* 互锁解除灯 * 互锁解除灯
*/ */
HSJC_LIGHT, PSD_HSJC_LIGHT,
/**
* 手动操作灯
*/
PSD_SDCZ_LIGHT,
/**
* 故障报警灯
*/
PSD_GZBJ_LIGHT,
/** /**
* 屏蔽门试灯 * 屏蔽门试灯
*/ */

View File

@ -3,17 +3,24 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj;
import club.joylink.rtss.services.IVirtualRealityIbpService; import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO; import club.joylink.rtss.vo.client.project.hhcj.HhcjIbpConfigVO;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects;
@Service @Service
public class HhcjIbpServiceImpl implements RealDeviceService { public class HhcjIbpServiceImpl implements RealDeviceService {
@Autowired @Autowired
private IVirtualRealityIbpService iVirtualRealityIbpService; private IVirtualRealityIbpService iVirtualRealityIbpService;
@Autowired
private PlcGatewayService plcGatewayService;
@Override @Override
public boolean canHandle(RealDeviceConfig deviceConfig) { public boolean canHandle(RealDeviceConfig deviceConfig) {
@ -27,6 +34,9 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
@Override @Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
if (plcGateway == null)
return;
HhcjIbpConfig config = (HhcjIbpConfig) deviceConfig; HhcjIbpConfig config = (HhcjIbpConfig) deviceConfig;
VirtualRealityIbp vrIbp = (VirtualRealityIbp) config.getMapElement(); VirtualRealityIbp vrIbp = (VirtualRealityIbp) config.getMapElement();
if (vrIbp == null) if (vrIbp == null)
@ -39,20 +49,158 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
boolean r_xx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_gm()); boolean r_xx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_gm());
boolean r_xx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_hsjc()); boolean r_xx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_hsjc());
boolean r_xy = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xy()); boolean r_xy = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xy());
boolean r_dcs = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_dcs()); boolean r_psd_sd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_psd_sd());
boolean r_sx_cz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_cz()); boolean r_sx_cz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_cz());
boolean r_sx_smkm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_smkm()); boolean r_sx_smkm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_smkm());
boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km()); boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km());
boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm()); boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm());
boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc()); boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.XXYS, false, r_xx_cz); boolean w_xx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_czyx());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.KM, false, r_xx_km); boolean w_xx_smkm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_smkm());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.GM, false, r_xx_gm); boolean w_xx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_km());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.HSJC, false, r_xx_hsjc); boolean w_xx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_gm());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.SXYS, true, r_sx_cz); boolean w_xx_gbsj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_gbsj());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.KM, true, r_sx_km); boolean w_xx_dk = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_dk());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.GM, true, r_sx_gm); boolean w_xx_sdcz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_sdcz());
iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, VirtualRealityIbp.Mean.HSJC, true, r_sx_hsjc); boolean w_xx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_hsjc());
boolean w_gzbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gzbj());
boolean w_psd_fmq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_psd_fmq());
boolean w_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_czyx());
boolean w_sx_smkm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_smkm());
boolean w_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_km());
boolean w_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_gm());
boolean w_sx_gbsj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_gbsj());
boolean w_sx_dk = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_dk());
boolean w_sx_sdcz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_sdcz());
boolean w_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_hsjc());
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, false, w_xx_czyx);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_SMKM, false, w_xx_smkm);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.KM, false, w_xx_km);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.GM, false, w_xx_gm);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.gmLight, false, w_xx_gbsj);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.kmLight, false, w_xx_dk);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_SDCZ_LIGHT, false, w_xx_sdcz);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_HSJC_LIGHT, false, w_xx_hsjc);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_GZBJ_LIGHT, null, w_gzbj);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_ALARM, null, w_psd_fmq);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_CZYX_LIGHT, true, w_sx_czyx);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_SMKM, true, w_sx_smkm);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.KM, true, w_sx_km);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.GM, true, w_sx_gm);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.gmLight, true, w_sx_gbsj);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.kmLight, true, w_sx_dk);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_SDCZ_LIGHT, true, w_sx_sdcz);
iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.PSD_HSJC_LIGHT, true, w_sx_hsjc);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.XXYS, false, r_xx_cz);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.KM, false, r_xx_km);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.GM, false, r_xx_gm);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.PSD_HSJC, false, r_xx_hsjc);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.PSD_BJQC, null, r_xy);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.PSD_SD, null, r_psd_sd);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.SXYS, true, r_sx_cz);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.KM, true, r_sx_km);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.GM, true, r_sx_gm);
iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.PSD_HSJC, true, r_sx_hsjc);
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel();
for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) {
Boolean on = null;
if (element.isTurnOn()) {
on = true;
} else if (element.isTurnOff()) {
on = false;
}
boolean currentIsOn = false;
Integer addr = null;
switch (element.getMean()) {
case KM:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_km();
currentIsOn = w_sx_km;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_km();
currentIsOn = w_xx_km;
}
break;
case PSD_SMKM:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_smkm();
currentIsOn = w_sx_smkm;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_smkm();
currentIsOn = w_xx_smkm;
}
break;
case GM:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_gm();
currentIsOn = w_sx_gm;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_gm();
currentIsOn = w_xx_gm;
}
break;
case PSD_ALARM:
addr = configVO.getW_psd_fmq();
currentIsOn = w_psd_fmq;
break;
case gmLight:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_gbsj();
currentIsOn = w_sx_gbsj;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_gbsj();
currentIsOn = w_xx_gbsj;
}
break;
case kmLight:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_dk();
currentIsOn = w_sx_dk;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_dk();
currentIsOn = w_xx_dk;
}
break;
case PSD_CZYX_LIGHT:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_czyx();
currentIsOn = w_sx_czyx;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_czyx();
currentIsOn = w_xx_czyx;
}
break;
case PSD_HSJC_LIGHT:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_hsjc();
currentIsOn = w_sx_hsjc;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_hsjc();
currentIsOn = w_xx_hsjc;
}
break;
case PSD_SDCZ_LIGHT:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_sdcz();
currentIsOn = w_sx_sdcz;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_sdcz();
currentIsOn = w_xx_sdcz;
}
break;
case PSD_GZBJ_LIGHT:
addr = configVO.getW_gzbj();
currentIsOn = w_gzbj;
break;
}
if (addr != null && on != null) {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, addr, currentIsOn, on, channel);
}
}
} }
} }

View File

@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.Objects;
@Slf4j @Slf4j
@Component @Component
@ -72,60 +72,77 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
boolean r_sd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sd()); boolean r_sd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sd());
boolean r_qdbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_qdbj()); boolean r_qdbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_qdbj());
boolean w_fmq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fmq()); boolean w_fmq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fmq());
boolean w_sx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_jjtcd());
boolean w_xx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_jjtcd()); boolean w_xx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_jjtcd());
boolean w_sx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_kcd());
boolean w_xx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_kcd()); boolean w_xx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_kcd());
boolean w_sx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_jjtcd());
boolean w_sx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_kcd());
boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx()); boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx());
boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km()); boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km());
boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm()); boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm());
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
//查找真实设备和vr设备 //
/*------------------------- 输入 -------------------------*/ iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.jjtcLight, false, w_xx_kcd);
//下行紧急停车 iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.kcLight, false, w_xx_kcd);
List<VirtualRealityIbp.IbpElement> jjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, false); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.jjtcLight, true, w_sx_kcd);
jjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_jjtc)); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.kcLight, true, w_sx_kcd);
//下行取消紧停 // 按钮灯
List<VirtualRealityIbp.IbpElement> qxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, false); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.JJTC, false, r_xx_jjtc);
qxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxjt)); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.QXJJTC, false, r_xx_qxjt);
//下行扣车 iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.KC, false, r_xx_kc);
List<VirtualRealityIbp.IbpElement> kc = vrIbp.query(VirtualRealityIbp.Mean.KC, false); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.ZZKC, false, r_xx_qxkc);
kc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_kc)); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.JJTC, true, r_sx_jjtc);
//下行取消扣车 iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.QXJJTC, true, r_sx_qxjt);
List<VirtualRealityIbp.IbpElement> qxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, false); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.KC, true, r_sx_kc);
qxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_xx_qxkc)); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.ZZKC, true, r_sx_qxkc);
//上行紧急停车 iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.XXYS, false, r_sx_czyx);
List<VirtualRealityIbp.IbpElement> sxjjtc = vrIbp.query(VirtualRealityIbp.Mean.JJTC, true); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.KM, true, r_sx_km);
sxjjtc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_jjtc)); iVirtualRealityIbpService.updateOnOrOff(vrIbp, VirtualRealityIbp.Mean.GM, true, r_sx_gm);
//上行取消紧停 // 按钮
List<VirtualRealityIbp.IbpElement> sxqxjt = vrIbp.query(VirtualRealityIbp.Mean.QXJJTC, true); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.JJTC, false, r_xx_jjtc);
sxqxjt.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxjt)); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.QXJJTC, false, r_xx_qxjt);
//上行扣车 iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.KC, false, r_xx_kc);
List<VirtualRealityIbp.IbpElement> sxkc = vrIbp.query(VirtualRealityIbp.Mean.KC, true); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.ZZKC, false, r_xx_qxkc);
sxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_kc)); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.JJTC, true, r_sx_jjtc);
//上行取消扣车 iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.QXJJTC, true, r_sx_qxjt);
List<VirtualRealityIbp.IbpElement> sxqxkc = vrIbp.query(VirtualRealityIbp.Mean.ZZKC, true); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.KC, true, r_sx_kc);
sxqxkc.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sx_qxkc)); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.ZZKC, true, r_sx_qxkc);
//试灯 iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.ZZKC, null, r_sd);
List<VirtualRealityIbp.IbpElement> sd = vrIbp.queryByMean(VirtualRealityIbp.Mean.SD); iVirtualRealityIbpService.pressOrRelease(simulation, vrIbp, VirtualRealityIbp.Mean.XXYS, false, r_sx_czyx);
sd.forEach(element -> iVirtualRealityIbpService.updateElementStatus(simulation, vrIbp, element, r_sd));
//下行允许禁止钥匙
List<VirtualRealityIbp.IbpElement> ibpElements = vrIbp.queryByMean(VirtualRealityIbp.Mean.XXYS);
ibpElements.forEach(ibpElement -> ibpElement.setOn(r_sx_czyx));
/*------------------------- 输出 -------------------------*/ /*------------------------- 输出 -------------------------*/
boolean xxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, false).stream() for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) {
.allMatch(VirtualRealityIbp.IbpElement::isOn); Integer addr = null;
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, xxkcd, channel); boolean currentIsOn = false;
boolean sxkcd = vrIbp.query(VirtualRealityIbp.Mean.kcLight, true).stream() Boolean turnOn = null;
.allMatch(VirtualRealityIbp.IbpElement::isOn); if (element.isTurnOn()) {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, sxkcd, channel); turnOn = true;
boolean xxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, false).stream() } else if (element.isTurnOff()) {
.allMatch(VirtualRealityIbp.IbpElement::isOn); turnOn = false;
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, xxjjtcd, channel); }
boolean sxjjtcd = vrIbp.query(VirtualRealityIbp.Mean.jjtcLight, true).stream() switch (element.getMean()) {
.allMatch(VirtualRealityIbp.IbpElement::isOn); case kcLight:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, sxjjtcd, channel); if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_kcd();
currentIsOn = w_sx_kcd;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_kcd();
currentIsOn = w_xx_kcd;
}
break;
case jjtcLight:
if (Objects.equals(true, element.getUp())) {
addr = configVO.getW_sx_jjtcd();
currentIsOn = w_sx_jjtcd;
} else if (Objects.equals(false, element.getUp())) {
addr = configVO.getW_xx_jjtcd();
currentIsOn = w_xx_jjtcd;
}
break;
}
if (addr != null && turnOn != null) {
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, addr, currentIsOn, turnOn, channel);
}
}
//ISCS状态 //ISCS状态
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
String iscsCode = configVO.getIscsCode(); String iscsCode = configVO.getIscsCode();

View File

@ -36,9 +36,9 @@ public class HhcjIbpConfigVO extends RealConfigVO {
private Integer r_xy = 15; private Integer r_xy = 15;
/** /**
* 灯测试 * 屏蔽门板块试灯
*/ */
private Integer r_dcs = 16; private Integer r_psd_sd = 16;
/** /**
* 上行操作开关 * 上行操作开关
@ -65,6 +65,96 @@ public class HhcjIbpConfigVO extends RealConfigVO {
*/ */
private Integer r_sx_hsjc = 21; private Integer r_sx_hsjc = 21;
/**
* 下行IBP/PSL操作允许灯
*/
private Integer w_xx_czyx = 41;
/**
* 下行首末开门按钮灯
*/
private Integer w_xx_smkm = 42;
/**
* 下行开门按钮灯
*/
private Integer w_xx_km = 43;
/**
* 下行关门按钮灯
*/
private Integer w_xx_gm = 44;
/**
* 下行所有门关闭且锁紧灯
*/
private Integer w_xx_gbsj = 45;
/**
* 下行所有门打开灯
*/
private Integer w_xx_dk = 46;
/**
* 下行手动操作灯
*/
private Integer w_xx_sdcz = 47;
/**
* 下行互锁解除灯
*/
private Integer w_xx_hsjc = 48;
/**
* 故障报警灯
*/
private Integer w_gzbj = 49;
/**
* 屏蔽门蜂鸣器
*/
private Integer w_psd_fmq = 50;
/**
* 上行操作允许灯
*/
private Integer w_sx_czyx = 51;
/**
* 上行首末开门按钮灯
*/
private Integer w_sx_smkm = 52;
/**
* 上行开门按钮灯
*/
private Integer w_sx_km = 53;
/**
* 上行关门按钮灯
*/
private Integer w_sx_gm = 54;
/**
* 上行所有门关闭锁紧灯
*/
private Integer w_sx_gbsj = 55;
/**
* 上行所有门打开灯
*/
private Integer w_sx_dk = 56;
/**
* 上行手动操作灯
*/
private Integer w_sx_sdcz = 57;
/**
* 上行互锁解除灯
*/
private Integer w_sx_hsjc = 58;
public HhcjIbpConfigVO() { public HhcjIbpConfigVO() {
super(0, 304); super(0, 304);
} }