|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjWeight;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjProportional
|
|
|
|
|
{
|
|
|
|
|
public class UpAction:ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
|
|
|
|
|
public static event EventHandler OnHandler;
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
DbMCControl materialGridControl =
|
|
|
|
|
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ProportionalSetting")
|
|
|
|
|
.FirstOrDefault(); //获取物料数据控件
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (MessageBox.Show("确定上传比例阀参数到数据库?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
// LoadingHelper.ShowLoadingScreen();
|
|
|
|
|
// var watchDog = LjHelp.WatchDog;
|
|
|
|
|
// if (watchDog == 0)
|
|
|
|
|
// {
|
|
|
|
|
// LoadingHelper.CloseForm();
|
|
|
|
|
// MessageBox.Show("PLC通讯失败");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LoadingHelper.CloseForm();
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
DoWord();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DoWord()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var views = new ProportionalPlc().UpFromPlc();
|
|
|
|
|
foreach (var v in views)
|
|
|
|
|
{
|
|
|
|
|
string sql =
|
|
|
|
|
$"update ProportionalSetting set SV={v.SV},PV={v.PV} where Id={v.Id}";
|
|
|
|
|
DBHelp.ExecuteNonQuery(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (OnHandler != null)
|
|
|
|
|
{
|
|
|
|
|
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|