feat: page-based navigation shell + Tests page wizard
Replace the monolithic MainWindow with a SelectedPage-driven shell (Dashboard / Pump / Bench / Tests / Results / Settings). The Tests page gets the Plan -> Preconditions -> Running -> Done wizard from ui-structure.md \u00a74, backed by a 7-item precondition gate and shared sub-views (PhaseCardView / TestSectionView / GraphicIndicatorView) extracted from the now-deleted monolithic TestPanelView. New VMs / views: - Tests wizard: TestPreconditions, PhaseCard, GraphicIndicator, TestSection, TestPlan, TestRunning, TestDone - Dashboard panels: DashboardConnection, DashboardReadings, DashboardAlarms, InterlockBanner, ResultHistory - Pump / bench panels: PumpIdentificationPanel, PumpLiveData, UnlockPanel, BenchDriveControl, BenchReadings, RelayBank, TemperatureControl, DtcList, AuthGate - Dialogs: generic ConfirmDialog, UserManageDialog, UserPromptDialog Supporting changes: - IsOilPumpOn exposed on MainViewModel for precondition evaluation - RequiresAuth added to TestDefinition (XML round-trip) - BipStatusDefinition + CompletedTestRun models - ~35 new Test.* localization keys (en + es) - Settings moved from modal dialog to full page - Pause / Retry / Skip stubs in TestRunningView; full spec in docs/gap-test-running-controls.md for follow-up implementation - docs/ui-structure.md captures the wizard design Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace HC_APTBS.Models
|
||||
@@ -41,18 +42,41 @@ namespace HC_APTBS.Models
|
||||
/// <summary>Additive offset correction applied after the gain.</summary>
|
||||
public double Offset { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Static logging hook used by runtime guards and <see cref="TryParse"/>.
|
||||
/// Wired at app startup to <c>IAppLogger.Warning</c>. Left null keeps the
|
||||
/// Models layer DI-free and testable. Signature: (source, message).
|
||||
/// </summary>
|
||||
public static Action<string, string>? WarningLogger { get; set; }
|
||||
|
||||
/// <summary>Set once per instance after the first zero-range warning, to prevent hot-loop log spam.</summary>
|
||||
private bool _warnedRangeZero;
|
||||
|
||||
/// <summary>
|
||||
/// Converts a raw CAN bus ADC count to a calibrated engineering-unit value.
|
||||
/// Returns 0 and warns once if <c>MaxVolt == MinVolt</c>.
|
||||
/// </summary>
|
||||
/// <param name="rawCanBusValue">10-bit ADC count from the CAN frame.</param>
|
||||
/// <returns>Calibrated value in engineering units.</returns>
|
||||
public double GetValueFromRaw(double rawCanBusValue)
|
||||
{
|
||||
double range = MaxVolt - MinVolt;
|
||||
if (range == 0.0)
|
||||
{
|
||||
if (!_warnedRangeZero)
|
||||
{
|
||||
WarningLogger?.Invoke(nameof(SensorConfiguration),
|
||||
$"MaxVolt == MinVolt for sensor '{SensorName}' (channel {Number}). Returning 0.");
|
||||
_warnedRangeZero = true;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// Convert ADC counts → volts (10-bit ADC, 5 V reference)
|
||||
double volts = rawCanBusValue * 5000.0 / 1024.0 / 1000.0;
|
||||
|
||||
// Map voltage range → engineering-unit range
|
||||
double value = volts * ((MaxVal - MinVal) / (MaxVolt - MinVolt));
|
||||
double value = volts * ((MaxVal - MinVal) / range);
|
||||
|
||||
return value * Gain + Offset;
|
||||
}
|
||||
@@ -73,17 +97,21 @@ namespace HC_APTBS.Models
|
||||
public static SensorConfiguration FromXml(XElement element)
|
||||
{
|
||||
var sc = new SensorConfiguration();
|
||||
TryParse(element.Attribute("num")?.Value, v => sc.Number = short.Parse(v));
|
||||
TryParse(element.Attribute("name")?.Value, v => sc.SensorName = v);
|
||||
TryParse(element.Element("Gain")?.Value, v => sc.Gain = double.Parse(v));
|
||||
TryParse(element.Element("Offset")?.Value, v => sc.Offset = double.Parse(v));
|
||||
TryParse(element.Element("MinVolt")?.Value, v => sc.MinVolt = double.Parse(v));
|
||||
TryParse(element.Element("MaxVolt")?.Value, v => sc.MaxVolt = double.Parse(v));
|
||||
TryParse(element.Element("MinVal")?.Value, v => sc.MinVal = double.Parse(v));
|
||||
TryParse(element.Element("MaxVal")?.Value, v => sc.MaxVal = double.Parse(v));
|
||||
TryParse(element.Attribute("num")?.Value, "num", v => sc.Number = short.Parse(v, CultureInfo.InvariantCulture));
|
||||
TryParse(element.Attribute("name")?.Value, "name", v => sc.SensorName = v);
|
||||
TryParse(element.Element("Gain")?.Value, "Gain", v => sc.Gain = ParseInvariant(v));
|
||||
TryParse(element.Element("Offset")?.Value, "Offset", v => sc.Offset = ParseInvariant(v));
|
||||
TryParse(element.Element("MinVolt")?.Value, "MinVolt", v => sc.MinVolt = ParseInvariant(v));
|
||||
TryParse(element.Element("MaxVolt")?.Value, "MaxVolt", v => sc.MaxVolt = ParseInvariant(v));
|
||||
TryParse(element.Element("MinVal")?.Value, "MinVal", v => sc.MinVal = ParseInvariant(v));
|
||||
TryParse(element.Element("MaxVal")?.Value, "MaxVal", v => sc.MaxVal = ParseInvariant(v));
|
||||
return sc;
|
||||
}
|
||||
|
||||
/// <summary>Parses a decimal under <see cref="CultureInfo.InvariantCulture"/>, tolerating comma separators.</summary>
|
||||
private static double ParseInvariant(string v)
|
||||
=> double.Parse(v.Replace(',', '.'), CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>Creates the default pressure sensor calibration for channel 1.</summary>
|
||||
public static SensorConfiguration DefaultPressureSensor()
|
||||
=> new SensorConfiguration
|
||||
@@ -97,10 +125,15 @@ namespace HC_APTBS.Models
|
||||
MaxVal = 20
|
||||
};
|
||||
|
||||
private static void TryParse(string? value, Action<string> assign)
|
||||
private static void TryParse(string? value, string fieldName, Action<string> assign)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
try { assign(value!); } catch { /* Ignore malformed XML values */ }
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
try { assign(value!); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
WarningLogger?.Invoke(nameof(SensorConfiguration),
|
||||
$"Skipped malformed '{fieldName}' value '{value}': {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user