|
|
|
|
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 SyncAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
private DbMCControl _clientGridControl = null; //料仓列表控件
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改料仓信息事件定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnSyncBin;
|
|
|
|
|
|
|
|
|
|
#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.ReadBinParam(item);//更新数据库
|
|
|
|
|
}
|
|
|
|
|
MessageBox.Show("同步设备参数信息成功!");
|
|
|
|
|
|
|
|
|
|
if (OnSyncBin != null)
|
|
|
|
|
OnSyncBin(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("设备设置参数失败!"+ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|