From 6748c7fe4cdf0491aeb1acbc8dfa6e91928e1881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sat, 9 Dec 2023 19:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B2=E6=B7=B7=E6=9C=BA=E7=A7=B0=E9=87=8F?= =?UTF-8?q?=E5=87=86=E5=A4=87=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Report/ReportReadDb.cs | 68 +++++++++++++++++++ .../Test/TestAction.cs | 11 ++- DataBlockHelper/DBHelpers/DB2105Helper.cs | 36 +++++++++- .../DBHelpers/DB2105WriteHelper.cs | 16 +++++ 4 files changed, 123 insertions(+), 8 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs index 87f8938..b3f936f 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Report/ReportReadDb.cs @@ -4,12 +4,19 @@ using DataBlockHelper.Entity.DB2106Entity; using DataBlockHelper.Entity.DB2107Entity; using DevExpress.Utils.Extensions; +using DevExpress.XtraPrinting; + +using HslCommunication.Enthernet; using ICSharpCode.Core; +using Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm; +using Mesnac.Action.ChemicalWeighing.Entity; using Mesnac.Action.ChemicalWeighing.FreeDb; using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity; using Mesnac.Action.ChemicalWeighing.FreeDb.DBEntity.Report; +using Mesnac.Action.ChemicalWeighing.ManualControl; +using Mesnac.Basic; using System; using System.Collections.Generic; @@ -22,6 +29,67 @@ namespace Mesnac.Action.ChemicalWeighing.Report { public class ReportReadDb { + + + /// + /// 干混料插入日志 + /// + public static void ReadFeededDry() + { + LoggingService.Debug("读取加料信息"+DateTime.Now.ToString()); + + DB2105Helper dB2105Helper = new DB2105Helper(); + List list=dB2105Helper.FeededDryList(); + for (int i = 0; i < list.Count; i++) + { + 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)); + + ManualLogControl(logName, value, 5, i + 1); + + DB2105WriteHelper.WriteFalseFeededDry(i + 1); + } + } + } + + /// + /// 日志插入 + /// + /// 日志内容 + /// 值 + /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值 + /// 设备编号 + /// 设备类型 0无 1水称 2螺旋 + private static void ManualLogControl(string logName, int value, int valuekind, int deviceno) + { + var Log = new ManualLogEntity() + { + logtext = logName, + logtime = DateTime.Now, + userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, + value = value, + deviceno = deviceno, + devicekind = 2, + valuekind = valuekind, + createdate = DateTime.Now.ToString("yyyyMMdd") + }; + + FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); + + + } + + public static void Read() { LoggingService.InfoFormatted("开始读取报表"); diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs index ee0d65f..bf205f1 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs @@ -43,7 +43,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test public void theout(object source, EventArgs e) { - // ReportReadDb.Read(); + } public void Run(RuntimeParameter runtime) @@ -60,14 +60,11 @@ namespace Mesnac.Action.ChemicalWeighing.Test this.hslMove.ForeColor = Color.Yellow; this.hslMove.Margin = new Padding(5, 6, 5, 6); - this.hslMove.MoveSpeed = 20f; + this.hslMove.MoveSpeed = 2f; this.hslMove.Size = new Size(726, 49); this.hslMove.TabIndex = 8; - this.hslMove.Text = @"公告:这是一条测试的公告信息11111111111111111111111111111111111111111111111111111111111" + - "1111111111111112312321" + - "3213213213213" + - "3213333333333333333311111。"; + this.hslMove.Text = @"公告:这是一条测试的公告信息"; mCButton.Click += MCButton_Click; @@ -81,7 +78,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test private void MCButton_Click(object sender, EventArgs e) { - new HttpResponse().GetLGInfo(); + ReportReadDb.ReadFeededDry(); } } } diff --git a/DataBlockHelper/DBHelpers/DB2105Helper.cs b/DataBlockHelper/DBHelpers/DB2105Helper.cs index 7437c2c..fe21e55 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", 126).Content; + this.bytes = PlcConnect.Instance.Read("DB2105.0.0", 134).Content; } public List Plan => new PlanArrayManager(4, 0, 12, bytes).GetList(); public bool[] Status => new FourBoolArrayManager(48, bytes).GetList(); @@ -144,6 +144,28 @@ namespace DataBlockHelper.DBHelpers public bool ReadReadyM8 => ReadReadyM(124); + /// + /// M1 + /// + + public bool FeededDry => ReadReady(110, 4); + + /// + /// 获取所有的 feededDry 是不是读取好了 + /// + /// + public List FeededDryList() + { + List ls = new List(8); + + for (int i = 110; i <=124; i=i+2) + { + ls.Add(ReadReady(i, 4)); + } + return ls; + } + + //94 public List ReadReady(int start) { @@ -165,6 +187,14 @@ namespace DataBlockHelper.DBHelpers var first = bytes.Skip(start).Take(1).First(); return first.GetBit(1); } + + + + public bool ReadReady(int start,int bit) + { + var first = bytes.Skip(start).Take(1).First(); + return first.GetBit(bit); + } } @@ -185,4 +215,8 @@ namespace DataBlockHelper.DBHelpers + + + + } diff --git a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs index 364ed1a..f09d9a5 100644 --- a/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs +++ b/DataBlockHelper/DBHelpers/DB2105WriteHelper.cs @@ -388,6 +388,22 @@ namespace DataBlockHelper.DBHelpers var operate= siemensS7Net.Write($"{DbName}.{start}.0", true); return operate.IsSuccess; } + + + /// + /// 传入机台1~8 自动清零 + /// + /// + /// + public static bool WriteFalseFeededDry(int no) + { + int start = 110; + int n = start+((no - 1)*2); + var siemensS7Net = PlcConnect.Instance; + + var operate = siemensS7Net.Write($"{DbName}.{n}.4", false); + return operate.IsSuccess; + }