页面逻辑添加
This commit is contained in:
@@ -58,6 +58,21 @@ namespace TabletTester2025.ViewModels
|
||||
[ObservableProperty] private bool _hardnessPass;
|
||||
[ObservableProperty] private double _hardnessAvg;
|
||||
[ObservableProperty] private double _hardnessRSD;
|
||||
|
||||
|
||||
//硬度新增
|
||||
//[ObservableProperty] private int _hardnessForward = 0;//硬前进
|
||||
//[ObservableProperty] private int _hardnessBack = 1;//硬后退
|
||||
//[ObservableProperty] private int _hardnessOver = 72; //硬度完成
|
||||
//[ObservableProperty] private int _hardnessStartOver = 92;// 硬复位完成
|
||||
//[ObservableProperty] private int _hardnessLimit = 298;// 硬度电机极限输入
|
||||
[ObservableProperty] private double _hardnessSudu = 300;// 硬度速度输入mm/min
|
||||
[ObservableProperty] private double _hardnessWeiyi = 310; // 硬度位移输入mm/min
|
||||
[ObservableProperty] private double _hardnessPoSun = 400; // 硬度破损判定输入N
|
||||
//[ObservableProperty] private int _hardnessMaxN = 72; //最大力采集
|
||||
|
||||
|
||||
|
||||
private List<double> _hardnessResults = new();
|
||||
|
||||
// 脆碎度
|
||||
@@ -787,7 +802,7 @@ namespace TabletTester2025.ViewModels
|
||||
if (Phase != TestPhase.Idle) return;
|
||||
CurrentTest = TestType.Hardness;
|
||||
Phase = TestPhase.Running;
|
||||
HardnessPass = false; // 添加这一行
|
||||
HardnessPass = false;
|
||||
_hardnessResults.Clear();
|
||||
|
||||
try
|
||||
@@ -796,33 +811,44 @@ namespace TabletTester2025.ViewModels
|
||||
double min = App.CurrentPharmaParams.HardnessMin_N;
|
||||
double max = App.CurrentPharmaParams.HardnessMax_N;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
{ // 1. 给PLC发指令:启动单次硬度测试
|
||||
double currentSpeed = _hardnessSudu;
|
||||
double currentWeiyi = _hardnessWeiyi;
|
||||
double currentPoSun = _hardnessPoSun;
|
||||
|
||||
// 如果你需要把这3个值发给PLC,就在这里发一次(测试开始用当前参数)
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessSudu, (float)currentSpeed);
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessWeiyi, (float)currentWeiyi);
|
||||
await _plc.WriteFloatAsync(_plcConfig.HardnessPoSun, (float)currentPoSun);
|
||||
|
||||
// 开始循环测试
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
await _plc.WriteCoilAsync(_plcConfig.HardnessStartCoil, true);
|
||||
|
||||
bool completed = false;
|
||||
while (!completed && Phase == TestPhase.Running)
|
||||
{
|
||||
await Task.Delay(200);// 每200ms轮询一次状态
|
||||
|
||||
await Task.Delay(200);
|
||||
completed = await _plc.ReadCoilAsync(_plcConfig.HardnessCompleteCoil);
|
||||
}
|
||||
|
||||
double val = await _plc.ReadFloatAsync(_plcConfig.HardnessValue);
|
||||
_hardnessResults.Add(val); // 把结果存到列表里
|
||||
_hardnessResults.Add(val);
|
||||
HardnessValue = val;
|
||||
|
||||
HardnessValue = val; // 更新界面上的实时测试力值
|
||||
|
||||
await Task.Delay(1000); // 间隔1秒,再进行下一次测试
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
// 计算结果
|
||||
HardnessAvg = _hardnessResults.Average();
|
||||
HardnessMax= _hardnessResults.Max();
|
||||
HardnessMax = _hardnessResults.Max();
|
||||
HardnessMin = _hardnessResults.Min();
|
||||
|
||||
HardnessCurrentCount = count;
|
||||
HardnessRSD = (StandardDeviation(_hardnessResults) / HardnessAvg) * 100;
|
||||
HardnessPass = HardnessAvg >= min && HardnessAvg <= max;
|
||||
Phase = TestPhase.Completed;//恢复启动按钮
|
||||
|
||||
Phase = TestPhase.Completed;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -832,11 +858,6 @@ namespace TabletTester2025.ViewModels
|
||||
finally
|
||||
{
|
||||
Phase = TestPhase.Idle;
|
||||
|
||||
// 在保存前设置崩解合格标志:剩余管数为0 且 崩解时间未超时
|
||||
//DisintegrationPass = (RemainingTubes == 0 && DisintegrationSeconds <= App.CurrentPharmaParams.DisintegrationMaxSeconds);
|
||||
|
||||
|
||||
await SaveBatchResult();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user