From f03460bbdc610d65024a8c9f0da4c594b6ad3fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Thu, 14 Dec 2023 15:01:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=B4=E7=A7=B0=E5=92=8C=E7=B2=89=E6=96=99?= =?UTF-8?q?=E7=9A=84=E7=A7=B0=E9=87=8F=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Report/ReportReadDb.cs | 123 +++++++++++++++--- .../Test/TestAction.cs | 7 +- .../DBHelpers/DB2107WriteHelper.cs | 26 ++++ DataBlockHelper/DBHelpers/DB2111Helper.cs | 1 + DataBlockHelper/DBHelpers/DB2111Writer.cs | 13 ++ DataBlockHelper/DataBlockHelper.csproj | 2 + .../Entity/DB2107Entity/NormalStatusEntity.cs | 12 ++ Main/MCEdit/Data/MCProject/nodeDataSource.xml | 2 +- 8 files changed, 164 insertions(+), 22 deletions(-) create mode 100644 DataBlockHelper/DBHelpers/DB2107WriteHelper.cs create mode 100644 DataBlockHelper/DBHelpers/DB2111Writer.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs index 206a36c..53f79f8 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs @@ -2,6 +2,7 @@ using DataBlockHelper.DBHelpers; using DataBlockHelper.Entity.DB2106Entity; using DataBlockHelper.Entity.DB2107Entity; +using DataBlockHelper.Entity.DB2111Entity; using DevExpress.Utils.Extensions; using DevExpress.XtraPrinting; @@ -35,27 +36,109 @@ namespace Mesnac.Action.ChemicalWeighing.Report /// public static void ReadFeededDry() { - + DB2107Helper dB2107Helper = new DB2107Helper(); + var nornalStatus = dB2107Helper.NormalStatus; + DB2111Helper dB2111Helper = new DB2111Helper(); + //黑粉准备好信号 + if (nornalStatus.spare1) + { + FeededDry(1, dB2111Helper.DryDosing_A); + } - DB2105Helper dB2105Helper = new DB2105Helper(); - List list = dB2105Helper.FeededDryList(); - for (int i = 0; i < list.Count; i++) + if (nornalStatus.spare2) { - if (list[i]) - { - var feedValue = new DB2107Helper().Weter[i].FeedValue.ToString("0.#"); - LoggingService.Debug($"{i + 1}:{feedValue}"); - var deviceno = (i + 3) / 2; - // 螺旋1启动向湿混机1 - string logName = $"螺旋{deviceno}向湿混机实际{i + 1}"; - LoggingService.Info(logName); - var value = Convert.ToInt32(Convert.ToDouble(feedValue)); - LjLogControl.ManualLogControl(logName, value, 4, i + 1, 2); - DB2105WriteHelper.WriteFalseFeededDry(i + 1); - } + FeededDry(2, dB2111Helper.DryDosing_B); + } + + if (nornalStatus.spare3) + { + FeededDry(3, dB2111Helper.DryDosing_C); + } + + if (nornalStatus.spare4) + { + FeededDry(4, dB2111Helper.DryDosing_D); + } + + + //水 + if (nornalStatus.RdyRpt_W1) + { + FeededWaterHA(dB2111Helper.hwReport_A); + } + + if (nornalStatus.RdyRpt_W2) + { + FeededWaterCA(dB2111Helper.cwReport_A); + } + + //热水B + if (nornalStatus.RdyRpt_W3) + { + FeededWaterHB(dB2111Helper.hwReport_B); + } + if (nornalStatus.RdyRpt_W4) + { + FeededWaterCB(dB2111Helper.cwReport_B); } } + + + //热水A + private static void FeededWaterHA(ReportDosEntity entity) + { + var actValue = Convert.ToInt32(entity.actValue); + string logName = $"热水秤A向 [{entity.eqNo}] 加水 {actValue}"; + LoggingService.Info(logName); + LjLogControl.ManualLogControl(logName, actValue, 2, entity.eqNo, 1); + DB2107WriteHelper.CleanWater(1); + } + + private static void FeededWaterCA(ReportDosEntity entity) + { + var actValue = Convert.ToInt32(entity.actValue); + string logName = $"冷水秤A向 [{entity.eqNo}] 加水 {actValue}"; + LoggingService.Info(logName); + LjLogControl.ManualLogControl(logName, actValue, 2, entity.eqNo, 1); + DB2107WriteHelper.CleanWater(2); + } + + + private static void FeededWaterHB(ReportDosEntity entity) + { + var actValue = Convert.ToInt32(entity.actValue); + string logName = $"热水秤B向 [{entity.eqNo+4}] 加水 {actValue}"; + LoggingService.Info(logName); + LjLogControl.ManualLogControl(logName, actValue, 2, entity.eqNo+4, 1); + DB2107WriteHelper.CleanWater(3); + } + + private static void FeededWaterCB(ReportDosEntity entity) + { + var actValue = Convert.ToInt32(entity.actValue); + string logName = $"冷水秤B向 [{entity.eqNo + 4}] 加水 {actValue}"; + LoggingService.Info(logName); + LjLogControl.ManualLogControl(logName, actValue, 2, entity.eqNo + 4, 1); + DB2107WriteHelper.CleanWater(4); + } + + + private static void FeededDry(int deviceno, ReportDosEntity entity) + { + + int no = deviceno * 2; + if (entity.eqNo == 1) + { + no = deviceno-1; + } + var actValue = Convert.ToInt32(entity.actValue); + string logName = $"螺旋{deviceno}向湿混机 [{no}] 投料 {actValue}"; + LoggingService.Info(logName); + LjLogControl.ManualLogControl(logName, actValue, 4, no, 2); + DB2107WriteHelper.CleanSpare(deviceno); + } + public static void ReadReport() { @@ -483,8 +566,12 @@ namespace Mesnac.Action.ChemicalWeighing.Report break; } } - FreeSqlUnit.Instance.Insert(report).ExecuteAffrows(); - FreeSqlUnit.Instance.Insert(lde).ExecuteAffrows(); + + if(lde.Count > 0) + { + FreeSqlUnit.Instance.Insert(report).ExecuteAffrows(); + FreeSqlUnit.Instance.Insert(lde).ExecuteAffrows(); + } } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs index f2222b7..ccc7493 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs @@ -43,7 +43,8 @@ namespace Mesnac.Action.ChemicalWeighing.Test public void theout(object source, EventArgs e) { - + LoggingService.InfoFormatted("定时器开始运行"); + ReportReadDb.ReadReport(); } public void Run(RuntimeParameter runtime) @@ -69,7 +70,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test mCButton.Click += MCButton_Click; - System.Timers.Timer t = new System.Timers.Timer(5000);//实例化Timer类,设置间隔时间为10000毫秒; + System.Timers.Timer t = new System.Timers.Timer(1000*20);//实例化Timer类,设置间隔时间为10000毫秒; t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件; t.AutoReset = true;//设置是执行一次(false)还是一直执行(true); t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件; @@ -78,7 +79,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test private void MCButton_Click(object sender, EventArgs e) { - // ReportReadDb.ReadFeededDry(); + ReportReadDb.ReadFeededDry(); var list= DB2105WriteHelper.GetWaterStatus(); } diff --git a/DataBlockHelper/DBHelpers/DB2107WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2107WriteHelper.cs new file mode 100644 index 0000000..d3843b9 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2107WriteHelper.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2107WriteHelper + { + static string DbName = "DB2107"; + public static void CleanSpare(int no) + { + int dian = no + 1; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.8.{dian}", false); + } + + public static void CleanWater(int no) + { + int dian = no + 1; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.5.{dian}", false); + } + } +} diff --git a/DataBlockHelper/DBHelpers/DB2111Helper.cs b/DataBlockHelper/DBHelpers/DB2111Helper.cs index ca8352a..c2524be 100644 --- a/DataBlockHelper/DBHelpers/DB2111Helper.cs +++ b/DataBlockHelper/DBHelpers/DB2111Helper.cs @@ -19,6 +19,7 @@ namespace DataBlockHelper.DBHelpers public ReportDosEntity hwReport_B => new ReportDosEntity(bytes, 1528); public ReportDosEntity cwReport_A => new ReportDosEntity(bytes, 1550); public ReportDosEntity cwReport_B => new ReportDosEntity(bytes, 1572); + public ReportDosEntity DryDosing_A => new ReportDosEntity(bytes, 1594); public ReportDosEntity DryDosing_B => new ReportDosEntity(bytes, 1616); public ReportDosEntity DryDosing_C => new ReportDosEntity(bytes, 1638); diff --git a/DataBlockHelper/DBHelpers/DB2111Writer.cs b/DataBlockHelper/DBHelpers/DB2111Writer.cs new file mode 100644 index 0000000..ff9f181 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2111Writer.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2111Writer + { + + } +} diff --git a/DataBlockHelper/DataBlockHelper.csproj b/DataBlockHelper/DataBlockHelper.csproj index 4bf9b1b..e89be44 100644 --- a/DataBlockHelper/DataBlockHelper.csproj +++ b/DataBlockHelper/DataBlockHelper.csproj @@ -56,7 +56,9 @@ + + diff --git a/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs b/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs index 1130597..1fc71b2 100644 --- a/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs +++ b/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs @@ -61,6 +61,12 @@ namespace DataBlockHelper.Entity.DB2107Entity RdyRpt_M7 = byt.GetBit(0); RdyRpt_M8 = byt.GetBit(1); + + spare1= byt.GetBit(2); + spare2 = byt.GetBit(3); + spare3 = byt.GetBit(4); + spare4 = byt.GetBit(5); + } public int WatchDog { get; private set; } @@ -98,5 +104,11 @@ namespace DataBlockHelper.Entity.DB2107Entity public bool RdyRpt_M6 { get; private set; } public bool RdyRpt_M7 { get; private set; } public bool RdyRpt_M8 { get; private set; } + + + public bool spare1 { get; private set; } + public bool spare2 { get; private set; } + public bool spare3 { get; private set; } + public bool spare4 { get; private set; } } } diff --git a/Main/MCEdit/Data/MCProject/nodeDataSource.xml b/Main/MCEdit/Data/MCProject/nodeDataSource.xml index 3600a0d..3c73a6a 100644 --- a/Main/MCEdit/Data/MCProject/nodeDataSource.xml +++ b/Main/MCEdit/Data/MCProject/nodeDataSource.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file