This commit is contained in:
@@ -78,6 +78,9 @@ namespace MembranePoreTester.ViewModels
|
||||
if (SetProperty(ref _selectedPressureMode, value))
|
||||
{
|
||||
Task.Run(async () => await WritePressureModeAsync(value?.Text ?? "低压"));
|
||||
|
||||
// 切换模式后调整加压上限
|
||||
AdjustPressureLimitForMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,6 +547,37 @@ namespace MembranePoreTester.ViewModels
|
||||
|
||||
|
||||
|
||||
// 在 StationItem 类中添加以下方法
|
||||
private void AdjustPressureLimitForMode()
|
||||
{
|
||||
bool isLowPressure = (SelectedPressureMode?.Text == "低压");
|
||||
double currentLimit = _pressureUpperLimit;
|
||||
double newLimit = currentLimit;
|
||||
|
||||
if (isLowPressure && currentLimit > 200)
|
||||
newLimit = 200;
|
||||
else if (!isLowPressure && currentLimit > 1000)
|
||||
newLimit = 1000;
|
||||
else
|
||||
return;
|
||||
|
||||
// 直接修改字段,避免触发 setter 中的校验和重复写 PLC
|
||||
_pressureUpperLimit = newLimit;
|
||||
OnPropertyChanged(nameof(PressureUpperLimit));
|
||||
|
||||
// 写回 PLC
|
||||
ushort address = StationId == 1 ? _plcConfig.PressureUpperLimit
|
||||
: StationId == 2 ? _plcConfig.PressureUpperLimit2
|
||||
: _plcConfig.PressureUpperLimit3;
|
||||
_ = _plcService.WriteMultipleRegistersAsync(address, (float)newLimit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user