mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 21:20:57 +00:00
leg-aware capacity and wagon sharing
This commit is contained in:
@@ -559,11 +559,14 @@ export function TrainCompositionDiagram({
|
||||
// ceiling the allocation engine spends from.
|
||||
const totalTare = normalized.reduce((s, w) => s + w.tareWeightTons, 0);
|
||||
const grossWeight = totalWeight + totalTare;
|
||||
// Weakest locomotive caps the set — same rule the allocation engine applies.
|
||||
// Engine rule (combinedLocomotiveLimits): coupled locomotives pull
|
||||
// TOGETHER, so their pull limits SUM.
|
||||
const pullLimits = locos
|
||||
.map((l) => Number(l.maxPullWeightTons))
|
||||
.filter((v) => Number.isFinite(v) && v > 0);
|
||||
const pullLimit = pullLimits.length ? Math.min(...pullLimits) : null;
|
||||
const pullLimit = pullLimits.length
|
||||
? pullLimits.reduce((sum, v) => sum + v, 0)
|
||||
: null;
|
||||
return {
|
||||
total: normalized.length,
|
||||
assigned,
|
||||
|
||||
@@ -132,17 +132,24 @@ export const TrainConsistView = ({
|
||||
0,
|
||||
);
|
||||
const tareUsed = wagons.reduce((sum, w) => sum + (w.tareWeightTons ?? 0), 0);
|
||||
const weightUsed = cargoUsed + tareUsed;
|
||||
const lengthUsed = wagons.reduce((sum, w) => sum + (w.lengthMeters ?? 0), 0);
|
||||
// Prefer the server's heaviest-edge figures: on a multi-stop corridor a
|
||||
// wagon reused across legs is several slots but one physical wagon, so the
|
||||
// plain sums over-report the train against the pull/length/slot caps.
|
||||
const heaviest = trainSet?.heaviestLeg;
|
||||
const weightUsed = heaviest?.grossWeightTons ?? cargoUsed + tareUsed;
|
||||
const lengthUsed =
|
||||
heaviest?.lengthMeters ?? wagons.reduce((sum, w) => sum + (w.lengthMeters ?? 0), 0);
|
||||
const wagonsUsed = heaviest?.loadedWagonCount ?? loadedCount;
|
||||
|
||||
// Weakest locomotive caps the set — same rule the allocation engine applies.
|
||||
// Engine rule (combinedLocomotiveLimits): coupled locomotives pull TOGETHER,
|
||||
// so pull caps SUM; the track doesn't lengthen, so the length cap is the MIN.
|
||||
const locos = trainSet?.locomotives?.length
|
||||
? trainSet.locomotives
|
||||
: trainSet?.locomotive
|
||||
? [trainSet.locomotive]
|
||||
: [];
|
||||
const weightMax = locos.length
|
||||
? Math.min(...locos.map((l) => l.maxPullWeightTons))
|
||||
? locos.reduce((sum, l) => sum + l.maxPullWeightTons, 0)
|
||||
: null;
|
||||
const lengthCaps = locos
|
||||
.map((l) => l.maxTrainLengthMeters)
|
||||
@@ -156,7 +163,7 @@ export const TrainConsistView = ({
|
||||
weightMax={weightMax}
|
||||
lengthUsed={lengthUsed}
|
||||
lengthMax={lengthMax}
|
||||
wagonCount={loadedCount}
|
||||
wagonCount={wagonsUsed}
|
||||
wagonMax={maxWagons}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user