From bc2af26dd51179f6553e60569d1c4e93c88a4b89 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 10:14:37 +0100 Subject: [PATCH] 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. --- application/driverhints.cpp | 2 +- application/driveruipanels.cpp | 16 +- input/messaging.cpp | 8 +- physics/components/airsupply.h | 312 ++++++++++++++++-- physics/components/body.cpp | 22 +- physics/components/cab.cpp | 8 +- physics/components/commands.cpp | 2 +- physics/components/controllers.cpp | 4 +- physics/components/drive.cpp | 2 +- physics/components/electrics.cpp | 2 +- physics/components/fizparser.cpp | 2 +- physics/components/fizsections.cpp | 46 +-- physics/components/pneumatics.cpp | 278 ++++++---------- physics/components/setup.cpp | 33 +- physics/components/traction.cpp | 2 +- physics/vehicle.h | 4 +- simulation/blackboxrecorder.cpp | 8 +- simulation/simulation.cpp | 2 +- tests/unit/consist.cpp | 2 +- tests/unit/drive.cpp | 6 +- tests/unit/figures.cpp | 2 +- tests/unit/golden.cpp | 18 +- tests/unit/invariants.cpp | 16 +- tests/unit/test_brake_handles.cpp | 18 +- tests/unit/test_brake_pipe.cpp | 10 +- tests/unit/test_brakes.cpp | 4 +- tests/unit/test_cab.cpp | 8 +- tests/unit/test_camshaft.cpp | 2 +- tests/unit/test_commands.cpp | 8 +- tests/unit/test_compressor.cpp | 68 ++-- tests/unit/test_controls.cpp | 16 +- tests/unit/test_crew.cpp | 4 +- tests/unit/test_definition.cpp | 36 +- tests/unit/test_dynamic_brake_diesel.cpp | 2 +- tests/unit/test_elf_controller.cpp | 26 +- tests/unit/test_feed_pipe.cpp | 24 +- tests/unit/test_figures.cpp | 8 +- tests/unit/test_genset.cpp | 2 +- tests/unit/test_horn.cpp | 24 +- tests/unit/test_line_contactors.cpp | 2 +- tests/unit/test_line_contactors_interlock.cpp | 12 +- tests/unit/test_mains_before_pantographs.cpp | 24 +- tests/unit/test_pressure_switch.cpp | 18 +- tests/unit/test_pullee.cpp | 24 +- tests/unit/vehicle.cpp | 8 +- vehicle/ai/consist.cpp | 24 +- vehicle/ai/engine.cpp | 6 +- vehicle/ai/force.cpp | 8 +- vehicle/ai/physicslog.cpp | 4 +- vehicle/ai/situation.cpp | 2 +- vehicle/cab/auxiliarycommands.cpp | 40 +-- vehicle/cab/setup.cpp | 12 +- vehicle/cab/train.cpp | 10 +- vehicle/cab/update.cpp | 30 +- vehicle/dynamic/consist.cpp | 6 +- vehicle/dynamic/lifecycle.cpp | 6 +- vehicle/dynamic/sounds.cpp | 10 +- vehicle/dynamic/update.cpp | 15 +- vehicle/dynamic/vehicletable.cpp | 6 +- widgets/vehicleparams.cpp | 10 +- 60 files changed, 731 insertions(+), 603 deletions(-) diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 7336b18dd..d84e663df 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -752,7 +752,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->mainPipe.pressure > 4.5 || mvControlling->air.mainReservoirVolume == 0.0; } ); + return mvControlling->mainPipe.Pressure() > 4.5 || mvControlling->air.config.mainReservoirVolume == 0.0; } ); break; } case driver_hint::waitpantographpressuretoolow: { diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 6ddc9aa4f..6533dcbbc 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -150,7 +150,7 @@ drivingaid_panel::update() { m_buffer.data(), m_buffer.size(), STR_C(" Pressure: %.2f kPa (train pipe: %.2f kPa)"), physics->brakes.cylinderPressure * 100, - physics->brakePipe.pressure * 100 ); + physics->brakePipe.Pressure() * 100 ); expandedtext = m_buffer.data(); } if( readout.ed_percent ) { @@ -849,11 +849,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.converter.IsAllowed() ? 'x' : '.', physics.converter.IsOverloaded() ? '!' : '.', - physics.air.compressor.running ? 'C' : - false == physics.air.compressor.allowLocal ? '-' : - physics.air.compressor.allow || (physics.air.compressor.start == start_t::automatic && physics.air.compressor.speed > 0.0) ? 'c' : + physics.air.compressor.IsRunning() ? 'C' : + false == physics.air.compressor.LocalSwitchOn() ? '-' : + physics.air.compressor.IsAllowed() || (physics.air.compressor.config.start == start_t::automatic && physics.air.compressor.config.speed > 0.0) ? 'c' : '.', - physics.air.compressor.governorLock ? '!' : '.', + physics.air.compressor.IsGovernorLocked() ? '!' : '.', physics.lineContactors.IsForcedOpen() ? '-' : physics.protection.PressureSwitchTripped() ? '!' : physics.lineContactors.IsClosed() ? '+' : @@ -936,13 +936,13 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.brakes.independentCylinderPressure, physics.brakes.distributor->GetBrakeStatus(), // pipes - physics.brakePipe.pressure, + physics.brakePipe.Pressure(), physics.brakes.handleCapPosition, - physics.mainPipe.pressure, + physics.mainPipe.Pressure(), physics.brakes.controlReservoirPressure, // tanks physics.brakes.distributor->GetBRP(), - physics.air.mainReservoirPressure, + physics.air.MainReservoirPressure(), physics.brakes.distributor->GetCRP() ); textline = m_buffer.data(); diff --git a/input/messaging.cpp b/input/messaging.cpp index e58483baa..8e4b6829c 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -284,10 +284,10 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) r.fPar[9] = Vehicle->physics->AccN; // przyspieszenie Y //na razie nie r.fPar[10] = Vehicle->physics->AccVert; // przyspieszenie Z r.fPar[11] = Vehicle->physics->DistCounter; // przejechana odległość w km - r.fPar[12] = Vehicle->physics->brakePipe.pressure; // ciśnienie w PG - r.fPar[13] = Vehicle->physics->mainPipe.pressure; // ciśnienie w PZ + r.fPar[12] = Vehicle->physics->brakePipe.Pressure(); // ciśnienie w PG + r.fPar[13] = Vehicle->physics->mainPipe.Pressure(); // ciśnienie w PZ r.fPar[14] = Vehicle->physics->brakes.cylinderPressure; // ciśnienie w CH - r.fPar[15] = Vehicle->physics->air.mainReservoirPressure; // ciśnienie w ZG + r.fPar[15] = Vehicle->physics->air.MainReservoirPressure(); // ciśnienie w ZG r.fPar[16] = Vehicle->physics->Itot; // Prąd całkowity r.iPar[17] = Vehicle->physics->MainCtrlPos; // Pozycja NJ r.iPar[18] = Vehicle->physics->ScndCtrlPos; // Pozycja NB @@ -296,7 +296,7 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) r.iPar[21] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania r.iPar[22] = Vehicle->physics->ResistorsFlag * 1 + Vehicle->physics->converter.IsRunning() * 2 - + Vehicle->physics->air.compressor.running * 4 + + Vehicle->physics->air.compressor.IsRunning() * 4 + Vehicle->physics->lineBreaker.IsClosed() * 8 #ifdef EU07_USEOLDDOORCODE + Vehicle->physics->DoorLeftOpened * 16 diff --git a/physics/components/airsupply.h b/physics/components/airsupply.h index d81fc3e29..6a034f776 100644 --- a/physics/components/airsupply.h +++ b/physics/components/airsupply.h @@ -8,10 +8,12 @@ http://mozilla.org/MPL/2.0/. */ // the supply of compressed air of a vehicle: the compressor and the main reservoir, held by physics::Vehicle as air; and -// the pipes along the train, held by it as brakePipe and mainPipe +// the pipes along the train, held by it as brakePipe and mainPipe. as the parts of the main circuit (maincircuit.h): the +// definition in `config`, the state behind queries and operations #pragma once +#include #include #include @@ -23,11 +25,23 @@ namespace physics { // a pipe along the train, coupled by the hoses between the vehicles: the brake pipe, the main reservoir pipe -struct TrainPipe +class TrainPipe { + public: std::shared_ptr reservoir; - double pressure = 0.0; - bool couplersPending{false}; // the pipe stepped, its exchange of air through the hoses is yet to come (UpdatePipeCouplers()) + + // the pressure in the pipe [bar], as it was last taken from its reservoir + double const &Pressure() const { return pressure; } + // the pressure taken from the reservoir of the pipe, after the flows of a step + void SetPressure(double const Pressure) { pressure = Pressure; } + + // the pipe stepped, its exchange of air through the hoses is yet to come (UpdatePipeCouplers()) + bool CouplersPending() const { return couplersPending; } + void SetCouplersPending(bool const State) { couplersPending = State; } + + private: + double pressure{0.0}; + bool couplersPending{false}; }; // where the compressor gets its power from (CompressorPower of the .fiz), in the order of the numbers it had before @@ -41,44 +55,272 @@ enum class CompressorSupply rearUnitConverter, // Coupler2: from the converter of the unit behind }; -// the compressor of the main reservoir -struct AirCompressor +// what the compressor needs to know in the step +struct CompressorInputs { - // the definition (the Brake section of the .fiz) - double minPressure = 0.0; // MinCP: it starts below this pressure of the main reservoir - double maxPressure = 0.0; // MaxCP: it stops above this pressure - double minPressureCabA = 0.0; // the pressures of each cab, where they differ (MinCP_B, MaxCP_B given) - double maxPressureCabA = 0.0; - double minPressureCabB = 0.0; // MinCP_B - double maxPressureCabB = 0.0; // MaxCP_B - bool cabDependent = false; // the pressures follow the occupied cab - double speed = 0.0; // CompressorSpeed: how fast it fills the main reservoir - CompressorSupply supply{CompressorSupply::converterManual}; // CompressorPower - double startDelay{0.0}; // CompressorStartDelay: how long it waits after getting its power before it can start, after the engine starts say [s] - bool tankValve{false}; // CompressorTankValve: the pressure over the top is let out of its tank at once - start_t start{start_t::manual}; // CompressorStart: whether it is started by hand, or another way - // the programmer of the compressors of a unit (the CompressorList section), indexed by the cl_* rows - std::array, 4> list{}; - int listPositions = 0; // Size: the positions of its switch - int listDefaultPosition = 1; // Default - bool listWraps = false; // Wrap - // the state - bool running = false; // it runs - bool allow = false; // it may start - bool allowLocal{true}; // the switch of the vehicle itself; most have none, so it allows - bool governorLock{false}; // the governor switched it off at the cut-out pressure + bool converterAllowed{false}; // the converter of the vehicle may run + bool mainCircuitPowered{false}; // the main circuit has its power + bool lowVoltage110v{false}; // the 110 V circuit has its power + bool coupledGovernorLock{false}; // a vehicle coupled permanently has its compressor stopped by the governor + bool switchingDelayPassed{false}; // the vehicle may switch something on again (LastSwitchingTime > CtrlDelay) + double engineRpmRatio{0.0}; // the revolutions of the engine against the most at its position, for a compressor it drives +}; + +// what the step of the compressor did, for the vehicle to follow it up +struct CompressorStep +{ + bool switched{false}; // it started or stopped + bool vented{false}; // the reservoir let air out over the top pressure +}; + +// the compressor of the main reservoir +class AirCompressor +{ + public: + struct Config + { + // the definition (the Brake section of the .fiz). where the pressures follow the occupied cab (cabDependent) the + // compressor sets minPressure and maxPressure to those of the cab in each step + double minPressure{0.0}; // MinCP: it starts below this pressure of the main reservoir + double maxPressure{0.0}; // MaxCP: it stops above this pressure + double minPressureCabA{0.0}; // the pressures of each cab, where they differ (MinCP_B, MaxCP_B given) + double maxPressureCabA{0.0}; + double minPressureCabB{0.0}; // MinCP_B + double maxPressureCabB{0.0}; // MaxCP_B + bool cabDependent{false}; // the pressures follow the occupied cab + double speed{0.0}; // CompressorSpeed: how fast it fills the main reservoir + CompressorSupply supply{CompressorSupply::converterManual}; // CompressorPower + double startDelay{0.0}; // CompressorStartDelay: how long it waits after getting its power before it can start, after the engine starts say [s] + bool tankValve{false}; // CompressorTankValve: the pressure over the top is let out of its tank at once + start_t start{start_t::manual}; // CompressorStart: whether it is started by hand, or another way + // the programmer of the compressors of a unit (the CompressorList section), indexed by the cl_* rows + std::array, 4> list{}; + int listPositions{0}; // Size: the positions of its switch + int listDefaultPosition{1}; // Default + bool listWraps{false}; // Wrap + }; + Config config; + + // a compressor of no output doesn't count + bool IsFitted() const { return config.speed != 0.0; } + bool IsRunning() const { return running; } + void Stop() { running = false; } + + // it may start, as its switch (or what drives it) has it + bool IsAllowed() const { return allow; } + void Allow(bool const State) { allow = State; } + // the switch of the vehicle itself; most have none, so it allows + bool LocalSwitchOn() const { return allowLocal; } + void SetLocalSwitch(bool const State) { allowLocal = State; } + // the governor switched it off at the cut-out pressure + bool IsGovernorLocked() const { return governorLock; } + + // the position of the switch of the programmer + int ListPosition() const { return listPosition; } + void SetListPosition(int const Position) { listPosition = std::min(std::max(Position, 0), config.listPositions); } + // the programmer at its default position, as the vehicle is placed + void ResetListPosition() + { + if (config.listPositions > 0) + { + listPosition = config.listDefaultPosition; + } + } + + // the pressures of the occupied cab, where they follow it + void SelectCab(int const Cab) + { + if (false == config.cabDependent) + { + return; + } + if (Cab > 0) + { + config.minPressure = config.minPressureCabA; + config.maxPressure = config.maxPressureCabA; + } + if (Cab < 0) + { + config.minPressure = config.minPressureCabB; + config.maxPressure = config.maxPressureCabB; + } + } + + // the fault the scenery can set (the damage events): its pressures moved out of reach, so it never starts; and back + void SetFault(bool const State) + { + constexpr double faultoffset{100000001}; + if (State) + { + if (config.minPressure > 0) + config.minPressure -= faultoffset; + if (config.maxPressure > 0) + config.maxPressure -= faultoffset; + } + else + { + if (config.minPressure < 0) + config.minPressure += faultoffset; + if (config.maxPressure < 0) + config.maxPressure += faultoffset; + } + } + + // the step of the compressor, which works the reservoir of the given volume of compressed air at the given pressure + CompressorStep Update(CompressorInputs const &Inputs, double &CompressedVolume, double const ReservoirPressure, double const dt) + { + CompressorStep step; + // assorted operational logic + auto const maxpressure{config.list[cl_MaxFactor][listPosition] * config.maxPressure}; + auto const minpressure{config.list[cl_MinFactor][listPosition] * config.minPressure}; + auto const speed{config.list[cl_SpeedFactor][listPosition] * config.speed}; + // checking the impact on the compressor allowance + if (auto const allowfactor{config.list[cl_Allow][listPosition]}; allowfactor > 0.5) + { + allow = allowfactor > 1.5; + } + switch (config.supply) + { + case CompressorSupply::converter: + allow = Inputs.converterAllowed; + break; + case CompressorSupply::engine: + // HACK: make sure compressor coupled with diesel engine is always ready for work + config.start = start_t::automatic; + break; + default: + break; + } + + // the main circuit, also for a compressor driven by the engine, otherwise the low voltage + auto const power{config.supply == CompressorSupply::mainCircuit || config.supply == CompressorSupply::engine ? Inputs.mainCircuitPowered : Inputs.lowVoltage110v}; + powerTime = power ? powerTime + dt : 0.0; + auto const ready{power && powerTime >= config.startDelay}; + // TBD: split CompressorAllow into separate enable/disable flags, inherit compressor from basic_device + auto const enable{allowLocal && (config.start == start_t::automatic || allow)}; + + auto const pressuretoolow{ReservoirPressure < minpressure}; + auto const pressuretoohigh{ReservoirPressure > maxpressure}; + + // TBD, TODO: break the lock with no low voltage power? + auto const governorlockpresent{maxpressure - minpressure > 0.0001}; + governorLock = governorlockpresent && false == pressuretoolow // unlock if pressure drops below minimal threshold + && (pressuretoohigh || governorLock); // lock if pressure goes above maximum threshold + // for these multi-unit engines compressors turn off whenever any of them was affected by the governor + // NOTE: this is crude implementation, limited only to adjacent vehicles + // TODO: re-implement when a more elegant/flexible system is in place + auto const locked{governorLock || Inputs.coupledGovernorLock}; + + auto const wasrunning{running}; + running = ready && enable && (false == locked || config.supply == CompressorSupply::engine) && (running || (enable && Inputs.switchingDelayPassed)); + step.switched = running != wasrunning; + + if (false == running) + { + return step; + } + + // working compressor adds air to the air reservoir + if (config.supply == CompressorSupply::engine) + { + // the compressor is coupled with the diesel engine, engine revolutions affect the output + CompressedVolume += speed * (2.0 * maxpressure - ReservoirPressure) / maxpressure * Inputs.engineRpmRatio * dt * (governorLock ? 0.0 : 1.0); // with the lock active air is vented out + } + else + { + // the compressor is a stand-alone device, working at steady pace + CompressedVolume += speed * (2.0 * maxpressure - ReservoirPressure) / maxpressure * dt; + } + + if (pressuretoohigh && (false == governorlockpresent || config.supply == CompressorSupply::engine)) + { + // vent some air out if there's no governor lock to stop the compressor from exceeding acceptable pressure level + step.vented = true; + auto ventedfraction{0.999}; // HACK: drop a tiny bit so the sound doesn't trigger repeatedly + if (false == governorlockpresent) + { + ventedfraction = 0.80; // arbitrary amount + } + else if (config.tankValve) + { + ventedfraction = minpressure / maxpressure; // drop to mincompressor level + } + CompressedVolume *= ventedfraction; + if (false == governorlockpresent || config.tankValve) + { + governorLock = false; + } + } + return step; + } + + private: + bool running{false}; + bool allow{false}; + bool allowLocal{true}; + bool governorLock{false}; double powerTime{0.0}; // how long it has had its power [s] - int listPosition = 0; // the position of the switch of the programmer + int listPosition{0}; }; // the supply of compressed air -struct AirSupply +class AirSupply { + public: + struct Config + { + double mainReservoirVolume{0.0}; // Vv: the volume of the main reservoir + double leakRate{0.01}; // AirLeakRate: the base rate of the air leaking from the components of the brakes (0.001 = 1 l/s) + }; + Config config; + AirCompressor compressor; - double mainReservoirVolume = 0.0; // Vv: the volume of the main reservoir - double mainReservoirPressure = 0.0; // the pressure in the main reservoir - double compressedVolume = 0.0; // the compressed air in the supply - double leakRate{0.01}; // AirLeakRate: the base rate of the air leaking from the components of the brakes (0.001 = 1 l/s) + + // the pressure in the main reservoir [bar], as the last step found it + double const &MainReservoirPressure() const { return mainReservoirPressure; } + // the pressure taken from the air in the reservoir; an empty one of no volume has none, and stops the compressor + void UpdatePressure() + { + if (config.mainReservoirVolume > 0) + { + mainReservoirPressure = compressedVolume / config.mainReservoirVolume; + } + else + { + mainReservoirPressure = 0; + compressor.Stop(); + } + } + + // the compressed air in the supply + double CompressedVolume() const { return compressedVolume; } + // air let into the reservoir, or out of it with a negative volume + void AddAir(double const Volume) { compressedVolume += Volume; } + // the reservoir filled with the given volume of compressed air, as the vehicle is placed + void Fill(double const Volume) { compressedVolume = Volume; } + // no air below nothing + void ClampEmpty() + { + if (compressedVolume < 0.0) + { + compressedVolume = 0.0; + } + } + + // the step of the reservoir and its compressor: the leaks, then the compressor, which fills it + CompressorStep Update(CompressorInputs const &Inputs, double const dt) + { + compressedVolume = std::max(0.0, compressedVolume - dt * config.leakRate * 0.1); // nieszczelności: 0.001=1l/s + mainReservoirPressure = compressedVolume / config.mainReservoirVolume; + return compressor.Update(Inputs, compressedVolume, mainReservoirPressure, dt); + } + + // for the tests: the pressure in the reservoir as given, whatever its air + void SetPressureForTest(double const Pressure) { mainReservoirPressure = Pressure; } + + private: + double mainReservoirPressure{0.0}; + double compressedVolume{0.0}; }; } // namespace physics diff --git a/physics/components/body.cpp b/physics/components/body.cpp index 2e3c533d4..aa1d84224 100644 --- a/physics/components/body.cpp +++ b/physics/components/body.cpp @@ -91,13 +91,13 @@ physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, st for (int k = 0; k < 17; ++k) cablights[k] = 0; - for (auto &compressorrow : air.compressor.list) + for (auto &compressorrow : air.compressor.config.list) for (int k = 1; k < 9; ++k) compressorrow[k] = 0; - air.compressor.list[0][0] = 0.0; - air.compressor.list[1][0] = 1.0; - air.compressor.list[2][0] = 1.0; - air.compressor.list[3][0] = 1.0; + air.compressor.config.list[0][0] = 0.0; + air.compressor.config.list[1][0] = 1.0; + air.compressor.config.list[2][0] = 1.0; + air.compressor.config.list[3][0] = 1.0; for (int b = -1; b <= MainBrakeMaxPos; ++b) { @@ -474,14 +474,8 @@ void physics::Vehicle::compute_movement_(double const Deltatime) MotorBlowersCheck(Deltatime); // uklady hamulcowe: ConverterCheck(Deltatime); - if (air.mainReservoirVolume > 0) - air.mainReservoirPressure = air.compressedVolume / air.mainReservoirVolume; - else - { - air.mainReservoirPressure = 0; - air.compressor.running = false; - } - if (air.mainReservoirVolume > 0.0) + air.UpdatePressure(); + if (air.config.mainReservoirVolume > 0.0) { // sprężarka musi mieć jakąś niezerową wydajność żeby rozważać jej załączenie i pracę CompressorCheck(Deltatime); @@ -840,7 +834,7 @@ void physics::Vehicle::ComputeTotalForce(double dt) double old_nrot = abs(nrot); nrot = v2n(); // przeliczenie prędkości liniowej na obrotową - if (true == TestFlag(brakes.method, bp_MHS) && brakePipe.pressure < 3.0 // ustawione na sztywno na 3 bar + if (true == TestFlag(brakes.method, bp_MHS) && brakePipe.Pressure() < 3.0 // ustawione na sztywno na 3 bar && Vel > 45 && true == TestFlag(brakes.delaySetting, bdelay_M)) { // doliczenie hamowania hamulcem szynowym diff --git a/physics/components/cab.cpp b/physics/components/cab.cpp index ed68b611c..4ec0ad598 100644 --- a/physics/components/cab.cpp +++ b/physics/components/cab.cpp @@ -57,7 +57,7 @@ bool physics::Vehicle::ChangeCab(int direction) if (brakes.handlePositions > 0 && (brakes.kind == TBrakeSystem::Pneumatic || brakes.kind == TBrakeSystem::ElectroPneumatic)) { BrakeLevelSet(brakes.driverValve->GetPos(bh_NP)); - brakes.pipeLimiterPressure = brakePipe.pressure; + brakes.pipeLimiterPressure = brakePipe.Pressure(); ActFlowSpeed = 0; } else @@ -76,14 +76,14 @@ int physics::Vehicle::SoundingHorns(int const Signal) const { return lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable(); } - if (air.mainReservoirVolume > 0.0) + if (air.config.mainReservoirVolume > 0.0) { - return air.mainReservoirPressure >= HornMinPressure; + return air.MainReservoirPressure() >= HornMinPressure; } // a vehicle without a main reservoir of its own takes the air from the main pipe, a vehicle without either // (a road vehicle, say) has no air to check auto const mainpipe{(Couplers[VehicleEnd::front].AllowedFlag | Couplers[VehicleEnd::rear].AllowedFlag).HasAny(Coupling::mainHose)}; - return false == mainpipe || mainPipe.pressure >= HornMinPressure; + return false == mainpipe || mainPipe.Pressure() >= HornMinPressure; }}; auto horns{0}; if (supplied(HornSupply)) diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index 80b8c153d..44c87d814 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -389,7 +389,7 @@ bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, doubl } else if (Command == VehicleCommand::compressorPreset) { - air.compressor.listPosition = safe_clamp(static_cast(CValue1), 0, air.compressor.listPositions); + air.compressor.SetListPosition(static_cast(CValue1)); OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index 4016f25a9..df91588b2 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -894,7 +894,7 @@ bool physics::Vehicle::MotorConnectorsCheck() // hunter-111211: wylacznik cisnieniowy // (on some vehicles it watches the brake pipe alone) - protection.UpdatePressureSwitch(brakes.cylinderPressure, brakePipe.pressure); + protection.UpdatePressureSwitch(brakes.cylinderPressure, brakePipe.Pressure()); if (true == protection.PressureSwitchTripped()) { @@ -1253,7 +1253,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt) { SpeedCtrlUnit.Standby = false; } - if (!SpeedCtrlUnit.BrakeIntervention && (brakes.distributor->GetEDBCP() > 0.4 || brakePipe.pressure < brakes.pipeHighPressure - 0.2)) + if (!SpeedCtrlUnit.BrakeIntervention && (brakes.distributor->GetEDBCP() > 0.4 || brakePipe.Pressure() < brakes.pipeHighPressure - 0.2)) SpeedCtrlUnit.Standby = true; if (EIMCtrlType >= 3 && UniCtrlList[MainCtrlPos].SpeedUp <= 0) { diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index d11d02638..5ff81e000 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -385,7 +385,7 @@ public: { ++vehicle.MainCtrlPos; } - vehicle.air.compressor.allow = vehicle.MainCtrlPowerPos() > 0; + vehicle.air.compressor.Allow(vehicle.MainCtrlPowerPos() > 0); return true; } bool DecreaseMainController(physics::Vehicle &vehicle, int const speed) const override diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 09b9b3290..49c64167a 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -49,7 +49,7 @@ physics::PantographAirSupply physics::Vehicle::PantographAirSupplyNow() const // tylko jeśli pantografujący supply.collectors = EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0; supply.multipleUnit = TrainType == train_type::emu; - supply.mainReservoirPressure = mainPipe.pressure; + supply.mainReservoirPressure = mainPipe.Pressure(); supply.controlReservoirPressure = brakes.controlReservoirPressure; supply.maxPressure = EnginePowerSource.CollectorParameters.MaxPress; supply.minPressure = EnginePowerSource.CollectorParameters.MinPress; diff --git a/physics/components/fizparser.cpp b/physics/components/fizparser.cpp index ca86e3de5..debbeb149 100644 --- a/physics/components/fizparser.cpp +++ b/physics/components/fizparser.cpp @@ -546,7 +546,7 @@ bool physics::Vehicle::readCompressorList(std::string const &Input) return false; } // NOTE: content of slot [x][0] is hardcoded elsewhere - parser >> air.compressor.list[0][idx + 1] >> air.compressor.list[1][idx + 1] >> air.compressor.list[2][idx + 1] >> air.compressor.list[3][idx + 1]; + parser >> air.compressor.config.list[0][idx + 1] >> air.compressor.config.list[1][idx + 1] >> air.compressor.config.list[2][idx + 1] >> air.compressor.config.list[3][idx + 1]; return true; } diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index a4d346bfc..d86a04e80 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -291,16 +291,16 @@ void physics::Vehicle::LoadFIZ_Brake(std::string const &line) extract_value(brakes.pipeLowPressure, "LoPP", line, ""); brakes.pipePressureRange = brakes.pipeHighPressure - brakes.pipeLowPressure; - extract_value(air.mainReservoirVolume, "Vv", line, ""); + extract_value(air.config.mainReservoirVolume, "Vv", line, ""); /* if( VeselVolume == 0.0 ) { VeselVolume = 0.01; } */ - extract_value(air.compressor.minPressure, "MinCP", line, ""); - extract_value(air.compressor.maxPressure, "MaxCP", line, ""); - extract_value(air.compressor.minPressureCabB, "MinCP_B", line, ""); - extract_value(air.compressor.maxPressureCabB, "MaxCP_B", line, ""); - extract_value(air.compressor.tankValve, "CompressorTankValve", line, ""); - extract_value(air.compressor.speed, "CompressorSpeed", line, ""); + extract_value(air.compressor.config.minPressure, "MinCP", line, ""); + extract_value(air.compressor.config.maxPressure, "MaxCP", line, ""); + extract_value(air.compressor.config.minPressureCabB, "MinCP_B", line, ""); + extract_value(air.compressor.config.maxPressureCabB, "MaxCP_B", line, ""); + extract_value(air.compressor.config.tankValve, "CompressorTankValve", line, ""); + extract_value(air.compressor.config.speed, "CompressorSpeed", line, ""); extract_value(brakes.emergencyValve.offPressure, "MinEVP", line, ""); extract_value(brakes.emergencyValve.onPressure, "MaxEVP", line, ""); extract_value(brakes.emergencyValve.area, "EVArea", line, ""); @@ -322,35 +322,35 @@ void physics::Vehicle::LoadFIZ_Brake(std::string const &line) {"Coupler2", rearUnitConverter} // włączana w silnikowym EZT z tyłu }; auto lookup = compressorpowers.find(extract_value("CompressorPower", line)); - air.compressor.supply = lookup != compressorpowers.end() ? lookup->second : converterManual; + air.compressor.config.supply = lookup != compressorpowers.end() ? lookup->second : converterManual; } - extract_value(air.compressor.startDelay, "CompressorStartDelay", line, ""); + extract_value(air.compressor.config.startDelay, "CompressorStartDelay", line, ""); - if (true == extract_value(air.leakRate, "AirLeakRate", line, "")) + if (true == extract_value(air.config.leakRate, "AirLeakRate", line, "")) { // the parameter is provided in form of a multiplier, where 1.0 means the default rate of 0.01 - air.leakRate *= 0.01; + air.config.leakRate *= 0.01; } extract_value(ReleaserEnabledOnlyAtNoPowerPos, "ReleaserPowerPosLock", line, EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric ? "yes" : "no"); - if (air.compressor.minPressureCabB > 0.0) + if (air.compressor.config.minPressureCabB > 0.0) { - air.compressor.minPressureCabA = air.compressor.minPressure; - air.compressor.cabDependent = true; + air.compressor.config.minPressureCabA = air.compressor.config.minPressure; + air.compressor.config.cabDependent = true; } else { - air.compressor.minPressureCabB = air.compressor.minPressure; + air.compressor.config.minPressureCabB = air.compressor.config.minPressure; } - if (air.compressor.maxPressureCabB > 0.0) + if (air.compressor.config.maxPressureCabB > 0.0) { - air.compressor.maxPressureCabA = air.compressor.maxPressure; - air.compressor.cabDependent = true; + air.compressor.config.maxPressureCabA = air.compressor.config.maxPressure; + air.compressor.config.cabDependent = true; } else { - air.compressor.maxPressureCabB = air.compressor.maxPressure; + air.compressor.config.maxPressureCabB = air.compressor.config.maxPressure; } } @@ -933,7 +933,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // compressor { auto lookup = starts.find(extract_value("CompressorStart", line)); - air.compressor.start = lookup != starts.end() ? lookup->second : manual; + air.compressor.config.start = lookup != starts.end() ? lookup->second : manual; } // pantograph compressor { @@ -1669,9 +1669,9 @@ void physics::Vehicle::LoadFIZ_LightsList(std::string const &Input) void physics::Vehicle::LoadFIZ_CompressorList(std::string const &Input) { - extract_value(air.compressor.listPositions, "Size", Input, ""); - extract_value(air.compressor.listWraps, "Wrap", Input, ""); - extract_value(air.compressor.listDefaultPosition, "Default", Input, ""); + extract_value(air.compressor.config.listPositions, "Size", Input, ""); + extract_value(air.compressor.config.listWraps, "Wrap", Input, ""); + extract_value(air.compressor.config.listDefaultPosition, "Default", Input, ""); } void physics::Vehicle::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line) diff --git a/physics/components/pneumatics.cpp b/physics/components/pneumatics.cpp index 4156ec35e..3fc4ba6a0 100644 --- a/physics/components/pneumatics.cpp +++ b/physics/components/pneumatics.cpp @@ -189,7 +189,7 @@ double physics::Vehicle::RealPipeRatio(void) const double rpp; if (brakes.pipePressureRange > 0) - rpp = (brakes.controlReservoirPressure - brakePipe.pressure) / brakes.pipePressureRange; + rpp = (brakes.controlReservoirPressure - brakePipe.Pressure()) / brakes.pipePressureRange; else rpp = 0; return rpp; @@ -206,10 +206,10 @@ double physics::Vehicle::PipeRatio(void) const if (brakes.pipePressureRange > 0) if (false) // SPKS!! no to jak nie wchodzimy to po co branch? { - if (3.0 * brakePipe.pressure > brakes.pipeHighPressure + brakes.pipeLowPressure + brakes.pipeLowPressure) - pr = (brakes.pipeHighPressure - std::min(brakes.pipeHighPressure, brakePipe.pressure)) / (brakes.pipePressureRange * 4.0 / 3.0); + if (3.0 * brakePipe.Pressure() > brakes.pipeHighPressure + brakes.pipeLowPressure + brakes.pipeLowPressure) + pr = (brakes.pipeHighPressure - std::min(brakes.pipeHighPressure, brakePipe.Pressure())) / (brakes.pipePressureRange * 4.0 / 3.0); else - pr = (brakes.pipeHighPressure - 1.0 / 3.0 * brakes.pipePressureRange - std::max(brakes.pipeLowPressure, brakePipe.pressure)) / (brakes.pipePressureRange * 2.0 / 3.0); + pr = (brakes.pipeHighPressure - 1.0 / 3.0 * brakes.pipePressureRange - std::max(brakes.pipeLowPressure, brakePipe.Pressure())) / (brakes.pipePressureRange * 2.0 / 3.0); // if (not TestFlag(BrakeStatus, b_Ractive)) // and(BrakeMethod and 1 = 0) and TestFlag(BrakeDelays, bdelay_R) and (Power < 1) and // (BrakeCtrlPos < 1) then pr : = std::min(0.5, pr); @@ -217,7 +217,7 @@ double physics::Vehicle::PipeRatio(void) const // then pr : = pr * 1.333; // dziwny rapid wywalamy } else - pr = (brakes.pipeHighPressure - std::max(brakes.pipeLowPressure, std::min(brakes.pipeHighPressure, brakePipe.pressure))) / brakes.pipePressureRange; + pr = (brakes.pipeHighPressure - std::max(brakes.pipeLowPressure, std::min(brakes.pipeHighPressure, brakePipe.Pressure()))) / brakes.pipePressureRange; else pr = 0; return pr; @@ -308,17 +308,17 @@ bool physics::Vehicle::AntiSlippingButton(void) bool physics::Vehicle::CompressorSwitch(bool State, range_t const Notify) { - if (air.compressor.start != start_t::manual) + if (air.compressor.config.start != start_t::manual) { // only pay attention if the compressor can be controlled manually return false; } - auto const initialstate{air.compressor.allow}; + auto const initialstate{air.compressor.IsAllowed()}; - if (air.mainReservoirVolume > 0.0 && air.compressor.speed > 0.0) + if (air.config.mainReservoirVolume > 0.0 && air.compressor.config.speed > 0.0) { - air.compressor.allow = State; + air.compressor.Allow(State); } if (Notify != range_t::local) @@ -326,22 +326,22 @@ bool physics::Vehicle::CompressorSwitch(bool State, range_t const Notify) SendCtrlToNext(VehicleCommand::compressorSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return air.compressor.allow != initialstate; + return air.compressor.IsAllowed() != initialstate; } bool physics::Vehicle::ChangeCompressorPreset(int const State, range_t const Notify) { - auto const initialstate{air.compressor.listPosition}; + auto const initialstate{air.compressor.ListPosition()}; - air.compressor.listPosition = safe_clamp(State, 0, air.compressor.listPositions); + air.compressor.SetListPosition(State); if (Notify != range_t::local) { SendCtrlToNext(VehicleCommand::compressorPreset, State, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return air.compressor.listPosition != initialstate; + return air.compressor.ListPosition() != initialstate; } // ************************************************************************************************* @@ -360,7 +360,7 @@ bool physics::Vehicle::IncBrakeLevelOld(void) // youBy: EP po nowemu IBLO = true; if (brakes.actualPressure.PipePressureVal < 0 && brakes.pressureTable[brakes.handlePosition - 1].PipePressureVal > 0) - brakes.pipeLimiterPressure = brakePipe.pressure; + brakes.pipeLimiterPressure = brakePipe.Pressure(); } else { @@ -727,7 +727,7 @@ void physics::Vehicle::UpdateBrakePressure(double dt) brakes.independentValveFlow = 0; brakes.brakeFlow = 0; - brakes.distributor->ForceLeak(dt * air.leakRate * 0.25); // fake air leaks from brake system reservoirs + brakes.distributor->ForceLeak(dt * air.config.leakRate * 0.25); // fake air leaks from brake system reservoirs auto const brakepress{brakes.cylinderPressure}; brakes.cylinderPressure = brakes.distributor->GetBCP(); @@ -747,143 +747,50 @@ void physics::Vehicle::UpdateBrakePressure(double dt) // ************************************************************************************************* void physics::Vehicle::CompressorCheck(double dt) { - - if (air.compressor.speed == 0.0) + auto &compressor{air.compressor}; + if (false == compressor.IsFitted()) { - air.compressor.allow = false; + compressor.Allow(false); return; } - - if (air.compressor.cabDependent) - { - if (CabActive > 0) - { - air.compressor.minPressure = air.compressor.minPressureCabA; - air.compressor.maxPressure = air.compressor.maxPressureCabA; - } - if (CabActive < 0) - { - air.compressor.minPressure = air.compressor.minPressureCabB; - air.compressor.maxPressure = air.compressor.maxPressureCabB; - } - } + compressor.SelectCab(CabActive); // EmergencyValve - brakes.emergencyValve.open = air.mainReservoirPressure > (brakes.emergencyValve.open ? brakes.emergencyValve.offPressure : brakes.emergencyValve.onPressure); + brakes.emergencyValve.open = air.MainReservoirPressure() > (brakes.emergencyValve.open ? brakes.emergencyValve.offPressure : brakes.emergencyValve.onPressure); if (brakes.emergencyValve.open) { - auto dV = static_cast(PF(0, air.mainReservoirPressure, brakes.emergencyValve.area) * dt); - air.compressedVolume -= dV; + auto dV = static_cast(PF(0, air.MainReservoirPressure(), brakes.emergencyValve.area) * dt); + air.AddAir(-dV); } - air.compressedVolume = std::max(0.0, air.compressedVolume - dt * air.leakRate * 0.1); // nieszczelności: 0.001=1l/s - - air.mainReservoirPressure = air.compressedVolume / air.mainReservoirVolume; - - // assorted operational logic - auto const MaxCompressorF{air.compressor.list[TCompressorList::cl_MaxFactor][air.compressor.listPosition] * air.compressor.maxPressure}; - auto const MinCompressorF{air.compressor.list[TCompressorList::cl_MinFactor][air.compressor.listPosition] * air.compressor.minPressure}; - auto const CompressorSpeedF{air.compressor.list[TCompressorList::cl_SpeedFactor][air.compressor.listPosition] * air.compressor.speed}; - // checking the impact on the compressor allowance - if (auto const AllowFactor{air.compressor.list[TCompressorList::cl_Allow][air.compressor.listPosition]}; AllowFactor > 0.5) - { - air.compressor.allow = AllowFactor > 1.5; - } - - switch (air.compressor.supply) - { - case CompressorSupply::converter: - { - air.compressor.allow = converter.IsAllowed(); - break; - } - case CompressorSupply::engine: - { - // HACK: make sure compressor coupled with diesel engine is always ready for work - air.compressor.start = start_t::automatic; - break; - } - default: - { - break; - } - } - - // the main circuit, also for a compressor driven by the engine, otherwise the low voltage - auto const compressorpower{air.compressor.supply == CompressorSupply::mainCircuit || air.compressor.supply == CompressorSupply::engine ? MainCircuitPowered() : lowVoltage.Is110vAvailable()}; - air.compressor.powerTime = compressorpower ? air.compressor.powerTime + dt : 0.0; - auto const compressorready{compressorpower && air.compressor.powerTime >= air.compressor.startDelay}; - // TBD: split CompressorAllow into separate enable/disable flags, inherit compressor from basic_device - auto const compressorenable{air.compressor.allowLocal && (air.compressor.start == start_t::automatic || air.compressor.allow)}; - auto const compressordisable{false == compressorenable}; - - auto const pressureistoolow{air.mainReservoirPressure < MinCompressorF}; - auto const pressureistoohigh{air.mainReservoirPressure > MaxCompressorF}; - - // TBD, TODO: break the lock with no low voltage power? - auto const governorlockispresent{MaxCompressorF - MinCompressorF > 0.0001}; - air.compressor.governorLock = governorlockispresent && false == pressureistoolow // unlock if pressure drops below minimal threshold - && (pressureistoohigh || air.compressor.governorLock); // lock if pressure goes above maximum threshold + CompressorInputs inputs; + inputs.converterAllowed = converter.IsAllowed(); + inputs.mainCircuitPowered = MainCircuitPowered(); + inputs.lowVoltage110v = lowVoltage.Is110vAvailable(); // for these multi-unit engines compressors turn off whenever any of them was affected by the governor // NOTE: this is crude implementation, limited only to adjacent vehicles - // TODO: re-implement when a more elegant/flexible system is in place - auto const coupledgovernorlock{ - (Couplers[VehicleEnd::rear].Connected != nullptr && true == Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::permanent) && Couplers[VehicleEnd::rear].Connected->air.compressor.governorLock) || - (Couplers[VehicleEnd::front].Connected != nullptr && true == Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::permanent) && Couplers[VehicleEnd::front].Connected->air.compressor.governorLock)}; - auto const governorlock{air.compressor.governorLock || coupledgovernorlock}; + auto const governorlocked = [this](VehicleEnd const End) { + auto const &coupler{Couplers[End]}; + return coupler.Connected != nullptr && coupler.CouplingFlag.HasAll(Coupling::permanent) && coupler.Connected->air.compressor.IsGovernorLocked(); + }; + inputs.coupledGovernorLock = governorlocked(VehicleEnd::rear) || governorlocked(VehicleEnd::front); + inputs.switchingDelayPassed = LastSwitchingTime > CtrlDelay; + inputs.engineRpmRatio = EngineRPMRatio(); - auto const compressorflag{air.compressor.running}; - air.compressor.running = - compressorready && false == compressordisable && (false == governorlock || air.compressor.supply == CompressorSupply::engine) && (air.compressor.running || (compressorenable && LastSwitchingTime > CtrlDelay)); - - if (air.compressor.running && air.compressor.running != compressorflag) + auto const step{air.Update(inputs, dt)}; + if (step.switched) { - // jeśli została załączona to trzeba ograniczyć ponowne włączenie - LastSwitchingTime = 0; + if (compressor.IsRunning()) + { + // jeśli została załączona to trzeba ograniczyć ponowne włączenie + LastSwitchingTime = 0; + } + Timer::subsystem.switching.note(compressor.IsRunning() ? Timer::switching_counter::compressor_on : Timer::switching_counter::compressor_off, this, &TypeName, &Name); } - if (air.compressor.running != compressorflag) + if (step.vented) { - Timer::subsystem.switching.note(air.compressor.running ? Timer::switching_counter::compressor_on : Timer::switching_counter::compressor_off, this, &TypeName, &Name); - } - - if (false == air.compressor.running) - { - return; - } - - // working compressor adds air to the air reservoir - if (air.compressor.supply == CompressorSupply::engine) - { - // the compressor is coupled with the diesel engine, engine revolutions affect the output - air.compressedVolume += - CompressorSpeedF * (2.0 * MaxCompressorF - air.mainReservoirPressure) / MaxCompressorF * EngineRPMRatio() * dt * (air.compressor.governorLock ? 0.0 : 1.0); // with the lock active air is vented out - } - else - { - // the compressor is a stand-alone device, working at steady pace - air.compressedVolume += CompressorSpeedF * (2.0 * MaxCompressorF - air.mainReservoirPressure) / MaxCompressorF * dt; - } - - if (pressureistoohigh && (false == governorlockispresent || air.compressor.supply == CompressorSupply::engine)) - { - // vent some air out if there's no governor lock to stop the compressor from exceeding acceptable pressure level SetFlag(SoundFlag, sound::relay | sound::loud); - auto ventedfraction{0.999}; // HACK: drop a tiny bit so the sound doesn't trigger repeatedly - if (false == governorlockispresent) - { - ventedfraction = 0.80; // arbitrary amount - } - else if (air.compressor.tankValve) - { - ventedfraction = MinCompressorF / MaxCompressorF; // drop to mincompressor level - } - air.compressedVolume *= ventedfraction; - if (false == governorlockispresent || air.compressor.tankValve) - { - air.compressor.governorLock = false; - } } - // a compressor not driven by the engine doesn't draw power (some 5 A) from the high- or low voltage circuit yet } @@ -893,9 +800,9 @@ void physics::Vehicle::CompressorCheck(double dt) // ************************************************************************************************* void physics::Vehicle::UpdatePipePressure(double dt) { - if (brakePipe.pressure > 1.0) + if (brakePipe.Pressure() > 1.0) { - brakePipe.reservoir->Flow(-brakePipe.pressure*air.leakRate * dt); + brakePipe.reservoir->Flow(-brakePipe.Pressure()*air.config.leakRate * dt); brakePipe.reservoir->Act(); } @@ -904,7 +811,7 @@ void physics::Vehicle::UpdatePipePressure(double dt) double temp; // int b; - brakePipe.pressure = brakePipe.reservoir->P(); + brakePipe.SetPressure(brakePipe.reservoir->P()); // PPP:=PipePress; brakes.driverValveFlow = 0; @@ -920,7 +827,7 @@ void physics::Vehicle::UpdatePipePressure(double dt) // 0.2*Spg brakePipe.reservoir->Flow(-brakes.driverValveFlow); - brakePipe.reservoir->Flow(-brakePipe.pressure * 0.001 * dt); + brakePipe.reservoir->Flow(-brakePipe.Pressure() * 0.001 * dt); // if Heating then // Pipe.Flow(PF(PipePress, 0, d2A(7)) * dt); // if ConverterFlag then @@ -944,14 +851,14 @@ void physics::Vehicle::UpdatePipePressure(double dt) } brakePipe.reservoir->Act(); - brakePipe.pressure = brakePipe.reservoir->P(); + brakePipe.SetPressure(brakePipe.reservoir->P()); if ((brakes.distributor->GetBrakeStatus() & b_dmg) == b_dmg) // jesli hamulec wyłączony temp = 0.0; // odetnij else temp = 1.0; // połącz - brakePipe.reservoir->Flow(temp * brakes.distributor->GetPF(temp * brakePipe.pressure, dt, Vel)); + brakePipe.reservoir->Flow(temp * brakes.distributor->GetPF(temp * brakePipe.Pressure(), dt, Vel)); // the air the brake hoses carry to and from the neighbours comes once all vehicles have stepped, UpdatePipeCouplers() - brakePipe.couplersPending = true; + brakePipe.SetCouplersPending(true); if (brakes.antiSlipType == 128) brakes.distributor->ASB(int(SlippingWheels && Vel > 1) * (1 + 2 * int(nrot_eps < -0.01))); @@ -960,19 +867,18 @@ void physics::Vehicle::UpdatePipePressure(double dt) // yB: jednokrokowe liczenie tego wszystkiego brakePipe.reservoir->Act(); - brakePipe.pressure = brakePipe.reservoir->P(); + brakePipe.SetPressure(brakePipe.reservoir->P()); brakes.driverValveFlow = brakes.driverValveFlow / (100.0 * dt); // normalizacja po czasie do syczenia; - if (brakePipe.pressure < -1.0) + if (brakePipe.Pressure() < -1.0) { - brakePipe.pressure = -1.0; + brakePipe.SetPressure(-1.0); brakePipe.reservoir->CreatePress(-1.0); brakePipe.reservoir->Act(); } - if (air.compressedVolume < 0.0) - air.compressedVolume = 0.0; + air.ClampEmpty(); } // the flow of the local brake valve, by the handle, the TRAXX's timed one, the integrated controller or the parking @@ -990,7 +896,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt) { lbpa = std::max(lbpa, brakes.holding.deceleration); } - brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.independentPositionEim), brakes.distributor->GetBCP(), mainPipe.pressure, dt, 0); + brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.independentPositionEim), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); } else { @@ -1011,7 +917,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt) { lbpa = 0.0; } - brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.independentPositionEim), brakes.distributor->GetBCP(), mainPipe.pressure, dt, 0); + brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.independentPositionEim), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); } } @@ -1031,23 +937,23 @@ void physics::Vehicle::UpdateMainValve(double dt) if (brakes.operatingMode < bom_EP || brakes.driverValve->GetPos(bh_EB) - 0.5 < brakes.handlePositionReal || (brakes.driverValveType != TBrakeHandle::MHZ_EN57 && brakes.driverValveType != TBrakeHandle::MHZ_K8P)) { - brakes.driverValveFlow = brakes.driverValve->GetPF(MainValveHandlePosition(), brakePipe.pressure, temp, dt, brakes.equivalentPipePressure); + brakes.driverValveFlow = brakes.driverValve->GetPF(MainValveHandlePosition(), brakePipe.Pressure(), temp, dt, brakes.equivalentPipePressure); } else { - brakes.driverValveFlow = brakes.driverValve->GetPF(0, brakePipe.pressure, temp, dt, brakes.equivalentPipePressure); + brakes.driverValveFlow = brakes.driverValve->GetPF(0, brakePipe.Pressure(), temp, dt, brakes.equivalentPipePressure); } } else if (brakes.handlePosition == brakes.driverValve->GetPos(bh_EB)) { - brakes.driverValveFlow = brakes.driverValve->GetPF(brakes.handlePositionReal, brakePipe.pressure, temp, dt, brakes.equivalentPipePressure); + brakes.driverValveFlow = brakes.driverValve->GetPF(brakes.handlePositionReal, brakePipe.Pressure(), temp, dt, brakes.equivalentPipePressure); } if (brakes.driverValveFlow < 0) // && (PipePressureVal > 0.01) //50 { - if (air.mainReservoirPressure > mainPipe.pressure) + if (air.MainReservoirPressure() > mainPipe.Pressure()) { - air.compressedVolume = air.compressedVolume + brakes.driverValveFlow / 1500.0; + air.AddAir(brakes.driverValveFlow / 1500.0); mainPipe.reservoir->Flow(brakes.driverValveFlow / 3.0); } else @@ -1058,16 +964,16 @@ void physics::Vehicle::UpdateMainValve(double dt) // the pressure the driver's handle is fed from: the main pipe's, or the brake pipe's own with the pipe locked double physics::Vehicle::MainValveSupply() { - brakes.pipeLock.locked = brakePipe.pressure < (brakes.pipeLock.locked ? brakes.pipeLock.offPressure : brakes.pipeLock.onPressure); + brakes.pipeLock.locked = brakePipe.Pressure() < (brakes.pipeLock.locked ? brakes.pipeLock.offPressure : brakes.pipeLock.onPressure); bool lock_new = (brakes.pipeLock.locked && !brakes.pipeLock.unlockPressed && brakes.handlePositionReal > brakes.pipeLock.unlockHandlePosition) || (brakes.emergencyCutsOffDriverValve && brakes.emergencyValve.flow > 0); // new simple codition based on .fiz bool lock_old = brakes.driverValveType == TBrakeHandle::FV4a // old complex condition based on assumptions - && brakePipe.pressure < 2.75 && (brakes.distributor->GetStatus() & b_rls) == 0 && brakes.subsystem == TBrakeSubSystem::ss_LSt && TrainType != train_type::emu && !brakes.pipeLock.unlockPressed; + && brakePipe.Pressure() < 2.75 && (brakes.distributor->GetStatus() & b_rls) == 0 && brakes.subsystem == TBrakeSubSystem::ss_LSt && TrainType != train_type::emu && !brakes.pipeLock.unlockPressed; if (lock_old || lock_new) { - return brakePipe.pressure + 0.00001; + return brakePipe.Pressure() + 0.00001; } - return mainPipe.pressure; + return mainPipe.Pressure(); } // the position the driver's handle works at: its own, or the one the speed control's brake intervention sets @@ -1101,7 +1007,7 @@ void physics::Vehicle::UpdateEmergencyValve(double dt) (0 == CabActive && (InactiveCabFlag & activation::emergencybrake) != 0)}; if (brakes.alarmChain || (ownemergency && false == PulleeMode)) { - brakes.emergencyValve.flow = PF(0, brakePipe.pressure, 0.15) * dt; + brakes.emergencyValve.flow = PF(0, brakePipe.Pressure(), 0.15) * dt; } brakes.driverValveFlow += brakes.emergencyValve.flow; } @@ -1246,9 +1152,9 @@ void physics::Vehicle::UpdateEPBrake() // ************************************************************************************************* void physics::Vehicle::UpdateScndPipePressure(double dt) { - if (mainPipe.pressure > 1.0) + if (mainPipe.Pressure() > 1.0) { - mainPipe.reservoir->Flow(-mainPipe.pressure*air.leakRate * dt); + mainPipe.reservoir->Flow(-mainPipe.Pressure()*air.config.leakRate * dt); mainPipe.reservoir->Act(); } @@ -1256,22 +1162,22 @@ void physics::Vehicle::UpdateScndPipePressure(double dt) UpdateSpringBrake(dt); - mainPipe.reservoir->Flow(brakes.distributor->GetHPFlow(mainPipe.pressure, dt)); + mainPipe.reservoir->Flow(brakes.distributor->GetHPFlow(mainPipe.Pressure(), dt)); // NOTE: condition disabled to allow the air flow from the main hose to the main tank as well - if (/* ( ( Compressor > ScndPipePress ) && ( */ air.mainReservoirVolume > 0.0 /* ) ) || ( TrainType == train_type::emu ) || ( TrainType == train_type::dmu ) */) + if (/* ( ( Compressor > ScndPipePress ) && ( */ air.config.mainReservoirVolume > 0.0 /* ) ) || ( TrainType == train_type::emu ) || ( TrainType == train_type::dmu ) */) { - double const dV = PF(air.mainReservoirPressure, mainPipe.pressure, Spz) * dt; - air.compressedVolume += dV / 1000.0; + double const dV = PF(air.MainReservoirPressure(), mainPipe.Pressure(), Spz) * dt; + air.AddAir(dV / 1000.0); mainPipe.reservoir->Flow(-dV); } // the air the main reservoir hoses carry to and from the neighbours comes once all vehicles have stepped, UpdatePipeCouplers() - mainPipe.couplersPending = true; + mainPipe.SetCouplersPending(true); mainPipe.reservoir->Act(); - mainPipe.pressure = mainPipe.reservoir->P(); + mainPipe.SetPressure(mainPipe.reservoir->P()); - if (mainPipe.pressure < -1) + if (mainPipe.Pressure() < -1) { - mainPipe.pressure = -1; + mainPipe.SetPressure(-1); mainPipe.reservoir->CreatePress(-1); mainPipe.reservoir->Act(); } @@ -1352,18 +1258,18 @@ double physics::Vehicle::GetDVc(double dt) if (Couplers[0].Connected != nullptr && Couplers[0].CouplingFlag.HasAll(Coupling::brakeHose)) { //*0.85 c = Couplers[0].Connected; // skrot //0.08 //e/D * L/D = e/D^2 * L - dv1 = 0.5 * dt * PF(brakePipe.pressure, neighbour_pipe_pressure(*c, c->brakePipe.pressure, *c->brakePipe.reservoir), brakes.pipeSection / (1.0 + 0.015 / brakes.pipeSection * Dim.L)); + dv1 = 0.5 * dt * PF(brakePipe.Pressure(), neighbour_pipe_pressure(*c, c->brakePipe.Pressure(), *c->brakePipe.reservoir), brakes.pipeSection / (1.0 + 0.015 / brakes.pipeSection * Dim.L)); c->brakePipe.reservoir->Flow(-dv1); - if (pipe_wakes(dv1, brakePipe.pressure, *c->brakePipe.reservoir)) + if (pipe_wakes(dv1, brakePipe.Pressure(), *c->brakePipe.reservoir)) c->switch_physics(true, wake_cause::mainpipe); } // sprzeg 2 if (Couplers[1].Connected != nullptr && Couplers[1].CouplingFlag.HasAll(Coupling::brakeHose)) { c = Couplers[1].Connected; // skrot - dv2 = 0.5 * dt * PF(brakePipe.pressure, neighbour_pipe_pressure(*c, c->brakePipe.pressure, *c->brakePipe.reservoir), brakes.pipeSection / (1.0 + 0.015 / brakes.pipeSection * Dim.L)); + dv2 = 0.5 * dt * PF(brakePipe.Pressure(), neighbour_pipe_pressure(*c, c->brakePipe.Pressure(), *c->brakePipe.reservoir), brakes.pipeSection / (1.0 + 0.015 / brakes.pipeSection * Dim.L)); c->brakePipe.reservoir->Flow(-dv2); - if (pipe_wakes(dv2, brakePipe.pressure, *c->brakePipe.reservoir)) + if (pipe_wakes(dv2, brakePipe.Pressure(), *c->brakePipe.reservoir)) c->switch_physics(true, wake_cause::mainpipe); } // if ((Couplers[1].Connected != NULL) && (Couplers[0].Connected != NULL)) @@ -1395,23 +1301,23 @@ double physics::Vehicle::GetScndDVc(double dt) if (Couplers[0].Connected != nullptr && Couplers[0].CouplingFlag.HasAll(Coupling::mainHose)) { c = Couplers[0].Connected; // skrot - dv1 = 0.5 * dt * PF(mainPipe.pressure, neighbour_pipe_pressure(*c, c->mainPipe.pressure, *c->mainPipe.reservoir), Spz * 0.75); + dv1 = 0.5 * dt * PF(mainPipe.Pressure(), neighbour_pipe_pressure(*c, c->mainPipe.Pressure(), *c->mainPipe.reservoir), Spz * 0.75); c->mainPipe.reservoir->Flow(-dv1); - if (pipe_wakes(dv1, mainPipe.pressure, *c->mainPipe.reservoir)) + if (pipe_wakes(dv1, mainPipe.Pressure(), *c->mainPipe.reservoir)) c->switch_physics(true, wake_cause::scndpipe); } // sprzeg 2 if (Couplers[1].Connected != nullptr && Couplers[1].CouplingFlag.HasAll(Coupling::mainHose)) { c = Couplers[1].Connected; // skrot - dv2 = 0.5 * dt * PF(mainPipe.pressure, neighbour_pipe_pressure(*c, c->mainPipe.pressure, *c->mainPipe.reservoir), Spz * 0.75); + dv2 = 0.5 * dt * PF(mainPipe.Pressure(), neighbour_pipe_pressure(*c, c->mainPipe.Pressure(), *c->mainPipe.reservoir), Spz * 0.75); c->mainPipe.reservoir->Flow(-dv2); - if (pipe_wakes(dv2, mainPipe.pressure, *c->mainPipe.reservoir)) + if (pipe_wakes(dv2, mainPipe.Pressure(), *c->mainPipe.reservoir)) c->switch_physics(true, wake_cause::scndpipe); } if (Couplers[1].Connected != nullptr && Couplers[0].Connected != nullptr && Couplers[0].CouplingFlag.HasAll(Coupling::mainHose) && Couplers[1].CouplingFlag.HasAll(Coupling::mainHose)) { - double const dV = 0.00025 * dt * PF(Couplers[0].Connected->mainPipe.pressure, Couplers[1].Connected->mainPipe.pressure, Spz * 0.25); + double const dV = 0.00025 * dt * PF(Couplers[0].Connected->mainPipe.Pressure(), Couplers[1].Connected->mainPipe.Pressure(), Spz * 0.25); Couplers[0].Connected->mainPipe.reservoir->Flow(+dV); Couplers[1].Connected->mainPipe.reservoir->Flow(-dV); } @@ -1457,7 +1363,7 @@ int hose_substeps(physics::Vehicle const &Vehicle, train_pipe const &trainPipe, auto const &other{*hose.Connected}; auto const othercapacity{(other.*trainPipe.pipe).reservoir->GetCap()}; // the flow per bar of the difference, at small differences, where it's the largest - auto const pressure{std::max((Vehicle.*trainPipe.pipe).pressure, (other.*trainPipe.pipe).pressure)}; + auto const pressure{std::max((Vehicle.*trainPipe.pipe).Pressure(), (other.*trainPipe.pipe).Pressure())}; auto const conductance{std::abs(PF(pressure, pressure - 0.01, area)) / 0.01}; auto const equalising{capacity * othercapacity / (capacity + othercapacity)}; substeps = std::max(substeps, static_cast(std::ceil(dt * conductance / equalising))); @@ -1477,7 +1383,7 @@ std::vector hose_trains(std::vector const &Vehi byaddress.reserve(Vehicles.size()); for (std::size_t index = 0; index < Vehicles.size(); ++index) { - if ((Vehicles[index]->*trainPipe.pipe).couplersPending) + if ((Vehicles[index]->*trainPipe.pipe).CouplersPending()) { byaddress.emplace_back(Vehicles[index], index); } @@ -1491,7 +1397,7 @@ std::vector hose_trains(std::vector const &Vehi std::vector stack; for (std::size_t first = 0; first < Vehicles.size(); ++first) { - if (false == (Vehicles[first]->*trainPipe.pipe).couplersPending || trains[first] != none) + if (false == (Vehicles[first]->*trainPipe.pipe).CouplersPending() || trains[first] != none) { continue; } @@ -1530,7 +1436,7 @@ void exchange_through_hoses(std::vector const &Vehicles, tra std::vector substeps; for (std::size_t index = 0; index < Vehicles.size(); ++index) { - if (false == (Vehicles[index]->*trainPipe.pipe).couplersPending) + if (false == (Vehicles[index]->*trainPipe.pipe).CouplersPending()) { continue; } @@ -1547,23 +1453,23 @@ void exchange_through_hoses(std::vector const &Vehicles, tra { for (std::size_t index = 0; index < Vehicles.size(); ++index) { - if (false == (Vehicles[index]->*trainPipe.pipe).couplersPending || trains[index] != train) + if (false == (Vehicles[index]->*trainPipe.pipe).CouplersPending() || trains[index] != train) { continue; } auto *vehicle{Vehicles[index]}; auto &pipe{*(vehicle->*trainPipe.pipe).reservoir}; pipe.Act(); // what the neighbours have sent in the meantime - (vehicle->*trainPipe.pipe).pressure = pipe.P(); + (vehicle->*trainPipe.pipe).SetPressure(pipe.P()); pipe.Flow((vehicle->*trainPipe.exchange)(substep)); pipe.Act(); - (vehicle->*trainPipe.pipe).pressure = pipe.P(); + (vehicle->*trainPipe.pipe).SetPressure(pipe.P()); } } } for (auto *vehicle : Vehicles) { - (vehicle->*trainPipe.pipe).couplersPending = false; + (vehicle->*trainPipe.pipe).SetCouplersPending(false); } } diff --git a/physics/components/setup.cpp b/physics/components/setup.cpp index ff2d4fe0e..424132c0c 100644 --- a/physics/components/setup.cpp +++ b/physics/components/setup.cpp @@ -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; diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index d00ea4a37..f6ab99ed5 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -113,7 +113,7 @@ double physics::Vehicle::Current(double n, double U) } // writepaslog("MotorCurrent ", FloatToStr(MotorCurrent)); - if (brakes.electrodynamic.type == dbrake_switch && (brakes.cylinderPressure > 2.0 || brakePipe.pressure < 3.6)) + if (brakes.electrodynamic.type == dbrake_switch && (brakes.cylinderPressure > 2.0 || brakePipe.Pressure() < 3.6)) { Im = 0; // Im:=0; diff --git a/physics/vehicle.h b/physics/vehicle.h index ba263d896..c6e4030eb 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -1524,7 +1524,7 @@ class Vehicle // (EmergencyBrakeMainOffPressure) while the master controller is on a power position bool EmergencyBrakeHoldsMainOff() const { - return lineBreaker.config.emergencyOffPressure > 0.0 && brakePipe.pressure < lineBreaker.config.emergencyOffPressure && false == IsMainCtrlNoPowerPos(); + return lineBreaker.config.emergencyOffPressure > 0.0 && brakePipe.Pressure() < lineBreaker.config.emergencyOffPressure && false == IsMainCtrlNoPowerPos(); } // whether the lamp of the open line contactors is lit. on the electric locomotives it tells the start can be made, so // it goes out with the start cut off; on the diesel-electric ones (the SU45 and SU46 family) it just tells the @@ -1546,7 +1546,7 @@ class Vehicle // whether the pneumatic louvres of the motor fans are still closed, the main reservoir short of the pressure that opens them bool LouvresClosed() const { - return air.mainReservoirPressure < LouvresOpenPressure; + return air.MainReservoirPressure() < LouvresOpenPressure; } // whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close bool LineContactorsInterlockReleased() const; diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index ac38229b6..17cc92dad 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -75,7 +75,7 @@ std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle cons auto const on{[](bool const State, std::uint32_t const Bit) { return State ? Bit : 0u; }}; return on(Occupied.lowVoltage.IsBatteryOn() || Controlling.lowVoltage.IsBatteryOn(), device::battery) | on(Controlling.lineBreaker.IsClosed(), device::main_breaker) | on(Controlling.pantographs[VehicleEnd::front].is_active, device::pantograph_front) | on(Controlling.pantographs[VehicleEnd::rear].is_active, device::pantograph_rear) | - on(Controlling.converter.IsRunning(), device::converter) | on(Controlling.air.compressor.running, device::compressor) | on(Controlling.lineContactors.IsClosed(), device::line_contactors) | + on(Controlling.converter.IsRunning(), device::converter) | on(Controlling.air.compressor.IsRunning(), device::compressor) | on(Controlling.lineContactors.IsClosed(), device::line_contactors) | on(Controlling.FuseFlag, device::overload_relay) | on(Controlling.SandDose, device::sanding) | on(Occupied.WarningSignal != 0, device::horn) | on(false == Occupied.Doors.instances[VehicleSide::left].is_closed, device::doors_left) | on(false == Occupied.Doors.instances[VehicleSide::right].is_closed, device::doors_right) | on(Occupied.Radio, device::radio) | @@ -453,12 +453,12 @@ void blackbox_recorder::write_cab() { sample.train_brake = static_cast(occupied->brakes.handlePositionSmooth); sample.local_brake = static_cast(occupied->brakes.independentPosition); sample.brake_cylinder = static_cast(occupied->brakes.cylinderPressure); - sample.brake_pipe = static_cast(occupied->brakePipe.pressure); + sample.brake_pipe = static_cast(occupied->brakePipe.Pressure()); sample.motor_current = static_cast(controlling->Im); if (owner != nullptr && owner->is_active()) sample.ai = owner->ai_reference(); sample.devices = devices_of(*occupied, *controlling); - sample.main_reservoir = static_cast(controlling->air.mainReservoirPressure); + sample.main_reservoir = static_cast(controlling->air.MainReservoirPressure()); sample.voltage = static_cast(controlling->EngineVoltage); sample.engine_rpm = static_cast(std::abs(controlling->enrot) * 60.0); // the lights at the ends of the train: of the vehicles at its ends, at their ends turned away from the rest @@ -478,7 +478,7 @@ void blackbox_recorder::write_cab() { // the const one: with no driver the first channel sample.radio_channel = static_cast(std::clamp(std::as_const(*train).RadioChannel(), 0, 255)); sample.driver_valve = occupied->brakes.driverValve != nullptr ? static_cast(occupied->brakes.driverValve->GetCP()) : 0.0f; - sample.feed_pipe = static_cast(occupied->mainPipe.pressure); + sample.feed_pipe = static_cast(occupied->mainPipe.Pressure()); sample.oil_pressure = controlling->OilPump.pressure; sample.water_temperature = controlling->diesel.heat.Twy; sample.oil_temperature = controlling->diesel.heat.To; diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index 626f6752c..e0ec57730 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -467,7 +467,7 @@ void state_manager::process_commands() { if (commanddata.command == user_command::fillcompressor) { TDynamicObject *vehicle = simulation::Vehicles.find(commanddata.payload); - vehicle->physics->air.compressedVolume = 8.0f * vehicle->physics->air.mainReservoirVolume; + vehicle->physics->air.Fill(8.0f * vehicle->physics->air.config.mainReservoirVolume); } if (commanddata.command == user_command::dynamicmove) { diff --git a/tests/unit/consist.cpp b/tests/unit/consist.cpp index 04338f4c4..5e82d4e88 100644 --- a/tests/unit/consist.cpp +++ b/tests/unit/consist.cpp @@ -84,7 +84,7 @@ void consist::step(track const &Track, double Dt) { auto pipe{0.0}; auto length{0.0}; for (auto const &vehicle : m_vehicles) { - pipe += vehicle->physics().brakePipe.pressure * vehicle->physics().Dim.L; + pipe += vehicle->physics().brakePipe.Pressure() * vehicle->physics().Dim.L; length += vehicle->physics().Dim.L; } pipe /= length; diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index a76beee6a..ed6db3738 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -86,7 +86,7 @@ void release_brakes(physics::Vehicle &Cab) { bool is_ready(driven const &Driven) { auto const &physics{Driven.controlling}; - auto const air{physics.air.mainReservoirVolume <= 0.0 || physics.mainPipe.pressure >= 4.5}; + auto const air{physics.air.config.mainReservoirVolume <= 0.0 || physics.mainPipe.Pressure() >= 4.5}; // the converter feeds the 110 V circuits (the electrodynamic brake's control among them); the AI switches // it on once the line breaker is closed, so a train already charged with air isn't ready before it runs auto const converter{physics.converter.config.start != start_t::manual || physics.converter.IsRunning()}; @@ -114,7 +114,7 @@ void raise_pantographs(driven const &Driven) { } pantographs.pantographAir.SwitchCompressor(true); } - else if (false == pantographs.pantographAir.IsConnectedToMainReservoir() || pantographs.pantographAir.Pressure() <= pantographs.mainPipe.pressure) { + else if (false == pantographs.pantographAir.IsConnectedToMainReservoir() || pantographs.pantographAir.Pressure() <= pantographs.mainPipe.Pressure()) { pantographs.pantographAir.SwitchCompressor(false); } Driven.cab.OperatePantographsValve(operation_t::enable); @@ -210,7 +210,7 @@ void drive_cycle(driven Driven, track const &Track, trace &Trace) { auto &cab{Driven.cab}; auto &controlling{Driven.controlling}; if (false == start_up(Driven, Track, 300.0, &Trace)) { - MESSAGE("didn't get ready: Mains " << controlling.lineBreaker.IsClosed() << ", main reservoir " << controlling.mainPipe.pressure); + MESSAGE("didn't get ready: Mains " << controlling.lineBreaker.IsClosed() << ", main reservoir " << controlling.mainPipe.Pressure()); } Trace.mark("release brakes"); release_brakes(cab); diff --git a/tests/unit/figures.cpp b/tests/unit/figures.cpp index 7e9fd110e..f3325c0a2 100644 --- a/tests/unit/figures.cpp +++ b/tests/unit/figures.cpp @@ -62,7 +62,7 @@ constexpr double pipe_back{4.9}; void figures::sample(double Time, physics::Vehicle const &Vehicle) { auto &part{m_parts.back()}; auto const speed{Vehicle.V * 3.6}; - auto const pipe{Vehicle.brakePipe.pressure}; + auto const pipe{Vehicle.brakePipe.Pressure()}; if (false == part.sampled) { part.sampled = true; // from the last step of the part before, so the parts add up to the run diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index 21db64dd4..0e7c7a1bc 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -75,7 +75,7 @@ std::vector traction() { std::vector brakes() { return { {"BrakeCtrlPos", [](auto const &M) { return M.brakes.handlePosition; }}, - {"PipePress", [](auto const &M) { return M.brakePipe.pressure; }}, + {"PipePress", [](auto const &M) { return M.brakePipe.Pressure(); }}, {"BrakePress", [](auto const &M) { return M.brakes.cylinderPressure; }}, {"LocBrakePress", [](auto const &M) { return M.brakes.independentCylinderPressure; }}, {"BRP", [](auto const &M) { return M.brakes.distributor->GetBRP(); }}, @@ -86,9 +86,9 @@ std::vector brakes() { std::vector air() { return { - {"Compressor", [](auto const &M) { return M.air.mainReservoirPressure; }}, - {"CompressorFlag", [](auto const &M) { return M.air.compressor.running ? 1.0 : 0.0; }}, - {"ScndPipePress", [](auto const &M) { return M.mainPipe.pressure; }}, + {"Compressor", [](auto const &M) { return M.air.MainReservoirPressure(); }}, + {"CompressorFlag", [](auto const &M) { return M.air.compressor.IsRunning() ? 1.0 : 0.0; }}, + {"ScndPipePress", [](auto const &M) { return M.mainPipe.Pressure(); }}, }; } @@ -162,7 +162,7 @@ std::vector parameters() { {"CntrlPipePress", [](auto const &M) { return M.brakes.controlReservoirPressure; }}, {"BrakeVolume", [](auto const &M) { return M.brakes.cylinderVolume; }}, {"BrakeVVolume", [](auto const &M) { return M.brakes.valveVolume; }}, - {"VeselVolume", [](auto const &M) { return M.air.mainReservoirVolume; }}, + {"VeselVolume", [](auto const &M) { return M.air.config.mainReservoirVolume; }}, {"BrakeCylNo", [](auto const &M) { return M.brakes.cylinders.count; }}, {"BrakeCylRadius", [](auto const &M) { return M.brakes.cylinders.radius; }}, {"BrakeCylDist", [](auto const &M) { return M.brakes.cylinders.stroke; }}, @@ -172,11 +172,11 @@ std::vector parameters() { {"RapidMult", [](auto const &M) { return M.brakes.rapidRatio; }}, {"RapidVel", [](auto const &M) { return M.brakes.rapidSpeed; }}, {"BrakeValveSize", [](auto const &M) { return M.brakes.distributorSize; }}, - {"MinCompressor", [](auto const &M) { return M.air.compressor.minPressure; }}, - {"MaxCompressor", [](auto const &M) { return M.air.compressor.maxPressure; }}, - {"CompressorSpeed", [](auto const &M) { return M.air.compressor.speed; }}, + {"MinCompressor", [](auto const &M) { return M.air.compressor.config.minPressure; }}, + {"MaxCompressor", [](auto const &M) { return M.air.compressor.config.maxPressure; }}, + {"CompressorSpeed", [](auto const &M) { return M.air.compressor.config.speed; }}, {"EmergencyValveOn", [](auto const &M) { return M.brakes.emergencyValve.onPressure; }}, - {"AirLeakRate", [](auto const &M) { return M.air.leakRate; }}, + {"AirLeakRate", [](auto const &M) { return M.air.config.leakRate; }}, {"BrakeCtrlPosNo", [](auto const &M) { return M.brakes.handlePositions; }}, {"MainCtrlPosNo", [](auto const &M) { return M.MainCtrlPosNo; }}, {"ScndCtrlPosNo", [](auto const &M) { return M.ScndCtrlPosNo; }}, diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index c2ea5f029..cb2ad3c02 100644 --- a/tests/unit/invariants.cpp +++ b/tests/unit/invariants.cpp @@ -42,13 +42,13 @@ std::vector const &invariants() { {"every value a number", [](auto const &M, double, auto const *) { std::initializer_list const values{M.V, M.AccS, M.Ft, M.Fb, M.Im, M.Itot, M.EngineVoltage, - M.enrot, M.brakePipe.pressure, M.brakes.cylinderPressure, M.brakes.independentCylinderPressure, M.mainPipe.pressure, M.air.mainReservoirPressure, M.lowVoltage.BatteryVoltage()}; + M.enrot, M.brakePipe.Pressure(), M.brakes.cylinderPressure, M.brakes.independentCylinderPressure, M.mainPipe.Pressure(), M.air.MainReservoirPressure(), M.lowVoltage.BatteryVoltage()}; return std::ranges::all_of(values, [](double const Value) { return std::isfinite(Value); }); }, [](auto const &M) { return values({{"V", M.V}, {"AccS", M.AccS}, {"Ft", M.Ft}, {"Fb", M.Fb}, {"Im", M.Im}, {"Itot", M.Itot}, {"EngineVoltage", M.EngineVoltage}, - {"enrot", M.enrot}, {"PipePress", M.brakePipe.pressure}, {"BrakePress", M.brakes.cylinderPressure}, {"LocBrakePress", M.brakes.independentCylinderPressure}, - {"ScndPipePress", M.mainPipe.pressure}, {"Compressor", M.air.mainReservoirPressure}, {"BatteryVoltage", M.lowVoltage.BatteryVoltage()}}); + {"enrot", M.enrot}, {"PipePress", M.brakePipe.Pressure()}, {"BrakePress", M.brakes.cylinderPressure}, {"LocBrakePress", M.brakes.independentCylinderPressure}, + {"ScndPipePress", M.mainPipe.Pressure()}, {"Compressor", M.air.MainReservoirPressure()}, {"BatteryVoltage", M.lowVoltage.BatteryVoltage()}}); }}, {"brake cylinders between empty and the vehicle's highest pressure", [](auto const &M, double, auto const *) { @@ -61,14 +61,14 @@ std::vector const &invariants() { [](auto const &M, double, auto const *) { // all the air comes from the main reservoirs, which the game sets up to 10 bar, some (the Impuls) to 12; // the driver's valve in its filling position joins the brake pipe to them - auto const highest{1.01 * std::max(10.0, M.air.compressor.maxPressure) + pressure_margin}; - std::initializer_list const pressures{M.brakePipe.pressure, M.mainPipe.pressure, M.air.mainReservoirPressure}; + auto const highest{1.01 * std::max(10.0, M.air.compressor.config.maxPressure) + pressure_margin}; + std::initializer_list const pressures{M.brakePipe.Pressure(), M.mainPipe.Pressure(), M.air.MainReservoirPressure()}; return std::ranges::all_of(pressures, [highest](double const Press) { return Press >= -pressure_margin && Press <= highest; }); }, - [](auto const &M) { return values({{"PipePress", M.brakePipe.pressure}, {"ScndPipePress", M.mainPipe.pressure}, {"Compressor", M.air.mainReservoirPressure}}); }}, + [](auto const &M) { return values({{"PipePress", M.brakePipe.Pressure()}, {"ScndPipePress", M.mainPipe.Pressure()}, {"Compressor", M.air.MainReservoirPressure()}}); }}, {"main reservoir no higher than the compressor's governor", - [](auto const &M, double, auto const *) { return M.air.compressor.maxPressure <= 0.0 || M.air.mainReservoirPressure <= 1.01 * M.air.compressor.maxPressure + pressure_margin; }, - [](auto const &M) { return values({{"Compressor", M.air.mainReservoirPressure}, {"MaxCompressor", M.air.compressor.maxPressure}}); }}, + [](auto const &M, double, auto const *) { return M.air.compressor.config.maxPressure <= 0.0 || M.air.MainReservoirPressure() <= 1.01 * M.air.compressor.config.maxPressure + pressure_margin; }, + [](auto const &M) { return values({{"Compressor", M.air.MainReservoirPressure()}, {"MaxCompressor", M.air.compressor.config.maxPressure}}); }}, {"no motor current with the line breaker open", [](auto const &M, double, auto const *) { return M.lineBreaker.IsClosed() || false == electric(M) || std::abs(M.Im) < 1.0; }, [](auto const &M) { return values({{"Mains", M.lineBreaker.IsClosed()}, {"Im", M.Im}, {"Itot", M.Itot}}); }}, diff --git a/tests/unit/test_brake_handles.cpp b/tests/unit/test_brake_handles.cpp index 12d91adec..d7b6ba077 100644 --- a/tests/unit/test_brake_handles.cpp +++ b/tests/unit/test_brake_handles.cpp @@ -35,7 +35,7 @@ void hold(vehicle &Vehicle, test::trace &Trace, std::string const &Event, double // every position of the driver's handle, recorded in the trace void every_position(vehicle &Vehicle, test::trace &Trace) { - Vehicle.hold_main_reservoir(std::max(Vehicle->air.compressor.maxPressure, 8.0)); + Vehicle.hold_main_reservoir(std::max(Vehicle->air.compressor.config.maxPressure, 8.0)); REQUIRE(Vehicle->brakes.driverValve != nullptr); auto &handle{*Vehicle->brakes.driverValve}; Vehicle.record(Trace); @@ -102,7 +102,7 @@ TEST_CASE("brake handles: the local brake handle of every real vehicle") { if (false == has_handle(real)) { continue; } - real.hold_main_reservoir(std::max(real->air.compressor.maxPressure, 8.0)); + real.hold_main_reservoir(std::max(real->air.compressor.config.maxPressure, 8.0)); test::trace trace{"local brake/" + path, handle_channels(), 100}; real.record(trace); REQUIRE(real->brakes.driverValve != nullptr); @@ -133,22 +133,22 @@ TEST_CASE("brake handles: the overload and the high pressure buttons of the MHZ vehicle real{definition, 0.0, "test", 1}; real->BatterySwitch(true); real->CabActivisation(); - real.hold_main_reservoir(std::max(real->air.compressor.maxPressure, 8.0)); + real.hold_main_reservoir(std::max(real->air.compressor.config.maxPressure, 8.0)); test::trace trace{"brake handles/buttons/" + name, handle_channels(), 100}; real.record(trace); REQUIRE(real->brakes.driverValve != nullptr); auto &handle{*real->brakes.driverValve}; driven_at(real, trace, "running", handle.GetPos(bh_RP), 60.0); - auto const running{real->brakePipe.pressure}; + auto const running{real->brakePipe.Pressure()}; handle.SetUniversalFlag(TUniversalBrake::ub_Overload); driven_at(real, trace, "overload button", handle.GetPos(bh_RP), 30.0); handle.SetUniversalFlag(0); - auto const overloaded{real->brakePipe.pressure}; + auto const overloaded{real->brakePipe.Pressure()}; driven_at(real, trace, "overload decaying", handle.GetPos(bh_RP), 240.0); - auto const decayed{real->brakePipe.pressure}; + auto const decayed{real->brakePipe.Pressure()}; handle.SetUniversalFlag(TUniversalBrake::ub_HighPressure); driven_at(real, trace, "high pressure button, filling stroke", handle.GetPos(bh_FS), 10.0); - auto const filled{real->brakePipe.pressure}; + auto const filled{real->brakePipe.Pressure()}; handle.SetUniversalFlag(0); driven_at(real, trace, "running", handle.GetPos(bh_RP), 120.0); CHECK(running == doctest::Approx(5.0).epsilon(0.01)); @@ -283,10 +283,10 @@ std::vector st113_run() { vehicle real{definition::fiz("en57_v1/6bai")}; REQUIRE(real->brakes.driverValveType == TBrakeHandle::St113); REQUIRE(real->brakes.driverValve != nullptr); - real.hold_main_reservoir(std::max(real->air.compressor.maxPressure, 8.0)); + real.hold_main_reservoir(std::max(real->air.compressor.config.maxPressure, 8.0)); auto &handle{*real->brakes.driverValve}; std::vector samples; - auto const sample{[&] { samples.push_back({handle.GetCP(), real->brakePipe.pressure, real->brakes.cylinderPressure, handle.GetEP()}); }}; + auto const sample{[&] { samples.push_back({handle.GetCP(), real->brakePipe.Pressure(), real->brakes.cylinderPressure, handle.GetEP()}); }}; auto const hold{[&](double Position, std::initializer_list Seconds) { real->BrakeLevelSet(Position); for (auto const seconds : Seconds) { diff --git a/tests/unit/test_brake_pipe.cpp b/tests/unit/test_brake_pipe.cpp index 6e7019afa..d2800784b 100644 --- a/tests/unit/test_brake_pipe.cpp +++ b/tests/unit/test_brake_pipe.cpp @@ -42,10 +42,10 @@ void passenger_train(test::consist &Train, int const Cars) { // at Pressure [bar], the physics stepping by Dt double application_time(test::consist &Train, double const Pressure, double const Dt) { auto &last{Train[Train.size() - 1]}; - auto const start{last->brakePipe.pressure}; + auto const start{last->brakePipe.Pressure()}; Train[0].hold_brake_pipe(Pressure); auto time{0.0}; - while (last->brakePipe.pressure > start - 0.5 && time < 60.0) { + while (last->brakePipe.Pressure() > start - 0.5 && time < 60.0) { Train.step({}, Dt); time += Dt; } @@ -72,8 +72,8 @@ TEST_CASE("brake pipe: the distributors of a standing freight train see the pres CAPTURE(i); auto &wagon{train[i].physics()}; // the distributor's valve chamber follows the pressure the distributor works with: the pipe's own - CHECK(std::abs(wagon.brakes.distributor->GetVRP() - wagon.brakePipe.pressure) < 0.005); - CHECK(wagon.brakePipe.pressure > 4.9); + CHECK(std::abs(wagon.brakes.distributor->GetVRP() - wagon.brakePipe.Pressure()) < 0.005); + CHECK(wagon.brakePipe.Pressure() > 4.9); // released, as the AI wants every vehicle before it starts (TController::CheckVehicles()) CHECK((wagon.brakes.distributor->GetBrakeStatus() & (b_on | b_hld)) == 0); CHECK(wagon.brakes.cylinderPressure < 0.1); @@ -106,7 +106,7 @@ TEST_CASE("brake pipe: a passenger train, whose exchange was stable in one step, for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); auto &car{train[i].physics()}; - CHECK(std::abs(car.brakes.distributor->GetVRP() - car.brakePipe.pressure) < 0.005); + CHECK(std::abs(car.brakes.distributor->GetVRP() - car.brakePipe.Pressure()) < 0.005); CHECK((car.brakes.distributor->GetBrakeStatus() & (b_on | b_hld)) == 0); CHECK(car.brakes.cylinderPressure < 0.1); } diff --git a/tests/unit/test_brakes.cpp b/tests/unit/test_brakes.cpp index 43ebdd098..1541cb9d3 100644 --- a/tests/unit/test_brakes.cpp +++ b/tests/unit/test_brakes.cpp @@ -114,14 +114,14 @@ TEST_CASE("brakes: a dead EN57 hauled with the brake hose alone charges from the car.brakePipe.reservoir->Act(); car.mainPipe.reservoir->CreatePress(0.0); car.mainPipe.reservoir->Act(); - car.air.compressedVolume = 0.0; + car.air.Fill(0.0); } locomotive.hold_brake_pipe(5.0); train.run(900.0); for (std::size_t i = 1; i < train.size(); ++i) { CAPTURE(i); auto &car{train[i].physics()}; - REQUIRE(car.mainPipe.pressure < 0.1); // no main reservoir pipe + REQUIRE(car.mainPipe.Pressure() < 0.1); // no main reservoir pipe CHECK(car.brakes.distributor->GetBRP() > 4.8); CHECK(car.brakes.distributor->GetCRP() > 4.8); CHECK(car.brakes.cylinderPressure < 0.1); diff --git a/tests/unit/test_cab.cpp b/tests/unit/test_cab.cpp index 2cbb7096d..a2b5faf5e 100644 --- a/tests/unit/test_cab.cpp +++ b/tests/unit/test_cab.cpp @@ -223,7 +223,7 @@ TEST_CASE("cab: the lamps and the buzzer of the security system left unattended" CHECK(blinked); CHECK(beeped); CHECK_FALSE(security.is_cabsignal_beeping()); - CHECK(eu07.brakePipe.pressure < 1.0); + CHECK(eu07.brakePipe.Pressure() < 1.0); CHECK(security.radiostop_available()); scenario.check(); } @@ -269,7 +269,7 @@ TEST_CASE("cab: the SM42's vigilance device switched off in the shunt mode, wher } CHECK(sm42.Vel > 1.0); CHECK_FALSE(blinked); - CHECK(sm42.brakePipe.pressure > 3.5); + CHECK(sm42.brakePipe.Pressure() > 3.5); scenario.act("shunt mode off"); scenario.notch_back(0); REQUIRE(sm42.CurrentSwitch(false)); @@ -293,7 +293,7 @@ TEST_CASE("cab: the vigilance device of the SM42 kept in the shunt mode, by defa scenario.act("unattended in shunt mode"); CHECK(unattended(scenario, 120)); CHECK(sm42.ShuntMode); - CHECK(sm42.brakePipe.pressure < 1.0); + CHECK(sm42.brakePipe.Pressure() < 1.0); scenario.check(); } @@ -324,7 +324,7 @@ TEST_CASE("cab: the SM42's vigilance alarm on, not cleared by switching into the CHECK(security.is_vigilance_blinking()); CHECK(security.is_beeping()); CHECK(security.is_braking()); - CHECK(sm42.brakePipe.pressure < 1.0); + CHECK(sm42.brakePipe.Pressure() < 1.0); scenario.act("acknowledged"); sm42.SecuritySystemReset(); scenario.train().run(1.0, scenario.line()); diff --git a/tests/unit/test_camshaft.cpp b/tests/unit/test_camshaft.cpp index 2c8a580d9..7231b2c5b 100644 --- a/tests/unit/test_camshaft.cpp +++ b/tests/unit/test_camshaft.cpp @@ -71,7 +71,7 @@ void running(physics::Vehicle &Locomotive, int const Direction, int const Positi Locomotive.CabActive = 1; Locomotive.DirActive = Direction; Locomotive.lineBreaker.Close(); - Locomotive.brakePipe.pressure = 5.0; // bar, the pressure switch lets the line contactors close + Locomotive.brakePipe.SetPressure(5.0); // bar, the pressure switch lets the line contactors close Locomotive.brakes.cylinderPressure = 0.0; Locomotive.lineContactors.Close(); Locomotive.MainCtrlActualPos = Position; diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index 68f652b7f..8566af2f9 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -55,8 +55,8 @@ std::vector state() { {"AutoRelayFlag", [](auto const &M) { return flag(M.AutoRelayFlag); }}, {"ConverterAllow", [](auto const &M) { return flag(M.converter.IsAllowed()); }}, {"Battery", [](auto const &M) { return flag(M.lowVoltage.IsBatteryOn()); }}, - {"CompressorAllow", [](auto const &M) { return flag(M.air.compressor.allow); }}, - {"CompressorListPos", [](auto const &M) { return M.air.compressor.listPosition; }}, + {"CompressorAllow", [](auto const &M) { return flag(M.air.compressor.IsAllowed()); }}, + {"CompressorListPos", [](auto const &M) { return M.air.compressor.ListPosition(); }}, {"DoorLock", [](auto const &M) { return flag(M.Doors.lock_enabled); }}, {"DoorStep", [](auto const &M) { return flag(M.Doors.step_enabled); }}, {"DoorRemoteOnly", [](auto const &M) { return flag(M.Doors.remote_only); }}, @@ -413,8 +413,8 @@ TEST_CASE("commands: every switch of the cab, worked on a pair standing under th {"PantPress", [](auto const &M) { return M.pantographAir.Pressure(); }}, {"GroundRelay", [](auto const &M) { return flag(M.protection.GroundHolds()); }}, {"ConverterFlag", [](auto const &M) { return flag(M.converter.IsRunning()); }}, - {"CompressorFlag", [](auto const &M) { return flag(M.air.compressor.running); }}, - {"Compressor", [](auto const &M) { return M.air.mainReservoirPressure; }}, + {"CompressorFlag", [](auto const &M) { return flag(M.air.compressor.IsRunning()); }}, + {"Compressor", [](auto const &M) { return M.air.MainReservoirPressure(); }}, {"MainCtrlActualPos", [](auto const &M) { return M.MainCtrlActualPos; }}, {"Itot", [](auto const &M) { return M.Itot; }}, {"FuseFlag", [](auto const &M) { return flag(M.FuseFlag); }}, diff --git a/tests/unit/test_compressor.cpp b/tests/unit/test_compressor.cpp index b4bc1a201..5694f2d65 100644 --- a/tests/unit/test_compressor.cpp +++ b/tests/unit/test_compressor.cpp @@ -26,7 +26,7 @@ vehicle compressor_vehicle(double const Delay, std::string const &Power = "Main" definition.set("Brake", "CompressorStartDelay", Delay); } vehicle vehicle{definition}; - vehicle->air.compressedVolume = 0.0; + vehicle->air.Fill(0.0); vehicle->LastSwitchingTime = 10.0; // nothing was switched lately return vehicle; } @@ -45,11 +45,11 @@ void run_compressor(vehicle &Vehicle, double const Seconds) { TEST_CASE("compressor: without a start delay the compressor starts with its power") { auto vehicle{compressor_vehicle(0.0)}; run_compressor(vehicle, 1.0); - REQUIRE_FALSE(vehicle->air.compressor.running); // no power, no compressor + REQUIRE_FALSE(vehicle->air.compressor.IsRunning()); // no power, no compressor vehicle->lineBreaker.Close(); run_compressor(vehicle, step); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: the compressor starts the delay after getting its power") { @@ -57,94 +57,94 @@ TEST_CASE("compressor: the compressor starts the delay after getting its power") vehicle->lineBreaker.Close(); run_compressor(vehicle, 4.9); - CHECK_FALSE(vehicle->air.compressor.running); - CHECK(vehicle->air.mainReservoirPressure == doctest::Approx(0.0)); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); + CHECK(vehicle->air.MainReservoirPressure() == doctest::Approx(0.0)); run_compressor(vehicle, 0.2); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); run_compressor(vehicle, 10.0); - CHECK(vehicle->air.mainReservoirPressure > 0.0); // and fills the reservoir + CHECK(vehicle->air.MainReservoirPressure() > 0.0); // and fills the reservoir } TEST_CASE("compressor: the delay starts over once the power is gone") { auto vehicle{compressor_vehicle(5.0)}; vehicle->lineBreaker.Close(); run_compressor(vehicle, 10.0); - REQUIRE(vehicle->air.compressor.running); + REQUIRE(vehicle->air.compressor.IsRunning()); vehicle->lineBreaker.Open(); // the engine stopped run_compressor(vehicle, 1.0); - CHECK_FALSE(vehicle->air.compressor.running); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); vehicle->lineBreaker.Close(); // and started again run_compressor(vehicle, 4.9); - CHECK_FALSE(vehicle->air.compressor.running); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); run_compressor(vehicle, 0.2); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: a compressor fed from the low voltage waits from the low voltage coming on") { auto vehicle{compressor_vehicle(5.0, "")}; // the default supply: the converter, the 110 V vehicle->lineBreaker.Close(); // which alone doesn't feed it run_compressor(vehicle, 10.0); - REQUIRE_FALSE(vehicle->air.compressor.running); + REQUIRE_FALSE(vehicle->air.compressor.IsRunning()); vehicle->lowVoltage.Set110vAvailableForTest(true); run_compressor(vehicle, 4.9); - CHECK_FALSE(vehicle->air.compressor.running); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); run_compressor(vehicle, 0.2); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: the pressure switch stops the compressor above the cut-out pressure") { auto vehicle{compressor_vehicle(0.0)}; vehicle->lineBreaker.Close(); - vehicle->air.compressedVolume = 8.5; // over MaxCP, in the reservoir of 1 m3 + vehicle->air.Fill(8.5); // over MaxCP, in the reservoir of 1 m3 run_compressor(vehicle, step); - CHECK(vehicle->air.compressor.governorLock); - CHECK_FALSE(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsGovernorLocked()); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: without a pressure switch the air over the cut-out pressure is vented") { auto vehicle{compressor_vehicle(0.0, "Main", 8.0)}; // MinCP the same as MaxCP: no pressure switch vehicle->lineBreaker.Close(); - vehicle->air.compressedVolume = 8.5; + vehicle->air.Fill(8.5); run_compressor(vehicle, step); - REQUIRE(vehicle->air.compressor.running); // nothing stops it - CHECK(vehicle->air.compressedVolume < 8.5 * 0.81); // a fifth of the air let out + REQUIRE(vehicle->air.compressor.IsRunning()); // nothing stops it + CHECK(vehicle->air.CompressedVolume() < 8.5 * 0.81); // a fifth of the air let out } TEST_CASE("compressor: an engine stopped before the delay passed counts the whole delay again") { auto vehicle{compressor_vehicle(30.0)}; vehicle->lineBreaker.Close(); // engine started run_compressor(vehicle, 20.0); - REQUIRE_FALSE(vehicle->air.compressor.running); + REQUIRE_FALSE(vehicle->air.compressor.IsRunning()); vehicle->lineBreaker.Open(); // engine stopped, 10 s short of the delay run_compressor(vehicle, 1.0); vehicle->lineBreaker.Close(); run_compressor(vehicle, 15.0); // 36 s since the first start, but only 15 s since this one - CHECK_FALSE(vehicle->air.compressor.running); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); run_compressor(vehicle, 15.1); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: the start delay holds back a compressor switched on by hand too") { auto vehicle{compressor_vehicle(30.0)}; - vehicle->air.compressor.start = start_t::manual; - vehicle->air.compressor.allow = true; // switch in the cabinet on before the engine start + vehicle->air.compressor.config.start = start_t::manual; + vehicle->air.compressor.Allow(true); // switch in the cabinet on before the engine start vehicle->lineBreaker.Close(); run_compressor(vehicle, 29.9); - CHECK_FALSE(vehicle->air.compressor.running); + CHECK_FALSE(vehicle->air.compressor.IsRunning()); run_compressor(vehicle, 0.2); - CHECK(vehicle->air.compressor.running); + CHECK(vehicle->air.compressor.IsRunning()); } TEST_CASE("compressor: the start delay is read from the brake section") { auto const delay{[](std::string const &Section) { - return vehicle{definition::load("wagon").set(Section, "CompressorStartDelay", 30)}->air.compressor.startDelay; + return vehicle{definition::load("wagon").set(Section, "CompressorStartDelay", 30)}->air.compressor.config.startDelay; }}; CHECK(delay("Brake") == doctest::Approx(30.0)); CHECK(delay("Cntrl") == doctest::Approx(0.0)); // the key isn't taken from the control section @@ -174,7 +174,7 @@ definition generator_vehicle(double const ConverterDelay, double const Compresso TEST_CASE("compressor: fed from the converter it waits for the converter start delay") { vehicle loco{generator_vehicle(30.0, 0.0)}; - REQUIRE(loco->air.compressor.supply == physics::CompressorSupply::converter); + REQUIRE(loco->air.compressor.config.supply == physics::CompressorSupply::converter); REQUIRE(loco->converter.config.startDelay == doctest::Approx(30.0)); loco.run(1.0); // engine off @@ -183,23 +183,23 @@ TEST_CASE("compressor: fed from the converter it waits for the converter start d loco->lineBreaker.Close(); // engine started loco.run(25.0); CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); loco.run(10.0); CHECK(loco->lowVoltage.Is110vAvailable()); - CHECK(loco->air.compressor.running); + CHECK(loco->air.compressor.IsRunning()); } TEST_CASE("compressor: fed from the converter the start delay counts from the converter voltage") { vehicle loco{generator_vehicle(20.0, 10.0)}; - REQUIRE(loco->air.compressor.startDelay == doctest::Approx(10.0)); + REQUIRE(loco->air.compressor.config.startDelay == doctest::Approx(10.0)); loco.run(1.0); // engine off loco->lineBreaker.Close(); // engine started loco.run(25.0); REQUIRE(loco->lowVoltage.Is110vAvailable()); // the converter is up - CHECK_FALSE(loco->air.compressor.running); // but the compressor waits for its own delay as well + CHECK_FALSE(loco->air.compressor.IsRunning()); // but the compressor waits for its own delay as well loco.run(10.0); - CHECK(loco->air.compressor.running); + CHECK(loco->air.compressor.IsRunning()); } diff --git a/tests/unit/test_controls.cpp b/tests/unit/test_controls.cpp index 6d853f799..0879c2fae 100644 --- a/tests/unit/test_controls.cpp +++ b/tests/unit/test_controls.cpp @@ -301,16 +301,16 @@ TEST_CASE("controls: emergency stops by the alarm chain and the radio-stop") { scenario.wait(40.0); // the pipe emptied, the whole train braked to a stop CHECK(stopped(scenario)); - CHECK(cab.brakePipe.pressure < 0.5); + CHECK(cab.brakePipe.Pressure() < 0.5); CHECK(scenario.vehicle(2).brakes.cylinderPressure > 1.0); scenario.act("alarm chain reset"); scenario.vehicle(1).AlarmChainSwitch(false); scenario.wait(10.0); // the FV4a handle stays cut off the emptied pipe of an LSt locomotive (lock_old in UpdatePipePressure) // until the releaser is held - CHECK(cab.brakePipe.pressure < 0.5); + CHECK(cab.brakePipe.Pressure() < 0.5); recharge(scenario); - CHECK(cab.brakePipe.pressure > 4.5); + CHECK(cab.brakePipe.Pressure() > 4.5); scenario.get_going(); notch_up(scenario, 20, 1.0); scenario.wait(20.0); @@ -320,12 +320,12 @@ TEST_CASE("controls: emergency stops by the alarm chain and the radio-stop") { cab.RadiostopSwitch(true); scenario.wait(40.0); CHECK(stopped(scenario)); - CHECK(cab.brakePipe.pressure < 0.5); + CHECK(cab.brakePipe.Pressure() < 0.5); scenario.act("radio-stop reset"); cab.RadiostopSwitch(false); scenario.wait(10.0); recharge(scenario); - CHECK(cab.brakePipe.pressure > 4.5); + CHECK(cab.brakePipe.Pressure() > 4.5); scenario.check(); } @@ -353,7 +353,7 @@ TEST_CASE("controls: releasers and the universal brake buttons") { CHECK(cab.brakes.cylinderPressure < 0.5); CHECK(coach.brakes.cylinderPressure < coachbraked - 1.0); CHECK(wagon.brakes.cylinderPressure < wagonbraked - 0.5); - CHECK(cab.brakePipe.pressure < 4.0); // the pipe stays where the service application left it + CHECK(cab.brakePipe.Pressure() < 4.0); // the pipe stays where the service application left it wagonbraked = wagon.brakes.cylinderPressure; scenario.act("releaser of the wagon"); wagon.BrakeReleaser(1); @@ -370,7 +370,7 @@ TEST_CASE("controls: releasers and the universal brake buttons") { scenario.act("running"); cab.BrakeLevelSet(cab.brakes.driverValve->GetPos(bh_RP)); scenario.wait(60.0); - CHECK(cab.brakePipe.pressure > 4.8); + CHECK(cab.brakePipe.Pressure() > 4.8); CHECK(released(scenario)); scenario.check(); } @@ -403,7 +403,7 @@ TEST_CASE("controls: the ep brake of electric units") { if (i == 3) { // the ep brake works the cylinders of every car by wire, the pipe stays charged (by the first // application the EW58's pipe is still charging after the start-up) - CHECK(cab.brakePipe.pressure > 4.8); + CHECK(cab.brakePipe.Pressure() > 4.8); CHECK(cab.brakes.cylinderPressure > 1.0); CHECK(last.brakes.cylinderPressure > 1.0); } diff --git a/tests/unit/test_crew.cpp b/tests/unit/test_crew.cpp index 042f02c39..1ebcc03c9 100644 --- a/tests/unit/test_crew.cpp +++ b/tests/unit/test_crew.cpp @@ -208,7 +208,7 @@ TEST_CASE("crew: a locomotive under power left by its driver stops and stays bra auto const stoppedafter{seconds_to_stop(train, 120.0)}; CAPTURE(stoppedafter); CHECK(std::abs(train[0].speed()) <= 0.01); - CHECK(eu07.brakePipe.pressure < 1.0); // vented by the emergency position + CHECK(eu07.brakePipe.Pressure() < 1.0); // vented by the emergency position CHECK(eu07.brakes.cylinderPressure > 2.0); // it keeps standing, also on a slope, with the engine as the driver left it train.run(120.0, track{0.15, 0.02, test::catenary_3kv}); @@ -252,7 +252,7 @@ TEST_CASE("crew: a train left by its driver is braked through the whole of it") CAPTURE(stoppedafter); CHECK(std::abs(train[0].speed()) <= 0.01); CHECK(std::abs(train[2].speed()) <= 0.01); - CHECK(last.brakePipe.pressure < 1.0); + CHECK(last.brakePipe.Pressure() < 1.0); CHECK(last.brakes.cylinderPressure > 1.0); } diff --git a/tests/unit/test_definition.cpp b/tests/unit/test_definition.cpp index bed2aba2f..6c9deb7d3 100644 --- a/tests/unit/test_definition.cpp +++ b/tests/unit/test_definition.cpp @@ -76,32 +76,32 @@ TEST_CASE("definition: a compressor list, whose positions allow the compressor a .set("CompressorList", "Default", 1) .set("CompressorList", "rows", {{2, 2, 1, 1}, {1, 1, 1, 1}, {2, 1, 0.9, 0.9}})}; vehicle real{eu07, 0.0, "test", 1}; - CHECK(real->air.compressor.listPositions == 3); - CHECK(real->air.compressor.list[3][3] == 0); + CHECK(real->air.compressor.config.listPositions == 3); + CHECK(real->air.compressor.config.list[3][3] == 0); auto driven{test::driving(real)}; test::track const line{0.15, 0.0, test::catenary_3kv}; REQUIRE(test::start_up(driven, line)); - CHECK(real->air.compressor.listPosition == 1); + CHECK(real->air.compressor.ListPosition() == 1); test::drive(driven, line, 60.0); - CHECK(real->air.compressor.allow); - CHECK(real->air.mainReservoirPressure <= real->air.compressor.maxPressure + 0.05); - CHECK(real->air.mainReservoirPressure >= real->air.compressor.minPressure - 0.05); + CHECK(real->air.compressor.IsAllowed()); + CHECK(real->air.MainReservoirPressure() <= real->air.compressor.config.maxPressure + 0.05); + CHECK(real->air.MainReservoirPressure() >= real->air.compressor.config.minPressure - 0.05); // the second position doesn't let it run CHECK(real->ChangeCompressorPreset(2)); test::drive(driven, line, 2.0); - CHECK_FALSE(real->air.compressor.allow); - CHECK_FALSE(real->air.compressor.running); + CHECK_FALSE(real->air.compressor.IsAllowed()); + CHECK_FALSE(real->air.compressor.IsRunning()); // the third lets it, under limits of nothing: with no span between them for the governor, the reservoir over // the upper limit gets vented while the compressor runs on CHECK(real->ChangeCompressorPreset(3)); - auto const full{real->air.mainReservoirPressure}; + auto const full{real->air.MainReservoirPressure()}; test::drive(driven, line, 10.0); - CHECK(real->air.compressor.allow); - CHECK(real->air.compressor.running); - CHECK(real->air.mainReservoirPressure < full - 1.0); + CHECK(real->air.compressor.IsAllowed()); + CHECK(real->air.compressor.IsRunning()); + CHECK(real->air.MainReservoirPressure() < full - 1.0); // no further than the last position CHECK_FALSE(real->ChangeCompressorPreset(5)); - CHECK(real->air.compressor.listPosition == 3); + CHECK(real->air.compressor.ListPosition() == 3); } TEST_CASE("definition: the compressor's limits set apart for the rear cab") { @@ -113,11 +113,11 @@ TEST_CASE("definition: the compressor's limits set apart for the rear cab") { test::track const line{0.15, 0.0, test::catenary_3kv}; REQUIRE(test::start_up(driven, line)); test::drive(driven, line, 120.0); - CHECK(real->air.compressor.cabDependent); - CHECK(real->air.compressor.maxPressure == doctest::Approx(cab > 0 ? 8.7 : 6.0)); - CHECK(real->air.compressor.minPressure == doctest::Approx(cab > 0 ? 7.0 : 5.0)); - CHECK(real->air.mainReservoirPressure <= real->air.compressor.maxPressure + 0.05); - CHECK(real->air.mainReservoirPressure >= real->air.compressor.minPressure - 0.05); + CHECK(real->air.compressor.config.cabDependent); + CHECK(real->air.compressor.config.maxPressure == doctest::Approx(cab > 0 ? 8.7 : 6.0)); + CHECK(real->air.compressor.config.minPressure == doctest::Approx(cab > 0 ? 7.0 : 5.0)); + CHECK(real->air.MainReservoirPressure() <= real->air.compressor.config.maxPressure + 0.05); + CHECK(real->air.MainReservoirPressure() >= real->air.compressor.config.minPressure - 0.05); } } diff --git a/tests/unit/test_dynamic_brake_diesel.cpp b/tests/unit/test_dynamic_brake_diesel.cpp index a5ed0ece1..0f7f084de 100644 --- a/tests/unit/test_dynamic_brake_diesel.cpp +++ b/tests/unit/test_dynamic_brake_diesel.cpp @@ -227,7 +227,7 @@ TEST_CASE("diesel-electric dynamic brake: blended with the locomotive's air brak scenario.wait(6.0); REQUIRE(locomotive.Vel > 15.0); CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0)); - CHECK(locomotive.brakePipe.pressure < 4.6); + CHECK(locomotive.brakePipe.Pressure() < 4.6); CHECK((locomotive.brakes.cylinderPressure < 0.2) == blending); scenario.check(); } diff --git a/tests/unit/test_elf_controller.cpp b/tests/unit/test_elf_controller.cpp index c2d3847aa..c89d56ee5 100644 --- a/tests/unit/test_elf_controller.cpp +++ b/tests/unit/test_elf_controller.cpp @@ -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); } } diff --git a/tests/unit/test_feed_pipe.cpp b/tests/unit/test_feed_pipe.cpp index a7eba7c0c..50a7441de 100644 --- a/tests/unit/test_feed_pipe.cpp +++ b/tests/unit/test_feed_pipe.cpp @@ -48,7 +48,7 @@ double off_pressure(test::consist &Train, double const Pressure, double const Se for (int step = 0; step < steps; ++step) { Train.step({}, Dt); for (std::size_t i = 0; i < Train.size(); ++i) { - off = std::max(off, std::abs(Train[i]->mainPipe.pressure - Pressure)); + off = std::max(off, std::abs(Train[i]->mainPipe.Pressure() - Pressure)); } } return off; @@ -67,13 +67,13 @@ evening_out even_out(Builder Train, int const Count, double const Pressure, doub Train(train, Count); for (std::size_t i = 0; i < train.size(); ++i) { auto &physics{train[i].physics()}; - REQUIRE(physics.air.mainReservoirVolume > 0.0); + REQUIRE(physics.air.config.mainReservoirVolume > 0.0); auto const pressure{i == 0 ? Pressure : Pressure - 1.0}; - physics.air.compressedVolume = pressure * physics.air.mainReservoirVolume; - physics.air.mainReservoirPressure = pressure; + physics.air.Fill(pressure * physics.air.config.mainReservoirVolume); + physics.air.SetPressureForTest(pressure); physics.mainPipe.reservoir->CreatePress(pressure); physics.mainPipe.reservoir->Act(); - physics.mainPipe.pressure = pressure; + physics.mainPipe.SetPressure(pressure); } evening_out result; auto const &first{train[0].physics()}; @@ -81,22 +81,22 @@ evening_out even_out(Builder Train, int const Count, double const Pressure, doub std::vector previous(train.size()); std::vector change(train.size()); for (std::size_t i = 0; i < train.size(); ++i) { - previous[i] = train[i]->mainPipe.pressure; + previous[i] = train[i]->mainPipe.Pressure(); } auto time{0.0}; while (time < 60.0) { train.step({}, Dt); time += Dt; for (std::size_t i = 0; i < train.size(); ++i) { - auto const step{train[i]->mainPipe.pressure - previous[i]}; + auto const step{train[i]->mainPipe.Pressure() - previous[i]}; if (step * change[i] < 0.0) { // turned back result.zigzag = std::max(result.zigzag, std::min(std::abs(step), std::abs(change[i]))); } change[i] = step; - previous[i] = train[i]->mainPipe.pressure; + previous[i] = train[i]->mainPipe.Pressure(); } - if (std::abs(first.air.mainReservoirPressure - last.air.mainReservoirPressure) < 0.05) { + if (std::abs(first.air.MainReservoirPressure() - last.air.MainReservoirPressure()) < 0.05) { result.time = time; break; } @@ -113,15 +113,15 @@ double charging_time(Builder Train, int const Count, double const Pressure, doub train[0].hold_main_reservoir(Pressure); for (std::size_t i = 1; i < train.size(); ++i) { auto &physics{train[i].physics()}; - REQUIRE(physics.air.mainReservoirVolume == 0.0); + REQUIRE(physics.air.config.mainReservoirVolume == 0.0); physics.mainPipe.reservoir->CreatePress(0.0); physics.mainPipe.reservoir->Act(); - physics.mainPipe.pressure = 0.0; + physics.mainPipe.SetPressure(0.0); } auto const &first{train[0].physics()}; auto const &last{train[train.size() - 1].physics()}; auto time{0.0}; - while ((last.mainPipe.pressure < 1.0 || std::abs(last.mainPipe.pressure - first.mainPipe.pressure) > 0.2) && time < 60.0) { + while ((last.mainPipe.Pressure() < 1.0 || std::abs(last.mainPipe.Pressure() - first.mainPipe.Pressure()) > 0.2) && time < 60.0) { train.step({}, Dt); time += Dt; } diff --git a/tests/unit/test_figures.cpp b/tests/unit/test_figures.cpp index 718d722f7..7eb7429c9 100644 --- a/tests/unit/test_figures.cpp +++ b/tests/unit/test_figures.cpp @@ -17,21 +17,21 @@ TEST_CASE("figures: a run split into parts by the events, each from the last ste test::figures figures; auto &physics{eu07.physics()}; physics.V = 10.0; - physics.brakePipe.pressure = 5.0; + physics.brakePipe.SetPressure(5.0); figures.sample(0.0, physics); figures.mark("brake"); figures.mark("hard"); for (int i = 1; i <= 10; ++i) { physics.V = 10.0 - i; physics.DistCounter += 0.005; - physics.brakePipe.pressure = 3.5; + physics.brakePipe.SetPressure(3.5); physics.brakes.cylinderPressure = 0.4 * i; figures.sample(i, physics); } figures.mark("release"); - physics.brakePipe.pressure = 4.0; + physics.brakePipe.SetPressure(4.0); figures.sample(11.0, physics); - physics.brakePipe.pressure = 5.0; + physics.brakePipe.SetPressure(5.0); figures.sample(12.0, physics); auto const lines{figures.lines()}; diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index 695f45193..ca2dc48a8 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -90,7 +90,7 @@ bool start_on_genset(vehicle &Vehicle, track const &Track = no_wire, double cons cab.CompressorSwitch(true); } run(Vehicle, 1.0, Track); - if (cab.lineBreaker.IsClosed() && cab.converter.IsRunning() && cab.mainPipe.pressure >= 4.5) { + if (cab.lineBreaker.IsClosed() && cab.converter.IsRunning() && cab.mainPipe.Pressure() >= 4.5) { // and the brakes let go test::release_brakes(cab); for (auto wait = 0; wait < 120 && cab.brakes.cylinderPressure > 0.05; ++wait) { diff --git a/tests/unit/test_horn.cpp b/tests/unit/test_horn.cpp index 021531986..65c600944 100644 --- a/tests/unit/test_horn.cpp +++ b/tests/unit/test_horn.cpp @@ -57,19 +57,19 @@ TEST_CASE("horn: a pneumatic horn sounds on the air of the main reservoir only") auto vehicle{horn_vehicle(test::definition::load("wagon"))}; REQUIRE(vehicle->HornSupply == horn_supply::air); // the default - vehicle->air.mainReservoirPressure = 6.5; + vehicle->air.SetPressureForTest(6.5); CHECK(vehicle->SoundingHorns(allhorns) == allhorns); - vehicle->air.mainReservoirPressure = 0.0; // the reservoir is empty + vehicle->air.SetPressureForTest(0.0); // the reservoir is empty CHECK(vehicle->SoundingHorns(allhorns) == 0); } TEST_CASE("horn: a vehicle without a main reservoir takes the horn air from the main pipe") { test::vehicle vehicle{test::definition::load("wagon")}; - REQUIRE(vehicle->air.mainReservoirVolume == 0.0); + REQUIRE(vehicle->air.config.mainReservoirVolume == 0.0); - vehicle->mainPipe.pressure = 5.0; + vehicle->mainPipe.SetPressure(5.0); CHECK(vehicle->SoundingHorns(horn::low) == horn::low); - vehicle->mainPipe.pressure = 0.0; + vehicle->mainPipe.SetPressure(0.0); CHECK(vehicle->SoundingHorns(horn::low) == 0); } @@ -78,7 +78,7 @@ TEST_CASE("horn: an electric horn sounds on the low voltage, whatever the air") REQUIRE(vehicle->HornSupply == horn_supply::electric); REQUIRE(vehicle->Horn3Supply == horn_supply::electric); // the third horn follows the others unless told otherwise - vehicle->air.mainReservoirPressure = 0.0; + vehicle->air.SetPressureForTest(0.0); vehicle->lowVoltage.Set24vAvailableForTest(true); CHECK(vehicle->SoundingHorns(allhorns) == allhorns); vehicle->lowVoltage.Set24vAvailableForTest(false); @@ -90,10 +90,10 @@ TEST_CASE("horn: the third horn can have a supply of its own, an electric horn o REQUIRE(vehicle->HornSupply == horn_supply::air); REQUIRE(vehicle->Horn3Supply == horn_supply::electric); - vehicle->air.mainReservoirPressure = 0.0; + vehicle->air.SetPressureForTest(0.0); vehicle->lowVoltage.Set24vAvailableForTest(true); CHECK(vehicle->SoundingHorns(allhorns) == 4); - vehicle->air.mainReservoirPressure = 6.5; + vehicle->air.SetPressureForTest(6.5); vehicle->lowVoltage.Set24vAvailableForTest(false); CHECK(vehicle->SoundingHorns(allhorns) == (horn::low | horn::high)); } @@ -101,16 +101,16 @@ TEST_CASE("horn: the third horn can have a supply of its own, an electric horn o TEST_CASE("horn: a vehicle without any air, a road vehicle say, sounds its pneumatic horn as before") { // no main reservoir and no main pipe connection at either end test::vehicle vehicle{test::definition::load("wagon").set("BuffCoupl", "AllowedFlag", 3)}; - REQUIRE(vehicle->air.mainReservoirVolume == 0.0); - vehicle->mainPipe.pressure = 0.0; + REQUIRE(vehicle->air.config.mainReservoirVolume == 0.0); + vehicle->mainPipe.SetPressure(0.0); CHECK(vehicle->SoundingHorns(allhorns) == allhorns); } TEST_CASE("horn: a pneumatic horn sounds from the threshold pressure up") { auto vehicle{horn_vehicle(test::definition::load("wagon"))}; - vehicle->air.mainReservoirPressure = physics::Vehicle::HornMinPressure; + vehicle->air.SetPressureForTest(physics::Vehicle::HornMinPressure); CHECK(vehicle->SoundingHorns(horn::low) == horn::low); - vehicle->air.mainReservoirPressure = physics::Vehicle::HornMinPressure - 0.01; + vehicle->air.SetPressureForTest(physics::Vehicle::HornMinPressure - 0.01); CHECK(vehicle->SoundingHorns(horn::low) == 0); } diff --git a/tests/unit/test_line_contactors.cpp b/tests/unit/test_line_contactors.cpp index 4429189d6..f332b4432 100644 --- a/tests/unit/test_line_contactors.cpp +++ b/tests/unit/test_line_contactors.cpp @@ -10,7 +10,7 @@ namespace { test::vehicle locomotive(bool const Pressureswitch) { test::vehicle vehicle{test::definition::load("wagon").set("Engine", "PressureSwitch", Pressureswitch)}; vehicle->lineContactors.Open(); // the line contactors open - vehicle->brakePipe.pressure = 5.0; + vehicle->brakePipe.SetPressure(5.0); return vehicle; } diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index 567834712..74e59d392 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -24,7 +24,7 @@ vehicle ready(std::string_view const Interlock) { vehicle locomotive{loaded}; locomotive->lineBreaker.Close(); locomotive->DirActive = 1; - locomotive->brakePipe.pressure = 5.0; + locomotive->brakePipe.SetPressure(5.0); locomotive->brakes.cylinderPressure = 0.0; return locomotive; } @@ -133,7 +133,7 @@ bool close_line_contactors(test::driven const &Driven) { // the brakes released and the cylinders empty enough for the pressure switch to let the vehicle start void release(test::driven const &Driven) { test::release_brakes(Driven.cab); - for (int i = 0; i < 90 && (Driven.controlling.brakes.cylinderPressure > 0.1 || Driven.controlling.brakePipe.pressure < 4.8); ++i) { + for (int i = 0; i < 90 && (Driven.controlling.brakes.cylinderPressure > 0.1 || Driven.controlling.brakePipe.Pressure() < 4.8); ++i) { test::drive(Driven, line, 1.0); } } @@ -302,14 +302,14 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of TEST_CASE("louvres: closed until the main reservoir reaches the pressure that opens them") { vehicle et22{definition::fiz("et22_v3/201e-w")}; CHECK(et22->LouvresOpenPressure == doctest::Approx(5.0)); // by default - et22->air.mainReservoirPressure = 4.9; + et22->air.SetPressureForTest(4.9); CHECK(et22->LouvresClosed()); - et22->air.mainReservoirPressure = 5.0; + et22->air.SetPressureForTest(5.0); CHECK_FALSE(et22->LouvresClosed()); vehicle given{definition::fiz("et22_v3/201e-w").set("Cntrl", "LouvresOpenPressure", 4.0)}; - given->air.mainReservoirPressure = 4.5; + given->air.SetPressureForTest(4.5); CHECK_FALSE(given->LouvresClosed()); - given->air.mainReservoirPressure = 3.9; + given->air.SetPressureForTest(3.9); CHECK(given->LouvresClosed()); } diff --git a/tests/unit/test_mains_before_pantographs.cpp b/tests/unit/test_mains_before_pantographs.cpp index 309556072..ea615d1f5 100644 --- a/tests/unit/test_mains_before_pantographs.cpp +++ b/tests/unit/test_mains_before_pantographs.cpp @@ -57,9 +57,9 @@ void switch_auxiliaries_on(test::vehicle &Loco) { // what the main reservoir gains over the given time [bar]; the compressor of the locomotive adds some 0.07 bar a second double reservoir_gain(test::vehicle &Loco, double const Seconds, test::track const &Track) { - auto const before{Loco->air.compressedVolume}; + auto const before{Loco->air.CompressedVolume()}; Loco.run(Seconds, Track); - return (Loco->air.compressedVolume - before) / Loco->air.mainReservoirVolume; + return (Loco->air.CompressedVolume() - before) / Loco->air.config.mainReservoirVolume; } // the locomotive started up the way the driver does it, the brakes released, then the master controller taken to the @@ -168,7 +168,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres REQUIRE(loco->pantographCircuit.SupplyVoltage() == 0.0); switch_auxiliaries_on(loco); REQUIRE(loco->converter.IsAllowed()); - REQUIRE(loco->air.compressor.allow); + REQUIRE(loco->air.compressor.IsAllowed()); // the line breaker closed on the battery, the pantographs down: there's nothing to run them on CHECK(reservoir_gain(loco, 20.0, line) < 0.01); @@ -176,7 +176,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres CHECK_FALSE(loco->MainCircuitPowered()); CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); // the pantograph up: the converter starts, and the compressor on its 110 V raise_pantograph(loco); @@ -185,7 +185,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres CHECK(loco->MainCircuitPowered()); CHECK(loco->converter.IsRunning()); CHECK(loco->lowVoltage.Is110vAvailable()); - CHECK(loco->air.compressor.running); + CHECK(loco->air.compressor.IsRunning()); // the voltage gone they stop, behind the line breaker which stays closed auto const *track{&line}; @@ -209,14 +209,14 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres CHECK_FALSE(loco->MainCircuitPowered()); CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); } TEST_CASE("mains before pantographs: with the flag whatever else the main circuit feeds waits for the traction voltage too") { // a compressor on the main circuit rather than the converter's 110 V, the motor blowers, the blowers of the starting // resistors, the heating test::vehicle loco{ep05(true).set("Brake", "CompressorPower", "Main"), 0.0, "test", 1}; - REQUIRE(loco->air.compressor.supply == physics::CompressorSupply::mainCircuit); + REQUIRE(loco->air.compressor.config.supply == physics::CompressorSupply::mainCircuit); REQUIRE(loco->HeatingPowerSource.SourceType == TPowerSource::Main); prepare(loco); close_line_breaker(loco); @@ -228,7 +228,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui loco.hold_main_reservoir(-1.0); CHECK(reservoir_gain(loco, 10.0, line) < 0.01); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); CHECK_FALSE(loco->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot == 0.0); CHECK_FALSE(loco->trainHeating.IsOn()); @@ -238,7 +238,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui REQUIRE(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(weak.voltage)); CHECK(reservoir_gain(loco, 10.0, weak) < 0.01); CHECK(loco->lineBreaker.IsClosed()); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); CHECK_FALSE(loco->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot == 0.0); CHECK_FALSE(loco->trainHeating.IsOn()); @@ -247,7 +247,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui raise_pantograph(loco); REQUIRE(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); - CHECK(loco->air.compressor.running); + CHECK(loco->air.compressor.IsRunning()); CHECK(loco->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot > 0.0); CHECK(loco->trainHeating.IsOn()); @@ -265,14 +265,14 @@ TEST_CASE("mains before pantographs: without the flag the converter and the comp CHECK(loco->MainCircuitPowered()); CHECK(loco->converter.IsRunning()); CHECK(loco->lowVoltage.Is110vAvailable()); - CHECK(loco->air.compressor.running); + CHECK(loco->air.compressor.IsRunning()); // too low a voltage opens the line breaker, and they stop with it loco.run(5.0, weak); CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); - CHECK_FALSE(loco->air.compressor.running); + CHECK_FALSE(loco->air.compressor.IsRunning()); } // the undervoltage trip was also what cut the traction motors off when the voltage went: the line contactors open diff --git a/tests/unit/test_pressure_switch.cpp b/tests/unit/test_pressure_switch.cpp index a45260b49..1fe1c76fb 100644 --- a/tests/unit/test_pressure_switch.cpp +++ b/tests/unit/test_pressure_switch.cpp @@ -74,13 +74,13 @@ void apply_independent_brake(test::vehicle &Loco, test::driven const &Driven) { Loco->IncLocalBrakeLevel(LocalBrakePosNo); test::drive(Driven, line, 20.0); REQUIRE(Loco->brakes.cylinderPressure == doctest::Approx(3.8).epsilon(0.03)); - REQUIRE(Loco->brakePipe.pressure > 4.8); + REQUIRE(Loco->brakePipe.Pressure() > 4.8); } void emergency_application(test::vehicle &Loco, test::driven const &Driven) { Loco->BrakeLevelSet(Loco->brakes.driverValve->GetPos(bh_EB)); test::drive(Driven, line, 10.0); - REQUIRE(Loco->brakePipe.pressure < 1.0); + REQUIRE(Loco->brakePipe.Pressure() < 1.0); } } // namespace @@ -138,8 +138,8 @@ TEST_CASE("pressure switch: without its brake cylinder half the brake pipe still SUBCASE("a service application") { loco->BrakeLevelSet(loco->brakes.driverValve->GetPos(bh_FB)); test::drive(driven, line, 15.0); - REQUIRE(loco->brakePipe.pressure < 3.6); - REQUIRE(loco->brakePipe.pressure > 3.0); + REQUIRE(loco->brakePipe.Pressure() < 3.6); + REQUIRE(loco->brakePipe.Pressure() > 3.0); } SUBCASE("an emergency application") { emergency_application(loco, driven); @@ -164,7 +164,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller loco->AlarmChainSwitch(true); } test::drive(driven, line, 10.0); - REQUIRE(loco->brakePipe.pressure < emergency_pressure); + REQUIRE(loco->brakePipe.Pressure() < emergency_pressure); REQUIRE(loco->MainCtrlPos == 5); CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::front].is_active); @@ -210,10 +210,10 @@ TEST_CASE("pressure switch: a service application with the master controller on // the last service position of the FV4a, 2.8 bar in the pipe loco->BrakeLevelSet(5.0); - auto lowest{loco->brakePipe.pressure}; + auto lowest{loco->brakePipe.Pressure()}; for (int second = 0; second < 60; ++second) { test::drive(driven, line, 1.0); - lowest = std::min(lowest, loco->brakePipe.pressure); + lowest = std::min(lowest, loco->brakePipe.Pressure()); } MESSAGE("the lowest brake pipe pressure of the service application: " << lowest << " bar"); REQUIRE(lowest < 3.0); @@ -273,7 +273,7 @@ TEST_CASE("pressure switch: after the emergency application the driver's start-u CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); - REQUIRE(loco->brakePipe.pressure < emergency_pressure); + REQUIRE(loco->brakePipe.Pressure() < emergency_pressure); // and it stays so test::drive(driven, line, 30.0); CHECK(loco->lineBreaker.IsClosed()); @@ -283,7 +283,7 @@ TEST_CASE("pressure switch: after the emergency application the driver's start-u // the pressure switch lets the start be made test::release_brakes(driven.cab); for (int i = 0; i < 180 && loco->protection.PressureSwitchTripped(); ++i) { - loco->BrakeReleaser(loco->brakePipe.pressure < 3.0 ? 1 : 0); + loco->BrakeReleaser(loco->brakePipe.Pressure() < 3.0 ? 1 : 0); test::drive(driven, line, 1.0); } loco->BrakeReleaser(0); diff --git a/tests/unit/test_pullee.cpp b/tests/unit/test_pullee.cpp index d75fb2611..33f8bbfb5 100644 --- a/tests/unit/test_pullee.cpp +++ b/tests/unit/test_pullee.cpp @@ -43,7 +43,7 @@ struct hauled_train { void drain_feed_air(physics::Vehicle &Vehicle) { Vehicle.mainPipe.reservoir->CreatePress(0.0); Vehicle.mainPipe.reservoir->Act(); - Vehicle.air.compressedVolume = 0.0; + Vehicle.air.Fill(0.0); } // whether the real vehicle can go in a train at all: the road vehicles can't, nor can the draisine, which has no coupler @@ -79,7 +79,7 @@ TEST_CASE("pullee: a dead Vectron vents the brake pipe of the train hauling it, REQUIRE_FALSE(train.hauled->PulleeMode); train.run(120.0); CHECK(train.hauled->brakes.emergencyValve.flow > 0.0); - CHECK(train.locomotive->brakePipe.pressure < 4.95); // the pipe sags although the locomotive keeps feeding it + CHECK(train.locomotive->brakePipe.Pressure() < 4.95); // the pipe sags although the locomotive keeps feeding it CHECK(train.hauled->brakes.cylinderPressure > 0.4); CHECK(train.hauled.speed() < 30.0); } @@ -87,7 +87,7 @@ TEST_CASE("pullee: a dead Vectron vents the brake pipe of the train hauling it, hauled_train train{vectron, 60.0, true}; train.run(120.0); CHECK(train.hauled->brakes.emergencyValve.flow == 0.0); - CHECK(train.locomotive->brakePipe.pressure > 4.99); + CHECK(train.locomotive->brakePipe.Pressure() > 4.99); CHECK(train.hauled->brakes.cylinderPressure < 0.1); CHECK(train.hauled->Fb < 1.0); CHECK(train.hauled.speed() > 40.0); // running resistance alone @@ -115,13 +115,13 @@ TEST_CASE("pullee: an EU07 with a driver can't release the brakes of a dead Vect if (false == pullee) { // the Vectron has emptied the brake pipe, and both locomotives stand on an emergency application CHECK(hauled->lowVoltage.IsBatteryOn()); - CHECK(locomotive->brakePipe.pressure < 1.0); + CHECK(locomotive->brakePipe.Pressure() < 1.0); CHECK(locomotive->brakes.cylinderPressure > 3.0); CHECK(hauled->brakes.cylinderPressure > 3.0); continue; } CHECK_FALSE(hauled->lowVoltage.IsBatteryOn()); - CHECK(locomotive->brakePipe.pressure > 4.9); + CHECK(locomotive->brakePipe.Pressure() > 4.9); CHECK(locomotive->brakes.cylinderPressure < 0.1); CHECK(hauled->brakes.cylinderPressure < 0.1); // the driver notches up watching the ammeter @@ -180,7 +180,7 @@ TEST_CASE("pullee: a dead EU47 starts to drag once its main reservoir has leaked CHECK(hauled.brakes.cylinderPressure < 0.1); CHECK(hauled.Fb < 1.0); train.run(1020.0); // 20 minutes since the start - CHECK(hauled.mainPipe.pressure < hauled.brakes.spring.minForcePressure); + CHECK(hauled.mainPipe.Pressure() < hauled.brakes.spring.minForcePressure); if (pullee) { CHECK(hauled.Fb < 1.0); } @@ -262,17 +262,17 @@ TEST_CASE("pullee: the brake valves in the cab of a vehicle prepared for hauling driven->DecLocalBrakeLevel(LocalBrakePosNo); driven.run(20.0); REQUIRE(driven->brakes.cylinderPressure < 0.1); - auto const charged{driven->brakePipe.pressure}; + auto const charged{driven->brakePipe.Pressure()}; // full service braking with the driver's valve driven->BrakeLevelSet(driven->brakes.driverValve->GetPos(bh_FB)); driven.run(10.0); if (pullee) { CHECK(driven->brakes.driverValveFlow == 0.0); - CHECK(driven->brakePipe.pressure > charged - 0.1); + CHECK(driven->brakePipe.Pressure() > charged - 0.1); CHECK(driven->brakes.cylinderPressure < 0.1); } else { - CHECK(driven->brakePipe.pressure < charged - 0.5); + CHECK(driven->brakePipe.Pressure() < charged - 0.5); CHECK(driven->brakes.cylinderPressure > 1.0); } // and the emergency position @@ -280,10 +280,10 @@ TEST_CASE("pullee: the brake valves in the cab of a vehicle prepared for hauling driven.run(10.0); if (pullee) { CHECK(driven->brakes.driverValveFlow == 0.0); - CHECK(driven->brakePipe.pressure > charged - 0.1); + CHECK(driven->brakePipe.Pressure() > charged - 0.1); } else { - CHECK(driven->brakePipe.pressure < 1.0); + CHECK(driven->brakePipe.Pressure() < 1.0); } } } @@ -421,7 +421,7 @@ TEST_CASE("pullee: every real vehicle prepared for hauling runs free behind a lo CHECK(hauled.brakes.emergencyValve.flow == 0.0); CHECK(hauled.brakes.cylinderPressure < 0.1); CHECK(hauled.Fb < 1.0); - CHECK(train.locomotive->brakePipe.pressure > 4.99); + CHECK(train.locomotive->brakePipe.Pressure() > 4.99); CHECK(train.hauled.speed() > 40.0); } } diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index 88e7a3b99..b9d678436 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -161,7 +161,7 @@ void vehicle::step(track const &Track, double Dt) { fast_move(Track, Dt, location); } forces(Dt); - move(Track, Dt, location, m_physics->brakePipe.pressure); + move(Track, Dt, location, m_physics->brakePipe.Pressure()); } namespace { @@ -204,8 +204,8 @@ void vehicle::begin_step() { if (m_pipepressure >= 0.0) { m_physics->brakePipe.reservoir->CreatePress(m_pipepressure); } - if (m_reservoirpressure >= 0.0 && m_physics->air.mainReservoirVolume > 0.0) { - m_physics->air.compressedVolume = m_reservoirpressure * m_physics->air.mainReservoirVolume; + if (m_reservoirpressure >= 0.0 && m_physics->air.config.mainReservoirVolume > 0.0) { + m_physics->air.Fill(m_reservoirpressure * m_physics->air.config.mainReservoirVolume); } // vehicle_table::update(), before the forces m_physics->ComputeConstans(); @@ -335,7 +335,7 @@ void pair::step(track const &Track, double Dt) { } for (auto &placed : m_vehicles) { auto const &physics{placed.owner->physics()}; - placed.position += placed.heading * placed.owner->move(Track, Dt, TLocation{placed.position, 0.0, 0.0}, physics.brakePipe.pressure); + placed.position += placed.heading * placed.owner->move(Track, Dt, TLocation{placed.position, 0.0, 0.0}, physics.brakePipe.Pressure()); } // vehicle_table::update_brake_pipes() physics::Vehicle::UpdatePipeCouplers({&m_vehicles[0].owner->physics(), &m_vehicles[1].owner->physics()}, Dt); diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index ca3fb0934..b5cd7e78a 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -107,7 +107,7 @@ void TController::Activation() if( occupied->brakes.handlePositions > 0 && ( BrakeSystem == TBrakeSystem::Pneumatic || BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) { - occupied->brakes.pipeLimiterPressure = occupied->brakePipe.pressure; + occupied->brakes.pipeLimiterPressure = occupied->brakePipe.Pressure(); occupied->ActFlowSpeed = 0; } BrakeLevelSet( occupied->brakes.handlePosition ); @@ -703,7 +703,7 @@ TController::determine_consist_state() { Ready = true; // wstępnie gotowy fReady = 0.0; // założenie, że odhamowany IsConsistBraked = occupied->brakes.kind == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ? occupied->brakes.cylinderPressure > 2.0 : - occupied->brakePipe.pressure < std::max(3.9, occupied->brakes.actualPressure.PipePressureVal) + 0.1; + occupied->brakePipe.Pressure() < std::max(3.9, occupied->brakes.actualPressure.PipePressureVal) + 0.1; fAccGravity = 0.0; // przyspieszenie wynikające z pochylenia IsAnyCouplerStretched = false; IsAnyDoorOnlyOpen[ VehicleSide::right ] = IsAnyDoorOnlyOpen[ VehicleSide::left ] = false; @@ -729,7 +729,7 @@ TController::determine_consist_state() { if( ( vehicle->brakes.kind != TBrakeSystem::Individual ) && ( vehicle->brakes.maxCylinderPressure[ 3 ] > 0.0 ) && ( false == TestFlag( vehicle->brakes.distributor->GetBrakeStatus(), b_dmg ) ) ) { // a brake cut out doesn't count - chargelevel = std::min( { chargelevel, vehicle->brakePipe.pressure, vehicle->brakes.distributor->GetBRP() } ); + chargelevel = std::min( { chargelevel, vehicle->brakePipe.Pressure(), vehicle->brakes.distributor->GetBRP() } ); } auto const wasready { Ready }; if( released || Ready ) { @@ -751,14 +751,14 @@ TController::determine_consist_state() { // Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka... if( bp >= 0.4 && (AIControllFlag || Global.AITrainman && occupied->Vel < EU07_AI_NOMOVEMENT && !is_emu() && !is_dmu()) && BrakeCtrlPosition == gbh_RP // jest pozycja jazdy && false == TestFlag(vehicle->brakes.distributor->GetBrakeStatus(), b_dmg) // brake isn't broken - && vehicle->brakePipe.pressure - occupied->brakes.driverValve->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy - && vehicle->brakes.distributor->GetCRP() > vehicle->brakePipe.pressure + 0.12 ) { // wg UIC określone sztywno na 0.04 + && vehicle->brakePipe.Pressure() - occupied->brakes.driverValve->GetRP() > -0.1 // jeśli ciśnienie jak dla jazdy + && vehicle->brakes.distributor->GetCRP() > vehicle->brakePipe.Pressure() + 0.12 ) { // wg UIC określone sztywno na 0.04 // za dużo w zbiorniku // indywidualne luzowanko vehicle->BrakeReleaser(1); } if (bp < 0.1 && (AIControllFlag || Global.AITrainman) && false == TestFlag(vehicle->brakes.distributor->GetBrakeStatus(), b_dmg) // brake isn't broken - && vehicle->brakes.distributor->GetCRP() < vehicle->brakePipe.pressure - 0.1) { + && vehicle->brakes.distributor->GetCRP() < vehicle->brakePipe.Pressure() - 0.1) { // już nie jest za dużo w zbiorniku // koniec indywidualnego luzowanka vehicle->BrakeReleaser(0); @@ -826,9 +826,9 @@ TController::determine_consist_state() { IsAnyConverterOverloadRelayOpen |= vehicle->converter.IsOverloaded(); IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; IsAnyGroundRelayOpen |= !vehicle->protection.GroundHolds(); - IsAnyCompressorPresent |= vehicle->air.compressor.speed > 0.0; - IsAnyCompressorEnabled |= vehicle->air.compressor.speed > 0.0 ? (vehicle->air.compressor.allow || vehicle->air.compressor.start == start_t::automatic) && vehicle->air.compressor.allowLocal : false; - IsAnyCompressorExplicitlyEnabled |= vehicle->air.compressor.speed > 0.0 ? vehicle->air.compressor.allow && vehicle->air.compressor.allowLocal : false; + IsAnyCompressorPresent |= vehicle->air.compressor.config.speed > 0.0; + IsAnyCompressorEnabled |= vehicle->air.compressor.config.speed > 0.0 ? (vehicle->air.compressor.IsAllowed() || vehicle->air.compressor.config.start == start_t::automatic) && vehicle->air.compressor.LocalSwitchOn() : false; + IsAnyCompressorExplicitlyEnabled |= vehicle->air.compressor.config.speed > 0.0 ? vehicle->air.compressor.IsAllowed() && vehicle->air.compressor.LocalSwitchOn() : false; IsAnyConverterPresent |= vehicle->converter.config.start != start_t::disabled; IsAnyConverterEnabled |= ( vehicle->converter.IsAllowed() || vehicle->converter.config.start == start_t::automatic ) && vehicle->converter.LocalSwitchOn(); IsAnyConverterExplicitlyEnabled |= vehicle->converter.IsAllowed() && vehicle->converter.LocalSwitchOn(); @@ -898,15 +898,15 @@ TController::determine_consist_state() { // a human driver's handle, which BrakeCtrlPosition doesn't follow occupied->brakes.handlePositionSmooth > occupied->brakes.driverValve->GetPos( bh_RP ) + 0.2 }; auto const reference { - brake_charge::reference( occupied->brakePipe.pressure, std::min( occupied->brakes.driverValve->GetRP(), 5.0 ), trainbrakeapplied ) }; + brake_charge::reference( occupied->brakePipe.Pressure(), std::min( occupied->brakes.driverValve->GetRP(), 5.0 ), trainbrakeapplied ) }; // air to charge with: the engine prepared, the main reservoir above what the pipe charges to, and the driver's // brake valve feeding the pipe at the head of the train. a train still being prepared from cold can't charge, // nor one whose pipe is locked (unlocked by control_releaser()): it waits without that counting as a stall, held // by its brakes as it can't release them either auto const supplied { iEngineActive - && ( std::max( mvControlling->air.mainReservoirPressure, occupied->air.mainReservoirPressure ) > reference ) - && ( occupied->brakePipe.pressure >= reference - brake_charge::margin ) }; + && ( std::max( mvControlling->air.MainReservoirPressure(), occupied->air.MainReservoirPressure() ) > reference ) + && ( occupied->brakePipe.Pressure() >= reference - brake_charge::margin ) }; auto const wasstalled { BrakeCharge.stalled }; IsConsistCharged = brake_charge::charged( BrakeCharge, chargelevel, reference, ElapsedTime, supplied ); if( BrakeCharge.stalled && ( false == wasstalled ) ) { diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index e665c6248..5233b6743 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -116,7 +116,7 @@ bool TController::PrepareEngine() else { // jeżeli jest wystarczające ciśnienie w pantografach if( false == pantographUnit->pantographAir.IsConnectedToMainReservoir() - || pantographUnit->pantographAir.Pressure() <= pantographUnit->mainPipe.pressure ) { // kurek przełączony albo główna już pompuje + || pantographUnit->pantographAir.Pressure() <= pantographUnit->mainPipe.Pressure() ) { // kurek przełączony albo główna już pompuje cue_action( driver_hint::pantographcompressoroff ); // sprężarkę pantografów można już wyłączyć } } @@ -163,7 +163,7 @@ bool TController::PrepareEngine() if( IsAnyCompressorPresent && IsAnyConverterEnabled ) { cue_action( driver_hint::compressoron ); } - if( mvControlling->mainPipe.pressure < 4.5 && mvControlling->air.mainReservoirVolume > 0.0 ) { + if( mvControlling->mainPipe.Pressure() < 4.5 && mvControlling->air.config.mainReservoirVolume > 0.0 ) { cue_action( driver_hint::waitpressuretoolow ); } // enable motor blowers @@ -207,7 +207,7 @@ bool TController::PrepareEngine() && false == IsAnyLineBreakerOpen && ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled ) && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ) - && ( mvControlling->mainPipe.pressure > 4.5 || mvControlling->air.mainReservoirVolume == 0.0 ); + && ( mvControlling->mainPipe.Pressure() > 4.5 || mvControlling->air.config.mainReservoirVolume == 0.0 ); } if( true == isready ) { diff --git a/vehicle/ai/force.cpp b/vehicle/ai/force.cpp index 69967d99e..b8cc3c823 100644 --- a/vehicle/ai/force.cpp +++ b/vehicle/ai/force.cpp @@ -603,7 +603,7 @@ void TController::control_releaser() { brake_releaser::conditions state; state.acceleration_desired = AccDesired; - state.pipe_pressure = occupied->brakePipe.pressure; + state.pipe_pressure = occupied->brakePipe.Pressure(); state.cylinder_pressure = occupied->brakes.cylinderPressure; state.control_pressure = occupied->brakes.distributor->GetCRP(); state.velocity = occupied->Vel; @@ -671,7 +671,7 @@ void TController::control_main_pipe() { auto const departblocked { is_departure_blocked( DepartBlockedFSDelay ) }; if( (drivingFlags.oerlikons || true == IsCargoTrain || departblocked) && BrakeCtrlPosition == gbh_RP && AbsAccS < 0.03 && AccDesired > -0.03 && VelDesired - occupied->Vel > 2.0 && fReady > 0.35 && ( occupied->brakes.equivalentPipePressure < 4.5 || departblocked ) // don't charge with a risk of overcharging the main pipe - && occupied->air.mainReservoirPressure >= 7.5 // don't charge without sufficient pressure in the tank + && occupied->air.MainReservoirPressure() >= 7.5 // don't charge without sufficient pressure in the tank && BrakeChargingCooldown >= 0.0 // don't charge while cooldown is active && (ActualProximityDist > 100.0 // don't charge if we're about to be braking soon || min_speed(occupied->Vel, VelNext) >= occupied->Vel) ) { @@ -683,7 +683,7 @@ void TController::control_main_pipe() { update_brake_charging(); - if( ( occupied->air.mainReservoirPressure < 5.0 + if( ( occupied->air.MainReservoirPressure() < 5.0 || ( BrakeCtrlPosition < gbh_RP && ( occupied->brakes.equivalentPipePressure > (fReady < 0.25 ? 5.1 : 5.2) || is_brake_charging_done() ) ) ) // the light application a charging train stands on stays, as in DecBrake() @@ -707,7 +707,7 @@ void TController::update_brake_charging() { for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { auto const isovercharged { vehicle->physics != occupied - && vehicle->physics->brakePipe.pressure > FSOverchargePipePress }; + && vehicle->physics->brakePipe.Pressure() > FSOverchargePipePress }; if( isovercharged ) { BrakeChargingPipeOverchargeStart.try_emplace( vehicle, ElapsedTime ); } diff --git a/vehicle/ai/physicslog.cpp b/vehicle/ai/physicslog.cpp index 820c90e9a..8430beac7 100644 --- a/vehicle/ai/physicslog.cpp +++ b/vehicle/ai/physicslog.cpp @@ -73,7 +73,7 @@ std::string TController::physicslog_line() const { << occupied->Ff << " " << occupied->Fb << " " << occupied->brakes.cylinderPressure << " " - << occupied->brakePipe.pressure << " " + << occupied->brakePipe.Pressure() << " " << mvControlling->Im << " " << int(mvControlling->MainCtrlPos) << " " << int(mvControlling->ScndCtrlPos) << " " @@ -117,7 +117,7 @@ void TController::PhysicsLog() line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << "\t"; line << mvControlling->AccS << "\t"; - line << occupied->brakePipe.pressure << "\t" << occupied->brakes.controlReservoirPressure << "\t" + line << occupied->brakePipe.Pressure() << "\t" << occupied->brakes.controlReservoirPressure << "\t" << occupied->brakes.cylinderPressure << "\t"; line << occupied->brakes.reservoirAir << "\t" << occupied->brakes.distributor->GetCRP() << "\n"; PhysicsLogs.append( VehicleName, line.str() ); diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index 755e24f7a..d51431ecc 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -143,7 +143,7 @@ TController::control_pantographs() { if( pantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } if( false == pantographUnit->pantographAir.config.autoValve - && occupied->mainPipe.pressure > 4.3 ) { + && occupied->mainPipe.Pressure() > 4.3 ) { // gdy główna sprężarka bezpiecznie nabije ciśnienie to można przestawić kurek na zasilanie pantografów z głównej pneumatyki cue_action( driver_hint::pantographairsourcesetmain ); } diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index 268e974b2..a815257f4 100644 --- a/vehicle/cab/auxiliarycommands.cpp +++ b/vehicle/cab/auxiliarycommands.cpp @@ -843,7 +843,7 @@ void TTrain::OnCommand_compressortoggle(TTrain *Train, command_data const &Comma if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const compressorisenabled{(Train->Dynamic()->Mechanik ? Train->Dynamic()->Mechanik->IsAnyCompressorEnabled : Train->occupied->air.compressor.allow)}; + auto const compressorisenabled{(Train->Dynamic()->Mechanik ? Train->Dynamic()->Mechanik->IsAnyCompressorEnabled : Train->occupied->air.compressor.IsAllowed())}; if (false == compressorisenabled) { @@ -895,7 +895,7 @@ void TTrain::OnCommand_compressorenable(TTrain *Train, command_data const &Comma void TTrain::OnCommand_compressordisable(TTrain *Train, command_data const &Command) { - if (Train->controlled->air.compressor.supply >= physics::CompressorSupply::converter) + if (Train->controlled->air.compressor.config.supply >= physics::CompressorSupply::converter) { return; } @@ -921,7 +921,7 @@ void TTrain::OnCommand_compressordisable(TTrain *Train, command_data const &Comm void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const &Command) { - if (Train->occupied->air.compressor.supply >= physics::CompressorSupply::converter) + if (Train->occupied->air.compressor.config.supply >= physics::CompressorSupply::converter) { return; } @@ -933,13 +933,13 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->occupied->air.compressor.allowLocal) + if (false == Train->occupied->air.compressor.LocalSwitchOn()) { // turn on // visual feedback Train->ggCompressorLocalButton.UpdateValue(1.0, Train->dsbSwitch); // effect - Train->occupied->air.compressor.allowLocal = true; + Train->occupied->air.compressor.SetLocalSwitch(true); } else { @@ -947,7 +947,7 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & // visual feedback Train->ggCompressorLocalButton.UpdateValue(0.0, Train->dsbSwitch); // effect - Train->occupied->air.compressor.allowLocal = false; + Train->occupied->air.compressor.SetLocalSwitch(false); } } } @@ -955,7 +955,7 @@ void TTrain::OnCommand_compressortogglelocal(TTrain *Train, command_data const & void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data const &Command) { - if (Train->occupied->air.compressor.listPositions == 0) + if (Train->occupied->air.compressor.config.listPositions == 0) { return; } @@ -967,14 +967,14 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data if (Train->ggCompressorListButton.type() == TGaugeType::push) { // impulse switch - if (Train->occupied->air.compressor.listPositions < Train->occupied->air.compressor.listDefaultPosition + 1) + if (Train->occupied->air.compressor.config.listPositions < Train->occupied->air.compressor.config.listDefaultPosition + 1) { return; } - Train->occupied->ChangeCompressorPreset(Command.action == GLFW_PRESS ? Train->occupied->air.compressor.listDefaultPosition + 1 : Train->occupied->air.compressor.listDefaultPosition); + Train->occupied->ChangeCompressorPreset(Command.action == GLFW_PRESS ? Train->occupied->air.compressor.config.listDefaultPosition + 1 : Train->occupied->air.compressor.config.listDefaultPosition); // visual feedback - Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.listPosition - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.ListPosition() - 1), Train->dsbSwitch); } else { @@ -984,12 +984,12 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data return; } - if (Train->occupied->air.compressor.listPosition < Train->occupied->air.compressor.listPositions || true == Train->occupied->air.compressor.listWraps) + if (Train->occupied->air.compressor.ListPosition() < Train->occupied->air.compressor.config.listPositions || true == Train->occupied->air.compressor.config.listWraps) { // active light preset is stored as value in range 1-LigthPosNo - Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.listPosition < Train->occupied->air.compressor.listPositions ? Train->occupied->air.compressor.listPosition + 1 : 1); // wrap mode + Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.ListPosition() < Train->occupied->air.compressor.config.listPositions ? Train->occupied->air.compressor.ListPosition() + 1 : 1); // wrap mode // visual feedback - Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.listPosition - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.ListPosition() - 1), Train->dsbSwitch); } } } @@ -997,7 +997,7 @@ void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_data const &Command) { - if (Train->occupied->air.compressor.listPositions == 0) + if (Train->occupied->air.compressor.config.listPositions == 0) { return; } @@ -1012,15 +1012,15 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d return; } - if (Train->occupied->air.compressor.listPosition > 1 || true == Train->occupied->air.compressor.listWraps) + if (Train->occupied->air.compressor.ListPosition() > 1 || true == Train->occupied->air.compressor.config.listWraps) { // active light preset is stored as value in range 1-LigthPosNo - Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.listPosition > 1 ? Train->occupied->air.compressor.listPosition - 1 : Train->occupied->air.compressor.listPositions); // wrap mode + Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.ListPosition() > 1 ? Train->occupied->air.compressor.ListPosition() - 1 : Train->occupied->air.compressor.config.listPositions); // wrap mode // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.listPosition - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.ListPosition() - 1), Train->dsbSwitch); } } } @@ -1028,7 +1028,7 @@ void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_d void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_data const &Command) { - if (Train->occupied->air.compressor.listPositions == 0) + if (Train->occupied->air.compressor.config.listPositions == 0) { return; } @@ -1037,12 +1037,12 @@ void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_da return; } // one change per key press - Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.listDefaultPosition); + Train->occupied->ChangeCompressorPreset(Train->occupied->air.compressor.config.listDefaultPosition); // visual feedback if (Train->ggCompressorListButton.SubModel != nullptr) { - Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.listPosition - 1), Train->dsbSwitch); + Train->ggCompressorListButton.UpdateValue(static_cast(Train->occupied->air.compressor.ListPosition() - 1), Train->dsbSwitch); } } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index c1cef46ad..bc7847051 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -995,9 +995,9 @@ void TTrain::set_cab_controls(int const Cab) } ggConverterLocalButton.PutValue(occupied->converter.LocalSwitchOn() ? 1.f : 0.f); // compressor - ggCompressorButton.PutValue(controlled->air.compressor.allow ? 1.f : 0.f); - ggCompressorLocalButton.PutValue(controlled->air.compressor.allowLocal ? 1.f : 0.f); - ggCompressorListButton.PutValue(static_cast(occupied->air.compressor.listPosition - 1)); + ggCompressorButton.PutValue(controlled->air.compressor.IsAllowed() ? 1.f : 0.f); + ggCompressorLocalButton.PutValue(controlled->air.compressor.LocalSwitchOn() ? 1.f : 0.f); + ggCompressorListButton.PutValue(static_cast(occupied->air.compressor.ListPosition() - 1)); // motor overload relay threshold / shunt mode ggMaxCurrentCtrl.PutValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); // automatic relays (AutoRelay) @@ -1824,14 +1824,14 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // manometr przewodu hamulcowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&occupied->brakePipe.pressure); + gauge.AssignDouble(&occupied->brakePipe.Pressure()); } else if (Label == "scndpress:") { // manometr przewodu hamulcowego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&occupied->mainPipe.pressure); + gauge.AssignDouble(&occupied->mainPipe.Pressure()); } else if (Label == "limpipepress:") { @@ -1866,7 +1866,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // manometr sprezarki/zbiornika glownego auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&occupied->air.mainReservoirPressure); + gauge.AssignDouble(&occupied->air.MainReservoirPressure()); } else if (Label == "oilpress:") { diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index 2ea772fb8..7c7546b0a 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -179,7 +179,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("main_ready", false == controlled->lineBreaker.IsClosed() && fHVoltage > 0.0 && controlled->lineBreaker.IsInitialised()); dict->insert("converter", occupied->lowVoltage.Is110vAvailable()); dict->insert("converter_overload", controlled->converter.IsOverloaded()); - dict->insert("compress", controlled->air.compressor.running); + dict->insert("compress", controlled->air.compressor.IsRunning()); dict->insert("pant_compressor", pantographUnit->pantographAir.IsCompressorRunning()); dict->insert("lights_front", occupied->iLights[VehicleEnd::front]); dict->insert("lights_rear", occupied->iLights[VehicleEnd::rear]); @@ -411,8 +411,8 @@ TTrain::state_t TTrain::get_state() const occupied->SecuritySystem.is_beeping(), btLampkaHVoltageB.GetValue(), fTachoVelocity, - static_cast(occupied->air.mainReservoirPressure), - static_cast(occupied->brakePipe.pressure), + static_cast(occupied->air.MainReservoirPressure()), + static_cast(occupied->brakePipe.Pressure()), static_cast(occupied->brakes.cylinderPressure), static_cast(pantographUnit->pantographAir.Pressure()), fHVoltage, @@ -677,7 +677,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target) if (Dynamic()->Mechanik) Dynamic()->Mechanik->MoveTo(target); - target_train->Occupied()->brakes.pipeLimiterPressure = target_train->Occupied()->brakePipe.pressure; + target_train->Occupied()->brakes.pipeLimiterPressure = target_train->Occupied()->brakePipe.Pressure(); target_train->Occupied()->CabActivisationAuto(true); // załączenie rozrządu (wirtualne kabiny) target_train->Dynamic()->MechInside = true; if (target_train->Dynamic()->Mechanik) @@ -748,7 +748,7 @@ void TTrain::MoveToVehicle(TDynamicObject *target) Dynamic()->Controller = Humandriver; } - Occupied()->brakes.pipeLimiterPressure = Occupied()->brakePipe.pressure; + Occupied()->brakes.pipeLimiterPressure = Occupied()->brakePipe.Pressure(); Occupied()->CabActivisationAuto(true); // załączenie rozrządu (wirtualne kabiny) } else diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 34bb1a9df..9aaba532c 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -433,8 +433,8 @@ void TTrain::updateUnitStates() if (p) { fPress[i][0] = static_cast(p->physics->brakes.cylinderPressure); - fPress[i][1] = static_cast(p->physics->brakePipe.pressure); - fPress[i][2] = static_cast(p->physics->mainPipe.pressure); + fPress[i][1] = static_cast(p->physics->brakePipe.Pressure()); + fPress[i][2] = static_cast(p->physics->mainPipe.Pressure()); fPress[i][3] = static_cast(p->physics->brakes.controlReservoirPressure); fPress[i][4] = static_cast(p->physics->brakes.distributor->GetBRP()); fPress[i][5] = static_cast((p->physics->TotalMass - p->physics->Mred) * 0.001); @@ -458,15 +458,15 @@ void TTrain::updateUnitStates() // TBD, TODO: clean up compressor data arrangement? if (iUnitNo <= 8) { - bComp[iUnitNo - 1][0] = bComp[iUnitNo - 1][0] || p->physics->air.compressor.allow || p->physics->air.compressor.start == start_t::automatic; + bComp[iUnitNo - 1][0] = bComp[iUnitNo - 1][0] || p->physics->air.compressor.IsAllowed() || p->physics->air.compressor.config.start == start_t::automatic; } - if (p->physics->air.compressor.speed > 0.00001) + if (p->physics->air.compressor.config.speed > 0.00001) { if (iUnitNo <= 8) { - bComp[iUnitNo - 1][1] = bComp[iUnitNo - 1][1] || p->physics->air.compressor.running; + bComp[iUnitNo - 1][1] = bComp[iUnitNo - 1][1] || p->physics->air.compressor.IsRunning(); } - bCompressors.emplace_back(p->physics->air.compressor.allow || p->physics->air.compressor.start == start_t::automatic, p->physics->air.compressor.running, i); + bCompressors.emplace_back(p->physics->air.compressor.IsAllowed() || p->physics->air.compressor.config.start == start_t::automatic, p->physics->air.compressor.IsRunning(), i); } bSlip[i] = p->physics->SlippingWheels; if (in < 8 && p->physics->inductionMotor.traction.maxPower > 1) @@ -581,9 +581,9 @@ void TTrain::updateFeedbackGauges() const { // wykonywać tylko gdy wyprowadzone na pulpit // Ra: sterowanie miernikiem: zbiornik główny - Console::ValueSet(0, occupied->air.mainReservoirPressure); + Console::ValueSet(0, occupied->air.MainReservoirPressure()); // Ra: sterowanie miernikiem: przewód główny - Console::ValueSet(1, occupied->brakePipe.pressure); + Console::ValueSet(1, occupied->brakePipe.Pressure()); // Ra: sterowanie miernikiem: cylinder hamulcowy Console::ValueSet(2, occupied->brakes.cylinderPressure); // woltomierz wysokiego napięcia @@ -607,7 +607,7 @@ void TTrain::updateConverterOverload(double const Deltatime) if (controlled->converter.IsRunning() == true) { fConverterTimer += static_cast(Deltatime); - if (controlled->air.compressor.running == true && controlled->air.compressor.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) && + if (controlled->air.compressor.IsRunning() == true && controlled->air.compressor.config.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) && DynamicObject->Controller == Humandriver // hunter-110212: poprawka dla EZT && DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag) { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/) @@ -620,7 +620,7 @@ void TTrain::updateConverterOverload(double const Deltatime) else if (fConverterTimer >= fConverterPrzekaznik) { // changed switch from always true to take into account state of the compressor switch - controlled->CompressorSwitch(controlled->air.compressor.allow); + controlled->CompressorSwitch(controlled->air.compressor.IsAllowed()); } } } @@ -777,7 +777,7 @@ void TTrain::updateBasicLamps() } // Lampka pracujacej sprezacki - if (controlled->air.compressor.running || occupied->air.compressor.running) + if (controlled->air.compressor.IsRunning() || occupied->air.compressor.IsRunning()) btCompressors.Turn(true); else btCompressors.Turn(false); @@ -848,8 +848,8 @@ void TTrain::updateCircuitLamps(double const Deltatime) btLampkaWysRozr.Turn(controlled->Imax >= controlled->ImaxHi); btLampkaNapNastHam.Turn(controlled->DirActive != 0); // napiecie na nastawniku hamulcowym - btLampkaSprezarka.Turn(controlled->air.compressor.running); // mutopsitka dziala - btLampkaSprezarkaOff.Turn(!controlled->air.compressor.running); + btLampkaSprezarka.Turn(controlled->air.compressor.IsRunning()); // mutopsitka dziala + btLampkaSprezarkaOff.Turn(!controlled->air.compressor.IsRunning()); btLampkaFuelPumpOff.Turn(!controlled->FuelPump.is_active); btLampkaOilPump.Turn(controlled->OilPump.is_active); // pre-lubrication pump, goes off once the engine is started @@ -1125,8 +1125,8 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) } } - btLampkaSprezarkaB.Turn(physics->air.compressor.running); // mutopsitka dziala - btLampkaSprezarkaBOff.Turn(false == physics->air.compressor.running); + btLampkaSprezarkaB.Turn(physics->air.compressor.IsRunning()); // mutopsitka dziala + btLampkaSprezarkaBOff.Turn(false == physics->air.compressor.IsRunning()); if (controlled->Signalling == true) { if (physics->brakes.cylinderPressure >= 1.45f) diff --git a/vehicle/dynamic/consist.cpp b/vehicle/dynamic/consist.cpp index 22d3c1a92..f5141d3be 100644 --- a/vehicle/dynamic/consist.cpp +++ b/vehicle/dynamic/consist.cpp @@ -109,7 +109,7 @@ float TDynamicObject::GetEPP() { if (!temp) break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów - eq += temp->physics->brakePipe.pressure * temp->physics->Dim.L; + eq += temp->physics->brakePipe.Pressure() * temp->physics->Dim.L; am += temp->physics->Dim.L; if ((temp->physics->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) break; // nic nie ma już dalej podłączone @@ -143,7 +143,7 @@ float TDynamicObject::GetEPP() { if (!temp) break; // Ra: zabezpieczenie przed ewentaulnymi błędami sprzęgów - eq += temp->physics->brakePipe.pressure * temp->physics->Dim.L; + eq += temp->physics->brakePipe.Pressure() * temp->physics->Dim.L; am += temp->physics->Dim.L; if ((temp->physics->Couplers[coupler_nr].CouplingFlag & Coupling::brakeHose) != Coupling::brakeHose) break; // nic nie ma już dalej podłączone @@ -170,7 +170,7 @@ float TDynamicObject::GetEPP() break; // jeśli jednak z tyłu nic nie ma } } - eq -= physics->brakePipe.pressure * physics->Dim.L; + eq -= physics->brakePipe.Pressure() * physics->Dim.L; am -= physics->Dim.L; return eq / am; }; diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index b3c7ed654..f9fac57ff 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -351,11 +351,11 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" { physics->brakes.distributor->ForceEmptiness(); physics->brakePipe.reservoir->CreatePress(0.0); - physics->brakePipe.pressure = 0.0; + physics->brakePipe.SetPressure(0.0); physics->mainPipe.reservoir->CreatePress(0.0); - physics->mainPipe.pressure = 0.0; + physics->mainPipe.SetPressure(0.0); physics->pantographAir.Empty(); - physics->air.compressedVolume = 0.0; + physics->air.Fill(0.0); } if ( contains( ActPar, '1' ) ) // wylaczanie 10% diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index 31ea07e97..4eca3f008 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -150,11 +150,11 @@ void TDynamicObject::renderAuxiliarySounds() { - if( physics->air.compressor.speed > 0.0 ) { + if( physics->air.compressor.config.speed > 0.0 ) { // McZapkie! - dzwiek compressor.wav tylko gdy dziala sprezarka - if( physics->air.compressor.running ) { + if( physics->air.compressor.IsRunning() ) { // for compressor coupled with the diesel engine sound pitch is driven by engine revolutions - if( physics->air.compressor.supply == physics::CompressorSupply::engine ) { + if( physics->air.compressor.config.supply == physics::CompressorSupply::engine ) { // presume the compressor sound is recorded for idle revolutions // increase the pitch according to increase of engine revolutions auto const enginefactor { @@ -170,7 +170,7 @@ void TDynamicObject::renderAuxiliarySounds() { } else { // enhanced sound path, with dedicated sound for idling compressor - if( physics->air.compressor.governorLock ) { + if( physics->air.compressor.IsGovernorLocked() ) { sCompressor.stop(); sCompressorIdle.play( sound_flags::exclusive | sound_flags::looping ); } @@ -308,7 +308,7 @@ void TDynamicObject::renderEmergencyBrakeSound() { // smooth out air flow rate m_emergencybrakeflow = m_emergencybrakeflow == 0.0 ? physics->brakes.emergencyValve.flow : std::lerp(m_emergencybrakeflow, physics->brakes.emergencyValve.flow, 0.1); // scale volume based on the flow rate and on the pressure in the main pipe - auto const flowpressure { std::clamp( m_emergencybrakeflow, 0.0, 1.0 ) + std::clamp( 0.1 * physics->brakePipe.pressure, 0.0, 0.5 ) }; + auto const flowpressure { std::clamp( m_emergencybrakeflow, 0.0, 1.0 ) + std::clamp( 0.1 * physics->brakePipe.Pressure(), 0.0, 0.5 ) }; m_emergencybrake .pitch( m_emergencybrake.m_frequencyoffset + 1.0 * m_emergencybrake.m_frequencyfactor ) .gain( m_emergencybrake.m_amplitudeoffset + std::clamp( flowpressure, 0.0, 1.0 ) * m_emergencybrake.m_amplitudefactor ) diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 1b65057ff..ffff2a58a 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -1530,20 +1530,7 @@ void TDynamicObject::Damage(char flag) { } - if (flag & 8) //blokada sprezarki - { - if (physics->air.compressor.minPressure>0) - physics->air.compressor.minPressure -= 100000001; - if (physics->air.compressor.maxPressure>0) - physics->air.compressor.maxPressure -= 100000001; - } - else - { - if (physics->air.compressor.minPressure<0) - physics->air.compressor.minPressure += 100000001; - if (physics->air.compressor.maxPressure<0) - physics->air.compressor.maxPressure += 100000001; - } + physics->air.compressor.SetFault((flag & 8) != 0); //blokada sprezarki if (flag & 16) //blokada wału { diff --git a/vehicle/dynamic/vehicletable.cpp b/vehicle/dynamic/vehicletable.cpp index 1b2ffe229..544866862 100644 --- a/vehicle/dynamic/vehicletable.cpp +++ b/vehicle/dynamic/vehicletable.cpp @@ -562,8 +562,8 @@ vehicle_table::update_brake_pipes( double const Deltatime ) { m_brakepipes.clear(); for( auto *vehicle : m_items ) { - if( ( true == vehicle->physics->brakePipe.couplersPending ) - || ( true == vehicle->physics->mainPipe.couplersPending ) ) { + if( ( true == vehicle->physics->brakePipe.CouplersPending() ) + || ( true == vehicle->physics->mainPipe.CouplersPending() ) ) { m_brakepipes.push_back( vehicle->physics ); } } @@ -690,7 +690,7 @@ vehicle_table::update_steps_parallel( double const Deltatime, int const Iteratio pipes.clear(); for( auto const index : members ) { auto *physics { m_items[ index ]->physics }; - if( physics->brakePipe.couplersPending || physics->mainPipe.couplersPending ) { + if( physics->brakePipe.CouplersPending() || physics->mainPipe.CouplersPending() ) { pipes.push_back( physics ); } } diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 57c66c7d2..41e9d0220 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -74,7 +74,7 @@ void ui::vehicleparams_panel::draw_mini(const physics::Vehicle &physics) draw_infobutton(STR_C("main.")); if (physics.converter.IsRunning()) draw_infobutton(STR_C("conv.")); - if (physics.air.compressor.running) + if (physics.air.compressor.IsRunning()) draw_infobutton(STR_C("comp.")); if (physics.WarningSignal) @@ -154,8 +154,8 @@ void ui::vehicleparams_panel::render_contents() (true == physics.WaterHeater.is_damaged ? '!' : (physics.WaterHeater.is_active ? 'H' : (false == physics.WaterHeater.breaker ? '-' : (physics.WaterHeater.is_enabled ? 'h' : '.')))), (physics.FuelPump.is_active ? 'F' : (physics.FuelPump.is_enabled ? 'f' : '.')), (physics.OilPump.is_active ? 'O' : (physics.OilPump.is_enabled ? 'o' : '.')), (false == physics.converter.LocalSwitchOn() ? '-' : (physics.converter.IsAllowed() ? (physics.converter.IsRunning() ? 'X' : 'x') : '.')), (physics.converter.IsOverloaded() ? '!' : '.'), - (physics.air.compressor.running ? 'C' : (false == physics.air.compressor.allowLocal ? '-' : ((physics.air.compressor.allow || physics.air.compressor.start == start_t::automatic) ? 'c' : '.'))), - (physics.air.compressor.governorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(physics.OilPump.pressure, 2) : "").c_str(), + (physics.air.compressor.IsRunning() ? 'C' : (false == physics.air.compressor.LocalSwitchOn() ? '-' : ((physics.air.compressor.IsAllowed() || physics.air.compressor.config.start == start_t::automatic) ? 'c' : '.'))), + (physics.air.compressor.IsGovernorLocked() ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(physics.OilPump.pressure, 2) : "").c_str(), // power transfers physics.Couplers[VehicleEnd::front].power_high.voltage, physics.Couplers[VehicleEnd::front].power_high.current, std::string(physics.Couplers[VehicleEnd::front].power_high.is_local ? "" : "-").c_str(), std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(physics.Couplers[VehicleEnd::rear].power_high.is_local ? "" : "-").c_str(), @@ -205,9 +205,9 @@ void ui::vehicleparams_panel::render_contents() // cylinders physics.brakes.cylinderPressure, physics.brakes.independentCylinderPressure, physics.brakes.distributor->GetBrakeStatus(), // pipes - physics.brakePipe.pressure, physics.brakes.handleCapPosition, physics.mainPipe.pressure, physics.brakes.controlReservoirPressure, + physics.brakePipe.Pressure(), physics.brakes.handleCapPosition, physics.mainPipe.Pressure(), physics.brakes.controlReservoirPressure, // tanks - physics.brakes.distributor->GetBRP(), physics.air.mainReservoirPressure, physics.brakes.distributor->GetCRP()); + physics.brakes.distributor->GetBRP(), physics.air.MainReservoirPressure(), physics.brakes.distributor->GetCRP()); ImGui::TextUnformatted(buffer.data());