diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ForceWaterControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ForceWaterControl.cs index a52627a..1f0464e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ForceWaterControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ForceWaterControl.cs @@ -42,13 +42,13 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl SetAllControls(); + StateRefresh(); + HslSwitchE.ForceControlHA.OnSwitchChanged += ForceControl_OnSwitchChanged; HslSwitchE.ForceControlCA.OnSwitchChanged += ForceControl_OnSwitchChanged; HslSwitchE.ForceControlHB.OnSwitchChanged += ForceControl_OnSwitchChanged; HslSwitchE.ForceControlCB.OnSwitchChanged += ForceControl_OnSwitchChanged; - StateRefresh(new object(), new EventArgs()); - BottomSelect(runtime); //timer = new Timer(); @@ -60,6 +60,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl private void ForceControl_OnSwitchChanged(object obj, bool state) { DB2105 = new DB2105Helper(); + HslSwitch hslSwitch = obj as HslSwitch; if (state) { if (MessageBox.Show("是否要打开强制排水模式?", "强制模式启动确认", @@ -70,7 +71,6 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl return; } } - HslSwitch hslSwitch = obj as HslSwitch; string name = hslSwitch.Name; switch (name) { @@ -91,12 +91,24 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl DefaultSwitch(hslSwitch, state); } - private void StateRefresh(object sender, EventArgs e) + private void StateRefresh() { - HslSwitchE.ForceControlHA.SwitchStatus = DB2105.Force_HA.forceOn; - HslSwitchE.ForceControlCA.SwitchStatus = DB2105.Force_CA.forceOn; - HslSwitchE.ForceControlHB.SwitchStatus = DB2105.Force_HB.forceOn; - HslSwitchE.ForceControlCB.SwitchStatus = DB2105.Force_CB.forceOn; + if (HslSwitchE.ForceControlHA.SwitchStatus != DB2105.Force_HA.forceOn) + { + HslSwitchE.ForceControlHA.SwitchStatus = DB2105.Force_HA.forceOn; + } + if (HslSwitchE.ForceControlCA.SwitchStatus != DB2105.Force_CA.forceOn) + { + HslSwitchE.ForceControlCA.SwitchStatus = DB2105.Force_CA.forceOn; + } + if (HslSwitchE.ForceControlHB.SwitchStatus != DB2105.Force_HB.forceOn) + { + HslSwitchE.ForceControlHB.SwitchStatus = DB2105.Force_HB.forceOn; + } + if (HslSwitchE.ForceControlCB.SwitchStatus != DB2105.Force_CB.forceOn) + { + HslSwitchE.ForceControlCB.SwitchStatus = DB2105.Force_CB.forceOn; + } DefaultSwitch(HslSwitchE.ForceControlHA, DB2105.Force_HA.forceOn); DefaultSwitch(HslSwitchE.ForceControlCA, DB2105.Force_CA.forceOn); DefaultSwitch(HslSwitchE.ForceControlHB, DB2105.Force_HB.forceOn);