精确优化模式切换
This commit is contained in:
@@ -748,13 +748,31 @@ namespace 全自动水压检测仪
|
||||
//低温指示
|
||||
if (modbusResults.LowStatus != null && modbusResults.LowStatus.Length > 0 && uiLight1 != null && !uiLight1.IsDisposed)
|
||||
{
|
||||
uiLight1.State = modbusResults.LowStatus[0] ? UILightState.On : UILightState.Off;
|
||||
bool previousLowTempState = uiLight1.State == UILightState.On;
|
||||
bool currentLowTempState = modbusResults.LowStatus[0];
|
||||
|
||||
uiLight1.State = currentLowTempState ? UILightState.On : UILightState.Off;
|
||||
|
||||
// 如果温度模式状态发生变化,更新控件可见性
|
||||
if (previousLowTempState != currentLowTempState)
|
||||
{
|
||||
UpdateControlsVisibilityByMode();
|
||||
}
|
||||
}
|
||||
|
||||
//高温指示
|
||||
if (modbusResults.HighStatus != null && modbusResults.HighStatus.Length > 0 && uiLight2 != null && !uiLight2.IsDisposed)
|
||||
{
|
||||
uiLight2.State = modbusResults.HighStatus[0] ? UILightState.On : UILightState.Off;
|
||||
bool previousHighTempState = uiLight2.State == UILightState.On;
|
||||
bool currentHighTempState = modbusResults.HighStatus[0];
|
||||
|
||||
uiLight2.State = currentHighTempState ? UILightState.On : UILightState.Off;
|
||||
|
||||
// 如果温度模式状态发生变化,更新控件可见性
|
||||
if (previousHighTempState != currentHighTempState)
|
||||
{
|
||||
UpdateControlsVisibilityByMode();
|
||||
}
|
||||
}
|
||||
|
||||
//高压进阀指示
|
||||
@@ -1206,6 +1224,13 @@ namespace 全自动水压检测仪
|
||||
private void uiSwitch1_Click(object sender, EventArgs e)
|
||||
{
|
||||
ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 10030);
|
||||
|
||||
// 切换模式后更新控件可见性
|
||||
// 延迟一小段时间等待PLC状态更新
|
||||
System.Threading.Tasks.Task.Delay(500).ContinueWith(_ =>
|
||||
{
|
||||
SafeInvoke(() => UpdateControlsVisibilityByMode());
|
||||
});
|
||||
}
|
||||
|
||||
//出口温度设置
|
||||
@@ -1266,6 +1291,9 @@ namespace 全自动水压检测仪
|
||||
_alarmMonitorTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化时根据当前模式更新控件可见性
|
||||
UpdateControlsVisibilityByMode();
|
||||
}
|
||||
|
||||
//返回录入系统
|
||||
@@ -1501,5 +1529,62 @@ namespace 全自动水压检测仪
|
||||
// 关闭当前窗口
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据温度模式更新控件可见性
|
||||
/// 常温模式:隐藏高温相关参数(高温实时液位、高温箱温度、高温加水)
|
||||
/// 高温模式:隐藏常温相关参数(常温实时液位、出口温度、常温加水、水箱加热)
|
||||
/// </summary>
|
||||
private void UpdateControlsVisibilityByMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 判断当前是否为高温模式(uiLight2亮起表示高温模式)
|
||||
bool isHighTempMode = uiLight2 != null && uiLight2.State == UILightState.On;
|
||||
|
||||
// 高温模式相关控件
|
||||
// 高温实时液位(mm) - uiPanel31包含uiLabel7, uiLabel8, uiLabel34, uiProcessBar2
|
||||
if (uiPanel31 != null) uiPanel31.Visible = isHighTempMode;
|
||||
|
||||
// 高温箱温度(°C) - uiPanel35包含uiLabel42, uiLabel43
|
||||
if (uiPanel35 != null) uiPanel35.Visible = isHighTempMode;
|
||||
|
||||
// 高温加水按钮 - uiButton5
|
||||
if (uiButton5 != null) uiButton5.Visible = isHighTempMode;
|
||||
|
||||
// 高温加水指示灯 - uiLight11
|
||||
if (uiPanel43 != null) uiPanel43.Visible = isHighTempMode;
|
||||
|
||||
// 常温模式相关控件
|
||||
// 常温实时液位(mm) - uiPanel23包含uiLabel12, uiLabel16, uiLabel17, uiProcessBar1
|
||||
if (uiPanel23 != null) uiPanel23.Visible = !isHighTempMode;
|
||||
|
||||
// 出口温度(°C) - uiPanel33包含uiLabel38, uiLabel39
|
||||
if (uiPanel33 != null) uiPanel33.Visible = !isHighTempMode;
|
||||
|
||||
// 常温加水按钮 - uiButton13
|
||||
if (uiButton13 != null) uiButton13.Visible = !isHighTempMode;
|
||||
|
||||
// 常温加水指示灯 - uiLight6
|
||||
if (uiPanel38 != null) uiPanel38.Visible = !isHighTempMode;
|
||||
|
||||
// 水箱加热按钮 - uiButton4
|
||||
if (uiButton4 != null) uiButton4.Visible = !isHighTempMode;
|
||||
|
||||
// 出口温度设置 - uiLabel48和uiTextBox9
|
||||
if (uiLabel48 != null) uiLabel48.Visible = !isHighTempMode;
|
||||
if (uiTextBox9 != null) uiTextBox9.Visible = !isHighTempMode;
|
||||
|
||||
// 高温箱温度设置 - uiLabel37和uiTextBox4
|
||||
if (uiLabel37 != null) uiLabel37.Visible = isHighTempMode;
|
||||
if (uiTextBox4 != null) uiTextBox4.Visible = isHighTempMode;
|
||||
|
||||
Debug.WriteLine($"[UpdateControlsVisibilityByMode] 模式切换完成 - 高温模式: {isHighTempMode}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[UpdateControlsVisibilityByMode] 更新控件可见性失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user