mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-16 13:04:09 +01:00
fix(blackbox): a buzzer cut by the power or the protection switched off is not acknowledged, and is named by every lamp it had
The keys tab's English names the train brake's positions and the dashboard light as the black box does.
This commit is contained in:
@@ -200,25 +200,35 @@ public sealed class EventList : ListBox
|
||||
var brakings = recording.SecurityBrakings();
|
||||
foreach (var span in recording.SecurityAlarms())
|
||||
{
|
||||
string who = ProtectionName(recording.CabAt(span.Start));
|
||||
// The lamps of all its samples: one buzzer for both, the other may join it before it's acknowledged.
|
||||
var lamps = recording.Cab.Where(c => c.Time >= span.Start && c.Time <= span.End)
|
||||
.Aggregate(SecurityFlags.None, (all, c) => all | c.Security);
|
||||
string who = ProtectionName(lamps);
|
||||
var before = recording.CabAt(span.Start);
|
||||
string text = brakings.Any(b => b.Start >= span.Start && b.Start <= span.End)
|
||||
? string.Format(culture, strings["EventSecurityAlarmMissed"], who)
|
||||
// Acknowledged when the sample it ended at buzzes no more: not the end of the recording or a gap in it.
|
||||
// Acknowledged when the sample it ended at buzzes no more and doesn't brake, in the same vehicle: not
|
||||
// the end of the recording or a gap in it, nor the power cut or the protection switched off.
|
||||
: recording.CabAt(span.End) is { } after && !after.VigilanceBuzzer && !after.CabSignalBuzzer
|
||||
&& !after.Has(SecurityFlags.Braking) && after.Vehicle == before?.Vehicle
|
||||
? string.Format(culture, strings["EventSecurityAlarmAcknowledged"], who, span.End - span.Start)
|
||||
: string.Format(culture, strings["EventSecurityAlarm"], who);
|
||||
events.Add(new BlackBoxEvent(span.Start, text, Palette.Buzzer, false));
|
||||
}
|
||||
foreach (var span in brakings)
|
||||
events.Add(new BlackBoxEvent(span.Start, string.Format(culture, strings["EventSecurityBraking"],
|
||||
ProtectionName(recording.CabAt(span.Start))), Palette.Bad, true));
|
||||
ProtectionName(recording.CabAt(span.Start)?.Security ?? SecurityFlags.None)),
|
||||
Palette.Bad, true));
|
||||
}
|
||||
|
||||
/// <summary>Which of them it was: the lamps blinking.</summary>
|
||||
private static string ProtectionName(CabSample? sample) =>
|
||||
sample is not { } s ? "CA"
|
||||
: s.Has(SecurityFlags.CabSignal) && s.Has(SecurityFlags.Vigilance) ? "CA/SHP"
|
||||
: s.Has(SecurityFlags.CabSignal) ? "SHP" : "CA";
|
||||
private static string ProtectionName(SecurityFlags lamps) =>
|
||||
(lamps & (SecurityFlags.CabSignal | SecurityFlags.Vigilance)) switch
|
||||
{
|
||||
SecurityFlags.CabSignal | SecurityFlags.Vigilance => "CA/SHP",
|
||||
SecurityFlags.CabSignal => "SHP",
|
||||
_ => "CA"
|
||||
};
|
||||
|
||||
private static void AddUserVehicles(Recording recording, IBlackBoxStrings strings, List<BlackBoxEvent> events, CultureInfo culture)
|
||||
{
|
||||
|
||||
@@ -53,6 +53,26 @@ public class SecurityBrakingTests
|
||||
Assert.Empty(recording.SecurityBrakings());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_buzzer_cut_by_the_power_is_not_acknowledged()
|
||||
{
|
||||
var recording = Drive(t => t is >= 2 and < 4 ? CabSignalBuzzing : t is >= 4 and < 8 ? NoPower : (byte)0);
|
||||
|
||||
var events = Events(recording);
|
||||
|
||||
Assert.Contains("Brzęczyk SHP", events);
|
||||
Assert.DoesNotContain(events, e => e.Contains("potwierdzony", System.StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_buzzer_the_other_joins_is_named_by_both()
|
||||
{
|
||||
// the alerter's buzzer, then a magnet passed before it's acknowledged
|
||||
var recording = Drive(t => t is >= 2 and < 4 ? (byte)0x05 : t is >= 4 and < 5 ? (byte)0x0f : (byte)0);
|
||||
|
||||
Assert.Contains("Brzęczyk CA/SHP, potwierdzony po 3.0 s", Events(recording));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_buzzer_not_acknowledged_is_followed_by_the_braking()
|
||||
{
|
||||
|
||||
@@ -859,8 +859,8 @@
|
||||
<String key="Cmd.trainbrakecharging">train brake valve: overcharge the brake pipe</String>
|
||||
<String key="Cmd.trainbrakerelease">train brake valve: running position</String>
|
||||
<String key="Cmd.trainbrakefirstservice">train brake valve: first braking step</String>
|
||||
<String key="Cmd.trainbrakeservice">train brake valve: full service</String>
|
||||
<String key="Cmd.trainbrakefullservice">train brake valve: supplementary braking</String>
|
||||
<String key="Cmd.trainbrakeservice">train brake valve: service braking</String>
|
||||
<String key="Cmd.trainbrakefullservice">train brake valve: full service</String>
|
||||
<String key="Cmd.trainbrakehandleoff">train brake valve: lap position</String>
|
||||
<String key="Cmd.trainbrakeemergency">emergency braking</String>
|
||||
<String key="Cmd.trainbrakebasepressureincrease">raise the brake pipe pressure level</String>
|
||||
@@ -970,7 +970,7 @@
|
||||
<String key="Cmd.interiorlightdimtoggle">toggle cab light dimming</String>
|
||||
<String key="Cmd.compartmentlightstoggle">toggle the compartment lights</String>
|
||||
<String key="Cmd.instrumentlighttoggle">toggle the instrument lights</String>
|
||||
<String key="Cmd.dashboardlighttoggle">toggle the desk lights</String>
|
||||
<String key="Cmd.dashboardlighttoggle">toggle the dashboard light</String>
|
||||
<String key="Cmd.timetablelighttoggle">toggle the timetable light</String>
|
||||
<String key="Cmd.generictoggle0">generic switch 0</String>
|
||||
<String key="Cmd.generictoggle1">generic switch 1</String>
|
||||
|
||||
Reference in New Issue
Block a user