diff --git a/Eu07.BlackBox.Views/CabPanel.cs b/Eu07.BlackBox.Views/CabPanel.cs
index b5f9c50..e6cdfb1 100644
--- a/Eu07.BlackBox.Views/CabPanel.cs
+++ b/Eu07.BlackBox.Views/CabPanel.cs
@@ -95,11 +95,16 @@ public sealed class CabPanel : Control
context.DrawText(speed, new Point(Pad, 24));
var unit = MapView.Text("km/h", Palette.DimText, 12);
context.DrawText(unit, new Point(Pad + speed.Width + 4, 24 + speed.Height - 21));
- // the wheels, when they turn otherwise: slipping, or locked in a skid
- if (s.WheelSpeedKmh is { } wheels && Math.Abs(Math.Abs(wheels) - s.AbsSpeedKmh) >= WheelsApartKmh)
- context.DrawText(MapView.Text(string.Format(culture, Strings["CabWheels"], Math.Abs(wheels)), Palette.Warn, 12),
- new Point(Pad + speed.Width + 4 + unit.Width + 8, 24 + speed.Height - 21));
double gaugeX = Pad + Math.Max(150, width * 0.42);
+ // the wheels, when they turn otherwise: slipping, or locked in a skid. Signed both, so wheels slipping ahead
+ // of a train rolling back show too. Kept off the gauges at the right, as the AI's line is.
+ if (s.WheelSpeedKmh is { } wheels && Math.Abs(wheels - s.SpeedKmh) >= WheelsApartKmh)
+ {
+ double wheelsX = Pad + speed.Width + 4 + unit.Width + 8;
+ using (context.PushClip(new Rect(wheelsX, 24, Math.Max(0, gaugeX - 8 - wheelsX), 40)))
+ context.DrawText(MapView.Text(string.Format(culture, Strings["CabWheels"], Math.Abs(wheels)), Palette.Warn, 12),
+ new Point(wheelsX, 24 + speed.Height - 21));
+ }
if (s.AiValid)
{
using (context.PushClip(new Rect(Pad, 76, gaugeX - Pad - 8, 40)))
diff --git a/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs b/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
index 15af89f..cee8efd 100644
--- a/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
+++ b/StarterNG.Tests/BlackBox/BlackBoxListingTests.cs
@@ -60,13 +60,15 @@ public class BlackBoxListingTests
public void Black_boxes_with_no_launch_noted_go_with_the_tapes_written_about_the_same_time()
{
var early = new DateTime(2026, 3, 1, 12, 0, 0, DateTimeKind.Utc);
+ // named in the local time they started at, whatever the zone the tests run in
+ string first = Box("td", early.AddHours(-1)), second = Box("td", early.AddMinutes(30));
var installation = new TestInstallation(new InMemoryFileSystem()
.WithFile(Log("a.dat"), "t")
- .WithFile(Log("td_2026-03-01_11-00-00.blackbox"), "b")
- .WithFile(Log("td_2026-03-01_12-30-00.blackbox"), "b")
+ .WithFile(Log(first), "b")
+ .WithFile(Log(second), "b")
.WrittenAt(Log("a.dat"), early)
- .WrittenAt(Log("td_2026-03-01_11-00-00.blackbox"), early.AddSeconds(2))
- .WrittenAt(Log("td_2026-03-01_12-30-00.blackbox"), early.AddHours(1)));
+ .WrittenAt(Log(first), early.AddSeconds(2))
+ .WrittenAt(Log(second), early.AddHours(1)));
var sessions = installation.Tapes.Sessions();
@@ -74,9 +76,9 @@ public class BlackBoxListingTests
Assert.All(sessions, session => Assert.Null(session.Launch));
// Newest first: the black box on its own, then the run with the tape.
Assert.Empty(sessions[0].Tapes);
- Assert.EndsWith("12-30-00.blackbox", Assert.Single(sessions[0].BlackBoxes).Path);
+ Assert.EndsWith(second, Assert.Single(sessions[0].BlackBoxes).Path);
Assert.Single(sessions[1].Tapes);
- Assert.EndsWith("11-00-00.blackbox", Assert.Single(sessions[1].BlackBoxes).Path);
+ Assert.EndsWith(first, Assert.Single(sessions[1].BlackBoxes).Path);
Assert.Equal(early, sessions[1].StartedUtc);
}
@@ -102,6 +104,31 @@ public class BlackBoxListingTests
Assert.EndsWith(box, Assert.Single(session.BlackBoxes).Path);
}
+ [Fact]
+ public void A_black_box_downloaded_later_takes_in_no_tapes_of_the_runs_after_it()
+ {
+ // Shared and downloaded two weeks later, so last written then; a run of its own with no launch noted since.
+ var shared = new DateTime(2026, 3, 1, 12, 0, 0, DateTimeKind.Utc);
+ var later = shared.AddDays(7);
+ string old = Box("td", shared), own = Box("td", later);
+ var installation = new TestInstallation(new InMemoryFileSystem()
+ .WithFile(Log(old), "b").WrittenAt(Log(old), shared.AddDays(14))
+ .WithFile(Log(own), "b").WrittenAt(Log(own), later.AddMinutes(30))
+ .WithFile(Log("ra.dat"), "t").WrittenAt(Log("ra.dat"), later.AddMinutes(30).AddSeconds(1))
+ .WithFile(Log("left.dat"), "t").WrittenAt(Log("left.dat"), later.AddMinutes(10)));
+
+ var recordings = StarterNG.Application.HaslerTapes.Recordings(new[]
+ {
+ new StarterNG.Application.BlackBoxRecording(Log(old), shared.AddDays(14), 1),
+ new StarterNG.Application.BlackBoxRecording(Log(own), later.AddMinutes(30), 1),
+ });
+ Assert.EndsWith(own, StarterNG.Application.HaslerTapes.RecordingAt(later.AddMinutes(10), recordings)!.Path);
+
+ var mine = Assert.Single(installation.Tapes.Sessions(), session => session.Tapes.Count > 0);
+ Assert.Equal(new[] { "left", "ra" }, mine.Tapes.Select(tape => tape.Vehicle).Order());
+ Assert.EndsWith(own, Assert.Single(mine.BlackBoxes).Path);
+ }
+
[Fact]
public void The_black_box_of_a_running_session_is_listed_while_it_is_written()
{
diff --git a/StarterNG.Tests/HaslerTapeTests.cs b/StarterNG.Tests/HaslerTapeTests.cs
index 8858f7c..15e2934 100644
--- a/StarterNG.Tests/HaslerTapeTests.cs
+++ b/StarterNG.Tests/HaslerTapeTests.cs
@@ -111,6 +111,77 @@ public class HaslerTapeTests
Assert.Equal(25 / 3.0 * 3.6, tape.AverageWithStopsKmh, 6);
}
+ [Fact]
+ public void A_stall_of_the_simulator_a_little_over_a_second_is_driven_not_a_gap()
+ {
+ // a line every 0.05 s, as at 60 FPS, and one step of 1.017 s: the frame held to a second, and the frame after
+ var text = new System.Text.StringBuilder(Header);
+ double t = 0;
+ for (int i = 0; i < 40; i++, t += 0.05)
+ text.Append(Line(t, 100, 0, 0));
+ t += 1.017 - 0.05;
+ for (int i = 0; i < 40; i++, t += 0.05)
+ text.Append(Line(t, 100, 0, 0));
+
+ var tape = HaslerTape.Parse(text.ToString());
+
+ Assert.Equal(0, tape.GapTime, 6);
+ Assert.Equal(tape.Duration, tape.RunningTime, 6);
+ Assert.Equal(tape.Duration * 100 / 3.6, tape.DistanceM, 6);
+ }
+
+ [Fact]
+ public void A_tape_read_in_pieces_cut_anywhere_is_the_tape_read_whole()
+ {
+ string text = Header + Line(0, 18, 0, 0, command: "Set Velocity") + Line(1, 36, 0.45, 0) + Line(2, 36, 0, 400)
+ + Line(602, 36, 0, 0, security: 1) + Line(603, 0, 0, 0);
+ var whole = HaslerTape.Parse(text);
+
+ for (int cut = 1; cut < text.Length; cut += 7)
+ {
+ var reader = new HaslerTape.Reader();
+ reader.Feed(text[..cut]);
+ reader.Feed(text[cut..]);
+ Assert.Equal(whole.Samples, reader.Tape(final: true).Samples);
+ }
+ }
+
+ [Fact]
+ public void A_line_not_ended_waits_for_its_end_while_the_tape_is_followed()
+ {
+ var reader = new HaslerTape.Reader();
+ string line = Line(1, 36, 0, 0);
+ reader.Feed(Header + Line(0, 36, 0, 0) + line[..20]);
+
+ Assert.Single(reader.Tape(final: false).Samples);
+ Assert.Single(reader.Tape(final: false).Samples);
+ reader.Feed(line[20..]);
+ Assert.Equal(2, reader.Tape(final: false).Samples.Count);
+ }
+
+ [Fact]
+ public void A_followed_tape_reads_what_was_added_and_one_begun_anew_whole()
+ {
+ string path = TestInstallation.At("physicslog", "EU07-424.dat");
+ var files = new InMemoryFileSystem().WithFile(path, Header + Line(0, 36, 0, 0));
+ var tapes = new TestInstallation(files).Tapes;
+ var file = Assert.Single(tapes.List());
+
+ Assert.Single(tapes.Load(file, follow: false)!.Samples);
+ files.WithFile(path, Header + Line(0, 36, 0, 0) + Line(1, 36, 0, 0) + Line(2, 36, 0, 0));
+ Assert.Equal(3, tapes.Load(file, follow: true)!.Samples.Count);
+
+ // begun anew, and already longer than was read: its time goes back
+ files.WithFile(path, Header + Line(0, 72, 0, 0) + Line(1, 72, 0, 0) + Line(2, 72, 0, 0) + Line(3, 72, 0, 0));
+ var tape = tapes.Load(file, follow: true)!;
+ Assert.Equal(4, tape.Samples.Count);
+ Assert.All(tape.Samples, s => Assert.Equal(72, s.SpeedKmh, 6));
+
+ // begun anew, and shorter
+ files.WithFile(path, Header + Line(0, 18, 0, 0));
+ Assert.Equal(18, Assert.Single(tapes.Load(file, follow: true)!.Samples).SpeedKmh, 6);
+ }
+
[Fact]
public void The_sample_under_a_point_of_the_tape_is_found_by_time_and_by_distance()
{
diff --git a/StarterNG/Application/HaslerTapes.cs b/StarterNG/Application/HaslerTapes.cs
index 9ef1d65..c183ebe 100644
--- a/StarterNG/Application/HaslerTapes.cs
+++ b/StarterNG/Application/HaslerTapes.cs
@@ -284,8 +284,9 @@ public sealed class HaslerTapes
// 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 recordings = Recordings(looseBoxes);
var loose = tapes.Where(t => tapeLaunch[t] is null)
- .Select(t => (Written: RecordingAt(t.LastWriteUtc, looseBoxes)?.LastWriteUtc ?? t.LastWriteUtc,
+ .Select(t => (Written: RecordingAt(t.LastWriteUtc, recordings)?.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);
@@ -320,15 +321,38 @@ public sealed class HaslerTapes
}
}
+ ///
+ /// When each black box recorded, its name read once: from the start its name has, to when it was last written,
+ /// and the tapes a moment after. No longer than until the next one started, though: a box downloaded or copied
+ /// later was last written then, not when it stopped, and would take in the tapes of the runs since.
+ ///
+ public static IReadOnlyList<(BlackBoxRecording Box, DateTime FromUtc, DateTime ToUtc)> Recordings(IEnumerable boxes)
+ {
+ var named = boxes.Select(box => (Box: box, Named: NamedBy(box.Path)))
+ .Where(each => each.Named is not null)
+ .Select(each => (each.Box, FromUtc: each.Named!.Value.StartedUtc))
+ .OrderBy(each => each.FromUtc)
+ .ToList();
+ var recordings = new List<(BlackBoxRecording, DateTime, DateTime)>(named.Count);
+ for (int i = 0; i < named.Count; i++)
+ {
+ var to = named[i].Box.LastWriteUtc + TapesAfterBlackBox;
+ if (i + 1 < named.Count && named[i + 1].FromUtc < to)
+ to = named[i + 1].FromUtc;
+ recordings.Add((named[i].Box, named[i].FromUtc, to));
+ }
+ return recordings;
+ }
+
///
/// 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();
+ public static BlackBoxRecording? RecordingAt(DateTime momentUtc, IEnumerable<(BlackBoxRecording Box, DateTime FromUtc, DateTime ToUtc)> recordings) =>
+ recordings.Where(each => each.FromUtc <= momentUtc && momentUtc <= each.ToUtc)
+ .OrderBy(each => (each.Box.LastWriteUtc - momentUtc).Duration())
+ .Select(each => each.Box)
+ .FirstOrDefault();
private TapeFile ReadTape(string path) =>
new(path, Path.GetFileNameWithoutExtension(path), _files.GetLastWriteTimeUtc(path), _files.GetFileSize(path));
@@ -426,19 +450,64 @@ public sealed class HaslerTapes
return new TapeSession(launch, started, written.Count > 0 ? written.Max() : started, running, listed, recorded);
}
- public HaslerTape? Load(TapeFile file)
+ // the tape followed as the simulator writes it: what of its file was read, and where it ended
+ private readonly object _followedLock = new();
+ private (string Path, long Read, byte[] Tail, HaslerTape.Reader Reader)? _followed;
+ // what of the end of the read part is kept, to tell the file still has it: one begun anew doesn't
+ private const int FollowedTail = 256;
+
+ public HaslerTape? Load(TapeFile file) => Load(file, follow: false);
+
+ private static byte[] Bytes(Stream stream, long from, long to)
{
- try
+ stream.Seek(from, SeekOrigin.Begin);
+ var bytes = new byte[to - from];
+ stream.ReadExactly(bytes);
+ return bytes;
+ }
+
+ ///
+ /// The tape of the file. Followed, the one read last and grown since: only what was added is read, so a log
+ /// written fast, at a higher time speed, is kept up with; a line not ended yet waits for the next time. Not
+ /// followed, or another file, or one shorter than was read - begun anew - it is read whole, and kept to be
+ /// followed from there.
+ ///
+ public HaslerTape? Load(TapeFile file, bool follow)
+ {
+ lock (_followedLock)
{
- // Through OpenRead, which does not mind the simulator still writing the file.
- using var stream = _files.OpenRead(file.Path);
- using var reader = new StreamReader(stream, Encoding.ASCII);
- return HaslerTape.Parse(reader.ReadToEnd());
- }
- catch (Exception ex)
- {
- _log.Log($"reading {file.Path}", ex);
- return null;
+ try
+ {
+ // Through OpenRead, which does not mind the simulator still writing the file.
+ using var stream = _files.OpenRead(file.Path);
+ if (!stream.CanSeek)
+ {
+ _followed = null;
+ using var whole = new StreamReader(stream, Encoding.ASCII);
+ return HaslerTape.Parse(whole.ReadToEnd());
+ }
+
+ long length = stream.Length;
+ // the same file grown, its end as it was read: else another, or begun anew, read whole
+ if (!follow || _followed is not { } followed || followed.Path != file.Path || length < followed.Read
+ || !Bytes(stream, followed.Read - followed.Tail.Length, followed.Read).AsSpan().SequenceEqual(followed.Tail))
+ followed = (file.Path, 0, Array.Empty(), new HaslerTape.Reader());
+ followed.Reader.Feed(Encoding.ASCII.GetString(Bytes(stream, followed.Read, length)));
+ // the time went back in what was added: the log begun anew and already longer than was read
+ if (followed.Read > 0 && followed.Reader.WentBack)
+ {
+ followed = (file.Path, 0, Array.Empty(), new HaslerTape.Reader());
+ followed.Reader.Feed(Encoding.ASCII.GetString(Bytes(stream, 0, length)));
+ }
+ _followed = (file.Path, length, Bytes(stream, Math.Max(0, length - FollowedTail), length), followed.Reader);
+ return followed.Reader.Tape(final: !follow);
+ }
+ catch (Exception ex)
+ {
+ _followed = null;
+ _log.Log($"reading {file.Path}", ex);
+ return null;
+ }
}
}
}
diff --git a/StarterNG/Domain/Tapes/HaslerTape.cs b/StarterNG/Domain/Tapes/HaslerTape.cs
index 35e16c7..820ddc8 100644
--- a/StarterNG/Domain/Tapes/HaslerTape.cs
+++ b/StarterNG/Domain/Tapes/HaslerTape.cs
@@ -41,15 +41,22 @@ public sealed class HaslerTape
private const int SecurityFromEndOf25 = 6; // a log with no header to tell: the columns up to the water's temperature
private const int MinimumColumns = 17;
- private const double MinimumGapSeconds = 1.0;
+ // above the longest step the simulator makes at once (its frame is held to a second) and a line's interval: a
+ // stall of the simulator, a dragged window say, is time driven or stood, not a gap
+ private const double MinimumGapSeconds = 2.0;
private const int GapSteps = 20;
- public HaslerTape(IReadOnlyList samples)
+ public HaslerTape(IReadOnlyList samples) : this(samples, GapAbove(samples))
+ {
+ }
+
+ // the gap already found, by the reader: the steps are sorted once, not again here
+ private HaslerTape(IReadOnlyList samples, double gap)
{
Samples = samples;
foreach (var s in samples)
MaxSpeedKmh = Math.Max(MaxSpeedKmh, s.SpeedKmh);
- double gap = GapAbove(samples);
+ GapSeconds = gap;
for (int i = 1; i < samples.Count; i++)
{
double step = samples[i].Time - samples[i - 1].Time;
@@ -78,6 +85,9 @@ public sealed class HaslerTape
/// Seconds of not recorded: the gaps, see .
public double GapTime { get; }
+ /// A step between two lines longer than this is a gap: of this tape.
+ public double GapSeconds { get; }
+
public double StandingTime => Duration - RunningTime - GapTime;
/// Mean speed while moving.
@@ -89,7 +99,7 @@ public sealed class HaslerTape
///
/// A step between two lines longer than this is time not recorded, the player in another vehicle before
/// coming back to this one: neither driving nor standing, and no distance. The lines come every 0.05 s of
- /// simulated time or so; it is twenty of their usual steps, a second at least.
+ /// simulated time or so; it is twenty of their usual steps, two seconds at least.
///
public static double GapAbove(IReadOnlyList samples)
{
@@ -104,47 +114,102 @@ public sealed class HaslerTape
public static HaslerTape Parse(string text)
{
- var samples = new List();
+ var reader = new Reader();
+ reader.Feed(text);
+ return reader.Tape(final: true);
+ }
- int securityFromEnd = SecurityFromEndOf25;
- foreach (var raw in text.Split('\n'))
+ ///
+ /// A tape read as it is written: each piece of the file given once, in order, so a log the simulator keeps
+ /// adding to - fast, at a higher time speed - is not read and split from its start every time it grows. A line
+ /// not ended yet waits for the rest.
+ ///
+ public sealed class Reader
+ {
+ private readonly List _samples = new();
+ private readonly System.Text.StringBuilder _unended = new();
+ private int _securityFromEnd = SecurityFromEndOf25;
+
+ public void Feed(string text)
+ {
+ WentBack = false;
+ int start = 0;
+ for (int end = text.IndexOf('\n'); end >= 0; end = text.IndexOf('\n', start))
+ {
+ if (_unended.Length > 0)
+ {
+ _unended.Append(text, start, end - start);
+ Keep(_unended.ToString(), _samples);
+ _unended.Clear();
+ }
+ else
+ Keep(text.Substring(start, end - start), _samples);
+ start = end + 1;
+ }
+ _unended.Append(text, start, text.Length - start);
+ }
+
+ ///
+ /// The tape of what was read. Final, the end of the file: a last line with no end is read too, though
+ /// only for this tape; otherwise it may be cut short by a simulator still writing, and waits.
+ ///
+ public HaslerTape Tape(bool final)
+ {
+ var read = _samples;
+ if (final && _unended.Length > 0)
+ {
+ read = new List(_samples);
+ Keep(_unended.ToString(), read);
+ }
+ // the distance, trapezoid by trapezoid, none over the gaps
+ var samples = new List(read.Count);
+ double gap = GapAbove(read), distance = 0;
+ for (int i = 0; i < read.Count; i++)
+ {
+ var sample = read[i];
+ if (i > 0)
+ {
+ var before = read[i - 1];
+ double step = sample.Time - before.Time;
+ if (step <= gap)
+ distance += (before.SpeedKmh + sample.SpeedKmh) / 2 / 3.6 * step;
+ }
+ samples.Add(sample with { DistanceM = distance });
+ }
+ return new HaslerTape(samples, gap);
+ }
+
+ private void Keep(string raw, List samples)
{
var columns = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
if (columns.Length == 0)
- continue;
+ return;
if (!Number(columns[TimeColumn], out double time))
{
// the header; a line of figures may have the word too, in the free text of its command
int heading = Array.IndexOf(columns, SecurityHeading);
if (heading >= 0)
- securityFromEnd = columns.Length - heading;
- continue;
+ _securityFromEnd = columns.Length - heading;
+ return;
}
if (columns.Length < MinimumColumns || !Number(columns[VelocityColumn], out double velocity))
- continue; // a line cut short by a simulator still writing
+ return; // a line cut short by a simulator still writing
Number(columns[BrakePressColumn], out double brake);
Number(columns[PipePressColumn], out double pipe);
Number(columns[MotorCurrentColumn], out double current);
- bool security = securityFromEnd <= columns.Length && columns[^securityFromEnd] == "1";
+ bool security = _securityFromEnd <= columns.Length && columns[^_securityFromEnd] == "1";
if (samples.Count > 0 && time < samples[^1].Time)
- continue;
+ {
+ WentBack = true;
+ return;
+ }
samples.Add(new TapeSample(time, Math.Abs(velocity), 0, brake, pipe, current, security));
}
- // the distance, trapezoid by trapezoid, none over the gaps
- double gap = GapAbove(samples), distance = 0;
- for (int i = 1; i < samples.Count; i++)
- {
- var (before, sample) = (samples[i - 1], samples[i]);
- double step = sample.Time - before.Time;
- if (step <= gap)
- distance += (before.SpeedKmh + sample.SpeedKmh) / 2 / 3.6 * step;
- samples[i] = sample with { DistanceM = distance };
- }
-
- return new HaslerTape(samples);
+ /// In the last piece fed, a line whose time was before the last one's, left out: maybe the log begun anew.
+ public bool WentBack { get; private set; }
}
/// Index of the last sample at or before the given time or distance.
diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
index e917a3d..d5dc3c2 100644
--- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs
+++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs
@@ -631,7 +631,9 @@ public sealed class HaslerTapeWindow : Window
_loading = true;
try
{
- var tape = await Task.Run(() => _tapes.Load(file));
+ // the same tape grown, as the simulator writes it: only what was added is read
+ bool follow = file.Path == _shown?.Path && file.Size >= _shown.Size;
+ var tape = await Task.Run(() => _tapes.Load(file, follow));
bool another = file.Path != _shown?.Path;
_shown = file;
_tapeless = null;
@@ -646,10 +648,13 @@ public sealed class HaslerTapeWindow : Window
_view.Tape = tape;
ShowMark(scrollTo: another && !scrollToEnd);
- _summary.Text = string.Format(App.Loc["HaslerSummary"], file.Vehicle, TapeFigures.Clock(tape.Duration),
+ // what was recorded is running and standing; a gap, the player in another vehicle, is neither
+ _summary.Text = string.Format(App.Loc["HaslerSummary"], file.Vehicle, TapeFigures.Clock(tape.Duration - tape.GapTime),
TapeFigures.Clock(tape.RunningTime), TapeFigures.Clock(tape.StandingTime),
tape.DistanceM / 1000.0, tape.MaxSpeedKmh, tape.AverageSpeedKmh,
tape.AverageWithStopsKmh);
+ if (tape.GapTime > 0)
+ _summary.Text += " · " + string.Format(App.Loc["HaslerGap"], TapeFigures.Clock(tape.GapTime));
if (_context?.Scenery is { } scenery)
_summary.Text += " · " + string.Format(App.Loc["HaslerScenario"], scenery);
if (_context?.Train is { } train)
diff --git a/StarterNG/Views/Tapes/TapeView.cs b/StarterNG/Views/Tapes/TapeView.cs
index 88446c2..727fc30 100644
--- a/StarterNG/Views/Tapes/TapeView.cs
+++ b/StarterNG/Views/Tapes/TapeView.cs
@@ -247,8 +247,22 @@ public abstract class TapeView : Control
}
}
+ double? before = null;
foreach (var s in tape.Samples)
{
+ // A gap, the player in another vehicle, is not drawn as if the train drove or stood through it: the
+ // line breaks off there.
+ if (before is { } previous && s.Time - previous > tape.GapSeconds)
+ {
+ Flush();
+ column = int.MinValue;
+ if (begun)
+ {
+ g.EndFigure(false);
+ begun = false;
+ }
+ }
+ before = s.Time;
int c = (int)Math.Round(XOf(s));
double value = y(s);
if (c != column)
diff --git a/StarterNG/startercfg/lang/cz.xml b/StarterNG/startercfg/lang/cz.xml
index 3454476..3bd9b22 100644
--- a/StarterNG/startercfg/lang/cz.xml
+++ b/StarterNG/startercfg/lang/cz.xml
@@ -98,6 +98,7 @@
hodina neznámá, čas se počítá od startu simulace
Pásku {0} se nepodařilo přečíst.
{0} · zaznamenáno {1} (jízda {2}, stání {3}) · dráha {4:0.00} km · Vmax {5:0} km/h · průměr za jízdy {6:0} km/h · průměr se zastávkami {7:0} km/h
+ nezaznamenáno {0}
{0} · {1:0.0} km · {2:0} km/h · válce {3:0.0} bar · proud {4}
Válce
HP
diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml
index 00d18b2..3c10bf1 100644
--- a/StarterNG/startercfg/lang/en.xml
+++ b/StarterNG/startercfg/lang/en.xml
@@ -98,6 +98,7 @@
hour unknown, time counted from the start of the simulation
Could not read the tape {0}.
{0} · recorded {1} (running {2}, standing {3}) · distance {4:0.00} km · Vmax {5:0} km/h · running average {6:0} km/h · average with stops {7:0} km/h
+ not recorded {0}
{0} · {1:0.0} km · {2:0} km/h · cylinders {3:0.0} bar · current {4}
Cylinders
BP
diff --git a/StarterNG/startercfg/lang/hu.xml b/StarterNG/startercfg/lang/hu.xml
index 4f18345..2b4cf38 100644
--- a/StarterNG/startercfg/lang/hu.xml
+++ b/StarterNG/startercfg/lang/hu.xml
@@ -98,6 +98,7 @@
az óra ismeretlen, az idő a szimuláció kezdetétől számít
A(z) {0} szalag nem olvasható.
{0} · rögzítve {1} (menet {2}, állás {3}) · út {4:0.00} km · Vmax {5:0} km/h · menetátlag {6:0} km/h · átlag megállásokkal {7:0} km/h
+ nem rögzítve {0}
{0} · {1:0.0} km · {2:0} km/h · hengerek {3:0.0} bar · áram {4}
Hengerek
Fővez.
diff --git a/StarterNG/startercfg/lang/pl.xml b/StarterNG/startercfg/lang/pl.xml
index bdbec33..8d02a3f 100644
--- a/StarterNG/startercfg/lang/pl.xml
+++ b/StarterNG/startercfg/lang/pl.xml
@@ -98,6 +98,7 @@
godzina nieznana, czas liczony od startu symulacji
Nie udało się odczytać taśmy {0}.
{0} · zarejestrowano {1} (jazda {2}, postój {3}) · droga {4:0.00} km · Vmax {5:0} km/h · Vśr jazdy {6:0} km/h · Vśr z postojami {7:0} km/h
+ nie zarejestrowano {0}
{0} · {1:0.0} km · {2:0} km/h · cylindry {3:0.0} bar · prąd {4}
Cylindry
PG
diff --git a/StarterNG/startercfg/lang/ru.xml b/StarterNG/startercfg/lang/ru.xml
index bcdc7d4..2bca963 100644
--- a/StarterNG/startercfg/lang/ru.xml
+++ b/StarterNG/startercfg/lang/ru.xml
@@ -98,6 +98,7 @@
час неизвестен, время считается от начала симуляции
Не удалось прочитать ленту {0}.
{0} · записано {1} (движение {2}, стоянка {3}) · путь {4:0.00} км · Vmax {5:0} км/ч · средняя в движении {6:0} км/ч · средняя со стоянками {7:0} км/ч
+ не записано {0}
{0} · {1:0.0} км · {2:0} км/ч · цилиндры {3:0.0} бар · ток {4}
Цилиндры
ТМ