You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
3.2 KiB
83 lines
3.2 KiB
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 读取数据
|
|
/// 右1充电机电表 69
|
|
/// 右2充电机电表 75
|
|
/// 右3充电机电表 76
|
|
/// 右4充电机电表 77
|
|
/// 右5充电机电表 78
|
|
/// 右6充电机电表 84
|
|
/// 右7充电机电表 85
|
|
/// 右8充电机电表 86
|
|
/// </summary>
|
|
/// <param name="master"></param>
|
|
/// <returns></returns>
|
|
private bool BatchRead(ModbusTcpMaster master)
|
|
{
|
|
OperateResult<byte[]> bytes01 = master.Read("s=69;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes02 = master.Read("s=75;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes03 = master.Read("s=76;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes04 = master.Read("s=77;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes05 = master.Read("s=78;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes06 = master.Read("s=84;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes07 = master.Read("s=85;4106", (ushort)10);
|
|
OperateResult<byte[]> bytes08 = master.Read("s=86;4106", (ushort)10);
|
|
if (bytes01.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes01.Content, ElectricMgr.ElectricMsg01, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes02.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes02.Content, ElectricMgr.ElectricMsg02, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes03.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes03.Content, ElectricMgr.ElectricMsg03, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes04.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes04.Content, ElectricMgr.ElectricMsg04, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes05.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes05.Content, ElectricMgr.ElectricMsg05, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes06.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes06.Content, ElectricMgr.ElectricMsg06, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes07.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes07.Content, ElectricMgr.ElectricMsg07, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
if (bytes08.Content != null)
|
|
{
|
|
ModbusDecoder.Decode<ElectricMsg>(bytes08.Content, ElectricMgr.ElectricMsg08, EndingConst.ByteSeq.AB, EndingConst.WordSeq.DC);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |