Merge remote-tracking branch 'origin/test' into ats-restruct
This commit is contained in:
commit
cea1f6de3b
@ -175,6 +175,8 @@ public class ZCLogicLoop {
|
|||||||
MovementAuthority.End end = checkSwitch(section, right);
|
MovementAuthority.End end = checkSwitch(section, right);
|
||||||
if (end != null)
|
if (end != null)
|
||||||
endList.add(end);
|
endList.add(end);
|
||||||
|
//前方列车
|
||||||
|
MovementAuthority.End trainEnd = checkSectionOccupied(section);
|
||||||
// 轨道尽头/问题道岔
|
// 轨道尽头/问题道岔
|
||||||
Section temp = section.getNextRunningSectionOf(right);
|
Section temp = section.getNextRunningSectionOf(right);
|
||||||
if (Objects.isNull(temp)) { // 到尽头
|
if (Objects.isNull(temp)) { // 到尽头
|
||||||
@ -198,22 +200,31 @@ public class ZCLogicLoop {
|
|||||||
|
|
||||||
section = temp;
|
section = temp;
|
||||||
}
|
}
|
||||||
// 前方列车
|
// // 前方列车
|
||||||
VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList);
|
// VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList);
|
||||||
if (Objects.nonNull(frontTrain)) {
|
// if (Objects.nonNull(frontTrain)) {
|
||||||
Section baseSection;
|
// Section baseSection;
|
||||||
if (Objects.equals(frontTrain.isRight(), train.isRight())) {
|
// if (Objects.equals(frontTrain.isRight(), train.isRight())) {
|
||||||
baseSection = frontTrain.calculateTailPosition().getSection();
|
// baseSection = frontTrain.calculateTailPosition().getSection();
|
||||||
} else {
|
// } else {
|
||||||
baseSection = frontTrain.getHeadPosition().getSection();
|
// baseSection = frontTrain.getHeadPosition().getSection();
|
||||||
}
|
// }
|
||||||
endList.add(new MovementAuthority.End(frontTrain,
|
// endList.add(new MovementAuthority.End(frontTrain,
|
||||||
MovementAuthority.EndType.FRONT_TRAIN,
|
// MovementAuthority.EndType.FRONT_TRAIN,
|
||||||
baseSection));
|
// baseSection));
|
||||||
}
|
// }
|
||||||
return endList;
|
return endList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MovementAuthority.End checkSectionOccupied(Section section) {
|
||||||
|
for (Section logic : section.getLogicList()) {
|
||||||
|
if (logic.isCtOccupied()) {
|
||||||
|
return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) {
|
private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) {
|
||||||
Section section = tailSection;
|
Section section = tailSection;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
@ -1251,18 +1251,9 @@ public class CalculateService {
|
|||||||
if (section.isPhysical()) {
|
if (section.isPhysical()) {
|
||||||
return sectionPosition;
|
return sectionPosition;
|
||||||
} else {
|
} else {
|
||||||
int offset = 0;
|
|
||||||
Section parent = section.getParent();
|
Section parent = section.getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
for (Section logicSection : parent.getLogicList()) {
|
return new SectionPosition(parent, section.getMinOffset() + sectionPosition.getOffset());
|
||||||
if (!logicSection.equals(section)) {
|
|
||||||
offset += logicSection.getLen();
|
|
||||||
} else {
|
|
||||||
offset += sectionPosition.getOffset();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new SectionPosition(parent, offset);
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -109,26 +109,30 @@ public class MovementAuthority {
|
|||||||
return new SectionPosition(section, offset);
|
return new SectionPosition(section, offset);
|
||||||
}
|
}
|
||||||
case FRONT_TRAIN: {
|
case FRONT_TRAIN: {
|
||||||
VirtualRealityTrain train = (VirtualRealityTrain) this.device;
|
Section section = (Section) this.device;
|
||||||
boolean trainRight = train.isRight();
|
return new SectionPosition(section.getParent(), right ? section.getMinOffset() : section.getMaxOffset());
|
||||||
SectionPosition headPosition = train.getHeadPosition();
|
|
||||||
SectionPosition tailPosition = CalculateService
|
|
||||||
.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen());
|
// VirtualRealityTrain train = (VirtualRealityTrain) this.device;
|
||||||
float offset;
|
// boolean trainRight = train.isRight();
|
||||||
if (Objects.equals(trainRight, right)) { // 同向,取车尾
|
// SectionPosition headPosition = train.getHeadPosition();
|
||||||
offset = right
|
// SectionPosition tailPosition = CalculateService
|
||||||
?
|
// .calculateNextPositionByStartAndLen(headPosition, !right, train.getLen());
|
||||||
tailPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE
|
// float offset;
|
||||||
:
|
// if (Objects.equals(trainRight, right)) { // 同向,取车尾
|
||||||
tailPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE;
|
// offset = right
|
||||||
} else { // 方向相反,取车头
|
// ?
|
||||||
offset = right
|
// tailPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE
|
||||||
?
|
// :
|
||||||
headPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE
|
// tailPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE;
|
||||||
:
|
// } else { // 方向相反,取车头
|
||||||
headPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE;
|
// offset = right
|
||||||
}
|
// ?
|
||||||
return new SectionPosition(this.baseSection, offset);
|
// headPosition.getOffset() - 2 * SimulationConstants.TRAIN_SAFE_DISTANCE
|
||||||
|
// :
|
||||||
|
// headPosition.getOffset() + 2 * SimulationConstants.TRAIN_SAFE_DISTANCE;
|
||||||
|
// }
|
||||||
|
// return new SectionPosition(this.baseSection, offset);
|
||||||
}
|
}
|
||||||
case END_TRACK: {
|
case END_TRACK: {
|
||||||
Section section = (Section) this.device;
|
Section section = (Section) this.device;
|
||||||
@ -138,7 +142,7 @@ public class MovementAuthority {
|
|||||||
case UNLOCKED_OVERLAP:
|
case UNLOCKED_OVERLAP:
|
||||||
case FAULT_SWITCH: {
|
case FAULT_SWITCH: {
|
||||||
Section section = (Section) this.device;
|
Section section = (Section) this.device;
|
||||||
float offset = right ? 0 : section.getLen();
|
float offset = right ? section.getLen() : 0;
|
||||||
SectionPosition stopPosition = new SectionPosition(section, offset);
|
SectionPosition stopPosition = new SectionPosition(section, offset);
|
||||||
return CalculateService.calculateNextPositionByStartAndLen(stopPosition, !right, 100);
|
return CalculateService.calculateNextPositionByStartAndLen(stopPosition, !right, 100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user