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

refactor(physics): the low voltage, the train heating and the pantographs keep their state to themselves

As the parts of the main circuit: the battery and the low voltage circuits,
the train heating, the circuit of the pantographs and their air become classes
with the definition in `config` and the state behind queries and operations.

The step of the air of the pantographs (the small compressor, the three-way
cock, the leaks, the pressure switch) moves into PantographAir::Update(), which
gets what it needs as plain values (PantographAirSupply) and reports a trip of
the pressure switch, so the vehicle opens its line breaker or switches the
converter of a unit off as before. The drain of the battery and its limits move
into LowVoltageSupply. The latch of the held battery button of the cab moves
from the physics to TTrain, where the button is.

The gauges of the cab bind to the values they show through const pointers
(TGauge::Assign*() take them), so the queries they bind to return const
references and the cab reads the state live without being able to change it.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 10:08:54 +01:00
parent 22ebc41d70
commit 160ffe2147
63 changed files with 746 additions and 561 deletions
+5 -5
View File
@@ -89,7 +89,7 @@ TEST_CASE("compressor: a compressor fed from the low voltage waits from the low
run_compressor(vehicle, 10.0);
REQUIRE_FALSE(vehicle->air.compressor.running);
vehicle->lowVoltage.power110vAvailable = true;
vehicle->lowVoltage.Set110vAvailableForTest(true);
run_compressor(vehicle, 4.9);
CHECK_FALSE(vehicle->air.compressor.running);
run_compressor(vehicle, 0.2);
@@ -178,15 +178,15 @@ TEST_CASE("compressor: fed from the converter it waits for the converter start d
REQUIRE(loco->converter.config.startDelay == doctest::Approx(30.0));
loco.run(1.0); // engine off
CHECK_FALSE(loco->lowVoltage.power110vAvailable);
CHECK_FALSE(loco->lowVoltage.Is110vAvailable());
loco->lineBreaker.Close(); // engine started
loco.run(25.0);
CHECK_FALSE(loco->lowVoltage.power110vAvailable);
CHECK_FALSE(loco->lowVoltage.Is110vAvailable());
CHECK_FALSE(loco->air.compressor.running);
loco.run(10.0);
CHECK(loco->lowVoltage.power110vAvailable);
CHECK(loco->lowVoltage.Is110vAvailable());
CHECK(loco->air.compressor.running);
}
@@ -197,7 +197,7 @@ TEST_CASE("compressor: fed from the converter the start delay counts from the co
loco.run(1.0); // engine off
loco->lineBreaker.Close(); // engine started
loco.run(25.0);
REQUIRE(loco->lowVoltage.power110vAvailable); // the converter is up
REQUIRE(loco->lowVoltage.Is110vAvailable()); // the converter is up
CHECK_FALSE(loco->air.compressor.running); // but the compressor waits for its own delay as well
loco.run(10.0);