大铁进路办理代码结构修改;大铁道岔转动、单/解锁联动;cilRepository.config赋值

This commit is contained in:
joylink_zhangsai 2021-05-08 14:47:20 +08:00
parent f234e39935
commit c7d5c38b73
8 changed files with 164 additions and 60 deletions

View File

@ -219,6 +219,8 @@ public class Operation {
Stand_Open,
/** 站台关闭 */
Stand_Close,
/** 站台紧急关闭 */
Stand_Emergency_Close,
//--------------------------- 控制模式 ---------------------------
/** 请求站控 */

View File

@ -4,7 +4,9 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService;
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.status.StandStatus;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -25,6 +27,9 @@ public class StandOperateHandler {
@Autowired
private StandOperateHandler standOperateHandler;
@Autowired
private CiApiService ciApiService;
/**
* 设置跳停
*/
@ -222,4 +227,10 @@ public class StandOperateHandler {
public void close(Simulation simulation, List<String> standCodes) {
atsStandService.close(simulation, standCodes);
}
@OperateHandlerMapping(type = Operation.Type.Stand_Emergency_Close)
public void emergencyClose(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
ciApiService.standEC(simulation, stand);
}
}

View File

@ -9,6 +9,7 @@ import club.joylink.rtss.simulation.rt.SRD.bo.SrPSD;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSwitch;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.RealLineConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@ -458,8 +458,16 @@ public class CilRouteLogicService {
}
}
} else {
try2LockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute); //尝试转动/锁闭设备
setLockingStateByInterlockCheck(cilRepository, cilRoute, commonRoute); //根据联锁检查情况设置锁闭状态
if (config.isLockFirst()) {
this.lockFirst(cilRepository, commonRoute, cilRoute);
}
try2TurnAndLockRouteMainDevices(rtSimulation, cilRepository, cilRoute, commonRoute, config); //尝试转动并锁闭进路主体设备
cilRoute.setLock(isRoutePassInterlockingCheck(cilRepository, commonRoute)); //根据联锁检查设置进路主体锁闭状态
try2TurnAndLockFlankDevices(rtSimulation, cilRepository, cilRoute, commonRoute); //尝试转动并锁闭侧防设备
cilRoute.setFl(isFlsPassInterlockingCheck(cilRepository, commonRoute)); //根据联锁检查设置侧防锁闭状态
try2TurnAndLockOverlapDevices(rtSimulation, cilRepository, cilRoute, commonRoute, config); //尝试转动并锁闭延续保护设备
cilRoute.setOl(isOverlapPassInterlockingCheck(cilRepository, commonRoute, cilRoute.getOverlap())); //根据联锁检查设置延续保护锁闭状态
CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId());
updateSignalLevel(cilRepository, cilRoute, commonRoute, cilSignal); //更新信号机信号级别
if (cilRoute.isCanAutoOpen()) //尝试开放信号
@ -505,23 +513,42 @@ public class CilRouteLogicService {
* 尝试锁闭进路内的设备
*/
private void try2LockRouteDevices(RtSimulation rtSimulation, CilRepository cilRepository, CilRoute cilRoute, CommonRoute commonRoute) {
// if (config.isLockFirst()) {
// this.lockFirst(cilRepository, commonRoute, cilRoute);
// }
TrackWay pathElement = commonRoute.getPathElement();
CommonSignal commonSignal = commonRoute.getStart();
CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId());
// 进路内的设备转动锁闭
List<SwitchPosition> spList = pathElement.getSpList();
if (!cilRoute.isLock()) {
cilSwitchLogicService.tryTurn(rtSimulation, spList); // 转动道岔
boolean allLock = try2RouteLockSwitches(cilRepository, cilRoute.getId(), spList); // 锁闭道岔
if (allLock) {
// if (!config.isLockFirst()) {
routeLockSections(cilRepository, commonRoute);
// }
CilConfig config = cilRepository.getConfig();
if (config.isLockFirst()) {
this.lockFirst(cilRepository, commonRoute, cilRoute);
}
try2TurnAndLockRouteMainDevices(rtSimulation, cilRepository, cilRoute, commonRoute, config);
try2TurnAndLockFlankDevices(rtSimulation, cilRepository, cilRoute, commonRoute);
try2TurnAndLockOverlapDevices(rtSimulation, cilRepository, cilRoute, commonRoute, config);
}
/**
* 尝试转动锁闭延续保护设备
*/
private void try2TurnAndLockOverlapDevices(RtSimulation rtSimulation, CilRepository cilRepository, CilRoute cilRoute, CommonRoute commonRoute, CilConfig config) {
// 延续保护设备转动锁闭
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
CommonOverlap commonOverlap = commonRoute.getOverlap();
if (!cilRoute.isOl()) {
TrackWay selectedPath = overlap.getSelectedPath();
if (selectedPath != null) {
cilSwitchLogicService.tryTurn(rtSimulation, selectedPath.getSpList());
boolean allSwitchesLocked = try2OverlapLockSwitches(cilRepository, overlap, selectedPath.getSpList()); // 锁闭道岔
if (allSwitchesLocked) {
if (!config.isLockFirst()) {
overlapLockSections(cilRepository, commonOverlap.getStart().isRight(), overlap.getSelectedPath().getSectionList());
}
}
}
}
}
}
/**
* 尝试转动锁闭侧防设备
*/
private void try2TurnAndLockFlankDevices(RtSimulation rtSimulation, CilRepository cilRepository, CilRoute cilRoute, CommonRoute commonRoute) {
// 侧防设备转动锁闭
List<CommonFls> flsList = commonRoute.getFlsList();
if (!CollectionUtils.isEmpty(flsList)) {
@ -541,20 +568,21 @@ public class CilRouteLogicService {
}
}
}
// 延续保护设备转动锁闭
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
CommonOverlap commonOverlap = commonRoute.getOverlap();
if (!cilRoute.isOl()) {
TrackWay selectedPath = overlap.getSelectedPath();
if (selectedPath != null) {
cilSwitchLogicService.tryTurn(rtSimulation, selectedPath.getSpList());
boolean allSwitchesLocked = try2OverlapLockSwitches(cilRepository, overlap, spList); // 锁闭道岔
if (allSwitchesLocked) {
// if (!config.isLockFirst()) {
overlapLockSections(cilRepository, commonOverlap.getStart().isRight(), overlap.getSelectedPath().getSectionList());
// }
}
/**
* 尝试转动锁闭进路主体设置
*/
private void try2TurnAndLockRouteMainDevices(RtSimulation rtSimulation, CilRepository cilRepository, CilRoute cilRoute, CommonRoute commonRoute, CilConfig config) {
// 进路内的设备转动锁闭
TrackWay pathElement = commonRoute.getPathElement();
List<SwitchPosition> spList = pathElement.getSpList();
if (!cilRoute.isLock()) {
cilSwitchLogicService.tryTurn(rtSimulation, spList); // 转动道岔
boolean allLock = try2RouteLockSwitches(cilRepository, cilRoute.getId(), spList); // 锁闭道岔
if (allLock) {
if (!config.isLockFirst()) {
routeLockSections(cilRepository, commonRoute);
}
}
}
@ -566,8 +594,8 @@ public class CilRouteLogicService {
private void updateSignalLevel(CilRepository cilRepository, CilRoute cilRoute, CommonRoute commonRoute, CilSignal cilSignal) {
//判断信号级别
if (cilRoute.isLock()) {
if (cilRoute.isFl() || CollectionUtils.isEmpty(commonRoute.getFlsList())) {
if (cilRoute.isOl() || cilRoute.getOverlap() == null) {
if (cilRoute.isFl()) {
if (cilRoute.isOl()) {
cilSignal.updateLevel(CilSignal.LEVEL_4);
} else {
cilSignal.updateLevel(CilSignal.LEVEL_3);
@ -631,6 +659,8 @@ public class CilRouteLogicService {
private boolean isFlsPassInterlockingCheck(CilRepository cilRepository, CommonRoute commonRoute) {
TrackWay pathElement = commonRoute.getPathElement();
List<CommonFls> flsList = pathElement.getFlsList();
if (CollectionUtils.isEmpty(flsList))
return true;
for (CommonFls commonFls : flsList) {
List<CommonFls.FlsElement> flsElements = commonFls.getFirstLevelList();
if (pathElement.isContainSwitchPosition(commonFls.getTarget().getCommonSwitch().getId(), commonFls.getTarget().isNormal())) {
@ -663,7 +693,11 @@ public class CilRouteLogicService {
}
public boolean isOverlapPassInterlockingCheck(CilRepository cilRepository, CommonRoute commonRoute, CilOverlap overlap) {
if (overlap == null)
return true;
TrackWay path = overlap.getSelectedPath();
if (path == null)
return true;
List<CommonSection> sectionList = path.getSectionList();
if (!CollectionUtils.isEmpty(sectionList)) {
for (CommonSection commonSection : sectionList) {

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.rt.repo.SwitchPosition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
@ -28,10 +29,19 @@ public class CilSwitchLogicService {
}
public void turn(RtSimulation rtSimulation, String id) {
CilRepository repository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSwitch aSwitch = repository.getSwitchById(id);
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CilSwitch aSwitch = cilRepository.getSwitchById(id);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(aSwitch.isLocked(), "道岔锁闭,无法转动");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(isOccupy(rtSimulation, id), "道岔占用,无法转动");
if (cilRepository.getConfig().isSwitchNRTurnChain()) {
CommonSwitch commonSwitch = commonRepository.getSwitchById(aSwitch.getId());
CommonSwitch linkedSwitch = commonSwitch.queryLinkedSwitch();
CilSwitch linkedCilSwitch = cilRepository.getSwitchById(linkedSwitch.getId());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(linkedCilSwitch.isLocked(), "道岔锁闭,无法转动");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(isOccupy(rtSimulation, linkedCilSwitch.getId()), "道岔占用,无法转动");
srdApiService.turnSwitch(rtSimulation, linkedCilSwitch.getId());
}
srdApiService.turnSwitch(rtSimulation, id);
}
@ -41,30 +51,33 @@ public class CilSwitchLogicService {
public void turn(RtSimulation rtSimulation, String switchId, int position) {
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CilSwitch aSwitch = cilRepository.getSwitchById(switchId);
if (aSwitch.getPosition() == position) {
return;
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(aSwitch.isLocked(), "道岔锁闭,无法转动");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(isOccupy(rtSimulation, switchId), "道岔占用,无法转动");
srdApiService.turnSwitch(rtSimulation, switchId, position);
// if (repository.getConfig().isSwitchNRTurnChain()) {
CommonSwitch commonSwitch = commonRepository.getSwitchById(switchId);
CommonSwitch linkedSwitch = commonSwitch.queryLinkedSwitch();
if (linkedSwitch != null) {
srdApiService.turnSwitch(rtSimulation, linkedSwitch.getId(), position);
}
// }
String failReason = tryTurn(rtSimulation, cilRepository, commonSwitch, position);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotHasText(failReason, failReason);
}
public void tryTurn(RtSimulation rtSimulation, CilRepository cilRepository, CommonSwitch commonSwitch, int position) {
CilSwitch cilSwitch = cilRepository.getSwitchById(commonSwitch.getId());
if (cilSwitch.getPosition() == position) {
return;
/**
* 尝试转动道岔
*
* @return 失败原因
*/
public String tryTurn(RtSimulation rtSimulation, CilRepository cilRepository, CommonSwitch commonSwitch, int position) {
String failReason = check4Turn(rtSimulation, cilRepository, commonSwitch, position);
if (StringUtils.hasText(failReason))
return failReason;
if (cilRepository.getConfig().isSwitchNRTurnChain()) {
CommonSwitch linkedSwitch = commonSwitch.queryLinkedSwitch();
if (linkedSwitch != null) {
String failReason2 = check4Turn(rtSimulation, cilRepository, linkedSwitch, position);
if (StringUtils.hasText(failReason2)) {
return failReason2;
} else {
srdApiService.turnSwitch(rtSimulation, linkedSwitch.getId(), position);
}
}
}
if (!cilSwitch.isLocked() && !isOccupy(rtSimulation, commonSwitch.getId())) {
srdApiService.turnSwitch(rtSimulation, commonSwitch.getId(), position);
}
return null;
}
public void tryTurn(RtSimulation rtSimulation, List<SwitchPosition> switchPositions) {
@ -90,8 +103,18 @@ public class CilSwitchLogicService {
public void singleLockSwitch(RtSimulation simulation, String id) {
CilRepository cilRepository = simulation.getRepository(CilRepository.NAME, CilRepository.class);
CommonRepository commonRepository = simulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CilSwitch cilSwitch = cilRepository.getSwitchById(id);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilSwitch.isLost(), "道岔失表,无法单锁");
if (cilRepository.getConfig().isSwitchSingleLockChain()) {
CommonSwitch commonSwitch = commonRepository.getSwitchById(id);
CommonSwitch linkedCommonSwitch = commonSwitch.queryLinkedSwitch();
if (linkedCommonSwitch != null) {
CilSwitch linkedCilSwitch = cilRepository.getSwitchById(linkedCommonSwitch.getId());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(linkedCilSwitch.isLost(), "联动道岔失表,无法单锁");
linkedCilSwitch.setSl(true);
}
}
cilSwitch.setSl(true);
}
@ -100,4 +123,15 @@ public class CilSwitchLogicService {
CilSwitch cilSwitch = cilRepository.getSwitchById(id);
cilSwitch.setSl(false);
}
private String check4Turn(RtSimulation simulation, CilRepository cilRepository, CommonSwitch commonSwitch, int position) {
CilSwitch cilSwitch = cilRepository.getSwitchById(commonSwitch.getId());
if (cilSwitch.getPosition() == position)
return "道岔已在指定位置";
if (cilSwitch.isLocked())
return String.format("道岔[%s]锁闭", commonSwitch.getId());
if (isOccupy(simulation, commonSwitch.getId()))
return String.format("道岔[%s]占用", commonSwitch.getId());
return null;
}
}

View File

@ -1,13 +1,27 @@
package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.vo.client.map.RealLineConfigVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
public class CilConfig {
boolean lockFirst;
boolean lockFirst = false;
/**
* 道岔正/反操是否联动
*/
private boolean switchNRTurnChain;
private boolean switchNRTurnChain = false;
/**
* 道岔单解/锁是否联动
*/
private boolean switchSingleLockChain = false;
public CilConfig(RealLineConfigVO configVO) {
this.lockFirst = configVO.getLockFirst();
this.switchNRTurnChain = configVO.getSwitchNRTurnChain();
this.switchSingleLockChain = configVO.getSwitchSingleLockChain();
}
}

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.vo.client.map.MapSwitchVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.RealLineConfigVO;
import club.joylink.rtss.vo.client.map.newmap.*;
import org.springframework.util.CollectionUtils;
@ -24,9 +25,18 @@ public class CilRepositoryBuilder {
// buildOverlaps(logicDataNew.getOverlapList(), cilRepository.overlapMap, cilRepository.signalMap, cilRepository.sectionMap, cilRepository.switchMap, cilRepository.flsMap);
buildAutoSignals(logicDataNew.getAutoSignalList(), cilRepository.autoSignalMap);
buildRoutes(logicDataNew.getRouteList(), cilRepository.routeMap, cilRepository);
buildConfig(mapVO.getConfigVO(), cilRepository);
return cilRepository;
}
private static void buildConfig(RealLineConfigVO configVO, CilRepository cilRepository) {
if (configVO != null) {
cilRepository.config = new CilConfig(configVO);
} else {
cilRepository.config = new CilConfig();
}
}
private static void buildSections(List<MapSectionNewVO> sectionList, Map<String, CilSection> sectionMap) {
for (MapSectionNewVO sectionNewVO : sectionList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(sectionMap.containsKey(sectionNewVO.getCode()),

View File

@ -15,9 +15,7 @@ import org.springframework.util.CollectionUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@ApiModel