mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-05 16:55:32 +01:00
798d86cb6c
Removes the commented-out code Sonar reports (cpp:S125) and the block comments holding "//" or "/*" (cpp:S1103) in the AI driver, the brakes, the vehicle setup and controllers, the dynamic object, the renderers and a few world/test files. Prose notes that explained why something was disabled stay as one line; trailing semicolons in prose comments that looked like code are dropped. Comment-only change: the preprocessed token stream of every changed file is the same as before, so the behaviour is unchanged.
268 lines
14 KiB
C++
268 lines
14 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 braking of a vehicle: its brake valves and cylinders, the handles of the driver, the blending of the brakes of a
|
|
// unit, the holding brake, the spring brake. Held by physics::Vehicle as brakes
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "physics/vehicletypes.h"
|
|
|
|
class TReservoir;
|
|
class TBrake;
|
|
class TDriverHandle;
|
|
|
|
namespace physics
|
|
{
|
|
|
|
// the blending of the electro-pneumatic and the electrodynamic brake of a unit (MED, the Blending section of the .fiz)
|
|
struct BrakeBlending
|
|
{
|
|
double maxSpeed = 0; // MED_Vmax: the top speed the momentary force of the EP brake is computed for [km/h]
|
|
double minSpeed = 0; // MED_Vmin: the lowest speed the momentary force of the EP brake is computed for [km/h]
|
|
double referenceSpeed = 0; // MED_Vref: the speed the available force of the EP brake is computed for [km/h]
|
|
double maxDeceleration{9.81}; // MED_amax: the most deceleration of the service braking [m/s2]
|
|
bool epCorrection = false; // MED_EPVC: the force of the EP brake corrected while the ED brake is unavailable
|
|
double epCorrectionTime = 7; // MED_EPVC_Time: how long that correction lasts [s]
|
|
bool loadCorrection = false; // MED_Ncor: the braking force corrected by the load on the axles
|
|
double minEdDemand = 0; // MED_MinBrakeReqED: below this demand only the EP brake brakes, the ED brake stays off
|
|
double edForceFactor = 1; // MED_FrEDFactor: the factor of the force of the ED brake, to correct the blending
|
|
double edFirstDelay = 0; // MED_FirstDelayED: the delay of the ED brake coming in, the first time [s]
|
|
double edNextDelay = 0; // MED_ScndDelayED: the delay of the ED brake growing, the times after [s]
|
|
// the state
|
|
double epCorrectionTimer = 0; // how long the force of the EP brake has been corrected [s]
|
|
double edDelayTimer = 0; // the count of the delay of the ED brake [s]
|
|
};
|
|
|
|
// the electrodynamic brake of a DC unit and the EP brake beside it (the DCEMUED section of the .fiz)
|
|
struct EmuDynamicBrake
|
|
{
|
|
int checkedCoupler{0}; // CouplerCheck: the coupler the ED brake of the unit is checked on
|
|
double epMaxSpeed{0.0}; // EP_max_Vel: the top speed the EP brake works at with the ED brake of the unit on (trailers)
|
|
double epMinCurrent{0.0}; // EP_min_Im: the current the EP brake stops working at with the ED brake of the car on (motor cars)
|
|
double epDelay{0.0}; // EP_delay: the delay of the EP brake coming in while the ED brake brakes
|
|
};
|
|
|
|
// the holding brake of a unit with the MED: it holds the unit standing, and lets go once power is demanded
|
|
struct HoldingBrake
|
|
{
|
|
double deceleration = 0.0; // SBD: the deceleration it holds the unit with [m/s2]
|
|
// SBDReleaseDelay: it lets go only once power has been demanded for this long [s]; 0 lets it go at the first demand
|
|
double releaseDelay = 0.0;
|
|
double releaseTimer = 0.0; // how long power has been demanded without a break [s]
|
|
};
|
|
|
|
// the spring brake: the spring of its cylinder brakes when the air leaves it (the SpringBrake section of the .fiz)
|
|
struct SpringBrake
|
|
{
|
|
std::shared_ptr<TReservoir> cylinder;
|
|
// the inputs
|
|
bool activate{false}; // switched on or off in service: the main valve or switch
|
|
bool shutOff{true}; // shut off for a fault: the valve in the pneumatic container
|
|
bool release{false}; // the emergency release rod
|
|
// the outputs
|
|
bool isReady{false}; // ready to brake: the cylinder armed, the spring tensioned
|
|
bool isActive{false}; // braking
|
|
double pressure{0.0}; // the pressure in the cylinder
|
|
// the configuration
|
|
bool pneumaticConnection{false}; // connected to the cylinders of the air brake
|
|
double maxSetPressure{0.0}; // MaxSP: the most pressure for the brake switched off
|
|
double resetPressure{0.0}; // ResetP: the pressure that arms the cylinder
|
|
double minForcePressure{0.1}; // MinFP: the least pressure of no force
|
|
double maxForce{0.0}; // MBF: the most force of the spring on the brake shoes or pads
|
|
double pressureOn{-2.0}; // PressOn: the pressure the brake turns on at
|
|
double pressureOff{-1.0}; // PressOff: the pressure the brake turns off at
|
|
double valveOffArea{0.0}; // the area of the filling valve (read from the key ValveOnArea)
|
|
double valveOnArea{0.0}; // the area of the dumping valve (read from the key ValveOffArea)
|
|
double valvePneumaticArea{0.0}; // ValvePNBArea: the area of the bypass to the cylinders of the air brake
|
|
int controlCouplings{127}; // MTC: the couplings the command needs to pass on, the number of the couplings of the .fiz
|
|
// of the vehicle with it
|
|
bool releasesParking{false}; // ReleaseParkingBySpringBrake
|
|
bool releasesParkingWithDoorOpen{false}; // ReleaseParkingBySpringBrakeWhenDoorIsOpen
|
|
bool cutsOffDrive{true}; // SpringBrakeCutsOffDrive
|
|
double driveEmergencySpeed{-1}; // SpringBrakeDriveEmergencyVel
|
|
};
|
|
|
|
// the braking of a vehicle beside its air brake valves
|
|
// the electrodynamic brake of the traction motors and its resistors
|
|
struct ElectrodynamicBrake
|
|
{
|
|
int type = 0; // one of the dbrake_ constants
|
|
int ammeters = 2; // the ammeters it shows on
|
|
bool splitFromPneumatic = false; // its controller is apart from the one of the independent air brake
|
|
int controllerPositions = 10; // DBPN: the positions of its controller
|
|
double controllerPosition = 0.0; // the position of its controller, 0..1, with splitFromPneumatic only
|
|
double resistance = 5.8; // of the braking resistors
|
|
double resistance1 = 5.8; // of the first mode
|
|
double resistance2 = 5.8; // of the second mode
|
|
bool on = false; // braking
|
|
bool emuWorking = true; // it works, in a multiple unit
|
|
bool resistorFansRunning = false; // the fans of the braking resistor
|
|
int resistorFansSustain = 0; // how long the fans still cool the resistor after it stops [s]
|
|
double resistorFansTimer = 0; // the timer of that
|
|
int resistorPassiveMaxCurrent = 0; // the most current of the resistor cooled passively
|
|
};
|
|
|
|
// the settings of the driver's brake valve (the Handle_* keys of the .fiz)
|
|
struct DriverValveSettings
|
|
{
|
|
bool automaticOverload = false; // the overcharge is let in automatically at the filling position
|
|
bool manualOverload = false; // the overcharge is let in by a button
|
|
double genericParameter1 = 0.0;
|
|
double genericParameter2 = 0.0;
|
|
double overloadMaxPressure = 1.0; // the most the overcharge raises the pressure
|
|
double overloadPressureDecrease = 0.002; // how fast the pressure of the overcharge falls
|
|
};
|
|
|
|
// the brake cylinders of a vehicle and their rigging
|
|
struct BrakeCylinders
|
|
{
|
|
int count = 0;
|
|
double radius = 0.0;
|
|
double stroke = 0.0;
|
|
std::array<double, 3> leverRatio{}; // the ratio of the brake rigging, by the load setting
|
|
double springForce = 0.0; // the sum of the forces of the return springs [kN]
|
|
double slackAdjusterForce = 0.0; // the resistance of the slack adjuster [kN]
|
|
double riggingEfficiency = 0.0; // the efficiency of the lever rigging
|
|
};
|
|
|
|
// the emergency valve, which lets the air out of the main reservoir above its pressure
|
|
struct EmergencyValve
|
|
{
|
|
double onPressure = 0.0; // MaxEVP: it opens above this pressure of the main reservoir
|
|
double offPressure = 0.0; // MinEVP: it closes again below this one
|
|
bool open = false;
|
|
double area = 0.0; // EVArea
|
|
double flow = 0.0; // the air through it in the last step
|
|
};
|
|
|
|
// the lock of the brake pipe in an emergency application
|
|
struct PipeLock
|
|
{
|
|
double onPressure = -1.0; // LPOn
|
|
double offPressure = -1.0; // LPOff
|
|
double unlockHandlePosition = -3.0; // HandlePipeUnlockPos: the position of the driver's valve that unlocks it
|
|
bool locked = false;
|
|
bool unlockPressed = false; // the button that unlocks it pressed
|
|
};
|
|
|
|
// the braking of a vehicle
|
|
struct Braking
|
|
{
|
|
// the valves
|
|
std::shared_ptr<TBrake> distributor; // the brake valve of the vehicle with its reservoirs and cylinders
|
|
std::shared_ptr<TDriverHandle> driverValve; // the driver's brake valve of the train brake
|
|
std::shared_ptr<TDriverHandle> independentValve; // the driver's valve of the independent brake
|
|
|
|
// the definition, what the .fiz gives: set as the vehicle loads, not changed after
|
|
struct Config
|
|
{
|
|
TBrakeSystem kind = TBrakeSystem::Individual; // the kind of the train brake
|
|
TBrakeSubSystem subsystem = TBrakeSubSystem::ss_None;
|
|
TBrakeValve distributorType = TBrakeValve::NoValve;
|
|
int distributorSize = 0;
|
|
std::string distributorParameters;
|
|
TBrakeHandle driverValveType = TBrakeHandle::NoHandle;
|
|
TBrakeHandle independentValveType = TBrakeHandle::NoHandle;
|
|
bool independentTraxx = false; // the independent brake of the Traxx kind
|
|
DriverValveSettings driverValveSettings;
|
|
TLocalBrake localKind = TLocalBrake::NoBrake; // the kind of the individual brake
|
|
TBrakePressureTable pressureTable; // the pressures in the pipe of the positions of the driver's valve
|
|
int antiSlipType = 0; // 0: no anti-slip brake, 1: by hand, 2: automatic
|
|
std::array<int, 3> universalButtonActions{}; // what the universal brake buttons do
|
|
double maxForce = 0.0; // the most force of the brake
|
|
std::array<double, 5> maxCylinderPressure{}; // by the load setting: auxiliary, empty, medium, loaded, anti-slip
|
|
double pressureToForce = 0.0; // P2FTrans
|
|
double trackBrakeForce = 0.0; // the force of the track brake
|
|
int method = 0; // the friction material and its flags (bp_*)
|
|
int blocksPerAxle = 0; // NBpA: 0, 1, 2 or 4
|
|
double maxPressureMass = 1.0; // MBPM: the mass of the highest pressure
|
|
double pipeHighPressure = 0.0; // the highest working pressure of the brake pipe
|
|
double pipeLowPressure = 0.0; // the lowest one
|
|
double pipePressureRange = 0.0; // the difference between them
|
|
double cylinderVolume = 0.0; // the volume of the brake cylinders
|
|
double valveVolume = 0.0; // BVV
|
|
BrakeCylinders cylinders;
|
|
double rapidRatio = 1.0; // the ratio of the rapid brake
|
|
double rapidSpeed = 55.0; // the speed the rapid brake switches at
|
|
double pipeSection = 0.0; // Spg: the cross-section of the brake pipe
|
|
bool emergencyCutsOffDriverValve = false; // EmergencyCutsOffHandle
|
|
TBrakeDelayTable delays; // the delays of applying and releasing
|
|
int handlePositions = 0; // the positions of the driver's valve
|
|
bool hasHandBrake = false;
|
|
int availableDelays = 0; // the delays it can be set to
|
|
int availableOperatingModes = 0;
|
|
};
|
|
Config config;
|
|
|
|
// the state
|
|
TBrakePressure actualPressure; // their values weighted for the present position of the valve
|
|
std::array<bool, 3> universalButtonPressed{}; // the universal brake buttons pressed
|
|
int loadSetting = 0; // the index of maxCylinderPressure the brake takes
|
|
double controlReservoirPressure = 0.0; // the pressure in the control reservoir
|
|
EmergencyValve emergencyValve;
|
|
PipeLock pipeLock;
|
|
double cylinderPressure = 0.0; // the pressure in the brake cylinders
|
|
double cylinderPressureRate = 0.0; // how fast it changes, averaged over about a second [bar/s], see accelerating()
|
|
double independentCylinderPressure = 0.0; // the pressure in the cylinders from the independent brake
|
|
double pipeCylinderPressure = 0.0; // the pressure in the cylinders from the brake pipe
|
|
double equivalentPipePressure = 0.0; // the pressure of the brake pipe of the consist
|
|
double pipeLimiterPressure = 0.0; // the pressure the stabiliser holds
|
|
double reservoirAir = 0.0; // the compressed air in the brake reservoir
|
|
double brakeFlow = 0.0; // the air of the step: into the cylinders,
|
|
double pipeFlow = 0.0; // of the brake pipe,
|
|
double driverValveFlow = 0.0; // through the driver's valve,
|
|
double independentValveFlow = 0.0; // through the valve of the independent brake
|
|
int const &HandlePosition() const { return handlePosition; } // the position of the driver's valve
|
|
void SetHandlePosition(int const Value) { handlePosition = Value; }
|
|
double const &HandlePositionReal() const { return handlePositionReal; } // the same, continuous, of the FV4a
|
|
void SetHandlePositionReal(double const Value) { handlePositionReal = Value; }
|
|
double const &HandleCapPosition() const { return handleCapPosition; } // the cap of the FV4a
|
|
void SetHandleCapPosition(double const Value) { handleCapPosition = Value; }
|
|
double const &HandlePositionSmooth() const { return handlePositionSmooth; } // the continuous position of the driver's valve
|
|
void SetHandlePositionSmooth(double const Value) { handlePositionSmooth = Value; }
|
|
double const &IndependentPosition() const { return independentPosition; } // the position of the independent brake
|
|
void SetIndependentPosition(double const Value) { independentPosition = Value; }
|
|
double const &IndependentPositionEim() const { return independentPositionEim; } // the position of the EP independent brake of the asynchronous EMUs
|
|
void SetIndependentPositionEim(double const Value) { independentPositionEim = Value; }
|
|
int const &HandBrakePosition() const { return handBrakePosition; }
|
|
void SetHandBrakePosition(int const Value) { handBrakePosition = Value; }
|
|
int status = 0; // the bits b_* (b_off 0, b_on, b_dmg, b_rls, b_asb, b_ep ...)
|
|
bool alarmChain = false; // the manual emergency brake
|
|
int delaySetting = 0; // the delay set (bdelay_*)
|
|
// the AI wagon inspector cut the brake out (b_dmg) and puts it back when the train no longer needs it cut out
|
|
// (brake_setting::apply). Anyone else cutting it out or putting it back takes it over
|
|
bool cutOutByInspector = false;
|
|
int operatingMode = 0; // the mode set (bom_*: PS/PN/EP/MED 1/2/4/8)
|
|
double unitForce = 0.0; // the braking force of one braked element
|
|
double antiSlipTimer = 0.0; // to switch the anti-slip brake off
|
|
|
|
ElectrodynamicBrake electrodynamic;
|
|
BrakeBlending blending;
|
|
EmuDynamicBrake emuDynamic;
|
|
HoldingBrake holding;
|
|
SpringBrake spring;
|
|
|
|
private:
|
|
// the positions of the handles: the driver, the cab and the AI move them through the operations above
|
|
int handlePosition = -2;
|
|
double handlePositionReal = 0.0;
|
|
double handleCapPosition = 0.0;
|
|
double handlePositionSmooth = -2.0;
|
|
double independentPosition = 0.0;
|
|
double independentPositionEim = 0.0;
|
|
int handBrakePosition = 0;
|
|
};
|
|
|
|
} // namespace physics
|