initial commit

This commit is contained in:
2026-04-11 12:45:18 +02:00
commit 6e1b929e2f
1246 changed files with 177580 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using HC_APTBS.Models;
namespace HC_APTBS.ViewModels
{
/// <summary>
/// Represents a single phase card within a test section.
/// Displays the phase name, enable/disable toggle, operation values,
/// and graphic result indicators.
/// </summary>
public sealed partial class PhaseCardViewModel : ObservableObject
{
// ── Identity ──────────────────────────────────────────────────────────────
/// <summary>Display name of the phase (e.g. "1 - S_001").</summary>
[ObservableProperty] private string _name = string.Empty;
/// <summary>True when failure in this phase halts the entire test sequence.</summary>
[ObservableProperty] private bool _isCritical;
// ── Enable/disable ────────────────────────────────────────────────────────
/// <summary>
/// Whether this phase is included in the test run.
/// Writing this property also updates the underlying <see cref="PhaseDefinition.Enabled"/>
/// and notifies the parent <see cref="TestSectionViewModel"/> to recalculate its
/// <c>AllPhasesChecked</c> state.
/// </summary>
[ObservableProperty] private bool _isEnabled = true;
// ── Execution state ───────────────────────────────────────────────────────
/// <summary>True while this phase is actively executing.</summary>
[ObservableProperty] private bool _isActive;
/// <summary>True when the phase completed and passed all criteria.</summary>
[ObservableProperty] private bool _isPassed;
/// <summary>True when the phase completed but failed one or more criteria.</summary>
[ObservableProperty] private bool _isFailed;
/// <summary>Short result label shown in the card (e.g. "PASS", "FAIL", "-").</summary>
[ObservableProperty] private string _resultText = string.Empty;
// ── Operation values visibility ───────────────────────────────────────────
/// <summary>
/// Controls visibility of the operation values section (RPM, ME, FBKW).
/// Bound from <see cref="TestPanelViewModel.ShowOperationValues"/>.
/// </summary>
[ObservableProperty] private bool _showOperationValues;
// ── Collections ───────────────────────────────────────────────────────────
/// <summary>Send parameters displayed in the card (RPM, ME, FBKW, etc.).</summary>
public ObservableCollection<OperationValueViewModel> OperationValues { get; } = new();
/// <summary>Readiness conditions displayed in the card (temperature, etc.).</summary>
public ObservableCollection<OperationValueViewModel> ReadyValues { get; } = new();
/// <summary>Graphic result indicators, one per receive parameter.</summary>
public ObservableCollection<GraphicIndicatorViewModel> ResultIndicators { get; } = new();
// ── Back-references ───────────────────────────────────────────────────────
/// <summary>Back-reference to the model for writing enabled state changes.</summary>
internal PhaseDefinition? Source { get; set; }
/// <summary>
/// Callback invoked when <see cref="IsEnabled"/> changes, so the parent
/// <see cref="TestSectionViewModel"/> can recalculate <c>AllPhasesChecked</c>.
/// </summary>
internal Action<PhaseCardViewModel>? EnabledChanged { get; set; }
// ── Change handlers ───────────────────────────────────────────────────────
partial void OnIsEnabledChanged(bool value)
{
// Write back to the model.
if (Source != null)
Source.Enabled = value;
ResultText = value ? "\u2013" : "disabled";
// Notify parent.
EnabledChanged?.Invoke(this);
}
// ── Public API ────────────────────────────────────────────────────────────
/// <summary>Resets execution state for a new test run.</summary>
public void Reset()
{
IsActive = false;
IsPassed = false;
IsFailed = false;
ResultText = IsEnabled ? "\u2013" : "disabled";
foreach (var indicator in ResultIndicators)
indicator.Reset();
}
}
}