using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
namespace Service.Humiture.Client;
///
///
///
[Scope]
public class HumiturePlcClientRight:ModbusTcpMaster
{
public HumiturePlcClientRight()
{
ReadAction = BatchRead;
Ip = "172.0.50.100";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private bool BatchRead(ModbusTcpMaster master)
{
var bytes01 = master.BatchReadHolderRegister(0, 2);
//TODO 地址未确定,不知道哪个是温度,哪个是湿度
if (bytes01 != null)
{
ModbusDecoder.Decode(bytes01, HumiturePlcMgr.HumitureMsg1, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
}
return true;
//var bytes02 = master.BatchReadHolderRegister(100, 6);
//byte[] bytes03 = new byte[bytes01.Length + bytes02.Length];
//Array.Copy(bytes01, 0, bytes03, 0, bytes01.Length);
//Array.Copy(bytes02, 0, bytes03, bytes01.Length, bytes02.Length);
}
}