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 PlcWeightToPlc : FeedingAction, IAction { private bool hasWeightType(List weightList, RecipeData.WeightType weightType) { foreach (RecipeData.RecipeWeightInfo w in weightList) { if (w.WeightType == (int)weightType) { return true; } } return false; } public void Run(RuntimeParameter runtime) { if (Mesnac.Basic.RunSchema.Instance.GetConfigValue("PlanExecuteType", "0").Trim() == "0") { return; } RecipeData recipe = new RecipeData(); int allche = recipe.GetCurrentPlanLotCount(); if (PlcData.Instance.MixingFinishedCount.NowValue.ToInt() >= allche) { new ProducingPlan.ExecutePlan().ExecuteNext(); return; } List weightList = recipe.GetCurrentRecipeWeightInfo(); if (PlcData.Instance.MixingFinishedCount.NowValue.ToInt() >= allche) { return; } if (PlcData.Instance.PloyFinishedCount.NowValue.ToInt() < allche && hasWeightType(weightList, RecipeData.WeightType.胶料)) { return; } if (PlcData.Instance.CarbonFinishedCount.NowValue.ToInt() < allche && hasWeightType(weightList, RecipeData.WeightType.炭黑)) { return; } if (PlcData.Instance.OilFinishedCount.NowValue.ToInt() < allche && hasWeightType(weightList, RecipeData.WeightType.油)) { return; } string planid = recipe.GetNextPlanID(); if (new BaseAction().NetType == BaseAction.NetTypes.Net) { new NetRecipe().GetRecipeByPlanID(planid); } string recipeid = recipe.GetRecipeID(planid); //下传称量信息 DataTable dt = recipe.GetRecipeWeigthData(recipeid); RecipeToDatabase recipeToDatabase = new RecipeToDatabase(); recipeToDatabase.DownloadRecipeWeightInfo(dt, true); recipeToDatabase.StartWeight(); new BasicInfo.DatabaseToPlc().Run(); } } }