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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPressure/UpAction.cs

57 lines
1.7 KiB
C#

using System;
using System.Linq;
using System.Windows.Forms;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
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, "pressureSetting")
.FirstOrDefault(); //获取物料数据控件
DoWord();
}
private void DoWord()
{
LoadingHelper.ShowLoadingScreen();
var i = LjHelp.WatchDog;
if (i == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
ICSharpCode.Core.LoggingService<UpAction>.Warn("PLC通讯失败");
return;
}
var pressureSettingViews = PressurePLC.UpdateFromPlc();
foreach (var v in pressureSettingViews)
{
string sql =
$"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
LoadingHelper.CloseForm();
if (OnHandler != null)
{
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
}
}
}