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

56 lines
1.6 KiB
C#

1 year ago
using System;
using System.Linq;
using System.Windows.Forms;
1 year ago
using Mesnac.Action.Base;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMaterial;
1 year ago
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public class UpAction:ChemicalWeighingAction, IAction
{
1 year ago
1 year ago
private RuntimeParameter _runtime;
1 year ago
public static event EventHandler OnHandler;
1 year ago
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "pressureSetting")
.FirstOrDefault(); //获取物料数据控件
DoWord();
1 year ago
}
private void DoWord()
{
11 months ago
var i = LjHelp.WatchDog;
if (i == 0)
{
11 months ago
MessageBox.Show("PLC通讯失败");
ICSharpCode.Core.LoggingService<UpAction>.Warn("PLC通讯失败");
return;
}
1 year ago
var pressureSettingViews = new PressurePLC().UpdateFromPlc();
1 year ago
foreach (var v in pressureSettingViews)
{
string sql =
$"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}";
1 year ago
DBHelp.ExecuteNonQuery(sql);
}
11 months ago
1 year ago
if (OnHandler != null)
{
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
1 year ago
}
}
}