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.

50 lines
1.3 KiB

using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
using Minio.DataModel;
using Service.PlcAfrica.Msg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static HybirdFrameworkCore.Const.EndingConst;
namespace Service.PlcAfrica.Client
{
[Scope]
public class PlcAfricaClient : ModbusTcpMaster
{
public PlcAfricaClient()
{
ReadAction = BatchRead;
Ip = "192.168.3.200";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq = EndingConst.WordSeq.DC;
}
private bool BatchRead(ModbusTcpMaster master)
{
bool resul = Connected;
//0x03
var bytes01 = master.Read("x=3;7000", 2500).Content;
if (bytes01 != null)
{
PlcAfricaMgr.DataValidityTime = DateTime.Now;
ModbusDecoder.Decode<PlcAfricaMsg>(bytes01, PlcAfricaMgr.PlcAfricaMsg,
EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
var vv= PlcAfricaMgr.PlcAfricaMsg.PowerChangeMode.Value;
}
return resul;
}
}
}