18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 22:07:55 +01:00

refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone

The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:

  physics/mover.h                  physics/vehicle.h
  TMoverParameters                 physics::Vehicle (in namespace physics)
  TDynamicObject::MoverParameters  physics
  mvOccupied, mvControlled         occupied, controlled (TTrain, TController)
  mvSecond, mvThird                secondUnit, thirdUnit
  mvPantographUnit                 pantographUnit
  mover, Mover, movers             physics, Physics, vehicles (locals, params)
  m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
                                   m_physics, otherPhysics, currentPhysics,
                                   from_vehicles, renderPhysicsEventSounds

The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.

By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).

For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.

The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
2026-11-28 23:56:46 +01:00
parent 9568dba9e4
commit d0387753f8
207 changed files with 5147 additions and 4950 deletions
+47 -47
View File
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
// the power supply: the batteries, the main switch, the pantographs, the converter, heating, lights, the genset
#include "stdafx.h"
#include "physics/mover.h"
#include "physics/vehicle.h"
#include "vehicle/DynObj.h"
#include "physics/oerlikonest.h"
#include "utilities/Globals.h"
@@ -32,7 +32,7 @@ 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 TMoverParameters::UpdatePantVolume(double dt)
void physics::Vehicle::UpdatePantVolume(double dt)
{
// check the pantograph compressor while at it
// TODO: move the check to a separate method
@@ -82,7 +82,7 @@ void TMoverParameters::UpdatePantVolume(double dt)
// 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 TMoverParameters::PantPressureSwitchCheck()
void physics::Vehicle::PantPressureSwitchCheck()
{
if (PantPress < EnginePowerSource.CollectorParameters.MinPress)
{
@@ -115,7 +115,7 @@ void TMoverParameters::PantPressureSwitchCheck()
// 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
void TMoverParameters::PantPressureSwitchTrip()
void physics::Vehicle::PantPressureSwitchTrip()
{
// opuszczenie pantografów przy niskim ciśnieniu
if (TrainType != train_type::emu)
@@ -140,7 +140,7 @@ void TMoverParameters::PantPressureSwitchTrip()
PantPressSwitchActive = false;
}
void TMoverParameters::UpdateBatteryVoltage(double dt)
void physics::Vehicle::UpdateBatteryVoltage(double dt)
{ // przeliczenie obciążenia baterii
using enum TEngineType;
if (BatteryVoltage > 0 && EngineType != DieselEngine && EngineType != WheelsDriven && NominalBatteryVoltage > 0)
@@ -167,7 +167,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
};
// the drop of the battery's voltage in dt, by what draws from it, or its rise by the converter charging it
double TMoverParameters::BatteryDrain(double dt, bool const converteractive) const
double physics::Vehicle::BatteryDrain(double dt, bool const converteractive) const
{
if (NominalBatteryVoltage / BatteryVoltage < 1.22 && Battery)
{ // 110V
@@ -185,7 +185,7 @@ double TMoverParameters::BatteryDrain(double dt, bool const converteractive) con
}
// the drain of a battery at its voltage, the converter charging it
double TMoverParameters::BatteryDrainCharged(double dt, bool const converteractive) const
double physics::Vehicle::BatteryDrainCharged(double dt, bool const converteractive) const
{
double sn1;
double sn2;
@@ -216,7 +216,7 @@ double TMoverParameters::BatteryDrainCharged(double dt, bool const converteracti
}
// the drain of a battery run down to 90 V, the converter charging it
double TMoverParameters::BatteryDrainLow(double dt, bool const converteractive) const
double physics::Vehicle::BatteryDrainLow(double dt, bool const converteractive) const
{
double sn1;
double sn2;
@@ -247,7 +247,7 @@ double TMoverParameters::BatteryDrainLow(double dt, bool const converteractive)
}
// the drain of a battery switched off, very slow
double TMoverParameters::BatteryDrainSwitchedOff(double dt) const
double physics::Vehicle::BatteryDrainSwitchedOff(double dt) const
{
double sn1;
double sn2;
@@ -265,7 +265,7 @@ double TMoverParameters::BatteryDrainSwitchedOff(double dt) const
return sn1 + sn2 + sn3 + sn4 + sn5;
}
void TMoverParameters::MainsCheck(double const Deltatime)
void physics::Vehicle::MainsCheck(double const Deltatime)
{
// if( MainsInitTime == 0.0 ) { return; }
@@ -328,7 +328,7 @@ void TMoverParameters::MainsCheck(double const Deltatime)
}
}
void TMoverParameters::LowVoltagePowerCheck(double const /*Deltatime*/)
void physics::Vehicle::LowVoltagePowerCheck(double const /*Deltatime*/)
{
auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
@@ -345,7 +345,7 @@ void TMoverParameters::LowVoltagePowerCheck(double const /*Deltatime*/)
}
}
void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, Coupling const kind)
void physics::Vehicle::PowerCouplersCheck(double const /*Deltatime*/, Coupling const kind)
{
if (kind != Coupling::highVoltage && kind != Coupling::power110v && kind != Coupling::power24v)
{
@@ -366,7 +366,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, Coupling c
}
// the current the vehicle draws from the circuit of the power coupling given
double *TMoverParameters::PowerCircuitCurrent(Coupling const kind)
double *physics::Vehicle::PowerCircuitCurrent(Coupling const kind)
{
switch (kind)
{
@@ -382,7 +382,7 @@ double *TMoverParameters::PowerCircuitCurrent(Coupling const kind)
}
// the voltage of the vehicle's own source for the coupling given; notes the low voltage circuits' too
double TMoverParameters::LocalPowerVoltage(Coupling const kind)
double physics::Vehicle::LocalPowerVoltage(Coupling const kind)
{
auto localvoltage{0.0};
@@ -461,7 +461,7 @@ double TMoverParameters::LocalPowerVoltage(Coupling const kind)
}
// the voltage passed through the vehicle to the coupler at its other end, from the coupled vehicle or its own source
void TMoverParameters::PowerCouplersVoltage(Coupling const kind, double const abslocalvoltage, bool const localpowersource)
void physics::Vehicle::PowerCouplersVoltage(Coupling const kind, double const abslocalvoltage, bool const localpowersource)
{
if (Couplers[VehicleEnd::front].power(kind) == nullptr)
{
@@ -537,7 +537,7 @@ void TMoverParameters::PowerCouplersVoltage(Coupling const kind, double const ab
}
// the current drawn through the couplers, shared by their voltages, or added to the vehicle's own
void TMoverParameters::PowerCouplersCurrent(Coupling const kind, bool const localpowersource)
void physics::Vehicle::PowerCouplersCurrent(Coupling const kind, bool const localpowersource)
{
auto const *frontcoupling{Couplers[VehicleEnd::front].power(kind)};
auto const *rearcoupling{Couplers[VehicleEnd::rear].power(kind)};
@@ -588,7 +588,7 @@ void TMoverParameters::PowerCouplersCurrent(Coupling const kind, bool const loca
}
// sprawdzanie przetwornicy
void TMoverParameters::ConverterCheck(double const Timestep)
void physics::Vehicle::ConverterCheck(double const Timestep)
{
// TODO: move other converter checks here, to have it all in one place for potential device object
if (ConverterStart != start_t::disabled && ConverterOverloadRelayOffWhenMainIsOff)
@@ -648,7 +648,7 @@ void TMoverParameters::ConverterCheck(double const Timestep)
};
// heating system status check
void TMoverParameters::HeatingCheck(double const /*Timestep*/)
void physics::Vehicle::HeatingCheck(double const /*Timestep*/)
{
// update heating devices
@@ -725,7 +725,7 @@ void TMoverParameters::HeatingCheck(double const /*Timestep*/)
}
}
void TMoverParameters::PantographsCheck(double const /*Timestep*/)
void physics::Vehicle::PantographsCheck(double const /*Timestep*/)
{
using enum start_t;
@@ -767,7 +767,7 @@ void TMoverParameters::PantographsCheck(double const /*Timestep*/)
// the genset of a dual-mode vehicle: started on request with the battery on, it cranks for start_time, then runs at
// idle and up to full revolutions with the traction demand; stopped, it coasts down. regulated voltage from idle up
void TMoverParameters::GensetCheck(double const Deltatime)
void physics::Vehicle::GensetCheck(double const Deltatime)
{
if (false == Genset.fitted())
{
@@ -822,7 +822,7 @@ void TMoverParameters::GensetCheck(double const Deltatime)
}
}
void TMoverParameters::LightsCheck(double const /*Timestep*/)
void physics::Vehicle::LightsCheck(double const /*Timestep*/)
{
auto &light{CompartmentLights};
@@ -844,7 +844,7 @@ void TMoverParameters::LightsCheck(double const /*Timestep*/)
// Q: 20160710
// włączenie / wyłączenie baterii
// *************************************************************************************************
bool TMoverParameters::BatterySwitch(bool State, range_t const Notify)
bool physics::Vehicle::BatterySwitch(bool State, range_t const Notify)
{
using enum range_t;
if (PulleeMode && State)
@@ -870,7 +870,7 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify)
return Battery != initialstate;
}
bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify)
bool physics::Vehicle::CompartmentLightsSwitch(bool State, range_t const Notify)
{
if (CompartmentLights.start_type == start_t::automatic)
@@ -892,7 +892,7 @@ bool TMoverParameters::CompartmentLightsSwitch(bool State, range_t const Notify)
}
// water pump state toggle
bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Notify)
bool physics::Vehicle::CompartmentLightsSwitchOff(bool State, range_t const Notify)
{
if (CompartmentLights.start_type == start_t::automatic)
@@ -917,7 +917,7 @@ bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Noti
// Q: 20160713
// włączenie / wyłączenie obwodu głownego
// *************************************************************************************************
bool TMoverParameters::MainSwitch(bool const State, range_t const Notify)
bool physics::Vehicle::MainSwitch(bool const State, range_t const Notify)
{
bool const initialstate{Mains || diesel.startupRequested};
@@ -934,7 +934,7 @@ bool TMoverParameters::MainSwitch(bool const State, range_t const Notify)
return (Mains || diesel.startupRequested) != initialstate;
}
void TMoverParameters::MainSwitch_(bool const State)
void physics::Vehicle::MainSwitch_(bool const State)
{
if (Mains == State || MainCtrlPosNo == 0)
@@ -978,7 +978,7 @@ void TMoverParameters::MainSwitch_(bool const State)
}
}
bool TMoverParameters::MainSwitchCheck() const
bool physics::Vehicle::MainSwitchCheck() const
{
using enum TEngineType;
@@ -1004,7 +1004,7 @@ bool TMoverParameters::MainSwitchCheck() const
// Q: 20160713
// włączenie / wyłączenie przetwornicy
// *************************************************************************************************
bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify)
bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify)
{
auto const initialstate{ConverterAllow};
@@ -1022,7 +1022,7 @@ bool TMoverParameters::ConverterSwitch(bool State, range_t const Notify)
return ConverterAllow != initialstate;
}
bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify)
bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify)
{
bool const initialstate{HeatingAllow};
@@ -1039,7 +1039,7 @@ bool TMoverParameters::HeatingSwitch(bool const State, range_t const Notify)
return HeatingAllow != initialstate;
}
void TMoverParameters::HeatingSwitch_(bool const State)
void physics::Vehicle::HeatingSwitch_(bool const State)
{
// TBD, TODO: activation dependencies?
@@ -1048,7 +1048,7 @@ void TMoverParameters::HeatingSwitch_(bool const 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
// the cars behind, which may start theirs on request
bool TMoverParameters::GensetSwitch(bool const State, range_t const Notify)
bool physics::Vehicle::GensetSwitch(bool const State, range_t const Notify)
{
auto const initialstate{Genset.is_enabled};
@@ -1067,26 +1067,26 @@ bool TMoverParameters::GensetSwitch(bool const State, range_t const Notify)
// the voltage of the vehicle's own source the traction selector picks: the catenary through the pantographs, or the
// genset of a dual-mode vehicle
double TMoverParameters::TractionSourceVoltage() const
double physics::Vehicle::TractionSourceVoltage() const
{
return GensetSelected() ? Genset.voltage : PantographVoltage;
}
// the voltage the traction circuit gets: from the vehicle's own source, or through the train's high voltage line
double TMoverParameters::TractionSupplyVoltage() const
double physics::Vehicle::TractionSupplyVoltage() const
{
return std::max(GetTrainsetHighVoltage(), TractionSourceVoltage());
}
// below it the undervoltage trip opens the line breaker
double TMoverParameters::TractionSupplyMinVoltage() const
double physics::Vehicle::TractionSupplyMinVoltage() const
{
return GensetSelected() ? 0.5 * Genset.voltage_nominal : EnginePowerSource.CollectorParameters.MinV;
}
// the power the traction may take [kW, at the wheels]: the genset's share at its present revolutions on the genset,
// no limit otherwise
double TMoverParameters::GensetTractionPowerLimit() const
double physics::Vehicle::GensetTractionPowerLimit() const
{
return GensetSelected() ? Genset.available_power() * Genset.traction_share : std::numeric_limits<double>::max();
}
@@ -1094,7 +1094,7 @@ double TMoverParameters::GensetTractionPowerLimit() const
// the current the vehicle draws through its pantographs [A], if they touch the wire: the traction's (none while
// braking on the resistors) and the heating's. on the genset the genset feeds the traction circuit, so only a heating
// fed straight from the pantographs is left
double TMoverParameters::CatenaryCurrent() const
double physics::Vehicle::CatenaryCurrent() const
{
if (GensetSelected())
{
@@ -1104,7 +1104,7 @@ double TMoverParameters::CatenaryCurrent() const
}
// returns voltage of defined main engine power source
double TMoverParameters::EnginePowerSourceVoltage() const
double physics::Vehicle::EnginePowerSourceVoltage() const
{
return EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? TractionSupplyVoltage() :
@@ -1114,7 +1114,7 @@ double TMoverParameters::EnginePowerSourceVoltage() const
// whether the main circuit feeds what runs on it: the converter, a compressor, the heating, the motor and resistor
// blowers, the traction motors
bool TMoverParameters::MainCircuitPowered() const
bool physics::Vehicle::MainCircuitPowered() const
{
if (false == Mains)
{
@@ -1131,7 +1131,7 @@ bool TMoverParameters::MainCircuitPowered() const
return EnginePowerSourceVoltage() >= TractionSupplyMinVoltage();
}
bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t const Notify)
bool physics::Vehicle::OperatePantographsValve(operation_t const State, range_t const Notify)
{
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0)
@@ -1191,7 +1191,7 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t
return true;
}
bool TMoverParameters::OperatePantographValve(VehicleEnd const End, operation_t const State, range_t const Notify)
bool physics::Vehicle::OperatePantographValve(VehicleEnd const End, operation_t const State, range_t const Notify)
{
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0)
@@ -1255,7 +1255,7 @@ bool TMoverParameters::OperatePantographValve(VehicleEnd const End, operation_t
return true;
}
bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify)
bool physics::Vehicle::DropAllPantographs(bool const State, range_t const Notify)
{
auto const initialstate{PantAllDown};
@@ -1274,7 +1274,7 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify
// Q: 20160709
// Funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT
// *************************************************************************************************
double TMoverParameters::GetTrainsetVoltage(CouplingSet const couplings) const
double physics::Vehicle::GetTrainsetVoltage(CouplingSet const couplings) const
{ // ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT
// TBD, TODO: call once per vehicle update, return cached results?
ByEnd<double> voltages{0.0, 0.0};
@@ -1301,13 +1301,13 @@ double TMoverParameters::GetTrainsetVoltage(CouplingSet const couplings) const
return std::max(voltages[VehicleEnd::front], voltages[VehicleEnd::rear]);
}
double TMoverParameters::GetTrainsetHighVoltage() const
double physics::Vehicle::GetTrainsetHighVoltage() const
{
return std::max(GetTrainsetVoltage(Coupling::highVoltage), HeatingAllow ? GetTrainsetVoltage(Coupling::heating) : 0.0);
}
int TMoverParameters::clampDimmerPosition(int const Position) const
int physics::Vehicle::clampDimmerPosition(int const Position) const
{
if (dimPositions.empty())
{
@@ -1316,7 +1316,7 @@ int TMoverParameters::clampDimmerPosition(int const Position) const
return std::clamp(Position, 0, static_cast<int>(dimPositions.size()) - 1);
}
TMoverParameters::dimPosition TMoverParameters::currentDimPosition() const
physics::Vehicle::dimPosition physics::Vehicle::currentDimPosition() const
{
if (modernDimmerPosition < 0 || modernDimmerPosition >= static_cast<int>(dimPositions.size()))
{
@@ -1325,7 +1325,7 @@ TMoverParameters::dimPosition TMoverParameters::currentDimPosition() const
return dimPositions[modernDimmerPosition];
}
bool TMoverParameters::stepDimmerPosition(int const Step)
bool physics::Vehicle::stepDimmerPosition(int const Step)
{
if (dimPositions.empty())
{
@@ -1353,7 +1353,7 @@ bool TMoverParameters::stepDimmerPosition(int const Step)
return true;
}
std::optional<lights_preset_cablight> TMoverParameters::LightsPresetCabLight(int const Position) const
std::optional<lights_preset_cablight> physics::Vehicle::LightsPresetCabLight(int const Position) const
{
if (Position < 1 || Position > static_cast<int>(LightsCabLight.size()))
{