Reapply "修改"

This reverts commit c89221db83.
This commit is contained in:
GukSang.Jin
2026-02-04 18:06:41 +08:00
parent c89221db83
commit 78e346bdec

View File

@@ -48,6 +48,10 @@ namespace 全自动水压检测仪
private System.Windows.Forms.Timer _readTimerTwo; // 第二个定时器引用
private bool _isManualInput = false; // 手动输入标记
private bool _isSwitchingWindow = false; // 窗口切换标记,避免并发
// 温度模式状态跟踪(用于防抖优化)
private bool _lastHighTempMode = false;
private bool _lastLowTempMode = false;
private ConductivityRepository _repository;
@@ -780,27 +784,23 @@ namespace 全自动水压检测仪
}
}
//低温指示
//低温指示(优化版本 - 减少不必要的UI更新
if (modbusResults.LowStatus != null && modbusResults.LowStatus.Length > 0 && uiLight1 != null && !uiLight1.IsDisposed)
{
bool previousLowTempState = uiLight1.State == UILightState.On;
bool currentLowTempState = modbusResults.LowStatus[0];
uiLight1.State = currentLowTempState ? UILightState.On : UILightState.Off;
// 如果温度模式状态发生变化,更新控件可见性
if (previousLowTempState != currentLowTempState)
// 只有状态真正改变时才更新控件可见性
if (_lastLowTempMode != currentLowTempState)
{
UpdateControlsVisibilityByMode();
}
}
//高温指示
//高温指示(优化版本 - 减少不必要的UI更新
if (modbusResults.HighStatus != null && modbusResults.HighStatus.Length > 0 && uiLight2 != null && !uiLight2.IsDisposed)
{
bool previousHighTempState = uiLight2.State == UILightState.On;
bool currentHighTempState = modbusResults.HighStatus[0];
uiLight2.State = currentHighTempState ? UILightState.On : UILightState.Off;
// 如果温度模式状态发生变化,更新控件可见性
@@ -1280,7 +1280,7 @@ namespace 全自动水压检测仪
ma?.BtnClickFunctionForNew(Function.ButtonType., 10082);
}
//切换实验模式
//切换实验模式(优化版本 - 减少延迟和卡顿)
private async void uiSwitch1_Click(object sender, EventArgs e)
{
try
@@ -1306,8 +1306,8 @@ namespace 全自动水压检测仪
}
});
// 延迟等待PLC状态更新
await Task.Delay(800);
// 缩短延迟时间从800ms减少到300ms
await Task.Delay(300);
// 更新控件可见性
SafeInvoke(() =>
@@ -1634,7 +1634,7 @@ namespace 全自动水压检测仪
/// <summary>
/// <summary>
/// 根据温度模式更新控件可见性
/// 根据温度模式更新控件可见性(优化版本 - 批量更新减少卡顿)
/// 常温模式:显示常温相关参数(常温实时液位、常温加水)
/// 高温模式:显示高温相关参数(高温实时液位、箱体温度、出口温度、高温加水、水箱加热)
/// </summary>
@@ -1767,7 +1767,6 @@ namespace 全自动水压检测仪
try
{
bool isHighTempMode = uiLight2 != null && uiLight2.State == UILightState.On;
bool isLowTempMode = uiLight1 != null && uiLight1.State == UILightState.On;
Debug.WriteLine($"[UpdateControlsVisibilityByMode] 开始更新 - 高温模式: {isHighTempMode}, 常温模式: {isLowTempMode}");