From d7cd1d90bcbdcca5a8d1cf548c1baf4d5ade3d91 Mon Sep 17 00:00:00 2001 From: nodyang Date: Tue, 24 Oct 2023 14:33:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=20add=20?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=85=8D=E7=BD=AE=E5=92=8C=20=E4=B8=8B?= =?UTF-8?q?=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LjPlanning/DryerView.cs | 19 ++ .../LjPlanning/LjPlanningPlcHelp.cs | 171 +++++++++++++++++- .../Mesnac.Action.ChemicalWeighing.csproj | 4 + 3 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DryerView.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DryerView.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DryerView.cs new file mode 100644 index 0000000..683f986 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DryerView.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using Mesnac.Action.ChemicalWeighing.LjMixManager; + +namespace Mesnac.Action.ChemicalWeighing.LjPlanning +{ + public class DryerView + { + + public DryerView() + { + RecipePlcViews = new List(); + RecipeSteps = new List(); + } + + public List RecipePlcViews { get; set; } + + public List RecipeSteps { get; set; } + } +} \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/LjPlanningPlcHelp.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/LjPlanningPlcHelp.cs index d27fc53..7c4f5d5 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/LjPlanningPlcHelp.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/LjPlanningPlcHelp.cs @@ -123,7 +123,6 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning public static void DownD1Recipe(List recipePlcViews, List recipeSteps) { - int begin = 58; DownCleanD1Recipe(begin); for (int i = 0; i < recipePlcViews.Count(); i++) @@ -625,5 +624,175 @@ namespace Mesnac.Action.ChemicalWeighing.LjPlanning PlcConnect.Instance.Write($"DB2104.56.1", true); } + + + public static DryerView GetDryerD1 => GetDryerView(58); + public static DryerView GetDryerD2 => GetDryerView(298); + public static DryerView GetDryerD3 => GetDryerView(538); + public static DryerView GetDryerD4 => GetDryerView(778); + + + public static DryerView GetGelatG1 => GetGelatView(1018); + + public static DryerView GetGelatG2 => GetGelatView(1158); + + + public static DryerView GetGelatG3 => GetGelatView(1298); + + + public static DryerView GetGelatG4 => GetGelatView(1438); + + public static DryerView GetGelatG5 => GetGelatView(1578); + public static DryerView GetGelatG6 => GetGelatView(1718); + public static DryerView GetGelatG7 => GetGelatView(1858); + + public static DryerView GetGelatG8 => GetGelatView(1998); + + + + public static List GetWeterM1 = GetWeterView(2138); + + public static List GetWeterM2 = GetWeterView(2338); + + public static List GetWeterM3 = GetWeterView(2538); + public static List GetWeterM4 = GetWeterView(2738); + public static List GetWeterM5 = GetWeterView(2938); + + public static List GetWeterM6 = GetWeterView(3138); + public static List GetWeterM7 = GetWeterView(3338); + public static List GetWeterM8 = GetWeterView(3538); + + + + private static DryerView GetDryerView(int start) + { + var byteTransform = PlcConnect.Instance.ByteTransform; + DryerView view = new DryerView(); + var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 240); + if (operateResult.IsSuccess) + { + List ls = new List(); + var convert = operateResult.Content; + var data = convert.Skip(0).Take(120); + for (int i = 0; i < 12; i++) + { + var bytes = data.Skip(i * 10).Take(10).ToArray(); + RecipePlcView plcView = new RecipePlcView + { + Bin = byteTransform.TransUInt16(bytes, 0), + Set = byteTransform.TransSingle(bytes, 2), + TolErance = byteTransform.TransSingle(bytes, 6) + }; + ls.Add(plcView); + } + + view.RecipePlcViews = ls; + + data = convert.Skip(120).Take(120); + + List lsSteps = new List(); + for (int i = 0; i < 10; i++) + { + var bytes = data.Skip(i * 10).Take(12).ToArray(); + Step step = new Step() + { + MixCode = byteTransform.TransUInt16(bytes, 0), + MixTime = byteTransform.TransUInt16(bytes, 2), + MixTemp = byteTransform.TransSingle(bytes, 4), + MixSpeed =byteTransform.TransSingle(bytes,8) + }; + lsSteps.Add(step); + } + + view.RecipeSteps = lsSteps; + + } + + return view; + } + + + private static DryerView GetGelatView(int start) + { + var byteTransform = PlcConnect.Instance.ByteTransform; + DryerView view = new DryerView(); + var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 140); + if (operateResult.IsSuccess) + { + List ls = new List(); + var convert = operateResult.Content; + var data = convert.Skip(0).Take(20); + for (int i = 0; i < 2; i++) + { + var bytes = data.Skip(i * 10).Take(10).ToArray(); + RecipePlcView plcView = new RecipePlcView + { + Bin = byteTransform.TransUInt16(bytes, 0), + Set = byteTransform.TransSingle(bytes, 2), + TolErance = byteTransform.TransSingle(bytes, 6) + }; + ls.Add(plcView); + } + + view.RecipePlcViews = ls; + + data = convert.Skip(20).Take(120); + + List lsSteps = new List(); + for (int i = 0; i < 10; i++) + { + var bytes = data.Skip(i * 10).Take(12).ToArray(); + Step step = new Step() + { + MixCode = byteTransform.TransUInt16(bytes, 0), + MixTime = byteTransform.TransUInt16(bytes, 2), + MixTemp = byteTransform.TransSingle(bytes, 4), + MixSpeed =byteTransform.TransSingle(bytes,8) + }; + lsSteps.Add(step); + } + + view.RecipeSteps = lsSteps; + + } + + return view; + } + + + + + + private static List GetWeterView(int start) + { + var byteTransform = PlcConnect.Instance.ByteTransform; + List ls = new List(); + var operateResult = PlcConnect.Instance.Read($"DB2104.{start}.0", 200); + List lsSteps = new List(); + if (operateResult.IsSuccess) + { + + var data = operateResult.Content; + + + for (int i = 0; i < 10; i++) + { + var bytes = data.Skip(i * 10).Take(20).ToArray(); + MixStep step = new MixStep() + { + MixCode = byteTransform.TransUInt16(bytes, 0), + MixTime = byteTransform.TransUInt16(bytes, 2), + MixTemp = byteTransform.TransSingle(bytes, 4), + MixSpeed =byteTransform.TransSingle(bytes,8), + SetValue = byteTransform.TransSingle(bytes,12), + SetTolerance = byteTransform.TransSingle(bytes,16) + }; + lsSteps.Add(step); + } + + } + + return lsSteps; + } } } \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index eb1c511..4f13eb5 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -176,6 +176,9 @@ False ..\..\..\PlugInPlatform\Mesnac.PlugIn.dll + + ..\..\Microsoft.Office.Interop.Excel.dll + @@ -395,6 +398,7 @@ +