移除更新
This commit is contained in:
@@ -32,15 +32,10 @@ namespace COFTester.Models
|
||||
/// </summary>
|
||||
public class TestParameters : INotifyPropertyChanged
|
||||
{
|
||||
private string _standard = "GB 10006";
|
||||
private double _sledMass = 0.0; // 不设置默认值,从寄存器读取
|
||||
private double _testSpeed = 0.0; // 不设置默认值,从寄存器读取
|
||||
private double _testDuration = 0.0; // 不设置默认值,从寄存器读取
|
||||
private double _testStroke = 0.0; // 不设置默认值,从寄存器读取
|
||||
private double _staticCalcStart = 0.0;
|
||||
private double _staticCalcEnd = 5.0;
|
||||
private double _kineticCalcStart = 10.0;
|
||||
private double _kineticCalcEnd = 75.0;
|
||||
private double _sampleWidth = 25.0; // 試樣寬度 (mm),用於剝離強度計算
|
||||
|
||||
// 手动控制参数 - 不设置默认值,从寄存器读取
|
||||
@@ -65,20 +60,12 @@ namespace COFTester.Models
|
||||
private bool _directionRight = true;
|
||||
private bool _directionLeft = false;
|
||||
|
||||
public string Standard
|
||||
{
|
||||
get => _standard;
|
||||
set
|
||||
{
|
||||
if (_standard != value)
|
||||
{
|
||||
_standard = value;
|
||||
OnPropertyChanged();
|
||||
// 当标准改变时,自动应用该标准的推荐参数
|
||||
ApplyStandardParameters();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 固定值 - 不再从UI配置,仅用于向后兼容
|
||||
public string Standard { get; set; } = "GB 10006";
|
||||
public double StaticCalcStart { get; set; } = 0.0;
|
||||
public double StaticCalcEnd { get; set; } = 5.0;
|
||||
public double KineticCalcStart { get; set; } = 10.0;
|
||||
public double KineticCalcEnd { get; set; } = 75.0;
|
||||
|
||||
public double SledMass
|
||||
{
|
||||
@@ -104,30 +91,6 @@ namespace COFTester.Models
|
||||
set { _testStroke = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public double StaticCalcStart
|
||||
{
|
||||
get => _staticCalcStart;
|
||||
set { _staticCalcStart = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public double StaticCalcEnd
|
||||
{
|
||||
get => _staticCalcEnd;
|
||||
set { _staticCalcEnd = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public double KineticCalcStart
|
||||
{
|
||||
get => _kineticCalcStart;
|
||||
set { _kineticCalcStart = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
public double KineticCalcEnd
|
||||
{
|
||||
get => _kineticCalcEnd;
|
||||
set { _kineticCalcEnd = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 試樣寬度 (mm),用於 GB/T 2792 剝離強度計算
|
||||
/// 標準試樣寬度:25mm
|
||||
@@ -265,37 +228,6 @@ namespace COFTester.Models
|
||||
public string MaterialType { get; set; } = "Plastic Film"; // 材料類型
|
||||
public string Operator { get; set; } = "Default"; // 操作員
|
||||
|
||||
/// <summary>
|
||||
/// 根据选择的标准自动应用推荐参数
|
||||
/// </summary>
|
||||
private void ApplyStandardParameters()
|
||||
{
|
||||
var standard = TestStandardManager.GetAllStandards()
|
||||
.FirstOrDefault(s => s.Name == _standard);
|
||||
|
||||
if (standard != null)
|
||||
{
|
||||
_sledMass = standard.RecommendedSledMass;
|
||||
_testSpeed = standard.RecommendedTestSpeed;
|
||||
_testDuration = standard.RecommendedTestDuration;
|
||||
_testStroke = standard.RecommendedStroke;
|
||||
_staticCalcStart = standard.StaticCalcStart;
|
||||
_staticCalcEnd = standard.StaticCalcEnd;
|
||||
_kineticCalcStart = standard.KineticCalcStart;
|
||||
_kineticCalcEnd = standard.KineticCalcEnd;
|
||||
|
||||
// 通知所有属性已更改
|
||||
OnPropertyChanged(nameof(SledMass));
|
||||
OnPropertyChanged(nameof(TestSpeed));
|
||||
OnPropertyChanged(nameof(TestDuration));
|
||||
OnPropertyChanged(nameof(TestStroke));
|
||||
OnPropertyChanged(nameof(StaticCalcStart));
|
||||
OnPropertyChanged(nameof(StaticCalcEnd));
|
||||
OnPropertyChanged(nameof(KineticCalcStart));
|
||||
OnPropertyChanged(nameof(KineticCalcEnd));
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void OnPropertyChanged([CallerMemberName] string? name = null)
|
||||
{
|
||||
|
||||
@@ -13,9 +13,7 @@ namespace COFTester.ViewModels
|
||||
{
|
||||
public class ConfigViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private TestStandard? _selectedStandard;
|
||||
private TestParameters _configParams;
|
||||
private bool _showKineticWarning;
|
||||
private readonly IDataAcquisitionService? _daqService;
|
||||
|
||||
public ConfigViewModel(TestParameters currentParams, IDataAcquisitionService? daqService = null)
|
||||
@@ -27,15 +25,10 @@ namespace COFTester.ViewModels
|
||||
_configParams = new TestParameters
|
||||
{
|
||||
// 基本測試參數 - 初始化為 0(空值)
|
||||
Standard = currentParams.Standard, // 保留標準選擇
|
||||
SledMass = 0.0,
|
||||
TestSpeed = 0.0,
|
||||
TestDuration = 0.0,
|
||||
TestStroke = 0.0,
|
||||
StaticCalcStart = currentParams.StaticCalcStart, // 保留計算區間
|
||||
StaticCalcEnd = currentParams.StaticCalcEnd,
|
||||
KineticCalcStart = currentParams.KineticCalcStart,
|
||||
KineticCalcEnd = currentParams.KineticCalcEnd,
|
||||
SampleWidth = currentParams.SampleWidth, // 保留試樣寬度
|
||||
|
||||
// 手動控制參數 - 初始化為 0(空值)
|
||||
@@ -55,16 +48,6 @@ namespace COFTester.ViewModels
|
||||
DirectionLeft = currentParams.DirectionLeft
|
||||
};
|
||||
|
||||
// 載入所有標準
|
||||
Standards = TestStandardManager.GetAllStandards();
|
||||
|
||||
// 選擇當前標準
|
||||
_selectedStandard = Standards.FirstOrDefault(s => s.Name == currentParams.Standard)
|
||||
?? Standards.First();
|
||||
|
||||
// 更新警告狀態
|
||||
UpdateKineticWarning();
|
||||
|
||||
ApplyCommand = new RelayCommand(Apply);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
|
||||
@@ -156,41 +139,6 @@ namespace COFTester.ViewModels
|
||||
|
||||
public LanguageResources Lang => LanguageResources.Instance;
|
||||
|
||||
public List<TestStandard> Standards { get; }
|
||||
|
||||
public TestStandard? SelectedStandard
|
||||
{
|
||||
get => _selectedStandard;
|
||||
set
|
||||
{
|
||||
if (_selectedStandard != value)
|
||||
{
|
||||
_selectedStandard = value;
|
||||
OnPropertyChanged();
|
||||
|
||||
// 自動填充推薦值
|
||||
if (_selectedStandard != null)
|
||||
{
|
||||
ApplyRecommendedValues(_selectedStandard);
|
||||
UpdateKineticWarning();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowKineticWarning
|
||||
{
|
||||
get => _showKineticWarning;
|
||||
set
|
||||
{
|
||||
if (_showKineticWarning != value)
|
||||
{
|
||||
_showKineticWarning = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TestParameters ConfigParams
|
||||
{
|
||||
get => _configParams;
|
||||
@@ -207,27 +155,6 @@ namespace COFTester.ViewModels
|
||||
public event EventHandler? RequestClose;
|
||||
public event EventHandler<TestParameters>? ConfigApplied;
|
||||
|
||||
private void UpdateKineticWarning()
|
||||
{
|
||||
ShowKineticWarning = _selectedStandard != null && !_selectedStandard.SupportsKineticFriction;
|
||||
}
|
||||
|
||||
private void ApplyRecommendedValues(TestStandard standard)
|
||||
{
|
||||
ConfigParams.Standard = standard.Name;
|
||||
ConfigParams.SledMass = standard.RecommendedSledMass;
|
||||
ConfigParams.TestSpeed = standard.RecommendedTestSpeed;
|
||||
ConfigParams.TestDuration = standard.RecommendedTestDuration;
|
||||
ConfigParams.TestStroke = standard.RecommendedStroke;
|
||||
ConfigParams.StaticCalcStart = standard.StaticCalcStart;
|
||||
ConfigParams.StaticCalcEnd = standard.StaticCalcEnd;
|
||||
ConfigParams.KineticCalcStart = standard.KineticCalcStart;
|
||||
ConfigParams.KineticCalcEnd = standard.KineticCalcEnd;
|
||||
|
||||
// 通知所有屬性更新
|
||||
OnPropertyChanged(nameof(ConfigParams));
|
||||
}
|
||||
|
||||
private void Apply()
|
||||
{
|
||||
ConfigApplied?.Invoke(this, ConfigParams);
|
||||
|
||||
@@ -1220,10 +1220,6 @@ namespace COFTester.ViewModels
|
||||
Parameters.TestSpeed = newParams.TestSpeed;
|
||||
Parameters.TestDuration = newParams.TestDuration;
|
||||
Parameters.TestStroke = newParams.TestStroke;
|
||||
Parameters.StaticCalcStart = newParams.StaticCalcStart;
|
||||
Parameters.StaticCalcEnd = newParams.StaticCalcEnd;
|
||||
Parameters.KineticCalcStart = newParams.KineticCalcStart;
|
||||
Parameters.KineticCalcEnd = newParams.KineticCalcEnd;
|
||||
|
||||
// 更新手動控制參數
|
||||
Parameters.HorizontalManualSpeed = newParams.HorizontalManualSpeed;
|
||||
|
||||
@@ -58,127 +58,6 @@
|
||||
<!-- Main Content -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<!-- 测试标准选择 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Lang.StandardSelection}" Style="{StaticResource SectionTitle}"/>
|
||||
|
||||
<!-- 标准下拉选择 -->
|
||||
<ComboBox ItemsSource="{Binding Standards}"
|
||||
SelectedItem="{Binding SelectedStandard}"
|
||||
FontSize="13"
|
||||
Height="42"
|
||||
VerticalContentAlignment="Center">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="5,3">
|
||||
<TextBlock Text="{Binding DisplayName}"
|
||||
FontWeight="SemiBold"
|
||||
FontSize="13"/>
|
||||
<TextBlock Text="{Binding TestObject}"
|
||||
FontSize="11"
|
||||
Foreground="#7F8C8D"
|
||||
Margin="0,2,0,0"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="8,6"/>
|
||||
<Setter Property="MinHeight" Value="50"/>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
|
||||
<!-- 标准详细信息卡片 -->
|
||||
<Border Background="#F8F9FA"
|
||||
CornerRadius="6"
|
||||
Padding="15"
|
||||
Margin="0,15,0,0"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 测试对象 -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="{Binding Lang.TestObject}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
Margin="0,0,10,8"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1"
|
||||
Text="{Binding SelectedStandard.TestObject}"
|
||||
FontSize="12"
|
||||
Foreground="#34495E"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<!-- 测试方法 -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Text="{Binding Lang.TestMethod}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
Margin="0,0,10,8"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
Text="{Binding SelectedStandard.TestMethod}"
|
||||
FontSize="12"
|
||||
Foreground="#34495E"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<!-- 关键指标 -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="{Binding Lang.KeyIndicators}"
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#2C3E50"
|
||||
Margin="0,0,10,8"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1"
|
||||
Text="{Binding SelectedStandard.KeyIndicators}"
|
||||
FontSize="12"
|
||||
Foreground="#27AE60"
|
||||
FontWeight="SemiBold"
|
||||
Margin="0,0,0,8"/>
|
||||
|
||||
<!-- 详细说明 -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Text="{Binding SelectedStandard.Description}"
|
||||
FontSize="11"
|
||||
Foreground="#7F8C8D"
|
||||
TextWrapping="Wrap"
|
||||
Margin="0,5,0,0"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- 警告提示(针对特殊标准) -->
|
||||
<Border Background="#FFF3CD"
|
||||
BorderBrush="#FFC107"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
Padding="12,8"
|
||||
Margin="0,10,0,0"
|
||||
Visibility="{Binding ShowKineticWarning, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="⚠️" FontSize="14" Margin="0,0,8,0"/>
|
||||
<TextBlock Text="{Binding Lang.KineticWarningMessage}"
|
||||
FontSize="11"
|
||||
Foreground="#856404"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 基本参数 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
@@ -330,49 +209,6 @@
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 计算区间 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Lang.CalculationRange}" Style="{StaticResource SectionTitle}"/>
|
||||
|
||||
<TextBlock Text="{Binding Lang.StaticCalcRange}" Style="{StaticResource LabelStyle}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="{Binding Lang.StartPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.StaticCalcStart}" Height="30" FontSize="13" Padding="5,6,0,0"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Text="~" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16" Margin="0,12,0,0"/>
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Text="{Binding Lang.EndPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.StaticCalcEnd}" Height="30" FontSize="13" Padding="5,6,0,0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="{Binding Lang.KineticCalcRange}" Style="{StaticResource LabelStyle}" Margin="0,15,0,4"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="{Binding Lang.StartPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.KineticCalcStart}" Height="30" FontSize="13" Padding="5,6,0,0"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1" Text="~" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="16" Margin="0,12,0,0"/>
|
||||
<StackPanel Grid.Column="2">
|
||||
<TextBlock Text="{Binding Lang.EndPosition}" FontSize="11" Foreground="{StaticResource GrayBrush}"/>
|
||||
<TextBox Text="{Binding ConfigParams.KineticCalcEnd}" Height="30" FontSize="13" Padding="5,6,0,0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
|
||||
@@ -83,14 +83,14 @@
|
||||
"AutoSaveResults": true,
|
||||
"DefaultTestParameters": {
|
||||
"Standard": "ASTM D1894",
|
||||
"SledMass": 200,
|
||||
"TestSpeed": 150,
|
||||
"TestDuration": 30,
|
||||
"TestStroke": 150,
|
||||
"StaticCalcStart": 0,
|
||||
"StaticCalcEnd": 5,
|
||||
"KineticCalcStart": 10,
|
||||
"KineticCalcEnd": 150,
|
||||
"SledMass": 200,
|
||||
"TestSpeed": 150,
|
||||
"TestDuration": 30,
|
||||
"TestStroke": 150,
|
||||
"SampleWidth": 25,
|
||||
"HorizontalManualSpeed": 10,
|
||||
"HorizontalManualDisplacement": 5,
|
||||
|
||||
Reference in New Issue
Block a user