18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 18:47:06 +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
+14 -14
View File
@@ -89,7 +89,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->lowVoltage.batteryStart != start_t::manual || occupied->lowVoltage.power24vAvailable == true; } );
return occupied->lowVoltage.config.batteryStart != start_t::manual || occupied->lowVoltage.Is24vAvailable() == true; } );
break;
}
case driver_hint::batteryoff: {
@@ -100,12 +100,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->lowVoltage.batteryStart != start_t::manual || occupied->lowVoltage.power24vAvailable == false; } );
return occupied->lowVoltage.config.batteryStart != start_t::manual || occupied->lowVoltage.Is24vAvailable() == false; } );
break;
}
// battery
case driver_hint::cabactivation: {
if (AIControllFlag && occupied->lowVoltage.power24vAvailable) {
if (AIControllFlag && occupied->lowVoltage.Is24vAvailable()) {
occupied->CabActivisation();
CheckVehicles();
}
@@ -224,46 +224,46 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// pantographs
case driver_hint::pantographairsourcesetmain: {
if( AIControllFlag ) {
pantographUnit->pantographAir.connectedToMainReservoir = true;
pantographUnit->pantographAir.ConnectToMainReservoir(true);
}
remove_hint( driver_hint::pantographairsourcesetauxiliary );
hint(
Action,
[this](float const /*Parameter*/) {
return pantographUnit->pantographAir.connectedToMainReservoir == true; } );
return pantographUnit->pantographAir.IsConnectedToMainReservoir() == true; } );
break;
}
case driver_hint::pantographairsourcesetauxiliary: {
if( AIControllFlag ) {
pantographUnit->pantographAir.connectedToMainReservoir = false;
pantographUnit->pantographAir.ConnectToMainReservoir(false);
}
remove_hint( driver_hint::pantographcompressoron );
hint(
Action,
[this](float const /*Parameter*/) {
return pantographUnit->pantographAir.connectedToMainReservoir == false; } );
return pantographUnit->pantographAir.IsConnectedToMainReservoir() == false; } );
break;
}
case driver_hint::pantographcompressoron: {
if( AIControllFlag ) {
pantographUnit->pantographAir.compressorRunning = true;
pantographUnit->pantographAir.SwitchCompressor(true);
}
remove_hint( driver_hint::pantographcompressoroff );
hint(
Action,
[this](float const /*Parameter*/) {
return pantographUnit->pantographAir.compressorRunning == true; } );
return pantographUnit->pantographAir.IsCompressorRunning() == true; } );
break;
}
case driver_hint::pantographcompressoroff: {
if( AIControllFlag ) {
pantographUnit->pantographAir.compressorRunning = false;
pantographUnit->pantographAir.SwitchCompressor(false);
}
remove_hint( driver_hint::pantographcompressoron );
hint(
Action,
[this](float const /*Parameter*/) {
return pantographUnit->pantographAir.compressorRunning == false; } );
return pantographUnit->pantographAir.IsCompressorRunning() == false; } );
break;
}
case driver_hint::pantographsvalveon: {
@@ -760,7 +760,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return pantographUnit->pantographAir.pressure >= (is_emu() ? (pantographUnit->pantographAir.pressureLockActive ? 4.6 : 2.6) : 4.2); } );
return pantographUnit->pantographAir.Pressure() >= (is_emu() ? (pantographUnit->pantographAir.IsPressureLockActive() ? 4.6 : 2.6) : 4.2); } );
break;
}
case driver_hint::waitbrakecharge: {
@@ -1218,7 +1218,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->trainHeating.allow == true; } );
return occupied->trainHeating.IsAllowed() == true; } );
break;
}
case driver_hint::consistheatingoff: {
@@ -1229,7 +1229,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
hint(
Action,
[this](float const /*Parameter*/) {
return occupied->trainHeating.allow == false; } );
return occupied->trainHeating.IsAllowed() == false; } );
break;
}