|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Net.NetworkInformation;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Mesnac.Action.Feeding.BasicInfo;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.FeedingPlc
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 终止称量
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class StopWeight : FeedingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.LogDebug("终止称量...");
|
|
|
|
|
|
|
|
|
|
string msg = String.Empty;
|
|
|
|
|
|
|
|
|
|
#region 判断当班计划界面是否打开
|
|
|
|
|
|
|
|
|
|
if (PlanCommon.IsInit == false)
|
|
|
|
|
{
|
|
|
|
|
msg = "当班计划还为初始化,请先打开当班计划,再进行此操作!";
|
|
|
|
|
ShowMsg(msg, Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (MessageBox.Show("确认终止称量吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string recipeName = new RecipeData().GetCurrentRecipeInfo().RecipeName;
|
|
|
|
|
base.LogInfo("终止称量:" + recipeName);
|
|
|
|
|
if (StopWeight.ExecStopWeight())
|
|
|
|
|
{
|
|
|
|
|
ShowMsg("写入终止称量至PLC成功...", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowMsg("写入终止称量至PLC失败...", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 把终止称量信号下传至PLC(位运算:位或2 )
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>下传成功返回true,否则返回false</returns>
|
|
|
|
|
public static bool ExecStopWeight()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
int readword = 0;
|
|
|
|
|
//Mesnac.Equips.Factory.Instance.Read();
|
|
|
|
|
if (int.TryParse(PlcData.Instance.AbortWeight.EquipData.LastBeforeMathValue.FirstOrDefault().ToString(), out readword))
|
|
|
|
|
{
|
|
|
|
|
readword = readword | 2;
|
|
|
|
|
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.AbortWeight, new object[] { readword }))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Debug("写入终止称量成功...");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ICSharpCode.Core.LoggingService.Warn("写入终止称量失败...");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService.Error("写入终止称量失败:" + ex.Message, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|