18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 01:46:01 +01:00

Merge pull request #292 from MaSzyna-EU07/fix/en57-ep2-brake-charging

EN57 brakes: charging when hauled with the brake hose alone, Knorr EP brake only with control power
This commit is contained in:
2026-11-09 12:48:13 +00:00
committed by GitHub
8 changed files with 231 additions and 22 deletions

View File

@@ -4,6 +4,7 @@
#include "golden.h"
#include "real_vehicles.h"
#include "drive.h"
#include "consist.h"
#include "McZapkie/hamulce.h"
@@ -35,6 +36,7 @@ void hold(vehicle &Vehicle, test::trace &Trace, std::string const &Event, double
// every position of the driver's handle, recorded in the trace
void every_position(vehicle &Vehicle, test::trace &Trace) {
Vehicle.hold_main_reservoir(std::max(Vehicle->MaxCompressor, 8.0));
REQUIRE(Vehicle->Handle != nullptr);
auto &handle{*Vehicle->Handle};
Vehicle.record(Trace);
@@ -57,6 +59,13 @@ void every_position(vehicle &Vehicle, test::trace &Trace) {
hold(Vehicle, Trace, "running", handle.GetPos(bh_RP), 60.0);
}
// the handle put to the given position and the vehicle driven from its cab for Seconds, marked in the trace
void driven_at(vehicle &Vehicle, test::trace &Trace, std::string const &Event, double Position, double Seconds) {
Trace.mark(Event);
Vehicle->BrakeLevelSet(Position);
test::drive(test::driving(Vehicle), {}, Seconds);
}
} // namespace
TEST_CASE("brake handles: every position of the driver's handle of every real vehicle") {
@@ -96,6 +105,7 @@ TEST_CASE("brake handles: the local brake handle of every real vehicle") {
real.hold_main_reservoir(std::max(real->MaxCompressor, 8.0));
test::trace trace{"local brake/" + path, handle_channels(), 100};
real.record(trace);
REQUIRE(real->Handle != nullptr);
real->BrakeLevelSet(real->Handle->GetPos(bh_RP));
trace.mark("charge");
real.run(60.0);
@@ -126,25 +136,21 @@ TEST_CASE("brake handles: the overload and the high pressure buttons of the MHZ
real.hold_main_reservoir(std::max(real->MaxCompressor, 8.0));
test::trace trace{"brake handles/buttons/" + name, handle_channels(), 100};
real.record(trace);
REQUIRE(real->Handle != nullptr);
auto &handle{*real->Handle};
auto const at{[&trace, &real](std::string const &Event, double Position, double Seconds) {
trace.mark(Event);
real->BrakeLevelSet(Position);
test::drive(test::driving(real), {}, Seconds);
}};
at("running", handle.GetPos(bh_RP), 60.0);
driven_at(real, trace, "running", handle.GetPos(bh_RP), 60.0);
auto const running{real->PipePress};
handle.SetUniversalFlag(TUniversalBrake::ub_Overload);
at("overload button", handle.GetPos(bh_RP), 30.0);
driven_at(real, trace, "overload button", handle.GetPos(bh_RP), 30.0);
handle.SetUniversalFlag(0);
auto const overloaded{real->PipePress};
at("overload decaying", handle.GetPos(bh_RP), 240.0);
driven_at(real, trace, "overload decaying", handle.GetPos(bh_RP), 240.0);
auto const decayed{real->PipePress};
handle.SetUniversalFlag(TUniversalBrake::ub_HighPressure);
at("high pressure button, filling stroke", handle.GetPos(bh_FS), 10.0);
driven_at(real, trace, "high pressure button, filling stroke", handle.GetPos(bh_FS), 10.0);
auto const filled{real->PipePress};
handle.SetUniversalFlag(0);
at("running", handle.GetPos(bh_RP), 120.0);
driven_at(real, trace, "running", handle.GetPos(bh_RP), 120.0);
CHECK(running == doctest::Approx(5.0).epsilon(0.01));
CHECK(overloaded > running + 0.3);
CHECK(decayed < overloaded);
@@ -152,3 +158,110 @@ TEST_CASE("brake handles: the overload and the high pressure buttons of the MHZ
trace.check();
}
}
// eu07/maszyna#134: the Knorr St113 of the EN57-001 releases the EP brake in the running position (bh_RP, Num 6)
// and applies it one position on (Num 8), short of the lap position (Num 5); the positions are those the keys
// select, and the EP brake works only with the control of the cab powered: the battery, the reverser out of
// neutral and the EP fuse on (Ctrl+Z), as the Oerlikon handle's
namespace {
// the front car of the EN57-001 driven from its cab, with the motor car behind it, which has the battery of the two;
// air in the reservoirs, the battery on
void ready_knorr_ep(test::consist &Unit) {
Unit.add(definition::fiz("en57_v1/6bai"), 1);
Unit.add(definition::fiz("en57_v1/5bgb"));
auto &cab{Unit[0]};
REQUIRE(cab->BrakeHandle == TBrakeHandle::St113);
REQUIRE(cab->Handle != nullptr);
cab->BatterySwitch(true);
cab->CabActivisation();
cab.hold_brake_pipe(5.0);
cab->BrakeLevelSet(cab->Handle->GetPos(bh_RP));
Unit.run(60.0);
}
// the EP brake button pressed in the given handle position, held for Seconds; the cylinder pressure of the cab car
double ep_brake(test::consist &Unit, double Position, double Seconds) {
auto &cab{Unit[0]};
cab->BrakeLevelSet(Position);
Unit.run(0.1);
cab->SwitchEPBrake(1);
Unit.run(Seconds);
return cab->BrakePress;
}
// the EP force the St113 handle of the cab car gives in the given position
double ep_at(test::consist &Unit, double Position) {
auto &cab{Unit[0]};
cab->BrakeLevelSet(Position);
Unit.run(0.1);
return cab->Handle->GetEP();
}
} // namespace
TEST_CASE("brake handles: the positions of the Knorr St113 EP brake") {
test::consist unit;
ready_knorr_ep(unit);
auto &cab{unit[0]};
REQUIRE(cab->Handle != nullptr);
auto &handle{*cab->Handle};
// the keys: Num 6 running, Num 8 the first position on, Num 5 the middle of the handle
CHECK(handle.GetPos(bh_RP) == doctest::Approx(0.0));
CHECK(ep_at(unit, 0.0) == doctest::Approx(-1.0)); // EP release
CHECK(ep_at(unit, 1.0) == doctest::Approx(1.0)); // EP brake
CHECK(ep_at(unit, cab->BrakeCtrlPosNo / 2) == doctest::Approx(0.0)); // lap, Num 5
CHECK(ep_at(unit, handle.GetPos(bh_FB)) == doctest::Approx(0.0));
CHECK(ep_at(unit, handle.GetPos(bh_EPR)) == doctest::Approx(-1.0));
CHECK(ep_at(unit, handle.GetPos(bh_EPB)) == doctest::Approx(1.0));
}
TEST_CASE("brake handles: the Knorr St113 EP brake needs the control of the cab powered") {
for (std::string const cut : {"reverser in neutral", "EP fuse off", "battery off"}) {
CAPTURE(cut);
test::consist unit;
ready_knorr_ep(unit);
auto &cab{unit[0]};
cab->DirectionForward();
unit.run(1.0);
REQUIRE(cab->EPBrakeControlPowered());
if (cut == "reverser in neutral") {
cab->DirectionBackward();
}
else if (cut == "EP fuse off") {
cab->EpFuseSwitch(false);
}
else {
cab->BatterySwitch(false);
}
unit.run(1.0);
REQUIRE_FALSE(cab->EPBrakeControlPowered());
// the button in the EP brake position does nothing
CHECK(ep_brake(unit, 1.0, 5.0) < 0.1);
CHECK(cab->EpForce == doctest::Approx(0.0));
cab->SwitchEPBrake(0);
}
test::consist unit;
ready_knorr_ep(unit);
auto &cab{unit[0]};
cab->DirectionForward();
unit.run(1.0);
// powered, the EP brake applies
auto const applied{ep_brake(unit, 1.0, 2.0)};
CHECK(applied > 0.5);
// the reverser put to neutral with the button still held: the EP brake drops out and holds what it applied
cab->DirectionBackward();
unit.run(0.1);
CHECK(cab->EpForce == doctest::Approx(0.0));
auto const held{cab->BrakePress};
unit.run(5.0);
CHECK(cab->BrakePress < held + 0.05);
CHECK(cab->BrakePress > 0.2);
// and doesn't release either, until the control is powered again
CHECK(ep_brake(unit, 0.0, 5.0) > 0.2);
cab->SwitchEPBrake(0);
cab->DirectionForward();
unit.run(0.1);
CHECK(ep_brake(unit, 0.0, 10.0) < 0.1);
}

View File

@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
#include "consist.h"
using test::definition;
using test::vehicle;
@@ -91,3 +92,48 @@ TEST_CASE("brakes: service braking stops a heavier wagon too") {
wagon.run(40.0 /* s */, test::track{0.15 /* friction */, 0.0 /* gradient */});
CHECK(std::abs(wagon.speed()) < 0.1);
}
// eu07/maszyna#87: the ESt4d of the EN57's EP2 valve charged its auxiliary reservoir from the main reservoir pipe
// alone, so a dead unit hauled by a locomotive coupled with the hook and the brake hose ("3") never charged it,
// its control reservoir stopped half way, and it didn't brake. Like every ESt, it charges from the brake pipe too
TEST_CASE("brakes: a dead EN57 hauled with the brake hose alone charges from the brake pipe and brakes") {
test::consist train;
auto &locomotive{train.add(definition::fiz("sm42_v1/6d1"))};
train.add(definition::fiz("en57_v1/5bgb"), 0, coupling::coupler | coupling::brakehose);
train.add(definition::fiz("en57_v1/6ba_840"));
train.add(definition::fiz("en57_v1/5bgaiii_led_spot"));
// a unit standing dead: no air anywhere, nothing in its main reservoir pipe
for (std::size_t i = 1; i < train.size(); ++i) {
auto &car{train[i].mover()};
REQUIRE(car.BrakeValve == TBrakeValve::EP2);
car.Hamulec->ForceEmptiness();
car.Pipe->CreatePress(0.0);
car.Pipe->Act();
car.Pipe2->CreatePress(0.0);
car.Pipe2->Act();
car.CompressedVolume = 0.0;
}
locomotive.hold_brake_pipe(5.0);
train.run(900.0);
for (std::size_t i = 1; i < train.size(); ++i) {
CAPTURE(i);
auto &car{train[i].mover()};
REQUIRE(car.ScndPipePress < 0.1); // no main reservoir pipe
CHECK(car.Hamulec->GetBRP() > 4.8);
CHECK(car.Hamulec->GetCRP() > 4.8);
CHECK(car.BrakePress < 0.1);
}
// a full service application brakes the unit, and it releases again
locomotive.hold_brake_pipe(3.5);
train.run(20.0);
for (std::size_t i = 1; i < train.size(); ++i) {
CAPTURE(i);
CHECK(train[i]->BrakePress > 2.0);
}
locomotive.hold_brake_pipe(5.0);
train.run(60.0);
for (std::size_t i = 1; i < train.size(); ++i) {
CAPTURE(i);
CHECK(train[i]->BrakePress < 0.1);
}
}