mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 00:22:42 +01:00
12c5bb35e7
The split of Driver.cpp, DynObj.cpp and Train.cpp took five helpers out of their anonymous namespaces. outside() is used in offtrack.cpp alone and goes back into its anonymous namespace. The four shared by the parts of a class go into a namespace of its module: vehicle_ai (brake_response_horizon, uphill_stopping_distance), vehicle_dynamic (seconds_since) and vehicle_cab (is_hold_coil_lever). The rename of mover to physics also hit comments where the word meant something else: "prime mover" and "move the master controller" are back.
1873 lines
92 KiB
C++
1873 lines
92 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/.
|
|
*/
|
|
|
|
#pragma once
|
|
//---------------------------------------------------------------------------
|
|
// Q: 20160805 - odlaczenie pliku fizyki .pas od kompilacji
|
|
#include <array>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <unordered_map>
|
|
#include "physics/brakes.h"
|
|
#include "physics/couplerphysics.h"
|
|
#include "physics/derailment.h"
|
|
#include "physics/collision.h"
|
|
#include "scripting/ladderlogic.h"
|
|
#include "vehicle/derailmotion.h"
|
|
#include "vehicle/odometerreading.h"
|
|
#include "physics/vehicletypes.h"
|
|
#include "physics/components/dieselengine.h"
|
|
#include "physics/components/inductionmotor.h"
|
|
#include "physics/components/braking.h"
|
|
#include "physics/components/airsupply.h"
|
|
#include "physics/components/devices.h"
|
|
#include "physics/components/pantographs.h"
|
|
#include "physics/components/maincircuit.h"
|
|
#include "physics/components/lowvoltage.h"
|
|
|
|
class TractionDrive;
|
|
|
|
class cParser;
|
|
namespace physics
|
|
{
|
|
class Vehicle;
|
|
}
|
|
/*
|
|
MaSzyna EU07 locomotive simulator
|
|
Copyright (C) 2001-2004 Maciej Czapkiewicz and others
|
|
|
|
*/
|
|
|
|
/*
|
|
(C) McZapkie v.2004.02
|
|
Co brakuje:
|
|
6. brak pantografow itp 'Nie do konca, juz czesc zrobiona - Winger
|
|
7. brak efektu grzania oporow rozruchowych, silnika, osi
|
|
9. ulepszyc sprzeg sztywny oraz automatyczny
|
|
10. klopoty z EN57
|
|
...
|
|
n. Inne lokomotywy oprocz elektrowozu pradu stalego
|
|
*/
|
|
/*
|
|
Zrobione:
|
|
1. model szeregowego silnika elektrycznego sterowanego reostatem
|
|
2. fizyka ruchu - sily oporu, nachylenia, przyspieszenia styczne i normalne,
|
|
przyczepnosc/poslizg przy hamowaniu i rozruchu
|
|
3. docisk klockow hamulcowych -hamulec reczny oraz pomocniczy hamulec pneumatyczny
|
|
4. ubytki cisnienia wskutek hamowania, kompresor - ladowanie zbiornika
|
|
5. niektore uszkodzenia i awarie - logika rozmyta
|
|
a) silnik elektryczny - za duzy prad, napiecie, obroty
|
|
b) sprzegi - zerwanie gdy zbyt duze sily
|
|
6. flagi niektorych dzwiekow
|
|
7. hamulec zasadniczy - elektropneumatyczny (impulsowanie), pneumatyczny - zmiany cisnienia
|
|
zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona
|
|
8. sprzegi - sila, tlumiennosc
|
|
9. lok. el. - wylacznik glowny, odlacznik uszkodzonych silnikow
|
|
10. parametry trakcji
|
|
11. opoznienia w zalaczaniu stycznikow
|
|
12. trakcja wielokrotna
|
|
13. informacja na temat zrodla mocy dla silnikow trakcyjnych, ogrzewania, oswietlenia
|
|
14. dumb - uproszczony model lokomotywy (tylko dla AI)
|
|
15. ladunki - ilosc, typ, szybkosc na- i rozladunku, funkcje przetestowac!
|
|
16. ulepszony model fizyczny silnika elektrycznego (hamowanie silnikiem, ujemne napiecia)
|
|
17. poprawione hamulce - parametry cylindrow itp
|
|
18. ulepszone hamulce - napelnianie uderzeniowe, stopnie hamowania
|
|
19. poprawione hamulce - wyszczegolnenie cisnienia dla stopni hamowania
|
|
20. poprawione hamulce elektropneumatyczne
|
|
21. poprawione hamowanie przeciwposlizgowe i odluzniacz
|
|
22. dodany model mechanicznego napedu recznego (drezyna)
|
|
23. poprawiona szybkosc hamowania pomocniczego i przeciwposlizgowego, odlaczanie silnikow, odlaczanie bocznikow
|
|
24. wprowadzone systemy zabezpieczenia: SHP, Czuwak, sygnalizacja kabinowa (nie dzialaja w DebugMode).
|
|
25. poprawiona predkosc propagacji fali cisnienia (normalizacja przez kwadrat dlugosci) //to jest zdeka liniowe
|
|
26. uwzgledniona masa ladunku, przesuniecie w/m toru ruchu
|
|
27. lampy/sygnaly przednie/tylne
|
|
28. wprowadzona pozycja odciecia hamulca (yB: tja, ale oerlikona....)
|
|
29. rozne poprawki: slizganie, wykolejanie itp
|
|
30. model silnika spalinowego z przekladnia mechaniczna
|
|
31. otwieranie drzwi, sprezarka, przetwornica
|
|
32. wylaczanie obliczen dla nieruchomych wagonow
|
|
33. Zbudowany model rozdzielacza powietrza roznych systemow
|
|
34. Poprawiona pozycja napelniania uderzeniowego i hamulec EP
|
|
35. Dodane baterie akumulatorow (KURS90)
|
|
36. Hamowanie elektrodynamiczne w ET42 i poprawione w EP09
|
|
37. jednokierunkowosc walu kulakowego w EZT (nie do konca)
|
|
38. wal kulakowy w ET40
|
|
39. poprawiona blokada nastawnika w ET40
|
|
...
|
|
*/
|
|
|
|
/// <summary>Steam-locomotive grate parameters.</summary>
|
|
struct TGrateType
|
|
{
|
|
/// <summary>Fuel type burned on this grate.</summary>
|
|
TFuelType FuelType;
|
|
/// <summary>Grate surface area [m²].</summary>
|
|
double GrateSurface;
|
|
/// <summary>Fuel transport speed (stoker rate).</summary>
|
|
double FuelTransportSpeed;
|
|
/// <summary>Fuel ignition temperature [°C].</summary>
|
|
double IgnitionTemperature;
|
|
/// <summary>Maximum allowable grate temperature [°C].</summary>
|
|
double MaxTemperature;
|
|
// inline TGrateType() {
|
|
// FuelType = Undefined;
|
|
// GrateSurface = 0.0;
|
|
// FuelTransportSpeed = 0.0;
|
|
// IgnitionTemperature = 0.0;
|
|
// MaxTemperature = 0.0;
|
|
// }
|
|
};
|
|
/// <summary>Steam-locomotive boiler parameters.</summary>
|
|
struct TBoilerType
|
|
{
|
|
/// <summary>Boiler internal volume [m³].</summary>
|
|
double BoilerVolume;
|
|
/// <summary>Heat exchange surface of the boiler [m²].</summary>
|
|
double BoilerHeatSurface;
|
|
/// <summary>Superheater surface [m²].</summary>
|
|
double SuperHeaterSurface;
|
|
/// <summary>Maximum water volume [m³].</summary>
|
|
double MaxWaterVolume;
|
|
/// <summary>Minimum (safety) water volume [m³].</summary>
|
|
double MinWaterVolume;
|
|
/// <summary>Maximum boiler pressure [bar].</summary>
|
|
double MaxPressure;
|
|
// inline TBoilerType() {
|
|
// BoilerVolume = 0.0;
|
|
// BoilerHeatSurface = 0.0;
|
|
// SuperHeaterSurface = 0.0;
|
|
// MaxWaterVolume = 0.0;
|
|
// MinWaterVolume = 0.0;
|
|
// MaxPressure = 0.0;
|
|
// }
|
|
};
|
|
/// <summary>Pantograph (current collector) model identifier.</summary>
|
|
enum TPantType
|
|
{
|
|
/// <summary>AKP-4E pantograph (PKP single-arm).</summary>
|
|
AKP_4E,
|
|
/// <summary>DSA-series pantograph (Stemmann).</summary>
|
|
DSAx,
|
|
/// <summary>EC160/EC200 pantograph.</summary>
|
|
EC160_200,
|
|
/// <summary>WBL85 pantograph.</summary>
|
|
WBL85
|
|
};
|
|
/// <summary>Current-collector (pantograph) configuration block.</summary>
|
|
struct TCurrentCollector
|
|
{
|
|
/// <summary>Number of pantographs of this type.</summary>
|
|
long CollectorsNo; // musi być tu, bo inaczej się kopie
|
|
/// <summary>Minimum pantograph height [m] (currently unused).</summary>
|
|
double MinH;
|
|
/// <summary>Maximum pantograph height [m] (currently unused).</summary>
|
|
double MaxH;
|
|
/// <summary>Working width of the contact strip [m].</summary>
|
|
double CSW; // szerokość części roboczej (styku) ślizgacza
|
|
/// <summary>Minimum acceptable contact-line voltage [V].</summary>
|
|
double MinV;
|
|
/// <summary>Maximum acceptable contact-line voltage [V].</summary>
|
|
double MaxV;
|
|
/// <summary>True if an over-voltage protection relay is fitted.</summary>
|
|
bool OVP; // czy jest przekaznik nadnapieciowy
|
|
/// <summary>Minimum voltage required to engage the main switch [V].</summary>
|
|
double InsetV; // minimalne napięcie wymagane do załączenia
|
|
/// <summary>Minimum air pressure required to operate [bar].</summary>
|
|
double MinPress; // minimalne ciśnienie do załączenia WS
|
|
/// <summary>Maximum air pressure after the reductor [bar].</summary>
|
|
double MaxPress; // maksymalne ciśnienie za reduktorem
|
|
/// <summary>True if power output is faked (e.g. for AI vehicles without a model).</summary>
|
|
bool FakePower;
|
|
/// <summary>Physical layout id (orientation / side).</summary>
|
|
int PhysicalLayout;
|
|
/// <summary>Pantograph type (model).</summary>
|
|
TPantType PantographType;
|
|
// inline TCurrentCollector() {
|
|
// CollectorsNo = 0;
|
|
// MinH, MaxH, CSW, MinV, MaxV = 0.0;
|
|
// OVP, InsetV, MinPress, MaxPress = 0.0;
|
|
// }
|
|
};
|
|
/// <summary>Power-source kind (where the vehicle gets electrical or mechanical energy from).</summary>
|
|
enum class TPowerSource
|
|
{
|
|
NotDefined,
|
|
InternalSource,
|
|
Transducer,
|
|
Generator,
|
|
Accumulator,
|
|
CurrentCollector,
|
|
PowerCable,
|
|
Heater,
|
|
Main
|
|
};
|
|
|
|
/// <summary>Diesel engine driven generator parameters and outputs.</summary>
|
|
struct engine_generator
|
|
{
|
|
// ld inputs
|
|
/// <summary>Pointer to the prime-mover revolutions [rev/s].</summary>
|
|
double *engine_revolutions; // revs per second of the prime mover
|
|
// config
|
|
/// <summary>Minimum working rev rate [rev/s].</summary>
|
|
double revolutions_min; // min working revolutions rate, in revs per second
|
|
/// <summary>Maximum working rev rate [rev/s].</summary>
|
|
double revolutions_max; // max working revolutions rate, in revs per second
|
|
/// <summary>Voltage generated at <c>revolutions_min</c> [V].</summary>
|
|
double voltage_min; // voltage generated at min working revolutions
|
|
/// <summary>Voltage generated at <c>revolutions_max</c> [V].</summary>
|
|
double voltage_max; // voltage generated at max working revolutions
|
|
// ld outputs
|
|
/// <summary>Current rev rate [rev/s].</summary>
|
|
double revolutions;
|
|
/// <summary>Current generated voltage [V].</summary>
|
|
double voltage;
|
|
};
|
|
|
|
/// <summary>Battery / accumulator power source.</summary>
|
|
struct TAccumulator
|
|
{
|
|
/// <summary>Maximum capacity [Ah].</summary>
|
|
double MaxCapacity;
|
|
/// <summary>Source used to recharge the battery.</summary>
|
|
TPowerSource RechargeSource;
|
|
// inline _vehicle__1() {
|
|
// MaxCapacity = 0.0;
|
|
// RechargeSource = NotDefined;
|
|
// }
|
|
};
|
|
|
|
/// <summary>Permanent power cable (e.g. to a heater) carrying a specific power form.</summary>
|
|
struct TPowerCable
|
|
{
|
|
/// <summary>Type of power transmitted.</summary>
|
|
TPowerType PowerTrans;
|
|
/// <summary>Steam pressure (when SteamPower is transmitted) [bar].</summary>
|
|
double SteamPressure;
|
|
// inline _vehicle__2() {
|
|
// SteamPressure = 0.0;
|
|
// PowerTrans = NoPower;
|
|
// }
|
|
};
|
|
|
|
/// <summary>Steam locomotive boiler-and-grate combo.</summary>
|
|
struct THeater
|
|
{
|
|
/// <summary>Grate parameters.</summary>
|
|
TGrateType Grate;
|
|
/// <summary>Boiler parameters.</summary>
|
|
TBoilerType Boiler;
|
|
};
|
|
|
|
/// <summary>Transducer (DC-DC / converter) parameters.</summary>
|
|
struct TTransducer
|
|
{
|
|
// ld inputs
|
|
/// <summary>Input voltage [V].</summary>
|
|
double InputVoltage;
|
|
};
|
|
|
|
/// <summary>
|
|
/// Generic power-source parameters. The trailing union holds source-specific
|
|
/// configuration depending on <c>SourceType</c>.
|
|
/// </summary>
|
|
struct TPowerParameters
|
|
{
|
|
/// <summary>Maximum source voltage [V].</summary>
|
|
double MaxVoltage{0.0};
|
|
/// <summary>Maximum source current [A].</summary>
|
|
double MaxCurrent{0.0};
|
|
/// <summary>Internal resistance [Ω].</summary>
|
|
double IntR{0.001};
|
|
/// <summary>Type of source (selects which union member is meaningful).</summary>
|
|
TPowerSource SourceType;
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
THeater RHeater;
|
|
};
|
|
struct
|
|
{
|
|
TPowerCable RPowerCable;
|
|
};
|
|
struct
|
|
{
|
|
TCurrentCollector CollectorParameters;
|
|
};
|
|
struct
|
|
{
|
|
TAccumulator RAccumulator;
|
|
};
|
|
struct
|
|
{
|
|
engine_generator EngineGenerator;
|
|
};
|
|
struct
|
|
{
|
|
TTransducer Transducer;
|
|
};
|
|
struct
|
|
{
|
|
TPowerType PowerType;
|
|
};
|
|
};
|
|
inline TPowerParameters()
|
|
{
|
|
SourceType = TPowerSource::NotDefined;
|
|
PowerType = TPowerType::NoPower;
|
|
RPowerCable.PowerTrans = TPowerType::NoPower;
|
|
}
|
|
};
|
|
|
|
/*dla lokomotyw elektrycznych:*/
|
|
struct TScheme
|
|
{
|
|
int Relay = 0; /*numer pozycji rozruchu samoczynnego*/
|
|
double R = 0.0; /*opornik rozruchowy*/ /*dla dizla napelnienie*/
|
|
int Bn = 0;
|
|
int Mn = 0; /*ilosc galezi i silnikow w galezi*/ /*dla dizla Mn: czy luz czy nie*/
|
|
bool AutoSwitch = false; /*czy dana pozycja nastawniana jest recznie czy autom.*/
|
|
int ScndAct = 0; /*jesli ma bocznik w nastawniku, to ktory bocznik na ktorej pozycji*/
|
|
};
|
|
using TSchemeTable = TScheme[ResArraySize + 1]; /*tablica rezystorow rozr.*/
|
|
struct TDEScheme
|
|
{
|
|
double RPM = 0.0; /*obroty diesla*/
|
|
double GenPower = 0.0; /*moc maksymalna*/
|
|
double Umax = 0.0; /*napiecie maksymalne*/
|
|
double Imax = 0.0; /*prad maksymalny*/
|
|
};
|
|
using TDESchemeTable = TDEScheme[33]; /*tablica WWList dla silnikow spalinowych*/
|
|
struct TFFScheme
|
|
{
|
|
double v = 0.0; // parametr wejsciowy
|
|
double freq = 0.0; // wyjscie: czestotliwosc falownika
|
|
};
|
|
using TFFSchemeTable = TFFScheme[33];
|
|
|
|
struct TWiperScheme
|
|
{
|
|
uint8_t byteSum = 0; // suma bitowa pracujacych wycieraczek
|
|
double WiperSpeed = 0.0; // predkosc wycieraczki
|
|
double interval = 0.0; // interwal pracy wycieraczki
|
|
double outBackDelay = 0.0; // czas po jakim wycieraczka zacznie wracac z konca do poczatku
|
|
};
|
|
using TWiperSchemeTable = TWiperScheme[16];
|
|
|
|
struct TShuntScheme
|
|
{
|
|
double Umin = 0.0;
|
|
double Umax = 0.0;
|
|
double Pmin = 0.0;
|
|
double Pmax = 0.0;
|
|
};
|
|
using TShuntSchemeTable = TShuntScheme[33];
|
|
struct TMPTRelay
|
|
{ /*lista przekaznikow bocznikowania*/
|
|
double Iup = 0.0;
|
|
double Idown = 0.0;
|
|
};
|
|
using TMPTRelayTable = TMPTRelay[MotorParametersArraySize + 1]; // indexed like MotorParam
|
|
|
|
struct TMotorParameters
|
|
{
|
|
double mfi{0.0};
|
|
double mIsat{0.0};
|
|
double mfi0{0.0}; // aproksymacja M(I) silnika} {dla dizla mIsat=przekladnia biegu
|
|
double fi{0.0};
|
|
double Isat{0.0};
|
|
double fi0{0.0}; // aproksymacja E(n)=fi*n} {dla dizla fi, mfi: predkosci przelozenia biegu <->
|
|
bool AutoSwitch{false};
|
|
};
|
|
|
|
struct TUniversalCtrl
|
|
{
|
|
int mode = 0; /*tryb pracy zadajnika - pomocnicze*/
|
|
double MinCtrlVal = 0.0; /*minimalna wartosc nastawy*/
|
|
double MaxCtrlVal = 0.0; /*maksymalna wartosc nastawy*/
|
|
double SetCtrlVal = 0.0; /*docelowa wartosc nastawy*/
|
|
double SpeedUp = 0.0; /*szybkosc zwiekszania nastawy*/
|
|
double SpeedDown = 0.0; /*szybkosc zmniejszania nastawy*/
|
|
int ReturnPosition = 0; /*pozycja na ktora odskakuje zadajnik*/
|
|
int NextPosFastInc = 0; /*nastepna duza pozycja przy przechodzeniu szybkim*/
|
|
int PrevPosFastDec = 0; /*poprzednia duza pozycja przy przechodzeniu szybkim*/
|
|
};
|
|
using TUniversalCtrlTable = std::array<TUniversalCtrl, UniversalCtrlArraySize + 1>;
|
|
|
|
class TSecuritySystem
|
|
{
|
|
bool vigilance_enabled = false;
|
|
bool cabsignal_enabled = false;
|
|
bool radiostop_enabled = false;
|
|
|
|
bool cabsignal_active = false;
|
|
bool pressed = false;
|
|
bool enabled = false;
|
|
bool is_sifa = false; // Sifa-like pedal device, with inverted input for convenient keyboard usage
|
|
bool separate_acknowledge = false; // cabsignal reset button is separate from vigilance
|
|
bool cabsignal_lock = false;
|
|
bool vigilance_suspended = false; // the vigilance device switched off by the shunt mode of the vehicle, see AwareOffInShuntMode
|
|
|
|
double vigilance_timer = 0.0;
|
|
double alert_timer = 0.0;
|
|
double press_timer = 0.0;
|
|
|
|
double velocity = 0.0;
|
|
bool power = false;
|
|
int cabactive = 0;
|
|
|
|
double AwareDelay = 30.0;
|
|
double AwareMinSpeed = 0.0;
|
|
double SoundSignalDelay = 5.0;
|
|
double EmergencyBrakeDelay = 5.0;
|
|
double MaxHoldTime = 1.5;
|
|
bool CabDependent = false;
|
|
bool AwareOffInShuntMode = false; // the shunt mode of the vehicle switches the vigilance device off, as on the SM42
|
|
|
|
public:
|
|
void set_enabled(bool e);
|
|
void acknowledge_press();
|
|
void acknowledge_release();
|
|
void cabsignal_reset();
|
|
void update(double dt, double Vel, bool pwr, int cab);
|
|
void set_cabsignal();
|
|
void set_cabsignal_lock(bool);
|
|
void set_shunt_mode(bool State);
|
|
bool is_blinking() const;
|
|
bool is_vigilance_blinking() const;
|
|
bool is_cabsignal_blinking() const;
|
|
bool is_beeping() const;
|
|
bool is_cabsignal_beeping() const;
|
|
bool is_braking() const;
|
|
bool is_engine_blocked() const;
|
|
bool radiostop_available() const;
|
|
bool has_separate_acknowledge() const;
|
|
void load(std::string const &line, double Vmax);
|
|
|
|
double MagnetLocation = 0.0;
|
|
};
|
|
|
|
struct TTransmision
|
|
{ // liczba zebow przekladni
|
|
int NToothM = 0;
|
|
int NToothW = 0;
|
|
double Ratio = 1.0;
|
|
double Efficiency = 1.0;
|
|
};
|
|
|
|
enum class TCouplerType
|
|
{
|
|
NoCoupler,
|
|
Articulated,
|
|
Bare,
|
|
Chain,
|
|
Screw,
|
|
Automatic
|
|
};
|
|
|
|
struct power_coupling
|
|
{
|
|
double current{0.0};
|
|
double voltage{0.0};
|
|
bool is_local{false}; // whether the power comes from external or onboard source
|
|
bool is_live{false}; // whether the coupling with next vehicle is live
|
|
};
|
|
|
|
struct TCoupling
|
|
{
|
|
/*parametry*/
|
|
double SpringKB = 1.0; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */
|
|
double DmaxB = 0.1; /*tolerancja scisku/rozciagania, sila rozerwania*/
|
|
double FmaxB = 1000.0;
|
|
double SpringKC = 1.0;
|
|
double DmaxC = 0.1;
|
|
double FmaxC = 1000.0;
|
|
double beta = 0.0;
|
|
TCouplerType CouplerType = TCouplerType::NoCoupler; /*typ sprzegu*/
|
|
CouplingSet AutomaticCouplingFlag{Coupling::coupler};
|
|
CouplingSet AllowedFlag{Coupling::coupler | Coupling::brakeHose}; // Ra: maska dostępnych
|
|
CouplingSet PowerFlag{Coupling::power110v | Coupling::power24v};
|
|
CouplingSet PowerCoupling{Coupling::permanent}; // type of coupling required for power transfer
|
|
/*zmienne*/
|
|
bool AutomaticCouplingAllowed{true}; // whether automatic coupling can be currently performed
|
|
CouplingSet CouplingFlag; // what the coupling joins; none: the vehicles only see each other
|
|
class physics::Vehicle *Connected = nullptr; /*co jest podlaczone*/
|
|
int ConnectedNr = 0; // Ra: od której strony podłączony do (Connected): 0=przód, 1=tył
|
|
// the end of the vehicle connected to, while there is one
|
|
VehicleEnd ConnectedEnd() const
|
|
{
|
|
return static_cast<VehicleEnd>(ConnectedNr);
|
|
}
|
|
double CForce = 0.0; /*sila z jaka dzialal*/
|
|
double Dist = 0.0; /*strzalka ugiecia zderzaków*/
|
|
bool CheckCollision = false; /*czy sprawdzac sile czy pedy*/
|
|
float stretch_duration{0.f}; // seconds, elapsed time with excessive force applied to the coupler
|
|
bool broken{false}; // the coupler broke (damage_coupler()), until it's repaired (repair_coupler())
|
|
// optional adapter piece
|
|
double adapter_length{0.0}; // meters, value added on the given end to standard vehicle (half)length
|
|
double adapter_height{0.0}; // meters, distance from rail level
|
|
TCouplerType adapter_type = TCouplerType::NoCoupler; // CouplerType override if other than NoCoupler
|
|
|
|
power_coupling power_high;
|
|
power_coupling power_110v;
|
|
power_coupling power_24v;
|
|
// the circuit of the power coupling given, nullptr for a coupling which isn't one
|
|
power_coupling *power(Coupling const kind)
|
|
{
|
|
switch (kind)
|
|
{
|
|
case Coupling::highVoltage:
|
|
return &power_high;
|
|
case Coupling::power110v:
|
|
return &power_110v;
|
|
case Coupling::power24v:
|
|
return &power_24v;
|
|
default:
|
|
return nullptr;
|
|
}
|
|
}
|
|
power_coupling const *power(Coupling const kind) const
|
|
{
|
|
switch (kind)
|
|
{
|
|
case Coupling::highVoltage:
|
|
return &power_high;
|
|
case Coupling::power110v:
|
|
return &power_110v;
|
|
case Coupling::power24v:
|
|
return &power_24v;
|
|
default:
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
// the physical model of the coupling (couplerphysics in eu07.ini), see couplerphysics.h: the parameters of this end,
|
|
// and the state of the coupling with the vehicle at this end, which that vehicle keeps alike on its own end
|
|
coupler_physics::end_parameters physics;
|
|
coupler_physics::pair_state physics_state;
|
|
// the collisions past the buffers (physics.collisions new), see collision.h: the optional keys of this end, the depth
|
|
// it's crushed to for good [m], and the hit of the pair in the step: whether either vehicle handled it already, its
|
|
// peak force [N] and how long that acted [s]
|
|
collision::end_definition collision;
|
|
double crush{0.0};
|
|
double closing{0.0}; // the velocity the buffers of the pair closed in at, at the start of the step [m/s]
|
|
bool hit_handled{false};
|
|
double hit_force{0.0};
|
|
double hit_duration{0.0};
|
|
// physics.collisions monitor: the log told of the crush of this hit of the pair already
|
|
bool crush_monitored{false};
|
|
// the energy the contact of the pair brought to its buffers, for the budget of the crush
|
|
collision::contact_energy contact;
|
|
// the log told of the vehicle at this end being inside this one already
|
|
bool inside_reported{false};
|
|
|
|
int sounds{0}; // sounds emitted by the coupling devices
|
|
bool Render = false; /*ABu: czy rysowac jak zaczepiony sprzeg*/
|
|
std::string control_type; // abstraction of control coupling interface and communication standard
|
|
|
|
inline bool has_adapter() const
|
|
{
|
|
return adapter_type != TCouplerType::NoCoupler;
|
|
}
|
|
inline TCouplerType type() const
|
|
{
|
|
return adapter_type == TCouplerType::NoCoupler ? CouplerType : adapter_type;
|
|
}
|
|
};
|
|
|
|
|
|
struct speed_control
|
|
{
|
|
bool IsActive = false;
|
|
bool Start = false;
|
|
bool ManualStateOverride = true;
|
|
bool BrakeIntervention = false;
|
|
bool BrakeInterventionBraking = false;
|
|
bool BrakeInterventionUnbraking = false;
|
|
bool Standby = false;
|
|
bool Parking = false;
|
|
double InitialPower = 1.0;
|
|
double FullPowerVelocity = -1;
|
|
double StartVelocity = -1;
|
|
double VelocityStep = 5;
|
|
double PowerStep = 0.1;
|
|
double MinPower = 0.0;
|
|
double MaxPower = 1.0;
|
|
double MinVelocity = 0;
|
|
double MaxVelocity = 120;
|
|
double DesiredVelocity = 0;
|
|
double DesiredPower = 1.0;
|
|
double Offset = -0.5;
|
|
double FactorPpos = 0.5;
|
|
double FactorPneg = 0.5;
|
|
double FactorIpos = 0.0;
|
|
double FactorIneg = 0.0;
|
|
double BrakeInterventionVel = 30.0;
|
|
double PowerUpSpeed = 1000;
|
|
double PowerDownSpeed = 1000;
|
|
};
|
|
|
|
namespace physics
|
|
{
|
|
|
|
class Vehicle
|
|
{ // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :)
|
|
public:
|
|
std::string chkPath;
|
|
bool reload_FIZ();
|
|
double dMoveLen = 0.0;
|
|
/*---opis lokomotywy, wagonu itp*/
|
|
/*--opis serii--*/
|
|
int CategoryFlag = 1; /*1 - pociag, 2 - samochod, 4 - statek, 8 - samolot*/
|
|
/*--sekcja stalych typowych parametrow*/
|
|
std::string TypeName; /*nazwa serii/typu*/
|
|
train_type TrainType{train_type::generic}; // the vehicles of a handling of their own, from the Type of the .fiz
|
|
// an electric or a diesel multiple unit
|
|
bool is_multiple_unit() const
|
|
{
|
|
return TrainType == train_type::emu || TrainType == train_type::dmu;
|
|
}
|
|
TEngineType EngineType = TEngineType::None; /*typ napedu*/
|
|
TPowerParameters EnginePowerSource; /*zrodlo mocy dla silnikow*/
|
|
TPowerParameters SystemPowerSource; /*zrodlo mocy dla systemow sterowania/przetwornic/sprezarek*/
|
|
TPowerParameters HeatingPowerSource; /*zrodlo mocy dla ogrzewania*/
|
|
TPowerParameters AlterHeatPowerSource; /*alternatywne zrodlo mocy dla ogrzewania*/
|
|
TPowerParameters LightPowerSource; /*zrodlo mocy dla oswietlenia*/
|
|
TPowerParameters AlterLightPowerSource; /*alternatywne mocy dla oswietlenia*/
|
|
double Vmax = -1.0;
|
|
double Mass = 0.0;
|
|
double Power = 0.0; /*max. predkosc kontrukcyjna, masa wlasna, moc*/
|
|
double Mred = 0.0; /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/
|
|
double TotalMass = 0.0; /*wyliczane przez ComputeMass*/
|
|
double LightPower = 0.0; /*moc pobierana na ogrzewanie/oswietlenie*/
|
|
bool EpFuse = true; /*Czy jest wlaczony hamulec EP*/
|
|
double EpForce = 0.0; /*Poziom zadanej sily EP*/
|
|
bool Signalling = false; /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/
|
|
bool Radio = false; /*Czy jest zalaczony radiotelefon*/
|
|
// the cut-off in the radio's power supply: a fuse in the cabinet, a lever on the desk or the switch on the radio's power
|
|
// supply (eu07/maszyna#438). Closed unless the driver opens it, so vehicles without such a switch work as before
|
|
bool RadioFuse = true;
|
|
TDimension Dim; /*wymiary*/
|
|
double Cx = 0.0; /*wsp. op. aerodyn.*/
|
|
float Floor = 0.96f; // poziom podłogi dla ładunków
|
|
// height of the centre of gravity of the empty vehicle above the rail [m] (CoGH in the Dimensions of the .fiz),
|
|
// negative when the definition gives none: derailment::default_centre_of_gravity() then
|
|
double CentreOfGravity = -1.0;
|
|
float WheelDiameter = 1.f; /*srednica kol napednych*/
|
|
float WheelDiameterL = 0.9f; // Ra: srednica kol tocznych przednich
|
|
float WheelDiameterT = 0.9f; // Ra: srednica kol tocznych tylnych
|
|
float TrackW = 1.435f; /*nominalna szerokosc toru [m]*/
|
|
double AxleInertialMoment = 0.0; /*moment bezwladnosci zestawu kolowego*/
|
|
std::string AxleArangement; /*uklad osi np. Bo'Bo' albo 1'C*/
|
|
int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/
|
|
int NAxles = 0; /*ilosc wszystkich osi j.w.*/
|
|
int BearingType = 1; /*lozyska: 0 - slizgowe, 1 - toczne*/
|
|
double ADist = 0.0;
|
|
double BDist = 0.0; /*odlegosc osi oraz czopow skretu*/
|
|
int SandCapacity = 0; /*zasobnik piasku [kg]*/
|
|
|
|
int wiperSwitchPos = 0; // pozycja przelacznika wycieraczek
|
|
double WiperAngle = {45.0}; // kat pracy wycieraczek
|
|
|
|
LowVoltageSupply lowVoltage; // the battery and the low voltage circuits (physics/components/lowvoltage.h)
|
|
TrainHeating trainHeating;
|
|
LineBreaker lineBreaker; // the main circuit (physics/components/maincircuit.h)
|
|
LineContactors lineContactors;
|
|
ProtectionRelays protection;
|
|
PowerConverter converter;
|
|
ByEnd<basic_pantograph> pantographs;
|
|
PantographCircuit pantographCircuit; // their voltages, switches, presets (physics/components/pantographs.h)
|
|
PantographAir pantographAir; // their reservoir, the small compressor, the valves
|
|
TrainPipe brakePipe; // the brake pipe along the train
|
|
TrainPipe mainPipe; // the main reservoir pipe along the train
|
|
AirSupply air; // the compressor and the main reservoir (physics/components/airsupply.h)
|
|
Braking brakes; // the blending, the holding brake, the spring brake (physics/components/braking.h)
|
|
|
|
int UniversalResetButtonFlag[3] = {0, 0, 0}; // customizable reset buttons assignments
|
|
int TurboTest = 0;
|
|
/*nastawniki:*/
|
|
int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/
|
|
int ScndCtrlPosNo = 0;
|
|
int LightsPosNo = 0;
|
|
int LightsDefPos = 1;
|
|
bool LightsWrap = false;
|
|
ByEnd<std::array<int, 18>> Lights; // pozycje świateł, przód - tył, 1 .. 16 (17 do lightsset)
|
|
// the cab interior light each light preset sets, from the optional third column of LightsList (bits of
|
|
// lights_preset_cablight::flag); -1: the preset leaves the cab light as it is (eu07/maszyna#529)
|
|
std::array<int, 18> LightsCabLight{[] {
|
|
std::array<int, 18> positions;
|
|
positions.fill(-1);
|
|
return positions;
|
|
}()};
|
|
int ScndInMain{0}; /*zaleznosc bocznika od nastawnika*/
|
|
double maxTachoSpeed = {0.0}; // maksymalna predkosc na tarczce predkosciomierza analogowego
|
|
bool HideDirStatusWhenMoving{false}; // Czy gasic lampki kierunku powyzej predkosci zdefiniowanej przez HideDirStatusSpeed
|
|
int HideDirStatusSpeed{1}; // Predkosc od ktorej lampki kierunku sa wylaczane
|
|
bool isDoubleClickForMeasureNeeded = {false}; // czy rozpoczecie pomiaru odleglosci odbywa sie po podwojnym wcisnienciu przycisku?
|
|
float DistanceCounterDoublePressPeriod = {1.f}; // czas w jakim nalezy podwojnie wcisnac przycisk, aby rozpoczac pomiar odleglosci
|
|
TSecuritySystem SecuritySystem;
|
|
int EmergencyBrakeWarningSignal{0}; // combined with basic WarningSignal when manual emergency brake is active
|
|
horn_supply HornSupply{horn_supply::air}; // of the low and high tone horns (WarningSignal 1 and 2)
|
|
horn_supply Horn3Supply{horn_supply::air}; // of the third horn (WarningSignal 4)
|
|
// main reservoir pressure [bar, as MinCP and MaxCP] below which a pneumatic horn stays silent
|
|
static constexpr double HornMinPressure{2.0};
|
|
TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/
|
|
int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/
|
|
bool UniCtrlIntegratedBrakePNCtrl = false; /*zintegrowany nastawnik JH obsluguje hamulec PN*/
|
|
bool UniCtrlIntegratedBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie*/
|
|
bool UniCtrlIntegratedLocalBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie hamulcem pomocniczym*/
|
|
int UniCtrlNoPowerPos{0}; // cached highesr position not generating traction force
|
|
// UCList CtrlValStep: the universal controller (EIMCtrlType 3) changes its setting in steps of this size (e.g. 0.05 for the
|
|
// 5% steps of the 6Dg), one at once when moved to a raising or lowering position, then one each time its SpeedUp / SpeedDown
|
|
// covers a step; 0 (the default) changes it continuously
|
|
double UniCtrlValStep{0.0};
|
|
|
|
/*-sekcja parametrow dla lokomotywy elektrycznej*/
|
|
TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/
|
|
int RlistSize = 0;
|
|
TMotorParameters MotorParam[MotorParametersArraySize + 1];
|
|
/*rozne parametry silnika przy bocznikowaniach*/
|
|
/*dla lokomotywy spalinowej z przekladnia mechaniczna: przelozenia biegow*/
|
|
// bounds-safe read access to MotorParam
|
|
TMotorParameters const &motor_param(int const Position) const
|
|
{
|
|
if (Position < 0)
|
|
return MotorParam[0];
|
|
if (Position > MotorParametersArraySize)
|
|
return MotorParam[MotorParametersArraySize];
|
|
return MotorParam[Position];
|
|
}
|
|
TTransmision Transmision;
|
|
// record {liczba zebow przekladni}
|
|
// NToothM, NToothW : byte;
|
|
// Ratio: real; {NToothW/NToothM}
|
|
// end;
|
|
double NominalVoltage = 0.0; /*nominalne napiecie silnika*/
|
|
double WindingRes = 0.0;
|
|
double u = 0.0; // wspolczynnik tarcia yB wywalic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
double CircuitRes = 0.0; /*rezystancje silnika i obwodu*/
|
|
int IminLo = 0;
|
|
int IminHi = 0; /*prady przelacznika automatycznego rozruchu, uzywane tez przez ai_driver*/
|
|
int ImaxLo = 0; // maksymalny prad niskiego rozruchu
|
|
int ImaxHi = 0; // maksymalny prad wysokiego rozruchu
|
|
bool MotorOverloadRelayHighThreshold{false};
|
|
double nmax = 0.0; /*maksymalna dop. ilosc obrotow /s*/
|
|
double InitialCtrlDelay = 0.0;
|
|
double CtrlDelay = 0.0; /* -//- -//- miedzy kolejnymi poz.*/
|
|
double CtrlDownDelay = 0.0; /* -//- -//- przy schodzeniu z poz.*/ /*hunter-101012*/
|
|
int FastSerialCircuit = 0; /*0 - po kolei zamyka styczniki az do osiagniecia szeregowej, 1 - natychmiastowe wejscie na szeregowa*/ /*hunter-111012*/
|
|
int BackwardsBranchesAllowed = 1;
|
|
int AutoRelayType = 0; /*0 -brak, 1 - jest, 2 - opcja*/
|
|
// FieldShuntSwitch=Yes: the switch of AutoRelay=Optional of a diesel-electric is its switch of the field shunting, as the SU45's
|
|
// and SP45's (fieldshunting.h): off, the field stays full. without it, off hands the shunting to the second controller, as before
|
|
bool FieldShuntSwitch = false;
|
|
bool CoupledCtrl = false; /*czy mainctrl i scndctrl sa sprzezone*/
|
|
bool HasCamshaft{false};
|
|
// the dynamic brake of a diesel-electric vehicle (Engine: EDBrake=...): the traction motors brake into resistors while
|
|
// the engine runs, with the force of the definition rather than from a circuit, as the drive of these vehicles is
|
|
// computed from the generator's power. no definition, no dynamic brake (MaSzyna-EU07/maszyna#82)
|
|
struct diesel_electric_dynamic_brake
|
|
{
|
|
enum class control
|
|
{
|
|
none,
|
|
controller, // the negative range of the integrated controller (EIMCtrlType > 0), as the TRAXX one of the BR285
|
|
lever // a lever of its own (the SplitEDPneumaticBrake one, DBPN steps), with the master controller at zero
|
|
};
|
|
control source{control::none};
|
|
double max_force{0.0}; // [N] at the wheel rims of the whole vehicle, EDBrakeFmax [kN]
|
|
double max_power{0.0}; // [W] the resistors take, EDBrakePmax [kW]; 0: no limit
|
|
double fade_low{0.0}; // [km/h] EDBrakeV0: no force below
|
|
double fade_high{0.0}; // [km/h] EDBrakeV1: the whole force above, rising in between
|
|
double rate{0.5}; // [1/s] EDBrakeRate: how fast the effort follows the demand
|
|
bool blending{false}; // EDBrakeBlending: the locomotive's train brake lets off while the dynamic brake works (Hamulec->SetED)
|
|
// state
|
|
double level{0.0}; // the effort, 0..1
|
|
double force{0.0}; // [N] the braking force, against the motion
|
|
};
|
|
diesel_electric_dynamic_brake DEDynamicBrake;
|
|
double TUHEX_Sum = 750; /*nastawa sterownika hamowania ED - aktualna*/
|
|
double TUHEX_Diff = 10; /*histereza działania sterownika hamowania ED*/
|
|
double TUHEX_MinIw = 60; /*minimalny prąd wzbudzenia przy hamowaniu ED - wynika z chk silnika*/
|
|
double TUHEX_MaxIw = 400; /*maksymalny prąd wzbudzenia przy hamowaniu ED - ograniczenie max siły*/
|
|
double TUHEX_Sum1 = 750; /*nastawa1 sterownika hamowania ED*/
|
|
double TUHEX_Sum2 = 750; /*nastawa2 sterownika hamowania ED*/
|
|
double TUHEX_Sum3 = 750; /*nastawa3 sterownika hamowania ED*/
|
|
int TUHEX_Stages = 0; /*liczba stopni hamowania ED*/
|
|
// TODO: wrap resistor fans variables and state into a device
|
|
int RVentType = 0; /*0 - brak, 1 - jest, 2 - automatycznie wlaczany*/
|
|
double RVentnmax = 1.0; /*maks. obroty wentylatorow oporow rozruchowych*/
|
|
double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/
|
|
double RVentSpeed{0.5}; // rozpedzanie sie wentylatora obr/s^2}
|
|
double RVentMinI{50.0}; // przy jakim pradzie sie wylaczaja}
|
|
bool RVentForceOn{false}; // forced activation switch
|
|
bool Trafo = false; /*pojazd wyposażony w transformator*/
|
|
|
|
// the diesel engine, its torque converter and its retarder (physics/components/dieselengine.h)
|
|
DieselEngine diesel;
|
|
TorqueConverter torqueConverter;
|
|
Retarder retarder;
|
|
double engagedownspeed = 0.9;
|
|
double engageupspeed = 0.5;
|
|
/*- dla lokomotyw spalinowo-elektrycznych -*/
|
|
double AnPos = 0.0; // pozycja sterowania dokladnego (analogowego)
|
|
bool AnalogCtrl = false; //
|
|
bool AnMainCtrl = false; //
|
|
bool ShuntModeAllow = false;
|
|
bool ShuntMode = false;
|
|
|
|
bool Flat = false;
|
|
double Vhyp = 1.0;
|
|
TDESchemeTable DElist;
|
|
TFFSchemeTable FFlist;
|
|
int FFListSize = 0;
|
|
TFFSchemeTable FFEDlist;
|
|
int FFEDListSize = 0;
|
|
TWiperSchemeTable WiperList;
|
|
int WiperListSize;
|
|
int WiperDefaultPos{0};
|
|
int modernWpierListSize;
|
|
|
|
double Vadd = 1.0;
|
|
TMPTRelayTable MPTRelay;
|
|
int RelayType = 0;
|
|
TShuntSchemeTable SST;
|
|
double PowerCorRatio = 1.0; // Wspolczynnik korekcyjny
|
|
/*- dla uproszczonego modelu silnika (dumb) oraz dla drezyny*/
|
|
double Ftmax = 0.0;
|
|
/*- dla lokomotyw z silnikami indukcyjnymi -*/
|
|
// the drive of induction motors (physics/components/inductionmotor.h)
|
|
InductionMotor inductionMotor;
|
|
|
|
/*-dla wagonow*/
|
|
struct load_attributes
|
|
{
|
|
std::string name; // name of the cargo
|
|
float offset_min{0.f}; // offset applied to cargo model when load amount is 0
|
|
|
|
load_attributes() = default;
|
|
load_attributes(std::string const &Name, float const Offsetmin) : name(Name), offset_min(Offsetmin) {}
|
|
};
|
|
std::vector<load_attributes> LoadAttributes;
|
|
float MaxLoad = 0.f; /*masa w T lub ilosc w sztukach - ladownosc*/
|
|
double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/
|
|
float LoadSpeed = 0.f;
|
|
float UnLoadSpeed = 0.f; /*szybkosc na- i rozladunku jednostki/s*/
|
|
#ifdef EU07_USEOLDDOORCODE
|
|
int DoorOpenCtrl = 0;
|
|
int DoorCloseCtrl = 0; /*0: przez pasazera, 1: przez maszyniste, 2: samoczynne (zamykanie)*/
|
|
double DoorStayOpen = 0.0; /*jak dlugo otwarte w przypadku DoorCloseCtrl=2*/
|
|
bool DoorClosureWarning = false; /*czy jest ostrzeganie przed zamknieciem*/
|
|
bool DoorClosureWarningAuto = false; // departure signal plays automatically while door closing button is held down
|
|
double DoorOpenSpeed = 1.0;
|
|
double DoorCloseSpeed = 1.0; /*predkosc otwierania i zamykania w j.u. */
|
|
double DoorMaxShiftL = 0.5;
|
|
double DoorMaxShiftR = 0.5;
|
|
double DoorMaxPlugShift = 0.1; /*szerokosc otwarcia lub kat*/
|
|
int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/
|
|
float DoorCloseDelay{0.f}; // delay (in seconds) before the door begin closing, once conditions to close are met
|
|
double PlatformSpeed = 0.5; /*szybkosc stopnia*/
|
|
double PlatformMaxShift{0.0}; /*wysuniecie stopnia*/
|
|
int PlatformOpenMethod{2}; /*sposob animacji stopnia*/
|
|
#endif
|
|
double MirrorMaxShift{90.0};
|
|
double MirrorVelClose{5.0};
|
|
bool MirrorForbidden{false}; /*czy jest pozwolenie na otworzenie lusterek (przycisk)*/
|
|
bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/
|
|
bool ScndCtrlResistiveLock{false}; // the shunt controller can't be moved, up or down, while the master controller is at zero or on a resistive position, and drops to 0 when the master controller gets there (ScndCtrlResistiveLock=Yes in Cntrl.)
|
|
bool SpeedCtrl = false; /*czy jest tempomat*/
|
|
speed_control SpeedCtrlUnit; /*parametry tempomatu*/
|
|
double SpeedCtrlButtons[10]{30, 40, 50, 60, 70, 80, 90, 100, 110, 120}; /*przyciski prędkości*/
|
|
double SpeedCtrlDelay = 2; /*opoznienie dzialania tempomatu z wybieralna predkoscia*/
|
|
double SpeedCtrlValue = 0; /*wybrana predkosc jazdy na tempomacie*/
|
|
/*--sekcja zmiennych*/
|
|
/*--opis konkretnego egzemplarza taboru*/
|
|
TLocation Loc{0.0, 0.0, 0.0}; // pozycja pojazdów do wyznaczenia odległości pomiędzy sprzęgami
|
|
TRotation Rot{0.0, 0.0, 0.0};
|
|
glm::vec3 Front{};
|
|
std::string Name; /*nazwa wlasna*/
|
|
ByEnd<TCoupling> Couplers; // urzadzenia zderzno-sprzegowe, polaczenia miedzy wagonami
|
|
// the physical coupler model covers the vehicle: it's in the player's train or in one the player's train closes in on
|
|
// (vehicle_table::update_coupler_physics()); with couplerphysics all in eu07.ini every vehicle is covered
|
|
bool CouplerPhysics{false};
|
|
ByEnd<neighbour_data> Neighbours; // potential collision sources
|
|
bool EventFlag = false; /*!o true jesli cos nietypowego sie wydarzy*/
|
|
int SoundFlag = 0; /*!o patrz stale sound_ */
|
|
int AIFlag{0}; // HACK: events of interest for consist owner
|
|
double DistCounter = 0.0; /*! licznik kilometrow */
|
|
// the criteria of derailment (physics.derailment new), and the distance travelled since they were checked [m]
|
|
derailment::monitor derailment_monitor;
|
|
double derailment_distance = 0.0;
|
|
// physics.derailment monitor: the name of the track the criteria were last reported on (one report on a track), and
|
|
// how many reports there were
|
|
std::optional<std::string const *> derailment_reported;
|
|
int derailment_reports = 0;
|
|
odometer::reading Odometer; // total distance run, kept between the sessions (eu07/maszyna#72)
|
|
std::pair<double, double> EnergyMeter; // energy <drawn, returned> from grid [kWh]
|
|
double V = 0.0; // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
|
|
double Vel = 0.0; // moduł prędkości w [km/h], używany przez AI
|
|
double AccS = 0.0; // efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
|
|
double AccSVBased{}; // tangential acceleration calculated from velocity change
|
|
double AccN = 0.0; // przyspieszenie normalne w [m/s^2]
|
|
double AccVert = 0.0; // vertical acceleration
|
|
double nrot = 0.0; // predkosc obrotowa kol (obrotow na sekunde)
|
|
double nrot_eps = 0.0; // przyspieszenie kątowe kół (bez kierunku)
|
|
double WheelFlat = 0.0;
|
|
bool TruckHunting{true}; // enable/disable truck hunting calculation
|
|
/*! rotacja kol [obr/s]*/
|
|
double EnginePower = 0.0; /*! chwilowa moc silnikow*/
|
|
double dL = 0.0;
|
|
double Fb = 0.0;
|
|
double Ff = 0.0; /*przesuniecie, sila hamowania i tarcia*/
|
|
double FTrain = 0.0;
|
|
double FStand = 0.0; /*! sila pociagowa i oporow ruchu*/
|
|
double FTotal = 0.0; /*! calkowita sila dzialajaca na pojazd*/
|
|
double Ntotal = 0.0; /*!s siła nacisku klockow*/
|
|
bool SlippingWheels = false;
|
|
bool SandDose = false; /*! poslizg kol, sypanie piasku*/
|
|
bool SandDoseManual = false; /*piaskowanie reczne*/
|
|
bool SandDoseAuto = false; /*piaskowanie automatyczne*/
|
|
bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/
|
|
double Sand = 0.0; /*ilosc piasku*/
|
|
/*! przyrosty cisnienia w kroku czasowym*/
|
|
fuel_pump FuelPump;
|
|
oil_pump OilPump;
|
|
genset_device Genset; // of a dual-mode vehicle, fitted() only with GensetPower
|
|
// the source the traction circuit takes its voltage from (the traction selector of a dual-mode vehicle)
|
|
enum class traction_mode { catenary, genset };
|
|
traction_mode TractionMode{traction_mode::catenary};
|
|
bool GensetSelected() const { return TractionMode == traction_mode::genset; }
|
|
water_pump WaterPump;
|
|
water_heater WaterHeater;
|
|
bool WaterCircuitsLink{false}; // optional connection between water circuits
|
|
ByEnd<cooling_fan> MotorBlowers;
|
|
door_data Doors;
|
|
float DoorsOpenWithPermitAfter{-1.f}; // remote open if permit button is held for specified time. NOTE: separate from door data as its cab control thing
|
|
int DoorsPermitLightBlinking{0}; // when the doors permit signal light is blinking
|
|
|
|
/*
|
|
*/
|
|
bool RadioStopFlag = false; /*hamowanie nagle*/
|
|
int TUHEX_StageActual = 0; /*aktualny stopien tuhexa*/
|
|
bool TUHEX_ResChange = false; /*czy zmiana rezystancji hamowania ED - odwzbudzanie*/
|
|
bool TUHEX_Active = false; /*czy hamowanie ED wywołane z zewnątrz*/
|
|
// NapUdWsp: integer;
|
|
double ActFlowSpeed = 0.0; /*szybkosc stabilizatora*/
|
|
|
|
DamageSet DamageFlag; // the damage of the vehicle
|
|
int EngDmgFlag = 0; // kombinacja bitowa stalych usterek}
|
|
|
|
// EndSignalsFlag: byte; {ABu 060205: zmiany - koncowki: 1/16 - swiatla prz/tyl, 2/31 - blachy prz/tyl}
|
|
// HeadSignalsFlag: byte; {ABu 060205: zmiany - swiatla: 1/2/4 - przod, 16/32/63 - tyl}
|
|
TCommand CommandIn;
|
|
/*komenda przekazywana przez PutCommand*/
|
|
/*i wykonywana przez RunInternalCommand*/
|
|
|
|
TTrackShape RunningShape; /*geometria toru po ktorym jedzie pojazd*/
|
|
TTrackParam RunningTrack; /*parametry toru po ktorym jedzie pojazd*/
|
|
double OffsetTrackH = 0.0;
|
|
double OffsetTrackV = 0.0; /*przesuniecie poz. i pion. w/m osi toru*/
|
|
|
|
/*-zmienne dla lokomotyw*/
|
|
bool ReleaserEnabledOnlyAtNoPowerPos{false};
|
|
int MainCtrlPos = 0; /*polozenie glownego nastawnika*/
|
|
int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/
|
|
int LightsPos = 0; /*polozenie przelacznika wielopozycyjnego swiatel*/
|
|
int DirActive = 0; // czy lok. jest wlaczona i w ktorym kierunku: względem wybranej kabiny: -1 - do tylu, +1 - do przodu, 0 - wylaczona
|
|
int DirAbsolute = 0; // zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1)
|
|
int MainCtrlMaxDirChangePos{0}; // can't change reverser state with master controller set above this position
|
|
int CabActive = 0; // numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
|
|
int CabOccupied = 0; // numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController
|
|
bool CabMaster = false; // czy pojazd jest nadrzędny w składzie
|
|
// pullee mode ("jazda ciągniona", MaSzyna-EU07/maszyna#64): the vehicle is prepared for being hauled dead in a
|
|
// train, see PulleeModeSwitch()
|
|
bool PulleeMode{false};
|
|
inline bool IsCabMaster() const
|
|
{
|
|
return CabActive == CabOccupied && CabMaster;
|
|
} // czy aktualna kabina jest na pewno tą, z której można sterować
|
|
bool AutomaticCabActivation = true; // czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
|
|
int InactiveCabFlag = 0; // co sie dzieje przy dezaktywacji kabiny
|
|
bool InactiveCabPantsCheck = false; // niech DynamicObject sprawdzi pantografy
|
|
double LastSwitchingTime = 0.0; /*czas ostatniego przelaczania czegos*/
|
|
int WarningSignal = 0; // 0: nie trabi, 1,2,4: trabi
|
|
bool DepartureSignal = false; /*sygnal odjazdu*/
|
|
bool InsideConsist = false;
|
|
/*-zmienne dla lokomotywy elektrycznej*/
|
|
TTractionParam RunningTraction; /*parametry sieci trakcyjnej najblizej lokomotywy*/
|
|
double enrot = 0.0; // ilosc obrotow silnika
|
|
double Im = 0.0; // prad silnika
|
|
/*
|
|
// currently not used
|
|
double IHeating = 0.0;
|
|
double ITraction = 0.0;
|
|
*/
|
|
double Itot = 0.0; // prad calkowity
|
|
double TotalCurrent = 0.0;
|
|
// momenty
|
|
double Mm = 0.0;
|
|
double Mw = 0.0;
|
|
// sily napedne
|
|
double Fw = 0.0;
|
|
double Ft = 0.0;
|
|
// Ra: Im jest ujemny, jeśli lok jedzie w stronę sprzęgu 1
|
|
// a ujemne powinien być przy odwróconej polaryzacji sieci...
|
|
// w wielu miejscach jest używane abs(Im)
|
|
int Imin = 0;
|
|
int Imax = 0; /*prad przelaczania automatycznego rozruchu, prad bezpiecznika*/
|
|
double EngineVoltage = 0.0; // voltage supplied to engine
|
|
int MainCtrlActualPos = 0; /*wskaznik RList*/
|
|
int ScndCtrlActualPos = 0; /*wskaznik MotorParam*/
|
|
bool DelayCtrlFlag = false; // czy czekanie na 1. pozycji na załączenie?
|
|
bool AutoRelayFlag = false; /*mozna zmieniac jesli AutoRelayType=2*/
|
|
bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/
|
|
double LouvresOpenPressure{5.0}; // main reservoir pressure [bar] at which the pneumatic louvres of the motor fans open (ET22)
|
|
bool ResistorsFlag = false; /*!o jazda rezystorowa*/
|
|
double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/
|
|
bool s_CAtestebrake = false; // hunter-091012: zmienna dla testu ca
|
|
std::array<std::pair<double, double>, 4> PowerCircuits; // 24v, 110v, 3x400v and 3000v power circuits, voltage from local sources and current draw pairs
|
|
|
|
/*- zmienne dla lokomotyw z silnikami indukcyjnymi -*/
|
|
double eimic = 0; /*aktualna pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
|
double eimic_analog = 0; /*pozycja zadajnika analogowa*/
|
|
double eimic_real = 0; /*faktycznie uzywana pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
|
double eimic_step_progress{0.0}; // the part of the next UniCtrlValStep the controller has covered so far
|
|
double eim_localbrake = 0; /*nastawa hamowania dodatkowego pneumatycznego lokomotywy*/
|
|
int EIMCtrlType = 0; /*rodzaj wariantu zadajnika jazdy*/
|
|
bool SpeedCtrlTypeTime = false; /*czy tempomat sterowany czasowo*/
|
|
int SpeedCtrlAutoTurnOffFlag = 0; /*czy tempomat sam się wyłącza*/
|
|
bool EIMCtrlAdditionalZeros = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
|
|
bool EIMCtrlEmergency = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
|
|
bool EIMCtrlMainEmergency = false; /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/
|
|
double SpeedCtrlTimer = 0; /*zegar dzialania tempomatu z wybieralna predkoscia*/
|
|
double eimicSpeedCtrl = 1; /*pozycja sugerowana przez tempomat*/
|
|
double eimicSpeedCtrlIntegral = 0; /*calkowany blad ustawienia predkosci*/
|
|
double NewSpeed = 0; /*nowa predkosc do zadania*/
|
|
|
|
/*-zmienne dla drezyny*/
|
|
double PulseForce = 0.0; /*przylozona sila*/
|
|
double PulseForceTimer = 0.0;
|
|
int PulseForceCount = 0;
|
|
|
|
/*dla drezyny, silnika spalinowego i parowego*/
|
|
double eAngle = M_PI * 0.5;
|
|
|
|
/*-dla wagonow*/
|
|
float LoadAmount = 0.f; /*masa w T lub ilosc w sztukach - zaladowane*/
|
|
load_attributes LoadType;
|
|
std::string LoadQuantity; // jednostki miary
|
|
int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model
|
|
bool LoadTypeChange{false}; // indicates load type was changed
|
|
double LastLoadChangeTime = 0.0; // raz (roz)ładowania
|
|
#ifdef EU07_USEOLDDOORCODE
|
|
bool DoorBlocked = false; // Czy jest blokada drzwi
|
|
bool DoorLockEnabled{true};
|
|
bool DoorLeftOpened = false; // stan drzwi
|
|
double DoorLeftOpenTimer{-1.0}; // left door closing timer for automatic door type
|
|
bool DoorRightOpened = false;
|
|
double DoorRightOpenTimer{-1.0}; // right door closing timer for automatic door type
|
|
#endif
|
|
|
|
int DoubleTr = 1; // trakcja ukrotniona - przedni pojazd 'Winger 160304
|
|
basic_light CompartmentLights;
|
|
|
|
bool PhysicActivation = true;
|
|
// what the brake force (Fb) came from when the physics fell asleep (switch_physics()), for the test of ComputeTotalForce():
|
|
// asleep, a vehicle keeps the Fb and FStand of its last step, and a change of these wakes it
|
|
struct
|
|
{
|
|
double cylinder{0.0}; // BrakePress
|
|
double spring{0.0}; // brakes.spring.pressure
|
|
int manual{0}; // ManualBrakePos
|
|
double local{0.0}; // LocalBrakePosA
|
|
} sleep_brakes;
|
|
|
|
/*ABu: stale dla wyznaczania sil (i nie tylko) po optymalizacji*/
|
|
double FrictConst1 = 0.0;
|
|
double FrictConst2s = 0.0;
|
|
double FrictConst2d = 0.0;
|
|
double TotalMassxg = 0.0; /*TotalMass*g*/
|
|
|
|
int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać
|
|
ByEnd<int> iLights; // bity zapalonych świateł tutaj, żeby dało się liczyć pobór prądu
|
|
|
|
// Status nowszego hebelka od przyciemniania swiatel/swiatel dlugich
|
|
// 0 - swiatla wylaczone (opcja dziala tylko gdy w fiz zdefiniowano OffState w sekcji Switches; w przeciwnym wypadku pstryk startuje z wartoscia == 1
|
|
// 1 - swiatla normalne przyciemnione
|
|
// 2 - swiatla normalne
|
|
// 3 - swiatla dlugie przyciemnione
|
|
// 4 - swiatla dlugie normalne
|
|
|
|
struct dimPosition
|
|
{
|
|
bool isOff = false;
|
|
bool isDimmed = false;
|
|
bool isHighBeam = false;
|
|
};
|
|
|
|
// default positions
|
|
std::vector<dimPosition> dimPositions = {{false, false, false}, // 0 - Not dimmed
|
|
{false, true, false}}; // 1 - Dimmed
|
|
|
|
int modernDimmerPosition{0};
|
|
int modernDimmerDefaultPosition{0};
|
|
// bool modernContainOffPos{true};
|
|
bool enableModernDimmer{false};
|
|
bool modernDimmerCanCycle{false};
|
|
// the given dimmer position brought into the DimmerList, to its first or last entry; 0 for an empty list
|
|
int clampDimmerPosition(int Position) const;
|
|
// the entry of the current dimmer position, or a plain one (not off, not dimmed, no high beam) when the
|
|
// position is outside the DimmerList: the .fiz can give a short or an empty list, or a DefaultPos past its end
|
|
dimPosition currentDimPosition() const;
|
|
// moves the dimmer by Step positions within the DimmerList, around to its other end when it can cycle;
|
|
// a position outside the list is brought into it first. false when the dimmer doesn't move
|
|
bool stepDimmerPosition(int Step);
|
|
|
|
// Barwa reflektora
|
|
int refR{255}; // Czerwony
|
|
int refG{255}; // Zielony
|
|
int refB{255}; // Niebieski
|
|
|
|
double dimMultiplier{0.6f}; // mnoznik swiatel przyciemnionych
|
|
double normMultiplier{1.0f}; // mnoznik swiatel zwyklych
|
|
double highDimMultiplier{2.5f}; // mnoznik dlugich przyciemnionych
|
|
double highMultiplier{2.8f}; // mnoznik dlugich
|
|
|
|
plc::basic_controller m_plc;
|
|
|
|
int AIHintPantstate{0}; // suggested pantograph setup
|
|
// suggested pantograph setup in shunting (AI: ShuntPantstate=, eu07/maszyna#461), the bits as in Pantstate: 1 front,
|
|
// 2 rear, 3 both; 0 (the default) shunts with the pantographs handled as in train mode
|
|
int AIHintShuntPantstate{0};
|
|
bool AIHintPantUpIfIdle{true}; // whether raise both pantographs if idling for a while
|
|
double AIHintLocalBrakeAccFactor{1.05}; // suggested acceleration weight for local brake operation
|
|
|
|
Vehicle(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab);
|
|
// obsługa sprzęgów
|
|
static double CouplerDist(physics::Vehicle const *Left, physics::Vehicle const *Right);
|
|
static double Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2);
|
|
bool Attach(int ConnectNo, int ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true);
|
|
int DettachStatus(int ConnectNo);
|
|
int DettachStatus(VehicleEnd const ConnectNo)
|
|
{
|
|
return DettachStatus(NumberOf(ConnectNo));
|
|
}
|
|
bool Dettach(int ConnectNo);
|
|
// the same by the ends, where they are known to be ends
|
|
bool Attach(VehicleEnd const ConnectNo, VehicleEnd const ConnectToNr, physics::Vehicle *ConnectTo, CouplingSet CouplingType, bool Enforce = false, bool Audible = true)
|
|
{
|
|
return Attach(NumberOf(ConnectNo), NumberOf(ConnectToNr), ConnectTo, CouplingType, Enforce, Audible);
|
|
}
|
|
bool Dettach(VehicleEnd const ConnectNo)
|
|
{
|
|
return Dettach(NumberOf(ConnectNo));
|
|
}
|
|
void damage_coupler(VehicleEnd const End);
|
|
// repairs the broken coupler of the end, and the one of the vehicle it was coupled with, so they can be coupled
|
|
// again; the vehicles clear their coupler damage once neither of their couplers is broken. returns: whether there
|
|
// was a broken coupler to repair
|
|
bool repair_coupler(VehicleEnd const End);
|
|
void Derail(DerailReason Reason);
|
|
// the velocity of the vehicles coupled to this one changes by the Change along the axis of this one [m/s], as the
|
|
// legacy derailment changes the velocity of this one (physics.collisions new)
|
|
void change_train_velocity(double Change);
|
|
// physics.derailment new: the criteria of derailment.h over the step, which travelled the Distance [m]; monitor: what
|
|
// they would do, to the log
|
|
void check_derailment(TTrackShape const &Shape, TTrackParam const &Track, double Distance);
|
|
// the vehicle leaves the rails, as the criteria of derailment.h found
|
|
void derail(derailment::verdict const &Verdict, derailment::vehicle_state const &Vehicle, derailment::track_state const &Track, std::string const *TrackName = nullptr);
|
|
// height of the centre of gravity above the rail with the load [m]
|
|
double centre_of_gravity() const;
|
|
// the vehicle is back on the rails (resetconsist, SetDamage taking VehicleDamage::derailed off): not derailed any more, and the
|
|
// criteria of derailment start from scratch, so a later derailment goes the way its model has it
|
|
void rerail();
|
|
// what resetconsist does to a vehicle: no damage of any kind, the alarm chain released, back on the rails
|
|
void repair_damage();
|
|
// how the vehicle left the rails by the criteria of derailment.h: upright, or on its side. none for any other
|
|
// derailment, which stops it as the legacy model does (with physics.collisions new by a friction of its weight, the
|
|
// forces of the vehicles coupled to it acting on it)
|
|
derailment::outcome Derailed{derailment::outcome::none};
|
|
// physics.derailment new: how the vehicle left the rails, for the way it leaves the track (vehicle/derailmotion.h):
|
|
// what derailed it, the lateral acceleration of its body out of the curve then [m/s2] (negative into the curve, where a
|
|
// buckle bends the line the other way), and the side it was pulled off to by a coupling (1 the left of its front, -1
|
|
// the right; 0 the side the acceleration throws it to, from the track)
|
|
derail_motion::cause DerailCause{derail_motion::cause::off_rails};
|
|
double DerailAcceleration{0.0};
|
|
int DerailSide{0};
|
|
// the vehicle off the track, on the ground: begun and stepped by TDynamicObject, which knows the ground; its friction
|
|
// and the grade under it go into the forces of this one
|
|
derail_motion::body OffTrack;
|
|
// physics.derailment new: the vehicle derailed by the physical criteria, the end of the track or a collision has to
|
|
// leave the track and its motion on the ground isn't begun yet. never with physics.derailment monitor, old or off
|
|
bool leaves_track() const;
|
|
// physics.derailment new: a coupling of a vehicle off the track pulls this one off the rails sideways, to the Side
|
|
// (1 the left of its front, -1 the right), with the lateral acceleration [m/s2] of the pull on it
|
|
void pull_off(int Side, double Acceleration, std::string const &Why);
|
|
// physics.collisions new: what the vehicle is for the defaults of its crush and its buffers, the crush curve and the
|
|
// height of the buffers of an end, and how long the push of its ends held its wheels over the climbing limit
|
|
collision::vehicle_kind collision_kind() const;
|
|
collision::crush_curve crush_curve_at(VehicleEnd End) const;
|
|
double buffer_height_at(VehicleEnd End) const;
|
|
collision::pushed_monitor pushed_off_monitor;
|
|
// how the vehicle left the rails in a collision (physics.collisions new): overriding or pushed off, NONE otherwise
|
|
DerailReason CollisionDerail{NONE};
|
|
// physics.collisions monitor: how many crushes the log told of, of the hits of this vehicle on the others
|
|
int crush_reports{0};
|
|
// physics.collisions new: the hit of the end on the stop of its buffers, harder than the steel takes, crushes the
|
|
// weaker end and may let one vehicle climb onto the other one, see collision.h. returns: whether it did, and the
|
|
// velocities took the hit; the legacy collision takes the rest. physics.collisions monitor: the log tells what the
|
|
// crush of the whole hit would be, once for a hit, nothing changes, and it returns false
|
|
bool crush_hit(VehicleEnd End, double dt);
|
|
// the force pressing the ends pushes the vehicle off the track (physics.collisions new), the step travelled the
|
|
// Distance [m]: the flange climbs while the wheels roll on
|
|
void check_pushed_off(double dt, double Distance);
|
|
// the vehicle leaves the rails in a collision, the reason told in the log, and slides on as the criteria of
|
|
// derailment.h have it
|
|
void derail_in_collision(DerailReason Reason, std::string const &Why);
|
|
bool DirectionForward();
|
|
bool DirectionBackward(void); /*! kierunek ruchu*/
|
|
bool EIMDirectionChangeAllow(void) const;
|
|
inline double IsVehicleEIMBrakingFactor() const
|
|
{
|
|
return brakes.electrodynamic.on && ResistorsFlag ? 0.0 : inductionMotor.state.lineCurrent < 0 ? -1.0 : 1.0;
|
|
}
|
|
void BrakeLevelSet(double b);
|
|
bool BrakeLevelAdd(double b);
|
|
bool IncBrakeLevel(); // wersja na użytek AI
|
|
bool DecBrakeLevel();
|
|
bool ChangeCab(int direction);
|
|
bool CurrentSwitch(bool const State);
|
|
bool IsMotorOverloadRelayHighThresholdOn() const;
|
|
void UpdateBatteryVoltage(double dt);
|
|
double BatteryDrain(double dt, bool converteractive) const;
|
|
double BatteryDrainCharged(double dt, bool converteractive) const;
|
|
double BatteryDrainLow(double dt, bool converteractive) const;
|
|
double BatteryDrainSwitchedOff(double dt) const;
|
|
double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc,
|
|
TRotation const &NewRot); // oblicza przesuniecie pojazdu
|
|
double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot); // oblicza przesuniecie pojazdu - wersja zoptymalizowana
|
|
void compute_movement_(double const Deltatime);
|
|
double ShowEngineRotation(int VehN) const;
|
|
|
|
// Q *******************************************************************************************
|
|
double GetTrainsetVoltage(CouplingSet const couplings = Coupling::heating | Coupling::highVoltage) const;
|
|
double GetTrainsetHighVoltage() const;
|
|
// what turns the physics on, counted for the debug panel (Timer::switching_counter)
|
|
enum class wake_cause
|
|
{
|
|
other,
|
|
mainpipe, // air flowing in from a neighbour along the brake pipe
|
|
scndpipe, // along the main reservoir pipe
|
|
command,
|
|
speed, // the test of ComputeTotalForce(): the vehicle moves
|
|
acceleration, // accelerates
|
|
neighbour, // a neighbour moves or accelerates
|
|
rest // active cab, switching, ezt/dmu
|
|
};
|
|
bool switch_physics(bool const State, wake_cause const Cause = wake_cause::other);
|
|
// whether the vehicle accelerates, for the test which turns the physics off in vehicles standing still (ComputeTotalForce()).
|
|
// standing still, its acceleration is the pull of the slope and of the couplers, as the brakes and the resistance count only
|
|
// against a speed (FTotal); with Global.physics_sleepheld one held by them, the way ComputeMovement() keeps it standing, doesn't
|
|
bool accelerating() const;
|
|
// with Global.physics_sleepheld, wakes the physics of a vehicle a brake of which was set by hand: one held by its brakes sleeps
|
|
// with the brake force it had (accelerating())
|
|
void wake_for_brake();
|
|
// whether the brakes of a vehicle whose physics sleeps have changed since it fell asleep, see sleep_brakes
|
|
bool brakes_changed_asleep() const;
|
|
double LocalBrakeRatio(void) const;
|
|
double ManualBrakeRatio(void) const;
|
|
double PipeRatio(void) const; /*ile napelniac*/
|
|
double RealPipeRatio(void) const; /*jak szybko*/
|
|
double BrakeVP(void) const;
|
|
double EngineRPMRatio() const; // returns current engine revolutions as percentage of max engine revolutions, in range 0-1
|
|
double EngineIdleRPM() const;
|
|
double EngineMaxRPM() const;
|
|
|
|
/*! przesylanie komend sterujacych*/
|
|
bool SendCtrlToNext(VehicleCommand const CtrlCommand, double const ctrlvalue, double const dir, CouplingSet const Couplertype = Coupling::control);
|
|
bool SetInternalCommand(VehicleCommand const NewCommand, double NewValue1, double NewValue2, CouplingSet const Couplertype = Coupling::control);
|
|
bool RunCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype = Coupling::control, std::string_view Argument = {});
|
|
// the parts of RunCommand(), by the area of the commands
|
|
bool RunControllerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunRelaysCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunCabCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunBrakeCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunBrakeEquipmentCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunAuxiliariesCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunPumpsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunBlowersCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunPowerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
bool RunDoorsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet Couplertype, bool &OK);
|
|
void DoorPermitCommand(double CValue1, double CValue2);
|
|
void DoorRemoteCommand(bool Open, double CValue1, double CValue2);
|
|
bool RunLoadCommand(VehicleCommand const Command, double CValue1, double CValue2, std::string_view Argument, bool &OK);
|
|
bool RunInternalCommand();
|
|
void PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation);
|
|
bool CabActivisation(bool const Enforce = false);
|
|
bool CabDeactivisation(bool const Enforce = false);
|
|
bool CabActivisationAuto(bool const Enforce = false);
|
|
bool CabDeactivisationAuto(bool const Enforce = false);
|
|
|
|
/*! funkcje zwiekszajace/zmniejszajace nastawniki*/
|
|
/*! glowny nastawnik:*/
|
|
bool IncMainCtrl(int CtrlSpeed);
|
|
bool DecMainCtrl(int CtrlSpeed);
|
|
// the parts of IncMainCtrl() and DecMainCtrl() which depend on the kind of the engine
|
|
bool IncMainCtrlByEngine(int CtrlSpeed);
|
|
bool IncMainCtrlSeriesMotor(int CtrlSpeed);
|
|
bool DecMainCtrlByEngine(int CtrlSpeed);
|
|
bool DecMainCtrlSeriesMotor(int CtrlSpeed);
|
|
bool IsMainCtrlActualNoPowerPos() const; // whether the master controller is actually set to position which won't generate any extra power
|
|
bool IsMainCtrlNoPowerPos() const; // whether the master controller is set to position which won't generate any extra power
|
|
bool IsMainCtrlMaxPowerPos() const;
|
|
int MainCtrlNoPowerPos() const; // highest setting of master controller which won't cause engine to generate extra power
|
|
int MainCtrlActualPowerPos() const; // current actual setting of master controller, relative to the highest setting not generating extra power
|
|
int MainCtrlPowerPos() const; // current setting of master controller, relative to the highest setting not generating extra power
|
|
// positions the master controller of the EIMCtrlType 2 (Elf) has below its own position 0, the emergency brake (0 or 1)
|
|
int EIMCtrlEmergencyPositions() const;
|
|
// whether the master controller is in its emergency brake position (EIMCtrlType 2 with EIMCtrlMainEmergency)
|
|
bool IsMainCtrlEmergencyPos() const;
|
|
// the master controller position sent to the coupled vehicles ("MainCtrl"), the same with and without
|
|
// EIMCtrlMainEmergency: the Elf's positions without the emergency brake one, which goes as the full braking
|
|
int MainCtrlPosForCoupled() const;
|
|
// the master controller position of this vehicle for one received from a coupled vehicle ("MainCtrl")
|
|
int MainCtrlPosFromCoupled(int Position) const;
|
|
/*! pomocniczy nastawnik:*/
|
|
bool IncScndCtrl(int CtrlSpeed);
|
|
bool DecScndCtrl(int CtrlSpeed);
|
|
int GetVirtualScndPos() const;
|
|
// whether ScndCtrlResistiveLock keeps the shunt controller from being moved at the current master controller position
|
|
bool IsScndCtrlLockedByMainCtrl() const;
|
|
// ScndCtrlResistiveLock: the shunt controller drops to 0 once the master controller is at zero or on a resistive position, so it
|
|
// can't stay engaged there, locked in place (eu07/maszyna#402)
|
|
void ScndCtrlResistiveLockCheck();
|
|
// NOTE: with the cruise control, either end of the secondary controller, as before the split of the two (eu07/maszyna#69)
|
|
bool IsScndCtrlNoPowerPos() const;
|
|
bool IsScndCtrlMaxPowerPos() const;
|
|
|
|
bool AddPulseForce(int Multipler); /*dla drezyny*/
|
|
|
|
bool SandboxManual(bool const State, range_t const Notify = range_t::consist); /*wlacza/wylacza reczne sypanie piasku*/
|
|
bool SandboxAuto(bool const State, range_t const Notify = range_t::consist); /*wlacza/wylacza automatyczne sypanie piasku*/
|
|
bool Sandbox(bool const State, range_t const Notify = range_t::consist); /*wlacza/wylacza sypanie piasku*/
|
|
bool SandboxAutoAllow(bool const State); /*wlacza/wylacza zezwolenie na automatyczne sypanie piasku*/
|
|
|
|
/*! zbijanie czuwaka/SHP*/
|
|
void SecuritySystemReset(void);
|
|
void SecuritySystemCheck(double dt);
|
|
|
|
bool BatterySwitch(bool State, range_t const Notify = range_t::consist);
|
|
bool EpFuseSwitch(bool State);
|
|
bool SpringBrakeActivate(bool State);
|
|
bool SpringBrakeShutOff(bool State);
|
|
bool SpringBrakeRelease();
|
|
bool PulleeModeSwitch(bool const State);
|
|
|
|
/*! stopnie hamowania - hamulec zasadniczy*/
|
|
bool IncBrakeLevelOld(void);
|
|
bool DecBrakeLevelOld(void);
|
|
bool IncLocalBrakeLevel(float const CtrlSpeed);
|
|
bool DecLocalBrakeLevel(float const CtrlSpeed);
|
|
/*! ABu 010205: - skrajne polozenia ham. pomocniczego*/
|
|
bool IncManualBrakeLevel(int CtrlSpeed);
|
|
bool DecManualBrakeLevel(int CtrlSpeed);
|
|
/*! oddzielny nastawnik hamulca elektrodynamicznego (gdy SplitEDPneumaticBrake)*/
|
|
bool IncDynamicBrakeLevel(float const CtrlSpeed);
|
|
bool DecDynamicBrakeLevel(float const CtrlSpeed);
|
|
bool DynamicBrakeLevelSet(double Position);
|
|
double DynamicBrakeRatio(void) const;
|
|
bool DynamicBrakeAvailable(void) const; /*czy ED dostepny w aktualnym oknie predkosci Vh0..Vh1*/
|
|
bool DynamicBrakeSwitch(bool Switch);
|
|
bool RadiostopSwitch(bool Switch);
|
|
bool AlarmChainSwitch(bool const State);
|
|
bool AntiSlippingBrake(void);
|
|
bool BrakeReleaser(int state);
|
|
bool UniversalBrakeButton(int button, int state); /*uniwersalny przycisk hamulca*/
|
|
bool SwitchEPBrake(int state);
|
|
// whether the EP brake control of the cab has power: battery, the reverser out of neutral and the EP fuse on
|
|
bool EPBrakeControlPowered() const;
|
|
bool AntiSlippingButton(void); /*! reczny wlacznik urzadzen antyposlizgowych*/
|
|
|
|
/*funkcje dla ukladow pneumatycznych*/
|
|
bool IncBrakePress(double &brake, double PressLimit, double dp);
|
|
bool DecBrakePress(double &brake, double PressLimit, double dp);
|
|
bool BrakeDelaySwitch(int BDS); /*! przelaczanie nastawy opoznienia*/
|
|
bool IncBrakeMult(void); /*przelaczanie prozny/ladowny*/
|
|
bool DecBrakeMult(void);
|
|
/*pomocnicze funkcje dla ukladow pneumatycznych*/
|
|
void UpdateBrakePressure(double dt);
|
|
void UpdatePipePressure(double dt);
|
|
// the parts of UpdatePipePressure()
|
|
void UpdateLocalBrakeValve(double dt);
|
|
void UpdateMainValve(double dt);
|
|
double MainValveSupply();
|
|
double MainValveHandlePosition() const;
|
|
void UpdateEmergencyValve(double dt);
|
|
void UpdateDistributorSettings();
|
|
void UpdateEPBrake();
|
|
void CompressorCheck(double dt); /*wlacza, wylacza kompresor, laduje zbiornik*/
|
|
void UpdatePantVolume(double dt); // Ra
|
|
void PantPressureSwitchCheck();
|
|
void PantPressureSwitchTrip();
|
|
void UpdateScndPipePressure(double dt);
|
|
void UpdateSpringBrake(double dt);
|
|
double GetDVc(double dt);
|
|
int PipeCouplersSubsteps(double dt) const;
|
|
double GetScndDVc(double dt);
|
|
int ScndPipeCouplersSubsteps(double dt) const;
|
|
// the air exchange through the brake and main reservoir hoses, after the vehicles stepped
|
|
static void UpdatePipeCouplers(std::vector<physics::Vehicle *> const &Vehicles, double dt);
|
|
|
|
/*funkcje obliczajace sily*/
|
|
void ComputeConstans(void); // ABu: wczesniejsze wyznaczenie stalych dla liczenia sil
|
|
void ComputeMass(void);
|
|
void ComputeTotalForce(double dt);
|
|
double Adhesive(double staticfriction) const;
|
|
double TractionForce(double dt);
|
|
// the parts of TractionForce(), in the order it makes them
|
|
double UpdateEngineRevolutions(double dt, double &dtrans, double &dmoment);
|
|
double DieselElectricTargetRevolutions();
|
|
void UpdateVentilators(double dt);
|
|
void UpdateResistorBlowers(double dt);
|
|
double UpdateEnginePower();
|
|
void VoltageRelaysCheck();
|
|
void DumbTractionForce(double PosRatio);
|
|
void WheelsDrivenTractionForce(double dt);
|
|
void SeriesMotorTractionForce(double dt);
|
|
void SeriesMotorDynamicBrake(double dt);
|
|
void DieselEngineTractionForce(double dt, double dmoment, double dtrans);
|
|
void DieselElectricTractionForce(double tmp);
|
|
void DieselElectricShuntForce(double tmpV, double &tmp);
|
|
double DieselElectricDigitalForce(double tmpV, double &tempUmax, double &tempImax);
|
|
double DieselElectricForce(double tmpV, double LinePower, double Ratio, double HyperbolaPower) const;
|
|
void DieselElectricShuntPower(double tmp);
|
|
void DieselElectricGenerator(double tmp, double tempUmax, double tempImax);
|
|
void ShuntFieldRelaysCheck(double tmpV, double PosRatio, double tmp);
|
|
void ShuntFieldRelaysType2(double tmp);
|
|
void ShuntFieldRelaysType41(double tmpV);
|
|
void ShuntFieldRelaysType45();
|
|
void ShuntFieldRelaysType46();
|
|
void ShuntFieldRelaysType46Up();
|
|
void ShuntFieldRelaysType46Down();
|
|
void InductionMotorTractionForce(double dt);
|
|
void InductionMotorSpeedControl(double dt);
|
|
void SpeedControlByTime(double dt);
|
|
void SpeedControlByPosition(double dt);
|
|
void InductionMotorBrakeBlending(double ActiveInverters, double &PosRatio, double &tmp);
|
|
void InductionMotorDynamicBrakeFlag();
|
|
double InductionMotorBrakeRatio(double ActiveInverters, double edBCP);
|
|
void InductionMotorDrive(double dt);
|
|
void InductionMotorForceLimits();
|
|
void UpdateInverterFrequency();
|
|
void InductionMotorOff();
|
|
// the dynamic brake of a diesel-electric vehicle: the effort following the demand, the force it gives at the speed
|
|
void update_dieselelectric_dynamic_brake(double dt);
|
|
double dieselelectric_dynamic_brake_demand() const; // 0..1, the effort the driver asks for
|
|
double dieselelectric_dynamic_brake_limit() const; // [N] the force at full effort at the speed
|
|
void apply_dieselelectric_dynamic_brake(double dt); // the force in place of the drive's one, over the step dt
|
|
double dieselelectric_motor_current(double Moment) const; // the current of the motors giving the moment
|
|
double FrictionForce() const;
|
|
double BrakeForceR(double ratio, double velocity) const;
|
|
double BrakeForceP(double press, double velocity) const;
|
|
double BrakeForce(const TTrackParam &Track);
|
|
double CouplerForce(VehicleEnd const End, double dt);
|
|
void CouplerStretchCheck(VehicleEnd End, double CF, double dt);
|
|
// whether the coupling at the end is computed by the physical model: couplerphysics set in eu07.ini, and this
|
|
// vehicle or the one at the end covered by it (CouplerPhysics), or every vehicle with couplerphysics all
|
|
bool coupler_physics_at(VehicleEnd const End) const;
|
|
// the force of the coupling at the end by the physical model (couplerphysics in eu07.ini), see couplerphysics.h
|
|
double coupler_force_physical(VehicleEnd const End, double const dt);
|
|
// with the physical model: whether the vehicles at the end hit the stop of their springs at the last update and
|
|
// still close in on it, so that they collide; a hit hard enough breaks the coupling or crushes the buffers
|
|
bool coupler_stop_hit(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd);
|
|
// couples the automatic couplers of the end and of the other vehicle pressed against each other, unless the hit
|
|
// is too fast for them to catch
|
|
void automatic_coupling(VehicleEnd const End, physics::Vehicle &Other, VehicleEnd const OtherEnd);
|
|
void CollisionDetect(VehicleEnd const End, double const dt);
|
|
// closing speed of a collision [km/h] above which the vehicles involved may derail, adjusted for their mass ratio
|
|
static constexpr double SafeCollisionVelocity{15.0};
|
|
// closing speed [km/h] of the End of this vehicle and the OtherEnd of the other vehicle it touches, along the coupler
|
|
// axis: the sum of the speeds in a head-on collision, the difference in a rear-end one, negative when they part
|
|
double CollisionVelocity(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const;
|
|
// velocity [m/s] of this vehicle relative to the other vehicle it touches with its End and the OtherEnd of the
|
|
// other one, along this vehicle's axis
|
|
double CouplerVelocityDifference(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const;
|
|
// whether the automatic couplers at the End of this vehicle and the OtherEnd of the other one can catch each other on
|
|
// contact, rather than the vehicles colliding (with crash damage enabled, only at a closing speed which doesn't derail them)
|
|
bool AutomaticCouplingSafe(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const;
|
|
// whether the control coupling (multiple-unit control) can join the End of this vehicle and the OtherEnd of the other
|
|
// one: not between an electric and a diesel traction vehicle, unless both couplers name the same control system
|
|
// (ControlType). Vehicles without own traction (cars, control trailers) take any. Global.control_coupling_engine_check
|
|
// off allows it always (eu07/maszyna#520)
|
|
bool ControlCouplingAllowed(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd) const;
|
|
// the CouplingType to join the End of this vehicle and the OtherEnd of the other one with, without the control coupling
|
|
// when ControlCouplingAllowed() rules it out. a permanent coupling (of the vehicles of one unit) is kept whole
|
|
CouplingSet CompatibleCoupling(VehicleEnd const End, physics::Vehicle const &Other, VehicleEnd const OtherEnd, CouplingSet const CouplingType) const;
|
|
// the horns of the Signal (WarningSignal bits) which have the air or the voltage they need to sound
|
|
int SoundingHorns(int const Signal) const;
|
|
// whether the signal lamps of the main circuit (line contactors, ground relay, motor overload relays) can light:
|
|
// the pressure switch, when fitted, cuts the start off and puts them out, otherwise they go out once the brakes are applied
|
|
bool MainCircuitLampsEnabled() const
|
|
{
|
|
return false == protection.pressureSwitch && (protection.hasPressureSwitch || brakes.cylinderPressure < 1.0);
|
|
}
|
|
// whether an emergency brake application holds the line breaker open: the brake pipe below the pressure taken for one
|
|
// (EmergencyBrakeMainOffPressure) while the master controller is on a power position
|
|
bool EmergencyBrakeHoldsMainOff() const
|
|
{
|
|
return lineBreaker.emergencyOffPressure > 0.0 && brakePipe.pressure < lineBreaker.emergencyOffPressure && false == IsMainCtrlNoPowerPos();
|
|
}
|
|
// whether the lamp of the open line contactors is lit. on the electric locomotives it tells the start can be made, so
|
|
// it goes out with the start cut off; on the diesel-electric ones (the SU45 and SU46 family) it just tells the
|
|
// contactors are open, whatever opened them: the master controller at 0, or the pressure switch (eu07/maszyna#263)
|
|
bool LineContactorsLampLit() const
|
|
{
|
|
if (EngineType == TEngineType::DieselElectric)
|
|
{
|
|
return false == lineContactors.closed;
|
|
}
|
|
return false == lineContactors.closed && MainCircuitLampsEnabled();
|
|
}
|
|
// the vehicles the line breaker / engine start switch of this vehicle works, and its engine stopping on its own
|
|
// stops: the whole consist, or with JointEngineStart=No this vehicle alone (eu07/maszyna#80)
|
|
range_t MainSwitchRange() const
|
|
{
|
|
return lineBreaker.jointStart ? range_t::consist : range_t::local;
|
|
}
|
|
// whether the pneumatic louvres of the motor fans are still closed, the main reservoir short of the pressure that opens them
|
|
bool LouvresClosed() const
|
|
{
|
|
return air.mainReservoirPressure < LouvresOpenPressure;
|
|
}
|
|
// whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close
|
|
bool LineContactorsInterlockReleased() const;
|
|
// whether the line contactors wait for the converter of the vehicle, switched off with its local switch (converterlocal_sw).
|
|
// the AI driver doesn't leave it so: the converters of the other vehicles running, it would wait for the contactors forever
|
|
bool LineContactorsHeldByLocalConverterSwitch() const
|
|
{
|
|
return lineContactors.interlock == line_contactors_interlock::converter && false == converter.allowLocal;
|
|
}
|
|
// whether the vehicle has a driver's cab: it has the driver's brake valve (BrakeHandle in the Cntrl. section of the
|
|
// .fiz), which the wagons and most cars of the units without a cab don't (a few copy the Cntrl. section of the cab
|
|
// car, as the EN57 s car does). it's the vehicle type's, unlike the cab the scenario puts a driver in
|
|
bool HasDriverCab() const
|
|
{
|
|
return brakes.driverValveType != TBrakeHandle::NoHandle;
|
|
}
|
|
// whether the cab command opening the main circuit opens it where the only cab switch of the circuit is the button
|
|
// closing it: on a diesel that's the starter button, and the command is the one way to stop an engine whose fuel pump
|
|
// starts on its own (eu07/maszyna#427). the other vehicles with such a button keep ignoring the command
|
|
bool MainCircuitOpensWithStarterOnly() const
|
|
{
|
|
return EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric;
|
|
}
|
|
// whether the pumps a joint oil and fuel pump switch works, those not started automatically, are all switched on
|
|
bool OilFuelPumpsEnabled() const
|
|
{
|
|
auto const fuelmanual{FuelPump.start_type != start_t::automatic};
|
|
auto const oilmanual{OilPump.start_type != start_t::automatic};
|
|
return (fuelmanual || oilmanual) && (false == fuelmanual || FuelPump.is_enabled) && (false == oilmanual || OilPump.is_enabled);
|
|
}
|
|
// 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);
|
|
}
|
|
/*obrot kol uwzgledniajacy poslizg*/
|
|
double ComputeRotatingWheel(double WForce, double dt, double n) const;
|
|
|
|
/*--funkcje dla lokomotyw*/
|
|
bool WaterPumpBreakerSwitch(bool State, range_t const Notify = range_t::consist); // water pump breaker state toggle
|
|
bool WaterPumpSwitch(bool State, range_t const Notify = range_t::consist); // water pump state toggle
|
|
bool WaterPumpSwitchOff(bool State, range_t const Notify = range_t::consist); // water pump state toggle
|
|
bool WaterHeaterBreakerSwitch(bool State, range_t const Notify = range_t::consist); // water heater breaker state toggle
|
|
bool WaterHeaterSwitch(bool State, range_t const Notify = range_t::consist); // water heater state toggle
|
|
bool WaterCircuitsLinkSwitch(bool State, range_t const Notify = range_t::consist); // water circuits link state toggle
|
|
bool FuelPumpSwitch(bool State, range_t const Notify = range_t::consist); // fuel pump state toggle
|
|
bool FuelPumpSwitchOff(bool State, range_t const Notify = range_t::consist); // fuel pump state toggle
|
|
bool OilPumpSwitch(bool State, range_t const Notify = range_t::consist); // oil pump state toggle
|
|
bool OilPumpSwitchOff(bool State, range_t const Notify = range_t::consist); // oil pump state toggle
|
|
bool MotorBlowersSwitch(bool State, VehicleEnd const Side, range_t const Notify = range_t::consist); // traction motor fan state toggle
|
|
bool MotorBlowersSwitchOff(bool State, VehicleEnd const Side, range_t const Notify = range_t::consist); // traction motor fan state toggle
|
|
bool CompartmentLightsSwitch(bool State, range_t const Notify = range_t::consist); // compartment lights state toggle
|
|
bool CompartmentLightsSwitchOff(bool State, range_t const Notify = range_t::consist); // compartment lights state toggle
|
|
bool MainSwitch(bool const State, range_t const Notify = range_t::consist); /*! wylacznik glowny*/
|
|
void MainSwitch_(bool const State);
|
|
bool MainSwitchCheck() const; // checks conditions for closing the line breaker
|
|
bool ConverterSwitch(bool State, range_t const Notify = range_t::consist); /*! wl/wyl przetwornicy*/
|
|
bool CompressorSwitch(bool State, range_t const Notify = range_t::consist); /*! wl/wyl sprezarki*/
|
|
bool ChangeCompressorPreset(int const Change, range_t const Notify = range_t::consist);
|
|
bool HeatingSwitch(bool const State, range_t const Notify = range_t::consist);
|
|
void HeatingSwitch_(bool const State);
|
|
double EnginePowerSourceVoltage() const; // returns voltage of defined main engine power source
|
|
bool TractionModeSwitch(traction_mode const Mode, range_t const Notify = range_t::consist); // traction selector of a dual-mode vehicle
|
|
bool GensetSwitch(bool const State, range_t const Notify = range_t::consist); // genset start/stop request
|
|
double TractionSourceVoltage() const; // of the vehicle's own source the traction selector picks: the pantographs' or the genset's
|
|
double TractionSupplyVoltage() const; // what the traction circuit gets: the own source's, or the train's high voltage line's
|
|
double TractionSupplyMinVoltage() const; // below it the line breaker opens (undervoltage)
|
|
double GensetTractionPowerLimit() const; // [kW] at the wheels, the largest double unless running on the genset
|
|
double CatenaryCurrent() const; // [A] what the vehicle draws through its pantographs, if they touch the wire
|
|
// whether the main circuit feeds what runs on it (the converter, a compressor, the heating, the motor and resistor
|
|
// blowers, the traction motors): the line breaker closed, and where it closes ahead of the pantographs and holds
|
|
// without traction voltage (PantographsRequireMains) also the voltage there, at least the one the undervoltage
|
|
// trip takes. everywhere else it's the same as Mains
|
|
bool MainCircuitPowered() const;
|
|
|
|
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
|
void LowVoltagePowerCheck(double const Deltatime);
|
|
void MainsCheck(double const Deltatime);
|
|
void PowerCouplersCheck(double const Deltatime, Coupling const kind);
|
|
// the parts of PowerCouplersCheck()
|
|
double LocalPowerVoltage(Coupling kind);
|
|
void PowerCouplersVoltage(Coupling kind, double abslocalvoltage, bool localpowersource);
|
|
void PowerCouplersCurrent(Coupling kind, bool localpowersource);
|
|
double *PowerCircuitCurrent(Coupling kind);
|
|
void ConverterCheck(double const Timestep); // przetwornica
|
|
void HeatingCheck(double const Timestep);
|
|
void WaterPumpCheck(double const Timestep);
|
|
void WaterHeaterCheck(double const Timestep);
|
|
void FuelPumpCheck(double const Timestep);
|
|
void OilPumpCheck(double const Timestep);
|
|
void MotorBlowersCheck(double const Timestep);
|
|
// whether the circuit a traction motor blower runs off has power: the battery, the converter or the main circuit, by its start type
|
|
bool MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const;
|
|
void PantographsCheck(double const Timestep);
|
|
void GensetCheck(double const Deltatime);
|
|
void LightsCheck(double const Timestep);
|
|
bool FuseOn(range_t const Notify = range_t::consist); // bezpiecznik nadamiary
|
|
bool FuseFlagCheck(void) const; // sprawdzanie flagi nadmiarowego
|
|
void FuseOff(void); // wylaczenie nadmiarowego
|
|
bool UniversalResetButton(int const Button, range_t const Notify = range_t::consist);
|
|
bool RelayReset(int const Relays, range_t const Notify = range_t::consist); // resets specified relays
|
|
// the drive of the kind of engine of the vehicle (physics/components/drive.h)
|
|
TractionDrive const &Drive() const;
|
|
double ShowCurrent(int AmpN) const; // pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
|
|
double ShowCurrentP(int AmpN) const; // pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722
|
|
|
|
/*!o pokazuje bezwgl. wartosc obrotow na obrotomierzu jednego z 3 pojazdow*/
|
|
/*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/
|
|
/*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/
|
|
double v2n(void);
|
|
double Current(double n, double U);
|
|
// the parts of Current()
|
|
void UpdateSeriesMotorDynamicBrakeFlag();
|
|
double SeriesMotorCurrent(double n, double U, double R, double Mn) const;
|
|
double SeriesMotorDrivingCurrent(double n, double U, double Rz, double Mn, int SP) const;
|
|
void MotorFailuresCheck(double n);
|
|
double Momentum(double I) const;
|
|
double MomentumF(double I, double Iw, int SCP) const;
|
|
|
|
bool CutOffEngine(void); // odlaczenie udszkodzonych silnikow
|
|
/*funkcje automatycznego rozruchu np EN57*/
|
|
bool MaxCurrentSwitch(bool State, range_t const Notify = range_t::consist); // przelacznik pradu wysokiego rozruchu
|
|
bool MinCurrentSwitch(bool State); // przelacznik pradu automatycznego rozruchu
|
|
bool AutoRelaySwitch(bool State); // przelacznik automatycznego rozruchu
|
|
bool AutoRelayCheck(); // symulacja automatycznego rozruchu
|
|
// the parts of AutoRelayCheck()
|
|
bool AutoRelayShuntStep(bool ARFASI2);
|
|
bool AutoRelayMainStep(bool ARFASI);
|
|
bool AutoRelayMainUp(bool ARFASI);
|
|
bool AutoRelayMainNotchUp();
|
|
bool AutoRelayMainDown();
|
|
bool AutoRelayLineContactorsStep(bool motorconnectorsoff);
|
|
bool CamshaftRunDown();
|
|
bool CamshaftRunDownEMU();
|
|
bool MotorConnectorsCheck();
|
|
bool ResistorsFlagCheck(void) const; // sprawdzenie kontrolki oporow rozruchowych NBMX
|
|
|
|
bool OperatePantographsValve(operation_t const State, range_t const Notify = range_t::consist);
|
|
bool OperatePantographValve(VehicleEnd const End, operation_t const State, range_t const Notify = range_t::consist);
|
|
bool DropAllPantographs(bool const State, range_t const Notify = range_t::consist);
|
|
|
|
void CheckEIMIC(double dt); // sprawdzenie i zmiana nastawy zintegrowanego nastawnika jazdy/hamowania
|
|
// the parts of CheckEIMIC(), by the kind of the controller
|
|
void EIMICFromController(double brakeDemand, double offset, double multiplier);
|
|
void EIMICFromSteps(double dt);
|
|
void EIMICFromFourPositions(double dt);
|
|
void EIMICFromUniversalController(double dt, double brakeDemand);
|
|
void UniversalControllerTrainBrake();
|
|
void EIMICTraxxLocalBrake(double dt);
|
|
void EIMICLimit();
|
|
// whether the holding brake (brakes.holding) lets go at the power demand (eimic, above 0 when power is demanded) of this step of
|
|
// Dt seconds: once the demand has stayed above 0 for brakes.holding.releaseDelay. a demand of 0 or less starts the count again
|
|
bool UpdateStopBrakeRelease(double Demand, double Dt);
|
|
void CheckSpeedCtrl(double dt);
|
|
void SpeedCtrlRegulator(double dt, double accfactor);
|
|
// whether the cruise control has a switch of its own: the secondary controller doubles as its switch unless it
|
|
// shunts the field of the traction motors already, or there's none (the 6Dg, the ST45; eu07/maszyna#69)
|
|
bool IsSpeedCtrlSeparate() const;
|
|
// whether the cruise control is switched on: by its own switch, or by the secondary controller off its zero position
|
|
bool IsSpeedCtrlEngaged() const;
|
|
// the driver's switch of the cruise control: on, to hold the speed of the moment, or off. its own switch, or the
|
|
// secondary controller doubling as one (first position on, back to zero off); returns whether it did anything
|
|
bool SpeedCtrlSwitch(bool State);
|
|
void SpeedCtrlButton(int button);
|
|
void SpeedCtrlInc();
|
|
void SpeedCtrlDec();
|
|
bool SpeedCtrlPowerInc();
|
|
bool SpeedCtrlPowerDec();
|
|
|
|
/*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/
|
|
bool dizel_EngageSwitch(double state);
|
|
bool dizel_EngageChange(double dt);
|
|
bool dizel_AutoGearCheck(void);
|
|
bool dizel_GearShiftCheck(double VelUp, double VelDown);
|
|
bool dizel_GearShiftRequest(double VelUp, double VelDown);
|
|
void dizel_ClutchCheck();
|
|
void dizel_ClutchByController();
|
|
void dizel_ClutchByIntegratedController();
|
|
double dizel_fillcheck(int mcp, double dt);
|
|
double dizel_DigitalFill(double dt);
|
|
double dizel_GovernorFill(int mcp, double realfill) const;
|
|
double dizel_GovernorRevolutions(int mcp, double &realfill) const;
|
|
double dizel_Momentum(double Fill, double n, double dt);
|
|
void hydro_TCFillCheck(double dt);
|
|
void hydro_TCTorque();
|
|
double dizel_MomentumRetarder(double n, double dt); // moment hamowania retardera
|
|
void dizel_HeatSet(float const Value);
|
|
void dizel_Heat(double const dt);
|
|
bool dizel_StartupCheck();
|
|
bool dizel_Update(double dt);
|
|
|
|
/* funckje dla wagonow*/
|
|
bool AssignLoad(std::string const &Name, float const Amount = 0.f);
|
|
bool LoadingDone(double LSpeed, std::string_view Loadname);
|
|
bool PermitDoors(VehicleSide const Door, bool const State = true, range_t const Notify = range_t::consist);
|
|
void PermitDoors_(VehicleSide const Door, bool const State = true);
|
|
bool ChangeDoorPermitPreset(int const Change, range_t const Notify = range_t::consist);
|
|
bool PermitDoorStep(bool const State, range_t const Notify = range_t::consist);
|
|
bool ChangeDoorControlMode(bool const State, range_t const Notify = range_t::consist);
|
|
bool OperateDoors(VehicleSide const Door, bool const State, range_t const Notify = range_t::consist);
|
|
bool LockDoors(bool const State, range_t const Notify = range_t::consist);
|
|
bool signal_departure(bool const State, range_t const Notify = range_t::consist); // toggles departure warning
|
|
void update_doors(double const Deltatime); // door controller update
|
|
door_closure_t door_closure() const; // state of the door closure signalling of this vehicle
|
|
// whether the door closure lamp in the cab of this vehicle is lit: with DoorClosureSignal, for the given state of the
|
|
// consist; without it, for the lock of the vehicle's own doors, as the lamp always worked
|
|
bool door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const;
|
|
// the parts of update_doors()
|
|
// not const: the door they change is one of Doors.instances
|
|
void update_door_requests(basic_door &door, bool localopencontrol, bool remoteopencontrol, bool localclosecontrol, bool remoteclosecontrol);
|
|
void move_door(basic_door &door, double Deltatime);
|
|
bool door_open_request(basic_door const &door, bool localopencontrol, bool remoteopencontrol) const;
|
|
bool door_close_request(basic_door const &door, bool localclosecontrol, bool remoteclosecontrol) const;
|
|
bool doors_powered() const;
|
|
bool door_step_folding(basic_door const &door) const;
|
|
float door_open_duration(basic_door const &door, bool localopencontrol, bool remoteopencontrol) const;
|
|
void update_door_timers(double Deltatime);
|
|
|
|
/* funkcje dla samochodow*/
|
|
bool ChangeOffsetH(double DeltaOffset);
|
|
|
|
/*funkcje ladujace pliki opisujace pojazd*/
|
|
bool LoadFIZ(std::string const &chkpath); // Q 20160717 bool LoadChkFile(std::string chkpath);
|
|
bool LoadFIZ_Text(std::string const &Text); // the same, from text in the .fiz format
|
|
bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
|
|
// the parts of CheckLocomotiveParameters()
|
|
void CreateBrakeValve();
|
|
void CreateBrakeHandles();
|
|
void CreateBrakePipes();
|
|
double InitialScndPipePress(double HosePressure) const;
|
|
void SetReadyToDepart();
|
|
void SetBraked();
|
|
std::string EngineDescription(int what) const;
|
|
// the cab interior light the light preset at given position (1-based, as LightsPos) sets, if it sets one
|
|
std::optional<lights_preset_cablight> LightsPresetCabLight(int Position) const;
|
|
|
|
private:
|
|
bool LoadFIZ_Parse(cParser &Parser); // reads the definition from either of the above
|
|
// the parts of LoadFIZ_Parse(), for a line of the definition
|
|
bool LoadFIZ_TableEnd(std::string const &inputline) const;
|
|
bool LoadFIZ_Section(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines);
|
|
bool LoadFIZ_TableSection(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines);
|
|
void LoadFIZ_TableRow(std::string const &inputline);
|
|
void LoadFIZ_Param(std::string const &line);
|
|
void LoadFIZ_Load(std::string const &line);
|
|
void LoadFIZ_Dimensions(std::string const &line);
|
|
void LoadFIZ_Wheels(std::string const &line);
|
|
void LoadFIZ_Brake(std::string const &line);
|
|
void LoadFIZ_Doors(std::string const &line);
|
|
void LoadFIZ_BuffCoupl(std::string const &line, int const Index);
|
|
void LoadFIZ_TurboPos(std::string const &line);
|
|
void LoadFIZ_Cntrl(std::string const &line);
|
|
void LoadFIZ_CntrlBrakes(std::string const &line);
|
|
void LoadFIZ_CntrlTrainBrake(std::string const &line);
|
|
void LoadFIZ_CntrlAntiSlipBrake(std::string_view asb);
|
|
void LoadFIZ_CntrlControllers(std::string const &line);
|
|
void LoadFIZ_CntrlStarts(std::string const &line);
|
|
void LoadFIZ_Blending(std::string const &line);
|
|
void LoadFIZ_DCEMUED(std::string const &line);
|
|
void LoadFIZ_SpringBrake(std::string const &line);
|
|
void LoadFIZ_Light(std::string const &line);
|
|
void LoadFIZ_Headlights(std::string const &Line);
|
|
void LoadFIZ_Clima(std::string const &line);
|
|
void LoadFIZ_Power(std::string const &Line);
|
|
void LoadFIZ_Genset(std::string const &Line);
|
|
void LoadFIZ_SpeedControl(std::string const &Line);
|
|
void LoadFIZ_Engine(std::string const &Input);
|
|
void LoadFIZ_EngineDiesel(std::string const &Input);
|
|
void LoadFIZ_EngineDieselElectric(std::string const &Input);
|
|
void LoadFIZ_EngineInductionMotor(std::string const &Input);
|
|
void LoadFIZ_EngineDieselShared(std::string const &Input);
|
|
void LoadFIZ_Switches(std::string const &Input);
|
|
void LoadFIZ_MotorParamTable(std::string const &Input);
|
|
void LoadFIZ_Circuit(std::string const &Input);
|
|
void LoadFIZ_AI(std::string const &Input);
|
|
void LoadFIZ_RList(std::string const &Input);
|
|
void LoadFIZ_UCList(std::string const &Input);
|
|
void LoadFIZ_DieselElectricDynamicBrake(std::string const &Input);
|
|
void LoadFIZ_DList(std::string const &Input);
|
|
void LoadFIZ_FFList(std::string const &Input);
|
|
void LoadFIZ_FFEDList(std::string const &Input);
|
|
void LoadFIZ_WiperList(std::string const &Input);
|
|
void LoadFIZ_LightsList(std::string const &Input);
|
|
void LoadFIZ_DimmerList(std::string const &Input);
|
|
void LoadFIZ_CompressorList(std::string const &Input);
|
|
void LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Input);
|
|
TPowerType LoadFIZ_PowerDecode(std::string const &Power) const;
|
|
TPowerSource LoadFIZ_SourceDecode(std::string const &Source) const;
|
|
TEngineType LoadFIZ_EngineDecode(std::string const &Engine) const;
|
|
bool readMPT0(std::string const &line);
|
|
bool readMPT(std::string const &line); // Q 20160717
|
|
bool readMPTElectricSeries(std::string const &line);
|
|
bool readMPTDieselElectric(std::string const &line);
|
|
bool readMPTDieselEngine(std::string const &line);
|
|
bool readBPT(/*int const ln,*/ std::string const &line); // Q 20160721
|
|
bool readRList(std::string const &Input);
|
|
bool readUCList(std::string const &Input);
|
|
bool readDList(std::string const &line);
|
|
bool readDMList(std::string const &line);
|
|
bool readV2NMAXList(std::string const &line);
|
|
bool readHTCList(std::string const &line);
|
|
bool readPmaxList(std::string const &line);
|
|
bool readFFList(std::string const &line);
|
|
bool readFFEDList(std::string const &line);
|
|
bool readWWList(std::string const &line);
|
|
bool readWiperList(std::string const &line);
|
|
bool readDimmerList(std::string const &line);
|
|
bool readLightsList(std::string const &Input);
|
|
bool readCompressorList(std::string const &Input);
|
|
void BrakeValveDecode(std::string const &s); // Q 20160719
|
|
void BrakeSubsystemDecode(); // Q 20160719
|
|
};
|
|
|
|
} // namespace physics
|
|
|
|
// double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
|
|
|
|
namespace simulation
|
|
{
|
|
|
|
using weights_table = std::unordered_map<std::string, float>;
|
|
|
|
extern weights_table Weights;
|
|
|
|
} // namespace simulation
|