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.

44 lines
1.2 KiB

4 months ago
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.100";
Port = 23;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private void BatchRead(ModbusTcpMaster master)
{
bool resul = Connected;
var bytes01 = master.Read("x=3;1", 80).Content;
4 months ago
var bytes02 = master.Read("x=3;32768", 80).Content;
4 months ago
if (bytes01 != null)
{
FireMgr.DataValidityTime = DateTime.Now;
4 months ago
ModbusDecoder.Decode<FireMsg>(bytes01, FireMgr.FireMsg, EndingConst.ByteSeq.AB,
4 months ago
EndingConst.WordSeq.DC);
}
if (bytes02 != null)
{
FireMgr.DataValidityTime = DateTime.Now;
4 months ago
ModbusDecoder.Decode<FaultMsg>(bytes02, FireMgr.FaultMsg, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
4 months ago
}
}
}