Skip to content

Commit d69dc03

Browse files
committed
editoast, front: fix margin at end instead of start of interval
Signed-off-by: Alice Khoudli <alice.khoudli@polytechnique.org>
1 parent a389ff6 commit d69dc03

3 files changed

Lines changed: 39 additions & 15 deletions

File tree

editoast/src/views/timetable/simulation.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub fn path_item_respect_margins<T: TrainScheduleLike>(
180180
path_item_time_provisional - prev_path_item_time_provisional;
181181
let margin_diff = interval_duration_final - interval_duration_provisional;
182182

183-
res[path_item_index] = margin_diff >= -TIME_APPROX_ERROR.num_milliseconds();
183+
res[prev_path_item_index] = margin_diff >= -TIME_APPROX_ERROR.num_milliseconds();
184184
});
185185

186186
res
@@ -727,18 +727,20 @@ mod tests {
727727
}
728728

729729
fn shallow_sim_too_fast_on_interval() -> SimulationResponseSuccess {
730+
// Too fast from A to B and from D to E
731+
// Respects margins from A to C as B to C compensates A to B, too fast on C to E as not compensated
730732
SimulationResponseSuccess {
731733
base: ReportTrain {
732-
path_item_times: vec![0, 4_730_243, 13_828_795],
734+
path_item_times: vec![0, 100_000, 200_000, 300_000, 400_000],
733735
..Default::default()
734736
},
735737
provisional: ReportTrain {
736-
path_item_times: vec![0, 5_222_392, 15_267_584],
738+
path_item_times: vec![0, 100_000, 200_000, 300_000, 400_000],
737739
..Default::default()
738740
},
739741
final_output: CompleteReportTrain {
740742
report_train: ReportTrain {
741-
path_item_times: vec![0, 5_280_030, 15_300_915],
743+
path_item_times: vec![0, 95_000, 201_000, 301_000, 396_000],
742744
..Default::default()
743745
},
744746
..Default::default()
@@ -801,7 +803,7 @@ mod tests {
801803
&sim.provisional.path_item_times,
802804
&schedule,
803805
);
804-
assert_eq!(*respect, [true, false, true]);
806+
assert_eq!(*respect, [false, true, true]);
805807
}
806808

807809
#[test]
@@ -813,7 +815,7 @@ mod tests {
813815
&sim.provisional.path_item_times,
814816
&schedule,
815817
);
816-
assert_eq!(*respect, [true, true, false]);
818+
assert_eq!(*respect, [true, true, false, true, true]);
817819
}
818820

819821
#[test]

editoast/src/views/timetable/tests/train_schedule_too_fast_on_interval.json

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,50 @@
3737
"type": "uic"
3838
}
3939
}
40+
},
41+
{
42+
"id": "idD",
43+
"location": {
44+
"operational_point": {
45+
"uic": 87700003,
46+
"secondary_code": "BV",
47+
"type": "uic"
48+
}
49+
}
50+
},
51+
{
52+
"id": "idE",
53+
"location": {
54+
"operational_point": {
55+
"uic": 87700004,
56+
"secondary_code": "BV",
57+
"type": "uic"
58+
}
59+
}
4060
}
4161
],
4262
"schedule": [
4363
{
4464
"at": "idB",
45-
"arrival": "PT5280S",
46-
"stop_for": null,
65+
"arrival": null,
66+
"stop_for": "PT1S",
4767
"reception_signal": "OPEN"
4868
},
4969
{
5070
"at": "idC",
51-
"arrival": "PT15300S",
71+
"arrival": "PT201S",
72+
"stop_for": null,
73+
"reception_signal": "OPEN"
74+
},
75+
{
76+
"at": "idE",
77+
"arrival": "PT396S",
5278
"stop_for": "P0D",
5379
"reception_signal": "OPEN"
5480
}
5581
],
5682
"margins": {
57-
"boundaries": ["idC"],
83+
"boundaries": ["idE"],
5884
"values": [
5985
"6.5min/100km",
6086
"0%"

front/src/modules/timesStops/hooks/useTimesStopsTableData.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,7 @@ const useTimesStopsTableData = (
273273
})
274274
: undefined;
275275
const scheduleNotHonored = stableIsValid && !stablePathItemRespect?.times[stepIndex];
276-
// The back end returns the status at the end of the interval but we want to display the information at the beginning of the interval so we check the next path items status
277-
const marginNotHonored =
278-
stableIsValid &&
279-
stepIndex < selectedTrain.path.length - 1 &&
280-
!stablePathItemRespect?.margins[stepIndex + 1];
276+
const marginNotHonored = stableIsValid && !stablePathItemRespect?.margins[stepIndex];
281277
const margins = computeMargins(
282278
getTheoreticalMargins(selectedTrain),
283279
selectedTrain,

0 commit comments

Comments
 (0)