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 <noreply@anthropic.com>
172 lines
9.1 KiB
C#
172 lines
9.1 KiB
C#
using System.Collections.Generic;
|
|
using Peak.Can.Basic;
|
|
using TPCANHandle = System.UInt16;
|
|
|
|
namespace HC_APTBS.Models
|
|
{
|
|
/// <summary>
|
|
/// Complete bench parameter configuration: CAN parameter map plus relay definitions.
|
|
/// Loaded from bench.xml at startup and edited via the BenchParamConfig view.
|
|
/// </summary>
|
|
public class BenchConfiguration
|
|
{
|
|
/// <summary>PCAN channel handle used for bench communication.</summary>
|
|
public TPCANHandle Channel { get; set; } = PCANBasic.PCAN_USBBUS1;
|
|
|
|
/// <summary>All bench parameters, keyed by name for quick lookup.</summary>
|
|
public Dictionary<string, CanBusParameter> ParametersByName { get; set; } = new();
|
|
|
|
/// <summary>Bench parameters grouped by CAN message ID for frame decoding.</summary>
|
|
public Dictionary<uint, List<CanBusParameter>> ParametersById { get; set; } = new();
|
|
|
|
/// <summary>Relay / solenoid output definitions, keyed by name.</summary>
|
|
public Dictionary<string, Relay> Relays { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Application-wide configuration settings persisted in config.xml.
|
|
/// </summary>
|
|
public class AppSettings
|
|
{
|
|
// ── Temperature control ───────────────────────────────────────────────
|
|
|
|
/// <summary>Maximum allowable oil temperature (°C) before the bench raises an alarm.</summary>
|
|
public int TempMax { get; set; } = 45;
|
|
|
|
/// <summary>Minimum oil temperature (°C) required before tests begin.</summary>
|
|
public int TempMin { get; set; } = 35;
|
|
|
|
// ── Refresh intervals ─────────────────────────────────────────────────
|
|
|
|
/// <summary>UI status refresh period (ms) during normal bench operation.</summary>
|
|
public int RefreshBenchInterfaceMs { get; set; } = 20;
|
|
|
|
/// <summary>UI refresh period (ms) while reading pump EEPROM data over K-Line.</summary>
|
|
public int RefreshWhileReadingMs { get; set; } = 1500;
|
|
|
|
/// <summary>CAN bus polling interval (ms) on the read thread.</summary>
|
|
public int RefreshCanBusReadMs { get; set; } = 2;
|
|
|
|
/// <summary>Interval (ms) between pump-status CAN request messages.</summary>
|
|
public int RefreshPumpRequestMs { get; set; } = 250;
|
|
|
|
/// <summary>Interval (ms) between pump-parameter CAN request messages.</summary>
|
|
public int RefreshPumpParamsMs { get; set; } = 4;
|
|
|
|
/// <summary>Blink period (ms) for LED indicator controls.</summary>
|
|
public int BlinkIntervalMs { get; set; } = 1000;
|
|
|
|
/// <summary>Flasher relay toggle interval (ms).</summary>
|
|
public int FlasherIntervalMs { get; set; } = 800;
|
|
|
|
// ── PID temperature controller ────────────────────────────────────────
|
|
|
|
/// <summary>Proportional gain.</summary>
|
|
public double PidP { get; set; } = 0.1;
|
|
|
|
/// <summary>Integral gain.</summary>
|
|
public double PidI { get; set; } = 0.1;
|
|
|
|
/// <summary>Derivative gain.</summary>
|
|
public double PidD { get; set; } = 0.04;
|
|
|
|
/// <summary>PID loop period (ms).</summary>
|
|
public int PidLoopMs { get; set; } = 250;
|
|
|
|
// ── Safety limits ─────────────────────────────────────────────────────
|
|
|
|
/// <summary>Maximum allowable bench speed (RPM) before the bench triggers an emergency stop.</summary>
|
|
public int SecurityRpmLimit { get; set; } = 2500;
|
|
|
|
/// <summary>Maximum allowable bench pressure (bar).</summary>
|
|
public int MaxPressureBar { get; set; } = 26;
|
|
|
|
// ── Test tolerance extensions ─────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Fractional tolerance extension for UP tests.
|
|
/// A value of 0.08 extends each tolerance bound by 8% of its magnitude.
|
|
/// </summary>
|
|
public double ToleranceUpExtension { get; set; } = 0.08;
|
|
|
|
/// <summary>
|
|
/// Fractional tolerance extension for PFP tests.
|
|
/// A value of 0.1 extends each tolerance bound by 10% of its magnitude.
|
|
/// </summary>
|
|
public double TolerancePfpExtension { get; set; } = 0.1;
|
|
|
|
// ── Encoder ───────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Encoder pulses per revolution (default 4096 for PSG encoder).</summary>
|
|
public int EncoderResolution { get; set; } = 4096;
|
|
|
|
// ── Motor control ─────────────────────────────────────────────────────
|
|
|
|
/// <summary>Analogue output voltage (V) that corresponds to maximum RPM.</summary>
|
|
public double VoltageForMaxRpm { get; set; } = 10;
|
|
|
|
/// <summary>Maximum motor speed the bench can command (RPM).</summary>
|
|
public int MaxRpm { get; set; } = 2500;
|
|
|
|
// ── Direction ─────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Default relay state for the "right" rotation direction.</summary>
|
|
public bool RightRelayValue { get; set; } = true;
|
|
|
|
/// <summary>Last rotation direction selected by the operator.</summary>
|
|
public short LastRotationDirection { get; set; } = RotationDirection.Right;
|
|
|
|
/// <summary>When true, the T-in temperature sensor check is bypassed.</summary>
|
|
public bool DefaultIgnoreTin { get; set; } = true;
|
|
|
|
// ── Log rotation ──────────────────────────────────────────────────────
|
|
|
|
/// <summary>Number of daily log files to retain before the oldest is deleted.</summary>
|
|
public int DaysKeepLogs { get; set; } = 7;
|
|
|
|
// ── Report ────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Company name printed in the report header.</summary>
|
|
public string CompanyName { get; set; } = string.Empty;
|
|
|
|
/// <summary>Company address/info printed in the report header.</summary>
|
|
public string CompanyInfo { get; set; } = string.Empty;
|
|
|
|
/// <summary>Absolute path to the company logo image for the report.</summary>
|
|
public string ReportLogoPath { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Comma-separated <c>user:salt:hash</c> credential entries for operator authentication
|
|
/// before report generation. Salt is 16-byte Base64, hash is PBKDF2-HMAC-SHA256 (600 000 iterations, 32-byte output) Base64.
|
|
/// Legacy <c>user:password</c> entries are auto-migrated on first load.
|
|
/// </summary>
|
|
public string Users { get; set; } = string.Empty;
|
|
|
|
// ── K-Line port ───────────────────────────────────────────────────────
|
|
|
|
/// <summary>Serial port or FTDI device identifier for the K-Line interface.</summary>
|
|
public string KLinePort { get; set; } = string.Empty;
|
|
|
|
// ── UI ────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>UI language code, e.g. "ESP" or "ENG".</summary>
|
|
public string Language { get; set; } = "ESP";
|
|
|
|
// ── Relations ─────────────────────────────────────────────────────────
|
|
|
|
/// <summary>RPM-to-voltage lookup table for motor speed control.</summary>
|
|
public List<RpmVoltageRelation> Relations { get; set; } = new();
|
|
|
|
// ── Sensor calibration ────────────────────────────────────────────────
|
|
|
|
/// <summary>Calibration data for each analogue sensor channel (keyed by channel number).</summary>
|
|
public Dictionary<int, SensorConfiguration> Sensors { get; set; } = new();
|
|
|
|
// ── Alarms ────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Active alarm definitions loaded from alarms.xml.</summary>
|
|
public List<Alarm> Alarms { get; set; } = new();
|
|
|
|
}
|
|
}
|