From bcb198e65ad91daa716d4f6f156e2be88fbd746f 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, 6 Dec 2023 21:32:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E7=A7=B0=E4=B8=8B=E4=BC=A0=20?= =?UTF-8?q?=E6=B0=B4=E7=A7=A4=E6=B7=BB=E5=8A=A0=20differ=20=E5=92=8C=20sta?= =?UTF-8?q?nd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoControl/AutoControl.cs | 2 +- .../Entity/GelerWeterControlsEntity.cs | 7 ++ .../AutoControl/InitAction.cs | 67 +++++++++++++++++++ .../AutoControl/PlcAutoWriteHelper.cs | 32 ++++++++- DataBlockHelper/DBHelpers/DB2104Helper.cs | 17 +++-- .../DBHelpers/DB2104WriteHelper.cs | 24 ++----- .../Entity/DB2104Entity/WaterView.cs | 4 ++ 7 files changed, 126 insertions(+), 27 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs index 2faae37..a783b7a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs @@ -78,7 +78,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl return; } - WaterDownload(TextE); + WaterDownload(TextE,ComboE); } #endregion diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs index 32ee8ce..1daef33 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs @@ -44,6 +44,8 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity public MCCombobox DryM12 { get; set; } public MCCombobox PasteChooseDry { get; set; } public MCCombobox PasteChooseWet { get; set; } + + public MCCombobox CALeftOrRight { get; set; } public MCCombobox HALeftOrRight { get; set; } public MCCombobox CBLeftOrRight { get; set; } @@ -137,6 +139,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity public MCTextBox HADeviation { get; set; } public MCTextBox CBDeviation { get; set; } public MCTextBox HBDeviation { get; set; } + + + + + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs index c87d512..0d388df 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs @@ -1,5 +1,7 @@ using DataBlockHelper.DBHelpers; using DevExpress.DataAccess.Wizard.Presenters; +using DevExpress.XtraEditors.Filtering.Templates; + using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.AutoControl.DB; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; @@ -9,8 +11,10 @@ using Mesnac.Action.ChemicalWeighing.LjPlanning; using Mesnac.Controls.Base; using Mesnac.Controls.Default; + using System; using System.Collections.Generic; +using System.Data; using System.Drawing; using System.Linq; using System.Reflection; @@ -39,6 +43,15 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl McControls = GetAllControls(); ControlsHelper.ControlImport(TextE, McControls); + + // McControls.FirstOrDefault(x => x.Name == name) + + //TextE.HALeftOrRight = McControls.FirstOrDefault(x => x.Name == "HALeftOrRight") as MCCombobox; + //TextE.HBLeftOrRight = McControls.FirstOrDefault(x => x.Name == "HBLeftOrRight") as MCCombobox; + //TextE.CALeftOrRight = McControls.FirstOrDefault(x => x.Name == "CALeftOrRight") as MCCombobox; + //TextE.CBLeftOrRight = McControls.FirstOrDefault(x => x.Name == "CBLeftOrRight") as MCCombobox; + + ControlsHelper.ControlImport(ComboE, McControls); ControlsHelper.ControlImport(LabelE, McControls); ControlsHelper.ControlImport(RadioE, McControls); @@ -228,6 +241,60 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl s1[i - 1] = "产线" + i; } ComboE.PasteChooseDry.DataSource = s1; + + DB2104Helper dB2104Helper=new DB2104Helper(); + + var data = GetTable(); + ComboE.CALeftOrRight.DataSource = data.Copy(); + ComboE.HALeftOrRight.DataSource = data.Copy(); + ComboE.CBLeftOrRight.DataSource = data.Copy(); + ComboE.HBLeftOrRight.DataSource = data.Copy(); + + var ha= dB2104Helper.GetAHotWater; + + TextE.HADeviation.MCValue = ha.differ; + ComboE.HALeftOrRight.MCValue = ha.stand; + + var hb = dB2104Helper.GetBHotWater; + TextE.HBDeviation.MCValue = hb.differ; + ComboE.HBLeftOrRight.MCValue = hb.stand; + + + var ca = dB2104Helper.GetAColWater; + + TextE.CADeviation.MCValue = ca.differ; + ComboE.CALeftOrRight.MCValue = ca.stand; + + var cb = dB2104Helper.GetBColWater; + + TextE.CBDeviation.MCValue = cb.differ; + + ComboE.CBLeftOrRight.MCValue = cb.stand; + + } + + + private DataTable GetTable() + { + DataTable dataTable = new System.Data.DataTable(); + dataTable.Columns.Add("CmbValue", typeof(string)); + dataTable.Columns.Add("CmbDisplay", typeof(string)); + + DataRow dr=dataTable.NewRow(); + dr[0] = "0"; + dr[1] = "无"; + dataTable.Rows.Add(dr); + dr = dataTable.NewRow(); + dr[0] = "1"; + dr[1] = "左"; + dataTable.Rows.Add(dr); + + dr = dataTable.NewRow(); + dr[0] = "2"; + dr[1] = "右"; + dataTable.Rows.Add(dr); + + return dataTable; } #endregion diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs index c4da126..358e05a 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs @@ -442,7 +442,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl #region 水称下传 - public static void WaterDownload(MCTextBoxEntity TextE) + public static void WaterDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE) { WaterEntity HotA = new WaterEntity(); WaterEntity ColdA = new WaterEntity(); @@ -451,6 +451,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl float hotASet, hotBSet, coldASet, coldBSet, hotATol, hotBTol, coldATol, coldBTol; + float cADeviation; ushort cALeftOrRight; + float hADeviation; ushort hALeftOrRight; + float cBDeviation; ushort cBLeftOrRight; + float hBDeviation; ushort hBLeftOrRight; + if (float.TryParse(Convert.ToString(TextE.HotValueA.MCValue), out hotASet) && float.TryParse(Convert.ToString(TextE.HotToleranceA.MCValue), out hotATol) && float.TryParse(Convert.ToString(TextE.HotValueB.MCValue), out hotBSet) && @@ -458,16 +463,39 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl float.TryParse(Convert.ToString(TextE.ColdValueA.MCValue), out coldASet) && float.TryParse(Convert.ToString(TextE.ColdToleranceA.MCValue), out coldATol) && float.TryParse(Convert.ToString(TextE.ColdValueB.MCValue), out coldBSet) && - float.TryParse(Convert.ToString(TextE.ColdToleranceB.MCValue), out coldBTol)) + float.TryParse(Convert.ToString(TextE.ColdToleranceB.MCValue), out coldBTol) + + + && float.TryParse(Convert.ToString(TextE.CADeviation.MCValue), out cADeviation) + && float.TryParse(Convert.ToString(TextE.HADeviation.MCValue), out hADeviation) + && float.TryParse(Convert.ToString(TextE.CBDeviation.MCValue), out cBDeviation) + && float.TryParse(Convert.ToString(TextE.HBDeviation.MCValue), out hBDeviation) + + + ) { HotA.Set = hotASet; HotB.Set = hotBSet; ColdA.Set = coldASet; ColdB.Set = coldBSet; + HotA.Tolerance = hotATol; HotB.Tolerance = hotBTol; ColdA.Tolerance = coldATol; ColdB.Tolerance = coldBTol; + + + HotA.differ = hADeviation; + HotB.differ = hBDeviation; + ColdA.differ = cADeviation; + ColdB.differ= cBDeviation; + + HotA.stand = Convert.ToInt16(ComboE.HALeftOrRight.MCValue); + HotB.stand = Convert.ToInt16(ComboE.HBLeftOrRight.MCValue); + + ColdA.stand = Convert.ToInt16(ComboE.CALeftOrRight.MCValue); + ColdB.stand = Convert.ToInt16(ComboE.CBLeftOrRight.MCValue); + Db2104WriteHelper.WriteAHostWater(HotA); Db2104WriteHelper.WriteBHostWater(HotB); Db2104WriteHelper.WriteAColWater(ColdA); diff --git a/DataBlockHelper/DBHelpers/DB2104Helper.cs b/DataBlockHelper/DBHelpers/DB2104Helper.cs index fc00d74..1fd2616 100644 --- a/DataBlockHelper/DBHelpers/DB2104Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2104Helper.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Collections; namespace DataBlockHelper.DBHelpers { @@ -13,7 +14,7 @@ namespace DataBlockHelper.DBHelpers public DB2104Helper() { - this.bytes = PlcConnect.Instance.Read("DB2104.0.0", 3618).Content; + this.bytes = PlcConnect.Instance.Read("DB2104.0.0", 3802).Content; } public RecipeCommEntity RecipeComm => RecipeCom(bytes); @@ -62,34 +63,38 @@ namespace DataBlockHelper.DBHelpers /// 热水秤B /// - public WaterEntity GetBHotWater => GetWater(3748); + public WaterEntity GetBHotWater => GetWater(3754); /// /// 冷水秤A /// - public WaterEntity GetAColWater => GetWater(3758); + public WaterEntity GetAColWater => GetWater(3770); /// /// 冷水秤B /// - public WaterEntity GetBColWater => GetWater(3768); + public WaterEntity GetBColWater => GetWater(3786); private WaterEntity GetWater(int start) { var instanceByteTransform = PlcConnect.Instance.ByteTransform; - var ls = this.bytes = PlcConnect.Instance.Read($"DB2104.{start}.0", 10).Content; + var ls = this.bytes = PlcConnect.Instance.Read($"DB2104.{start}.0", 16).Content; WaterEntity entity = new WaterEntity { Bin = instanceByteTransform.TransInt16(ls, 0), Set = instanceByteTransform.TransSingle(ls, 2), - Tolerance = instanceByteTransform.TransSingle(ls, 6) + Tolerance = instanceByteTransform.TransSingle(ls, 6), + differ = instanceByteTransform.TransSingle(ls, 10), + stand = instanceByteTransform.TransInt16(ls, 14), }; return entity; + + } diff --git a/DataBlockHelper/DBHelpers/DB2104WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2104WriteHelper.cs index 5155ae4..d2d1b21 100644 --- a/DataBlockHelper/DBHelpers/DB2104WriteHelper.cs +++ b/DataBlockHelper/DBHelpers/DB2104WriteHelper.cs @@ -7,21 +7,7 @@ namespace DataBlockHelper.DBHelpers { private static readonly string DbName = "DB2104"; - /// - /// 写入水 写入集合顺序 A热水 B热水 冷水A 冷水B - /// - /// - public static bool Write(List ls) - { - int start = 3578; - for (int i = 0; i < ls.Count; i++) - { - int no = start + (i * 10); - Write(no, ls[i]); - } - - return true; - } + /// /// A热水 /// @@ -37,7 +23,7 @@ namespace DataBlockHelper.DBHelpers /// public static void WriteBHostWater(WaterEntity entity) { - Write(3748, entity); + Write(3754, entity); } /// /// 冷水A @@ -45,7 +31,7 @@ namespace DataBlockHelper.DBHelpers /// public static void WriteAColWater(WaterEntity entity) { - Write(3758, entity); + Write(3770, entity); } /// /// 冷水B @@ -53,7 +39,7 @@ namespace DataBlockHelper.DBHelpers /// public static void WriteBColWater(WaterEntity entity) { - Write(3768, entity); + Write(3786, entity); } @@ -63,6 +49,8 @@ namespace DataBlockHelper.DBHelpers siemensS7Net.Write($"{DbName}.{start}.0", entity.Bin); siemensS7Net.Write($"{DbName}.{start+2}.0", entity.Set); siemensS7Net.Write($"{DbName}.{start+6}.0", entity.Tolerance); + siemensS7Net.Write($"{DbName}.{start + 10}.0", entity.differ); + siemensS7Net.Write($"{DbName}.{start + 14}.0", entity.stand); } } } \ No newline at end of file diff --git a/DataBlockHelper/Entity/DB2104Entity/WaterView.cs b/DataBlockHelper/Entity/DB2104Entity/WaterView.cs index 82da9d0..bab37b4 100644 --- a/DataBlockHelper/Entity/DB2104Entity/WaterView.cs +++ b/DataBlockHelper/Entity/DB2104Entity/WaterView.cs @@ -5,5 +5,9 @@ public short Bin { get; set; } public float Set { get; set; } public float Tolerance { get; set; } + + public float differ { get; set; } + + public short stand { get; set; } } } \ No newline at end of file