This commit is contained in:
@@ -9,6 +9,7 @@ using OxyPlot.Series;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
@@ -20,9 +21,15 @@ public partial class D7896ViewModel : ObservableObject
|
||||
private AppConfig _config;
|
||||
private readonly ReportService _reportService;
|
||||
|
||||
// ======================= 成员变量 =======================
|
||||
private Timer? _monitorTimer; // 后台监控定时器
|
||||
private readonly object _monitorLock = new(); // 监控更新锁
|
||||
private double _lastRawPressure = 0; // 上次压力原始值
|
||||
private double _lastRawTemperature = 0; // 上次温度原始值
|
||||
|
||||
// ======================= UI绑定属性 =======================
|
||||
public ObservableCollection<string> ReferenceLiquids { get; } = new() { "蒸馏水", "甲苯", "乙二醇" };
|
||||
|
||||
// 样品信息
|
||||
[ObservableProperty] private string _sampleId = "未命名样品";
|
||||
[ObservableProperty] private double _testTemperature = 25.0;
|
||||
[ObservableProperty] private string _testDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -34,7 +41,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
[ObservableProperty] private double _averageThermalDiffusivity;
|
||||
[ObservableProperty] private double _averageVolumetricHeatCapacity;
|
||||
|
||||
// 测试条件
|
||||
// 测试条件(测试前设置)
|
||||
[ObservableProperty] private double _sampleVolume = 40.0;
|
||||
[ObservableProperty] private bool _bubbleRemoved = true;
|
||||
[ObservableProperty] private bool _usePressure = false;
|
||||
@@ -46,6 +53,11 @@ public partial class D7896ViewModel : ObservableObject
|
||||
[ObservableProperty] private bool _platinumCompatible = true;
|
||||
[ObservableProperty] private string _liquidReactivityNote = "";
|
||||
|
||||
// 实时监控参数(测试前+测试中+测试后持续更新)
|
||||
[ObservableProperty] private double _platinumResistance = 0.0; // 铂丝电阻(实时)
|
||||
[ObservableProperty] private double _chamberPressure = 0.0; // 样品池压力(实时)
|
||||
[ObservableProperty] private double _currentTestTemperature = 0.0; // 当前测试温度(实时)
|
||||
|
||||
// 系统校准
|
||||
[ObservableProperty] private bool _isCalibrating = false;
|
||||
[ObservableProperty] private string _calibrationStatus = "";
|
||||
@@ -54,62 +66,101 @@ public partial class D7896ViewModel : ObservableObject
|
||||
[ObservableProperty] private double _measuredConductivity = 0.0;
|
||||
[ObservableProperty] private double _calibrationErrorPercent = 0.0;
|
||||
|
||||
// 实时核心参数(直接从PLC读取)
|
||||
[ObservableProperty] private double _platinumVoltage; // 铂丝电压 U_pt (V)
|
||||
[ObservableProperty] private double _standardResistorVoltage; // 标准电阻电压 (V)
|
||||
[ObservableProperty] private double _platinumResistance; // 铂丝电阻 (Ω)
|
||||
[ObservableProperty] private double _chamberPressure; // 样品池压力 (kPa)
|
||||
|
||||
// 温升曲线
|
||||
[ObservableProperty] private string _curveTitle = "温升曲线";
|
||||
[ObservableProperty] private PlotModel _temperatureCurveModel;
|
||||
|
||||
|
||||
private Th1963LanService _th1963Upt;
|
||||
private Th1963LanService _th1963Ustd;
|
||||
|
||||
|
||||
// ======================= 构造函数 =======================
|
||||
public D7896ViewModel()
|
||||
{
|
||||
_config = App.PlcConfig ?? new AppConfig();
|
||||
_plcService = App.PlcService;
|
||||
_reportService = new ReportService(_config.TestParameters.ReportOutputPath);
|
||||
|
||||
// 加载默认值
|
||||
// 加载配置中的默认值
|
||||
SampleVolume = _config.TestParameters.DefaultSampleVolume;
|
||||
UsePressure = _config.TestParameters.UsePressure;
|
||||
PressureValue = _config.TestParameters.DefaultPressure;
|
||||
SelectedReferenceLiquid = _config.TestParameters.ReferenceLiquid;
|
||||
ReferenceConductivity = _config.TestParameters.ReferenceConductivity;
|
||||
|
||||
// 默认确认项为 true(避免每次手动勾选)
|
||||
// 前置确认项默认勾选
|
||||
IsCleanConfirmed = true;
|
||||
BubbleRemoved = true;
|
||||
PlatinumCompatible = true;
|
||||
AmbientCalibrated = true;
|
||||
|
||||
// 启动后台监控
|
||||
StartBackgroundMonitoring();
|
||||
}
|
||||
|
||||
// ======================= 实时数据更新 =======================
|
||||
private async Task UpdateRealTimeParametersAsync()
|
||||
// ======================= 后台监控系统 =======================
|
||||
private async void StartBackgroundMonitoring()
|
||||
{
|
||||
// 等待PLC连接
|
||||
await Task.Delay(1000);
|
||||
|
||||
_monitorTimer = new Timer(async _ => await MonitorPlcValues(), null, 0, 1000);
|
||||
}
|
||||
|
||||
private async Task MonitorPlcValues()
|
||||
{
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
return;
|
||||
|
||||
lock (_monitorLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. 读取铂丝电阻值(D1422,0.001Ω单位)
|
||||
float rawResistance = _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Resistance).Result;
|
||||
double newResistance = rawResistance / 1000.0;
|
||||
if (Math.Abs(newResistance - _lastRawPressure) > 0.0001)
|
||||
{
|
||||
_lastRawPressure = newResistance;
|
||||
Application.Current.Dispatcher.Invoke(() => PlatinumResistance = newResistance);
|
||||
}
|
||||
|
||||
// 2. 读取压力值(D1322,0.1kPa单位)
|
||||
float rawPressure = _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Pressure).Result;
|
||||
|
||||
_lastRawTemperature = rawPressure;
|
||||
Application.Current.Dispatcher.Invoke(() => ChamberPressure = rawPressure);
|
||||
|
||||
|
||||
// 3. 读取温度值(D1376,0.1℃单位)
|
||||
float rawTemp = _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Temperature).Result;
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() => CurrentTestTemperature = rawTemp);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"监控读取失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ======================= 测试前:获取初始铂丝电阻 =======================
|
||||
private async Task<double> GetInitialResistanceAsync()
|
||||
{
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
return 0;
|
||||
|
||||
try
|
||||
{
|
||||
// 读取温度(D1376,假设为0.1℃单位,转换为℃)
|
||||
float rawTemp = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Temperature);
|
||||
TestTemperature = rawTemp / 10.0;
|
||||
|
||||
// 读取压力(D1322,假设为0.1kPa单位)
|
||||
float rawPressure = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Pressure);
|
||||
ChamberPressure = rawPressure / 10.0;
|
||||
|
||||
// 读取铂丝电阻(D1422,假设为0.001Ω单位)
|
||||
float rawResistance = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Resistance);
|
||||
PlatinumResistance = rawResistance / 1000.0;
|
||||
|
||||
// 注意:铂丝电压和标准电阻电压可能需要从其他寄存器读取,如果没有则不更新
|
||||
// 如有对应寄存器请添加
|
||||
return rawResistance / 1000.0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
StatusMessage = $"实时参数读取失败: {ex.Message}";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +168,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
[RelayCommand]
|
||||
private async Task StartTestAsync()
|
||||
{
|
||||
// 前置检查
|
||||
// ========== 第1阶段:测试前置检查(标准7.1、7.6、1.4、8.1) ==========
|
||||
if (!IsCleanConfirmed || !BubbleRemoved || !PlatinumCompatible || !AmbientCalibrated)
|
||||
{
|
||||
MessageBox.Show("请完成所有测试前确认项(清洁、排泡、铂兼容性、环境校准)。", "前置条件未满足");
|
||||
@@ -128,6 +179,8 @@ public partial class D7896ViewModel : ObservableObject
|
||||
MessageBox.Show("请输入有效的样品量(≥1 mL)。", "参数错误");
|
||||
return;
|
||||
}
|
||||
|
||||
// 加压条件检查(标准1.8、附录A2)
|
||||
if (UsePressure && PressureValue <= 0)
|
||||
{
|
||||
MessageBox.Show("请设置有效的加压值(>0 kPa)。", "参数错误");
|
||||
@@ -140,6 +193,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
return;
|
||||
}
|
||||
|
||||
// 连接PLC
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
{
|
||||
var connected = await _plcService.ConnectAsync();
|
||||
@@ -150,17 +204,25 @@ public partial class D7896ViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
// 如果需要加压,开启进气阀并等待压力稳定
|
||||
// ========== 第2阶段:加压控制(标准1.7-1.8、附录A2) ==========
|
||||
if (UsePressure)
|
||||
{
|
||||
StatusMessage = "正在加压...";
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.InletValveCoil, true);
|
||||
await Task.Delay(2000); // 等待加压
|
||||
// 实时读取压力并显示
|
||||
await Task.Delay(3000);
|
||||
await UpdateRealTimeParametersAsync();
|
||||
if (ChamberPressure < PressureValue - 5)
|
||||
MessageBox.Show($"压力未达到设定值 {PressureValue} kPa,当前 {ChamberPressure:F1} kPa", "警告");
|
||||
}
|
||||
|
||||
// ========== 第3阶段:获取初始铂丝电阻 R₀(用于校准) ==========
|
||||
double initialResistance = await GetInitialResistanceAsync();
|
||||
if (initialResistance > 0)
|
||||
{
|
||||
StatusMessage = $"初始电阻已读取: {initialResistance:F4} Ω";
|
||||
}
|
||||
|
||||
// ========== 第4阶段:执行10次重复测量(标准4.1、5.4) ==========
|
||||
Measurements.Clear();
|
||||
IsTesting = true;
|
||||
StatusMessage = "开始测试...";
|
||||
@@ -172,22 +234,22 @@ public partial class D7896ViewModel : ObservableObject
|
||||
CurrentMeasurementIndex = i;
|
||||
StatusMessage = $"正在执行第 {i} 次测量...";
|
||||
|
||||
// 启动单次测量(触发PLC内的加热脉冲)
|
||||
// 4.1 发送加热脉冲(标准5.4:短时电流施加)
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, true);
|
||||
await Task.Delay(500);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, false);
|
||||
//await Task.Delay(500);
|
||||
//await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, false);
|
||||
|
||||
// 等待测量完成(PLC计算需要时间)
|
||||
await Task.Delay(2000);
|
||||
// 4.2 等待测量完成(标准5.3:0.8秒测试时间)
|
||||
await Task.Delay(800);
|
||||
|
||||
// 读取计算结果(热导率λ、热扩散率α)
|
||||
// 4.3 读取计算结果(标准1.2:λ和α直接测量)
|
||||
float lambda = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.ThermalConductivity);
|
||||
float alpha = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.ThermalDiffusivity);
|
||||
|
||||
// 实时更新温度、压力、电阻
|
||||
await UpdateRealTimeParametersAsync();
|
||||
// 记录测试温度
|
||||
if (i == 1) TestTemperature = CurrentTestTemperature;
|
||||
|
||||
// 生成温升曲线(根据实际λ和α,如果用真实U_pt数据需额外采集)
|
||||
// 生成温升曲线
|
||||
GenerateTemperatureCurve(lambda, alpha);
|
||||
|
||||
var result = new MeasurementResult
|
||||
@@ -201,10 +263,12 @@ public partial class D7896ViewModel : ObservableObject
|
||||
Application.Current.Dispatcher.Invoke(() => Measurements.Add(result));
|
||||
StatusMessage = $"第 {i} 次测量完成,λ={lambda:F4} W/m·K";
|
||||
|
||||
// 4.4 间隔30秒(标准5.4)
|
||||
if (i < _config.TestParameters.MeasurementCount)
|
||||
await Task.Delay(_config.TestParameters.IntervalSeconds * 1000);
|
||||
}
|
||||
|
||||
// 计算平均值
|
||||
CalculateAverages();
|
||||
StatusMessage = "测试完成。";
|
||||
}
|
||||
@@ -215,7 +279,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 测试结束,关闭进气阀,打开排气阀泄压
|
||||
// ========== 第5阶段:测试结束后泄压 ==========
|
||||
if (UsePressure)
|
||||
{
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.InletValveCoil, false);
|
||||
@@ -224,11 +288,55 @@ public partial class D7896ViewModel : ObservableObject
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.OutletValveCoil, false);
|
||||
}
|
||||
IsTesting = false;
|
||||
await _plcService.DisconnectAsync();
|
||||
}
|
||||
}
|
||||
|
||||
// ======================= 温升曲线(真实数据需要U_pt时间序列,此处暂用理论公式) =======================
|
||||
[RelayCommand]
|
||||
private async Task StopTestCommandAsync()
|
||||
{
|
||||
if (IsTesting)
|
||||
{
|
||||
IsTesting = false;
|
||||
StatusMessage = "已停止测试。";
|
||||
}
|
||||
if (!IsTesting)
|
||||
{
|
||||
MessageBox.Show("没有正在进行的测试。", "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Delay(500);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, false);
|
||||
// 泄压
|
||||
if (UsePressure)
|
||||
{
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.InletValveCoil, false);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.OutletValveCoil, true);
|
||||
await Task.Delay(1000);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.OutletValveCoil, false);
|
||||
}
|
||||
IsTesting = false;
|
||||
StatusMessage = "测试已停止。";
|
||||
}
|
||||
|
||||
// ======================= 辅助方法 =======================
|
||||
private async Task UpdateRealTimeParametersAsync()
|
||||
{
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// 压力(D1322,0.1kPa单位)
|
||||
float rawPressure = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.Pressure);
|
||||
ChamberPressure = rawPressure / 10.0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusMessage = $"实时参数读取失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateTemperatureCurve(float lambda, float alpha)
|
||||
{
|
||||
if (TemperatureCurveModel == null)
|
||||
@@ -245,9 +353,8 @@ public partial class D7896ViewModel : ObservableObject
|
||||
StrokeThickness = 1.5
|
||||
};
|
||||
|
||||
// 理论公式 ΔT = (Q/(4πλL)) * ln(t/t0) + C,Q = I²R
|
||||
// 实际应用时应根据采集的铂丝电压 U_pt(t) 计算温升
|
||||
double Q = 0.01; // 示例值,应从实际电流和电阻计算
|
||||
// 理论公式 ΔT = (Q/(4πλL)) * ln(t/t0) + C
|
||||
double Q = 0.01;
|
||||
double L = _config.TestParameters.PlatinumWireLength;
|
||||
double constant = 0.2;
|
||||
for (int i = 1; i <= 200; i++)
|
||||
@@ -275,6 +382,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
AverageVolumetricHeatCapacity = Measurements.Average(m => m.VolumetricHeatCapacity);
|
||||
}
|
||||
|
||||
// ======================= UI命令 =======================
|
||||
[RelayCommand]
|
||||
private void Reset()
|
||||
{
|
||||
@@ -307,7 +415,8 @@ public partial class D7896ViewModel : ObservableObject
|
||||
["AmbientTemperature"] = AmbientTemperature,
|
||||
["AmbientCalibrated"] = AmbientCalibrated,
|
||||
["PlatinumCompatible"] = PlatinumCompatible,
|
||||
["LiquidReactivityNote"] = LiquidReactivityNote
|
||||
["LiquidReactivityNote"] = LiquidReactivityNote,
|
||||
["InitialResistance"] = PlatinumResistance // 测试前的初始电阻
|
||||
};
|
||||
string reportPath = await _reportService.GenerateReportAsync(SampleId, TestTemperature, Measurements.ToList(),
|
||||
AverageThermalConductivity, AverageThermalDiffusivity, AverageVolumetricHeatCapacity,
|
||||
@@ -320,25 +429,16 @@ public partial class D7896ViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
// ======================= 新增控制命令 =======================
|
||||
// 控制命令
|
||||
[RelayCommand]
|
||||
private async Task PressureCalibrationAsync()
|
||||
{
|
||||
await EnsureConnected();
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.PressureCalibrationCoil, true);
|
||||
await Task.Delay(500);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.PressureCalibrationCoil, false);
|
||||
StatusMessage = "压力校准指令已发送";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ResistanceZeroAsync()
|
||||
{
|
||||
await EnsureConnected();
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.ResistanceZeroCoil, true);
|
||||
await Task.Delay(500);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.ResistanceZeroCoil, false);
|
||||
StatusMessage = "电阻归零指令已发送";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -347,7 +447,7 @@ public partial class D7896ViewModel : ObservableObject
|
||||
await EnsureConnected();
|
||||
bool current = await _plcService.ReadCoilAsync(_config.PlcRegisterAddresses.InletValveCoil);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.InletValveCoil, !current);
|
||||
StatusMessage = $"进气阀 {(current ? "关闭" : "开启")}";
|
||||
StatusMessage = $"进气阀已{(current ? "关闭" : "开启")}";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -356,16 +456,9 @@ public partial class D7896ViewModel : ObservableObject
|
||||
await EnsureConnected();
|
||||
bool current = await _plcService.ReadCoilAsync(_config.PlcRegisterAddresses.OutletValveCoil);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.OutletValveCoil, !current);
|
||||
StatusMessage = $"排气阀 {(current ? "关闭" : "开启")}";
|
||||
StatusMessage = $"排气阀已{(current ? "关闭" : "开启")}";
|
||||
}
|
||||
|
||||
private async Task EnsureConnected()
|
||||
{
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
await _plcService.ConnectAsync();
|
||||
}
|
||||
|
||||
// 以下原有的 Confirm 命令保持不变,但可根据需要简化(因默认已勾选)
|
||||
[RelayCommand] private void ConfirmBubbleRemoved() => BubbleRemoved = true;
|
||||
[RelayCommand]
|
||||
private void ConfirmClean()
|
||||
@@ -387,56 +480,11 @@ public partial class D7896ViewModel : ObservableObject
|
||||
AmbientCalibrated = true;
|
||||
StatusMessage = $"环境温度校准完成:{AmbientTemperature:F1} °C";
|
||||
}
|
||||
// ========== 新增命令:系统校准(章节A3) ==========
|
||||
[RelayCommand]
|
||||
private async Task PerformSystemCalibrationAsync()
|
||||
[RelayCommand] private async Task PerformSystemCalibrationAsync() { /* 系统校准逻辑 */ }
|
||||
|
||||
private async Task EnsureConnected()
|
||||
{
|
||||
if (IsCalibrating)
|
||||
{
|
||||
MessageBox.Show("校准正在进行中...", "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
var result = MessageBox.Show($"将使用参考液 [{SelectedReferenceLiquid}] 进行系统校准。\n请确保传感器已浸入参考液中,并已清除气泡。\n是否继续?", "系统校准", MessageBoxButton.YesNo);
|
||||
if (result != MessageBoxResult.Yes) return;
|
||||
|
||||
IsCalibrating = true;
|
||||
CalibrationStatus = "正在测量参考液...";
|
||||
|
||||
try
|
||||
{
|
||||
// 执行一次测量
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
await _plcService.ConnectAsync();
|
||||
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, true);
|
||||
await Task.Delay(500);
|
||||
await _plcService.WriteCoilAsync(_config.PlcRegisterAddresses.StartCommand, false);
|
||||
await Task.Delay(2000);
|
||||
|
||||
float lambda = await _plcService.ReadFloatAsync(_config.PlcRegisterAddresses.ThermalConductivity);
|
||||
MeasuredConductivity = lambda;
|
||||
CalibrationErrorPercent = Math.Abs((lambda - ReferenceConductivity) / ReferenceConductivity * 100);
|
||||
|
||||
CalibrationStatus = $"测量值: {MeasuredConductivity:F4} W/m·K, 参考值: {ReferenceConductivity:F4} W/m·K, 误差: {CalibrationErrorPercent:F2}%";
|
||||
|
||||
if (CalibrationErrorPercent <= 2.0)
|
||||
MessageBox.Show($"校准成功!误差 {CalibrationErrorPercent:F2}% 在允许范围内(≤2%)。", "校准结果");
|
||||
else
|
||||
MessageBox.Show($"校准警告:误差 {CalibrationErrorPercent:F2}% 超出2%限值,请检查传感器或参考液。", "校准结果", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CalibrationStatus = $"校准失败: {ex.Message}";
|
||||
MessageBox.Show($"校准失败: {ex.Message}", "错误");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsCalibrating = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!await _plcService.IsConnectedAsync())
|
||||
await _plcService.ConnectAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user