【地图设备筛选、背景设置修改】
This commit is contained in:
parent
3ff942aaa4
commit
47987c9040
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.vo.training2.rule;
|
||||
|
||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
||||
@ -236,12 +237,10 @@ public enum BgSceneStatusRule {
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
section.setRouteLock(true);
|
||||
section.setLockRight(true);
|
||||
if(!CollectionUtils.isEmpty(section.getLogicList())) {
|
||||
section.getLogicList().forEach(s -> {
|
||||
s.setRouteLock(true);
|
||||
s.setLockRight(true);
|
||||
});
|
||||
if (section.isCross()) {
|
||||
section.getLogicList().get(0).setRouteLock(true);
|
||||
} else if (section.isShowLogic()) {
|
||||
section.getLogicList().forEach(s -> s.setRouteLock(true));
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
@ -285,7 +284,7 @@ public enum BgSceneStatusRule {
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
section.setSpeedUpLimit(5);
|
||||
return null;
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") {
|
||||
@ -325,7 +324,7 @@ public enum BgSceneStatusRule {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
|
||||
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
|
||||
BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight());
|
||||
return null;
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -362,7 +361,13 @@ public enum BgSceneStatusRule {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Stand stand = (Stand) mapElement;
|
||||
stand.setTrainLimit(3);
|
||||
if (MapPrdTypeEnum.LOCAL.equals(simulation.getBuildParams().getProdType())) {
|
||||
// 现地,设置背景为现地扣车
|
||||
stand.setStationHoldTrain(true);
|
||||
} else {
|
||||
// 行调,设置背景为中心扣车
|
||||
stand.setCenterHoldTrain(true);
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
|
@ -4,10 +4,12 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@ -65,45 +67,32 @@ public enum MapDeviceRule {
|
||||
SECTION_LIST("区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<Route> routeList = ROUTE_LIST.filterMapDeviceList(simulation);
|
||||
List<Section> sectionList = new ArrayList<>(100);
|
||||
routeList.forEach(route -> sectionList.addAll(route.getSectionList()));
|
||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_STAND_TURN_BACK_LIST("折返区段列表") {
|
||||
SECTION_LOGIC_LIST("逻辑区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(section -> section.isStandTrack() && section.isTurnBackTrack())
|
||||
.collect(Collectors.toList());
|
||||
return MapDeviceRule.generateRandomElement(sectionList, 2);
|
||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isLogicSection);
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") {
|
||||
SECTION_PHYSICAL_LIST("物理区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter())
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter())
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isSwitchAxleCounterSection);
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
;
|
||||
|
||||
private String description;
|
||||
@ -133,4 +122,36 @@ public enum MapDeviceRule {
|
||||
}
|
||||
return givenList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选符合条件的方法
|
||||
* @param simulation 仿真
|
||||
* @param filterFunction 筛选条件
|
||||
* @return 返回区段列表
|
||||
*/
|
||||
private static List<Section> querySectionListByFunction(Simulation simulation, Function<Section, Boolean> filterFunction) {
|
||||
return simulation.getRepository().getSectionList().stream().filter(section -> {
|
||||
Station deviceStation = section.getDeviceStation();
|
||||
if (deviceStation != null && deviceStation.isDepot()) {
|
||||
return false;
|
||||
}
|
||||
Section axleCounterSection = section.findAxleCounterSection();
|
||||
if (axleCounterSection != null) {
|
||||
Station axleDeviceStation = axleCounterSection.getDeviceStation();
|
||||
if (axleDeviceStation != null && axleDeviceStation.isDepot()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(section.getName())){
|
||||
return false;
|
||||
}
|
||||
if (section.getParent() != null && section.getParent().isCross()) {
|
||||
return false;
|
||||
}
|
||||
if (filterFunction != null) {
|
||||
return filterFunction.apply(section);
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user