- Replace LCD-style readings with a 3×2 KPI tile grid (Fluent card surfaces, 52pt values) - Add persistent top connection strip with horizontal chips + pump name badge - Add elapsed test timer (DispatcherTimer, mm:ss) to Test Summary card - Restyle Test Summary and Active Alarms with Fluent brushes/iconography - Add Devices column (CAN / K-Line / Bench tiles) between KPI grid and test/alarms - Enumerates attached PCAN USB channels via PCAN_ATTACHED_CHANNELS API - Enumerates FTDI K-Line adapters via existing FtdiInterface helpers - Click to connect/disconnect; confirmation dialog when session active or test running - Hover tint: blue = will connect, red = will disconnect; Bench row is read-only stub - Extend ICanService with SelectedChannel + EnumerateAttachedChannels() - Expose IKwpService.ConnectedPort for active session device tracking - Add DeviceRow button style with MultiDataTrigger hover colour logic - Add 30+ new localization keys (ES + EN) for KPI labels, devices, confirmations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
123 lines
5.5 KiB
C#
123 lines
5.5 KiB
C#
using System.ComponentModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using HC_APTBS.Models;
|
|
using HC_APTBS.ViewModels.Dialogs;
|
|
|
|
namespace HC_APTBS.ViewModels.Pages
|
|
{
|
|
/// <summary>Identifies the sub-section shown inside the Pump navigation page.</summary>
|
|
public enum PumpSubPage
|
|
{
|
|
/// <summary>§3.a — Pump selection and K-Line ECU read.</summary>
|
|
Identification = 0,
|
|
/// <summary>§3.b — Diagnostic Trouble Codes.</summary>
|
|
Dtcs = 1,
|
|
/// <summary>§3.c — Live pump CAN readings and status words.</summary>
|
|
LiveData = 2,
|
|
/// <summary>§3.d — DFI calibration and ME/FBKW/PreIn manual control (auth-gated).</summary>
|
|
Adaptation = 3,
|
|
/// <summary>§3.e — Ford VP44 immobilizer unlock (visible only when required).</summary>
|
|
Unlock = 4
|
|
}
|
|
|
|
/// <summary>
|
|
/// ViewModel for the Pump navigation page.
|
|
///
|
|
/// <para>Thin façade that groups the pump-related child ViewModels owned by
|
|
/// <see cref="MainViewModel"/> and adds sub-page navigation, banner flags,
|
|
/// and the Adaptation auth gate. Holds a <see cref="Root"/> reference so
|
|
/// page XAML can bind to MainViewModel-owned properties (PumpRpm, PumpTemp,
|
|
/// KLineState, …) via <c>{Binding Root.X}</c>.</para>
|
|
/// </summary>
|
|
public sealed partial class PumpPageViewModel : ObservableObject
|
|
{
|
|
/// <summary>Root ViewModel — owns services, live readings, and global commands.</summary>
|
|
public MainViewModel Root { get; }
|
|
|
|
// ── Child VM façades ──────────────────────────────────────────────────────
|
|
|
|
/// <summary>Pump selector and K-Line read (§3.a).</summary>
|
|
public PumpIdentificationViewModel Identification => Root.PumpIdentification;
|
|
|
|
/// <summary>Diagnostic Trouble Code list (§3.b).</summary>
|
|
public DtcListViewModel DtcList { get; }
|
|
|
|
/// <summary>DFI management (§3.d).</summary>
|
|
public DfiManageViewModel DfiViewModel => Root.DfiViewModel;
|
|
|
|
/// <summary>Manual pump control sliders (§3.d).</summary>
|
|
public PumpControlViewModel PumpControl => Root.PumpControl;
|
|
|
|
/// <summary>First pump status display — Status word (§3.c).</summary>
|
|
public StatusDisplayViewModel StatusDisplay1 => Root.StatusDisplay1;
|
|
|
|
/// <summary>Second pump status display — Empf3 word (§3.c).</summary>
|
|
public StatusDisplayViewModel StatusDisplay2 => Root.StatusDisplay2;
|
|
|
|
/// <summary>Current immobilizer unlock VM (§3.e). Null when no unlock is in progress for this pump.</summary>
|
|
public UnlockProgressViewModel? UnlockVm => Root.CurrentUnlockVm;
|
|
|
|
// ── Navigation state ──────────────────────────────────────────────────────
|
|
|
|
/// <summary>Currently selected Pump sub-section.</summary>
|
|
[ObservableProperty] private PumpSubPage _selectedSubPage = PumpSubPage.Identification;
|
|
|
|
// ── Banner flags (derived from Root state) ────────────────────────────────
|
|
|
|
/// <summary>True when a pump has been loaded from the database.</summary>
|
|
[ObservableProperty] private bool _isPumpSelected;
|
|
|
|
/// <summary>True when the K-Line session is currently open.</summary>
|
|
[ObservableProperty] private bool _isKLineSessionOpen;
|
|
|
|
/// <summary>True when the K-Line session is in the failed state.</summary>
|
|
[ObservableProperty] private bool _isKLineSessionFailed;
|
|
|
|
/// <summary>True for pumps that require a Ford immobilizer unlock (Type 1 or 2).</summary>
|
|
[ObservableProperty] private bool _isUnlockApplicable;
|
|
|
|
/// <summary>Constructs the page VM and subscribes to relevant Root state changes.</summary>
|
|
public PumpPageViewModel(
|
|
MainViewModel root,
|
|
DtcListViewModel dtcList)
|
|
{
|
|
Root = root;
|
|
DtcList = dtcList;
|
|
|
|
// Initialise derived flags from the current Root state.
|
|
RefreshDerivedFlags();
|
|
|
|
// Keep the derived flags in sync with Root changes.
|
|
Root.PropertyChanged += OnRootPropertyChanged;
|
|
Root.PumpIdentification.PumpChanged += _ => RefreshDerivedFlags();
|
|
}
|
|
|
|
private void OnRootPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
{
|
|
switch (e.PropertyName)
|
|
{
|
|
case nameof(MainViewModel.KLineState):
|
|
IsKLineSessionOpen = Root.KLineState == KLineConnectionState.Connected;
|
|
IsKLineSessionFailed = Root.KLineState == KLineConnectionState.Failed;
|
|
break;
|
|
|
|
case nameof(MainViewModel.CurrentUnlockVm):
|
|
OnPropertyChanged(nameof(UnlockVm));
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void RefreshDerivedFlags()
|
|
{
|
|
IsPumpSelected = Root.CurrentPump != null;
|
|
IsKLineSessionOpen = Root.KLineState == KLineConnectionState.Connected;
|
|
IsKLineSessionFailed = Root.KLineState == KLineConnectionState.Failed;
|
|
IsUnlockApplicable = Root.CurrentPump != null && Root.CurrentPump.UnlockType != 0;
|
|
OnPropertyChanged(nameof(UnlockVm));
|
|
|
|
// Drop any stale DTCs from the previous pump.
|
|
DtcList.Reset();
|
|
}
|
|
}
|
|
}
|