feat(tapes): tape recording turns the black box on, not the physics log of every vehicle

The simulator now records the black box on its own ("blackbox yes") and writes the .dat tapes of the
vehicles the player was in when it closes, so the tapes no longer need "physicslog yes", which keeps a
log of every vehicle of the scenery open and written twenty times a second (some 500 files on
Tomaszewo, past what the runtime allowed).

- The settings have a box of their own for the black box and its tapes, next to the physics log of
  every vehicle, which stays for diagnostics.
- "Turn on recording" of the tapes' window turns the black box on.
- The key is read as the simulator reads it: with no line of its own it goes with the physics log. It
  is written where it says more than the physics log or where the file has it already, so an ini
  without it stays so.
- A launch is noted for the tapes with either one on; "live" follows a tape only with the physics log,
  as the black box writes its tapes at the end, and its tip says so.
This commit is contained in:
maj00r
2026-11-14 00:05:06 +01:00
parent 1ef630b1b6
commit 4429eff4ef
15 changed files with 149 additions and 16 deletions

View File

@@ -26,7 +26,7 @@ public sealed class DefaultBlackBoxStrings : IBlackBoxStrings
["Pause"] = "Pause",
["Follow"] = "Follow the train",
["Fit"] = "Whole map",
["NoFile"] = "Open a black box: physicslog/*.blackbox, written with the physics logs on.",
["NoFile"] = "Open a black box: physicslog/*.blackbox, written with the black box or the physics logs on.",
["Unreadable"] = "Can't read {0}: {1}",
["Reading"] = "Reading {0}…",
["Summary"] = "{0} · {1:0.0} km · max {2:0} km/h · driven {3} · autopilot {4} · over the AI {5} ({6} by more than {7:0} km/h, at most +{8:0} km/h) · signals {9} · at danger {10} · commands {11}",
@@ -297,7 +297,7 @@ public sealed class DefaultBlackBoxStrings : IBlackBoxStrings
["Pause"] = "Pauza",
["Follow"] = "Śledź pociąg",
["Fit"] = "Cała mapa",
["NoFile"] = "Otwórz czarną skrzynkę: physicslog/*.blackbox, zapisywaną razem z logami fizyki.",
["NoFile"] = "Otwórz czarną skrzynkę: physicslog/*.blackbox, zapisywaną przy włączonej czarnej skrzynce albo logach fizyki.",
["Unreadable"] = "Nie można odczytać {0}: {1}",
["Reading"] = "Czytanie {0}…",
["Summary"] = "{0} · {1:0.0} km · maks. {2:0} km/h · jazda {3} · autopilot {4} · ponad AI {5} (w tym {6} o więcej niż {7:0} km/h, najwyżej +{8:0} km/h) · sygnalizatory {9} · minięte na „Stój” {10} · komendy {11}",

View File

@@ -1302,4 +1302,86 @@ public class SettingsStoreTests
Assert.False(store.LoadFailed);
Assert.Equal(60, store.Settings.FieldOfView);
}
[Theory]
[InlineData("physicslog yes\n", true)]
[InlineData("physicslog no\n", false)]
[InlineData("physicslog yes\nblackbox no\n", false)]
[InlineData("physicslog no\nblackbox yes\n", true)]
public void The_black_box_goes_with_the_physics_log_unless_the_ini_says_otherwise(string ini, bool recorded)
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
installation.SettingsStore.Load();
Assert.Equal(recorded, installation.SettingsStore.Settings.BlackBox);
}
[Fact]
public void Tapes_turned_on_write_the_black_box_and_leave_the_physics_log_off()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = true;
installation.SettingsStore.Save();
Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
}
[Fact]
public void A_black_box_that_says_no_more_than_the_physics_log_adds_no_line()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.Width = 1600;
installation.SettingsStore.Save();
Assert.Null(LineFor(installation, "blackbox"));
}
[Theory]
[InlineData("physicslog yes\nblackbox yes\n")]
[InlineData("physicslog no\nblackbox yes\n")]
public void A_black_box_line_of_the_file_says_no_once_the_box_is_off(string ini)
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = false;
installation.SettingsStore.Settings.PhysicsLog = false;
installation.SettingsStore.Save();
Assert.Equal("blackbox no", LineFor(installation, "blackbox"));
Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
}
[Fact]
public void The_physics_log_turned_off_keeps_the_tapes_it_brought()
{
// an ini of before the black box had a key: the tapes came with the physics log
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.PhysicsLog = false;
installation.SettingsStore.Save();
Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
}
[Fact]
public void A_black_box_line_written_once_goes_away_when_it_says_no_more()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = true;
installation.SettingsStore.Save();
installation.SettingsStore.Settings.BlackBox = false;
installation.SettingsStore.Save();
Assert.Null(LineFor(installation, "blackbox"));
}
}

