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.

35 lines
917 B

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