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.
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.LjWeight;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjProportional
|
|
{
|
|
public class DownAction : ChemicalWeighingAction, IAction
|
|
{
|
|
public static event EventHandler OnHandler;
|
|
|
|
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, "ProportionalSetting")
|
|
.FirstOrDefault(); //获取物料数据控件
|
|
this._materialGridControl = materialGridControl;
|
|
|
|
|
|
if (MessageBox.Show("确定下发到PLC?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) ==
|
|
DialogResult.OK)
|
|
{
|
|
LoadingHelper.ShowLoadingScreen();
|
|
var watchDog = LjHelp.WatchDog;
|
|
if (watchDog == 0)
|
|
{
|
|
LoadingHelper.CloseForm();
|
|
MessageBox.Show("PLC通讯失败");
|
|
return;
|
|
}
|
|
|
|
DoWord();
|
|
LoadingHelper.CloseForm();
|
|
|
|
if (OnHandler != null)
|
|
{
|
|
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void DoWord()
|
|
{
|
|
DataGridView gridView = _materialGridControl.BaseControl as DataGridView;
|
|
var gridViewDataSource = gridView.DataSource as DataTable;
|
|
|
|
List<ProportionalSettingView> lsView = new List<ProportionalSettingView>();
|
|
|
|
var dataRowCollection = gridViewDataSource.Rows;
|
|
foreach (DataRow o in dataRowCollection)
|
|
{
|
|
ProportionalSettingView view = new ProportionalSettingView();
|
|
view.Id = (int)o["Id"];
|
|
view.Name = o["Name"].ToString();
|
|
view.SV = Convert.ToSingle(o["SV"]);
|
|
lsView.Add(view);
|
|
}
|
|
|
|
ProportionalPlc.DownToPlc(lsView);
|
|
|
|
}
|
|
}
|
|
} |