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.

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