diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index e5fc834..3dc70aa 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -169,6 +169,9 @@ False ..\..\..\PlugInPlatform\Mesnac.PlugIn.dll + + ..\..\Microsoft.Office.Interop.Excel.dll + @@ -567,6 +570,7 @@ + Form diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Pl/Class1.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Pl/Class1.cs new file mode 100644 index 0000000..3ba3d67 --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Pl/Class1.cs @@ -0,0 +1,37 @@ +using HslCommunication.Profinet.Siemens; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Action.ChemicalWeighing.Pl +{ + public class PlcConnect + { + + + private static readonly Lazy lazy = new Lazy(() => new PlcConnect().SiemensS7NetConnection()); + public static SiemensS7Net Instance => lazy.Value; + + private PlcConnect() + { + + } + + + + + + private SiemensS7Net SiemensS7NetConnection() + { + SiemensPLCS siemensPLCS = SiemensPLCS.S1500; + SiemensS7Net s7 = new SiemensS7Net(siemensPLCS); + s7.IpAddress ="192.168.1.50"; + s7.Port =102; + s7.ConnectServer(); + return s7; + } + } +} diff --git a/DataBlockHelper/BitHelper.cs b/DataBlockHelper/BitHelper.cs new file mode 100644 index 0000000..09c0de4 --- /dev/null +++ b/DataBlockHelper/BitHelper.cs @@ -0,0 +1,88 @@ +using System; + +namespace DataBlockHelper +{ + public static class BitHelper + { + /// 设置数据位 + /// 数值 + /// + /// + /// + public static UInt16 SetBit(this UInt16 value, Int32 position, Boolean flag) + { + return SetBits(value, position, 1, (flag ? (Byte)1 : (Byte)0)); + } + + /// 设置数据位 + /// 数值 + /// + /// + /// + /// + public static UInt16 SetBits(this UInt16 value, Int32 position, Int32 length, UInt16 bits) + { + if (length <= 0 || position >= 16) return value; + + var mask = (2 << (length - 1)) - 1; + + value &= (UInt16)~(mask << position); + value |= (UInt16)((bits & mask) << position); + + return value; + } + + /// 设置数据位 + /// 数值 + /// + /// + /// + public static Byte SetBit(this Byte value, Int32 position, Boolean flag) + { + if (position >= 8) return value; + + var mask = (2 << (1 - 1)) - 1; + + value &= (Byte)~(mask << position); + value |= (Byte)(((flag ? 1 : 0) & mask) << position); + + return value; + } + + /// 获取数据位 + /// 数值 + /// + /// + public static Boolean GetBit(this UInt16 value, Int32 position) + { + return GetBits(value, position, 1) == 1; + } + + /// 获取数据位 + /// 数值 + /// + /// + /// + public static UInt16 GetBits(this UInt16 value, Int32 position, Int32 length) + { + if (length <= 0 || position >= 16) return 0; + + var mask = (2 << (length - 1)) - 1; + + return (UInt16)((value >> position) & mask); + } + + /// 获取数据位 + /// 数值 + /// + /// + public static Boolean GetBit(this Byte value, Int32 position) + { + if (position >= 8) return false; + + var mask = (2 << (1 - 1)) - 1; + + return ((Byte)((value >> position) & mask)) == 1; + } + } +} \ No newline at end of file diff --git a/DataBlockHelper/Class1.cs b/DataBlockHelper/Class1.cs new file mode 100644 index 0000000..9a0d532 --- /dev/null +++ b/DataBlockHelper/Class1.cs @@ -0,0 +1,6 @@ +namespace DataBlockHelper +{ + public class Class1 + { + } +} \ No newline at end of file diff --git a/DataBlockHelper/DBHelpers/DB1Helper.cs b/DataBlockHelper/DBHelpers/DB1Helper.cs new file mode 100644 index 0000000..2307827 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB1Helper.cs @@ -0,0 +1,86 @@ +using DataBlockHelper.Entity.DB1Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB1Helper + { + public ForAoaLogInFC3005Entity PR1DBT01 => new ForAoaLogInFC3005Entity(0); + public ForAoaLogInFC3005Entity PR1DBT02 => new ForAoaLogInFC3005Entity(8); + public ForAoaLogInFC3005Entity PR1DBT03 => new ForAoaLogInFC3005Entity(16); + public ForAoaLogInFC3005Entity PR1DBT04 => new ForAoaLogInFC3005Entity(24); + public ForAoaLogInFC3005Entity PR2DBT01 => new ForAoaLogInFC3005Entity(32); + public ForAoaLogInFC3005Entity PR2DBT02 => new ForAoaLogInFC3005Entity(40); + public ForAoaLogInFC3005Entity PR2DBT03 => new ForAoaLogInFC3005Entity(48); + public ForAoaLogInFC3005Entity PR2DBT04 => new ForAoaLogInFC3005Entity(56); + public ForAoaLogInFC3005Entity PR3DBT01 => new ForAoaLogInFC3005Entity(64); + public ForAoaLogInFC3005Entity PR3DBT02 => new ForAoaLogInFC3005Entity(72); + public ForAoaLogInFC3005Entity PR3DBT03 => new ForAoaLogInFC3005Entity(80); + public ForAoaLogInFC3005Entity PR3DBT04 => new ForAoaLogInFC3005Entity(88); + public ForAoaLogInFC3005Entity PR1ASI01 => new ForAoaLogInFC3005Entity(96); + public ForAoaLogInFC3005Entity PR1BSI01 => new ForAoaLogInFC3005Entity(104); + public ForAoaLogInFC3005Entity PR1CSI01 => new ForAoaLogInFC3005Entity(112); + public ForAoaLogInFC3005Entity PR1DSI01 => new ForAoaLogInFC3005Entity(120); + public ForAoaLogInFC3005Entity PR1ESI01 => new ForAoaLogInFC3005Entity(128); + public ForAoaLogInFC3005Entity PR1FSI01 => new ForAoaLogInFC3005Entity(136); + public ForAoaLogInFC3005Entity PR1GSI01 => new ForAoaLogInFC3005Entity(144); + public ForAoaLogInFC3005Entity PR1HSI01 => new ForAoaLogInFC3005Entity(152); + public ForAoaLogInFC3005Entity PR1ISI01 => new ForAoaLogInFC3005Entity(160); + public ForAoaLogInFC3005Entity PR1JSI01 => new ForAoaLogInFC3005Entity(168); + public ForAoaLogInFC3005Entity PR1OSI01 => new ForAoaLogInFC3005Entity(176); + public ForAoaLogInFC3005Entity PR1PCP01 => new ForAoaLogInFC3005Entity(184); + public ForAoaLogInFC3005Entity PR1PCP02 => new ForAoaLogInFC3005Entity(192); + public ForAoaLogInFC3005Entity PR1PCP03 => new ForAoaLogInFC3005Entity(200); + public ForAoaLogInFC3005Entity LS1ASI01 => new ForAoaLogInFC3005Entity(208); + public ForAoaLogInFC3005Entity LS1BSI01 => new ForAoaLogInFC3005Entity(216); + public ForAoaLogInFC3005Entity LS1CSI01 => new ForAoaLogInFC3005Entity(224); + public ForAoaLogInFC3005Entity LS1DSI01 => new ForAoaLogInFC3005Entity(232); + public ForAoaLogInFC3005Entity LS1ESI01 => new ForAoaLogInFC3005Entity(240); + public ForAoaLogInFC3005Entity LS1FSI01 => new ForAoaLogInFC3005Entity(248); + public ForAoaLogInFC3005Entity LS1GSI01 => new ForAoaLogInFC3005Entity(256); + public ForAoaLogInFC3005Entity LS1HSI01 => new ForAoaLogInFC3005Entity(264); + public ForAoaLogInFC3005Entity LS1ISI01 => new ForAoaLogInFC3005Entity(272); + public ForAoaLogInFC3005Entity LS1JSI01 => new ForAoaLogInFC3005Entity(280); + public ForAoaLogInFC3005Entity LS1OSI01 => new ForAoaLogInFC3005Entity(288); + public ForAoaLogInFC3005Entity HR1ASI01 => new ForAoaLogInFC3005Entity(296); + public ForAoaLogInFC3005Entity HR1BSI01 => new ForAoaLogInFC3005Entity(304); + public ForAoaLogInFC3005Entity HR1CSI01 => new ForAoaLogInFC3005Entity(312); + public ForAoaLogInFC3005Entity HR1DSI01 => new ForAoaLogInFC3005Entity(320); + public ForAoaLogInFC3005Entity HR1ESI01 => new ForAoaLogInFC3005Entity(328); + public ForAoaLogInFC3005Entity HR1FSI01 => new ForAoaLogInFC3005Entity(336); + public ForAoaLogInFC3005Entity HR1GSI01 => new ForAoaLogInFC3005Entity(344); + public ForAoaLogInFC3005Entity HR1HSI01 => new ForAoaLogInFC3005Entity(352); + public ForAoaLogInFC3005Entity HR1ISI01 => new ForAoaLogInFC3005Entity(360); + public ForAoaLogInFC3005Entity HR1JSI01 => new ForAoaLogInFC3005Entity(368); + public ForAoaLogInFC3005Entity HR1OSI01 => new ForAoaLogInFC3005Entity(376); + + public ForAoaLogInFC3006Entity SPV1DBT01 => new ForAoaLogInFC3006Entity(384); + public ForAoaLogInFC3006Entity SPV1DBT02 => new ForAoaLogInFC3006Entity(392); + public ForAoaLogInFC3006Entity SPV2DBT01 => new ForAoaLogInFC3006Entity(400); + public ForAoaLogInFC3006Entity SPV2DBT02 => new ForAoaLogInFC3006Entity(408); + public ForAoaLogInFC3006Entity SPV3DBT01 => new ForAoaLogInFC3006Entity(416); + public ForAoaLogInFC3006Entity SPV3DBT02 => new ForAoaLogInFC3006Entity(424); + + public ForAoaLogInFC3005Entity From_SiloA => new ForAoaLogInFC3005Entity(432); + public ForAoaLogInFC3005Entity From_SiloB => new ForAoaLogInFC3005Entity(440); + public ForAoaLogInFC3005Entity From_SiloC => new ForAoaLogInFC3005Entity(448); + public ForAoaLogInFC3005Entity From_SiloD => new ForAoaLogInFC3005Entity(456); + public ForAoaLogInFC3005Entity From_SiloE => new ForAoaLogInFC3005Entity(464); + public ForAoaLogInFC3005Entity From_SiloF => new ForAoaLogInFC3005Entity(472); + public ForAoaLogInFC3005Entity From_SiloG => new ForAoaLogInFC3005Entity(480); + public ForAoaLogInFC3005Entity From_SiloH => new ForAoaLogInFC3005Entity(488); + public ForAoaLogInFC3005Entity From_SiloI => new ForAoaLogInFC3005Entity(496); + public ForAoaLogInFC3005Entity From_SiloJ => new ForAoaLogInFC3005Entity(504); + public ForAoaLogInFC3005Entity From_SiloK => new ForAoaLogInFC3005Entity(512); + public ForAoaLogInFC3005Entity From_SiloL => new ForAoaLogInFC3005Entity(520); + public ForAoaLogInFC3005Entity From_SiloM => new ForAoaLogInFC3005Entity(528); + public ForAoaLogInFC3005Entity From_SiloN => new ForAoaLogInFC3005Entity(536); + public ForAoaLogInFC3005Entity From_SiloO => new ForAoaLogInFC3005Entity(544); + + + } +} diff --git a/DataBlockHelper/DBHelpers/DB2102Helper.cs b/DataBlockHelper/DBHelpers/DB2102Helper.cs new file mode 100644 index 0000000..0ca02b2 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2102Helper.cs @@ -0,0 +1,115 @@ +using DataBlockHelper.Entity.DB2102Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2102Helper + { + public FOR_VALVE_DoubleEntity DV2PCP01 => new FOR_VALVE_DoubleEntity(130); + public FOR_VALVE_DoubleEntity DV2PCP02 => new FOR_VALVE_DoubleEntity(132); + public FOR_VALVE_DoubleEntity DV2PCP03 => new FOR_VALVE_DoubleEntity(134); + public FOR_VALVE_DoubleEntity DV2PCP04 => new FOR_VALVE_DoubleEntity(136); + public FOR_VALVE_DoubleEntity DV2PCP05 => new FOR_VALVE_DoubleEntity(138); + public FOR_VALVE_DoubleEntity DV2PCP06 => new FOR_VALVE_DoubleEntity(140); + public FOR_VALVE_DoubleEntity DV2PCP07 => new FOR_VALVE_DoubleEntity(142); + public FOR_VALVE_DoubleEntity DV2PCP08 => new FOR_VALVE_DoubleEntity(144); + public FOR_VALVE_DoubleEntity DV2PCP09 => new FOR_VALVE_DoubleEntity(146); + public FOR_VALVE_DoubleEntity DV2PCP10 => new FOR_VALVE_DoubleEntity(148); + public FOR_VALVE_DoubleEntity DV2PCP11 => new FOR_VALVE_DoubleEntity(150); + public FOR_VALVE_DoubleEntity DV2PCP12 => new FOR_VALVE_DoubleEntity(152); + public FOR_VALVE_DoubleEntity DV2PCP13 => new FOR_VALVE_DoubleEntity(154); + public FOR_VALVE_DoubleEntity DV2PCP14 => new FOR_VALVE_DoubleEntity(156); + + public FOR_VALVE_SingleEntity BU1ASF01 => new FOR_VALVE_SingleEntity(0); + public FOR_VALVE_SingleEntity BU1BSF01 => new FOR_VALVE_SingleEntity(2); + public FOR_VALVE_SingleEntity BU1CSF01 => new FOR_VALVE_SingleEntity(4); + public FOR_VALVE_SingleEntity BU1DSF01 => new FOR_VALVE_SingleEntity(6); + public FOR_VALVE_SingleEntity BU1ESF01 => new FOR_VALVE_SingleEntity(8); + public FOR_VALVE_SingleEntity BU1FSF01 => new FOR_VALVE_SingleEntity(10); + public FOR_VALVE_SingleEntity BU1GSF01 => new FOR_VALVE_SingleEntity(12); + public FOR_VALVE_SingleEntity BU1HSF01 => new FOR_VALVE_SingleEntity(14); + public FOR_VALVE_SingleEntity BU1ISF01 => new FOR_VALVE_SingleEntity(16); + public FOR_VALVE_SingleEntity BU1JSF01 => new FOR_VALVE_SingleEntity(18); + public FOR_VALVE_SingleEntity BU1KSF01 => new FOR_VALVE_SingleEntity(20); + public FOR_VALVE_SingleEntity BU1LSF01 => new FOR_VALVE_SingleEntity(22); + public FOR_VALVE_SingleEntity BU1MSF01 => new FOR_VALVE_SingleEntity(24); + public FOR_VALVE_SingleEntity BU1NSF01 => new FOR_VALVE_SingleEntity(26); + public FOR_VALVE_SingleEntity BU1OSF01 => new FOR_VALVE_SingleEntity(28); + public FOR_VALVE_SingleEntity BU1BLT01 => new FOR_VALVE_SingleEntity(30); + public FOR_VALVE_SingleEntity BU1BLT02 => new FOR_VALVE_SingleEntity(32); + public FOR_VALVE_SingleEntity BU1BLT03 => new FOR_VALVE_SingleEntity(34); + public FOR_VALVE_SingleEntity BU1BLT04 => new FOR_VALVE_SingleEntity(36); + public FOR_VALVE_SingleEntity BU1BLT05 => new FOR_VALVE_SingleEntity(38); + public FOR_VALVE_SingleEntity BU1BLT06 => new FOR_VALVE_SingleEntity(40); + public FOR_VALVE_SingleEntity BU1BLT07 => new FOR_VALVE_SingleEntity(42); + public FOR_VALVE_SingleEntity BU2BLT01 => new FOR_VALVE_SingleEntity(44); + public FOR_VALVE_SingleEntity BU2BLT02 => new FOR_VALVE_SingleEntity(46); + public FOR_VALVE_SingleEntity BU2BLT03 => new FOR_VALVE_SingleEntity(48); + public FOR_VALVE_SingleEntity BU2BLT04 => new FOR_VALVE_SingleEntity(50); + public FOR_VALVE_SingleEntity BU2BLT05 => new FOR_VALVE_SingleEntity(52); + public FOR_VALVE_SingleEntity BU3BLT01 => new FOR_VALVE_SingleEntity(54); + public FOR_VALVE_SingleEntity BU3BLT02 => new FOR_VALVE_SingleEntity(56); + public FOR_VALVE_SingleEntity BU3BLT03 => new FOR_VALVE_SingleEntity(58); + public FOR_VALVE_SingleEntity BU3BLT04 => new FOR_VALVE_SingleEntity(60); + public FOR_VALVE_SingleEntity BU3BLT05 => new FOR_VALVE_SingleEntity(62); + public FOR_VALVE_SingleEntity BU3BLT06 => new FOR_VALVE_SingleEntity(64); + public FOR_VALVE_SingleEntity BU3BLT07 => new FOR_VALVE_SingleEntity(66); + public FOR_VALVE_SingleEntity BU4BLT01 => new FOR_VALVE_SingleEntity(68); + public FOR_VALVE_SingleEntity BU4BLT02 => new FOR_VALVE_SingleEntity(70); + public FOR_VALVE_SingleEntity BU4BLT03 => new FOR_VALVE_SingleEntity(72); + public FOR_VALVE_SingleEntity BU4BLT04 => new FOR_VALVE_SingleEntity(74); + public FOR_VALVE_SingleEntity BU4BLT05 => new FOR_VALVE_SingleEntity(76); + public FOR_VALVE_SingleEntity BU4BLT06 => new FOR_VALVE_SingleEntity(78); + public FOR_VALVE_SingleEntity BU4BLT07 => new FOR_VALVE_SingleEntity(80); + public FOR_VALVE_SingleEntity BU5BLT01 => new FOR_VALVE_SingleEntity(82); + public FOR_VALVE_SingleEntity BU5BLT02 => new FOR_VALVE_SingleEntity(84); + public FOR_VALVE_SingleEntity BU5BLT03 => new FOR_VALVE_SingleEntity(86); + public FOR_VALVE_SingleEntity BU5BLT04 => new FOR_VALVE_SingleEntity(88); + public FOR_VALVE_SingleEntity BU2ASF01 => new FOR_VALVE_SingleEntity(90); + public FOR_VALVE_SingleEntity BU2ASF02 => new FOR_VALVE_SingleEntity(92); + public FOR_VALVE_SingleEntity BU2BSF01 => new FOR_VALVE_SingleEntity(94); + public FOR_VALVE_SingleEntity BU2BSF02 => new FOR_VALVE_SingleEntity(96); + public FOR_VALVE_SingleEntity BU2CSF01 => new FOR_VALVE_SingleEntity(98); + public FOR_VALVE_SingleEntity BU2CSF02 => new FOR_VALVE_SingleEntity(100); + public FOR_VALVE_SingleEntity BU2DSF01 => new FOR_VALVE_SingleEntity(102); + public FOR_VALVE_SingleEntity BU2DSF02 => new FOR_VALVE_SingleEntity(104); + public FOR_VALVE_SingleEntity BU1ADB01 => new FOR_VALVE_SingleEntity(106); + public FOR_VALVE_SingleEntity BU1BDB01 => new FOR_VALVE_SingleEntity(108); + public FOR_VALVE_SingleEntity BU1CDB01 => new FOR_VALVE_SingleEntity(110); + public FOR_VALVE_SingleEntity BU1DDB01 => new FOR_VALVE_SingleEntity(112); + public FOR_VALVE_SingleEntity BU1EDB01 => new FOR_VALVE_SingleEntity(114); + public FOR_VALVE_SingleEntity BU1FDB01 => new FOR_VALVE_SingleEntity(116); + public FOR_VALVE_SingleEntity BU1GDB01 => new FOR_VALVE_SingleEntity(118); + public FOR_VALVE_SingleEntity BU1HDB01 => new FOR_VALVE_SingleEntity(120); + public FOR_VALVE_SingleEntity BU1IDB01 => new FOR_VALVE_SingleEntity(122); + public FOR_VALVE_SingleEntity BU1JDB01 => new FOR_VALVE_SingleEntity(124); + public FOR_VALVE_SingleEntity BU1KDB01 => new FOR_VALVE_SingleEntity(126); + public FOR_VALVE_SingleEntity BU1LDB01 => new FOR_VALVE_SingleEntity(128); + + public FOR_VALVE_SingleEntity BU1DRB01 => new FOR_VALVE_SingleEntity(158); + public FOR_VALVE_SingleEntity BU2DRB01 => new FOR_VALVE_SingleEntity(160); + public FOR_VALVE_SingleEntity BU3DRB01 => new FOR_VALVE_SingleEntity(162); + public FOR_VALVE_SingleEntity BU4DRB01 => new FOR_VALVE_SingleEntity(164); + public FOR_VALVE_SingleEntity BU1GEB01 => new FOR_VALVE_SingleEntity(166); + public FOR_VALVE_SingleEntity BU2GEB01 => new FOR_VALVE_SingleEntity(168); + public FOR_VALVE_SingleEntity BU3GEB01 => new FOR_VALVE_SingleEntity(170); + public FOR_VALVE_SingleEntity BU4GEB01 => new FOR_VALVE_SingleEntity(172); + public FOR_VALVE_SingleEntity BU5GEB01 => new FOR_VALVE_SingleEntity(174); + public FOR_VALVE_SingleEntity BU6GEB01 => new FOR_VALVE_SingleEntity(176); + public FOR_VALVE_SingleEntity BU7GEB01 => new FOR_VALVE_SingleEntity(178); + public FOR_VALVE_SingleEntity BU8GEB01 => new FOR_VALVE_SingleEntity(180); + public FOR_VALVE_SingleEntity BUWeter1 => new FOR_VALVE_SingleEntity(182); + public FOR_VALVE_SingleEntity BUWeter2 => new FOR_VALVE_SingleEntity(184); + public FOR_VALVE_SingleEntity BUWeter3 => new FOR_VALVE_SingleEntity(186); + public FOR_VALVE_SingleEntity BUWeter4 => new FOR_VALVE_SingleEntity(188); + public FOR_VALVE_SingleEntity BUWeter5 => new FOR_VALVE_SingleEntity(190); + public FOR_VALVE_SingleEntity BUWeter6 => new FOR_VALVE_SingleEntity(192); + public FOR_VALVE_SingleEntity BUWeter7 => new FOR_VALVE_SingleEntity(194); + public FOR_VALVE_SingleEntity BUWeter8 => new FOR_VALVE_SingleEntity(196); + + } +} diff --git a/DataBlockHelper/DBHelpers/DB2103Helper.cs b/DataBlockHelper/DBHelpers/DB2103Helper.cs new file mode 100644 index 0000000..253cb7a --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2103Helper.cs @@ -0,0 +1,99 @@ +using DataBlockHelper.Entity.DB2103Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2103Helper + { + public FOR_MOTOREntity DM1ASI01 => new FOR_MOTOREntity(0); + public FOR_MOTOREntity DM1BSI01 => new FOR_MOTOREntity(2); + public FOR_MOTOREntity DM1CSI01 => new FOR_MOTOREntity(4); + public FOR_MOTOREntity DM1DSI01 => new FOR_MOTOREntity(6); + public FOR_MOTOREntity DM1ESI01 => new FOR_MOTOREntity(8); + public FOR_MOTOREntity DM1FSI01 => new FOR_MOTOREntity(10); + public FOR_MOTOREntity DM1GSI01 => new FOR_MOTOREntity(12); + public FOR_MOTOREntity DM1HSI01 => new FOR_MOTOREntity(14); + public FOR_MOTOREntity DM1ISI01 => new FOR_MOTOREntity(16); + public FOR_MOTOREntity DM1JSI01 => new FOR_MOTOREntity(18); + public FOR_MOTOREntity DM1KSI01 => new FOR_MOTOREntity(20); + public FOR_MOTOREntity DM1LSI01 => new FOR_MOTOREntity(22); + public FOR_MOTOREntity DM1MSI01 => new FOR_MOTOREntity(24); + public FOR_MOTOREntity DM1NSI01 => new FOR_MOTOREntity(26); + public FOR_MOTOREntity DM1OSI01 => new FOR_MOTOREntity(28); + public FOR_MOTOREntity DM1ADB01 => new FOR_MOTOREntity(30); + public FOR_MOTOREntity DM1BDB01 => new FOR_MOTOREntity(32); + public FOR_MOTOREntity DM1CDB01 => new FOR_MOTOREntity(34); + public FOR_MOTOREntity DM1DDB01 => new FOR_MOTOREntity(36); + public FOR_MOTOREntity DM1EDB01 => new FOR_MOTOREntity(38); + public FOR_MOTOREntity DM1FDB01 => new FOR_MOTOREntity(40); + public FOR_MOTOREntity DM1GDB01 => new FOR_MOTOREntity(42); + public FOR_MOTOREntity DM1HDB01 => new FOR_MOTOREntity(44); + public FOR_MOTOREntity DM1IDB01 => new FOR_MOTOREntity(46); + public FOR_MOTOREntity DM1JDB01 => new FOR_MOTOREntity(48); + public FOR_MOTOREntity DM1KDB01 => new FOR_MOTOREntity(50); + public FOR_MOTOREntity DM1LDB01 => new FOR_MOTOREntity(52); + public FOR_MOTOREntity DM1ADF01 => new FOR_MOTOREntity(54); + public FOR_MOTOREntity DM1BDF01 => new FOR_MOTOREntity(56); + public FOR_MOTOREntity DM1CDF01 => new FOR_MOTOREntity(58); + public FOR_MOTOREntity DM1DDF01 => new FOR_MOTOREntity(60); + public FOR_MOTOREntity DM1EDF01 => new FOR_MOTOREntity(62); + public FOR_MOTOREntity DM1FDF01 => new FOR_MOTOREntity(64); + public FOR_MOTOREntity DM1GDF01 => new FOR_MOTOREntity(66); + public FOR_MOTOREntity DM1HDF01 => new FOR_MOTOREntity(68); + public FOR_MOTOREntity DM1IDF01 => new FOR_MOTOREntity(70); + public FOR_MOTOREntity DM1JDF01 => new FOR_MOTOREntity(72); + public FOR_MOTOREntity DM1KDF01 => new FOR_MOTOREntity(74); + public FOR_MOTOREntity DM1LDF01 => new FOR_MOTOREntity(76); + public FOR_MOTOREntity DMFILTER => new FOR_MOTOREntity(78); + public FOR_MOTOREntity DM1ASF01 => new FOR_MOTOREntity(80); + public FOR_MOTOREntity DM1BSF01 => new FOR_MOTOREntity(82); + public FOR_MOTOREntity DM1CSF01 => new FOR_MOTOREntity(84); + public FOR_MOTOREntity DM1DSF01 => new FOR_MOTOREntity(86); + public FOR_MOTOREntity DM1ESF01 => new FOR_MOTOREntity(88); + public FOR_MOTOREntity DM1FSF01 => new FOR_MOTOREntity(90); + public FOR_MOTOREntity DM1GSF01 => new FOR_MOTOREntity(92); + public FOR_MOTOREntity DM1HSF01 => new FOR_MOTOREntity(94); + public FOR_MOTOREntity DM1ISF01 => new FOR_MOTOREntity(96); + public FOR_MOTOREntity DM1JSF01 => new FOR_MOTOREntity(98); + public FOR_MOTOREntity DM1KSF01 => new FOR_MOTOREntity(100); + public FOR_MOTOREntity DM1LSF01 => new FOR_MOTOREntity(102); + public FOR_MOTOREntity DM1MSF01 => new FOR_MOTOREntity(104); + public FOR_MOTOREntity DM1NSF01 => new FOR_MOTOREntity(106); + + public FOR_MOTOR_VFDEntity _24T11A_D => new FOR_MOTOR_VFDEntity(108); + public FOR_MOTOR_VFDEntity _64T01G_J => new FOR_MOTOR_VFDEntity(122); + public FOR_MOTOR_VFDEntity _64T61E_F => new FOR_MOTOR_VFDEntity(136); + public FOR_MOTOR_VFDEntity DM1K_NSF01 => new FOR_MOTOR_VFDEntity(150); + public FOR_MOTOR_VFDEntity DM1OSF01 => new FOR_MOTOR_VFDEntity(164); + public FOR_MOTOR_VFDEntity DM2ASF01 => new FOR_MOTOR_VFDEntity(178); + public FOR_MOTOR_VFDEntity DM2BSF01 => new FOR_MOTOR_VFDEntity(192); + public FOR_MOTOR_VFDEntity DM2CSF01 => new FOR_MOTOR_VFDEntity(206); + public FOR_MOTOR_VFDEntity DM2DSF01 => new FOR_MOTOR_VFDEntity(220); + public FOR_MOTOR_VFDEntity DM1DRY1 => new FOR_MOTOR_VFDEntity(234); + public FOR_MOTOR_VFDEntity DM1DRY2 => new FOR_MOTOR_VFDEntity(248); + public FOR_MOTOR_VFDEntity DM1DRY3 => new FOR_MOTOR_VFDEntity(262); + public FOR_MOTOR_VFDEntity DM1DRY4 => new FOR_MOTOR_VFDEntity(276); + public FOR_MOTOR_VFDEntity DM1GEM => new FOR_MOTOR_VFDEntity(290); + public FOR_MOTOR_VFDEntity DM2GEM => new FOR_MOTOR_VFDEntity(304); + public FOR_MOTOR_VFDEntity DM3GEM => new FOR_MOTOR_VFDEntity(318); + public FOR_MOTOR_VFDEntity DM4GEM => new FOR_MOTOR_VFDEntity(332); + public FOR_MOTOR_VFDEntity DM5GEM => new FOR_MOTOR_VFDEntity(346); + public FOR_MOTOR_VFDEntity DM6GEM => new FOR_MOTOR_VFDEntity(360); + public FOR_MOTOR_VFDEntity DM7GEM => new FOR_MOTOR_VFDEntity(374); + public FOR_MOTOR_VFDEntity DM8GEM => new FOR_MOTOR_VFDEntity(388); + + public FOR_MOTOREntity DMWETER1 => new FOR_MOTOREntity(402); + public FOR_MOTOREntity DMWETER2 => new FOR_MOTOREntity(404); + public FOR_MOTOREntity DMWETER3 => new FOR_MOTOREntity(406); + public FOR_MOTOREntity DMWETER4 => new FOR_MOTOREntity(408); + public FOR_MOTOREntity DMWETER5 => new FOR_MOTOREntity(410); + public FOR_MOTOREntity DMWETER6 => new FOR_MOTOREntity(412); + public FOR_MOTOREntity DMWETER7 => new FOR_MOTOREntity(414); + public FOR_MOTOREntity DMWETER8 => new FOR_MOTOREntity(416); + + } +} diff --git a/DataBlockHelper/DBHelpers/DB2104Helper.cs b/DataBlockHelper/DBHelpers/DB2104Helper.cs new file mode 100644 index 0000000..02931b9 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2104Helper.cs @@ -0,0 +1,52 @@ +using DataBlockHelper.Entity.DB2107Entity; +using DataBlockHelper.Entity.DB2104Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2104Helper + { + public RecipeCommEntity RecipeComm => RecipeCom(); + + private RecipeCommEntity RecipeCom() + { + return new RecipeCommEntity(); + } + + public EnableStatusEntity EnableStatus => EnableS(); + + private EnableStatusEntity EnableS() + { + return new EnableStatusEntity(); + } + + public DryerEntity Dryer_D1 => new DryerEntity(58); + public DryerEntity Dryer_D2 => new DryerEntity(218); + public DryerEntity Dryer_D3 => new DryerEntity(378); + public DryerEntity Dryer_D4 => new DryerEntity(538); + + public GelatEntity Gelat_G1 => new GelatEntity(698); + public GelatEntity Gelat_G2 => new GelatEntity(858); + public GelatEntity Gelat_G3 => new GelatEntity(1018); + public GelatEntity Gelat_G4 => new GelatEntity(1178); + public GelatEntity Gelat_G5 => new GelatEntity(1338); + public GelatEntity Gelat_G6 => new GelatEntity(1498); + public GelatEntity Gelat_G7 => new GelatEntity(1658); + public GelatEntity Gelat_G8 => new GelatEntity(1818); + + public WeterEntity Weter_M1 => new WeterEntity(1978); + public WeterEntity Weter_M2 => new WeterEntity(2178); + public WeterEntity Weter_M3 => new WeterEntity(2378); + public WeterEntity Weter_M4 => new WeterEntity(2578); + public WeterEntity Weter_M5 => new WeterEntity(2778); + public WeterEntity Weter_M6 => new WeterEntity(2978); + public WeterEntity Weter_M7 => new WeterEntity(3178); + public WeterEntity Weter_M8 => new WeterEntity(3378); + + + } +} diff --git a/DataBlockHelper/DBHelpers/DB2105Helper.cs b/DataBlockHelper/DBHelpers/DB2105Helper.cs new file mode 100644 index 0000000..8afed87 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2105Helper.cs @@ -0,0 +1,18 @@ +using DataBlockHelper.Entity.DB2107Entity; +using DataBlockHelper.Entity.DB2105Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2105Helper + { + public List Plan => new PlanArrayManager(4, 0, 12).GetList(); + public bool[] Status => new FourBoolArrayManager(48).GetList(); + public bool[] End => new FourBoolArrayManager(50).GetList(); + + } +} diff --git a/DataBlockHelper/DBHelpers/DB2106Helper.cs b/DataBlockHelper/DBHelpers/DB2106Helper.cs new file mode 100644 index 0000000..3d68a78 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2106Helper.cs @@ -0,0 +1,17 @@ +using DataBlockHelper.Entity.DB2104Entity; +using DataBlockHelper.Entity.DB2106Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2106Helper + { + public DryerReportEntity DryReport => new DryerReportEntity(0); + public GelReportEntity GelReport => new GelReportEntity(1072); + public WetMixingEntity WetReport => new WetMixingEntity(3568); + } +} diff --git a/DataBlockHelper/DBHelpers/DB2107Helper.cs b/DataBlockHelper/DBHelpers/DB2107Helper.cs new file mode 100644 index 0000000..9fb1fd4 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2107Helper.cs @@ -0,0 +1,83 @@ +using DataBlockHelper.Entity.DB2107Entity; + +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB2107Helper + { + public NormalStatusEntity NormalStatus => NormalS(); + + private NormalStatusEntity NormalS() + { + return new NormalStatusEntity(); + } + + public ControlSignEntity ControlSign => ControlS(); + + + private ControlSignEntity ControlS() + { + return new ControlSignEntity(); + } + + public PressureEntity Pressure => Press(); + + private PressureEntity Press() + { + return new PressureEntity(); + } + + public PIDEntity PID => Pid(); + + private PIDEntity Pid() + { + return new PIDEntity(); + } + + public WeightEntity Weight => Weigh(); + + private WeightEntity Weigh() + { + return new WeightEntity(); + } + + public WeightPraEntity WeightPra => WeightP(); + + private WeightPraEntity WeightP() + { + return new WeightPraEntity(); + } + + public SpeedEntity Speed => Spee(); + + private SpeedEntity Spee() + { + return new SpeedEntity(); + } + + public List Dryer => new UntiStatusHMIArrayManager(4, 1408, 32).GetList(); + public List Gelater => new UntiStatusHMIArrayManager(8, 1536, 32).GetList(); + public List Weter => new UntiStatusHMIArrayManager(8, 1792, 32).GetList(); + + public ValveEntity Valve => Val(); + + private ValveEntity Val() + { + return new ValveEntity(); + } + + public LevelEntity Level => Lev(); + + private LevelEntity Lev() + { + return new LevelEntity(); + } + + + } + +} diff --git a/DataBlockHelper/DBHelpers/DB90Helper.cs b/DataBlockHelper/DBHelpers/DB90Helper.cs new file mode 100644 index 0000000..e12f3c8 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB90Helper.cs @@ -0,0 +1,94 @@ +using DataBlockHelper.Entity.DB90Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB90Helper + { + public ForValveSingleEntity BU3DBT06 => new ForValveSingleEntity(0); + public ForValveSingleEntity BU3DBT07 => new ForValveSingleEntity(2); + public ForValveSingleEntity BU1DBT01 => new ForValveSingleEntity(4); + public ForValveSingleEntity BU1DBT03 => new ForValveSingleEntity(6); + public ForValveSingleEntity BU1DBT02 => new ForValveSingleEntity(8); + public ForValveSingleEntity BU1DBT04 => new ForValveSingleEntity(10); + public ForValveSingleEntity BU2DBT01 => new ForValveSingleEntity(12); + public ForValveSingleEntity BU2DBT03 => new ForValveSingleEntity(14); + public ForValveSingleEntity BU2DBT02 => new ForValveSingleEntity(16); + public ForValveSingleEntity BU2DBT04 => new ForValveSingleEntity(18); + public ForValveSingleEntity BU3DBT01 => new ForValveSingleEntity(20); + public ForValveSingleEntity BU3DBT03 => new ForValveSingleEntity(22); + public ForValveSingleEntity BU3DBT02 => new ForValveSingleEntity(24); + public ForValveSingleEntity BU3DBT04 => new ForValveSingleEntity(26); + public ForValveSingleEntity BU1DBT06 => new ForValveSingleEntity(28); + public ForValveSingleEntity BU1DBT07 => new ForValveSingleEntity(30); + public ForValveSingleEntity BU2DBT06 => new ForValveSingleEntity(32); + public ForValveSingleEntity BU2DBT07 => new ForValveSingleEntity(34); + public ForValveSingleEntity AS1DBT01 => new ForValveSingleEntity(36); + public ForValveSingleEntity AS1DBT02 => new ForValveSingleEntity(38); + public ForValveSingleEntity AS1DBT03 => new ForValveSingleEntity(40); + public ForValveSingleEntity AS1DBT04 => new ForValveSingleEntity(42); + public ForValveSingleEntity AS1DBT05 => new ForValveSingleEntity(44); + public ForValveSingleEntity AS1DBT06 => new ForValveSingleEntity(46); + public ForValveSingleEntity AS1DBT07 => new ForValveSingleEntity(48); + public ForValveSingleEntity AS2DBT01 => new ForValveSingleEntity(50); + public ForValveSingleEntity AS2DBT02 => new ForValveSingleEntity(52); + public ForValveSingleEntity AS2DBT03 => new ForValveSingleEntity(54); + public ForValveSingleEntity AS2DBT04 => new ForValveSingleEntity(56); + public ForValveSingleEntity AS2DBT05 => new ForValveSingleEntity(58); + public ForValveSingleEntity AS2DBT06 => new ForValveSingleEntity(60); + public ForValveSingleEntity AS2DBT07 => new ForValveSingleEntity(62); + public ForValveSingleEntity AS3DBT01 => new ForValveSingleEntity(64); + public ForValveSingleEntity AS3DBT02 => new ForValveSingleEntity(66); + public ForValveSingleEntity AS3DBT03 => new ForValveSingleEntity(68); + public ForValveSingleEntity AS3DBT04 => new ForValveSingleEntity(70); + public ForValveSingleEntity AS3DBT05 => new ForValveSingleEntity(72); + public ForValveSingleEntity AS3DBT06 => new ForValveSingleEntity(74); + public ForValveSingleEntity AS3DBT07 => new ForValveSingleEntity(76); + public ForValveSingleEntity AS1PCP01 => new ForValveSingleEntity(78); + public ForValveSingleEntity AS1PCP02 => new ForValveSingleEntity(80); + public ForValveSingleEntity AS1PCP03 => new ForValveSingleEntity(82); + public ForValveSingleEntity AS1ASI01 => new ForValveSingleEntity(84); + public ForValveSingleEntity AS1BSI01 => new ForValveSingleEntity(86); + public ForValveSingleEntity AS1CSI01 => new ForValveSingleEntity(88); + public ForValveSingleEntity AS1DSI01 => new ForValveSingleEntity(90); + public ForValveSingleEntity AS1ESI01 => new ForValveSingleEntity(92); + public ForValveSingleEntity AS1FSI01 => new ForValveSingleEntity(94); + public ForValveSingleEntity AS1GSI01 => new ForValveSingleEntity(96); + public ForValveSingleEntity AS1HSI01 => new ForValveSingleEntity(98); + public ForValveSingleEntity AS1ISI01 => new ForValveSingleEntity(100); + public ForValveSingleEntity AS1JSI01 => new ForValveSingleEntity(102); + public ForValveSingleEntity AS1OSI01 => new ForValveSingleEntity(104); + public ForValveSingleEntity SV1DSM01 => new ForValveSingleEntity(106); + public ForValveSingleEntity SV1DSM02 => new ForValveSingleEntity(108); + public ForValveSingleEntity SV2DSM01 => new ForValveSingleEntity(110); + public ForValveSingleEntity SV2DSM02 => new ForValveSingleEntity(112); + public ForValveSingleEntity SV3DSM01 => new ForValveSingleEntity(114); + public ForValveSingleEntity SV3DSM02 => new ForValveSingleEntity(116); + public ForValveSingleEntity PV1GDC01 => new ForValveSingleEntity(118); + public ForValveSingleEntity PV1GDC02 => new ForValveSingleEntity(120); + + public ForValveDoubleEntity DV1PCP01 => new ForValveDoubleEntity(122); + public ForValveDoubleEntity DV1PCP02 => new ForValveDoubleEntity(124); + public ForValveDoubleEntity DV1PCP03 => new ForValveDoubleEntity(126); + public ForValveDoubleEntity DV1PCP04 => new ForValveDoubleEntity(128); + public ForValveDoubleEntity DV1PCP05 => new ForValveDoubleEntity(130); + public ForValveDoubleEntity DV1PCP06 => new ForValveDoubleEntity(132); + public ForValveDoubleEntity DV1PCP07 => new ForValveDoubleEntity(134); + public ForValveDoubleEntity DV1PCP08 => new ForValveDoubleEntity(136); + public ForValveDoubleEntity DV1PCP09 => new ForValveDoubleEntity(138); + public ForValveDoubleEntity DV1PCP10 => new ForValveDoubleEntity(140); + public ForValveDoubleEntity DV1PCP11 => new ForValveDoubleEntity(142); + public ForValveDoubleEntity DV1PCP12 => new ForValveDoubleEntity(144); + public ForValveDoubleEntity DV1PCP13 => new ForValveDoubleEntity(146); + public ForValveDoubleEntity DV1PCP14 => new ForValveDoubleEntity(148); + public ForValveDoubleEntity DV1PCP15 => new ForValveDoubleEntity(150); + + + public ForValveSingleEntity SV1GDS01 => new ForValveSingleEntity(152); + + } +} diff --git a/DataBlockHelper/DBHelpers/DB91Helper.cs b/DataBlockHelper/DBHelpers/DB91Helper.cs new file mode 100644 index 0000000..6c75e93 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB91Helper.cs @@ -0,0 +1,29 @@ +using DataBlockHelper.Entity.DB91Entity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.DBHelpers +{ + public class DB91Helper + { + public ForMotorEntity DM1GDP01 => new ForMotorEntity(0); + public ForMotorEntity DM1ASIG01 => new ForMotorEntity(2); + public ForMotorEntity DM1BSIG01 => new ForMotorEntity(4); + public ForMotorEntity DM1CSIG01 => new ForMotorEntity(6); + public ForMotorEntity DM1DSIG01 => new ForMotorEntity(8); + public ForMotorEntity DM1GDS01 => new ForMotorEntity(10); + public ForMotorEntity DM1GDS02 => new ForMotorEntity(12); + public ForMotorEntity DM1GDS03 => new ForMotorEntity(14); + public ForMotorEntity DM1GDS04 => new ForMotorEntity(16); + public ForMotorEntity DM1GDS05 => new ForMotorEntity(18); + public ForMotorSToTEntity DM1GDS06 => new ForMotorSToTEntity(20); + public ForMotorSToTEntity DM1GDS07 => new ForMotorSToTEntity(28); + public ForMotorVFD DM1DSM01 => new ForMotorVFD(36); + public ForMotorVFD DM2DSM01 => new ForMotorVFD(50); + public ForMotorVFD DM3DSM01 => new ForMotorVFD(64); + public ForMotorVFD DM1GDS12 => new ForMotorVFD(78); + } +} diff --git a/DataBlockHelper/DataBlockHelper.csproj b/DataBlockHelper/DataBlockHelper.csproj new file mode 100644 index 0000000..81c0d1f --- /dev/null +++ b/DataBlockHelper/DataBlockHelper.csproj @@ -0,0 +1,100 @@ + + + + + Debug + AnyCPU + {4E36DF17-E81D-4360-8687-8AD75422B470} + Library + Properties + DataBlockHelper + DataBlockHelper + v4.5.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Actions\HslCommunication.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataBlockHelper/DbWrite/PlcWriteUtil.cs b/DataBlockHelper/DbWrite/PlcWriteUtil.cs new file mode 100644 index 0000000..ae5a302 --- /dev/null +++ b/DataBlockHelper/DbWrite/PlcWriteUtil.cs @@ -0,0 +1,99 @@ +using System; +using HslCommunication.Profinet.Siemens; + +namespace DataBlockHelper.DbWrite +{ + + + + public class PlcWriteUtil + { + private static SiemensS7Net _siemensS7Net => PlcConnect.Instance; + + public PlcWriteUtil() + { + + } + + + public void Write(PlcDbEnum dbEnum, string address, PlcDbType dbType, object value) + { + string plcAddress = $"{dbEnum.ToString()}.{address}"; + switch (dbType) + { + case PlcDbType.PlcInt: + _siemensS7Net.Write(plcAddress, Convert.ToInt32(value)); + break; + + case PlcDbType.PlcUint: + _siemensS7Net.Write(plcAddress, Convert.ToInt16(value)); + break; + + case PlcDbType.PlcBoolean: + _siemensS7Net.Write(plcAddress, Convert.ToBoolean(value)); + break; + + case PlcDbType.PlcFloat: + _siemensS7Net.Write(plcAddress, Convert.ToSingle(value)); + break; + } + + + } + + /// + /// 可能要读取M块 + /// + /// + /// + /// + + public void Write(string plcAddress, PlcDbType dbType, object value) + { + + switch (dbType) + { + case PlcDbType.PlcInt: + _siemensS7Net.Write(plcAddress, Convert.ToInt32(value)); + break; + + case PlcDbType.PlcUint: + _siemensS7Net.Write(plcAddress, Convert.ToInt16(value)); + break; + + case PlcDbType.PlcBoolean: + _siemensS7Net.Write(plcAddress, Convert.ToBoolean(value)); + break; + + case PlcDbType.PlcFloat: + _siemensS7Net.Write(plcAddress, Convert.ToSingle(value)); + break; + } + + + } + + + } + + public enum PlcDbEnum + { + + Db2102 = 2102, + Db2103 = 2103, + Db2104 = 2104, + Db2105 = 2105, + Db2106 = 2106, + Db2107 = 2107, + + } + + public enum PlcDbType + { + PlcUint, + PlcInt, + PlcFloat, + PlcBoolean + } +} + diff --git a/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3005Entity.cs b/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3005Entity.cs new file mode 100644 index 0000000..24a5f8d --- /dev/null +++ b/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3005Entity.cs @@ -0,0 +1,27 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB1Entity +{ + public class ForAoaLogInFC3005Entity + { + public ForAoaLogInFC3005Entity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB1." + startSet + ".0", 8); + + var content = read.Content; + + byte byt = content[6]; + + Min = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + Max = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + Value = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + + Alarm = byt.GetBit(0); + } + public short Min { get; private set; } + public short Max { get; private set; } + public short Value { get; private set; } + public bool Alarm { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3006Entity.cs b/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3006Entity.cs new file mode 100644 index 0000000..fb9c817 --- /dev/null +++ b/DataBlockHelper/Entity/DB1Entity/ForAoaLogInFC3006Entity.cs @@ -0,0 +1,27 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB1Entity +{ + public class ForAoaLogInFC3006Entity + { + public ForAoaLogInFC3006Entity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB1." + startSet + ".0", 8); + + var content = read.Content; + + byte byt = content[6]; + + Min = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + Max = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + SetValue = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + + Alarm = byt.GetBit(0); + } + public short Min { get; private set; } + public short Max { get; private set; } + public short SetValue { get; private set; } + public bool Alarm { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_DoubleEntity.cs b/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_DoubleEntity.cs new file mode 100644 index 0000000..f6e36b2 --- /dev/null +++ b/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_DoubleEntity.cs @@ -0,0 +1,54 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2102Entity +{ + public class FOR_VALVE_DoubleEntity + { + public FOR_VALVE_DoubleEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2102." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + SetLeftManual = byt.GetBit(2); + SetRightManual = byt.GetBit(3); + SetLeftAuto = byt.GetBit(4); + SetRightAuto = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + LeftPosition = byt.GetBit(7); + + byt = content[1]; + + RightPosition = byt.GetBit(0); + SetLeft = byt.GetBit(1); + SetRight = byt.GetBit(2); + AlarmLeftPosition = byt.GetBit(3); + AlarmRightPosition = byt.GetBit(4); + AlarmPosition = byt.GetBit(5); + Alarm = byt.GetBit(6); + + } + + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool SetLeftManual { get; private set; } + public bool SetRightManual { get; private set; } + public bool SetLeftAuto { get; private set; } + public bool SetRightAuto { get; private set; } + public bool AlarmReset { get; private set; } + public bool LeftPosition { get; private set; } + public bool RightPosition { get; private set; } + public bool SetLeft { get; private set; } + public bool SetRight { get; private set; } + public bool AlarmLeftPosition { get; private set; } + public bool AlarmRightPosition { get; private set; } + public bool AlarmPosition { get; private set; } + public bool Alarm { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_SingleEntity.cs b/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_SingleEntity.cs new file mode 100644 index 0000000..8e1f9e6 --- /dev/null +++ b/DataBlockHelper/Entity/DB2102Entity/FOR_VALVE_SingleEntity.cs @@ -0,0 +1,50 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2102Entity +{ + public class FOR_VALVE_SingleEntity + { + public FOR_VALVE_SingleEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2102." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + AlarmReset = byt.GetBit(2); + SetManual = byt.GetBit(3); + SetAuto = byt.GetBit(4); + SetPosition = byt.GetBit(5); + UnSetPosition = byt.GetBit(6); + Set = byt.GetBit(7); + + byt = content[1]; + + AlarmSetPos = byt.GetBit(0); + AlarmUnSetPos = byt.GetBit(1); + AlarmPosition = byt.GetBit(2); + Alarm = byt.GetBit(3); + P = byt.GetBit(4); + + } + + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool AlarmReset { get; private set; } + public bool SetManual { get; private set; } + public bool SetAuto { get; private set; } + public bool SetPosition { get; private set; } + public bool UnSetPosition { get; private set; } + public bool Set { get; private set; } + public bool AlarmSetPos { get; private set; } + public bool AlarmUnSetPos { get; private set; } + public bool AlarmPosition { get; private set; } + public bool Alarm { get; private set; } + public bool P { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOREntity.cs b/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOREntity.cs new file mode 100644 index 0000000..2c79dec --- /dev/null +++ b/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOREntity.cs @@ -0,0 +1,44 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2103Entity +{ + public class FOR_MOTOREntity + { + public FOR_MOTOREntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2103." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + AlarmReset = byt.GetBit(2); + StartManual = byt.GetBit(3); + StopManual = byt.GetBit(4); + StartAuto = byt.GetBit(5); + StopAuto = byt.GetBit(6); + Running = byt.GetBit(7); + + byt = content[1]; + + Run = byt.GetBit(0); + Alarm = byt.GetBit(1); + + } + + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool AlarmReset { get; private set; } + public bool StartManual { get; private set; } + public bool StopManual { get; private set; } + public bool StartAuto { get; private set; } + public bool StopAuto { get; private set; } + public bool Running { get; private set; } + public bool Run { get; private set; } + public bool Alarm { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOR_VFDEntity.cs b/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOR_VFDEntity.cs new file mode 100644 index 0000000..6b94045 --- /dev/null +++ b/DataBlockHelper/Entity/DB2103Entity/FOR_MOTOR_VFDEntity.cs @@ -0,0 +1,57 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2103Entity +{ + public class FOR_MOTOR_VFDEntity + { + public FOR_MOTOR_VFDEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2103." + startSet + ".0", 14); + + var content = read.Content; + + byte byt = content[0]; + + AutoMode = byt.GetBit(0); + ManMode = byt.GetBit(1); + Start_A = byt.GetBit(2); + Stop_A = byt.GetBit(3); + Start_M = byt.GetBit(4); + Stop_M = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + EXT_Estop = byt.GetBit(7); + + byt = content[1]; + + Running = byt.GetBit(0); + Alarm = byt.GetBit(1); + Error = byt.GetBit(2); + Enable = byt.GetBit(3); + Polarity = byt.GetBit(4); + + SetSpeed_A = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); + SetSpeed_M = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + ACT_Speed = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + + } + + public bool AutoMode { get; private set; } + public bool ManMode { get; private set; } + public bool Start_A { get; private set; } + public bool Stop_A { get; private set; } + public bool Start_M { get; private set; } + public bool Stop_M { get; private set; } + public bool AlarmReset { get; private set; } + public bool EXT_Estop { get; private set; } + public bool Running { get; private set; } + public bool Alarm { get; private set; } + public bool Error { get; private set; } + public bool Enable { get; private set; } + public bool Polarity { get; private set; } + public float SetSpeed_A { get; private set; } + public float SetSpeed_M { get; private set; } + public float ACT_Speed { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2104Entity/DryerEntity.cs b/DataBlockHelper/Entity/DB2104Entity/DryerEntity.cs new file mode 100644 index 0000000..a0e11b6 --- /dev/null +++ b/DataBlockHelper/Entity/DB2104Entity/DryerEntity.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2104Entity +{ + public class DryerEntity + { + private int StartSet; + public DryerEntity(int startSet) + { + this.StartSet = startSet; + } + public DaybinE Daybin => new DaybinE(StartSet); + public List Step => new RecipeArrayManager(10, StartSet + 40, 12).GetRecipe_GmixEList(); + } + + public class DaybinE + { + private int StartSet; + public DaybinE(int startSet) + { + this.StartSet = startSet; + } + + public List Recipe => new RecipeArrayManager(4, StartSet, 10).GetRecipe_DosEList(); + } + + public class Recipe_DosE + { + public Recipe_DosE(byte[] content) + { + Bin = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + Set = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); + TolErance = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + } + + public short Bin { get; private set; } + public float Set { get; private set; } + public float TolErance { get; private set; } + } + + public class Recipe_GmixE + { + public Recipe_GmixE(byte[] content) + { + MixCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + } + + public short MixCode { get; private set; } + public short MixTime { get; private set; } + public float MixTemp { get; private set; } + public float MixSpeed { get; private set; } + + } + + public class RecipeArrayManager + { + private int Length; + private int StartSet; + private int SLength; + + public RecipeArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetRecipe_GmixEList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2104." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Recipe_GmixE(singleBlock)); + } + return ListE; + } + + public List GetRecipe_DosEList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2104." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Recipe_DosE(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2104Entity/EnableStatusEntity.cs b/DataBlockHelper/Entity/DB2104Entity/EnableStatusEntity.cs new file mode 100644 index 0000000..948c0f6 --- /dev/null +++ b/DataBlockHelper/Entity/DB2104Entity/EnableStatusEntity.cs @@ -0,0 +1,100 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2104Entity +{ + public class EnableStatusEntity + { + public EnableStatusEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2104.52.0", 5); + + var content = read.Content; + + byte byt = content[0]; + + EnableDB_B1 = byt.GetBit(0); + EnableDB_B2 = byt.GetBit(1); + EnableDB_B3 = byt.GetBit(2); + EnableDB_B4 = byt.GetBit(3); + EnableDB_B5 = byt.GetBit(4); + EnableDB_B6 = byt.GetBit(5); + EnableDB_B7 = byt.GetBit(6); + EnableDB_B8 = byt.GetBit(7); + + byt = content[1]; + + EnableDB_B9 = byt.GetBit(0); + EnableDB_B10 = byt.GetBit(1); + EnableDB_B11 = byt.GetBit(2); + EnableDB_B12 = byt.GetBit(3); + EnableWater_S1 = byt.GetBit(4); + EnableWater_S2 = byt.GetBit(5); + EnableDryer_D1 = byt.GetBit(6); + EnableDryer_D2 = byt.GetBit(7); + + byt = content[2]; + + EnableDryer_D3 = byt.GetBit(0); + EnableDryer_D4 = byt.GetBit(1); + EnableGelat_G1 = byt.GetBit(2); + EnableGelat_G2 = byt.GetBit(3); + EnableGelat_G3 = byt.GetBit(4); + EnableGelat_G4 = byt.GetBit(5); + EnableGelat_G5 = byt.GetBit(6); + EnableGelat_G6 = byt.GetBit(7); + + byt = content[3]; + + EnableGelat_G7 = byt.GetBit(0); + EnableGelat_G8 = byt.GetBit(1); + EnableWeter_M1 = byt.GetBit(2); + EnableWeter_M2 = byt.GetBit(3); + EnableWeter_M3 = byt.GetBit(4); + EnableWeter_M4 = byt.GetBit(5); + EnableWeter_M5 = byt.GetBit(6); + EnableWeter_M6 = byt.GetBit(7); + + byt = content[4]; + + EnableWeter_M7 = byt.GetBit(0); + EnableWeter_M8 = byt.GetBit(1); + } + + public bool EnableDB_B1 { get; private set; } + public bool EnableDB_B2 { get; private set; } + public bool EnableDB_B3 { get; private set; } + public bool EnableDB_B4 { get; private set; } + public bool EnableDB_B5 { get; private set; } + public bool EnableDB_B6 { get; private set; } + public bool EnableDB_B7 { get; private set; } + public bool EnableDB_B8 { get; private set; } + public bool EnableDB_B9 { get; private set; } + public bool EnableDB_B10 { get; private set; } + public bool EnableDB_B11 { get; private set; } + public bool EnableDB_B12 { get; private set; } + public bool EnableWater_S1 { get; private set; } + public bool EnableWater_S2 { get; private set; } + public bool EnableDryer_D1 { get; private set; } + public bool EnableDryer_D2 { get; private set; } + public bool EnableDryer_D3 { get; private set; } + public bool EnableDryer_D4 { get; private set; } + public bool EnableGelat_G1 { get; private set; } + public bool EnableGelat_G2 { get; private set; } + public bool EnableGelat_G3 { get; private set; } + public bool EnableGelat_G4 { get; private set; } + public bool EnableGelat_G5 { get; private set; } + public bool EnableGelat_G6 { get; private set; } + public bool EnableGelat_G7 { get; private set; } + public bool EnableGelat_G8 { get; private set; } + public bool EnableWeter_M1 { get; private set; } + public bool EnableWeter_M2 { get; private set; } + public bool EnableWeter_M3 { get; private set; } + public bool EnableWeter_M4 { get; private set; } + public bool EnableWeter_M5 { get; private set; } + public bool EnableWeter_M6 { get; private set; } + public bool EnableWeter_M7 { get; private set; } + public bool EnableWeter_M8 { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2104Entity/GelatEntity.cs b/DataBlockHelper/Entity/DB2104Entity/GelatEntity.cs new file mode 100644 index 0000000..8d18244 --- /dev/null +++ b/DataBlockHelper/Entity/DB2104Entity/GelatEntity.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2104Entity +{ + public class GelatEntity + { + private int StartSet; + public GelatEntity(int startSet) + { + this.StartSet = startSet; + } + + public WDaybinE Daybin => new WDaybinE(StartSet); + public WaterSCE WaterSC => new WaterSCE(StartSet); + public List Step => new RecipeArrayManager(10, StartSet + 40, 12).GetRecipe_GmixEList(); + } + + public class WDaybinE + { + private int StartSet; + public WDaybinE(int startSet) + { + this.StartSet = startSet; + } + + public List Recipe => new RecipeArrayManager(2, StartSet, 10).GetRecipe_DosEList(); + } + + public class WaterSCE + { + private int StartSet; + public WaterSCE(int startSet) + { + this.StartSet = startSet; + } + + public List Recipe => new RecipeArrayManager(2, StartSet + 20, 10).GetRecipe_DosEList(); + } + + +} diff --git a/DataBlockHelper/Entity/DB2104Entity/RecipeCommEntity.cs b/DataBlockHelper/Entity/DB2104Entity/RecipeCommEntity.cs new file mode 100644 index 0000000..fee140e --- /dev/null +++ b/DataBlockHelper/Entity/DB2104Entity/RecipeCommEntity.cs @@ -0,0 +1,39 @@ +using HslCommunication; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; + + +namespace DataBlockHelper.Entity.DB2104Entity +{ + public class RecipeCommEntity + { + public RecipeCommEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2104.2.0", 50); + + var content = read.Content; + + var instanceByteTransform = PlcConnect.Instance.ByteTransform; + + RecpieCode = instanceByteTransform.TransUInt16(content, 0); + PlanCode = instanceByteTransform.TransUInt16(content, 2); + RecipeName =instanceByteTransform.TransString(content, 4, 21, Encoding.ASCII); + PlanName = instanceByteTransform.TransString(content, 26, 21, Encoding.ASCII); + Batch = instanceByteTransform.TransInt16(content, 48); + + } + + public ushort RecpieCode { get; private set; } + public ushort PlanCode { get; private set; } + public string RecipeName { get; private set; } + public string PlanName { get; private set; } + public short Batch { get; private set; } + } +} + + + + diff --git a/DataBlockHelper/Entity/DB2104Entity/WeterEntity.cs b/DataBlockHelper/Entity/DB2104Entity/WeterEntity.cs new file mode 100644 index 0000000..6b988a8 --- /dev/null +++ b/DataBlockHelper/Entity/DB2104Entity/WeterEntity.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2104Entity +{ + public class WeterEntity + { + int StartSet; + public WeterEntity(int startSet) + { + this.StartSet = startSet; + } + public List Step => new WeterArrayManager(10, StartSet, 20).GetList(); + } + + + + public class Recipe_WMixE + { + public Recipe_WMixE(byte[] content) + { + MixCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 12); + Tolerance = PlcConnect.Instance.ByteTransform.TransSingle(content, 16); + } + + public short MixCode { get; private set; } + public short MixTime { get; private set; } + public float MixTemp { get; private set; } + public float MixSpeed { get; private set; } + public float SetValue { get; private set; } + public float Tolerance { get; private set; } + + + } + + public class WeterArrayManager + { + private int Length; + private int StartSet; + private int SLength; + + public WeterArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2104." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Recipe_WMixE(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2105Entity/FourBoolArrayEntity.cs b/DataBlockHelper/Entity/DB2105Entity/FourBoolArrayEntity.cs new file mode 100644 index 0000000..d8d6143 --- /dev/null +++ b/DataBlockHelper/Entity/DB2105Entity/FourBoolArrayEntity.cs @@ -0,0 +1,30 @@ + + +namespace DataBlockHelper.Entity.DB2105Entity +{ + public class FourBoolArrayManager + { + private int StartSet; + public FourBoolArrayManager(int startSet) + { + StartSet = startSet; + } + + + public bool[] GetList() + { + bool[] ListE = new bool[4]; + var getListE = PlcConnect.Instance.Read("DB2105." + StartSet + ".0", 1); + var content = getListE.Content; + + byte byt = content[0]; + + ListE[0] = byt.GetBit(0); + ListE[1] = byt.GetBit(1); + ListE[2] = byt.GetBit(2); + ListE[3] = byt.GetBit(3); + + return ListE;; + } + } +} diff --git a/DataBlockHelper/Entity/DB2105Entity/PlanEntity.cs b/DataBlockHelper/Entity/DB2105Entity/PlanEntity.cs new file mode 100644 index 0000000..7670904 --- /dev/null +++ b/DataBlockHelper/Entity/DB2105Entity/PlanEntity.cs @@ -0,0 +1,61 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2105Entity +{ + public class PlanEntity + { + public PlanEntity(byte[] content) + { + + RecipeCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + PlanCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + Start = PlcConnect.Instance.ByteTransform.TransInt16(content, 6); + Pause = PlcConnect.Instance.ByteTransform.TransInt16(content, 8); + Stop = PlcConnect.Instance.ByteTransform.TransInt16(content, 10); + + } + + public int RecipeCode { get; private set; } + public int PlanCode { get; private set; } + public int Batch { get; private set; } + public int Start { get; private set; } + public int Pause { get; private set; } + public int Stop { get; private set; } + + +} + + + public class PlanArrayManager + { + private int Length; + private int StartSet; + private int SLength; + public PlanArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2105." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new PlanEntity(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2106Entity/DryReportEntity.cs b/DataBlockHelper/Entity/DB2106Entity/DryReportEntity.cs new file mode 100644 index 0000000..66fbbc2 --- /dev/null +++ b/DataBlockHelper/Entity/DB2106Entity/DryReportEntity.cs @@ -0,0 +1,138 @@ +using HslCommunication; +using HslCommunication.Profinet.Inovance; +using HslCommunication.Profinet.Knx; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2106Entity +{ + public class DryerReportEntity + { + private int StartSet; + public DryerReportEntity(int startSet) + { + this.StartSet = startSet; + } + public Dryer_ Dryer_A => new Dryer_(StartSet); + public Dryer_ Dryer_B => new Dryer_(StartSet + 268); + public Dryer_ Dryer_C => new Dryer_(StartSet + 536); + public Dryer_ Dryer_D => new Dryer_(StartSet + 804); + } + + public class Dryer_ + { + private int StartSet; + public Dryer_(int startSet) + { + this.StartSet = startSet; + } + + public List Dos => new ReportArrayManager(4, StartSet, 22).GetReport_DosEList(); + public List Mix => new ReportArrayManager(10, StartSet + 88, 18).GetReport_MixEList(); + } + + public class Report_DosE + { + public Report_DosE(byte[] content) + { + EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14); + ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18); + } + + public Report_DosE(ushort startSet) + { + var read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 22); + var content = read.Content; + + EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + Batch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MatCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + SetValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + SetToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + ActValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 14); + ActToler = PlcConnect.Instance.ByteTransform.TransSingle(content, 18); + } + + public short EqNo { get; private set; } + public short Batch { get; private set; } + public short MatCode { get; private set; } + public float SetValue { get; private set; } + public float SetToler { get; private set; } + public float ActValue { get; private set; } + public float ActToler { get; private set; } + } + + public class Report_MixE + { + public Report_MixE(byte[] content) + { + EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + MixBatch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MixStep = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + ActCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 6); + MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 8); + MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 14); + } + + + public short EqNo { get; private set; } + public short MixBatch { get; private set; } + public short MixStep { get; private set; } + public short ActCode { get; private set; } + public short MixTime { get; private set; } + public float MixTemp { get; private set; } + public float MixSpeed { get; private set; } + + } + + public class ReportArrayManager + { + private int Length; + private int StartSet; + private int SLength; + + public ReportArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetReport_MixEList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Report_MixE(singleBlock)); + } + return ListE; + } + + public List GetReport_DosEList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Report_DosE(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2106Entity/GelReportEntity.cs b/DataBlockHelper/Entity/DB2106Entity/GelReportEntity.cs new file mode 100644 index 0000000..256a299 --- /dev/null +++ b/DataBlockHelper/Entity/DB2106Entity/GelReportEntity.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2106Entity +{ + public class GelReportEntity + { + private int StartSet; + public GelReportEntity(int startSet) + { + this.StartSet = startSet; + } + public Gel_ Gel_A => new Gel_(StartSet); + public Gel_ Gel_B => new Gel_(StartSet + 312); + public Gel_ Gel_C => new Gel_(StartSet + 624); + public Gel_ Gel_D => new Gel_(StartSet + 936); + public Gel_ Gel_E => new Gel_(StartSet + 1248); + public Gel_ Gel_F => new Gel_(StartSet + 1560); + public Gel_ Gel_G => new Gel_(StartSet + 1872); + public Gel_ Gel_H => new Gel_(StartSet + 2184); + } + + public class Gel_ + { + private int StartSet; + public Gel_(int startSet) + { + this.StartSet = startSet; + } + + public List GelDosing => new ReportArrayManager(4, StartSet, 22).GetReport_DosEList(); + public Report_DosE HotWater => new Report_DosE(Convert.ToUInt16(StartSet + 88)); + public Report_DosE CoolWater => new Report_DosE(Convert.ToUInt16(StartSet + 110)); + public List GelMixing => new ReportArrayManager(10, StartSet + 132, 18).GetReport_MixEList(); + } + + + + + + +} diff --git a/DataBlockHelper/Entity/DB2106Entity/WetReportEntity.cs b/DataBlockHelper/Entity/DB2106Entity/WetReportEntity.cs new file mode 100644 index 0000000..3dafe49 --- /dev/null +++ b/DataBlockHelper/Entity/DB2106Entity/WetReportEntity.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2106Entity +{ + public class WetMixingEntity + { + private int StartSet; + public WetMixingEntity(int startSet) + { + this.StartSet = startSet; + } + + public List WetMixing_A => new WetReportArrayManager(10, StartSet, 26).GetList(); + public List WetMixing_B => new WetReportArrayManager(10, StartSet + 260, 26).GetList(); + public List WetMixing_C => new WetReportArrayManager(10, StartSet + 520, 26).GetList(); + public List WetMixing_D => new WetReportArrayManager(10, StartSet + 780, 26).GetList(); + public List WetMixing_E => new WetReportArrayManager(10, StartSet + 1040, 26).GetList(); + public List WetMixing_F => new WetReportArrayManager(10, StartSet + 1300, 26).GetList(); + public List WetMixing_G => new WetReportArrayManager(10, StartSet + 1560, 26).GetList(); + public List WetMixing_H => new WetReportArrayManager(10, StartSet + 1820, 26).GetList(); + + + } + + + + public class Report_WMixE + { + public Report_WMixE(byte[] content) + { + EqNo = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + MixBatch = PlcConnect.Instance.ByteTransform.TransInt16(content, 2); + MixStep = PlcConnect.Instance.ByteTransform.TransInt16(content, 4); + ActCode = PlcConnect.Instance.ByteTransform.TransInt16(content, 6); + MixTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 8); + MixTemp = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + MixSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 14); + ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 18); + ActTolerence = PlcConnect.Instance.ByteTransform.TransSingle(content, 22); + + } + + public short EqNo { get; private set; } + public short MixBatch { get; private set; } + public short MixStep { get; private set; } + public short ActCode { get; private set; } + public short MixTime { get; private set; } + public float MixTemp { get; private set; } + public float MixSpeed { get; private set; } + public float ActWeight { get; private set; } + public float ActTolerence { get; private set; } + + } + + public class WetReportArrayManager + { + private int Length; + private int StartSet; + private int SLength; + + public WetReportArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2106." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new Report_WMixE(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/ControlSignEntity.cs b/DataBlockHelper/Entity/DB2107Entity/ControlSignEntity.cs new file mode 100644 index 0000000..3530aff --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/ControlSignEntity.cs @@ -0,0 +1,39 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class ControlSignEntity + { + public ControlSignEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2107.10.0", 2); + + var content = read.Content; + + byte byt = content[0]; + + AutoMode = byt.GetBit(0); + LocMode = byt.GetBit(1); + TestMode = byt.GetBit(2); + Start = byt.GetBit(3); + Pause = byt.GetBit(4); + Stop = byt.GetBit(5); + Reset = byt.GetBit(6); + AlarmAck = byt.GetBit(7); + + byt = content[1]; + + LampTest = byt.GetBit(0); + } + public bool AutoMode { get; private set; } + public bool LocMode { get; private set; } + public bool TestMode { get; private set; } + public bool Start { get; private set; } + public bool Pause { get; private set; } + public bool Stop { get; private set; } + public bool Reset { get; private set; } + public bool AlarmAck { get; private set; } + public bool LampTest { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/LevelEntity.cs b/DataBlockHelper/Entity/DB2107Entity/LevelEntity.cs new file mode 100644 index 0000000..f2b2366 --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/LevelEntity.cs @@ -0,0 +1,77 @@ +using HslCommunication; + + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class LevelEntity + { + public LevelEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2107.2060.0", 3); + + var content = read.Content; + + byte byt = content[0]; + + LowLevel_D1 = byt.GetBit(0); + HighLevel_D1 = byt.GetBit(1); + LowLevel_D2 = byt.GetBit(2); + HighLevel_D2 = byt.GetBit(3); + LowLevel_D3 = byt.GetBit(4); + HighLevel_D3 = byt.GetBit(5); + LowLevel_D4 = byt.GetBit(6); + HighLevel_D4 = byt.GetBit(7); + + byt = content[1]; + + LowLevel_D5 = byt.GetBit(0); + HighLevel_D5 = byt.GetBit(1); + LowLevel_D6 = byt.GetBit(2); + HighLevel_D6 = byt.GetBit(3); + LowLevel_D7 = byt.GetBit(4); + HighLevel_D7 = byt.GetBit(5); + LowLevel_D8 = byt.GetBit(6); + HighLevel_D8 = byt.GetBit(7); + + byt = content[2]; + + LowLevel_D9 = byt.GetBit(0); + HighLevel_D9 = byt.GetBit(1); + LowLevel_D10 = byt.GetBit(2); + HighLevel_D10 = byt.GetBit(3); + LowLevel_D11 = byt.GetBit(4); + HighLevel_D11 = byt.GetBit(5); + LowLevel_D12 = byt.GetBit(6); + HighLevel_D12 = byt.GetBit(7); + + } + + public bool LowLevel_D1 { get; private set; } + public bool HighLevel_D1 { get; private set; } + public bool LowLevel_D2 { get; private set; } + public bool HighLevel_D2 { get; private set; } + public bool LowLevel_D3 { get; private set; } + public bool HighLevel_D3 { get; private set; } + public bool LowLevel_D4 { get; private set; } + public bool HighLevel_D4 { get; private set; } + public bool LowLevel_D5 { get; private set; } + public bool HighLevel_D5 { get; private set; } + public bool LowLevel_D6 { get; private set; } + public bool HighLevel_D6 { get; private set; } + public bool LowLevel_D7 { get; private set; } + public bool HighLevel_D7 { get; private set; } + public bool LowLevel_D8 { get; private set; } + public bool HighLevel_D8 { get; private set; } + public bool LowLevel_D9 { get; private set; } + public bool HighLevel_D9 { get; private set; } + public bool LowLevel_D10 { get; private set; } + public bool HighLevel_D10 { get; private set; } + public bool LowLevel_D11 { get; private set; } + public bool HighLevel_D11 { get; private set; } + public bool LowLevel_D12 { get; private set; } + public bool HighLevel_D12 { get; private set; } + + } +} + diff --git a/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs b/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs new file mode 100644 index 0000000..ba215e0 --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/NormalStatusEntity.cs @@ -0,0 +1,102 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class NormalStatusEntity + { + public NormalStatusEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2107.2.0", 7); + + var content = read.Content; + + WatchDog = PlcConnect.Instance.ByteTransform.TransInt16(content, 0); + + byte byt = content[2]; + + RecipeRun = byt.GetBit(0); + RecipePause = byt.GetBit(1); + Ready = byt.GetBit(2); + Alarm = byt.GetBit(3); + EMStop = byt.GetBit(4); + RdyRpt_V1 = byt.GetBit(5); + RdyRpt_V2 = byt.GetBit(6); + RdyRpt_V3 = byt.GetBit(7); + + byt = content[3]; + + RdyRpt_V4 = byt.GetBit(0); + RdyRpt_V5 = byt.GetBit(1); + RdyRpt_W1 = byt.GetBit(2); + RdyRpt_W2 = byt.GetBit(3); + RdyRpt_W3 = byt.GetBit(4); + RdyRpt_W4 = byt.GetBit(5); + RdyRpt_D1 = byt.GetBit(6); + RdyRpt_D2 = byt.GetBit(7); + + byt = content[4]; + + RdyRpt_D3 = byt.GetBit(0); + RdyRpt_D4 = byt.GetBit(1); + RdyRpt_G1 = byt.GetBit(2); + RdyRpt_G2 = byt.GetBit(3); + RdyRpt_G3 = byt.GetBit(4); + RdyRpt_G4 = byt.GetBit(5); + RdyRpt_G5 = byt.GetBit(6); + RdyRpt_G6 = byt.GetBit(7); + + byt = content[5]; + + RdyRpt_G7 = byt.GetBit(0); + RdyRpt_G8 = byt.GetBit(1); + RdyRpt_M1 = byt.GetBit(2); + RdyRpt_M2 = byt.GetBit(3); + RdyRpt_M3 = byt.GetBit(4); + RdyRpt_M4 = byt.GetBit(5); + RdyRpt_M5 = byt.GetBit(6); + RdyRpt_M6 = byt.GetBit(7); + + byt = content[6]; + + RdyRpt_M7 = byt.GetBit(0); + RdyRpt_M8 = byt.GetBit(1); + } + + public int WatchDog { get; private set; } + public bool RecipeRun { get; private set; } + public bool RecipePause { get; private set; } + public bool Ready { get; private set; } + public bool Alarm { get; private set; } + public bool EMStop { get; private set; } + public bool RdyRpt_V1 { get; private set; } + public bool RdyRpt_V2 { get; private set; } + public bool RdyRpt_V3 { get; private set; } + public bool RdyRpt_V4 { get; private set; } + public bool RdyRpt_V5 { get; private set; } + public bool RdyRpt_W1 { get; private set; } + public bool RdyRpt_W2 { get; private set; } + public bool RdyRpt_W3 { get; private set; } + public bool RdyRpt_W4 { get; private set; } + public bool RdyRpt_D1 { get; private set; } + public bool RdyRpt_D2 { get; private set; } + public bool RdyRpt_D3 { get; private set; } + public bool RdyRpt_D4 { get; private set; } + public bool RdyRpt_G1 { get; private set; } + public bool RdyRpt_G2 { get; private set; } + public bool RdyRpt_G3 { get; private set; } + public bool RdyRpt_G4 { get; private set; } + public bool RdyRpt_G5 { get; private set; } + public bool RdyRpt_G6 { get; private set; } + public bool RdyRpt_G7 { get; private set; } + public bool RdyRpt_G8 { get; private set; } + public bool RdyRpt_M1 { get; private set; } + public bool RdyRpt_M2 { get; private set; } + public bool RdyRpt_M3 { get; private set; } + public bool RdyRpt_M4 { get; private set; } + public bool RdyRpt_M5 { get; private set; } + public bool RdyRpt_M6 { get; private set; } + public bool RdyRpt_M7 { get; private set; } + public bool RdyRpt_M8 { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/PIDEntity.cs b/DataBlockHelper/Entity/DB2107Entity/PIDEntity.cs new file mode 100644 index 0000000..0137d04 --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/PIDEntity.cs @@ -0,0 +1,35 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class PIDEntity + { + public PID_HMI Convey_V1 => new PID_HMI(614); + public PID_HMI Purge_V1 => new PID_HMI(622); + public PID_HMI Convey_V2 => new PID_HMI(630); + public PID_HMI Purge_V2 => new PID_HMI(638); + public PID_HMI Convey_V3 => new PID_HMI(646); + public PID_HMI Purge_V3 => new PID_HMI(654); + public PID_HMI Convey_V4 => new PID_HMI(662); + public PID_HMI Purge_V4 => new PID_HMI(670); + public PID_HMI Convey_V5 => new PID_HMI(678); + public PID_HMI Purge_V5 => new PID_HMI(686); + } + + public class PID_HMI + { + public PID_HMI(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 8); + + var content = read.Content; + + PV = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); + SV = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + } + + public float PV { get; private set; } + public float SV { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/PressureEntity.cs b/DataBlockHelper/Entity/DB2107Entity/PressureEntity.cs new file mode 100644 index 0000000..289474b --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/PressureEntity.cs @@ -0,0 +1,67 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class PressureEntity + { + public Pressure_HMI MainPress_V1 => new Pressure_HMI(12); + public Pressure_HMI TopPressure_V1 => new Pressure_HMI(26); + public Pressure_HMI LinePressure_V1 => new Pressure_HMI(40); + public Pressure_HMI MainPress_V2 => new Pressure_HMI(54); + public Pressure_HMI TopPressure_V2 => new Pressure_HMI(68); + public Pressure_HMI LinePressure_V2 => new Pressure_HMI(82); + public Pressure_HMI MainPress_V3 => new Pressure_HMI(96); + public Pressure_HMI TopPressure_V3 => new Pressure_HMI(110); + public Pressure_HMI LinePressure_V3 => new Pressure_HMI(124); + public Pressure_HMI MainPress_V4 => new Pressure_HMI(138); + public Pressure_HMI TopPressure_V4 => new Pressure_HMI(152); + public Pressure_HMI LinePressure_V4 => new Pressure_HMI(166); + public Pressure_HMI MainPress_V5 => new Pressure_HMI(180); + public Pressure_HMI TopPressure_V5 => new Pressure_HMI(194); + public Pressure_HMI LinePressure_V5 => new Pressure_HMI(208); + public Pressure_HMI PressDaybin_B1 => new Pressure_HMI(222); + public Pressure_HMI PressDaybin_B2 => new Pressure_HMI(236); + public Pressure_HMI PressDaybin_B3 => new Pressure_HMI(250); + public Pressure_HMI PressDaybin_B4 => new Pressure_HMI(264); + public Pressure_HMI PressDaybin_B5 => new Pressure_HMI(278); + public Pressure_HMI PressDaybin_B6 => new Pressure_HMI(292); + public Pressure_HMI PressDaybin_B7 => new Pressure_HMI(306); + public Pressure_HMI PressDaybin_B8 => new Pressure_HMI(320); + public Pressure_HMI PressDaybin_B9 => new Pressure_HMI(334); + public Pressure_HMI PressDaybin_B10 => new Pressure_HMI(348); + public Pressure_HMI PressDaybin_B11 => new Pressure_HMI(362); + public Pressure_HMI PressDaybin_B12 => new Pressure_HMI(376); + public Pressure_HMI PR2PCP01 => new Pressure_HMI(390); + public Pressure_HMI PR2PCP02 => new Pressure_HMI(404); + public Pressure_HMI PR2PCP03 => new Pressure_HMI(418); + + + } + + public class Pressure_HMI + { + public Pressure_HMI(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 14); + + var content = read.Content; + + ActualValue = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); + LowLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + HighLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + + byte byt = content[12]; + + Alarm = byt.GetBit(0); + + } + + public float ActualValue { get; private set; } + public float LowLimit { get; private set; } + public float HighLimit { get; private set; } + public bool Alarm { get; private set; } + } + + +} diff --git a/DataBlockHelper/Entity/DB2107Entity/SpeedEntity.cs b/DataBlockHelper/Entity/DB2107Entity/SpeedEntity.cs new file mode 100644 index 0000000..74cfb9f --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/SpeedEntity.cs @@ -0,0 +1,63 @@ +using HslCommunication; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class SpeedEntity + { + public SpeedEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2107.1324.0", 84); + + var content = read.Content; + + ManSpeed_D1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); + ManSpeed_D2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + ManSpeed_D3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + ManSpeed_D4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 12); + ManSpeed_G1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 16); + ManSpeed_G2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 20); + ManSpeed_G3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 24); + ManSpeed_G4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 28); + ManSpeed_G5 = PlcConnect.Instance.ByteTransform.TransSingle(content, 32); + ManSpeed_G6 = PlcConnect.Instance.ByteTransform.TransSingle(content, 36); + ManSpeed_G7 = PlcConnect.Instance.ByteTransform.TransSingle(content, 40); + ManSpeed_G8 = PlcConnect.Instance.ByteTransform.TransSingle(content, 44); + ManSpeed_H1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 48); + ManSpeed_H2 = PlcConnect.Instance.ByteTransform.TransSingle(content, 52); + ManSpeed_H3 = PlcConnect.Instance.ByteTransform.TransSingle(content, 56); + ManSpeed_H4 = PlcConnect.Instance.ByteTransform.TransSingle(content, 60); + ManSpeed_S1 = PlcConnect.Instance.ByteTransform.TransSingle(content, 64); + ManSpeed_S5 = PlcConnect.Instance.ByteTransform.TransSingle(content, 68); + ManSpeed_S7 = PlcConnect.Instance.ByteTransform.TransSingle(content, 72); + ManSpeed_S11 = PlcConnect.Instance.ByteTransform.TransSingle(content, 76); + ManSpeed_S15 = PlcConnect.Instance.ByteTransform.TransSingle(content, 80); + } + + public float ManSpeed_D1 { get; private set; } + public float ManSpeed_D2 { get; private set; } + public float ManSpeed_D3 { get; private set; } + public float ManSpeed_D4 { get; private set; } + public float ManSpeed_G1 { get; private set; } + public float ManSpeed_G2 { get; private set; } + public float ManSpeed_G3 { get; private set; } + public float ManSpeed_G4 { get; private set; } + public float ManSpeed_G5 { get; private set; } + public float ManSpeed_G6 { get; private set; } + public float ManSpeed_G7 { get; private set; } + public float ManSpeed_G8 { get; private set; } + public float ManSpeed_H1 { get; private set; } + public float ManSpeed_H2 { get; private set; } + public float ManSpeed_H3 { get; private set; } + public float ManSpeed_H4 { get; private set; } + public float ManSpeed_S1 { get; private set; } + public float ManSpeed_S5 { get; private set; } + public float ManSpeed_S7 { get; private set; } + public float ManSpeed_S11 { get; private set; } + public float ManSpeed_S15 { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/UntiStatusHMIArrayEntity.cs b/DataBlockHelper/Entity/DB2107Entity/UntiStatusHMIArrayEntity.cs new file mode 100644 index 0000000..adf1d6d --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/UntiStatusHMIArrayEntity.cs @@ -0,0 +1,74 @@ + +using System; +using System.Collections.Generic; +using System.Linq; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class UntiStatusHMIArrayEntity + { + public UntiStatusHMIArrayEntity(byte[] content) + { + + + byte byt = content[0]; + Mode = byt.GetBit(0); + Status = byt.GetBit(1); + + Batch = PlcConnect.Instance.ByteTransform.TransUInt16(content, 2); + Step = PlcConnect.Instance.ByteTransform.TransUInt16(content, 4); + StepCode = PlcConnect.Instance.ByteTransform.TransUInt16(content, 6); + TotalTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 8); + StepTime = PlcConnect.Instance.ByteTransform.TransInt32(content, 12); + Temperature = PlcConnect.Instance.ByteTransform.TransSingle(content, 16); + Speed = PlcConnect.Instance.ByteTransform.TransSingle(content, 20); + Currnet = PlcConnect.Instance.ByteTransform.TransSingle(content, 24); + Pressure = PlcConnect.Instance.ByteTransform.TransSingle(content, 28); + } + + public bool Mode { get; private set; } + public bool Status { get; private set; } + public ushort Batch { get; private set; } + public ushort Step { get; private set; } + public ushort StepCode { get; private set; } + public int TotalTime { get; private set; } + public int StepTime { get; private set; } + public float Temperature { get; private set; } + public float Speed { get; private set; } + public float Currnet { get; private set; } + public float Pressure { get; private set; } + } + + + public class UntiStatusHMIArrayManager + { + private int Length; + private int StartSet; + private int SLength; + public UntiStatusHMIArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + if (!getListE.IsSuccess) + { + throw new Exception(getListE.Message); + } + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new UntiStatusHMIArrayEntity(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/ValveEntity.cs b/DataBlockHelper/Entity/DB2107Entity/ValveEntity.cs new file mode 100644 index 0000000..fd2d461 --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/ValveEntity.cs @@ -0,0 +1,220 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class ValveEntity + { + public ValveEntity() + { + OperateResult read = PlcConnect.Instance.Read("DB2107.2048.0", 11); + + var content = read.Content; + + byte byt = content[0]; + + AS1BLT01 = byt.GetBit(0); + AS1BLT02 = byt.GetBit(1); + AS1BLT03 = byt.GetBit(2); + AS1BLT04 = byt.GetBit(3); + AS1BLT05 = byt.GetBit(4); + AS2BLT01 = byt.GetBit(5); + AS2BLT02 = byt.GetBit(6); + AS2BLT03 = byt.GetBit(7); + + byt = content[1]; + + AS2BLT04 = byt.GetBit(0); + AS2BLT05 = byt.GetBit(1); + AS3BLT01 = byt.GetBit(2); + AS3BLT02 = byt.GetBit(3); + AS3BLT03 = byt.GetBit(4); + AS3BLT04 = byt.GetBit(5); + AS3BLT05 = byt.GetBit(6); + AS4BLT01 = byt.GetBit(7); + + byt = content[2]; + + AS4BLT02 = byt.GetBit(0); + AS4BLT03 = byt.GetBit(1); + AS4BLT04 = byt.GetBit(2); + AS4BLT05 = byt.GetBit(3); + AS5BLT01 = byt.GetBit(4); + AS5BLT02 = byt.GetBit(5); + AS5BLT03 = byt.GetBit(6); + AS5BLT04 = byt.GetBit(7); + + byt = content[3]; + + AS5BLT05 = byt.GetBit(0); + AS1OIS01 = byt.GetBit(1); + AS1OIS02 = byt.GetBit(2); + AS1OIS03 = byt.GetBit(3); + AS2OIS01 = byt.GetBit(4); + AS2OIS02 = byt.GetBit(5); + AS2OIS03 = byt.GetBit(6); + AS3OIS01 = byt.GetBit(7); + + byt = content[4]; + + AS3OIS02 = byt.GetBit(0); + AS3OIS03 = byt.GetBit(1); + AS4OIS01 = byt.GetBit(2); + AS4OIS02 = byt.GetBit(3); + AS4OIS03 = byt.GetBit(4); + AS2PCP01 = byt.GetBit(5); + AS2PCP02 = byt.GetBit(6); + AS2PCP03 = byt.GetBit(7); + + byt = content[5]; + + PV1ADB01 = byt.GetBit(0); + PV1BDB01 = byt.GetBit(1); + PV1CDB01 = byt.GetBit(2); + PV1DDB01 = byt.GetBit(3); + PV1EDB01 = byt.GetBit(4); + PV1FDB01 = byt.GetBit(5); + PV1GDB01 = byt.GetBit(6); + PV1HDB01 = byt.GetBit(7); + + byt = content[6]; + + PV1IDB01 = byt.GetBit(0); + PV1JDB01 = byt.GetBit(1); + PV1KDB01 = byt.GetBit(2); + PV1LDB01 = byt.GetBit(3); + PM1ADF01 = byt.GetBit(4); + PM1BDF01 = byt.GetBit(5); + PM1CDF01 = byt.GetBit(6); + PM1DDF01 = byt.GetBit(7); + + byt = content[7]; + + PM1EDF01 = byt.GetBit(0); + PM1FDF01 = byt.GetBit(1); + PM1GDF01 = byt.GetBit(2); + PM1HDF01 = byt.GetBit(3); + PM1IDF01 = byt.GetBit(4); + PM1JDF01 = byt.GetBit(5); + PM1KDF01 = byt.GetBit(6); + PM1LDF01 = byt.GetBit(7); + + byt = content[8]; + + PV2ADB01 = byt.GetBit(0); + PV2BDB01 = byt.GetBit(1); + PV2CDB01 = byt.GetBit(2); + PV2DDB01 = byt.GetBit(3); + AS1GET01 = byt.GetBit(4); + AS1GET02 = byt.GetBit(5); + AS2GET01 = byt.GetBit(6); + AS2GET02 = byt.GetBit(7); + + byt = content[9]; + + AS3GET01 = byt.GetBit(0); + AS3GET02 = byt.GetBit(1); + AS4GET01 = byt.GetBit(2); + AS4GET02 = byt.GetBit(3); + AS5GET01 = byt.GetBit(4); + AS5GET02 = byt.GetBit(5); + AS6GET01 = byt.GetBit(6); + AS6GET02 = byt.GetBit(7); + + byt = content[10]; + + AS7GET01 = byt.GetBit(0); + AS7GET02 = byt.GetBit(1); + AS8GET01 = byt.GetBit(2); + AS8GET02 = byt.GetBit(3); + + } + + public bool AS1BLT01 { get; private set; } + public bool AS1BLT02 { get; private set; } + public bool AS1BLT03 { get; private set; } + public bool AS1BLT04 { get; private set; } + public bool AS1BLT05 { get; private set; } + public bool AS2BLT01 { get; private set; } + public bool AS2BLT02 { get; private set; } + public bool AS2BLT03 { get; private set; } + public bool AS2BLT04 { get; private set; } + public bool AS2BLT05 { get; private set; } + public bool AS3BLT01 { get; private set; } + public bool AS3BLT02 { get; private set; } + public bool AS3BLT03 { get; private set; } + public bool AS3BLT04 { get; private set; } + public bool AS3BLT05 { get; private set; } + public bool AS4BLT01 { get; private set; } + public bool AS4BLT02 { get; private set; } + public bool AS4BLT03 { get; private set; } + public bool AS4BLT04 { get; private set; } + public bool AS4BLT05 { get; private set; } + public bool AS5BLT01 { get; private set; } + public bool AS5BLT02 { get; private set; } + public bool AS5BLT03 { get; private set; } + public bool AS5BLT04 { get; private set; } + public bool AS5BLT05 { get; private set; } + public bool AS1OIS01 { get; private set; } + public bool AS1OIS02 { get; private set; } + public bool AS1OIS03 { get; private set; } + public bool AS2OIS01 { get; private set; } + public bool AS2OIS02 { get; private set; } + public bool AS2OIS03 { get; private set; } + public bool AS3OIS01 { get; private set; } + public bool AS3OIS02 { get; private set; } + public bool AS3OIS03 { get; private set; } + public bool AS4OIS01 { get; private set; } + public bool AS4OIS02 { get; private set; } + public bool AS4OIS03 { get; private set; } + public bool AS2PCP01 { get; private set; } + public bool AS2PCP02 { get; private set; } + public bool AS2PCP03 { get; private set; } + public bool PV1ADB01 { get; private set; } + public bool PV1BDB01 { get; private set; } + public bool PV1CDB01 { get; private set; } + public bool PV1DDB01 { get; private set; } + public bool PV1EDB01 { get; private set; } + public bool PV1FDB01 { get; private set; } + public bool PV1GDB01 { get; private set; } + public bool PV1HDB01 { get; private set; } + public bool PV1IDB01 { get; private set; } + public bool PV1JDB01 { get; private set; } + public bool PV1KDB01 { get; private set; } + public bool PV1LDB01 { get; private set; } + public bool PM1ADF01 { get; private set; } + public bool PM1BDF01 { get; private set; } + public bool PM1CDF01 { get; private set; } + public bool PM1DDF01 { get; private set; } + public bool PM1EDF01 { get; private set; } + public bool PM1FDF01 { get; private set; } + public bool PM1GDF01 { get; private set; } + public bool PM1HDF01 { get; private set; } + public bool PM1IDF01 { get; private set; } + public bool PM1JDF01 { get; private set; } + public bool PM1KDF01 { get; private set; } + public bool PM1LDF01 { get; private set; } + public bool PV2ADB01 { get; private set; } + public bool PV2BDB01 { get; private set; } + public bool PV2CDB01 { get; private set; } + public bool PV2DDB01 { get; private set; } + public bool AS1GET01 { get; private set; } + public bool AS1GET02 { get; private set; } + public bool AS2GET01 { get; private set; } + public bool AS2GET02 { get; private set; } + public bool AS3GET01 { get; private set; } + public bool AS3GET02 { get; private set; } + public bool AS4GET01 { get; private set; } + public bool AS4GET02 { get; private set; } + public bool AS5GET01 { get; private set; } + public bool AS5GET02 { get; private set; } + public bool AS6GET01 { get; private set; } + public bool AS6GET02 { get; private set; } + public bool AS7GET01 { get; private set; } + public bool AS7GET02 { get; private set; } + public bool AS8GET01 { get; private set; } + public bool AS8GET02 { get; private set; } + + + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/WeightEntity.cs b/DataBlockHelper/Entity/DB2107Entity/WeightEntity.cs new file mode 100644 index 0000000..0d41da0 --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/WeightEntity.cs @@ -0,0 +1,49 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class WeightEntity + { + public Silo_HMI Hopper_1 => new Silo_HMI(432); + public Silo_HMI Hopper_2 => new Silo_HMI(446); + public Silo_HMI Hopper_3 => new Silo_HMI(460); + public Silo_HMI Hopper_4 => new Silo_HMI(474); + public Silo_HMI Vessel_1 => new Silo_HMI(488); + public Silo_HMI Vessel_2 => new Silo_HMI(502); + public Silo_HMI Vessel_3 => new Silo_HMI(516); + public Silo_HMI Vessel_4 => new Silo_HMI(530); + public Silo_HMI Vessel_5 => new Silo_HMI(544); + public Silo_HMI WScale_1 => new Silo_HMI(558); + public Silo_HMI WScale_2 => new Silo_HMI(572); + public Silo_HMI WScale_3 => new Silo_HMI(586); + public Silo_HMI WScale_4 => new Silo_HMI(600); + + } + + public class Silo_HMI + { + public Silo_HMI(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB2107." + startSet + ".0", 14); + + var content = read.Content; + + ActWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); + HighWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + LowWeight = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + + byte byt = content[12]; + + HighLevel = byt.GetBit(0); + Lowlevel = byt.GetBit(1); + } + + public float ActWeight { get; private set; } + public float HighWeight { get; private set; } + public float LowWeight { get; private set; } + public bool HighLevel { get; private set; } + public bool Lowlevel { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB2107Entity/WeightPraEntity.cs b/DataBlockHelper/Entity/DB2107Entity/WeightPraEntity.cs new file mode 100644 index 0000000..5a3e7af --- /dev/null +++ b/DataBlockHelper/Entity/DB2107Entity/WeightPraEntity.cs @@ -0,0 +1,66 @@ +using Microsoft.VisualBasic; +using System; +using System.Collections.Generic; +using System.Linq; + + +namespace DataBlockHelper.Entity.DB2107Entity +{ + public class WeightPraEntity + { + public List Silo => new WeightParaArrayManager(15, 694, 18).GetList(); + public List Daybin => new WeightParaArrayManager(12, 964, 18).GetList(); + public List Hoper => new WeightParaArrayManager(4, 1180, 18).GetList(); + public List Water => new WeightParaArrayManager(4, 1252, 18).GetList(); + } + + + + public class WeightParaE + { + public WeightParaE(byte[] content) + { + HighSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 0); + LowSpeed = PlcConnect.Instance.ByteTransform.TransSingle(content, 4); + WeightSlow = PlcConnect.Instance.ByteTransform.TransSingle(content, 8); + Precut = PlcConnect.Instance.ByteTransform.TransSingle(content, 12); + JogTime = PlcConnect.Instance.ByteTransform.TransInt16(content, 16); + + } + + public float HighSpeed { get; private set; } + public float LowSpeed { get; private set; } + public float WeightSlow { get; private set; } + public float Precut { get; private set; } + public int JogTime { get; private set; } + + } + + public class WeightParaArrayManager + { + private int Length; + private int StartSet; + private int SLength; + + public WeightParaArrayManager(ushort length, int startSet, int sLength) + { + Length = length; + StartSet = startSet; + SLength = sLength; + } + + public List GetList() + { + List ListE = new List(Length); + var getListE = PlcConnect.Instance.Read("DB2107." + StartSet + ".0", Convert.ToUInt16(Length * SLength)); + var content = getListE.Content; + + for (int i = 0; i < Length; i++) + { + var singleBlock = content.Skip(SLength * i).Take(SLength).ToArray(); + ListE.Add(new WeightParaE(singleBlock)); + } + return ListE; + } + } +} diff --git a/DataBlockHelper/Entity/DB90Entity/ForValveDoubleEntity.cs b/DataBlockHelper/Entity/DB90Entity/ForValveDoubleEntity.cs new file mode 100644 index 0000000..09b1e82 --- /dev/null +++ b/DataBlockHelper/Entity/DB90Entity/ForValveDoubleEntity.cs @@ -0,0 +1,51 @@ +using HslCommunication; + +namespace DataBlockHelper.Entity.DB90Entity +{ + public class ForValveDoubleEntity + { + public ForValveDoubleEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB90." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + SetLeftManual = byt.GetBit(2); + SetRightManual = byt.GetBit(3); + SetLeftAuto = byt.GetBit(4); + SetRightAuto = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + LeftPosition = byt.GetBit(7); + + byt = content[1]; + + RightPosition = byt.GetBit(0); + SetLeft = byt.GetBit(1); + SetRight = byt.GetBit(2); + AlarmLeftPosition = byt.GetBit(3); + AlarmRightPosition = byt.GetBit(4); + AlarmPosition = byt.GetBit(4); + Alarm = byt.GetBit(4); + } + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool SetLeftManual { get; private set; } + public bool SetRightManual { get; private set; } + public bool SetLeftAuto { get; private set; } + public bool SetRightAuto { get; private set; } + public bool AlarmReset { get; private set; } + public bool LeftPosition { get; private set; } + public bool RightPosition { get; private set; } + public bool SetLeft { get; private set; } + public bool SetRight { get; private set; } + public bool AlarmLeftPosition { get; private set; } + public bool AlarmRightPosition { get; private set; } + public bool AlarmPosition { get; private set; } + public bool Alarm { get; private set; } + } +} + diff --git a/DataBlockHelper/Entity/DB90Entity/ForValveSingleEntity.cs b/DataBlockHelper/Entity/DB90Entity/ForValveSingleEntity.cs new file mode 100644 index 0000000..0c94a3f --- /dev/null +++ b/DataBlockHelper/Entity/DB90Entity/ForValveSingleEntity.cs @@ -0,0 +1,44 @@ +using HslCommunication; + +namespace DataBlockHelper.Entity.DB90Entity +{ + public class ForValveSingleEntity + { + public ForValveSingleEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB90." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + SetManual = byt.GetBit(2); + SetAuto = byt.GetBit(3); + AlarmReset = byt.GetBit(4); + SetPosition = byt.GetBit(5); + UnSetPosition = byt.GetBit(6); + + byt = content[1]; + + Set = byt.GetBit(0); + AlarmSetPos = byt.GetBit(1); + AlarmUnSetPos = byt.GetBit(2); + AlarmPosition = byt.GetBit(3); + Alarm = byt.GetBit(4); + } + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool SetManual { get; private set; } + public bool SetAuto { get; private set; } + public bool AlarmReset { get; private set; } + public bool SetPosition { get; private set; } + public bool UnSetPosition { get; private set; } + public bool Set { get; private set; } + public bool AlarmSetPos { get; private set; } + public bool AlarmUnSetPos { get; private set; } + public bool AlarmPosition { get; private set; } + public bool Alarm { get; private set; } + } +} diff --git a/DataBlockHelper/Entity/DB91Entity/ForMotorEntity.cs b/DataBlockHelper/Entity/DB91Entity/ForMotorEntity.cs new file mode 100644 index 0000000..5cd4f39 --- /dev/null +++ b/DataBlockHelper/Entity/DB91Entity/ForMotorEntity.cs @@ -0,0 +1,43 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB91Entity +{ + public class ForMotorEntity + { + public ForMotorEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB91." + startSet + ".0", 2); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + StartManual = byt.GetBit(2); + StopManual = byt.GetBit(3); + StartAuto = byt.GetBit(4); + StopAuto = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + Running = byt.GetBit(7); + + byt = content[1]; + + Run = byt.GetBit(0); + Alarm = byt.GetBit(1); + } + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool StartManual { get; private set; } + public bool StopManual { get; private set; } + public bool StartAuto { get; private set; } + public bool StopAuto { get; private set; } + public bool AlarmReset { get; private set; } + public bool Running { get; private set; } + public bool Run { get; private set; } + public bool Alarm { get; private set; } + + + } +} diff --git a/DataBlockHelper/Entity/DB91Entity/ForMotorSToTEntity.cs b/DataBlockHelper/Entity/DB91Entity/ForMotorSToTEntity.cs new file mode 100644 index 0000000..f2fd493 --- /dev/null +++ b/DataBlockHelper/Entity/DB91Entity/ForMotorSToTEntity.cs @@ -0,0 +1,62 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB91Entity +{ + public class ForMotorSToTEntity + { + public ForMotorSToTEntity(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB91." + startSet + ".0", 8); + + var content = read.Content; + + byte byt = content[0]; + + ManualMode = byt.GetBit(0); + AutoMode = byt.GetBit(1); + StartManual = byt.GetBit(2); + StopManual = byt.GetBit(3); + StartAuto = byt.GetBit(4); + StopAuto = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + Running_M = byt.GetBit(7); + + byt = content[1]; + + Running_S = byt.GetBit(0); + Running_T = byt.GetBit(1); + Run_M = byt.GetBit(2); + Run_S = byt.GetBit(3); + Run_T = byt.GetBit(4); + Alarm = byt.GetBit(5); + Alarm_M = byt.GetBit(6); + Alarm_S = byt.GetBit(7); + + byt = content[2]; + + Alarm_T = byt.GetBit(0); + + STOTTIME = PlcConnect.Instance.ByteTransform.TransInt32(content, 4); + } + public bool ManualMode { get; private set; } + public bool AutoMode { get; private set; } + public bool StartManual { get; private set; } + public bool StopManual { get; private set; } + public bool StartAuto { get; private set; } + public bool StopAuto { get; private set; } + public bool AlarmReset { get; private set; } + public bool Running_M { get; private set; } + public bool Running_S { get; private set; } + public bool Running_T { get; private set; } + public bool Run_M { get; private set; } + public bool Run_S { get; private set; } + public bool Run_T { get; private set; } + public bool Alarm { get; private set; } + public bool Alarm_M { get; private set; } + public bool Alarm_S { get; private set; } + public bool Alarm_T { get; private set; } + public int STOTTIME { get; private set; } + + } +} diff --git a/DataBlockHelper/Entity/DB91Entity/ForMotorVFD.cs b/DataBlockHelper/Entity/DB91Entity/ForMotorVFD.cs new file mode 100644 index 0000000..cf3b1fe --- /dev/null +++ b/DataBlockHelper/Entity/DB91Entity/ForMotorVFD.cs @@ -0,0 +1,62 @@ +using HslCommunication; + + +namespace DataBlockHelper.Entity.DB91Entity +{ + public class ForMotorVFD + { + public ForMotorVFD(ushort startSet) + { + OperateResult read = PlcConnect.Instance.Read("DB91." + startSet + ".0", 14); + + var content = read.Content; + + byte byt = content[0]; + + Auto_BT = byt.GetBit(0); + Man_BT = byt.GetBit(1); + Start_A = byt.GetBit(2); + Stop_A = byt.GetBit(3); + Start_M = byt.GetBit(4); + Stop_M = byt.GetBit(5); + AlarmReset = byt.GetBit(6); + EXT_Estop = byt.GetBit(7); + + byt = content[1]; + + AutoMode = byt.GetBit(0); + ManMode = byt.GetBit(1); + VVVF_OK = byt.GetBit(2); + Running = byt.GetBit(3); + Alarm = byt.GetBit(4); + Error = byt.GetBit(5); + Enable = byt.GetBit(6); + Polarity = byt.GetBit(7); + + SetSpeed_A = PlcConnect.Instance.ByteTransform.TransSingle(content, 2); + SetSpeed_M = PlcConnect.Instance.ByteTransform.TransSingle(content, 6); + ACT_Speed = PlcConnect.Instance.ByteTransform.TransSingle(content, 10); + } + public bool Auto_BT { get; private set; } + public bool Man_BT { get; private set; } + public bool Start_A { get; private set; } + public bool Stop_A { get; private set; } + public bool Start_M { get; private set; } + public bool Stop_M { get; private set; } + public bool AlarmReset { get; private set; } + public bool EXT_Estop { get; private set; } + public bool AutoMode { get; private set; } + public bool ManMode { get; private set; } + public bool VVVF_OK { get; private set; } + public bool Running { get; private set; } + public bool Alarm { get; private set; } + public bool Error { get; private set; } + public bool Enable { get; private set; } + public bool Polarity { get; private set; } + public float SetSpeed_A { get; private set; } + public float SetSpeed_M { get; private set; } + public float ACT_Speed { get; private set; } + + + } +} diff --git a/DataBlockHelper/PlcConnect.cs b/DataBlockHelper/PlcConnect.cs new file mode 100644 index 0000000..35c867b --- /dev/null +++ b/DataBlockHelper/PlcConnect.cs @@ -0,0 +1,58 @@ +using HslCommunication.Instrument.DLT; +using HslCommunication.Profinet.Siemens; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + + +namespace DataBlockHelper +{ + public class PlcConnect + { + + public static PlcConfig Config; + + private static readonly Lazy lazy = new Lazy(() => new PlcConnect().SiemensS7NetConnection()); + public static SiemensS7Net Instance => lazy.Value; + + private PlcConnect() + { + + } + + + public static void Init(PlcConfig config) + { + Config = config ?? new PlcConfig(); + } + + + public SiemensS7Net SiemensS7NetConnection() + { + SiemensPLCS siemensPLCS = SiemensPLCS.S1500; + SiemensS7Net s7 = new SiemensS7Net(siemensPLCS); + s7.IpAddress = Config.IpAddress; + s7.Port = Config.Port; + s7.ConnectServer(); + return s7; + } + } + + + public class PlcConfig + { + public PlcConfig() + { + IpAddress = "192.168.1.50"; + Port = 102; + + } + + public string IpAddress { get; set; } + public int Port { get; set; } + } +} diff --git a/DataBlockHelper/Properties/AssemblyInfo.cs b/DataBlockHelper/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..95b0be3 --- /dev/null +++ b/DataBlockHelper/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DataBlockHelper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DataBlockHelper")] +[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4E36DF17-E81D-4360-8687-8AD75422B470")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SlnMix.VS2013.sln b/SlnMix.VS2013.sln index 7d5ae39..55b580e 100644 --- a/SlnMix.VS2013.sln +++ b/SlnMix.VS2013.sln @@ -165,6 +165,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DoUtils", "DoUtils", "{9F21 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mesnac.DoUtils", "Mesnac.DoUtils\Mesnac.DoUtils.csproj", "{AD132CAD-5288-44DC-A38F-4B0658FC228C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataBlockHelper", "DataBlockHelper\DataBlockHelper.csproj", "{4E36DF17-E81D-4360-8687-8AD75422B470}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -331,6 +333,18 @@ Global {AD132CAD-5288-44DC-A38F-4B0658FC228C}.Release|Mixed Platforms.Build.0 = Release|Any CPU {AD132CAD-5288-44DC-A38F-4B0658FC228C}.Release|x86.ActiveCfg = Release|Any CPU {AD132CAD-5288-44DC-A38F-4B0658FC228C}.Release|x86.Build.0 = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|x86.ActiveCfg = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Debug|x86.Build.0 = Debug|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|Any CPU.Build.0 = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|x86.ActiveCfg = Release|Any CPU + {4E36DF17-E81D-4360-8687-8AD75422B470}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -360,6 +374,7 @@ Global {D0C0324F-434E-47EB-8F7C-BA6CD7F233B4} = {DE938080-4A00-4686-9CE4-1C33FCA86346} {6A2190C6-B530-4D5B-BD34-29EFB0431F67} = {66F3B234-E56C-4EF4-AB6D-BB6D91467855} {AD132CAD-5288-44DC-A38F-4B0658FC228C} = {9F21B6A6-9B19-4AAC-88EF-A430D8808540} + {4E36DF17-E81D-4360-8687-8AD75422B470} = {DE8C4FC3-17D6-4217-8AB1-72ADE8D85810} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {125BF7F5-E6EF-487C-B939-0631965DB3C1}