From 19f884cdbb31e704e52d6efad4fc14ca9928d8f8 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Fri, 27 Nov 2026 18:53:06 +0100 Subject: [PATCH] refactor(physics): the vehicle vocabulary in physics/vehicletypes.h; DynObj.h and Driver.h no longer include mover.h DynObj.h included physics/mover.h, so nearly every file of the simulator compiled the whole vehicle physics (TMoverParameters and the brakes) though most of them only name a vehicle end, a coupling or a light. - physics/vehicletypes.h: the enums, flags and small structures the rest of the simulator passes around (end, side, coupling, light, sound, activation, train_type, TEngineType, TBrakeSystem..., TLocation, TTrackShape, neighbour_data), moved from mover.h as they were. mover.h includes it. - DynObj.h and Driver.h include vehicletypes.h; TMoverParameters is forward declared (utilities/Classes.h). Their inline accessors that read the mover (NextConnected(), GetVelocity(), is_emu(), DirectionalVel()...) are defined in DynObj.cpp and Driver.cpp. - the files that use the mover include physics/mover.h themselves. Now 140 of the 730 objects of the build depend on mover.h and brakes.h, about 80 of them unit tests. No change in behaviour: 1142/1142 tests, golden traces exact against staging 62f7a29b. --- application/application.cpp | 1 + application/consistviews.cpp | 1 + application/driverhints.cpp | 1 + application/drivermode.cpp | 1 + application/driveruipanels.cpp | 1 + application/editormode.cpp | 1 + application/editormodeselftestscene.cpp | 1 + audio/sound.cpp | 1 + input/drivermouseinput.cpp | 1 + input/messaging.cpp | 1 + physics/mover.h | 806 +--------------------- physics/vehicletypes.h | 822 +++++++++++++++++++++++ rendering/common/locallights.cpp | 1 + rendering/common/localshadows.cpp | 1 + rendering/common/scenewalk.cpp | 1 + rendering/common/screenreflections.cpp | 1 + rendering/common/windscreenwater.cpp | 1 + rendering/lightarray.cpp | 1 + rendering/opengl46/opengl46renderer.cpp | 1 + rendering/particles.cpp | 1 + rendering/vulkan14/vulkan14frame.cpp | 1 + scene/scene.cpp | 1 + scripting/lua.cpp | 1 + simulation/blackboxrecorder.cpp | 1 + simulation/simulation.cpp | 1 + simulation/simulationstateserializer.cpp | 1 + utilities/motiontelemetry.cpp | 1 + utilities/uart.cpp | 1 + vehicle/Driver.cpp | 19 + vehicle/Driver.h | 27 +- vehicle/DynObj.cpp | 17 + vehicle/DynObj.h | 34 +- vehicle/Train.cpp | 1 + vehicle/crewchange.cpp | 1 + widgets/trainingcard.cpp | 1 + widgets/vehicleparams.cpp | 1 + world/Event.cpp | 1 + world/Road.cpp | 1 + world/RoadPoint.cpp | 1 + world/Track.cpp | 1 + world/TrackBuckle.cpp | 1 + world/TrkFoll.cpp | 1 + world/station.cpp | 1 + 43 files changed, 918 insertions(+), 844 deletions(-) create mode 100644 physics/vehicletypes.h diff --git a/application/application.cpp b/application/application.cpp index 563cba5c1..8181c014e 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -47,6 +47,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "utilities/translation.h" +#include "physics/mover.h" #if WITH_DISCORD_RPC #include "ref/discord-rpc/include/discord_rpc.h" diff --git a/application/consistviews.cpp b/application/consistviews.cpp index 49815f6e8..ca9d979dd 100644 --- a/application/consistviews.cpp +++ b/application/consistviews.cpp @@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Camera.h" #include "vehicle/Driver.h" #include "vehicle/DynObj.h" +#include "physics/mover.h" namespace { diff --git a/application/driverhints.cpp b/application/driverhints.cpp index cd1967aa2..3851b91e7 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Driver.h" #include "utilities/Globals.h" #include "utilities/utilities.h" +#include "physics/mover.h" void TController::hint( driver_hint const Value, hintpredicate const Predicate, float const Predicateparameter ) { diff --git a/application/drivermode.cpp b/application/drivermode.cpp index e76baec1c..20df43a3b 100644 --- a/application/drivermode.cpp +++ b/application/drivermode.cpp @@ -31,6 +31,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "rendering/renderer.h" #include "utilities/Logs.h" +#include "physics/mover.h" #include diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index f577573c9..fd77d352b 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -34,6 +34,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "widgets/vehicleparams.h" #include "utilities/U8.h" +#include "physics/mover.h" #define DRIVER_HINT_CONTENT #include "application/driverhints.h" diff --git a/application/editormode.cpp b/application/editormode.cpp index 2cb34401c..4d858e325 100644 --- a/application/editormode.cpp +++ b/application/editormode.cpp @@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "application/editorgestures.h" #include "scene/scenenodegroups.h" #include "application/editoruilayer.h" +#include "physics/mover.h" #ifndef _WIN32 #include #include diff --git a/application/editormodeselftestscene.cpp b/application/editormodeselftestscene.cpp index df5d62622..f9315e9e5 100644 --- a/application/editormodeselftestscene.cpp +++ b/application/editormodeselftestscene.cpp @@ -47,6 +47,7 @@ http://mozilla.org/MPL/2.0/. #include #include #include "application/editormodeselftest.h" +#include "physics/mover.h" editor_mode::selftest_result editor_mode::selftest_scene(std::string const &command, std::istringstream &words) { diff --git a/audio/sound.cpp b/audio/sound.cpp index 426ee3cc4..6e5b8ab28 100644 --- a/audio/sound.cpp +++ b/audio/sound.cpp @@ -17,6 +17,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "simulation/simulation.h" #include "audio/audiorenderer_extra.h" +#include "physics/mover.h" // constructors sound_source::sound_source( sound_placement const Placement, float const Range ) : diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index 47105ac22..35d8fbffe 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -21,6 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "application/uilayer.h" #include "utilities/Logs.h" #include "utilities/utilities.h" +#include "physics/mover.h" auto const EU07_CONTROLLER_MOUSESLIDERSIZE{ 0.6 }; diff --git a/input/messaging.cpp b/input/messaging.cpp index 66a39e7d5..f91da91bd 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -19,6 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Driver.h" #include "world/mtable.h" #include "utilities/Logs.h" +#include "physics/mover.h" #ifdef _WIN32 extern "C" diff --git a/physics/mover.h b/physics/mover.h index 0e2211afe..f20b72414 100644 --- a/physics/mover.h +++ b/physics/mover.h @@ -21,6 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "scripting/ladderlogic.h" #include "vehicle/derailmotion.h" #include "vehicle/odometerreading.h" +#include "physics/vehicletypes.h" class cParser; /* @@ -87,804 +88,6 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona ... */ - -/// Global counter incremented when a string-to-numeric conversion fails during config parsing. -extern int ConversionError; - -/// Static friction coefficient for steel-on-steel contact (used for adhesion at standstill). -const double Steel2Steel_friction = 0.15; // tarcie statyczne -/// Earth gravitational acceleration [m/s^2]. -const double g = 9.81; // przyspieszenie ziemskie -/// Sand consumption rate when sanding is active [kg/s]. -const double SandSpeed = 0.1; // ile kg/s} -/// 2*pi shortcut. -const double Pirazy2 = 6.2831853071794f; - -//-- var, const, procedure --------------------------------------------------- -/// Truthy alias used by CheckLocomotiveParameters() to ignore a check failure. -static bool const Go = true; -/// Falsy alias used by CheckLocomotiveParameters() to abort on a check failure. -static bool const Hold = false; /*dla CheckLocomotiveParameters*/ -/// Maximum number of resistor / scheme entries for electric motor traction. -static int const ResArraySize = 64; /*dla silnikow elektrycznych*/ -/// Maximum number of motor-parameter table entries (gear stages). -static int const MotorParametersArraySize = 10; -/// Maximum number of pantograph current collectors per vehicle. -static int const maxcc = 4; /*max. ilosc odbierakow pradu*/ -// static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca pomocniczego*/ -// static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ -/// Number of positions on the manual (parking) brake handle. -static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/ -/// Number of positions on the lights selector switch. -static int const LightsSwitchPosNo = 16; -/// Maximum number of positions of the universal (auxiliary) controller. -static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/ - -/*uszkodzenia toru*/ -/// Track damage flag: rail wear. -static int const dtrack_railwear = 2; -/// Track damage flag: free / loose rail. -static int const dtrack_freerail = 4; -/// Track damage flag: thin (worn-out) rail. -static int const dtrack_thinrail = 8; -/// Track damage flag: bent rail. -static int const dtrack_railbend = 16; -/// Track damage flag: vegetation overgrowth. -static int const dtrack_plants = 32; -/// Track damage flag: track impassable for movement. -static int const dtrack_nomove = 64; -/// Track damage flag: rails missing entirely. -static int const dtrack_norail = 128; - -/*uszkodzenia taboru*/ -/// Vehicle damage flag: thin wheel (locomotives). -static int const dtrain_thinwheel = 1; /*dla lokomotyw*/ -/// Vehicle damage flag: shifted load (wagons). -static int const dtrain_loadshift = 1; /*dla wagonow*/ -/// Vehicle damage flag: wheel wear. -static int const dtrain_wheelwear = 2; -/// Vehicle damage flag: bearing failure. -static int const dtrain_bearing = 4; -/// Vehicle damage flag: coupling damage. -static int const dtrain_coupling = 8; -/// Vehicle damage flag: ventilator failure (electric locomotive). -static int const dtrain_ventilator = 16; /*dla lokomotywy el.*/ -/// Vehicle damage flag: load damage (wagons). -static int const dtrain_loaddamage = 16; /*dla wagonow*/ -/// Vehicle damage flag: engine failure (locomotives). -static int const dtrain_engine = 32; /*dla lokomotyw*/ -/// Vehicle damage flag: load destroyed (wagons). -static int const dtrain_loaddestroyed = 32; /*dla wagonow*/ -/// Vehicle damage flag: axle damage. -static int const dtrain_axle = 64; -/// Vehicle damage flag: derailment. -static int const dtrain_out = 128; /*wykolejenie*/ -/// Vehicle damage flag: broken pantograph. -static int const dtrain_pantograph = 256; /*polamanie pantografu*/ - -/// Reason for a derailment event. -enum DerailReason -{ - /// No derailment. - NONE = 0, - /// End of track reached. - END_OF_TRACK = 1, // Ra: powód wykolejenia: brak szyn - /// Speed too high for curve (overturn). - TOO_HIGH_SPEED = 2, // Ra: powód wykolejenia: przewrócony na łuku - /// Track gauge does not match wheelset gauge. - GAUGE_MISMATCH = 3, // Ra: powód wykolejenia: za szeroki tor - /// Track type incompatible with this vehicle. - WRONG_TRACK_TYPE = 4, // Ra: powód wykolejenia: nieodpowiednia trajektoria - /// Collision with another vehicle. - COLLISION = 5, // powód wykolejenia: zderzenie z innym pojazdem - /// Trailing through a switch with a movable nose set the other way. - TRAILED_SWITCH = 6, // powód wykolejenia: rozprucie rozjazdu z ruchomym dziobem - /// Climbed onto the vehicle it hit, its end crushed (physics.collisions new). - COLLISION_OVERRIDE = 7, // najechanie - /// Pushed off the track by the force pressing its end (physics.collisions new). - COLLISION_PUSHED_OFF = 8, // wyciśnięcie z toru -}; - -/*wagi prawdopodobienstwa dla funkcji FuzzyLogic*/ -/// Fuzzy-logic probability weight: electric engine general problem. -#define p_elengproblem (1e-02) -/// Fuzzy-logic probability weight: electric engine damage. -#define p_elengdamage (1e-01) -/// Fuzzy-logic probability weight: coupler damage. -#define p_coupldmg (2e-03) -/// Fuzzy-logic probability weight: derailment. -#define p_derail (1e-03) -/// Fuzzy-logic probability weight: acceleration-related event. -#define p_accn (1e-01) -/// Fuzzy-logic probability weight: damage caused by wheel slip. -#define p_slippdmg (1e-03) - -/*typ sprzegu*/ -/// Coupling type: virtual — vehicles share a track and are aware of each other. -static int const ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie -/// Coupling type: physical coupler. -static int const ctrain_coupler = 1; // sprzeg fizyczny -/// Coupling type: pneumatic brake hose. -static int const ctrain_pneumatic = 2; // przewody hamulcowe -/// Coupling type: control cable (multiple-unit). -static int const ctrain_controll = 4; // przewody sterujące (ukrotnienie) -/// Coupling type: high-voltage power cable. -static int const ctrain_power = 8; // przewody zasilające (WN) -/// Coupling type: passenger gangway. -static int const ctrain_passenger = 16; // mostek przejściowy -/// Coupling type: secondary 8 atm pneumatic line (yellow, main air). -static int const ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem) -/// Coupling type: high-voltage train heating cable. -static int const ctrain_heating = 64; // przewody ogrzewania WN -/// Coupling type: permanent (inter-section) — not separable during ordinary shunting; encoded as negative in config files. -static int const ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna -/// Vehicle ends — front or rear (mutually exclusive). -enum end -{ - /// Front end. - front = 0, - /// Rear end. - rear = 1 -}; - -/// Vehicle sides — right or left (mutually exclusive). -enum side -{ - /// Right side. - right = 0, - /// Left side. - left = 1 -}; - -/// Bit flags representing the kind of physical/logical connections in a coupling. Combinable. -enum coupling -{ - /// No coupling (virtual / not connected). - faux = 0x0, - /// Mechanical coupler. - coupler = 0x1, - /// Pneumatic brake hose (PG). - brakehose = 0x2, - /// Control cable (multiple-unit). - control = 0x4, - /// High-voltage cable (traction supply). - highvoltage = 0x8, - /// Passenger gangway. - gangway = 0x10, - /// Main air (8 atm) line — secondary pneumatic supply. - mainhose = 0x20, - /// Train heating cable. - heating = 0x40, - /// Permanent (non-separable) coupling. - permanent = 0x80, - /// 24 V auxiliary power cable. - power24v = 0x100, - /// 110 V auxiliary power cable. - power110v = 0x200, - /// 3-phase 400 V auxiliary power cable. - power3x400v = 0x400, - // uic = 0x1000, -}; -/// Range of effect for a control command (mutually exclusive). -enum class range_t -{ - /// Affects only this vehicle. - local, - /// Affects this multiple-unit (vehicles permanently coupled into a unit). - unit, - /// Affects the entire consist. - consist -}; -/// State of the door closure signalling (SOD) of a vehicle or a consist, ordered from the least to the most -/// severe: the state of a consist is the most severe state of its vehicles. -enum class door_closure_t -{ - /// No doors worked by the crew: the vehicle doesn't take part in the signalling. - none, - /// All doors closed and locked: they can't be opened. - locked, - /// All doors closed, but released: a permit is given, or no lock holds them shut. - released, - /// A door is open, or not fully closed yet. - open -}; -/// Whether the door closure signalling lamp is lit: steadily for locked doors, in the lit phase of the -/// blinking for released ones, never with a door open or with no doors signalled. -bool door_closure_lamp(door_closure_t const State, bool const BlinkLit); -/// Possible settings for an enable/disable input pair (mutually exclusive). -enum class operation_t -{ - /// No input. - none = 0, - /// Enable input held active. - enable, - /// Disable input held active. - disable, - /// Enable button press transition (rising edge). - enable_on, - /// Enable button release transition. - enable_off, - /// Disable button press transition. - disable_on, - /// Disable button release transition. - disable_off, -}; -/// What else the line contactors of a vehicle need before they can close (LineContactorsInterlock in the Cntrl. section). -enum class line_contactors_interlock -{ - /// Nothing more, the legacy behaviour. - none, - /// The converter of the vehicle itself running, where it drives the traction motor fans (ET42). - converter, - /// The traction motor blowers of the vehicle running. - motor_blowers -}; -/// Auto-start method for ancillary devices (mutually exclusive). -enum class start_t -{ - /// Device cannot be started. - disabled, - /// Manual start only. - manual, - /// Starts automatically. - automatic, - /// Manual start with automatic fallback. - manualwithautofallback, - /// Driven by the converter state. - converter, - /// Driven by the battery state. - battery, - /// Driven by direction selector state. - direction -}; -/// Bit flags representing vehicle external lights (positions and types). Combinable. -enum light -{ - - /// Headlight, left. - headlight_left = 1 << 0, - /// Red marker, left. - redmarker_left = 1 << 1, - /// Headlight, upper centre. - headlight_upper = 1 << 2, - // TBD, TODO: redmarker_upper support? - /// Headlight, right. - headlight_right = 1 << 4, - /// Red marker, right. - redmarker_right = 1 << 5, - /// Rear-end markers (combined). - rearendsignals = 1 << 6, - /// Auxiliary light, left (e.g. ditch light). - auxiliary_left = 1 << 7, - /// Auxiliary light, right. - auxiliary_right = 1 << 8, - /// High-beam headlight, left. - highbeamlight_left = 1 << 9, - /// High-beam headlight, right. - highbeamlight_right = 1 << 10 -}; - -/// The cab interior light a position of the light preset selector sets (eu07/maszyna#529). -struct lights_preset_cablight -{ - /// Bits of the optional third column of a LightsList row. - enum flag - { - /// The cab light is on. - light_on = 1 << 0, - /// The cab light is dimmed. - light_dimmed = 1 << 1 - }; - bool light{false}; - bool dim{false}; -}; - -/// Door operation method (who controls them and how) — mutually exclusive. -enum control_t -{ - /// Local; passengers operate manually, doors open/close for the duration of loading. - passenger, // local, opened/closed for duration of loading - /// Remote; driver-operated. - driver, // remote, operated by the driver - /// Local autonomous; close when the vehicle moves and/or after a timeout. - autonomous, // local, closed when vehicle moves and/or after timeout - /// Remote; conductor-operated. - conductor, // remote, operated by the conductor - /// Primarily manual but also responds to remote control. - mixed // primary manual but answers also to remote control -}; -/*typ hamulca elektrodynamicznego*/ -/// Electrodynamic-brake type: no ED brake. -static int const dbrake_none = 0; -/// Electrodynamic-brake type: passive (always on while moving). -static int const dbrake_passive = 1; -/// Electrodynamic-brake type: switchable (driver toggles). -static int const dbrake_switch = 2; -/// Electrodynamic-brake type: reversal (engaged via reverser). -static int const dbrake_reversal = 4; -/// Electrodynamic-brake type: automatic (engages from main brake). -static int const dbrake_automatic = 8; - -/*dzwieki*/ -/// Bit flags identifying sound events emitted by a vehicle. Combinable. -enum sound -{ - /// No sound event. - none, - /// Generic "loud" event flag (e.g. impact / forced action). - loud = 1 << 0, - /// Coupler stretching to its limit. - couplerstretch = 1 << 1, - /// Buffer clash (vehicles colliding). - bufferclash = 1 << 2, - /// Contactor / relay clicking. - relay = 1 << 3, - /// Series-parallel switch operating. - parallel = 1 << 4, - /// Field-shunt contactor operating. - shuntfield = 1 << 5, - /// Generic pneumatic event. - pneumatic = 1 << 6, - /// Coupling detached. - detach = 1 << 7, - /// Mechanical coupler attached. - attachcoupler = 1 << 8, - /// Brake hose attached. - attachbrakehose = 1 << 9, - /// Main air hose attached. - attachmainhose = 1 << 10, - /// Control cable attached. - attachcontrol = 1 << 11, - /// Gangway attached. - attachgangway = 1 << 12, - /// Heating cable attached. - attachheating = 1 << 13, - /// Adapter piece attached to coupler. - attachadapter = 1 << 14, - /// Adapter piece removed from coupler. - removeadapter = 1 << 15, - /// Door-open permission signalling. - doorpermit = 1 << 16, -}; - -/// Bit flags for the customizable reset button — which protective relay it resets. Combinable. -enum relay_t -{ - /// Main circuit ground-fault relay. - maincircuitground = 1 << 0, - /// Auxiliary circuit ground-fault relay. - auxiliarycircuitground = 1 << 1, - /// Traction motor overload relay. - tractionnmotoroverload = 1 << 2, - /// Primary converter overload relay. - primaryconverteroverload = 1 << 3, - /// Secondary converter overload relay. - secondaryconverteroverload = 1 << 4, - /// Ventilator overload relay. - ventillatoroverload = 1 << 5, - /// Heating overload relay. - heatingoverload = 1 << 6, - /// Electrodynamic-brake overload relay. - electrodynamicbrakesoverload = 1 << 7, -}; - -/// Bit flags for actions triggered on cab activation / deactivation. Combinable. -enum activation -{ - /// Engage the emergency brake. - emergencybrake = 1 << 0, - /// Operate cab mirrors. - mirrors = 1 << 1, - /// Raise the pantographs. - pantographsup = 1 << 2, - /// Switch on red end-of-train markers. - redmarkers = 1 << 3, - /// Set door-open permit. - doorpermition = 1 << 4, - /// Engage the spring brake. - springbrakeon = 1 << 5, - /// Release the spring brake. - springbrakeoff = 1 << 6, - /// Place the reverser in neutral. - neutraldirection = 1 << 7, -}; - -/// The vehicles the code handles in a way of their own, by the Type of the Param section of the .fiz -/// (TrainType). A vehicle is of one of them; a .fiz type not listed is generic. -enum class train_type -{ - /// No handling of its own. - generic, - /// Electric multiple unit (Type=EZT). - emu, - /// Diesel multiple unit (Type=DMU). - dmu, - /// ET22 locomotive (Type=ET22, since the Megapack). - et22, - /// ET40 locomotive. - et40, - /// ET41 locomotive. - et41, - /// ET42 locomotive. - et42, - /// EP05 locomotive. - ep05, - /// SN61 railcar: the type is read, but nothing handles it on its own. - sn61, - /// Pseudo-diesel (an electric drivetrain with the input model of a diesel). - pseudodiesel, - /// Škoda 181 and 182 locomotives (Type=181 or 182). - skoda181, -}; - -// stałe dla asynchronów -/// EIM config index: dfic — frequency rise rate at start. -static int const eimc_s_dfic = 0; -/// EIM config index: dfmax — maximum frequency rate of change. -static int const eimc_s_dfmax = 1; -/// EIM config index: p — number of pole pairs. -static int const eimc_s_p = 2; -/// EIM config index: cfu — voltage / frequency conversion coefficient. -static int const eimc_s_cfu = 3; -/// EIM config index: cim — current / current conversion coefficient. -static int const eimc_s_cim = 4; -/// EIM config index: icif — magnetisation current ratio. -static int const eimc_s_icif = 5; -/// EIM config index: Uzmax — maximum DC link voltage. -static int const eimc_f_Uzmax = 7; -/// EIM config index: Uzh — DC link voltage at field-weakening transition. -static int const eimc_f_Uzh = 8; -/// EIM config index: DU — voltage drop at the converter. -static int const eimc_f_DU = 9; -/// EIM config index: I0 — no-load magnetising current. -static int const eimc_f_I0 = 10; -/// EIM config index: cfu — V/f gain in normal mode. -static int const eimc_f_cfu = 11; -/// EIM config index: cfuH — V/f gain in field-weakening region. -static int const eimc_f_cfuH = 12; -/// EIM config index: F0 — starting force at zero speed. -static int const eimc_p_F0 = 13; -/// EIM config index: a1 — force-frequency slope coefficient. -static int const eimc_p_a1 = 14; -/// EIM config index: Pmax — maximum power. -static int const eimc_p_Pmax = 15; -/// EIM config index: Fh — force at field-weakening point. -static int const eimc_p_Fh = 16; -/// EIM config index: Ph — power at field-weakening point. -static int const eimc_p_Ph = 17; -/// EIM config index: Vh0 — speed where field weakening begins. -static int const eimc_p_Vh0 = 18; -/// EIM config index: Vh1 — speed of full field weakening. -static int const eimc_p_Vh1 = 19; -/// EIM config index: Imax — maximum motor current. -static int const eimc_p_Imax = 20; -/// EIM config index: abed — anti-skid set point. -static int const eimc_p_abed = 21; -/// EIM config index: eped — EP brake intensity bias. -static int const eimc_p_eped = 22; - -// zmienne dla asynchronów -/// EIM variable index: FMAXMAX — absolute maximum allowable force. -static int const eimv_FMAXMAX = 0; -/// EIM variable index: Fmax — current force limit. -static int const eimv_Fmax = 1; -/// EIM variable index: ks — slip coefficient. -static int const eimv_ks = 2; -/// EIM variable index: df — frequency offset. -static int const eimv_df = 3; -/// EIM variable index: fp — base frequency. -static int const eimv_fp = 4; -/// EIM variable index: U — applied voltage. -static int const eimv_U = 5; -/// EIM variable index: pole — pole-pair indicator. -static int const eimv_pole = 6; -/// EIM variable index: Ic — control current. -static int const eimv_Ic = 7; -/// EIM variable index: If — field current. -static int const eimv_If = 8; -/// EIM variable index: M — torque. -static int const eimv_M = 9; -/// EIM variable index: Fr — actual force. -static int const eimv_Fr = 10; -/// EIM variable index: Ipoj — line current. -static int const eimv_Ipoj = 11; -/// EIM variable index: Pm — mechanical power. -static int const eimv_Pm = 12; -/// EIM variable index: Pe — electrical power. -static int const eimv_Pe = 13; -/// EIM variable index: eta — efficiency. -static int const eimv_eta = 14; -/// EIM variable index: fkr — critical frequency. -static int const eimv_fkr = 15; -/// EIM variable index: Uzsmax — maximum measured DC link voltage. -static int const eimv_Uzsmax = 16; -/// EIM variable index: Pmax — instantaneous power limit. -static int const eimv_Pmax = 17; -/// EIM variable index: Fzad — set-point force. -static int const eimv_Fzad = 18; -/// EIM variable index: Imax — maximum allowed current. -static int const eimv_Imax = 19; -/// EIM variable index: Fful — full force. -static int const eimv_Fful = 20; - -/// Brake-of-mode flag: PS (pneumatic, primary). -static int const bom_PS = 1; -/// Brake-of-mode flag: PN (pneumatic, no electrodynamic). -static int const bom_PN = 2; -/// Brake-of-mode flag: EP (electro-pneumatic). -static int const bom_EP = 4; -/// Brake-of-mode flag: MED (mixed pneumatic+ED). -static int const bom_MED = 8; - -/// Bit flags reporting vehicle problems that prevent driving. -enum TProblem // lista problemów taboru, które uniemożliwiają jazdę -{ // flagi bitowe - /// The vehicle has the brake applied or seized axles. - pr_Hamuje = 1, // pojazd ma załączony hamulec lub zatarte osie - /// The vehicle requires pantographs to be inflated/raised. - pr_Pantografy = 2, // pojazd wymaga napompowania pantografów - /// Reserved sentinel — last bit flag. - pr_Ostatni = 0x80000000 // ostatnia flaga bitowa -}; - -/// Compressor parameter list — indices into the compressor programmer table. -enum TCompressorList // lista parametrów w programatorze sprężarek -{ // pozycje kolejne - /// Compressor enable permission (0/1). - cl_Allow = 0, // zezwolenie na pracę sprężarek - /// Compressor output multiplier. - cl_SpeedFactor = 1, // mnożnik wydajności - /// Pressure-switch lower threshold multiplier. - cl_MinFactor = 2, // mnożnik progu załącznika ciśnieniowego - /// Pressure-switch upper threshold multiplier. - cl_MaxFactor = 3 // mnożnik progu wyłącznika ciśnieniowego -}; - -/// 3-D position in world coordinates [m]. -struct TLocation -{ - /// X coordinate. - double X; - /// Y coordinate (vertical). - double Y; - /// Z coordinate. - double Z; -}; - -/// Euler-angle rotation (radians) around X / Y / Z axes. -struct TRotation -{ - /// Rotation around X axis. - double Rx; - /// Rotation around Y axis. - double Ry; - /// Rotation around Z axis. - double Rz; -}; - -/// Vehicle bounding box (width × length × height [m]). -struct TDimension -{ - /// Width. - double W = 0.0; - /// Length. - double L = 0.0; - /// Height. - double H = 0.0; -}; - -/// A pending command queued for the vehicle, with its arguments and propagation rules. -struct TCommand -{ - /// Command name. - std::string Command; /*komenda*/ - /// First numeric argument. - double Value1 = 0.0; /*argumenty komendy*/ - /// Second numeric argument. - double Value2 = 0.0; - /// Coupling flag controlling how the command propagates between vehicles. - int Coupling{coupling::control}; // coupler flag used to determine command propagation - /// World-space location associated with the command. - TLocation Location; -}; - -/*tory*/ -/// Geometric shape of a track segment under the vehicle. -struct TTrackShape -{ /*ksztalt odcinka*/ - /// Curvature radius [m]; 0 means straight track. - double R = 0.0; // promien - /// Segment length [m]. - double Len = 0.0; // dlugosc - /// Track gradient (rise/run). - double dHtrack = 0.0; // nachylenie - /// Track cant / superelevation. - double dHrail = 0.0; // przechylka - /// Lateral curvature of the track unevenness under the vehicle [1/m], see world/TrackUneven.h. - double uneven_curvature = 0.0; - /// Cross level unevenness of the track [mm]. - double uneven_cross = 0.0; - /// Curvature a buckle of the track adds under the body [1/m], positive with the curve, see world/TrackBuckle.h. - double buckle_curvature = 0.0; -}; - -/// Per-segment track parameters: gauge, friction, category, load capacity, damage. -struct TTrackParam -{ /*parametry odcinka - szerokosc, tarcie statyczne, kategoria, obciazalnosc w t/os, uszkodzenia*/ - /// Track gauge / width [m]. - double Width = 0.0; - /// Static friction coefficient on this segment. - double friction = 0.0; - /// Track category bit flags. - int CategoryFlag = 0; - /// Track-quality bit flags. - int QualityFlag = 0; - /// Track-damage bit flags (dtrack_*). - int DamageFlag = 0; - /// Maximum allowed velocity on this segment (used by AI driver). - double Velmax; /*dla uzytku maszynisty w ai_driver*/ - /// Name of the track, for the log; nullptr where there is none. - std::string const *Name = nullptr; -}; - -/// Traction-supply parameters at the vehicle's current location. -struct TTractionParam -{ - /// Catenary voltage [V]. - double TractionVoltage = 0.0; /*napiecie*/ - /// Catenary frequency [Hz] (0 for DC). - double TractionFreq = 0.0; /*czestotliwosc*/ - /// Maximum current capacity [A]. - double TractionMaxCurrent = 0.0; /*obciazalnosc*/ - /// Pantograph-catenary contact resistance [Ω]. - double TractionResistivity = 0.0; /*rezystancja styku*/ -}; -/*powyzsze parametry zwiazane sa z torem po ktorym aktualnie pojazd jedzie*/ - -// what a horn needs to sound: air from the main reservoir, or the low voltage -enum class horn_supply -{ - air, - electric -}; - -/// High-level brake-system family. -enum class TBrakeSystem -{ - /// Individual (vehicle-only) brake. - Individual, - /// Pneumatic brake (Westinghouse-style). - Pneumatic, - /// Electro-pneumatic brake. - ElectroPneumatic -}; -/// Brake-system subtype identifying the manufacturer's distributor family. -enum class TBrakeSubSystem -{ - ss_None, - ss_W, - ss_K, - ss_KK, - ss_Hik, - ss_ESt, - ss_KE, - ss_LSt, - ss_MT, - ss_Dako -}; -/// Specific brake-distributor (valve) model. -enum class TBrakeValve -{ - NoValve, - W, - W_Lu_VI, - W_Lu_L, - W_Lu_XR, - K, - Kg, - Kp, - Kss, - Kkg, - Kkp, - Kks, - Hikg1, - Hikss, - Hikp1, - KE, - SW, - EStED, - NESt3, - ESt3, - LSt, - ESt4, - ESt3AL2, - EP1, - EP2, - M483, - CV1_L_TR, - CV1, - CV1_R, - Other -}; -/// Specific driver's brake-handle model (cab valve). -enum class TBrakeHandle -{ - NoHandle, - West, - FV4a, - M394, - M254, - FVE408, - FVel6, - D2, - Knorr, - FD1, - BS2, - testH, - St113, - MHZ_P, - MHZ_T, - MHZ_EN57, - MHZ_K5P, - MHZ_K8P, - MHZ_6P -}; -/// Type of the auxiliary (independent) brake. -enum class TLocalBrake -{ - NoBrake, - ManualBrake, - PneumaticBrake, - HydraulicBrake -}; -/// Brake delay parameter table (apply/release for passenger and freight). -using TBrakeDelayTable = double[4]; - -/// One row of the brake pressure / pipe pressure / flow-speed table for a brake handle position. -struct TBrakePressure -{ - /// Brake pipe pressure target [bar]. - double PipePressureVal = 0.0; - /// Brake cylinder pressure target [bar]. - double BrakePressureVal = 0.0; - /// Flow speed (orifice scaling). - double FlowSpeedVal = 0.0; - /// Brake system this entry applies to. - TBrakeSystem BrakeType = TBrakeSystem::Pneumatic; -}; - -/// Brake pressure table indexed by handle position. -using TBrakePressureTable = std::map; - -/// Engine / drive type. -enum class TEngineType -{ - None, - Dumb, - WheelsDriven, - ElectricSeriesMotor, - ElectricInductionMotor, - DieselEngine, - SteamEngine, - DieselElectric, - Main -}; -/// Form of energy supplied by the power source. -enum class TPowerType -{ - NoPower, - BioPower, - MechPower, - ElectricPower, - SteamPower -}; -/// Fuel type for combustion engines. -enum class TFuelType -{ - Undefined, - Coal, - Oil -}; /// Steam-locomotive grate parameters. struct TGrateType { @@ -1360,13 +563,6 @@ struct TCoupling } }; -class TDynamicObject; -struct neighbour_data -{ - TDynamicObject *vehicle{nullptr}; // detected obstacle - int vehicle_end{-1}; // facing end of the obstacle - float distance{10000.f}; // distance to the obstacle // NOTE: legacy value. TBD, TODO: use standard -1 instead? -}; struct speed_control { diff --git a/physics/vehicletypes.h b/physics/vehicletypes.h new file mode 100644 index 000000000..b8160ab3d --- /dev/null +++ b/physics/vehicletypes.h @@ -0,0 +1,822 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// the vocabulary of the vehicles: their ends, sides, couplings, lights, sounds, types of drive and brake, the +// flags and the small structures the rest of the simulator passes around without needing the physics itself + +#pragma once + +#include +#include + +/// Global counter incremented when a string-to-numeric conversion fails during config parsing. +extern int ConversionError; + +/// Static friction coefficient for steel-on-steel contact (used for adhesion at standstill). +const double Steel2Steel_friction = 0.15; // tarcie statyczne +/// Earth gravitational acceleration [m/s^2]. +const double g = 9.81; // przyspieszenie ziemskie +/// Sand consumption rate when sanding is active [kg/s]. +const double SandSpeed = 0.1; // ile kg/s} +/// 2*pi shortcut. +const double Pirazy2 = 6.2831853071794f; + +//-- var, const, procedure --------------------------------------------------- +/// Truthy alias used by CheckLocomotiveParameters() to ignore a check failure. +static bool const Go = true; +/// Falsy alias used by CheckLocomotiveParameters() to abort on a check failure. +static bool const Hold = false; /*dla CheckLocomotiveParameters*/ +/// Maximum number of resistor / scheme entries for electric motor traction. +static int const ResArraySize = 64; /*dla silnikow elektrycznych*/ +/// Maximum number of motor-parameter table entries (gear stages). +static int const MotorParametersArraySize = 10; +/// Maximum number of pantograph current collectors per vehicle. +static int const maxcc = 4; /*max. ilosc odbierakow pradu*/ +// static int const LocalBrakePosNo = 10; /*ilosc nastaw hamulca pomocniczego*/ +// static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/ +/// Number of positions on the manual (parking) brake handle. +static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/ +/// Number of positions on the lights selector switch. +static int const LightsSwitchPosNo = 16; +/// Maximum number of positions of the universal (auxiliary) controller. +static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/ + +/*uszkodzenia toru*/ +/// Track damage flag: rail wear. +static int const dtrack_railwear = 2; +/// Track damage flag: free / loose rail. +static int const dtrack_freerail = 4; +/// Track damage flag: thin (worn-out) rail. +static int const dtrack_thinrail = 8; +/// Track damage flag: bent rail. +static int const dtrack_railbend = 16; +/// Track damage flag: vegetation overgrowth. +static int const dtrack_plants = 32; +/// Track damage flag: track impassable for movement. +static int const dtrack_nomove = 64; +/// Track damage flag: rails missing entirely. +static int const dtrack_norail = 128; + +/*uszkodzenia taboru*/ +/// Vehicle damage flag: thin wheel (locomotives). +static int const dtrain_thinwheel = 1; /*dla lokomotyw*/ +/// Vehicle damage flag: shifted load (wagons). +static int const dtrain_loadshift = 1; /*dla wagonow*/ +/// Vehicle damage flag: wheel wear. +static int const dtrain_wheelwear = 2; +/// Vehicle damage flag: bearing failure. +static int const dtrain_bearing = 4; +/// Vehicle damage flag: coupling damage. +static int const dtrain_coupling = 8; +/// Vehicle damage flag: ventilator failure (electric locomotive). +static int const dtrain_ventilator = 16; /*dla lokomotywy el.*/ +/// Vehicle damage flag: load damage (wagons). +static int const dtrain_loaddamage = 16; /*dla wagonow*/ +/// Vehicle damage flag: engine failure (locomotives). +static int const dtrain_engine = 32; /*dla lokomotyw*/ +/// Vehicle damage flag: load destroyed (wagons). +static int const dtrain_loaddestroyed = 32; /*dla wagonow*/ +/// Vehicle damage flag: axle damage. +static int const dtrain_axle = 64; +/// Vehicle damage flag: derailment. +static int const dtrain_out = 128; /*wykolejenie*/ +/// Vehicle damage flag: broken pantograph. +static int const dtrain_pantograph = 256; /*polamanie pantografu*/ + +/// Reason for a derailment event. +enum DerailReason +{ + /// No derailment. + NONE = 0, + /// End of track reached. + END_OF_TRACK = 1, // Ra: powód wykolejenia: brak szyn + /// Speed too high for curve (overturn). + TOO_HIGH_SPEED = 2, // Ra: powód wykolejenia: przewrócony na łuku + /// Track gauge does not match wheelset gauge. + GAUGE_MISMATCH = 3, // Ra: powód wykolejenia: za szeroki tor + /// Track type incompatible with this vehicle. + WRONG_TRACK_TYPE = 4, // Ra: powód wykolejenia: nieodpowiednia trajektoria + /// Collision with another vehicle. + COLLISION = 5, // powód wykolejenia: zderzenie z innym pojazdem + /// Trailing through a switch with a movable nose set the other way. + TRAILED_SWITCH = 6, // powód wykolejenia: rozprucie rozjazdu z ruchomym dziobem + /// Climbed onto the vehicle it hit, its end crushed (physics.collisions new). + COLLISION_OVERRIDE = 7, // najechanie + /// Pushed off the track by the force pressing its end (physics.collisions new). + COLLISION_PUSHED_OFF = 8, // wyciśnięcie z toru +}; + +/*wagi prawdopodobienstwa dla funkcji FuzzyLogic*/ +/// Fuzzy-logic probability weight: electric engine general problem. +#define p_elengproblem (1e-02) +/// Fuzzy-logic probability weight: electric engine damage. +#define p_elengdamage (1e-01) +/// Fuzzy-logic probability weight: coupler damage. +#define p_coupldmg (2e-03) +/// Fuzzy-logic probability weight: derailment. +#define p_derail (1e-03) +/// Fuzzy-logic probability weight: acceleration-related event. +#define p_accn (1e-01) +/// Fuzzy-logic probability weight: damage caused by wheel slip. +#define p_slippdmg (1e-03) + +/*typ sprzegu*/ +/// Coupling type: virtual — vehicles share a track and are aware of each other. +static int const ctrain_virtual = 0; // gdy pojazdy na tym samym torze się widzą wzajemnie +/// Coupling type: physical coupler. +static int const ctrain_coupler = 1; // sprzeg fizyczny +/// Coupling type: pneumatic brake hose. +static int const ctrain_pneumatic = 2; // przewody hamulcowe +/// Coupling type: control cable (multiple-unit). +static int const ctrain_controll = 4; // przewody sterujące (ukrotnienie) +/// Coupling type: high-voltage power cable. +static int const ctrain_power = 8; // przewody zasilające (WN) +/// Coupling type: passenger gangway. +static int const ctrain_passenger = 16; // mostek przejściowy +/// Coupling type: secondary 8 atm pneumatic line (yellow, main air). +static int const ctrain_scndpneumatic = 32; // przewody 8 atm (żółte; zasilanie powietrzem) +/// Coupling type: high-voltage train heating cable. +static int const ctrain_heating = 64; // przewody ogrzewania WN +/// Coupling type: permanent (inter-section) — not separable during ordinary shunting; encoded as negative in config files. +static int const ctrain_depot = 128; // nie rozłączalny podczas zwykłych manewrów (międzyczłonowy), we wpisie wartość ujemna +/// Vehicle ends — front or rear (mutually exclusive). +enum end +{ + /// Front end. + front = 0, + /// Rear end. + rear = 1 +}; + +/// Vehicle sides — right or left (mutually exclusive). +enum side +{ + /// Right side. + right = 0, + /// Left side. + left = 1 +}; + +/// Bit flags representing the kind of physical/logical connections in a coupling. Combinable. +enum coupling +{ + /// No coupling (virtual / not connected). + faux = 0x0, + /// Mechanical coupler. + coupler = 0x1, + /// Pneumatic brake hose (PG). + brakehose = 0x2, + /// Control cable (multiple-unit). + control = 0x4, + /// High-voltage cable (traction supply). + highvoltage = 0x8, + /// Passenger gangway. + gangway = 0x10, + /// Main air (8 atm) line — secondary pneumatic supply. + mainhose = 0x20, + /// Train heating cable. + heating = 0x40, + /// Permanent (non-separable) coupling. + permanent = 0x80, + /// 24 V auxiliary power cable. + power24v = 0x100, + /// 110 V auxiliary power cable. + power110v = 0x200, + /// 3-phase 400 V auxiliary power cable. + power3x400v = 0x400, + // uic = 0x1000, +}; +/// Range of effect for a control command (mutually exclusive). +enum class range_t +{ + /// Affects only this vehicle. + local, + /// Affects this multiple-unit (vehicles permanently coupled into a unit). + unit, + /// Affects the entire consist. + consist +}; +/// State of the door closure signalling (SOD) of a vehicle or a consist, ordered from the least to the most +/// severe: the state of a consist is the most severe state of its vehicles. +enum class door_closure_t +{ + /// No doors worked by the crew: the vehicle doesn't take part in the signalling. + none, + /// All doors closed and locked: they can't be opened. + locked, + /// All doors closed, but released: a permit is given, or no lock holds them shut. + released, + /// A door is open, or not fully closed yet. + open +}; +/// Whether the door closure signalling lamp is lit: steadily for locked doors, in the lit phase of the +/// blinking for released ones, never with a door open or with no doors signalled. +bool door_closure_lamp(door_closure_t const State, bool const BlinkLit); +/// Possible settings for an enable/disable input pair (mutually exclusive). +enum class operation_t +{ + /// No input. + none = 0, + /// Enable input held active. + enable, + /// Disable input held active. + disable, + /// Enable button press transition (rising edge). + enable_on, + /// Enable button release transition. + enable_off, + /// Disable button press transition. + disable_on, + /// Disable button release transition. + disable_off, +}; +/// What else the line contactors of a vehicle need before they can close (LineContactorsInterlock in the Cntrl. section). +enum class line_contactors_interlock +{ + /// Nothing more, the legacy behaviour. + none, + /// The converter of the vehicle itself running, where it drives the traction motor fans (ET42). + converter, + /// The traction motor blowers of the vehicle running. + motor_blowers +}; +/// Auto-start method for ancillary devices (mutually exclusive). +enum class start_t +{ + /// Device cannot be started. + disabled, + /// Manual start only. + manual, + /// Starts automatically. + automatic, + /// Manual start with automatic fallback. + manualwithautofallback, + /// Driven by the converter state. + converter, + /// Driven by the battery state. + battery, + /// Driven by direction selector state. + direction +}; +/// Bit flags representing vehicle external lights (positions and types). Combinable. +enum light +{ + + /// Headlight, left. + headlight_left = 1 << 0, + /// Red marker, left. + redmarker_left = 1 << 1, + /// Headlight, upper centre. + headlight_upper = 1 << 2, + // TBD, TODO: redmarker_upper support? + /// Headlight, right. + headlight_right = 1 << 4, + /// Red marker, right. + redmarker_right = 1 << 5, + /// Rear-end markers (combined). + rearendsignals = 1 << 6, + /// Auxiliary light, left (e.g. ditch light). + auxiliary_left = 1 << 7, + /// Auxiliary light, right. + auxiliary_right = 1 << 8, + /// High-beam headlight, left. + highbeamlight_left = 1 << 9, + /// High-beam headlight, right. + highbeamlight_right = 1 << 10 +}; + +/// The cab interior light a position of the light preset selector sets (eu07/maszyna#529). +struct lights_preset_cablight +{ + /// Bits of the optional third column of a LightsList row. + enum flag + { + /// The cab light is on. + light_on = 1 << 0, + /// The cab light is dimmed. + light_dimmed = 1 << 1 + }; + bool light{false}; + bool dim{false}; +}; + +/// Door operation method (who controls them and how) — mutually exclusive. +enum control_t +{ + /// Local; passengers operate manually, doors open/close for the duration of loading. + passenger, // local, opened/closed for duration of loading + /// Remote; driver-operated. + driver, // remote, operated by the driver + /// Local autonomous; close when the vehicle moves and/or after a timeout. + autonomous, // local, closed when vehicle moves and/or after timeout + /// Remote; conductor-operated. + conductor, // remote, operated by the conductor + /// Primarily manual but also responds to remote control. + mixed // primary manual but answers also to remote control +}; +/*typ hamulca elektrodynamicznego*/ +/// Electrodynamic-brake type: no ED brake. +static int const dbrake_none = 0; +/// Electrodynamic-brake type: passive (always on while moving). +static int const dbrake_passive = 1; +/// Electrodynamic-brake type: switchable (driver toggles). +static int const dbrake_switch = 2; +/// Electrodynamic-brake type: reversal (engaged via reverser). +static int const dbrake_reversal = 4; +/// Electrodynamic-brake type: automatic (engages from main brake). +static int const dbrake_automatic = 8; + +/*dzwieki*/ +/// Bit flags identifying sound events emitted by a vehicle. Combinable. +enum sound +{ + /// No sound event. + none, + /// Generic "loud" event flag (e.g. impact / forced action). + loud = 1 << 0, + /// Coupler stretching to its limit. + couplerstretch = 1 << 1, + /// Buffer clash (vehicles colliding). + bufferclash = 1 << 2, + /// Contactor / relay clicking. + relay = 1 << 3, + /// Series-parallel switch operating. + parallel = 1 << 4, + /// Field-shunt contactor operating. + shuntfield = 1 << 5, + /// Generic pneumatic event. + pneumatic = 1 << 6, + /// Coupling detached. + detach = 1 << 7, + /// Mechanical coupler attached. + attachcoupler = 1 << 8, + /// Brake hose attached. + attachbrakehose = 1 << 9, + /// Main air hose attached. + attachmainhose = 1 << 10, + /// Control cable attached. + attachcontrol = 1 << 11, + /// Gangway attached. + attachgangway = 1 << 12, + /// Heating cable attached. + attachheating = 1 << 13, + /// Adapter piece attached to coupler. + attachadapter = 1 << 14, + /// Adapter piece removed from coupler. + removeadapter = 1 << 15, + /// Door-open permission signalling. + doorpermit = 1 << 16, +}; + +/// Bit flags for the customizable reset button — which protective relay it resets. Combinable. +enum relay_t +{ + /// Main circuit ground-fault relay. + maincircuitground = 1 << 0, + /// Auxiliary circuit ground-fault relay. + auxiliarycircuitground = 1 << 1, + /// Traction motor overload relay. + tractionnmotoroverload = 1 << 2, + /// Primary converter overload relay. + primaryconverteroverload = 1 << 3, + /// Secondary converter overload relay. + secondaryconverteroverload = 1 << 4, + /// Ventilator overload relay. + ventillatoroverload = 1 << 5, + /// Heating overload relay. + heatingoverload = 1 << 6, + /// Electrodynamic-brake overload relay. + electrodynamicbrakesoverload = 1 << 7, +}; + +/// Bit flags for actions triggered on cab activation / deactivation. Combinable. +enum activation +{ + /// Engage the emergency brake. + emergencybrake = 1 << 0, + /// Operate cab mirrors. + mirrors = 1 << 1, + /// Raise the pantographs. + pantographsup = 1 << 2, + /// Switch on red end-of-train markers. + redmarkers = 1 << 3, + /// Set door-open permit. + doorpermition = 1 << 4, + /// Engage the spring brake. + springbrakeon = 1 << 5, + /// Release the spring brake. + springbrakeoff = 1 << 6, + /// Place the reverser in neutral. + neutraldirection = 1 << 7, +}; + +/// The vehicles the code handles in a way of their own, by the Type of the Param section of the .fiz +/// (TrainType). A vehicle is of one of them; a .fiz type not listed is generic. +enum class train_type +{ + /// No handling of its own. + generic, + /// Electric multiple unit (Type=EZT). + emu, + /// Diesel multiple unit (Type=DMU). + dmu, + /// ET22 locomotive (Type=ET22, since the Megapack). + et22, + /// ET40 locomotive. + et40, + /// ET41 locomotive. + et41, + /// ET42 locomotive. + et42, + /// EP05 locomotive. + ep05, + /// SN61 railcar: the type is read, but nothing handles it on its own. + sn61, + /// Pseudo-diesel (an electric drivetrain with the input model of a diesel). + pseudodiesel, + /// Škoda 181 and 182 locomotives (Type=181 or 182). + skoda181, +}; + +// stałe dla asynchronów +/// EIM config index: dfic — frequency rise rate at start. +static int const eimc_s_dfic = 0; +/// EIM config index: dfmax — maximum frequency rate of change. +static int const eimc_s_dfmax = 1; +/// EIM config index: p — number of pole pairs. +static int const eimc_s_p = 2; +/// EIM config index: cfu — voltage / frequency conversion coefficient. +static int const eimc_s_cfu = 3; +/// EIM config index: cim — current / current conversion coefficient. +static int const eimc_s_cim = 4; +/// EIM config index: icif — magnetisation current ratio. +static int const eimc_s_icif = 5; +/// EIM config index: Uzmax — maximum DC link voltage. +static int const eimc_f_Uzmax = 7; +/// EIM config index: Uzh — DC link voltage at field-weakening transition. +static int const eimc_f_Uzh = 8; +/// EIM config index: DU — voltage drop at the converter. +static int const eimc_f_DU = 9; +/// EIM config index: I0 — no-load magnetising current. +static int const eimc_f_I0 = 10; +/// EIM config index: cfu — V/f gain in normal mode. +static int const eimc_f_cfu = 11; +/// EIM config index: cfuH — V/f gain in field-weakening region. +static int const eimc_f_cfuH = 12; +/// EIM config index: F0 — starting force at zero speed. +static int const eimc_p_F0 = 13; +/// EIM config index: a1 — force-frequency slope coefficient. +static int const eimc_p_a1 = 14; +/// EIM config index: Pmax — maximum power. +static int const eimc_p_Pmax = 15; +/// EIM config index: Fh — force at field-weakening point. +static int const eimc_p_Fh = 16; +/// EIM config index: Ph — power at field-weakening point. +static int const eimc_p_Ph = 17; +/// EIM config index: Vh0 — speed where field weakening begins. +static int const eimc_p_Vh0 = 18; +/// EIM config index: Vh1 — speed of full field weakening. +static int const eimc_p_Vh1 = 19; +/// EIM config index: Imax — maximum motor current. +static int const eimc_p_Imax = 20; +/// EIM config index: abed — anti-skid set point. +static int const eimc_p_abed = 21; +/// EIM config index: eped — EP brake intensity bias. +static int const eimc_p_eped = 22; + +// zmienne dla asynchronów +/// EIM variable index: FMAXMAX — absolute maximum allowable force. +static int const eimv_FMAXMAX = 0; +/// EIM variable index: Fmax — current force limit. +static int const eimv_Fmax = 1; +/// EIM variable index: ks — slip coefficient. +static int const eimv_ks = 2; +/// EIM variable index: df — frequency offset. +static int const eimv_df = 3; +/// EIM variable index: fp — base frequency. +static int const eimv_fp = 4; +/// EIM variable index: U — applied voltage. +static int const eimv_U = 5; +/// EIM variable index: pole — pole-pair indicator. +static int const eimv_pole = 6; +/// EIM variable index: Ic — control current. +static int const eimv_Ic = 7; +/// EIM variable index: If — field current. +static int const eimv_If = 8; +/// EIM variable index: M — torque. +static int const eimv_M = 9; +/// EIM variable index: Fr — actual force. +static int const eimv_Fr = 10; +/// EIM variable index: Ipoj — line current. +static int const eimv_Ipoj = 11; +/// EIM variable index: Pm — mechanical power. +static int const eimv_Pm = 12; +/// EIM variable index: Pe — electrical power. +static int const eimv_Pe = 13; +/// EIM variable index: eta — efficiency. +static int const eimv_eta = 14; +/// EIM variable index: fkr — critical frequency. +static int const eimv_fkr = 15; +/// EIM variable index: Uzsmax — maximum measured DC link voltage. +static int const eimv_Uzsmax = 16; +/// EIM variable index: Pmax — instantaneous power limit. +static int const eimv_Pmax = 17; +/// EIM variable index: Fzad — set-point force. +static int const eimv_Fzad = 18; +/// EIM variable index: Imax — maximum allowed current. +static int const eimv_Imax = 19; +/// EIM variable index: Fful — full force. +static int const eimv_Fful = 20; + +/// Brake-of-mode flag: PS (pneumatic, primary). +static int const bom_PS = 1; +/// Brake-of-mode flag: PN (pneumatic, no electrodynamic). +static int const bom_PN = 2; +/// Brake-of-mode flag: EP (electro-pneumatic). +static int const bom_EP = 4; +/// Brake-of-mode flag: MED (mixed pneumatic+ED). +static int const bom_MED = 8; + +/// Bit flags reporting vehicle problems that prevent driving. +enum TProblem // lista problemów taboru, które uniemożliwiają jazdę +{ // flagi bitowe + /// The vehicle has the brake applied or seized axles. + pr_Hamuje = 1, // pojazd ma załączony hamulec lub zatarte osie + /// The vehicle requires pantographs to be inflated/raised. + pr_Pantografy = 2, // pojazd wymaga napompowania pantografów + /// Reserved sentinel — last bit flag. + pr_Ostatni = 0x80000000 // ostatnia flaga bitowa +}; + +/// Compressor parameter list — indices into the compressor programmer table. +enum TCompressorList // lista parametrów w programatorze sprężarek +{ // pozycje kolejne + /// Compressor enable permission (0/1). + cl_Allow = 0, // zezwolenie na pracę sprężarek + /// Compressor output multiplier. + cl_SpeedFactor = 1, // mnożnik wydajności + /// Pressure-switch lower threshold multiplier. + cl_MinFactor = 2, // mnożnik progu załącznika ciśnieniowego + /// Pressure-switch upper threshold multiplier. + cl_MaxFactor = 3 // mnożnik progu wyłącznika ciśnieniowego +}; + +/// 3-D position in world coordinates [m]. +struct TLocation +{ + /// X coordinate. + double X; + /// Y coordinate (vertical). + double Y; + /// Z coordinate. + double Z; +}; + +/// Euler-angle rotation (radians) around X / Y / Z axes. +struct TRotation +{ + /// Rotation around X axis. + double Rx; + /// Rotation around Y axis. + double Ry; + /// Rotation around Z axis. + double Rz; +}; + +/// Vehicle bounding box (width × length × height [m]). +struct TDimension +{ + /// Width. + double W = 0.0; + /// Length. + double L = 0.0; + /// Height. + double H = 0.0; +}; + +/// A pending command queued for the vehicle, with its arguments and propagation rules. +struct TCommand +{ + /// Command name. + std::string Command; /*komenda*/ + /// First numeric argument. + double Value1 = 0.0; /*argumenty komendy*/ + /// Second numeric argument. + double Value2 = 0.0; + /// Coupling flag controlling how the command propagates between vehicles. + int Coupling{coupling::control}; // coupler flag used to determine command propagation + /// World-space location associated with the command. + TLocation Location; +}; + +/*tory*/ +/// Geometric shape of a track segment under the vehicle. +struct TTrackShape +{ /*ksztalt odcinka*/ + /// Curvature radius [m]; 0 means straight track. + double R = 0.0; // promien + /// Segment length [m]. + double Len = 0.0; // dlugosc + /// Track gradient (rise/run). + double dHtrack = 0.0; // nachylenie + /// Track cant / superelevation. + double dHrail = 0.0; // przechylka + /// Lateral curvature of the track unevenness under the vehicle [1/m], see world/TrackUneven.h. + double uneven_curvature = 0.0; + /// Cross level unevenness of the track [mm]. + double uneven_cross = 0.0; + /// Curvature a buckle of the track adds under the body [1/m], positive with the curve, see world/TrackBuckle.h. + double buckle_curvature = 0.0; +}; + +/// Per-segment track parameters: gauge, friction, category, load capacity, damage. +struct TTrackParam +{ /*parametry odcinka - szerokosc, tarcie statyczne, kategoria, obciazalnosc w t/os, uszkodzenia*/ + /// Track gauge / width [m]. + double Width = 0.0; + /// Static friction coefficient on this segment. + double friction = 0.0; + /// Track category bit flags. + int CategoryFlag = 0; + /// Track-quality bit flags. + int QualityFlag = 0; + /// Track-damage bit flags (dtrack_*). + int DamageFlag = 0; + /// Maximum allowed velocity on this segment (used by AI driver). + double Velmax; /*dla uzytku maszynisty w ai_driver*/ + /// Name of the track, for the log; nullptr where there is none. + std::string const *Name = nullptr; +}; + +/// Traction-supply parameters at the vehicle's current location. +struct TTractionParam +{ + /// Catenary voltage [V]. + double TractionVoltage = 0.0; /*napiecie*/ + /// Catenary frequency [Hz] (0 for DC). + double TractionFreq = 0.0; /*czestotliwosc*/ + /// Maximum current capacity [A]. + double TractionMaxCurrent = 0.0; /*obciazalnosc*/ + /// Pantograph-catenary contact resistance [Ω]. + double TractionResistivity = 0.0; /*rezystancja styku*/ +}; +/*powyzsze parametry zwiazane sa z torem po ktorym aktualnie pojazd jedzie*/ + +// what a horn needs to sound: air from the main reservoir, or the low voltage +enum class horn_supply +{ + air, + electric +}; + +/// High-level brake-system family. +enum class TBrakeSystem +{ + /// Individual (vehicle-only) brake. + Individual, + /// Pneumatic brake (Westinghouse-style). + Pneumatic, + /// Electro-pneumatic brake. + ElectroPneumatic +}; +/// Brake-system subtype identifying the manufacturer's distributor family. +enum class TBrakeSubSystem +{ + ss_None, + ss_W, + ss_K, + ss_KK, + ss_Hik, + ss_ESt, + ss_KE, + ss_LSt, + ss_MT, + ss_Dako +}; +/// Specific brake-distributor (valve) model. +enum class TBrakeValve +{ + NoValve, + W, + W_Lu_VI, + W_Lu_L, + W_Lu_XR, + K, + Kg, + Kp, + Kss, + Kkg, + Kkp, + Kks, + Hikg1, + Hikss, + Hikp1, + KE, + SW, + EStED, + NESt3, + ESt3, + LSt, + ESt4, + ESt3AL2, + EP1, + EP2, + M483, + CV1_L_TR, + CV1, + CV1_R, + Other +}; +/// Specific driver's brake-handle model (cab valve). +enum class TBrakeHandle +{ + NoHandle, + West, + FV4a, + M394, + M254, + FVE408, + FVel6, + D2, + Knorr, + FD1, + BS2, + testH, + St113, + MHZ_P, + MHZ_T, + MHZ_EN57, + MHZ_K5P, + MHZ_K8P, + MHZ_6P +}; +/// Type of the auxiliary (independent) brake. +enum class TLocalBrake +{ + NoBrake, + ManualBrake, + PneumaticBrake, + HydraulicBrake +}; +/// Brake delay parameter table (apply/release for passenger and freight). +using TBrakeDelayTable = double[4]; + +/// One row of the brake pressure / pipe pressure / flow-speed table for a brake handle position. +struct TBrakePressure +{ + /// Brake pipe pressure target [bar]. + double PipePressureVal = 0.0; + /// Brake cylinder pressure target [bar]. + double BrakePressureVal = 0.0; + /// Flow speed (orifice scaling). + double FlowSpeedVal = 0.0; + /// Brake system this entry applies to. + TBrakeSystem BrakeType = TBrakeSystem::Pneumatic; +}; + +/// Brake pressure table indexed by handle position. +using TBrakePressureTable = std::map; + +/// Engine / drive type. +enum class TEngineType +{ + None, + Dumb, + WheelsDriven, + ElectricSeriesMotor, + ElectricInductionMotor, + DieselEngine, + SteamEngine, + DieselElectric, + Main +}; +/// Form of energy supplied by the power source. +enum class TPowerType +{ + NoPower, + BioPower, + MechPower, + ElectricPower, + SteamPower +}; +/// Fuel type for combustion engines. +enum class TFuelType +{ + Undefined, + Coal, + Oil +}; + +class TDynamicObject; +struct neighbour_data +{ + TDynamicObject *vehicle{nullptr}; // detected obstacle + int vehicle_end{-1}; // facing end of the obstacle + float distance{10000.f}; // distance to the obstacle // NOTE: legacy value. TBD, TODO: use standard -1 instead? +}; diff --git a/rendering/common/locallights.cpp b/rendering/common/locallights.cpp index ff6b1465e..5f04155cf 100644 --- a/rendering/common/locallights.cpp +++ b/rendering/common/locallights.cpp @@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/Train.h" #include "simulation/simulation.h" #include "rendering/geometrybank.h" +#include "physics/mover.h" namespace { diff --git a/rendering/common/localshadows.cpp b/rendering/common/localshadows.cpp index 87fc056f8..49ce195ce 100644 --- a/rendering/common/localshadows.cpp +++ b/rendering/common/localshadows.cpp @@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Train.h" #include "rendering/common/skyocclusion.h" +#include "physics/mover.h" namespace gfx { diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index fa95b7670..1a91a1f5c 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -30,6 +30,7 @@ http://mozilla.org/MPL/2.0/. #include "model/AnimModel.h" #include "model/Model3d.h" #include "rendering/common/skyocclusion.h" +#include "physics/mover.h" #include #include #include diff --git a/rendering/common/screenreflections.cpp b/rendering/common/screenreflections.cpp index a00ad7f05..0976305b5 100644 --- a/rendering/common/screenreflections.cpp +++ b/rendering/common/screenreflections.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "gl/ubo.h" #include "utilities/Globals.h" +#include "physics/mover.h" namespace { diff --git a/rendering/common/windscreenwater.cpp b/rendering/common/windscreenwater.cpp index 9a52eb3fe..78d3a2edc 100644 --- a/rendering/common/windscreenwater.cpp +++ b/rendering/common/windscreenwater.cpp @@ -19,6 +19,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "vehicle/DynObj.h" #include "vehicle/Train.h" +#include "physics/mover.h" namespace gfx { diff --git a/rendering/lightarray.cpp b/rendering/lightarray.cpp index 15020894b..f34a4d183 100644 --- a/rendering/lightarray.cpp +++ b/rendering/lightarray.cpp @@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "rendering/lightarray.h" #include "vehicle/DynObj.h" +#include "physics/mover.h" void light_array::insert( TDynamicObject const *Owner ) { diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index 29663ec23..1bbeb17fe 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/. #include "rendering/opengl46/opengl46geometrybank.h" #include "rendering/screenshot.h" #include "rendering/editoroverlay.h" +#include "physics/mover.h" #include #include diff --git a/rendering/particles.cpp b/rendering/particles.cpp index 87fc7c0b5..9879cba25 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "simulation/simulationenvironment.h" #include "utilities/Logs.h" #include "vehicle/smoke.h" +#include "physics/mover.h" void diff --git a/rendering/vulkan14/vulkan14frame.cpp b/rendering/vulkan14/vulkan14frame.cpp index 9a033978a..12f3cf9b0 100644 --- a/rendering/vulkan14/vulkan14frame.cpp +++ b/rendering/vulkan14/vulkan14frame.cpp @@ -32,6 +32,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/utilities.h" #include "utilities/color.h" +#include "physics/mover.h" #include diff --git a/scene/scene.cpp b/scene/scene.cpp index 506b52d67..c8272519f 100644 --- a/scene/scene.cpp +++ b/scene/scene.cpp @@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/. #include "rendering/renderer.h" #include "widgets/map_objects.h" #include "vehicle/aiwire.h" +#include "physics/mover.h" #include diff --git a/scripting/lua.cpp b/scripting/lua.cpp index 2011413b5..27224605f 100644 --- a/scripting/lua.cpp +++ b/scripting/lua.cpp @@ -7,6 +7,7 @@ #include "simulation/simulation.h" #include "scripting/luasandbox.h" #include "utilities/utilities.h" +#include "physics/mover.h" lua::lua() { diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index e4161ce61..3599bb1bb 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/physicslog.h" #include "utilities/utilities.h" #include "world/stationnames.h" +#include "physics/mover.h" #include #include diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index 2eb0a3c89..477203061 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -37,6 +37,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "vehicle/Driver.h" #include "world/catenary_scene.h" +#include "physics/mover.h" namespace simulation { diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index c1fad53ae..69fc726b9 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -37,6 +37,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/utilities.h" #include "editor/editorTerrainStreamer.hpp" +#include "physics/mover.h" #include diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp index b0dd02dc1..ed2e9f8fe 100644 --- a/utilities/motiontelemetry.cpp +++ b/utilities/motiontelemetry.cpp @@ -6,6 +6,7 @@ #include "utilities/Timer.h" #include "vehicle/Driver.h" #include "simulation/simulation.h" +#include "physics/mover.h" #ifdef _WIN32 #include diff --git a/utilities/uart.cpp b/utilities/uart.cpp index 632c2b4c6..902c95b5f 100644 --- a/utilities/uart.cpp +++ b/utilities/uart.cpp @@ -9,6 +9,7 @@ #include "utilities/utilities.h" #include "simulation/simulationtime.h" #include "application/application.h" +#include "physics/mover.h" const char* const uart_baudrates_list[] = { "300", diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index eb89088ac..e6b6eff5d 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/Driver.h" +#include "physics/mover.h" #include "utilities/Globals.h" #include "utilities/translation.h" @@ -9661,3 +9662,21 @@ TController::UpdateBrakingHelper() { } } } + +bool TController::is_train() const { + return TestFlag( mvOccupied->CategoryFlag, 1 ); } + +bool TController::is_car() const { + return TestFlag( mvOccupied->CategoryFlag, 2 ); } + +bool TController::is_emu() const { + return mvControlling->TrainType == train_type::emu; } + +bool TController::is_dmu() const { + return mvControlling->TrainType == train_type::dmu; } + +bool TController::has_diesel_engine() const { + return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; } + +double TController::DirectionalVel() const { + return mvOccupied->Vel * sign( iDirection * mvOccupied->V ); } diff --git a/vehicle/Driver.h b/vehicle/Driver.h index 539542725..04ba00d01 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/. #include #include "utilities/Classes.h" #include "utilities/utilities.h" -#include "physics/mover.h" +#include "physics/vehicletypes.h" #include "audio/sound.h" #include "vehicle/DynObj.h" #include "world/mtable.h" @@ -266,22 +266,11 @@ public: inline bool is_active() const { return TestFlag( iDrivigFlags, moveActive ); } - inline - bool is_train() const { - return TestFlag( mvOccupied->CategoryFlag, 1 ); } - inline - bool is_car() const { - return TestFlag( mvOccupied->CategoryFlag, 2 ); } - inline - bool is_emu() const { - return mvControlling->TrainType == train_type::emu; } - inline - bool is_dmu() const { - return mvControlling->TrainType == train_type::dmu; } - inline - bool has_diesel_engine() const { - return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; - } + bool is_train() const; + bool is_car() const; + bool is_emu() const; + bool is_dmu() const; + bool has_diesel_engine() const; TBrakeSystem consist_brake_system() const; // the next change of the speed limit ahead, as the driving aid tells it: the speed and the distance to it. // the speed is the present limit (VelDesired) when nothing worth telling changes within the scan range @@ -335,9 +324,7 @@ private: inline int DrivigFlags() const { return iDrivigFlags; }; - inline - double DirectionalVel() const { - return mvOccupied->Vel * sign( iDirection * mvOccupied->V ); } + double DirectionalVel() const; double brake_increase_margin() const; bool uphill_stop_hold() const; diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index c37efe824..53a1680b0 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "vehicle/DynObj.h" +#include "physics/mover.h" #include "vehicle/lightsprogrammer.h" @@ -10425,3 +10426,19 @@ vehicle_table::erase_disabled() { return true; } + +// the vehicles coupled at the ends, and the ends of theirs facing this one +TDynamicObject *TDynamicObject::NextConnected() { return MoverParameters->Neighbours[ end::rear ].vehicle; } +TDynamicObject *TDynamicObject::PrevConnected() { return MoverParameters->Neighbours[ end::front ].vehicle; } +TDynamicObject *TDynamicObject::NextConnected() const { return MoverParameters->Neighbours[ end::rear ].vehicle; } +TDynamicObject *TDynamicObject::PrevConnected() const { return MoverParameters->Neighbours[ end::front ].vehicle; } +int TDynamicObject::NextConnectedNo() const { return MoverParameters->Neighbours[ end::rear ].vehicle_end; } +int TDynamicObject::PrevConnectedNo() const { return MoverParameters->Neighbours[ end::front ].vehicle_end; } + +void TDynamicObject::SetdMoveLen( double dMoveLen ) { MoverParameters->dMoveLen = dMoveLen; } +void TDynamicObject::ResetdMoveLen() { MoverParameters->dMoveLen = 0; } +double TDynamicObject::GetdMoveLen() { return MoverParameters->dMoveLen; } + +double TDynamicObject::GetVelocity() const { return MoverParameters->Vel; } +double TDynamicObject::GetLength() const { return MoverParameters->Dim.L; } +double TDynamicObject::GetWidth() const { return MoverParameters->Dim.W; } diff --git a/vehicle/DynObj.h b/vehicle/DynObj.h index 389e6edef..b11ec9e84 100644 --- a/vehicle/DynObj.h +++ b/vehicle/DynObj.h @@ -14,7 +14,9 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Classes.h" #include "interfaces/IMaterial.h" -#include "physics/mover.h" +#include "physics/vehicletypes.h" +#include "physics/derailment.h" +#include "vehicle/derailmotion.h" #include "world/TrkFoll.h" #include "vehicle/Button.h" #include "vehicle/AirCoupler.h" @@ -228,12 +230,12 @@ public: std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)" glm::dmat4 mMatrix; // macierz przekształcenia do renderowania modeli TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie - inline TDynamicObject *NextConnected() { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) - inline TDynamicObject *PrevConnected() { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) - inline TDynamicObject *NextConnected() const { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1) - inline TDynamicObject *PrevConnected() const { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1) - inline int NextConnectedNo() const { return MoverParameters->Neighbours[ end::rear ].vehicle_end; } - inline int PrevConnectedNo() const { return MoverParameters->Neighbours[ end::front ].vehicle_end; } + TDynamicObject *NextConnected(); // pojazd podłączony od strony sprzęgu 1 (kabina -1) + TDynamicObject *PrevConnected(); // pojazd podłączony od strony sprzęgu 0 (kabina 1) + TDynamicObject *NextConnected() const; // pojazd podłączony od strony sprzęgu 1 (kabina -1) + TDynamicObject *PrevConnected() const; // pojazd podłączony od strony sprzęgu 0 (kabina 1) + int NextConnectedNo() const; + int PrevConnectedNo() const; // Dev tools void Reload(); @@ -671,12 +673,9 @@ private: TDynamicObject * PrevAny() const; TDynamicObject * Prev(int C = -1) const; TDynamicObject * Next(int C = -1) const; - void SetdMoveLen(double dMoveLen) { - MoverParameters->dMoveLen = dMoveLen; } - void ResetdMoveLen() { - MoverParameters->dMoveLen = 0; } - double GetdMoveLen() { - return MoverParameters->dMoveLen; } + void SetdMoveLen(double dMoveLen); + void ResetdMoveLen(); + double GetdMoveLen(); int GetPneumatic(bool front, bool red); void SetPneumatic(bool front, bool red); @@ -849,12 +848,9 @@ public: return glm::value_ptr(mMatrix); }; inline double * Matrix() { return glm::value_ptr(mMatrix); }; - inline double GetVelocity() const { - return MoverParameters->Vel; }; - inline double GetLength() const { - return MoverParameters->Dim.L; }; - inline double GetWidth() const { - return MoverParameters->Dim.W; }; + double GetVelocity() const; + double GetLength() const; + double GetWidth() const; double radius() const; // calculates distance between event-starting axle and front of the vehicle double tracing_offset() const; diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 27f23b601..e736bafdf 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -37,6 +37,7 @@ http://mozilla.org/MPL/2.0/. #include "Console.h" #include "application/application.h" #include "rendering/renderer.h" +#include "physics/mover.h" #include #include #include diff --git a/vehicle/crewchange.cpp b/vehicle/crewchange.cpp index e7bf4abe8..8f44556b4 100644 --- a/vehicle/crewchange.cpp +++ b/vehicle/crewchange.cpp @@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Train.h" #include "vehicle/handover.h" +#include "physics/mover.h" namespace crew { diff --git a/widgets/trainingcard.cpp b/widgets/trainingcard.cpp index b261a5d4d..de46f9cd8 100644 --- a/widgets/trainingcard.cpp +++ b/widgets/trainingcard.cpp @@ -2,6 +2,7 @@ #include "widgets/trainingcard.h" #include "simulation/simulation.h" #include "utilities/utilities.h" +#include "physics/mover.h" #ifdef __linux__ #include diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index c2b140d8a..56f28782b 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -4,6 +4,7 @@ #include "application/driveruipanels.h" #include "vehicle/Driver.h" #include "vehicle/Train.h" +#include "physics/mover.h" ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) : ui_panel(std::string(STR("Vehicle parameters")) + ": " + vehicle, false), m_vehicle_name(vehicle) { diff --git a/world/Event.cpp b/world/Event.cpp index 814cd9918..acd53908c 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -34,6 +34,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/Logs.h" #include "widgets/map_objects.h" +#include "physics/mover.h" void basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) { diff --git a/world/Road.cpp b/world/Road.cpp index bbfb9d8cc..58b5fd575 100644 --- a/world/Road.cpp +++ b/world/Road.cpp @@ -20,6 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/parser.h" #include "utilities/utilities.h" +#include "physics/mover.h" namespace { diff --git a/world/RoadPoint.cpp b/world/RoadPoint.cpp index 776d747e4..15ae891ad 100644 --- a/world/RoadPoint.cpp +++ b/world/RoadPoint.cpp @@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Logs.h" #include "utilities/parser.h" #include "utilities/utilities.h" +#include "physics/mover.h" namespace { diff --git a/world/Track.cpp b/world/Track.cpp index 990ff4b0b..6e2824756 100644 --- a/world/Track.cpp +++ b/world/Track.cpp @@ -31,6 +31,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Timer.h" #include "utilities/Logs.h" #include "rendering/renderer.h" +#include "physics/mover.h" #include diff --git a/world/TrackBuckle.cpp b/world/TrackBuckle.cpp index c8c20fe08..f0328d8d1 100644 --- a/world/TrackBuckle.cpp +++ b/world/TrackBuckle.cpp @@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Globals.h" #include "utilities/Logs.h" #include "vehicle/DynObj.h" +#include "physics/mover.h" #include diff --git a/world/TrkFoll.cpp b/world/TrkFoll.cpp index bc8027f43..6477f9763 100644 --- a/world/TrkFoll.cpp +++ b/world/TrkFoll.cpp @@ -21,6 +21,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/DynObj.h" #include "vehicle/Driver.h" #include "utilities/Logs.h" +#include "physics/mover.h" namespace { diff --git a/world/station.cpp b/world/station.cpp index 90b443e86..5e4dd9590 100644 --- a/world/station.cpp +++ b/world/station.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/utilities.h" #include "vehicle/DynObj.h" #include "world/mtable.h" +#include "physics/mover.h" namespace simulation {