添加道岔计轴预复位的状态及处理逻辑

This commit is contained in:
joylink_zhangsai 2021-01-22 20:38:36 +08:00
parent 4e85d158e4
commit 39af42d875
14 changed files with 92 additions and 2 deletions

View File

@ -235,6 +235,7 @@ public class SwitchOperateHandler {
/**道岔计轴预复位*/ /**道岔计轴预复位*/
@OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset) @OperateHandlerMapping(type = Operation.Type.Switch_Axle_Pre_Reset)
public void axlePreReset(Simulation simulation, String switchCode) { public void axlePreReset(Simulation simulation, String switchCode) {
ciApiService.switchAxlePreReset(simulation, switchCode);
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode()); ciApiService.axlePreReset(simulation, aSwitch.getA().getParent().getCode());
} }

View File

@ -266,6 +266,13 @@ public class CILogicLoop {
section.axleCounterClear(); section.axleCounterClear();
} }
section.judgeAsValid(); section.judgeAsValid();
//预复位
if (!virtualAxleCounter.isPreReset()) {
List<Switch> switchList = section.getRelSwitchList();
if (!CollectionUtils.isEmpty(switchList)) {
switchList.forEach(aSwitch -> aSwitch.setPreReset(false));
}
}
}); });
} }

View File

@ -324,4 +324,9 @@ public interface CiApiService {
* 计轴预复位 * 计轴预复位
*/ */
void axlePreReset(Simulation simulation, String sectionCode); void axlePreReset(Simulation simulation, String sectionCode);
/**
* 道岔计轴预复位
*/
void switchAxlePreReset(Simulation simulation, String switchCode);
} }

View File

@ -502,4 +502,10 @@ public class CiApiServiceImpl implements CiApiService {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), chooseSection + "计轴未占用,无需预复位"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(virtualAxleCounter.isOccupy(), chooseSection + "计轴未占用,无需预复位");
virtualAxleCounter.preReset(); virtualAxleCounter.preReset();
} }
@Override
public void switchAxlePreReset(Simulation simulation, String switchCode) {
Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
aSwitch.setPreReset(true);
}
} }

View File

@ -257,7 +257,13 @@ public class RouteService {
List<Section> sectionList = route.getSectionList(); List<Section> sectionList = route.getSectionList();
for (Section section : sectionList) { for (Section section : sectionList) {
if (section.isOccupied() && !section.isPreReset()) { if (section.isOccupied() && !section.isPreReset()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); if (section.isSwitchTrack()) {
if (!section.getRelSwitch().isPreReset()) {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section);
}
} else {
return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section);
}
} }
} }
// 延续保护检查 // 延续保护检查
@ -751,6 +757,7 @@ public class RouteService {
// 设置延时 // 设置延时
route.getStart().setDelayTime(route.getDelayReleaseTime() * 1000); route.getStart().setDelayTime(route.getDelayReleaseTime() * 1000);
route.setDelayUnlocking(true); route.setDelayUnlocking(true);
route.getLogicSections().forEach(section -> section.setDelayUnlock(true));
return true; return true;
} }
@ -770,6 +777,7 @@ public class RouteService {
// 进路解锁完成 // 进路解锁完成
route.setDelayUnlocking(false); route.setDelayUnlocking(false);
start.setDelayTime(0); start.setDelayTime(0);
route.getLogicSections().forEach(section -> section.setDelayUnlock(false));
} else { } else {
start.setDelayTime(delayTime); start.setDelayTime(delayTime);
} }

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.command; package club.joylink.rtss.simulation.cbtc.command;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
@ -165,9 +166,11 @@ public class CommandBO {
} }
} else { } else {
SectionPosition nextStopPosition = train.calculateNextStandStopPosition(); SectionPosition nextStopPosition = train.calculateNextStandStopPosition();
if (nextStopPosition == null) { if (nextStopPosition == null && train.getTarget() != null) {
nextStopPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(right)); nextStopPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(right));
} }
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(nextStopPosition,
train.debugStr() + "找不到下一个停车点");
stepList.add(buildDriveStep(nextStopPosition)); stepList.add(buildDriveStep(nextStopPosition));
} }
stepList.add(buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM)); stepList.add(buildDriverDriveModeChangeOperationStep(train.getGroupNumber(), DriveMode.CM));

View File

@ -493,6 +493,21 @@ public class Route extends MapNamedElement {
return false; return false;
} }
/**
* 获取进路的所有子区段
*/
public List<Section> getLogicSections() {
List<Section> sections = new ArrayList<>();
for (Section section : sectionList) {
if (CollectionUtils.isEmpty(section.getLogicList())) {
sections.add(section);
} else {
sections.addAll(section.getLogicList());
}
}
return sections;
}
/** /**
* 进路检查失败原因 * 进路检查失败原因
*/ */

View File

