using DataBlockHelper.DBHelpers; using DataBlockHelper.Entity.DB2104Entity; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; using Mesnac.Controls.Base; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.AutoControl { public class DryerWaterControl : ChemicalWeighingAction, IAction { private List McControls; // 获取Query控件 DryerWaterControlsEntity ControlsEntity = new DryerWaterControlsEntity(); public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须要调用 McControls = GetAllControls(); ControlImport(); BottomSelect(runtime); } private void ControlImport() { ControlsEntity.WaterConfrim = GetButtonControl("WaterConfrim"); ControlsEntity.ColdValueA = GetBaseControl("ColdValueA"); ControlsEntity.ColdValueB = GetBaseControl("ColdValueB"); ControlsEntity.HotValueA = GetBaseControl("HotValueA"); ControlsEntity.HotValueB = GetBaseControl("HotValueB"); ControlsEntity.ColdToleranceA = GetBaseControl("ColdToleranceA"); ControlsEntity.ColdToleranceB = GetBaseControl("ColdToleranceB"); ControlsEntity.HotToleranceA = GetBaseControl("HotToleranceA"); ControlsEntity.HotToleranceB = GetBaseControl("HotToleranceB"); } private void BottomSelect(RuntimeParameter runtime) { if(ControlsEntity.WaterConfrim == runtime.Sender) { WaterEntity HotA = new WaterEntity(); WaterEntity ColdA = new WaterEntity(); WaterEntity HotB = new WaterEntity(); WaterEntity ColdB = new WaterEntity(); HotA.Set = Convert.ToSingle(ControlsEntity.HotValueA.MCValue); HotA.TolErance = Convert.ToSingle(ControlsEntity.HotToleranceA.MCValue); HotB.Set = Convert.ToSingle(ControlsEntity.HotValueB.MCValue); HotB.TolErance = Convert.ToSingle(ControlsEntity.HotToleranceB.MCValue); ColdA.Set = Convert.ToSingle(ControlsEntity.ColdValueA.MCValue); ColdA.TolErance = Convert.ToSingle(ControlsEntity.ColdToleranceA.MCValue); ColdB.Set = Convert.ToSingle(ControlsEntity.ColdValueB.MCValue); ColdB.TolErance = Convert.ToSingle(ControlsEntity.ColdToleranceB.MCValue); } } private IBaseControl GetBaseControl(string name) { return McControls.First(x => x.Name == name) as IBaseControl; } private Button GetButtonControl(string name) { return McControls.First(x => x.Name == name) as Button; } } }