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

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