fix: 2026/2/6 提交 更新
This commit is contained in:
@@ -32,7 +32,7 @@ namespace COFTester.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TestParameters : INotifyPropertyChanged
|
public class TestParameters : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private double _sledMass = 0.0; // 不设置默认值,从寄存器读取
|
private double _sledMass = 200.0; // 默认值 200g
|
||||||
private double _testSpeed = 0.0; // 不设置默认值,从寄存器读取
|
private double _testSpeed = 0.0; // 不设置默认值,从寄存器读取
|
||||||
private double _testDuration = 0.0; // 不设置默认值,从寄存器读取
|
private double _testDuration = 0.0; // 不设置默认值,从寄存器读取
|
||||||
private double _testStroke = 0.0; // 不设置默认值,从寄存器读取
|
private double _testStroke = 0.0; // 不设置默认值,从寄存器读取
|
||||||
|
|||||||
@@ -727,6 +727,18 @@ namespace COFTester.Services
|
|||||||
await WriteTestParametersAsync(parameters);
|
await WriteTestParametersAsync(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公开方法:写入水平测试参数到 PLC 寄存器(D370, D380)
|
||||||
|
/// 供标准选择功能调用
|
||||||
|
/// </summary>
|
||||||
|
public abstract Task WriteHorizontalTestParametersAsync(double speed, double displacement);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 公开方法:写入升降测试参数到 PLC 寄存器(D330, D340)
|
||||||
|
/// 供自定义参数更新功能调用
|
||||||
|
/// </summary>
|
||||||
|
public abstract Task WriteVerticalTestParametersAsync(double speed, double displacement);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 將兩個寄存器轉換為 32位浮點型 (IEEE 754)
|
/// 將兩個寄存器轉換為 32位浮點型 (IEEE 754)
|
||||||
///
|
///
|
||||||
@@ -1305,6 +1317,76 @@ namespace COFTester.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入水平测试参数到 PLC 寄存器(D370 水平测试速度, D380 水平测试位移)
|
||||||
|
/// 供标准选择功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteHorizontalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusTCP] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D370 水平測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D380 水平測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusTCP] 水平測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試速度: {speed} mm/min → D{_config.HorizontalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試位移: {displacement} mm → D{_config.HorizontalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusTCP] 水平測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入升降测试参数到 PLC 寄存器(D330 升降测试速度, D340 升降测试位移)
|
||||||
|
/// 供自定义参数更新功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteVerticalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusTCP] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D330 升降測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D340 升降測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusTCP] 升降測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試速度: {speed} mm/min → D{_config.VerticalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試位移: {displacement} mm → D{_config.VerticalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusTCP] 升降測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 讀取位置數據(升降位置和水平位置)
|
/// 讀取位置數據(升降位置和水平位置)
|
||||||
/// D12 升降位置(只讀), D16 水平位置(只讀)
|
/// D12 升降位置(只讀), D16 水平位置(只讀)
|
||||||
@@ -1868,6 +1950,76 @@ namespace COFTester.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入水平测试参数到 PLC 寄存器(D370 水平测试速度, D380 水平测试位移)
|
||||||
|
/// 供标准选择功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteHorizontalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusRTU] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D370 水平測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D380 水平測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusRTU] 水平測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試速度: {speed} mm/min → D{_config.HorizontalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試位移: {displacement} mm → D{_config.HorizontalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusRTU] 水平測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入升降测试参数到 PLC 寄存器(D330 升降测试速度, D340 升降测试位移)
|
||||||
|
/// 供自定义参数更新功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteVerticalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusRTU] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D330 升降測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D340 升降測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusRTU] 升降測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試速度: {speed} mm/min → D{_config.VerticalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試位移: {displacement} mm → D{_config.VerticalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusRTU] 水平測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 讀取位置數據
|
/// 讀取位置數據
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -2380,6 +2532,76 @@ namespace COFTester.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入水平测试参数到 PLC 寄存器(D370 水平测试速度, D380 水平测试位移)
|
||||||
|
/// 供标准选择功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteHorizontalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusASCII] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D370 水平測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D380 水平測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.HorizontalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusASCII] 水平測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試速度: {speed} mm/min → D{_config.HorizontalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 水平測試位移: {displacement} mm → D{_config.HorizontalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusASCII] 水平測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入升降测试参数到 PLC 寄存器(D330 升降测试速度, D340 升降测试位移)
|
||||||
|
/// 供自定义参数更新功能调用
|
||||||
|
/// </summary>
|
||||||
|
public override async Task WriteVerticalTestParametersAsync(double speed, double displacement)
|
||||||
|
{
|
||||||
|
if (_modbusMaster == null || !_isConnected)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ModbusASCII] 無法寫入參數:設備未連接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// D330 升降測試速度
|
||||||
|
var speedRegs = ConvertFloatToRegisters((float)speed);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestSpeedRegister, speedRegs);
|
||||||
|
|
||||||
|
// D340 升降測試位移
|
||||||
|
var dispRegs = ConvertFloatToRegisters((float)displacement);
|
||||||
|
await _modbusMaster.WriteMultipleRegistersAsync(
|
||||||
|
_config.SlaveId, _config.VerticalTestDisplacementRegister, dispRegs);
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusASCII] 升降測試參數寫入完成:");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試速度: {speed} mm/min → D{_config.VerticalTestSpeedRegister}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($" 升降測試位移: {displacement} mm → D{_config.VerticalTestDisplacementRegister}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ModbusASCII] 升降測試參數寫入失敗: {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 讀取位置數據
|
/// 讀取位置數據
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -301,9 +301,6 @@ namespace COFTester.Services
|
|||||||
$"滑块质量: {parameters.SledMass:F1} g",
|
$"滑块质量: {parameters.SledMass:F1} g",
|
||||||
$"测试速度: {parameters.TestSpeed:F1} mm/min",
|
$"测试速度: {parameters.TestSpeed:F1} mm/min",
|
||||||
$"测试行程: {parameters.TestStroke:F1} mm",
|
$"测试行程: {parameters.TestStroke:F1} mm",
|
||||||
$"测试时长: {parameters.TestDuration:F1} s",
|
|
||||||
$"静摩擦计算区间: {parameters.StaticCalcStart:F1} - {parameters.StaticCalcEnd:F1} mm",
|
|
||||||
$"动摩擦计算区间: {parameters.KineticCalcStart:F1} - {parameters.KineticCalcEnd:F1} mm",
|
|
||||||
$"操作员: {parameters.Operator}"
|
$"操作员: {parameters.Operator}"
|
||||||
} : new[]
|
} : new[]
|
||||||
{
|
{
|
||||||
@@ -311,9 +308,6 @@ namespace COFTester.Services
|
|||||||
$"Sled Mass: {parameters.SledMass:F1} g",
|
$"Sled Mass: {parameters.SledMass:F1} g",
|
||||||
$"Test Speed: {parameters.TestSpeed:F1} mm/min",
|
$"Test Speed: {parameters.TestSpeed:F1} mm/min",
|
||||||
$"Test Stroke: {parameters.TestStroke:F1} mm",
|
$"Test Stroke: {parameters.TestStroke:F1} mm",
|
||||||
$"Test Duration: {parameters.TestDuration:F1} s",
|
|
||||||
$"Static COF Range: {parameters.StaticCalcStart:F1} - {parameters.StaticCalcEnd:F1} mm",
|
|
||||||
$"Kinetic COF Range: {parameters.KineticCalcStart:F1} - {parameters.KineticCalcEnd:F1} mm",
|
|
||||||
$"Operator: {parameters.Operator}"
|
$"Operator: {parameters.Operator}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace COFTester.ViewModels
|
|||||||
private string _testButtonText; // 测试按钮文本
|
private string _testButtonText; // 测试按钮文本
|
||||||
private bool _m31Status = false; // M31状态:true=测试中,false=停止
|
private bool _m31Status = false; // M31状态:true=测试中,false=停止
|
||||||
private bool _canStartTest = true; // 是否可以开始测试
|
private bool _canStartTest = true; // 是否可以开始测试
|
||||||
|
private string _selectedStandard = ""; // 选中的标准:GB10006/ISO8295/ASTMD1894
|
||||||
|
|
||||||
public MainViewModel(IDataAcquisitionService daqService, DataProcessingService processingService, AppConfig config)
|
public MainViewModel(IDataAcquisitionService daqService, DataProcessingService processingService, AppConfig config)
|
||||||
{
|
{
|
||||||
@@ -80,6 +81,12 @@ namespace COFTester.ViewModels
|
|||||||
ForceCalibrationCommand = new RelayCommand(ForceCalibration, () => !_isTesting && IsConnected);
|
ForceCalibrationCommand = new RelayCommand(ForceCalibration, () => !_isTesting && IsConnected);
|
||||||
ReturnToOriginCommand = new RelayCommand(ReturnToOrigin, () => !_isTesting && IsConnected);
|
ReturnToOriginCommand = new RelayCommand(ReturnToOrigin, () => !_isTesting && IsConnected);
|
||||||
|
|
||||||
|
// 标准选择命令
|
||||||
|
SelectStandardCommand = new RelayCommand<string>(SelectStandard, _ => IsConnected);
|
||||||
|
|
||||||
|
// 自定义参数更新命令
|
||||||
|
UpdateCustomParametersCommand = new AsyncRelayCommand(UpdateCustomParametersAsync, () => IsConnected && SelectedStandard == "Custom");
|
||||||
|
|
||||||
Parameters = _config.DefaultTestParameters ?? new TestParameters();
|
Parameters = _config.DefaultTestParameters ?? new TestParameters();
|
||||||
TestRecords = new ObservableCollection<TestResult>();
|
TestRecords = new ObservableCollection<TestResult>();
|
||||||
TestRecords.CollectionChanged += (s, e) =>
|
TestRecords.CollectionChanged += (s, e) =>
|
||||||
@@ -499,6 +506,20 @@ namespace COFTester.ViewModels
|
|||||||
set { _testButtonText = value; OnPropertyChanged(); }
|
set { _testButtonText = value; OnPropertyChanged(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前选中的测试标准
|
||||||
|
/// </summary>
|
||||||
|
public string SelectedStandard
|
||||||
|
{
|
||||||
|
get => _selectedStandard;
|
||||||
|
set { _selectedStandard = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsStandardParametersReadOnly)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准参数是否只读(非自定义模式时为只读)
|
||||||
|
/// </summary>
|
||||||
|
public bool IsStandardParametersReadOnly => SelectedStandard != "Custom";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Commands
|
#region Commands
|
||||||
@@ -517,6 +538,12 @@ namespace COFTester.ViewModels
|
|||||||
public ICommand ZeroCalibrationCommand { get; }
|
public ICommand ZeroCalibrationCommand { get; }
|
||||||
public ICommand ForceCalibrationCommand { get; }
|
public ICommand ForceCalibrationCommand { get; }
|
||||||
public ICommand ReturnToOriginCommand { get; }
|
public ICommand ReturnToOriginCommand { get; }
|
||||||
|
|
||||||
|
// 标准选择命令
|
||||||
|
public ICommand SelectStandardCommand { get; }
|
||||||
|
|
||||||
|
// 自定义参数更新命令
|
||||||
|
public ICommand UpdateCustomParametersCommand { get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Event Handlers
|
#region Event Handlers
|
||||||
@@ -648,12 +675,21 @@ namespace COFTester.ViewModels
|
|||||||
|
|
||||||
if (deviceParams != null)
|
if (deviceParams != null)
|
||||||
{
|
{
|
||||||
// 只更新设置页显示的4个测试参数
|
// 更新设置页显示的4个测试参数
|
||||||
Parameters.HorizontalTestSpeed = deviceParams.HorizontalTestSpeed;
|
Parameters.HorizontalTestSpeed = deviceParams.HorizontalTestSpeed;
|
||||||
Parameters.HorizontalTestDisplacement = deviceParams.HorizontalTestDisplacement;
|
Parameters.HorizontalTestDisplacement = deviceParams.HorizontalTestDisplacement;
|
||||||
Parameters.VerticalTestSpeed = deviceParams.VerticalTestSpeed;
|
Parameters.VerticalTestSpeed = deviceParams.VerticalTestSpeed;
|
||||||
Parameters.VerticalTestDisplacement = deviceParams.VerticalTestDisplacement;
|
Parameters.VerticalTestDisplacement = deviceParams.VerticalTestDisplacement;
|
||||||
|
|
||||||
|
// 如果没有选择标准,使用PLC的默认值更新报告参数
|
||||||
|
if (string.IsNullOrEmpty(SelectedStandard))
|
||||||
|
{
|
||||||
|
Parameters.TestSpeed = deviceParams.HorizontalTestSpeed;
|
||||||
|
Parameters.TestStroke = deviceParams.HorizontalTestDisplacement;
|
||||||
|
Parameters.Standard = "自定义配置"; // 显示为PLC默认配置
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ViewModel] 未选择标准,使用PLC默认值");
|
||||||
|
}
|
||||||
|
|
||||||
// 通知UI更新
|
// 通知UI更新
|
||||||
OnPropertyChanged(nameof(Parameters));
|
OnPropertyChanged(nameof(Parameters));
|
||||||
|
|
||||||
@@ -998,6 +1034,154 @@ namespace COFTester.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准选择 - 根据选择的标准写入对应的测试参数到寄存器
|
||||||
|
/// </summary>
|
||||||
|
private async void SelectStandard(string standardCode)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!IsConnected)
|
||||||
|
{
|
||||||
|
StatusMessage = "请先连接设备";
|
||||||
|
MessageBox.Show("请先连接设备后再选择标准", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_daqService is not ModbusServiceBase modbusService)
|
||||||
|
{
|
||||||
|
StatusMessage = "当前通信模式不支持标准选择";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新选中状态(触发按钮高亮和输入框可编辑状态)
|
||||||
|
SelectedStandard = standardCode;
|
||||||
|
|
||||||
|
// 如果选择自定义,不写入参数,只切换到可编辑模式
|
||||||
|
if (standardCode == "Custom")
|
||||||
|
{
|
||||||
|
StatusMessage = "已切换到自定义模式,可手动修改参数";
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ViewModel] 切换到自定义模式");
|
||||||
|
CommandManager.InvalidateRequerySuggested();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据标准代码设置参数
|
||||||
|
double speed = 0;
|
||||||
|
double displacement = 0;
|
||||||
|
string standardName = "";
|
||||||
|
|
||||||
|
switch (standardCode)
|
||||||
|
{
|
||||||
|
case "GB10006":
|
||||||
|
speed = 100.0; // GB/T 10006-2021: 100 mm/min
|
||||||
|
displacement = 80.0; // 80 mm
|
||||||
|
standardName = "GB/T 10006-2021";
|
||||||
|
break;
|
||||||
|
case "ISO8295":
|
||||||
|
speed = 100.0; // ISO 8295:1995: 100 mm/min
|
||||||
|
displacement = 80.0; // 80 mm
|
||||||
|
standardName = "ISO 8295:1995";
|
||||||
|
break;
|
||||||
|
case "ASTMD1894":
|
||||||
|
speed = 150.0; // ASTM D1894-24: 150 mm/min
|
||||||
|
displacement = 150.0; // 150 mm
|
||||||
|
standardName = "ASTM D1894-24";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
StatusMessage = "未知的标准代码";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusMessage = $"正在应用标准 {standardName}...";
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 选择标准: {standardName}");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 保持用户选择的滑块质量: {Parameters.SledMass} g");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 水平测试速度: {speed} mm/min");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 水平测试位移: {displacement} mm");
|
||||||
|
|
||||||
|
// 写入寄存器(只写入水平测试参数)
|
||||||
|
await modbusService.WriteHorizontalTestParametersAsync(speed, displacement);
|
||||||
|
|
||||||
|
// 更新所有相关参数(用于报告生成)
|
||||||
|
// 注意:不更新 SledMass,保留用户在UI上选择的质量值
|
||||||
|
Parameters.Standard = standardName; // 更新标准名称
|
||||||
|
// Parameters.SledMass 保持用户选择的值(200g/300g/500g)
|
||||||
|
Parameters.TestSpeed = speed; // 更新测试速度(用于报告)
|
||||||
|
Parameters.TestStroke = displacement; // 更新测试行程(用于报告)
|
||||||
|
Parameters.HorizontalTestSpeed = speed; // 更新水平测试速度
|
||||||
|
Parameters.HorizontalTestDisplacement = displacement; // 更新水平测试位移
|
||||||
|
OnPropertyChanged(nameof(Parameters));
|
||||||
|
|
||||||
|
StatusMessage = $"已应用标准: {standardName}";
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 标准 {standardName} 应用成功");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 升降参数保持PLC原值不变");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StatusMessage = $"应用标准失败: {ex.Message}";
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 应用标准失败: {ex.Message}");
|
||||||
|
MessageBox.Show($"应用标准时发生错误:\n{ex.Message}",
|
||||||
|
"错误",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新自定义参数到设备
|
||||||
|
/// </summary>
|
||||||
|
private async Task UpdateCustomParametersAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!IsConnected)
|
||||||
|
{
|
||||||
|
StatusMessage = "请先连接设备";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_daqService is not ModbusServiceBase modbusService)
|
||||||
|
{
|
||||||
|
StatusMessage = "当前通信模式不支持参数更新";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusMessage = "正在更新自定义参数...";
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ViewModel] 开始更新自定义参数");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 水平测试速度: {Parameters.HorizontalTestSpeed} mm/min");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 水平测试位移: {Parameters.HorizontalTestDisplacement} mm");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 升降测试速度: {Parameters.VerticalTestSpeed} mm/min");
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 升降测试位移: {Parameters.VerticalTestDisplacement} mm");
|
||||||
|
|
||||||
|
// 写入水平测试参数
|
||||||
|
await modbusService.WriteHorizontalTestParametersAsync(
|
||||||
|
Parameters.HorizontalTestSpeed,
|
||||||
|
Parameters.HorizontalTestDisplacement);
|
||||||
|
|
||||||
|
// 写入升降测试参数
|
||||||
|
await modbusService.WriteVerticalTestParametersAsync(
|
||||||
|
Parameters.VerticalTestSpeed,
|
||||||
|
Parameters.VerticalTestDisplacement);
|
||||||
|
|
||||||
|
StatusMessage = "自定义参数已更新到设备";
|
||||||
|
System.Diagnostics.Debug.WriteLine("[ViewModel] 自定义参数更新成功");
|
||||||
|
|
||||||
|
MessageBox.Show("自定义参数已成功更新到设备",
|
||||||
|
"成功",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
StatusMessage = $"更新参数失败: {ex.Message}";
|
||||||
|
System.Diagnostics.Debug.WriteLine($"[ViewModel] 更新参数失败: {ex.Message}");
|
||||||
|
MessageBox.Show($"更新参数时发生错误:\n{ex.Message}",
|
||||||
|
"错误",
|
||||||
|
MessageBoxButton.OK,
|
||||||
|
MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 复归 - 向 M1300 写入命令 3
|
/// 复归 - 向 M1300 写入命令 3
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1510,6 +1694,52 @@ namespace COFTester.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 泛型 RelayCommand 實現,支持命令參數
|
||||||
|
/// </summary>
|
||||||
|
public class RelayCommand<T> : ICommand
|
||||||
|
{
|
||||||
|
private readonly Action<T> _execute;
|
||||||
|
private readonly Func<T, bool>? _canExecute;
|
||||||
|
|
||||||
|
public RelayCommand(Action<T> execute, Func<T, bool>? canExecute = null)
|
||||||
|
{
|
||||||
|
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
|
||||||
|
_canExecute = canExecute;
|
||||||
|
|
||||||
|
// 訂閱 CommandManager 的 RequerySuggested 事件
|
||||||
|
CommandManager.RequerySuggested += OnCanExecuteChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanExecute(object? parameter)
|
||||||
|
{
|
||||||
|
if (parameter is T typedParameter)
|
||||||
|
{
|
||||||
|
return _canExecute == null || _canExecute(typedParameter);
|
||||||
|
}
|
||||||
|
return _canExecute == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(object? parameter)
|
||||||
|
{
|
||||||
|
if (parameter is T typedParameter)
|
||||||
|
{
|
||||||
|
_execute(typedParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler? CanExecuteChanged
|
||||||
|
{
|
||||||
|
add { CommandManager.RequerySuggested += value; }
|
||||||
|
remove { CommandManager.RequerySuggested -= value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCanExecuteChanged(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// 自動觸發 CanExecuteChanged
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 異步 RelayCommand 實現,用於異步操作(如連接設備)
|
/// 異步 RelayCommand 實現,用於異步操作(如連接設備)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- 第五行:水平测试速度 | 水平测试位移 -->
|
<!-- 第五行:水平测试速度 | 水平测试位移 -->
|
||||||
<StackPanel Grid.Row="4" Grid.Column="0" Margin="0,12,0,12">
|
<!--<StackPanel Grid.Row="4" Grid.Column="0" Margin="0,12,0,12">
|
||||||
<TextBlock Text="{Binding Lang.HorizontalTestSpeed}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
<TextBlock Text="{Binding Lang.HorizontalTestSpeed}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBox Text="{Binding ConfigParams.HorizontalTestSpeed, UpdateSourceTrigger=PropertyChanged}"
|
<TextBox Text="{Binding ConfigParams.HorizontalTestSpeed, UpdateSourceTrigger=PropertyChanged}"
|
||||||
@@ -172,9 +172,9 @@
|
|||||||
<TextBlock Text="mm/min" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
<TextBlock Text="mm/min" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
|
|
||||||
<StackPanel Grid.Row="4" Grid.Column="2" Margin="0,12,0,12">
|
<!--<StackPanel Grid.Row="4" Grid.Column="2" Margin="0,12,0,12">
|
||||||
<TextBlock Text="{Binding Lang.HorizontalTestDisplacement}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
<TextBlock Text="{Binding Lang.HorizontalTestDisplacement}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBox Text="{Binding ConfigParams.HorizontalTestDisplacement, UpdateSourceTrigger=PropertyChanged}"
|
<TextBox Text="{Binding ConfigParams.HorizontalTestDisplacement, UpdateSourceTrigger=PropertyChanged}"
|
||||||
@@ -182,10 +182,10 @@
|
|||||||
<TextBlock Text="mm" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
<TextBlock Text="mm" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
|
|
||||||
<!-- 第六行:升降测试速度 | 升降测试位移 -->
|
<!-- 第六行:升降测试速度 | 升降测试位移 -->
|
||||||
<StackPanel Grid.Row="5" Grid.Column="0" Margin="0,0,0,0">
|
<!--<StackPanel Grid.Row="5" Grid.Column="0" Margin="0,0,0,0">
|
||||||
<TextBlock Text="{Binding Lang.VerticalTestSpeed}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
<TextBlock Text="{Binding Lang.VerticalTestSpeed}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBox Text="{Binding ConfigParams.VerticalTestSpeed, UpdateSourceTrigger=PropertyChanged}"
|
<TextBox Text="{Binding ConfigParams.VerticalTestSpeed, UpdateSourceTrigger=PropertyChanged}"
|
||||||
@@ -193,9 +193,9 @@
|
|||||||
<TextBlock Text="mm/min" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
<TextBlock Text="mm/min" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
|
|
||||||
<StackPanel Grid.Row="5" Grid.Column="2" Margin="0,0,0,0">
|
<!--<StackPanel Grid.Row="5" Grid.Column="2" Margin="0,0,0,0">
|
||||||
<TextBlock Text="{Binding Lang.VerticalTestDisplacement}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
<TextBlock Text="{Binding Lang.VerticalTestDisplacement}" FontSize="12" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,4"/>
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBox Text="{Binding ConfigParams.VerticalTestDisplacement, UpdateSourceTrigger=PropertyChanged}"
|
<TextBox Text="{Binding ConfigParams.VerticalTestDisplacement, UpdateSourceTrigger=PropertyChanged}"
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
<TextBlock Text="mm" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
<TextBlock Text="mm" FontSize="11" Foreground="{StaticResource GrayBrush}"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,8,0" IsHitTestVisible="False"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Window x:Class="COFTester.Views.MainWindow"
|
<Window x:Class="COFTester.Views.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="CSI-H238M Precision Friction Tester" Height="800" Width="1024"
|
Title="CSI-H238M 高配版摩擦系数仪、摩擦系数测定仪" Height="800" Width="1024"
|
||||||
Background="#F0F3F5">
|
Background="#F0F3F5">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style x:Key="NavButtonStyle" TargetType="RadioButton">
|
<Style x:Key="NavButtonStyle" TargetType="RadioButton">
|
||||||
|
|||||||
@@ -52,49 +52,330 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- 水平测试速度 (只读,从寄存器读取) -->
|
<!-- 质量选择 -->
|
||||||
<TextBlock Text="{Binding Lang.HorizontalTestSpeed}" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
<TextBlock Text="滑块质量" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
||||||
<TextBox Text="{Binding Parameters.HorizontalTestSpeed, StringFormat={}{0:F1} mm/min, Mode=OneWay}"
|
<ComboBox SelectedValue="{Binding Parameters.SledMass, Mode=TwoWay}"
|
||||||
|
SelectedValuePath="Tag"
|
||||||
Margin="0,0,0,15"
|
Margin="0,0,0,15"
|
||||||
IsReadOnly="True"
|
|
||||||
Background="#F5F5F5"
|
|
||||||
Height="40"
|
Height="40"
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
FontSize="13"
|
FontSize="13"
|
||||||
BorderBrush="#E0E0E0"/>
|
VerticalContentAlignment="Center"
|
||||||
|
BorderBrush="#E0E0E0">
|
||||||
|
<ComboBoxItem Content="200 g" Tag="200" IsSelected="True"/>
|
||||||
|
<ComboBoxItem Content="300 g" Tag="300"/>
|
||||||
|
<ComboBoxItem Content="500 g" Tag="500"/>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<!-- 水平测试位移 (只读,从寄存器读取) -->
|
<!-- 标准选择 -->
|
||||||
<TextBlock Text="{Binding Lang.HorizontalTestDisplacement}" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
<TextBlock Text="测试标准" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
||||||
<TextBox Text="{Binding Parameters.HorizontalTestDisplacement, StringFormat={}{0:F1} mm, Mode=OneWay}"
|
<UniformGrid Rows="1" Columns="4" Margin="0,0,0,15">
|
||||||
Margin="0,0,0,15"
|
<Button Content="GB/T 10006-2021"
|
||||||
IsReadOnly="True"
|
Command="{Binding SelectStandardCommand}"
|
||||||
Background="#F5F5F5"
|
CommandParameter="GB10006"
|
||||||
|
Margin="0,0,3,0"
|
||||||
Height="40"
|
Height="40"
|
||||||
VerticalContentAlignment="Center"
|
FontSize="11"
|
||||||
FontSize="13"
|
Cursor="Hand">
|
||||||
BorderBrush="#E0E0E0"/>
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
<Setter Property="Foreground" Value="#2C3E50"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="6">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#F0F8FF"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</Trigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectedStandard}" Value="GB10006">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3498DB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- 升降测试速度 (只读,从寄存器读取) -->
|
<Button Content="ISO 8295:1995"
|
||||||
<TextBlock Text="{Binding Lang.VerticalTestSpeed}" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
Command="{Binding SelectStandardCommand}"
|
||||||
<TextBox Text="{Binding Parameters.VerticalTestSpeed, StringFormat={}{0:F1} mm/min, Mode=OneWay}"
|
CommandParameter="ISO8295"
|
||||||
Margin="0,0,0,15"
|
Margin="1.5,0,1.5,0"
|
||||||
IsReadOnly="True"
|
|
||||||
Background="#F5F5F5"
|
|
||||||
Height="40"
|
Height="40"
|
||||||
VerticalContentAlignment="Center"
|
FontSize="11"
|
||||||
FontSize="13"
|
Cursor="Hand">
|
||||||
BorderBrush="#E0E0E0"/>
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
<Setter Property="Foreground" Value="#2C3E50"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="6">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#F0F8FF"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</Trigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectedStandard}" Value="ISO8295">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3498DB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- 升降测试位移 (只读,从寄存器读取) -->
|
<Button Content="ASTM D1894-24"
|
||||||
<TextBlock Text="{Binding Lang.VerticalTestDisplacement}" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
Command="{Binding SelectStandardCommand}"
|
||||||
<TextBox Text="{Binding Parameters.VerticalTestDisplacement, StringFormat={}{0:F1} mm, Mode=OneWay}"
|
CommandParameter="ASTMD1894"
|
||||||
Margin="0,0,0,15"
|
Margin="1.5,0,1.5,0"
|
||||||
IsReadOnly="True"
|
Height="40"
|
||||||
Background="#F5F5F5"
|
FontSize="11"
|
||||||
|
Cursor="Hand">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
<Setter Property="Foreground" Value="#2C3E50"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="6">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#F0F8FF"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</Trigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectedStandard}" Value="ASTMD1894">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3498DB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button Content="自定义"
|
||||||
|
Command="{Binding SelectStandardCommand}"
|
||||||
|
CommandParameter="Custom"
|
||||||
|
Margin="3,0,0,0"
|
||||||
|
Height="40"
|
||||||
|
FontSize="11"
|
||||||
|
Cursor="Hand">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
<Setter Property="Foreground" Value="#2C3E50"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#E0E0E0"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="6">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#F0F8FF"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</Trigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectedStandard}" Value="Custom">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#3498DB"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter TargetName="border" Property="BorderBrush" Value="#3498DB"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
</UniformGrid>
|
||||||
|
|
||||||
|
<!-- 水平测试参数 (一行显示) -->
|
||||||
|
<TextBlock Text="水平测试参数" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
||||||
|
<Grid Margin="0,0,0,15">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="10"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="0">
|
||||||
|
<TextBlock Text="速度 (mm/min)" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,3"/>
|
||||||
|
<TextBox Text="{Binding Parameters.HorizontalTestSpeed, StringFormat={}{0:F1}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
Height="40"
|
Height="40"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
FontSize="13"
|
FontSize="13"
|
||||||
BorderBrush="#E0E0E0"/>
|
BorderBrush="#E0E0E0"
|
||||||
|
IsReadOnly="{Binding IsStandardParametersReadOnly}">
|
||||||
|
<TextBox.Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#F5F5F5"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsStandardParametersReadOnly}" Value="False">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Style>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="2">
|
||||||
|
<TextBlock Text="位移 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,3"/>
|
||||||
|
<TextBox Text="{Binding Parameters.HorizontalTestDisplacement, StringFormat={}{0:F1}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Height="40"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
FontSize="13"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
IsReadOnly="{Binding IsStandardParametersReadOnly}">
|
||||||
|
<TextBox.Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#F5F5F5"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsStandardParametersReadOnly}" Value="False">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Style>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 升降测试参数 (一行显示) -->
|
||||||
|
<TextBlock Text="升降测试参数" Margin="0,10,0,5" FontSize="13" Foreground="{StaticResource GrayBrush}"/>
|
||||||
|
<Grid Margin="0,0,0,15">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="10"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="0">
|
||||||
|
<TextBlock Text="速度 (mm/min)" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,3"/>
|
||||||
|
<TextBox Text="{Binding Parameters.VerticalTestSpeed, StringFormat={}{0:F1}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Height="40"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
FontSize="13"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
IsReadOnly="{Binding IsStandardParametersReadOnly}">
|
||||||
|
<TextBox.Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#F5F5F5"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsStandardParametersReadOnly}" Value="False">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Style>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="2">
|
||||||
|
<TextBlock Text="位移 (mm)" FontSize="11" Foreground="{StaticResource GrayBrush}" Margin="0,0,0,3"/>
|
||||||
|
<TextBox Text="{Binding Parameters.VerticalTestDisplacement, StringFormat={}{0:F1}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Height="40"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
FontSize="13"
|
||||||
|
BorderBrush="#E0E0E0"
|
||||||
|
IsReadOnly="{Binding IsStandardParametersReadOnly}">
|
||||||
|
<TextBox.Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="Background" Value="#F5F5F5"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsStandardParametersReadOnly}" Value="False">
|
||||||
|
<Setter Property="Background" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Style>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- 更新按钮 (仅在自定义模式下显示) -->
|
||||||
|
<Button Command="{Binding UpdateCustomParametersCommand}"
|
||||||
|
Height="40"
|
||||||
|
Background="#27AE60"
|
||||||
|
Foreground="White"
|
||||||
|
BorderThickness="0"
|
||||||
|
Cursor="Hand"
|
||||||
|
FontSize="14"
|
||||||
|
Margin="0,0,0,15">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Border x:Name="border" Background="{TemplateBinding Background}" CornerRadius="6">
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter TargetName="border" Property="Background" Value="#229954"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding SelectedStandard}" Value="Custom">
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
|
<TextBlock Text="" FontFamily="Segoe MDL2 Assets" FontSize="16" Margin="0,0,5,0" VerticalAlignment="Center"/>
|
||||||
|
<TextBlock Text="更新参数到设备" VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user