feat(tapes): the tapes of every train, physicslog.trains, turned on with the tape recording

The simulator writes the .dat logs of the drivers of rail vehicles only with
"physicslog.trains yes": the tape of every train, without the road vehicles
and the passengers that make "physicslog yes" hundreds of files. The settings
have a box for it, "Turn on recording" of the tapes' window turns it on with
the black box, and a launch is noted and followed with it. The black box goes
with it when the ini says nothing of its own, as the simulator has it; the line
is written only once on, or where the file has it.
This commit is contained in:
maj00r
2026-11-15 23:46:27 +01:00
parent b2fd53f7bc
commit 92c0283479
13 changed files with 77 additions and 8 deletions

View File

@@ -1371,6 +1371,41 @@ public class SettingsStoreTests
Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
}
[Theory]
[InlineData("physicslog no\n", false, false)]
[InlineData("physicslog no\nphysicslog.trains yes\n", true, true)]
[InlineData("physicslog no\nphysicslog.trains yes\nblackbox no\n", true, false)]
public void The_logs_of_the_trains_are_read_and_bring_the_black_box_as_the_simulator_has_it(string ini, bool trains, bool recorded)
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
installation.SettingsStore.Load();
Assert.Equal(trains, installation.SettingsStore.Settings.PhysicsLogTrains);
Assert.Equal(recorded, installation.SettingsStore.Settings.BlackBox);
}
[Fact]
public void The_logs_of_the_trains_are_written_only_once_on_or_where_the_file_has_them()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Save();
Assert.Null(LineFor(installation, "physicslog.trains"));
installation.SettingsStore.Settings.PhysicsLogTrains = true;
installation.SettingsStore.Settings.BlackBox = true;
installation.SettingsStore.Save();
Assert.Equal("physicslog.trains yes", LineFor(installation, "physicslog.trains"));
// it says no more than the logs of the trains bring
Assert.Null(LineFor(installation, "blackbox"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.PhysicsLogTrains = false;
installation.SettingsStore.Save();
Assert.Equal("physicslog.trains no", LineFor(installation, "physicslog.trains"));
}
[Fact]
public void A_black_box_line_written_once_goes_away_when_it_says_no_more()
{

View File

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

View File

@@ -140,6 +140,13 @@ public sealed class SimulatorSettings
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;
/// <summary>
/// The physics logs (.dat) of the trains only, "physicslog.trains": of each driver of rail vehicles, not of the
/// passengers nor of the vehicles of the roads. The tapes of every train, far fewer files than the log of every vehicle.
/// </summary>
public bool PhysicsLogTrains;
/// <summary>Whether eu07.ini had a line for the logs of the trains when read: kept, else written only when on.</summary>
public bool PhysicsLogTrainsInIni;
public bool DebugLog = true;
public bool MultipleLogs;
public bool DisplaySimulation = true;

View File

@@ -157,9 +157,11 @@ 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.PhysicsLogTrainsInIni = c.Has("physicslog.trains");
s.PhysicsLogTrains = c.GetBool("physicslog.trains", false);
// the simulator records the black box along with the physics logs when the ini says nothing of it
s.BlackBoxInIni = c.Has("blackbox");
s.BlackBox = s.BlackBoxInIni ? c.GetBool("blackbox", false) : s.PhysicsLog;
s.BlackBox = s.BlackBoxInIni ? c.GetBool("blackbox", false) : s.PhysicsLog || s.PhysicsLogTrains;
int debugLog = c.GetInt("debuglog", 3);
s.DebugLog = (debugLog & 1) != 0;
s.DebugLogVisible = (debugLog & 2) != 0;
@@ -373,10 +375,13 @@ 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
// written where it says more than the physics logs, 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)
if (s.BlackBoxInIni || s.BlackBox != (s.PhysicsLog || s.PhysicsLogTrains))
c.SetBool("blackbox", s.BlackBox);
// a simulator before it doesn't know the line: an ini without it stays so while it is off
if (s.PhysicsLogTrainsInIni || s.PhysicsLogTrains)
c.SetBool("physicslog.trains", s.PhysicsLogTrains);
c.SetInt("debuglog",
(s.DebugLog ? 1 : 0) | (s.DebugLogVisible ? 2 : 0) | s.DebugLogExtraBits);
c.SetBool("multiplelogs", s.MultipleLogs);

View File

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

View File

@@ -556,6 +556,9 @@
<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 [SaveTrainTapesDesc], Source={x:Static starterNg:App.Loc}}" ConfigKey="physicslog.trains">
<CheckBox x:Name="TrainTapesCb" Content="{Binding [SaveTrainTapes], 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

@@ -330,6 +330,7 @@ public partial class Settings : UserControl, ISettingsCapture
{
SpeedometerTapesCb.IsChecked = AppServices.Current.Settings.PhysicsLog;
BlackBoxCb.IsChecked = AppServices.Current.Settings.BlackBox;
TrainTapesCb.IsChecked = AppServices.Current.Settings.PhysicsLogTrains;
SimLogsCb.IsChecked = AppServices.Current.Settings.DebugLog;
});
@@ -443,6 +444,7 @@ public partial class Settings : UserControl, ISettingsCapture
OverheadOnlyCb.IsChecked = s.LiveTraction;
SpeedometerTapesCb.IsChecked = s.PhysicsLog;
BlackBoxCb.IsChecked = s.BlackBox;
TrainTapesCb.IsChecked = s.PhysicsLogTrains;
SimLogsCb.IsChecked = s.DebugLog;
KeepLogsCb.IsChecked = s.MultipleLogs;
DisplaySimulationCb.IsChecked = s.DisplaySimulation;
@@ -877,6 +879,7 @@ public partial class Settings : UserControl, ISettingsCapture
s.LiveTraction = IsChecked(OverheadOnlyCb);
s.PhysicsLog = IsChecked(SpeedometerTapesCb);
s.BlackBox = IsChecked(BlackBoxCb);
s.PhysicsLogTrains = IsChecked(TrainTapesCb);
s.DebugLog = IsChecked(SimLogsCb);
s.MultipleLogs = IsChecked(KeepLogsCb);
s.DisplaySimulation = IsChecked(DisplaySimulationCb);

