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.Qingquan.BasicInfo; namespace Mesnac.Action.Feeding.Qingquan.FeedingPlc { /// /// 把开始密炼信号下传至PLC /// public class StartMixingToPlc : FeedingAction, IAction { /// /// 把开始密炼信号下传至PLC 业务入口 /// /// public void Run(RuntimeParameter runtime) { base.RunIni(runtime); bool IsSuccess = DownloadStartMixing(); if (!IsSuccess) { throw new Exception("开始称量信息下载错误!"); } } /// /// 把开始密炼信号下传至PLC /// /// 成功返回true,失败返回false public bool DownloadStartMixing() { try { int data = 0; bool isSuccess = int.TryParse(PlcData.Instance.StartMix.LastValue.ToInt().ToString(), out data); //Mesnac.Equips.Factory.Instance.Read(); //bool isSuccess = int.TryParse(PlcData.Instance.StartMix.EquipData.LastBeforeMathValue.FirstOrDefault().ToString(), out data); if (isSuccess) { data = data | 1; isSuccess = PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.StartMix, new object[] { data }); if (isSuccess) { ICSharpCode.Core.LoggingService.Debug("把开始密炼信号下传至PLC成功!"); } else { ICSharpCode.Core.LoggingService.Warn("把开始密炼信号下传至PLC失败!"); } } else { ICSharpCode.Core.LoggingService.Warn("把开始密炼信号下传至PLC失败!"); } return isSuccess; } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("把开始密炼信号下传至PLC失败:" + ex.Message, ex); return false; } } } }