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

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