View File

@@ -163,7 +163,12 @@ public sealed class HaslerTapeWindow : Window
Content = _view
};
_recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings => settings.BlackBox = true);
// the black box, with the tapes of the player's vehicles, and the tapes of every train
_recordingOff = Strip("HaslerRecordingOff", "HaslerRecordingEnable", settings =>
{
settings.BlackBox = true;
settings.PhysicsLogTrains = true;
});
_logOff = Strip("HaslerLogOff", "HaslerLogEnable", settings => settings.DebugLog = true);
var folder = ToolButton(App.Loc["HaslerOpenFolder"]);
@@ -229,7 +234,7 @@ public sealed class HaslerTapeWindow : Window
private void ShowWhatIsKnown()
{
var settings = AppServices.Current.Settings;
bool recording = settings.PhysicsLog || settings.BlackBox;
bool recording = settings.PhysicsLog || settings.BlackBox || settings.PhysicsLogTrains;
_recordingOff.IsVisible = !recording;
_logOff.IsVisible = recording && !settings.DebugLog;

View File

@@ -500,6 +500,8 @@
<String key="PowerOverheadLineOnly">Napájení jen pod trolejí</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 průběžně, každé 2 s, zapisuje pásky (.dat) vozidel, ve kterých jste.</String>
<String key="SaveTrainTapes">Nahrávat pásky rychloměru všech vlaků</String>
<String key="SaveTrainTapesDesc">Průběžně, každé 2 s, zapisuje pásky (.dat) každého vlaku scenérie do složky physicslog/: jednu na strojvedoucího kolejových vozidel, bez silničních vozidel a cestujících. Mnohem méně souborů než fyzikální log každého vozidla.</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>

View File

@@ -519,6 +519,8 @@
<String key="PowerOverheadLineOnlyDesc">When disabled, a raised pantograph can power the vehicle even without touching the wire.</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 writes the tapes (.dat) of the vehicles you are in as it goes, every 2 s.</String>
<String key="SaveTrainTapes">Record the speedometer tapes of every train</String>
<String key="SaveTrainTapesDesc">Writes the tapes (.dat) of every train of the scenery to the physicslog/ folder as it goes, every 2 s: one per driver of rail vehicles, not of road vehicles nor passengers. Far fewer files than the physics log of every vehicle.</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: a line every 0.05 s, added every 2 s. For diagnostics: on a large scenery that is hundreds of files.</String>
<String key="SaveSimLogs">Save simulation log</String>

View File

@@ -500,6 +500,8 @@
<String key="PowerOverheadLineOnly">Táplálás csak felsővezeték alatt</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 menet közben, 2 másodpercenként kiírja azoknak a járműveknek a szalagjait (.dat), amelyekben ülsz.</String>
<String key="SaveTrainTapes">Minden vonat sebességmérő-szalagjának rögzítése</String>
<String key="SaveTrainTapesDesc">Menet közben, 2 másodpercenként kiírja a pálya minden vonatának szalagját (.dat) a physicslog/ mappába: egyet a sínjárművek minden vezetőjének, közúti járművek és utasok nélkül. Jóval kevesebb fájl, mint minden jármű fizikai naplója.</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>

View File

@@ -519,6 +519,8 @@
<String key="PowerOverheadLineOnlyDesc">Gdy wyłączone, podniesiony pantograf zasila pojazd nawet bez kontaktu z drutem.</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/ i na bieżąco, co 2 s, zapisuje taśmy (.dat) pojazdów, w których jesteś.</String>
<String key="SaveTrainTapes">Zapisuj taśmy prędkościomierza wszystkich pociągów</String>
<String key="SaveTrainTapesDesc">Na bieżąco, co 2 s, zapisuje taśmy (.dat) każdego pociągu scenerii do folderu physicslog/: jedną na maszynistę pojazdów szynowych, bez pojazdów drogowych i pasażerów. Znacznie mniej plików niż log fizyki każdego pojazdu.</String>
<String key="SaveSpeedometerTapes">Zapisuj log parametrów fizycznych wszystkich pojazdów</String>
<String key="SaveSpeedometerTapesDesc">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.</String>
<String key="SaveSimLogs">Zapisuj log z symulacji</String>

View File

@@ -500,6 +500,8 @@
<String key="PowerOverheadLineOnly">Питание только под контактной сетью</String>
<String key="SaveBlackBox">Записывать чёрный ящик и ленты скоростемера</String>
<String key="SaveBlackBoxDesc">Записывает поездку в один файл в папке physicslog/ и по ходу, каждые 2 с, сохраняет ленты (.dat) тех единиц, в которых вы находитесь.</String>
<String key="SaveTrainTapes">Записывать ленты скоростемера всех поездов</String>
<String key="SaveTrainTapesDesc">По ходу, каждые 2 с, сохраняет ленты (.dat) каждого поезда сценария в папку physicslog/: по одной на машиниста рельсового состава, без автомобилей и пассажиров. Гораздо меньше файлов, чем физический журнал каждой единицы.</String>
<String key="SaveSpeedometerTapes">Сохранять физический лог всех единиц</String>
<String key="SaveSimLogs">Сохранять журнал симуляции</String>
<String key="KeepPrevLogs">Сохранять предыдущие журналы</String>