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

This commit is contained in:
Jade 2021-12-07 09:24:25 +08:00
commit a834811cab
5 changed files with 48 additions and 42 deletions

View File

@ -465,7 +465,7 @@ public class CiRouteService {
if (!logic.isOccupied() && /*!logic.isInvalid() &&*/ logic.isRouteLockOn(right)) {
logic.routeUnlocking(route);
logic.overlapUnlocking();
} else if(logic.isOccupied() || logic.isInvalid()) {
} else if(logic.isOccupied() /*|| logic.isInvalid()*/) {
break;
}
}

View File

@ -318,13 +318,22 @@ public class MapDeviceBuilder {
});
/* ZC和区段相互赋值 */
// ZC
if (graphData.getZcList().size() == 1) {
if (graphData.getZcList().size() == 1 && CollectionUtils.isEmpty(graphData.getZcList().get(0).getManagedSectionList())) {
//线路的ZC只有一个ZC没有设置关联区段自动关联全线计轴区段
MapZcVO mapZcVO = graphData.getZcList().get(0);
ZC zc = (ZC) elementMap.get(mapZcVO.getCode());
physicalSectionList.forEach(section -> {
zc.addSection(section);
section.addZc(zc);
});
elementMap.values().stream()
.filter(element -> element instanceof Section)
.map(element -> (Section) element)
.filter(Section::isAxleCounterSection)
.forEach(section -> {
zc.addSection(section);
section.addZc(zc);
});
// physicalSectionList.forEach(section -> {
// zc.addSection(section);
// section.addZc(zc);
// });
} else {
graphData.getZcList().forEach(mapZcVO -> {
if (mapZcVO.isNoService())
@ -338,15 +347,20 @@ public class MapDeviceBuilder {
Section section = (Section) elementMap.get(sectionCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(section,
String.format("ZC[%s]关联的区段[%s]不存在", zc.getCode(), sectionCode));
if (section.isPhysical()) {
section.addZc(zc);
zc.addSection(section);
} else if (section.isSwitchAxleCounterSection() || section.isCross()) {
section.getLogicList().forEach(logic -> {
logic.addZc(zc);
zc.addSection(logic);
});
Section axleCounterSection = section.findAxleCounterSection();
if (axleCounterSection != null) {
axleCounterSection.addZc(zc);
zc.addSection(axleCounterSection);
}
// if (section.isPhysical()) {
// section.addZc(zc);
// zc.addSection(section);
// } else if (section.isSwitchAxleCounterSection() || section.isCross()) {
// section.getLogicList().forEach(logic -> {
// logic.addZc(zc);
// zc.addSection(logic);
// });
// }
}
}
});

View File

@ -12,10 +12,7 @@ import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
/**
* 区段
@ -165,7 +162,7 @@ public class Section extends DelayUnlockDevice {
/**
* 所属zc
*/
private List<ZC> zcs = new ArrayList<>();
private Set<ZC> zcs = new HashSet<>();
// ------------------状态属性---------------------
@ -1148,10 +1145,15 @@ public class Section extends DelayUnlockDevice {
* 任意一个zc正常工作
*/
public boolean anyZcWorking() {
if (!CollectionUtils.isEmpty(zcs)) {
return zcs.stream().anyMatch(zc -> !zc.isFault());
Section axleCounterSection = this.findAxleCounterSection();
if (axleCounterSection != null && !CollectionUtils.isEmpty(axleCounterSection.getZcs())) {
return axleCounterSection.getZcs().stream().anyMatch(zc -> !zc.isFault());
}
return false;
// if (!CollectionUtils.isEmpty(zcs)) {
// return zcs.stream().anyMatch(zc -> !zc.isFault());
// }
// return false;
}
public void setInvalid(boolean invalid) {

View File

@ -1,11 +1,10 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
/**
* 区域控制器
@ -13,7 +12,7 @@ import java.util.Objects;
@Getter
public class ZC extends MayOutOfOrderDevice {
private List<Section> sections = new ArrayList<>();
private Set<Section> sections = new HashSet<>();
public ZC(String code, String name) {
super(code, name, DeviceType.ZC);

View File

@ -136,29 +136,20 @@ public class VRTrainRunningService {
return;
//进入计轴区段判断
Section headAxleCounterSectionNew = headPositionNew.getSection();
if (!headAxleCounterSectionNew.isAxleCounter()) {
headAxleCounterSectionNew = headAxleCounterSectionNew.getParent();
}
if (!headAxleCounterSectionNew.isAxleCounter()) { //当是物理区段-岔心-道岔计轴区段三层结构的时候需要多这次判断
headAxleCounterSectionNew = headAxleCounterSectionNew.getParent();
}
if (headAxleCounterSectionNew != null && headAxleCounterSectionNew.isAxleCounter()) { //新的区段是计轴区段
Section headSectionOld = headPosition.getSection();
if (!headAxleCounterSectionNew.equals(headSectionOld) && !headAxleCounterSectionNew.equals(headSectionOld.getParent())) { //新计轴区段和老区段不一样
Section headAxleCounterSectionNew = headPositionNew.getSection().findAxleCounterSection();
if (headAxleCounterSectionNew != null) {
Section headAxleCounterSection = headPosition.getSection().findAxleCounterSection();
if (!headAxleCounterSectionNew.equals(headAxleCounterSection)) { //车头所在计轴区段发生变化
headAxleCounterSectionNew.getVirtualAxleCounter().trainIn(trainRight);
}
}
//离开计轴区段判断
SectionPosition tailPositionOld = CalculateService.calculateNextPositionByStartAndLen(headPosition, !trainRight, train.getLen(), true);
Section tailAxleCounterSection = tailPositionOld.getSection();
if (!tailAxleCounterSection.isAxleCounter()) {
tailAxleCounterSection = tailAxleCounterSection.getParent();
}
if (tailAxleCounterSection != null && tailAxleCounterSection.isAxleCounter()) { //老的车尾区段是计轴区段
Section tailAxleCounterSection = tailPositionOld.getSection().findAxleCounterSection();
if (tailAxleCounterSection != null) {
SectionPosition tailPositionNew = CalculateService.calculateNextPositionByStartAndLen(headPositionNew, !trainRight, train.getLen(), true);
Section tailSectionNew = tailPositionNew.getSection();
if (!tailAxleCounterSection.equals(tailSectionNew) && !tailAxleCounterSection.equals(tailSectionNew.getParent())) { //老车尾计轴区段和新车尾区段不一样
Section tailAxleCounterSectionNew = tailPositionNew.getSection().findAxleCounterSection();
if (!tailAxleCounterSection.equals(tailAxleCounterSectionNew)) { //车尾所在计轴区段发生变化
tailAxleCounterSection.getVirtualAxleCounter().trainOut(trainRight);
}
}