This commit is contained in:
@@ -114,16 +114,28 @@ namespace MembranePoreTester.ViewModels
|
|||||||
flow = Math.Round(ConvertFlowByMode(rawFlow), 2);
|
flow = Math.Round(ConvertFlowByMode(rawFlow), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pressure <= 0 || flow <= 0)
|
||||||
|
return;
|
||||||
CurrentFlow = flow;
|
CurrentFlow = flow;
|
||||||
// 3. 直接新增一行(不查找相同压力)
|
// 3. 查找是否已有相同压力点(按两位小数匹配),有则更新对应流量,否则新增
|
||||||
var newPoint = new Models.DataPoint
|
var existing = Record.DataPoints.FirstOrDefault(p => Math.Abs(p.Pressure - pressure) < 0.001);
|
||||||
|
if (existing != null)
|
||||||
{
|
{
|
||||||
Pressure = pressure,
|
if (TestMode != null && TestMode.Contains("湿膜"))
|
||||||
WetFlow = TestMode.Contains("湿膜") ? flow : 0,
|
existing.WetFlow = flow;
|
||||||
DryFlow = TestMode.Contains("干膜") ? flow : 0
|
else
|
||||||
};
|
existing.DryFlow = flow;
|
||||||
Record.DataPoints.Add(newPoint);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newPoint = new Models.DataPoint
|
||||||
|
{
|
||||||
|
Pressure = Math.Round(pressure, 2),
|
||||||
|
WetFlow = TestMode != null && TestMode.Contains("湿膜") ? flow : 0,
|
||||||
|
DryFlow = TestMode != null && TestMode.Contains("干膜") ? flow : 0
|
||||||
|
};
|
||||||
|
Record.DataPoints.Add(newPoint);
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 刷新曲线
|
// 4. 刷新曲线
|
||||||
UpdatePlot();
|
UpdatePlot();
|
||||||
@@ -732,7 +744,14 @@ namespace MembranePoreTester.ViewModels
|
|||||||
public string TestMode
|
public string TestMode
|
||||||
{
|
{
|
||||||
get => _testMode;
|
get => _testMode;
|
||||||
set => SetProperty(ref _testMode, value);
|
set
|
||||||
|
{
|
||||||
|
if (SetProperty(ref _testMode, value))
|
||||||
|
{
|
||||||
|
// 切换测试模式时刷新曲线显示(显示对应模式的历史数据)
|
||||||
|
UpdatePlot();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -785,6 +804,9 @@ namespace MembranePoreTester.ViewModels
|
|||||||
TitleFontWeight = 1
|
TitleFontWeight = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 让线条更平滑:使用线性插值(OxyPlot 默认即可),同时关闭区域填充等
|
||||||
|
model.DefaultColors = new[] { OxyColors.Blue, OxyColors.Red };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 添加坐标轴
|
// 添加坐标轴
|
||||||
@@ -799,41 +821,56 @@ namespace MembranePoreTester.ViewModels
|
|||||||
{
|
{
|
||||||
Position = AxisPosition.Left,
|
Position = AxisPosition.Left,
|
||||||
Title = "流量 (L/min)",
|
Title = "流量 (L/min)",
|
||||||
TitleFontSize = 12
|
TitleFontSize = 12,
|
||||||
|
Minimum = 0, // 从0开始绘制,避免覆盖整个Y轴
|
||||||
|
MajorGridlineStyle = LineStyle.Solid,
|
||||||
|
MinorGridlineStyle = LineStyle.Dot
|
||||||
});
|
});
|
||||||
|
|
||||||
// 湿膜流量 - 使用更清晰的标题
|
// 湿膜流量 - 使用更清晰的标题
|
||||||
var wetSeries = new LineSeries
|
var wetSeries = new LineSeries
|
||||||
{
|
{
|
||||||
Title = "● 湿膜流量 (Wet Flow)",
|
Title = "湿膜流量 (Wet Flow)",
|
||||||
Color = OxyColors.Blue,
|
Color = OxyColors.Blue,
|
||||||
MarkerType = MarkerType.Circle,
|
MarkerType = MarkerType.None,
|
||||||
MarkerSize = 4,
|
StrokeThickness = 1
|
||||||
MarkerStroke = OxyColors.Blue,
|
|
||||||
MarkerFill = OxyColors.Blue,
|
|
||||||
StrokeThickness = 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 干膜流量 - 使用更清晰的标题
|
// 干膜流量 - 使用更清晰的标题
|
||||||
var drySeries = new LineSeries
|
var drySeries = new LineSeries
|
||||||
{
|
{
|
||||||
Title = "▲ 干膜流量 (Dry Flow)",
|
Title = "干膜流量 (Dry Flow)",
|
||||||
Color = OxyColors.Red,
|
Color = OxyColors.Red,
|
||||||
MarkerType = MarkerType.Triangle,
|
MarkerType = MarkerType.None,
|
||||||
MarkerSize = 5,
|
StrokeThickness = 1
|
||||||
MarkerStroke = OxyColors.Red,
|
|
||||||
MarkerFill = OxyColors.Red,
|
|
||||||
StrokeThickness = 2
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 始终按记录填充两个序列(保留历史数据),但只在当前测试模式下将对应序列添加到图表
|
||||||
foreach (var dp in sorted)
|
foreach (var dp in sorted)
|
||||||
{
|
{
|
||||||
wetSeries.Points.Add(new OxyPlot.DataPoint(dp.Pressure, dp.WetFlow));
|
wetSeries.Points.Add(new OxyPlot.DataPoint(dp.Pressure, dp.WetFlow));
|
||||||
drySeries.Points.Add(new OxyPlot.DataPoint(dp.Pressure, dp.DryFlow));
|
drySeries.Points.Add(new OxyPlot.DataPoint(dp.Pressure, dp.DryFlow));
|
||||||
}
|
}
|
||||||
|
|
||||||
model.Series.Add(wetSeries);
|
// 根据当前 TestMode 决定显示哪条曲线,切换回另一种模式时其历史数据会从 Record 恢复并显示
|
||||||
model.Series.Add(drySeries);
|
if (TestMode != null && TestMode.Contains("湿膜"))
|
||||||
|
{
|
||||||
|
if (wetSeries.Points.Count > 0)
|
||||||
|
model.Series.Add(wetSeries);
|
||||||
|
}
|
||||||
|
else if (TestMode != null && TestMode.Contains("干膜"))
|
||||||
|
{
|
||||||
|
if (drySeries.Points.Count > 0)
|
||||||
|
model.Series.Add(drySeries);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 如果没有明确模式,默认显示两条曲线(适用于同时显示的情况)
|
||||||
|
if (wetSeries.Points.Count > 0)
|
||||||
|
model.Series.Add(wetSeries);
|
||||||
|
if (drySeries.Points.Count > 0)
|
||||||
|
model.Series.Add(drySeries);
|
||||||
|
}
|
||||||
|
|
||||||
lock (_plotLock)
|
lock (_plotLock)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,6 +152,7 @@
|
|||||||
|
|
||||||
<Label Grid.Row="3" Grid.Column="2" Content="(干/湿膜)/(大/小流量):"/>
|
<Label Grid.Row="3" Grid.Column="2" Content="(干/湿膜)/(大/小流量):"/>
|
||||||
<ComboBox HorizontalAlignment="Left" Grid.Row="3" Grid.Column="3" SelectedItem="{Binding TestMode}" Width="80">
|
<ComboBox HorizontalAlignment="Left" Grid.Row="3" Grid.Column="3" SelectedItem="{Binding TestMode}" Width="80">
|
||||||
|
<ComboBoxItem Content="全部" />
|
||||||
<ComboBoxItem Content="湿膜" IsSelected="True"/>
|
<ComboBoxItem Content="湿膜" IsSelected="True"/>
|
||||||
<ComboBoxItem Content="干膜"/>
|
<ComboBoxItem Content="干膜"/>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user