View File

@@ -40,6 +40,18 @@ public class StartSimulationTests
Assert.Contains($"vehicle\t{driven}\tPKP/EP07\tep07.mmd", noted);
}
[Fact]
public void With_the_black_box_alone_the_launch_is_noted_for_the_tapes_it_writes_at_the_end()
{
var (start, _, installation) = Rig(files => files.WithExecutable(Build), sceneryClock: "07:52");
installation.SettingsStore.Settings.BlackBox = true;
start.Execute(freeFly: false, saveSettings: false);
string noted = installation.Files.ReadAllText(TestInstallation.At("physicslog", "starter-launch.txt"));
Assert.Contains("clock\t07:52", noted);
}
[Fact]
public void Without_the_physics_log_nothing_is_noted()
{

View File

@@ -144,7 +144,7 @@ public sealed class StartSimulation
if (saveSettings)
_settings.CaptureAndSave();
if (_settings.Settings.PhysicsLog)
if (_settings.Settings.PhysicsLog || _settings.Settings.BlackBox)
_tapes.RecordLaunch(scenery, trainset, freeFly ? null : vehicle);
string[] arguments = freeFly || string.IsNullOrEmpty(vehicle)

View File

@@ -133,6 +133,13 @@ public sealed class SimulatorSettings
public bool EnableTraction = true;
public bool LiveTraction = true;
public bool PhysicsLog;
/// <summary>
/// The black box of the session, and with it the tapes (.dat) of the vehicles the player was in, written when the
/// simulator closes: the tapes without the log of every vehicle. With no entry of its own it goes with the physics log.
/// </summary>
public bool BlackBox;
/// <summary>Whether eu07.ini had a line of its own for the black box when read: it is kept saying what is wanted.</summary>
public bool BlackBoxInIni;
public bool DebugLog = true;
public bool MultipleLogs;
public bool DisplaySimulation = true;

View File

@@ -157,6 +157,9 @@ public sealed class SettingsSerializer
s.EnableTraction = c.GetBool("enabletraction", true);
s.LiveTraction = c.GetBool("livetraction", true);
s.PhysicsLog = c.GetBool("physicslog", false);
// the simulator records the black box along with the physics log when the ini says nothing of it
s.BlackBoxInIni = c.Has("blackbox");
s.BlackBox = s.BlackBoxInIni ? c.GetBool("blackbox", false) : s.PhysicsLog;
int debugLog = c.GetInt("debuglog", 3);
s.DebugLog = (debugLog & 1) != 0;
s.DebugLogVisible = (debugLog & 2) != 0;
@@ -370,6 +373,10 @@ public sealed class SettingsSerializer
c.SetBool("enabletraction", s.EnableTraction);
c.SetBool("livetraction", s.LiveTraction);
c.SetBool("physicslog", s.PhysicsLog);
// written where it says more than the physics log, or where the file has it already: an ini without it
// stays so, and a line written once and no longer saying more goes away on the next save
if (s.BlackBoxInIni || s.BlackBox != s.PhysicsLog)
c.SetBool("blackbox", s.BlackBox);
c.SetInt("debuglog",
(s.DebugLog ? 1 : 0) | (s.DebugLogVisible ? 2 : 0) | s.DebugLogExtraBits);
c.SetBool("multiplelogs", s.MultipleLogs);

View File

@@ -709,7 +709,7 @@ public partial class MainWindow : Window
/// </summary>
private static void FollowLastRun()
{
if (AppServices.Current.Settings.PhysicsLog)
if (AppServices.Current.Settings.PhysicsLog || AppServices.Current.Settings.BlackBox)
_ = Task.Run(AppServices.Current.Tapes.FollowLastRun);
}

View File

@@ -553,6 +553,9 @@
<ctl:SettingRow ConfigKey="livetraction" Description="{Binding [PowerOverheadLineOnlyDesc], Source={x:Static starterNg:App.Loc}}">
<CheckBox x:Name="OverheadOnlyCb" Content="{Binding [PowerOverheadLineOnly], Source={x:Static starterNg:App.Loc}}" />
</ctl:SettingRow>
<ctl:SettingRow Description="{Binding [SaveBlackBoxDesc], Source={x:Static starterNg:App.Loc}}" ConfigKey="blackbox">
<CheckBox x:Name="BlackBoxCb" Content="{Binding [SaveBlackBox], Source={x:Static starterNg:App.Loc}}" />
</ctl:SettingRow>
<ctl:SettingRow Description="{Binding [SaveSpeedometerTapesDesc], Source={x:Static starterNg:App.Loc}}" ConfigKey="physicslog">
<CheckBox x:Name="SpeedometerTapesCb" Content="{Binding [SaveSpeedometerTapes], Source={x:Static starterNg:App.Loc}}" />
</ctl:SettingRow>

View File

@@ -329,6 +329,7 @@ public partial class Settings : UserControl, ISettingsCapture
WhileLoading(() =>
{
SpeedometerTapesCb.IsChecked = AppServices.Current.Settings.PhysicsLog;
BlackBoxCb.IsChecked = AppServices.Current.Settings.BlackBox;
SimLogsCb.IsChecked = AppServices.Current.Settings.DebugLog;
});
@@ -441,6 +442,7 @@ public partial class Settings : UserControl, ISettingsCapture
PantographBreakCb.IsChecked = s.EnableTraction;
OverheadOnlyCb.IsChecked = s.LiveTraction;
SpeedometerTapesCb.IsChecked = s.PhysicsLog;
BlackBoxCb.IsChecked = s.BlackBox;
SimLogsCb.IsChecked = s.DebugLog;
KeepLogsCb.IsChecked = s.MultipleLogs;
DisplaySimulationCb.IsChecked = s.DisplaySimulation;
@@ -874,6 +876,7 @@ public partial class Settings : UserControl, ISettingsCapture
s.EnableTraction = IsChecked(PantographBreakCb);
s.LiveTraction = IsChecked(OverheadOnlyCb);
s.PhysicsLog = IsChecked(SpeedometerTapesCb);
s.BlackBox = IsChecked(BlackBoxCb);
s.DebugLog = IsChecked(SimLogsCb);
s.MultipleLogs = IsChecked(KeepLogsCb);
s.DisplaySimulation = IsChecked(DisplaySimulationCb);

View File

@@ -163,7 +163,7 @@ public sealed class HaslerTapeWindow : Window
Content = _view
};
_recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings => settings.PhysicsLog = true);
_recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings => settings.BlackBox = true);
_logOff = Strip("HaslerLogOff", "HaslerLogEnable", settings => settings.DebugLog = true);
var folder = ToolButton(App.Loc["HaslerOpenFolder"]);
@@ -229,14 +229,18 @@ public sealed class HaslerTapeWindow : Window
private void ShowWhatIsKnown()
{
var settings = AppServices.Current.Settings;
_recordingOff.IsVisible = !settings.PhysicsLog;
_logOff.IsVisible = settings.PhysicsLog && !settings.DebugLog;
bool recording = settings.PhysicsLog || settings.BlackBox;
_recordingOff.IsVisible = !recording;
_logOff.IsVisible = recording && !settings.DebugLog;
bool canFollow = _running && _tapes.DrivenVehicle is not null;
// 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;
_live.IsEnabled = canFollow;
if (!canFollow)
_live.IsChecked = false;
ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip" : "HaslerLiveIdle"]);
ToolTip.SetTip(_live, App.Loc[canFollow ? "HaslerLiveTip"
: _running && !settings.PhysicsLog ? "HaslerLiveAtClose"
: "HaslerLiveIdle"]);
}
private DockPanel Strip(string textKey, string buttonKey, Action<SimulatorSettings> enable)

