using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Const; using HybirdFrameworkDriver.ModbusTcpMaster; using log4net; using Service.FireControl.Msg; namespace Service.FireControl.Client; [Scope] public class FireControlClient: ModbusTcpMaster { private static readonly ILog Log = LogManager.GetLogger(typeof(FireControlClient)); public FireControlClient() { ReadAction = BatchRead; Ip = "172.0.50.101"; Port = 502; Duration = 1000; AutoReConnect = true; ByteSeq = EndingConst.ByteSeq.BA; WordSeq= EndingConst.WordSeq.CD; } private void BatchRead(ModbusTcpMaster master) { var bytes02 = master.BatchReadHolderRegister(1, 17);//0x01 var bytes03 = master.BatchReadHolderRegister(1, 3);//0x03 var bytes04 = master.BatchReadHolderRegister(0x0100, 383);//0x03 var bytes05 = master.BatchReadHolderRegister(1, 115);//0x04 var bytes06 = master.BatchReadHolderRegister(0x0800, 2048);//0x04 var bytes07 = master.BatchReadHolderRegister(0x1000, 32);//0x04 var bytes08 = master.BatchReadHolderRegister(0x0000, 134);//0x05 var bytes09 = master.BatchReadHolderRegister(0x0100, 64);//0x06 if (bytes02 != null) { ModbusDecoder.Decode(bytes02, FireControlMgr.Subzone2, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes03 != null) { ModbusDecoder.Decode(bytes03, FireControlMgr.Subzone3, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes04 != null) { ModbusDecoder.Decode(bytes04, FireControlMgr.Subzone4, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes05 != null) { ModbusDecoder.Decode(bytes05, FireControlMgr.Subzone5, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes06 != null) { ModbusDecoder.Decode(bytes06, FireControlMgr.Subzone6, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes07 != null) { ModbusDecoder.Decode(bytes07, FireControlMgr.Subzone7, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes08 != null) { ModbusDecoder.Decode(bytes08, FireControlMgr.Subzone8, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes09 != null) { ModbusDecoder.Decode(bytes09, FireControlMgr.Subzone9, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } } }