Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
walker-sheng 2021-01-22 16:28:07 +08:00
commit dc6fc9345c
18 changed files with 239 additions and 228 deletions

View File

@ -75,6 +75,8 @@ public class Operation {
Switch_Force_Turn,
/** 道岔钩锁*/
Switch_Hook_Lock,
/** 道岔强解 */
Switch_Force_Unlock,
//--------------------------- 区段 ---------------------------
/** 封锁 */

View File

@ -112,10 +112,4 @@ public class SectionOperateHandler {
this.atsSectionService.confirmAxleValid(simulation, section);
}
/**强解*/
@OperateHandlerMapping(type = Operation.Type.Section_Force_Unlock)
public void forceUnlock(Simulation simulation, String sectionCode) {
this.ciApiService.sectionForceUnlock(simulation, sectionCode);
}
}

View File

@ -117,8 +117,8 @@ public class SignalOperateHandler {
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Auto_Setting)
public void setRouteHumanControl(Simulation simulation, List<String> routeCodeList) {
this.atsRouteService.setRouteHumanControl(simulation, routeCodeList);
public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
this.atsRouteService.setRouteHumanControl(simulation, signalCode, routeCodeList);
}
/**
@ -128,8 +128,8 @@ public class SignalOperateHandler {
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Open_Auto_Setting)
public void setRouteAtsControl(Simulation simulation, List<String> routeCodeList) {
this.atsRouteService.setRouteAtsControl(simulation, routeCodeList);
public void setRouteAtsControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
this.atsRouteService.setRouteAtsControl(simulation, signalCode, routeCodeList);
}

View File

@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
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;
import java.util.Objects;
@ -35,32 +36,48 @@ public class AtsRouteService {
* 进路收人工控
*
* @param simulation
* @param signalCode
* @param routeCodeList
*/
public void setRouteHumanControl(Simulation simulation, List<String> routeCodeList) {
public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
if (!CollectionUtils.isEmpty(routeCodeList)) {
routeCodeList.forEach(routeCode -> {
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
route.setAtsControl(false);
});
} else if (StringUtils.hasText(signalCode)) {
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
List<Route> routeList = signal.getRouteList();
if (!CollectionUtils.isEmpty(routeList)) {
routeList.forEach(route -> route.setAtsControl(false));
}
}
}
/**
* 进路交自动控
*/
public void setRouteAtsControl(Simulation simulation, List<String> routeCodeList) {
public void setRouteAtsControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
SimulationDataRepository repository = simulation.getRepository();
if (!CollectionUtils.isEmpty(routeCodeList)) {
List<Route> routes = routeCodeList.stream().map(routeCode -> repository.getByCode(routeCode, Route.class)).collect(Collectors.toList());
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
Signal start = routes.get(0).getStart();
String startSignalCode = start.getCode();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routes.stream().allMatch(route-> route.getStart().getCode().equals(startSignalCode)),
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routes.stream().allMatch(route -> route.getStart().getCode().equals(startSignalCode)),
"所选进路的始端信号机不同,处理逻辑未知");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(start.isHumanControl(), String.format("信号机[%s]需处于人工控状态", start.getCode()));
}
routes.forEach(route -> route.setAtsControl(true));
} else if (StringUtils.hasText(signalCode)) {
Signal signal = repository.getByCode(signalCode, Signal.class);
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isHumanControl(), String.format("信号机[%s]需处于人工控状态", signal.getCode()));
}
List<Route> routeList = signal.getRouteList();
if (!CollectionUtils.isEmpty(routeList)) {
routeList.forEach(route -> route.setAtsControl(true));
}
}
}

View File

