18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 12:57:06 +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
+16 -17
View File
@@ -49,9 +49,9 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
Sand = SandCapacity;
// NOTE: for diesel-powered vehicles we automatically convert legacy "main" power source to more accurate "engine"
if (air.compressor.supply == CompressorSupply::mainCircuit && (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric))
if (air.compressor.config.supply == CompressorSupply::mainCircuit && (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric))
{
air.compressor.supply = CompressorSupply::engine;
air.compressor.config.supply = CompressorSupply::engine;
}
// for these engine types secondary controller positions index MotorParam table
@@ -96,8 +96,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
// set default wiper switch position
wiperSwitchPos = WiperDefaultPos;
if (air.compressor.listPositions > 0)
air.compressor.listPosition = air.compressor.listDefaultPosition;
air.compressor.ResetListPosition();
// the genset of a dual-mode vehicle is a second source of the traction circuit of an induction motor vehicle
if (Genset.fitted() && (EngineType != TEngineType::ElectricInductionMotor || EnginePowerSource.SourceType != TPowerSource::CurrentCollector))
@@ -134,14 +133,14 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
if (brakes.independentValveType == TBrakeHandle::Knorr)
brakes.independentPosition = 0.5;
brakePipe.reservoir->CreatePress(brakePipe.pressure);
mainPipe.reservoir->CreatePress(mainPipe.pressure);
brakePipe.reservoir->CreatePress(brakePipe.Pressure());
mainPipe.reservoir->CreatePress(mainPipe.Pressure());
brakePipe.reservoir->Act();
mainPipe.reservoir->Act();
brakes.equivalentPipePressure = brakePipe.pressure;
brakes.equivalentPipePressure = brakePipe.Pressure();
brakes.driverValve->Init(brakePipe.pressure);
brakes.driverValve->Init(brakePipe.Pressure());
ComputeConstans();
@@ -188,7 +187,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
brakes.delays[b] = brakes.delays[b] * (2.5 + Random(0.0, 0.2)) / 3.0;
}
brakes.distributor->Init(brakePipe.pressure, brakes.pipeHighPressure, brakes.pipeLowPressure, brakes.cylinderPressure, brakes.delaySetting);
brakes.distributor->Init(brakePipe.Pressure(), brakes.pipeHighPressure, brakes.pipeLowPressure, brakes.cylinderPressure, brakes.delaySetting);
/*
ScndPipePress = Compressor;
*/
@@ -406,9 +405,9 @@ void physics::Vehicle::CreateBrakePipes()
// the pressure of the main pipe at the start: the main reservoir's, or HosePressure fed through a main hose, or none
double physics::Vehicle::InitialScndPipePress(double const HosePressure) const
{
if (air.mainReservoirVolume > 0.0)
if (air.config.mainReservoirVolume > 0.0)
{
return air.compressedVolume / air.mainReservoirVolume;
return air.CompressedVolume() / air.config.mainReservoirVolume;
}
if (Couplers[VehicleEnd::front].AllowedFlag.HasAny(Coupling::mainHose) || Couplers[VehicleEnd::rear].AllowedFlag.HasAny(Coupling::mainHose))
{
@@ -421,9 +420,9 @@ double physics::Vehicle::InitialScndPipePress(double const HosePressure) const
void physics::Vehicle::SetReadyToDepart()
{
WriteLog("Ready to depart");
air.compressedVolume = air.mainReservoirVolume * air.compressor.minPressure * 9.8 / 10.0;
mainPipe.pressure = InitialScndPipePress(5.0);
brakePipe.pressure = brakes.controlReservoirPressure;
air.Fill(air.config.mainReservoirVolume * air.compressor.config.minPressure * 9.8 / 10.0);
mainPipe.SetPressure(InitialScndPipePress(5.0));
brakePipe.SetPressure(brakes.controlReservoirPressure);
brakes.cylinderPressure = 0.0;
brakes.independentPosition = 0.0;
if (CabActive == 0)
@@ -449,12 +448,12 @@ void physics::Vehicle::SetBraked()
{
WriteLog("Braked");
brakes.reservoirAir = brakes.valveVolume * brakes.maxCylinderPressure[3];
air.compressedVolume = air.mainReservoirVolume * air.compressor.minPressure * 0.55;
air.Fill(air.config.mainReservoirVolume * air.compressor.config.minPressure * 0.55);
/*
ScndPipePress = 5.1;
*/
mainPipe.pressure = InitialScndPipePress(5.1);
brakePipe.pressure = brakes.pipeLowPressure;
mainPipe.SetPressure(InitialScndPipePress(5.1));
brakePipe.SetPressure(brakes.pipeLowPressure);
brakes.pipeCylinderPressure = brakes.maxCylinderPressure[3] * 0.5;
brakes.cylinderPressure = brakes.maxCylinderPressure[3] * 0.5;
brakes.independentPosition = 0.0;