From d0dc861f1bf2c13b65196a35e6a011ed18d9463b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Wed, 27 Dec 2023 09:59:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=93=E9=80=81=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LjDeliver/DaCangFactory.cs | 126 ++++++++++++++++++ .../LjDeliver/DeliverInitAction.cs | 52 +++++--- .../Mesnac.Action.ChemicalWeighing.csproj | 1 + DataBlockHelper/PlcConnect.cs | 2 +- 4 files changed, 165 insertions(+), 16 deletions(-) create mode 100644 Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DaCangFactory.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DaCangFactory.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DaCangFactory.cs new file mode 100644 index 0000000..f18d332 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DaCangFactory.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Action.ChemicalWeighing.LjDeliver +{ + public class DaCangFactory + { + public static IDictionary GetDefault() + { + IDictionary keyValuePairs=new + Dictionary(); + keyValuePairs.Add("小料1", new DaCangValue() + { + volume = 150, + Density = 0.69f + }); + + keyValuePairs.Add("小料2", new DaCangValue() + { + volume = 150, + Density = 0.87f + }); + + keyValuePairs.Add("木粉", new DaCangValue() + { + volume = 300, + Density = 0.4f + }); + + keyValuePairs.Add("碳酸钙", new DaCangValue() + { + volume = 300, + Density = 1.7f + }); + + + + keyValuePairs.Add("木薯粉", new DaCangValue() + { + volume = 300, + Density = 0.71f + }); + + keyValuePairs.Add("玉米粉", new DaCangValue() + { + volume = 300, + Density = 0.69f + }); + + + + keyValuePairs.Add("碳粉1", new DaCangValue() + { + volume = 700, + Density = 0.64f + }); + + keyValuePairs.Add("碳粉2", new DaCangValue() + { + volume = 700, + Density = 0.65f + }); + + keyValuePairs.Add("碳粉3", new DaCangValue() + { + volume = 700, + Density = 0.69f + }); + + keyValuePairs.Add("碳粉4", new DaCangValue() + { + volume = 700, + Density = 0.77f + }); + + + keyValuePairs.Add("碳粉5", new DaCangValue() + { + volume = 700, + Density = 0.64f + }); + + keyValuePairs.Add("碳粉6", new DaCangValue() + { + volume = 700, + Density = 0.65f + }); + + keyValuePairs.Add("碳粉7", new DaCangValue() + { + volume = 700, + Density = 0.69f + }); + + keyValuePairs.Add("碳粉8", new DaCangValue() + { + volume = 700, + Density = 0.77f + }); + + keyValuePairs.Add("回收罐", new DaCangValue() + { + volume = 50, + Density = 0.69f + }); + + return keyValuePairs; + } + } + + public class DaCangValue + { + /// + /// 体积 + /// + public int volume { get; set; } + + /// + /// 密度 + /// + public float Density { get; set; } + } +} diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs index 8f40c70..36c50b0 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs @@ -2,6 +2,9 @@ using DataBlockHelper.DBHelpers; using DevExpress.Data.Filtering.Helpers; using DevExpress.Utils.FormShadow; + +using HslCommunication.LogNet; + using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjDeliver.Entity; using Mesnac.Action.ChemicalWeighing.LjMaterial; @@ -865,22 +868,41 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliver ControlsHelper.SetHslBottle(bottleE.Bottle14, PlcTemp.Bottle14_Set); ControlsHelper.SetHslBottle(bottleE.Bottle15, PlcTemp.Bottle15_Set); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue1, Math.Round(PlcTemp.Bottle1_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue2, Math.Round(PlcTemp.Bottle2_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue3, Math.Round(PlcTemp.Bottle3_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue4, Math.Round(PlcTemp.Bottle4_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue5, Math.Round(PlcTemp.Bottle5_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue6, Math.Round(PlcTemp.Bottle6_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue7, Math.Round(PlcTemp.Bottle7_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue8, Math.Round(PlcTemp.Bottle8_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue9, Math.Round(PlcTemp.Bottle9_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue10, Math.Round(PlcTemp.Bottle10_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue11, Math.Round(PlcTemp.Bottle11_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue12, Math.Round(PlcTemp.Bottle12_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue13, Math.Round(PlcTemp.Bottle13_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue14, Math.Round(PlcTemp.Bottle14_Set, 1) + " %"); - ControlsImprot.SetMCLabel(LabelE.HslBottleValue15, Math.Round(PlcTemp.Bottle15_Set, 1) + " %"); + + var dic = DaCangFactory.GetDefault(); + + + + ControlsImprot.SetMCLabel(LabelE.HslBottleValue1, JiSuan(PlcTemp.Bottle1_Set, dic["小料1"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue2, JiSuan(PlcTemp.Bottle2_Set, dic["小料2"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue3, JiSuan(PlcTemp.Bottle3_Set, dic["木粉"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue4, JiSuan(PlcTemp.Bottle4_Set, dic["碳酸钙"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue5, JiSuan(PlcTemp.Bottle5_Set, dic["木薯粉"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue6, JiSuan(PlcTemp.Bottle6_Set, dic["玉米粉"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue7, JiSuan(PlcTemp.Bottle7_Set, dic["碳粉1"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue8, JiSuan(PlcTemp.Bottle8_Set, dic["碳粉2"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue9, JiSuan(PlcTemp.Bottle9_Set, dic["碳粉3"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue10, JiSuan(PlcTemp.Bottle10_Set, dic["碳粉4"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue11, JiSuan(PlcTemp.Bottle11_Set, dic["碳粉5"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue12, JiSuan(PlcTemp.Bottle12_Set, dic["碳粉6"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue13, JiSuan(PlcTemp.Bottle13_Set, dic["碳粉7"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue14, JiSuan(PlcTemp.Bottle14_Set, dic["碳粉8"]) + "t"); + ControlsImprot.SetMCLabel(LabelE.HslBottleValue15, JiSuan(PlcTemp.Bottle15_Set, dic["小料1"]) + "t"); } + + + public string JiSuan(double x, DaCangValue daCangValue) + { + var bottleValue3 = Math.Round(x * daCangValue.volume * daCangValue.Density, 2)/100; + var entity= bottleValue3.ToString("f1"); + if (entity == "0.0") + { + return "0"; + } + return entity; + } + + #endregion diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 346eefd..ba1676d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -311,6 +311,7 @@ + diff --git a/DataBlockHelper/PlcConnect.cs b/DataBlockHelper/PlcConnect.cs index f01510b..c506a62 100644 --- a/DataBlockHelper/PlcConnect.cs +++ b/DataBlockHelper/PlcConnect.cs @@ -44,8 +44,8 @@ namespace DataBlockHelper return s7; } - } + } }