You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Space -> pause/resume toggle (Goal 8 integration point)
59
+
55
60
# Other tasks
56
61
./gradlew javadoc # Generate documentation
57
62
./gradlew dependencies # Show dependency tree
58
63
```
59
64
60
65
For complete build system documentation including dependency management, GitHub Packages authentication, manual JAR execution, and Gradle configuration files, see **[docs/KOTLIN_STYLE_GUIDE.md](docs/KOTLIN_STYLE_GUIDE.md)** under "Build & Development Environment".
61
66
62
-
### Running Animated Simulation (Current Branch)
67
+
### Running Simulation with Speed Control
63
68
64
-
Use the animated GUI when you need the current real-time animated desktop view:
69
+
Use the animated GUI when you need live speed changes:
This branch does **not** expose interactive Goal 7 speed controls in the desktop GUI yet.
3
+
Goal 7 adds live wall-clock speed control to the animated simulation GUI.
4
4
5
-
What is currently available is a fixed real-time animated simulation mode for built-in GUI examples. This document describes the current user-visible behavior so the desktop UI is not documented more broadly than it is implemented.
5
+
The control changes how fast events are presented to the user. It does **not** change simulation semantics, event ordering, or physics calculations.
6
6
7
-
## Current Status
7
+
## Overview
8
8
9
-
The animated GUI currently provides:
9
+
Use speed control when you want to:
10
10
11
-
- a top `ControlPanel` with **Time** and **Status**
12
-
- an `EventTimelinePanel` for simulation events
13
-
- real-time synchronization for the built-in GUI example path
11
+
- slow the model down for teaching or demos
12
+
- run near real time while watching train movement
13
+
- fast-forward through long scenarios
14
+
- pause temporarily while preparing for deeper Goal 8 debugging workflows
14
15
15
-
The animated GUI currently does **not** provide:
16
+
Supported range:
16
17
17
-
- a speed slider
18
-
- speed preset buttons
19
-
- speed-related menu items
20
-
- keyboard shortcuts for speed changes
21
-
- pause/resume controls
22
-
- a speed indicator in the status bar during simulation mode
18
+
-**0.1x** minimum speed
19
+
-**50x** highest one-click preset
20
+
-**100x** absolute runner limit
23
21
24
22
## Quick Start
25
23
26
-
Launch the animated GUI example:
24
+
Start the animated GUI:
27
25
28
26
```bash
29
27
./gradlew runExampleGui
@@ -35,46 +33,94 @@ Or run the JAR directly after building:
For your own XML file, open the desktop UI and use **Simulation → Start...**.
39
37
40
-
When `exampleGui` starts, the application shows:
38
+
When simulation mode is active, the GUI shows:
41
39
42
-
- the animated railway canvas
43
-
- the top control panel with `Time` and `Status`
44
-
- the event timeline
40
+
- the animated control panel (`Time`, `Status`, `Stop`)
41
+
- the speed control panel (`Speed` slider, presets, live speed label)
42
+
- the status bar speed indicator when speed is not `1.0x`
45
43
46
-
During simulation mode, `Frame` hides the `StatusBar`, so there is no separate speed readout in the current UI.
44
+
## GUI Controls
47
45
48
-
##What “Speed Control” Means on This Branch
46
+
### Speed slider
49
47
50
-
For the built-in animated GUI example, `ExampleRegistry` creates `ShuntingLoop` with:
48
+
- Range: **0.1x to 10.0x**
49
+
- Step: **0.1x**
50
+
- Best for fine adjustment while the simulation is already running
51
51
52
-
-`enableRealTimeSync = true`
53
-
-`speedMultiplier = 1.0`
52
+
### Preset buttons
54
53
55
-
That means the current GUI example runs at a fixed real-time rate intended for observation, not live user adjustment.
54
+
The panel and **Simulation → Speed** menu provide these presets:
56
55
57
-
The console example path still runs without this GUI-specific real-time synchronization.
56
+
-`0.1x`
57
+
-`0.5x`
58
+
-`1x`
59
+
-`2x`
60
+
-`5x`
61
+
-`10x`
62
+
-`50x`
63
+
64
+
`50x` is intentionally above the slider range. The slider stays clamped at its maximum visual position while the runner continues at `50x`.
65
+
66
+
### Status indicator
67
+
68
+
The status bar shows `Speed: X.Xx` whenever the current speed differs from `1.0x`. At the default speed the indicator is hidden to keep the bar uncluttered.
69
+
70
+

71
+
72
+

73
+
74
+
## Keyboard Shortcuts
75
+
76
+
Shortcuts are active in **simulation mode** while the application window has focus.
77
+
78
+
| Shortcut | Action |
79
+
| --- | --- |
80
+
|`1`| Set speed to `0.5x`|
81
+
|`2`| Set speed to `1x`|
82
+
|`3`| Set speed to `2x`|
83
+
|`4`| Set speed to `5x`|
84
+
|`5`| Set speed to `10x`|
85
+
|`+`| Increase speed by `×1.5`|
86
+
|`-`| Decrease speed by `÷1.5`|
87
+
|`Space`| Pause or resume the active simulation |
88
+
89
+
Notes:
90
+
91
+
- On most keyboards, `+` is **Shift+`=`**.
92
+
- Numpad `+` and `-` are also supported.
93
+
-`Space` is the current Goal 8 integration point: it toggles the runner pause flag directly.
94
+
95
+
## Common Use Cases
96
+
97
+
-**Educational demo:** start at `0.5x` or `1x`, then drop to `0.1x` before a switch or semaphore change.
98
+
-**Normal observation:** keep the model at `1x` or `2x` and watch the event timeline.
99
+
-**Long scenario review:** jump to `10x` or `50x` to move through uneventful periods quickly.
100
+
-**Pre-debug pause workflow:** press `Space`, inspect the current state, then resume.
58
101
59
102
## Technical Details
60
103
61
-
-`exampleGui` launches the animated desktop UI from `Main.runExampleGui(...)`.
62
-
- The GUI example uses `ShuntingLoop(..., enableRealTimeSync = true, speedMultiplier = 1.0)`.
63
-
-`Main.runExampleGui(...)` starts `context.run()` on a background thread.
64
-
-`Frame` updates the animated `ControlPanel` time display with a 10 Hz Swing timer.
65
-
-`Frame.switchToSimulationMode()` hides `StatusBar` and shows `ControlPanel` plus `EventTimelinePanel`.
66
-
-A standalone `SimulationRunner` class exists in `desktop-ui`, but it is not wired into `Frame` or the current animated GUI flow on this branch.
104
+
-Speed control is implemented by `SimulationRunner`.
105
+
- The runner wraps `SimulationContext.run()` on a dedicated simulation thread.
0 commit comments