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.
108 lines
4.4 KiB
C#
108 lines
4.4 KiB
C#
using DataBlockHelper.DBHelpers;
|
|
using DataBlockHelper.Entity.DB2104Entity;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
using Mesnac.Controls.Base;
|
|
using Mesnac.Core.Service;
|
|
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<Control> 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)
|
|
{
|
|
if (MessageBox.Show("确认下发水称数据?", "下发确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
{
|
|
return;
|
|
}
|
|
|
|
WaterEntity HotA = new WaterEntity();
|
|
WaterEntity ColdA = new WaterEntity();
|
|
WaterEntity HotB = new WaterEntity();
|
|
WaterEntity ColdB = new WaterEntity();
|
|
|
|
float hotASet, hotBSet, coldASet, coldBSet, hotATol, hotBTol, coldATol, coldBTol;
|
|
|
|
if (float.TryParse(Convert.ToString(ControlsEntity.HotValueA.MCValue), out hotASet) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.HotToleranceA.MCValue), out hotATol) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.HotValueB.MCValue), out hotBSet) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.HotToleranceB.MCValue), out hotBTol) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.ColdValueA.MCValue), out coldASet) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.ColdToleranceA.MCValue), out coldATol) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.ColdValueB.MCValue), out coldBSet) &&
|
|
float.TryParse(Convert.ToString(ControlsEntity.ColdToleranceB.MCValue), out coldBTol))
|
|
{
|
|
HotA.Set = hotASet;
|
|
HotB.Set = hotBSet;
|
|
ColdA.Set = coldASet;
|
|
ColdB.Set = coldBSet;
|
|
HotA.Tolerance = hotATol;
|
|
HotB.Tolerance = hotBTol;
|
|
ColdA.Tolerance = coldATol;
|
|
ColdB.Tolerance = coldBTol;
|
|
Db2104WriteHelper.WriteAHostWater(HotA);
|
|
Db2104WriteHelper.WriteBHostWater(HotB);
|
|
Db2104WriteHelper.WriteAColWater(ColdA);
|
|
Db2104WriteHelper.WriteBColWater(ColdB);
|
|
MesnacServiceManager.Instance.LoggingService.Info("水称数据下发成功!");
|
|
MessageBox.Show("水称数据下发成功");
|
|
}
|
|
else
|
|
{
|
|
MesnacServiceManager.Instance.LoggingService.Info("输入数值的格式有误");
|
|
MessageBox.Show("输入数值的格式有误!");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|