From a2c121bf611e6ec4245e08379954cf91fe3607d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Fri, 12 Jan 2024 14:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=9A=84=E7=82=B9=E5=87=BB=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ControlBoardButtonAction.cs | 48 ++++---- .../LjDeliverControlBoard/InitAction.cs | 30 +++++ DataBlockHelper/DBHelpers/DB191Helper.cs | 104 +++++++++++++++++- DataBlockHelper/DBHelpers/DB191WriteHelper.cs | 30 +++++ 4 files changed, 188 insertions(+), 24 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/ControlBoardButtonAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/ControlBoardButtonAction.cs index 4773892..e709454 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/ControlBoardButtonAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/ControlBoardButtonAction.cs @@ -195,7 +195,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard Convert.ToBoolean(RadioButtonE.StoreDC.MCValue) ); } - + //自动按钮 if (runtime.Sender == ButtonE.SwitchAutoMode) { string name = MotorSelect.Text; @@ -204,18 +204,19 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard return; } - string str = MotorSelect.MCValue.ToString(); - int value = Convert.ToInt32(str); - if (value <= 32) - { - ControlsHelper.WriteMode(str, false); - } - else - { - ControlsHelper.WriteMode(str, true); - } + int index = MotorSelect.SelectedIndex; + DB191WriteHelper.AddDianJi(index, false); + //int value = Convert.ToInt32(str); + //if (value <= 32) + //{ + // ControlsHelper.WriteMode(str, false); + //} + //else + //{ + // ControlsHelper.WriteMode(str, true); + //} } - + //点击手动 if (runtime.Sender == ButtonE.SwitchManualMode) { string name = MotorSelect.Text; @@ -224,16 +225,19 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard return; } - string str = MotorSelect.MCValue.ToString(); - int value = Convert.ToInt32(str); - if (value <= 32) - { - ControlsHelper.WriteMode(str, true); - } - else - { - ControlsHelper.WriteMode(str, false); - } + int index = MotorSelect.SelectedIndex; + DB191WriteHelper.AddDianJi(index, true); + + //string str = MotorSelect.MCValue.ToString(); + //int value = Convert.ToInt32(str); + //if (value <= 32) + //{ + // ControlsHelper.WriteMode(str, true); + //} + //else + //{ + // ControlsHelper.WriteMode(str, false); + //} } if (runtime.Sender == ButtonE.ManualModeOnOff) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/InitAction.cs index 3ff4bf1..6520eaf 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjDeliverControlBoard/InitAction.cs @@ -1,5 +1,7 @@ using DataBlockHelper; using DataBlockHelper.DBHelpers; +using DevExpress.XtraSplashScreen; + using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard.Entity; using Mesnac.Action.ChemicalWeighing.Util; @@ -290,6 +292,15 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard SetPanelC(); GetMotorStatus(); + GetMotorStatus2(); + try + { + if (GetAllControls().Count == 0) + { + timer.Stop(); + timer.Dispose(); + } + } finally {} } private void GetMotorStatus() @@ -312,6 +323,8 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard LabelE.NowMode.MCValue = "未设置"; } + + if (!byt.GetBit(2) && byt.GetBit(3)) { LabelE.NowManual.MCValue = "关闭"; @@ -381,6 +394,23 @@ namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard } } + + private void GetMotorStatus2() + { + int str = MotorSelect.SelectedIndex; + var dic= DB191.GetDianJi; + //1 手动 + if (dic[str]) + { + LabelE.NowMode.MCValue = "手动"; + } + else + { + LabelE.NowMode.MCValue = "自动"; + } + + + } private void SetPanelA() { ControlsImprot.SetSwitchLight(SwitchLightE.SGLAA, DB191.ControlPanel_A.siloGroupLamp1); diff --git a/DataBlockHelper/DBHelpers/DB191Helper.cs b/DataBlockHelper/DBHelpers/DB191Helper.cs index 57bff12..56b3ff3 100644 --- a/DataBlockHelper/DBHelpers/DB191Helper.cs +++ b/DataBlockHelper/DBHelpers/DB191Helper.cs @@ -9,9 +9,9 @@ namespace DataBlockHelper.DBHelpers { public class DB191Helper : DBHelper { - public DB191Helper() + public DB191Helper() { - bytes = PlcConnect.Instance.Read("DB191.0.0", 32).Content; + bytes = PlcConnect.Instance.Read("DB191.0.0", 33).Content; } public ControlPanelEntity ControlPanel_A => new ControlPanelEntity(0, bytes); @@ -23,6 +23,9 @@ namespace DataBlockHelper.DBHelpers public ForConveyorStep ConveyStep_C => new ForConveyorStep(20, bytes); + + + public bool[] GetVesselMode() { var content = bytes.Skip(24).Take(6).ToArray(); @@ -59,5 +62,102 @@ namespace DataBlockHelper.DBHelpers return bools; } + + + public Dictionary GetDianJi + { + get + { + DmAm dmAm = new DmAm(bytes); + Dictionary keys = new Dictionary(); + + keys.Add(0, dmAm.DM1GDP01); + keys.Add(1, dmAm.DM1ASIG01); + keys.Add(2, dmAm.DM1BSIG01); + keys.Add(3, dmAm.DM1CSIG01); + keys.Add(4, dmAm.DM1DSIG01); + keys.Add(5, dmAm.DM1ESIG01); + keys.Add(6, dmAm.DM1GDS01); + keys.Add(7, dmAm.DM1GDS02); + keys.Add(8, dmAm.DM1GDS03); + keys.Add(9, dmAm.DM1GDS04); + keys.Add(10, dmAm.DM1GDS05); + keys.Add(11, dmAm.DM1GDS06); + keys.Add(12, dmAm.DM1GDS09); + keys.Add(13, dmAm.DM1DSM01); + keys.Add(14, dmAm.DM2DSM01); + keys.Add(15, dmAm.DM3DSM01); + keys.Add(16, dmAm.DM1GDS12); + return keys; + + + + } + } + + + } + public class DmAm + { + + public DmAm(byte[] bytes) { + + var content = bytes.Skip(30).Take(3).ToArray(); + + byte byt = content[0]; + DM1GDP01=byt.GetBit(3); + DM1ASIG01 = byt.GetBit(4); + DM1BSIG01 = byt.GetBit(5); + DM1CSIG01=byt.GetBit(6); + DM1DSIG01 = byt.GetBit(7); + + byt = content[1]; + DM1ESIG01= byt.GetBit(0); + + DM1GDS01 = byt.GetBit(1); + DM1GDS02 = byt.GetBit(2); + DM1GDS03 = byt.GetBit(3); + DM1GDS04 = byt.GetBit(4); + DM1GDS05 = byt.GetBit(5); + DM1GDS06 = byt.GetBit(6); + DM1GDS09 = byt.GetBit(7); + + byt = content[2]; + DM1DSM01 = byt.GetBit(0); + DM2DSM01 = byt.GetBit(1); + DM3DSM01=byt.GetBit(2); + DM1GDS12 = byt.GetBit(3); + } + //3 + public bool DM1GDP01 { get; set; } + //4 + public bool DM1ASIG01 { get; set; } + //5 + public bool DM1BSIG01 { get; set; } + //6 + public bool DM1CSIG01 { get; set; } + //7 + public bool DM1DSIG01 { get; set; } + + //0 + public bool DM1ESIG01 { get; set; } + + public bool DM1GDS01 { get; set; } + public bool DM1GDS02 { get; set; } + public bool DM1GDS03 { get; set; } + public bool DM1GDS04 { get; set; } + public bool DM1GDS05 { get; set; } + public bool DM1GDS06 { get; set; } + //7 + public bool DM1GDS09 { get; set; } + + + + public bool DM1DSM01 { get; set; } + + public bool DM2DSM01 { get; set; } + public bool DM3DSM01 { get; set; } + + public bool DM1GDS12 { get; set; } } } diff --git a/DataBlockHelper/DBHelpers/DB191WriteHelper.cs b/DataBlockHelper/DBHelpers/DB191WriteHelper.cs index b6a2878..8759cbd 100644 --- a/DataBlockHelper/DBHelpers/DB191WriteHelper.cs +++ b/DataBlockHelper/DBHelpers/DB191WriteHelper.cs @@ -169,5 +169,35 @@ namespace DataBlockHelper.DBHelpers { siemensS7Net.Write($"{DbName}.{start}.{bit}", state); } + + + public static void AddDianJi(int start, bool state) + { + Dictionary dic = new Dictionary() + { + [0] = "30.3", + [1] = "30.4", + [2] = "30.5", + [3] = "30.6", + [4] = "30.7", + [5] = "31.0", + [6] = "31.1", + [7] = "31.2", + [8] = "31.3", + [9] = "31.4", + [10] = "31.5", + [11] = "31.6", + [12] = "31.7", + [13] = "32.0", + [14] = "32.1", + [15] = "32.2", + [16] = "32.3", + }; + + string val = dic[start]; + + siemensS7Net.Write($"{DbName}.{val}", state); + + } } }