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