18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 03:37:09 +01:00

refactor(physics): the demand of the integrated controller is private to the vehicle

eimic_real, the demand of the integrated controller the vehicle goes by with
the speed control counted, which TDynamicObject and the consist braking set
for the vehicle that leads, is private: EimicReal() and SetEimicReal(). The
field of the same name of drivingaid::input stays as it is.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:39:07 +01:00
parent f0978c36c7
commit 23b695752a
23 changed files with 76 additions and 73 deletions
+13 -13
View File
@@ -281,7 +281,7 @@ template <typename Action> double release_time(elf &Unit, double Seconds, Action
auto const time{i * step_time};
Act(time);
Unit.unit.step(Unit.line);
if (cab.UpdateStopBrakeRelease(cab.eimic_real, step_time)) {
if (cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time)) {
return time;
}
}
@@ -339,14 +339,14 @@ template <typename Action> start start_off(elf &Unit, double Seconds, Action Act
auto const time{i * step_time};
Act(time);
Unit.unit.step(Unit.line);
auto const released{cab.UpdateStopBrakeRelease(cab.eimic_real, step_time)};
auto const released{cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time)};
if (cab.Vel > 1.0) {
shuntmode = false;
}
hold(Unit, shuntmode && false == released);
if (released && result.release < 0.0) {
result.release = time;
result.demand = cab.eimic_real;
result.demand = cab.EimicReal();
}
if (cab.Vel > 0.5 && result.moving < 0.0) {
result.moving = time;
@@ -397,7 +397,7 @@ TEST_CASE("elf holding brake: the controller held at power") {
REQUIRE(unit.ready);
auto const release{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
CHECK(release == doctest::Approx(0.0));
CHECK(unit.cab().eimic_real == doctest::Approx(0.01));
CHECK(unit.cab().EimicReal() == doctest::Approx(0.01));
}
SUBCASE("with SBDReleaseDelay=1.0 it lets go as the demand starts to ramp up, about 1 s on") {
elf unit{{data::plain}, elf_delay};
@@ -405,10 +405,10 @@ TEST_CASE("elf holding brake: the controller held at power") {
auto &cab{unit.cab()};
auto const release{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
// the 1% of the first step is all there is until then
auto const demand{cab.eimic_real};
auto const demand{cab.EimicReal()};
// the step the ramp of the demand starts at
auto rampstart{release};
while (cab.eimic_real < 0.0101 && rampstart < 5.0) {
while (cab.EimicReal() < 0.0101 && rampstart < 5.0) {
rampstart += step_time;
unit.unit.step(unit.line);
}
@@ -425,10 +425,10 @@ TEST_CASE("elf holding brake: the controller flicked to power once and back to h
REQUIRE(unit.ready);
auto &cab{unit.cab()};
auto const release{release_time(unit, 5.0, [&unit](double Time) { flick(unit, Time); })};
MESSAGE("flick: release " << release << " s, demand " << cab.eimic_real);
MESSAGE("flick: release " << release << " s, demand " << cab.EimicReal());
CHECK(release == doctest::Approx(1.0).epsilon(0.015));
// the demand stays at the 1% of the flick
CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02));
CHECK(cab.EimicReal() == doctest::Approx(0.01).epsilon(0.02));
}
TEST_CASE("elf holding brake: a demand dropped to zero before the delay starts the count again") {
@@ -439,7 +439,7 @@ TEST_CASE("elf holding brake: a demand dropped to zero before the delay starts t
auto const release{release_time(unit, 5.0, [&unit](double Time) { unit.set_controller(Time > 0.495 && Time < 0.695 ? 2 : 4); })};
MESSAGE("restart: release " << release << " s");
CHECK(release == doctest::Approx(1.7).epsilon(0.01));
CHECK(cab.eimic_real > 0.0);
CHECK(cab.EimicReal() > 0.0);
}
TEST_CASE("elf holding brake: it comes back when the demand drops to zero at standstill") {
@@ -451,8 +451,8 @@ TEST_CASE("elf holding brake: it comes back when the demand drops to zero at sta
// the braking position takes the demand off: the brake holds from the next step
unit.set_controller(2);
unit.unit.step(unit.line);
CHECK(cab.eimic_real <= 0.0);
CHECK_FALSE(cab.UpdateStopBrakeRelease(cab.eimic_real, step_time));
CHECK(cab.EimicReal() <= 0.0);
CHECK_FALSE(cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time));
// and power demanded again waits the delay again
auto const again{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
CHECK(again == doctest::Approx(1.0).epsilon(0.015));
@@ -529,8 +529,8 @@ TEST_CASE("elf holding brake: the force of the motors at 1% against the holding
unit.set_controller(3);
unit.wait(5.0);
auto const holding{cab.brakes.holding.deceleration * mass};
MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.eimic_real << ", cab car Ft " << cab.Ft()
MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.EimicReal() << ", cab car Ft " << cab.Ft()
<< " N, Fful " << cab.inductionMotor.state.fullForce << " kN, speed " << cab.Vel << " km/h after 5 s");
CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02));
CHECK(cab.EimicReal() == doctest::Approx(0.01).epsilon(0.02));
CHECK(cab.Ft() * powered < 0.1 * holding);
}