mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 02:42:46 +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:
@@ -33,9 +33,9 @@ drivingaid::readout read(vehicle &Vehicle, drivingaid::cab_controls const &Cab)
|
||||
// what the panel showed before: the throttle and brakes numbers, and the local brake always
|
||||
drivingaid::readout before(physics::Vehicle const &Physics) {
|
||||
drivingaid::readout result;
|
||||
result.throttle_first = Physics.EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * Physics.eimic_real)) : Physics.MainCtrlPos();
|
||||
result.throttle_first = Physics.EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * Physics.EimicReal())) : Physics.MainCtrlPos();
|
||||
result.throttle_second = Physics.EIMCtrlType > 0 ? Physics.MainCtrlPos() : Physics.ScndCtrlPos();
|
||||
result.brake_first = Physics.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Physics.eimic_real) : Physics.brakes.HandlePositionSmooth();
|
||||
result.brake_first = Physics.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Physics.EimicReal()) : Physics.brakes.HandlePositionSmooth();
|
||||
result.local_brake = Physics.brakes.IndependentPosition() * LocalBrakePosNo;
|
||||
return result;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ TEST_CASE("driving aid: the Vectron's ED lever shows as a negative throttle step
|
||||
REQUIRE(vectron->Vel > 15.0); // above Vh1, where the ED brake has its full demand
|
||||
auto const braking{read(vectron, vectron_cab)};
|
||||
CHECK(braking.throttle_first == -6);
|
||||
REQUIRE(vectron->eimic_real == doctest::Approx(-0.4));
|
||||
REQUIRE(vectron->EimicReal() == doctest::Approx(-0.4));
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == 40);
|
||||
// the train brake handle and the local brake, as before
|
||||
@@ -85,10 +85,10 @@ TEST_CASE("driving aid: the Traxx's ED braking from its master controller") {
|
||||
// B+: the braking demand ramps towards full
|
||||
traxx->SetMainCtrlPos(0);
|
||||
traxx.run(3.0, line);
|
||||
REQUIRE(traxx->eimic_real < -0.2);
|
||||
REQUIRE(traxx->EimicReal() < -0.2);
|
||||
auto const braking{read(traxx, lever_cab)};
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * traxx->eimic_real));
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * traxx->EimicReal()));
|
||||
// the drive demand stays at zero while braking, with the controller position next to it, as before
|
||||
CHECK(braking.throttle_first == 0);
|
||||
CHECK(braking.throttle_second == 0);
|
||||
@@ -108,10 +108,10 @@ TEST_CASE("driving aid: the Elf leaves out the local brake it has no control of,
|
||||
// the controller at its lowest braking position: the demand ramps towards full braking
|
||||
elf->SetMainCtrlPos(0);
|
||||
elf.run(2.0, line);
|
||||
REQUIRE(elf->eimic_real < -0.1);
|
||||
REQUIRE(elf->EimicReal() < -0.1);
|
||||
auto const braking{read(elf, elf_cab)};
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * elf->eimic_real));
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * elf->EimicReal()));
|
||||
CHECK(braking.throttle_first == 0);
|
||||
CHECK(braking.throttle_second == 0);
|
||||
CHECK_FALSE(braking.show_local_brake);
|
||||
@@ -163,7 +163,7 @@ TEST_CASE("driving aid: every real vehicle with a local brake control shows the
|
||||
for (auto const &[mainctrl, localbrake, eimic] : {std::tuple{0, 0.0, 0.0}, std::tuple{1, 0.4, -0.25}, std::tuple{1, 0.0, 0.6}}) {
|
||||
real->SetMainCtrlPos(std::min(mainctrl, real->MainCtrlPosNo));
|
||||
real->brakes.SetIndependentPosition(localbrake);
|
||||
real->eimic_real = eimic;
|
||||
real->SetEimicReal(eimic);
|
||||
auto const now{read(real, lever_cab)};
|
||||
auto const was{before(real.physics())};
|
||||
CHECK(now.throttle_first == was.throttle_first);
|
||||
|
||||
Reference in New Issue
Block a user