mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
d0387753f8
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.
72 lines
3.8 KiB
C++
72 lines
3.8 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
// the drive of a vehicle, by the kind of its engine (EngineType, the Engine section of the .fiz): what each kind of
|
|
// drive does in the step of the vehicle, in place of a switch on the engine type in each of those places. the drives
|
|
// hold no state of their own yet (it is in physics::Vehicle): there is one of each kind, shared by the vehicles
|
|
|
|
#pragma once
|
|
|
|
#include "physics/vehicletypes.h"
|
|
|
|
namespace physics { class Vehicle; }
|
|
|
|
// what the step of the traction gives the drive
|
|
struct DriveStep
|
|
{
|
|
double dt{0.0}; // the length of the step [s]
|
|
double posRatio{0.0}; // the share of the controller positions, of the drive of no engine model (Dumb)
|
|
double revolutions{0.0}; // the revolutions of the engine
|
|
double moment{0.0}; // the moment of the diesel engine
|
|
double transmission{0.0}; // the ratio of the transmission of the diesel engine
|
|
};
|
|
|
|
class TractionDrive
|
|
{
|
|
public:
|
|
virtual ~TractionDrive() = default;
|
|
|
|
// the power of the engine for the controller positions; returns the share of the positions (Dumb), 0 for the others
|
|
virtual double UpdateEnginePower(physics::Vehicle &vehicle) const;
|
|
// before the traction force, whether the reverser is set or not
|
|
virtual void BeforeTractionForce(physics::Vehicle &vehicle, double dt) const;
|
|
// the traction force of the step (Ft), the reverser set
|
|
virtual void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const;
|
|
// after the traction force, whether the reverser is set or not
|
|
virtual void AfterTractionForce(physics::Vehicle &vehicle) const;
|
|
// the blowers of the starting resistors and the fans of the radiators
|
|
virtual void UpdateVentilators(physics::Vehicle &vehicle, double dt) const;
|
|
// the current the given ammeter of the cab shows
|
|
virtual double ShowCurrent(physics::Vehicle const &vehicle, int ammeter) const;
|
|
// the revolutions of the engine against the most it gives at the present controller position, 0..1; 1 with no
|
|
// engine of revolutions
|
|
virtual double EngineRpmRatio(physics::Vehicle const &vehicle) const;
|
|
// the revolutions of the engine idling and at most [rpm]; the largest double with no engine of revolutions
|
|
virtual double EngineIdleRpm(physics::Vehicle const &vehicle) const;
|
|
virtual double EngineMaxRpm(physics::Vehicle const &vehicle) const;
|
|
// the revolutions of the engine in the step (enrot); returns the revolutions a diesel-electric engine aims for, 0 for
|
|
// the others. a diesel engine with a mechanical transmission gives its ratio and its moment through the references
|
|
virtual double UpdateEngineRevolutions(physics::Vehicle &vehicle, double dt, double &transmission, double &moment) const;
|
|
// a notch up and down of the master controller, as the kind of the engine takes it; return whether it moved
|
|
virtual bool IncreaseMainController(physics::Vehicle &vehicle, int speed) const;
|
|
virtual bool DecreaseMainController(physics::Vehicle &vehicle, int speed) const;
|
|
// whether the line breaker has the power it needs to close, before the genset of a dual-mode vehicle has its say
|
|
virtual bool MainsPowerAvailable(physics::Vehicle const &vehicle) const;
|
|
// the relays that open the line breaker at a voltage out of range, or the line contactors
|
|
virtual void CheckVoltageRelays(physics::Vehicle &vehicle) const;
|
|
// the engine in the step of the vehicle: the automatic start of the series motors, the diesel engine; returns
|
|
// whether a relay clicked
|
|
virtual bool UpdateEngine(physics::Vehicle &vehicle, double dt) const;
|
|
// the voltage of the traction motors in the step (EngineVoltage)
|
|
virtual void UpdateEngineVoltage(physics::Vehicle &vehicle, double dt) const;
|
|
};
|
|
|
|
// the drive of the given kind of engine
|
|
TractionDrive const &DriveOf(TEngineType type);
|