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 ElectricClientLeft:ModbusTcpMaster
{
public ElectricClientLeft()
{
ReadAction = BatchRead;
Ip = "172.0.20.58";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
///
/// 读取数据
/// 左1充电机电表 60
/// 左2充电机电表 61
/// 左3充电机电表 62
/// 左4充电机电表 63
/// 左5充电机电表 71
/// 左6充电机电表 72
/// 左7充电机电表 73
/// 左8充电机电表 74
///
///
///
private bool BatchRead(ModbusTcpMaster master)
{
OperateResult bytes01 = master.Read("s=60;4106", (ushort)10);
OperateResult bytes02 = master.Read("s=61;4106", (ushort)10);
OperateResult bytes03 = master.Read("s=62;4106", (ushort)10);
OperateResult bytes04 = master.Read("s=63;4106", (ushort)10);
OperateResult bytes05 = master.Read("s=71;4106", (ushort)10);
OperateResult bytes06 = master.Read("s=72;4106", (ushort)10);
OperateResult bytes07 = master.Read("s=73;4106", (ushort)10);
OperateResult bytes08 = master.Read("s=74;4106", (ushort)10);
if (bytes01.Content != null)
{
ModbusDecoder.Decode(bytes01.Content, ElectricMgr.ElectricMsg11, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes02.Content != null)
{
ModbusDecoder.Decode(bytes02.Content, ElectricMgr.ElectricMsg12, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes03.Content != null)
{
ModbusDecoder.Decode(bytes03.Content, ElectricMgr.ElectricMsg13, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes04.Content != null)
{
ModbusDecoder.Decode(bytes04.Content, ElectricMgr.ElectricMsg14, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes05.Content != null)
{
ModbusDecoder.Decode(bytes05.Content, ElectricMgr.ElectricMsg15, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes06.Content != null)
{
ModbusDecoder.Decode(bytes06.Content, ElectricMgr.ElectricMsg16, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes07.Content != null)
{
ModbusDecoder.Decode(bytes07.Content, ElectricMgr.ElectricMsg17, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
if (bytes08.Content != null)
{
ModbusDecoder.Decode(bytes08.Content, ElectricMgr.ElectricMsg18, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
}
return true;
}
}