feat: redesign Bench page with Fluent card layout and radial advance monitor

Three-column layout replacing the old HMI grid:
- BenchRpmCommandCard: inline numeric input, 2×4 preset grid, Start/Stop
- BenchActuatorsCard: direction toggle, oil pump, temperature PID, misc relays
  with FluentStateToggle showing checked state via AccentFillColor
- BenchLiveDataCard: 2×5 KPI tiles (RPM, P1, P2, Q-Delivery, Q-Over, temps)
- BenchChartsCard: 2×2 compact chart grid (Delivery, Over, P1, P2)
- AdvanceMonitorCard: RadialAngleGauge custom FrameworkElement + PSG/INJ readouts,
  Δ° lock offset input, Zero PSG / Zero INJ buttons

Supporting changes:
- AngleDisplayViewModel: promote _currentManualDegrees, _isLockSet to
  [ObservableProperty]; add PsgRelativeDegrees, InjEncoderDegreesValue,
  TargetLockAngle, IsRunningMode (29/31 hysteresis); computed PrimaryGaugeAngle,
  TargetAngleForGauge, SecondaryGaugeAngle
- BenchControlViewModel: add IsDirectionLeft computed property,
  SetDirectionRightCommand, SetDirectionLeftCommand, ApplyRpmCommand
- FlowmeterChartView: add IsCompact DP (false default) for 90px compact height
- Styles.xaml: add IsChecked trigger to FluentStateToggle (accent fill + white text)
- Strings.en/es.xaml: add all new card and actuator string keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-20 17:45:59 +02:00
parent 70be693116
commit 69bfda54e1
19 changed files with 1361 additions and 59 deletions

View File

