【修改车站获取指示灯列表BUG】

【增加按钮枚举类型】
【指示灯、按钮初始化类型筛选】

Signed-off-by: weizhihong <weizhihong@joylink.club>
This commit is contained in:
weizhihong 2022-04-21 11:06:11 +08:00
parent 4cbb439634
commit 17edb388d8
4 changed files with 110 additions and 82 deletions

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.cbtc.build; package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.constant.SignalModel; import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
@ -1517,14 +1516,14 @@ public class MapDeviceBuilder {
*/ */
private static void buildAssistIndicator(Map<String, MapElement> elementMap private static void buildAssistIndicator(Map<String, MapElement> elementMap
, List<String> errMsgList, List<MapIndicatorLightVO> indicatorList) { , List<String> errMsgList, List<MapIndicatorLightVO> indicatorList) {
// 区间占用\辅助状态\总辅助\发车辅助\接车辅助\接发车箭头\复原\事故\闭塞
List<String> indicatorTypeList = Arrays.asList(
"SectionOccupied", "AssistStatus", "TotalAssist", "DepartAssist", "PickAssist", "PickOrDepartArrow",
"Recovery", "Accident", "Occlusion"
);
indicatorList indicatorList
.stream() .stream()
.filter(mapIndicatorLightVO -> .filter(mapIndicatorLightVO -> indicatorTypeList.contains(mapIndicatorLightVO.getType()))
Arrays.stream(DirectionLabelEnum.values())
.filter(e -> e.equals(mapIndicatorLightVO.getLabelEnum()))
.findAny()
.isPresent()
)
.forEach(mapSignalButtonVO -> { .forEach(mapSignalButtonVO -> {
if (elementMap.containsKey(mapSignalButtonVO.getCode())) { if (elementMap.containsKey(mapSignalButtonVO.getCode())) {
errMsgList.add(String.format("指示灯[%s]必须唯一", mapSignalButtonVO.getCode())); errMsgList.add(String.format("指示灯[%s]必须唯一", mapSignalButtonVO.getCode()));
@ -1547,14 +1546,16 @@ public class MapDeviceBuilder {
*/ */
private static void buildAssistButton(Map<String, MapElement> elementMap private static void buildAssistButton(Map<String, MapElement> elementMap
, List<String> errMsgList, List<MapSignalButtonVO> signalButtonList) { , List<String> errMsgList, List<MapSignalButtonVO> signalButtonList) {
// 改方
List<MapSignalButtonVO.Type> buttonTypeList = Arrays.asList(
MapSignalButtonVO.Type.ASSIST,
MapSignalButtonVO.Type.PICK_ASSIST,
MapSignalButtonVO.Type.DEPART_ASSIST,
MapSignalButtonVO.Type.CHANGE_DIRECTION
);
signalButtonList signalButtonList
.stream() .stream()
.filter(mapSignalButtonVO -> .filter(mapSignalButtonVO -> buttonTypeList.contains(mapSignalButtonVO.getType()))
Arrays.stream(DirectionLabelEnum.values())
.filter(e -> e.equals(mapSignalButtonVO.getLabelEnum()))
.findAny()
.isPresent()
)
.forEach(mapSignalButtonVO -> { .forEach(mapSignalButtonVO -> {
if (elementMap.containsKey(mapSignalButtonVO.getCode())) { if (elementMap.containsKey(mapSignalButtonVO.getCode())) {
errMsgList.add(String.format("按钮[%s]必须唯一", mapSignalButtonVO.getCode())); errMsgList.add(String.format("按钮[%s]必须唯一", mapSignalButtonVO.getCode()));

View File

@ -23,11 +23,11 @@ import java.util.stream.Collectors;
public class Station extends MayOutOfOrderDevice { public class Station extends MayOutOfOrderDevice {
public Station(String code, String name) { public Station(String code, String name) {
super(code, name, DeviceType.STATION); super(code, name, DeviceType.STATION);
this.transferList = new ArrayList<>(); transferList = new ArrayList<>();
this.turnBackList = new ArrayList<>(); turnBackList = new ArrayList<>();
this.rdStandList = new ArrayList<>(); rdStandList = new ArrayList<>();
this.ldStandList = new ArrayList<>(); ldStandList = new ArrayList<>();
this.controlMode = ControlMode.Center; controlMode = ControlMode.Center;
} }
/** /**
@ -183,52 +183,52 @@ public class Station extends MayOutOfOrderDevice {
/** /**
* 按钮列表 * 按钮列表
*/ */
private List<Button> buttonsList; private List<Button> buttonsList = new ArrayList<>();
/** /**
* 指示灯列表 * 指示灯列表
*/ */
private List<Indicator> indicatorList; private List<Indicator> indicatorList = new ArrayList<>();
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();
if (this.vrIbp != null) { if (vrIbp != null) {
vrIbp.reset(); vrIbp.reset();
} }
this.totalGuideLock = false; totalGuideLock = false;
if (this.hasControlMode) { if (hasControlMode) {
this.controlMode = ControlMode.Center; controlMode = ControlMode.Center;
} }
if (Objects.nonNull(this.tbStrategyId)) { if (Objects.nonNull(tbStrategyId)) {
this.tbStrategyId = this.getDefaultTbStrategyId(); tbStrategyId = getDefaultTbStrategyId();
} }
this.applicant = null; applicant = null;
this.apply2TheControlMode = null; apply2TheControlMode = null;
this.validDuration = null; validDuration = null;
this.interlockMachineStarting = false; interlockMachineStarting = false;
this.restartTime = null; restartTime = null;
this.controller = null; controller = null;
this.emergencyController = false; emergencyController = false;
this.controlApplicant = null; controlApplicant = null;
this.preResetValidDuration = new AtomicInteger(0); preResetValidDuration = new AtomicInteger(0);
} }
public List<Stand> getStandOf(boolean right) { public List<Stand> getStandOf(boolean right) {
if (right) { if (right) {
return this.rdStandList; return rdStandList;
} else { } else {
return this.ldStandList; return ldStandList;
} }
} }
public void addTransferTrack(Section section) { public void addTransferTrack(Section section) {
this.transferList.add(section); transferList.add(section);
} }
public void addTurnBackSection(Section section) { public void addTurnBackSection(Section section) {
this.turnBackList.add(section); turnBackList.add(section);
} }
public List<Stand> getAllStandList() { public List<Stand> getAllStandList() {
@ -239,35 +239,35 @@ public class Station extends MayOutOfOrderDevice {
} }
public void addRdStand(Stand stand) { public void addRdStand(Stand stand) {
this.rdStandList.add(stand); rdStandList.add(stand);
} }
public void addLdStand(Stand stand) { public void addLdStand(Stand stand) {
this.ldStandList.add(stand); ldStandList.add(stand);
} }
public StationTurnBackStrategyOption getCurrentTurnBackStrategy() { public StationTurnBackStrategyOption getCurrentTurnBackStrategy() {
return this.getTurnBackStrategyById(this.tbStrategyId); return getTurnBackStrategyById(tbStrategyId);
} }
public StationTurnBackStrategyOption getTurnBackStrategyById(Integer id) { public StationTurnBackStrategyOption getTurnBackStrategyById(Integer id) {
if (Objects.isNull(this.tbStrategyMap)) { if (Objects.isNull(tbStrategyMap)) {
throw new SimulationException(SimulationExceptionType.System_Fault, throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("车站[%s(%s)]没有折返策略", this.getName(), this.getCode())); String.format("车站[%s(%s)]没有折返策略", getName(), getCode()));
} }
StationTurnBackStrategyOption strategyOption = this.tbStrategyMap.get(id); StationTurnBackStrategyOption strategyOption = tbStrategyMap.get(id);
if (Objects.isNull(strategyOption)) { if (Objects.isNull(strategyOption)) {
throw new SimulationException(SimulationExceptionType.System_Fault, throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("车站[%s(%s)]没有id为[%s]的折返策略", this.getName(), this.getCode(), id)); String.format("车站[%s(%s)]没有id为[%s]的折返策略", getName(), getCode(), id));
} }
return strategyOption; return strategyOption;
} }
public boolean isDefaultTurnBackStrategyId() { public boolean isDefaultTurnBackStrategyId() {
if (Objects.isNull(this.getTbStrategyId())) { if (Objects.isNull(getTbStrategyId())) {
return true; return true;
} else { } else {
StationTurnBackStrategyOption option = this.getCurrentTurnBackStrategy(); StationTurnBackStrategyOption option = getCurrentTurnBackStrategy();
if (option.getType().equals(TurnBackStrategyType.NONE)) { if (option.getType().equals(TurnBackStrategyType.NONE)) {
return true; return true;
} }
@ -282,7 +282,7 @@ public class Station extends MayOutOfOrderDevice {
*/ */
public boolean isNormal() { public boolean isNormal() {
boolean normal = false; boolean normal = false;
List<Stand> allStandList = this.getAllStandList(); List<Stand> allStandList = getAllStandList();
if (!CollectionUtils.isEmpty(allStandList)) { if (!CollectionUtils.isEmpty(allStandList)) {
for (Stand stand : allStandList) { for (Stand stand : allStandList) {
if (!stand.isSmall()) { if (!stand.isSmall()) {
@ -295,27 +295,27 @@ public class Station extends MayOutOfOrderDevice {
} }
public void surrenderControl() { public void surrenderControl() {
this.controlMode = ControlMode.None; controlMode = ControlMode.None;
} }
public boolean isSurrenderControl() { public boolean isSurrenderControl() {
return this.controlMode == ControlMode.None; return controlMode == ControlMode.None;
} }
public void occControl() { public void occControl() {
this.controlMode = ControlMode.Center; controlMode = ControlMode.Center;
} }
public void localControl() { public void localControl() {
this.controlMode = ControlMode.Local; controlMode = ControlMode.Local;
} }
/** /**
* 获取控制权转换申请者的id * 获取控制权转换申请者的id
*/ */
public String getApplicantId() { public String getApplicantId() {
if (this.getApplicant() != null) { if (getApplicant() != null) {
return this.getApplicant().getId(); return getApplicant().getId();
} }
return null; return null;
} }
@ -324,38 +324,38 @@ public class Station extends MayOutOfOrderDevice {
* 申请控制权转换 * 申请控制权转换
*/ */
public void apply4ControlTransfer(SimulationMember applicant, ControlMode controlMode) { public void apply4ControlTransfer(SimulationMember applicant, ControlMode controlMode) {
this.setApplicant(applicant); setApplicant(applicant);
this.setApply2TheControlMode(controlMode); setApply2TheControlMode(controlMode);
this.setValidDuration(SimulationConstants.CONTROL_TRANSFER_VALID_DURATION); setValidDuration(SimulationConstants.CONTROL_TRANSFER_VALID_DURATION);
} }
/** /**
* 取消控制权转换申请 * 取消控制权转换申请
*/ */
public void cancelControlTransferApplication() { public void cancelControlTransferApplication() {
this.setApplicant(null); setApplicant(null);
this.setApply2TheControlMode(null); setApply2TheControlMode(null);
this.setValidDuration(null); setValidDuration(null);
} }
/** /**
* 是否控制权转换申请中 * 是否控制权转换申请中
*/ */
public boolean isControlTransferApplying() { public boolean isControlTransferApplying() {
return this.getApplicant() != null return getApplicant() != null
&& this.getApply2TheControlMode() != null && getApply2TheControlMode() != null
&& this.getValidDuration() != null; && getValidDuration() != null;
} }
public Integer getValidDurationInSeconds() { public Integer getValidDurationInSeconds() {
if (this.validDuration == null) { if (validDuration == null) {
return null; return null;
} }
return this.validDuration / 1000; return validDuration / 1000;
} }
public boolean isNoDepotAndNoNormalStand() { public boolean isNoDepotAndNoNormalStand() {
List<Stand> allStandList = this.getAllStandList(); List<Stand> allStandList = getAllStandList();
boolean hasNormal = false; boolean hasNormal = false;
for (Stand stand : allStandList) { for (Stand stand : allStandList) {
if (!stand.isSmall()) { if (!stand.isSmall()) {
@ -363,11 +363,11 @@ public class Station extends MayOutOfOrderDevice {
break; break;
} }
} }
return !this.isDepot() && !hasNormal; return !isDepot() && !hasNormal;
} }
public boolean isNormalStandTrack(String sectionCode) { public boolean isNormalStandTrack(String sectionCode) {
for (Stand stand : this.getAllStandList()) { for (Stand stand : getAllStandList()) {
if (!stand.isSmall() && Objects.equals(stand.getSection().getCode(), sectionCode)) { if (!stand.isSmall() && Objects.equals(stand.getSection().getCode(), sectionCode)) {
return true; return true;
} }
@ -377,7 +377,7 @@ public class Station extends MayOutOfOrderDevice {
public List<Section> getParkSectionListBy(boolean right) { public List<Section> getParkSectionListBy(boolean right) {
List<Section> list = new ArrayList<>(); List<Section> list = new ArrayList<>();
List<Stand> standList = this.getStandOf(right); List<Stand> standList = getStandOf(right);
for (Stand stand : standList) { for (Stand stand : standList) {
if (!list.contains(stand.getSection())) { if (!list.contains(stand.getSection())) {
list.add(stand.getSection()); list.add(stand.getSection());
@ -390,13 +390,13 @@ public class Station extends MayOutOfOrderDevice {
* 该区段所属的正常站台是否右向 * 该区段所属的正常站台是否右向
*/ */
public boolean isStandOfSectionRight(@NonNull Section section) { public boolean isStandOfSectionRight(@NonNull Section section) {
List<Stand> stands = this.getAllNormalStands(); List<Stand> stands = getAllNormalStands();
for (Stand stand : stands) { for (Stand stand : stands) {
if (section.equals(stand.getSection())) { if (section.equals(stand.getSection())) {
return stand.isRight(); return stand.isRight();
} }
} }
throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("区段[%s]不是车站[%s]的站台轨", section.getCode(), this.getCode())); throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("区段[%s]不是车站[%s]的站台轨", section.getCode(), getCode()));
} }
public String getControllerId() { public String getControllerId() {
@ -414,18 +414,18 @@ public class Station extends MayOutOfOrderDevice {
} }
public int getPreResetValidDurationInSeconds() { public int getPreResetValidDurationInSeconds() {
return this.preResetValidDuration.get() / 1000; return preResetValidDuration.get() / 1000;
} }
public boolean isPreReset() { public boolean isPreReset() {
return this.preResetValidDuration != null && this.preResetValidDuration.get() > 0; return preResetValidDuration != null && preResetValidDuration.get() > 0;
} }
/** /**
* 查询优先的折返轨 * 查询优先的折返轨
*/ */
public Section queryFirstTurnBackSection() { public Section queryFirstTurnBackSection() {
if (CollectionUtils.isEmpty(this.tbStrategyMap) || this.tbStrategyId == null) { if (CollectionUtils.isEmpty(tbStrategyMap) || tbStrategyId == null) {
return null; return null;
} }
StationTurnBackStrategyOption strategy = getCurrentTurnBackStrategy(); StationTurnBackStrategyOption strategy = getCurrentTurnBackStrategy();
@ -442,11 +442,11 @@ public class Station extends MayOutOfOrderDevice {
} }
public void addDevice(StatusDevice device) { public void addDevice(StatusDevice device) {
this.deviceMap.put(device.getCode(), device); deviceMap.put(device.getCode(), device);
} }
public boolean isAtsRouteTriggerFault() { public boolean isAtsRouteTriggerFault() {
return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(this.getFault()); return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(getFault());
} }
public enum ControlMode { public enum ControlMode {
@ -478,14 +478,14 @@ public class Station extends MayOutOfOrderDevice {
* 是否中控 * 是否中控
*/ */
public boolean isCenterControl() { public boolean isCenterControl() {
return Objects.equals(ControlMode.Center, this.controlMode); return Objects.equals(ControlMode.Center, controlMode);
} }
/** /**
* 是否站控 * 是否站控
*/ */
public boolean isLocalControl() { public boolean isLocalControl() {
return Objects.equals(ControlMode.Local, this.controlMode); return Objects.equals(ControlMode.Local, controlMode);
} }
/** /**
@ -530,8 +530,9 @@ public class Station extends MayOutOfOrderDevice {
return getAllStandList().stream().filter(stand -> !stand.isSmall()).collect(Collectors.toList()); return getAllStandList().stream().filter(stand -> !stand.isSmall()).collect(Collectors.toList());
} }
@Override
public String debugStr() { public String debugStr() {
return String.format("车站[%s]", this.getName()); return String.format("车站[%s]", getName());
} }
@Override @Override

View File

@ -41,6 +41,11 @@ public class MapIndicatorLightVO {
*/ */
private DirectionLabelEnum labelEnum; private DirectionLabelEnum labelEnum;
/**
* 方向
*/
private boolean right;
// public enum Type{ // public enum Type{
// AtsControl, // AtsControl,

View File

@ -44,6 +44,27 @@ public class MapSignalButtonVO {
FLEXIBLE, FLEXIBLE,
RAMP_TERMINAL, RAMP_TERMINAL,
TRAIN_TERMINAL, TRAIN_TERMINAL,
SHUNT_TERMINAL SHUNT_TERMINAL,
/**
* 总辅助按钮
*/
ASSIST,
/**
* 接辅助按钮
*/
PICK_ASSIST,
/**
* 发辅助按钮
*/
DEPART_ASSIST,
/**
* 事故按钮
*/
ACCIDENT,
/**
* 改方按钮
*/
CHANGE_DIRECTION
} }
} }