diff --git a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ManualDebugForm.cs b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ManualDebugForm.cs index 79d88b9..21089fd 100644 --- a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ManualDebugForm.cs +++ b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/ManualDebugForm.cs @@ -133,6 +133,120 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 this.Invoke(new Action(() => Debug.WriteLine($"读取系数失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error))); } + //混氧 + try + { + bool[] registers2 = await _modbusMaster?.ReadCoilsAsync(1, 101, 1); + + if (registers2 != null && registers2.Length >= 1) + { + bool value2 = registers2[0]; + this.Invoke(new Action(() => + { + if (value2) + { + uiButton1.Text = "混氧中"; + uiButton1.ForeColor = Color.Red; + + } + else + { + uiButton1.Text = "手动混氧"; + uiButton1.ForeColor = Color.White; + } + })); + } + } + catch (Exception ex) + { + Debug.WriteLine($"读取混氧状态失败: {ex.Message}"); + } + //灯 + try + { + bool[] registers3 = await _modbusMaster?.ReadCoilsAsync(1, 11, 1); + + if (registers3 != null && registers3.Length >= 1) + { + bool value3 = registers3[0]; + this.Invoke(new Action(() => + { + if (value3) + { + uiButton2.Text = "开灯中"; + uiButton2.ForeColor = Color.Red; + + } + else + { + uiButton2.Text = "💡 灯开关"; + uiButton2.ForeColor = Color.White; + } + })); + } + } + catch (Exception ex) + { + Debug.WriteLine($"读取灯状态失败: {ex.Message}"); + } + + //灭火 + try + { + bool[] registers4 = await _modbusMaster?.ReadCoilsAsync(1, 99, 1); + + if (registers4 != null && registers4.Length >= 1) + { + bool value4 = registers4[0]; + this.Invoke(new Action(() => + { + if (value4) + { + uiButton3.Text = "灭火中"; + uiButton3.ForeColor = Color.Red; + + } + else + { + uiButton3.Text = "🚨 灭火"; + uiButton3.ForeColor = Color.White; + } + })); + } + } + catch (Exception ex) + { + Debug.WriteLine($"读取灭火状态失败: {ex.Message}"); + } + + //光斑 + try + { + bool[] registers5 = await _modbusMaster?.ReadCoilsAsync(1, 250, 1); + + if (registers5 != null && registers5.Length >= 1) + { + bool value5 = registers5[0]; + this.Invoke(new Action(() => + { + if (value5) + { + uiButton4.Text = "光斑运行中"; + uiButton4.ForeColor = Color.Red; + + } + else + { + uiButton4.Text = "⚫ 光斑开关"; + uiButton4.ForeColor = Color.White; + } + })); + } + } + catch (Exception ex) + { + Debug.WriteLine($"读取光斑状态失败: {ex.Message}"); + } } @@ -157,11 +271,6 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 } ma = new Function(_modbusMaster); - //_readTimer = InitTimer(); - //if (_modbusMaster != null) - //{ - // _readTimer.Start(); - //} _modbusMaster?.WriteSingleRegister(1, 2, 0); this.FormClosed += (s, args) => @@ -210,39 +319,24 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 this.Close();//返回主页面 } - private void ToggleButtonWithText(UIButton button, ref bool state, string onText, string offText) - { - state = !state; - button.ForeColor = state ? Color.Red : Color.White; - button.Text = state ? onText : offText; - } - - bool isbt1on = false; - //bool isbt4on = false; - bool isbt2on=false; - bool isbt3on = false; #region 按钮 private void uiButton1_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton1, ref isbt1on, "混氧中", "手动混氧"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 101);//混氧开关 } private void uiButton4_Click(object sender, EventArgs e) { - //ToggleButtonWithText(uiButton4, ref isbt4on, "光斑运行中", "⚫ 光斑开关"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 250);//光斑开关 } private void uiButton2_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton2, ref isbt2on, "开灯中", "💡 灯开关"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 11);//灯开关 } private void uiButton3_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton3, ref isbt3on, "灭火中", "🚨 灭火"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 99);//灭火 } diff --git a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PrimaryIgnitionForm.cs b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PrimaryIgnitionForm.cs index 1375eb8..ae17a54 100644 --- a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PrimaryIgnitionForm.cs +++ b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/PrimaryIgnitionForm.cs @@ -334,7 +334,7 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 } catch (Exception ex) { - Debug.WriteLine($"读取灭火状态失败: {ex.Message}"); + Debug.WriteLine($"读取灯状态失败: {ex.Message}"); } } diff --git a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/SecondaryIgnitionForm.cs b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/SecondaryIgnitionForm.cs index f412619..e0828ed 100644 --- a/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/SecondaryIgnitionForm.cs +++ b/外科辅料和患者防护罩激光抗性测试仪/外科辅料和患者防护罩激光抗性测试仪/SecondaryIgnitionForm.cs @@ -683,19 +683,11 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 ma?.BtnClickFunctionForNew(Function.ButtonType.复归型, 304);//手动停止 } - bool isbt3on=false; private void uiButton3_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton3, ref isbt3on, "灭火中", "灭火"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 99);//灭火 } - private void ToggleButtonWithText(UIButton button, ref bool state, string onText, string offText) - { - state = !state; - button.ForeColor = state ? Color.Red : Color.White; - button.Text = state ? onText : offText; - } #endregion private void uiButton7_Click(object sender, EventArgs e) { @@ -860,17 +852,14 @@ namespace 外科辅料和患者防护罩激光抗性测试仪 } } - bool isbt14on = false; - bool isbt9on = false; + private void uiButton9_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton9, ref isbt9on, "混氧中", "手动混氧"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 101);//混氧开关 } private void uiButton14_Click(object sender, EventArgs e) { - ToggleButtonWithText(uiButton14, ref isbt14on, "开灯中", "💡 灯开关"); ma?.BtnClickFunctionForNew(Function.ButtonType.切换型, 11);//灯开关 }