@@ -31,10 +31,15 @@ namespace HC_APTBS.ViewModels
private double _zeroPsgEncoder;
private double _zeroInjDegrees;
private double _injEncoderDegrees;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(PrimaryGaugeAngle))]
[NotifyPropertyChangedFor(nameof(SecondaryGaugeAngle))]
private double _currentManualDegrees;
private double _lockAngleValue;
private bool _isLockSet;
private bool _isManualVisible;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TargetAngleForGauge))]
private bool _isLockSet;
private bool _isManualVisible;
// ── Observable properties (bound by View) ─────────────────────────────────
@@ -68,6 +73,27 @@ namespace HC_APTBS.ViewModels
/// <summary>Foreground brush for the lock angle display (Green/Red/White).</summary>
[ObservableProperty] private Brush _lockAngleForeground = Brushes.White;
// ── Numeric doubles for radial advance-monitor control ────────────────────
/// <summary>PSG relative angle as a double for gauge binding.</summary>
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(PrimaryGaugeAngle))]
private double _psgRelativeDegrees;
/// <summary>INJ encoder absolute degrees (0360) as a double.</summary>
[ObservableProperty] private double _injEncoderDegreesValue;
/// <summary>Lock angle target (0360 degrees) as a double for gauge binding.</summary>
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(TargetAngleForGauge))]
private double _targetLockAngle;
/// <summary>True when bench RPM ≥ 31, hysteresis-cleared below 29.</summary>
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(PrimaryGaugeAngle))]
[NotifyPropertyChangedFor(nameof(SecondaryGaugeAngle))]
private bool _isRunningMode;
// ── Constructor ───────────────────────────────────────────────────────────
/// <summary>
@@ -78,6 +104,17 @@ namespace HC_APTBS.ViewModels
_encoderResolution = configService.Settings.EncoderResolution;
}
// ── Computed for radial gauge ─────────────────────────────────────────────
/// <summary>Primary thumb angle: manual-wheel angle in hand-mode, PSG relative angle when running.</summary>
public double PrimaryGaugeAngle => IsRunningMode ? PsgRelativeDegrees : CurrentManualDegrees;
/// <summary>Target thumb angle for the radial gauge, or null when no lock has been set yet.</summary>
public double? TargetAngleForGauge => IsLockSet ? TargetLockAngle : (double?)null;
/// <summary>Ghost secondary thumb angle: manual-wheel position shown when running, null in hand-mode (primary already shows it).</summary>
public double? SecondaryGaugeAngle => IsRunningMode ? CurrentManualDegrees : (double?)null;
// ── Public update (called from MainViewModel.OnRefreshTick) ───────────────
/// <summary>
@@ -98,6 +135,11 @@ namespace HC_APTBS.ViewModels
_currentRpm = rpm;
_isDirectionRight = isDirectionRight;
if (!IsRunningMode && rpm >= 31.0)
IsRunningMode = true;
else if (IsRunningMode && rpm < 29.0)
IsRunningMode = false;
RecalculatePsg();
RecalculateInj();
RecalculateManual();
@@ -150,7 +192,8 @@ namespace HC_APTBS.ViewModels
if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out double delta))
{
_lockAngleValue = CalculateLockAngle(delta);
_isLockSet = true;
TargetLockAngle = _lockAngleValue;
IsLockSet = true;
LockAngleDisplay = FormatAngle(_lockAngleValue);
}
@@ -183,8 +226,9 @@ namespace HC_APTBS.ViewModels
if (relDeg > 180) relDeg = 360 - relDeg;
relDeg *= sign;
PsgEncoderAngle = FormatAngle(rawDeg);
PsgRelativeAngle = FormatAngle(relDeg);
PsgRelativeDegrees = relDeg;
PsgEncoderAngle = FormatAngle(rawDeg);
PsgRelativeAngle = FormatAngle(relDeg);
}
private void RecalculateInj()
@@ -202,7 +246,8 @@ namespace HC_APTBS.ViewModels
double sign = DirectionSign;
// INJ encoder → degrees (full 0360, NO 180 normalization).
_injEncoderDegrees = _injRaw * (360.0 / _encoderResolution);
_injEncoderDegrees = _injRaw * (360.0 / _encoderResolution);
InjEncoderDegreesValue = _injEncoderDegrees;
// Relative angle from zero reference.
double relDeg = (_injEncoderDegrees - _zeroInjDegrees) * sign;
@@ -216,13 +261,14 @@ namespace HC_APTBS.ViewModels
CultureInfo.InvariantCulture, out double delta))
{
_lockAngleValue = CalculateLockAngle(delta);
TargetLockAngle = _lockAngleValue;
LockAngleDisplay = FormatAngle(_lockAngleValue);
}
}
private void RecalculateManual()
{
_currentManualDegrees = _manualRaw * (360.0 / _encoderResolution);
CurrentManualDegrees = _manualRaw * (360.0 / _encoderResolution);
if (_currentRpm < 30)
{

View File

@@ -22,7 +22,12 @@ namespace HC_APTBS.ViewModels
// ── Direction ─────────────────────────────────────────────────────────────
/// <summary>True when the bench rotates clockwise (right). False for counter-clockwise (left).</summary>
[ObservableProperty] private bool _isDirectionRight = true;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsDirectionLeft))]
private bool _isDirectionRight = true;
/// <summary>True when the bench rotates counter-clockwise (left). Computed inverse of <see cref="IsDirectionRight"/>.</summary>
public bool IsDirectionLeft => !IsDirectionRight;
// ── Oil pump ──────────────────────────────────────────────────────────────
@@ -85,6 +90,14 @@ namespace HC_APTBS.ViewModels
_bench.SetRelay(RelayNames.DirectionLeft, !value);
}
/// <summary>Sets the bench rotation direction to clockwise (right).</summary>
[RelayCommand]
private void SetDirectionRight() => IsDirectionRight = true;
/// <summary>Sets the bench rotation direction to counter-clockwise (left).</summary>
[RelayCommand]
private void SetDirectionLeft() => IsDirectionRight = false;
// ── Oil pump toggle ───────────────────────────────────────────────────────
partial void OnIsOilPumpOnChanged(bool value)
@@ -167,6 +180,13 @@ namespace HC_APTBS.ViewModels
IsBenchRunning = false;
}
/// <summary>
/// Applies the RPM value from <see cref="RpmInputText"/> and starts the bench.
/// Bound to the inline Apply button in <c>BenchRpmCommandCard</c>.
/// </summary>
[RelayCommand]
private void ApplyRpm() => StartBench();
/// <summary>
/// Quick-select button handler: sets the RPM input and starts the bench.
/// </summary>