From 9c0b8000e65d9a56c17099d019aa441f3d24991d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Tue, 16 Jan 2024 16:34:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E4=BD=8E=E6=96=99=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LjDeliver/DeliverInitAction.cs | 53 ++++++++++++ .../LjDeliver/Entity/DeliverEntity.cs | 2 +- DataBlockHelper/DBHelpers/DB139Helper.cs | 81 +++++++++++++++++++ DataBlockHelper/DataBlockHelper.csproj | 1 + 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 DataBlockHelper/DBHelpers/DB139Helper.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs index 1af8b51..2f33d44 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/DeliverInitAction.cs @@ -198,8 +198,61 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliver DBOtherSetData(); AlarmControl(); + SetSilo(); } + /// + /// 显示高低料位 + /// + public void SetSilo() + { + var db139 = new DB139Helper(); + // ControlsImprot.SetSwitchLight + var obj = SwitchlightE.HSiloA; + var list= db139.LowLevel; + + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloA, list[0]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloB, list[1]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloC, list[2]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloD, list[3]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloE, list[4]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloF, list[5]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloG, list[6]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloH, list[7]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloI, list[8]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloJ, list[9]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloK, list[10]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloL, list[11]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloM, list[12]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloM, list[13]); + ControlsImprot.SetSwitchLight(SwitchlightE.LSiloO, list[14]); + + + list = db139.HowLevel; + + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloA, list[0]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloB, list[1]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloC, list[2]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloD, list[3]); + + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloE, list[4]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloF, list[5]); + + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloG, list[6]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloH, list[7]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloI, list[8]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloJ, list[9]); + + //ControlsImprot.SetSwitchLight(SwitchlightE.LSiloK, list[10]); + //ControlsImprot.SetSwitchLight(SwitchlightE.LSiloL, list[11]); + //ControlsImprot.SetSwitchLight(SwitchlightE.LSiloM, list[12]); + //ControlsImprot.SetSwitchLight(SwitchlightE.LSiloM, list[13]); + ControlsImprot.SetSwitchLight(SwitchlightE.HSiloO, list[10]); + + + } + + #region plc读取前端控件值写入 private void DB1GetData() diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/Entity/DeliverEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/Entity/DeliverEntity.cs index 7090a71..d5522be 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/Entity/DeliverEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliver/Entity/DeliverEntity.cs @@ -191,7 +191,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliver.Entity public SwitchLight HSiloB { get; set; } public SwitchLight HSiloC { get; set; } public SwitchLight HSiloD { get; set; } - public SwitchLight HSiloE { get; set; } + public SwitchLight HSiloE { get; set; } public SwitchLight HSiloF { get; set; } public SwitchLight HSiloG { get; set; } public SwitchLight HSiloH { get; set; } diff --git a/DataBlockHelper/DBHelpers/DB139Helper.cs b/DataBlockHelper/DBHelpers/DB139Helper.cs new file mode 100644 index 0000000..7038e4c --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB139Helper.cs @@ -0,0 +1,81 @@ +using HslCommunication; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB139Helper: DBHelper + { + public DB139Helper() + { + + OperateResult db = PlcConnect.Instance.Read("DB139.0.0", 32); + bytes = db.Content; + } + + + public List LowLevel + { + + get + { + List result = new List(); + byte[] content = bytes.Skip(0).Take(2).ToArray(); + var con = content[0]; + result.Add(con.GetBit(0)); + result.Add(con.GetBit(1)); + result.Add(con.GetBit(2)); + result.Add(con.GetBit(3)); + result.Add(con.GetBit(4)); + result.Add(con.GetBit(5)); + result.Add(con.GetBit(6)); + result.Add(con.GetBit(7)); + con = content[1]; + result.Add(con.GetBit(0)); + result.Add(con.GetBit(1)); + result.Add(con.GetBit(2)); + result.Add(con.GetBit(3)); + result.Add(con.GetBit(4)); + result.Add(con.GetBit(5)); + result.Add(con.GetBit(6)); + + return result; + } + } + + + + public List HowLevel + { + + get + { + + OperateResult db = PlcConnect.Instance.Read("M1023.0", 2); + + List result = new List(); + byte[] content = db.Content.ToArray(); + var con = content[0]; + result.Add(con.GetBit(0)); + result.Add(con.GetBit(1)); + result.Add(con.GetBit(2)); + result.Add(con.GetBit(3)); + result.Add(con.GetBit(4)); + result.Add(con.GetBit(5)); + result.Add(con.GetBit(6)); + result.Add(con.GetBit(7)); + con = content[1]; + result.Add(con.GetBit(0)); + result.Add(con.GetBit(1)); + result.Add(con.GetBit(2)); + + + return result; + } + } + } +} diff --git a/DataBlockHelper/DataBlockHelper.csproj b/DataBlockHelper/DataBlockHelper.csproj index 5d3f56b..4b3bc2f 100644 --- a/DataBlockHelper/DataBlockHelper.csproj +++ b/DataBlockHelper/DataBlockHelper.csproj @@ -54,6 +54,7 @@ +