using HslCommunication; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Const; using HybirdFrameworkDriver.ModbusTcpMaster; using Service.HelpRight.ElectricMeter; using Service.Ups.Client; using Service.Ups.UpsMsg; namespace Service.Help.ElectricMeter.ElectricClient; [Scope] public class ElectricClientRight:ModbusTcpMaster { public ElectricClientRight() { ReadAction = BatchRead; Ip = "172.0.20.56"; Port = 502; Duration = 1000; AutoReConnect = true; ByteSeq = EndingConst.ByteSeq.BA; WordSeq= EndingConst.WordSeq.CD; } /// /// 读取数据 /// 右1充电机电表 69 /// 右2充电机电表 75 /// 右3充电机电表 76 /// 右4充电机电表 77 /// 右5充电机电表 78 /// 右6充电机电表 84 /// 右7充电机电表 85 /// 右8充电机电表 86 /// /// /// private bool BatchRead(ModbusTcpMaster master) { OperateResult bytes01 = master.Read("s=69;4106", (ushort)10); OperateResult bytes02 = master.Read("s=75;4106", (ushort)10); OperateResult bytes03 = master.Read("s=76;4106", (ushort)10); OperateResult bytes04 = master.Read("s=77;4106", (ushort)10); OperateResult bytes05 = master.Read("s=78;4106", (ushort)10); OperateResult bytes06 = master.Read("s=84;4106", (ushort)10); OperateResult bytes07 = master.Read("s=85;4106", (ushort)10); OperateResult bytes08 = master.Read("s=86;4106", (ushort)10); if (bytes01.Content != null) { ModbusDecoder.Decode(bytes01.Content, ElectricMgr.ElectricMsg01, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes02.Content != null) { ModbusDecoder.Decode(bytes02.Content, ElectricMgr.ElectricMsg02, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes03.Content != null) { ModbusDecoder.Decode(bytes03.Content, ElectricMgr.ElectricMsg03, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes04.Content != null) { ModbusDecoder.Decode(bytes04.Content, ElectricMgr.ElectricMsg04, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes05.Content != null) { ModbusDecoder.Decode(bytes05.Content, ElectricMgr.ElectricMsg05, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes06.Content != null) { ModbusDecoder.Decode(bytes06.Content, ElectricMgr.ElectricMsg06, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes07.Content != null) { ModbusDecoder.Decode(bytes07.Content, ElectricMgr.ElectricMsg07, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } if (bytes08.Content != null) { ModbusDecoder.Decode(bytes08.Content, ElectricMgr.ElectricMsg08, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC); } return true; } }