using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Const; using HybirdFrameworkDriver.ModbusTcpMaster; using Service.Fire.Msg; namespace Service.Fire.Client; [Scope] public class FireClient: ModbusTcpMaster { public FireClient() { ReadAction = BatchRead; Ip = "192.168.3.210"; Port = 23; Duration = 1000; AutoReConnect = true; ByteSeq = EndingConst.ByteSeq.BA; WordSeq= EndingConst.WordSeq.CD; } private bool BatchRead(ModbusTcpMaster master) { bool resul = Connected; var bytes01 = master.Read("x=3;1", 80).Content; var bytes02 = master.Read("x=3;32768", 80).Content; if (bytes01 != null) { FireMgr.DataValidityTime = DateTime.Now; ModbusDecoder.Decode(bytes01, FireMgr.FireMsg, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes02 != null) { FireMgr.DataValidityTime = DateTime.Now; ModbusDecoder.Decode(bytes02, FireMgr.FaultMsg, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } return true; } }