Files
HC_APTBS/Models/BipStatusDefinition.cs
LucianoDev 827b811b39 feat: developer tools page, auto-test orchestrator, BIP display, tests redesign
Bundles several feature streams that have been iterating on the working tree:

- Developer Tools page (Debug-only via DEVELOPER_TOOLS symbol): hosts the
  identification card, manual KWP write + transaction log, ROM/EEPROM dump
  card with progress banner and completion message, persisted custom-commands
  library, persisted EEPROM passwords library. New service primitives:
  IKwpService.SendRawCustomAsync / ReadEepromAsync / ReadRomEepromAsync.
  Persistence mirrors the Clients XML pattern in two new files
  (custom_commands.xml, eeprom_passwords.xml).
- Auto-test orchestrator (IAutoTestOrchestrator + AutoTestState): linear
  K-Line read -> unlock -> bench-on -> test sequence with snackbar UI and
  progress dialog VM, gated on dashboard alarms.
- BIP-STATUS display: BipDisplayViewModel + BipDisplayView, RAM read at
  0x0106 via IKwpService.ReadBipStatusAsync; status definitions in
  BipStatusDefinition.
- Tests page redesign: TestSectionCard + PhaseTileView replacing the old
  TestPlanView/TestRunningView/TestDoneView/TestPreconditionsView/
  TestSectionView controls and their VMs.
- Pump command sliders: Fluent thick-track style with overhang thumb,
  click-anywhere-and-drag, mouse-wheel adjustment.
- Window startup: app.manifest declares PerMonitorV2 DPI awareness,
  MainWindow installs a WM_GETMINMAXINFO hook in OnSourceInitialized and
  maximizes there (after the hook is in place) so the app fits the work
  area exactly on any display configuration.
- Misc: PercentToPixelsConverter, seed_aliases.py one-shot pump-alias
  importer, tools/Import-BipStatus.ps1, kline_eeprom_spec.md and
  dump-functions reference docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 13:59:50 +02:00

65 lines
2.7 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace HC_APTBS.Models
{
// BIP (Begin of Injection Period) status definitions.
// Applies only to pre-injection PSG5-PI pumps (Type 2 T15xxx / Type 3 T18xxx Ford).
// Null on standard VP44 pumps.
// Data source: KWP RAM read of ADR-S_BIP_HW_UW at address 0x0106 (16-bit unsigned).
/// <summary>
/// One BIP-STATUS entry: a 16-bit HEX pattern matched against the captured BIP
/// status word, together with the reaction to apply on a match.
/// </summary>
public class BipStatusDefinition
{
/// <summary>Zero-based definition index (BIP-STATUS0 = 0 … BIP-STATUS7 = 7).</summary>
public int Index { get; set; }
/// <summary>Whether this definition participates in pattern matching.</summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// 16-bit nibble pattern compared against the captured BIP status word.
/// Legacy examples: 0x0000 = BIP OK, 0x000F = no BIP in window,
/// 0x00F0 = no BIP + MV off, 0x0F00 = no MV drive, 0xF00F = deviation too large.
/// </summary>
public ushort HexPattern { get; set; }
/// <summary>
/// Reaction code applied on match:
/// 0 = none, 1 = abort (emergency stop), 2 = warning, 3 = log-only.
/// </summary>
public int Reaction { get; set; } = 0;
/// <summary>
/// Special-function marker from legacy CFG:
/// 9 = standard handling, 0xB = Ford timing-correction (Type 3 only).
/// </summary>
public int SpecialFunction { get; set; } = 9;
/// <summary>Human-readable description shown on match.</summary>
public string Description { get; set; } = string.Empty;
}
/// <summary>
/// Per-pump BIP status container. Holds up to 8 <see cref="BipStatusDefinition"/>
/// entries (max by legacy convention; not validated).
/// </summary>
public class PumpBipDefinition
{
/// <summary>Ordered BIP status definitions (max 8).</summary>
public List<BipStatusDefinition> Bits { get; set; } = new();
/// <summary>
/// Returns the first enabled definition whose <see cref="BipStatusDefinition.HexPattern"/>
/// matches <paramref name="value"/> via bitmask semantics: all bits set in the pattern
/// must be set in the captured word (<c>(value &amp; pattern) == pattern</c>).
/// Pattern 0x0000 matches any value (OK state by convention in the legacy CFG).
/// </summary>
public BipStatusDefinition? Match(ushort value) =>
Bits.FirstOrDefault(b => b.Enabled && (value & b.HexPattern) == b.HexPattern);
}
}