mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 15:02:15 +01:00
fix(blackbox): the protection braking with no power not counted as the driver's
TSecuritySystem brakes whenever it has no power, a cab not yet started or a power cut, with no lamp lit. Only braking with the alerter or the cab signalling lamp is the driver's not acknowledging.
This commit is contained in:
@@ -519,8 +519,13 @@ public sealed class Recording
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>When the train protection braked the user's train: the alerter or the cab signalling not acknowledged.</summary>
|
/// <summary>
|
||||||
public IReadOnlyList<TimeSpanRange> SecurityBrakings() => CabSpans(s => s.Has(SecurityFlags.Braking));
|
/// When the train protection braked the user's train: the alerter or the cab signalling not acknowledged, its lamp
|
||||||
|
/// blinking. Braking with neither is the protection with no power (TSecuritySystem::is_braking), a cab not yet
|
||||||
|
/// started or a power cut: no driver's fault, not counted.
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyList<TimeSpanRange> SecurityBrakings() =>
|
||||||
|
CabSpans(s => s.Has(SecurityFlags.Braking) && (s.Has(SecurityFlags.Vigilance) || s.Has(SecurityFlags.CabSignal)));
|
||||||
|
|
||||||
/// <summary>The commands the user gave in a vehicle, presses only.</summary>
|
/// <summary>The commands the user gave in a vehicle, presses only.</summary>
|
||||||
public IEnumerable<CommandEntry> UserCommands() => _commands.Where(c => c.Pressed && c.Vehicle != 0);
|
public IEnumerable<CommandEntry> UserCommands() => _commands.Where(c => c.Pressed && c.Vehicle != 0);
|
||||||
|
|||||||
19
StarterNG.Tests/BlackBox/SecurityBrakingTests.cs
Normal file
19
StarterNG.Tests/BlackBox/SecurityBrakingTests.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Eu07.BlackBox;
|
||||||
|
|
||||||
|
namespace StarterNG.Tests.BlackBox;
|
||||||
|
|
||||||
|
public class SecurityBrakingTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void The_protection_braking_with_no_power_is_not_the_drivers_fault()
|
||||||
|
{
|
||||||
|
var file = new BlackBoxFile().Info().Vehicle(1, "EP07-424").User(0, 1, true);
|
||||||
|
// no power for the first seconds, then the cab signalling not acknowledged
|
||||||
|
for (double t = 0; t <= 20; t += 0.5)
|
||||||
|
file.Cab(t, 1, 100, 0, security: (byte)(t < 5 ? 0x10 : t is >= 10 and < 12 ? 0x1a : 0));
|
||||||
|
var recording = BlackBoxReader.Read(file.Stream());
|
||||||
|
|
||||||
|
var braking = Assert.Single(recording.SecurityBrakings());
|
||||||
|
Assert.Equal(10, braking.Start, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user