View File

@@ -497,7 +497,9 @@
<String key="PhysicsAccuracyIncreased">Zvýšená přesnost fyziky</String>
<String key="BreakingPantographPossibility">Možnost zlomení pantografu</String>
<String key="PowerOverheadLineOnly">Napájení jen pod trolejí</String>
<String key="SaveSpeedometerTapes">Ukládat pásky rychloměru</String>
<String key="SaveBlackBox">Nahrávat černou skříňku a pásky rychloměru</String>
<String key="SaveBlackBoxDesc">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.</String>
<String key="SaveSpeedometerTapes">Ukládat fyzikální log všech vozidel</String>
<String key="SaveSimLogs">Ukládat log simulace</String>
<String key="KeepPrevLogs">Zachovat předchozí logy</String>
<String key="DisplaySimulation">Zobrazit simulaci</String>
@@ -844,6 +846,7 @@
<String key="HaslerTrain">vlak {0}</String>
<String key="HaslerRoleDrivenEarlier">Řízené dříve</String>
<String key="HaslerLiveIdle">Funguje, když běží relace spuštěná ze starteru.</String>
<String key="HaslerLiveAtClose">Černá skříňka zapíše pásky po zavření simulátoru. Živě funguje s fyzikálním logem.</String>
<String key="HaslerLogOff">Log simulátoru je vypnutý: starter nevidí přesedání.</String>
<String key="HaslerLogEnable">Zapnout log</String>
<String key="HaslerRoleStartedIn">Vozidlo ze startu</String>

