feat: chart grid, pressure tolerance bands, QDelivery RPM normalization, pump page polish
Charts - Add faint background grid (0.75px, #E0E0E0) to all live charts; matches PDF report style - Show min/max tolerance bands on P1/P2 pressure charts during test runs (previously only Q-Delivery/Q-Over) - Broaden BenchService.ToleranceUpdated to fire for every phase receive; UI routes by name - Clear P1/P2 traces on PhaseChanged alongside Delivery/Over CAN - Normalize QDelivery flow rate to 1000 RPM reference before IIR filter so RPM spikes are low-pass filtered with flow-rate transients (matches old_source behavior) Pump page - Reorder columns: identification left, commands center, live data right - PreIn control always visible; disabled when pump lacks pre-injection (rename IsPreInVisible -> IsPreInAvailable) - Swap value/label order in command cards - Remove redundant KlineErrors row from identification card Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,15 @@ namespace HC_APTBS.Infrastructure.Pcan
|
|||||||
private Dictionary<uint, List<CanBusParameter>> _parameterMap = new();
|
private Dictionary<uint, List<CanBusParameter>> _parameterMap = new();
|
||||||
private readonly object _mapLock = new();
|
private readonly object _mapLock = new();
|
||||||
|
|
||||||
|
// Cached reference to the bench RPM parameter, re-resolved on every SetParameters /
|
||||||
|
// AddParameters call. Used to normalize QDelivery (flow rate) against shaft speed
|
||||||
|
// before the IIR low-pass filter runs, so that RPM spikes are filtered alongside
|
||||||
|
// flow-rate transients rather than bleeding into the displayed value unfiltered.
|
||||||
|
// Matches old_source behavior (Herlic2.0/MainWindow.xaml.cs:656, 1874).
|
||||||
|
private CanBusParameter? _benchRpmParam;
|
||||||
|
private const double QDeliveryReferenceRpm = 1000.0;
|
||||||
|
private const double QDeliveryMinRpm = 1.0;
|
||||||
|
|
||||||
private Thread? _readThread;
|
private Thread? _readThread;
|
||||||
private AutoResetEvent? _receiveEvent;
|
private AutoResetEvent? _receiveEvent;
|
||||||
private volatile bool _stopRead = true;
|
private volatile bool _stopRead = true;
|
||||||
@@ -228,6 +237,7 @@ namespace HC_APTBS.Infrastructure.Pcan
|
|||||||
lock (_mapLock)
|
lock (_mapLock)
|
||||||
{
|
{
|
||||||
_parameterMap = parameters;
|
_parameterMap = parameters;
|
||||||
|
ResolveBenchRpmParam();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +251,24 @@ namespace HC_APTBS.Infrastructure.Pcan
|
|||||||
if (!_parameterMap.ContainsKey(kv.Key))
|
if (!_parameterMap.ContainsKey(kv.Key))
|
||||||
_parameterMap.Add(kv.Key, kv.Value);
|
_parameterMap.Add(kv.Key, kv.Value);
|
||||||
}
|
}
|
||||||
|
ResolveBenchRpmParam();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call under _mapLock.
|
||||||
|
private void ResolveBenchRpmParam()
|
||||||
|
{
|
||||||
|
_benchRpmParam = null;
|
||||||
|
foreach (var list in _parameterMap.Values)
|
||||||
|
{
|
||||||
|
foreach (var p in list)
|
||||||
|
{
|
||||||
|
if (p.Name == BenchParameterNames.BenchRpm)
|
||||||
|
{
|
||||||
|
_benchRpmParam = p;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,15 +536,27 @@ namespace HC_APTBS.Infrastructure.Pcan
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spike rejection for QDelivery: discard values that are more than
|
// Spike rejection for QDelivery: discard values that are more than
|
||||||
// 100x the previous reading (caused by relay switching noise).
|
// 100x the previous raw reading (caused by relay switching noise).
|
||||||
|
// Compare against the previous raw-normalized value below.
|
||||||
if (param.Name == BenchParameterNames.QDelivery)
|
if (param.Name == BenchParameterNames.QDelivery)
|
||||||
{
|
{
|
||||||
if (previousValue > 0.1 && param.Value > previousValue * 100)
|
// Normalize raw flow rate to a 1000 RPM reference BEFORE filtering,
|
||||||
|
// so that RPM spikes are low-pass filtered together with flow-rate
|
||||||
|
// transients rather than appearing as instantaneous jumps in the
|
||||||
|
// normalized output.
|
||||||
|
double rpm = _benchRpmParam?.Value ?? 0;
|
||||||
|
double normalized = rpm < QDeliveryMinRpm
|
||||||
|
? 0
|
||||||
|
: param.Value * (QDeliveryReferenceRpm / rpm);
|
||||||
|
|
||||||
|
if (previousValue > 0.1 && normalized > previousValue * 100)
|
||||||
{
|
{
|
||||||
_log.Warning(LogId,
|
_log.Warning(LogId,
|
||||||
$"QDelivery spike suppressed: prev={previousValue:F3}, new={param.Value:F3}");
|
$"QDelivery spike suppressed: prev={previousValue:F3}, new={normalized:F3}");
|
||||||
param.Value = previousValue;
|
normalized = previousValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
param.Value = normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply single-pole IIR low-pass filter.
|
// Apply single-pole IIR low-pass filter.
|
||||||
|
|||||||
@@ -754,13 +754,10 @@ namespace HC_APTBS.Services.Impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify chart view of expected tolerance bands.
|
// Notify chart view of expected tolerance bands for every receive.
|
||||||
|
// The UI layer routes to the appropriate chart by parameter name.
|
||||||
foreach (var recv in phase.Receives)
|
foreach (var recv in phase.Receives)
|
||||||
{
|
|
||||||
if (recv.Name == BenchParameterNames.QDelivery ||
|
|
||||||
recv.Name == BenchParameterNames.QOver)
|
|
||||||
ToleranceUpdated?.Invoke(recv.Name, recv.Value, recv.Tolerance);
|
ToleranceUpdated?.Invoke(recv.Name, recv.Value, recv.Tolerance);
|
||||||
}
|
|
||||||
|
|
||||||
// ── Step 4: Conditioning time countdown ───────────────────────────
|
// ── Step 4: Conditioning time countdown ───────────────────────────
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
|
|||||||
@@ -252,6 +252,8 @@ namespace HC_APTBS.ViewModels
|
|||||||
// Clear real-time plot traces at each new phase boundary.
|
// Clear real-time plot traces at each new phase boundary.
|
||||||
FlowmeterChart.Delivery.Clear();
|
FlowmeterChart.Delivery.Clear();
|
||||||
FlowmeterChart.Over.Clear();
|
FlowmeterChart.Over.Clear();
|
||||||
|
BenchPage.PressureTrace.P1.Clear();
|
||||||
|
BenchPage.PressureTrace.P2.Clear();
|
||||||
});
|
});
|
||||||
_bench.PhaseTimerTick += (section, remaining, total) => App.Current.Dispatcher.Invoke(
|
_bench.PhaseTimerTick += (section, remaining, total) => App.Current.Dispatcher.Invoke(
|
||||||
() => TestPanel.ApplyPhaseTimerTick(section, remaining, total));
|
() => TestPanel.ApplyPhaseTimerTick(section, remaining, total));
|
||||||
@@ -269,6 +271,10 @@ namespace HC_APTBS.ViewModels
|
|||||||
{
|
{
|
||||||
TestPanel.UpdateLiveIndicator(paramName, value);
|
TestPanel.UpdateLiveIndicator(paramName, value);
|
||||||
FlowmeterChart.SetTolerance(paramName, value, tolerance);
|
FlowmeterChart.SetTolerance(paramName, value, tolerance);
|
||||||
|
if (paramName == BenchParameterNames.Pressure)
|
||||||
|
BenchPage.PressureTrace.P1.SetTolerance(value, tolerance);
|
||||||
|
else if (paramName == BenchParameterNames.AnalogSensor2)
|
||||||
|
BenchPage.PressureTrace.P2.SetTolerance(value, tolerance);
|
||||||
});
|
});
|
||||||
|
|
||||||
_bench.MeasurementSampled += (name, value) => App.Current.Dispatcher.Invoke(() =>
|
_bench.MeasurementSampled += (name, value) => App.Current.Dispatcher.Invoke(() =>
|
||||||
@@ -277,6 +283,10 @@ namespace HC_APTBS.ViewModels
|
|||||||
FlowmeterChart.Delivery.AddValue(value);
|
FlowmeterChart.Delivery.AddValue(value);
|
||||||
else if (name == BenchParameterNames.QOver)
|
else if (name == BenchParameterNames.QOver)
|
||||||
FlowmeterChart.Over.AddValue(value);
|
FlowmeterChart.Over.AddValue(value);
|
||||||
|
else if (name == BenchParameterNames.Pressure)
|
||||||
|
BenchPage.PressureTrace.P1.AddValue(value);
|
||||||
|
else if (name == BenchParameterNames.AnalogSensor2)
|
||||||
|
BenchPage.PressureTrace.P2.AddValue(value);
|
||||||
});
|
});
|
||||||
_bench.EmergencyStopTriggered += reason => App.Current.Dispatcher.Invoke(() =>
|
_bench.EmergencyStopTriggered += reason => App.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
@@ -329,7 +339,7 @@ namespace HC_APTBS.ViewModels
|
|||||||
_can.RegisterPumpMessageIds(GetReceiveMessageIds(pump.ParametersById));
|
_can.RegisterPumpMessageIds(GetReceiveMessageIds(pump.ParametersById));
|
||||||
|
|
||||||
// Configure pump control sliders.
|
// Configure pump control sliders.
|
||||||
PumpControl.IsPreInVisible = pump.HasPreInjection;
|
PumpControl.IsPreInAvailable = pump.HasPreInjection;
|
||||||
PumpControl.IsEnabled = true;
|
PumpControl.IsEnabled = true;
|
||||||
PumpControl.Reset();
|
PumpControl.Reset();
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace HC_APTBS.ViewModels
|
|||||||
// ── Visibility / enablement ───────────────────────────────────────────────
|
// ── Visibility / enablement ───────────────────────────────────────────────
|
||||||
|
|
||||||
/// <summary>True when the current pump supports pre-injection.</summary>
|
/// <summary>True when the current pump supports pre-injection.</summary>
|
||||||
[ObservableProperty] private bool _isPreInVisible;
|
[ObservableProperty] private bool _isPreInAvailable;
|
||||||
|
|
||||||
/// <summary>True when a pump is selected and CAN is connected.</summary>
|
/// <summary>True when a pump is selected and CAN is connected.</summary>
|
||||||
[ObservableProperty] private bool _isEnabled;
|
[ObservableProperty] private bool _isEnabled;
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ namespace HC_APTBS.ViewModels
|
|||||||
new Axis
|
new Axis
|
||||||
{
|
{
|
||||||
AnimationsSpeed = TimeSpan.Zero,
|
AnimationsSpeed = TimeSpan.Zero,
|
||||||
MinLimit = 0
|
MinLimit = 0,
|
||||||
|
SeparatorsPaint = new SolidColorPaint(new SKColor(224, 224, 224), 0.75f)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,12 @@
|
|||||||
<Grid Grid.Row="1">
|
<Grid Grid.Row="1">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="1*" MinWidth="260"/>
|
<ColumnDefinition Width="1*" MinWidth="260"/>
|
||||||
<ColumnDefinition Width="1.5*"/>
|
|
||||||
<ColumnDefinition Width="1*" MinWidth="280"/>
|
<ColumnDefinition Width="1*" MinWidth="280"/>
|
||||||
|
<ColumnDefinition Width="1.5*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- Col 0: Commands (top 2*) + Idling Calibration (bottom 1*) -->
|
<!-- Col 0: Commands (top 2*) + Idling Calibration (bottom 1*) -->
|
||||||
<Grid Grid.Column="0">
|
<Grid Grid.Column="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="2*"/>
|
<RowDefinition Height="2*"/>
|
||||||
<RowDefinition Height="1*"/>
|
<RowDefinition Height="1*"/>
|
||||||
@@ -48,10 +48,10 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Col 1: Live Data (full height) -->
|
<!-- Col 1: Live Data (full height) -->
|
||||||
<uc:PumpLiveDataCard Grid.Column="1"/>
|
<uc:PumpLiveDataCard Grid.Column="2"/>
|
||||||
|
|
||||||
<!-- Col 2: Identification (Auto) + DTCs (*) -->
|
<!-- Col 2: Identification (Auto) + DTCs (*) -->
|
||||||
<Grid Grid.Column="2">
|
<Grid Grid.Column="0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
<!-- DataContext = PumpControlViewModel (via {Binding PumpControl}) -->
|
<!-- DataContext = PumpControlViewModel (via {Binding PumpControl}) -->
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
|
|
||||||
|
|
||||||
<Style x:Key="SettingsTextBox" TargetType="TextBox">
|
<Style x:Key="SettingsTextBox" TargetType="TextBox">
|
||||||
<Setter Property="Width" Value="44"/>
|
<Setter Property="Width" Value="44"/>
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||||
@@ -81,15 +79,15 @@
|
|||||||
Style="{StaticResource PumpCommandLabel}"
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
Margin="0,2,0,6"/>
|
Margin="0,2,0,6"/>
|
||||||
|
|
||||||
|
<!-- Parameter name (above current value) -->
|
||||||
|
<TextBlock Text="{DynamicResource Pump.Commands.Fbkw}"
|
||||||
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
|
Margin="0,0,0,2"/>
|
||||||
|
|
||||||
<!-- Editable value box -->
|
<!-- Editable value box -->
|
||||||
<TextBox Text="{Binding FbkwValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
<TextBox Text="{Binding FbkwValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
||||||
Style="{StaticResource PumpCommandValue}"/>
|
Style="{StaticResource PumpCommandValue}"/>
|
||||||
|
|
||||||
<!-- Parameter name -->
|
|
||||||
<TextBlock Text="{DynamicResource Pump.Commands.Fbkw}"
|
|
||||||
Style="{StaticResource PumpCommandLabel}"
|
|
||||||
Margin="0,6,0,0"/>
|
|
||||||
|
|
||||||
<!-- Settings popup -->
|
<!-- Settings popup -->
|
||||||
<Popup IsOpen="{Binding IsChecked, ElementName=FbkwToggle}"
|
<Popup IsOpen="{Binding IsChecked, ElementName=FbkwToggle}"
|
||||||
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
||||||
@@ -140,12 +138,12 @@
|
|||||||
Style="{StaticResource PumpCommandLabel}"
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
Margin="0,2,0,6"/>
|
Margin="0,2,0,6"/>
|
||||||
|
|
||||||
<TextBox Text="{Binding MeValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
|
||||||
Style="{StaticResource PumpCommandValue}"/>
|
|
||||||
|
|
||||||
<TextBlock Text="{DynamicResource Pump.Commands.Me}"
|
<TextBlock Text="{DynamicResource Pump.Commands.Me}"
|
||||||
Style="{StaticResource PumpCommandLabel}"
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
Margin="0,6,0,0"/>
|
Margin="0,0,0,2"/>
|
||||||
|
|
||||||
|
<TextBox Text="{Binding MeValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
||||||
|
Style="{StaticResource PumpCommandValue}"/>
|
||||||
|
|
||||||
<Popup IsOpen="{Binding IsChecked, ElementName=MeToggle}"
|
<Popup IsOpen="{Binding IsChecked, ElementName=MeToggle}"
|
||||||
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
||||||
@@ -168,9 +166,9 @@
|
|||||||
</Popup>
|
</Popup>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- ── PreIn (conditional) ─────────────────────────────── -->
|
<!-- ── PreIn (always visible; disabled when pump lacks pre-injection) ── -->
|
||||||
<StackPanel Grid.Column="2" HorizontalAlignment="Center"
|
<StackPanel Grid.Column="2" HorizontalAlignment="Center"
|
||||||
Visibility="{Binding IsPreInVisible, Converter={StaticResource BoolToVis}}">
|
IsEnabled="{Binding IsPreInAvailable}">
|
||||||
<ToggleButton x:Name="PreInToggle"
|
<ToggleButton x:Name="PreInToggle"
|
||||||
Width="28" Height="22"
|
Width="28" Height="22"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
@@ -197,12 +195,12 @@
|
|||||||
Style="{StaticResource PumpCommandLabel}"
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
Margin="0,2,0,6"/>
|
Margin="0,2,0,6"/>
|
||||||
|
|
||||||
<TextBox Text="{Binding PreInValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
|
||||||
Style="{StaticResource PumpCommandValue}"/>
|
|
||||||
|
|
||||||
<TextBlock Text="{DynamicResource Pump.Commands.PreIn}"
|
<TextBlock Text="{DynamicResource Pump.Commands.PreIn}"
|
||||||
Style="{StaticResource PumpCommandLabel}"
|
Style="{StaticResource PumpCommandLabel}"
|
||||||
Margin="0,6,0,0"/>
|
Margin="0,0,0,2"/>
|
||||||
|
|
||||||
|
<TextBox Text="{Binding PreInValue, UpdateSourceTrigger=PropertyChanged, StringFormat=F2}"
|
||||||
|
Style="{StaticResource PumpCommandValue}"/>
|
||||||
|
|
||||||
<Popup IsOpen="{Binding IsChecked, ElementName=PreInToggle}"
|
<Popup IsOpen="{Binding IsChecked, ElementName=PreInToggle}"
|
||||||
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
StaysOpen="False" Placement="Bottom" AllowsTransparency="True">
|
||||||
|
|||||||
@@ -122,11 +122,6 @@
|
|||||||
<TextBlock Text="{DynamicResource PumpId.Dfi}" Style="{StaticResource IdLabel}"/>
|
<TextBlock Text="{DynamicResource PumpId.Dfi}" Style="{StaticResource IdLabel}"/>
|
||||||
<TextBlock Text="{Binding KlineDfi}" Style="{StaticResource IdValue}"/>
|
<TextBlock Text="{Binding KlineDfi}" Style="{StaticResource IdValue}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,2">
|
|
||||||
<TextBlock Text="{DynamicResource PumpId.Errors}" Style="{StaticResource IdLabel}"/>
|
|
||||||
<TextBlock Text="{Binding KlineErrors}" Style="{StaticResource IdValue}"
|
|
||||||
Foreground="{DynamicResource SystemFillColorCriticalBrush}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user