From aebfaf34ac4bc281ac01384de5718ccfbcc8dc52 Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 16 Nov 2026 02:20:34 +0100 Subject: [PATCH] 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. --- Eu07.BlackBox.Views/EventList.cs | 24 +++++++++++++------ .../BlackBox/SecurityBrakingTests.cs | 20 ++++++++++++++++ StarterNG/startercfg/lang/en.xml | 6 ++--- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Eu07.BlackBox.Views/EventList.cs b/Eu07.BlackBox.Views/EventList.cs index 4bcb854..91aa150 100644 --- a/Eu07.BlackBox.Views/EventList.cs +++ b/Eu07.BlackBox.Views/EventList.cs @@ -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)); } /// Which of them it was: the lamps blinking. - 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 events, CultureInfo culture) { diff --git a/StarterNG.Tests/BlackBox/SecurityBrakingTests.cs b/StarterNG.Tests/BlackBox/SecurityBrakingTests.cs index e6d6ae5..12e0816 100644 --- a/StarterNG.Tests/BlackBox/SecurityBrakingTests.cs +++ b/StarterNG.Tests/BlackBox/SecurityBrakingTests.cs @@ -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() { diff --git a/StarterNG/startercfg/lang/en.xml b/StarterNG/startercfg/lang/en.xml index e0a4ba1..19020ca 100644 --- a/StarterNG/startercfg/lang/en.xml +++ b/StarterNG/startercfg/lang/en.xml @@ -859,8 +859,8 @@ train brake valve: overcharge the brake pipe train brake valve: running position train brake valve: first braking step - train brake valve: full service - train brake valve: supplementary braking + train brake valve: service braking + train brake valve: full service train brake valve: lap position emergency braking raise the brake pipe pressure level @@ -970,7 +970,7 @@ toggle cab light dimming toggle the compartment lights toggle the instrument lights - toggle the desk lights + toggle the dashboard light toggle the timetable light generic switch 0 generic switch 1