View File

@@ -516,8 +516,10 @@
<String key="BreakingPantographPossibilityDesc">Disabling protects the pantograph from breaking on faulty overhead line geometry.</String>
<String key="PowerOverheadLineOnly">Powered only under overhead line</String>
<String key="PowerOverheadLineOnlyDesc">When disabled, a raised pantograph can power the vehicle even without touching the wire.</String>
<String key="SaveSpeedometerTapes">Save physics parameters log</String>
<String key="SaveSpeedometerTapesDesc">Writes a detailed trip log to the physicslog/ folder.</String>
<String key="SaveBlackBox">Record the black box and the speedometer tapes</String>
<String key="SaveBlackBoxDesc">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.</String>
<String key="SaveSpeedometerTapes">Save the physics log of every vehicle</String>
<String key="SaveSpeedometerTapesDesc">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.</String>
<String key="SaveSimLogs">Save simulation log</String>
<String key="KeepPrevLogs">Keep previous logs</String>
<String key="KeepPrevLogsDesc">Creates a separate log file for each scenery instead of overwriting errors.txt.</String>
@@ -1073,6 +1075,7 @@
<String key="HaslerTrain">train {0}</String>
<String key="HaslerRoleDrivenEarlier">Driven earlier</String>
<String key="HaslerLiveIdle">Works while a session started from the starter runs.</String>
<String key="HaslerLiveAtClose">The black box writes the tapes when the simulator closes. Live works with the physics log.</String>
<String key="HaslerLogOff">The simulator's log is off: the starter does not see changes of vehicle.</String>
<String key="HaslerLogEnable">Turn the log on</String>
<String key="HaslerRoleStartedIn">Vehicle at the start</String>

View File

@@ -497,7 +497,9 @@
<String key="PhysicsAccuracyIncreased">Növelt fizikai pontosság</String>
<String key="BreakingPantographPossibility">Áramszedő törésének lehetősége</String>
<String key="PowerOverheadLineOnly">Táplálás csak felsővezeték alatt</String>
<String key="SaveSpeedometerTapes">Sebességmérő-szalagok mentése</String>
<String key="SaveBlackBox">Fekete doboz és sebességmérő-szalagok rögzítése</String>
<String key="SaveBlackBoxDesc">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.</String>
<String key="SaveSpeedometerTapes">Minden jármű fizikai naplójának mentése</String>
<String key="SaveSimLogs">Szimulációs napló mentése</String>
<String key="KeepPrevLogs">Korábbi naplók megtartása</String>
<String key="DisplaySimulation">Szimuláció megjelenítése</String>
@@ -844,6 +846,7 @@
<String key="HaslerTrain">vonat {0}</String>
<String key="HaslerRoleDrivenEarlier">Korábban vezetett</String>
<String key="HaslerLiveIdle">Az indítóból indított munkamenet alatt működik.</String>
<String key="HaslerLiveAtClose">A fekete doboz a szimulátor bezárásakor írja ki a szalagokat. Az élő nézet a fizikai naplóval működik.</String>
<String key="HaslerLogOff">A szimulátor naplója ki van kapcsolva: az indító nem látja a járműváltást.</String>
<String key="HaslerLogEnable">Napló bekapcsolása</String>
<String key="HaslerRoleStartedIn">Indulási jármű</String>

