From f96ab5dfecb8e767bc190951e4a3afce732d56ba Mon Sep 17 00:00:00 2001 From: wangsr Date: Fri, 27 Oct 2023 15:30:09 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E8=87=AA=E5=8A=A8=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=94=B9=E5=8F=98=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/GelerWeterControlsEntity.cs | 17 +- .../AutoControl/GelerWeterControl.cs | 42 +++- .../AutoControl/InitAction.cs | 66 ++++- DataBlockHelper/DBHelpers/DB2105Helper.cs | 2 +- .../Data/MCProject/nodeForm/AutoControlC.xml | 232 +++--------------- 5 files changed, 136 insertions(+), 223 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs index 527fe78..14b1c4d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/Entity/GelerWeterControlsEntity.cs @@ -41,14 +41,15 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity public IBaseControl WetOutDelayTime { get; set; } public IBaseControl ManualWeight { get; set; } public IBaseControl ManualTolerance { get; set; } - public IBaseControl State1 { get; set; } - public IBaseControl State2 { get; set; } - public IBaseControl State3 { get; set; } - public IBaseControl State4 { get; set; } - public IBaseControl State5 { get; set; } - public IBaseControl State6 { get; set; } - public IBaseControl State7 { get; set; } - public IBaseControl State8 { get; set; } + + public MCLabel State1 { get; set; } + public MCLabel State2 { get; set; } + public MCLabel State3 { get; set; } + public MCLabel State4 { get; set; } + public MCLabel State5 { get; set; } + public MCLabel State6 { get; set; } + public MCLabel State7 { get; set; } + public MCLabel State8 { get; set; } public Button WetManualControl { get; set; } public Button Download { get; set; } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs index 0a2b6a7..55afc38 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/GelerWeterControl.cs @@ -7,18 +7,12 @@ using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; using Mesnac.Action.ChemicalWeighing.LjMixManager; using Mesnac.Controls.Base; using Mesnac.Controls.Default; -using Mesnac.Core.Service; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using Mesnac.Controls.Default; using Button = System.Windows.Forms.Button; -using System.Data; using Mesnac.Action.ChemicalWeighing.LjPlanning; -using Steema.TeeChart.Functions; namespace Mesnac.Action.ChemicalWeighing.AutoControl { @@ -63,20 +57,40 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl int bin1 = Convert.ToInt32(ControlsEntity.ChooseMaterial1.MCValue.ToString()); int bin2 = Convert.ToInt32(ControlsEntity.ChooseMaterial2.MCValue.ToString()); - + List recipes = new List(); + float t1 = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString()); + float t2 = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString()); + + if(bin2 == -1) + { + if (t1 < 0.1) + { + MessageBox.Show("公差不能小于0.1!"); + return; + } + } + else + { + if (t1 < 0.1 || t2 < 0.1) + { + MessageBox.Show("公差不能小于0.1!"); + return; + } + } + RecipePlcView recipe1 = new RecipePlcView() { Bin = (short)StockMaterrialDbHelp.GetCodeById(bin1), Set = Convert.ToSingle(ControlsEntity.MaterialWeight1.MCValue.ToString()), - Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString()), + Tolerance = t1, }; RecipePlcView recipe2 = new RecipePlcView() { Bin = (short)StockMaterrialDbHelp.GetCodeById(bin2), Set = Convert.ToSingle(ControlsEntity.MaterialWeight2.MCValue.ToString()), - Tolerance = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString()), + Tolerance = t2, }; recipes.Add(recipe1); @@ -451,10 +465,18 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl return; } + float t = Convert.ToSingle(ControlsEntity.ManualTolerance.MCValue.ToString()); + + if (t < 0.1) + { + MessageBox.Show("公差不能小于0.1!"); + return; + } + SetValue value = new SetValue() { Value = Convert.ToSingle(ControlsEntity.ManualWeight.MCValue.ToString()), - Toterance = Convert.ToSingle(ControlsEntity.ManualTolerance.MCValue.ToString()) + Toterance = t }; switch (SingleSelect()) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs index 21b06b6..95c3142 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/InitAction.cs @@ -1,4 +1,5 @@ -using DevExpress.DataAccess.Wizard.Presenters; +using DataBlockHelper.DBHelpers; +using DevExpress.DataAccess.Wizard.Presenters; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.AutoControl.DB; using Mesnac.Action.ChemicalWeighing.AutoControl.Entity; @@ -51,9 +52,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl timer = new Timer(); timer.Interval = 1000; timer.Enabled = true; - //timer.Tick += new EventHandler(StateRefresh);//添加事件 + timer.Tick += new EventHandler(StateRefresh);//添加事件 } + #region 前端状态 + private void StateRefresh(object sender, EventArgs e) { if (GetAllDbMCControlsByOption(DbOptionTypes.QueryAndModify).Count == 0) @@ -62,7 +65,51 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl timer.Dispose(); } + DB2105Helper dB2105Helper = new DB2105Helper(); + + var startJob = dB2105Helper.GetStartJob; + + ControlsEntity.State1.MCValue = ConvertOnOff(startJob[0].Val); + ControlsEntity.State2.MCValue = ConvertOnOff(startJob[1].Val); + ControlsEntity.State3.MCValue = ConvertOnOff(startJob[2].Val); + ControlsEntity.State4.MCValue = ConvertOnOff(startJob[3].Val); + ControlsEntity.State5.MCValue = ConvertOnOff(startJob[4].Val); + ControlsEntity.State6.MCValue = ConvertOnOff(startJob[5].Val); + ControlsEntity.State7.MCValue = ConvertOnOff(startJob[6].Val); + ControlsEntity.State8.MCValue = ConvertOnOff(startJob[7].Val); + ControlsEntity.State1.BackColor = ConvertColor(startJob[0].Val); + ControlsEntity.State2.BackColor = ConvertColor(startJob[1].Val); + ControlsEntity.State3.BackColor = ConvertColor(startJob[2].Val); + ControlsEntity.State4.BackColor = ConvertColor(startJob[3].Val); + ControlsEntity.State5.BackColor = ConvertColor(startJob[4].Val); + ControlsEntity.State6.BackColor = ConvertColor(startJob[5].Val); + ControlsEntity.State7.BackColor = ConvertColor(startJob[6].Val); + ControlsEntity.State8.BackColor = ConvertColor(startJob[7].Val); + } + + private string ConvertOnOff(bool state) + { + if (state) + { + return "启动"; + } + else + { + return "停止"; + } + } + + private Color ConvertColor(bool state) + { + if (state) + { + return Color.LightGreen; + } + else + { + return Color.Transparent; + } } private void Mcradion_CheckedChanged(object sender, EventArgs e) @@ -76,9 +123,11 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl ControlsEntity.Line6.BackColor = backColor; ControlsEntity.Line7.BackColor = backColor; ControlsEntity.Line8.BackColor = backColor; - mCRadio.BackColor = Color.LightGreen; + mCRadio.BackColor = Color.LightSkyBlue; } + #endregion + /// /// 控件从Plc初始化 /// @@ -179,8 +228,17 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl ControlsEntity.Line7 = GetMCRadioButtonControl("Line7"); ControlsEntity.Line8 = GetMCRadioButtonControl("Line8"); + ControlsEntity.State1 = GetBaseControl("State1") as MCLabel; + ControlsEntity.State2 = GetBaseControl("State2") as MCLabel; + ControlsEntity.State3 = GetBaseControl("State3") as MCLabel; + ControlsEntity.State4 = GetBaseControl("State4") as MCLabel; + ControlsEntity.State5 = GetBaseControl("State5") as MCLabel; + ControlsEntity.State6 = GetBaseControl("State6") as MCLabel; + ControlsEntity.State7 = GetBaseControl("State7") as MCLabel; + ControlsEntity.State8 = GetBaseControl("State8") as MCLabel; + ControlsEntity.ChooseMaterial1 = GetBaseControl("ChooseMaterial1") as MCCombobox; - ControlsEntity.ChooseMaterial2 = GetBaseControl("ChooseMaterial2") as MCCombobox;; + ControlsEntity.ChooseMaterial2 = GetBaseControl("ChooseMaterial2") as MCCombobox; ControlsEntity.MaterialWeight1 = GetBaseControl("MaterialWeight1"); ControlsEntity.MaterialWeight2 = GetBaseControl("MaterialWeight2"); diff --git a/DataBlockHelper/DBHelpers/DB2105Helper.cs b/DataBlockHelper/DBHelpers/DB2105Helper.cs index d8e04dd..c64570d 100644 --- a/DataBlockHelper/DBHelpers/DB2105Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2105Helper.cs @@ -12,7 +12,7 @@ namespace DataBlockHelper.DBHelpers { public DB2105Helper() { - this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 52).Content; + this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 126).Content; } public List Plan => new PlanArrayManager(4, 0, 12, bytes).GetList(); public bool[] Status => new FourBoolArrayManager(48, bytes).GetList(); diff --git a/Main/MCEdit/Data/MCProject/nodeForm/AutoControlC.xml b/Main/MCEdit/Data/MCProject/nodeForm/AutoControlC.xml index 284e928..6df065f 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/AutoControlC.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/AutoControlC.xml @@ -77,8 +77,7 @@ - - + Red DarkGray @@ -91,34 +90,13 @@ None True True - - 825, 61 + 停止 + 807, 61 State8 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 776, 61 - MCLabel37 - 56, 16 + 40, 16 - - + Red DarkGray @@ -131,34 +109,13 @@ None True True - - 715, 61 + 停止 + 697, 61 State7 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 666, 61 - MCLabel39 - 56, 16 + 40, 16 - - + Red DarkGray @@ -171,34 +128,13 @@ None True True - - 605, 61 + 停止 + 587, 61 State6 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 556, 61 - MCLabel41 - 56, 16 + 40, 16 - - + Red DarkGray @@ -211,34 +147,13 @@ None True True - - 495, 61 + 停止 + 477, 61 State5 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 446, 61 - MCLabel43 - 56, 16 + 40, 16 - - + Red DarkGray @@ -251,34 +166,13 @@ None True True - - 385, 61 + 停止 + 367, 61 State4 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 336, 61 - MCLabel45 - 56, 16 + 40, 16 - - + Red DarkGray @@ -291,34 +185,13 @@ None True True - - 275, 61 + 停止 + 257, 61 State3 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 226, 61 - MCLabel47 - 56, 16 + 40, 16 - - + Red DarkGray @@ -331,34 +204,13 @@ None True True - - 165, 61 + 停止 + 147, 61 State2 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 116, 61 - MCLabel49 - 56, 16 + 40, 16 - - + Red DarkGray @@ -371,30 +223,10 @@ QueryAndModify True True - - 55, 61 + 停止 + 37, 61 State1 - 24, 16 - - - - - - Red - DarkGray - - - False - - - - None - True - True - 状态: - 6, 61 - MCLabel52 - 56, 16 + 40, 16