Black box: older recordings read as before, single vehicles told apart, each platform end its own tolerance

- A light pattern asked for in a recording made before the lamps were
  written is checked as the signal it shows, as before.
- Whether the couplings were written is told by the format (the
  movement in the cab samples), not by there being any: a recording
  where every train is a single vehicle has none, and the user going
  over to another vehicle left the timetable shown.
- The 2 m a train may stand off the platform is at each end, not for
  both together.
This commit is contained in:
maj00r
2026-11-11 01:05:59 +01:00
parent 532875fc7b
commit de3f088ba8
5 changed files with 57 additions and 5 deletions

View File

@@ -124,6 +124,16 @@ public class HeadCodeTests
Assert.Empty(summary.LightsFaults);
}
[Fact]
public void An_older_recording_reads_a_pattern_asked_for_as_the_signal_it_shows()
{
// Pc 5 asked for at the tail, the rear-end signals lit, no lamps written: Pc 5 as before
var f = new BlackBoxFile().Info();
for (double t = 0; t < 30; t += 0.5)
f.Cab(t, 1, 1000 + t * 10, 40, lightsHead: Pc1, lightsTail: 0x40, movement: 1, hintTail: 0x22);
Assert.Empty(BlackBoxReader.Read(f.End(30).Stream()).Summarize().LightsFaults);
}
[Fact]
public void An_older_recording_tells_nothing_of_the_signals()
{
@@ -155,6 +165,32 @@ public class UserVehicleTests
Assert.Equal("ROJ1", r.TimetableAt(70)!.Train);
Assert.Null(r.TimetableAt(120));
}
[Fact]
public void Single_vehicles_with_no_coupling_written_are_still_told_apart()
{
// A recording made with the movement written, where no train is longer than one vehicle: no coupling at all.
var f = new BlackBoxFile().Info()
.Timetable(0, 1, "ROJ1", "A", "B", ("A", -1, 635), ("B", 640, -1));
for (double t = 0; t < 100; t += 0.5)
f.Cab(t, t < 50 ? 1u : 9u, 1000, 0, movement: 1);
var r = BlackBoxReader.Read(f.End(100).Stream());
Assert.Equal("ROJ1", r.TimetableAt(20)!.Train);
Assert.Null(r.TimetableAt(70));
}
[Fact]
public void An_older_recording_with_no_coupling_keeps_the_timetable()
{
var f = new BlackBoxFile().Info()
.Timetable(0, 1, "ROJ1", "A", "B", ("A", -1, 635), ("B", 640, -1));
for (double t = 0; t < 100; t += 0.5)
f.Cab(t, t < 50 ? 1u : 2u, 1000, 0);
var r = BlackBoxReader.Read(f.End(100).Stream());
Assert.Equal("ROJ1", r.TimetableAt(70)!.Train);
}
}
/// <summary>The departures and the platforms in the summary.</summary>

View File

@@ -47,6 +47,15 @@ public class PlatformTests
Assert.Equal(1, stop.OffPlatform, 1);
}
[Fact]
public void Each_end_has_its_own_tolerance()
{
// the head 1.5 m past the stop point, the tail 1.5 m past the platform's end
var stop = Stop(-1.5f, 204f, 201);
Assert.True(stop.OnPlatform);
Assert.Equal(3, stop.OffPlatform, 1);
}
[Fact]
public void A_train_within_the_platform_is_along_it()
{