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.

78 lines
2.4 KiB
C#

1 year ago
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.XlPlcHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.BinManage
{
class UpLoadAction : ChemicalWeighingAction, IAction
{
/// <summary>
/// 刷新
/// </summary>
public static event EventHandler OnRefresh;
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null; //料仓列表控件
#endregion
#region 事件定义
/// <summary>
/// 修改料仓信息事件定义
/// </summary>
public static event EventHandler OnUpLoadBin;
#endregion
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
this._runtime = runtime;
#region 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Bin").FirstOrDefault();
if (clientGridControl == null)
{
ICSharpCode.Core.LoggingService<ModifyBinAction>.Error("缺少料仓信息列表控件...");
return;
}
this._runtime = runtime;
this._clientGridControl = clientGridControl;
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
#endregion
try
{
//if (BasePlcHelper.Instance.plt_plc_State.NowValue.ToInt() != 1) { MessageBox.Show("PLC连接失败请检查相关设备"); return; }
var list = BinHelper.getBinList();
foreach (var item in list)
{
PlcPlanHelper.WriteBinParam(item);//更新PLC
}
MessageBox.Show("设备设置参数成功!");
if (OnUpLoadBin != null)
OnUpLoadBin(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
catch (Exception ex)
{
MessageBox.Show("设备设置参数失败!" + ex.Message);
}
}
}
}