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", Convert.ToUInt16(view.Bin)); int set = start+2; PlcConnect.Instance.Write($"DB2104.{set}.0", Convert.ToSingle(view.Set)); int tolerance = start+6; PlcConnect.Instance.Write($"DB2104.{tolerance}.0", Convert.ToSingle(view.TolErance)); } private static void DowSteps(int start, Step step) { int mixCode = start; PlcConnect.Instance.Write($"DB2104.{mixCode}.0", Convert.ToUInt16(step.MixCode)); int mixTime = start + 2; PlcConnect.Instance.Write($"DB2104.{mixTime}.0", Convert.ToUInt16(step.MixTime)); int mixTemp = start + 4; PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", Convert.ToSingle(step.MixTemp)); int mixSpeed = start + 8; PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", Convert.ToSingle(step.MixSpeed)); } private static void DowMSteps(int start, MixStep step) { int mixCode = start; PlcConnect.Instance.Write($"DB2104.{mixCode}.0", Convert.ToUInt16(step.MixCode)); int mixTime = start + 2; PlcConnect.Instance.Write($"DB2104.{mixTime}.0", Convert.ToUInt16(step.MixTime)); int mixTemp = start + 4; PlcConnect.Instance.Write($"DB2104.{mixTemp}.0", Convert.ToSingle(step.MixTemp)); int mixSpeed = start + 8; PlcConnect.Instance.Write($"DB2104.{mixSpeed}.0", Convert.ToSingle(step.MixSpeed)); int setValue = start + 12; PlcConnect.Instance.Write($"DB2104.{setValue}.0", Convert.ToSingle(step.SetValue)); int tolerance = start + 16; PlcConnect.Instance.Write($"DB2104.{tolerance}.0", Convert.ToSingle(step.SetTolerance)); } /// /// 干混机1 /// /// /// public static void DownD1Recipe(List recipePlcViews, List recipeSteps) { int begin = 58; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 98; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownD2Recipe(List recipePlcViews, List recipeSteps) { int begin = 218; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 258; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownD3Recipe(List recipePlcViews, List recipeSteps) { int begin = 378; 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; } } public static void DownD4Recipe(List recipePlcViews, List recipeSteps) { int begin = 538; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 578; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG1Recipe(List recipePlcViews,List reShui,List recipeSteps) { int begin = 698; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 718; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 738; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG2Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin = 858; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 878; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[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; } } public static void DownG3Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin = 1018; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1038; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1058; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG4Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin = 1178; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1198; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1218; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG5Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin = 1338; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1358; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1378; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG6Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin =1498; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1518; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1538; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG7Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin =1658; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1678; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1698; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownG8Recipe(List recipePlcViews, List reShui, List recipeSteps) { int begin =1818; for (int i = 0; i < recipePlcViews.Count(); i++) { var view = recipePlcViews[i]; Dowd(begin, view); begin += 10; } begin = 1838; for (int i = 0; i < reShui.Count(); i++) { var view = reShui[i]; Dowd(begin, view); begin += 10; } begin = 1858; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowSteps(begin, view); begin += 12; } } public static void DownM1Recipe(List recipeSteps) { int begin = 1978; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM2Recipe(List recipeSteps) { int begin = 2178; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM3Recipe(List recipeSteps) { int begin = 2378; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM4Recipe(List recipeSteps) { int begin = 2578; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM5Recipe(List recipeSteps) { int begin = 2778; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM6Recipe(List recipeSteps) { int begin = 2978; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM7Recipe(List recipeSteps) { int begin = 3178; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } public static void DownM8Recipe(List recipeSteps) { int begin = 3378; for (int i = 0; i < recipeSteps.Count(); i++) { var view = recipeSteps[i]; DowMSteps(begin, view); begin += 20; } } } }