This commit is contained in:
@@ -129,28 +129,40 @@ namespace MembranePoreTester.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 始终读取压力
|
||||
float rawPressure = await _plcService.ReadPressureAsync();
|
||||
float rawWetFlow = await _plcService.ReadWetFlowAsync();
|
||||
float rawDryFlow = await _plcService.ReadDryFlowAsync();
|
||||
|
||||
double pressure = rawPressure * _plcConfig.PressureFactor;
|
||||
double wetFlow = rawWetFlow * _plcConfig.WetFlowFactor;
|
||||
double dryFlow = rawDryFlow * _plcConfig.DryFlowFactor;
|
||||
|
||||
if (SelectedDataPoint != null)
|
||||
{
|
||||
// 更新选中行
|
||||
SelectedDataPoint.Pressure = pressure;
|
||||
SelectedDataPoint.WetFlow = wetFlow;
|
||||
SelectedDataPoint.DryFlow = dryFlow;
|
||||
if (TestMode == "湿膜")
|
||||
{
|
||||
float rawWet = await _plcService.ReadWetFlowAsync();
|
||||
SelectedDataPoint.WetFlow = rawWet * _plcConfig.WetFlowFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
float rawDry = await _plcService.ReadDryFlowAsync();
|
||||
SelectedDataPoint.DryFlow = rawDry * _plcConfig.DryFlowFactor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Record.DataPoints.Add(new DataPoint
|
||||
// 新增一行
|
||||
var newPoint = new DataPoint { Pressure = pressure };
|
||||
if (TestMode == "湿膜")
|
||||
{
|
||||
Pressure = pressure,
|
||||
WetFlow = wetFlow,
|
||||
DryFlow = dryFlow
|
||||
});
|
||||
float rawWet = await _plcService.ReadWetFlowAsync();
|
||||
newPoint.WetFlow = rawWet * _plcConfig.WetFlowFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
float rawDry = await _plcService.ReadDryFlowAsync();
|
||||
newPoint.DryFlow = rawDry * _plcConfig.DryFlowFactor;
|
||||
}
|
||||
Record.DataPoints.Add(newPoint);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -309,5 +321,15 @@ namespace MembranePoreTester.ViewModels
|
||||
MessageBox.Show("导出成功");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string _testMode = "湿膜";
|
||||
public string TestMode
|
||||
{
|
||||
get => _testMode;
|
||||
set => SetProperty(ref _testMode, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,12 @@
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,5">
|
||||
<Button Content="添加行" Command="{Binding AddDataPointCommand}" Padding="10,5" Margin="5"/>
|
||||
<Button Content="删除行" Command="{Binding RemoveDataPointCommand}" Padding="10,5" Margin="5"/>
|
||||
|
||||
<!-- 新增:模式选择 -->
|
||||
<ComboBox SelectedItem="{Binding TestMode}" Width="80" Margin="5">
|
||||
<ComboBoxItem Content="湿膜" IsSelected="True"/>
|
||||
<ComboBoxItem Content="干膜"/>
|
||||
</ComboBox>
|
||||
<Button Content="读取PLC" Command="{Binding ReadPlcCommand}" Padding="10,5" Margin="5"/>
|
||||
</StackPanel>
|
||||
<DataGrid ItemsSource="{Binding Record.DataPoints}" AutoGenerateColumns="False" CanUserAddRows="False">
|
||||
|
||||
Reference in New Issue
Block a user