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/DownAction.cs

61 lines
2.1 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using DevExpress.Office.Utils;
using DevExpress.Utils.Text;
using Mesnac.Action.Base;
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public class DownAction:ChemicalWeighingAction, IAction
{
1 year ago
public static event EventHandler OnHandler;
1 year ago
private DbMCControl _materialGridControl = null; //物料列表控件
private RuntimeParameter _runtime;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "pressureSetting")
.FirstOrDefault(); //获取物料数据控件
this._materialGridControl = materialGridControl;
if (MessageBox.Show("确定下发压力参数到PLC?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
1 year ago
{
DoWord();
};
}
private void DoWord()
{
DataGridView gridView=_materialGridControl.BaseControl as DataGridView;
var gridViewDataSource = gridView.DataSource as DataTable;
List<PressureSettingView> lsView = new List<PressureSettingView>();
var dataRowCollection = gridViewDataSource.Rows;
foreach (DataRow o in dataRowCollection)
{
PressureSettingView view = new PressureSettingView();
view.Id = (int)o["Id"];
view.Name = o["Name"].ToString();
view.ActualValue = 0;
view.LowLimit = Convert.ToSingle(o["LowLimit"]);
view.HighLimit = Convert.ToSingle(o["HighLimit"]);
view.Alarm = Convert.ToInt32(o["Alarm"]);
lsView.Add(view);
}
1 year ago
PressurePLC.DownToPlc(lsView);
1 year ago
}
}
}