diff --git a/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs b/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
index ceed107..15af89f 100644
--- a/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
+++ b/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
@@ -80,6 +80,28 @@ public class BlackBoxListingTests
Assert.Equal(early, sessions[1].StartedUtc);
}
+ [Fact]
+ public void The_tape_of_a_vehicle_left_early_in_a_run_with_no_launch_goes_with_its_black_box()
+ {
+ // The black box writes the tapes as it goes: that of the vehicle the player left after ten minutes ends
+ // twenty minutes before the run, that of the next one with it.
+ var started = new DateTime(2026, 3, 1, 12, 0, 0, DateTimeKind.Utc);
+ string box = Box("td", started);
+ var installation = new TestInstallation(new InMemoryFileSystem()
+ .WithFile(Log("first.dat"), "t")
+ .WithFile(Log("second.dat"), "t")
+ .WithFile(Log(box), "b")
+ .WrittenAt(Log("first.dat"), started.AddMinutes(10))
+ .WrittenAt(Log(box), started.AddMinutes(30))
+ .WrittenAt(Log("second.dat"), started.AddMinutes(30).AddSeconds(1)));
+
+ var session = Assert.Single(installation.Tapes.Sessions());
+
+ Assert.Null(session.Launch);
+ Assert.Equal(new[] { "first", "second" }, session.Tapes.Select(tape => tape.Vehicle).Order());
+ Assert.EndsWith(box, Assert.Single(session.BlackBoxes).Path);
+ }
+
[Fact]
public void The_black_box_of_a_running_session_is_listed_while_it_is_written()
{
diff --git a/StarterNG.Tests/StartSimulationTests.cs b/StarterNG.Tests/StartSimulationTests.cs
index 973683b..b291945 100644
--- a/StarterNG.Tests/StartSimulationTests.cs
+++ b/StarterNG.Tests/StartSimulationTests.cs
@@ -41,7 +41,7 @@ public class StartSimulationTests
}
[Fact]
- public void With_the_black_box_alone_the_launch_is_noted_for_the_tapes_it_writes_at_the_end()
+ public void With_the_black_box_alone_the_launch_is_noted_for_the_tapes_it_writes()
{
var (start, _, installation) = Rig(files => files.WithExecutable(Build), sceneryClock: "07:52");
installation.SettingsStore.Settings.BlackBox = true;
diff --git a/StarterNG/Application/HaslerTapes.cs b/StarterNG/Application/HaslerTapes.cs
index a49baf8..9ef1d65 100644
--- a/StarterNG/Application/HaslerTapes.cs
+++ b/StarterNG/Application/HaslerTapes.cs
@@ -35,6 +35,7 @@ public sealed class HaslerTapes
{
private const int RememberedLaunches = 30;
private static readonly TimeSpan QuietBetweenRuns = TimeSpan.FromMinutes(2);
+ private static readonly TimeSpan TapesAfterBlackBox = TimeSpan.FromSeconds(10);
private readonly IFileSystem _files;
private readonly IGamePaths _paths;
@@ -244,8 +245,9 @@ public sealed class HaslerTapes
///
/// The runs the tapes came from, the running or latest one first. A tape belongs
/// to the last launch before it was written, unless a run the starter didn't launch
- /// began between them; one with no launch goes with those written about the same
- /// time, as a run writes them all at its end.
+ /// began between them; one with no launch goes with the black box recording when it
+ /// was written, or else with those written about the same time, as a run writes its
+ /// logs until it ends.
///
public IReadOnlyList Sessions()
{
@@ -278,11 +280,14 @@ public sealed class HaslerTapes
boxesBehind.GetValueOrDefault(launch, new List())));
}
- // What no launch covers goes together by when it was written: a run writes it all at its end.
+ // What no launch covers goes together by when it was written: a run writes its logs until it ends. A tape
+ // written while a black box recorded is of its run, though: the black box writes the tapes of the player's
+ // vehicles as it goes, and that of a vehicle the player left ends before the run does.
+ var looseBoxes = boxes.Where(b => LaunchOf(b, launches) is null).ToList();
var loose = tapes.Where(t => tapeLaunch[t] is null)
- .Select(t => (Written: t.LastWriteUtc, Tape: (TapeFile?)t, Box: (BlackBoxRecording?)null))
- .Concat(boxes.Where(b => LaunchOf(b, launches) is null)
- .Select(b => (Written: b.LastWriteUtc, Tape: (TapeFile?)null, Box: (BlackBoxRecording?)b)))
+ .Select(t => (Written: RecordingAt(t.LastWriteUtc, looseBoxes)?.LastWriteUtc ?? t.LastWriteUtc,
+ Tape: (TapeFile?)t, Box: (BlackBoxRecording?)null))
+ .Concat(looseBoxes.Select(b => (Written: b.LastWriteUtc, Tape: (TapeFile?)null, Box: (BlackBoxRecording?)b)))
.OrderBy(file => file.Written);
var run = new List();
var runBoxes = new List();
@@ -315,6 +320,16 @@ public sealed class HaslerTapes
}
}
+ ///
+ /// The black box that was recording at the moment, the tapes being written last, a moment after it is closed.
+ /// Of more, the one that stopped nearest to it.
+ ///
+ private static BlackBoxRecording? RecordingAt(DateTime momentUtc, IEnumerable boxes) =>
+ boxes.Where(box => NamedBy(box.Path) is { } named && named.StartedUtc <= momentUtc
+ && momentUtc <= box.LastWriteUtc + TapesAfterBlackBox)
+ .OrderBy(box => (box.LastWriteUtc - momentUtc).Duration())
+ .FirstOrDefault();
+
private TapeFile ReadTape(string path) =>
new(path, Path.GetFileNameWithoutExtension(path), _files.GetLastWriteTimeUtc(path), _files.GetFileSize(path));
diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
index bef75b2..e917a3d 100644
--- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs
+++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
@@ -233,14 +233,12 @@ public sealed class HaslerTapeWindow : Window
_recordingOff.IsVisible = !recording;
_logOff.IsVisible = recording && !settings.DebugLog;
- // the black box alone writes the tapes when the simulator closes: only the physics log grows while it runs
- bool canFollow = _running && settings.PhysicsLog && _tapes.DrivenVehicle is not null;
+ // the physics logs and the black box's tapes both grow while the simulator runs, every two seconds
+ bool canFollow = _running && recording && _tapes.DrivenVehicle is not null;
_live.IsEnabled = canFollow;
if (!canFollow)
_live.IsChecked = false;
- ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip"
- : _running && !settings.PhysicsLog ? "HaslerLiveAtClose"
- : "HaslerLiveIdle"]);
+ ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip" : "HaslerLiveIdle"]);
}
private DockPanel Strip(string textKey, string buttonKey, Action enable)
diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml
index 674e288..3454476 100644
--- a/StarterNG/startercfg/lang/cz.xml
+++ b/StarterNG/startercfg/lang/cz.xml
@@ -498,7 +498,7 @@
Možnost zlomení pantografu
Napájení jen pod trolejí
Nahrávat černou skříňku a pásky rychloměru
- Nahrává jízdu do jednoho souboru ve složce physicslog/ a po zavření simulátoru zapíše pásky (.dat) vozidel, ve kterých jste byli.
+ Nahrává jízdu do jednoho souboru ve složce physicslog/ a průběžně, každé 2 s, zapisuje pásky (.dat) vozidel, ve kterých jste.
Ukládat fyzikální log všech vozidel
Ukládat log simulace
Zachovat předchozí logy
@@ -846,7 +846,6 @@
vlak {0}
Řízené dříve
Funguje, když běží relace spuštěná ze starteru.
- Černá skříňka zapíše pásky po zavření simulátoru. Živě funguje s fyzikálním logem.
Log simulátoru je vypnutý: starter nevidí přesedání.
Zapnout log
Vozidlo ze startu
diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml
index 53f5576..00d18b2 100644
--- a/StarterNG/startercfg/lang/en.xml
+++ b/StarterNG/startercfg/lang/en.xml
@@ -517,9 +517,9 @@
Powered only under overhead line
When disabled, a raised pantograph can power the vehicle even without touching the wire.
Record the black box and the speedometer tapes
- Records the session to one file in the physicslog/ folder and, when the simulator closes, writes the tapes (.dat) of the vehicles you were in.
+ Records the session to one file in the physicslog/ folder and writes the tapes (.dat) of the vehicles you are in as it goes, every 2 s.
Save the physics log of every vehicle
- Writes the log of every vehicle of the scenery to the physicslog/ folder as it runs, 20 times a second. For diagnostics: on a large scenery that is hundreds of open files.
+ Writes the log of every vehicle of the scenery to the physicslog/ folder: a line every 0.05 s, added every 2 s. For diagnostics: on a large scenery that is hundreds of files.
Save simulation log
Keep previous logs
Creates a separate log file for each scenery instead of overwriting errors.txt.
@@ -1075,7 +1075,6 @@
train {0}
Driven earlier
Works while a session started from the starter runs.
- The black box writes the tapes when the simulator closes. Live works with the physics log.
The simulator's log is off: the starter does not see changes of vehicle.
Turn the log on
Vehicle at the start
diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml
index 04e7cd2..4f18345 100644
--- a/StarterNG/startercfg/lang/hu.xml
+++ b/StarterNG/startercfg/lang/hu.xml
@@ -498,7 +498,7 @@
Áramszedő törésének lehetősége
Táplálás csak felsővezeték alatt
Fekete doboz és sebességmérő-szalagok rögzítése
- A menetet egy fájlba rögzíti a physicslog/ mappában, és a szimulátor bezárásakor kiírja azoknak a járműveknek a szalagjait (.dat), amelyekben ültél.
+ A menetet egy fájlba rögzíti a physicslog/ mappában, és menet közben, 2 másodpercenként kiírja azoknak a járműveknek a szalagjait (.dat), amelyekben ülsz.
Minden jármű fizikai naplójának mentése
Szimulációs napló mentése
Korábbi naplók megtartása
@@ -846,7 +846,6 @@
vonat {0}
Korábban vezetett
Az indítóból indított munkamenet alatt működik.
- A fekete doboz a szimulátor bezárásakor írja ki a szalagokat. Az élő nézet a fizikai naplóval működik.
A szimulátor naplója ki van kapcsolva: az indító nem látja a járműváltást.
Napló bekapcsolása
Indulási jármű
diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml
index d8e8edf..bdbec33 100644
--- a/StarterNG/startercfg/lang/pl.xml
+++ b/StarterNG/startercfg/lang/pl.xml
@@ -517,9 +517,9 @@
Zasilanie tylko pod siecią trakcyjna
Gdy wyłączone, podniesiony pantograf zasila pojazd nawet bez kontaktu z drutem.
Zapisuj czarną skrzynkę i taśmy prędkościomierza
- Nagrywa przejazd do jednego pliku w folderze physicslog/, a po zamknięciu symulatora zapisuje taśmy (.dat) pojazdów, w których byłeś.
+ Nagrywa przejazd do jednego pliku w folderze physicslog/ i na bieżąco, co 2 s, zapisuje taśmy (.dat) pojazdów, w których jesteś.
Zapisuj log parametrów fizycznych wszystkich pojazdów
- Zapisuje na bieżąco log każdego pojazdu scenerii do folderu physicslog/, 20 razy na sekundę. Do diagnostyki: na dużej scenerii to setki otwartych plików.
+ Zapisuje log każdego pojazdu scenerii do folderu physicslog/: wiersz co 0,05 s, dopisywany co 2 s. Do diagnostyki: na dużej scenerii to setki plików.
Zapisuj log z symulacji
Zachowuj poprzednie logi
Tworzy osobny plik logu dla każdej scenerii zamiast nadpisywać errors.txt.
@@ -897,7 +897,6 @@
pociąg {0}
Prowadzony wcześniej
Działa, gdy trwa sesja uruchomiona ze Startera.
- Czarna skrzynka zapisuje taśmy po zamknięciu symulatora. Na żywo działa z logiem parametrów fizycznych.
Log symulatora jest wyłączony: Starter nie widzi przesiadek.
Włącz log
Pojazd ze startu
diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml
index a4639d9..bcdc7d4 100644
--- a/StarterNG/startercfg/lang/ru.xml
+++ b/StarterNG/startercfg/lang/ru.xml
@@ -498,7 +498,7 @@
Возможность излома пантографа
Питание только под контактной сетью
Записывать чёрный ящик и ленты скоростемера
- Записывает поездку в один файл в папке physicslog/, а при закрытии симулятора сохраняет ленты (.dat) тех единиц, в которых вы были.
+ Записывает поездку в один файл в папке physicslog/ и по ходу, каждые 2 с, сохраняет ленты (.dat) тех единиц, в которых вы находитесь.
Сохранять физический лог всех единиц
Сохранять журнал симуляции
Сохранять предыдущие журналы
@@ -846,7 +846,6 @@
поезд {0}
Управлялся ранее
Работает, пока идёт сеанс, запущенный из стартера.
- Чёрный ящик сохраняет ленты при закрытии симулятора. Режим «вживую» работает с физическим логом.
Журнал симулятора выключен: стартер не видит пересадок.
Включить журнал
Транспорт на старте