Skip to content

Commit d5cd3fe

Browse files
committed
core: sim: add more details when a train lacks traction
1 parent 32c5a20 commit d5cd3fe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

core/envelope-sim/src/main/java/fr/sncf/osrd/envelope_sim/pipelines/MaxEffortEnvelope.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,18 @@ private static void accelerate(
119119
cursor.findPosition(overlayBuilder.getLastPos());
120120
if (overlayBuilder.lastIntersection == 0) {
121121
// The train stopped before reaching the end
122-
throw new OSRDError(ErrorType.ImpossibleSimulationError);
122+
var err = new OSRDError(ErrorType.ImpossibleSimulationError);
123+
var offset = cursor.getPosition();
124+
err.context.put("offset", String.format("%.0fm", offset));
125+
var headPosition = Math.min(Math.max(0, offset), context.path.getLength());
126+
var tailPosition =
127+
Math.min(Math.max(0, headPosition - context.rollingStock.getLength()), context.path.getLength());
128+
var grade = context.path.getAverageGrade(headPosition, tailPosition);
129+
err.context.put("grade", String.format("%.2fm/km", grade));
130+
var map = context.tractiveEffortCurveMap.get(cursor.getPosition());
131+
assert map != null;
132+
err.context.put("traction_force", String.format("%.2fN", map[0].maxEffort()));
133+
throw err;
123134
}
124135
builder.addPart(partBuilder.build());
125136
}

0 commit comments

Comments
 (0)