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>
148 lines
7.2 KiB
C#
148 lines
7.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using HC_APTBS.Models;
|
|
|
|
namespace HC_APTBS.Services
|
|
{
|
|
/// <summary>
|
|
/// Provides read/write access to persisted application configuration.
|
|
/// Configuration files live under <c>%UserProfile%\.HC_APTBS\config\</c>.
|
|
/// </summary>
|
|
public interface IConfigurationService
|
|
{
|
|
// ── Settings ──────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Application-wide settings (temperature limits, PID, refresh rates, etc.).</summary>
|
|
AppSettings Settings { get; }
|
|
|
|
/// <summary>Persists <see cref="Settings"/> to <c>config.xml</c>.</summary>
|
|
void SaveSettings();
|
|
|
|
// ── Bench configuration ───────────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Current bench CAN parameter map and relay definitions.
|
|
/// Loaded from <c>bench.xml</c> on first access.
|
|
/// </summary>
|
|
BenchConfiguration Bench { get; }
|
|
|
|
/// <summary>Persists <see cref="Bench"/> to <c>bench.xml</c>.</summary>
|
|
void SaveBench();
|
|
|
|
// ── Pump database ─────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Returns all known pump IDs from the pump database.</summary>
|
|
IReadOnlyList<string> GetPumpIds();
|
|
|
|
/// <summary>
|
|
/// Loads the full <see cref="PumpDefinition"/> for the pump with the given ID,
|
|
/// including its CAN parameter map and test list.
|
|
/// </summary>
|
|
PumpDefinition? LoadPump(string pumpId);
|
|
|
|
/// <summary>Persists a pump definition back to the database.</summary>
|
|
void SavePump(PumpDefinition pump);
|
|
|
|
// ── Pump equivalence / alias lookup ───────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Returns the canonical pump ID whose <c><Aliases><KlineId></c>
|
|
/// entries contain <paramref name="klinePumpId"/>, or <c>null</c> if no
|
|
/// alias matches. Comparison is case-insensitive and trims whitespace.
|
|
/// </summary>
|
|
string? FindPumpIdByKlineAlias(string klinePumpId);
|
|
|
|
/// <summary>
|
|
/// Returns the canonical pump ID whose <c><Aliases><ModelRef></c>
|
|
/// entries equal <paramref name="modelRef"/> (case-insensitive, trimmed),
|
|
/// or <c>null</c> if no alias matches.
|
|
/// </summary>
|
|
string? FindPumpIdByModelRef(string modelRef);
|
|
|
|
/// <summary>
|
|
/// Persists a new K-Line alias under the given canonical pump.
|
|
/// No-op if the canonical pump does not exist or if the alias is already present.
|
|
/// </summary>
|
|
void AddKlineAlias(string canonicalPumpId, string klineAlias);
|
|
|
|
// ── Clients ───────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Sorted client name → contact info dictionary.</summary>
|
|
SortedDictionary<string, string> Clients { get; }
|
|
|
|
/// <summary>Persists the client list to <c>clients.xml</c>.</summary>
|
|
void SaveClients();
|
|
|
|
// ── Developer libraries (saved KWP commands + EEPROM passwords) ──────────
|
|
|
|
/// <summary>
|
|
/// User-saved raw KWP custom commands, persisted in <c>custom_commands.xml</c>.
|
|
/// Populated and edited by the Developer Tools page; not used by production paths.
|
|
/// </summary>
|
|
ObservableCollection<CustomCommand> CustomCommands { get; }
|
|
|
|
/// <summary>Persists <see cref="CustomCommands"/> to <c>custom_commands.xml</c>.</summary>
|
|
void SaveCustomCommands();
|
|
|
|
/// <summary>
|
|
/// User-saved EEPROM unlock passwords (zone + 16-bit key), persisted in
|
|
/// <c>eeprom_passwords.xml</c>. Populated and edited by the Developer Tools page.
|
|
/// </summary>
|
|
ObservableCollection<EepromPassword> EepromPasswords { get; }
|
|
|
|
/// <summary>Persists <see cref="EepromPasswords"/> to <c>eeprom_passwords.xml</c>.</summary>
|
|
void SaveEepromPasswords();
|
|
|
|
// ── Pump status definitions ───────────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Loads the <see cref="PumpStatusDefinition"/> for the given status ID.
|
|
/// Definitions are cached after first load. Returns null if the ID is not found.
|
|
/// </summary>
|
|
PumpStatusDefinition? LoadPumpStatus(int statusId);
|
|
|
|
// ── Alarms ────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Persists alarm definitions to <c>alarms.xml</c>.</summary>
|
|
void SaveAlarms();
|
|
|
|
// ── Sensors ───────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Saves updated sensor calibration data to <c>sensors.xml</c>.</summary>
|
|
void SaveSensors();
|
|
|
|
// ── Users ─────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Validates a username/password pair against stored credentials.</summary>
|
|
bool ValidateUser(string username, string password);
|
|
|
|
/// <summary>Returns all stored usernames (passwords are never exposed).</summary>
|
|
IReadOnlyList<string> GetUsers();
|
|
|
|
/// <summary>Replaces all stored user credentials and persists them.</summary>
|
|
void UpdateUsers(Dictionary<string, string> users);
|
|
|
|
/// <summary>
|
|
/// Adds a new user with the given plaintext password.
|
|
/// Returns false if the username already exists, if either field is empty/whitespace,
|
|
/// or if the username contains the reserved separator characters <c>':'</c> or <c>','</c>.
|
|
/// Hashes of existing users are preserved.
|
|
/// </summary>
|
|
bool AddUser(string username, string password);
|
|
|
|
/// <summary>
|
|
/// Removes the user with the given username.
|
|
/// Returns false if the user does not exist or if this would remove the last remaining user.
|
|
/// Hashes of other users are preserved.
|
|
/// </summary>
|
|
bool RemoveUser(string username);
|
|
|
|
/// <summary>
|
|
/// Replaces the stored password for an existing user.
|
|
/// Returns false if the user does not exist or the password is empty.
|
|
/// Hashes of other users are preserved.
|
|
/// </summary>
|
|
bool ChangeUserPassword(string username, string newPassword);
|
|
}
|
|
}
|