Skip to content

Commit

Permalink
front: fix cached power restrictions on GEV
Browse files Browse the repository at this point in the history
The power restrictions were computed only when the path of the selected train changed, and not when the selected train himself changed.
Thus, if 2 trains had exactly the same path, then the power restrictions were not re-computed when switching from one to another.

Now, the power restrictions are computed each time the selected train or the pathfinding changes.

Signed-off-by: Clara Ni <[email protected]>
  • Loading branch information
clarani committed Feb 6, 2025
1 parent 716e6c8 commit a832366
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,24 @@ const useSpeedSpaceChart = (
);

setFormattedPathProperties(formattedPathProps);

// Format power restrictions
const powerRestrictions = formatPowerRestrictionRangesWithHandled({
selectedTrainSchedule: trainScheduleResult,
selectedTrainRollingStock: rollingStock,
pathfindingResult,
pathProperties: formattedPathProps,
});
setFormattedPowerRestrictions(powerRestrictions);
}
};

getPathProperties();
}, [pathProperties, infraId, rollingStock]);

useEffect(() => {
if (trainScheduleResult && rollingStock && pathfindingResult && formattedPathProperties) {
const powerRestrictions = formatPowerRestrictionRangesWithHandled({
selectedTrainSchedule: trainScheduleResult,
selectedTrainRollingStock: rollingStock,
pathfindingResult,
pathProperties: formattedPathProperties,
});
setFormattedPowerRestrictions(powerRestrictions);
}
}, [formattedPathProperties, trainScheduleResult]);

// setup chart synchronizer
useEffect(() => {
if (simulation?.status === 'success' && trainScheduleResult && rollingStock && departureTime) {
Expand Down

0 comments on commit a832366

Please sign in to comment.