From 37d099cdbd2546a6b09bb0eb39e4398d4bc178ce Mon Sep 17 00:00:00 2001 From: LucianoDev Date: Thu, 16 Apr 2026 13:22:48 +0200 Subject: [PATCH] feat: add Ford VP44 unlock progress dialog, K-Line fast unlock, localization, safety dialogs, and settings Unlock progress UI: - UnlockProgressDialog with dark-themed progress ring, phase indicator, elapsed time, and cancel/close buttons (non-modal, draggable borderless window) - UnlockProgressViewModel with event-driven progress tracking via IUnlockService - Triggers on pump selection (manual or K-Line auto-detect), not test start UnlockService rewrite: - Persistent CAN senders that outlive the unlock sequence (StopSenders on pump change) - Concurrent K-Line fast unlock: awaits session Connected, sends RAM timer shortcut ({02 88 02 03 A8 01 00}), verifies via CAN TestUnlock before skipping wait - Fix Type 1 verification (Value == 0 means unlocked, was inverted) K-Line fast unlock support: - IKwpService.TryFastUnlockAsync / KwpService implementation Additional features: - ILocalizationService with ES/EN resource dictionaries and runtime switching - Safety dialogs: VoltageWarning, OilPumpConfirm, RpmSafetyWarning - SettingsDialog for app configuration - BenchService enhancements, ConfigurationService improvements, PDF report updates - All UI strings localized via DynamicResource Co-Authored-By: Claude Opus 4.6 --- App.xaml | 5 + App.xaml.cs | 1 + CLAUDE.md | 10 +- MainWindow.xaml | 103 +++--- Models/BenchConfiguration.cs | 7 +- Resources/Strings.en.xaml | 322 +++++++++++++++++ Resources/Strings.es.xaml | 322 +++++++++++++++++ Services/IBenchService.cs | 13 + Services/IConfigurationService.cs | 5 +- Services/IKwpService.cs | 10 + Services/ILocalizationService.cs | 39 ++ Services/IUnlockService.cs | 9 + Services/Impl/BenchService.cs | 129 +++++++ Services/Impl/ConfigurationService.cs | 116 +++++- Services/Impl/KwpService.cs | 33 ++ Services/Impl/LocalizationService.cs | 83 +++++ Services/Impl/PdfService.cs | 79 +++-- Services/Impl/UnlockService.cs | 240 ++++++++++--- ViewModels/BenchControlViewModel.cs | 43 ++- ViewModels/DfiManageViewModel.cs | 12 +- ViewModels/Dialogs/KlineErrorsViewModel.cs | 7 +- ViewModels/Dialogs/OilPumpConfirmViewModel.cs | 51 +++ .../Dialogs/RpmSafetyWarningViewModel.cs | 72 ++++ ViewModels/Dialogs/SettingsViewModel.cs | 290 +++++++++++++++ ViewModels/Dialogs/UnlockProgressViewModel.cs | 152 ++++++++ ViewModels/Dialogs/UserCheckViewModel.cs | 8 +- ViewModels/Dialogs/VoltageWarningViewModel.cs | 41 +++ ViewModels/MainViewModel.cs | 205 +++++++++-- ViewModels/PhaseCardViewModel.cs | 9 +- ViewModels/PumpIdentificationViewModel.cs | 5 +- ViewModels/ResultDisplayViewModel.cs | 23 +- ViewModels/TestDisplayViewModel.cs | 11 +- ViewModels/TestPanelViewModel.cs | 10 +- ViewModels/TestSectionViewModel.cs | 34 +- Views/Dialogs/KlineErrorsDialog.xaml | 10 +- Views/Dialogs/OilPumpConfirmDialog.xaml | 57 +++ Views/Dialogs/OilPumpConfirmDialog.xaml.cs | 20 ++ Views/Dialogs/ReportDialog.xaml | 28 +- Views/Dialogs/RpmSafetyWarningDialog.xaml | 63 ++++ Views/Dialogs/RpmSafetyWarningDialog.xaml.cs | 20 ++ Views/Dialogs/SettingsDialog.xaml | 333 ++++++++++++++++++ Views/Dialogs/SettingsDialog.xaml.cs | 18 + Views/Dialogs/UnlockProgressDialog.xaml | 138 ++++++++ Views/Dialogs/UnlockProgressDialog.xaml.cs | 49 +++ Views/Dialogs/UserCheckDialog.xaml | 10 +- Views/Dialogs/VoltageWarningDialog.xaml | 59 ++++ Views/Dialogs/VoltageWarningDialog.xaml.cs | 20 ++ Views/UserControls/AngleDisplayView.xaml | 14 +- Views/UserControls/BenchParamConfigView.xaml | 10 +- Views/UserControls/DfiManageView.xaml | 55 +-- Views/UserControls/PumpControlView.xaml | 30 +- .../UserControls/PumpIdentificationView.xaml | 28 +- Views/UserControls/ResultDisplayView.xaml | 12 +- Views/UserControls/TestPanelView.xaml | 24 +- docs/gap-ford-unlock-ui.md | 89 +++-- 55 files changed, 3207 insertions(+), 379 deletions(-) create mode 100644 Resources/Strings.en.xaml create mode 100644 Resources/Strings.es.xaml create mode 100644 Services/ILocalizationService.cs create mode 100644 Services/Impl/LocalizationService.cs create mode 100644 ViewModels/Dialogs/OilPumpConfirmViewModel.cs create mode 100644 ViewModels/Dialogs/RpmSafetyWarningViewModel.cs create mode 100644 ViewModels/Dialogs/SettingsViewModel.cs create mode 100644 ViewModels/Dialogs/UnlockProgressViewModel.cs create mode 100644 ViewModels/Dialogs/VoltageWarningViewModel.cs create mode 100644 Views/Dialogs/OilPumpConfirmDialog.xaml create mode 100644 Views/Dialogs/OilPumpConfirmDialog.xaml.cs create mode 100644 Views/Dialogs/RpmSafetyWarningDialog.xaml create mode 100644 Views/Dialogs/RpmSafetyWarningDialog.xaml.cs create mode 100644 Views/Dialogs/SettingsDialog.xaml create mode 100644 Views/Dialogs/SettingsDialog.xaml.cs create mode 100644 Views/Dialogs/UnlockProgressDialog.xaml create mode 100644 Views/Dialogs/UnlockProgressDialog.xaml.cs create mode 100644 Views/Dialogs/VoltageWarningDialog.xaml create mode 100644 Views/Dialogs/VoltageWarningDialog.xaml.cs diff --git a/App.xaml b/App.xaml index 8ea1286..3a364b7 100644 --- a/App.xaml +++ b/App.xaml @@ -3,5 +3,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HC_APTBS"> + + + + + diff --git a/App.xaml.cs b/App.xaml.cs index aff240e..d2f826c 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -69,6 +69,7 @@ public partial class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // ── ViewModels ──────────────────────────────────────────────────────── services.AddSingleton(); diff --git a/CLAUDE.md b/CLAUDE.md index 691efc8..16d723c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -83,11 +83,14 @@ ViewModels/ — [ObservableProperty] / [RelayCommand], no UI lo FlowmeterChartViewModel.cs — Real-time flowmeter charts AngleDisplayViewModel.cs — Encoder angle monitoring (PSG, INJ, Manual, Lock Angle) StatusDisplayViewModel.cs — Pump status word display - Dialogs/ — KlineErrors, Progress, Report, UserCheck ViewModels + Dialogs/ — KlineErrors, OilPumpConfirm, Progress, Report, RpmSafetyWarning, + Settings, UnlockProgress, UserCheck, VoltageWarning ViewModels Views/ MainWindow.xaml — Root UI (multi-panel layout) - Dialogs/ — KlineErrorsDialog, ProgressDialog, ReportDialog, UserCheckDialog + Dialogs/ — KlineErrorsDialog, OilPumpConfirmDialog, ProgressDialog, + ReportDialog, RpmSafetyWarningDialog, SettingsDialog, + UnlockProgressDialog, UserCheckDialog, VoltageWarningDialog UserControls/ — AngleDisplay, BenchParamConfig, DfiManage, FlowmeterChart, PumpControl, PumpIdentification, ResultDisplay, StatusDisplay, TestDisplay, TestPanel @@ -147,14 +150,11 @@ See `docs/` guidelines for full specs. Priority: CRITICAL > HIGH > MEDIUM > LOW. **HIGH — Missing safety features:** - No QOver zero-flow safety check (old: emergency stop if QOver==0 while RPM>300 + oil pump on) -- No safety dialogs: 27V warning, oil pump confirmation, RPM warning - Alarm bit collection during tests not wired up (`PhaseDefinition.RecordErrorBit` never called) - No per-sample real-time UI callback during measurement (old fired per-sample events for live charts) - Pump parameters (ME/FBKW/PreIn) not zeroed between test phases **HIGH — Missing features:** -- Ford unlock progress UI (service exists, no View — old had WUnlocker.xaml with visual ring + progress bar) -- No localization system (old had Spanish/English resource dictionaries with runtime switching) - No encryption (old encrypted user passwords with AES-256 + pump data with Rijndael; new stores plaintext) - No KlineIDs auto-mapping (old remembered K-Line ID → pump ID associations) diff --git a/MainWindow.xaml b/MainWindow.xaml index 32cf193..d51d82f 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -7,7 +7,7 @@ xmlns:uc="clr-namespace:HC_APTBS.Views.UserControls" xmlns:models="clr-namespace:HC_APTBS.Models" mc:Ignorable="d" - Title="HC_APTBS — Herlic Test Bench" + Title="{DynamicResource App.Title}" Height="1080" Width="1920" WindowState="Maximized" WindowStartupLocation="CenterScreen" @@ -68,7 +68,8 @@ - + + @@ -105,7 +106,7 @@ - + @@ -126,7 +127,7 @@ - @@ -139,7 +140,7 @@ - @@ -153,7 +154,7 @@ - @@ -167,7 +168,7 @@ - @@ -184,7 +185,7 @@ - @@ -192,9 +193,9 @@ - + + + + + + diff --git a/Views/Dialogs/UnlockProgressDialog.xaml.cs b/Views/Dialogs/UnlockProgressDialog.xaml.cs new file mode 100644 index 0000000..eb7c181 --- /dev/null +++ b/Views/Dialogs/UnlockProgressDialog.xaml.cs @@ -0,0 +1,49 @@ +using System.ComponentModel; +using System.Windows; +using System.Windows.Input; +using HC_APTBS.ViewModels.Dialogs; + +namespace HC_APTBS.Views.Dialogs +{ + /// + /// Non-modal window showing immobilizer unlock progress. + /// Prevents user-initiated closing until the unlock sequence completes; + /// programmatic close via always succeeds. + /// Equivalent to the old WUnlocker window. + /// + public partial class UnlockProgressDialog : Window + { + private bool _forceClose; + + /// Creates the dialog and wires the ViewModel. + public UnlockProgressDialog(UnlockProgressViewModel vm) + { + InitializeComponent(); + DataContext = vm; + vm.RequestClose += ForceClose; + } + + /// Closes the window unconditionally (bypasses the completion guard). + public void ForceClose() + { + _forceClose = true; + Close(); + } + + /// Allows dragging the borderless window by clicking anywhere. + private void OnMouseDrag(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left) + DragMove(); + } + + /// Prevents user-initiated closing while the unlock sequence is still running. + private void OnWindowClosing(object? sender, CancelEventArgs e) + { + if (_forceClose) return; + + if (DataContext is UnlockProgressViewModel vm && !vm.IsComplete) + e.Cancel = true; + } + } +} diff --git a/Views/Dialogs/UserCheckDialog.xaml b/Views/Dialogs/UserCheckDialog.xaml index 7de5b68..aa1a6ea 100644 --- a/Views/Dialogs/UserCheckDialog.xaml +++ b/Views/Dialogs/UserCheckDialog.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - Title="User Authentication" + Title="{DynamicResource Dialog.UserCheck.Title}" Height="170" Width="420" ResizeMode="NoResize" WindowStartupLocation="CenterOwner"> @@ -21,12 +21,12 @@ -