From 441698afe29e77c0507546452d7fc758bc01c4f8 Mon Sep 17 00:00:00 2001 From: nodyang Date: Thu, 26 Oct 2023 09:50:01 +0800 Subject: [PATCH 1/3] =?UTF-8?q?DB2105WriteHelper=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B9=B2=E6=B7=B7=E6=9C=BA=20=E6=B9=BF=E6=B7=B7=E6=9C=BA=20?= =?UTF-8?q?=E4=B8=8B=E6=96=99=20=E6=8B=8D=E5=86=B7=E7=83=AD=E6=B0=B4?= =?UTF-8?q?=E7=9A=84=E6=8C=89=E9=92=AE=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBHelpers/DB2105WriteHelper.cs | 210 +++++++++++++++++- 1 file changed, 209 insertions(+), 1 deletion(-) diff --git a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs index 0e6244d..ee20343 100644 --- a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs +++ b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace DataBlockHelper.DBHelpers { @@ -182,5 +183,212 @@ namespace DataBlockHelper.DBHelpers siemensS7Net.Write($"{DbName}:{start+4}.0", setValue.Toterance); } + + + /// + /// 点击下粉料按钮 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好 + /// + /// + public static bool WriteG1Pd() + { + return WriteG(94,3); + } + + public static bool WriteG1Cw() + { + return WriteG(94,4); + } + + public static bool WriteG1Hw() + { + return WriteG(94,5); + } + + + public static bool WriteG2Pd() + { + return WriteG(96,3); + } + + public static bool WriteG2Cw() + { + return WriteG(96,4); + } + + public static bool WriteG2Hw() + { + return WriteG(96,5); + } + + + + public static bool WriteG3Pd() + { + return WriteG(98,3); + } + + public static bool WriteG3Cw() + { + return WriteG(98,4); + } + + public static bool WriteG3Hw() + { + return WriteG(98,5); + } + + + public static bool WriteG4Pd() + { + return WriteG(100,3); + } + + public static bool WriteG4Cw() + { + return WriteG(100,4); + } + + public static bool WriteG4Hw() + { + return WriteG(100,5); + } + + + public static bool WriteG5Pd() + { + return WriteG(102,3); + } + + public static bool WriteG5Cw() + { + return WriteG(102,4); + } + + public static bool WriteG5Hw() + { + return WriteG(102,5); + } + + + public static bool WriteG6Pd() + { + return WriteG(104,3); + } + + public static bool WriteG6Cw() + { + return WriteG(104,4); + } + + public static bool WriteG6Hw() + { + return WriteG(104,5); + } + + + public static bool WriteG7Pd() + { + return WriteG(106,3); + } + + public static bool WriteG7Cw() + { + return WriteG(106,4); + } + + public static bool WriteG7Hw() + { + return WriteG(106,5); + } + + + public static bool WriteG8Pd() + { + return WriteG(108,3); + } + + public static bool WriteG8Cw() + { + return WriteG(108,4); + } + + public static bool WriteG8Hw() + { + return WriteG(108,5); + } + + + /// + /// 点击下粉料按钮 湿混机 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好 + /// + /// + + public static bool WriteM1() + { + return WriteM(110); + } + + public static bool WriteM2() + { + return WriteM(112); + } + + public static bool WriteM3() + { + return WriteM(114); + } + public static bool WriteM4() + { + return WriteM(116); + } + public static bool WriteM5() + { + return WriteM(118); + } + public static bool WriteM6() + { + return WriteM(120); + } + public static bool WriteM7() + { + return WriteM(122); + } + + public static bool WriteM8() + { + return WriteM(124); + } + + + + private static bool WriteG(int start,int dian) + { + var siemensS7Net = PlcConnect.Instance; + var operateResult = siemensS7Net.ReadBool($"{DbName}.{start}.{dian}"); + if (!operateResult.Content) + { + return false; + } + + var operate= siemensS7Net.Write($"{DbName}.{start}.{dian-3}", true); + return operate.IsSuccess; + } + + + private static bool WriteM(int start) + { + var siemensS7Net = PlcConnect.Instance; + var operateResult = siemensS7Net.ReadBool($"{DbName}.{start}.1"); + if (!operateResult.Content) + { + return false; + } + + var operate= siemensS7Net.Write($"{DbName}.{start}.0", true); + return operate.IsSuccess; + } + + + } } \ No newline at end of file From f5b934fdb49b2651cfe17f7dc41df159c258404c Mon Sep 17 00:00:00 2001 From: nodyang Date: Thu, 26 Oct 2023 09:53:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?GetCodeById=20=E4=BF=AE=E5=A4=8D=E4=B8=8D?= =?UTF-8?q?=E7=AD=89=E4=BA=8E0=20=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoControl/DB/StockMaterrialDBHelp.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs index ed8f400..c25e60e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs @@ -75,9 +75,16 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB public static int GetCodeById(int id) { - string sql = $"select Code from lj_stock_material where Id={id}"; - var dataTable = DBHelp.GetTable(sql); - return Convert.ToInt16(dataTable.Rows[0][0]); + + if (id > 0) + { + string sql = $"select Code from lj_stock_material where Id={id}"; + var dataTable = DBHelp.GetTable(sql); + return Convert.ToInt16(dataTable.Rows[0][0]); + } + + return id; + } From 1e30a7d07a1501bbf39bd95d38327da651b21862 Mon Sep 17 00:00:00 2001 From: nodyang Date: Thu, 26 Oct 2023 09:54:19 +0800 Subject: [PATCH 3/3] GetCodeById --- .../AutoControl/DB/StockMaterrialDBHelp.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs index c25e60e..be1644b 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/AutoControl/DB/StockMaterrialDBHelp.cs @@ -80,7 +80,13 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB { string sql = $"select Code from lj_stock_material where Id={id}"; var dataTable = DBHelp.GetTable(sql); - return Convert.ToInt16(dataTable.Rows[0][0]); + if (dataTable.Rows.Count == 1) + { + return Convert.ToInt16(dataTable.Rows[0][0]); + } + + return id; + } return id;