From c5313427524f3fda7d2bc0255e712ef93c397b8f 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, 13 Dec 2023 09:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=95=B0=E6=8D=AE=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoControl/AutoControl.cs | 14 +- .../AutoControl/PlcAutoWriteHelper.cs | 145 ++++++++++-------- DataBlockHelper/DBHelpers/DB2104Helper.cs | 1 - DataBlockHelper/PlcConnect.cs | 19 ++- 4 files changed, 99 insertions(+), 80 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs index 67e41f3..e474dbf 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/AutoControl.cs @@ -246,13 +246,13 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl //手动加糊化料 if (ButtonE.WetManualGel == runtime.Sender) { - if (MessageBox.Show("请使用手动加料", "请使用手动加料", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + if (MessageBox.Show("糊化机打成手动 然后开门放料", "请使用手动加料", MessageBoxButtons.OK, MessageBoxIcon.Question) == DialogResult.No) { return; } return; - + //bool isReady = WetGelatDownload(RadioE); @@ -276,11 +276,15 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl return; } - WetGelatDownload(TextE, RadioE); + bool b= WetGelatDownload(TextE, RadioE); + if (b) + { + LjLogControl.ManualLogControl("手动下冷水", 3, Convert.ToInt32(TextE.ManualWeight.MCValue.ToString()), ControlsHelper.SingleSelect(RadioE), 2); - LjLogControl.ManualLogControl("手动下冷水", 3, Convert.ToInt32(TextE.ManualWeight.MCValue.ToString()), ControlsHelper.SingleSelect(RadioE), 2); + MessageBox.Show("数据下传成功!"); + } - MessageBox.Show("数据下传成功!"); + } if(ButtonE.WetManualControlStop== runtime.Sender) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs index e1300d4..fe30380 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/PlcAutoWriteHelper.cs @@ -714,7 +714,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl #region 湿混机手动下粉料 - public static void WetGelatDownload(MCTextBoxEntity TextE, MCRadioButtonEntity RadioE) + public static bool WetGelatDownload(MCTextBoxEntity TextE, MCRadioButtonEntity RadioE) { float t = Convert.ToSingle(TextE.ManualTolerance.MCValue.ToString()); float w = Convert.ToSingle(TextE.ManualWeight.MCValue.ToString()); @@ -722,7 +722,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (t < 0.1) { MessageBox.Show("公差不能小于0.1!"); - return; + return false; } SetValue value = new SetValue() @@ -732,7 +732,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl }; DB2105Helper dB2105= new DB2105Helper(); - + bool run = false; var singE = ControlsHelper.SingleSelect(RadioE); switch (singE) { @@ -742,7 +742,8 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (h1.RunStatus) { ShowError(); - return; + run = true; + } break; @@ -752,7 +753,8 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (h2.RunStatus) { ShowError(); - return; + run = true; + } break; @@ -762,7 +764,8 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (h3.RunStatus) { ShowError(); - return; + run = true; + } break; @@ -773,78 +776,88 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl if (h4.RunStatus) { ShowError(); - return; + run = true; + } break; } - - switch (singE) + if (run == false) { - case 1: - - PowderDownSignel(MinAnPlc.Heir1, 1); - DB2105WriteHelper.WriteSetValueH1(value); - DB2105WriteHelper.WriteH(1, "L", true); - // DB2105WriteHelper.WriteManScrewH1(); - - break; - case 2: - PowderDownSignel(MinAnPlc.Heir1, 1); - DB2105WriteHelper.WriteSetValueH1(value); - DB2105WriteHelper.WriteH(1, "R", true); - // DB2105WriteHelper.WriteManScrewH2(); - - break; - case 3: - PowderDownSignel(MinAnPlc.Heir2, 2); - DB2105WriteHelper.WriteSetValueH2(value); - DB2105WriteHelper.WriteH(2, "L", true); - // DB2105WriteHelper.WriteManScrewH3(); - - break; - case 4: - PowderDownSignel(MinAnPlc.Heir2, 2); - DB2105WriteHelper.WriteSetValueH2(value); - DB2105WriteHelper.WriteH(2, "R", true); - // DB2105WriteHelper.WriteManScrewH4(); + switch (singE) + { + case 1: + + PowderDownSignel(MinAnPlc.Heir1, 1); + DB2105WriteHelper.WriteSetValueH1(value); + DB2105WriteHelper.WriteH(1, "L", true); + // DB2105WriteHelper.WriteManScrewH1(); + + break; + case 2: + PowderDownSignel(MinAnPlc.Heir1, 1); + DB2105WriteHelper.WriteSetValueH1(value); + DB2105WriteHelper.WriteH(1, "R", true); + // DB2105WriteHelper.WriteManScrewH2(); + + break; + case 3: + PowderDownSignel(MinAnPlc.Heir2, 2); + DB2105WriteHelper.WriteSetValueH2(value); + DB2105WriteHelper.WriteH(2, "L", true); + // DB2105WriteHelper.WriteManScrewH3(); + + break; + case 4: + PowderDownSignel(MinAnPlc.Heir2, 2); + DB2105WriteHelper.WriteSetValueH2(value); + DB2105WriteHelper.WriteH(2, "R", true); + // DB2105WriteHelper.WriteManScrewH4(); + + break; + case 5: + PowderDownSignel(MinAnPlc.Heir3, 3); + DB2105WriteHelper.WriteSetValueH3(value); + DB2105WriteHelper.WriteH(3, "L", true); + //DB2105WriteHelper.WriteManScrewH5(); + + break; + case 6: + PowderDownSignel(MinAnPlc.Heir3, 3); + DB2105WriteHelper.WriteSetValueH3(value); + + DB2105WriteHelper.WriteH(3, "R", true); + // DB2105WriteHelper.WriteManScrewH6(); + break; + case 7: + PowderDownSignel(MinAnPlc.Heir4, 4); + DB2105WriteHelper.WriteSetValueH4(value); + DB2105WriteHelper.WriteH(4, "L", true); + // DB2105WriteHelper.WriteManScrewH7(); + + break; + case 8: + PowderDownSignel(MinAnPlc.Heir4, 4); + DB2105WriteHelper.WriteSetValueH4(value); + DB2105WriteHelper.WriteH(4, "R", true); + //DB2105WriteHelper.WriteManScrewH8(); + + break; + default: + MessageBox.Show("当前未选择产线!"); + return false; + } - break; - case 5: - PowderDownSignel(MinAnPlc.Heir3, 3); - DB2105WriteHelper.WriteSetValueH3(value); - DB2105WriteHelper.WriteH(3, "L", true); - //DB2105WriteHelper.WriteManScrewH5(); + ManualWeightLog(w, t, RadioE); - break; - case 6: - PowderDownSignel(MinAnPlc.Heir3, 3); - DB2105WriteHelper.WriteSetValueH3(value); - DB2105WriteHelper.WriteH(3, "R", true); - // DB2105WriteHelper.WriteManScrewH6(); - break; - case 7: - PowderDownSignel(MinAnPlc.Heir4, 4); - DB2105WriteHelper.WriteSetValueH4(value); - DB2105WriteHelper.WriteH(4, "L", true); - // DB2105WriteHelper.WriteManScrewH7(); + return true; - break; - case 8: - PowderDownSignel(MinAnPlc.Heir4, 4); - DB2105WriteHelper.WriteSetValueH4(value); - DB2105WriteHelper.WriteH(4,"R", true); - //DB2105WriteHelper.WriteManScrewH8(); - - break; - default: - MessageBox.Show("当前未选择产线!"); - return; } - ManualWeightLog(w, t, RadioE); + return false; + } diff --git a/DataBlockHelper/DBHelpers/DB2104Helper.cs b/DataBlockHelper/DBHelpers/DB2104Helper.cs index 1fd2616..66841c0 100644 --- a/DataBlockHelper/DBHelpers/DB2104Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2104Helper.cs @@ -82,7 +82,6 @@ namespace DataBlockHelper.DBHelpers private WaterEntity GetWater(int start) { var instanceByteTransform = PlcConnect.Instance.ByteTransform; - var ls = this.bytes = PlcConnect.Instance.Read($"DB2104.{start}.0", 16).Content; WaterEntity entity = new WaterEntity { diff --git a/DataBlockHelper/PlcConnect.cs b/DataBlockHelper/PlcConnect.cs index 98c6a99..85fc4cc 100644 --- a/DataBlockHelper/PlcConnect.cs +++ b/DataBlockHelper/PlcConnect.cs @@ -27,19 +27,22 @@ namespace DataBlockHelper SiemensPLCS siemensPLCS = SiemensPLCS.S1500; SiemensS7Net s7 = new SiemensS7Net(siemensPLCS); s7.SetPersistentConnection(); - s7.IpAddress = "172.18.4.100"; + // s7.IpAddress = "172.18.4.100"; + + + s7.IpAddress = "192.168.1.110"; s7.Port = 102; var su = s7.ConnectServer(); if (!su.IsSuccess) { - s7.IpAddress = "192.168.0.100"; - s7.Port = 7788; - var fn = s7.ConnectServer(); - if (!fn.IsSuccess) - { - return new SiemensS7Net(siemensPLCS); - } + //s7.IpAddress = "192.168.0.100"; + //s7.Port = 7788; + //var fn = s7.ConnectServer(); + //if (!fn.IsSuccess) + //{ + // return new SiemensS7Net(siemensPLCS); + //} } return s7;