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
931 B

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