Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
04aee988b3
@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|||||||
import club.joylink.rtss.simulation.cbtc.data.status.StationStatus;
|
import club.joylink.rtss.simulation.cbtc.data.status.StationStatus;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
|
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
|
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferResultVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
@ -185,24 +186,20 @@ public class AtsStationService {
|
|||||||
if (CollectionUtils.isEmpty(replyVOList)) {
|
if (CollectionUtils.isEmpty(replyVOList)) {
|
||||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "回复结果列表不能为空");
|
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "回复结果列表不能为空");
|
||||||
}
|
}
|
||||||
Map<String,Object> resultMap = null;
|
List<ControlTransferResultVO> resultVOList = new ArrayList<>(replyVOList.size());
|
||||||
SimulationMember applicant = null;
|
|
||||||
for (ControlTransferReplyVO reply : replyVOList) {
|
for (ControlTransferReplyVO reply : replyVOList) {
|
||||||
Station station = simulation.getRepository().getByCode(reply.getStationCode(), Station.class);
|
Station station = simulation.getRepository().getByCode(reply.getStationCode(), Station.class);
|
||||||
if (station.isControlTransferApplying()) {
|
if (station.isControlTransferApplying()) {
|
||||||
if (reply.isAgree()) {
|
if (reply.isAgree()) {
|
||||||
station.setControlMode(controlMode);
|
station.setControlMode(controlMode);
|
||||||
}
|
}
|
||||||
resultMap = new HashMap<>();
|
resultVOList.add(new ControlTransferResultVO(station, reply.isAgree()));
|
||||||
applicant = station.getApplicant();
|
|
||||||
resultMap.put("stationCode", station.getCode());
|
|
||||||
resultMap.put("applicantId", applicant.getId());
|
|
||||||
resultMap.put("apply2TheControlMode", station.getApply2TheControlMode());
|
|
||||||
resultMap.put("status", reply.isAgree());
|
|
||||||
station.cancelControlTransferApplication();
|
station.cancelControlTransferApplication();
|
||||||
sendHandlerMessage(simulation, applicant, resultMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(resultVOList)) {
|
||||||
|
resultVOList.forEach(vo -> sendHandlerMessage(simulation.getId(), vo));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -567,13 +564,12 @@ public class AtsStationService {
|
|||||||
/**
|
/**
|
||||||
* 发送车站转换结果
|
* 发送车站转换结果
|
||||||
*
|
*
|
||||||
* @param simulation 仿真
|
* @param group 仿真
|
||||||
* @param applicant 申请者
|
* @param vo 转换结果
|
||||||
* @param data 转换结果
|
|
||||||
*/
|
*/
|
||||||
private void sendHandlerMessage(Simulation simulation, SimulationMember applicant, Map<String, Object> data) {
|
private void sendHandlerMessage(String group, ControlTransferResultVO vo) {
|
||||||
SocketMessageVO<Map<String, Object>> messageVO =
|
SocketMessageVO<Map<String, Object>> messageVO =
|
||||||
SocketMessageFactory.build(WebSocketMessageType.Simulation_Control_Transfer_Result, simulation.getId(), data);
|
SocketMessageFactory.build(WebSocketMessageType.Simulation_Control_Transfer_Result, group, vo.getData());
|
||||||
stompMessageService.sendToUser(Set.of(applicant.getUserId()), messageVO);
|
stompMessageService.sendToUser(Set.of(vo.getUserId()), messageVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.data.vo;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 控制权转换结果信息
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ControlTransferResultVO {
|
||||||
|
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
private String applicantId;
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
private Station.ControlMode apply2TheControlMode;
|
||||||
|
|
||||||
|
private boolean status;
|
||||||
|
|
||||||
|
public ControlTransferResultVO(Station station, boolean agree) {
|
||||||
|
this.status = agree;
|
||||||
|
this.stationCode = station.getCode();
|
||||||
|
this.applicantId = station.getApplicantId();
|
||||||
|
this.userId = station.getApplicant().getUserId();
|
||||||
|
this.apply2TheControlMode = station.getApply2TheControlMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getData() {
|
||||||
|
Map<String,Object> resultMap = new HashMap<>();
|
||||||
|
resultMap.put("stationCode", stationCode);
|
||||||
|
resultMap.put("applicantId", applicantId);
|
||||||
|
resultMap.put("apply2TheControlMode", apply2TheControlMode);
|
||||||
|
resultMap.put("status", status);
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
}
|
@ -83,7 +83,6 @@ public enum BgSceneStatusRule {
|
|||||||
return getBgScene(simulation);
|
return getBgScene(simulation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SWITCH_NP_NB_BG_SCENE("宁波道岔定位背景") {
|
SWITCH_NP_NB_BG_SCENE("宁波道岔定位背景") {
|
||||||
@Override
|
@Override
|
||||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||||
@ -214,7 +213,12 @@ public enum BgSceneStatusRule {
|
|||||||
@Override
|
@Override
|
||||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||||
Signal signal = (Signal) mapElement;
|
Signal signal = (Signal) mapElement;
|
||||||
Route route = signal.getRouteList().get(0);
|
Route route = signal.getRouteList().stream()
|
||||||
|
.filter(r -> r.getSwitchList().stream().allMatch(switchElement -> switchElement.isNormal()))
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
if (route == null) {
|
||||||
|
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||||
|
}
|
||||||
openRouteDirect(simulation, route);
|
openRouteDirect(simulation, route);
|
||||||
return getBgScene(simulation);
|
return getBgScene(simulation);
|
||||||
}
|
}
|
||||||
@ -295,6 +299,21 @@ public enum BgSceneStatusRule {
|
|||||||
return getBgScene(simulation);
|
return getBgScene(simulation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
SIGNAL_HUMAN_RELEASE_BG_SCENE("信号机总人解背景"){
|
||||||
|
@Override
|
||||||
|
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||||
|
Signal signal = (Signal) mapElement;
|
||||||
|
Route route = signal.getRouteList().get(0);
|
||||||
|
openRouteDirect(simulation, route);
|
||||||
|
closeSignalDirectly(route.getStart());
|
||||||
|
// 添加信号机
|
||||||
|
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
|
||||||
|
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
|
||||||
|
Section section = route.getStart().getSection();
|
||||||
|
trainOnline(simulation, train, section, route.isRight());
|
||||||
|
return getBgScene(simulation);
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 区段区故解背景
|
* 区段区故解背景
|
||||||
*/
|
*/
|
||||||
@ -716,4 +735,20 @@ public enum BgSceneStatusRule {
|
|||||||
repository.addOnlineTrain(train);
|
repository.addOnlineTrain(train);
|
||||||
repository.addTrainInfo(trainInfo);
|
repository.addTrainInfo(trainInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直接关灯(默认逻辑点灯)
|
||||||
|
*/
|
||||||
|
private static void closeSignalDirectly(Signal signal) {
|
||||||
|
VirtualRealitySignal virtualSignal = signal.getVirtualSignal();
|
||||||
|
signal.changeLightType(true);
|
||||||
|
SignalAspect defaultAspect = virtualSignal.getModel().getDefaultAspect();
|
||||||
|
if (signal.isLogicLight()) {
|
||||||
|
virtualSignal.control(SignalAspect.No);
|
||||||
|
} else {
|
||||||
|
virtualSignal.control(defaultAspect);
|
||||||
|
}
|
||||||
|
virtualSignal.finish();
|
||||||
|
signal.setAspect(defaultAspect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package club.joylink.rtss.vo.training2.rule;
|
package club.joylink.rtss.vo.training2.rule;
|
||||||
|
|
||||||
|
import club.joylink.rtss.constants.BusinessConsts;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||||
@ -123,6 +124,23 @@ public enum MapDeviceRule {
|
|||||||
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
STAND_NO_DEPOT_LIST("非停车场站台列表") {
|
||||||
|
@Override
|
||||||
|
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Stand> standList = simulation.getRepository().getStandList().stream().filter(stand -> {
|
||||||
|
if (stand.getStation() != null && stand.getStation().isDepot())
|
||||||
|
return false;
|
||||||
|
if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!stand.getStation().isHasControlMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(stand -> stand.getStation().getSn())).collect(Collectors.toList());
|
||||||
|
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
ROUTE_LIST("进路列表") {
|
ROUTE_LIST("进路列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
@ -158,25 +176,6 @@ public enum MapDeviceRule {
|
|||||||
return generateRandomElement(routeList, NUMBER);
|
return generateRandomElement(routeList, NUMBER);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ROUTE_ATP_LIST("ATP进路列表") {
|
|
||||||
@Override
|
|
||||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
|
||||||
List<Route> routeList = simulation.getRepository().getRouteList().stream().filter(route -> {
|
|
||||||
if (route.getStart() == null || route.getStart().isVirtual()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 获取集中站的信息
|
|
||||||
if (route.getInterlockStation() == null || !route.getInterlockStation().isCentralized()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!route.isAtp()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return generateRandomElement(routeList, NUMBER);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ROUTE_FIRST_STATION_LIST("获取第一个站进路列表") {
|
ROUTE_FIRST_STATION_LIST("获取第一个站进路列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
@ -220,24 +219,6 @@ public enum MapDeviceRule {
|
|||||||
return generateRandomElement(switchList, 1);
|
return generateRandomElement(switchList, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SWITCH_ATP_LIST("集中站道岔列表") {
|
|
||||||
@Override
|
|
||||||
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
|
||||||
List<Switch> switchList = simulation.getRepository().getSwitchList().stream()
|
|
||||||
.filter(aSwitch -> {
|
|
||||||
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot())
|
|
||||||
return false;
|
|
||||||
if (!aSwitch.getDeviceStation().isCentralized()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (aSwitch.isSingleLock()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return generateRandomElement(switchList, 1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
CONTROL_STATION_SWITCH_LIST("控制模式车站的道岔列表") {
|
CONTROL_STATION_SWITCH_LIST("控制模式车站的道岔列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
||||||
@ -309,24 +290,6 @@ public enum MapDeviceRule {
|
|||||||
return MapDeviceRule.generateRandomElement(signalList, NUMBER);
|
return MapDeviceRule.generateRandomElement(signalList, NUMBER);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SIGNAL_ATP_LIST("集中站信号机列表") {
|
|
||||||
@Override
|
|
||||||
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
|
||||||
List<Signal> signalList = simulation.getRepository().getSignalList().stream().filter(signal -> {
|
|
||||||
if (signal.getDeviceStation() == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!signal.getDeviceStation().isCentralized()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (signal.getRouteList().isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return generateRandomElement(signalList, NUMBER);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SIGNAL_FIRST_STATION_LIST("获取第一个站信号机列表") {
|
SIGNAL_FIRST_STATION_LIST("获取第一个站信号机列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||||
@ -349,20 +312,6 @@ public enum MapDeviceRule {
|
|||||||
return generateRandomElement(sectionList, 1);
|
return generateRandomElement(sectionList, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SECTION_LOGIC_LIST("逻辑区段列表") {
|
|
||||||
@Override
|
|
||||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
|
||||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isLogicSection);
|
|
||||||
return generateRandomElement(sectionList, NUMBER);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SECTION_PHYSICAL_LIST("物理区段列表") {
|
|
||||||
@Override
|
|
||||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
|
||||||
List<Section> sectionList = querySectionListByFunction(simulation, Section::isAxleCounterSection);
|
|
||||||
return generateRandomElement(sectionList, NUMBER);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
|
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
@ -426,6 +375,226 @@ public enum MapDeviceRule {
|
|||||||
.filter(Station::isInterlock).collect(Collectors.toList());
|
.filter(Station::isInterlock).collect(Collectors.toList());
|
||||||
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
|
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**************************************** 车站列表 *********************************************/
|
||||||
|
STATION_NORMAL_LIST("车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalStationList(simulation, null), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STATION_CONTROL_LIST("控制模式车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
//找到所有有控制模式的车站
|
||||||
|
List<Station> stationList = queryNormalStationList(simulation, s -> s.isHasControlMode() && s.isInterlock());
|
||||||
|
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STATION_INTERLOCK_LIST("联锁车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Station> stationList = queryNormalStationList(simulation, Station::isInterlock);
|
||||||
|
return MapDeviceRule.generateRandomElement(stationList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STATION_TURN_BACK_LIST("折返车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Station> stationList = queryNormalStationList(simulation, Station::isTurnBack);
|
||||||
|
return generateRandomElement(stationList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STATION_CENTRALIZED_LIST("集中车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Station> stationList = queryNormalStationList(simulation, Station::isCentralized);
|
||||||
|
return generateRandomElement(stationList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STATION_INTERLOCK_CENTRALIZED_LIST("联锁集中车站列表") {
|
||||||
|
@Override
|
||||||
|
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Station> stationList = queryNormalStationList(simulation, s -> s.isInterlock() && s.isCentralized());
|
||||||
|
return generateRandomElement(stationList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**************************************** 站台列表 *********************************************/
|
||||||
|
STAND_NORMAL_LIST("站台列表") {
|
||||||
|
@Override
|
||||||
|
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return MapDeviceRule.generateRandomElement(queryNormalStandList(simulation, null), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STAND_CONTROL_LIST("控制模式车站站台列表") {
|
||||||
|
@Override
|
||||||
|
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Stand> standList = queryNormalStandList(simulation,
|
||||||
|
stand -> stand.getStation().isHasControlMode() && stand.getStation().isInterlock());
|
||||||
|
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STAND_CENTRALIZED_LIST("集中车站站台列表") {
|
||||||
|
@Override
|
||||||
|
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Stand> standList = queryNormalStandList(simulation, stand -> stand.getStation().isCentralized());
|
||||||
|
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
STAND_INTERLOCK_CENTRALIZED_LIST("联锁集中车站站台列表") {
|
||||||
|
@Override
|
||||||
|
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Stand> standList = queryNormalStandList(simulation,
|
||||||
|
stand -> stand.getStation().isCentralized() && stand.getStation().isInterlock());
|
||||||
|
return MapDeviceRule.generateRandomElement(standList, NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**************************************** 区段列表 *********************************************/
|
||||||
|
SECTION_NORMAL_LIST("区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
List<Section> sectionList = queryNormalSectionList(simulation, section -> {
|
||||||
|
// 普通区段排除道岔区段
|
||||||
|
if (section.isSwitchTrack() || section.isSwitchAxleCounterSection() || section.isLogicSection() || section.isCross()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
return generateRandomElement(sectionList, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_LOGIC_LIST("逻辑区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(querySectionListByFunction(simulation, Section::isLogicSection), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_PHYSICAL_LIST("物理区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(querySectionListByFunction(simulation, Section::isAxleCounterSection), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_SWITCH_TRACK_LIST("道岔物理区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(querySectionListByFunction(simulation, Section::isSwitchTrack), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_SWITCH_AXLE_TRACK_LIST("道岔计轴区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(querySectionListByFunction(simulation,s -> s.isAxleCounter() && !s.isSwitchAxleCounterSection()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_CROSS_LIST("岔心区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(querySectionListByFunction(simulation, Section::isCross), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_STAND_TRACK_LIST("站台轨区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return MapDeviceRule.generateRandomElement(querySectionListByFunction(simulation, Section::isStandTrack), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SECTION_STAND_TURN_BACK_TRACK_LIST("折返站台轨区段列表") {
|
||||||
|
@Override
|
||||||
|
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return MapDeviceRule.generateRandomElement(
|
||||||
|
querySectionListByFunction(simulation, s -> s.isStandTrack() && s.isTurnBackTrack()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**************************************** 信号机列表 *********************************************/
|
||||||
|
SIGNAL_NORMAL_LIST("信号机列表") {
|
||||||
|
@Override
|
||||||
|
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSignalList(simulation, signal -> {
|
||||||
|
// 获取存在全部定位的进路信号机
|
||||||
|
boolean isExistNormalRoute = signal.getRouteList().stream().allMatch(route -> {
|
||||||
|
if (route.getSwitchList().stream().allMatch(switchElement -> !switchElement.isNormal())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (!isExistNormalRoute) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Signal.SignalType.DEPARTURE.equals(signal.getType()) || Signal.SignalType.PROTECTION.equals(signal.getType());
|
||||||
|
}), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SIGNAL_CI_LIST("联锁自动信号机列表") {
|
||||||
|
@Override
|
||||||
|
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSignalList(simulation, signal -> {
|
||||||
|
if (signal.getRouteList().stream().noneMatch(Route::isArs)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (signal.getRouteList().stream().noneMatch(Route::isFlt)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return signal.getStation().isInterlock();
|
||||||
|
}), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SIGNAL_GUIDE_LIST("引导信号机列表") {
|
||||||
|
@Override
|
||||||
|
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSignalList(simulation, signal -> signal.getRouteList().stream().anyMatch(Route::isGuide)), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SIGNAL_ATP_LIST("集中站信号机列表") {
|
||||||
|
@Override
|
||||||
|
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSignalList(simulation, signal -> signal.getStation().isCentralized()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**************************************** 道岔列表 *********************************************/
|
||||||
|
SWITCH_NORMAL_LIST("道岔列表") {
|
||||||
|
@Override
|
||||||
|
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSwitchList(simulation, s -> !s.isSingleLock()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SWITCH_ATP_LIST("集中站道岔列表") {
|
||||||
|
@Override
|
||||||
|
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSwitchList(simulation, s -> s.getDeviceStation().isCentralized()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SWITCH_CONTROL_LIST("控制模式车站道岔列表") {
|
||||||
|
@Override
|
||||||
|
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalSwitchList(simulation, s -> s.getDeviceStation().isHasControlMode()), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**************************************** 进路列表 *********************************************/
|
||||||
|
ROUTE_NORMAL_LIST("进路列表") {
|
||||||
|
@Override
|
||||||
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return MapDeviceRule.generateRandomElement(queryNormalRouteList(simulation, route -> {
|
||||||
|
return !route.isTurnBack() && !route.isGuide() && !route.isPassRoute() && !route.isLongShuntingRoute();
|
||||||
|
}), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ROUTE_ATP_LIST("ATP进路列表") {
|
||||||
|
@Override
|
||||||
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalRouteList(simulation, route ->{
|
||||||
|
return route.getInterlockStation().isCentralized() && route.isAtp() && !route.isGuide();
|
||||||
|
}), NUMBER);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ROUTE_GUIDE_LIST("引导进路列表") {
|
||||||
|
@Override
|
||||||
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
|
return generateRandomElement(queryNormalRouteList(simulation, route -> {
|
||||||
|
return route.getStart().isCallOn() && route.isGuide();
|
||||||
|
}), NUMBER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -500,4 +669,150 @@ public enum MapDeviceRule {
|
|||||||
return true;
|
return true;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通车站列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 筛选条件
|
||||||
|
* @return 车站列表
|
||||||
|
*/
|
||||||
|
private static List<Station> queryNormalStationList(Simulation simulation, Function<Station, Boolean> filterFun) {
|
||||||
|
return simulation.getRepository().getStationList().stream()
|
||||||
|
.filter(station -> {
|
||||||
|
if (station.isDepot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filterFun != null) {
|
||||||
|
return filterFun.apply(station);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(Station::getSn)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通站台列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 筛选条件
|
||||||
|
* @return 站台列表
|
||||||
|
*/
|
||||||
|
private static List<Stand> queryNormalStandList(Simulation simulation, Function<Stand, Boolean> filterFun) {
|
||||||
|
return simulation.getRepository().getStandList().stream()
|
||||||
|
.filter(stand -> {
|
||||||
|
if (stand.getStation() == null || stand.getStation().isDepot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!stand.isVisible() || !stand.hasDoor() || stand.isSmall()) { // 特殊站台
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filterFun != null) {
|
||||||
|
return filterFun.apply(stand);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(s -> s.getStation().getSn())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通区段列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 筛选条件
|
||||||
|
* @return 区段列表
|
||||||
|
*/
|
||||||
|
private static List<Section> queryNormalSectionList(Simulation simulation, Function<Section, Boolean> filterFun) {
|
||||||
|
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 (filterFun != null) {
|
||||||
|
if (section.getParent() != null && section.getParent().isCross()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return filterFun.apply(section);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(s -> s.getDeviceStation().getSn())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通信号机列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 过滤条件
|
||||||
|
* @return 信号机列表
|
||||||
|
*/
|
||||||
|
private static List<Signal> queryNormalSignalList(Simulation simulation, Function<Signal, Boolean> filterFun) {
|
||||||
|
return simulation.getRepository().getSignalList().stream().filter(signal -> {
|
||||||
|
if (signal.isVirtual()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (signal.getStation() == null || signal.getStation().isDepot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(signal.getRouteList())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filterFun != null) {
|
||||||
|
return filterFun.apply(signal);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(s -> s.getStation().getSn())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通道岔列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 过滤条件
|
||||||
|
* @return 道岔列表
|
||||||
|
*/
|
||||||
|
private static List<Switch> queryNormalSwitchList(Simulation simulation, Function<Switch, Boolean> filterFun) {
|
||||||
|
return simulation.getRepository().getSwitchList().stream().filter(aSwitch -> {
|
||||||
|
if (aSwitch.getDeviceStation() != null && aSwitch.getDeviceStation().isDepot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filterFun != null) {
|
||||||
|
return filterFun.apply(aSwitch);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(s -> s.getDeviceStation().getSn())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选普通进路列表
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param filterFun 过滤条件
|
||||||
|
* @return 进路列表
|
||||||
|
*/
|
||||||
|
private static List<Route> queryNormalRouteList(Simulation simulation, Function<Route, Boolean> filterFun) {
|
||||||
|
return simulation.getRepository().getRouteList().stream().filter(route -> {
|
||||||
|
if (route.getInterlockStation().isDepot()) { // 停车场进路排除
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (route.getStart() == null || route.getDestination() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (route.getStart().isVirtual()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (route.getStart().getStation() == null || route.getStart().getStation().isDepot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 排除道岔默认单锁的进路
|
||||||
|
if (route.getSwitchList().stream().anyMatch(switchElement -> !switchElement.isNormal())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (filterFun != null) {
|
||||||
|
return filterFun.apply(route);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).sorted(Comparator.comparingInt(r -> r.getInterlockStation().getSn())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,22 +16,23 @@ public abstract class MapElementRule {
|
|||||||
* @return 车站信息
|
* @return 车站信息
|
||||||
*/
|
*/
|
||||||
public static Station queryStation(Object mapElement) {
|
public static Station queryStation(Object mapElement) {
|
||||||
if (mapElement instanceof Route) {
|
if (mapElement instanceof Station) {
|
||||||
return ((Route) mapElement).getInterlockStation();
|
|
||||||
} else if (mapElement instanceof Signal) {
|
|
||||||
return ((Signal) mapElement).getDeviceStation();
|
|
||||||
} else if (mapElement instanceof Station) {
|
|
||||||
return (Station) mapElement;
|
return (Station) mapElement;
|
||||||
} else if (mapElement instanceof Switch) {
|
} else if (mapElement instanceof Stand) {
|
||||||
return ((Switch) mapElement).getDeviceStation();
|
return ((Stand) mapElement).getStation();
|
||||||
} else if (mapElement instanceof Section) {
|
} else if (mapElement instanceof Section) {
|
||||||
Section section = (Section) mapElement;
|
Section section = (Section) mapElement;
|
||||||
if (section.getStation() != null) {
|
if (section.getStation() != null) {
|
||||||
return section.getStation();
|
return section.getStation();
|
||||||
|
} else if (section.getDeviceStation() != null) {
|
||||||
|
return section.getDeviceStation();
|
||||||
}
|
}
|
||||||
return section.getDeviceStation();
|
} else if (mapElement instanceof Signal) {
|
||||||
} else if (mapElement instanceof Stand) {
|
return ((Signal) mapElement).getStation();
|
||||||
return ((Stand) mapElement).getDeviceStation();
|
} else if (mapElement instanceof Switch) {
|
||||||
|
return ((Switch) mapElement).getDeviceStation();
|
||||||
|
} else if (mapElement instanceof Route) {
|
||||||
|
return ((Route) mapElement).getInterlockStation();
|
||||||
}
|
}
|
||||||
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||||
}
|
}
|
||||||
@ -43,33 +44,31 @@ public abstract class MapElementRule {
|
|||||||
*/
|
*/
|
||||||
public static Signal querySignal(Object mapElement) {
|
public static Signal querySignal(Object mapElement) {
|
||||||
if (mapElement instanceof Route) {
|
if (mapElement instanceof Route) {
|
||||||
Route route = (Route) mapElement;
|
return ((Route) mapElement).getStart();
|
||||||
return route.getStart();
|
|
||||||
} else if (mapElement instanceof Signal) {
|
} else if (mapElement instanceof Signal) {
|
||||||
return (Signal) mapElement;
|
return (Signal) mapElement;
|
||||||
} else if (mapElement instanceof Section) {
|
} else if (mapElement instanceof Section) {
|
||||||
Section section = (Section) mapElement;
|
return querySectionSignal((Section) mapElement);
|
||||||
boolean flag = true;
|
|
||||||
do {
|
|
||||||
if (section.getSignalToLeft() != null) {
|
|
||||||
return section.getSignalToLeft();
|
|
||||||
} else if (section.getSignalToRight() != null) {
|
|
||||||
return section.getSignalToRight();
|
|
||||||
}
|
|
||||||
if (section.getParent() != null) {
|
|
||||||
section = section.getParent();
|
|
||||||
} else {
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
} while (flag);
|
|
||||||
} else if (mapElement instanceof Stand) {
|
} else if (mapElement instanceof Stand) {
|
||||||
Section section = ((Stand) mapElement).getSection();
|
return querySectionSignal(((Stand) mapElement).getSection());
|
||||||
|
}
|
||||||
|
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Signal querySectionSignal(Section section) {
|
||||||
|
boolean flag = true;
|
||||||
|
do {
|
||||||
if (section.getSignalToLeft() != null) {
|
if (section.getSignalToLeft() != null) {
|
||||||
return section.getSignalToLeft();
|
return section.getSignalToLeft();
|
||||||
} else if (section.getSignalToRight() != null) {
|
} else if (section.getSignalToRight() != null) {
|
||||||
return section.getSignalToRight();
|
return section.getSignalToRight();
|
||||||
}
|
}
|
||||||
}
|
if (section.getParent() != null) {
|
||||||
|
section = section.getParent();
|
||||||
|
} else {
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
} while (flag);
|
||||||
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ public enum MapLocationRule {
|
|||||||
SWITCH_MAP_LOCATION("使用道岔定位") {
|
SWITCH_MAP_LOCATION("使用道岔定位") {
|
||||||
@Override
|
@Override
|
||||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||||
Switch aSwitch = (Switch) mapElement;
|
return MapLocationRule.SECTION_MAP_LOCATION.doHandle(simulation, ((Switch) mapElement).getA());
|
||||||
return MapLocationRule.SECTION_MAP_LOCATION.doHandle(simulation, aSwitch.getA());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user