修改:移动授权计算bug
This commit is contained in:
parent
645a06cec4
commit
86dce84b28
@ -140,6 +140,25 @@ public class ZCLogicLoop {
|
|||||||
endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION));
|
endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION));
|
||||||
return endList;
|
return endList;
|
||||||
}
|
}
|
||||||
|
//通信车占用区段
|
||||||
|
List<Section> logicList = section.getLogicList();
|
||||||
|
if (!CollectionUtils.isEmpty(logicList)) {
|
||||||
|
Section logicSection = headPosition.getLogicSection();
|
||||||
|
int index = logicList.indexOf(logicSection);
|
||||||
|
if (right) {
|
||||||
|
for (int i = index + 1; i < logicList.size(); i++) {
|
||||||
|
MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right);
|
||||||
|
if (end != null)
|
||||||
|
endList.add(end);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = index - 1; i >= 0; i--) {
|
||||||
|
MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right);
|
||||||
|
if (end != null)
|
||||||
|
endList.add(end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (count < 50) {
|
while (count < 50) {
|
||||||
++count;
|
++count;
|
||||||
@ -183,8 +202,8 @@ public class ZCLogicLoop {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//前方列车
|
//通信车占用区段
|
||||||
MovementAuthority.End trainEnd = checkSectionOccupied(temp);
|
MovementAuthority.End trainEnd = checkSectionOccupied(temp, right);
|
||||||
if (trainEnd != null)
|
if (trainEnd != null)
|
||||||
endList.add(trainEnd);
|
endList.add(trainEnd);
|
||||||
//非通信车占用区段
|
//非通信车占用区段
|
||||||
@ -196,10 +215,9 @@ public class ZCLogicLoop {
|
|||||||
if (cs != null)
|
if (cs != null)
|
||||||
endList.add(cs);
|
endList.add(cs);
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(endList) && endList.size() == 1 && !endList.get(0).getType().equals(MovementAuthority.EndType.CLOSED_SIGNAL)) {
|
if (endList.stream().anyMatch(end2 -> !MovementAuthority.EndType.CLOSED_SIGNAL.equals(end2.getType()))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
section = temp;
|
section = temp;
|
||||||
}
|
}
|
||||||
// // 前方列车
|
// // 前方列车
|
||||||
@ -218,9 +236,25 @@ public class ZCLogicLoop {
|
|||||||
return endList;
|
return endList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MovementAuthority.End checkSectionOccupied(Section section) {
|
private MovementAuthority.End checkSectionOccupied(Section section, boolean right) {
|
||||||
for (Section logic : section.getLogicList()) {
|
List<Section> logicList = section.getLogicList();
|
||||||
|
if (!CollectionUtils.isEmpty(logicList)) {
|
||||||
|
if (right) {
|
||||||
|
for (Section logic : logicList) {
|
||||||
if (logic.isCtOccupied()) {
|
if (logic.isCtOccupied()) {
|
||||||
|
return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = logicList.size() - 1; i >= 0; i--) {
|
||||||
|
Section logic = logicList.get(i);
|
||||||
|
if (logic.isCtOccupied()) {
|
||||||
|
return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (section.isCtOccupied()) {
|
||||||
return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null);
|
return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,9 @@ public class MovementAuthority {
|
|||||||
}
|
}
|
||||||
case FRONT_TRAIN: {
|
case FRONT_TRAIN: {
|
||||||
Section section = (Section) this.device;
|
Section section = (Section) this.device;
|
||||||
return new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset());
|
SectionPosition sectionPosition = new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset());
|
||||||
|
CalculateService.calculateNextPositionByStartAndLen(sectionPosition, !right, 2 * SimulationConstants.TRAIN_SAFE_DISTANCE);
|
||||||
|
return sectionPosition;
|
||||||
|
|
||||||
|
|
||||||
// VirtualRealityTrain train = (VirtualRealityTrain) this.device;
|
// VirtualRealityTrain train = (VirtualRealityTrain) this.device;
|
||||||
|
Loading…
Reference in New Issue
Block a user