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 { public class RecipeToPlc : FeedingAction, IAction { private bool IsNet() { bool Result = false; Result = base.NetType == NetTypes.Net; return Result; } private DateTime Now() { if (IsNet()) { try { DbHelper dbHelper = NewDbHelper(Basic.DataSourceFactory.MCDbType.Server); dbHelper.CommandType = CommandType.Text; dbHelper.ClearParameter(); dbHelper.CommandText = "select getdate();"; DateTime time = (DateTime)dbHelper.ToScalar(); new Basic.LocalTime().Set(time); return time; } catch { return DateTime.Now; } } else { return DateTime.Now; } } public void Run(RuntimeParameter runtime) { base.RunIni(runtime); BasicInfo.RecipeData recipeData = new BasicInfo.RecipeData(); if ((double)PlcData.Instance.MixerAuto.LastValue == 0) { MessageBox.Show("密炼机本控", "系统提示"); } if ((double)PlcData.Instance.MixerNormal.LastValue == 0) { MessageBox.Show("密炼机故障", "系统提示"); } #region RecipeWeightInfo List weightlst = recipeData.GetCurrentRecipeWeightInfo(); bool isExists = false; foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst) { if (weight.WeightType == 0) { isExists = true; break; } } if (isExists) { if ((double)PlcData.Instance.CarbonNormal.LastValue == 0) { MessageBox.Show("炭黑称故障", "系统提示"); } if ((double)PlcData.Instance.CarbonAuto.LastValue == 0) { MessageBox.Show("炭黑称手动", "系统提示"); } } isExists = false; foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst) { if (weight.WeightType == 1) { isExists = true; break; } } if (isExists) { if ((double)PlcData.Instance.OilNormal.LastValue == 0) { MessageBox.Show("油称故障", "系统提示"); } if ((double)PlcData.Instance.OilAuto.LastValue == 0) { MessageBox.Show("油称手动", "系统提示"); } } isExists = false; foreach (BasicInfo.RecipeData.RecipeWeightInfo weight in weightlst) { if (weight.WeightType == 3) { isExists = true; break; } } if (isExists) { if ((double)PlcData.Instance.FenLiaoNormal.LastValue == 0) { MessageBox.Show("粉料秤故障", "系统提示"); } if ((double)PlcData.Instance.FenLiaoAuto.LastValue == 0) { MessageBox.Show("粉料秤手动", "系统提示"); } } #endregion bool IsSuccess = true; if (IsSuccess) { IsSuccess = recipeData.DownloadCurrentRecipeInfo(); } } } }