17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-28 13:27:30 +01:00

fix: review findings of PR 217

- the pressures of the mover are in bar (MinCP=7.0 in the vehicle definitions), so the 0.2 the pneumatic horns
  needed was 0.2 bar; it's 2 bar now, and the tests take their pressures in bar too,
- the lamps of the ground relay and of the motor overload relays follow the pressure switch as the line
  contactors one does, TMoverParameters::MainCircuitLampsEnabled(), so the lamps of one cab go out together,
- the joint oil and fuel pump switch leaves out a pump started automatically, which ignores the switching:
  with one, it couldn't turn the other off, and showed off with both running (OilFuelPumpsEnabled()),
- the kind of the train heating switch comes from the occupied vehicle on entering the cab too, as in the
  switch commands; in a multiple unit these are different vehicles,
- CouplerForce() put the force taken back by the other vehicle on its far coupler when the vehicles faced each
  other (Couplers[1 - End] rather than the coupler it's coupled with),
- the velocity difference along the coupler axis computed once, CouplerVelocityDifference(), for CouplerForce()
  and CollisionVelocity(),
- the attachcoupler flag added without the SetFlag() call with 0, the index of the mirror moves noted as by side.

Tests: the coupler force of vehicles facing each other, the joint switch with an automatic pump, the lamps of
the main circuit, the horn and compressor pressures in bar.
This commit is contained in:
jerrrrycho
2026-10-17 17:15:28 +02:00
parent db220a1a98
commit 00805cfe77
9 changed files with 128 additions and 29 deletions

52
tests/unit/test_pumps.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
// the joint oil and fuel pump switch (MaSzyna-EU07/maszyna#81) works the pumps which aren't started automatically
namespace {
test::vehicle pumps_vehicle(std::string const &Fuelstart, std::string const &Oilstart) {
return test::vehicle{test::definition::load("wagon").set("Cntrl", "FuelStart", Fuelstart).set("Cntrl", "OilStart", Oilstart)};
}
// what the two-state joint switch does when pressed, as TTrain::OnCommand_oilfuelpumptoggle()
void press_joint_switch(test::vehicle &Vehicle) {
auto const enable{false == Vehicle->OilFuelPumpsEnabled()};
Vehicle->FuelPumpSwitch(enable, range_t::local);
Vehicle->FuelPumpSwitchOff(false == enable, range_t::local);
Vehicle->OilPumpSwitch(enable, range_t::local);
Vehicle->OilPumpSwitchOff(false == enable, range_t::local);
}
} // namespace
TEST_CASE("pumps: the joint switch turns both manual pumps on, then off") {
auto vehicle{pumps_vehicle("Manual", "Manual")};
REQUIRE_FALSE(vehicle->OilFuelPumpsEnabled());
press_joint_switch(vehicle);
CHECK(vehicle->FuelPump.is_enabled);
CHECK(vehicle->OilPump.is_enabled);
CHECK(vehicle->OilFuelPumpsEnabled());
press_joint_switch(vehicle);
CHECK_FALSE(vehicle->FuelPump.is_enabled);
CHECK_FALSE(vehicle->OilPump.is_enabled);
}
TEST_CASE("pumps: with one pump started automatically the joint switch still turns the other one off") {
auto vehicle{pumps_vehicle("Manual", "Automatic")};
press_joint_switch(vehicle);
REQUIRE(vehicle->FuelPump.is_enabled);
CHECK(vehicle->OilFuelPumpsEnabled()); // the switch shows on
press_joint_switch(vehicle);
CHECK_FALSE(vehicle->FuelPump.is_enabled);
}
TEST_CASE("pumps: with one manual pump on and the other off the joint switch turns both on") {
auto vehicle{pumps_vehicle("Manual", "Manual")};
vehicle->FuelPumpSwitch(true, range_t::local);
REQUIRE_FALSE(vehicle->OilFuelPumpsEnabled());
press_joint_switch(vehicle);
CHECK(vehicle->FuelPump.is_enabled);
CHECK(vehicle->OilPump.is_enabled);
}