速度曲线限速逻辑重写

This commit is contained in:
joylink_zhangsai 2021-08-24 13:07:49 +08:00
parent 3fbef78cb4
commit 27e2f456fc
2 changed files with 25 additions and 6 deletions

View File

@ -976,12 +976,21 @@ public class Section extends MayOutOfOrderDevice {
return this.getSpeedUpLimit() / 3.6f;
} else if (this.isSwitchTrack() && this.getRelSwitch().isReversePosition()) {
return 30 / 3.6f;
} else if (this.getParent() != null) {
return this.getParent().getNeedLimitSpeed();
} else if (isLogicStandTrack()) { //站台逻辑区段默认限速
return 45 / 3.6f;
}
return null;
}
private boolean isLogicStandTrack() {
Section parent = this.getParent();
if (parent == null || !parent.isStandTrack())
return false;
float left = parent.getStopPointByDirection(false);
float right = parent.getStopPointByDirection(true);
return this.minOffset <= right && this.maxOffset >= left;
}
/**
* 根据方向获取终点偏移量
*/

View File

@ -300,19 +300,26 @@ public class SpeedCurve {
Float tailLimitSpeed = tailPosition.getLogicSection().getNeedLimitSpeed();
float limitSpeed = tailLimitSpeed == null ? recommendedSpeedMax : Math.min(tailLimitSpeed, recommendedSpeedMax);
SectionPosition endPosition;
float vt = 0;
SpeedCurve speedCurve = buildTargetSpeedCurve(totalLen, v0, 0, limitSpeed);
for (int i = 0; i < 20; i++) {
if (base == null)
break;
List<Section> logicSections = base.getLogicList();
if (logicSections == null) {
logicSections = Collections.singletonList(base);
}
for (Section logic : logicSections) {
int index = right ? 0 : logicSections.size() - 1;
int x = right ? 1 : -1;
Float distance = null;
for (; 0 <= index && index < logicSections.size(); index += x) {
Section logic = logicSections.get(index);
Float needLimitSpeed = logic.getNeedLimitSpeed();
if (needLimitSpeed != null && needLimitSpeed * 0.9f < limitSpeed) { //新的限速更小
endPosition = new SectionPosition(base, logic.getEndOffsetByDirection(!right)); //限速起始点
Float distance = CalculateService.calculateDistance(headPosition, endPosition, right);
if (distance != null && distance < 500 && distance < totalLen) { //限速点在车头前方限速点距车头不超过500m因为超过500m就不用顾忌
distance = CalculateService.calculateDistance(headPosition, endPosition, right);
if (distance != null && (distance > 500 || distance > totalLen)) //限速点在车头前方限速点距车头不超过500m过早考虑限速没有意义
break;
if (distance != null && distance > 0) {
//取最靠下的速度曲线
SpeedCurve limitSpeedCurve = buildTargetSpeedCurve(distance, v0, needLimitSpeed * 0.9f, limitSpeed); //到达新限速点的速度曲线
float speed = speedCurve.getSpeedOf(speedCurve.getTotalDistance());
@ -326,6 +333,9 @@ public class SpeedCurve {
}
}
}
if (distance != null && (distance > 500 || distance > totalLen))
break;
base = base.getNextRunningSectionOf(right);
}
return speedCurve;
}