feat: developer tools page, auto-test orchestrator, BIP display, tests redesign
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>
This commit is contained in:
@@ -12,14 +12,42 @@ namespace HC_APTBS.ViewModels
|
||||
/// <summary>
|
||||
/// Reusable ViewModel for a single real-time scrolling line chart.
|
||||
/// Backed by LiveChartsCore with a fixed-width sample window.
|
||||
///
|
||||
/// <para>Two modes:</para>
|
||||
/// <list type="bullet">
|
||||
/// <item><b>Index-axis (default):</b> <see cref="LineSeries{TModel}"/> of doubles; X = array index;
|
||||
/// axis is static. Samples shuffle through fixed X slots on each <see cref="AddValue"/>.</item>
|
||||
/// <item><b>Smooth-scroll (opt-in):</b> <see cref="LineSeries{TModel}"/> of <see cref="ObservablePoint"/>
|
||||
/// with X on a monotonic sample-index timeline. A host-driven per-frame hook calls
|
||||
/// <see cref="UpdateViewport"/> to slide the X-axis window, producing true continuous
|
||||
/// leftward motion independent of data cadence.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public sealed partial class SingleFlowChartViewModel : ObservableObject
|
||||
{
|
||||
private const int DefaultMaxSamples = 200;
|
||||
private const int SmoothTrimMargin = 4;
|
||||
|
||||
private readonly ObservableCollection<double> _values = new();
|
||||
private readonly bool _smoothScroll;
|
||||
private readonly int _maxSamples;
|
||||
|
||||
// Index-axis mode storage.
|
||||
private readonly ObservableCollection<double>? _values;
|
||||
|
||||
// Smooth-scroll mode storage + timeline state.
|
||||
// The series holds N committed points at integer X positions plus one trailing
|
||||
// "endpoint" whose X/Y interpolate each render frame from the previous committed
|
||||
// point toward the pending sample. On each new sample the endpoint snaps to its
|
||||
// target (becoming committed) and a new endpoint is appended at the same spot.
|
||||
// Net effect: the line tip slides continuously instead of hopping +1 in X per sample.
|
||||
private readonly ObservableCollection<ObservablePoint>? _points;
|
||||
private long _nextCommitX;
|
||||
private double _prevCommittedValue;
|
||||
private double _pendingValue;
|
||||
private DateTime _pendingArrivalUtc;
|
||||
private int _sampleCount;
|
||||
private ObservablePoint? _endpoint;
|
||||
|
||||
/// <summary>Chart title label.</summary>
|
||||
[ObservableProperty] private string _title = string.Empty;
|
||||
|
||||
@@ -47,32 +75,69 @@ namespace HC_APTBS.ViewModels
|
||||
/// <param name="title">Display title for the chart.</param>
|
||||
/// <param name="lineColor">SKColor for the line series.</param>
|
||||
/// <param name="maxSamples">Maximum number of samples before the oldest is dropped.</param>
|
||||
public SingleFlowChartViewModel(string title, SKColor lineColor, int maxSamples = DefaultMaxSamples)
|
||||
/// <param name="smoothScroll">
|
||||
/// When true, store samples on a monotonic X timeline and expect the host to call
|
||||
/// <see cref="UpdateViewport"/> each render frame to slide the visible window.
|
||||
/// When false (default), use the legacy index-axis behavior.
|
||||
/// </param>
|
||||
public SingleFlowChartViewModel(string title, SKColor lineColor, int maxSamples = DefaultMaxSamples, bool smoothScroll = false)
|
||||
{
|
||||
_title = title;
|
||||
_maxSamples = maxSamples;
|
||||
_title = title;
|
||||
_maxSamples = maxSamples;
|
||||
_smoothScroll = smoothScroll;
|
||||
|
||||
Series = new ISeries[]
|
||||
if (smoothScroll)
|
||||
{
|
||||
new LineSeries<double>
|
||||
_points = new ObservableCollection<ObservablePoint>();
|
||||
Series = new ISeries[]
|
||||
{
|
||||
Values = _values,
|
||||
Fill = null,
|
||||
GeometrySize = 0,
|
||||
Stroke = new SolidColorPaint(lineColor, 2),
|
||||
LineSmoothness = 0,
|
||||
AnimationsSpeed = TimeSpan.Zero
|
||||
}
|
||||
};
|
||||
new LineSeries<ObservablePoint>
|
||||
{
|
||||
Values = _points,
|
||||
Fill = null,
|
||||
GeometrySize = 0,
|
||||
Stroke = new SolidColorPaint(lineColor, 2),
|
||||
LineSmoothness = 0,
|
||||
AnimationsSpeed = TimeSpan.Zero
|
||||
}
|
||||
};
|
||||
|
||||
XAxes = new Axis[]
|
||||
{
|
||||
new Axis
|
||||
XAxes = new Axis[]
|
||||
{
|
||||
IsVisible = false,
|
||||
AnimationsSpeed = TimeSpan.Zero
|
||||
}
|
||||
};
|
||||
new Axis
|
||||
{
|
||||
IsVisible = false,
|
||||
AnimationsSpeed = TimeSpan.Zero,
|
||||
MinLimit = 0,
|
||||
MaxLimit = maxSamples
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
_values = new ObservableCollection<double>();
|
||||
Series = new ISeries[]
|
||||
{
|
||||
new LineSeries<double>
|
||||
{
|
||||
Values = _values,
|
||||
Fill = null,
|
||||
GeometrySize = 0,
|
||||
Stroke = new SolidColorPaint(lineColor, 2),
|
||||
LineSmoothness = 0,
|
||||
AnimationsSpeed = TimeSpan.Zero
|
||||
}
|
||||
};
|
||||
|
||||
XAxes = new Axis[]
|
||||
{
|
||||
new Axis
|
||||
{
|
||||
IsVisible = false,
|
||||
AnimationsSpeed = TimeSpan.Zero
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
YAxes = new Axis[]
|
||||
{
|
||||
@@ -91,10 +156,94 @@ namespace HC_APTBS.ViewModels
|
||||
/// </summary>
|
||||
public void AddValue(double value)
|
||||
{
|
||||
_values.Add(value);
|
||||
CurrentValue = value;
|
||||
if (_values.Count > _maxSamples)
|
||||
_values.RemoveAt(0);
|
||||
|
||||
if (_smoothScroll)
|
||||
{
|
||||
_sampleCount++;
|
||||
|
||||
if (_sampleCount == 1)
|
||||
{
|
||||
// First sample — commit at X=0 and anchor the viewport so the point sits
|
||||
// at the right edge. No endpoint yet; we need two samples before we can
|
||||
// interpolate between previous and pending.
|
||||
_points!.Add(new ObservablePoint(0, value));
|
||||
_nextCommitX = 1;
|
||||
_prevCommittedValue = value;
|
||||
_pendingValue = value;
|
||||
_pendingArrivalUtc = DateTime.UtcNow;
|
||||
XAxes[0].MaxLimit = 0;
|
||||
XAxes[0].MinLimit = -_maxSamples;
|
||||
}
|
||||
else if (_sampleCount == 2)
|
||||
{
|
||||
// Second sample — create the sliding endpoint at the previous committed
|
||||
// point. UpdateViewport will interpolate it toward the pending target.
|
||||
_pendingValue = value;
|
||||
_pendingArrivalUtc = DateTime.UtcNow;
|
||||
_endpoint = new ObservablePoint(_nextCommitX - 1, _prevCommittedValue);
|
||||
_points!.Add(_endpoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Third+ sample — finalize the existing endpoint at its target (making
|
||||
// it a committed point), advance the commit index, then append a fresh
|
||||
// endpoint at the just-finalized position. Because the endpoint is
|
||||
// already at X = _nextCommitX after the last render frame with
|
||||
// fraction≈1, the viewport continues from the same position without
|
||||
// a visible hop.
|
||||
_endpoint!.X = _nextCommitX;
|
||||
_endpoint.Y = _pendingValue;
|
||||
_prevCommittedValue = _pendingValue;
|
||||
_nextCommitX++;
|
||||
|
||||
_pendingValue = value;
|
||||
_pendingArrivalUtc = DateTime.UtcNow;
|
||||
_endpoint = new ObservablePoint(_nextCommitX - 1, _prevCommittedValue);
|
||||
_points!.Add(_endpoint);
|
||||
|
||||
// Keep a small margin past the visible window so the leftmost point
|
||||
// doesn't pop as the viewport advances past the trim boundary.
|
||||
while (_points.Count > _maxSamples + SmoothTrimMargin)
|
||||
_points.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_values!.Add(value);
|
||||
if (_values.Count > _maxSamples)
|
||||
_values.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smooth-scroll mode only: slides the X-axis viewport so the rightmost visible edge
|
||||
/// drifts continuously past the most recent sample, producing frame-rate smooth motion
|
||||
/// independent of data cadence. Host calls this once per render frame (e.g. from
|
||||
/// <c>CompositionTarget.Rendering</c>).
|
||||
/// </summary>
|
||||
/// <param name="nowUtc">Current time; pass <see cref="DateTime.UtcNow"/>.</param>
|
||||
/// <param name="nominalPeriodMs">
|
||||
/// Expected inter-sample period in milliseconds (e.g. <c>1000/Hz</c>). Used to interpolate
|
||||
/// fractional progress between samples.
|
||||
/// </param>
|
||||
public void UpdateViewport(DateTime nowUtc, double nominalPeriodMs)
|
||||
{
|
||||
if (!_smoothScroll || _endpoint == null || nominalPeriodMs <= 0)
|
||||
return;
|
||||
|
||||
double fraction = (nowUtc - _pendingArrivalUtc).TotalMilliseconds / nominalPeriodMs;
|
||||
if (fraction < 0) fraction = 0;
|
||||
else if (fraction > 1) fraction = 1;
|
||||
|
||||
double slideX = (_nextCommitX - 1) + fraction;
|
||||
double slideY = _prevCommittedValue + (_pendingValue - _prevCommittedValue) * fraction;
|
||||
|
||||
_endpoint.X = slideX;
|
||||
_endpoint.Y = slideY;
|
||||
|
||||
XAxes[0].MaxLimit = slideX;
|
||||
XAxes[0].MinLimit = slideX - _maxSamples;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -116,11 +265,25 @@ namespace HC_APTBS.ViewModels
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all sample data and tolerance bands.
|
||||
/// Clears all sample data and tolerance bands. Resets the smooth-scroll timeline.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
_values.Clear();
|
||||
if (_smoothScroll)
|
||||
{
|
||||
_points!.Clear();
|
||||
_nextCommitX = 0;
|
||||
_prevCommittedValue = 0;
|
||||
_pendingValue = 0;
|
||||
_sampleCount = 0;
|
||||
_endpoint = null;
|
||||
XAxes[0].MinLimit = 0;
|
||||
XAxes[0].MaxLimit = _maxSamples;
|
||||
}
|
||||
else
|
||||
{
|
||||
_values!.Clear();
|
||||
}
|
||||
Sections = Array.Empty<RectangularSection>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user