@ -219,6 +219,11 @@ public class Section extends MayOutOfOrderDevice {
*/ */
private boolean noStatus; private boolean noStatus;
/**
* 延时解锁
*/
private boolean delayUnlock;
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();
@ -234,6 +239,7 @@ public class Section extends MayOutOfOrderDevice {
this.speedUpLimit = -1; this.speedUpLimit = -1;
this.delayTime = 0; this.delayTime = 0;
this.noStatus = false; this.noStatus = false;
this.delayUnlock = false;
} }
/** /**
@ -919,6 +925,9 @@ public class Section extends MayOutOfOrderDevice {
* 是否预复位 * 是否预复位
*/ */
public boolean isPreReset() { public boolean isPreReset() {
if (switchTrack) {
return false;
}
if (virtualAxleCounter == null) { if (virtualAxleCounter == null) {
if (parent != null) if (parent != null)
return parent.isPreReset(); return parent.isPreReset();

View File

@ -99,6 +99,11 @@ public class Switch extends MayOutOfOrderDevice {
*/ */
private boolean noStatus; private boolean noStatus;
/**
* 预复位
*/
private boolean preReset;
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();

View File

@ -87,6 +87,9 @@ public class SectionStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private boolean preReset; private boolean preReset;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean delayUnlock;
private String fault; private String fault;
public SectionStatus(Section section) { public SectionStatus(Section section) {
@ -103,6 +106,7 @@ public class SectionStatus extends DeviceStatus {
this.speedUpLimit = section.getSpeedUpLimit(); this.speedUpLimit = section.getSpeedUpLimit();
this.noStatus = section.isNoStatus(); this.noStatus = section.isNoStatus();
this.preReset = section.isPreReset(); this.preReset = section.isPreReset();
this.delayUnlock = section.isDelayUnlock();
this.fault = section.getFault() == null ? null : section.getFault().toString(); this.fault = section.getFault() == null ? null : section.getFault().toString();
} }
@ -171,6 +175,11 @@ public class SectionStatus extends DeviceStatus {
status.setPreReset(this.preReset); status.setPreReset(this.preReset);
change = true; change = true;
} }
if (!Objects.equals(this.delayUnlock, section.isDelayUnlock())) {
this.delayUnlock = section.isDelayUnlock();
status.setDelayUnlock(this.delayUnlock);
change = true;
}
return change; return change;
} }
@ -188,6 +197,7 @@ public class SectionStatus extends DeviceStatus {
statusVO.setBlockade(blockade); statusVO.setBlockade(blockade);
statusVO.setNoStatus(noStatus); statusVO.setNoStatus(noStatus);
statusVO.setPreReset(preReset); statusVO.setPreReset(preReset);
statusVO.setDelayUnlock(delayUnlock);
return statusVO; return statusVO;
} }

View File

@ -63,6 +63,9 @@ public class SwitchStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus; private boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean preReset;
/** /**
* 故障 * 故障
*/ */
@ -79,6 +82,7 @@ public class SwitchStatus extends DeviceStatus {
this.reversePosition = aSwitch.isReversePosition(); this.reversePosition = aSwitch.isReversePosition();
this.delayTime = aSwitch.getDelayTime() / 1000; this.delayTime = aSwitch.getDelayTime() / 1000;
this.noStatus = aSwitch.isNoStatus(); this.noStatus = aSwitch.isNoStatus();
this.preReset = aSwitch.isPreReset();
} }
@Override @Override
@ -132,6 +136,11 @@ public class SwitchStatus extends DeviceStatus {
status.setNoStatus(this.noStatus); status.setNoStatus(this.noStatus);
change = true; change = true;
} }
if (!Objects.equals(this.preReset, aSwitch.isPreReset())) {
this.preReset = aSwitch.isPreReset();
status.setPreReset(this.preReset);
change = true;
}
if (!Objects.equals(this.fault, aSwitch.getFault())) { if (!Objects.equals(this.fault, aSwitch.getFault())) {
this.fault = (Switch.SwitchFault) aSwitch.getFault(); this.fault = (Switch.SwitchFault) aSwitch.getFault();
status.setFault(this.fault != null ? this.fault.name() : null); status.setFault(this.fault != null ? this.fault.name() : null);
@ -151,6 +160,7 @@ public class SwitchStatus extends DeviceStatus {
statusVO.setBlockade(blockade); statusVO.setBlockade(blockade);
statusVO.setSingleLock(singleLock); statusVO.setSingleLock(singleLock);
statusVO.setNoStatus(noStatus); statusVO.setNoStatus(noStatus);
statusVO.setPreReset(preReset);
statusVO.setFault(this.fault != null ? this.fault.name() : null); statusVO.setFault(this.fault != null ? this.fault.name() : null);
return statusVO; return statusVO;
} }

View File

@ -58,6 +58,9 @@ public class SectionStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean preReset; private Boolean preReset;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean delayUnlock;
private String fault; private String fault;
public SectionStatusVO(Section section) { public SectionStatusVO(Section section) {

View File

@ -52,6 +52,9 @@ public class SwitchStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class) @JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus; private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean preReset;
@JsonInclude @JsonInclude
private String fault; private String fault;

View File

@ -68,6 +68,8 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice {
public void preReset() { public void preReset() {
if (occupy) { if (occupy) {
this.preReset = true; this.preReset = true;
this.leftCount = 0;
this.rightCount = 0;
} }
} }
@ -83,6 +85,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice {
* @param trainRight 列车运行方向 * @param trainRight 列车运行方向
*/ */
public void trainIn(boolean trainRight) { public void trainIn(boolean trainRight) {
System.out.println("列车进入计轴区段");
if (trainRight) { if (trainRight) {
leftCount++; leftCount++;
} else { } else {
@ -97,6 +100,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice {
* @param trainRight 列车运行方向 * @param trainRight 列车运行方向
*/ */
public void trainOut(boolean trainRight) { public void trainOut(boolean trainRight) {
System.out.println("列车离开计轴区段");
if (trainRight) { if (trainRight) {
leftCount--; leftCount--;
} else { } else {
@ -112,6 +116,7 @@ public class VirtualRealitySectionAxleCounter extends VirtualRealityDevice {
public void judgePreResetSuccess() { public void judgePreResetSuccess() {
if (preReset) { if (preReset) {
if (leftCount == 0 && rightCount == 0) { if (leftCount == 0 && rightCount == 0) {
preReset = false;
if (Fault.FAULT.equals(this.fault)) { if (Fault.FAULT.equals(this.fault)) {
this.fault = null; this.fault = null;
} }