修改停稳倒计时实现逻辑

This commit is contained in:
joylink_zhangsai 2022-08-23 10:04:17 +08:00
parent d510fb990b
commit 0433273f35
7 changed files with 64 additions and 18 deletions

View File

@ -86,19 +86,30 @@ public class CiLogic {
* 区段停稳倒计时
*/
public void sectionStopCountDown(Simulation simulation) {
for (Stand stand : simulation.getRepository().getStandList()) {
Section track = stand.getSection();
if (track.getStopCountDown() == null) {
//股道占用且股道两边没有占用
if (track.isOccupied()) {
if (!track.getNextRunningSectionOf(false).isOccupied() && !track.getNextRunningSectionOf(true).isOccupied()) {
track.startStopCountDown();
for (Section section : simulation.getRepository().getHasStopCountDownSections()) {
int stopCountDown = section.getStopCountDown();
if (stopCountDown == 0) {
//股道占用且股道有占用
if (section.isOccupied()) {
if (section.getNextRunningSectionOf(false).isOccupied() || section.getNextRunningSectionOf(true).isOccupied()) {
section.readyStartStopCountDown();
}
}
} else {
track.setStopCountDown(track.getStopCountDown() - SimulationConstants.CI_LOOP_RATE);
if (track.getStopCountDown() <= 0) {
track.setStopCountDown(null);
if (stopCountDown == -1) {
// 股道占用股道两边没有占用股道没有进路锁闭或该进路正在正常解锁
if (section.isOccupied()) {
if ((!section.getNextRunningSectionOf(false).isOccupied()
&& !section.getNextRunningSectionOf(true).isOccupied())
&& (section.getRoute() == null || section.getRoute().isNormalUnlock())) {
section.startStopCountDown();
}
}
} else {
section.setStopCountDown(stopCountDown - SimulationConstants.CI_LOOP_RATE);
if (stopCountDown <= 0) {
section.setStopCountDown(0);
}
}
}
}

View File

@ -1116,6 +1116,7 @@ public class MapDeviceBuilder {
section.setVirtualAxleCounter(axleCounter);
deviceMap.put(axleCounter.getCode(), axleCounter);
}
section.setHasStopCountDown(sectionVO.isHasStopCD());
}
}

View File

@ -1248,4 +1248,10 @@ public class SimulationDataRepository {
}
return stream.collect(Collectors.toList());
}
public List<Section> getHasStopCountDownSections() {
return getListByType(MapElement.DeviceType.SECTION, Section.class).stream()
.filter(Section::isHasStopCountDown)
.collect(Collectors.toList());
}
}

View File

@ -164,6 +164,11 @@ public class Section extends DelayUnlockDevice {
*/
private Set<ZC> zcs = new HashSet<>();
/**
* 有停稳计时
*/
private boolean hasStopCountDown;
// ------------------状态属性---------------------
/**
@ -263,8 +268,11 @@ public class Section extends DelayUnlockDevice {
/**
* 停稳倒计时
* 0 表示初始状态
* -1 表示准备开始计时
* 非负数表示当前计时
*/
private Integer stopCountDown;
private int stopCountDown;
@Override
public void reset() {
@ -287,7 +295,7 @@ public class Section extends DelayUnlockDevice {
this.closed = false;
this.badShunt = false;
this.shuntingTypeList = new ArrayList<>();
this.stopCountDown = null;
this.stopCountDown = 0;
}
/**
@ -297,14 +305,19 @@ public class Section extends DelayUnlockDevice {
stopCountDown = 40 * 1000;
}
public Integer getStopCountDownInSeconds() {
return stopCountDown == null ? null : stopCountDown / 1000;
/**
* 准备开始停稳倒计时
*/
public void readyStartStopCountDown() {
stopCountDown = -1;
}
public int getStopCountDownInSeconds() {
return stopCountDown / 1000;
}
/**
* 区段是否被列车占用
*
* @return
*/
public boolean isOccupied() {
return this.nctOccupied || this.ctOccupied || this.isLogicOccupied();

View File

@ -253,12 +253,12 @@ public class SectionStatus extends DeviceStatus {
this.badShunt = section.isBadShunt();
status.setBadShunt(this.badShunt);
}
Integer stopCountDownInSeconds = section.getStopCountDownInSeconds();
int stopCountDownInSeconds = section.getStopCountDownInSeconds();
if (!Objects.equals(this.stopCountDown, stopCountDownInSeconds)) {
change = true;
this.stopCountDown = stopCountDownInSeconds;
}
status.setStopCountDown(stopCountDown == null ? null : stopCountDown);
status.setStopCountDown(stopCountDown == 0 ? null : stopCountDown);
return change;
}

View File

@ -106,6 +106,11 @@ public class StorageSection extends StorageDelayUnlockDevice {
*/
private Boolean badShunt;
/**
* 停稳倒计时
*/
private Integer stopCountDown;
public StorageSection(Section section) {
super(section);
}
@ -176,6 +181,10 @@ public class StorageSection extends StorageDelayUnlockDevice {
this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
}
if (section.getStopCountDown() != 0) {
change = true;
this.stopCountDown = section.getStopCountDown();
}
return change;
}
@ -197,5 +206,6 @@ public class StorageSection extends StorageDelayUnlockDevice {
section.setSpeedLimitBeforeFault(speedLimitBeforeFault);
section.setShuntingTypeList(shuntingTypeList != null ? shuntingTypeList : new ArrayList<>());
section.setBadShunt(badShunt != null ? badShunt : false);
section.setStopCountDown(stopCountDown == null ? 0 : stopCountDown);
}
}

View File

@ -48,6 +48,11 @@ public class MapSectionNewVO {
*/
private Point namePosition;
/**
* 有停稳计时
*/
private boolean hasStopCD;
/**
* 停车倒计时显示坐标
*/