View File

@@ -516,8 +516,10 @@
<String key="BreakingPantographPossibilityDesc">Wyłączenie chroni pantograf przed uszkodzeniem przy błędnej geometrii sieci.</String>
<String key="PowerOverheadLineOnly">Zasilanie tylko pod siecią trakcyjna</String>
<String key="PowerOverheadLineOnlyDesc">Gdy wyłączone, podniesiony pantograf zasila pojazd nawet bez kontaktu z drutem.</String>
<String key="SaveSpeedometerTapes">Zapisuj log parametrów fizycznych</String>
<String key="SaveSpeedometerTapesDesc">Zapisuje szczegółowy log jazdy do folderu physicslog/.</String>
<String key="SaveBlackBox">Zapisuj czarną skrzynkę i taśmy prędkościomierza</String>
<String key="SaveBlackBoxDesc">Nagrywa przejazd do jednego pliku w folderze physicslog/, a po zamknięciu symulatora zapisuje taśmy (.dat) pojazdów, w których byłeś.</String>
<String key="SaveSpeedometerTapes">Zapisuj log parametrów fizycznych wszystkich pojazdów</String>
<String key="SaveSpeedometerTapesDesc">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.</String>
<String key="SaveSimLogs">Zapisuj log z symulacji</String>
<String key="KeepPrevLogs">Zachowuj poprzednie logi</String>
<String key="KeepPrevLogsDesc">Tworzy osobny plik logu dla każdej scenerii zamiast nadpisywać errors.txt.</String>
@@ -895,6 +897,7 @@
<String key="HaslerTrain">pociąg {0}</String>
<String key="HaslerRoleDrivenEarlier">Prowadzony wcześniej</String>
<String key="HaslerLiveIdle">Działa, gdy trwa sesja uruchomiona ze Startera.</String>
<String key="HaslerLiveAtClose">Czarna skrzynka zapisuje taśmy po zamknięciu symulatora. Na żywo działa z logiem parametrów fizycznych.</String>
<String key="HaslerLogOff">Log symulatora jest wyłączony: Starter nie widzi przesiadek.</String>
<String key="HaslerLogEnable">Włącz log</String>
<String key="HaslerRoleStartedIn">Pojazd ze startu</String>

View File

@@ -497,7 +497,9 @@
<String key="PhysicsAccuracyIncreased">Повышенная точность физики</String>
<String key="BreakingPantographPossibility">Возможность излома пантографа</String>
<String key="PowerOverheadLineOnly">Питание только под контактной сетью</String>
<String key="SaveSpeedometerTapes">Сохранять ленты скоростемера</String>
<String key="SaveBlackBox">Записывать чёрный ящик и ленты скоростемера</String>
<String key="SaveBlackBoxDesc">Записывает поездку в один файл в папке physicslog/, а при закрытии симулятора сохраняет ленты (.dat) тех единиц, в которых вы были.</String>
<String key="SaveSpeedometerTapes">Сохранять физический лог всех единиц</String>
<String key="SaveSimLogs">Сохранять журнал симуляции</String>
<String key="KeepPrevLogs">Сохранять предыдущие журналы</String>
<String key="DisplaySimulation">Показывать симуляцию</String>
@@ -844,6 +846,7 @@
<String key="HaslerTrain">поезд {0}</String>
<String key="HaslerRoleDrivenEarlier">Управлялся ранее</String>
<String key="HaslerLiveIdle">Работает, пока идёт сеанс, запущенный из стартера.</String>
<String key="HaslerLiveAtClose">Чёрный ящик сохраняет ленты при закрытии симулятора. Режим «вживую» работает с физическим логом.</String>
<String key="HaslerLogOff">Журнал симулятора выключен: стартер не видит пересадок.</String>
<String key="HaslerLogEnable">Включить журнал</String>
<String key="HaslerRoleStartedIn">Транспорт на старте</String>