mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-28 18:34:19 +01:00
* test(scenarios): the L053 poranek cases now fail on the station's SM42
#409 fixed what both l053_poranek_tme222158_debica cases were marked
xfail for: the EP07 on Tm4 stops at the checkpoint, and the ET21 no
longer stands off the wire at Debica Towarowa. Run on staging f15ea405,
neither passes yet: TME222158 gets to Debica and reports there, but the
station's SM42-1096, ordered to uncouple at step 10 of deb_sm42_stat,
pushes its cut past debica_k_sem_info at danger and never gets the
coupler off, so the station never gives TME222158 step 1 and both runs
end as a standstill (4347 s and 4576 s of simulation time). The xfail
marks stay, with that reason.
* fix(ai): keep the locomotive released while it pushes the buffers in to uncouple
Stage 3 of uncoupling (TController::UpdateDisconnect) ends only when the locomotive has pushed the buffers
together: a screw coupler is let go with the buffers under 0.01 m apart (or over 0.2 m). Nothing else ends
the stage. The consist brakes applied in stage 2 hold the locomotive as well, and only its brake releaser
lets it go. The AI worked the releaser in that stage only while it wanted to speed up (AccDesired above
-0.05), together with the start-off rules of control_releaser.
When the cut stands across a signal at stop for the direction the locomotive pushes in, the driver counts
the signal as passed at its first move after the direction change, VelSignalLast becomes 0 and AccDesired
stays at -0.05 or -0.85. The releaser then went off, the brake cylinder filled again from the brake pipe,
the pressure switch cut the power, and the locomotive stood for good with the buffers 0.018 m apart. The
station's SM42-1096 at Debica on L053 poranek did that at step 10 of deb_sm42_stat and logged "actuating
and compressing buffers..." for the rest of the run (a temporary log line showed the brake cylinder going
from 1.25 to 3.69 bar with the releaser off, and the gap staying at 0.0184 m).
In stage 3 the releaser now stays on while the locomotive's brake cylinder holds more than 0.1 bar,
whatever AccDesired is. The push asks for 2 km/h at most and the cut stays braked, so this changes nothing
else. Everything else, including the rest of the uncoupling (the direction changes before and after it)
and coupling, keeps the old rule. The overcharge guard (pipe above 5.2 bar) still turns the releaser off.
The decision moves into vehicle/brakereleaser.{h,cpp} so it is unit tested; control_releaser does the same
cues in the same order as before.
On L053 poranek the SM42 now uncouples at step 10 in 0.2 s (gap 0.021 -> 0.0096 m) and the mission goes on.
* test(scenarios): a shunter uncouples with its wagons standing across a signal at stop
sm42_td_uncouple_past_signal (fragment td_uncouple_past_signal.scn) rebuilds the uncoupling of the SM42 at
Debica on L053 poranek on td.scn. An SM42 pulls three loaded wagons back along tor1k, stops in front of a
closed track with the far end of the last wagon 2 m past the exit signal stacja1_j at stop, and gets
Shunt 0 0 at once. The pull leaves the screw coupler 0.019 m apart at the buffers. Before the fix of the
releaser the locomotive stayed braked and the case ran into its timeout with no "uncoupled" in the log;
now it uncouples within a second.
* test(scenarios): the L053 poranek cases pass again
With the station's SM42-1096 uncoupling at step 10 of deb_sm42_stat again (the releaser fix before this
commit), both l053_poranek_tme222158_debica cases pass: TME222158 gets its exit signal at Debica after
4086.2 s of simulation, and with the ET21 after 4131.6 s. The xfail marks go, so that the runner doesn't
fail on XPASS, and the README rows say so.
115 lines
4.3 KiB
C++
115 lines
4.3 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
|
|
#include "vehicle/brakereleaser.h"
|
|
|
|
// when the AI works the brake releaser of its locomotive (TController::control_releaser). in stage 3 of uncoupling
|
|
// the locomotive pushes towards the cut it leaves, until the screw coupler slackens enough to be let go
|
|
// (TController::UpdateDisconnect). the consist brakes applied in stage 2 hold the locomotive too, and only the
|
|
// releaser lets it go. the releaser was worked only while the driver wanted to speed up (AccDesired above
|
|
// -0.05), so a signal at stop the cut stood across after the direction change, which caps the speed at 0, left the
|
|
// locomotive braked and the uncoupling went on for good (SM42 at Debica on L053).
|
|
|
|
namespace {
|
|
|
|
// a locomotive standing in stage 3 of uncoupling, braked by the consist's brake application of stage 2
|
|
brake_releaser::conditions compressing_buffers(double const Acceleration) {
|
|
brake_releaser::conditions state;
|
|
state.acceleration_desired = Acceleration;
|
|
state.pipe_pressure = 3.8;
|
|
state.cylinder_pressure = 1.5;
|
|
state.control_pressure = 5.0;
|
|
state.velocity = 0.0;
|
|
state.pressing = true;
|
|
state.compressing_buffers = true;
|
|
return state;
|
|
}
|
|
|
|
// a locomotive standing braked at the head of a train with a charged brake pipe, about to start off
|
|
brake_releaser::conditions standing_braked(double const Acceleration) {
|
|
brake_releaser::conditions state;
|
|
state.acceleration_desired = Acceleration;
|
|
state.pipe_pressure = 5.0;
|
|
state.cylinder_pressure = 1.0;
|
|
state.control_pressure = 5.0;
|
|
state.velocity = 0.0;
|
|
return state;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("brake releaser: stage 3 of uncoupling releases the locomotive whatever the driver's acceleration") {
|
|
for (auto const acceleration : {0.3, 0.0, -0.05, -0.2, -0.9}) {
|
|
CAPTURE(acceleration);
|
|
auto const wanted{brake_releaser::decide(compressing_buffers(acceleration))};
|
|
CHECK(wanted.actuate);
|
|
CHECK_FALSE(wanted.fill_pipe);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("brake releaser: stage 3 of uncoupling leaves a released locomotive alone") {
|
|
for (auto const acceleration : {0.3, -0.9}) {
|
|
CAPTURE(acceleration);
|
|
auto state{compressing_buffers(acceleration)};
|
|
state.cylinder_pressure = 0.05;
|
|
CHECK_FALSE(brake_releaser::decide(state).actuate);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("brake releaser: pressing outside stage 3 still needs the driver to want to speed up") {
|
|
// the direction changes of stages 2 and 4, and coupling, are as before: the releaser goes on only with
|
|
// AccDesired above -0.05
|
|
auto state{compressing_buffers(0.3)};
|
|
state.compressing_buffers = false;
|
|
CHECK(brake_releaser::decide(state).actuate);
|
|
state.acceleration_desired = -0.05;
|
|
CHECK_FALSE(brake_releaser::decide(state).actuate);
|
|
state.acceleration_desired = -0.9;
|
|
CHECK_FALSE(brake_releaser::decide(state).actuate);
|
|
}
|
|
|
|
TEST_CASE("brake releaser: starting off releases a braked locomotive below 1 km/h") {
|
|
CHECK(brake_releaser::decide(standing_braked(0.3)).actuate);
|
|
CHECK_FALSE(brake_releaser::decide(standing_braked(-0.05)).actuate);
|
|
|
|
auto moving{standing_braked(0.3)};
|
|
moving.velocity = 1.0;
|
|
CHECK_FALSE(brake_releaser::decide(moving).actuate);
|
|
|
|
auto lightly{standing_braked(0.3)};
|
|
lightly.cylinder_pressure = 0.4;
|
|
CHECK_FALSE(brake_releaser::decide(lightly).actuate);
|
|
|
|
// the control reservoir not charged: releasing would vent it
|
|
auto uncharged{standing_braked(0.3)};
|
|
uncharged.control_pressure = 4.9;
|
|
CHECK_FALSE(brake_releaser::decide(uncharged).actuate);
|
|
// unless the train brake is held on purpose to start uphill
|
|
uncharged.uphill_start = true;
|
|
CHECK(brake_releaser::decide(uncharged).actuate);
|
|
}
|
|
|
|
TEST_CASE("brake releaser: an empty brake pipe is filled up when the driver wants to speed up") {
|
|
auto state{standing_braked(0.3)};
|
|
state.pipe_pressure = 2.9;
|
|
state.cylinder_pressure = 0.0;
|
|
auto const wanted{brake_releaser::decide(state)};
|
|
CHECK(wanted.actuate);
|
|
CHECK(wanted.fill_pipe);
|
|
|
|
state.acceleration_desired = -0.2;
|
|
auto const braking{brake_releaser::decide(state)};
|
|
CHECK_FALSE(braking.actuate);
|
|
CHECK_FALSE(braking.fill_pipe);
|
|
}
|
|
|
|
TEST_CASE("brake releaser: an overcharged brake pipe turns the releaser off, in stage 3 of uncoupling too") {
|
|
auto starting{standing_braked(0.3)};
|
|
starting.pipe_pressure = 5.3;
|
|
CHECK_FALSE(brake_releaser::decide(starting).actuate);
|
|
|
|
auto uncoupling{compressing_buffers(-0.9)};
|
|
uncoupling.pipe_pressure = 5.3;
|
|
CHECK_FALSE(brake_releaser::decide(uncoupling).actuate);
|
|
}
|