|
|
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 SystemReset : FeedingAction, IAction
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 系统复位关键业务
|
|
|
/// </summary>
|
|
|
/// <returns>成功返回1,失败返回其他值,密炼机有物料:-1,下传复位信号失败:-2,清除完成数失败:-3</returns>
|
|
|
public int ExecuteReset()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
int iExistsMaterial = 0;
|
|
|
//iExistsMaterial = PlcData.Instance.HasMaterial.LastValue.ToInt();
|
|
|
//Mesnac.Equips.Factory.Instance.Read();
|
|
|
//if (int.TryParse(PlcData.Instance.HasMaterial.EquipData.LastBeforeMathValue.FirstOrDefault().ToString(), out iExistsMaterial))
|
|
|
if (int.TryParse(PlcData.Instance.HasMaterial.LastValue.ToInt().ToString(), out iExistsMaterial))
|
|
|
{
|
|
|
iExistsMaterial = iExistsMaterial & 0x0001; //取最低位
|
|
|
if (iExistsMaterial == 1)
|
|
|
{
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
if (!PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.SysReset, new object[] { 1 }))
|
|
|
{
|
|
|
return -2;
|
|
|
}
|
|
|
|
|
|
//if (!PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.MixingFinishedCountReset, new object[] { 0 }))
|
|
|
//{
|
|
|
// return -3;
|
|
|
//}
|
|
|
ICSharpCode.Core.LoggingService.Debug("系统复位成功!");
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("系统复位失败!");
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Error("系统复位失败:" + ex.Message, ex);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 系统复位入口
|
|
|
/// </summary>
|
|
|
/// <param name="runtime"></param>
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.LogDebug("系统复位...");
|
|
|
if (MessageBox.Show("确认系统复位吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
int result = ExecuteReset();
|
|
|
if (result == -1)
|
|
|
{
|
|
|
MessageBox.Show("存在物料,不能进行复位!");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (result == -2)
|
|
|
{
|
|
|
MessageBox.Show("写入复位标志失败!");
|
|
|
return;
|
|
|
}
|
|
|
MessageBox.Show("写入复位标志成功!");
|
|
|
}
|
|
|
}
|
|
|
} |