|
1 | 1 | # Open Rails Architecture
|
2 | 2 |
|
3 |
| -TBD |
4 |
| - |
5 | 3 | This document will describe the overall structure of Open Rails and how we expect different areas of the program to work together.
|
| 4 | + |
| 5 | +## Threading model |
| 6 | + |
| 7 | +The threading in Open Rails has two key threads working together (Render and Updater) to simulate and render the world, with a number of auxiliary threads for other functions. |
| 8 | + |
| 9 | +- Render process [main thread] |
| 10 | + - Read user input |
| 11 | + - Swap next/current frames |
| 12 | + - Resume Updater |
| 13 | + - Render current frame |
| 14 | + - Wait until Updater is finished |
| 15 | +- Updater process |
| 16 | + - Suspended until restarted by Render |
| 17 | + - Every 250ms if Loader is suspended: check for anything to load and resume Loader |
| 18 | + - Run simulation |
| 19 | + - Prepare next frame for rendering |
| 20 | +- Loader process |
| 21 | + - Suspended until restarted by Updater |
| 22 | + - Load content for simulation and rendering |
| 23 | +- Sound process |
| 24 | + - Wait 50ms |
| 25 | + - Update all sound outputs (volumes, 3D position, etc.) |
| 26 | +- Watchdog process |
| 27 | + - Every 1s: checks above processes are making forward progress |
| 28 | + - If a process stops responding for more than 10s (60s for Loader), the whole application is terminated with an error containing the hung process' stack trace |
| 29 | +- Web Server process |
| 30 | + - Handle all web and API requests |
| 31 | + |
| 32 | +## Simulator object relationships |
| 33 | + |
| 34 | +This tree is a summary of the important object relationships (aggregation) inside the simulation. Each entry is a class whose instances can be accessed from the parent item. |
| 35 | + |
| 36 | +- `Simulator` |
| 37 | + - `Activity` |
| 38 | + - `LevelCrossings` |
| 39 | + - `Signals` |
| 40 | + - `Train` (collection) |
| 41 | + - `TrainCar` (collection) |
| 42 | + - **Physics simulation** |
| 43 | + - `BrakeSystem` |
| 44 | + - `IPowerSupply` (interface) |
| 45 | + - `WheelAxle` (collection) |
| 46 | + - (child `MSTSWagon`) `MSTSCoupling` |
| 47 | + - (child `MSTSLocomotive`) `ScriptedBrakeController` |
| 48 | + - (child `MSTSLocomotive`) `ScriptedTrainControlSystem` |
| 49 | + - (child `MSTSDieselLocomotive`) `DieselEngines` |
| 50 | + - **Visual simulation** |
| 51 | + - `FreightAnimations` |
| 52 | + - `PassengerViewPoint` (collection) |
| 53 | + - `TrainCarPart` (collection) |
| 54 | + - `ViewPoint` (collection) |
| 55 | + - (child `MSTSWagon`) `IntakePoint` (collection) |
| 56 | + - (child `MSTSWagon`) `ParticleEmitterData` (collection) |
| 57 | + - (child `MSTSLocomotive`) `CabView` (collection) |
| 58 | + - (child `MSTSLocomotive`) `CabView3D` |
| 59 | + - `UserSettings` |
| 60 | + - `Weather` |
| 61 | + |
| 62 | +## Simulator class relationships |
| 63 | + |
| 64 | +This tree is a summary of the important class relationships (inheritance) inside the simulation. Each top-level entry is a separate hierarchy of classes. |
| 65 | + |
| 66 | +- `BrakeSystem` (abstract) |
| 67 | + - `MSTSBrakeSystem` (abstract) |
| 68 | + - `AirSinglePipe` |
| 69 | + - `AirTwinPipe` |
| 70 | + - `EPBrakeSystem` |
| 71 | + - `SMEBrakeSystem` |
| 72 | + - `SingleTransferPipe` |
| 73 | + - `ManualBraking` |
| 74 | + - `VacuumSinglePipe` |
| 75 | + - `StraightVacuumSinglePipe` |
| 76 | +- `IPowerSupply` (interface) |
| 77 | + - `ILocomotivePowerSupply` (interface) |
| 78 | + - `ScriptedLocomotivePowerSupply` (abstract) |
| 79 | + - `ScriptedControlCarPowerSupply` |
| 80 | + - `ScriptedDieselPowerSupply` |
| 81 | + - `ScriptedDualModePowerSupply` |
| 82 | + - `ScriptedElectricPowerSupply` |
| 83 | + - `SteamPowerSupply` |
| 84 | + - `IPassengerCarPowerSupply` (interface) |
| 85 | + - `ScriptedPassengerCarPowerSupply` |
| 86 | +- `Train` |
| 87 | + - `AITrain` |
| 88 | + - `TTTrain` |
| 89 | +- `TrainCar` (abstract) |
| 90 | + - `MSTSWagon` |
| 91 | + - `MSTSLocomotive` |
| 92 | + - `MSTSControlTrailerCar` |
| 93 | + - `MSTSDieselLocomotive` |
| 94 | + - `MSTSElectricLocomotive` |
| 95 | + - `MSTSSteamLocomotive` |
0 commit comments