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.
94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
|
|
using DataBlockHelper;
|
|
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.LjPlanning.Db;
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
|
|
{
|
|
public class PauseAction:ChemicalWeighingAction, IAction
|
|
{
|
|
private DbMCControl _materialGridControl = null; //物料列表控件
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
|
public static event EventHandler OnPause;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须调用
|
|
this._runtime = runtime;
|
|
DbMCControl materialGridControl =
|
|
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning")
|
|
.FirstOrDefault(); //获取物料数据控件
|
|
this._materialGridControl = materialGridControl;
|
|
|
|
DataGridView clientGridView = this._materialGridControl.BaseControl as DataGridView;
|
|
|
|
//验证是否选中某物料
|
|
if (clientGridView.SelectedRows.Count != 1)
|
|
{
|
|
|
|
MessageBox.Show("请选择要修改的数据", Mesnac.Basic.LanguageHelper.Caption,
|
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
this._runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
|
|
var dataGridViewRow = clientGridView.SelectedRows[0];
|
|
var id = Convert.ToInt32(dataGridViewRow.Cells["Id"].Value);
|
|
|
|
|
|
//Pause
|
|
|
|
|
|
string message = "是否暂停系统";
|
|
var formul = LjFormulaDb.GetById(id);
|
|
|
|
if (MessageBox.Show(message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) ==
|
|
DialogResult.OK)
|
|
{
|
|
var unit= formul.Unit;
|
|
switch (unit)
|
|
{
|
|
case 1:
|
|
|
|
PlcConnect.Instance.Write($"DB2105.8.0", Convert.ToUInt16(1));
|
|
|
|
// plc.PlcWriteByDataKey(plc.Plan0_Pause, new object[] { 1 });
|
|
break;
|
|
case 2:
|
|
PlcConnect.Instance.Write($"DB2105.20.0", Convert.ToUInt16(1));
|
|
// plc.PlcWriteByDataKey(plc.Plan1_Pause, new object[] { 1 });
|
|
break;
|
|
|
|
case 3:
|
|
PlcConnect.Instance.Write($"DB2105.32.0", Convert.ToUInt16(1));
|
|
// plc.PlcWriteByDataKey(plc.Plan2_Pause, new object[] { 1 });
|
|
break;
|
|
|
|
case 4:
|
|
PlcConnect.Instance.Write($"DB2105.44.0", Convert.ToUInt16(1));
|
|
// plc.PlcWriteByDataKey(plc.Plan3_Pause, new object[] { 1 });
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (OnPause != null)
|
|
{
|
|
|
|
|
|
|
|
OnPause(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
}
|
|
}
|
|
}
|
|
} |