From 160ffe2147b53677af302640c387c10399aedc06 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 10:08:54 +0100 Subject: [PATCH] refactor(physics): the low voltage, the train heating and the pantographs keep their state to themselves As the parts of the main circuit: the battery and the low voltage circuits, the train heating, the circuit of the pantographs and their air become classes with the definition in `config` and the state behind queries and operations. The step of the air of the pantographs (the small compressor, the three-way cock, the leaks, the pressure switch) moves into PantographAir::Update(), which gets what it needs as plain values (PantographAirSupply) and reports a trip of the pressure switch, so the vehicle opens its line breaker or switches the converter of a unit off as before. The drain of the battery and its limits move into LowVoltageSupply. The latch of the held battery button of the cab moves from the physics to TTrain, where the button is. The gauges of the cab bind to the values they show through const pointers (TGauge::Assign*() take them), so the queries they bind to return const references and the cab reads the state live without being able to change it. No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit. --- application/driverhints.cpp | 28 +-- application/driveruipanels.cpp | 14 +- input/messaging.cpp | 2 +- physics/components/body.cpp | 4 +- physics/components/cab.cpp | 4 +- physics/components/collisions.cpp | 2 +- physics/components/commands.cpp | 8 +- physics/components/diesel.cpp | 22 +- physics/components/doors.cpp | 6 +- physics/components/drive.cpp | 10 +- physics/components/electrics.cpp | 196 ++++++----------- physics/components/fizsections.cpp | 29 +-- physics/components/lowvoltage.h | 123 +++++++++-- physics/components/pantographs.h | 197 ++++++++++++++++-- physics/components/pneumatics.cpp | 10 +- physics/components/securitysystem.cpp | 4 +- physics/components/setup.cpp | 8 +- physics/components/traction.cpp | 14 +- physics/vehicle.h | 4 +- rendering/lightarray.cpp | 4 +- simulation/blackboxrecorder.cpp | 4 +- tests/unit/drive.cpp | 14 +- tests/unit/golden.cpp | 6 +- tests/unit/invariants.cpp | 8 +- tests/unit/test_auxiliaries.cpp | 56 ++--- tests/unit/test_commands.cpp | 6 +- tests/unit/test_compartment_lights.cpp | 20 +- tests/unit/test_compartment_lights_switch.cpp | 2 +- tests/unit/test_compressor.cpp | 10 +- tests/unit/test_controls.cpp | 10 +- tests/unit/test_engine_shutdown.cpp | 2 +- tests/unit/test_genset.cpp | 18 +- tests/unit/test_horn.cpp | 10 +- tests/unit/test_line_contactors_interlock.cpp | 12 +- tests/unit/test_mains_before_pantographs.cpp | 40 ++-- tests/unit/test_oil_pump.cpp | 8 +- tests/unit/test_pressure_switch.cpp | 10 +- tests/unit/test_pullee.cpp | 20 +- tests/unit/test_radio.cpp | 14 +- tests/unit/test_switches.cpp | 4 +- tests/unit/vehicle.cpp | 8 +- vehicle/Gauge.cpp | 8 +- vehicle/Gauge.h | 16 +- vehicle/Train.h | 1 + vehicle/ai/consist.cpp | 10 +- vehicle/ai/controls.cpp | 2 +- vehicle/ai/engine.cpp | 16 +- vehicle/ai/orders.cpp | 2 +- vehicle/ai/situation.cpp | 22 +- vehicle/cab/auxiliarycommands.cpp | 2 +- vehicle/cab/cabcommands.cpp | 30 +-- vehicle/cab/equipmentcommands.cpp | 10 +- vehicle/cab/pantographcommands.cpp | 32 +-- vehicle/cab/setup.cpp | 16 +- vehicle/cab/sounds.cpp | 2 +- vehicle/cab/train.cpp | 18 +- vehicle/cab/update.cpp | 52 ++--- vehicle/dynamic/destinations.cpp | 2 +- vehicle/dynamic/lifecycle.cpp | 3 +- vehicle/dynamic/sounds.cpp | 12 +- vehicle/dynamic/update.cpp | 68 +++--- vehicle/dynamic/visual.cpp | 4 +- widgets/vehicleparams.cpp | 8 +- 63 files changed, 746 insertions(+), 561 deletions(-) diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 0f49b1933..7336b18dd 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -89,7 +89,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->lowVoltage.batteryStart != start_t::manual || occupied->lowVoltage.power24vAvailable == true; } ); + return occupied->lowVoltage.config.batteryStart != start_t::manual || occupied->lowVoltage.Is24vAvailable() == true; } ); break; } case driver_hint::batteryoff: { @@ -100,12 +100,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->lowVoltage.batteryStart != start_t::manual || occupied->lowVoltage.power24vAvailable == false; } ); + return occupied->lowVoltage.config.batteryStart != start_t::manual || occupied->lowVoltage.Is24vAvailable() == false; } ); break; } // battery case driver_hint::cabactivation: { - if (AIControllFlag && occupied->lowVoltage.power24vAvailable) { + if (AIControllFlag && occupied->lowVoltage.Is24vAvailable()) { occupied->CabActivisation(); CheckVehicles(); } @@ -224,46 +224,46 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // pantographs case driver_hint::pantographairsourcesetmain: { if( AIControllFlag ) { - pantographUnit->pantographAir.connectedToMainReservoir = true; + pantographUnit->pantographAir.ConnectToMainReservoir(true); } remove_hint( driver_hint::pantographairsourcesetauxiliary ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->pantographAir.connectedToMainReservoir == true; } ); + return pantographUnit->pantographAir.IsConnectedToMainReservoir() == true; } ); break; } case driver_hint::pantographairsourcesetauxiliary: { if( AIControllFlag ) { - pantographUnit->pantographAir.connectedToMainReservoir = false; + pantographUnit->pantographAir.ConnectToMainReservoir(false); } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->pantographAir.connectedToMainReservoir == false; } ); + return pantographUnit->pantographAir.IsConnectedToMainReservoir() == false; } ); break; } case driver_hint::pantographcompressoron: { if( AIControllFlag ) { - pantographUnit->pantographAir.compressorRunning = true; + pantographUnit->pantographAir.SwitchCompressor(true); } remove_hint( driver_hint::pantographcompressoroff ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->pantographAir.compressorRunning == true; } ); + return pantographUnit->pantographAir.IsCompressorRunning() == true; } ); break; } case driver_hint::pantographcompressoroff: { if( AIControllFlag ) { - pantographUnit->pantographAir.compressorRunning = false; + pantographUnit->pantographAir.SwitchCompressor(false); } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->pantographAir.compressorRunning == false; } ); + return pantographUnit->pantographAir.IsCompressorRunning() == false; } ); break; } case driver_hint::pantographsvalveon: { @@ -760,7 +760,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->pantographAir.pressure >= (is_emu() ? (pantographUnit->pantographAir.pressureLockActive ? 4.6 : 2.6) : 4.2); } ); + return pantographUnit->pantographAir.Pressure() >= (is_emu() ? (pantographUnit->pantographAir.IsPressureLockActive() ? 4.6 : 2.6) : 4.2); } ); break; } case driver_hint::waitbrakecharge: { @@ -1218,7 +1218,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->trainHeating.allow == true; } ); + return occupied->trainHeating.IsAllowed() == true; } ); break; } case driver_hint::consistheatingoff: { @@ -1229,7 +1229,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->trainHeating.allow == false; } ); + return occupied->trainHeating.IsAllowed() == false; } ); break; } diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 493f65ce5..6ddc9aa4f 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -816,7 +816,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f"), // devices - physics.lowVoltage.batteryOn ? 'B' : '.', + physics.lowVoltage.IsBatteryOn() ? 'B' : '.', physics.pantographAir.valve.is_active ? '+' : '.', physics.pantographs[VehicleEnd::rear].valve.is_active ? 'O' : physics.pantographs[VehicleEnd::rear].valve.is_enabled ? 'o' : @@ -824,8 +824,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.pantographs[VehicleEnd::front].valve.is_active ? 'P' : physics.pantographs[VehicleEnd::front].valve.is_enabled ? 'p' : '.', - physics.pantographAir.pressureLockActive ? '!' : - physics.pantographAir.pressureSwitchActive ? '*' : + physics.pantographAir.IsPressureLockActive() ? '!' : + physics.pantographAir.IsPressureSwitchPrimed() ? '*' : '.', physics.WaterPump.is_active ? 'W' : false == physics.WaterPump.breaker ? '-' : @@ -858,8 +858,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.protection.PressureSwitchTripped() ? '!' : physics.lineContactors.IsClosed() ? '+' : '.', - physics.trainHeating.on ? 'H' : - physics.trainHeating.allow ? 'h' : + physics.trainHeating.IsOn() ? 'H' : + physics.trainHeating.IsAllowed() ? 'h' : '.', physics.brakes.distributor->Releaser() ? '^' : '.', std::string( m_input.mechanik ? STR(" R") + ( physics.Radio && physics.RadioFuse ? std::to_string( m_input.mechanik->iRadioChannel ) : "-" ) : "" ).c_str(), @@ -951,8 +951,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C(" pantograph: %.2f%cMT"), - physics.pantographAir.pressure, - physics.pantographAir.connectedToMainReservoir ? '-' : '|' ); + physics.pantographAir.Pressure(), + physics.pantographAir.IsConnectedToMainReservoir() ? '-' : '|' ); textline += m_buffer.data(); } diff --git a/input/messaging.cpp b/input/messaging.cpp index 64a0a74f8..e58483baa 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -329,7 +329,7 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) Vehicle->physics->ShowCurrent(p + 1); // amperomierze kolejnych grup // WriteLog("zapisalem prady"); r.iPar[30] = Vehicle->physics->WarningSignal; // trabienie - r.fPar[31] = Vehicle->physics->pantographCircuit.supplyVoltage; // napiecie WN + r.fPar[31] = Vehicle->physics->pantographCircuit.SupplyVoltage(); // napiecie WN // WriteLog("Parametry gotowe"); i <<= 2; // ilość bajtów r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować diff --git a/physics/components/body.cpp b/physics/components/body.cpp index 30d19d59c..2e3c533d4 100644 --- a/physics/components/body.cpp +++ b/physics/components/body.cpp @@ -525,9 +525,7 @@ void physics::Vehicle::compute_movement_(double const Deltatime) PowerCouplersCheck(Deltatime, Coupling::power110v); PowerCouplersCheck(Deltatime, Coupling::power24v); - lowVoltage.power24vVoltage = std::max(PowerCircuits[0].first, GetTrainsetVoltage(Coupling::power24v)); - lowVoltage.power24vAvailable = lowVoltage.power24vVoltage > 0; - lowVoltage.power110vAvailable = PowerCircuits[1].first > 0 || GetTrainsetVoltage(Coupling::power110v) > 0; + lowVoltage.SetSupply(std::max(PowerCircuits[0].first, GetTrainsetVoltage(Coupling::power24v)), PowerCircuits[1].first > 0 || GetTrainsetVoltage(Coupling::power110v) > 0); } // ************************************************************************************************* diff --git a/physics/components/cab.cpp b/physics/components/cab.cpp index cf9e52321..ed68b611c 100644 --- a/physics/components/cab.cpp +++ b/physics/components/cab.cpp @@ -74,7 +74,7 @@ int physics::Vehicle::SoundingHorns(int const Signal) const auto const supplied{[this](horn_supply const Supply) { if (Supply == horn_supply::electric) { - return lowVoltage.power24vAvailable || lowVoltage.power110vAvailable; + return lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable(); } if (air.mainReservoirVolume > 0.0) { @@ -204,7 +204,7 @@ bool physics::Vehicle::PulleeModeSwitch(bool const State) DecManualBrakeLevel(ManualBrakePosNo); brakes.spring.activate = false; SecuritySystem.set_enabled(false); - lowVoltage.batteryOn = false; + lowVoltage.DisconnectBattery(); } return true; } diff --git a/physics/components/collisions.cpp b/physics/components/collisions.cpp index e46bae097..8f985fe39 100644 --- a/physics/components/collisions.cpp +++ b/physics/components/collisions.cpp @@ -238,7 +238,7 @@ collision::vehicle_kind physics::Vehicle::collision_kind() const auto const unit{is_multiple_unit()}; auto const passengers{std::any_of(LoadAttributes.begin(), LoadAttributes.end(), [](auto const &Load) { return ToLower(Load.name).starts_with("passenger"); })}; // a coach heats its compartments; the crash zone is a matter of each end (crush_of()) - return collision::kind_of(powered, unit || passengers || (false == powered && trainHeating.power > 0.0), false); + return collision::kind_of(powered, unit || passengers || (false == powered && trainHeating.config.power > 0.0), false); } collision::crush_curve physics::Vehicle::crush_curve_at(VehicleEnd const End) const diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index 875431621..80b8c153d 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -325,7 +325,7 @@ bool physics::Vehicle::RunBrakeEquipmentCommand(VehicleCommand const Command, do } else if (Command == VehicleCommand::springBrakeActivate) { - if (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) + if (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) { brakes.spring.activate = CValue1 > 0; OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); @@ -370,9 +370,9 @@ bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, doubl else if (Command == VehicleCommand::batterySwitch) /*NBMX*/ { // the battery of a vehicle prepared for hauling (PulleeMode) stays off - if (lowVoltage.batteryStart == start_t::manual && (false == PulleeMode || CValue1 <= 0.0)) + if (false == PulleeMode || CValue1 <= 0.0) { - lowVoltage.batteryOn = CValue1 > 0.0; + lowVoltage.SwitchBattery(CValue1 > 0.0); } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -690,7 +690,7 @@ void physics::Vehicle::DoorRemoteCommand(bool const Open, double const CValue1, { using enum control_t; if (auto const doorcontrol{Open ? Doors.open_control : Doors.close_control}; - (doorcontrol != conductor && doorcontrol != driver && doorcontrol != mixed) || (false == lowVoltage.power24vAvailable && false == lowVoltage.power110vAvailable)) + (doorcontrol != conductor && doorcontrol != driver && doorcontrol != mixed) || (false == lowVoltage.Is24vAvailable() && false == lowVoltage.Is110vAvailable())) { return; } diff --git a/physics/components/diesel.cpp b/physics/components/diesel.cpp index decd11eb5..489892607 100644 --- a/physics/components/diesel.cpp +++ b/physics/components/diesel.cpp @@ -50,7 +50,7 @@ double physics::Vehicle::EngineMaxRPM() const void physics::Vehicle::WaterPumpCheck(double const /*Timestep*/) { // NOTE: breaker override with start type is sm42 specific hack, replace with ability to define the presence of the breaker - WaterPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && true == WaterPump.breaker && false == WaterPump.is_disabled && + WaterPump.is_active = true == (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) && true == WaterPump.breaker && false == WaterPump.is_disabled && (true == WaterPump.is_active || true == WaterPump.is_enabled || WaterPump.start_type == start_t::battery); } @@ -58,7 +58,7 @@ void physics::Vehicle::WaterPumpCheck(double const /*Timestep*/) void physics::Vehicle::WaterHeaterCheck(double const /*Timestep*/) { - WaterHeater.is_active = false == WaterHeater.is_damaged && true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && true == WaterHeater.is_enabled && true == WaterHeater.breaker && + WaterHeater.is_active = false == WaterHeater.is_damaged && true == (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) && true == WaterHeater.is_enabled && true == WaterHeater.breaker && (WaterHeater.is_active || WaterHeater.config.temp_min < 0 || diesel.heat.temperatura1 < WaterHeater.config.temp_min); WaterHeater.is_damaged = true == WaterHeater.is_damaged || (true == WaterHeater.is_active && false == WaterPump.is_active); @@ -74,7 +74,7 @@ void physics::Vehicle::FuelPumpCheck(double const /*Timestep*/) { using enum start_t; - FuelPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && false == FuelPump.is_disabled && + FuelPump.is_active = true == (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) && false == FuelPump.is_disabled && (FuelPump.is_active || (FuelPump.start_type == manual ? FuelPump.is_enabled : FuelPump.start_type == automatic ? diesel.startupRequested || lineBreaker.IsClosed() : FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || lineBreaker.IsClosed() : @@ -85,7 +85,7 @@ void physics::Vehicle::FuelPumpCheck(double const /*Timestep*/) void physics::Vehicle::OilPumpCheck(double const Timestep) { - OilPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && false == lineBreaker.IsClosed() && false == OilPump.is_disabled && + OilPump.is_active = true == (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) && false == lineBreaker.IsClosed() && false == OilPump.is_disabled && (OilPump.is_active || (OilPump.start_type == start_t::manual ? OilPump.is_enabled : OilPump.start_type == start_t::automatic ? diesel.startupRequested : OilPump.start_type == start_t::manualwithautofallback ? OilPump.is_enabled || diesel.startupRequested : @@ -341,10 +341,10 @@ double physics::Vehicle::DieselElectricTargetRevolutions() else tmp = DElist[protection.PressureSwitchTripped() ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0; - if (true == trainHeating.allow && trainHeating.power > 0 && trainHeating.engineRpm > 0) + if (true == trainHeating.IsAllowed() && trainHeating.config.power > 0 && trainHeating.config.engineRpm > 0) { // bump engine revolutions up if needed, when heating is on - tmp = std::max(tmp, std::min(EngineMaxRPM(), trainHeating.engineRpm) / 60.0); + tmp = std::max(tmp, std::min(EngineMaxRPM(), trainHeating.config.engineRpm) / 60.0); } // NOTE: fake diesel.fill calculation for the sake of smoke emitter which uses this parameter to determine smoke opacity diesel.fill = std::clamp(0.2 + 0.35 * (tmp - enrot) + 0.5 * (std::abs(Im) / DElist[MainCtrlPosNo].Imax), 0.05, 1.0); @@ -385,9 +385,9 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) auto power = Power; tempImax = DElist[MainCtrlPos].Imax; tempUmax = DElist[MainCtrlPos].Umax; - if (true == trainHeating.on) + if (true == trainHeating.IsOn()) { - power -= trainHeating.power; + power -= trainHeating.config.power; } power = std::max(power, 0.0); // NOTE: very crude way to approximate power generated at current rpm instead of instant top output @@ -1373,7 +1373,7 @@ void physics::Vehicle::dizel_Heat(double const dt) // engine heat transfers auto const Ge{engineon * (0.21 * diesel.heat.powerfactor * EnginePower + 12) / 3600}; // TODO: replace fixed heating power cost with more accurate calculation - auto const obciazenie{engineon * (diesel.heat.powerfactor * EnginePower / 950 + (trainHeating.on ? trainHeating.power : 0) + 70)}; + auto const obciazenie{engineon * (diesel.heat.powerfactor * EnginePower / 950 + (trainHeating.IsOn() ? trainHeating.config.power : 0) + 70)}; auto const Qd{qs * Ge - obciazenie}; // silnik oddaje czesc ciepla do wody chlodzacej, a takze pewna niewielka czesc do otoczenia, modyfikowane przez okienko auto const Qs{(Qd - diesel.heat.kfs * (diesel.heat.Ts - diesel.heat.Tsr) - diesel.heat.kfe * /* ( 0.3 + 0.7 * ( diesel.heat.okienko ? 1 : 0 ) ) * */ (diesel.heat.Ts - diesel.heat.Te))}; @@ -1400,7 +1400,7 @@ void physics::Vehicle::dizel_Heat(double const dt) { // auxiliary water circuit setup diesel.heat.water_aux.is_warm = true == diesel.heat.cooling || - (true == lineBreaker.IsClosed() && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + (true == lineBreaker.IsClosed() && lowVoltage.BatteryVoltage() > 0.75 * lowVoltage.config.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ && diesel.heat.water_aux.config.temp_cooling > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_cooling - (diesel.heat.water_aux.is_warm ? 8 : 0)); auto const PTC2{(diesel.heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)}; diesel.heat.rpmwz2 = static_cast(PTC2 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); @@ -1423,7 +1423,7 @@ void physics::Vehicle::dizel_Heat(double const dt) diesel.heat.water.is_flowing = diesel.heat.water.config.temp_flow < 0 || diesel.heat.temperatura1 > diesel.heat.water.config.temp_flow - (diesel.heat.water.is_flowing ? 5 : 0); auto const obieg{(diesel.heat.water.is_flowing ? 1 : 0)}; diesel.heat.water.is_warm = - true == diesel.heat.cooling || (true == lineBreaker.IsClosed() && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + true == diesel.heat.cooling || (true == lineBreaker.IsClosed() && lowVoltage.BatteryVoltage() > 0.75 * lowVoltage.config.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ && diesel.heat.water.config.temp_cooling > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_cooling - (diesel.heat.water.is_warm ? 8 : 0)); auto const PTC1{(diesel.heat.water.is_warm /*or PTC1p*/ ? 1 : 0)}; diesel.heat.rpmwz = static_cast(PTC1 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); diff --git a/physics/components/doors.cpp b/physics/components/doors.cpp index 613d33da4..e1afcdba1 100644 --- a/physics/components/doors.cpp +++ b/physics/components/doors.cpp @@ -281,7 +281,7 @@ bool physics::Vehicle::OperateDoors(VehicleSide const Door, bool const State, ra else { // remote door operation signals require power to propagate - if (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) + if (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) { door.remote_open = State; door.remote_close = false == State; @@ -486,9 +486,9 @@ bool physics::Vehicle::doors_powered() const } if (Doors.voltage == 24) { - return lowVoltage.power24vAvailable || lowVoltage.power110vAvailable; + return lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable(); } - return Doors.voltage == 110 && lowVoltage.power110vAvailable; + return Doors.voltage == 110 && lowVoltage.Is110vAvailable(); } // whether the unfolded step folds: without the permission to stay out, or with the door closing, once it's about to diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index 309a040ba..d11d02638 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -125,7 +125,7 @@ void updateRadiatorFans(physics::Vehicle &vehicle, double const dt) // else it needs the voltage of the source bool linePowerAvailable(physics::Vehicle const &vehicle) { - return vehicle.lineBreaker.config.pantographsRequireIt ? vehicle.lowVoltage.power24vAvailable || vehicle.lowVoltage.power110vAvailable : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; + return vehicle.lineBreaker.config.pantographsRequireIt ? vehicle.lowVoltage.Is24vAvailable() || vehicle.lowVoltage.Is110vAvailable() : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; } // a notch of the master controller of the drives without steps of their own (no engine, Dumb, diesel-electric, @@ -199,7 +199,7 @@ public: } bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { - return vehicle.lowVoltage.power24vAvailable; + return vehicle.lowVoltage.Is24vAvailable(); } bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override { @@ -259,7 +259,7 @@ public: void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // update the state of voltage relays - auto const voltage{std::max(vehicle.GetTrainsetHighVoltage(), vehicle.pantographCircuit.supplyVoltage)}; + auto const voltage{std::max(vehicle.GetTrainsetHighVoltage(), vehicle.pantographCircuit.SupplyVoltage())}; // where the line breaker holds without voltage (closed ahead of the pantographs) the undervoltage relay opens the // line contactors instead, see MotorConnectorsCheck(). it picks up again only with the master controller back // where a start begins, as the line breaker it stands in for wouldn't close on a running position either: at @@ -422,7 +422,7 @@ public: } bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { - return vehicle.lowVoltage.power24vAvailable; + return vehicle.lowVoltage.Is24vAvailable(); } bool UpdateEngine(physics::Vehicle &vehicle, double const dt) const override { @@ -524,7 +524,7 @@ public: } bool MainsPowerAvailable(physics::Vehicle const &vehicle) const override { - return vehicle.lowVoltage.power24vAvailable; + return vehicle.lowVoltage.Is24vAvailable(); } void CheckVoltageRelays(physics::Vehicle &vehicle) const override { diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 3f426e9d3..09b9b3290 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -34,87 +34,40 @@ http://mozilla.org/MPL/2.0/. // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak void physics::Vehicle::UpdatePantVolume(double dt) { - // check the pantograph compressor while at it - // TODO: move the check to a separate method - // automatic start if the pressure is too low - pantographAir.compressorRunning |= pantographAir.pressure < 4.2 && true == (pantographs[VehicleEnd::front].is_active | pantographs[VehicleEnd::rear].is_active) // TODO: any_pantograph_is_active method - && (pantographAir.compressorStart == start_t::automatic || pantographAir.compressorStart == start_t::manualwithautofallback); - - auto const lowvoltagepower{lowVoltage.power24vAvailable || lowVoltage.power110vAvailable}; - pantographAir.compressorRunning &= lowvoltagepower; - - if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector // tylko jeśli pantografujący - && EnginePowerSource.CollectorParameters.CollectorsNo > 0) + if (pantographAir.Update(PantographAirSupplyNow(), dt)) { - // Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem - // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS - // Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć - // WS i odpalić resztę - if (pantographAir.autoValve ? pantographAir.pressure < mainPipe.pressure : pantographAir.connectedToMainReservoir) // kurek zamyka połączenie z ZG - { // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje - // Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem - pantographAir.pressure = mainPipe.pressure; - // ograniczenie ciśnienia do MaxPress (tylko w pantografach!) - pantographAir.pressure = safe_clamp(mainPipe.pressure, 0.0, EnginePowerSource.CollectorParameters.MaxPress); - pantographAir.volume = (pantographAir.pressure + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem - } - else - { // zbiornik główny odcięty, można pompować pantografy - if (pantographAir.compressorRunning) - { - // włączona mała sprężarka - pantographAir.volume += dt - // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 - * (TrainType == train_type::emu ? 0.003 : 0.005) / std::max(1.0, pantographAir.pressure) * (0.45 - (0.1 / pantographAir.volume / 10 - 0.1)) / 0.45; - } - pantographAir.pressure = safe_clamp(10.0 * pantographAir.volume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika - } - if (!pantographAir.compressorRunning && pantographAir.volume > 0.1) - pantographAir.volume -= dt * 0.0003 * std::max(1.0, pantographAir.pressure * 0.5); // nieszczelności: 0.0003=0.3l/s + PantPressureSwitchTrip(); + } +} - PantPressureSwitchCheck(); - } - else - { // a tu coś dla SM42 i SM31, aby pokazywać na manometrze - pantographAir.pressure = brakes.controlReservoirPressure; - } -}; +// what the air of the pantographs needs to know in the step +physics::PantographAirSupply physics::Vehicle::PantographAirSupplyNow() const +{ + PantographAirSupply supply; + supply.anyPantographActive = pantographs[VehicleEnd::front].is_active || pantographs[VehicleEnd::rear].is_active; + supply.lowVoltage = lowVoltage.IsAvailable(); + // 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.controlReservoirPressure = brakes.controlReservoirPressure; + supply.maxPressure = EnginePowerSource.CollectorParameters.MaxPress; + supply.minPressure = EnginePowerSource.CollectorParameters.MinPress; + return supply; +} // the pantographs' pressure switch: low, it opens the line breaker (or locks the converter of a unit) once; // primed again over 4.6 bar, where the pantographs' compressor stops at 4.8 void physics::Vehicle::PantPressureSwitchCheck() { - if (pantographAir.pressure < EnginePowerSource.CollectorParameters.MinPress) + if (pantographAir.UpdatePressureSwitch(PantographAirSupplyNow())) { - // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php - if (true == pantographAir.pressureSwitchActive) - { - PantPressureSwitchTrip(); - } - } - else if (pantographAir.pressure >= 4.6) - { - // NOTE: we require active low power source to prime the pressure switch - // this is a work-around for potential isssues caused by the switch activating on otherwise idle vehicles, but should check whether it's accurate - if (true == lowVoltage.power24vAvailable || true == lowVoltage.power110vAvailable) - { - // prime the pressure switch - pantographAir.pressureSwitchActive = true; - // turn off the subsystems lock - pantographAir.pressureLockActive = false; - } - - if (pantographAir.pressure >= 4.8) - { - // Winger - automatyczne wylaczanie malej sprezarki - // TODO: governor lock, disables usage until pressure drop below 3.8 (should really make compressor object we could reuse) - pantographAir.compressorRunning = false; - } + PantPressureSwitchTrip(); } } -// the pantographs' pressure switch tripped by the low pressure: the line breaker opened, unless the voltage comes from -// elsewhere, or the converter of a unit locked; spent until primed again +// the pantographs' pressure switch tripped by the low pressure (pantographAir spent the switch, and locked a unit): the line +// breaker opened, unless the voltage comes from elsewhere, or the converter of a unit switched off void physics::Vehicle::PantPressureSwitchTrip() { // opuszczenie pantografów przy niskim ciśnieniu @@ -132,52 +85,44 @@ void physics::Vehicle::PantPressureSwitchTrip() { // specialized variant for EMU -- pwr system disables converter and heating, // and prevents their activation until pressure switch is set again - pantographAir.pressureLockActive = true; // TODO: separate 'heating allowed' from actual heating flag, so we can disable it here without messing up heating toggle ConverterSwitch(false, range_t::unit); } - // mark the pressure switch as spent - pantographAir.pressureSwitchActive = false; } void physics::Vehicle::UpdateBatteryVoltage(double dt) { // przeliczenie obciążenia baterii using enum TEngineType; - if (lowVoltage.batteryVoltage > 0 && EngineType != DieselEngine && EngineType != WheelsDriven && lowVoltage.nominalBatteryVoltage > 0) + if (lowVoltage.BatteryVoltage() > 0 && EngineType != DieselEngine && EngineType != WheelsDriven && lowVoltage.config.nominalBatteryVoltage > 0) { // HACK: allow to draw power also from adjacent converter, applicable for EMUs // TODO: expand power cables system to include low voltage power transfers // HACK: emulate low voltage generator powered directly by the diesel engine - auto const converteractive{lowVoltage.power110vAvailable || (EngineType == DieselElectric && true == lineBreaker.IsClosed()) || (EngineType == DieselEngine && true == lineBreaker.IsClosed())}; + auto const converteractive{lowVoltage.Is110vAvailable() || (EngineType == DieselElectric && true == lineBreaker.IsClosed()) || (EngineType == DieselEngine && true == lineBreaker.IsClosed())}; - lowVoltage.batteryVoltage -= BatteryDrain(dt, converteractive); - if (lowVoltage.nominalBatteryVoltage / lowVoltage.batteryVoltage > 1.57 && MainSwitch(false) && EngineType != DieselEngine && EngineType != WheelsDriven) + if (lowVoltage.DrainBattery(BatteryDrain(dt, converteractive)) && MainSwitch(false) && EngineType != DieselEngine && EngineType != WheelsDriven) EventFlag = true; // wywalanie szybkiego z powodu zbyt niskiego napiecia - if (lowVoltage.batteryVoltage > lowVoltage.nominalBatteryVoltage) - lowVoltage.batteryVoltage = lowVoltage.nominalBatteryVoltage; // wstrzymanie ładowania pow. 110V - if (lowVoltage.batteryVoltage < 0.01) - lowVoltage.batteryVoltage = 0.01; } else { // TODO: check and implement proper way to handle this for diesel engines - lowVoltage.batteryVoltage = lowVoltage.nominalBatteryVoltage; + lowVoltage.KeepBatteryCharged(); } }; // the drop of the battery's voltage in dt, by what draws from it, or its rise by the converter charging it double physics::Vehicle::BatteryDrain(double dt, bool const converteractive) const { - if (lowVoltage.nominalBatteryVoltage / lowVoltage.batteryVoltage < 1.22 && lowVoltage.batteryOn) + if (lowVoltage.config.nominalBatteryVoltage / lowVoltage.BatteryVoltage() < 1.22 && lowVoltage.IsBatteryOn()) { // 110V return BatteryDrainCharged(dt, converteractive); } - if (lowVoltage.nominalBatteryVoltage / lowVoltage.batteryVoltage >= 1.22 && lowVoltage.batteryOn) + if (lowVoltage.config.nominalBatteryVoltage / lowVoltage.BatteryVoltage() >= 1.22 && lowVoltage.IsBatteryOn()) { // 90V return BatteryDrainLow(dt, converteractive); } - if (!lowVoltage.batteryOn) + if (!lowVoltage.IsBatteryOn()) { return BatteryDrainSwitchedOff(dt); } @@ -223,7 +168,7 @@ double physics::Vehicle::BatteryDrainLow(double dt, bool const converteractive) double sn3; double sn4; double sn5; - if (pantographAir.compressorRunning) + if (pantographAir.IsCompressorRunning()) sn1 = dt * 0.0046; else sn1 = 0; @@ -254,7 +199,7 @@ double physics::Vehicle::BatteryDrainSwitchedOff(double dt) const double sn3; double sn4; double sn5; - if (lowVoltage.nominalBatteryVoltage / lowVoltage.batteryVoltage < 1.22) + if (lowVoltage.config.nominalBatteryVoltage / lowVoltage.BatteryVoltage() < 1.22) sn1 = dt * 50; else sn1 = 0; @@ -276,12 +221,12 @@ void physics::Vehicle::MainsCheck(double const Deltatime) { case TPowerSource::CurrentCollector: { - localvoltage = std::max(localvoltage, pantographCircuit.supplyVoltage); + localvoltage = std::max(localvoltage, pantographCircuit.SupplyVoltage()); break; } case TPowerSource::Accumulator: { - localvoltage = std::max(localvoltage, lowVoltage.power24vVoltage); + localvoltage = std::max(localvoltage, lowVoltage.Voltage24v()); break; } default: @@ -295,7 +240,7 @@ void physics::Vehicle::MainsCheck(double const Deltatime) localvoltage = Genset.voltage; } // a line breaker closed ahead of the pantographs gets ready on the low voltage circuits - auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (lineBreaker.config.pantographsRequireIt && (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable))}; + auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (lineBreaker.config.pantographsRequireIt && (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()))}; // optional automatic circuit start, once the circuit is initialised if (lineBreaker.UpdateInitialisation(maincircuitpowersupply, Deltatime) && lineBreaker.config.start != start_t::manual && false == (lineBreaker.IsClosed() || diesel.startupRequested)) @@ -313,7 +258,7 @@ void physics::Vehicle::MainsCheck(double const Deltatime) void physics::Vehicle::LowVoltagePowerCheck(double const /*Deltatime*/) { - auto const lowvoltagepower{lowVoltage.power24vAvailable || lowVoltage.power110vAvailable}; + auto const lowvoltagepower{lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()}; if (EngineType == TEngineType::ElectricSeriesMotor) { @@ -370,7 +315,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) case Coupling::highVoltage: { // heating power sources - if (trainHeating.on) + if (trainHeating.IsOn()) { switch (HeatingPowerSource.SourceType) { @@ -381,7 +326,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) } case TPowerSource::CurrentCollector: { - localvoltage = pantographCircuit.supplyVoltage; + localvoltage = pantographCircuit.SupplyVoltage(); break; } case TPowerSource::Main: @@ -409,7 +354,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) { if (converter.IsRunning()) { - localvoltage = lowVoltage.nominalBatteryVoltage; + localvoltage = lowVoltage.config.nominalBatteryVoltage; } // TBD, TODO: reduce by current draw? PowerCircuits[1].first = localvoltage; @@ -418,9 +363,9 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) case Coupling::power24v: { - if (lowVoltage.batteryOn) + if (lowVoltage.IsBatteryOn()) { - localvoltage = lowVoltage.batteryVoltage; + localvoltage = lowVoltage.BatteryVoltage(); } // TBD, TODO: reduce by current draw? PowerCircuits[0].first = localvoltage; @@ -463,7 +408,7 @@ void physics::Vehicle::PowerCouplersVoltage(Coupling const kind, double const ab auto const oppositeheatingcoupling{oppositecoupler.CouplingFlag.HasAny(Coupling::heating)}; oppositecouplingispresent = oppositehighvoltagecoupling || oppositeheatingcoupling; - localpowerexportisenabled = oppositehighvoltagecoupling || (oppositeheatingcoupling && localpowersource && trainHeating.on); + localpowerexportisenabled = oppositehighvoltagecoupling || (oppositeheatingcoupling && localpowersource && trainHeating.IsOn()); break; } @@ -568,9 +513,9 @@ void physics::Vehicle::ConverterCheck(double const Timestep) { ConverterSupply supply; supply.lineBreakerClosed = lineBreaker.IsClosed(); - supply.lowVoltage24v = lowVoltage.power24vAvailable; + supply.lowVoltage24v = lowVoltage.Is24vAvailable(); supply.directionActive = DirActive != 0; - supply.pantographPressureLock = pantographAir.pressureLockActive; + supply.pantographPressureLock = pantographAir.IsPressureLockActive(); // HACK: allow carriages to operate converter without (missing) fuse prerequisite supply.highVoltage = Power > 1.0 ? MainCircuitPowered() : GetTrainsetHighVoltage() > 0.0; supply.damaged = TestFlag(EngDmgFlag, 4); @@ -593,7 +538,7 @@ void physics::Vehicle::HeatingCheck(double const /*Timestep*/) generator.revolutions = *generator.engine_revolutions; auto const absrevolutions{std::abs(generator.revolutions)}; - generator.voltage = (false == trainHeating.allow ? 0.0 : + generator.voltage = (false == trainHeating.IsAllowed() ? 0.0 : // TODO: add support for desired voltage selector absrevolutions < generator.revolutions_min ? generator.voltage_min * absrevolutions / generator.revolutions_min : @@ -605,9 +550,9 @@ void physics::Vehicle::HeatingCheck(double const /*Timestep*/) } // quick check first to avoid unnecessary calls... - if (false == trainHeating.allow) + if (false == trainHeating.IsAllowed()) { - trainHeating.on = false; + trainHeating.SetOn(false); return; } // ...detailed check if we're still here @@ -624,7 +569,7 @@ void physics::Vehicle::HeatingCheck(double const /*Timestep*/) } case TPowerSource::CurrentCollector: { - voltage = pantographCircuit.supplyVoltage; + voltage = pantographCircuit.SupplyVoltage(); break; } case TPowerSource::PowerCable: @@ -647,11 +592,11 @@ void physics::Vehicle::HeatingCheck(double const /*Timestep*/) } } - trainHeating.on = voltage > heatingpowerthreshold; + trainHeating.SetOn(voltage > heatingpowerthreshold); - if (trainHeating.on) + if (trainHeating.IsOn()) { - TotalCurrent += 1000 * trainHeating.power / voltage; // heater power cost presumably specified in kilowatts + TotalCurrent += 1000 * trainHeating.config.power / voltage; // heater power cost presumably specified in kilowatts } } @@ -661,7 +606,7 @@ void physics::Vehicle::PantographsCheck(double const /*Timestep*/) { auto const &valve{pantographAir.valve}; - auto const lowvoltagepower{valve.solenoid ? lowVoltage.power24vAvailable || lowVoltage.power110vAvailable : true}; + auto const lowvoltagepower{valve.solenoid ? lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable() : true}; auto const autostart{valve.start_type == automatic || valve.start_type == manualwithautofallback}; auto const manualcontrol{valve.start_type == manual || valve.start_type == manualwithautofallback}; @@ -677,13 +622,13 @@ void physics::Vehicle::PantographsCheck(double const /*Timestep*/) { auto &valve{pantograph.valve}; - auto const lowvoltagepower{valve.solenoid ? lowVoltage.power24vAvailable || lowVoltage.power110vAvailable : true}; + auto const lowvoltagepower{valve.solenoid ? lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable() : true}; auto const autostart{valve.start_type == automatic || valve.start_type == manualwithautofallback}; auto const manualcontrol{valve.start_type == manual || valve.start_type == manualwithautofallback}; valve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state && (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state, without it just pass through - && (manualcontrol && lowvoltagepower ? false == pantographCircuit.allDown : true) && + && (manualcontrol && lowvoltagepower ? false == pantographCircuit.AllDown() : true) && (lineBreaker.IsClosed() || false == lineBreaker.config.pantographsRequireIt) // fed through the closed line breaker, where it comes first && (valve.is_active || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower)); // shouldn't ever get this far but, eh @@ -705,7 +650,7 @@ void physics::Vehicle::GensetCheck(double const Deltatime) } auto &genset{Genset}; auto const wasactive{genset.is_active}; - auto const lowvoltagepower{lowVoltage.power24vAvailable || lowVoltage.power110vAvailable}; + auto const lowvoltagepower{lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()}; auto const requested{lowvoltagepower && false == genset.is_disabled && (genset.start_type == start_t::automatic ? GensetSelected() : genset.is_enabled)}; if (false == requested) { @@ -759,13 +704,13 @@ void physics::Vehicle::LightsCheck(double const /*Timestep*/) light.is_active = // TODO: bind properly power source when ld is in place - (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) // power source + (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) // power source && false == light.is_disabled && (true == light.is_active || (light.start_type == start_t::manual ? light.is_enabled : true)); light.intensity = (light.is_active ? 1.0f : 0.0f) // TODO: bind properly power source when ld is in place - * (lowVoltage.power110vAvailable ? 1.0f : - lowVoltage.power24vAvailable ? 0.5f : + * (lowVoltage.Is110vAvailable() ? 1.0f : + lowVoltage.Is24vAvailable() ? 0.5f : 0.0f) * light.dimming; } @@ -782,13 +727,10 @@ bool physics::Vehicle::BatterySwitch(bool State, range_t const Notify) // the battery of a vehicle prepared for hauling stays off return false; } - auto const initialstate{lowVoltage.batteryOn}; + auto const initialstate{lowVoltage.IsBatteryOn()}; // Ra: ukrotnienie załączania baterii jest jakąś fikcją... - if (lowVoltage.batteryStart == start_t::manual) - { - lowVoltage.batteryOn = State; - } + lowVoltage.SwitchBattery(State); // switching batteries does not require activation if (Notify != local) @@ -797,7 +739,7 @@ bool physics::Vehicle::BatterySwitch(bool State, range_t const Notify) SendCtrlToNext(VehicleCommand::batterySwitch, State ? 1 : 0, -1, Notify == unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return lowVoltage.batteryOn != initialstate; + return lowVoltage.IsBatteryOn() != initialstate; } bool physics::Vehicle::CompartmentLightsSwitch(bool State, range_t const Notify) @@ -952,7 +894,7 @@ bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify) bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify) { - bool const initialstate{trainHeating.allow}; + bool const initialstate{trainHeating.IsAllowed()}; HeatingSwitch_(State); @@ -963,14 +905,14 @@ bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify) SendCtrlToNext(VehicleCommand::heatingSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return trainHeating.allow != initialstate; + return trainHeating.IsAllowed() != initialstate; } void physics::Vehicle::HeatingSwitch_(bool const State) { // TBD, TODO: activation dependencies? - trainHeating.allow = State; + trainHeating.Allow(State); } // the start request of the genset of a dual-mode vehicle; one which starts on its own ignores it, but passes it on to @@ -996,7 +938,7 @@ bool physics::Vehicle::GensetSwitch(bool const State, range_t const Notify) // genset of a dual-mode vehicle double physics::Vehicle::TractionSourceVoltage() const { - return GensetSelected() ? Genset.voltage : pantographCircuit.supplyVoltage; + return GensetSelected() ? Genset.voltage : pantographCircuit.SupplyVoltage(); } // the voltage the traction circuit gets: from the vehicle's own source, or through the train's high voltage line @@ -1035,7 +977,7 @@ double physics::Vehicle::EnginePowerSourceVoltage() const { return EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? TractionSupplyVoltage() : - EnginePowerSource.SourceType == TPowerSource::Accumulator ? lowVoltage.power24vVoltage : + EnginePowerSource.SourceType == TPowerSource::Accumulator ? lowVoltage.Voltage24v() : 0.0; } @@ -1185,9 +1127,9 @@ bool physics::Vehicle::OperatePantographValve(VehicleEnd const End, operation_t bool physics::Vehicle::DropAllPantographs(bool const State, range_t const Notify) { - auto const initialstate{pantographCircuit.allDown}; + auto const initialstate{pantographCircuit.AllDown()}; - pantographCircuit.allDown = State; + pantographCircuit.SetAllDown(State); if (Notify != range_t::local) { @@ -1231,7 +1173,7 @@ double physics::Vehicle::GetTrainsetVoltage(CouplingSet const couplings) const double physics::Vehicle::GetTrainsetHighVoltage() const { - return std::max(GetTrainsetVoltage(Coupling::highVoltage), trainHeating.allow ? GetTrainsetVoltage(Coupling::heating) : 0.0); + return std::max(GetTrainsetVoltage(Coupling::highVoltage), trainHeating.IsAllowed() ? GetTrainsetVoltage(Coupling::heating) : 0.0); } int physics::Vehicle::clampDimmerPosition(int const Position) const diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index 3f7556b72..a4d346bfc 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -62,7 +62,7 @@ void physics::Vehicle::LoadFIZ_Param(std::string const &line) extract_value(Vmax, "Vmax", line, "0"); extract_value(Power, "PWR", line, "0"); extract_value(SandCapacity, "SandCap", line, "0"); - extract_value(trainHeating.power, "HeatingP", line, "0"); + extract_value(trainHeating.config.power, "HeatingP", line, "0"); extract_value(LightPower, "LightP", line, "0"); { @@ -896,9 +896,9 @@ void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line) extract_value(isDoubleClickForMeasureNeeded, "DCMB", line, ""); extract_value(DistanceCounterDoublePressPeriod, "DCDPP", line, ""); - extract_value(lowVoltage.batteryButtonImpulse, "IBTB", line, ""); - extract_value(lowVoltage.batteryButtonHeld, "SBBBH", line, ""); - extract_value(lowVoltage.batteryButtonHoldTime, "BBHT", line, ""); + extract_value(lowVoltage.config.batteryButtonImpulse, "IBTB", line, ""); + extract_value(lowVoltage.config.batteryButtonHeld, "SBBBH", line, ""); + extract_value(lowVoltage.config.batteryButtonHoldTime, "BBHT", line, ""); } // Cntrl.: how the devices start (MainStart, BatteryStart, ...) and their relays @@ -921,7 +921,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // battery { auto lookup = starts.find(extract_value("BatteryStart", line)); - lowVoltage.batteryStart = lookup != starts.end() ? lookup->second : manual; + lowVoltage.config.batteryStart = lookup != starts.end() ? lookup->second : manual; } // converter { @@ -938,11 +938,11 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // pantograph compressor { auto lookup = starts.find(extract_value("PantCompressorStart", line)); - pantographAir.compressorStart = lookup != starts.end() ? lookup->second : manual; + pantographAir.config.compressorStart = lookup != starts.end() ? lookup->second : manual; } // pantograph compressor valve - pantographAir.autoValve = TrainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs - extract_value(pantographAir.autoValve, "PantAutoValve", line, ""); + pantographAir.config.autoValve = TrainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs + extract_value(pantographAir.config.autoValve, "PantAutoValve", line, ""); // pantographs valve { auto lookup = starts.find(extract_value("PantEPValveStart", line)); @@ -1076,8 +1076,9 @@ void physics::Vehicle::LoadFIZ_Light(std::string const &line) LoadFIZ_PowerParamsDecode(AlterLightPowerSource, "AlterL", line); extract_value(NominalVoltage, "Volt", line, ""); - extract_value(lowVoltage.batteryVoltage, "LMaxVoltage", line, ""); - lowVoltage.nominalBatteryVoltage = static_cast(lowVoltage.batteryVoltage); + auto batteryvoltage{lowVoltage.BatteryVoltage()}; + extract_value(batteryvoltage, "LMaxVoltage", line, ""); + lowVoltage.SetBattery(batteryvoltage); } void physics::Vehicle::LoadFIZ_Clima(std::string const &line) @@ -1368,7 +1369,7 @@ void physics::Vehicle::LoadFIZ_EngineDieselElectric(std::string const &Input) ImaxHi = 2; ImaxLo = 1; } - extract_value(trainHeating.engineRpm, "HeatingRPM", Input, ""); + extract_value(trainHeating.config.engineRpm, "HeatingRPM", Input, ""); extract_value(diesel.shaftInertia, "AIM", Input, "1.25"); extract_value(diesel.revolutionsDecreaseRate, "RPMDecRate", Input, ""); LoadFIZ_DieselElectricDynamicBrake(Input); @@ -1468,12 +1469,12 @@ void physics::Vehicle::LoadFIZ_EngineDieselShared(std::string const &Input) void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) { - extract_value(pantographCircuit.switchType, "Pantograph", Input, ""); + extract_value(pantographCircuit.config.switchType, "Pantograph", Input, ""); extract_value(converter.config.switchType, "Converter", Input, ""); extract_value(lineContactors.config.switchType, "MotorConnectors", Input, ""); - trainHeating.switchImpulse = ToLower(extract_value("TrainHeating", Input)) == "impulse"; + trainHeating.config.switchImpulse = ToLower(extract_value("TrainHeating", Input)) == "impulse"; // because people can't make up their minds whether it's "impulse" or "Impulse"... - pantographCircuit.switchType = ToLower(pantographCircuit.switchType); + pantographCircuit.config.switchType = ToLower(pantographCircuit.config.switchType); converter.config.switchType = ToLower(converter.config.switchType); lineContactors.config.switchType = ToLower(lineContactors.config.switchType); // universal reset buttons assignments diff --git a/physics/components/lowvoltage.h b/physics/components/lowvoltage.h index 5127e3455..0709d8101 100644 --- a/physics/components/lowvoltage.h +++ b/physics/components/lowvoltage.h @@ -7,7 +7,8 @@ obtain one at http://mozilla.org/MPL/2.0/. */ -// the low voltage supply and the train heating of a vehicle, held by physics::Vehicle as lowVoltage and trainHeating +// the low voltage supply and the train heating of a vehicle, held by physics::Vehicle as lowVoltage and trainHeating. +// as the parts of the main circuit (maincircuit.h): the definition in `config`, the state behind queries and operations #pragma once @@ -17,30 +18,112 @@ namespace physics { // the battery and the low voltage circuits -struct LowVoltageSupply +class LowVoltageSupply { - bool batteryOn = false; // the battery switched on - double batteryVoltage = 0.0; - float nominalBatteryVoltage = 0.f; - start_t batteryStart = start_t::manual; - bool power110vAvailable = false; // the 110 V circuit has power, as the last step found it - bool power24vAvailable = false; // the 24 V circuit has power, as the last step found it - double power24vVoltage{0.0}; // the voltage of the battery circuit, as the last step found it - // the battery switch of the cab - bool batteryButtonFired = false; // the button already pressed - bool batteryButtonImpulse = false; // the switch works as a single button - bool batteryButtonHeld = false; // the button has to be held to switch the battery on or off - float batteryButtonHoldTime = 1.f; // how long it has to be held [s] + public: + struct Config + { + float nominalBatteryVoltage{0.f}; + start_t batteryStart{start_t::manual}; + // the battery switch of the cab + bool batteryButtonImpulse{false}; // the switch works as a single button + bool batteryButtonHeld{false}; // the button has to be held to switch the battery on or off + float batteryButtonHoldTime{1.f}; // how long it has to be held [s] + }; + Config config; + + // the battery of the definition (LMaxVoltage), charged + void SetBattery(double const Voltage) + { + batteryVoltage = Voltage; + config.nominalBatteryVoltage = static_cast(Voltage); + } + + bool IsBatteryOn() const { return batteryOn; } + // the battery switch, where the battery is switched by hand; returns whether that changed it + bool SwitchBattery(bool const State) + { + auto const initialstate{batteryOn}; + if (config.batteryStart == start_t::manual) + { + batteryOn = State; + } + return batteryOn != initialstate; + } + // the battery cut off whatever its switch, as for a vehicle prepared for hauling + void DisconnectBattery() { batteryOn = false; } + // the battery as the vehicle is placed: on, unless the vehicle has none + void ResetBattery() { batteryOn = config.batteryStart != start_t::disabled; } + // for the tests: the battery on or off, whatever its switch + void SetBatteryOnForTest(bool const State) { batteryOn = State; } + + double BatteryVoltage() const { return batteryVoltage; } + // the battery drained by the given amount [V]; returns whether its voltage fell too low for the line breaker to hold. + // it neither charges above its nominal voltage nor drops to nothing + bool DrainBattery(double const Drain) + { + batteryVoltage -= Drain; + auto const toolow{config.nominalBatteryVoltage / batteryVoltage > 1.57}; + if (batteryVoltage > config.nominalBatteryVoltage) + { + batteryVoltage = config.nominalBatteryVoltage; // wstrzymanie ładowania pow. 110V + } + if (batteryVoltage < 0.01) + { + batteryVoltage = 0.01; + } + return toolow; + } + // the battery kept at its nominal voltage, where its drain isn't modelled + void KeepBatteryCharged() { batteryVoltage = config.nominalBatteryVoltage; } + + // the low voltage circuits, as the last step found them + bool const &Is24vAvailable() const { return power24vAvailable; } + bool const &Is110vAvailable() const { return power110vAvailable; } + // either of them + bool IsAvailable() const { return power24vAvailable || power110vAvailable; } + // the voltage of the battery circuit + double Voltage24v() const { return power24vVoltage; } + // the circuits in the step: the 24 V one from its voltage, the 110 V one as given + void SetSupply(double const Voltage24v, bool const Available110v) + { + power24vVoltage = Voltage24v; + power24vAvailable = power24vVoltage > 0; + power110vAvailable = Available110v; + } + // for the tests of the parts the circuits feed: the power of a circuit as given, whatever the voltage + void Set24vAvailableForTest(bool const State) { power24vAvailable = State; } + void Set110vAvailableForTest(bool const State) { power110vAvailable = State; } + + private: + bool batteryOn{false}; + double batteryVoltage{0.0}; + bool power110vAvailable{false}; + bool power24vAvailable{false}; + double power24vVoltage{0.0}; }; // the heating of the train fed by the vehicle -struct TrainHeating +class TrainHeating { - bool on = false; - bool allow{false}; // the heating switch. TODO: wrap the heating in a basic device - bool switchImpulse{false}; // the switch springs back to its middle position - double power = 0.0; - double engineRpm{0.0}; // the revolutions of the engine guaranteed with the heating on + public: + struct Config + { + bool switchImpulse{false}; // the switch springs back to its middle position + double power{0.0}; + double engineRpm{0.0}; // the revolutions of the engine guaranteed with the heating on + }; + Config config; + + bool IsOn() const { return on; } + void SetOn(bool const State) { on = State; } + // the heating switch. TODO: wrap the heating in a basic device + bool IsAllowed() const { return allow; } + void Allow(bool const State) { allow = State; } + + private: + bool on{false}; + bool allow{false}; }; } // namespace physics diff --git a/physics/components/pantographs.h b/physics/components/pantographs.h index e4ee98505..4e406593a 100644 --- a/physics/components/pantographs.h +++ b/physics/components/pantographs.h @@ -8,10 +8,12 @@ http://mozilla.org/MPL/2.0/. */ // the circuit and the air of the pantographs of a vehicle, held by physics::Vehicle as pantographCircuit and -// pantographAir beside its pantographs +// pantographAir beside its pantographs. as the parts of the main circuit (maincircuit.h): the definition in `config`, the +// state behind queries and operations #pragma once +#include #include #include @@ -21,30 +23,191 @@ namespace physics { // the circuit of the pantographs: their voltages, the kind of their switches, the presets of the cabs -struct PantographCircuit +class PantographCircuit { - double frontVoltage = 0.0; // the voltage at the front pantograph - double rearVoltage = 0.0; // the voltage at the rear one - double supplyVoltage{0.0}; // the voltage supplied to the pantographs - bool allDown{false}; // the switch that lowers all of them - std::string switchType; // PantSwitchType: the kind of the switches of the cab + public: + struct Config + { + std::string switchType; // PantSwitchType: the kind of the switches of the cab + }; + Config config; + + // the voltage at the pantograph of the given end, from the overhead line it touches + double Voltage(VehicleEnd const End) const { return End == VehicleEnd::front ? frontVoltage : rearVoltage; } + double FrontVoltage() const { return frontVoltage; } + double RearVoltage() const { return rearVoltage; } + void SetFrontVoltage(double const Voltage) { frontVoltage = Voltage; } + void SetRearVoltage(double const Voltage) { rearVoltage = Voltage; } + // the voltage supplied to the pantographs, from the overhead line the vehicle is under + double SupplyVoltage() const { return supplyVoltage; } + void SetSupplyVoltage(double const Voltage) { supplyVoltage = Voltage; } + + // the switch that lowers all of them + bool AllDown() const { return allDown; } + void SetAllDown(bool const State) { allDown = State; } + // the presets of the pantographs: the setups they can be switched to as chars, and the one selected in each cab std::pair> presets{"0132", {0, 0}}; + + private: + double frontVoltage{0.0}; + double rearVoltage{0.0}; + double supplyVoltage{0.0}; + bool allDown{false}; +}; + +// what the air of the pantographs needs to know in the step +struct PantographAirSupply +{ + bool anyPantographActive{false}; // a pantograph of the vehicle is up or rising + bool lowVoltage{false}; // the low voltage circuits have their power + bool collectors{false}; // the vehicle takes its power through pantographs: they have air of their own + bool multipleUnit{false}; // an electric multiple unit: its small compressor fills slower, its pressure switch locks + double mainReservoirPressure{0.0}; // [bar] + double controlReservoirPressure{0.0}; // [bar], what the gauge shows on a vehicle of no pantographs + double maxPressure{0.0}; // of the pantographs [bar], CollectorParameters.MaxPress + double minPressure{0.0}; // below which the pressure switch trips [bar], CollectorParameters.MinPress }; // the air of the pantographs: their reservoir, the small compressor that fills it, the valves -struct PantographAir +class PantographAir { - double volume = 0.48; // so that the raised pantographs drop soon with the compressor off - double pressure = 0.0; // in the reservoirs of the pantographs - bool compressorRunning = false; // the small compressor - start_t compressorStart{start_t::manual}; // PantCompressorStart - int compressorPower = 0; // SmallCompressorPower + public: + struct Config + { + start_t compressorStart{start_t::manual}; // PantCompressorStart + int compressorPower{0}; // SmallCompressorPower + bool autoValve{false}; // the kind of the valve of the small compressor fitted + }; + Config config; + basic_valve valve; - bool connectedToMainReservoir = true; // the three-way cock: to the main reservoir, or to the small compressor - bool autoValve{false}; // the kind of the valve of the small compressor fitted - bool pressureSwitchActive{false}; // the pressure switch, primed at the pressure set in the air of the pantographs - bool pressureLockActive{false}; // fires when the pressure switch trips by the pressure dropping below its level + + // in the reservoirs of the pantographs [bar] + double const &Pressure() const { return pressure; } + // the air in them, in the units of the model of their reservoir + double Volume() const { return volume; } + // the reservoirs of a vehicle placed with its pantographs down and empty + void Empty() + { + volume = 0.1; + pressure = 0.0; + } + + // the small compressor + bool IsCompressorRunning() const { return compressorRunning; } + void SwitchCompressor(bool const State) { compressorRunning = State; } + // the three-way cock: to the main reservoir, or to the small compressor + bool IsConnectedToMainReservoir() const { return connectedToMainReservoir; } + void ConnectToMainReservoir(bool const State) { connectedToMainReservoir = State; } + + // the pressure switch, primed at the pressure set in the air of the pantographs + bool IsPressureSwitchPrimed() const { return pressureSwitchActive; } + // the lock of the converter and the heating of a multiple unit, set when the pressure switch trips + bool IsPressureLockActive() const { return pressureLockActive; } + + // the step of the air of the pantographs. returns whether the pressure switch tripped in it, by the pressure falling + // below its level: the switch is spent then, and the lock of a multiple unit set; what else follows is up to the vehicle + bool Update(PantographAirSupply const &Supply, double const dt) + { + // automatic start if the pressure is too low + compressorRunning |= pressure < 4.2 && Supply.anyPantographActive && (config.compressorStart == start_t::automatic || config.compressorStart == start_t::manualwithautofallback); + compressorRunning &= Supply.lowVoltage; + + if (false == Supply.collectors) + { + // a tu coś dla SM42 i SM31, aby pokazywać na manometrze + pressure = Supply.controlReservoirPressure; + return false; + } + // Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem + // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS + // Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć + // WS i odpalić resztę + if (config.autoValve ? pressure < Supply.mainReservoirPressure : connectedToMainReservoir) // kurek zamyka połączenie z ZG + { + // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje + // Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem + // ograniczenie ciśnienia do MaxPress (tylko w pantografach!) + // (the bounds as the .fiz gives them, which may cross) + pressure = std::min(std::max(Supply.mainReservoirPressure, 0.0), Supply.maxPressure); + volume = (pressure + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem + } + else + { + // zbiornik główny odcięty, można pompować pantografy + if (compressorRunning) + { + // włączona mała sprężarka + volume += dt + // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 + * (Supply.multipleUnit ? 0.003 : 0.005) / std::max(1.0, pressure) * (0.45 - (0.1 / volume / 10 - 0.1)) / 0.45; + } + pressure = std::min(std::max(10.0 * volume - 1.0, 0.0), Supply.maxPressure); // tu by się przydała objętość zbiornika + } + if (false == compressorRunning && volume > 0.1) + { + volume -= dt * 0.0003 * std::max(1.0, pressure * 0.5); // nieszczelności: 0.0003=0.3l/s + } + return UpdatePressureSwitch(Supply); + } + + // the pressure switch: low, it trips once (see Update()); primed again over 4.6 bar, where the small compressor stops + // at 4.8. returns whether it tripped + bool UpdatePressureSwitch(PantographAirSupply const &Supply) + { + if (pressure < Supply.minPressure) + { + // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php + if (false == pressureSwitchActive) + { + return false; + } + // specialized variant for EMU -- pwr system disables converter and heating, + // and prevents their activation until pressure switch is set again + if (Supply.multipleUnit) + { + pressureLockActive = true; + } + // mark the pressure switch as spent + pressureSwitchActive = false; + return true; + } + if (pressure >= 4.6) + { + // NOTE: we require active low power source to prime the pressure switch + // this is a work-around for potential isssues caused by the switch activating on otherwise idle vehicles, but should check whether it's accurate + if (Supply.lowVoltage) + { + // prime the pressure switch + pressureSwitchActive = true; + // turn off the subsystems lock + pressureLockActive = false; + } + if (pressure >= 4.8) + { + // Winger - automatyczne wylaczanie malej sprezarki + // TODO: governor lock, disables usage until pressure drop below 3.8 (should really make compressor object we could reuse) + compressorRunning = false; + } + } + return false; + } + + // for the tests: the reservoirs at the given pressure, with the pressure switch primed or not + void SetForTest(double const Pressure, bool const PressureSwitchPrimed) + { + pressure = Pressure; + pressureSwitchActive = PressureSwitchPrimed; + } + + private: + double volume{0.48}; // so that the raised pantographs drop soon with the compressor off + double pressure{0.0}; + bool compressorRunning{false}; + bool connectedToMainReservoir{true}; + bool pressureSwitchActive{false}; + bool pressureLockActive{false}; }; } // namespace physics diff --git a/physics/components/pneumatics.cpp b/physics/components/pneumatics.cpp index 886ce0cd7..4156ec35e 100644 --- a/physics/components/pneumatics.cpp +++ b/physics/components/pneumatics.cpp @@ -246,7 +246,7 @@ bool physics::Vehicle::EpFuseSwitch(bool State) // ************************************************************************************************* bool physics::Vehicle::SpringBrakeActivate(bool State) { - if (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) + if (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) { SendCtrlToNext(VehicleCommand::springBrakeActivate, int(State), CabActive, CouplingSet::FromBits(brakes.spring.controlCouplings)); @@ -541,7 +541,7 @@ bool physics::Vehicle::UniversalBrakeButton(int button, int state) bool OK = true; // false tylko jeśli nie uda się wysłać, GF 20161124 brakes.universalButtonPressed[button] = state > 0; int flag = 0; - if (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) + if (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()) { for (int i = 0; i < 3; i++) { @@ -588,7 +588,7 @@ bool physics::Vehicle::SwitchEPBrake(int state) bool physics::Vehicle::EPBrakeControlPowered() const { - return lowVoltage.power24vAvailable && DirActive != 0 && EpFuse; + return lowVoltage.Is24vAvailable() && DirActive != 0 && EpFuse; } // ************************************************************************************************* @@ -810,7 +810,7 @@ void physics::Vehicle::CompressorCheck(double dt) } // 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.power110vAvailable}; + 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 @@ -1226,7 +1226,7 @@ void physics::Vehicle::UpdateEPBrake() else EpForce = 0.0; - brakes.electrodynamic.emuWorking = EpForce > 0.001 ? lowVoltage.power110vAvailable : true; + brakes.electrodynamic.emuWorking = EpForce > 0.001 ? lowVoltage.Is110vAvailable() : true; double temp1 = EpForce; if (brakes.emuDynamic.epMaxSpeed > 0.001 && Vel > brakes.emuDynamic.epMaxSpeed && brakes.electrodynamic.emuWorking) diff --git a/physics/components/securitysystem.cpp b/physics/components/securitysystem.cpp index 5d1fdf2e6..3671c0b4b 100644 --- a/physics/components/securitysystem.cpp +++ b/physics/components/securitysystem.cpp @@ -248,12 +248,12 @@ void physics::Vehicle::SecuritySystemReset(void) // zbijanie czuwaka/SHP // ************************************************************************************************* void physics::Vehicle::SecuritySystemCheck(double dt) { - bool isPower = lowVoltage.power24vAvailable || lowVoltage.power110vAvailable; + bool isPower = lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable(); // the shunt mode of the SM42 switches its vigilance device (CA) off, on the vehicles with AwareOffInShuntMode=Yes (eu07/maszyna#457) SecuritySystem.set_shunt_mode(ShuntMode); SecuritySystem.update(dt, Vel, isPower, CabActive); - if (!lowVoltage.batteryOn || !Radio || !RadioFuse) + if (!lowVoltage.IsBatteryOn() || !Radio || !RadioFuse) { // wyłączenie baterii deaktywuje sprzęt RadiostopSwitch(false); } diff --git a/physics/components/setup.cpp b/physics/components/setup.cpp index 128047d35..ff2d4fe0e 100644 --- a/physics/components/setup.cpp +++ b/physics/components/setup.cpp @@ -41,9 +41,9 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) AutoRelayFlag = AutoRelayType == 1; - if (lowVoltage.nominalBatteryVoltage == 0.0) + if (lowVoltage.config.nominalBatteryVoltage == 0.0) { - lowVoltage.batteryStart = start_t::disabled; + lowVoltage.config.batteryStart = start_t::disabled; } Sand = SandCapacity; @@ -111,7 +111,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) { HeatingPowerSource.SourceType = TPowerSource::Main; } - if (HeatingPowerSource.SourceType == TPowerSource::NotDefined && trainHeating.power > 0) + if (HeatingPowerSource.SourceType == TPowerSource::NotDefined && trainHeating.config.power > 0) { HeatingPowerSource.SourceType = TPowerSource::PowerCable; HeatingPowerSource.PowerType = TPowerType::ElectricPower; @@ -441,7 +441,7 @@ void physics::Vehicle::SetReadyToDepart() DirAbsolute = DirActive * CabActive; // kierunek jazdy względem sprzęgów brakes.pipeLimiterPressure = brakes.controlReservoirPressure; - lowVoltage.batteryOn = lowVoltage.batteryStart != start_t::disabled; + lowVoltage.ResetBattery(); } // the air and the brakes of a vehicle standing braked diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index 0feef1456..d00ea4a37 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -97,7 +97,7 @@ double physics::Vehicle::Current(double n, double U) } } - if (brakes.electrodynamic.on && !FuseFlag && brakes.electrodynamic.type == dbrake_automatic && lowVoltage.power110vAvailable && lineBreaker.IsClosed()) // hamowanie EP09 //TUHEX + if (brakes.electrodynamic.on && !FuseFlag && brakes.electrodynamic.type == dbrake_automatic && lowVoltage.Is110vAvailable() && lineBreaker.IsClosed()) // hamowanie EP09 //TUHEX { // TODO: zrobic bardziej uniwersalne nie tylko dla EP09 MotorCurrent = -std::max(motor_param(0).fi * (Vadd / (Vadd + motor_param(0).Isat) - motor_param(0).fi0), 0.) * n * 2.0 / brakes.electrodynamic.resistance; @@ -139,11 +139,11 @@ void physics::Vehicle::UpdateSeriesMotorDynamicBrakeFlag() brakes.electrodynamic.on = false; else if (brakes.cylinderPressure > 0.25 && brakes.distributor->GetEDBCP() > 0.25) brakes.electrodynamic.on = true; - brakes.electrodynamic.on = brakes.electrodynamic.on && lowVoltage.power110vAvailable; + brakes.electrodynamic.on = brakes.electrodynamic.on && lowVoltage.Is110vAvailable(); } if (brakes.electrodynamic.type == dbrake_automatic && TrainType == train_type::emu) { - brakes.electrodynamic.on = lowVoltage.power110vAvailable && (TUHEX_Active || Vadd > TUHEX_MinIw) && brakes.electrodynamic.emuWorking; + brakes.electrodynamic.on = lowVoltage.Is110vAvailable() && (TUHEX_Active || Vadd > TUHEX_MinIw) && brakes.electrodynamic.emuWorking; } // wylacznik cisnieniowy yBARC - to jest chyba niepotrzebne tutaj Q: no to usuwam... @@ -381,9 +381,9 @@ bool physics::Vehicle::MotorBlowerPowerIsAvailable(cooling_fan const &Blower) co switch (Blower.start_type) { case start_t::battery: - return lowVoltage.power24vAvailable; + return lowVoltage.Is24vAvailable(); case start_t::converter: - return lowVoltage.power110vAvailable; + return lowVoltage.Is110vAvailable(); default: return MainCircuitPowered(); } @@ -1437,7 +1437,7 @@ void physics::Vehicle::FuseOff(void) bool physics::Vehicle::UniversalResetButton(int const Button, range_t const Notify) { - if (auto const lowvoltagepower{lowVoltage.power24vAvailable || lowVoltage.power110vAvailable}; false == lowvoltagepower) + if (auto const lowvoltagepower{lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()}; false == lowvoltagepower) { return false; } @@ -1457,7 +1457,7 @@ bool physics::Vehicle::UniversalResetButton(int const Button, range_t const Noti bool physics::Vehicle::RelayReset(int const Relays, range_t const Notify) { - auto const lowvoltagepower{lowVoltage.power24vAvailable || lowVoltage.power110vAvailable}; + auto const lowvoltagepower{lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()}; bool reset{false}; if (TestFlag(Relays, relay_t::maincircuitground) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && diff --git a/physics/vehicle.h b/physics/vehicle.h index 2cc62bc21..ba263d896 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -1416,6 +1416,8 @@ class Vehicle void UpdatePantVolume(double dt); // Ra void PantPressureSwitchCheck(); void PantPressureSwitchTrip(); + // what the air of the pantographs needs to know in the step + PantographAirSupply PantographAirSupplyNow() const; void UpdateScndPipePressure(double dt); void UpdateSpringBrake(double dt); double GetDVc(double dt); @@ -1578,7 +1580,7 @@ class Vehicle // whether the radio is switched on, its power supply isn't cut off and it has the low voltage to work bool RadioPowered() const { - return Radio && RadioFuse && (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable); + return Radio && RadioFuse && (lowVoltage.Is24vAvailable() || lowVoltage.Is110vAvailable()); } /*obrot kol uwzgledniajacy poslizg*/ double ComputeRotatingWheel(double WForce, double dt, double n) const; diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index 33c5415f4..01ff98ee0 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -52,8 +52,8 @@ light_array::update() { light.direction.z = -light.direction.z; } // determine intensity of this light set - if( ( true == light.owner->physics->lowVoltage.power24vAvailable ) - || ( true == light.owner->physics->lowVoltage.power110vAvailable ) ) { + if( ( true == light.owner->physics->lowVoltage.Is24vAvailable() ) + || ( true == light.owner->physics->lowVoltage.Is110vAvailable() ) ) { // with power on, the intensity depends on the state of activated switches // first we cross-check the list of enabled lights with the lights installed in the vehicle... auto const lights { light.owner->physics->iLights[ light.index ] & light.owner->LightList( static_cast( light.index ) ) }; diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index 568e8ba97..ac38229b6 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -73,13 +73,13 @@ blackbox::driver driver_of(TDynamicObject const &Vehicle) { std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle const &Controlling) { namespace device = blackbox::cab_devices; auto const on{[](bool const State, std::uint32_t const Bit) { return State ? Bit : 0u; }}; - return on(Occupied.lowVoltage.batteryOn || Controlling.lowVoltage.batteryOn, device::battery) | on(Controlling.lineBreaker.IsClosed(), device::main_breaker) | + 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.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) | - on(Controlling.trainHeating.on, device::heating) | on(Occupied.brakes.spring.isActive, device::spring_brake) | on(Controlling.ShuntMode, device::shunt_mode) | + on(Controlling.trainHeating.IsOn(), device::heating) | on(Occupied.brakes.spring.isActive, device::spring_brake) | on(Controlling.ShuntMode, device::shunt_mode) | // the doors as the cab works them: the permits, the departure signal, the steps and the lock on(Occupied.DepartureSignal, device::departure_signal) | on(Occupied.Doors.instances[VehicleSide::left].open_permit, device::door_permit_left) | on(Occupied.Doors.instances[VehicleSide::right].open_permit, device::door_permit_right) | on(Occupied.Doors.step_enabled, device::door_step) | diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index dbba5d1d5..a76beee6a 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -108,14 +108,14 @@ void prepare_diesel(driven const &Driven) { // the pantographs' own air topped up by their compressor, and the pantographs raised void raise_pantographs(driven const &Driven) { auto &pantographs{Driven.pantographs}; - if (auto const enough{(pantographs.TrainType == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.pantographAir.pressure < enough) { - if (false == pantographs.pantographAir.autoValve) { - pantographs.pantographAir.connectedToMainReservoir = false; // the pantographs on their own air + if (auto const enough{(pantographs.TrainType == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.pantographAir.Pressure() < enough) { + if (false == pantographs.pantographAir.config.autoValve) { + pantographs.pantographAir.ConnectToMainReservoir(false); // the pantographs on their own air } - pantographs.pantographAir.compressorRunning = true; + pantographs.pantographAir.SwitchCompressor(true); } - else if (false == pantographs.pantographAir.connectedToMainReservoir || pantographs.pantographAir.pressure <= pantographs.mainPipe.pressure) { - pantographs.pantographAir.compressorRunning = false; + else if (false == pantographs.pantographAir.IsConnectedToMainReservoir() || pantographs.pantographAir.Pressure() <= pantographs.mainPipe.pressure) { + pantographs.pantographAir.SwitchCompressor(false); } Driven.cab.OperatePantographsValve(operation_t::enable); Driven.cab.OperatePantographValve(VehicleEnd::rear, operation_t::enable); @@ -184,7 +184,7 @@ bool start_up(driven Driven, track const &Track, double Seconds, trace *Trace) { if (collector) { raise_pantographs(Driven); } - if (false == collector || std::max(controlling.GetTrainsetHighVoltage(), controlling.pantographCircuit.supplyVoltage) > controlling.EnginePowerSource.CollectorParameters.MinV) { + if (false == collector || std::max(controlling.GetTrainsetHighVoltage(), controlling.pantographCircuit.SupplyVoltage()) > controlling.EnginePowerSource.CollectorParameters.MinV) { // a direction first, as in TController::PrepareDirection(): the relays reset only with one set for (int i = 0; i < 3 && cab.DirActive <= 0; ++i) { cab.DirectionForward(); diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index e252ff90f..21db64dd4 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -133,9 +133,9 @@ std::vector parameters() { {"TotalMass", [](auto const &M) { return M.TotalMass; }}, {"Mred", [](auto const &M) { return M.Mred; }}, {"Power", [](auto const &M) { return M.Power; }}, - {"HeatingPower", [](auto const &M) { return M.trainHeating.power; }}, + {"HeatingPower", [](auto const &M) { return M.trainHeating.config.power; }}, {"LightPower", [](auto const &M) { return M.LightPower; }}, - {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.batteryVoltage; }}, + {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.BatteryVoltage(); }}, {"Cx", [](auto const &M) { return M.Cx; }}, {"WheelDiameter", [](auto const &M) { return M.WheelDiameter; }}, {"TrackW", [](auto const &M) { return M.TrackW; }}, @@ -189,7 +189,7 @@ std::vector parameters() { {"Imax", [](auto const &M) { return M.Imax; }}, {"EIMCtrlType", [](auto const &M) { return M.EIMCtrlType; }}, {"Volume", [](auto const &M) { return M.brakes.reservoirAir; }}, - {"PantVolume", [](auto const &M) { return M.pantographAir.volume; }}, + {"PantVolume", [](auto const &M) { return M.pantographAir.Volume(); }}, }; for (int i = 0; i < 5; ++i) { result.emplace_back(std::format("MaxBrakePress{}", i), [i](auto const &M) { return M.brakes.maxCylinderPressure[i]; }); diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index f85c88105..c2ea5f029 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}}); + {"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 *) { @@ -93,8 +93,8 @@ std::vector const &invariants() { }, [](auto const &M) { return values({{"enrot", M.enrot}, {"dizel_nmax", M.diesel.maxRevolutions}}); }}, {"battery no higher than its nominal voltage", - [](auto const &M, double, auto const *) { return M.lowVoltage.nominalBatteryVoltage <= 0.0 || M.lowVoltage.batteryVoltage <= 1.05 * M.lowVoltage.nominalBatteryVoltage; }, - [](auto const &M) { return values({{"BatteryVoltage", M.lowVoltage.batteryVoltage}, {"NominalBatteryVoltage", M.lowVoltage.nominalBatteryVoltage}}); }}, + [](auto const &M, double, auto const *) { return M.lowVoltage.config.nominalBatteryVoltage <= 0.0 || M.lowVoltage.BatteryVoltage() <= 1.05 * M.lowVoltage.config.nominalBatteryVoltage; }, + [](auto const &M) { return values({{"BatteryVoltage", M.lowVoltage.BatteryVoltage()}, {"NominalBatteryVoltage", M.lowVoltage.config.nominalBatteryVoltage}}); }}, {"distance counted as the speed runs", [](auto const &M, double Time, auto const *Before) { if (Before == nullptr) { diff --git a/tests/unit/test_auxiliaries.cpp b/tests/unit/test_auxiliaries.cpp index 5df40fd95..c8ca48ed2 100644 --- a/tests/unit/test_auxiliaries.cpp +++ b/tests/unit/test_auxiliaries.cpp @@ -14,15 +14,15 @@ namespace { std::vector auxiliaries() { return { - {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.batteryVoltage; }}, - {"Battery", [](auto const &M) { return M.lowVoltage.batteryOn ? 1.0 : 0.0; }}, + {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.BatteryVoltage(); }}, + {"Battery", [](auto const &M) { return M.lowVoltage.IsBatteryOn() ? 1.0 : 0.0; }}, {"ConverterFlag", [](auto const &M) { return M.converter.IsRunning() ? 1.0 : 0.0; }}, - {"Power110vIsAvailable", [](auto const &M) { return M.lowVoltage.power110vAvailable ? 1.0 : 0.0; }}, - {"PantPress", [](auto const &M) { return M.pantographAir.pressure; }}, - {"PantVolume", [](auto const &M) { return M.pantographAir.volume; }}, - {"PantCompFlag", [](auto const &M) { return M.pantographAir.compressorRunning ? 1.0 : 0.0; }}, - {"PantPressSwitchActive", [](auto const &M) { return M.pantographAir.pressureSwitchActive ? 1.0 : 0.0; }}, - {"PantPressLockActive", [](auto const &M) { return M.pantographAir.pressureLockActive ? 1.0 : 0.0; }}, + {"Power110vIsAvailable", [](auto const &M) { return M.lowVoltage.Is110vAvailable() ? 1.0 : 0.0; }}, + {"PantPress", [](auto const &M) { return M.pantographAir.Pressure(); }}, + {"PantVolume", [](auto const &M) { return M.pantographAir.Volume(); }}, + {"PantCompFlag", [](auto const &M) { return M.pantographAir.IsCompressorRunning() ? 1.0 : 0.0; }}, + {"PantPressSwitchActive", [](auto const &M) { return M.pantographAir.IsPressureSwitchPrimed() ? 1.0 : 0.0; }}, + {"PantPressLockActive", [](auto const &M) { return M.pantographAir.IsPressureLockActive() ? 1.0 : 0.0; }}, }; } @@ -35,21 +35,21 @@ TEST_CASE("auxiliaries: the battery drained by the lights and the pantographs' c scenario.add("4e_v1/4e", 1); REQUIRE(scenario.start_up()); auto &eu07{scenario.cab()}; - REQUIRE(eu07.lowVoltage.batteryVoltage == doctest::Approx(eu07.lowVoltage.nominalBatteryVoltage)); + REQUIRE(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(eu07.lowVoltage.config.nominalBatteryVoltage)); scenario.act("converter off, lights on, small compressor on"); eu07.ConverterSwitch(false); eu07.iLights[VehicleEnd::front] = 1 | 2 | 4; eu07.iLights[VehicleEnd::rear] = 16; - eu07.pantographAir.compressorRunning = true; + eu07.pantographAir.SwitchCompressor(true); scenario.wait(30.0); - CHECK(eu07.lowVoltage.batteryVoltage < 0.83 * eu07.lowVoltage.nominalBatteryVoltage); + CHECK(eu07.lowVoltage.BatteryVoltage() < 0.83 * eu07.lowVoltage.config.nominalBatteryVoltage); CHECK(eu07.lineBreaker.IsClosed()); scenario.wait(5000.0); - CHECK(eu07.lowVoltage.batteryVoltage < eu07.lowVoltage.nominalBatteryVoltage / 1.57); + CHECK(eu07.lowVoltage.BatteryVoltage() < eu07.lowVoltage.config.nominalBatteryVoltage / 1.57); CHECK_FALSE(eu07.lineBreaker.IsClosed()); scenario.act("start up again"); CHECK_FALSE(scenario.start_up()); - CHECK(eu07.lowVoltage.batteryVoltage < eu07.lowVoltage.nominalBatteryVoltage / 1.57); + CHECK(eu07.lowVoltage.BatteryVoltage() < eu07.lowVoltage.config.nominalBatteryVoltage / 1.57); scenario.check(); } @@ -61,20 +61,20 @@ TEST_CASE("auxiliaries: the battery switched off, and charged by the converter") scenario.act("converter off"); eu07.ConverterSwitch(false); scenario.wait(10.0); - auto const discharged{eu07.lowVoltage.batteryVoltage}; - CHECK(discharged < 0.83 * eu07.lowVoltage.nominalBatteryVoltage); + auto const discharged{eu07.lowVoltage.BatteryVoltage()}; + CHECK(discharged < 0.83 * eu07.lowVoltage.config.nominalBatteryVoltage); // the converter charges it back at once scenario.act("converter on"); eu07.ConverterSwitch(true); scenario.wait(10.0); - CHECK(eu07.lowVoltage.batteryVoltage == doctest::Approx(eu07.lowVoltage.nominalBatteryVoltage)); + CHECK(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(eu07.lowVoltage.config.nominalBatteryVoltage)); // switched off, the battery falls to 90 V at once, then holds scenario.act("battery off"); eu07.MainSwitch(false); eu07.ConverterSwitch(false); eu07.BatterySwitch(false); scenario.wait(10.0); - CHECK(eu07.lowVoltage.batteryVoltage == doctest::Approx(discharged).epsilon(0.01)); + CHECK(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(discharged).epsilon(0.01)); scenario.check(); } @@ -90,23 +90,23 @@ TEST_CASE("auxiliaries: the pantographs on their own tank, leaking until the pre auto &eu07{scenario.cab()}; // started up on the small compressor, the tank gets joined to the main reservoir, which primes the switch scenario.act("tank joined to the main reservoir"); - eu07.pantographAir.connectedToMainReservoir = true; + eu07.pantographAir.ConnectToMainReservoir(true); scenario.wait(30.0); - REQUIRE(eu07.pantographAir.pressureSwitchActive); + REQUIRE(eu07.pantographAir.IsPressureSwitchPrimed()); scenario.act("tank cut off the main reservoir"); - eu07.pantographAir.connectedToMainReservoir = false; - eu07.pantographAir.compressorRunning = false; + eu07.pantographAir.ConnectToMainReservoir(false); + eu07.pantographAir.SwitchCompressor(false); scenario.wait(600.0); - CHECK(eu07.pantographAir.pressure < eu07.EnginePowerSource.CollectorParameters.MinPress); - CHECK_FALSE(eu07.pantographAir.pressureSwitchActive); + CHECK(eu07.pantographAir.Pressure() < eu07.EnginePowerSource.CollectorParameters.MinPress); + CHECK_FALSE(eu07.pantographAir.IsPressureSwitchPrimed()); CHECK_FALSE(eu07.lineBreaker.IsClosed()); scenario.act("small compressor on"); - eu07.pantographAir.compressorRunning = true; - for (int i = 0; i < 60 && eu07.pantographAir.compressorRunning; ++i) { + eu07.pantographAir.SwitchCompressor(true); + for (int i = 0; i < 60 && eu07.pantographAir.IsCompressorRunning(); ++i) { scenario.wait(10.0); } - CHECK_FALSE(eu07.pantographAir.compressorRunning); - CHECK(eu07.pantographAir.pressure >= 4.6); // stopped at 4.8, leaking since - CHECK(eu07.pantographAir.pressureSwitchActive); + CHECK_FALSE(eu07.pantographAir.IsCompressorRunning()); + CHECK(eu07.pantographAir.Pressure() >= 4.6); // stopped at 4.8, leaking since + CHECK(eu07.pantographAir.IsPressureSwitchPrimed()); scenario.check(); } diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index f4e2c4841..68f652b7f 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -47,14 +47,14 @@ std::vector state() { {"CompartmentLightsEnabled", [](auto const &M) { return flag(M.CompartmentLights.is_enabled); }}, {"CompartmentLightsDisabled", [](auto const &M) { return flag(M.CompartmentLights.is_disabled); }}, {"MainSwitch", [](auto const &M) { return flag(M.lineBreaker.IsClosed()); }}, - {"Heating", [](auto const &M) { return flag(M.trainHeating.on); }}, + {"Heating", [](auto const &M) { return flag(M.trainHeating.IsOn()); }}, {"DirActive", [](auto const &M) { return M.DirActive; }}, {"DirAbsolute", [](auto const &M) { return M.DirAbsolute; }}, {"CabActive", [](auto const &M) { return M.CabActive; }}, {"CabMaster", [](auto const &M) { return flag(M.CabMaster); }}, {"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.batteryOn); }}, + {"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; }}, {"DoorLock", [](auto const &M) { return flag(M.Doors.lock_enabled); }}, @@ -410,7 +410,7 @@ TEST_CASE("commands: every switch of the cab, worked on a pair standing under th channels.insert(channels.end(), { {"PantFrontActive", [](auto const &M) { return flag(M.pantographs[VehicleEnd::front].is_active); }}, {"PantRearActive", [](auto const &M) { return flag(M.pantographs[VehicleEnd::rear].is_active); }}, - {"PantPress", [](auto const &M) { return M.pantographAir.pressure; }}, + {"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); }}, diff --git a/tests/unit/test_compartment_lights.cpp b/tests/unit/test_compartment_lights.cpp index 917618544..8724a135b 100644 --- a/tests/unit/test_compartment_lights.cpp +++ b/tests/unit/test_compartment_lights.cpp @@ -20,32 +20,32 @@ void lights_check(vehicle &Car) { TEST_CASE("compartment lights: the lights need low voltage power and the switch") { vehicle car{definition::fiz("elf_v1/21we-a")}; REQUIRE(car->CompartmentLights.start_type == start_t::manual); - car->lowVoltage.power24vAvailable = false; - car->lowVoltage.power110vAvailable = false; + car->lowVoltage.Set24vAvailableForTest(false); + car->lowVoltage.Set110vAvailableForTest(false); car->CompartmentLightsSwitch(true, range_t::local); // switch on, no power lights_check(car); CHECK_FALSE(car->CompartmentLights.is_active); - car->lowVoltage.power110vAvailable = true; // converter on + car->lowVoltage.Set110vAvailableForTest(true); // converter on lights_check(car); CHECK(car->CompartmentLights.is_active); CHECK(car->CompartmentLights.intensity == doctest::Approx(1.0)); - car->lowVoltage.power110vAvailable = false; // battery only: the lights stay on, dimmed - car->lowVoltage.power24vAvailable = true; + car->lowVoltage.Set110vAvailableForTest(false); // battery only: the lights stay on, dimmed + car->lowVoltage.Set24vAvailableForTest(true); lights_check(car); CHECK(car->CompartmentLights.is_active); CHECK(car->CompartmentLights.intensity == doctest::Approx(0.5)); - car->lowVoltage.power24vAvailable = false; // no power at all + car->lowVoltage.Set24vAvailableForTest(false); // no power at all lights_check(car); CHECK_FALSE(car->CompartmentLights.is_active); } TEST_CASE("compartment lights: the off switch turns the lights off, the on switch back on") { vehicle car{definition::fiz("elf_v1/21we-a")}; - car->lowVoltage.power110vAvailable = true; + car->lowVoltage.Set110vAvailableForTest(true); lights_check(car); CHECK_FALSE(car->CompartmentLights.is_active); // manual start: off until switched on @@ -68,13 +68,13 @@ TEST_CASE("compartment lights: the off switch turns the lights off, the on switc TEST_CASE("compartment lights: lights started automatically come on with the power alone") { vehicle car{definition::fiz("elf_v1/21we-a").set("Cntrl", "CompartmentLightsStart", "Automatic")}; REQUIRE(car->CompartmentLights.start_type == start_t::automatic); - car->lowVoltage.power24vAvailable = false; - car->lowVoltage.power110vAvailable = false; + car->lowVoltage.Set24vAvailableForTest(false); + car->lowVoltage.Set110vAvailableForTest(false); lights_check(car); CHECK_FALSE(car->CompartmentLights.is_active); - car->lowVoltage.power110vAvailable = true; + car->lowVoltage.Set110vAvailableForTest(true); lights_check(car); CHECK(car->CompartmentLights.is_active); } diff --git a/tests/unit/test_compartment_lights_switch.cpp b/tests/unit/test_compartment_lights_switch.cpp index 8bc096c5d..0433c1d1f 100644 --- a/tests/unit/test_compartment_lights_switch.cpp +++ b/tests/unit/test_compartment_lights_switch.cpp @@ -117,7 +117,7 @@ void toggle(vehicle &Car, cab_controls const &Cab) { // the Elf (21WE-a), its compartment lights started by hand, with the converter running void power_up(vehicle &Car) { REQUIRE(Car->CompartmentLights.start_type == start_t::manual); - Car->lowVoltage.power110vAvailable = true; + Car->lowVoltage.Set110vAvailableForTest(true); lights_check(Car); REQUIRE_FALSE(Car->CompartmentLights.is_active); } diff --git a/tests/unit/test_compressor.cpp b/tests/unit/test_compressor.cpp index b9c8bc6fc..b4bc1a201 100644 --- a/tests/unit/test_compressor.cpp +++ b/tests/unit/test_compressor.cpp @@ -89,7 +89,7 @@ TEST_CASE("compressor: a compressor fed from the low voltage waits from the low run_compressor(vehicle, 10.0); REQUIRE_FALSE(vehicle->air.compressor.running); - vehicle->lowVoltage.power110vAvailable = true; + vehicle->lowVoltage.Set110vAvailableForTest(true); run_compressor(vehicle, 4.9); CHECK_FALSE(vehicle->air.compressor.running); run_compressor(vehicle, 0.2); @@ -178,15 +178,15 @@ TEST_CASE("compressor: fed from the converter it waits for the converter start d REQUIRE(loco->converter.config.startDelay == doctest::Approx(30.0)); loco.run(1.0); // engine off - CHECK_FALSE(loco->lowVoltage.power110vAvailable); + CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); loco->lineBreaker.Close(); // engine started loco.run(25.0); - CHECK_FALSE(loco->lowVoltage.power110vAvailable); + CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); CHECK_FALSE(loco->air.compressor.running); loco.run(10.0); - CHECK(loco->lowVoltage.power110vAvailable); + CHECK(loco->lowVoltage.Is110vAvailable()); CHECK(loco->air.compressor.running); } @@ -197,7 +197,7 @@ TEST_CASE("compressor: fed from the converter the start delay counts from the co loco.run(1.0); // engine off loco->lineBreaker.Close(); // engine started loco.run(25.0); - REQUIRE(loco->lowVoltage.power110vAvailable); // the converter is up + REQUIRE(loco->lowVoltage.Is110vAvailable()); // the converter is up CHECK_FALSE(loco->air.compressor.running); // but the compressor waits for its own delay as well loco.run(10.0); diff --git a/tests/unit/test_controls.cpp b/tests/unit/test_controls.cpp index a7f73561d..6d853f799 100644 --- a/tests/unit/test_controls.cpp +++ b/tests/unit/test_controls.cpp @@ -456,13 +456,13 @@ TEST_CASE("controls: train heating from the locomotive") { scenario.act("heating on"); cab.HeatingSwitch(true); scenario.wait(30.0); - CHECK(cab.trainHeating.on); - CHECK(scenario.vehicle(2).trainHeating.on); + CHECK(cab.trainHeating.IsOn()); + CHECK(scenario.vehicle(2).trainHeating.IsOn()); scenario.act("heating off"); cab.HeatingSwitch(false); scenario.wait(10.0); - CHECK_FALSE(cab.trainHeating.on); - CHECK_FALSE(scenario.vehicle(2).trainHeating.on); + CHECK_FALSE(cab.trainHeating.IsOn()); + CHECK_FALSE(scenario.vehicle(2).trainHeating.IsOn()); scenario.check(); } @@ -552,7 +552,7 @@ TEST_CASE("controls: the automatic electrodynamic brake of the EP09, in service scenario.add("bdhpumn_v3/bdhpumn", 0, test::consist::full_coupling, 120.0); REQUIRE(scenario.start_up()); auto &ep09{scenario.cab()}; - REQUIRE(ep09.lowVoltage.power110vAvailable); + REQUIRE(ep09.lowVoltage.Is110vAvailable()); scenario.act(std::string{"brake "} + name); ep09.BrakeLevelSet(ep09.brakes.driverValve->GetPos(bh_MB) + steps); scenario.wait(10.0); diff --git a/tests/unit/test_engine_shutdown.cpp b/tests/unit/test_engine_shutdown.cpp index b96aa011c..a841da08d 100644 --- a/tests/unit/test_engine_shutdown.cpp +++ b/tests/unit/test_engine_shutdown.cpp @@ -39,7 +39,7 @@ TEST_CASE("engine shutdown: neither the fuel pump switch nor the battery switch CHECK(shunter->lineBreaker.IsClosed()); shunter->BatterySwitch(false); shunter.run(10.0); - CHECK(shunter->lowVoltage.power110vAvailable); // the converter run by the engine keeps feeding the fuel pump + CHECK(shunter->lowVoltage.Is110vAvailable()); // the converter run by the engine keeps feeding the fuel pump CHECK(shunter->lineBreaker.IsClosed()); CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index 1c32112ba..695f45193 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -133,8 +133,8 @@ TEST_CASE("genset: a vehicle without the keys has none and stays on the catenary CHECK(cab.TractionMode == traction_mode::catenary); CHECK_FALSE(cab.GensetSelected()); REQUIRE(test::start_up(test::driving(dragon6), wire)); - CHECK(cab.pantographCircuit.supplyVoltage > 2900.0); - CHECK(cab.TractionSupplyVoltage() == std::max(cab.GetTrainsetHighVoltage(), cab.pantographCircuit.supplyVoltage)); + CHECK(cab.pantographCircuit.SupplyVoltage() > 2900.0); + CHECK(cab.TractionSupplyVoltage() == std::max(cab.GetTrainsetHighVoltage(), cab.pantographCircuit.SupplyVoltage())); CHECK(cab.TractionSupplyMinVoltage() == cab.EnginePowerSource.CollectorParameters.MinV); CHECK(cab.GensetTractionPowerLimit() == std::numeric_limits::max()); // a start request does nothing without a genset @@ -230,7 +230,7 @@ TEST_CASE("genset: started, it closes the line breaker without a catenary") { run(dragon6, 1.0); } REQUIRE(cab.lineBreaker.IsClosed()); - CHECK(cab.pantographCircuit.supplyVoltage == 0.0); + CHECK(cab.pantographCircuit.SupplyVoltage() == 0.0); dragon6.step(no_wire); CHECK(cab.EngineVoltage == 3000.0); CHECK(cab.MainCircuitPowered()); @@ -263,7 +263,7 @@ TEST_CASE("genset: on the genset position the catenary feeds nothing") { REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); // the pantographs up under the wire, the genset stopped: the line breaker never closes CHECK_FALSE(test::start_up(test::driving(dragon6), wire, 120.0)); - REQUIRE(cab.pantographCircuit.supplyVoltage > 2900.0); + REQUIRE(cab.pantographCircuit.SupplyVoltage() > 2900.0); CHECK_FALSE(cab.lineBreaker.IsClosed()); CHECK_FALSE(cab.MainSwitchCheck()); dragon6.step(wire); @@ -430,7 +430,7 @@ TEST_CASE("genset: no battery, no start") { REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); cab.GensetSwitch(true); run(dragon6, 20.0); - CHECK_FALSE(cab.lowVoltage.power24vAvailable); + CHECK_FALSE(cab.lowVoltage.Is24vAvailable()); CHECK_FALSE(cab.Genset.is_cranking); CHECK_FALSE(cab.Genset.is_active); CHECK(cab.Genset.revolutions == 0.0); @@ -445,8 +445,7 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre vehicle dragon6{dragon_genset(), 0.0, "test", 1}; auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); - cab.pantographAir.pressureSwitchActive = true; - cab.pantographAir.pressure = 0.0; + cab.pantographAir.SetForTest(0.0, true); cab.PantPressureSwitchCheck(); CHECK(cab.lineBreaker.IsClosed()); } @@ -456,8 +455,7 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre REQUIRE(test::start_up(test::driving(dragon6), wire)); REQUIRE(cab.lineBreaker.IsClosed()); // the pressure switch looks at the voltage through the couplers, not the pantographs' - cab.pantographAir.pressureSwitchActive = true; - cab.pantographAir.pressure = 0.0; + cab.pantographAir.SetForTest(0.0, true); cab.PantPressureSwitchCheck(); CHECK_FALSE(cab.lineBreaker.IsClosed()); } @@ -536,7 +534,7 @@ TEST_CASE("genset: one genset feeds the next car through the high voltage coupli train.run(10.0, no_wire); REQUIRE(first.Genset.is_active); CHECK(second.GetTrainsetHighVoltage() > 2900.0); - CHECK(second.pantographCircuit.supplyVoltage == 0.0); + CHECK(second.pantographCircuit.SupplyVoltage() == 0.0); // the second one, on its catenary position with the pantographs down, takes it as the catenary's second.BatterySwitch(true); train.run(10.0, no_wire); diff --git a/tests/unit/test_horn.cpp b/tests/unit/test_horn.cpp index e606f4105..021531986 100644 --- a/tests/unit/test_horn.cpp +++ b/tests/unit/test_horn.cpp @@ -79,9 +79,9 @@ TEST_CASE("horn: an electric horn sounds on the low voltage, whatever the air") REQUIRE(vehicle->Horn3Supply == horn_supply::electric); // the third horn follows the others unless told otherwise vehicle->air.mainReservoirPressure = 0.0; - vehicle->lowVoltage.power24vAvailable = true; + vehicle->lowVoltage.Set24vAvailableForTest(true); CHECK(vehicle->SoundingHorns(allhorns) == allhorns); - vehicle->lowVoltage.power24vAvailable = false; + vehicle->lowVoltage.Set24vAvailableForTest(false); CHECK(vehicle->SoundingHorns(allhorns) == 0); } @@ -91,10 +91,10 @@ TEST_CASE("horn: the third horn can have a supply of its own, an electric horn o REQUIRE(vehicle->Horn3Supply == horn_supply::electric); vehicle->air.mainReservoirPressure = 0.0; - vehicle->lowVoltage.power24vAvailable = true; + vehicle->lowVoltage.Set24vAvailableForTest(true); CHECK(vehicle->SoundingHorns(allhorns) == 4); vehicle->air.mainReservoirPressure = 6.5; - vehicle->lowVoltage.power24vAvailable = false; + vehicle->lowVoltage.Set24vAvailableForTest(false); CHECK(vehicle->SoundingHorns(allhorns) == (horn::low | horn::high)); } @@ -116,6 +116,6 @@ TEST_CASE("horn: a pneumatic horn sounds from the threshold pressure up") { TEST_CASE("horn: an electric horn sounds on 110 V too") { auto vehicle{horn_vehicle(test::definition::load("wagon").set("Cntrl", "HornType", "Electric"))}; - vehicle->lowVoltage.power110vAvailable = true; + vehicle->lowVoltage.Set110vAvailableForTest(true); CHECK(vehicle->SoundingHorns(horn::high) == horn::high); } diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index 94e658281..567834712 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -52,7 +52,7 @@ TEST_CASE("line contactors interlock: without one the converter and the blowers TEST_CASE("line contactors interlock: on the converter, they close only with the vehicle's own converter running") { auto locomotive{ready("Converter")}; locomotive->converter.SetRunningForTest(false); - locomotive->lowVoltage.power110vAvailable = true; // the 110 V from the other section doesn't run this one's fans + locomotive->lowVoltage.Set110vAvailableForTest(true); // the 110 V from the other section doesn't run this one's fans CHECK_FALSE(locomotive->MotorConnectorsCheck()); locomotive->converter.SetRunningForTest(true); CHECK(locomotive->MotorConnectorsCheck()); @@ -95,16 +95,16 @@ TEST_CASE("line contactors interlock: a blower starting with the speed needs to SUBCASE("off the converter, it needs the 110 V") { rear.start_type = start_t::converter; rear.is_enabled = false; // nothing for the driver to switch on - locomotive->lowVoltage.power110vAvailable = false; + locomotive->lowVoltage.Set110vAvailableForTest(false); CHECK_FALSE(locomotive->MotorConnectorsCheck()); - locomotive->lowVoltage.power110vAvailable = true; + locomotive->lowVoltage.Set110vAvailableForTest(true); CHECK(locomotive->MotorConnectorsCheck()); } SUBCASE("off the battery, it needs the 24 V") { rear.start_type = start_t::battery; - locomotive->lowVoltage.power24vAvailable = false; + locomotive->lowVoltage.Set24vAvailableForTest(false); CHECK_FALSE(locomotive->MotorConnectorsCheck()); - locomotive->lowVoltage.power24vAvailable = true; + locomotive->lowVoltage.Set24vAvailableForTest(true); CHECK(locomotive->MotorConnectorsCheck()); } SUBCASE("one without a start velocity still has to run") { @@ -271,7 +271,7 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of rear.converter.SetLocalSwitch(false); test::drive(driven, line, 2.0); REQUIRE_FALSE(rear.converter.IsRunning()); - CHECK(rear.lowVoltage.power110vAvailable); + CHECK(rear.lowVoltage.Is110vAvailable()); test::release_brakes(driven.cab); for (int i = 0; i < 3 && driven.cab.DirActive <= 0; ++i) { diff --git a/tests/unit/test_mains_before_pantographs.cpp b/tests/unit/test_mains_before_pantographs.cpp index fdbd4ca91..309556072 100644 --- a/tests/unit/test_mains_before_pantographs.cpp +++ b/tests/unit/test_mains_before_pantographs.cpp @@ -26,7 +26,7 @@ test::definition ep05(bool const Mainsfirst) { // battery and cab on, direction set and the relays reset, the pantographs on the main reservoir's air void prepare(test::vehicle &Loco) { Loco.hold_main_reservoir(6.0); - Loco->pantographAir.connectedToMainReservoir = true; + Loco->pantographAir.ConnectToMainReservoir(true); Loco->BatterySwitch(true); Loco->CabActivisation(); for (int i = 0; i < 3 && Loco->DirActive <= 0; ++i) { @@ -94,7 +94,7 @@ TEST_CASE("mains before pantographs: without the flag the line breaker needs the CHECK_FALSE(loco->lineBreaker.IsClosed()); raise_pantograph(loco); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); close_line_breaker(loco); CHECK(loco->lineBreaker.IsClosed()); // the pantographs stay up with the line breaker open, and the line breaker opens without voltage @@ -115,20 +115,20 @@ TEST_CASE("mains before pantographs: with the flag the pantographs rise only thr // the pantographs stay down while the line breaker is open raise_pantograph(loco); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == 0.0); + CHECK(loco->pantographCircuit.SupplyVoltage() == 0.0); // the line breaker closes without voltage, and the pantograph rises through it close_line_breaker(loco); CHECK(loco->lineBreaker.IsClosed()); raise_pantograph(loco); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK(loco->lineBreaker.IsClosed()); // opening the line breaker drops the pantograph, which stays down until the line breaker closes again loco->MainSwitch(false); loco.run(2.0, line); CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == 0.0); + CHECK(loco->pantographCircuit.SupplyVoltage() == 0.0); // a pantograph lowered under the closed line breaker leaves it closed close_line_breaker(loco); raise_pantograph(loco); @@ -153,7 +153,7 @@ TEST_CASE("mains before pantographs: with the flag the driver's start-up gets th auto driven{test::driving(loco)}; REQUIRE(test::start_up(driven, line)); CHECK(loco->lineBreaker.IsClosed()); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK(test::is_ready(driven)); } @@ -165,7 +165,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres prepare(loco); close_line_breaker(loco); REQUIRE(loco->lineBreaker.IsClosed()); - REQUIRE(loco->pantographCircuit.supplyVoltage == 0.0); + REQUIRE(loco->pantographCircuit.SupplyVoltage() == 0.0); switch_auxiliaries_on(loco); REQUIRE(loco->converter.IsAllowed()); REQUIRE(loco->air.compressor.allow); @@ -175,16 +175,16 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres CHECK(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); CHECK_FALSE(loco->converter.IsRunning()); - CHECK_FALSE(loco->lowVoltage.power110vAvailable); + CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); CHECK_FALSE(loco->air.compressor.running); // the pantograph up: the converter starts, and the compressor on its 110 V raise_pantograph(loco); - REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + REQUIRE(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); CHECK(loco->converter.IsRunning()); - CHECK(loco->lowVoltage.power110vAvailable); + CHECK(loco->lowVoltage.Is110vAvailable()); CHECK(loco->air.compressor.running); // the voltage gone they stop, behind the line breaker which stays closed @@ -202,13 +202,13 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres SUBCASE("the voltage in the catenary below the one the locomotive works on") { track = &weak; loco.run(5.0, weak); - REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); + REQUIRE(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(weak.voltage)); } CHECK(reservoir_gain(loco, 10.0, *track) < 0.01); CHECK(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); CHECK_FALSE(loco->converter.IsRunning()); - CHECK_FALSE(loco->lowVoltage.power110vAvailable); + CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); CHECK_FALSE(loco->air.compressor.running); } @@ -231,26 +231,26 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui CHECK_FALSE(loco->air.compressor.running); CHECK_FALSE(loco->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot == 0.0); - CHECK_FALSE(loco->trainHeating.on); + CHECK_FALSE(loco->trainHeating.IsOn()); SUBCASE("nor do they run on a voltage below the one the locomotive works on") { raise_pantograph(loco, weak); - REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); + 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->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot == 0.0); - CHECK_FALSE(loco->trainHeating.on); + CHECK_FALSE(loco->trainHeating.IsOn()); } SUBCASE("with the voltage they do") { raise_pantograph(loco); - REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + 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->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot > 0.0); - CHECK(loco->trainHeating.on); + CHECK(loco->trainHeating.IsOn()); } } @@ -264,14 +264,14 @@ TEST_CASE("mains before pantographs: without the flag the converter and the comp CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); CHECK(loco->converter.IsRunning()); - CHECK(loco->lowVoltage.power110vAvailable); + CHECK(loco->lowVoltage.Is110vAvailable()); CHECK(loco->air.compressor.running); // 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.power110vAvailable); + CHECK_FALSE(loco->lowVoltage.Is110vAvailable()); CHECK_FALSE(loco->air.compressor.running); } @@ -296,7 +296,7 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when // the voltage back, with the master controller still where it was: the camshaft went down to zero and stays // there, the motors still cut off; the converter is back on its own test::drive(driven, line, 10.0); - REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + REQUIRE(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); REQUIRE(loco->MainCtrlPos == 5); CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->converter.IsRunning()); diff --git a/tests/unit/test_oil_pump.cpp b/tests/unit/test_oil_pump.cpp index 94e590208..674930af2 100644 --- a/tests/unit/test_oil_pump.cpp +++ b/tests/unit/test_oil_pump.cpp @@ -12,7 +12,7 @@ using test::vehicle; TEST_CASE("oil pump: the pre-lubrication pump works before the engine start and stops once the engine runs") { vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Manual")}; REQUIRE(loco->OilPump.start_type == start_t::manual); - loco->lowVoltage.power24vAvailable = true; // battery on + loco->lowVoltage.Set24vAvailableForTest(true); // battery on loco->OilPumpCheck(0.01); CHECK_FALSE(loco->OilPump.is_active); // not switched on yet @@ -29,7 +29,7 @@ TEST_CASE("oil pump: the pre-lubrication pump works before the engine start and TEST_CASE("oil pump: the pump started with the engine start procedure stops once the engine runs") { vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Automatic")}; REQUIRE(loco->OilPump.start_type == start_t::automatic); - loco->lowVoltage.power24vAvailable = true; + loco->lowVoltage.Set24vAvailableForTest(true); loco->diesel.startupRequested = true; // starter button pressed loco->OilPumpCheck(0.01); @@ -46,8 +46,8 @@ TEST_CASE("oil pump: the pump started with the engine start procedure stops once TEST_CASE("oil pump: without power the pump and its lamp stay off") { vehicle loco{definition::load("cab_vehicle")}; - loco->lowVoltage.power24vAvailable = false; - loco->lowVoltage.power110vAvailable = false; + loco->lowVoltage.Set24vAvailableForTest(false); + loco->lowVoltage.Set110vAvailableForTest(false); loco->OilPump.is_enabled = true; loco->OilPumpCheck(0.01); diff --git a/tests/unit/test_pressure_switch.cpp b/tests/unit/test_pressure_switch.cpp index 2c30692d6..a45260b49 100644 --- a/tests/unit/test_pressure_switch.cpp +++ b/tests/unit/test_pressure_switch.cpp @@ -169,7 +169,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::front].is_active); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == 0.0); + CHECK(loco->pantographCircuit.SupplyVoltage() == 0.0); CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); @@ -193,7 +193,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller emergency_application(loco, driven); CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK(loco->Im == 0.0); // and the master controller moved with the pipe empty is the same as the application made with it moved @@ -234,7 +234,7 @@ TEST_CASE("pressure switch: without the key an emergency application leaves the REQUIRE(loco->MainCtrlPos == 5); CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); // the pressure switch cuts the motors off CHECK(loco->protection.PressureSwitchTripped()); CHECK_FALSE(loco->lineContactors.IsClosed()); @@ -250,7 +250,7 @@ TEST_CASE("pressure switch: where the pantographs don't hang on the line breaker emergency_application(loco, driven); CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); } @@ -272,7 +272,7 @@ TEST_CASE("pressure switch: after the emergency application the driver's start-u CHECK(loco->MainCtrlPos == 0); CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.SupplyVoltage() == doctest::Approx(test::catenary_3kv)); REQUIRE(loco->brakePipe.pressure < emergency_pressure); // and it stays so test::drive(driven, line, 30.0); diff --git a/tests/unit/test_pullee.cpp b/tests/unit/test_pullee.cpp index 62f620270..d75fb2611 100644 --- a/tests/unit/test_pullee.cpp +++ b/tests/unit/test_pullee.cpp @@ -114,13 +114,13 @@ TEST_CASE("pullee: an EU07 with a driver can't release the brakes of a dead Vect test::drive(driven, track, 60.0); if (false == pullee) { // the Vectron has emptied the brake pipe, and both locomotives stand on an emergency application - CHECK(hauled->lowVoltage.batteryOn); + CHECK(hauled->lowVoltage.IsBatteryOn()); CHECK(locomotive->brakePipe.pressure < 1.0); CHECK(locomotive->brakes.cylinderPressure > 3.0); CHECK(hauled->brakes.cylinderPressure > 3.0); continue; } - CHECK_FALSE(hauled->lowVoltage.batteryOn); + CHECK_FALSE(hauled->lowVoltage.IsBatteryOn()); CHECK(locomotive->brakePipe.pressure > 4.9); CHECK(locomotive->brakes.cylinderPressure < 0.1); CHECK(hauled->brakes.cylinderPressure < 0.1); @@ -335,9 +335,9 @@ TEST_CASE("pullee: entering the mode lets go of the hand brake and the spring br } SUBCASE("a locomotive ready to depart, its battery on") { vehicle vectron{definition::fiz("vectron_v1/wariant_7w"), 0.1}; - REQUIRE(vectron->lowVoltage.batteryOn); + REQUIRE(vectron->lowVoltage.IsBatteryOn()); CHECK(vectron->PulleeModeSwitch(true)); - CHECK_FALSE(vectron->lowVoltage.batteryOn); + CHECK_FALSE(vectron->lowVoltage.IsBatteryOn()); } } @@ -345,7 +345,7 @@ TEST_CASE("pullee: the battery and the cabs of a vehicle prepared for hauling st vehicle vectron{definition::fiz("vectron_v1/wariant_7w"), 0.0, "test", 1}; REQUIRE(vectron->PulleeModeSwitch(true)); CHECK_FALSE(vectron->BatterySwitch(true)); - CHECK_FALSE(vectron->lowVoltage.batteryOn); + CHECK_FALSE(vectron->lowVoltage.IsBatteryOn()); CHECK_FALSE(vectron->CabActivisation()); CHECK_FALSE(vectron->CabActivisation(true)); CHECK(vectron->CabActive == 0); @@ -357,7 +357,7 @@ TEST_CASE("pullee: the battery and the cabs of a vehicle prepared for hauling st REQUIRE(vectron->PulleeModeSwitch(false)); CHECK_FALSE(vectron->PulleeMode); CHECK(vectron->BatterySwitch(true)); - CHECK(vectron->lowVoltage.batteryOn); + CHECK(vectron->lowVoltage.IsBatteryOn()); CHECK(vectron->CabActivisation()); CHECK(vectron->CabActive == 1); // a vehicle driven from isn't one to haul @@ -394,14 +394,14 @@ TEST_CASE("pullee: the battery and cab commands of the train's driver pass a veh if (pullee) { REQUIRE(hauled->PulleeModeSwitch(true)); } - REQUIRE_FALSE(hauled->lowVoltage.batteryOn); + REQUIRE_FALSE(hauled->lowVoltage.IsBatteryOn()); locomotive->BatterySwitch(true); locomotive->CabActivisation(); train.run(2.0); - CHECK(hauled->lowVoltage.batteryOn == (false == pullee)); + CHECK(hauled->lowVoltage.IsBatteryOn() == (false == pullee)); CHECK(hauled->CabActive == (pullee ? 0 : 1)); // the vehicle behind it gets them either way - CHECK(last->lowVoltage.batteryOn); + CHECK(last->lowVoltage.IsBatteryOn()); CHECK(last->CabActive == 1); } } @@ -439,7 +439,7 @@ TEST_CASE("pullee: every real vehicle standing braked releases once prepared for auto const &hauled{train.hauled.physics()}; CHECK(hauled.brakes.handBrakePosition == 0); CHECK_FALSE(hauled.brakes.spring.activate); - CHECK_FALSE(hauled.lowVoltage.batteryOn); + CHECK_FALSE(hauled.lowVoltage.IsBatteryOn()); train.run(180.0); CHECK(hauled.brakes.emergencyValve.flow == 0.0); CHECK(hauled.brakes.cylinderPressure < 0.1); diff --git a/tests/unit/test_radio.cpp b/tests/unit/test_radio.cpp index abe4ef9f8..696624cce 100644 --- a/tests/unit/test_radio.cpp +++ b/tests/unit/test_radio.cpp @@ -8,8 +8,8 @@ TEST_CASE("radio: a radio switched on with the low voltage works") { test::vehicle vehicle{test::definition::load("wagon")}; vehicle->Radio = true; - SUBCASE("24 V") { vehicle->lowVoltage.power24vAvailable = true; } - SUBCASE("110 V") { vehicle->lowVoltage.power110vAvailable = true; } + SUBCASE("24 V") { vehicle->lowVoltage.Set24vAvailableForTest(true); } + SUBCASE("110 V") { vehicle->lowVoltage.Set110vAvailableForTest(true); } CHECK(vehicle->RadioPowered()); } @@ -17,12 +17,12 @@ TEST_CASE("radio: a radio switched off or without the low voltage doesn't") { test::vehicle vehicle{test::definition::load("wagon")}; SUBCASE("switched off") { vehicle->Radio = false; - vehicle->lowVoltage.power24vAvailable = true; + vehicle->lowVoltage.Set24vAvailableForTest(true); } SUBCASE("batteries off") { vehicle->Radio = true; - vehicle->lowVoltage.power24vAvailable = false; - vehicle->lowVoltage.power110vAvailable = false; + vehicle->lowVoltage.Set24vAvailableForTest(false); + vehicle->lowVoltage.Set110vAvailableForTest(false); } CHECK_FALSE(vehicle->RadioPowered()); } @@ -38,7 +38,7 @@ TEST_CASE("radio: the radio fuse is closed by default") { TEST_CASE("radio: an opened radio fuse cuts the radio off") { test::vehicle vehicle{test::definition::load("wagon")}; vehicle->Radio = true; - vehicle->lowVoltage.power24vAvailable = true; + vehicle->lowVoltage.Set24vAvailableForTest(true); vehicle->RadioFuse = false; CHECK_FALSE(vehicle->RadioPowered()); vehicle->RadioFuse = true; @@ -47,7 +47,7 @@ TEST_CASE("radio: an opened radio fuse cuts the radio off") { TEST_CASE("radio: opening the radio fuse at a standstill resets the radio-stop, as switching the radio off does") { test::vehicle loco{test::definition::fiz("4e_v1/4e")}; - loco->lowVoltage.batteryOn = true; + loco->lowVoltage.SetBatteryOnForTest(true); loco->Radio = true; REQUIRE(loco->RadiostopSwitch(true)); loco->SecuritySystemCheck(0.1); diff --git a/tests/unit/test_switches.cpp b/tests/unit/test_switches.cpp index f2ca6de17..444606524 100644 --- a/tests/unit/test_switches.cpp +++ b/tests/unit/test_switches.cpp @@ -7,10 +7,10 @@ TEST_CASE("switches: the train heating switch can spring back (MaSzyna-EU07/maszyna#85)") { SUBCASE("impulse") { test::vehicle vehicle{test::definition::load("cab_vehicle").set("Switches", "TrainHeating", "Impulse")}; - CHECK(vehicle->trainHeating.switchImpulse); // whichever the case it's written in + CHECK(vehicle->trainHeating.config.switchImpulse); // whichever the case it's written in } SUBCASE("a plain switch by default") { test::vehicle vehicle{test::definition::load("cab_vehicle")}; - CHECK_FALSE(vehicle->trainHeating.switchImpulse); + CHECK_FALSE(vehicle->trainHeating.config.switchImpulse); } } diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index 4e98ed74f..88e7a3b99 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -225,15 +225,15 @@ double vehicle::move(track const &Track, double Dt, TLocation const &Location, d // what TDynamicObject::Update() does before the movement. a raised pantograph touches the wire at once, // the game animates its rise auto &physics{*m_physics}; - physics.pantographCircuit.frontVoltage = physics.pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0; - physics.pantographCircuit.rearVoltage = physics.pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0; + physics.pantographCircuit.SetFrontVoltage(physics.pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0); + physics.pantographCircuit.SetRearVoltage(physics.pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0); TTractionParam traction; traction.TractionVoltage = - physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(physics.pantographCircuit.rearVoltage), std::abs(physics.pantographCircuit.frontVoltage)) : 0.95 * physics.EnginePowerSource.MaxVoltage; + physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(physics.pantographCircuit.RearVoltage()), std::abs(physics.pantographCircuit.FrontVoltage())) : 0.95 * physics.EnginePowerSource.MaxVoltage; traction.TractionFreq = 0; traction.TractionMaxCurrent = 7500; traction.TractionResistivity = 0.3; - physics.pantographCircuit.supplyVoltage = traction.TractionVoltage; + physics.pantographCircuit.SetSupplyVoltage(traction.TractionVoltage); if (m_cab != 0) { using enum TEngineType; // the driver's own vehicle, which gets the average pressure of the train's brake pipe diff --git a/vehicle/Gauge.cpp b/vehicle/Gauge.cpp index 0944fe83b..48b21ac1c 100644 --- a/vehicle/Gauge.cpp +++ b/vehicle/Gauge.cpp @@ -509,25 +509,25 @@ TGauge TGauge::MirrorCopy() const { return mirror; } -void TGauge::AssignFloat(float *fValue) +void TGauge::AssignFloat(float const *fValue) { m_datatype = 'f'; fData = fValue; }; -void TGauge::AssignDouble(double *dValue) +void TGauge::AssignDouble(double const *dValue) { m_datatype = 'd'; dData = dValue; }; -void TGauge::AssignInt(int *iValue) +void TGauge::AssignInt(int const *iValue) { m_datatype = 'i'; iData = iValue; }; -void TGauge::AssignBool(bool *bValue) +void TGauge::AssignBool(bool const *bValue) { m_datatype = 'b'; bData = bValue; diff --git a/vehicle/Gauge.h b/vehicle/Gauge.h index 9c93057c1..0bda4f2b6 100644 --- a/vehicle/Gauge.h +++ b/vehicle/Gauge.h @@ -55,10 +55,10 @@ public: float GetValue() const; float GetDesiredValue() const; void Update( bool const Power = true ); - void AssignFloat(float *fValue); - void AssignDouble(double *dValue); - void AssignInt(int *iValue); - void AssignBool(bool *bValue); + void AssignFloat(float const *fValue); + void AssignDouble(double const *dValue); + void AssignInt(int const *iValue); + void AssignBool(bool const *bValue); void UpdateValue(); void AssignState( bool const *State ); // copies of the control animated along with it, from its definitions marked duplicate: yes @@ -142,10 +142,10 @@ private: char m_datatype { '\0' }; // typ zmiennej parametru: f-float, d-double, i-int, b-bool; none until one is assigned union { // wskaźnik na parametr pokazywany przez animację - float *fData; - double *dData { nullptr }; - int *iData; - bool *bData; + float const *fData; + double const *dData { nullptr }; + int const *iData; + bool const *bData; }; bool m_state { false }; // visibility of the control's submodel(s); false : default, true: active bool const *m_stateinput { nullptr }; // bound variable determining visibility of the control's submodel(s) diff --git a/vehicle/Train.h b/vehicle/Train.h index 078a06064..89892b423 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -970,6 +970,7 @@ private: float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem float fBatteryTimer = {-1.f}; // Hirek: zalaczanie baterii z opoznieniem (tylko gdy zdefiniowano takie zachowanie w fiz) bool allowBatteryToggle = true; // Hirek: zabezpieczenie przed przelaczaniem bateri on/off + bool batteryButtonFired{false}; // the battery button held down has switched the battery already, until it is let go int ScreenUpdateRate { 0 }; // vehicle specific python screen update rate override // McZapkie-240302 - przyda sie do tachometru diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index 2ced8b5f1..ca3fb0934 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -379,8 +379,8 @@ bool TController::CheckVehicles(DriverOrders user) // HACK: wagony muszą mieć baterię załączoną do otwarcia drzwi... p->physics->BatterySwitch( true ); // enable heating and converter in carriages with can be heated - if( p->physics->trainHeating.power > 0 ) { - p->physics->trainHeating.allow = true; + if( p->physics->trainHeating.config.power > 0 ) { + p->physics->trainHeating.Allow(true); p->physics->ConverterSwitch( true, range_t::local ); hasheaters = true; } @@ -485,7 +485,7 @@ bool TController::CheckVehicles(DriverOrders user) false == isheatingcouplingactive ? false : ispassengertrain ? hasheaters : false) }; - if( mvControlling->trainHeating.allow != isheatingneeded ) { + if( mvControlling->trainHeating.IsAllowed() != isheatingneeded ) { cue_action( isheatingneeded ? driver_hint::consistheatingon : @@ -680,12 +680,12 @@ TController::determine_consist_state() { // ABu-160305 testowanie gotowości do jazdy // Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma odhamować - if (occupied->CabActive == 0 && occupied->lowVoltage.power24vAvailable) + if (occupied->CabActive == 0 && occupied->lowVoltage.Is24vAvailable()) { cue_action( driver_hint::cabactivation ); } else if (!occupied->AutomaticCabActivation - && ( occupied->CabActive == -occupied->CabOccupied || !occupied->CabMaster || !occupied->lowVoltage.power24vAvailable ) ) + && ( occupied->CabActive == -occupied->CabOccupied || !occupied->CabMaster || !occupied->lowVoltage.Is24vAvailable() ) ) { cue_action( driver_hint::cabdeactivation ); } diff --git a/vehicle/ai/controls.cpp b/vehicle/ai/controls.cpp index 58b77d265..0b9bc5cb6 100644 --- a/vehicle/ai/controls.cpp +++ b/vehicle/ai/controls.cpp @@ -506,7 +506,7 @@ bool TController::IncSpeed() } // TODO: move all fVoltage assignments to a single, more generic place if( mvControlling->EnginePowerSource.SourceType == TPowerSource::Accumulator ) { - fVoltage = mvControlling->lowVoltage.batteryVoltage; + fVoltage = mvControlling->lowVoltage.BatteryVoltage(); } if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.PressureSwitchTripped() && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.IsClosed()) && (Ready || drivingFlags.press)) { // youBy polecił dodać 2012-09-08 v367 diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index b70f23289..e665c6248 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -102,21 +102,21 @@ bool TController::PrepareEngine() if( pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { // if our pantograph unit isn't a pantograph-devoid fallback - if (pantographUnit->pantographAir.pressure < sufficientpantographpressure) { + if (pantographUnit->pantographAir.Pressure() < sufficientpantographpressure) { // załączenie małej sprężarki - if( false == pantographUnit->pantographAir.autoValve ) { + if( false == pantographUnit->pantographAir.config.autoValve ) { // odłączenie zbiornika głównego, bo z nim nie da rady napompować cue_action( driver_hint::pantographairsourcesetauxiliary ); } cue_action( driver_hint::pantographcompressoron ); // załączenie sprężarki pantografów - if( pantographUnit->pantographAir.compressorRunning ) { + if( pantographUnit->pantographAir.IsCompressorRunning() ) { cue_action( driver_hint::waitpantographpressuretoolow ); } } else { // jeżeli jest wystarczające ciśnienie w pantografach - if( false == pantographUnit->pantographAir.connectedToMainReservoir - || pantographUnit->pantographAir.pressure <= pantographUnit->mainPipe.pressure ) { // kurek przełączony albo główna już pompuje + if( false == pantographUnit->pantographAir.IsConnectedToMainReservoir() + || 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ć } } @@ -130,7 +130,7 @@ bool TController::PrepareEngine() auto const ispoweravailable = mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector - || std::max(mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.supplyVoltage) > mvControlling->EnginePowerSource.CollectorParameters.MinV; + || std::max(mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.SupplyVoltage()) > mvControlling->EnginePowerSource.CollectorParameters.MinV; // standing with the pantographs up and no voltage, nothing the driver does starts the vehicle. it says so, and keeps // trying: towed back under the wire, or with the power switched on, the vehicle gets prepared after all report_power_stall( ispoweravailable, sufficientpantographpressure ); @@ -235,7 +235,7 @@ TController::report_power_stall( bool const Poweravailable, double const Pantogr state.collector = mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector; state.power = Poweravailable; state.standing = occupied->Vel < EU07_AI_NOMOVEMENT; - if( pantographUnit->pantographAir.pressure >= Pantographpressure ) { + if( pantographUnit->pantographAir.Pressure() >= Pantographpressure ) { state.pantographs_up = pantographUnit->pantographs[ VehicleEnd::front ].is_active || pantographUnit->pantographs[ VehicleEnd::rear ].is_active; @@ -339,7 +339,7 @@ bool TController::ReleaseEngine() { // && ( false == IsAnyCompressorEnabled ) // && ( false == IsAnyConverterEnabled ) && false == mvControlling->lineBreaker.IsClosed() - && false == occupied->lowVoltage.power24vAvailable }; + && false == occupied->lowVoltage.Is24vAvailable() }; if (OK) { // jeśli się zatrzymał diff --git a/vehicle/ai/orders.cpp b/vehicle/ai/orders.cpp index 954c56dfc..0c1acba8f 100644 --- a/vehicle/ai/orders.cpp +++ b/vehicle/ai/orders.cpp @@ -1178,7 +1178,7 @@ TController::handle_engine() { if( OrderCurrentGet() == DriverOrder::waitForOrders && false == iEngineActive // && ( false == AIControllFlag ) - && true == occupied->lowVoltage.power24vAvailable ) { + && true == occupied->lowVoltage.Is24vAvailable() ) { OrderNext( DriverOrder::prepareEngine ); } // basic engine preparation diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index af896e558..755e24f7a 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -142,14 +142,14 @@ TController::control_pantographs() { if( pantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } - if( false == pantographUnit->pantographAir.autoValve + if( false == pantographUnit->pantographAir.config.autoValve && 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 ); } // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić rozruch o losowy czas - fVoltage = 0.5 * (fVoltage + std::max( mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.supplyVoltage ) ); + fVoltage = 0.5 * (fVoltage + std::max( mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.SupplyVoltage() ) ); if( fVoltage < mvControlling->EnginePowerSource.CollectorParameters.MinV && fActionTime >= PrepareTime ) { // gdy rozłączenie WS z powodu niskiego napięcia // jeśli czas oczekiwania nie został ustawiony, losowy czas oczekiwania przed ponownym załączeniem jazdy @@ -197,18 +197,18 @@ TController::control_pantographs() { // jazda na tylnym if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 - if( pantographUnit->pantographCircuit.rearVoltage == 0.0 + if( pantographUnit->pantographCircuit.RearVoltage() == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( pantographUnit->pantographCircuit.supplyVoltage == 0.0 + && ( pantographUnit->pantographCircuit.SupplyVoltage() == 0.0 || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::rearpantographvalveon ); } } else { // jak jedzie w kierunku sprzęgu 0 - if( pantographUnit->pantographCircuit.frontVoltage == 0.0 + if( pantographUnit->pantographCircuit.FrontVoltage() == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( pantographUnit->pantographCircuit.supplyVoltage == 0.0 + && ( pantographUnit->pantographCircuit.SupplyVoltage() == 0.0 || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::frontpantographvalveon ); } @@ -218,14 +218,14 @@ TController::control_pantographs() { // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden if (iDirection >= 0 && useregularpantographlayout) // jak jedzie w kierunku sprzęgu 0 { // poczekać na podniesienie tylnego - if (pantographUnit->pantographCircuit.frontVoltage != 0.0 && pantographUnit->pantographCircuit.rearVoltage != 0.0) + if (pantographUnit->pantographCircuit.FrontVoltage() != 0.0 && pantographUnit->pantographCircuit.RearVoltage() != 0.0) { // czy jest napięcie zasilające na tylnym? cue_action(driver_hint::frontpantographvalveoff); // opuszcza od sprzęgu 0 } } else { // poczekać na podniesienie przedniego - if (pantographUnit->pantographCircuit.rearVoltage != 0.0 && pantographUnit->pantographCircuit.frontVoltage != 0.0) + if (pantographUnit->pantographCircuit.RearVoltage() != 0.0 && pantographUnit->pantographCircuit.FrontVoltage() != 0.0) { // czy jest napięcie zasilające na przednim? cue_action(driver_hint::rearpantographvalveoff); // opuszcza od sprzęgu 1 } @@ -262,14 +262,14 @@ TController::control_pantographs() { if (iDirection >= 0 && useregularpantographlayout) { // jak jedzie w kierunku sprzęgu 0 - if (pantographUnit->pantographCircuit.frontVoltage == 0.0) + if (pantographUnit->pantographCircuit.FrontVoltage() == 0.0) { cue_action(driver_hint::frontpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } } else { - if (pantographUnit->pantographCircuit.rearVoltage == 0.0) + if (pantographUnit->pantographCircuit.RearVoltage() == 0.0) { cue_action(driver_hint::rearpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } @@ -291,7 +291,7 @@ TController::control_pantographs_setup( int const Setup ) { if( rear ) { cue_action( driver_hint::rearpantographvalveon ); } - if( auto const setuplive { ( front && pantographUnit->pantographCircuit.frontVoltage != 0.0 ) || ( rear && pantographUnit->pantographCircuit.rearVoltage != 0.0 ) }; + if( auto const setuplive { ( front && pantographUnit->pantographCircuit.FrontVoltage() != 0.0 ) || ( rear && pantographUnit->pantographCircuit.RearVoltage() != 0.0 ) }; false == setuplive ) { return; } diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index b2c8b50d3..268e974b2 100644 --- a/vehicle/cab/auxiliarycommands.cpp +++ b/vehicle/cab/auxiliarycommands.cpp @@ -684,7 +684,7 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman // only reacting to press, so the switch doesn't flip back and forth if key is held down auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->converter.IsOverloaded())}; - if (Train->occupied->converter.config.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->lowVoltage.power110vAvailable && false == overloadrelayisopen) + if (Train->occupied->converter.config.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->lowVoltage.Is110vAvailable() && false == overloadrelayisopen) { // turn on OnCommand_converterenable(Train, Command); diff --git a/vehicle/cab/cabcommands.cpp b/vehicle/cab/cabcommands.cpp index 30f020482..8db842f8c 100644 --- a/vehicle/cab/cabcommands.cpp +++ b/vehicle/cab/cabcommands.cpp @@ -300,7 +300,7 @@ void TTrain::OnCommand_batterytoggle(TTrain *Train, command_data const &Command) if (Train->allowBatteryToggle || Command.action != GLFW_REPEAT) { // keep the switch from flipping back and forth if key is held down - if (false == Train->occupied->lowVoltage.power24vAvailable) + if (false == Train->occupied->lowVoltage.Is24vAvailable()) { // turn on OnCommand_batteryenable(Train, Command); @@ -315,7 +315,7 @@ void TTrain::OnCommand_batterytoggle(TTrain *Train, command_data const &Command) void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) { - if (!Train->occupied->lowVoltage.batteryButtonImpulse) + if (!Train->occupied->lowVoltage.config.batteryButtonImpulse) { // regular button behavior if (Command.action == GLFW_PRESS) { @@ -346,12 +346,12 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) { if (Command.action == GLFW_PRESS) { - if (Train->occupied->lowVoltage.batteryButtonHeld) + if (Train->occupied->lowVoltage.config.batteryButtonHeld) { // jesli przycisk trzeba przytrzymac Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch); Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->fBatteryTimer = Train->occupied->lowVoltage.batteryButtonHoldTime; // start timer + Train->fBatteryTimer = Train->occupied->lowVoltage.config.batteryButtonHoldTime; // start timer } else { @@ -376,15 +376,15 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) Train->ggBatteryOnButton.UpdateValue(0.0f, Train->dsbSwitch); Train->fBatteryTimer = -1.f; // Train->allowBatteryToggle = true; - Train->occupied->lowVoltage.batteryButtonFired = false; + Train->batteryButtonFired = false; } - else if (Command.action == GLFW_REPEAT && Train->occupied->lowVoltage.batteryButtonHeld) + else if (Command.action == GLFW_REPEAT && Train->occupied->lowVoltage.config.batteryButtonHeld) { // trzymamy przycisk - if (Train->fBatteryTimer <= 0.0 && Train->occupied->lowVoltage.batteryOn == false && !Train->occupied->lowVoltage.batteryButtonFired) + if (Train->fBatteryTimer <= 0.0 && Train->occupied->lowVoltage.IsBatteryOn() == false && !Train->batteryButtonFired) { Train->occupied->BatterySwitch(true); - Train->occupied->lowVoltage.batteryButtonFired = true; + Train->batteryButtonFired = true; // side-effects if (Train->occupied->LightsPosNo > 0) @@ -399,7 +399,7 @@ void TTrain::OnCommand_batteryenable(TTrain *Train, command_data const &Command) void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command) { - if (!Train->occupied->lowVoltage.batteryButtonImpulse) + if (!Train->occupied->lowVoltage.config.batteryButtonImpulse) { // regular button behavior if (Command.action == GLFW_PRESS) { @@ -429,12 +429,12 @@ void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command { if (Command.action == GLFW_PRESS) { - if (Train->occupied->lowVoltage.batteryButtonHeld) + if (Train->occupied->lowVoltage.config.batteryButtonHeld) { // jesli przycisk trzeba przytrzymac Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch); Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch); - Train->fBatteryTimer = Train->occupied->lowVoltage.batteryButtonHoldTime; // start timer + Train->fBatteryTimer = Train->occupied->lowVoltage.config.batteryButtonHoldTime; // start timer } else { @@ -458,15 +458,15 @@ void TTrain::OnCommand_batterydisable(TTrain *Train, command_data const &Command Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch); Train->ggBatteryOffButton.UpdateValue(0.0f, Train->dsbSwitch); Train->allowBatteryToggle = true; - Train->occupied->lowVoltage.batteryButtonFired = false; + Train->batteryButtonFired = false; } - else if (Command.action == GLFW_REPEAT && Train->occupied->lowVoltage.batteryButtonHeld) + else if (Command.action == GLFW_REPEAT && Train->occupied->lowVoltage.config.batteryButtonHeld) { // trzymamy przycisk - if (Train->fBatteryTimer <= 0.0 && Train->occupied->lowVoltage.batteryOn == true && !Train->occupied->lowVoltage.batteryButtonFired) + if (Train->fBatteryTimer <= 0.0 && Train->occupied->lowVoltage.IsBatteryOn() == true && !Train->batteryButtonFired) { Train->occupied->BatterySwitch(false); - Train->occupied->lowVoltage.batteryButtonFired = true; + Train->batteryButtonFired = true; // side-effects if (Train->occupied->LightsPosNo > 0) diff --git a/vehicle/cab/equipmentcommands.cpp b/vehicle/cab/equipmentcommands.cpp index 398836221..c1d974872 100644 --- a/vehicle/cab/equipmentcommands.cpp +++ b/vehicle/cab/equipmentcommands.cpp @@ -62,7 +62,7 @@ void TTrain::OnCommand_heatingtoggle(TTrain *Train, command_data const &Command) if (Command.action == GLFW_PRESS) { // ignore repeats so the switch doesn't flip back and forth if key is held down - if (false == Train->controlled->trainHeating.allow) + if (false == Train->controlled->trainHeating.IsAllowed()) { // turn on OnCommand_heatingenable(Train, Command); @@ -73,7 +73,7 @@ void TTrain::OnCommand_heatingtoggle(TTrain *Train, command_data const &Command) OnCommand_heatingdisable(Train, Command); } } - else if (Command.action == GLFW_RELEASE && (Train->ggTrainHeatingButton.type() == TGaugeType::push || Train->occupied->trainHeating.switchImpulse)) + else if (Command.action == GLFW_RELEASE && (Train->ggTrainHeatingButton.type() == TGaugeType::push || Train->occupied->trainHeating.config.switchImpulse)) { // impulse switch // visual feedback @@ -91,7 +91,7 @@ void TTrain::OnCommand_heatingenable(TTrain *Train, command_data const &Command) // visual feedback Train->ggTrainHeatingButton.UpdateValue(1.0, Train->dsbSwitch); } - else if (Command.action == GLFW_RELEASE && Train->occupied->trainHeating.switchImpulse) + else if (Command.action == GLFW_RELEASE && Train->occupied->trainHeating.config.switchImpulse) { // the switch springs back to the middle Train->ggTrainHeatingButton.UpdateValue(0.0, Train->dsbSwitch); @@ -107,7 +107,7 @@ void TTrain::OnCommand_heatingdisable(TTrain *Train, command_data const &Command Train->occupied->HeatingSwitch(false); // visual feedback: an impulse switch is pushed the other way, down auto position{0.0}; - if (Train->occupied->trainHeating.switchImpulse) + if (Train->occupied->trainHeating.config.switchImpulse) { position = -1.0; } @@ -117,7 +117,7 @@ void TTrain::OnCommand_heatingdisable(TTrain *Train, command_data const &Command } Train->ggTrainHeatingButton.UpdateValue(position, Train->dsbSwitch); } - else if (Command.action == GLFW_RELEASE && Train->occupied->trainHeating.switchImpulse) + else if (Command.action == GLFW_RELEASE && Train->occupied->trainHeating.config.switchImpulse) { Train->ggTrainHeatingButton.UpdateValue(0.0, Train->dsbSwitch); } diff --git a/vehicle/cab/pantographcommands.cpp b/vehicle/cab/pantographcommands.cpp index a1806c9d6..f41689591 100644 --- a/vehicle/cab/pantographcommands.cpp +++ b/vehicle/cab/pantographcommands.cpp @@ -73,7 +73,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->occupied->pantographCircuit.switchType == "impulse") + if (Train->occupied->pantographCircuit.config.switchType == "impulse") { auto const ismanual{Train->iCabn == 0}; Train->occupied->OperatePantographValve(VehicleEnd::front, operation_t::none, ismanual ? range_t::local : range_t::consist); @@ -107,7 +107,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->occupied->pantographCircuit.switchType == "impulse") + if (Train->occupied->pantographCircuit.config.switchType == "impulse") { auto const ismanual{Train->iCabn == 0}; Train->occupied->OperatePantographValve(VehicleEnd::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); @@ -134,7 +134,7 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.config.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -163,7 +163,7 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.config.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -182,7 +182,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C return; } // prevent operation without submodel outside of engine compartment - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.switchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.config.switchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) { return; } @@ -192,7 +192,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.config.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -211,7 +211,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co return; } - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.switchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.config.switchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) { return; } @@ -221,7 +221,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.config.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -254,9 +254,9 @@ void TTrain::OnCommand_pantographlowerall(TTrain *Train, command_data const &Com // two-state switch, only cares about press events if (Command.action == GLFW_PRESS) { - Train->pantographUnit->DropAllPantographs(false == Train->pantographUnit->pantographCircuit.allDown); + Train->pantographUnit->DropAllPantographs(false == Train->pantographUnit->pantographCircuit.AllDown()); // visual feedback - Train->ggPantAllDownButton.UpdateValue(Train->pantographUnit->pantographCircuit.allDown ? 1.0 : 0.0, Train->dsbSwitch); + Train->ggPantAllDownButton.UpdateValue(Train->pantographUnit->pantographCircuit.AllDown() ? 1.0 : 0.0, Train->dsbSwitch); } } else @@ -525,7 +525,7 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle(TTrain *Train, command_da if (Command.action == GLFW_PRESS) { // only react to press - if (Train->controlled->pantographAir.connectedToMainReservoir == false) + if (Train->controlled->pantographAir.IsConnectedToMainReservoir() == false) { // connect pantographs with primary tank OnCommand_pantographcompressorvalveenable(Train, Command); @@ -552,7 +552,7 @@ void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_da { // only react to press // connect pantographs with primary tank - Train->controlled->pantographAir.connectedToMainReservoir = true; + Train->controlled->pantographAir.ConnectToMainReservoir(true); // visual feedback: Train->ggPantCompressorValve.UpdateValue(0.0); } @@ -572,7 +572,7 @@ void TTrain::OnCommand_pantographcompressorvalvedisable(TTrain *Train, command_d { // only react to press // connect pantograps with pantograph compressor - Train->controlled->pantographAir.connectedToMainReservoir = false; + Train->controlled->pantographAir.ConnectToMainReservoir(false); // visual feedback: Train->ggPantCompressorValve.UpdateValue(1.0); } @@ -590,10 +590,10 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // press or hold to activate - if (Train->pantographUnit->pantographAir.pressure < 4.8 && true == Train->pantographUnit->lowVoltage.power24vAvailable) + if (Train->pantographUnit->pantographAir.Pressure() < 4.8 && true == Train->pantographUnit->lowVoltage.Is24vAvailable()) { // needs live power source and low enough pressure to work - Train->pantographUnit->pantographAir.compressorRunning = true; + Train->pantographUnit->pantographAir.SwitchCompressor(true); } // visual feedback Train->ggPantCompressorButton.UpdateValue(1.0); @@ -601,7 +601,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data else { // release to disable - Train->pantographUnit->pantographAir.compressorRunning = false; + Train->pantographUnit->pantographAir.SwitchCompressor(false); // visual feedback Train->ggPantCompressorButton.UpdateValue(0.0); } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index 47cc28267..c1cef46ad 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -888,7 +888,7 @@ void TTrain::set_cab_controls(int const Cab) { // switches // battery - ggBatteryButton.PutValue(ggBatteryButton.type() == TGaugeType::push ? 0.5f : occupied->lowVoltage.power24vAvailable ? 1.f : 0.f); + ggBatteryButton.PutValue(ggBatteryButton.type() == TGaugeType::push ? 0.5f : occupied->lowVoltage.Is24vAvailable() ? 1.f : 0.f); // activation ggCabActivationButton.PutValue(ggCabActivationButton.type() == TGaugeType::push ? 0.5f : occupied->IsCabMaster() ? 1.f : 0.f); // line breaker @@ -985,9 +985,9 @@ void TTrain::set_cab_controls(int const Cab) ggPantValvesButton.PutValue(0.5f); // auxiliary compressor - ggPantCompressorValve.PutValue(controlled->pantographAir.connectedToMainReservoir ? 0.f : // default setting is pantographs connected with primary tank + ggPantCompressorValve.PutValue(controlled->pantographAir.IsConnectedToMainReservoir() ? 0.f : // default setting is pantographs connected with primary tank 1.f); - ggPantCompressorButton.PutValue(pantographUnit->pantographAir.compressorRunning ? 1.f : 0.f); + ggPantCompressorButton.PutValue(pantographUnit->pantographAir.IsCompressorRunning() ? 1.f : 0.f); // converter if (occupied->converter.config.switchType != "impulse") { @@ -1077,9 +1077,9 @@ void TTrain::set_cab_controls(int const Cab) ggDoorStepButton.PutValue(occupied->Doors.step_enabled ? 1.f : 0.f); } // heating - if (false == ggTrainHeatingButton.is_push() && false == occupied->trainHeating.switchImpulse) + if (false == ggTrainHeatingButton.is_push() && false == occupied->trainHeating.config.switchImpulse) { - ggTrainHeatingButton.PutValue(controlled->trainHeating.on ? 1.f : 0.f); + ggTrainHeatingButton.PutValue(controlled->trainHeating.IsOn() ? 1.f : 0.f); } // brake acting time if (ggBrakeProfileCtrl.SubModel != nullptr) @@ -1340,7 +1340,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co {"i-doorpermit_any:", &m_doorpermits}, {"i-doorstep:", &occupied->Doors.step_enabled}, {"i-mainpipelock:", &occupied->brakes.pipeLock.locked}, - {"i-battery:", &occupied->lowVoltage.power24vAvailable}, + {"i-battery:", &occupied->lowVoltage.Is24vAvailable()}, {"i-cablight:", &Cabine[iCabn].bLight}, {"i-compartmentlights:", &occupied->CompartmentLights.is_active}, }; @@ -1845,7 +1845,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // manometr zbiornika kontrolnego/rorzďż˝du auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&pantographUnit->pantographAir.pressure); + gauge.AssignDouble(&pantographUnit->pantographAir.Pressure()); } else if (Label == "springbrakepress:") { @@ -1901,7 +1901,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // pantograph tank pressure auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&pantographUnit->pantographAir.pressure); + gauge.AssignDouble(&pantographUnit->pantographAir.Pressure()); } // yB - dla drugiej sekcji else if (Label == "hvbcurrent1:") diff --git a/vehicle/cab/sounds.cpp b/vehicle/cab/sounds.cpp index ebf928565..d893fd457 100644 --- a/vehicle/cab/sounds.cpp +++ b/vehicle/cab/sounds.cpp @@ -340,7 +340,7 @@ void TTrain::update_sounds(double const Deltatime) } // power-reliant sounds - if (occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable) + if (occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable()) { // buzzer shp diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index c9581e0d2..2ea772fb8 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -173,14 +173,14 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("cabactive", occupied->CabActive); dict->insert("master", occupied->CabMaster); // basic systems state data - dict->insert("battery", occupied->lowVoltage.power24vAvailable); + dict->insert("battery", occupied->lowVoltage.Is24vAvailable()); dict->insert("linebreaker", controlled->lineBreaker.IsClosed()); dict->insert("main_init", controlled->lineBreaker.RemainingInitTime() < controlled->lineBreaker.config.initTime && controlled->lineBreaker.RemainingInitTime() > 0.0); dict->insert("main_ready", false == controlled->lineBreaker.IsClosed() && fHVoltage > 0.0 && controlled->lineBreaker.IsInitialised()); - dict->insert("converter", occupied->lowVoltage.power110vAvailable); + dict->insert("converter", occupied->lowVoltage.Is110vAvailable()); dict->insert("converter_overload", controlled->converter.IsOverloaded()); dict->insert("compress", controlled->air.compressor.running); - dict->insert("pant_compressor", pantographUnit->pantographAir.compressorRunning); + dict->insert("pant_compressor", pantographUnit->pantographAir.IsCompressorRunning()); dict->insert("lights_front", occupied->iLights[VehicleEnd::front]); dict->insert("lights_rear", occupied->iLights[VehicleEnd::rear]); dict->insert("off_from_dimmer", occupied->currentDimPosition().isOff); @@ -242,7 +242,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("ca", occupied->SecuritySystem.is_vigilance_blinking()); dict->insert("shp", occupied->SecuritySystem.is_cabsignal_blinking()); dict->insert("distance_counter", m_distancecounter); - dict->insert("pantpress", std::abs(pantographUnit->pantographAir.pressure)); + dict->insert("pantpress", std::abs(pantographUnit->pantographAir.Pressure())); dict->insert("universal3", InstrumentLightActive); for (auto idx = 0; idx < ggUniversals.size(); idx++) { @@ -267,7 +267,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("odometer", occupied->DistCounter); // distance run in the session, km dict->insert("odometer_total", occupied->Odometer.km); // the vehicle's odometer, kept between the sessions // electric current data - dict->insert("traction_voltage", std::abs(pantographUnit->pantographCircuit.supplyVoltage)); + dict->insert("traction_voltage", std::abs(pantographUnit->pantographCircuit.SupplyVoltage())); dict->insert("voltage", std::abs(controlled->EngineVoltage)); dict->insert("im", std::abs(controlled->Im)); dict->insert("fuse", controlled->FuseFlag); @@ -414,7 +414,7 @@ TTrain::state_t TTrain::get_state() const static_cast(occupied->air.mainReservoirPressure), static_cast(occupied->brakePipe.pressure), static_cast(occupied->brakes.cylinderPressure), - static_cast(pantographUnit->pantographAir.pressure), + static_cast(pantographUnit->pantographAir.Pressure()), fHVoltage, {fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, ggLVoltage.GetValue(), @@ -429,7 +429,7 @@ TTrain::state_t TTrain::get_state() const occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].open_permit, occupied->Doors.instances[occupied->CabOccupied < 0 ? VehicleSide::left : VehicleSide::right].is_open, occupied->Doors.step_enabled, - occupied->lowVoltage.power24vAvailable, + occupied->lowVoltage.Is24vAvailable(), 0, occupied->brakes.pipeLock.locked, btLampkaRadioMessage.GetValue(), @@ -439,7 +439,7 @@ TTrain::state_t TTrain::get_state() const bool TTrain::is_eztoer() const { - return controlled->TrainType == train_type::emu && occupied->brakes.subsystem == TBrakeSubSystem::ss_ESt && controlled->lowVoltage.power24vAvailable == true && controlled->EpFuse == true && + return controlled->TrainType == train_type::emu && occupied->brakes.subsystem == TBrakeSubSystem::ss_ESt && controlled->lowVoltage.Is24vAvailable() == true && controlled->EpFuse == true && controlled->DirActive != 0; // od yB } @@ -562,7 +562,7 @@ void TTrain::UpdateCab() void TTrain::add_distance(double const Distance) { - auto const meterenabled{m_distancecounter >= 0 && (occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable)}; + auto const meterenabled{m_distancecounter >= 0 && (occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable())}; if (true == meterenabled) { diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 86e2281ee..34bb1a9df 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -65,7 +65,7 @@ bool TTrain::Update(double const Deltatime) updateUnitStates(); updateFeedbackGauges(); updateConverterOverload(Deltatime); - auto const lowvoltagepower{occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable}; + auto const lowvoltagepower{occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable()}; updateSecondUnitGauges(); updateClock(); @@ -122,12 +122,12 @@ bool TTrain::Update(double const Deltatime) } // update direction relay - if (prevBatState != occupied->lowVoltage.power24vAvailable) + if (prevBatState != occupied->lowVoltage.Is24vAvailable()) SetupDirectionRelays(); if (prevDirection != occupied->DirActive) UpdateDirectionRelays(); - prevBatState = occupied->lowVoltage.power24vAvailable; + prevBatState = occupied->lowVoltage.Is24vAvailable(); prevDirection = occupied->DirActive; // sounds @@ -361,7 +361,7 @@ void TTrain::updateVoltagesAndCurrents() // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys if (controlled->EngineType != TEngineType::DieselElectric && controlled->EngineType != TEngineType::ElectricInductionMotor) { // Ra 2014-09: czy taki rozdzia? ma sens? - fHVoltage = static_cast(std::max(controlled->pantographCircuit.supplyVoltage, + fHVoltage = static_cast(std::max(controlled->pantographCircuit.SupplyVoltage(), controlled->GetTrainsetHighVoltage())); // Winger czy to nie jest zle? } // *controlled->Mains); @@ -483,11 +483,11 @@ void TTrain::updateUnitStates() fEIMParams[1 + in][9] = static_cast(p->physics->EngineVoltage); fEIMParams[0][6] += fEIMParams[1 + in][8]; bMains[in] = p->physics->lineBreaker.IsClosed(); - fCntVol[in] = static_cast(p->physics->lowVoltage.batteryVoltage); + fCntVol[in] = static_cast(p->physics->lowVoltage.BatteryVoltage()); bFuse[in] = p->physics->FuseFlag; - bBatt[in] = p->physics->lowVoltage.batteryOn; + bBatt[in] = p->physics->lowVoltage.IsBatteryOn(); bConv[in] = p->physics->converter.IsRunning(); - bHeat[in] = p->physics->trainHeating.on; + bHeat[in] = p->physics->trainHeating.IsOn(); // bComp[in][2] = (p->physics->CompressorAllow || (p->physics->CompressorStart == start_t::automatic)); // bComp[in][3] = (p->physics->CompressorFlag); in++; @@ -506,11 +506,11 @@ void TTrain::updateUnitStates() fDieselParams[1 + in][8] = p->physics->diesel.heat.Ts; fDieselParams[1 + in][9] = static_cast(p->physics->retarder.fill); bMains[in] = p->physics->lineBreaker.IsClosed(); - fCntVol[in] = static_cast(p->physics->lowVoltage.batteryVoltage); + fCntVol[in] = static_cast(p->physics->lowVoltage.BatteryVoltage()); bFuse[in] = p->physics->FuseFlag; - bBatt[in] = p->physics->lowVoltage.batteryOn; + bBatt[in] = p->physics->lowVoltage.IsBatteryOn(); bConv[in] = p->physics->converter.IsRunning(); - bHeat[in] = p->physics->trainHeating.on; + bHeat[in] = p->physics->trainHeating.IsOn(); in++; iPowerNo = in; } @@ -725,7 +725,7 @@ void TTrain::updateEngineGauges() { // NOTE: since we don't have functional converter object, we're faking it here by simple check whether converter is on // TODO: implement object-based circuits and power systems model so we can have this working more properly - ggLVoltage.UpdateValue(static_cast(std::max(occupied->lowVoltage.power110vAvailable ? occupied->lowVoltage.nominalBatteryVoltage : 0.0, occupied->lowVoltage.power24vAvailable ? occupied->lowVoltage.batteryVoltage : 0.0))); + ggLVoltage.UpdateValue(static_cast(std::max(occupied->lowVoltage.Is110vAvailable() ? occupied->lowVoltage.config.nominalBatteryVoltage : 0.0, occupied->lowVoltage.Is24vAvailable() ? occupied->lowVoltage.BatteryVoltage() : 0.0))); ggLVoltage.Update(); } @@ -798,7 +798,7 @@ void TTrain::updateBasicLamps() btCabActived.Turn(false); } - if (controlled->lowVoltage.batteryOn && controlled->CabActive != 0) + if (controlled->lowVoltage.IsBatteryOn() && controlled->CabActive != 0) btAKLVents.Turn(true); else btAKLVents.Turn(false); @@ -831,8 +831,8 @@ void TTrain::updateCircuitLamps(double const Deltatime) btLampkaMainBreakerReady.Turn(controlled->lineBreaker.IsInitialised() && m_linebreakerstate != linebreaker::state::closing && !controlled->lineBreaker.IsClosed()); btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->lineBreaker.IsClosed() || controlled->lineBreaker.RemainingInitTime() < 0.0 && simulation::Time.data().wMilliseconds > 500); - btLampkaPrzetw.Turn(occupied->lowVoltage.power110vAvailable); - btLampkaPrzetwOff.Turn(!occupied->lowVoltage.power110vAvailable); + btLampkaPrzetw.Turn(occupied->lowVoltage.Is110vAvailable()); + btLampkaPrzetwOff.Turn(!occupied->lowVoltage.Is110vAvailable()); btLampkaPrzetwAOff.Turn(!controlled->converter.IsRunning()); btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->converter.IsOverloaded()); @@ -1374,7 +1374,7 @@ void TTrain::updateHeatingAndInstrumentLights() { //--------- // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy - if (controlled->trainHeating.on == true && controlled->converter.IsOverloaded() == false) + if (controlled->trainHeating.IsOn() == true && controlled->converter.IsOverloaded() == false) btLampkaOgrzewanieSkladu.Turn(true); else btLampkaOgrzewanieSkladu.Turn(false); @@ -1382,11 +1382,11 @@ void TTrain::updateHeatingAndInstrumentLights() //---------- // lights - auto const lightpower{(InstrumentLightType == 0 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : + auto const lightpower{(InstrumentLightType == 0 ? occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable() : InstrumentLightType == 1 ? controlled->lineBreaker.IsClosed() : - InstrumentLightType == 2 ? occupied->lowVoltage.power110vAvailable : - InstrumentLightType == 3 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : - InstrumentLightType == 4 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : + InstrumentLightType == 2 ? occupied->lowVoltage.Is110vAvailable() : + InstrumentLightType == 3 ? occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable() : + InstrumentLightType == 4 ? occupied->lowVoltage.Is24vAvailable() || occupied->lowVoltage.Is110vAvailable() : false)}; InstrumentLightActive = InstrumentLightType == 3 ? true : // TODO: link the light state with the state of the master key InstrumentLightType == 4 ? occupied->iLights[VehicleEnd::front] != 0 || occupied->iLights[VehicleEnd::rear] != 0 : @@ -1574,7 +1574,7 @@ void TTrain::updateCabLightLevels() for (auto &cab : Cabine) { - auto const cablightlevel = (cab.bLight == false ? 0.f : cab.bLightDim == true ? 0.4f : 1.f) * (occupied->lowVoltage.power110vAvailable ? 1.f : 0.5f); + auto const cablightlevel = (cab.bLight == false ? 0.f : cab.bLightDim == true ? 0.4f : 1.f) * (occupied->lowVoltage.Is110vAvailable() ? 1.f : 0.5f); if (cab.LightLevel != cablightlevel) { @@ -1593,21 +1593,21 @@ void TTrain::updateCabLightLevels() void TTrain::UpdateDirectionRelays() { - if (occupied->DirActive < 0 && occupied->lowVoltage.power24vAvailable) // wstecz + if (occupied->DirActive < 0 && occupied->lowVoltage.Is24vAvailable()) // wstecz Dynamic()->sDirectionRelayR.play(); - if (occupied->DirActive == 0 && occupied->lowVoltage.power24vAvailable) // neutral + if (occupied->DirActive == 0 && occupied->lowVoltage.Is24vAvailable()) // neutral Dynamic()->sDirectionRelayN.play(); - if (occupied->DirActive > 0 && occupied->lowVoltage.power24vAvailable) // przod + if (occupied->DirActive > 0 && occupied->lowVoltage.Is24vAvailable()) // przod Dynamic()->sDirectionRelayD.play(); } void TTrain::SetupDirectionRelays() { - if (occupied->lowVoltage.power24vAvailable) + if (occupied->lowVoltage.Is24vAvailable()) { - if (occupied->DirActive < 0 && occupied->lowVoltage.power24vAvailable) // wstecz + if (occupied->DirActive < 0 && occupied->lowVoltage.Is24vAvailable()) // wstecz Dynamic()->sDirectionRelayR.play(); - if (occupied->DirActive > 0 && occupied->lowVoltage.power24vAvailable) // przod + if (occupied->DirActive > 0 && occupied->lowVoltage.Is24vAvailable()) // przod Dynamic()->sDirectionRelayD.play(); } else if (occupied->DirActive != 0) // neutral diff --git a/vehicle/dynamic/destinations.cpp b/vehicle/dynamic/destinations.cpp index 6311c8799..556629ed2 100644 --- a/vehicle/dynamic/destinations.cpp +++ b/vehicle/dynamic/destinations.cpp @@ -106,7 +106,7 @@ void TDynamicObject::update_destinations() { if( DestinationSign.sign == nullptr ) { return; } - auto const lowvoltagepower { ( physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable ) }; + auto const lowvoltagepower { ( physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() ) }; DestinationSign.sign->fLight = DestinationSign.has_light && lowvoltagepower ? 2.0 : -1.0; diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index ddd6816e5..b3c7ed654 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -354,8 +354,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" physics->brakePipe.pressure = 0.0; physics->mainPipe.reservoir->CreatePress(0.0); physics->mainPipe.pressure = 0.0; - physics->pantographAir.volume = 0.1; - physics->pantographAir.pressure = 0.0; + physics->pantographAir.Empty(); physics->air.compressedVolume = 0.0; } diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index ca0f4b863..31ea07e97 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -117,7 +117,7 @@ void TDynamicObject::renderAuxiliarySounds() { // NBMX dzwiek przetwornicy if( physics->converter.IsRunning() ) { if( physics->EngineType == TEngineType::ElectricSeriesMotor ) { - auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->pantographCircuit.supplyVoltage ) }; + auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->pantographCircuit.SupplyVoltage() ) }; if( voltage > 0.0 ) { // NOTE: we do sound modulation here to avoid sudden jump on voltage loss frequency = voltage / (physics->NominalVoltage * physics->RList[physics->RlistSize].Mn); @@ -187,7 +187,7 @@ void TDynamicObject::renderAuxiliarySounds() { } // Winger 160404 - dzwiek malej sprezarki - if( physics->pantographAir.compressorRunning ) { + if( physics->pantographAir.IsCompressorRunning() ) { sSmallCompressor.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -197,7 +197,7 @@ void TDynamicObject::renderAuxiliarySounds() { // heater sound { auto const isdieselenginepowered { physics->EngineType == TEngineType::DieselElectric || physics->EngineType == TEngineType::DieselEngine }; - if( true == physics->trainHeating.on + if( true == physics->trainHeating.IsOn() && ( false == isdieselenginepowered || std::abs(physics->enrot) > 0.01 ) ) { sHeater @@ -212,7 +212,7 @@ void TDynamicObject::renderAuxiliarySounds() { } // battery sound - if( physics->lowVoltage.batteryOn ) { + if( physics->lowVoltage.IsBatteryOn() ) { m_batterysound.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -487,7 +487,7 @@ void TDynamicObject::renderDepartureSignalSounds() { // NBMX sygnal odjazdu if( physics->Doors.has_warning ) { - auto const lowvoltagepower { physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable }; + auto const lowvoltagepower { physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() }; for( auto &doorspeaker : m_doorspeakers ) { // TBD, TODO: per-location door state triggers? if( physics->DepartureSignal @@ -514,7 +514,7 @@ void TDynamicObject::renderAnnouncementSounds() { // announcements { - auto const lowvoltagepower { physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable }; + auto const lowvoltagepower { physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() }; if( lowvoltagepower ) { // system is powered up, can play queued announcements if( false == m_pasystem.announcement_queue.empty() diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index d859d7674..1b65057ff 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -257,7 +257,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) // napiecie sieci trakcyjnej if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // dla EZT tylko silnikowy - tmpTraction.TractionVoltage = std::max( std::abs( physics->pantographCircuit.rearVoltage ), std::abs( physics->pantographCircuit.frontVoltage ) ); + tmpTraction.TractionVoltage = std::max( std::abs( physics->pantographCircuit.RearVoltage() ), std::abs( physics->pantographCircuit.FrontVoltage() ) ); // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod izolatorem daje 0.15s) // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod izolatorem if( tmpTraction.TractionVoltage > 0.0) { @@ -266,7 +266,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) else { NoVoltTime += dt1; if( NoVoltTime <= 0.2 ) { - tmpTraction.TractionVoltage = physics->pantographCircuit.supplyVoltage; + tmpTraction.TractionVoltage = physics->pantographCircuit.SupplyVoltage(); } else { // jeśli jedzie @@ -295,7 +295,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) tmpTraction.TractionMaxCurrent = 7500; // Ra: chyba za dużo? powinno wywalać przy 1500 tmpTraction.TractionResistivity = 0.3; - physics->pantographCircuit.supplyVoltage = tmpTraction.TractionVoltage; + physics->pantographCircuit.SetSupplyVoltage(tmpTraction.TractionVoltage); } // the driver of the vehicle: the integrated controller, the brakes blended over a consist with induction motors, the AI @@ -735,7 +735,7 @@ void TDynamicObject::switchOffMainsWithoutBattery() { // fragment "z EXE Kursa" if( physics->lineBreaker.IsClosed() ) { // nie wchodzić w funkcję bez potrzeby - if( false == (physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable) + if( false == (physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable()) /* // NOTE: disabled on account of multi-unit setups, where the unmanned unit wouldn't be affected && ( Controller == Humandriver ) @@ -1037,8 +1037,8 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && physics->EnginePowerSource.CollectorParameters.FakePower) { - physics->pantographCircuit.rearVoltage = 0.95 * physics->EnginePowerSource.MaxVoltage; - physics->pantographCircuit.frontVoltage = 0.95 * physics->EnginePowerSource.MaxVoltage; + physics->pantographCircuit.SetRearVoltage(0.95 * physics->EnginePowerSource.MaxVoltage); + physics->pantographCircuit.SetFrontVoltage(0.95 * physics->EnginePowerSource.MaxVoltage); } } @@ -1059,9 +1059,9 @@ void TDynamicObject::updatePantograph( int const i, double const fPantCurrent, d if (p->fAngleU > M_PI) p->fAngleU = M_PI; if (i & 1) // zgłoszono, że po połamaniu potrafi zostać zasilanie - physics->pantographCircuit.rearVoltage = 0.0; + physics->pantographCircuit.SetRearVoltage(0.0); else - physics->pantographCircuit.frontVoltage = 0.0; + physics->pantographCircuit.SetFrontVoltage(0.0); return; // reszta wtedy nie jest wykonywana } PantDiff = p->PantTraction - p->PantWys; // docelowy-aktualny @@ -1078,30 +1078,29 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d if (Global.bLiveTraction == false && p->hvPowerWire == nullptr ) { // jeśli nie ma drutu, może pooszukiwać - physics->pantographCircuit.frontVoltage = - p->PantWys >= 1.2 ? + physics->pantographCircuit.SetFrontVoltage(p->PantWys >= 1.2 ? 0.95 * physics->EnginePowerSource.MaxVoltage : - 0.0; + 0.0); } else if( true == physics->pantographs[VehicleEnd::front].is_active && PantDiff < 0.01 ) // tolerancja niedolegania { if (p->hvPowerWire) { - auto const lastvoltage { physics->pantographCircuit.frontVoltage }; + auto const lastvoltage { physics->pantographCircuit.FrontVoltage() }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - physics->pantographCircuit.frontVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, 0.0 ); + physics->pantographCircuit.SetFrontVoltage(p->hvPowerWire->VoltageGet( physics->pantographCircuit.SupplyVoltage(), 0.0 )); } else { - physics->pantographCircuit.frontVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, fPantCurrent ); - if( physics->pantographCircuit.frontVoltage > 0.0 ) { + physics->pantographCircuit.SetFrontVoltage(p->hvPowerWire->VoltageGet( physics->pantographCircuit.SupplyVoltage(), fPantCurrent )); + if( physics->pantographCircuit.FrontVoltage() > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && physics->pantographCircuit.frontVoltage > 0.0 ) { + && physics->pantographCircuit.FrontVoltage() > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle @@ -1111,40 +1110,39 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - physics->pantographCircuit.frontVoltage = 0.0; + physics->pantographCircuit.SetFrontVoltage(0.0); } else - physics->pantographCircuit.frontVoltage = 0.0; - ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.frontVoltage * fPantCurrent * dt1 / 3600000.0; + physics->pantographCircuit.SetFrontVoltage(0.0); + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.FrontVoltage() * fPantCurrent * dt1 / 3600000.0; break; case 1: if( false == Global.bLiveTraction && nullptr == p->hvPowerWire ) { // jeśli nie ma drutu, może pooszukiwać - physics->pantographCircuit.rearVoltage = - p->PantWys >= 1.2 ? + physics->pantographCircuit.SetRearVoltage(p->PantWys >= 1.2 ? 0.95 * physics->EnginePowerSource.MaxVoltage : - 0.0; + 0.0); } else if ( true == physics->pantographs[VehicleEnd::rear].is_active && PantDiff < 0.01 ) { if (p->hvPowerWire) { - auto const lastvoltage { physics->pantographCircuit.rearVoltage }; + auto const lastvoltage { physics->pantographCircuit.RearVoltage() }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - physics->pantographCircuit.rearVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, 0.0 ); + physics->pantographCircuit.SetRearVoltage(p->hvPowerWire->VoltageGet( physics->pantographCircuit.SupplyVoltage(), 0.0 )); } else { - physics->pantographCircuit.rearVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, fPantCurrent ); - if( physics->pantographCircuit.rearVoltage > 0.0 ) { + physics->pantographCircuit.SetRearVoltage(p->hvPowerWire->VoltageGet( physics->pantographCircuit.SupplyVoltage(), fPantCurrent )); + if( physics->pantographCircuit.RearVoltage() > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && physics->pantographCircuit.rearVoltage > 0.0 ) { + && physics->pantographCircuit.RearVoltage() > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z < 0 ) { // limit to pantographs located in the rear half of the vehicle @@ -1154,13 +1152,13 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - physics->pantographCircuit.rearVoltage = 0.0; + physics->pantographCircuit.SetRearVoltage(0.0); } else { // Global.iPause ^= 2; - physics->pantographCircuit.rearVoltage = 0.0; + physics->pantographCircuit.SetRearVoltage(0.0); } - ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.rearVoltage * fPantCurrent * dt1 / 3600000.0; + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.RearVoltage() * fPantCurrent * dt1 / 3600000.0; break; } // pozostałe na razie nie obsługiwane } @@ -1169,18 +1167,18 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double const PantDiff, double const dt1 ) { double k; // tymczasowy kąt - if( physics->pantographAir.pressure > ( + if( physics->pantographAir.Pressure() > ( physics->TrainType == train_type::emu ? 2.45 : // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 3.45 ) ) { // z EXE Kursa // Ra: wysokość zależy od ciśnienia !!! - pantspeedfactor = 0.015 * physics->pantographAir.pressure * dt1; + pantspeedfactor = 0.015 * physics->pantographAir.Pressure() * dt1; } else { pantspeedfactor = 0.0; } - if( false == ( physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable ) ) { + if( false == ( physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() ) ) { pantspeedfactor = 0.0; } pantspeedfactor = std::max( 0.0, pantspeedfactor ); @@ -1282,12 +1280,12 @@ void TDynamicObject::updateWipers( double const dt1 ) // rozroznienie kabinowe if (physics->CabActive == 1) { - wipersActive = (bytesum & 1 << i) != 0 && physics->lowVoltage.batteryOn; + wipersActive = (bytesum & 1 << i) != 0 && physics->lowVoltage.IsBatteryOn(); } else if (physics->CabActive == -1) { // odwroconie indexow wycieraczek - wipersActive = (bytesum & 1 << dWiperPos.size() - 1 - i) != 0 && physics->lowVoltage.batteryOn; + wipersActive = (bytesum & 1 << dWiperPos.size() - 1 - i) != 0 && physics->lowVoltage.IsBatteryOn(); } else { wipersActive = false; diff --git a/vehicle/dynamic/visual.cpp b/vehicle/dynamic/visual.cpp index 52be7d914..8e322cc02 100644 --- a/vehicle/dynamic/visual.cpp +++ b/vehicle/dynamic/visual.cpp @@ -346,7 +346,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) btnOn = true; } // else btCPass2.TurnOff(); - if (physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable) + if (physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable()) { // sygnaly konca pociagu if (m_endsignals1.Active()) { if (TestFlag(physics->iLights[VehicleEnd::front], light::redmarker_left | light::redmarker_right ) ) { @@ -441,7 +441,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) } // vehicle within 400m - if( physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable ) + if( physics->lowVoltage.Is24vAvailable() || physics->lowVoltage.Is110vAvailable() ) { // sygnały czoła pociagu //Ra: wyświetlamy bez // ograniczeń odległości, by były widoczne z // daleka diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index ecada0130..57c66c7d2 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -68,7 +68,7 @@ void ui::vehicleparams_panel::draw_mini(const physics::Vehicle &physics) if (physics.pantographs[VehicleEnd::front].is_active) draw_infobutton("╨╨╨", ImVec2(290, 10)); - if (physics.lowVoltage.batteryOn) + if (physics.lowVoltage.IsBatteryOn()) draw_infobutton(STR_C("bat."), ImVec2(120, 55)); if (physics.lineBreaker.IsClosed()) draw_infobutton(STR_C("main.")); @@ -148,8 +148,8 @@ void ui::vehicleparams_panel::render_contents() std::snprintf(buffer.data(), buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"), // devices - (physics.lowVoltage.batteryOn ? 'B' : '.'), (physics.lineBreaker.IsClosed() ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.pantographs[VehicleEnd::rear].is_active ? (physics.pantographCircuit.rearVoltage > 0.0 ? 'O' : 'o') : '.'), - (physics.pantographs[VehicleEnd::front].is_active ? (physics.pantographCircuit.frontVoltage > 0.0 ? 'P' : 'p') : '.'), (physics.pantographAir.pressureLockActive ? '!' : (physics.pantographAir.pressureSwitchActive ? '*' : '.')), + (physics.lowVoltage.IsBatteryOn() ? 'B' : '.'), (physics.lineBreaker.IsClosed() ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.pantographs[VehicleEnd::rear].is_active ? (physics.pantographCircuit.RearVoltage() > 0.0 ? 'O' : 'o') : '.'), + (physics.pantographs[VehicleEnd::front].is_active ? (physics.pantographCircuit.FrontVoltage() > 0.0 ? 'P' : 'p') : '.'), (physics.pantographAir.IsPressureLockActive() ? '!' : (physics.pantographAir.IsPressureSwitchPrimed() ? '*' : '.')), (physics.WaterPump.is_active ? 'W' : (false == physics.WaterPump.breaker ? '-' : (physics.WaterPump.is_enabled ? 'w' : '.'))), (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' : '.')), @@ -213,7 +213,7 @@ void ui::vehicleparams_panel::render_contents() if (physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), physics.pantographAir.pressure, (physics.pantographAir.connectedToMainReservoir ? '-' : '|')); + std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), physics.pantographAir.Pressure(), (physics.pantographAir.IsConnectedToMainReservoir() ? '-' : '|')); ImGui::TextUnformatted(buffer.data()); }