You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.1 KiB
C#
113 lines
4.1 KiB
C#
using DataBlockHelper.DBHelpers;
|
|
using DataBlockHelper.Entity.DB2106Entity;
|
|
using HslCommunication.Instrument.DLT;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
using Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity;
|
|
using Mesnac.Action.ChemicalWeighing.Report.Entity;
|
|
using Mesnac.Basic;
|
|
using Mesnac.Controls.ChemicalWeighing;
|
|
using Mesnac.Controls.Default;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.ManualControl
|
|
{
|
|
public class ForceWaterControl : ChemicalWeighingAction, IAction
|
|
{
|
|
FHslSwitchEntity HslSwitchE = new FHslSwitchEntity();
|
|
DB2105Helper DB2105 = new DB2105Helper();
|
|
|
|
private List<Control> Controls;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须要调用
|
|
|
|
Controls = GetAllControls();
|
|
|
|
ControlsHelper.ControlImport<HslSwitch>(HslSwitchE, Controls);
|
|
|
|
StateRefresh();
|
|
|
|
HslSwitchE.ForceControlHA.OnSwitchChanged += ForceControl_OnSwitchChanged;
|
|
HslSwitchE.ForceControlCA.OnSwitchChanged += ForceControl_OnSwitchChanged;
|
|
HslSwitchE.ForceControlHB.OnSwitchChanged += ForceControl_OnSwitchChanged;
|
|
HslSwitchE.ForceControlCB.OnSwitchChanged += ForceControl_OnSwitchChanged;
|
|
|
|
}
|
|
|
|
private void ForceControl_OnSwitchChanged(object obj, bool state)
|
|
{
|
|
DB2105 = new DB2105Helper();
|
|
HslSwitch hslSwitch = obj as HslSwitch;
|
|
if (state)
|
|
{
|
|
if (MessageBox.Show("是否要打开强制排水模式?", "强制模式启动确认",
|
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
{
|
|
HslSwitch hs = obj as HslSwitch;
|
|
hs.SwitchStatus = false;
|
|
state = false;
|
|
}
|
|
}
|
|
string name = hslSwitch.Name;
|
|
switch (name)
|
|
{
|
|
case "ForceControlHA":
|
|
DB2105WriteHelper.AddHaAddForceOn(state);
|
|
break;
|
|
case "ForceControlCA":
|
|
DB2105WriteHelper.AddCaAddForceOn(state);
|
|
break;
|
|
case "ForceControlHB":
|
|
DB2105WriteHelper.AddHbAddForceOn(state);
|
|
break;
|
|
case "ForceControlCB":
|
|
DB2105WriteHelper.AddCbAddForceOn(state);
|
|
break;
|
|
default: break;
|
|
}
|
|
DefaultSwitch(hslSwitch, state);
|
|
}
|
|
|
|
private void StateRefresh()
|
|
{
|
|
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);
|
|
DefaultSwitch(HslSwitchE.ForceControlCB, DB2105.Force_CB.forceOn);
|
|
}
|
|
|
|
|
|
|
|
private void DefaultSwitch(HslSwitch hslSwitch, bool state)
|
|
{
|
|
string status = state ? "强制状态开" : "强制状态关";
|
|
hslSwitch.Text = status;
|
|
hslSwitch.SwitchStatus = state;
|
|
}
|
|
}
|
|
}
|