18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 15:17:08 +01:00

refactor(physics): the compressed air supply and the pipes keep their state to themselves

The compressor, the main reservoir and the pipes along the train
(physics/components/airsupply.h) become classes, as the parts of the main
circuit: the definition in `config`, the state behind queries and operations.

The step of the compressor (the programmer of a unit, its supply and its start
delay, the governor and its lock, the venting over the top pressure) moves into
AirCompressor::Update(), with what it needs from the vehicle as plain values
(CompressorInputs); the vehicle follows the step up as before (the switching
delay, the counter of the debug panel, the sound of the relay). The leaks and
the pressure of the main reservoir move into AirSupply, and the reservoir is
filled and drawn through it.

The fault of the compressor the scenery can set no longer adds 100000001 to its
pressures from TDynamicObject::Damage(): AirCompressor::SetFault() does the same
arithmetic, so a fault behaves exactly as it did.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 10:14:37 +01:00
parent 160ffe2147
commit bc2af26dd5
60 changed files with 731 additions and 603 deletions
+13 -13
View File
@@ -61,7 +61,7 @@ struct elf {
}
test::release_brakes(cab());
recharge();
charged = cab().brakePipe.pressure > 4.5;
charged = cab().brakePipe.Pressure() > 4.5;
}
// the pipe charged again after an emergency stop: the Elf locks its emptied pipe off the brake handle (LPOn,
// LPOff) until the unlock button (UBB1, the first universal brake button) is held, the handle at running
@@ -105,7 +105,7 @@ TEST_CASE("elf controller: without EIMCtrlMainEmergency the positions stay as th
CHECK_FALSE(physics.IsMainCtrlEmergencyPos());
unit.wait(10.0);
CHECK(physics.eimic == doctest::Approx(-1.0));
CHECK(physics.brakePipe.pressure > 4.5);
CHECK(physics.brakePipe.Pressure() > 4.5);
}
TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the emergency brake one") {
@@ -127,14 +127,14 @@ TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the e
physics.MainCtrlPos = 1;
unit.wait(10.0);
CHECK(physics.eimic == doctest::Approx(-1.0));
CHECK(physics.brakePipe.pressure > 4.5);
CHECK(physics.brakePipe.Pressure() > 4.5);
}
SUBCASE("the braking position, formerly 1, ramps the braking up") {
physics.MainCtrlPos = 2;
unit.wait(1.0);
CHECK(physics.eimic < 0.0);
CHECK(physics.eimic > -1.0);
CHECK(physics.brakePipe.pressure > 4.5);
CHECK(physics.brakePipe.Pressure() > 4.5);
}
SUBCASE("the emergency brake position brakes fully at once and empties the pipe") {
physics.MainCtrlPos = 0;
@@ -143,13 +143,13 @@ TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the e
unit.unit.step(unit.line);
CHECK(physics.eimic == doctest::Approx(-1.0));
unit.wait(10.0);
CHECK(physics.brakePipe.pressure < 0.5);
CHECK(physics.brakePipe.Pressure() < 0.5);
CHECK(physics.brakes.cylinderPressure > 1.0);
// out of it the pipe charges again
physics.MainCtrlPos = physics.MainCtrlNoPowerPos();
CHECK_FALSE(physics.IsMainCtrlEmergencyPos());
unit.recharge();
CHECK(physics.brakePipe.pressure > 4.5);
CHECK(physics.brakePipe.Pressure() > 4.5);
}
}
@@ -195,8 +195,8 @@ TEST_CASE("elf controller: the emergency brake position vents the pipe only from
CHECK(rear.IsMainCtrlEmergencyPos());
CHECK_FALSE(rear.IsCabMaster());
unit.wait(10.0);
CHECK(unit.cab().brakePipe.pressure > 4.5);
CHECK(rear.brakePipe.pressure > 4.5);
CHECK(unit.cab().brakePipe.Pressure() > 4.5);
CHECK(rear.brakePipe.Pressure() > 4.5);
}
TEST_CASE("elf controller: an Elf with the emergency brake position leading one without it") {
@@ -217,15 +217,15 @@ TEST_CASE("elf controller: an Elf with the emergency brake position leading one
unit.set_controller(1);
CHECK(other.MainCtrlPos == 0);
unit.wait(10.0);
CHECK(lead.brakePipe.pressure > 4.5);
CHECK(lead.brakePipe.Pressure() > 4.5);
}
SUBCASE("the emergency brake: the other one at its full braking, the pipe vented by the lead") {
unit.set_controller(0);
REQUIRE(lead.IsMainCtrlEmergencyPos());
CHECK(other.MainCtrlPos == 0);
unit.wait(10.0);
CHECK(lead.brakePipe.pressure < 0.5);
CHECK(other.brakePipe.pressure < 0.5);
CHECK(lead.brakePipe.Pressure() < 0.5);
CHECK(other.brakePipe.Pressure() < 0.5);
}
}
@@ -247,8 +247,8 @@ TEST_CASE("elf controller: an Elf without the emergency brake position leading o
CHECK(other.MainCtrlPos == 1);
CHECK_FALSE(other.IsMainCtrlEmergencyPos());
unit.wait(10.0);
CHECK(lead.brakePipe.pressure > 4.5);
CHECK(other.brakePipe.pressure > 4.5);
CHECK(lead.brakePipe.Pressure() > 4.5);
CHECK(other.brakePipe.Pressure() > 4.5);
}
}