You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.7 KiB
C#

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<RecipeData.RecipeWeightInfo> 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<RecipeData.RecipeWeightInfo> 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();
}
}
}