using System; using System.Collections.Generic; using System.Linq; using DataBlockHelper; using Mesnac.Action.ChemicalWeighing.LjMixManager; namespace Mesnac.Action.ChemicalWeighing.LjPlanning { public class LjPlanningPlcHelp { private static void Dowd(int start, RecipePlcView view) { int bin = start; PlcConnect.Instance.Write($"DB2104.{bin}.0", view.Bin); int set = start+2; PlcConnect.Instance.Write($"DB2104.{set}.0",view.Set); int tolerance = start+6; PlcConnect.Instance.Write($"DB2104.{tolerance}.0", view.TolErance); } private static void DowSteps(int start, Step step) { int mixCode = start; PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode); int mixTime = start + 2; PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime); int mixTemp = start + 4; PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp); int mixSpeed = start + 8; PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed); } private static void DowMSteps(int start, MixStep step) { int mixCode = start; PlcConnect.Instance.Write($"DB2104.{mixCode}.0", step.MixCode); int mixTime = start + 2; PlcConnect.Instance.Write($"DB2104.{mixTime}.0", step.MixTime); int mixTemp = start + 4; PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", step.MixTemp); int mixSpeed = start + 8; PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", step.MixSpeed); int setValue = start + 12; PlcConnect.Instance.Write($"DB2104.{setValue}.0", step.SetValue); int tolerance = start + 16; PlcConnect.Instance.Write($"DB2104.{tolerance}.0", step.SetTolerance); } private static List GetClean(int num) { List ls = new List(num); for (int i = 0; i < num; i++) { ls.Add(new RecipePlcView() { Bin = 0, TolErance = 0, Set = 0 }); } return ls; } private static List GetCleanStep(int num) { List ls = new List(num); for (int i = 0; i < num; i++) { ls.Add(new Step() { MixCode = 0, MixSpeed = 0, MixTemp = 0, MixTime = 0 }); } return ls; } private static List GetCleanMixStep(int num) { List ls = new List(num); for (int i = 0; i < num; i++) { ls.Add(new MixStep() { MixCode = 0, MixSpeed = 0, MixTemp = 0, MixTime = 0, SetTolerance =0, SetValue = 0 }); } return ls; } /// /// 干混机1 /// /// /// public static void DownD1Recipe(List recipePlcViews, List recipeSteps) { int begin = 58; DownCleanD1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin += 120; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.53.6",true); } private static void DownCleanD1Recipe(int begin) { List recipePlcViews = GetClean(12); List recipeSteps = GetCleanStep(10); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin +=120; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } private static void DownCleanG1Recipe(int begin) { List recipePlcViews = GetClean(2); List recipeSteps = GetCleanStep(10); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin +=20; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } private static void DownM1CleanRecipe(int begin) { List recipeSteps = GetCleanMixStep(10); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownD2Recipe(List recipePlcViews, List recipeSteps) { int begin = 298; DownCleanD1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 418; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.53.7", true); } public static void DownD3Recipe(List recipePlcViews, List recipeSteps) { int begin = 538; DownCleanD1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 658; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.0", true); } public static void DownD4Recipe(List recipePlcViews, List recipeSteps) { int begin = 778; DownCleanD1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 898; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.1", true); } public static void DownG1Recipe(List recipePlcViews,List recipeSteps) { int begin = 1018; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1038; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.53.6",true); } public static void DownG2Recipe(List recipePlcViews, List recipeSteps) { int begin = 1158; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1178; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.2", true); } public static void DownG3Recipe(List recipePlcViews, List recipeSteps) { int begin = 1298; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1318; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.53.7", true); } public static void DownG4Recipe(List recipePlcViews, List recipeSteps) { int begin = 1438; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1458; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.4", true); } public static void DownG5Recipe(List recipePlcViews, List recipeSteps) { int begin = 1578; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1598; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.6", true); } public static void DownG6Recipe(List recipePlcViews, List recipeSteps) { int begin =1718; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1738; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.54.7", true); } public static void DownG7Recipe(List recipePlcViews, List recipeSteps) { int begin =1858; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1878; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.55.0", true); } public static void DownG8Recipe(List recipePlcViews, List recipeSteps) { int begin =1998; DownCleanG1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 2018; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } PlcConnect.Instance.Write($"DB2104.55.1", true); } public static void DownM1Recipe(List recipeSteps) { int begin = 2138; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.2", true); } public static void DownM2Recipe(List recipeSteps) { int begin = 2338; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.3", true); } public static void DownM3Recipe(List recipeSteps) { int begin = 2538; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.4", true); } public static void DownM4Recipe(List recipeSteps) { int begin = 2738; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.5", true); } public static void DownM5Recipe(List recipeSteps) { int begin = 2938; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.6", true); } public static void DownM6Recipe(List recipeSteps) { int begin = 2978; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.55.7", true); } public static void DownM7Recipe(List recipeSteps) { int begin = 3138; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.56.0", true); } public static void DownM8Recipe(List recipeSteps) { int begin = 3338; DownM1CleanRecipe(begin); for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } PlcConnect.Instance.Write($"DB2104.56.1", true); } } }