@ -293,9 +293,9 @@ public class CILogicLoop {
Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault();
if (fault != null) {
aSwitch.setSplit(true);
switch (fault) {
case SPLIT:
case SQUEEZE:
break;
case NORMAL_SPLIT: {
VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
@ -309,7 +309,6 @@ public class CILogicLoop {
}
}
} else {
aSwitch.setSplit(false);
VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse());
}

View File

@ -164,8 +164,6 @@ public interface CiApiService {
*/
void sectionFaultUnlock(Simulation simulation, String sectionCode);
void sectionForceUnlock(Simulation simulation, String sectionCode);
/**
* 区故解
* @param simulation

View File

@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
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;
import java.util.Objects;
@ -191,7 +192,7 @@ public class CiApiServiceImpl implements CiApiService {
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
SimulationDataRepository repository = simulation.getRepository();
TrainInfo firstTrain = repository.querySignalApproachedFirstTrain(route.getStart());
if (route.isApproachLock() && Objects.nonNull(firstTrain) && !firstTrain.isStop()) { // 接近锁闭总人解
if (route.isApproachLock() /*&& Objects.nonNull(firstTrain) && !firstTrain.isStop()*/) { // 接近锁闭总人解
this.routeService.humanCancel(simulation, route);
} else {
this.routeService.cancelNoApproachLock(simulation, route);
@ -206,20 +207,6 @@ public class CiApiServiceImpl implements CiApiService {
@Override
public void sectionFaultUnlock(Simulation simulation, String sectionCode) {
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null;
for (Route route : lockedRouteList) {
if (route.isRouteSection(section)) {
lockedRoute = route;
break;
}
}
this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute);
}
@Override
public void sectionForceUnlock(Simulation simulation, String sectionCode) {
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null;
@ -229,7 +216,7 @@ public class CiApiServiceImpl implements CiApiService {
break;
}
}
this.sectionService.sectionForceUnlock(simulation, section, lockedRoute);
this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute);
}
@Override
@ -371,51 +358,57 @@ public class CiApiServiceImpl implements CiApiService {
public void setGuide(Simulation simulation, String signalCode, String routeCode) {
SimulationDataRepository repository = simulation.getRepository();
MapConfig config = repository.getConfig();
if (config.isGuideNeedRouteSettingFirst()) {
// 需要先办理进路
if (Objects.isNull(signalCode)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument,"操作参数缺少信号机");
} else {
Signal signal = repository.getByCode(signalCode, Signal.class);
if (!CollectionUtils.isEmpty(signal.getRouteList())) { // 是进路始端
Route lockedRoute = signal.getLockedRoute();
if (Objects.isNull(lockedRoute)) { // 没有已办理进路异常
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,"操作信号机没有已办理的进路");
} else { // 开引导信号
this.signalService.openGuideSignal(simulation, signal);
}
}
}
return;
}
if (routeCode != null) {
Route route = repository.getByCode(routeCode, Route.class);
if (route.isLock()) {
signalService.openGuideSignal(simulation, route.getStart());
} else {
routeService.settingGuideRoute(simulation, route);
}
} else if (signalCode != null) {
Signal signal = repository.getByCode(signalCode, Signal.class);
if (signal.getLockedRoute() != null) { //如果有已锁闭进路
signalService.openGuideSignal(simulation, signal);
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路
List<Route> collect = signal.getRouteList().stream()
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList();
}
Route route = collect.get(0);
routeService.settingGuideRoute(simulation, route);
} else { //如果信号机没有关联进路
signalService.openGuideSignal(simulation, signal);
}
Signal signal;
Route route = null;
if (StringUtils.hasText(signalCode)) {
signal = repository.getByCode(signalCode, Signal.class);
} else if (StringUtils.hasText(routeCode)) {
route = repository.getByCode(routeCode, Route.class);
signal = route.getStart();
} else {
throw new SimulationException(SimulationExceptionType.Illegal_Argument,"操作参数缺少信号机或进路");
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
}
//条件检查
if (config.isGuideNeedRouteSettingFirst()) {
List<Route> routeList = signal.getRouteList();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode()));
if (route != null) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode()));
} else {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode()));
}
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode()));
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isApproachOccupy(), String.format("对%s开放引导操作失败接近区段没有列车占用", signal.getName()));
//办理引导进路或开放引导信号
if (config.isGuideNeedRouteSettingFirst()) {
signalService.openGuideSignal(simulation, signal);
} else {
if (route != null) {
if (route.isLock()) {
signalService.openGuideSignal(simulation, route.getStart());
} else {
routeService.settingGuideRoute(simulation, route);
}
} else {
if (signal.getLockedRoute() != null) { //如果有已锁闭进路
signalService.openGuideSignal(simulation, signal);
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路
List<Route> collect = signal.getRouteList().stream()
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList();
}
route = collect.get(0);
routeService.settingGuideRoute(simulation, route);
} else { //如果信号机没有关联进路
signalService.openGuideSignal(simulation, signal);
}
}
}
}
@ -474,6 +467,7 @@ public class CiApiServiceImpl implements CiApiService {
@Override
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isSectionOccupied(), "道岔未被占用,不能使用强转");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode()));
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
if (normal == null) {

View File

@ -153,6 +153,12 @@ public class RouteService {
// 封锁状态
if (section.isBlockade()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section);
} else if (!CollectionUtils.isEmpty(section.getLogicList())) {
for (Section logicSection : section.getLogicList()) {
if (logicSection.isBlockade()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection);
}
}
}
// 进路内区段锁闭方向不是此进路方向
if ((section.isRouteLock() || section.isOverlapLock()) &&
@ -650,7 +656,10 @@ public class RouteService {
if (route.isLock()) { // 进路锁闭
// 取消进路逻辑
if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) {
route.getStart().getRouteList().forEach(aRoute -> aRoute.setAtsControl(false));
route.getStart().getRouteList().forEach(aRoute -> {
aRoute.setAtsControl(false);
aRoute.setCiControl(false);
});
} else {
route.setAtsControl(false);
}
@ -728,7 +737,10 @@ public class RouteService {
String.format("正在延时解锁"));
}
if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) {
route.getStart().getRouteList().forEach(aRoute -> aRoute.setAtsControl(false));
route.getStart().getRouteList().forEach(aRoute -> {
aRoute.setAtsControl(false);
aRoute.setCiControl(false);
});
} else {
route.setAtsControl(false);
}
@ -1066,6 +1078,9 @@ public class RouteService {
} else {
if (section.isSwitchTrack()) { // 如果是道岔区段解锁道岔
section.routeUnlocking(right);
if (section.getParent() != null && section.getParent().isCross()) {
section.getParent().routeUnlocking(right);
}
relSwitch.routeUnlock();
relSwitch.overlapUnLock();
// 侧防解锁

View File

@ -4,8 +4,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -26,14 +24,13 @@ public class SectionService {
/**
* 封锁(封锁后包含区段的进路不能排列)
* @param section
*/
public void blockade(Section section) {
// if(section.isRouteLock() || section.isOverlapLock()) {
// log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode()));
// return;
// }
if(!section.isBlockade()) {
if (!section.isBlockade()) {
section.setBlockade(true);
if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
section.getLogicList().forEach(logic -> logic.setBlockade(true));
@ -43,10 +40,9 @@ public class SectionService {
/**
* 解封
* @param section
*/
public void unblock(Section section) {
if(section.isBlockade()) {
if (section.isBlockade()) {
section.setBlockade(false);
if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) {
section.getLogicList().forEach(logic -> logic.setBlockade(false));
@ -56,33 +52,8 @@ public class SectionService {
/**
* 区故解
* @param simulation
* @param section
* @param route
*/
public void sectionFaultUnlock(Simulation simulation, Section section, Route route) {
if (Objects.nonNull(route) && route.isApproachLock()) { // 进路接近锁闭
// 关闭进路始端信号机
this.signalService.close(simulation, route.getStart());
// 区段延时解锁
section.setDelayTime(route.getDelayReleaseTime() * 1000);
} else { // 解锁
if (Objects.nonNull(route)) {
if (route.isOpen()) {
this.signalService.close(simulation, route.getStart());
} else if (route.isLock()){
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"延时解锁中");
}
}
section.faultUnlock();
if(section.isShowLogic()){
section.getLogicList().forEach(ls -> ls.faultUnlock());
}
}
}
public void sectionForceUnlock(Simulation simulation, Section section, Route route) {
if (route != null) {
if (route.isOpen()) {
signalService.close(simulation, route.getStart());
@ -90,19 +61,23 @@ public class SectionService {
if (route.isApproachLock()) {
// 区段延时解锁
section.setDelayTime(route.getDelayReleaseTime() * 1000);
if(section.isShowLogic()){
if (section.isShowLogic()) {
section.getLogicList().forEach(ls -> ls.setDelayTime(route.getDelayReleaseTime() * 1000));
}
return;
} else {
route.setLock(false);
}
}
section.forceUnlocking();
if(section.isShowLogic()){
section.getLogicList().forEach(ls -> ls.forceUnlocking());
section.faultUnlock();
if (section.isShowLogic()) {
section.getLogicList().forEach(Section::faultUnlock);
}
}
/**
* 区段延时区故解
*
* @param simulation
* @param section
*/
@ -114,7 +89,7 @@ public class SectionService {
List<Route> routeList = simulation.getRepository().queryAllLockedRoute();
Route lockedRoute = null;
for (Route route : routeList) {
if (route.isRouteSection(section)) {
if (route.containSection(section)) {
lockedRoute = route;
break;
}
@ -123,11 +98,7 @@ public class SectionService {
lockedRoute.setLock(false);
this.signalService.close(simulation, lockedRoute.getStart());
}
if(section.isFaultLock()){
section.faultUnlock();
}else{
section.forceUnlocking();
}
section.faultUnlock();
section.setDelayTime(0);
} else {
section.setDelayTime(remainTime);

View File

@ -8,8 +8,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@ -134,22 +132,19 @@ public class SwitchService {
* @param route
*/
public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) {
if (Objects.nonNull(route) && route.isApproachLock()) { // 进路接近锁闭
// 关闭进路始端信号机
this.signalService.close(simulation, route.getStart());
// 区段延时解锁
aSwitch.setDelayTime(route.getDelayReleaseTime()*1000);
} else { // 解锁
if (Objects.nonNull(route)) {
if (route.isOpen()) {
this.signalService.close(simulation, route.getStart());
} else if (route.isLock()){
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
"延时解锁中");
}
if (route != null) {
if (route.isOpen()) {
signalService.close(simulation, route.getStart());
}
if (route.isApproachLock()) {
// 区段延时解锁
aSwitch.setDelayTime(route.getDelayReleaseTime() * 1000);
return;
} else {
route.setLock(false);
}
aSwitch.sectionFaultUnlock();
}
aSwitch.sectionFaultUnlock();
}
public void delayUnlock(Simulation simulation, Switch aSwitch) {

View File

@ -31,6 +31,7 @@ public abstract class MayOutOfOrderDevice extends MapNamedElement {
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$1"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$2"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$3"),
@JsonSubTypes.Type(value = Switch.SwitchFault.class, name = "Switch$SwitchFault$4"),
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$1"),
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"),
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"),

View File

@ -66,11 +66,6 @@ public class Section extends MayOutOfOrderDevice {
*/
private boolean axleCounter;
/**
* 是否岔心
*/
private boolean crossing;
/**
* 虚拟真实计轴器
*/
@ -91,7 +86,7 @@ public class Section extends MayOutOfOrderDevice {
private Section parent;
/**
* 关联的逻辑区段列表
* 岔心关联的道岔计轴区段道岔计轴区段关联的道岔区段物理区段关联的逻辑区段
*/
private List<Section> logicList;
@ -535,10 +530,13 @@ public class Section extends MayOutOfOrderDevice {
/**
* 进路锁闭(连同逻辑区段)
*
* @param right
*/
public void routeLocking(boolean right) {
//岔心锁闭
if (this.parent != null && this.parent.isCross()) {
this.parent.setRouteLock(true);
this.parent.setLockRight(right);
}
this.routeLock = true;
this.lockRight = right;
if (!CollectionUtils.isEmpty(this.logicList)) {
@ -552,6 +550,12 @@ public class Section extends MayOutOfOrderDevice {
* @param right
*/
public void routeUnlocking(boolean right) {
//岔心锁闭
if (this.parent != null && this.parent.isCross()) {
this.parent.setRouteLock(false);
this.parent.setOverlapLock(false);
this.parent.setLockRight(false);
}
if (this.isRouteLockOn(right)) {
this.routeLock = false;
this.overlapLock = false;
@ -575,6 +579,11 @@ public class Section extends MayOutOfOrderDevice {
* 进路延续保护(连同逻辑区段)
*/
public void overlapLocking(boolean lockRight) {
//封锁岔心
if (this.parent != null && this.parent.isCross()) {
this.parent.setOverlapLock(true);
this.parent.setLockRight(lockRight);
}
this.overlapLock = true;
this.lockRight = lockRight;
if (!CollectionUtils.isEmpty(this.logicList)) {

View File

@ -371,7 +371,7 @@ public class Signal extends MayOutOfOrderDevice {
}
public void guideStart() {
this.guideRemain = 15 * 1000;
this.guideRemain = 30 * 1000;
}
public void guideInfinite() {
@ -391,7 +391,7 @@ public class Signal extends MayOutOfOrderDevice {
*/
public boolean isHumanControl() {
if (!CollectionUtils.isEmpty(routeList)) {
return routeList.stream().noneMatch(Route::isAtsControl);
return routeList.stream().allMatch(route -> !route.isAtsControl() && !route.isCiControl());
} else {
return false;
}

View File

@ -94,11 +94,6 @@ public class Switch extends MayOutOfOrderDevice {
*/
private int delayTime;
/**
* 是否失表故障
*/
private boolean split;
/**
* 无状态
*/
@ -116,14 +111,11 @@ public class Switch extends MayOutOfOrderDevice {
this.normalPosition = true;
this.reversePosition = false;
this.delayTime = 0;
this.split = false;
this.noStatus = false;
}
/**
* 是否被锁闭
*
* @return
*/
public boolean isLocked() {
return this.singleLock || this.routeLock || this.overlapLock || this.isFpLock();
@ -131,8 +123,6 @@ public class Switch extends MayOutOfOrderDevice {
/**
* 是否道岔区段被占用
*
* @return
*/
public boolean isSectionOccupied() {
return this.a.isOccupied();
@ -140,9 +130,6 @@ public class Switch extends MayOutOfOrderDevice {
/**
* 道岔是否在定/反位上
*
* @param normal
* @return
*/
public boolean isOnPosition(boolean normal) {
return (this.normalPosition && normal) || (!normal && this.reversePosition);
@ -150,9 +137,6 @@ public class Switch extends MayOutOfOrderDevice {
/**
* 是否道岔关联的区段
*
* @param section
* @return
*/
public boolean isRelatedSection(Section section) {
return Objects.equals(this.a.getCode(), section.getCode()) ||
@ -286,7 +270,7 @@ public class Switch extends MayOutOfOrderDevice {
if (section.isSwitchTrack() && Objects.equals(section.getRelSwitch().getC(), section)) { // 是另一个道岔的C区段则是联动道岔
return section.getRelSwitch();
}
if (Objects.nonNull(section.getParent()) && section.getParent().isCrossing()) {
if (Objects.nonNull(section.getParent()) && section.getParent().isCross()) {
if (Objects.equals(section.getRightSection(), this.getC())) {
return section.getLeftSection().getRelSwitch();
} else if (Objects.equals(section.getLeftSection(), this.getC())) {
@ -380,6 +364,19 @@ public class Switch extends MayOutOfOrderDevice {
return List.of(a, b, c);
}
/**
* 是否失表
*/
public boolean isLoss() {
return !this.isNormalPosition() && !this.isReversePosition();
}
public void forceUnlock() {
this.routeLock = false;
this.overlapLock = false;
this.fpLock = false;
}
public enum SwitchFault implements DeviceFault {
/**
* 道岔失表
@ -428,10 +425,33 @@ public class Switch extends MayOutOfOrderDevice {
aSwitch.setReversePosition(false);
return true;
}
},
/**
* 挤岔
*/
SQUEEZE {
@Override
public boolean apply(MayOutOfOrderDevice device) {
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
if (VirtualRealitySwitch.Fault.SQUEEZE.apply(vrSwitch)) {
aSwitch.setFault(this);
aSwitch.setNormalPosition(false);
aSwitch.setReversePosition(false);
return true;
}
return false;
}
@Override
public void fix(MayOutOfOrderDevice device) {
super.fix(device);
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
VirtualRealitySwitch.Fault.SQUEEZE.fix(vrSwitch);
vrSwitch.startSetting(true);
}
}
}
public boolean isLoss() {
return !this.isNormalPosition() && !this.isReversePosition();
}
}

View File

@ -55,11 +55,6 @@ public class SwitchStatus extends DeviceStatus {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private boolean reversePosition;
/** 是否故障失表了 */
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private boolean split;
/**
* 延时区段故障解锁剩余时间,单位s
*/
@ -68,6 +63,11 @@ public class SwitchStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
/**
* 故障
*/
private Switch.SwitchFault fault;
public SwitchStatus(Switch aSwitch) {
super(aSwitch.getCode(), aSwitch.getDeviceType());
this.singleLock = aSwitch.isSingleLock();
@ -77,7 +77,6 @@ public class SwitchStatus extends DeviceStatus {
this.overlapLock = aSwitch.isOverlapLock();
this.normalPosition = aSwitch.isNormalPosition();
this.reversePosition = aSwitch.isReversePosition();
this.split = aSwitch.isSplit();
this.delayTime = aSwitch.getDelayTime() / 1000;
this.noStatus = aSwitch.isNoStatus();
}
@ -122,11 +121,6 @@ public class SwitchStatus extends DeviceStatus {
status.setReversePosition(this.reversePosition);
change = true;
}
if (!Objects.equals(this.split, aSwitch.isSplit())) {
this.split = aSwitch.isSplit();
status.setSplit(this.split);
change = true;
}
int dt = aSwitch.getDelayTime() / 1000;
if (dt != this.delayTime) {
this.delayTime = dt;
@ -138,21 +132,26 @@ public class SwitchStatus extends DeviceStatus {
status.setNoStatus(this.noStatus);
change = true;
}
if (!Objects.equals(this.fault, aSwitch.getFault())) {
this.fault = (Switch.SwitchFault) aSwitch.getFault();
status.setFault(this.fault != null ? this.fault.name() : null);
change = true;
}
return change;
}
@Override
public DeviceStatusVO convert2VO(MapElement device) {
SwitchStatusVO statusVO = new SwitchStatusVO((Switch) device);
statusVO.setSplit(split);
statusVO.setReversePosition(reversePosition);
statusVO.setNormalPosition(normalPosition);
statusVO.setOverlapLock(overlapLock);
statusVO.setRouteLock(routeLock);
statusVO.setFpLock(this.fpLock);
statusVO.setFpLock(fpLock);
statusVO.setBlockade(blockade);
statusVO.setSingleLock(singleLock);
statusVO.setNoStatus(noStatus);
statusVO.setFault(this.fault != null ? this.fault.name() : null);
return statusVO;
}
}

View File

@ -79,13 +79,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
*/
private Integer delayTime;
/**
* 是否失表
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean split;
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
@ -136,10 +129,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
change = true;
storageSwitch.setDelayTime(s.getDelayTime());
}
if (s.isSplit()) {
change = true;
storageSwitch.setSplit(s.isSplit());
}
if (s.isNoStatus()) {
change = true;
storageSwitch.setNoStatus(s.isNoStatus());
@ -166,7 +155,6 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice {
s.setNormalPosition(normalPosition != null ? normalPosition : true);
s.setReversePosition(reversePosition != null ? reversePosition : false);
s.setDelayTime(delayTime != null ? delayTime : 0);
s.setSplit(split != null ? split : false);
s.setNoStatus(noStatus != null ? noStatus : false);
}
}

View File

@ -46,16 +46,15 @@ public class SwitchStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean reversePosition;
/** 是否故障失表了 */
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean split;
@JsonInclude
private Integer delayTime;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonInclude
private String fault;
public SwitchStatusVO(Switch aSwitch) {
super(aSwitch.getCode(), aSwitch.getDeviceType());
}

View File

@ -14,20 +14,30 @@ import java.util.Objects;
@Setter
public class VirtualRealitySwitch extends VirtualRealityDevice {
/** 虚拟道岔转换时间 */
/**
* 虚拟道岔转换时间
*/
private float settingTime;
/** 是否定位 */
/**
* 是否定位
*/
private boolean normal;
/** 是否反位 */
/**
* 是否反位
*/
private boolean reverse;
// -------------运行逻辑控制参数-------------
/** 是否正在转换 */
/**
* 是否正在转换
*/
private boolean setting;
/** 道岔转换剩余时间 */
/**
* 道岔转换剩余时间
*/
private Float remainTime;
/**
@ -35,10 +45,12 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
*/
private int timeoutRemain;
/** 道岔转换指令——是否转动到定位 */
/**
* 道岔转换指令是否转动到定位
*/
private boolean toNormal;
/*private SwitchFault fault;*/
private Fault fault;
public VirtualRealitySwitch(String code, String name) {
super(code, name, MapElement.DeviceType.SWITCH);
@ -76,7 +88,6 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
/**
* 开始转换
* @param toNormal
*/
public void startSetting(boolean toNormal) {
this.remainTime = this.settingTime;
@ -92,11 +103,10 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
this.setting = false;
this.remainTime = null;
this.timeoutRemain = 0;
/*if (this.isFault()) {
// 如果故障
if (Fault.SQUEEZE.equals(this.fault)) {
return;
}*/
if(this.toNormal) {
}
if (this.toNormal) {
this.normal = true;
this.reverse = false;
} else {
@ -107,6 +117,7 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
/**
* 是否失表
*
* @return
*/
public boolean isLoss() {
@ -117,10 +128,10 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
* 失去表示
*/
public void loss() {
if(this.normal) {
if (this.normal) {
this.normal = false;
}
if(this.reverse) {
if (this.reverse) {
this.reverse = false;
}
}
@ -136,30 +147,29 @@ public class VirtualRealitySwitch extends VirtualRealityDevice {
return this.isSetting() && Objects.equals(toNormal, this.toNormal);
}
/*public enum SwitchFault implements DeviceFault {
*//** 道岔挤岔 *//*
SPLIT{
public enum Fault {
/**
* 挤岔
*/
SQUEEZE {
@Override
public boolean applyOn(VirtualRealityDevice device) {
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) device;
if (Objects.equals(vrSwitch.getFault(), SPLIT)) {
public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault()))
return false;
}
vrSwitch.setFault(SPLIT);
if (!vrSwitch.isLoss()) {
vrSwitch.setToNormal(vrSwitch.isNormal());
}
vrSwitch.loss();
vrSwitch.setFault(this);
vrSwitch.setNormal(false);
vrSwitch.setReverse(false);
return true;
}
};
@Override
public void clearFrom(VirtualRealityDevice device) {
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) device;
public abstract boolean apply(VirtualRealitySwitch vrSwitch);
public void fix(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) {
vrSwitch.setFault(null);
vrSwitch.endSetting();
}
},
}*/
}
}
}