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.

37 lines
990 B

5 months ago
using System.Collections.Concurrent;
using DotNetty.Buffers;
using DotNetty.Transport.Channels;
using HybirdFrameworkDriver.ModbusTcpMaster;
using log4net;
namespace HybirdFrameworkDriver.Session;
public class ModbusSession
{
private static readonly ILog Log = LogManager.GetLogger(typeof(ModbusSession));
public ModbusTcpMaster.ModbusTcpMaster ModbusTcpMaster;
private String IpAddr { get; }
public String Key { get; set; }
public ConcurrentDictionary<String, Object> BusinessMap { get;set; }
public ModbusSession(ModbusTcpMaster.ModbusTcpMaster modbusTcpMaster)
{
this.ModbusTcpMaster = modbusTcpMaster;
this.IpAddr = modbusTcpMaster.Ip;
this.Key = modbusTcpMaster.connectId;
}
public bool Write<T>(ModbusProperty<T> property)
{
return ModbusTcpMaster.WriteValue(property);
}
public byte[]? Read(int registerNo, int length)
{
return ModbusTcpMaster.BatchRead(registerNo,length);
}
}